parser: promote all children in AMethPropdef
authorJean Privat <jean@pryen.org>
Thu, 1 May 2014 17:24:53 +0000 (13:24 -0400)
committerJean Privat <jean@pryen.org>
Mon, 12 May 2014 14:56:56 +0000 (10:56 -0400)
The point of the series is to refactorize the hierarchy of AMethPropdef
and simplify the complex syntactic variants.

So, put all specific fields in the root class, so clients will not need
to use the current complex hierarchy.

Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize_property.nit
src/parser/parser_nodes.nit

index 9425fcf..f36bd40 100644 (file)
@@ -410,10 +410,10 @@ redef class AMethPropdef
                                name_node = self
                        else if self isa AConcreteInitPropdef then
                                name = "init"
-                               name_node = self.n_kwinit
+                               name_node = self.n_kwinit.as(not null)
                        else if self isa AExternInitPropdef then
                                name = "init"
-                               name_node = self.n_kwnew
+                               name_node = self.n_kwnew.as(not null)
                        else
                                abort
                        end
index 7bee993..4a195df 100644 (file)
@@ -785,12 +785,23 @@ end
 # A definition of all kind of method (including constructors)
 abstract class AMethPropdef
        super APropdef
+       readable writable var _n_kwmeth: nullable TKwmeth
+       readable writable var _n_kwinit: nullable TKwinit
+       readable writable var _n_kwnew: nullable TKwnew
        readable writable var _n_methid: nullable AMethid = null
        readable writable var _n_signature: nullable ASignature
+       readable writable var _n_block: nullable AExpr = null
+       readable writable var _n_extern: nullable TString = null
+       readable writable var _n_extern_calls: nullable AExternCalls = null
+       readable writable var _n_extern_code_block: nullable AExternCodeBlock = null
        redef fun hot_location
        do
                if n_methid != null then
                        return n_methid.location
+               else if n_kwinit != null then
+                       return n_kwinit.location
+               else if n_kwnew != null then
+                       return n_kwnew.location
                else
                        return location
                end
@@ -801,34 +812,26 @@ end
 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
 class ADeferredMethPropdef
        super AMethPropdef
-       readable writable var _n_kwmeth: TKwmeth
 end
 
 # A method marked intern
 class AInternMethPropdef
        super AMethPropdef
-       readable writable var _n_kwmeth: TKwmeth
 end
 
 # A method of a constructor marked extern
 abstract class AExternPropdef
        super AMethPropdef
-       readable writable var _n_extern: nullable TString = null
-       readable writable var _n_extern_calls: nullable AExternCalls = null
-       readable writable var _n_extern_code_block: nullable AExternCodeBlock = null
 end
 
 # A method marked extern
 class AExternMethPropdef
        super AExternPropdef
-       readable writable var _n_kwmeth: TKwmeth
 end
 
 # A method with a body
 class AConcreteMethPropdef
        super AMethPropdef
-       readable writable var _n_kwmeth: nullable TKwmeth
-       readable writable var _n_block: nullable AExpr = null
 end
 
 # A constructor
@@ -840,15 +843,12 @@ end
 class AConcreteInitPropdef
        super AConcreteMethPropdef
        super AInitPropdef
-       readable writable var _n_kwinit: TKwinit
-       redef fun hot_location do return n_kwinit.location
 end
 
 # A constructor marked extern (defined with the `new` keyword)
 class AExternInitPropdef
        super AExternPropdef
        super AInitPropdef
-       readable writable var _n_kwnew: TKwnew
 end
 
 # The implicit main method