From e408b0e4b98c1d13d4a14a1c193f10e08aaba2cb Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 22 Jul 2014 23:27:13 +0300 Subject: [PATCH] fixed while instruciton linking after change in method add --- lib/ast/while_expression.rb | 3 ++- lib/virtual/method_definition.rb | 2 +- test/virtual/test_methods.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ast/while_expression.rb b/lib/ast/while_expression.rb index 8b6e3b31..9a02b429 100644 --- a/lib/ast/while_expression.rb +++ b/lib/ast/while_expression.rb @@ -15,7 +15,8 @@ module Ast raise part.inspect if last.nil? end # unconditionally brnach to the start - method.add start + merge.next = method.current.next + method.current.next = start # here we add the end of while that the branch jumps to #but don't link it in (not using add) method.current = merge diff --git a/lib/virtual/method_definition.rb b/lib/virtual/method_definition.rb index eb8743be..849dab4d 100644 --- a/lib/virtual/method_definition.rb +++ b/lib/virtual/method_definition.rb @@ -52,7 +52,7 @@ module Virtual def set_var name , var v = has_var name if( v ) - puts "resetting local #{v}" + puts "resetting local #{v.inspect}" else v = Local.new(name , var) @locals << v diff --git a/test/virtual/test_methods.rb b/test/virtual/test_methods.rb index d7c954c2..c9542a5d 100644 --- a/test/virtual/test_methods.rb +++ b/test/virtual/test_methods.rb @@ -68,7 +68,7 @@ def fibonaccit(n) end end HERE - @output = "---RETURN_MARKER- !ruby/object:Virtual::MethodDefinitionRETURN_MARKER name: :fibonaccitRETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::ArgumentRETURN_MARKER name: :nRETURN_MARKER type: !ruby/object:Virtual::Mystery {}RETURN_MARKER locals:RETURN_MARKER - !ruby/object:Virtual::LocalRETURN_MARKER name: :aRETURN_MARKER type: &2 !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 0RETURN_MARKER - !ruby/object:Virtual::LocalRETURN_MARKER name: :someRETURN_MARKER type: !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 43RETURN_MARKER - &1 !ruby/object:Virtual::LocalRETURN_MARKER name: :otherRETURN_MARKER type: !ruby/object:Virtual::ReturnRETURN_MARKER name: :returnRETURN_MARKER type: !ruby/class 'Virtual::Mystery'RETURN_MARKER tmps: []RETURN_MARKER receiver: !ruby/object:Virtual::SelfReferenceRETURN_MARKER clazz: RETURN_MARKER return_type: *1RETURN_MARKER start: !ruby/object:Virtual::MethodEnterRETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :aRETURN_MARKER value: *2RETURN_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: :fibonaccitRETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::ArgumentRETURN_MARKER name: :nRETURN_MARKER type: !ruby/object:Virtual::Mystery {}RETURN_MARKER locals:RETURN_MARKER - !ruby/object:Virtual::LocalRETURN_MARKER name: :aRETURN_MARKER type: &2 !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 0RETURN_MARKER - &4 !ruby/object:Virtual::LocalRETURN_MARKER name: :someRETURN_MARKER type: &3 !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 43RETURN_MARKER - &1 !ruby/object:Virtual::LocalRETURN_MARKER name: :otherRETURN_MARKER type: &5 !ruby/object:Virtual::ReturnRETURN_MARKER name: :returnRETURN_MARKER type: !ruby/class 'Virtual::Mystery'RETURN_MARKER tmps: []RETURN_MARKER receiver: !ruby/object:Virtual::SelfReferenceRETURN_MARKER clazz: RETURN_MARKER return_type: *1RETURN_MARKER start: !ruby/object:Virtual::MethodEnterRETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :aRETURN_MARKER value: *2RETURN_MARKER next: &6 !ruby/object:Virtual::LabelRETURN_MARKER name: while_startRETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :nRETURN_MARKER next: !ruby/object:Virtual::ImplicitBranchRETURN_MARKER name: :while_39010RETURN_MARKER other: &7 !ruby/object:Virtual::LabelRETURN_MARKER name: :while_39010RETURN_MARKER next: !ruby/object:Virtual::MethodReturnRETURN_MARKER next: RETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :someRETURN_MARKER value: *3RETURN_MARKER next: !ruby/object:Virtual::FrameGetRETURN_MARKER name: :someRETURN_MARKER next: !ruby/object:Virtual::LoadSelfRETURN_MARKER value: *4RETURN_MARKER next: !ruby/object:Virtual::FrameSendRETURN_MARKER name: :*RETURN_MARKER args:RETURN_MARKER - !ruby/object:Virtual::IntegerConstantRETURN_MARKER integer: 4RETURN_MARKER next: !ruby/object:Virtual::FrameSetRETURN_MARKER name: :otherRETURN_MARKER value: *5RETURN_MARKER next: *6RETURN_MARKER current: *7RETURN_MARKER" check end