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