2016-12-15 18:20:54 +01:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2016-12-15 18:20:54 +01:00
|
|
|
module Builtin
|
|
|
|
module CompileHelper
|
|
|
|
|
2016-12-21 21:35:36 +01:00
|
|
|
def self_and_int_arg(compiler , source)
|
2018-03-11 12:32:42 +01:00
|
|
|
me = compiler.add_known( :self )
|
2016-12-27 19:39:39 +01:00
|
|
|
int_arg = load_int_arg_at(compiler , source , 1 )
|
|
|
|
return me , int_arg
|
2016-12-15 18:20:54 +01:00
|
|
|
end
|
|
|
|
|
2016-12-15 18:31:39 +01:00
|
|
|
def compiler_for( type , method_name , extra_args = {})
|
|
|
|
args = {:index => :Integer}.merge( extra_args )
|
2018-03-11 12:32:42 +01:00
|
|
|
Risc::MethodCompiler.create_method(type , method_name , args ).init_method
|
2016-12-15 18:20:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
# Load the value
|
2016-12-27 19:39:39 +01:00
|
|
|
def load_int_arg_at(compiler, source , at)
|
|
|
|
int_arg = compiler.use_reg :Integer
|
2016-12-28 19:37:54 +01:00
|
|
|
compiler.add_slot_to_reg(source , :message , :arguments , int_arg )
|
|
|
|
compiler.add_slot_to_reg(source , int_arg , at + 1, int_arg ) #1 for type
|
2016-12-27 19:39:39 +01:00
|
|
|
return int_arg
|
2016-12-15 18:20:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|