ni_nitdoc: added fast copy past utility to signatures.
[nit.git] / src / syntax / syntax_base.nit
index 68f8fa2..a8d166d 100644 (file)
@@ -22,7 +22,7 @@ import mmloader
 
 # Concrete NIT source module
 class MMSrcModule
-special MMModule
+       super MMModule
        # A source module can locate AST nodes of related MM entities
        # Once a source module AST is no more needed, _nodes is set to null
        # See ToolContext::keep_ast property in syntax.nit for details
@@ -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.")
@@ -83,7 +83,7 @@ end
 
 # Concrete NIT source local classes
 class MMSrcLocalClass
-special MMConcreteClass
+       super MMConcreteClass
        # The first related AST node (if any)
        fun node: nullable AClassdef do return mmmodule.nodes(self).as(nullable AClassdef)
 
@@ -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.")
@@ -134,7 +134,7 @@ end
 
 # Concrete NIT source attribute
 class MMSrcAttribute
-special MMAttribute
+       super MMAttribute
        redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
        do
@@ -144,16 +144,17 @@ special MMAttribute
 end
 
 # Concrete NIT source method
-class MMSrcMethod
-special MMMethod
+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
-special MMSrcMethod
+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)
        do
@@ -164,7 +165,7 @@ end
 
 # Concrete NIT source method for an automatic read accesor
 class MMReadImplementationMethod
-special MMAttrImplementationMethod
+       super MMAttrImplementationMethod
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
        do
                super(name, cla, n)
@@ -173,7 +174,7 @@ end
 
 # Concrete NIT source method for an automatic write accesor
 class MMWriteImplementationMethod
-special MMAttrImplementationMethod
+       super MMAttrImplementationMethod
        init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
        do
                super(name, cla, n)
@@ -182,27 +183,35 @@ end
 
 # Concrete NIT source method for an explicit method
 class MMMethSrcMethod
-special MMSrcMethod
+       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
 
 # Concrete NIT source virtual type
 class MMSrcTypeProperty
-special MMLocalProperty
-special MMTypeProperty
+       super MMLocalProperty
+       super MMTypeProperty
        init(name: Symbol, cla: MMLocalClass, n: ATypePropdef)
        do
                super(name, cla)
@@ -211,7 +220,7 @@ end
 
 # Concrete NIT implicit constructor
 class MMImplicitInit
-special MMMethSrcMethod
+       super MMMethSrcMethod
        fun super_init: nullable MMLocalProperty is abstract
        redef fun is_init do return true
        readable var _unassigned_attributes: Array[MMSrcAttribute]
@@ -248,21 +257,21 @@ end
 
 # Variable declared with 'var'
 class VarVariable
-special Variable
+       super Variable
        redef fun kind do return once "variable"
        init(n: Symbol, d: ANode) do super
 end
 
 # Parameter of method (declared in signature)
 class ParamVariable
-special Variable
+       super Variable
        redef fun kind do return once "parameter"
        init(n: Symbol, d: nullable ANode) do super
 end
 
 # Automatic variable (like in the 'for' statement)
 class AutoVariable
-special Variable
+       super Variable
        redef fun kind do return once "automatic variable"
        init(n: Symbol, d: ANode) do super
 end
@@ -270,7 +279,7 @@ end
 # False variable corresponding to closures declared in signatures
 # Lives in the same namespace than variables
 class ClosureVariable
-special Variable
+       super Variable
        redef fun kind do return once "closure"
 
        # The signature of the closure
@@ -286,8 +295,8 @@ end
 ###############################################################################
 
 # Visitor used during the syntax analysis
-class AbsSyntaxVisitor
-special Visitor
+abstract class AbsSyntaxVisitor
+       super Visitor
        fun get_type_by_name(clsname: Symbol): MMType
        do
                if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
@@ -338,12 +347,6 @@ special Visitor
                return get_type_by_name(once ("String".to_symbol))
        end
 
-       # The primitive type Collection[nullable Object]
-       fun type_collection: MMType
-       do
-               return get_instantiated_type_by_name(once ("Collection".to_symbol), [type_object.as_nullable])
-       end
-
        # The primitive type NativeString
        fun type_nativestring: MMType
        do
@@ -399,19 +402,19 @@ special Visitor
        # 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
@@ -736,8 +739,8 @@ redef class AExpr
        fun stype: MMType is abstract
 end
 
-class AAbsAbsSendExpr
-special AExpr
+abstract class AAbsAbsSendExpr
+       super AExpr
        # The signature of the called property (require is_typed)
        fun prop_signature: MMSignature is abstract
 
@@ -745,8 +748,8 @@ special AExpr
        fun raw_arguments: Array[AExpr] is abstract
 end
 
-class AAbsSendExpr
-special AAbsAbsSendExpr
+abstract class AAbsSendExpr
+       super AAbsAbsSendExpr
        # The invoked method (require is_typed)
        fun prop: MMMethod is abstract
 
@@ -754,21 +757,21 @@ special AAbsAbsSendExpr
        fun return_type: nullable MMType is abstract
 end
 
-class ASuperInitCall
-special AAbsSendExpr
+abstract class ASuperInitCall
+       super AAbsSendExpr
 end
 
 redef class ASuperExpr
-special ASuperInitCall
+       super ASuperInitCall
        fun init_in_superclass: nullable MMMethod is abstract
 end
 
 redef class ANewExpr
-special AAbsSendExpr
+       super AAbsSendExpr
 end
 
 redef class ASendExpr
-special ASuperInitCall
+       super ASuperInitCall
        # Closure definitions
        fun closure_defs: nullable Array[AClosureDef] is abstract
 end
@@ -778,20 +781,20 @@ redef class AReassignFormExpr
        fun assign_method: MMMethod is abstract
 end
 
-class ASendReassignExpr
-special ASendExpr
-special AReassignFormExpr
+abstract class ASendReassignExpr
+       super ASendExpr
+       super AReassignFormExpr
        # The invoked method used to read (require is_typed)
        # prop is the method used to write
        fun read_prop: MMMethod is abstract
 end
 
 redef class ACallReassignExpr
-special ASendReassignExpr
+       super ASendReassignExpr
 end
 
 redef class ABraReassignExpr
-special ASendReassignExpr
+       super ASendReassignExpr
 end
 
 redef class AAttrFormExpr
@@ -814,7 +817,7 @@ end
 
 redef class AForExpr
        # Associated automatic local variable
-       fun variable: AutoVariable is abstract
+       fun variables: Array[AutoVariable] is abstract
 end
 
 redef class ASelfExpr
@@ -828,7 +831,7 @@ redef class AVarFormExpr
 end
 
 redef class AClosureCallExpr
-special AAbsAbsSendExpr
+       super AAbsAbsSendExpr
        # Associated closure variable
        fun variable: ClosureVariable is abstract
 end
@@ -840,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