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
|
|
|
#Load self by "calling" on_name
|
|
|
|
me = compiler.process( Typed::Tree::NameExpression.new( :self) )
|
|
|
|
# Load the argument
|
|
|
|
index = compiler.use_reg :Integer
|
2016-12-21 21:35:36 +01:00
|
|
|
compiler.add_code Register.get_slot(source , :message , 1 , index )
|
2016-12-15 18:20:54 +01:00
|
|
|
return me , index
|
|
|
|
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-21 21:35:36 +01:00
|
|
|
def load_arg_at(compiler, source , at)
|
2016-12-15 18:20:54 +01:00
|
|
|
value = compiler.use_reg :Integer
|
2016-12-21 21:35:36 +01:00
|
|
|
compiler.add_code Register.get_slot(source , :message , at , value )
|
2016-12-15 18:20:54 +01:00
|
|
|
value
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|