add operator to builder
just minus for now, easily extended
This commit is contained in:
@ -69,11 +69,11 @@ module Risc
|
||||
space << Parfait.object_space
|
||||
space << space[:nil_object]
|
||||
|
||||
add Risc.op(source + "if method is nil", :- , space , typed_method )
|
||||
space - typed_method
|
||||
if_zero exit_label
|
||||
|
||||
name << typed_method[:name]
|
||||
add Risc.op(source + " compare name with me", :- , name , word )
|
||||
name - word
|
||||
if_not_zero false_label
|
||||
|
||||
typed_method << typed_method[:binary]
|
||||
|
@ -77,6 +77,13 @@ module Risc
|
||||
return ins
|
||||
end
|
||||
|
||||
def -( right )
|
||||
raise "operators only on registers, not #{right.class}" unless right.is_a? RiscValue
|
||||
op = Risc.op("#{self.type} - #{right.type}", :- , self , right )
|
||||
builder.add(op) if builder
|
||||
op
|
||||
end
|
||||
|
||||
# just capture the values in an intermediary object (RValue)
|
||||
# The RValue then gets used in a RegToSlot ot SlotToReg, where
|
||||
# the values are unpacked to call Risc.reg_to_slot or Risc.slot_to_reg
|
||||
|
Reference in New Issue
Block a user