diff dmd/DsymbolTable.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents 1475fd394c9e
children b0d41ff5e0df
line wrap: on
line diff
--- a/dmd/DsymbolTable.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DsymbolTable.d	Sun Oct 17 07:42:00 2010 +0400
@@ -8,17 +8,15 @@
 
 import std.stdio;
 
-class DsymbolTable
+import dmd.TObject;
+
+class DsymbolTable : TObject
 {
     StringTable tab;
 
     this()
 	{
-		tab = new StringTable;
-	}
-	
-    ~this()
-	{
+		register();
 	}
 
     // Look up Identifier. Return Dsymbol if found, NULL if not.
@@ -26,10 +24,9 @@
 	{
 debug {
 		assert(ident);
-		assert(tab);
 }
-		StringValue* sv = tab.lookup(ident.string_);
-		return (sv ? cast(Dsymbol)sv.ptrvalue : null);
+		Object* sv = tab.lookup(ident.string_);
+		return (sv ? cast(Dsymbol)*sv : null);
 	}
 
     // Insert Dsymbol in table. Return NULL if already there.
@@ -38,7 +35,6 @@
 		Identifier ident = s.ident;
 debug {
 		assert(ident);
-		assert(tab);
 }
 
 		return insert(ident, s);
@@ -49,15 +45,15 @@
 	{
 		assert(false);
 	}
-	
+
     Dsymbol insert(Identifier ident, Dsymbol s)	// when ident and s are not the same
 	{
-		StringValue* sv = tab.insert(ident.toChars());
+		Object* sv = tab.insert(ident.toChars());
 		if (sv is null) {
 			return null;		// already in table
 		}
 
-		sv.ptrvalue = cast(void*)s;
+		*sv = s;
 		return s;
 	}
-}
\ No newline at end of file
+}