fun native_array_instance(elttype: MType, length: RuntimeVariable): RuntimeVariable is abstract
- fun calloc_array(ret_type: MType, arguments: Array[RuntimeVariable]) is abstract
-
fun native_array_def(pname: String, ret_type: nullable MType, arguments: Array[RuntimeVariable]): Bool do return false
# Return an element of a native array.
else if pname == "sys" then
v.ret(v.new_expr("glob_sys", ret.as(not null)))
return true
- else if pname == "calloc_array" then
- v.calloc_array(ret.as(not null), arguments)
- return true
else if pname == "object_id" then
v.ret(v.new_expr("(long){arguments.first}", ret.as(not null)))
return true
self.add("{recv}[{i}]={val};")
end
- redef fun calloc_array(ret_type, arguments)
- do
- self.ret(self.new_expr("NEW_{ret_type.c_name}({arguments[1]})", ret_type))
- end
-
redef fun send(m, args)
do
var types = self.collect_types(args.first)
self.add("{res} = NEW_{nclass.c_name}({length});")
return res
end
-
- redef fun calloc_array(ret_type, arguments)
- do
- var ret = ret_type.as(MClassType)
- self.require_declaration("NEW_{ret.mclass.c_name}")
- self.ret(self.new_expr("NEW_{ret.mclass.c_name}({arguments[1]})", ret_type))
- end
end