rubyx/test/support/fake_compiler.rb
Torsten 0ce14bdfd1 moving to SA register names (wip)
starting to implement register allocation by first creating SA
Single Assignment means a register is only every assigned a value once. Hence for any operation involving another register, a new register is created.
We do this with a naming scheme for the registers in dot notation (as it would be in c) which means 2 registers with the same name, should have the same contents. This does not apply to temporaries, but that is another day.
Starting WIP now, and will create many red commits before merging when green.
2020-03-22 14:31:43 +02:00

41 lines
799 B
Ruby

module Risc
class FakeCallable
def self_type
Parfait.object_space.types.values.first
end
def name
:fake_name
end
end
def self.test_compiler(label = SlotMachine::Label.new("start","start_label"))
CallableCompiler.new( FakeCallable.new , label)
end
class FakeCompiler
attr_reader :instructions
def initialize
@instructions = []
end
def add_code(c)
@instructions << c
end
def current
@instructions.last
end
def slot_type(slot,type)
type.type_for(slot)
end
def resolve_type(name)
Parfait.object_space.types.values.first
end
def reset_regs
end
def add_constant(c)
end
end
class RegisterValue
def is_object?
@symbol.to_s.start_with?("id_")
end
end
end