v.add_decl("#define {pg.attr_access}(recv) ATTR(recv, {pg.color_id})")
end
end
- assert p isa MMSrcLocalProperty
+ assert p isa MMConcreteProperty
p.compile_property_to_c(v)
end
end
class TableEltPropPos
special LocalTableElt
- attr _property: MMSrcLocalProperty
+ attr _property: MMConcreteProperty
redef meth symbol do return _property.global.color_id
redef meth value(ga) do return "{ga.color(self)} /* Property {_property} */"
- init(p: MMSrcLocalProperty)
+ init(p: MMConcreteProperty)
do
_property = p
end
end
end
-redef class MMSrcLocalProperty
+redef class MMConcreteProperty
# Compile the property as a C property
meth compile_property_to_c(v: CompilerVisitor) do end
end
redef class MMSrcLocalClass
# 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
# * 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
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
readable writable attr _formal_dict: Map[Symbol, MMTypeFormalParameter]
# Concrete NIT source properties by name
- readable attr _src_local_properties: Map[Symbol, MMSrcLocalProperty]
+ readable attr _src_local_properties: Map[Symbol, MMConcreteProperty]
init(n: Symbol, cla: PClassdef, a: Int)
do
super(n, a)
_nodes = [cla]
- _src_local_properties = new HashMap[Symbol, MMSrcLocalProperty]
+ _src_local_properties = new HashMap[Symbol, MMConcreteProperty]
end
end
end
end
-# Concrete NIT source local property
-class MMSrcLocalProperty
-special MMConcreteProperty
- # Type of the related AST node
- type NODE: PPropdef
-
- # The related AST node
- readable attr _node: NODE
+redef class MMConcreteProperty
+ # The attached node (if any)
+ meth node: PNode do return null
end
# Concrete NIT source attribute
class MMSrcAttribute
-special MMSrcLocalProperty
+special MMConcreteProperty
special MMAttribute
+ redef readable attr _node: AAttrPropdef
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
super(name, cla, self)
# Concrete NIT source method
class MMSrcMethod
-special MMSrcLocalProperty
+special MMConcreteProperty
special MMMethod
end
# Concrete NIT source method for an automatic accesor
class MMAttrImplementationMethod
special MMSrcMethod
- redef type NODE: AAttrPropdef
+ redef readable attr _node: AAttrPropdef
end
# Concrete NIT source method for an automatic read accesor
# Concrete NIT source method for an explicit method
class MMMethSrcMethod
special MMSrcMethod
- redef type NODE: AMethPropdef
-
+ redef readable attr _node: AMethPropdef
init(name: Symbol, cla: MMLocalClass, n: AMethPropdef)
do
super(name, cla, self)
# Concrete NIT source virtual type
class MMSrcTypeProperty
-special MMSrcLocalProperty
+special MMConcreteProperty
special MMTypeProperty
+ redef readable attr _node: ATypePropdef
init(name: Symbol, cla: MMLocalClass, n: ATypePropdef)
do
super(name, cla, self)
readable writable attr _local_class: MMSrcLocalClass
# The current property
- readable writable attr _local_property: MMSrcLocalProperty
+ readable writable attr _local_property: MMConcreteProperty
# The current tool configuration/status
readable attr _tc: ToolContext