Add default values for some primitive type attributes.
[nit.git] / src / metamodel / abstractmetamodel.nit
index 2874b49..4ce08ef 100644 (file)
@@ -322,18 +322,31 @@ class MMGlobalClass
        end
 
        # Is the global class an interface?
-       readable writable attr _is_interface: Bool
+       readable writable attr _is_interface: Bool = false
 
        # Is the global class an abstract class?
-       readable writable attr _is_abstract: Bool
+       readable writable attr _is_abstract: Bool = false
 
        # Is the global class a universal class?
-       readable writable attr _is_universal: Bool
+       readable writable attr _is_universal: Bool = false
 
        # Visibility of the global class
        # 1 -> public
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
+
+       # Is the global class a mixin class?
+       # A mixin class inherits all constructors from a superclass
+       meth is_mixin: Bool
+       do
+               return _mixin_of != self
+       end
+
+       # Indicate the superclass the class is a mixin of.
+       # If mixin_of == self then the class is not a mixin
+       # Is two classes have the same mixin_of value, then they both belong to the same mixing group
+       readable writable attr _mixin_of: MMGlobalClass = self
+
 end
 
 # Local classes are classes defined, refined or imported in a module
@@ -443,6 +456,30 @@ class MMLocalClass
 
                return null
        end
+
+       # Select a method from its name
+       # TODO: Will disapear when qualified names will be available
+       meth select_method(name: Symbol): MMMethod
+       do
+               assert name != null
+               var gp = method(name)
+               if gp == null then return null
+               var res = self[gp]
+               assert res isa MMMethod
+               return res
+       end
+       
+       # Select an attribute from its name
+       # TODO: Will disapear when qualified names will be available
+       meth select_attribute(name: Symbol): MMAttribute
+       do
+               assert name != null
+               var gp = attribute(name)
+               if gp == null then return null
+               var res = self[gp]
+               assert res isa MMAttribute
+               return res
+       end
        
        # Look in super-classes (by specialization) and return properties with name
        # Beware, global property of results is not intended to be the same
@@ -555,11 +592,20 @@ class MMGlobalProperty
        # Is the global property a constructor (thus also a method)?
        readable writable attr _is_init: Bool
 
+       # Is the global property a constructor for a given class?
+       meth is_init_for(c: MMLocalClass): Bool
+       do
+               if not is_init then return false
+               var sc = intro.local_class
+               var res = c.che <= sc and c.global.mixin_of == sc.global.mixin_of
+               return res
+       end
+
        # Visibility of the property
        # 1 -> public
        # 2 -> protected
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
 end
 
 # Local properties are properties defined (explicitely or not) in a local class
@@ -610,7 +656,7 @@ class MMLocalProperty
        redef meth to_s do return name.to_s
 
        # Is the concrete property contain a `super' in the body?
-       readable writable attr _need_super: Bool
+       readable writable attr _need_super: Bool = false
 
        protected init(n: Symbol, bc: MMLocalClass)
        do