From 422ec6410543c5ad3d2fa4988b58c19740776f16 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 20 May 2015 17:29:08 +0300 Subject: [PATCH] all green That fixes all existing tests. Operation successful Off course there is tests missing :-( --- lib/arm/instructions/call_instruction.rb | 8 ++++---- lib/parfait/method.rb | 5 +++-- lib/parfait/object.rb | 4 ++-- lib/parfait/space.rb | 2 +- lib/virtual/boot.rb | 3 +-- lib/virtual/compile_parfait.rb | 4 ++++ lib/virtual/compiler/basic_expressions.rb | 12 ++++++------ lib/virtual/compiler/if_expression.rb | 16 ++++++++-------- test/virtual/test_methods.rb | 10 +++++----- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/lib/arm/instructions/call_instruction.rb b/lib/arm/instructions/call_instruction.rb index 64557312..cdc53a79 100644 --- a/lib/arm/instructions/call_instruction.rb +++ b/lib/arm/instructions/call_instruction.rb @@ -1,11 +1,11 @@ module Arm # There are only three call instructions in arm branch (b), call (bl) and syscall (swi) - + # A branch could be called a jump as it has no notion of returning - + # The pc is put into the link register to make a return possible # a return is affected by moving the stored link register into the pc, effectively a branch - + # swi (SoftWareInterrupt) or system call is how we call the kernel. # in Arm the register layout is different and so we have to place the syscall code into register 7 # Registers 0-6 hold the call values as for a normal c call @@ -36,7 +36,7 @@ module Arm if( arg.is_a? Fixnum ) #HACK to not have to change the code just now arg = Virtual::IntegerConstant.new( arg ) end - if arg.is_a?(Virtual::Block) or arg.is_a?(Virtual::CompiledMethod) + if arg.is_a?(Virtual::Block) or arg.is_a?(Virtual::CompiledMethodInfo) #relative addressing for jumps/calls diff = arg.position - self.position # but because of the arm "theoretical" 3- stage pipeline, we have to subtract 2 words (fetch/decode) diff --git a/lib/parfait/method.rb b/lib/parfait/method.rb index 4515d006..59baf728 100644 --- a/lib/parfait/method.rb +++ b/lib/parfait/method.rb @@ -42,12 +42,13 @@ module Parfait # determine whether this method has an argument by the name def has_arg name - @arg_names.index_of name.to_sym + raise "uups #{name}.#{name.class}" unless name.is_a? Word + @arg_names.index_of name end # determine if method has a local variable or tmp (anonymous local) by given name def has_local name - name = name.to_sym + raise "uups #{name}.#{name.class}" unless name.is_a? Word index = @locals.index(name) index = @tmps.index(name) unless index index diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index f14f30d4..582ae01e 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -19,7 +19,7 @@ module Parfait def self.new_object *args object = self.new(*args) - puts "NEW #{object.class}" + #puts "NEW #{object.class}" object end @@ -42,7 +42,7 @@ module Parfait end def get_layout() - puts "ME #{self.class}" + #puts "ME #{self.class}" return internal_object_get(LAYOUT_INDEX) end diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index c9c67b5d..4a294317 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -67,7 +67,7 @@ module Parfait raise "uups #{name}.#{name.class}" unless name.is_a? Word c = @classes[name] raise "uups " if name.is_a? String - puts "MISS, no class #{name} #{name.class}" # " #{@classes}" + puts "MISS, no class #{name} #{name.class}" unless c # " #{@classes}" c end diff --git a/lib/virtual/boot.rb b/lib/virtual/boot.rb index f0d54e1d..c277efd4 100644 --- a/lib/virtual/boot.rb +++ b/lib/virtual/boot.rb @@ -20,11 +20,10 @@ module Virtual #space_layout = # Parfait::Layout.new_object space_class - puts "Space #{space.get_layout}" +# puts "Space #{space.get_layout}" end def boot_classes! - puts "BOOT" values = [ "Integer" , "Object" , "Value" , "Kernel"] rest = ["Word" , "Class" , "Dictionary" , "Space" , "List", "Layout"] (values + rest).each { |cl| @space.create_class(Virtual.new_word(cl)) } diff --git a/lib/virtual/compile_parfait.rb b/lib/virtual/compile_parfait.rb index 5f98bb7f..3a7a650d 100644 --- a/lib/virtual/compile_parfait.rb +++ b/lib/virtual/compile_parfait.rb @@ -20,12 +20,15 @@ module Parfait # they respresent the smallest code needed to build larger functionality # but should _never_ be used outside parfait. in fact that should be impossible def internal_object_get_typeword + raise "failed init for #{self.class}" unless @memory @memory[0] end def internal_object_set_typeword w + raise "failed init for #{self.class}" unless @memory @memory[0] = w end def internal_object_length + raise "failed init for #{self.class}" unless @memory @memory.length - 1 # take of type-word end # 1 -based index @@ -34,6 +37,7 @@ module Parfait end # 1 -based index def internal_object_set(index , value) + raise "failed init for #{self.class}" unless @memory @memory[index] = value end def internal_object_grow(length) diff --git a/lib/virtual/compiler/basic_expressions.rb b/lib/virtual/compiler/basic_expressions.rb index 825b5ebf..9f85a20e 100644 --- a/lib/virtual/compiler/basic_expressions.rb +++ b/lib/virtual/compiler/basic_expressions.rb @@ -46,13 +46,13 @@ module Virtual # whichever way this goes the result is stored in the return slot (as all compiles) def self.compile_name expression , method return Self.new( Mystery ) if expression.name == :self - name = expression.name - if method.has_var(expression.name) + name = Virtual.new_word expression.name.to_s + if method.has_var(name) # either an argument, so it's stored in message if( index = method.has_arg(name)) - method.info.add_code MessageGet.new(name , index) + method.info.add_code MessageGet.new(expression.name , index) else # or a local so it is in the frame - method.info.add_code FrameGet.new(name , index) + method.info.add_code FrameGet.new(expression.name , index) end else call = Ast::CallSiteExpression.new(expression.name , [] ) #receiver self is implicit @@ -83,11 +83,11 @@ module Virtual raise "must assign to NameExpression , not #{expression.left}" unless expression.left.instance_of? Ast::NameExpression r = Compiler.compile(expression.right , method ) raise "oh noo, nil from where #{expression.right.inspect}" unless r - index = method.has_arg(name) + index = method.has_arg(Virtual.new_word name) if index method.info.add_code Set.new(Return.new , MessageSlot.new(index , r,type , r )) else - index = method.ensure_local(expression.left.name) + index = method.ensure_local(Virtual.new_word expression.left.name) method.info.add_code Set.new(Return.new , FrameSlot.new(index , r.type , r )) end r diff --git a/lib/virtual/compiler/if_expression.rb b/lib/virtual/compiler/if_expression.rb index b23fb70b..d21eaa44 100644 --- a/lib/virtual/compiler/if_expression.rb +++ b/lib/virtual/compiler/if_expression.rb @@ -5,18 +5,18 @@ module Virtual def self.compile_if expression , method # to execute the logic as the if states it, the blocks are the other way around # so we can the jump over the else if true ,and the else joins unconditionally after the true_block - merge_block = method.new_block "if_merge" # last one, created first - true_block = method.new_block "if_true" # second, linked in after current, before merge - false_block = method.new_block "if_false" # directly next in order, ie if we don't jump we land here + merge_block = method.info.new_block "if_merge" # last one, created first + true_block = method.info.new_block "if_true" # second, linked in after current, before merge + false_block = method.info.new_block "if_false" # directly next in order, ie if we don't jump we land here is = Compiler.compile(expression.cond, method ) # TODO should/will use different branches for different conditions. # just a scetch : cond_val = cond_val.is_true?(method) unless cond_val.is_a? BranchCondition - method.add_code IsTrueBranch.new( true_block ) + method.info.add_code IsTrueBranch.new( true_block ) # compile the true block (as we think of it first, even it is second in sequential order) - method.current true_block + method.info.current true_block last = is expression.if_true.each do |part| last = Compiler.compile(part,method ) @@ -24,16 +24,16 @@ module Virtual end # compile the false block - method.current false_block + method.info.current false_block expression.if_false.each do |part| #puts "compiling in if false #{part}" last = Compiler.compile(part,method ) raise part.inspect if last.nil? end - method.add_code UnconditionalBranch.new( merge_block ) + method.info.add_code UnconditionalBranch.new( merge_block ) #puts "compiled if: end" - method.current merge_block + method.info.current merge_block #TODO should return the union of the true and false types last diff --git a/test/virtual/test_methods.rb b/test/virtual/test_methods.rb index 0ddadd48..a094a266 100644 --- a/test/virtual/test_methods.rb +++ b/test/virtual/test_methods.rb @@ -9,7 +9,7 @@ def foo(x) 5 end HERE - @output = "-Virtual::CompiledMethod(:name => :foo, :class_name => 'Object')*^* :arg_names [:x]*^* :locals []*^* :tmps []*^* :receiver Virtual::Self(:index => 3, :type => Virtual::Mystery)*^* :return_type &1 Virtual::Return(:index => 5, :type => Virtual::Integer)*^* :value &2 Virtual::IntegerConstant(:integer => 5)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set(:to => *1, :from => *2)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)" + @output = "-&2 Parfait::Method(:name => Parfait::Word('foo'))*^* :arg_names [:x]*^* :locals []*^* :tmps []*^* :for_class &1 Parfait::Class(:name => Parfait::Word('Object'))*^* :instance_methods -Parfait::Method(:name => Parfait::Word('main'), :for_class => *1)*^* :arg_names []*^* :locals []*^* :tmps []*^* :info Virtual::CompiledMethodInfo(:return_type => *6)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* -*2*^* :super_class &3 Parfait::Class(:name => Parfait::Word('Value'))*^* :instance_methods []*^* :meta_class Virtual::MetaClass(:me_self => *3)*^* :functions []*^* :object_layout []*^* :meta_class Virtual::MetaClass(:me_self => *1)*^* :functions []*^* :object_layout []*^* :info Virtual::CompiledMethodInfo()*^* :return_type &4 Virtual::Return(:index => 5, :type => Virtual::Integer)*^* :value &5 Virtual::IntegerConstant(:integer => 5)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set(:to => *4, :from => *5)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* :receiver Virtual::Self(:index => 3, :type => &6 Virtual::Mystery)" check end @@ -20,7 +20,7 @@ def foo() end foo() HERE - @output = "-Virtual::CompiledMethod(:name => :foo, :class_name => 'Object')*^* :arg_names []*^* :locals []*^* :tmps []*^* :receiver Virtual::Self(:index => 3, :type => *1)*^* :return_type Virtual::Return(:index => 5, :type => *1)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => *1)*^* :from &4 Virtual::Self(:index => 3, :type => *1)*^* -Virtual::Set(:from => Parfait::Word('puts'))*^* :to Virtual::NewName(:index => 4, :type => *1)*^* -Virtual::Set(:from => Parfait::Word('Hello'))*^* :to &3 Virtual::Return(:index => 5, :type => &2 Virtual::Reference, :value => Parfait::Word('Hello'))*^* -Virtual::Set()*^* :to &5 Virtual::NewMessageSlot(:index => 0, :type => &2 Virtual::Reference, :value => *3)*^* :from &3 Virtual::Return(:index => 5, :type => &2 Virtual::Reference, :value => Parfait::Word('Hello'))*^* -Virtual::MessageSend(:name => :puts)*^* :me &4 Virtual::Self(:index => 3, :type => *1)*^* :args [*5]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^*-Virtual::Return(:index => 5, :type => &1 Virtual::Mystery)" + @output = "-&4 Parfait::Method(:name => Parfait::Word('foo'))*^* :arg_names []*^* :locals []*^* :tmps []*^* :for_class &1 Parfait::Class(:name => Parfait::Word('Object'))*^* :instance_methods -Parfait::Method(:name => Parfait::Word('main'), :for_class => *1)*^* :arg_names []*^* :locals []*^* :tmps []*^* :info Virtual::CompiledMethodInfo(:return_type => *2)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => *2)*^* :from &3 Virtual::Self(:index => 3, :type => *2)*^* -Virtual::Set(:from => Parfait::Word('foo'))*^* :to Virtual::NewName(:index => 4, :type => *2)*^* -Virtual::MessageSend(:name => :foo)*^* :me &3 Virtual::Self(:index => 3, :type => *2)*^* :args []*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* -*4*^* :super_class &5 Parfait::Class(:name => Parfait::Word('Value'))*^* :instance_methods []*^* :meta_class Virtual::MetaClass(:me_self => *5)*^* :functions []*^* :object_layout []*^* :meta_class Virtual::MetaClass(:me_self => *1)*^* :functions []*^* :object_layout []*^* :info Virtual::CompiledMethodInfo()*^* :return_type Virtual::Return(:index => 5, :type => *2)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => *2)*^* :from &8 Virtual::Self(:index => 3, :type => *2)*^* -Virtual::Set(:from => Parfait::Word('puts'))*^* :to Virtual::NewName(:index => 4, :type => *2)*^* -Virtual::Set(:from => Parfait::Word('Hello'))*^* :to &7 Virtual::Return(:index => 5, :type => &6 Virtual::Reference, :value => Parfait::Word('Hello'))*^* -Virtual::Set()*^* :to &9 Virtual::NewMessageSlot(:index => 0, :type => &6 Virtual::Reference, :value => *7)*^* :from &7 Virtual::Return(:index => 5, :type => &6 Virtual::Reference, :value => Parfait::Word('Hello'))*^* -Virtual::MessageSend(:name => :puts)*^* :me &8 Virtual::Self(:index => 3, :type => *2)*^* :args [*9]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* :receiver Virtual::Self(:index => 3, :type => *2)*^*-Virtual::Return(:index => 5, :type => &2 Virtual::Mystery)" check end @@ -41,7 +41,7 @@ def foo(x) 2 + 5 end HERE - @output = "-Virtual::CompiledMethod(:name => :foo, :class_name => 'Object')*^* :arg_names [:x]*^* :locals [:abba]*^* :tmps []*^* :receiver Virtual::Self(:index => 3, :type => &1 Virtual::Mystery)*^* :return_type Virtual::Return(:index => 5, :type => &1 Virtual::Mystery)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to &4 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *2)*^* :from &2 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *1)*^* :from Virtual::FrameSlot(:index => 1, :type => &3 Virtual::Integer, :value => *4)*^* -Virtual::Set()*^* :to &6 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *5)*^* :from &5 Virtual::IntegerConstant(:integer => 2)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => &3 Virtual::Integer)*^* :from &6 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *5)*^* -Virtual::Set(:from => Parfait::Word('+'))*^* :to Virtual::NewName(:index => 4, :type => *1)*^* -Virtual::Set()*^* :to &8 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *7)*^* :from &7 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to &9 Virtual::NewMessageSlot(:index => 0, :type => &3 Virtual::Integer, :value => *8)*^* :from &8 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *7)*^* -Virtual::MessageSend(:name => :+)*^* :me &6 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *5)*^* :args [*9]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)" + @output = "-&2 Parfait::Method(:name => Parfait::Word('foo'))*^* :arg_names [:x]*^* :locals [Parfait::Word('abba')]*^* :tmps []*^* :for_class &1 Parfait::Class(:name => Parfait::Word('Object'))*^* :instance_methods -Parfait::Method(:name => Parfait::Word('main'), :for_class => *1)*^* :arg_names []*^* :locals []*^* :tmps []*^* :info Virtual::CompiledMethodInfo(:return_type => *4)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* -*2*^* :super_class &3 Parfait::Class(:name => Parfait::Word('Value'))*^* :instance_methods []*^* :meta_class Virtual::MetaClass(:me_self => *3)*^* :functions []*^* :object_layout []*^* :meta_class Virtual::MetaClass(:me_self => *1)*^* :functions []*^* :object_layout []*^* :info Virtual::CompiledMethodInfo()*^* :return_type Virtual::Return(:index => 5, :type => &4 Virtual::Mystery)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to &7 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *5)*^* :from &5 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *4)*^* :from Virtual::FrameSlot(:index => 1, :type => &6 Virtual::Integer, :value => *7)*^* -Virtual::Set()*^* :to &9 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *8)*^* :from &8 Virtual::IntegerConstant(:integer => 2)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => &6 Virtual::Integer)*^* :from &9 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *8)*^* -Virtual::Set(:from => Parfait::Word('+'))*^* :to Virtual::NewName(:index => 4, :type => *4)*^* -Virtual::Set()*^* :to &11 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *10)*^* :from &10 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to &12 Virtual::NewMessageSlot(:index => 0, :type => &6 Virtual::Integer, :value => *11)*^* :from &11 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *10)*^* -Virtual::MessageSend(:name => :+)*^* :me &9 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *8)*^* :args [*12]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* :receiver Virtual::Self(:index => 3, :type => &4 Virtual::Mystery)" check end @@ -51,7 +51,7 @@ def foo() 2 + 5 end HERE - @output = "-Virtual::CompiledMethod(:name => :foo, :class_name => 'Object')*^* :arg_names []*^* :locals []*^* :tmps []*^* :receiver Virtual::Self(:index => 3, :type => &1 Virtual::Mystery)*^* :return_type Virtual::Return(:index => 5, :type => &1 Virtual::Mystery)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to &4 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *2)*^* :from &2 Virtual::IntegerConstant(:integer => 2)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => &3 Virtual::Integer)*^* :from &4 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *2)*^* -Virtual::Set(:from => Parfait::Word('+'))*^* :to Virtual::NewName(:index => 4, :type => *1)*^* -Virtual::Set()*^* :to &6 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *5)*^* :from &5 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to &7 Virtual::NewMessageSlot(:index => 0, :type => &3 Virtual::Integer, :value => *6)*^* :from &6 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *5)*^* -Virtual::MessageSend(:name => :+)*^* :me &4 Virtual::Return(:index => 5, :type => &3 Virtual::Integer, :value => *2)*^* :args [*7]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)" + @output = "-&2 Parfait::Method(:name => Parfait::Word('foo'))*^* :arg_names []*^* :locals []*^* :tmps []*^* :for_class &1 Parfait::Class(:name => Parfait::Word('Object'))*^* :instance_methods -Parfait::Method(:name => Parfait::Word('main'), :for_class => *1)*^* :arg_names []*^* :locals []*^* :tmps []*^* :info Virtual::CompiledMethodInfo(:return_type => *4)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* -*2*^* :super_class &3 Parfait::Class(:name => Parfait::Word('Value'))*^* :instance_methods []*^* :meta_class Virtual::MetaClass(:me_self => *3)*^* :functions []*^* :object_layout []*^* :meta_class Virtual::MetaClass(:me_self => *1)*^* :functions []*^* :object_layout []*^* :info Virtual::CompiledMethodInfo()*^* :return_type Virtual::Return(:index => 5, :type => &4 Virtual::Mystery)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to &7 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *5)*^* :from &5 Virtual::IntegerConstant(:integer => 2)*^* -Virtual::NewMessage(:length => -1)*^* -Virtual::Set()*^* :to Virtual::NewSelf(:index => 3, :type => &6 Virtual::Integer)*^* :from &7 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *5)*^* -Virtual::Set(:from => Parfait::Word('+'))*^* :to Virtual::NewName(:index => 4, :type => *4)*^* -Virtual::Set()*^* :to &9 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *8)*^* :from &8 Virtual::IntegerConstant(:integer => 5)*^* -Virtual::Set()*^* :to &10 Virtual::NewMessageSlot(:index => 0, :type => &6 Virtual::Integer, :value => *9)*^* :from &9 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *8)*^* -Virtual::MessageSend(:name => :+)*^* :me &7 Virtual::Return(:index => 5, :type => &6 Virtual::Integer, :value => *5)*^* :args [*10]*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* :receiver Virtual::Self(:index => 3, :type => &4 Virtual::Mystery)" check end @@ -65,7 +65,7 @@ def ofthen(n) end end HERE - @output = "-Virtual::CompiledMethod(:name => :ofthen, :class_name => 'Object')*^* :arg_names [:n]*^* :locals [:isit, :maybenot]*^* :tmps []*^* :receiver Virtual::Self(:index => 3, :type => &4 Virtual::Mystery)*^* :return_type &6 Virtual::Return(:index => 5, :type => &1 Virtual::Integer)*^* :value &7 Virtual::IntegerConstant(:integer => 667)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *1, :value => *2)*^* :from &2 Virtual::IntegerConstant(:integer => 0)*^* -Virtual::IsTrueBranch(:to => *8)*^* -Virtual::Block(:length => -1, :name => :if_false)*^* :codes -Virtual::Set(:to => *6, :from => *7)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *4)*^* :from Virtual::FrameSlot(:index => 2, :type => *1, :value => *6)*^* -Virtual::UnconditionalBranch(:to => *9)*^* -&8 Virtual::Block(:length => -1, :name => :if_true)*^* :codes -Virtual::Set()*^* :to &5 Virtual::Return(:index => 5, :type => *1)*^* :value &3 Virtual::IntegerConstant(:integer => 42)*^* :from &3 Virtual::IntegerConstant(:integer => 42)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *4)*^* :from Virtual::FrameSlot(:index => 1, :type => *1)*^* :value &5 Virtual::Return(:index => 5, :type => *1)*^* :value &3 Virtual::IntegerConstant(:integer => 42)*^* -&9 Virtual::Block(:length => -1, :name => :if_merge)*^* :codes []*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)" + @output = "-&2 Parfait::Method(:name => Parfait::Word('ofthen'))*^* :arg_names [:n]*^* :locals [Parfait::Word('isit'), Parfait::Word('maybenot')]*^* :tmps []*^* :for_class &1 Parfait::Class(:name => Parfait::Word('Object'))*^* :instance_methods -Parfait::Method(:name => Parfait::Word('main'), :for_class => *1)*^* :arg_names []*^* :locals []*^* :tmps []*^* :info Virtual::CompiledMethodInfo(:return_type => *7)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* -*2*^* :super_class &3 Parfait::Class(:name => Parfait::Word('Value'))*^* :instance_methods []*^* :meta_class Virtual::MetaClass(:me_self => *3)*^* :functions []*^* :object_layout []*^* :meta_class Virtual::MetaClass(:me_self => *1)*^* :functions []*^* :object_layout []*^* :info Virtual::CompiledMethodInfo()*^* :return_type &9 Virtual::Return(:index => 5, :type => &4 Virtual::Integer)*^* :value &10 Virtual::IntegerConstant(:integer => 667)*^* :blocks -Virtual::Block(:length => -1, :name => :enter)*^* :codes -Virtual::MethodEnter(:length => -1)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *4, :value => *5)*^* :from &5 Virtual::IntegerConstant(:integer => 0)*^* -Virtual::IsTrueBranch(:to => *11)*^* -Virtual::Block(:length => -1, :name => :if_false)*^* :codes -Virtual::Set(:to => *9, :from => *10)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *7)*^* :from Virtual::FrameSlot(:index => 2, :type => *4, :value => *9)*^* -Virtual::UnconditionalBranch(:to => *12)*^* -&11 Virtual::Block(:length => -1, :name => :if_true)*^* :codes -Virtual::Set()*^* :to &8 Virtual::Return(:index => 5, :type => *4)*^* :value &6 Virtual::IntegerConstant(:integer => 42)*^* :from &6 Virtual::IntegerConstant(:integer => 42)*^* -Virtual::Set()*^* :to Virtual::Return(:index => 5, :type => *7)*^* :from Virtual::FrameSlot(:index => 1, :type => *4)*^* :value &8 Virtual::Return(:index => 5, :type => *4)*^* :value &6 Virtual::IntegerConstant(:integer => 42)*^* -&12 Virtual::Block(:length => -1, :name => :if_merge)*^* :codes []*^* -Virtual::Block(:length => -1, :name => :return)*^* :codes -Virtual::MethodReturn(:length => -1)*^* :receiver Virtual::Self(:index => 3, :type => &7 Virtual::Mystery)" check end