Remove the now useless MMConcreteProperty class
authorJean Privat <jean@pryen.org>
Tue, 23 Dec 2008 22:48:34 +0000 (17:48 -0500)
committerJean Privat <jean@pryen.org>
Tue, 23 Dec 2008 22:48:34 +0000 (17:48 -0500)
src/compiling/compiling_base.nit
src/compiling/compiling_global.nit
src/compiling/compiling_methods.nit
src/metamodel/abstractmetamodel.nit
src/metamodel/inheritance.nit
src/syntax/mmbuilder.nit
src/syntax/syntax_base.nit
src/syntax/typing.nit

index bf1a744..c5bf61d 100644 (file)
@@ -290,7 +290,7 @@ redef class MMLocalProperty
        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
index c40fcc6..84ae7de 100644 (file)
@@ -518,7 +518,6 @@ redef class MMSrcModule
                                                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
@@ -556,11 +555,11 @@ 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
@@ -591,7 +590,7 @@ special TableEltPropPos
                                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
@@ -853,9 +852,8 @@ redef class MMLocalClass
                                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
@@ -895,7 +893,7 @@ redef class MMLocalClass
                                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("}")
index 274ffa4..02d0d68 100644 (file)
@@ -207,7 +207,7 @@ redef class MMMethod
        # == 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))
@@ -272,7 +272,7 @@ redef class MMAttribute
        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
index 1a2eb86..2874b49 100644 (file)
@@ -514,7 +514,7 @@ class MMGlobalProperty
        # 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
@@ -522,29 +522,28 @@ class MMGlobalProperty
                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 ?
@@ -563,8 +562,7 @@ class MMGlobalProperty
        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
@@ -575,9 +573,8 @@ class MMLocalProperty
        # 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
@@ -601,14 +598,24 @@ class MMLocalProperty
                _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
 
@@ -627,21 +634,3 @@ class MMConcreteClass
 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
-
index e311563..15ac695 100644 (file)
@@ -318,7 +318,7 @@ redef class MMLocalClass
 
                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
@@ -329,10 +329,9 @@ redef class MMLocalClass
                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
@@ -344,8 +343,8 @@ redef class MMLocalClass
                                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
@@ -364,24 +363,18 @@ redef class MMLocalClass
        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
 
index 2032534..56e2ace 100644 (file)
@@ -151,7 +151,7 @@ redef class MMSrcLocalClass
        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
@@ -179,7 +179,7 @@ redef class MMSrcLocalClass
        end
 end
 
-redef class MMConcreteProperty
+redef class MMLocalProperty
        private meth accept_property_visitor(v: AbsSyntaxVisitor)
        do
        end
@@ -616,7 +616,7 @@ redef class PPropdef
        # * 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)
@@ -626,7 +626,7 @@ redef class PPropdef
        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
@@ -666,11 +666,10 @@ redef class PPropdef
                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
@@ -694,7 +693,7 @@ redef class PPropdef
        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
@@ -711,7 +710,7 @@ redef class PPropdef
 
                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)
 
@@ -962,7 +961,7 @@ end
 
 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
@@ -1042,7 +1041,7 @@ end
 
 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
index d1fc546..ee7de59 100644 (file)
@@ -66,13 +66,13 @@ special MMConcreteClass
        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
 
@@ -99,26 +99,26 @@ redef class MMGlobalProperty
        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
 
@@ -134,7 +134,7 @@ special MMAttrImplementationMethod
 
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
        do
-               super(name, cla, self)
+               super(name, cla)
                _node = n
        end
 end
@@ -145,7 +145,7 @@ special MMAttrImplementationMethod
 
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
        do
-               super(name, cla, self)
+               super(name, cla)
                _node = n
        end
 end
@@ -156,19 +156,19 @@ special MMSrcMethod
        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
@@ -268,7 +268,7 @@ special Visitor
        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 
index 61d26e5..0920070 100644 (file)
@@ -654,7 +654,7 @@ special ASuperInitCall
        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