nitc :: SerializationPhasePreModel :: generate_deserialization_init
Will be filled by SerializationPhasePostModel
.
# Add an empty constructor to the automated nclassdef
#
# Will be filled by `SerializationPhasePostModel`.
fun generate_deserialization_init(nclassdef: AClassdef)
do
var npropdefs = nclassdef.n_propdefs
# Do not insert a `from_deserializer` if it already exists
for npropdef in npropdefs do
if npropdef isa AMethPropdef then
var methid = npropdef.n_methid
if methid != null and methid.collect_text == "from_deserializer" then
return
end
end
end
var code = """
redef init from_deserializer(v) do abort"""
var npropdef = toolcontext.parse_propdef(code).as(AMethPropdef)
npropdefs.add npropdef
nclassdef.parent.as(AModule).inits_to_retype.add npropdef
end
src/frontend/serialization_model_phase.nit:210,2--233,4