2018-07-16 10:46:18 +02:00
|
|
|
module Risc
|
2020-03-09 11:48:47 +01:00
|
|
|
module HasCompiler
|
|
|
|
def risc(i)
|
|
|
|
assert @compiler , "no compiler"
|
|
|
|
instructions = @compiler.risc_instructions
|
|
|
|
return instructions if i == 0
|
|
|
|
instructions.next(i)
|
|
|
|
end
|
|
|
|
end
|
2019-09-15 17:31:10 +02:00
|
|
|
class FakeCallable
|
|
|
|
def self_type
|
|
|
|
Parfait.object_space.types.values.first
|
|
|
|
end
|
2019-09-17 09:18:45 +02:00
|
|
|
def name
|
|
|
|
:fake_name
|
|
|
|
end
|
2019-09-15 17:31:10 +02:00
|
|
|
end
|
2020-02-28 11:54:17 +01:00
|
|
|
def self.test_compiler(label = SlotMachine::Label.new("start","start_label"))
|
|
|
|
CallableCompiler.new( FakeCallable.new , label)
|
|
|
|
end
|
2018-07-16 10:46:18 +02:00
|
|
|
class FakeCompiler
|
2018-08-19 12:06:00 +02:00
|
|
|
attr_reader :instructions
|
|
|
|
def initialize
|
|
|
|
@instructions = []
|
|
|
|
end
|
|
|
|
def add_code(c)
|
|
|
|
@instructions << c
|
|
|
|
end
|
|
|
|
def current
|
|
|
|
@instructions.last
|
|
|
|
end
|
2018-07-16 10:46:18 +02:00
|
|
|
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
|
2020-02-29 16:16:52 +01:00
|
|
|
class RegisterValue
|
|
|
|
def is_object?
|
|
|
|
@symbol.to_s.start_with?("id_")
|
|
|
|
end
|
|
|
|
end
|
2018-07-16 10:46:18 +02:00
|
|
|
end
|