for m in mainmodule.in_importation.greaters do for cd in m.mclassdefs do
var mclass = cd.mclass
- # Collect methods ad attributes
+ # Collect methods and attributes
for p in cd.intro_mproperties do
if p isa MMethod then
if rta == null then
var alloc = v.nit_alloc("sizeof(struct instance) + {attrs.length}*sizeof(nitattribute_t)", mclass.full_name)
v.add("{res} = {alloc};")
end
+ if modelbuilder.toolcontext.opt_trace.value then
+ v.add("tracepoint(Nit_Compiler, Object_Instance,\"{mtype}\", (uintptr_t)self);")
+ v.add("GC_register_finalizer(self, object_destroy_callback, NULL, NULL, NULL);")
+ end
v.add("{res}->type = type;")
hardening_live_type(v, "type")
v.require_declaration("class_{c_name}")
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