create a reduce_int on RegisterSlot
that just passes through to RegisterValue by calling to_reg
This commit is contained in:
parent
17a1121408
commit
2656bfacb2
@ -62,6 +62,13 @@ module Risc
|
|||||||
slot_to_reg.register
|
slot_to_reg.register
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# just pass the call through. That is we create the register (call to_reg)
|
||||||
|
# and call reduce_int on the result
|
||||||
|
# Just so the dsl code can be a bit shorter / less cluttered
|
||||||
|
def reduce_int(bool)
|
||||||
|
to_reg.reduce_int(bool)
|
||||||
|
end
|
||||||
|
|
||||||
# similar to above (<< which produces reg_to_slot), this produces reg_to_byte
|
# similar to above (<< which produces reg_to_slot), this produces reg_to_byte
|
||||||
# from itself (the slot) and the register given
|
# from itself (the slot) and the register given
|
||||||
def <=( reg )
|
def <=( reg )
|
||||||
|
@ -17,8 +17,8 @@ module SlotMachine
|
|||||||
merge_label = Risc.label("merge" , "merge_label_#{object_id}")
|
merge_label = Risc.label("merge" , "merge_label_#{object_id}")
|
||||||
result = Risc::RegisterValue.new(:result , :Object)
|
result = Risc::RegisterValue.new(:result , :Object)
|
||||||
builder.build do
|
builder.build do
|
||||||
left = message[:receiver].to_reg.reduce_int(false) #false == hack
|
left = message[:receiver].reduce_int(false) #false == hack
|
||||||
right = message[:arg1].to_reg.reduce_int(false)
|
right = message[:arg1].reduce_int(false)
|
||||||
|
|
||||||
if(operator.to_s.start_with?('<') )
|
if(operator.to_s.start_with?('<') )
|
||||||
right.op :- , left
|
right.op :- , left
|
||||||
|
@ -8,7 +8,7 @@ module SlotMachine
|
|||||||
integer_reg = builder.register( :integer_reg )
|
integer_reg = builder.register( :integer_reg )
|
||||||
integer_const = builder.register( :integer_const )
|
integer_const = builder.register( :integer_const )
|
||||||
builder.build do
|
builder.build do
|
||||||
integer_self = message[:receiver].to_reg.reduce_int(false)
|
integer_self = message[:receiver].reduce_int(false)
|
||||||
transfer( integer_self , integer_1)
|
transfer( integer_self , integer_1)
|
||||||
transfer( integer_self , integer_reg)
|
transfer( integer_self , integer_reg)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ module SlotMachine
|
|||||||
integer_1 = builder.register( :integer_1 )
|
integer_1 = builder.register( :integer_1 )
|
||||||
integer_self = builder.register( :integer_self )
|
integer_self = builder.register( :integer_self )
|
||||||
builder.build do
|
builder.build do
|
||||||
integer_self = message[:receiver].to_reg.reduce_int(false)
|
integer_self = message[:receiver].reduce_int(false)
|
||||||
load_object( 2 , integer_1)
|
load_object( 2 , integer_1)
|
||||||
integer_self.op :>> , integer_1
|
integer_self.op :>> , integer_1
|
||||||
integer_tmp[Parfait::Integer.integer_index] << integer_self
|
integer_tmp[Parfait::Integer.integer_index] << integer_self
|
||||||
|
@ -5,7 +5,7 @@ module SlotMachine
|
|||||||
integer_tmp = builder.allocate_int
|
integer_tmp = builder.allocate_int
|
||||||
builder.build do
|
builder.build do
|
||||||
object = message[:receiver].to_reg
|
object = message[:receiver].to_reg
|
||||||
integer = message[:arg1].to_reg.reduce_int(false)
|
integer = message[:arg1].reduce_int(false)
|
||||||
object <= object[integer]
|
object <= object[integer]
|
||||||
integer_tmp[Parfait::Integer.integer_index] << object
|
integer_tmp[Parfait::Integer.integer_index] << object
|
||||||
message[:return_value] << integer_tmp
|
message[:return_value] << integer_tmp
|
||||||
|
@ -2,7 +2,7 @@ module SlotMachine
|
|||||||
class GetInternalWord < Macro
|
class GetInternalWord < Macro
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
compiler.builder(compiler.source).build do
|
compiler.builder(compiler.source).build do
|
||||||
integer = message[:arg1].to_reg.reduce_int(false)
|
integer = message[:arg1].reduce_int(false)
|
||||||
message[:return_value] << message[:receiver][integer]
|
message[:return_value] << message[:receiver][integer]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,8 @@ module SlotMachine
|
|||||||
integer_tmp = builder.allocate_int
|
integer_tmp = builder.allocate_int
|
||||||
operator = @operator # make accessible in block
|
operator = @operator # make accessible in block
|
||||||
builder.build do
|
builder.build do
|
||||||
integer = message[:receiver].to_reg.reduce_int(false)
|
integer = message[:receiver].reduce_int(false)
|
||||||
integer_reg = message[:arg1].to_reg.reduce_int(false)
|
integer_reg = message[:arg1].reduce_int(false)
|
||||||
integer.op operator , integer_reg
|
integer.op operator , integer_reg
|
||||||
integer_tmp[Parfait::Integer.integer_index] << integer
|
integer_tmp[Parfait::Integer.integer_index] << integer
|
||||||
message[:return_value] << integer_tmp
|
message[:return_value] << integer_tmp
|
||||||
|
Loading…
Reference in New Issue
Block a user