Remove class MMSrcLocalProperty. Use MMConcreteProperty instead
authorJean Privat <jean@pryen.org>
Fri, 14 Nov 2008 10:04:41 +0000 (05:04 -0500)
committerJean Privat <jean@pryen.org>
Fri, 14 Nov 2008 10:04:41 +0000 (05:04 -0500)
src/compiling/compiling_global.nit
src/compiling/compiling_methods.nit
src/syntax/mmbuilder.nit
src/syntax/syntax_base.nit

index f51aede..bf5c74b 100644 (file)
@@ -518,7 +518,7 @@ redef class MMSrcModule
                                                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
@@ -556,11 +556,11 @@ 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
index 8a95a4a..29c6fda 100644 (file)
@@ -272,7 +272,7 @@ redef class MMAttribute
        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
index e9cf796..ab85b7c 100644 (file)
@@ -135,12 +135,12 @@ 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
@@ -595,7 +595,7 @@ redef class PPropdef
        # * 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)
@@ -605,7 +605,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: 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
@@ -645,7 +645,7 @@ redef class PPropdef
                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
@@ -672,7 +672,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: 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
@@ -940,7 +940,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: MMSrcLocalProperty) is abstract
+       meth check_visibility(v: AbsSyntaxVisitor, p: MMConcreteProperty) is abstract
 end
 
 redef class ASignature
@@ -1020,7 +1020,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: MMSrcLocalProperty) is abstract
+       private meth check_visibility(v: AbsSyntaxVisitor, p: MMConcreteProperty) is abstract
 end
 
 redef class AType
index 6bd86ef..e35b117 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, 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
 
@@ -99,20 +99,16 @@ redef class MMGlobalProperty
        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)
@@ -122,14 +118,14 @@ end
 
 # 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
@@ -157,8 +153,7 @@ end
 # 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)
@@ -168,8 +163,9 @@ end
 
 # 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)
@@ -270,7 +266,7 @@ special Visitor
        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