2016-12-15 19:20:54 +02:00
|
|
|
|
2017-01-19 09:02:29 +02:00
|
|
|
module Risc
|
2016-12-15 19:20:54 +02:00
|
|
|
module Builtin
|
|
|
|
module CompileHelper
|
|
|
|
|
2016-12-21 22:35:36 +02:00
|
|
|
def self_and_int_arg(compiler , source)
|
2017-01-16 09:33:49 +02:00
|
|
|
me = compiler.process( Vm::Tree::KnownName.new( :self) )
|
2016-12-27 20:39:39 +02:00
|
|
|
int_arg = load_int_arg_at(compiler , source , 1 )
|
|
|
|
return me , int_arg
|
2016-12-15 19:20:54 +02:00
|
|
|
end
|
|
|
|
|
2016-12-15 19:31:39 +02:00
|
|
|
def compiler_for( type , method_name , extra_args = {})
|
|
|
|
args = {:index => :Integer}.merge( extra_args )
|
2017-01-17 21:23:58 +02:00
|
|
|
Vm::MethodCompiler.create_method(type , method_name , args ).init_method
|
2016-12-15 19:20:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# Load the value
|
2016-12-27 20:39:39 +02:00
|
|
|
def load_int_arg_at(compiler, source , at)
|
|
|
|
int_arg = compiler.use_reg :Integer
|
2016-12-28 20:37:54 +02: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 20:39:39 +02:00
|
|
|
return int_arg
|
2016-12-15 19:20:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|