adds explicit load_self instruction
This commit is contained in:
@ -30,7 +30,17 @@ def foo(x)
|
||||
2 + 5
|
||||
end
|
||||
HERE
|
||||
@output = [Virtual::Method.new(:foo,[Ast::NameExpression.new(:x)],Virtual::SelfReference.new(nil),Virtual::Return.new( Virtual::Mystery),Virtual::MethodEnter.new(Virtual::FrameSet.new(:abba,Virtual::IntegerConstant.new(5))))]
|
||||
@output = [Virtual::Method.new(:foo,[Ast::NameExpression.new(:x)],Virtual::SelfReference.new(nil),Virtual::Return.new(Virtual::Mystery),Virtual::MethodEnter.new(Virtual::FrameSet.new(:abba,Virtual::IntegerConstant.new(5),Virtual::LoadSelf.new(Virtual::IntegerConstant.new(2),Virtual::FrameSend.new(:+,[Virtual::IntegerConstant.new(5)],nil)))))]
|
||||
check
|
||||
end
|
||||
|
||||
def test_function_ops_simple
|
||||
@string_input = <<HERE
|
||||
def foo()
|
||||
2 + 5
|
||||
end
|
||||
HERE
|
||||
@output = [Virtual::Method.new(:foo,[],Virtual::SelfReference.new(nil),Virtual::Return.new(Virtual::Mystery),Virtual::MethodEnter.new(Virtual::LoadSelf.new(Virtual::IntegerConstant.new(2),Virtual::FrameSend.new(:+,[Virtual::IntegerConstant.new(5)],nil))))]
|
||||
check
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,8 @@ module VirtualHelper
|
||||
syntax = parser.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
machine = Virtual::Machine.new
|
||||
expressions = parts.compile(machine.frame , Virtual::Method.main )
|
||||
main = Virtual::Method.main
|
||||
expressions = parts.compile(machine.frame , main )
|
||||
assert_equal @output , expressions
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user