slight cleanup and rename test case

This commit is contained in:
Torsten Ruger 2014-06-17 14:25:33 +02:00
parent 7d05b7c42f
commit a859951a8f
5 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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