tool: use ccache in gccx, if available
[nit.git] / src / icode / icode_base.nit
index f15b4a0..d795c55 100644 (file)
@@ -32,6 +32,10 @@ class IRegister
        end
 end
 
+# A mark used to associate IEscapes to ISeqs
+class IEscapeMark
+end
+
 # A Closure declaration
 class IClosureDecl
        # The associated closure definition
@@ -52,11 +56,14 @@ class IRoutine
        readable writable var _closure_decls: nullable Sequence[IClosureDecl] = null
 
        # The local variables (excluding params and result)
-       readable var _registers: Set[IRegister] = new ArraySet[IRegister]
+       readable var _registers: Set[IRegister] = new HashSet[IRegister]
 
        # The result of the routine
        readable var _result: nullable IRegister
 
+       # The local escapes marks of the routine
+       readable var _escape_marks: Set[IEscapeMark] = new HashSet[IEscapeMark]
+
        # The sequence of icode
        readable var _body: ISeq = new ISeq
 
@@ -159,6 +166,10 @@ class ISeq
 special ICode0
        # The sequence of icode
        readable var _icodes: List[ICode] = new List[ICode]
+
+       # The associated iescape_mark (if any)
+       readable writable var _iescape_mark: nullable IEscapeMark
+
        init do end
 end
 
@@ -184,9 +195,9 @@ end
 class IEscape
 special ICode0
        # The seqeuence to escape
-       # The control flow continues at the next icode after the sequence
-       readable var _seq: ISeq
-       init(seq: ISeq) do _seq = seq
+       # The control flow continues at the next icode after the associated sequence
+       readable var _iescape_mark: IEscapeMark
+       init(mark: IEscapeMark) do _iescape_mark = mark
 end
 
 # An abort statement
@@ -235,8 +246,13 @@ end
 
 # An instantiation
 # no reciever, all exprs are arguments
+# Will call in order:
+# - IAllocateInstance
+# - IInitAttributes
+# - IStaticCall -> target Initializer
+# - ICheckInstance
 class INew
-special ICall
+special IAbsCall
        # The type to instantiate
        readable var _stype: MMType
        init(t: MMType, p: MMMethod, a: Sequence[IRegister])
@@ -246,6 +262,49 @@ special ICall
        end
 end
 
+# An allocation of a new object
+# No receivers, returns a new object of type 't'
+# Will allocate memory and ensure dynamic type and object identity
+class IAllocateInstance
+special ICode0
+       # The type to allocate
+       readable var _stype: MMType
+       init(t: MMType)
+       do
+               _stype = t
+       end
+end
+
+# A static call to a specific method
+class IStaticCall
+special IAbsCall
+       init(p: MMMethod, a: Sequence[IRegister]) do super
+end
+
+# A validation of a newly constructed instance
+class ICheckInstance
+special ICode1
+       # The type to allocate
+       readable var _stype: MMType
+       init(t: MMType, e: IRegister)
+       do
+               super(e)
+               _stype = t
+       end
+end
+
+# Initialisation of default attributes of a new instance
+class IInitAttributes
+special ICode1
+       # The type to initialize
+       readable var _stype: MMType
+       init(t: MMType, e: IRegister)
+       do
+               super(e)
+               _stype = t
+       end
+end
+
 # A closure call
 # exprs are the arguments
 class IClosCall
@@ -263,24 +322,78 @@ special ICodeN
        end
 end
 
-# A native C code
-# Mainly used to implements things that do not have a specific ICode yet
+# A native inlined call
+# Native are associated to local properties to distinguish them
 # expr are the arguments
 class INative
 special ICodeN
-       # The native C code
-       # Special character sequence '@@@' will be substitued in order with the arguments
-       readable var _code: String
+       # The associated local property
+       readable var _method: MMMethod
 
-       init(c: String, e: nullable Sequence[IRegister])
+       init(m: MMMethod, e: nullable Sequence[IRegister])
        do
                super(e)
-               _code = c
+               _method = m
        end
 
        redef readable writable var _is_pure: Bool = false
 end
 
+# A literal Int value
+class IIntValue
+special ICode0
+       # The value
+       readable var _value: String
+
+       init(v: String) do _value = v
+
+       redef fun is_pure do return true
+end
+
+# A literal Bool value
+class IBoolValue
+special ICode0
+       # The value
+       readable var _value: Bool
+
+       init(v: Bool) do _value = v
+
+       redef fun is_pure do return true
+end
+
+# A literal NativeString value
+class IStringValue
+special ICode0
+       # The value
+       readable var _value: String
+
+       init(v: String) do _value = v
+
+       redef fun is_pure do return true
+end
+
+# A literal Float value
+class IFloatValue
+special ICode0
+       # The value
+       readable var _value: String
+
+       init(v: String) do _value = v
+
+       redef fun is_pure do return true
+end
+
+# A literal Char value
+class ICharValue
+special ICode0
+       # The value
+       readable var _value: String
+
+       init(v: String) do _value = v
+
+       redef fun is_pure do return true
+end
+
 # A register assigment
 # expr is the assigned value
 # result is the register assigned