diff sema/DType.d @ 49:c7cde6af0095 new_gen

Seperated the AST from LLVM * Changed SmallArray sligthly * Added a NullAction that doesn't do anything
author Anders Halager <halager@gmail.com>
date Sat, 26 Apr 2008 13:15:37 +0200
parents 1a7a308f75b2
children 79cb0afafabe
line wrap: on
line diff
--- a/sema/DType.d	Thu Apr 24 19:42:53 2008 +0200
+++ b/sema/DType.d	Sat Apr 26 13:15:37 2008 +0200
@@ -1,9 +1,5 @@
 module sema.DType;
 
-import tango.text.Util : jhash;
-
-import LLVM = llvm.llvm;
-
 import lexer.Token,
        ast.Exp;
 
@@ -14,22 +10,19 @@
     private char[] id;
     private Location loc;
     public DType actual;
-    private LLVM.Type llvmType;
 
     this(Identifier id, DType actual = null)
     {
         Token temp = id.token;
         this.id = temp.get;
         this.loc = temp.location;
-        if (actual !is null)
-            this.actual = this;
+        this.actual = actual is null? this : actual;
     }
 
     this(char[] id, DType actual = null)
     {
         this.id = id;
-        if (actual !is null)
-            this.actual = this;
+        this.actual = actual is null? this : actual;
     }
 
     int opEquals(Object o)
@@ -46,6 +39,13 @@
         return 0;
     }
 
+    /**
+      Hashing is done by casting the reference to a void* and taking that
+      value, but this gives a bad distribution of hash-values.
+
+      Multiple DType's allocated close to each other will only have a
+      difference in the lower bits of their hashes.
+     */
     hash_t toHash()
     {
         return cast(hash_t)(cast(void*)this);
@@ -53,7 +53,6 @@
 
     char[] name() { return id; }
     Location getLoc() { return loc; }
-    LLVM.Type llvm() { return llvmType; }
     int byteSize() { return 0; }
 
     static DInteger
@@ -66,7 +65,6 @@
     static this()
     {
         Void   = new DType("void");
-        Void.llvmType = LLVM.Type.Void;
 
         Bool   = new DInteger("bool",    1, false);
         Byte   = new DInteger("byte",    8, false);
@@ -80,6 +78,9 @@
     }
 }
 
+/**
+  Class to represent the built-in integer types, from byte to long.
+ */
 class DInteger : DType
 {
     this(char[] name, int bits, bool unsigned)
@@ -87,7 +88,6 @@
         super(name, null);
         this.bits = bits;
         this.unsigned = unsigned;
-        llvmType = LLVM.IntegerType.Get(bits);
     }
 
     override int byteSize() { return bits / 8; }
@@ -109,17 +109,10 @@
     {
         this.members = members;
 
-        LLVM.Type[] types;
-
         foreach (type; members)
-        {
-            types ~= type.llvm;
             bytes_total += type.byteSize();
-        }
+    }
 
-        this.llvmType = LLVM.StructType.Get(types);
-
-    }
     DType[char[]] members;
     private int bytes_total;
 }
@@ -130,6 +123,7 @@
     {
         super(id, actual);
     }
+
     DType[] params;
     DType return_type;
 }