little cleanup

code climate inspired
This commit is contained in:
Torsten Ruger 2018-03-26 14:15:48 +03:00
parent 60617ca632
commit 231025389a
3 changed files with 15 additions and 13 deletions

View File

@ -5,6 +5,13 @@ class String
end 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/padding"
require_relative "risc/positioned" require_relative "risc/positioned"

View File

@ -21,14 +21,15 @@ module Risc
end end
def self.issue_call( compiler , callee ) 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) ret_tmp = compiler.use_reg(:Label)
compiler.add_load_constant("#{callee.name} load ret", return_label , ret_tmp) 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_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_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_function_call( "#{callee_name} call" , callee )
compiler.add_code return_label compiler.add_code return_label
compiler.add_transfer("#{callee.name} remove new message", Risc.message_reg , Risc.new_message_reg ) 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_slot_to_reg("#{callee_name} restore message" , :new_message , :caller , :message )
end end
end end

View File

@ -8,11 +8,5 @@ module Vool
@name , @left , @right = name , left , right @name , @left , @right = name , left , right
end end
def collect(arr)
@receiver.collect(arr)
@arguments.collect(arr)
super
end
end end
end end