From 01752aab053184d075e105cbf05290463a60ba97 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 15 Aug 2018 19:37:03 +0300 Subject: [PATCH] remove the last use of an add_xx function, closing #9 --- lib/risc/builder.rb | 14 -------------- lib/risc/builtin/object.rb | 9 +++++---- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/risc/builder.rb b/lib/risc/builder.rb index e1848953..377d1593 100644 --- a/lib/risc/builder.rb +++ b/lib/risc/builder.rb @@ -137,20 +137,6 @@ module Risc to[Parfait::Integer.integer_index] << from end end - - # for computationally building code (ie writing assembler) these short cuts - # help to instantiate risc instructions and add them immediately - [ :slot_to_reg , :load_constant, :load_data, - :transfer ].each do |method| - define_method("add_#{method}".to_sym) do |*args| - if not @source_used - args[0] = @source - @source_used = true - end - add_code Risc.send( method , *args ) - end - end - end diff --git a/lib/risc/builtin/object.rb b/lib/risc/builtin/object.rb index 1479de59..db70ea19 100644 --- a/lib/risc/builtin/object.rb +++ b/lib/risc/builtin/object.rb @@ -87,10 +87,11 @@ module Risc # Assumes int return value and extracts the fixnum for process exit code def exit_sequence(builder) save_message( builder ) - message = Risc.message_reg - builder.add_slot_to_reg "get return" , message , :return_value , message - builder.add_slot_to_reg( "reduce return" , message , Parfait::Integer.integer_index , message) - builder.add_code Syscall.new("emit_syscall(exit)", :exit ) + builder.build do + message << message[:return_value] + message.reduce_int + add_code Syscall.new("emit_syscall(exit)", :exit ) + end end # the exit function