From 231025389a8fe379452818987844b3fbe4794812 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 26 Mar 2018 14:15:48 +0300 Subject: [PATCH] little cleanup code climate inspired --- lib/risc.rb | 7 +++++++ lib/risc/instructions/function_call.rb | 15 ++++++++------- lib/vool/statements/logical_statement.rb | 6 ------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/risc.rb b/lib/risc.rb index e21c7402..d0914660 100644 --- a/lib/risc.rb +++ b/lib/risc.rb @@ -5,6 +5,13 @@ class String end +# The RiscMachine, is an abstract machine with registers. Think of it as an arm machine with +# normal instruction names. It is not however an abstraction of existing hardware, but only +# of that subset that we need. +# See risc/Readme +module Risc +end + require_relative "risc/padding" require_relative "risc/positioned" diff --git a/lib/risc/instructions/function_call.rb b/lib/risc/instructions/function_call.rb index 3a090c9c..f57b56ba 100644 --- a/lib/risc/instructions/function_call.rb +++ b/lib/risc/instructions/function_call.rb @@ -21,14 +21,15 @@ module Risc end def self.issue_call( compiler , callee ) - return_label = Risc.label("_return_label #{callee.name}" , "#{compiler.type.object_class.name}.#{compiler.method.name}" ) + callee_name = callee.name + return_label = Risc.label("_return_label #{callee_name}" , "#{compiler.type.object_class.name}.#{compiler.method.name}" ) ret_tmp = compiler.use_reg(:Label) - compiler.add_load_constant("#{callee.name} load ret", return_label , ret_tmp) - compiler.add_reg_to_slot("#{callee.name} store ret", ret_tmp , :new_message , :return_address) - compiler.add_transfer("#{callee.name} move new message", Risc.new_message_reg , Risc.message_reg ) - compiler.add_code Risc.function_call( "#{callee.name} call" , callee ) + compiler.add_load_constant("#{callee_name} load ret", return_label , ret_tmp) + compiler.add_reg_to_slot("#{callee_name} store ret", ret_tmp , :new_message , :return_address) + compiler.add_transfer("#{callee_name} move new message", Risc.new_message_reg , Risc.message_reg ) + compiler.add_function_call( "#{callee_name} call" , callee ) compiler.add_code return_label - compiler.add_transfer("#{callee.name} remove new message", Risc.message_reg , Risc.new_message_reg ) - compiler.add_slot_to_reg("#{callee.name} restore message" , :new_message , :caller , :message ) + compiler.add_transfer("#{callee_name} remove new message", Risc.message_reg , Risc.new_message_reg ) + compiler.add_slot_to_reg("#{callee_name} restore message" , :new_message , :caller , :message ) end end diff --git a/lib/vool/statements/logical_statement.rb b/lib/vool/statements/logical_statement.rb index 9fac70f9..e3d927eb 100644 --- a/lib/vool/statements/logical_statement.rb +++ b/lib/vool/statements/logical_statement.rb @@ -8,11 +8,5 @@ module Vool @name , @left , @right = name , left , right end - def collect(arr) - @receiver.collect(arr) - @arguments.collect(arr) - super - end - end end