From 71a716120040fd1efcc5a2bba4c676a7bd0a716a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 8 Aug 2018 12:02:24 +0300 Subject: [PATCH] redid div4 with builder --- lib/risc/builtin/integer.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/risc/builtin/integer.rb b/lib/risc/builtin/integer.rb index 7718a4b3..a4c8d906 100644 --- a/lib/risc/builtin/integer.rb +++ b/lib/risc/builtin/integer.rb @@ -6,16 +6,15 @@ module Risc include CompileHelper def div4(context) - source = "div4" compiler = compiler_for(:Integer,:div4 ,{}) - builder = compiler.compiler_builder(compiler.source) - me = builder.add_known( :receiver ) - builder.reduce_int( source , me ) - two = compiler.use_reg :fixnum , value: 2 - builder.add_load_data( source , 2 , two ) - builder.add_code Risc.op( source , :>> , me , two) - builder.add_new_int(source,me , two) - builder.add_reg_to_slot( source , two , Risc.message_reg , :return_value) + compiler.compiler_builder(compiler.source).build do + integer << message[:receiver] + integer << integer[Parfait::Integer.integer_index] + integer_reg << 2 + integer.op :>> , integer_reg + add_new_int("div4", integer , integer_reg) + message[:return_value] << integer_reg + end compiler.add_mom( Mom::ReturnSequence.new) return compiler end