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-14 15:56:13 +01:00
|
|
|
me = compiler.add_known( :receiver )
|
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
|
|
|
|
|
2018-03-18 17:38:35 +01:00
|
|
|
def compiler_for( type , method_name , arguments , locals = {})
|
|
|
|
frame = Parfait::NamedList.type_for( locals ) #TODO fix locals passing/ using in builtin
|
|
|
|
args = Parfait::NamedList.type_for( arguments )
|
2018-03-25 18:37:51 +02:00
|
|
|
Risc::MethodCompiler.create_method(type , method_name , args, frame )
|
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
|