move to parfait integers in risc layer

loading constants means loading parfait objects
objects have to me collected in machine
integer ok, string/true/false/nil next
This commit is contained in:
Torsten Ruger
2018-03-31 13:25:59 +03:00
parent 6e941ebcb7
commit 9e9b5c7f37
6 changed files with 31 additions and 2 deletions

View File

@ -55,6 +55,11 @@ module Risc
@objects ||= Collector.collect_space
end
# add a constant (which get created during compilatio and need to be linked)
def add_constant(const)
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
@constants << const
end
# To create binaries, objects (and labels) need to have a position
# (so objects can be loaded and branches know where to jump)
#

View File

@ -92,7 +92,7 @@ module Risc
# for computationally building code (ie writing assembler) these short cuts
# help to instantiate risc instructions and add them immediately
[:label, :reg_to_slot , :slot_to_reg , :load_constant, :load_data,
[:label, :reg_to_slot , :slot_to_reg , :load_constant, :load_data,
:function_return , :function_call,
:transfer , :reg_to_slot , :byte_to_reg , :reg_to_byte].each do |method|
define_method("add_#{method}".to_sym) do |*args|
@ -132,5 +132,8 @@ module Risc
@regs.clear
end
def add_constant(const)
Risc.machine.add_constant(const)
end
end
end