2016-12-15 18:20:54 +01:00
|
|
|
|
|
|
|
module Register
|
|
|
|
module Builtin
|
|
|
|
module CompileHelper
|
|
|
|
|
2016-12-21 21:35:36 +01:00
|
|
|
def self_and_int_arg(compiler , source)
|
2016-12-15 18:20:54 +01:00
|
|
|
me = compiler.process( Typed::Tree::NameExpression.new( :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 )
|
2016-12-18 13:15:19 +01:00
|
|
|
Typed::MethodCompiler.new.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
|
|
|
|
compiler.add_code Register.slot_to_reg(source , :message , :arguments , int_arg )
|
|
|
|
compiler.add_code Register.slot_to_reg(source , int_arg , at + 1, int_arg ) #1 for type
|
|
|
|
return int_arg
|
2016-12-15 18:20:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|