diff --git a/lib/risc/register_slot.rb b/lib/risc/register_slot.rb index 88759131..057a70a2 100644 --- a/lib/risc/register_slot.rb +++ b/lib/risc/register_slot.rb @@ -62,6 +62,13 @@ module Risc slot_to_reg.register 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 # from itself (the slot) and the register given def <=( reg ) diff --git a/lib/slot_machine/macro/comparison.rb b/lib/slot_machine/macro/comparison.rb index b47c4dbd..69b0e66d 100644 --- a/lib/slot_machine/macro/comparison.rb +++ b/lib/slot_machine/macro/comparison.rb @@ -17,8 +17,8 @@ module SlotMachine merge_label = Risc.label("merge" , "merge_label_#{object_id}") result = Risc::RegisterValue.new(:result , :Object) builder.build do - left = message[:receiver].to_reg.reduce_int(false) #false == hack - right = message[:arg1].to_reg.reduce_int(false) + left = message[:receiver].reduce_int(false) #false == hack + right = message[:arg1].reduce_int(false) if(operator.to_s.start_with?('<') ) right.op :- , left diff --git a/lib/slot_machine/macro/div10.rb b/lib/slot_machine/macro/div10.rb index c09c4e74..0123fe16 100644 --- a/lib/slot_machine/macro/div10.rb +++ b/lib/slot_machine/macro/div10.rb @@ -8,7 +8,7 @@ module SlotMachine integer_reg = builder.register( :integer_reg ) integer_const = builder.register( :integer_const ) 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_reg) diff --git a/lib/slot_machine/macro/div4.rb b/lib/slot_machine/macro/div4.rb index 94c65f4d..6708d7df 100644 --- a/lib/slot_machine/macro/div4.rb +++ b/lib/slot_machine/macro/div4.rb @@ -6,7 +6,7 @@ module SlotMachine integer_1 = builder.register( :integer_1 ) integer_self = builder.register( :integer_self ) builder.build do - integer_self = message[:receiver].to_reg.reduce_int(false) + integer_self = message[:receiver].reduce_int(false) load_object( 2 , integer_1) integer_self.op :>> , integer_1 integer_tmp[Parfait::Integer.integer_index] << integer_self diff --git a/lib/slot_machine/macro/get_internal_byte.rb b/lib/slot_machine/macro/get_internal_byte.rb index 6729380b..73796562 100644 --- a/lib/slot_machine/macro/get_internal_byte.rb +++ b/lib/slot_machine/macro/get_internal_byte.rb @@ -5,7 +5,7 @@ module SlotMachine integer_tmp = builder.allocate_int builder.build do object = message[:receiver].to_reg - integer = message[:arg1].to_reg.reduce_int(false) + integer = message[:arg1].reduce_int(false) object <= object[integer] integer_tmp[Parfait::Integer.integer_index] << object message[:return_value] << integer_tmp diff --git a/lib/slot_machine/macro/get_internal_word.rb b/lib/slot_machine/macro/get_internal_word.rb index 73c2db66..24458656 100644 --- a/lib/slot_machine/macro/get_internal_word.rb +++ b/lib/slot_machine/macro/get_internal_word.rb @@ -2,7 +2,7 @@ module SlotMachine class GetInternalWord < Macro def to_risc(compiler) 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] end end diff --git a/lib/slot_machine/macro/operator.rb b/lib/slot_machine/macro/operator.rb index 5e25221e..3ca6025f 100644 --- a/lib/slot_machine/macro/operator.rb +++ b/lib/slot_machine/macro/operator.rb @@ -11,8 +11,8 @@ module SlotMachine integer_tmp = builder.allocate_int operator = @operator # make accessible in block builder.build do - integer = message[:receiver].to_reg.reduce_int(false) - integer_reg = message[:arg1].to_reg.reduce_int(false) + integer = message[:receiver].reduce_int(false) + integer_reg = message[:arg1].reduce_int(false) integer.op operator , integer_reg integer_tmp[Parfait::Integer.integer_index] << integer message[:return_value] << integer_tmp