Note all the properties of our MClassDef will also generate an AST representation. Make an error if the attribute already has a representation in the modelbuilder. This method also create the default constructor.
# Creation of a new class (AST representation) with the given MClassDef.
# Note all the properties of our MClassDef will also generate an AST representation.
# Make an error if the attribute already has a representation in the modelbuilder.
# This method also create the default constructor.
fun create_class_from_mclassdef(mclassdef: MClassDef, mmodule: MModule): AStdClassdef do
var n_classdef = mclassdef.create_ast_representation
n_classdef.location = mclassdef.location
n_classdef.validate
for n_propdef in n_classdef.n_propdefs do
var mpropdef = n_propdef.mpropdef
assert mpropdef != null
var p_npropdef = mpropdef2node(mpropdef)
if p_npropdef != null then error(null, "The property `{mpropdef.name}` already has a representation in the AST.")
unsafe_add_mpropdef2npropdef(mpropdef, n_propdef)
end
process_default_constructors(n_classdef)
unsafe_add_mclassdef2nclassdef(mclassdef, n_classdef)
return n_classdef
end
src/astbuilder.nit:1146,2--1168,4