var res: nullable RuntimeVariable = null
var recv = arguments.first
var consider_null = not self.compiler.modelbuilder.toolcontext.opt_no_check_null.value or mmethod.name == "==" or mmethod.name == "!="
- if maybenull(recv) and consider_null then
+ if maybe_null(recv) and consider_null then
self.add("if ({recv} == NULL) \{")
if mmethod.name == "==" or mmethod.name == "is_same_instance" then
res = self.new_var(bool_type)
return k == interface_kind or t.is_c_primitive
end
- fun maybe_null(value: RuntimeVariable): Bool
- do
- var t = value.mcasttype
- return t isa MNullableType or t isa MNullType
- end
-
redef fun array_instance(array, elttype)
do
var nclass = mmodule.native_array_class
return res
end
- redef fun native_array_instance(elttype: MType, length: RuntimeVariable): RuntimeVariable
+ redef fun native_array_instance(elttype, length)
do
var mtype = mmodule.native_array_type(elttype)
self.require_declaration("NEW_{mtype.mclass.c_name}")
var recv = self.frame.arguments.first
var recv_type_info = self.type_info(recv)
self.require_declaration(mtype.const_color)
- return self.new_expr("NEW_{mtype.mclass.c_name}({length}, {recv_type_info}->resolution_table->types[{mtype.const_color}])", mtype)
+ return self.new_expr("NEW_{mtype.mclass.c_name}((int){length}, {recv_type_info}->resolution_table->types[{mtype.const_color}])", mtype)
end
compiler.undead_types.add(mtype)
self.require_declaration("type_{mtype.c_name}")
- return self.new_expr("NEW_{mtype.mclass.c_name}({length}, &type_{mtype.c_name})", mtype)
+ return self.new_expr("NEW_{mtype.mclass.c_name}((int){length}, &type_{mtype.c_name})", mtype)
end
redef fun native_array_def(pname, ret_type, arguments)