# Compute class ancestors types
var mmbv1b = new ClassAncestorBuilder(tc, self)
for c in classes do
- if c isa MMSrcLocalClass then
- for n in c.nodes do
- mmbv1b.visit(n)
- end
- end
+ c.accept_class_visitor(mmbv1b)
c.compute_ancestors
end
if tc.error_count > 0 then exit(1)
# Check class conformity
var mmbv1b = new ClassVerifierVisitor(tc, self)
for c in classes do
- if c isa MMSrcLocalClass then
- for n in c.nodes do
- mmbv1b.visit(n)
- end
- end
+ c.accept_class_visitor(mmbv1b)
end
if tc.error_count > 0 then exit(1)
c.inherit_global_properties
# Global property introduction and redefinition
+ c.accept_class_visitor(mmbv2)
if c isa MMSrcLocalClass then
- for n in c.nodes do
- mmbv2.visit(n)
- end
end
# Note that inherited unredefined property are processed on demand latter
# Property signature analysis and inheritance conformance
var mmbv3 = new PropertyVerifierVisitor(tc, self)
for c in classes do
- if c isa MMSrcLocalClass then
- for n in c.nodes do
- mmbv3.visit(n)
- end
- end
+ c.accept_properties_visitor(mmbv3)
end
# Check inherited local properties
end
end
+redef class MMLocalClass
+ # Accept a class visitor (on class nodes)
+ private meth accept_class_visitor(v: AbsSyntaxVisitor)
+ do
+ end
+
+ # Accept a class visitor (on class properties)
+ private meth accept_properties_visitor(v: AbsSyntaxVisitor)
+ do
+ end
+end
+
redef class MMSrcLocalClass
+ redef meth accept_class_visitor(v)
+ do
+ for n in nodes do
+ v.visit(n)
+ end
+ end
+
+ # Accept a class visitor (on class properties)
+ redef meth accept_properties_visitor(v)
+ do
+ for n in nodes do
+ v.visit(n)
+ end
+
+ for p in src_local_properties do
+ p.accept_property_visitor(v)
+ end
+ end
# Add a source property
# Register it to the class and attach it to global property
- private meth add_src_local_property(v: PropertyBuilderVisitor, prop: MMSrcLocalProperty)
+ private meth add_src_local_property(v: PropertyBuilderVisitor, prop: MMConcreteProperty)
do
var pname = prop.name
# Check double definition in the same class
if src_local_properties.has_key(pname) then
- v.error(prop.node, "Error: A property {pname} is already defined in class {name} at line {src_local_properties[pname].node.first_token.line}.")
+ v.error(prop.node, "Error: A property {pname} is already defined in class {name}.")
return
end
src_local_properties[pname] = prop
end
end
+redef class MMConcreteProperty
+ private meth accept_property_visitor(v: AbsSyntaxVisitor)
+ do
+ end
+end
# Concrete NIT class specialization relation
class MMSrcAncestor
special MMAncestor
# Import super-modules
var module_names_to_import = new Array[Symbol]
var module_visibility = new HashMap[Symbol, Int]
- var no_import: PImport
+ var no_import: PImport = null
for i in n_imports do
var n = i.module_name
if n != null then
# * Check redef errors.
# * Check forbiden attribute definitions.
# * Check signature conformance.
- private meth process_and_check(v: PropertyVerifierVisitor, prop: MMSrcLocalProperty, has_redef: Bool, visibility_level: Int)
+ private meth process_and_check(v: PropertyVerifierVisitor, prop: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
do
if prop.global.intro == prop then
do_and_check_intro(v, prop, has_redef, visibility_level)
end
# The part of process_and_check when prop is an introduction
- private meth do_and_check_intro(v: PropertyVerifierVisitor, prop: MMSrcLocalProperty, has_redef: Bool, visibility_level: Int)
+ private meth do_and_check_intro(v: PropertyVerifierVisitor, prop: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
do
var glob = prop.global
var gbc = prop.local_class.global
end
end
- private meth inherit_signature(v: PropertyVerifierVisitor, prop: MMSrcLocalProperty, supers: Array[MMLocalProperty])
+ private meth inherit_signature(v: PropertyVerifierVisitor, prop: MMConcreteProperty, supers: Array[MMLocalProperty])
do
var s = prop.signature
for ip in supers do
+ assert ip isa MMConcreteProperty
var isig = ip.signature.adaptation_to(v.local_class.get_type)
if s == null then
end
# The part of process_and_check when prop is a redefinition
- private meth do_and_check_redef(v: PropertyVerifierVisitor, prop: MMSrcLocalProperty, has_redef: Bool, visibility_level: Int)
+ private meth do_and_check_redef(v: PropertyVerifierVisitor, prop: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
do
var is_init = self isa AConcreteInitPropdef
var glob = prop.global
redef class PSignature
# Check that visibilities of types in the signature are compatible with the visibility of the property.
- meth check_visibility(v: AbsSyntaxVisitor, p: MMSrcLocalProperty) is abstract
+ meth check_visibility(v: AbsSyntaxVisitor, p: MMConcreteProperty) is abstract
end
redef class ASignature
redef class PType
# Check that visibilities of types in the signature are compatible with the visibility of the property.
- private meth check_visibility(v: AbsSyntaxVisitor, p: MMSrcLocalProperty) is abstract
+ private meth check_visibility(v: AbsSyntaxVisitor, p: MMConcreteProperty) is abstract
end
redef class AType