diff --git a/lib/ast/basic_expressions.rb b/lib/ast/basic_expressions.rb index 8dd542c5..330a7e8f 100644 --- a/lib/ast/basic_expressions.rb +++ b/lib/ast/basic_expressions.rb @@ -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 diff --git a/lib/virtual/method_definition.rb b/lib/virtual/method_definition.rb index b7ff0402..811630e5 100644 --- a/lib/virtual/method_definition.rb +++ b/lib/virtual/method_definition.rb @@ -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 diff --git a/test/virtual/test_methods.rb b/test/virtual/test_methods.rb index 8ef877e1..1b5585f4 100644 --- a/test/virtual/test_methods.rb +++ b/test/virtual/test_methods.rb @@ -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 = <