rename 'package' to 'module'
[nit.git] / src / syntax / syntax_base.nit
index 6d9bf07..fb2db7b 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # Common syntax structures for syntax analysis of NIT AST.
-package syntax_base
+module syntax_base
 
 import parser
 import mmloader
@@ -71,7 +71,7 @@ redef class MMGlobalClass
                if vpm == 3 then
                        return true
                else if vpm == 0 then
-                       v.error(n, "Visibility error: Class {self} comes from the hidden module {cm}.") # TODO: should not occur
+                       v.error(n, "Visibility error: Class {self} comes from the hidden module {pm}.") # TODO: should not occur
                        return false
                else if visibility_level >= 3 then
                        v.error(n, "Visibility error: Class {self} is private.")
@@ -111,7 +111,7 @@ redef class MMGlobalProperty
                        return true
                else if vpm == 0 then
                        # TODO: should not occurs 
-                       v.error(n, "Visibility error: Property {self} comes from the hidden module {cm}.")
+                       v.error(n, "Visibility error: Property {self} comes from the hidden module {pm}.")
                        return false
                else if visibility_level >= 3 then
                        v.error(n, "Visibility error: Property {self} is private.")
@@ -144,15 +144,16 @@ class MMSrcAttribute
 end
 
 # Concrete NIT source method
-class MMSrcMethod
+abstract class MMSrcMethod
        super MMMethod
        redef fun is_intern do return false
+       redef fun is_extern do return false
        redef fun is_abstract do return false
        redef fun extern_name do return null
 end
 
 # Concrete NIT source method for an automatic accesor
-class MMAttrImplementationMethod
+abstract class MMAttrImplementationMethod
        super MMSrcMethod
        redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
@@ -185,17 +186,25 @@ class MMMethSrcMethod
        super MMSrcMethod
        redef readable var _is_init: Bool
        redef readable var _is_intern: Bool
+       redef readable var _is_extern: Bool
        redef readable var _is_abstract: Bool
        redef readable writable var _extern_name: nullable String # Will be computed during MMBuilder
+       redef readable var _explicit_casts : Set[MMImportedCast] = new HashSet[MMImportedCast]
+       redef readable var _explicit_imports : Set[MMExplicitImport] = new HashSet[MMExplicitImport]
        redef fun node: nullable AMethPropdef do return mmmodule.nodes(self).as(nullable AMethPropdef)
        init(name: Symbol, cla: MMLocalClass, n: nullable AMethPropdef)
        do
                super(name, cla)
                cla.mmmodule.nodes(self) = n
-               _is_init = node isa AConcreteInitPropdef
+               _is_init = node isa AInitPropdef
                _is_intern = node isa AInternMethPropdef
+               _is_extern = node isa AExternPropdef
                _is_abstract = node isa ADeferredMethPropdef
                _extern_name = null
+
+               if is_extern then
+                       mmmodule.is_extern_hybrid = true
+               end
        end
 end
 
@@ -286,7 +295,7 @@ end
 ###############################################################################
 
 # Visitor used during the syntax analysis
-class AbsSyntaxVisitor
+abstract class AbsSyntaxVisitor
        super Visitor
        fun get_type_by_name(clsname: Symbol): MMType
        do
@@ -393,19 +402,19 @@ class AbsSyntaxVisitor
        # Display an error for a given syntax node
        fun error(n: nullable ANode, s: String)
        do
-               _tc.error(if n == null then null else n.location, s)
+               _tc.error(if n == null then null else n.hot_location, s)
        end
 
        # Add an error, show errors and quit
        fun fatal_error(n: nullable ANode, s: String)
        do
-               _tc.fatal_error(if n == null then null else n.location, s)
+               _tc.fatal_error(if n == null then null else n.hot_location, s)
        end
 
        # Display a warning for a given syntax node
        fun warning(n: nullable ANode, s: String)
        do
-               _tc.warning(if n == null then null else n.location, s)
+               _tc.warning(if n == null then null else n.hot_location, s)
        end
 
        # Check conformity and display error
@@ -730,7 +739,7 @@ redef class AExpr
        fun stype: MMType is abstract
 end
 
-class AAbsAbsSendExpr
+abstract class AAbsAbsSendExpr
        super AExpr
        # The signature of the called property (require is_typed)
        fun prop_signature: MMSignature is abstract
@@ -739,7 +748,7 @@ class AAbsAbsSendExpr
        fun raw_arguments: Array[AExpr] is abstract
 end
 
-class AAbsSendExpr
+abstract class AAbsSendExpr
        super AAbsAbsSendExpr
        # The invoked method (require is_typed)
        fun prop: MMMethod is abstract
@@ -748,7 +757,7 @@ class AAbsSendExpr
        fun return_type: nullable MMType is abstract
 end
 
-class ASuperInitCall
+abstract class ASuperInitCall
        super AAbsSendExpr
 end
 
@@ -772,7 +781,7 @@ redef class AReassignFormExpr
        fun assign_method: MMMethod is abstract
 end
 
-class ASendReassignExpr
+abstract class ASendReassignExpr
        super ASendExpr
        super AReassignFormExpr
        # The invoked method used to read (require is_typed)
@@ -834,3 +843,13 @@ redef class AClosureDef
        # Automatic variables
        readable writable var _variables: nullable Array[AutoVariable]
 end
+
+redef class AMethid
+       # Name of method
+       fun name: nullable Symbol is abstract
+end
+
+redef class AExprs
+       # Return an array made of each expr
+       fun to_a: Array[AExpr] do return self.n_exprs.to_a
+end