Fix super as statement
Super is a statement, a send really. Not an expression (as maybe in c++) The actual implementation will be a bit tricky, like raise, a bit of stack walking, but not impossible. Still, later
This commit is contained in:
@ -31,7 +31,7 @@
|
||||
end
|
||||
|
||||
def to_s
|
||||
"Integer #{value}"
|
||||
"Integer " + value.to_s
|
||||
end
|
||||
# compile time method to set the actual value.
|
||||
# this should not really be part of parfait, as ints are immutable at runtime.
|
||||
@ -59,7 +59,7 @@
|
||||
class ReturnAddress < Integer
|
||||
|
||||
def to_s
|
||||
"ReturnAddress 0x#{object_id.to_s(16)}:#{value}"
|
||||
"ReturnAddress 0x" + object_id.to_s(16) + ":" + value.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,11 +44,6 @@ module Ruby
|
||||
"self"
|
||||
end
|
||||
end
|
||||
class SuperExpression < Constant
|
||||
def to_s(depth = 0)
|
||||
"super"
|
||||
end
|
||||
end
|
||||
class StringConstant < ValueConstant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
|
@ -74,6 +74,9 @@ module Ruby
|
||||
def on_arg( arg )
|
||||
arg.first
|
||||
end
|
||||
def on_optarg(arg)
|
||||
arg.first
|
||||
end
|
||||
|
||||
def on_block(block_node)
|
||||
sendd = process(block_node.children[0])
|
||||
@ -232,14 +235,14 @@ module Ruby
|
||||
|
||||
# this is a call to super without args (z = zero arity)
|
||||
def on_zsuper exp
|
||||
SendStatement.new( nil , SuperExpression.new , nil)
|
||||
SuperStatement.new([])
|
||||
end
|
||||
|
||||
# this is a call to super with args and
|
||||
# same name as current method, which is set later
|
||||
def on_super( statement )
|
||||
arguments = process_all(statement.children)
|
||||
SendStatement.new( nil , SuperExpression.new , arguments)
|
||||
SuperStatement.new( arguments)
|
||||
end
|
||||
|
||||
def on_assignment statement
|
||||
@ -250,10 +253,6 @@ module Ruby
|
||||
w
|
||||
end
|
||||
|
||||
def handler_missing(node)
|
||||
not_implemented(node)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def instance_name sym
|
||||
|
@ -8,4 +8,10 @@ module Ruby
|
||||
at_depth( depth , "#{receiver}.#{name}(#{arguments.join(', ')})")
|
||||
end
|
||||
end
|
||||
class SuperStatement < SendStatement
|
||||
def initialize(args)
|
||||
super(:super , SelfExpression.new , args)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -86,11 +86,6 @@ module Vool
|
||||
"self"
|
||||
end
|
||||
end
|
||||
class SuperExpression < Statement
|
||||
def to_s(depth = 0)
|
||||
"super"
|
||||
end
|
||||
end
|
||||
class StringConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
|
@ -75,6 +75,7 @@ require_relative "class_method_expression"
|
||||
require_relative "return_statement"
|
||||
require_relative "statements"
|
||||
require_relative "send_statement"
|
||||
require_relative "super_statement"
|
||||
require_relative "variables"
|
||||
require_relative "while_statement"
|
||||
require_relative "yield_statement"
|
||||
|
5
lib/vool/super_statement.rb
Normal file
5
lib/vool/super_statement.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Vool
|
||||
class SuperStatement < SendStatement
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user