Fix first Slot instruction that uses builder
now without method_missing and names but still with instance_eval, hmm. Tried without, makes code much less readable
This commit is contained in:
@ -142,6 +142,9 @@ module Risc
|
||||
return ins
|
||||
end
|
||||
|
||||
def load_object(object)
|
||||
@compiler.load_object(object)
|
||||
end
|
||||
# for some methods that return an integer it is beneficial to pre allocate the
|
||||
# integer and store it in the return value. That is what this function does.
|
||||
#
|
||||
|
@ -96,6 +96,7 @@ module Risc
|
||||
def load_object( object )
|
||||
raise "must be Parfait, not #{object.class}" unless object.is_a?(Parfait::Object)
|
||||
ins = Risc.load_constant("load to #{object.type}" , object)
|
||||
ins.register.set_compiler(self)
|
||||
add_code ins
|
||||
# todo for constants (not objects)
|
||||
# add_constant(right) if compiler
|
||||
|
@ -20,13 +20,13 @@ module SlotMachine
|
||||
|
||||
def to_risc(compiler)
|
||||
false_label = @false_label.risc_label(compiler)
|
||||
builder = compiler.builder("TruthCheck")
|
||||
condition_reg = @condition.to_register(compiler,self)
|
||||
builder.build do
|
||||
object! << Parfait.object_space.false_object
|
||||
|
||||
compiler.build(self.to_s) do
|
||||
object = load_object Parfait.object_space.false_object
|
||||
object.op :- , condition_reg
|
||||
if_zero false_label
|
||||
object << Parfait.object_space.nil_object
|
||||
object = load_object Parfait.object_space.nil_object
|
||||
object.op :- , condition_reg
|
||||
if_zero false_label
|
||||
end
|
||||
|
Reference in New Issue
Block a user