diff --git a/lib/ast/call_site_expression.rb b/lib/ast/call_site_expression.rb index 046234b8..2e0a9789 100644 --- a/lib/ast/call_site_expression.rb +++ b/lib/ast/call_site_expression.rb @@ -10,7 +10,8 @@ module Ast puts "compiling receiver #{receiver} (call #{name})" if receiver.is_a? ModuleName clazz = context.object_space.get_or_create_class receiver.name - function = clazz.resolve_function name + value_receiver = clazz.meta_class + function = value_receiver.resolve_function name elsif receiver.is_a?(StringExpression) or receiver.is_a?(IntegerExpression) #TODO obviously the class is wrong, but you gotta start somewhere clazz = context.object_space.get_or_create_class :Object diff --git a/lib/vm/function.rb b/lib/vm/function.rb index 95cc243b..a328debf 100644 --- a/lib/vm/function.rb +++ b/lib/vm/function.rb @@ -78,7 +78,7 @@ module Vm def new_local type = Vm::Integer register = args.length + 3 + @locals.length # three for the receiver, return and type regs l = type.new(register) #so start at r3 - puts "new local #{l.register_symbol}" + #puts "new local #{l.register_symbol}" raise "Register overflow in function #{name}" if register >= 13 # yep, 13 is bad luck @locals << l l diff --git a/lib/vm/instruction.rb b/lib/vm/instruction.rb index 7097e591..7aa1c2a5 100644 --- a/lib/vm/instruction.rb +++ b/lib/vm/instruction.rb @@ -131,7 +131,7 @@ module Vm def assigns [@result.register] end - def to_asm + def to_s "#{opcode} #{result.to_asm} , #{left.to_asm} , #{right.to_asm} #{super}" end end @@ -149,6 +149,9 @@ module Vm def assigns [] end + def to_s + "#{opcode} #{@left.to_asm} , #{@right.to_asm} #{super}" + end end class MoveInstruction < Instruction def initialize to , from , options = {} @@ -196,5 +199,8 @@ module Vm [] end end + def to_s + "#{opcode} #{@first.to_asm} #{super}" + end end end diff --git a/lib/vm/passes.rb b/lib/vm/passes.rb index ed358560..fd9633eb 100644 --- a/lib/vm/passes.rb +++ b/lib/vm/passes.rb @@ -34,7 +34,7 @@ module Vm # small todo. This does not catch condition_code that are not :al next if (n.attributes.length > 3) or (kode.attributes.length > 3) if kode.result == n.from - puts "Logic #{kode} goes #{n}" + puts "Logic reduction #{kode} removes #{n}" kode.result = n.to block.codes.delete(n) end @@ -56,7 +56,7 @@ module Vm # small todo. This does not catch condition_code that are not :al next if (n.attributes.length > 3) or (kode.attributes.length > 3) if kode.to == n.from - puts "Move #{kode} goes #{n} " + puts "Move reduction #{kode}: removes #{n} " kode.to = n.to block.codes.delete(n) end @@ -94,7 +94,7 @@ module Vm locals = block.function.locals_at block pop = block.next.codes.first if(locals.empty?) - puts "Empty #{block.name}" + #puts "Empty #{block.name}" block.codes.delete(push) block.next.codes.delete(pop) else diff --git a/test/fragments/test_class.rb b/test/fragments/test_string_class.rb similarity index 100% rename from test/fragments/test_class.rb rename to test/fragments/test_string_class.rb