meth cname: String
do
if _cname_cache == null then
- _cname_cache = cmangle(concrete_property.module.name, concrete_property.local_class.name, name)
+ _cname_cache = cmangle(module.name, local_class.name, name)
end
return _cname_cache
end
v.add_decl("#define {pg.attr_access}(recv) ATTR(recv, {pg.color_id})")
end
end
- assert p isa MMConcreteProperty
p.compile_property_to_c(v)
end
end
class TableEltPropPos
special LocalTableElt
- attr _property: MMConcreteProperty
+ attr _property: MMLocalProperty
redef meth symbol do return _property.global.color_id
redef meth value(ga) do return "{ga.color(self)} /* Property {_property} */"
- init(p: MMConcreteProperty)
+ init(p: MMLocalProperty)
do
_property = p
end
found = true
else if found and c.che < s then
var p = s[g]
- if p != null and p isa MMConcreteProperty then
+ if p != null then
#print "found {s.module}::{s}::{p}"
return p.cname
end
var t = p.signature.return_type
if p isa MMAttribute and t != null then
# FIXME: Not compatible with sep compilation
- var pi = p.concrete_property
- assert pi isa MMSrcAttribute
- var np = pi.node
+ assert p isa MMSrcAttribute
+ var np = p.node
assert np isa AAttrPropdef
var ne = np.n_expr
if ne != null then
v.indent
v.add_instr(init_table_decl)
v.add_instr("val_t self = NEW_{name}();")
- v.add_instr("{p.concrete_property.cname}({args.join(", ")});")
+ v.add_instr("{p.cname}({args.join(", ")});")
v.add_instr("return self;")
v.unindent
v.add_instr("}")
# == and != are guarded and possibly inlined
meth compile_call(v: CompilerVisitor, cargs: Array[String]): String
do
- var i = concrete_property
+ var i = self
assert i isa MMSrcMethod
if i.node isa AInternMethPropdef or
(i.local_class.name == (once "Array".to_symbol) and name == (once "[]".to_symbol))
end
end
-redef class MMConcreteProperty
+redef class MMLocalProperty
# Compile the property as a C property
meth compile_property_to_c(v: CompilerVisitor) do end
end
# The local property for each class that has the global property
# The introducing local property
- readable attr _intro: MMConcreteProperty
+ readable attr _intro: MMLocalProperty
# The local class that introduces the global property
meth local_class: MMLocalClass
return intro.local_class
end
- # The concrete property redefinition hierarchy
- readable attr _concrete_property_hierarchy: PartialOrder[MMConcreteProperty] = new PartialOrder[MMConcreteProperty]
+ # The property redefinition hierarchy
+ readable attr _property_hierarchy: PartialOrder[MMLocalProperty] = new PartialOrder[MMLocalProperty]
# Create a new global property introduced by a local one
- protected init(p: MMConcreteProperty)
+ protected init(p: MMLocalProperty)
do
assert p != null
- assert p.concrete_property != null
- _concrete_property_hierarchy = new PartialOrder[MMConcreteProperty]
+ _property_hierarchy = new PartialOrder[MMLocalProperty]
_intro = p
- add_concrete_property(p, new Array[MMConcreteProperty])
+ add_local_property(p, new Array[MMLocalProperty])
end
redef meth to_s do return intro.full_name
- # Register a new concrete property
- meth add_concrete_property(i: MMConcreteProperty, sup: Array[MMConcreteProperty])
+ # Register a new local property
+ meth add_local_property(i: MMLocalProperty, sup: Array[MMLocalProperty])
do
assert i != null
assert sup != null
- i._cprhe = _concrete_property_hierarchy.add(i,sup)
+ i._prhe = _property_hierarchy.add(i,sup)
end
# Is the global property an attribute ?
readable writable attr _visibility_level: Int
end
-# Local properties are adaptation of concrete local properties
-# They can be adapted for inheritance (or importation) or for type variarion (genericity, etc.)
+# Local properties are properties defined (explicitely or not) in a local class
class MMLocalProperty
# The name of the property
readable attr _name: Symbol
# The global property where belong the local property
readable attr _global: MMGlobalProperty
- # The concrete property
- # May be self if self is a concrete property
- readable attr _concrete_property: MMConcreteProperty
+ # Redefinition hierarchy of the local property
+ readable attr _prhe: PartialOrderElement[MMLocalProperty]
# The module of the local property
meth module: MMModule do return _local_class.module
_global = g
_local_class.register_local_property(self)
end
+
+ # Introduce a new global property for this local one
+ meth new_global
+ do
+ assert _global == null
+ _global = new MMGlobalProperty(self)
+ _local_class.register_global_property(_global)
+ end
redef meth to_s do return name.to_s
- protected init(n: Symbol, bc: MMLocalClass, i: MMConcreteProperty)
+ # Is the concrete property contain a `super' in the body?
+ readable writable attr _need_super: Bool
+
+ protected init(n: Symbol, bc: MMLocalClass)
do
_name = n
_local_class = bc
- _concrete_property = i
end
end
special MMLocalClass
end
-# Concrete local properties
-class MMConcreteProperty
-special MMLocalProperty
- # Redefinition hierarchy of the concrete property
- readable attr _cprhe: PartialOrderElement[MMConcreteProperty]
-
- # Is the concrete property contain a `super' in the body?
- readable writable attr _need_super: Bool
-
- # Introduce a new global property for this local one
- meth new_global
- do
- assert _global == null
- _global = new MMGlobalProperty(self)
- _local_class.register_global_property(_global)
- end
-end
-
var impl: MMLocalProperty
- var ghier = glob.concrete_property_hierarchy
+ var ghier = glob.property_hierarchy
var supers = che.direct_greaters
if ghier.length == 1 then
# Unredefined property
else
# Hard multiple inheritance
# First compute the set of bottom properties
- var impls = new ArraySet[MMConcreteProperty]
+ var impls = new ArraySet[MMLocalProperty]
for sc in supers do
var p = sc[glob]
- assert p isa MMConcreteProperty
if p != null then impls.add(p)
end
# Second, extract most specific
for i in impls2 do
print(" {i.full_name}")
end
- print("------- {glob.concrete_property_hierarchy.first}")
- print("------- {glob.concrete_property_hierarchy.to_dot}")
+ print("------- {glob.property_hierarchy.first}")
+ print("------- {glob.property_hierarchy.to_dot}")
exit(1)
end
impl = impls2.first
end
end
-redef class MMConcreteProperty
- # FIXME: use this
- meth is_deferred: Bool do return false
-end
-
redef class MMLocalProperty
# Attach self to a global property
meth inherit_global(g: MMGlobalProperty)
do
set_global(g)
- var impls = new Array[MMConcreteProperty]
+ var impls = new Array[MMLocalProperty]
for sc in local_class.che.direct_greaters do
var p = sc[g]
if p == null then continue
- assert p isa MMConcreteProperty
impls.add(p)
end
- g.add_concrete_property(concrete_property, impls)
+ g.add_local_property(self, impls)
end
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: MMConcreteProperty)
+ private meth add_src_local_property(v: PropertyBuilderVisitor, prop: MMLocalProperty)
do
var pname = prop.name
# Check double definition in the same class
end
end
-redef class MMConcreteProperty
+redef class MMLocalProperty
private meth accept_property_visitor(v: AbsSyntaxVisitor)
do
end
# * Check redef errors.
# * Check forbiden attribute definitions.
# * Check signature conformance.
- private meth process_and_check(v: PropertyVerifierVisitor, prop: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
+ private meth process_and_check(v: PropertyVerifierVisitor, prop: MMLocalProperty, 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: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
+ private meth do_and_check_intro(v: PropertyVerifierVisitor, prop: MMLocalProperty, 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: MMConcreteProperty, supers: Array[MMLocalProperty])
+ private meth inherit_signature(v: PropertyVerifierVisitor, prop: MMLocalProperty, 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: MMConcreteProperty, has_redef: Bool, visibility_level: Int)
+ private meth do_and_check_redef(v: PropertyVerifierVisitor, prop: MMLocalProperty, has_redef: Bool, visibility_level: Int)
do
var is_init = self isa AConcreteInitPropdef
var glob = prop.global
var s = prop.signature
#print "process {prop.local_class.module}::{prop.local_class}::{prop} from global {prop.global.local_property.local_class.module}::{prop.global.local_property.local_class}::{prop.global.local_property}"
- for i in prop.cprhe.direct_greaters do
+ for i in prop.prhe.direct_greaters do
var ip = i.local_class[prop.global]
var isig = i.signature.adaptation_to(v.local_class.get_type)
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: MMConcreteProperty) is abstract
+ meth check_visibility(v: AbsSyntaxVisitor, p: MMLocalProperty) 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: MMConcreteProperty) is abstract
+ private meth check_visibility(v: AbsSyntaxVisitor, p: MMLocalProperty) 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, MMConcreteProperty]
+ readable attr _src_local_properties: Map[Symbol, MMLocalProperty]
init(n: Symbol, cla: PClassdef, a: Int)
do
super(n, a)
_nodes = [cla]
- _src_local_properties = new HashMap[Symbol, MMConcreteProperty]
+ _src_local_properties = new HashMap[Symbol, MMLocalProperty]
end
end
end
end
-redef class MMConcreteProperty
+redef class MMLocalProperty
# The attached node (if any)
meth node: PNode do return null
end
# Concrete NIT source attribute
class MMSrcAttribute
-special MMConcreteProperty
+special MMLocalProperty
special MMAttribute
redef readable attr _node: AAttrPropdef
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
- super(name, cla, self)
+ super(name, cla)
_node = n
end
end
# Concrete NIT source method
class MMSrcMethod
-special MMConcreteProperty
+special MMLocalProperty
special MMMethod
end
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
- super(name, cla, self)
+ super(name, cla)
_node = n
end
end
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
- super(name, cla, self)
+ super(name, cla)
_node = n
end
end
redef readable attr _node: AMethPropdef
init(name: Symbol, cla: MMLocalClass, n: AMethPropdef)
do
- super(name, cla, self)
+ super(name, cla)
_node = n
end
end
# Concrete NIT source virtual type
class MMSrcTypeProperty
-special MMConcreteProperty
+special MMLocalProperty
special MMTypeProperty
redef readable attr _node: ATypePropdef
init(name: Symbol, cla: MMLocalClass, n: ATypePropdef)
do
- super(name, cla, self)
+ super(name, cla)
_node = n
end
end
readable writable attr _local_class: MMSrcLocalClass
# The current property
- readable writable attr _local_property: MMConcreteProperty
+ readable writable attr _local_property: MMLocalProperty
# The current tool configuration/status
readable attr _tc: ToolContext
readable attr _init_in_superclass: MMMethod
redef meth after_typing(v)
do
- var precs: Array[MMLocalProperty] = v.local_property.cprhe.direct_greaters
+ var precs: Array[MMLocalProperty] = v.local_property.prhe.direct_greaters
if not precs.is_empty then
v.local_property.need_super = true
else if v.local_property.global.is_init then