model: add `MMethod::is_toplevel`
authorJean Privat <jean@pryen.org>
Tue, 10 Jun 2014 18:53:12 +0000 (14:53 -0400)
committerJean Privat <jean@pryen.org>
Tue, 10 Jun 2014 21:15:19 +0000 (17:15 -0400)
Documentation will like to have such an information easily available.

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

src/model/model.nit
src/modelize_property.nit

index 629dadb..6732a16 100644 (file)
@@ -1718,6 +1718,10 @@ class MMethod
                super
        end
 
+       # Is the property defined at the top_level of the module?
+       # Currently such a property are stored in `Object`
+       var is_toplevel: Bool writable = false
+
        # Is the property a constructor?
        # Warning, this property can be inherited by subclasses with or without being a constructor
        # therefore, you should use `is_init_for` the verify if the property is a legal constructor for a given class
index 5efeb9c..dbdd43a 100644 (file)
@@ -449,6 +449,7 @@ redef class AMethPropdef
                        mprop = new MMethod(mclassdef, name, mvisibility)
                        mprop.is_init = is_init
                        mprop.is_new = n_kwnew != null
+                       if nclassdef isa ATopClassdef then mprop.is_toplevel = true
                        if not self.check_redef_keyword(modelbuilder, nclassdef, n_kwredef, false, mprop) then return
                else
                        if not self.check_redef_keyword(modelbuilder, nclassdef, n_kwredef, not self isa AMainMethPropdef, mprop) then return