diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index 69e5e62f..12e30535 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -13,13 +13,13 @@ module Register space = Parfait::Space.object_space space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init - compiler.add_code LoadConstant.new("__init__ load Space", space , space_reg) + compiler.add_code Register.load_constant("__init__ load Space", space , space_reg) message_ind = Register.resolve_to_index( :space , :first_message ) compiler.add_code Register.slot_to_reg( "__init__ load 1st message" , space_reg , message_ind , :message) compiler.add_code Register.reg_to_slot( "__init__ store Space in message", space_reg , :message , :receiver) exit_label = Label.new("_exit_label for __init__" , "#{compiler.type.object_class.name}.#{compiler.method.name}" ) ret_tmp = compiler.use_reg(:Label) - compiler.add_code Register::LoadConstant.new("__init__ load return", exit_label , ret_tmp) + compiler.add_code Register.load_constant("__init__ load return", exit_label , ret_tmp) compiler.add_code Register.reg_to_slot("__init__ store return", ret_tmp , :message , :return_address) compiler.add_code FunctionCall.new( "__init__ issue call" , Register.machine.space.get_main ) compiler.add_code exit_label diff --git a/lib/register/instructions/function_call.rb b/lib/register/instructions/function_call.rb index 498a214c..6253ce0d 100644 --- a/lib/register/instructions/function_call.rb +++ b/lib/register/instructions/function_call.rb @@ -18,7 +18,7 @@ module Register def self.issue_call( compiler , callee ) return_label = Label.new("_return_label #{callee.name}" , "#{compiler.type.object_class.name}.#{compiler.method.name}" ) ret_tmp = compiler.use_reg(:Label) - compiler.add_code Register::LoadConstant.new("#{callee.name} load ret", return_label , ret_tmp) + compiler.add_code Register.load_constant("#{callee.name} load ret", return_label , ret_tmp) compiler.add_code Register.reg_to_slot("#{callee.name} store ret", ret_tmp , :new_message , :return_address) compiler.add_code RegisterTransfer.new("#{callee.name} move new message", Register.new_message_reg , Register.message_reg ) compiler.add_code FunctionCall.new( "#{callee.name} call" , callee ) diff --git a/lib/register/instructions/load_constant.rb b/lib/register/instructions/load_constant.rb index 0c53add3..ebd25f2f 100644 --- a/lib/register/instructions/load_constant.rb +++ b/lib/register/instructions/load_constant.rb @@ -30,7 +30,7 @@ module Register end end end - def self.load_constant source , constant , register + def self.load_constant( source , constant , register ) LoadConstant.new source , constant , register end end diff --git a/lib/typed/method_compiler/basic_values.rb b/lib/typed/method_compiler/basic_values.rb index 8e9aba73..b7551538 100644 --- a/lib/typed/method_compiler/basic_values.rb +++ b/lib/typed/method_compiler/basic_values.rb @@ -13,25 +13,25 @@ module Typed def on_IntegerExpression expression int = expression.value reg = use_reg :Integer , int - add_code Register::LoadConstant.new( expression, int , reg ) + add_code Register.load_constant( expression, int , reg ) return reg end def on_TrueExpression expression reg = use_reg :Boolean - add_code Register::LoadConstant.new( expression, true , reg ) + add_code Register.load_constant( expression, true , reg ) return reg end def on_FalseExpression expression reg = use_reg :Boolean - add_code Register::LoadConstant.new( expression, false , reg ) + add_code Register.load_constant( expression, false , reg ) return reg end def on_NilExpression expression reg = use_reg :NilClass - add_code Register::LoadConstant.new( expression, nil , reg ) + add_code Register.load_constant( expression, nil , reg ) return reg end @@ -39,7 +39,7 @@ module Typed value = Parfait.new_word expression.value.to_sym reg = use_reg :Word Register.machine.constants << value - add_code Register::LoadConstant.new( expression, value , reg ) + add_code Register.load_constant( expression, value , reg ) return reg end @@ -48,7 +48,7 @@ module Typed clazz = Parfait::Space.object_space.get_class_by_name! name raise "No such class #{name}" unless clazz reg = use_reg :MetaClass , clazz - add_code Register::LoadConstant.new( expression, clazz , reg ) + add_code Register.load_constant( expression, clazz , reg ) return reg end diff --git a/lib/typed/method_compiler/call_site.rb b/lib/typed/method_compiler/call_site.rb index ad9bd188..8c1dc7e7 100644 --- a/lib/typed/method_compiler/call_site.rb +++ b/lib/typed/method_compiler/call_site.rb @@ -58,12 +58,12 @@ module Typed def set_message_details( method , name_s , arguments ) name = name_s.name name_tmp = use_reg(:Word) - add_code Register::LoadConstant.new("#{name} load method name", name , name_tmp) + add_code Register.load_constant("#{name} load method name", name , name_tmp) add_code Register.reg_to_slot( "#{name} store method name" , name_tmp , :new_message , :name) # next arg and local types args_reg = use_reg(:Type , method.arguments ) list_reg = use_reg(:NamedList , arguments ) - add_code Register::LoadConstant.new("#{name} load methods", method , args_reg) + add_code Register.load_constant("#{name} load methods", method , args_reg) args_type_index = method.get_type().variable_index(:arguments) raise args_type_index.to_s unless args_type_index == 6 add_code Register.slot_to_reg( "#{name} get args type from method" , args_reg , args_type_index , args_reg ) @@ -72,7 +72,7 @@ module Typed #FIXME need to set type of locals too. sama sama # len_tmp = use_reg(:Integer , arguments.to_a.length ) -# add_code Register::LoadConstant.new(name_s, arguments.to_a.length , len_tmp) +# add_code Register.load_constant(name_s, arguments.to_a.length , len_tmp) # add_code Register.reg_to_slot( name_s , len_tmp , :new_message , :indexed_length) end diff --git a/lib/typed/method_compiler/name_expression.rb b/lib/typed/method_compiler/name_expression.rb index f2e5f7ca..2192acff 100644 --- a/lib/typed/method_compiler/name_expression.rb +++ b/lib/typed/method_compiler/name_expression.rb @@ -45,7 +45,7 @@ module Typed def handle_special_space(statement) space = Parfait::Space.object_space reg = use_reg :Space , space - add_code Register::LoadConstant.new( "#{statement} load space", space , reg ) + add_code Register.load_constant( "#{statement} load space", space , reg ) return reg end