changeset 522:812f497b20dc

Added module dil.TypesEnum. Added struct TypeMetaInfo and metaInfoTable array. Added type member to class Expression.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 16 Dec 2007 19:14:21 +0100
parents 772ffdb18fd4
children d22a33cab0b5
files trunk/src/dil/Expressions.d trunk/src/dil/TypeSystem.d trunk/src/dil/TypesEnum.d
diffstat 3 files changed, 127 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Expressions.d	Sat Dec 15 22:51:27 2007 +0100
+++ b/trunk/src/dil/Expressions.d	Sun Dec 16 19:14:21 2007 +0100
@@ -10,9 +10,11 @@
 import dil.Statements;
 import dil.Identifier;
 import dil.Scope;
+import dil.TypeSystem;
 
 abstract class Expression : Node
 {
+  Type type; /// The type of this expression.
   this()
   {
     super(NodeCategory.Expression);
--- a/trunk/src/dil/TypeSystem.d	Sat Dec 15 22:51:27 2007 +0100
+++ b/trunk/src/dil/TypeSystem.d	Sun Dec 16 19:14:21 2007 +0100
@@ -5,10 +5,20 @@
 module dil.TypeSystem;
 
 import dil.Symbol;
+import dil.TypesEnum;
 
 abstract class Type : Symbol
 {
   Type next;
+  TYP typ;
+
+  this(){}
+
+  this(Type next, TYP typ)
+  {
+    this.next = next;
+    this.typ = typ;
+  }
 }
 
 class TypeBasic : Type
@@ -26,6 +36,11 @@
 
 }
 
+class TypeSArray : Type
+{
+
+}
+
 class TypePointer : Type
 {
 
@@ -35,3 +50,58 @@
 {
 
 }
+
+struct TypeMetaInfo
+{
+  char mangle; /// Mangle character of the type.
+  size_t size; /// Byte size of the type.
+}
+
+static const TypeMetaInfo metaInfoTable[] = [
+  {'?', -1}, // Error
+
+  {'a', 1},   // Char
+  {'u', 2},   // Wchar
+  {'w', 4},   // Dchar
+  {'b', 1},   // Bool
+  {'g', 1},   // Byte
+  {'h', 1},   // Ubyte
+  {'s', 2},   // Short
+  {'t', 2},   // Ushort
+  {'i', 4},   // Int
+  {'k', 4},   // Uint
+  {'l', 8},   // Long
+  {'m', 8},   // Ulong
+  {'?', 16},  // Cent
+  {'?', 16},  // Ucent
+  {'f', 4},   // Float
+  {'d', 8},   // Double
+  {'e', 12},  // Real
+  {'o', 4},   // Ifloat
+  {'p', 8},   // Idouble
+  {'j', 12},  // Ireal
+  {'q', 8},   // Cfloat
+  {'r', 16},  // Cdouble
+  {'c', 24},  // Creal
+  {'v', 1},   // void
+
+  {'n', -1},  // None
+
+  {'A', 8}, // Dynamic array
+  {'G', 8}, // Static array
+  {'H', 8}, // Associative array
+
+  {'E', -1}, // Enum
+  {'S', -1}, // Struct
+  {'C', -1}, // Class
+  {'T', -1}, // Typedef
+  {'F', -1}, // Function
+  {'D', -1}, // Delegate
+  {'P', -1}, // Pointer
+  {'R', -1}, // Reference
+  {'I', -1}, // Identifier
+  {'?', -1}, // Template instance
+  {'B', -1}, // Tuple
+  {'x', -1}, // Const, D2
+  {'y', -1}, // Invariant, D2
+];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/dil/TypesEnum.d	Sun Dec 16 19:14:21 2007 +0100
@@ -0,0 +1,55 @@
+/++
+  Author: Aziz Köksal
+  License: GPL3
++/
+module dil.TypesEnum;
+
+enum TYP
+{
+  Error,
+  // Basic types.
+  Char,    // char
+  Wchar,   // wchar
+  Dchar,   // dchar
+  Bool,    // bool
+  Byte,    // int8
+  Ubyte,   // uint8
+  Short,   // int16
+  Ushort,  // uint16
+  Int,     // int32
+  Uint,    // uint32
+  Long,    // int64
+  Ulong,   // uint64
+  Cent,    // int128
+  Ucent,   // uint128
+  Float,   // float32
+  Double,  // float64
+  Real,    // float80
+  Ifloat,  // imaginary float32
+  Idouble, // imaginary float64
+  Ireal,   // imaginary float80
+  Cfloat,  // complex float32
+  Cdouble, // complex float64
+  Creal,   // complex float80
+  Void,    // void
+
+  None,   // TypeNone in the specs. Why?
+
+  DArray, // Dynamic
+  SArray, // Static
+  AArray, // Associative
+
+  Enum,
+  Struct,
+  Class,
+  Typedef,
+  Function,
+  Delegate,
+  Pointer,
+  Reference,
+  Identifier,
+  TInstance, // Template instance.
+  Tuple,
+  Const, // D2
+  Invariant, // D2
+}