redid div4 with builder

This commit is contained in:
Torsten Ruger 2018-08-08 12:02:24 +03:00
parent c63e55c2bc
commit 71a7161200

View File

@ -6,16 +6,15 @@ module Risc
include CompileHelper include CompileHelper
def div4(context) def div4(context)
source = "div4"
compiler = compiler_for(:Integer,:div4 ,{}) compiler = compiler_for(:Integer,:div4 ,{})
builder = compiler.compiler_builder(compiler.source) compiler.compiler_builder(compiler.source).build do
me = builder.add_known( :receiver ) integer << message[:receiver]
builder.reduce_int( source , me ) integer << integer[Parfait::Integer.integer_index]
two = compiler.use_reg :fixnum , value: 2 integer_reg << 2
builder.add_load_data( source , 2 , two ) integer.op :>> , integer_reg
builder.add_code Risc.op( source , :>> , me , two) add_new_int("div4", integer , integer_reg)
builder.add_new_int(source,me , two) message[:return_value] << integer_reg
builder.add_reg_to_slot( source , two , Risc.message_reg , :return_value) end
compiler.add_mom( Mom::ReturnSequence.new) compiler.add_mom( Mom::ReturnSequence.new)
return compiler return compiler
end end