last inherited test

This commit is contained in:
Torsten Ruger 2014-07-27 10:09:31 +03:00
parent 1a95835442
commit 8718ebf476
3 changed files with 5 additions and 4 deletions

View File

@ -68,6 +68,7 @@ module Ast
def compile method , message
raise "must assign to NameExpression , not #{left}" unless left.instance_of? NameExpression
r = right.compile(method,message)
raise "oh noo, nil from where #{right.inspect}" unless r
message.compile_set( method , left.name , r )
end
def old_scratch

View File

@ -59,7 +59,7 @@ module Virtual
def set_var name , var
v = has_var name
if( v )
puts "resetting local #{v.inspect}"
v.type = var
else
v = Local.new(name , var)
@locals << v

View File

@ -106,11 +106,11 @@ def retvar(n)
end
end
HERE
@output = "---RETURN_MARKER- !ruby/object:Virtual::MethodDefinitionRETURN_MARKER name: :retvarRETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::ArgumentRETURN_MARKER name: :nRETURN_MARKER type: !ruby/object:Virtual::Mystery {}RETURN_MARKER locals: []RETURN_MARKER tmps: []RETURN_MARKER receiver: !ruby/object:Virtual::SelfReferenceRETURN_MARKER clazz: RETURN_MARKER return_type: !ruby/object:Virtual::ReferenceRETURN_MARKER clazz: RETURN_MARKER start: !ruby/object:Virtual::MethodEnterRETURN_MARKER next: !ruby/object:Virtual::LabelRETURN_MARKER name: while_startRETURN_MARKER next: !ruby/object:Virtual::MethodReturnRETURN_MARKER next: RETURN_MARKER current: !ruby/object:Virtual::LabelRETURN_MARKER name: :while_39010RETURN_MARKER next: RETURN_MARKER"
@output = "---RETURN_MARKER- !ruby/object:Virtual::MethodDefinitionRETURN_MARKER name: :retvarRETURN_MARKER args:RETURN_MARKER - &1 !ruby/object:Virtual::ArgumentRETURN_MARKER name: :nRETURN_MARKER type: &2 !ruby/object:Virtual::ReturnRETURN_MARKER name: :returnRETURN_MARKER type: !ruby/class 'Virtual::Mystery'RETURN_MARKER locals: []RETURN_MARKER tmps: []RETURN_MARKER receiver: !ruby/object:Virtual::SelfReferenceRETURN_MARKER clazz: RETURN_MARKER return_type: !ruby/object:Virtual::ReferenceRETURN_MARKER clazz: RETURN_MARKER start: !ruby/object:Virtual::MethodEnterRETURN_MARKER next: &3 !ruby/object:Virtual::LabelRETURN_MARKER name: while_startRETURN_MARKER next: !ruby/object:Virtual::MessageGetRETURN_MARKER name: :nRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *1RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :>RETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 5RETURN_MARKER next: !ruby/object:Virtual::ImplicitBranchRETURN_MARKER name: :while_39010RETURN_MARKER other: &4 !ruby/object:Virtual::LabelRETURN_MARKER name: :while_39010RETURN_MARKER next: !ruby/object:Virtual::MethodReturnRETURN_MARKER next: RETURN_MARKER next: !ruby/object:Virtual::MessageGetRETURN_MARKER name: :nRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *1RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :+RETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 1RETURN_MARKER next: !ruby/object:Virtual::MessageSetRETURN_MARKER name: :nRETURN_MARKER value: *2RETURN_MARKER next: *3RETURN_MARKER current: *4RETURN_MARKER"
check
end
def ttest_function_big_while
def test_function_big_while
@string_input = <<HERE
def fibonaccit(n)
a = 0
@ -124,7 +124,7 @@ def fibonaccit(n)
end
end
HERE
@output = [Virtual::MethodDefinition.new(:foo,[Ast::NameExpression.new(:x)])]
@output = "---RETURN_MARKER- !ruby/object:Virtual::MethodDefinitionRETURN_MARKER name: :fibonaccitRETURN_MARKER args:RETURN_MARKER - &4 !ruby/object:Virtual::ArgumentRETURN_MARKER name: :nRETURN_MARKER type: &7 !ruby/object:Virtual::ReturnRETURN_MARKER name: :returnRETURN_MARKER type: &1 !ruby/class 'Virtual::Mystery'RETURN_MARKER locals:RETURN_MARKER - &3 !ruby/object:Virtual::LocalRETURN_MARKER name: :aRETURN_MARKER type: &2 !ruby/object:Virtual::LocalRETURN_MARKER name: :bRETURN_MARKER type: &6 !ruby/object:Virtual::ReturnRETURN_MARKER name: :returnRETURN_MARKER type: *1RETURN_MARKER - *2RETURN_MARKER - &5 !ruby/object:Virtual::LocalRETURN_MARKER name: :tmpRETURN_MARKER type: *3RETURN_MARKER tmps: []RETURN_MARKER receiver: !ruby/object:Virtual::SelfReferenceRETURN_MARKER clazz: RETURN_MARKER return_type: *4RETURN_MARKER start: !ruby/object:Virtual::MethodEnterRETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :aRETURN_MARKER value: !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 0RETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :bRETURN_MARKER value: !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 1RETURN_MARKER next: &8 !ruby/object:Virtual::LabelRETURN_MARKER name: while_startRETURN_MARKER next: !ruby/object:Virtual::MessageGetRETURN_MARKER name: :nRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *4RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :>RETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 1RETURN_MARKER next: !ruby/object:Virtual::ImplicitBranchRETURN_MARKER name: :while_39010RETURN_MARKER other: &9 !ruby/object:Virtual::LabelRETURN_MARKER name: :while_39010RETURN_MARKER next: !ruby/object:Virtual::MethodReturnRETURN_MARKER next: RETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :aRETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :tmpRETURN_MARKER value: *3RETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :bRETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :aRETURN_MARKER value: *2RETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :tmpRETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :bRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *5RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :+RETURN_MARKER args:RETURN_MARKER - *2RETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :bRETURN_MARKER value: *6RETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :bRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: !ruby/object:Virtual::SelfRETURN_MARKER name: :selfRETURN_MARKER type: !ruby/object:Virtual::Mystery {}RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :putsRETURN_MARKER args:RETURN_MARKER - *2RETURN_MARKER next: !ruby/object:Virtual::MessageGetRETURN_MARKER name: :nRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *4RETURN_MARKER next: !ruby/object:Virtual::MessageSendRETURN_MARKER name: :-RETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 1RETURN_MARKER next: !ruby/object:Virtual::MessageSetRETURN_MARKER name: :nRETURN_MARKER value: *7RETURN_MARKER next: *8RETURN_MARKER current: *9RETURN_MARKER"
check
end
end