# Generate a alloc-instance + init-attributes
fun init_instance(mtype: MClassType): RuntimeVariable is abstract
src/compiler/abstract_compiler.nit:1669,2--1670,66
redef fun init_instance(mtype)
do
self.require_declaration("NEW_{mtype.mclass.c_name}")
var compiler = self.compiler
if mtype isa MGenericType and mtype.need_anchor then
hardening_live_open_type(mtype)
link_unresolved_type(self.frame.mpropdef.mclassdef, mtype)
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}({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}(&type_{mtype.c_name})", mtype)
end
src/compiler/separate_compiler.nit:1840,2--1855,4
redef fun init_instance(mtype)
do
mtype = self.anchor(mtype).as(MClassType)
if not self.compiler.runtime_type_analysis.live_types.has(mtype) then
debug "problem: {mtype} was detected dead"
end
var res = self.new_expr("NEW_{mtype.c_name}()", mtype)
res.is_exact = true
return res
end
src/compiler/global_compiler.nit:860,2--869,4