changeset 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 cd48cb899aee
files commands.linux.txt commands.txt dmd/AddAssignExp.d dmd/AddExp.d dmd/AddrExp.d dmd/AggregateDeclaration.d dmd/AliasDeclaration.d dmd/AliasThis.d dmd/AlignDeclaration.d dmd/AndAndExp.d dmd/AndAssignExp.d dmd/AndExp.d dmd/AnonDeclaration.d dmd/AnonymousAggregateDeclaration.d dmd/Array.d dmd/ArrayExp.d dmd/ArrayInitializer.d dmd/ArrayLengthExp.d dmd/ArrayLiteralExp.d dmd/ArrayScopeSymbol.d dmd/AsmStatement.d dmd/AssertExp.d dmd/AssignExp.d dmd/AssocArrayLiteralExp.d dmd/AttribDeclaration.d dmd/BaseClass.d dmd/BinExp.d dmd/BoolExp.d dmd/BreakStatement.d dmd/CallExp.d dmd/CaseRangeStatement.d dmd/CaseStatement.d dmd/CastExp.d dmd/CatAssignExp.d dmd/CatExp.d dmd/Catch.d dmd/ClassDeclaration.d dmd/ClassInfoDeclaration.d dmd/CmpExp.d dmd/ComExp.d dmd/CommaExp.d dmd/CompileDeclaration.d dmd/CompileExp.d dmd/CompileStatement.d dmd/ComplexExp.d dmd/CompoundDeclarationStatement.d dmd/CompoundStatement.d dmd/CondExp.d dmd/Condition.d dmd/ConditionalDeclaration.d dmd/ConditionalStatement.d dmd/ContinueStatement.d dmd/CtorDeclaration.d dmd/DVCondition.d dmd/DebugCondition.d dmd/DebugSymbol.d dmd/Declaration.d dmd/DeclarationExp.d dmd/DeclarationStatement.d dmd/DefaultInitExp.d dmd/DefaultStatement.d dmd/DelegateExp.d dmd/DeleteDeclaration.d dmd/DeleteExp.d dmd/DivAssignExp.d dmd/DivExp.d dmd/DoStatement.d dmd/DocComment.d dmd/DollarExp.d dmd/DotExp.d dmd/DotIdExp.d dmd/DotTemplateExp.d dmd/DotTemplateInstanceExp.d dmd/DotTypeExp.d dmd/Dsymbol.d dmd/DsymbolExp.d dmd/DsymbolTable.d dmd/DtorDeclaration.d dmd/EnumDeclaration.d dmd/EnumMember.d dmd/EqualExp.d dmd/ErrorExp.d dmd/ExpInitializer.d dmd/ExpStatement.d dmd/Expression.d dmd/File.d dmd/FileExp.d dmd/FileInitExp.d dmd/FileName.d dmd/ForStatement.d dmd/ForeachRangeStatement.d dmd/ForeachStatement.d dmd/FuncAliasDeclaration.d dmd/FuncDeclaration.d dmd/FuncExp.d dmd/FuncLiteralDeclaration.d dmd/Global.d dmd/GotoCaseStatement.d dmd/GotoDefaultStatement.d dmd/GotoStatement.d dmd/HaltExp.d dmd/IRState.d dmd/Identifier.d dmd/IdentifierExp.d dmd/IdentityExp.d dmd/IfStatement.d dmd/Import.d dmd/InExp.d dmd/IndexExp.d dmd/Initializer.d dmd/InlineDoState.d dmd/IntegerExp.d dmd/InterState.d dmd/InterfaceDeclaration.d dmd/InvariantDeclaration.d dmd/IsExp.d dmd/LabelDsymbol.d dmd/LabelStatement.d dmd/Lexer.d dmd/Library.d dmd/LineInitExp.d dmd/LinkDeclaration.d dmd/Loc.d dmd/MinAssignExp.d dmd/MinExp.d dmd/ModAssignExp.d dmd/ModExp.d dmd/Module.d dmd/ModuleDeclaration.d dmd/ModuleInfoDeclaration.d dmd/MulAssignExp.d dmd/MulExp.d dmd/NegExp.d dmd/NewAnonClassExp.d dmd/NewDeclaration.d dmd/NewExp.d dmd/NotExp.d dmd/NullExp.d dmd/OnScopeStatement.d dmd/OrAssignExp.d dmd/OrExp.d dmd/OrOrExp.d dmd/OutBuffer.d dmd/OverExp.d dmd/OverloadSet.d dmd/Package.d dmd/Param.d dmd/Parameter.d dmd/Parser.d dmd/PeelStatement.d dmd/PostBlitDeclaration.d dmd/PostExp.d dmd/PowAssignExp.d dmd/PowExp.d dmd/PragmaDeclaration.d dmd/PragmaStatement.d dmd/ProtDeclaration.d dmd/PtrExp.d dmd/RealExp.d dmd/RemoveExp.d dmd/ReturnStatement.d dmd/Scope.d dmd/ScopeDsymbol.d dmd/ScopeExp.d dmd/ScopeStatement.d dmd/Section.d dmd/ShlAssignExp.d dmd/ShlExp.d dmd/ShrAssignExp.d dmd/ShrExp.d dmd/SliceExp.d dmd/Statement.d dmd/StaticAssert.d dmd/StaticAssertStatement.d dmd/StaticCtorDeclaration.d dmd/StaticDtorDeclaration.d dmd/StaticIfCondition.d dmd/StaticIfDeclaration.d dmd/StorageClassDeclaration.d dmd/String.d dmd/StringEntry.d dmd/StringExp.d dmd/StringTable.d dmd/StringValue.d dmd/StructDeclaration.d dmd/StructInitializer.d dmd/StructLiteralExp.d dmd/SuperExp.d dmd/SwitchErrorStatement.d dmd/SwitchStatement.d dmd/SymOffExp.d dmd/SymbolDeclaration.d dmd/SymbolExp.d dmd/SynchronizedStatement.d dmd/TObject.d dmd/TemplateAliasParameter.d dmd/TemplateDeclaration.d dmd/TemplateExp.d dmd/TemplateInstance.d dmd/TemplateMixin.d dmd/TemplateParameter.d dmd/TemplateThisParameter.d dmd/TemplateTupleParameter.d dmd/TemplateTypeParameter.d dmd/TemplateValueParameter.d dmd/ThisDeclaration.d dmd/ThisExp.d dmd/ThrowStatement.d dmd/TraitsExp.d dmd/TryCatchStatement.d dmd/TryFinallyStatement.d dmd/Tuple.d dmd/TupleDeclaration.d dmd/TupleExp.d dmd/Type.d dmd/TypeAArray.d dmd/TypeArray.d dmd/TypeBasic.d dmd/TypeClass.d dmd/TypeDArray.d dmd/TypeDelegate.d dmd/TypeEnum.d dmd/TypeExp.d dmd/TypeFunction.d dmd/TypeIdentifier.d dmd/TypeInfoArrayDeclaration.d dmd/TypeInfoAssociativeArrayDeclaration.d dmd/TypeInfoClassDeclaration.d dmd/TypeInfoConstDeclaration.d dmd/TypeInfoDeclaration.d dmd/TypeInfoDelegateDeclaration.d dmd/TypeInfoEnumDeclaration.d dmd/TypeInfoFunctionDeclaration.d dmd/TypeInfoInterfaceDeclaration.d dmd/TypeInfoInvariantDeclaration.d dmd/TypeInfoPointerDeclaration.d dmd/TypeInfoSharedDeclaration.d dmd/TypeInfoStaticArrayDeclaration.d dmd/TypeInfoStructDeclaration.d dmd/TypeInfoTupleDeclaration.d dmd/TypeInfoTypedefDeclaration.d dmd/TypeInfoWildDeclaration.d dmd/TypeInstance.d dmd/TypeNewArray.d dmd/TypeNext.d dmd/TypePointer.d dmd/TypeQualified.d dmd/TypeReference.d dmd/TypeReturn.d dmd/TypeSArray.d dmd/TypeSlice.d dmd/TypeStruct.d dmd/TypeTuple.d dmd/TypeTypedef.d dmd/TypeTypeof.d dmd/TypedefDeclaration.d dmd/TypeidExp.d dmd/UAddExp.d dmd/UnaExp.d dmd/UnionDeclaration.d dmd/UnitTestDeclaration.d dmd/UnrolledLoopStatement.d dmd/UshrAssignExp.d dmd/UshrExp.d dmd/Util.d dmd/VarDeclaration.d dmd/VarExp.d dmd/VersionCondition.d dmd/VersionSymbol.d dmd/VoidInitializer.d dmd/VolatileStatement.d dmd/WhileStatement.d dmd/WithScopeSymbol.d dmd/WithStatement.d dmd/XorAssignExp.d dmd/XorExp.d dmd/backend/LIST.d dmd/backend/glue.d dmd/codegen/Util.d main.d
diffstat 280 files changed, 1034 insertions(+), 621 deletions(-) [+]
line wrap: on
line diff
--- a/commands.linux.txt	Sun Oct 10 10:38:55 2010 +0400
+++ b/commands.linux.txt	Sun Oct 17 07:42:00 2010 +0400
@@ -354,6 +354,7 @@
 dmd/TemplateExp.d
 dmd/DotTypeExp.d
 dmd/IndexExp.d
+dmd/TObject.d
 dmd/VarDeclaration.d
 dmd/VersionCondition.d
 dmd/VersionSymbol.d
--- a/commands.txt	Sun Oct 10 10:38:55 2010 +0400
+++ b/commands.txt	Sun Oct 17 07:42:00 2010 +0400
@@ -350,6 +350,7 @@
 dmd\TemplateExp.d
 dmd\DotTypeExp.d
 dmd\IndexExp.d
+dmd\TObject.d
 dmd\VarDeclaration.d
 dmd\VersionCondition.d
 dmd\VersionSymbol.d
--- a/dmd/AddAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AddAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKaddass, AddAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/AddExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AddExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKadd, AddExp.sizeof, e1, e2);
 	}
 
--- a/dmd/AddrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AddrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -36,6 +36,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKaddress, AddrExp.sizeof, e);
 	}
 
--- a/dmd/AggregateDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AggregateDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -181,6 +181,7 @@
 
     this(Loc loc, Identifier id)
 	{
+		register();
 		super(id);
 		this.loc = loc;
 
--- a/dmd/AliasDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AliasDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 
 	this(Loc loc, Identifier ident, Type type)
 	{
+		register();
 		super(ident);
 
 		//printf("AliasDeclaration(id = '%s', type = %p)\n", id.toChars(), type);
@@ -44,6 +45,7 @@
 
 	this(Loc loc, Identifier id, Dsymbol s)
 	{
+		register();
 		super(id);
 
 		//printf("AliasDeclaration(id = '%s', s = %p)\n", id->toChars(), s);
--- a/dmd/AliasThis.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AliasThis.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,6 +16,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(null);		// it's anonymous (no identifier)
 		this.loc = loc;
 		this.ident = ident;
--- a/dmd/AlignDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AlignDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 
     this(uint sa, Dsymbols decl)
 	{
+		register();
 		super(decl);
 		salign = sa;
 	}
--- a/dmd/AndAndExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AndAndExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKandand, AndAndExp.sizeof, e1, e2);
 	}
 
--- a/dmd/AndAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AndAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKandass, AndAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/AndExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AndExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKand, AndExp.sizeof, e1, e2);
 	}
 
--- a/dmd/AnonDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AnonDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,6 +22,7 @@
 
 	this(Loc loc, int isunion, Dsymbols decl)
 	{
+		register();
 		super(decl);
 		this.loc = loc;
 		this.isunion = isunion;
--- a/dmd/AnonymousAggregateDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AnonymousAggregateDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -8,6 +8,7 @@
 {
     this()
     {
+		register();
 		super(Loc(0), null);
     }
 
--- a/dmd/Array.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Array.d	Sun Oct 17 07:42:00 2010 +0400
@@ -7,7 +7,9 @@
 import core.stdc.string;
 import core.stdc.stdlib;
 
-class Array
+import dmd.TObject;
+
+class Array : TObject
 {
 	uint dim = 0;
     uint allocdim = 0;
@@ -182,7 +184,7 @@
 	}
 }
 
-class Vector(T)
+class Vector(T) : TObject
 {
 public:
     @property final size_t dim()
--- a/dmd/ArrayExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ArrayExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
 	this(Loc loc, Expression e1, Expressions args)
 	{
+		register();
 		super(loc, TOK.TOKarray, ArrayExp.sizeof, e1);
 		arguments = args;
 	}
--- a/dmd/ArrayInitializer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ArrayInitializer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,7 @@
 
     this(Loc loc)
 	{
+		register();
 		super(loc);
 		index = new Expressions();
 		value = new Initializers();
--- a/dmd/ArrayLengthExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ArrayLengthExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -38,6 +38,7 @@
 {
 	this(Loc loc, Expression e1)
 	{
+		register();
 		super(loc, TOK.TOKarraylength, ArrayLengthExp.sizeof, e1);
 	}
 
--- a/dmd/ArrayLiteralExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ArrayLiteralExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -40,12 +40,14 @@
 
 	this(Loc loc, Expressions elements)
 	{
+		register();
 		super(loc, TOK.TOKarrayliteral, ArrayLiteralExp.sizeof);
 		this.elements = elements;
 	}
 
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKarrayliteral, ArrayLiteralExp.sizeof);
 		elements = new Expressions();
 		elements.push(e);
--- a/dmd/ArrayScopeSymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ArrayScopeSymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -35,6 +35,7 @@
 
     this(Scope sc, Expression e)
 	{
+		register();
 		super();
 		assert(e.op == TOKindex || e.op == TOKslice);
 		this.exp = e;
@@ -43,6 +44,7 @@
 	
     this(Scope sc, TypeTuple t)
 	{
+		register();
 		exp = null;
 		type = t;
 		td = null;
@@ -51,6 +53,8 @@
 	
     this(Scope sc, TupleDeclaration s)
 	{
+		register();
+
 		exp = null;
 		type = null;
 		td = s;
--- a/dmd/AsmStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AsmStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -49,6 +49,8 @@
 
     this(Loc loc, Token* tokens)
 	{
+		register();
+
 		super(loc);
 		this.tokens = tokens;
 	}
--- a/dmd/AssertExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AssertExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -50,6 +50,8 @@
 
 	this(Loc loc, Expression e, Expression msg = null)
 	{
+		register();
+
 		super(loc, TOK.TOKassert, AssertExp.sizeof, e);
 		this.msg = msg;
 	}
--- a/dmd/AssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -57,6 +57,8 @@
 
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, TOK.TOKassign, AssignExp.sizeof, e1, e2);
 	}
 
--- a/dmd/AssocArrayLiteralExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AssocArrayLiteralExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -36,6 +36,8 @@
 
 	this(Loc loc, Expressions keys, Expressions values)
 	{
+		register();
+
 		super(loc, TOK.TOKassocarrayliteral, this.sizeof);
 		assert(keys.dim == values.dim);
 		this.keys = keys;
--- a/dmd/AttribDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/AttribDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,8 @@
 
     this(Dsymbols decl)
 	{
+		register();
+
 		this.decl = decl;
 	}
 	
--- a/dmd/BaseClass.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/BaseClass.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,13 +10,16 @@
 import dmd.Dsymbol;
 import dmd.FuncDeclaration;
 import dmd.ArrayTypes;
+import dmd.Util;
 
 import core.stdc.stdlib;
 import core.stdc.string;
 
 import core.memory;
 
-class BaseClass
+import dmd.TObject;
+
+class BaseClass : TObject
 {
     Type type;				// (before semantic processing)
     PROT protection;		// protection for the base interface
@@ -32,15 +35,19 @@
 
     this()
 	{
+		register();
+
 		vtbl = new Array();
 	}
 
     this(Type type, PROT protection)
 	{
+		register();
+
 		//printf("BaseClass(this = %p, '%s')\n", this, type->toChars());
 		this.type = type;
 		this.protection = protection;
-		
+
 		vtbl = new Array();
 	}
 
@@ -109,7 +116,7 @@
 
 		return result;
 	}
-	
+
     void copyBaseInterfaces(BaseClasses vtblInterfaces)
 	{
 		//printf("+copyBaseInterfaces(), %s\n", base.toChars());
@@ -118,18 +125,13 @@
 
 		baseInterfaces.length = base.interfaces_dim;
 
-		int size = BaseClass.classinfo.init.length;
-
 		//printf("%s.copyBaseInterfaces()\n", base.toChars());
 		for (int i = 0; i < baseInterfaces.length; i++)
 		{
 			BaseClass b2 = base.interfaces[i];
 			assert(b2.vtbl.dim == 0);	// should not be filled yet
 
-			void* mem = GC.malloc(size);
-			memcpy(mem, cast(void*)b2, size);
-
-			BaseClass b = cast(BaseClass)mem;
+			BaseClass b = cloneThis(b2);
 			baseInterfaces[i] = b;
 
 			if (i)				// single inheritance is i==0
@@ -138,4 +140,4 @@
 		}
 		//printf("-copyBaseInterfaces\n");
 	}
-}
\ No newline at end of file
+}
--- a/dmd/BinExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/BinExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -394,6 +394,8 @@
 
     this(Loc loc, TOK op, int size, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, op, size);
 		this.e1 = e1;
 		this.e2 = e2;
@@ -1485,8 +1487,9 @@
 
 		/* Look up name in hash table
 		 */
-		StringValue* sv = global.arrayfuncs.update(name[0..namelen]);
-		FuncDeclaration fd = cast(FuncDeclaration)sv.ptrvalue;
+        auto s = name[0..namelen];
+		Object* sv = global.arrayfuncs.update(s);
+		FuncDeclaration fd = cast(FuncDeclaration)*sv;
 		if (!fd)
 		{
 			/* Some of the array op functions are written as library functions,
@@ -1701,7 +1704,7 @@
 				 */
 				TypeFunction ftype = new TypeFunction(fparams, type, 0, LINKc);
 				//printf("ftype: %s\n", ftype.toChars());
-				fd = new FuncDeclaration(Loc(0), Loc(0), Lexer.idPool(name[0..namelen]), STCundefined, ftype);
+				fd = new FuncDeclaration(Loc(0), Loc(0), Lexer.idPool(s), STCundefined, ftype);
 				fd.fbody = fbody;
 				fd.protection = PROT.PROTpublic;
 				fd.linkage = LINKc;
@@ -1720,9 +1723,9 @@
 			else
 			{   /* In library, refer to it.
 				 */
-				fd = FuncDeclaration.genCfunc(type, name[0..namelen]);
+				fd = FuncDeclaration.genCfunc(type, s);
 			}
-			sv.ptrvalue = cast(void*)fd;	// cache symbol in hash table
+			*sv = fd;	// cache symbol in hash table
 		}
 
 		/* Call the function fd(arguments)
--- a/dmd/BoolExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/BoolExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,8 @@
 {
 	this(Loc loc, Expression e, Type t)
 	{
+		register();
+
 		super(loc, TOKtobool, BoolExp.sizeof, e);
 		type = t;
 	}
--- a/dmd/BreakStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/BreakStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,8 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
+
 		super(loc);
 		this.ident = ident;
 	}
--- a/dmd/CallExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CallExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -82,17 +82,23 @@
 
 	this(Loc loc, Expression e, Expressions exps)
 	{
+		register();
+
 		super(loc, TOK.TOKcall, CallExp.sizeof, e);
 		this.arguments = exps;
 	}
 
 	this(Loc loc, Expression e)
 	{
+		register();
+
 		super(loc, TOK.TOKcall, CallExp.sizeof, e);
 	}
 
 	this(Loc loc, Expression e, Expression earg1)
 	{
+		register();
+
 		super(loc, TOK.TOKcall, CallExp.sizeof, e);
 		
 		auto arguments = new Expressions();
@@ -106,6 +112,8 @@
 
 	this(Loc loc, Expression e, Expression earg1, Expression earg2)
 	{
+		register();
+
 		super(loc, TOK.TOKcall, CallExp.sizeof, e);
 		
 		auto arguments = new Expressions();
--- a/dmd/CaseRangeStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CaseRangeStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,8 @@
 
     this(Loc loc, Expression first, Expression last, Statement s)
 	{
+		register();
+
 		super(loc);
 		this.first = first;
 		this.last = last;
--- a/dmd/CaseStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CaseStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,8 @@
 
     this(Loc loc, Expression exp, Statement s)
 	{
+		register();
+
 		super(loc);
 		
 		this.exp = exp;
--- a/dmd/CastExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CastExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -53,6 +53,8 @@
 
 	this(Loc loc, Expression e, Type t)
 	{
+		register();
+
 		super(loc, TOK.TOKcast, CastExp.sizeof, e);
 		to = t;
 		this.mod = cast(MOD)~0;
@@ -60,6 +62,8 @@
 
 	this(Loc loc, Expression e, MOD mod)
 	{
+		register();
+
 		super(loc, TOK.TOKcast, CastExp.sizeof, e);
 		to = null;
 		this.mod = mod;
--- a/dmd/CatAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CatAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,6 +28,8 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, TOK.TOKcatass, CatAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/CatExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CatExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -31,6 +31,8 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, TOK.TOKcat, CatExp.sizeof, e1, e2);
 	}
 
--- a/dmd/Catch.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Catch.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,7 +15,9 @@
 import dmd.HdrGenState;
 import dmd.BE;
 
-class Catch
+import dmd.TObject;
+
+class Catch : TObject
 {
     Loc loc;
     Type type;
@@ -25,6 +27,8 @@
 
     this(Loc loc, Type t, Identifier id, Statement handler)
 	{
+		register();
+
 		//printf("Catch(%s, loc = %s)\n", id.toChars(), loc.toChars());
 		this.loc = loc;
 		this.type = t;
--- a/dmd/ClassDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ClassDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -116,6 +116,8 @@
 
     this(Loc loc, Identifier id, BaseClasses baseclasses)
 	{
+		register();
+
 		super(loc, id);
 
 		vtbl = new Array();
--- a/dmd/ClassInfoDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ClassInfoDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,8 @@
 
 	this(ClassDeclaration cd)
 	{
+		register();
+
 		super(Loc(0), global.classinfo.type, cd.ident, null);
 		
 		this.cd = cd;
--- a/dmd/CmpExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CmpExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,6 +33,8 @@
 {
 	this(TOK op, Loc loc, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, op, CmpExp.sizeof, e1, e2);
 	}
 
--- a/dmd/ComExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ComExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,8 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
+
 		super(loc, TOKtilde, ComExp.sizeof, e);
 	}
 
--- a/dmd/CommaExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CommaExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,8 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
+
 		super(loc, TOK.TOKcomma, CommaExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/CompileDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CompileDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,6 +28,8 @@
 
 	this(Loc loc, Expression exp)
 	{
+		register();
+
 		super(null);
 		//printf("CompileDeclaration(loc = %d)\n", loc.linnum);
 		this.loc = loc;
--- a/dmd/CompileExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CompileExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKmixin, this.sizeof, e);
 	}
 
--- a/dmd/CompileStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CompileStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,7 @@
 
 	this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
--- a/dmd/ComplexExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ComplexExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,6 +28,7 @@
 
 	this(Loc loc, Complex!(real) value, Type type)
 	{
+		register();
 		super(loc, TOK.TOKcomplex80, ComplexExp.sizeof);
 		this.value = value;
 		this.type = type;
--- a/dmd/CompoundDeclarationStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CompoundDeclarationStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
     this(Loc loc, Statements s)
 	{
+		register();
 		super(loc, s);
 		///statements = s;
 	}
--- a/dmd/CompoundStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CompoundStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,12 +33,14 @@
 
     this(Loc loc, Statements s)
 	{
+		register();
 		super(loc);
 		statements = s;
 	}
 	
     this(Loc loc, Statement s1, Statement s2)
 	{
+		register();
 		super(loc);
 		
 		statements = new Statements();
--- a/dmd/CondExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CondExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,7 @@
 
     this(Loc loc, Expression econd, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKquestion, CondExp.sizeof, e1, e2);
 		this.econd = econd;
 	}
--- a/dmd/Condition.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Condition.d	Sun Oct 17 07:42:00 2010 +0400
@@ -7,7 +7,9 @@
 import dmd.OutBuffer;
 import dmd.HdrGenState;
 
-class Condition
+import dmd.TObject;
+
+class Condition : TObject
 {
     Loc loc;
     int inc = 0;// 0: not computed yet
@@ -16,6 +18,7 @@
 
     this(Loc loc)
 	{
+		register();
 		this.loc = loc;
 	}
 
--- a/dmd/ConditionalDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ConditionalDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -17,6 +17,7 @@
 
     this(Condition condition, Dsymbols decl, Dsymbols elsedecl)
 	{
+		register();
 		super(decl);
 		//printf("ConditionalDeclaration.ConditionalDeclaration()\n");
 		this.condition = condition;
--- a/dmd/ConditionalStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ConditionalStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 
     this(Loc loc, Condition condition, Statement ifbody, Statement elsebody)
 	{
+		register();
 		super(loc);
 		this.condition = condition;
 		this.ifbody = ifbody;
--- a/dmd/ContinueStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ContinueStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(loc);
 		this.ident = ident;
 	}
--- a/dmd/CtorDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/CtorDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
     this(Loc loc, Loc endloc, Parameters arguments, int varargs)
 	{
+		register();
 		super(loc, endloc, Id.ctor, STC.STCundefined, null);
 		
 		this.arguments = arguments;
--- a/dmd/DVCondition.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DVCondition.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 
     this(Module mod, uint level, Identifier ident)
 	{
+		register();
 		super(Loc(0));
 		this.mod = mod;
 		this.level = level;
--- a/dmd/DebugCondition.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DebugCondition.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,6 +33,7 @@
 
     this(Module mod, uint level, Identifier ident)
 	{
+		register();
 		super(mod, level, ident);
 	}
 
--- a/dmd/DebugSymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DebugSymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,12 +23,14 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(ident);
 		this.loc = loc;
 	}
 
     this(Loc loc, uint level)
 	{
+		register();
 		this.level = level;
 		this.loc = loc;
 	}
--- a/dmd/Declaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Declaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -89,6 +89,7 @@
 
     this(Identifier id)
 	{
+		register();
 		super(id);
 	}
 	
--- a/dmd/DeclarationExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DeclarationExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -9,6 +9,7 @@
 import dmd.Loc;
 import dmd.STC;
 import dmd.Scope;
+import dmd.Util;
 import dmd.InlineCostState;
 import dmd.IRState;
 import dmd.InlineDoState;
@@ -33,6 +34,7 @@
 
 	this(Loc loc, Dsymbol declaration)
 	{
+		register();
 		super(loc, TOK.TOKdeclaration, DeclarationExp.sizeof);
 		this.declaration = declaration;
 	}
@@ -65,7 +67,7 @@
 		}
 
 		if (s.isVarDeclaration())
-		{	
+		{
 			// Do semantic() on initializer first, so:
 			//	int a = a;
 			// will be illegal.
@@ -81,16 +83,16 @@
 			if (!sc.insert(s))
 				error("declaration %s is already defined", s.toPrettyChars());
 			else if (sc.func)
-			{   
+			{
 				VarDeclaration v = s.isVarDeclaration();
 				if (s.isFuncDeclaration() && !sc.func.localsymtab.insert(s))
 					error("declaration %s is already defined in another scope in %s", s.toPrettyChars(), sc.func.toChars());
 				else if (!global.params.useDeprecated)
-				{	
+				{
 					// Disallow shadowing
 
 					for (Scope scx = sc.enclosing; scx && scx.func is sc.func; scx = scx.enclosing)
-					{   
+					{
 						Dsymbol s2;
 
 						if (scx.scopesym && scx.scopesym.symtab && (s2 = scx.scopesym.symtab.lookup(s.ident)) !is null && s !is s2)
@@ -152,7 +154,7 @@
 ///} else {
 ///			else if (s == v && v.isConst() && v.init)
 ///}
-			{   
+			{
 				e = v.init.toExpression();
 				if (!e)
 					e = EXP_CANT_INTERPRET;
@@ -163,7 +165,7 @@
 		else if (declaration.isAttribDeclaration() ||
 			 declaration.isTemplateMixin() ||
 			 declaration.isTupleDeclaration())
-		{	
+		{
 			// These can be made to work, too lazy now
 			error("Declaration %s is not yet implemented in CTFE", toChars());
 
@@ -207,7 +209,7 @@
 	{
 		VarDeclaration v = declaration.isVarDeclaration();
 		if (v && v.init)
-		{	
+		{
 			ExpInitializer ie = v.init.isExpInitializer();
 			return ie && ie.exp.canThrow();
 		}
@@ -290,7 +292,7 @@
 		if (td)
 		{
 			for (size_t i = 0; i < td.objects.dim; i++)
-			{   
+			{
 				DsymbolExp se = cast(DsymbolExp)td.objects.data[i];
 				assert(se.op == TOKdsymbol);
 				se.s;
@@ -304,11 +306,8 @@
 		}
 		else
 		{
-			VarDeclaration vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd.init);
-			
-			///*vto = *vd;
-			memcpy(cast(void*)vto, cast(void*)vd, VarDeclaration.classinfo.init.length);
-			
+			VarDeclaration vto = cloneThis(vd);
+
 			vto.parent = ids.parent;
 			vto.csym = null;
 			vto.isym = null;
--- a/dmd/DeclarationStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DeclarationStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,11 +20,13 @@
 
     this(Loc loc, Dsymbol declaration)
 	{
+		register();
 		super(loc, new DeclarationExp(loc, declaration));
 	}
 	
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc, exp);
 	}
 	
--- a/dmd/DefaultInitExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DefaultInitExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
 	this(Loc loc, TOK subop, int size)
 	{
+		register();
 		super(loc, TOKdefault, size);
 		this.subop = subop;
 	}
--- a/dmd/DefaultStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DefaultStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 
     this(Loc loc, Statement s)
 	{
+		register();
 		super(loc);
 		this.statement = s;
 	}
--- a/dmd/DelegateExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DelegateExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,6 +33,7 @@
 
 	this(Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = false)
 	{
+		register();
 		super(loc, TOK.TOKdelegate, DelegateExp.sizeof, e);
 		this.func = f;
 		this.hasOverloads = hasOverloads;
--- a/dmd/DeleteDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DeleteDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 
     this(Loc loc, Loc endloc, Parameters arguments)
 	{
+		register();
 		super(loc, endloc, Id.classDelete, STCstatic, null);
 		this.arguments = arguments;
 	}
--- a/dmd/DeleteExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DeleteExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -45,6 +45,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKdelete, DeleteExp.sizeof, e);
 	}
 
--- a/dmd/DivAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DivAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKdivass, DivAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/DivExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DivExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKdiv, DivExp.sizeof, e1, e2);
 	}
 
--- a/dmd/DoStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DoStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
     this(Loc loc, Statement b, Expression c)
 	{
+		register();
 		super(loc);
 		body_ = b;
 		condition = c;
--- a/dmd/DocComment.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DocComment.d	Sun Oct 17 07:42:00 2010 +0400
@@ -9,7 +9,9 @@
 import dmd.Dsymbol;
 import dmd.OutBuffer;
 
-class DocComment
+import dmd.TObject;
+
+class DocComment : TObject
 {
     Array sections;		// Section*[]
 
@@ -21,6 +23,7 @@
 
     this()
 	{
+		register();
 		assert(false);
 	}
 
--- a/dmd/DollarExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DollarExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -11,6 +11,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc, Id.dollar);
 	}
 }
--- a/dmd/DotExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DotExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOKdotexp, DotExp.sizeof, e1, e2);
 	}
 
--- a/dmd/DotIdExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DotIdExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -50,6 +50,7 @@
 
 	this(Loc loc, Expression e, Identifier ident)
 	{
+		register();
 		super(loc, TOK.TOKdot, DotIdExp.sizeof, e);
 		this.ident = ident;
 	}
--- a/dmd/DotTemplateExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DotTemplateExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 
 	this(Loc loc, Expression e, TemplateDeclaration td)
 	{
+		register();
 		super(loc, TOK.TOKdottd, this.sizeof, e);
 		this.td = td;
 	}
--- a/dmd/DotTemplateInstanceExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DotTemplateInstanceExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -40,6 +40,7 @@
 
 	this(Loc loc, Expression e, Identifier name, Objects tiargs)
 	{
+		register();
 		super(loc, TOK.TOKdotti, DotTemplateInstanceExp.sizeof, e);
 		//printf("DotTemplateInstanceExp()\n");
 		this.ti = new TemplateInstance(loc, name);
--- a/dmd/DotTypeExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DotTypeExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,6 +22,7 @@
 
 	this(Loc loc, Expression e, Dsymbol s)
 	{
+		register();
 		super(loc, TOK.TOKdottype, DotTypeExp.sizeof, e);
 		this.sym = s;
 		this.type = s.getType();
--- a/dmd/Dsymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Dsymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -134,7 +134,9 @@
 
 alias Vector!Dsymbol Dsymbols;
 
-class Dsymbol
+import dmd.TObject;
+
+class Dsymbol : TObject
 {
     Identifier ident;
     Identifier c_ident;
@@ -147,11 +149,13 @@
 
     this()
 	{
+		register();
 		// do nothing
 	}
 	
     this(Identifier ident)
 	{
+		register();
 		this.ident = ident;
 	}
 
--- a/dmd/DsymbolExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DsymbolExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -43,6 +43,7 @@
 
 	this(Loc loc, Dsymbol s, bool hasOverloads = false)
 	{
+		register();
 		super(loc, TOK.TOKdsymbol, DsymbolExp.sizeof);
 		this.s = s;
 		this.hasOverloads = hasOverloads;
--- 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
+}
--- a/dmd/DtorDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/DtorDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,11 +20,13 @@
 {
 	this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, Id.dtor, STCundefined, null);
 	}
 
 	this(Loc loc, Loc endloc, Identifier id)
 	{
+		register();
 		super(loc, endloc, id, STCundefined, null);
 	}
 
--- a/dmd/EnumDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/EnumDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -64,6 +64,7 @@
     
     this(Loc loc, Identifier id, Type memtype)
 	{
+		register();
 		super(id);
 		this.loc = loc;
 		type = new TypeEnum(this);
--- a/dmd/EnumMember.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/EnumMember.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 
 	this(Loc loc, Identifier id, Expression value, Type type)
 	{
+		register();
 		super(id);
 
 		this.value = value;
--- a/dmd/EqualExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/EqualExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,7 @@
 {
 	this(TOK op, Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, op, EqualExp.sizeof, e1, e2);
 		assert(op == TOK.TOKequal || op == TOK.TOKnotequal);
 	}
--- a/dmd/ErrorExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ErrorExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,6 +16,7 @@
 {
 	this()
 	{
+		register();
 		super(Loc(0), 0, Type.terror);
 	    op = TOKerror;
 	}
--- a/dmd/ExpInitializer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ExpInitializer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
--- a/dmd/ExpStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ExpStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,10 +28,17 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
 	
+	/*
+	~this()
+	{
+		delete exp;
+	}
+	*/
     override Statement syntaxCopy()
 	{
 		Expression e = exp ? exp.syntaxCopy() : null;
--- a/dmd/Expression.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Expression.d	Sun Oct 17 07:42:00 2010 +0400
@@ -183,7 +183,9 @@
     return type ? type.toChars() : "null";
 }
 
-class Expression
+import dmd.TObject;
+
+class Expression : TObject
 {
     Loc loc;			// file location
     TOK op;		// handy to minimize use of dynamic_cast
@@ -192,6 +194,7 @@
 
     this(Loc loc, TOK op, int size)
 	{
+		register();
 		this.loc = loc;
 		//writef("Expression.Expression(op = %d %s) this = %p\n", op, to!(string)(op), this);
 		this.op = op;
@@ -207,23 +210,9 @@
 	/*********************************
 	 * Does *not* do a deep copy.
 	 */
-    Expression copy()	/// bad bad bad
+    Expression copy()
 	{
-		Expression e;
-		if (!size)
-		{
-debug {
-			writef("No expression copy for: %s\n", toChars());
-			writef("op = %d\n", op);
-			dump(0);
-}
-			assert(0);
-		}
-		auto size = this.classinfo.init.length;
-		auto ptr = GC.malloc(size);
-		memcpy(ptr, cast(void*)this, size);
-
-		return cast(Expression)ptr;
+		return cloneThis(this);
 	}
 	
     Expression syntaxCopy()
--- a/dmd/File.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/File.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,7 +24,9 @@
 
 import core.memory;
 
-class File
+import dmd.TObject;
+
+class File : TObject
 {
     int ref_;					// != 0 if this is a reference to someone else's buffer
     ubyte* buffer;				// data for our file
@@ -35,11 +37,13 @@
 
     this(string n)
 	{
+		register();
 		name = new FileName(n);
 	}
 
     this(FileName n)
 	{
+		register();
 		name = n;
 	}
 
--- a/dmd/FileExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FileExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOKmixin, FileExp.sizeof, e);
 	}
 
--- a/dmd/FileInitExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FileInitExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc, TOK.TOKfile, this.sizeof);
 	}
 
--- a/dmd/FileName.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FileName.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,11 +32,13 @@
 {
     this(string str)
 	{
+		register();
 		super(str);
 	}
 
     this(string path, string name)
 	{
+		register();
 		super(combine(path, name));
 	}
 
--- a/dmd/ForStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ForStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
     this(Loc loc, Statement init, Expression condition, Expression increment, Statement body_)
 	{
+		register();
 		super(loc);
 		
 		this.init = init;
--- a/dmd/ForeachRangeStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ForeachRangeStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -46,6 +46,7 @@
 
     this(Loc loc, TOK op, Parameter arg, Expression lwr, Expression upr, Statement body_)
 	{
+		register();
 		super(loc);
 		this.op = op;
 		this.arg = arg;
--- a/dmd/ForeachStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ForeachStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -88,6 +88,7 @@
 
     this(Loc loc, TOK op, Parameters arguments, Expression aggr, Statement body_)
 	{
+		register();
 		super(loc);
 		
 		this.op = op;
--- a/dmd/FuncAliasDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FuncAliasDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
     this(FuncDeclaration funcalias)
 	{
+		register();
 		super(funcalias.loc, funcalias.endloc, funcalias.ident, funcalias.storage_class, funcalias.type);
 		assert(funcalias !is this);
 		this.funcalias = funcalias;
--- a/dmd/FuncDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FuncDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -197,6 +197,7 @@
 
     this(Loc loc, Loc endloc, Identifier id, StorageClass storage_class, Type type)
 	{
+		register();
 		super(id);
 
 		//printf("FuncDeclaration(id = '%s', type = %p)\n", id.toChars(), type);
--- a/dmd/FuncExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FuncExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,6 +28,7 @@
 
 	this(Loc loc, FuncLiteralDeclaration fd)
 	{
+		register();
 		super(loc, TOK.TOKfunction, FuncExp.sizeof);
 		this.fd = fd;
 	}
--- a/dmd/FuncLiteralDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/FuncLiteralDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 
     this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes)
 	{
+		register();
 		super(loc, endloc, null, STC.STCundefined, type);
 		
 		string id;
--- a/dmd/Global.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Global.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,6 +10,8 @@
 import dmd.Token;
 import dmd.Scope;
 import dmd.Module;
+import dmd.Expression;
+import dmd.Dsymbol;
 import dmd.Type;
 import dmd.TypeInfoDeclaration;
 import dmd.Id;
@@ -31,7 +33,9 @@
 import core.stdc.time;
 import core.stdc.stdio;
 
-class Global
+import dmd.TObject;
+
+class Global : TObject
 {
     string mars_ext = "d";
     string sym_ext	= "d";
@@ -152,26 +156,26 @@
 
 	// Used in TypeDelegate
 	Symbol* Delegate_s;
-	
+
 	// Used in TypeInfoStructDeclaration
 	TypeFunction tftohash;
 	TypeFunction tftostring;
-	
+
 	// Used in backend.glue
 	Array obj_symbols_towrite;
 	Outbuffer objbuf;
 	string lastmname;
 	int count;
-	
+
 	// Used in backend.iasm
 	ASM_STATE asmstate;
 	Token* asmtok;
 	TOK tok_value;
-	
+
 	// Used in backend.StringTab
 	StringTab[STSIZE] stringTab;
 	size_t stidx;
-	
+
 	// Used in backend.Util
 	elem* eictor;
 	Symbol* ictorlocalgot;
@@ -182,36 +186,39 @@
 	int dtorcount;
 	Symbol* localgot;
 
+    Dsymbol sdummy;
+	Expression edummy;
+
 	this()
 	{
-		params.versionids = new Array();
+	    register();
+
+		params.versionids = new Vector!(string)();
 		params.imppath = new Array();
 
 		st = new DsymbolTable();
-		stringtable = new StringTable();
 		stringbuffer = new OutBuffer();
 
 		modules = new DsymbolTable();
 		amodules = new Array();
 		deferred = new Array();
 
-		type_stringtable = new StringTable();
+		sarray = new Array();
 
-		arrayfuncs = new StringTable();
+		obj_symbols_towrite = new Array();
 
-		sarray = new Array();
-		
-		obj_symbols_towrite = new Array();
-		
 		ectorgates = new Array();
-		
+
+		sdummy = new Dsymbol();
+		edummy = new Expression(Loc(0), TOK.init, 0);
+
 		init_time();
 	}
 
 	void initClasssym()
 	{
 		scc = fake_classsym(Id.ClassInfo);
-		
+
 		scope Scope sc = new Scope();
 
 		tftohash = new TypeFunction(null, Type.thash_t, 0, LINK.LINKd);
--- a/dmd/GotoCaseStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/GotoCaseStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		cs = null;
 		this.exp = exp;
--- a/dmd/GotoDefaultStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/GotoDefaultStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 
     this(Loc loc)
 	{
+		register();
 		super(loc);
 		sw = null;
 	}
--- a/dmd/GotoStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/GotoStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -31,6 +31,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(loc);
 		this.ident = ident;
 	}
--- a/dmd/HaltExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/HaltExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc, TOK.TOKhalt, HaltExp.sizeof);
 	}
 
--- a/dmd/IRState.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IRState.d	Sun Oct 17 07:42:00 2010 +0400
@@ -56,12 +56,12 @@
 			deferToObj = irs.deferToObj;
 		}
 	}
-	
+
     this(IRState* irs, Dsymbol s)
 	{
 		assert(false);
 	}
-	
+
     this(Module m, Dsymbol s)
 	{
 		this.m = m;
@@ -82,7 +82,7 @@
 		}
 		return null;
 	}
-	
+
     block* getContBlock(Identifier ident)
 	{
 		IRState* bc;
@@ -99,7 +99,7 @@
 		}
 		return null;
 	}
-	
+
     block* getSwitchBlock()
 	{
 		for (IRState* bc = &this; bc; bc = bc.prev)
@@ -109,7 +109,7 @@
 		}
 		return null;
 	}
-	
+
     block* getDefaultBlock()
 	{
 		for (IRState* bc = &this; bc; bc = bc.prev)
@@ -119,7 +119,7 @@
 		}
 		return null;
 	}
-	
+
     FuncDeclaration getFunc()
 	{
 		IRState* bc;
@@ -195,4 +195,4 @@
     {
 		block_appendexp(irs.blx.curblock, incUsageElem(irs, loc));
     }
-}
\ No newline at end of file
+}
--- a/dmd/Identifier.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Identifier.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,13 +10,16 @@
 
 import std.string;
 
-class Identifier
+import dmd.TObject;
+
+class Identifier : TObject
 {
     TOK value;
     string string_;
 
     this(string string_, TOK value)
 	{
+		register();
 		this.string_ = string_;
 		this.value = value;
 	}
--- a/dmd/IdentifierExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IdentifierExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,12 +30,14 @@
 
 	this(Loc loc, Identifier ident)
 	{
+		register();
 		super(loc, TOK.TOKidentifier, IdentifierExp.sizeof);
 		this.ident = ident;
 	}
 
 	this(Loc loc, Declaration var)
 	{
+		register();
 		assert(false);
 		super(loc, TOK.init, 0);
 	}
--- a/dmd/IdentityExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IdentityExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
 	this(TOK op, Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, op, IdentityExp.sizeof, e1, e2);
 	}
 
--- a/dmd/IfStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IfStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -42,6 +42,7 @@
 
     this(Loc loc, Parameter arg, Expression condition, Statement ifbody, Statement elsebody)
 	{
+		register();
 		super(loc);
 		this.arg = arg;
 		this.condition = condition;
--- a/dmd/Import.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Import.d	Sun Oct 17 07:42:00 2010 +0400
@@ -58,6 +58,7 @@
 
 	this(Loc loc, Identifiers packages, Identifier id, Identifier aliasId, int isstatic)
 	{
+		register();
 		super(id);
 		
 		names = new Array();
--- a/dmd/InExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/InExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOKin, InExp.sizeof, e1, e2);
 	}
 
--- a/dmd/IndexExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IndexExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -12,6 +12,7 @@
 import dmd.Type;
 import dmd.ScopeDsymbol;
 import dmd.TY;
+import dmd.Util;
 import dmd.ArrayScopeSymbol;
 import dmd.PREC;
 import dmd.TypeNext;
@@ -55,6 +56,7 @@
 
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKindex, IndexExp.sizeof, e1, e2);
 		//printf("IndexExp.IndexExp('%s')\n", toChars());
 	}
@@ -82,7 +84,7 @@
 		t1 = e1.type.toBasetype();
 
 		if (t1.ty == Tsarray || t1.ty == Tarray || t1.ty == Ttuple)
-		{	
+		{
 			// Create scope for 'length' variable
 			sym = new ArrayScopeSymbol(sc, this);
 			sym.loc = loc;
@@ -132,7 +134,7 @@
 			}
 
 			case Taarray:
-			{   
+			{
 				TypeAArray taa = cast(TypeAArray)t1;
 				if (!arrayTypeCompatible(e2.loc, e2.type, taa.index))
 				{
@@ -152,7 +154,7 @@
 				TypeTuple tup;
 
 				if (e1.op == TOKtuple)
-				{	
+				{
 					te = cast(TupleExp)e1;
 					length = te.exps.dim;
 				}
@@ -229,10 +231,10 @@
 		Expression e1 = this.e1.optimize(WANTvalue | (result & WANTinterpret));
 		e1 = fromConstInitializer(result, e1);
 		if (this.e1.op == TOKvar)
-		{	
+		{
 			VarExp ve = cast(VarExp)this.e1;
 			if (ve.var.storage_class & STCmanifest)
-			{   
+			{
 				/* We generally don't want to have more than one copy of an
 				 * array literal, but if it's an enum we have to because the
 				 * enum isn't stored elsewhere. See Bugzilla 2559
@@ -295,9 +297,8 @@
 			ExpInitializer ieto;
 			VarDeclaration vto;
 
-			vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd.init);
-			///*vto = *vd;
-			memcpy(cast(void*)vto, cast(void*)vd, VarDeclaration.classinfo.init.length);
+			vto = cloneThis(vd);
+
 			vto.parent = ids.parent;
 			vto.csym = null;
 			vto.isym = null;
@@ -324,7 +325,7 @@
 		e1.scanForNestedRef(sc);
 
 		if (lengthVar)
-		{	
+		{
 			//printf("lengthVar\n");
 			lengthVar.parent = sc.parent;
 		}
@@ -391,7 +392,7 @@
 
 				// Construct: ((e || ModuleAssert(line)),n)
 				Symbol* sassert = irs.blx.module_.toModuleArray();
-				
+
 				ea = el_bin(OPcall,TYvoid,el_var(sassert),
 				el_long(TYint, loc.linnum));
 				e = el_bin(OPoror,TYvoid,e,ea);
@@ -402,7 +403,7 @@
 				e.Enumbytes = cast(uint)type.size();
 		}
 		else
-		{	
+		{
 			elem* einit = resolveLengthVar(lengthVar, &n1, t1);
 			elem* n2 = e2.toElem(irs);
 
@@ -442,7 +443,7 @@
 
 			n1 = array_toPtr(t1, n1);
 
-			{   
+			{
 				elem* escale;
 
 				escale = el_long(TYint, t1.nextOf().size());
@@ -450,7 +451,7 @@
 				e = el_bin(OPadd, TYnptr, n1, n2);
 				e = el_una(OPind, type.totym(), e);
 				if (tybasic(e.Ety) == TYstruct || tybasic(e.Ety) == TYarray)
-				{	
+				{
 					e.Ety = TYstruct;
 					e.Enumbytes = cast(uint)type.size();
 				}
--- a/dmd/Initializer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Initializer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,12 +16,15 @@
 
 import dmd.backend.dt_t;
 
-class Initializer
+import dmd.TObject;
+
+class Initializer : TObject
 {
     Loc loc;
 
     this(Loc loc)
 	{
+		register();
 		this.loc = loc;
 	}
 	
--- a/dmd/InlineDoState.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/InlineDoState.d	Sun Oct 17 07:42:00 2010 +0400
@@ -7,7 +7,9 @@
 import dmd.Expression;
 import dmd.ArrayTypes;
 
-class InlineDoState
+import dmd.TObject;
+
+class InlineDoState : TObject
 {
     VarDeclaration vthis;
     Array from;		// old Dsymbols
@@ -16,6 +18,7 @@
 	
 	this()
 	{
+		register();
 		from = new Array();
 		to = new Array();
 	}
--- a/dmd/IntegerExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IntegerExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -31,6 +31,7 @@
 
 	this(Loc loc, ulong value, Type type)
 	{
+		register();
 		super(loc, TOK.TOKint64, IntegerExp.sizeof);
 		
 		//printf("IntegerExp(value = %lld, type = '%s')\n", value, type ? type.toChars() : "");
@@ -46,6 +47,7 @@
 
 	this(ulong value)
 	{
+		register();
 		super(Loc(0), TOK.TOKint64, IntegerExp.sizeof);
 		this.type = Type.tint32;
 		this.value = value;
--- a/dmd/InterState.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/InterState.d	Sun Oct 17 07:42:00 2010 +0400
@@ -6,10 +6,13 @@
 import dmd.Expression;
 import dmd.Statement;
 
-class InterState
+import dmd.TObject;
+
+class InterState : TObject
 {
 	this()
 	{
+		register();
 		vars = new Dsymbols();
 	}
 	
--- a/dmd/InterfaceDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/InterfaceDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -39,6 +39,7 @@
 }
     this(Loc loc, Identifier id, BaseClasses baseclasses)
 	{
+		register();
 		super(loc, id, baseclasses);
 
 		if (id is Id.IUnknown)	// IUnknown is the root of all COM interfaces
--- a/dmd/InvariantDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/InvariantDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 {
     this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, Id.classInvariant, STCundefined, null);
 	}
 
--- a/dmd/IsExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/IsExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -45,6 +45,7 @@
 
 	this(Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters parameters)
 	{
+		register();
 		super(loc, TOK.TOKis, IsExp.sizeof);
 		
 		this.targ = targ;
--- a/dmd/LabelDsymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/LabelDsymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
     this(Identifier ident)
 	{
+		register();
 		super(ident);
 	}
 	
--- a/dmd/LabelStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/LabelStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -34,6 +34,7 @@
 
     this(Loc loc, Identifier ident, Statement statement)
 	{
+		register();
 		super(loc);
 		this.ident = ident;
 		this.statement = statement;
--- a/dmd/Lexer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Lexer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -340,7 +340,9 @@
 	return true;
 }
 
-class Lexer
+import dmd.TObject;
+
+class Lexer : TObject
 {
     Loc loc;			// for error messages
 
@@ -355,8 +357,9 @@
 
     this(Module mod, ubyte* base, uint begoffset, uint endoffset, int doDocComment, int commentToken)
 	{
+		register();
 		loc = Loc(mod, 1);
-		
+
 		memset(&token,0,token.sizeof);
 		this.base = base;
 		this.end  = base + endoffset;
@@ -374,7 +377,7 @@
 		{
 			p += 2;
 			while (1)
-			{  
+			{
 				ubyte c = *p;
 				switch (c)
 				{
@@ -658,7 +661,7 @@
 	enum CMoctal =	0x1;
 	enum  CMhex =	0x2;
 	enum  CMidchar =	0x4;
-	
+
 	ubyte isoctal (ubyte c) { return cmtable[c] & CMoctal; }
 	ubyte ishex   (ubyte c) { return cmtable[c] & CMhex; }
 	ubyte isidchar(ubyte c) { return cmtable[c] & CMidchar; }
@@ -675,17 +678,17 @@
 				cmtable[c] |= CMidchar;
 		}
 	}
-	
-	static StringTable stringtable()
+
+	static ref StringTable stringtable()
 	{
 		return global.stringtable;
 	}
-	
+
 	static OutBuffer stringbuffer()
 	{
 		return global.stringbuffer;
 	}
-	
+
     static void initKeywords()
 	{
 		uint nkeywords = keywords.length;
@@ -694,14 +697,14 @@
 			nkeywords -= 2;
 
 		cmtable_init();
-		
+
 		for (uint u = 0; u < nkeywords; u++)
 		{
 			//printf("keyword[%d] = '%.*s'\n",u, keywords[u].name);
 			string s = keywords[u].name;
 			TOK v = keywords[u].value;
-			StringValue* sv = stringtable.insert(s);
-			sv.ptrvalue = cast(void*) new Identifier(sv.lstring.string_, v);
+			Object* sv = stringtable.insert(s);
+			*sv = new Identifier(s, v);
 
 			//printf("tochars[%d] = '%s'\n",v, s);
 			Token.tochars[v] = s;
@@ -794,7 +797,7 @@
 		Token.tochars[TOK.TOKat]		= "@";
         Token.tochars[TOK.TOKpow]		= "^^";
         Token.tochars[TOK.TOKpowass]		= "^^=";
-        
+
 		 // For debugging
 		Token.tochars[TOKerror]		= "error";
 		Token.tochars[TOK.TOKdotexp]		= "dotexp";
@@ -818,12 +821,12 @@
 
     static Identifier idPool(string s)
 	{
-		StringValue* sv = stringtable.update(s);
-		Identifier id = cast(Identifier) sv.ptrvalue;
+		Object* sv = stringtable.update(s);
+		Identifier id = cast(Identifier) *sv;
 		if (id is null)
 		{
-			id = new Identifier(sv.lstring.string_, TOK.TOKidentifier);
-			sv.ptrvalue = cast(void*)id;
+			id = new Identifier(s, TOK.TOKidentifier);
+			*sv = id;
 		}
 
 		return id;
@@ -1068,12 +1071,14 @@
 		            break;
 		        }
 
-		        StringValue *sv = stringtable.update((cast(immutable(char)*)t.ptr)[0.. p - t.ptr]);
-		        Identifier id = cast(Identifier) sv.ptrvalue;
-                    
+                auto s = cast(string)(t.ptr[0.. p - t.ptr]);
+		        Object* sv = stringtable.update(s);
+		        Identifier id = cast(Identifier) *sv;
+
 				if (id is null)
-				{   id = new Identifier(sv.lstring.string_, TOK.TOKidentifier);
-					sv.ptrvalue = cast(void*)id;
+				{
+				    id = new Identifier(s, TOK.TOKidentifier);
+					*sv = id;
 				}
 				t.ident = id;
 				t.value = cast(TOK) id.value;
@@ -1340,7 +1345,7 @@
 						}
 						continue;
 					}
-					
+
 					default:
 						break;	///
 				}
@@ -1555,7 +1560,7 @@
 				else
 					t.value = TOK.TOKtilde;		// ~
 				return;
-                
+
 version(DMDV2) {
 	    case '^':
 		p++;
@@ -1636,7 +1641,7 @@
 						t.value = TOK.TOKmul;
 					}
 					return;
-					
+
 				case '%':
 					p++;
 					if (*p == '=') {
@@ -1795,7 +1800,7 @@
 				p++;
 				c = *p;
 				if (ishex(cast(ubyte)c))
-				{   
+				{
 					uint v;
 
 					n = 0;
@@ -1835,7 +1840,7 @@
 					case ';':
 						c = HtmlNamedEntity(idstart, p - idstart);
 						if (c == ~0)
-						{   
+						{
 							error("unnamed character entity &%s;", idstart[0..(p - idstart)]);
 							c = ' ';
 						}
@@ -1860,7 +1865,7 @@
 
 			default:
 				if (isoctal(cast(ubyte)c))
-				{   
+				{
 					uint v;
 
 					n = 0;
@@ -1940,7 +1945,7 @@
 			}
 			stringbuffer.writeByte(c);
 		}
-		
+
 		assert(false);
 	}
 
@@ -1986,7 +1991,7 @@
 
 				case '"':
 					if (n & 1)
-					{   
+					{
 						error("odd number (%d) of hex characters in hex string", n);
 						stringbuffer.writeByte(v);
 					}
@@ -2096,7 +2101,7 @@
 					break;
 			}
 			if (delimleft == 0)
-			{   
+			{
 				delimleft = c;
 				nest = 1;
 				nestcount = 1;
@@ -2109,18 +2114,18 @@
 				else if (c == '<')
 					delimright = '>';
 				else if (isalpha(c) || c == '_' || (c >= 0x80 && isUniAlpha(c)))
-				{	
+				{
 					// Start of identifier; must be a heredoc
 					Token t2;
 					p--;
 					scan(&t2);		// read in heredoc identifier
 					if (t2.value != TOKidentifier)
-					{   
+					{
 						error("identifier expected for heredoc, not %s", t2.toChars());
 						delimright = c;
 					}
 					else
-					{   
+					{
 						hereid = t2.ident;
 						//printf("hereid = '%s'\n", hereid.toChars());
 						blankrol = 1;
@@ -2128,7 +2133,7 @@
 					nest = 0;
 				}
 				else
-				{	
+				{
 					delimright = c;
 					nest = 0;
 					if (isspace(c))
@@ -2138,7 +2143,7 @@
 			else
 			{
 				if (blankrol)
-				{	
+				{
 					error("heredoc rest of line should be blank");
 					blankrol = 0;
 					continue;
@@ -2156,14 +2161,14 @@
 				else if (c == delimright)
 					goto Ldone;
 				if (startline && isalpha(c) && hereid)
-				{	
+				{
 					Token t2;
 					ubyte* psave = p;
 					p--;
 					scan(&t2);		// read in possible heredoc identifier
 					//printf("endid = '%s'\n", t2.ident.toChars());
 					if (t2.value == TOKidentifier && t2.ident.equals(hereid))
-					{   
+					{
 						/* should check that rest of line is blank
 						 */
 						goto Ldone;
@@ -2211,7 +2216,7 @@
 		ubyte* pstart = ++p;
 
 		while (true)
-		{	
+		{
 			Token tok;
 
 			scan(&tok);
@@ -2327,7 +2332,7 @@
 			}
 			stringbuffer.writeByte(c);
 		}
-		
+
 		assert(false);
 	}
 
@@ -2391,7 +2396,7 @@
 		}
 
 		if (*p != '\'')
-		{	
+		{
 			error("unterminated character constant");
 			return tk;
 		}
@@ -2423,7 +2428,7 @@
 	{
 		assert(false);
 	}
-	
+
 	/**************************************
 	 * Read in a number.
 	 * If it's an integer, store it in tok.TKutok.Vlong.
@@ -2450,7 +2455,7 @@
 			FLAGS_unsigned = 2,		// u or U suffix
 			FLAGS_long     = 4,		// l or L suffix
 		};
-		
+
 		FLAGS flags = FLAGS.FLAGS_decimal;
 
 		int i;
@@ -2889,7 +2894,7 @@
 					case 9:
 						dblstate = 1;
 						if (c == 'X' || c == 'x')
-						{	
+						{
 							hex++;
 							break;
 						}
@@ -2907,14 +2912,14 @@
 
 					case 2:			// no more digits to left of .
 						if (c == '.')
-						{   
+						{
 							dblstate++;
 							break;
 						}
 					case 4:			// no more digits to right of .
 						if ((c == 'E' || c == 'e') ||
 							hex && (c == 'P' || c == 'p'))
-						{   
+						{
 							dblstate = 5;
 							hex = 0;	// exponent is always decimal
 							break;
@@ -2996,7 +3001,7 @@
 				default:
 			}
 		}
-		
+
 	version (Windows) { ///&& __DMC__
 		__locale_decpoint = save;
 	}
@@ -3027,7 +3032,7 @@
 
 		global.errors++;
 	}
-	
+
 	/*********************************************
 	 * Do pragma.
 	 * Currently, the only pragma supported is:
@@ -3092,7 +3097,7 @@
 					stringbuffer.reset();
 					p++;
 					while (1)
-					{   
+					{
 						uint c;
 
 						c = *p;
@@ -3112,7 +3117,7 @@
 
 							default:
 								if (c & 0x80)
-								{   
+								{
 									uint u = decodeUTF();
 									if (u == PS || u == LS)
 										goto Lerr;
@@ -3127,7 +3132,7 @@
 
 				default:
 					if (*p & 0x80)
-					{   
+					{
 						uint u = decodeUTF();
 						if (u == PS || u == LS)
 							goto Lnewline;
@@ -3306,7 +3311,7 @@
 		//printf("Lexer::combineComments('%s', '%s')\n", c1, c2);
 
 		string c = c2;
-		
+
 		if (c1)
 		{
 			c = c1;
@@ -3357,7 +3362,7 @@
 		//writef("Lexer.combineComments('%s', '%s')\n", c1, c2);
 
 		char[] c = cast(char[]) c2;
-		
+
 		if (c1 !is null)
 		{
 			c = cast(char[]) c1;
@@ -3370,7 +3375,7 @@
 				c[len1 .. len1 + c2.length] = c2[];
 			}
 		}
-		
+
 		return cast(string)c;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/Library.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Library.d	Sun Oct 17 07:42:00 2010 +0400
@@ -130,7 +130,7 @@
     memcpy(name, p, len);
     name[len] = 0;
     *pp = p + len;
-	
+
 	return len;
 }
 
@@ -148,7 +148,7 @@
 {
 	ObjSymbol** p1 = cast(ObjSymbol**)a;
 	ObjSymbol** p2 = cast(ObjSymbol**)b;
-	
+
     return cmp((*p1).name, (*p2).name);
 }
 version (Windows)
@@ -158,7 +158,7 @@
  * Returns:
  *	0	failure
  */
- 
+
 extern (C) extern uint _rotl(uint value, int shift);
 extern (C) extern uint _rotr(uint value, int shift);
 
@@ -254,7 +254,9 @@
     return 0;
 }
 
-class Library
+import dmd.TObject;
+
+class Library : TObject
 {
     File libfile;
     Array objmodules;	// ObjModule[]
@@ -264,11 +266,11 @@
 
     this()
 	{
+		register();
 		libfile = null;
-		
+
 		objmodules = new Array();
 		objsymbols = new Array();
-		tab = new StringTable();
 	}
 
 	/***********************************
@@ -280,7 +282,7 @@
 	{
 		string arg = filename;
 		if (arg.length == 0)
-		{   
+		{
 			// Generate lib file name from first obj name
 			string n = (cast(String)global.params.objfiles.data[0]).str;
 
@@ -352,7 +354,7 @@
 			return;
 		}
 		else
-		{	
+		{
 			// Not a library, assume OMF object module
 			g_page_size = 16;
 		}
@@ -383,7 +385,7 @@
 				case LHEADR :
 				case THEADR :
 					if (!om)
-					{   
+					{
 						char name[LIBIDMAX + 1];
 						om = new ObjModule();
 						om.flags = 0;
@@ -391,7 +393,7 @@
 						p += 3;
 						parseName(&p, name.ptr);
 						if (first_module && module_name && !islibrary)
-						{	
+						{
 							// Remove path and extension
 							string fname = FileName.name(module_name);
 							string ext = FileName.ext(fname);
@@ -402,7 +404,7 @@
 							om.name = fname;
 						}
 						else
-						{	
+						{
 							/* Use THEADR name as module name,
 							 * removing path and extension.
 							 */
@@ -411,12 +413,12 @@
 							if (ext.length != 0) {
 								fname = fname[0..$-ext.length-1];
 							}
-							
+
 							om.name = fname;
 							om.flags |= MFtheadr;
 						}
 						if (strcmp(name.ptr, "C".ptr) == 0)	   // old C compilers did this
-						{	
+						{
 							om.flags |= MFgentheadr;  // generate our own THEADR
 							om.base = pnext;	   // skip past THEADR
 						}
@@ -428,7 +430,7 @@
 				case MODEND :
 				case M386END:
 					if (om)
-					{   
+					{
 						om.page = cast(ushort)((om.base - pstart) / g_page_size);
 						om.length = pnext - om.base;
 						om = null;
@@ -438,9 +440,9 @@
 					t = (t + g_page_size - 1) & ~cast(uint)(g_page_size - 1);
 					pnext = pstart + t;
 					break;
-				
+
 				default:
-					// ignore 
+					// ignore
 					;
 			}
 		}
@@ -478,15 +480,15 @@
 	version (LOG) {
 		printf("Library.addSymbol(%s, %s, %d)\n", om.name, name, pickAny);
 	}
-		StringValue* s = tab.insert(name);
+		Object* s = tab.insert(name);
 		if (!s)
-		{	
+		{
 			// already in table
 			if (!pickAny)
-			{   
+			{
 				s = tab.lookup(name);
 				assert(s);
-				ObjSymbol* os = cast(ObjSymbol*)s.ptrvalue;
+				ObjSymbol* os = *cast(ObjSymbol**)s;
 				error("multiple definition of %s: %s and %s: %s",
 				om.name, name, os.om.name, os.name);
 			}
@@ -496,12 +498,12 @@
 			ObjSymbol* os = new ObjSymbol();
 			os.name = name;
 			os.om = om;
-			s.ptrvalue = cast(void*)os;
+			*s = cast(Object)cast(void*)os; /// !!!!
 
 			objsymbols.push(os);
 		}
 	}
-	
+
     void scanObjModule(ObjModule* om)
 	{
 		int easyomf;
@@ -605,7 +607,7 @@
 
 				case COMENT:
 					// Recognize Phar Lap EASY-OMF format
-					{   
+					{
 						enum ubyte[7] omfstr = [0x80,0xAA,'8','0','3','8','6'];
 
 						if (recLen == omfstr.sizeof)
@@ -619,7 +621,7 @@
 						}
 					}
 					// Recognize .IMPDEF Import Definition Records
-					{   
+					{
 						enum ubyte[3] omfstr = [0, 0xA0, 1];
 
 						if (recLen >= 7)
@@ -638,7 +640,7 @@
 					break;
 
 				default:
-					// ignore 
+					// ignore
 					;
 			}
 		}
@@ -648,7 +650,7 @@
 		///for (u = 1; u < names.dim; u++)
 		///	free(names.data[u]);
 	}
-	
+
 	/***********************************
 	 * Calculates number of pages needed for dictionary
 	 * Returns:
@@ -662,13 +664,13 @@
 		uint symSize = 0;
 
 		for (int i = 0; i < objsymbols.dim; i++)
-		{	
+		{
 			ObjSymbol* s = cast(ObjSymbol*)objsymbols.data[i];
 			symSize += ( s.name.length + 4 ) & ~1;
 		}
 
 		for (int i = 0; i < objmodules.dim; i++)
-		{	
+		{
 			ObjModule* om = cast(ObjModule*)objmodules.data[i];
 
 			size_t len = om.name.length;
@@ -701,7 +703,7 @@
 		for (int i = 0; 1; i++)
 		{
 			if ( primes[i] == 0 )
-			{   
+			{
 				// Quick and easy way is out.
 				// Now try and find first prime number > ndicpages
 				uint prime;
@@ -730,7 +732,7 @@
 
 		return ndicpages;
 	}
-	
+
 	/*******************************************
 	 * Write the module and symbol names to the dictionary.
 	 * Returns:
@@ -744,12 +746,12 @@
 
 		// Add each of the module names
 		for (int i = 0; i < objmodules.dim; i++)
-		{	
+		{
 			ObjModule* om = cast(ObjModule*)objmodules.data[i];
 
 			ushort n = cast(ushort)om.name.length;
 			if (n > 255)
-			{   
+			{
 				entry[0] = 0xFF;
 				entry[1] = 0;
 				*cast(ushort*)(entry.ptr + 2) = cast(ushort)(n + 1);
@@ -757,7 +759,7 @@
 				n += 3;
 			}
 			else
-			{   
+			{
 				entry[ 0 ] = cast(ubyte)(1 + n);
 				memcpy(entry.ptr + 1, om.name.ptr, n );
 			}
@@ -774,12 +776,12 @@
 
 		// Add each of the symbols
 		for (int i = 0; i < objsymbols.dim; i++)
-		{	
+		{
 			ObjSymbol* os = cast(ObjSymbol*)objsymbols.data[i];
 
 			ushort n = cast(ushort)os.name.length;
 			if (n > 255)
-			{   
+			{
 				entry[0] = 0xFF;
 				entry[1] = 0;
 				*cast(ushort*)(entry.ptr + 2) = n;
@@ -787,7 +789,7 @@
 				n += 3;
 			}
 			else
-			{   
+			{
 				entry[ 0 ] = cast(ubyte)n;
 				memcpy( entry.ptr + 1, os.name.ptr, n );
 			}
@@ -802,7 +804,7 @@
 
 		return 1;
 	}
-	
+
 	/**********************************************
 	 * Create and write library to libbuf.
 	 * The library consists of:
@@ -817,7 +819,7 @@
 		 * to go into the dictionary
 		 */
 		for (int i = 0; i < objmodules.dim; i++)
-		{   
+		{
 			ObjModule* om = cast(ObjModule*)objmodules.data[i];
 			scanObjModule(om);
 		}
@@ -837,7 +839,7 @@
 			uint offset = g_page_size;
 
 			for (int i = 0; i < objmodules.dim; i++)
-			{   
+			{
 				ObjModule* om = cast(ObjModule*)objmodules.data[i];
 
 				uint page = offset / g_page_size;
@@ -879,7 +881,7 @@
 		/* Write each object module into the library
 		 */
 		for (int i = 0; i < objmodules.dim; i++)
-		{	
+		{
 			ObjModule* om = cast(ObjModule*)objmodules.data[i];
 
 			uint page = libbuf.offset / g_page_size;
@@ -905,7 +907,7 @@
 				ubyte checksum = 0;
 				ubyte* p = header.ptr;
 				while (n--)
-				{	
+				{
 					checksum -= *p;
 					p++;
 				}
@@ -958,7 +960,7 @@
 				bucketsP[u * BUCKETPAGE + HASHMOD] = (HASHMOD + 1) >> 1;
 			}
 
-			if (FillDict(bucketsP, ndicpages)) 
+			if (FillDict(bucketsP, ndicpages))
 				break;
 			padding += 16;      // try again with more margins
 		}
@@ -985,22 +987,25 @@
 } // version (Windows)
 else version(TARGET_LINUX)
 {
-class Library
+
+import dmd.TObject;
+
+class Library : TObject
 {
     void setFilename(string dir, string filename)
     {
     	assert(0);
     }
-    
+
     void addObject(string module_name, void *buf, size_t buflen)
     {
     	assert(0);
     }
-    
+
     void write()
     {
     	assert(0);
     }
-	
+
 }
 }
--- a/dmd/LineInitExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/LineInitExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc, TOK.TOKline, this.sizeof);
 	}
 
--- a/dmd/LinkDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/LinkDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
     this(LINK p, Dsymbols decl)
 	{
+		register();
 		super(decl);
 		//printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl);
 		linkage = p;
--- a/dmd/Loc.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Loc.d	Sun Oct 17 07:42:00 2010 +0400
@@ -41,4 +41,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/MinAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/MinAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKminass, MinAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/MinExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/MinExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKmin, MinExp.sizeof, e1, e2);
 	}
 
--- a/dmd/ModAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ModAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKmodass, this.sizeof, e1, e2);
 	}
 	
--- a/dmd/ModExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ModExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKmod, ModExp.sizeof, e1, e2);
 	}
 
--- a/dmd/Module.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Module.d	Sun Oct 17 07:42:00 2010 +0400
@@ -211,8 +211,8 @@
     Vector!string debugidsNot;		// forward referenced debug identifiers
 
     uint versionlevel;	// version level
-    Array versionids;		// version identifiers
-    Array versionidsNot;	// forward referenced version identifiers
+    Vector!(string) versionids;		// version identifiers
+    Vector!(string) versionidsNot;	// forward referenced version identifiers
 
     Macro macrotable;		// document comment macros
     Escape escapetable;	// document comment escapes
@@ -220,7 +220,13 @@
 
     this(string filename, Identifier ident, int doDocComment, int doHdrGen)
 	{
+		register();
+
 		super(ident);
+
+		versionids = new Vector!string;
+		versionidsNot = new Vector!string;
+
 		FileName objfilename;
 
 		aimports = new Array();
@@ -354,13 +360,12 @@
 		}
 
 		if (result) {
-			writeln("loading ", result);
 			m.srcfile = new File(result);
 		}
 
 		if (global.params.verbose)
 		{
-			writef("import    ");
+			write("import    ");
 			if (packages)
 			{
 				foreach (pid; packages)
--- a/dmd/ModuleDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ModuleDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -5,7 +5,9 @@
 import dmd.ArrayTypes;
 import dmd.OutBuffer;
 
-class ModuleDeclaration
+import dmd.TObject;
+
+class ModuleDeclaration : TObject
 {
     Identifier id;
     Identifiers packages;		// array of Identifier's representing packages
@@ -13,6 +15,7 @@
 
     this(Identifiers packages, Identifier id, bool safe)
 	{
+		register();
 		this.packages = packages;
 		this.id = id;
 		this.safe = safe;
--- a/dmd/ModuleInfoDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ModuleInfoDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -17,6 +17,7 @@
 
 	this(Module mod)
 	{
+		register();
 		super(Loc(0), global.moduleinfo.type, mod.ident, null);
 	}
 	
--- a/dmd/MulAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/MulAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKmulass, MulAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/MulExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/MulExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKmul, MulExp.sizeof, e1, e2);
 	}
 
--- a/dmd/NegExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NegExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOKneg, NegExp.sizeof, e);
 	}
 
--- a/dmd/NewAnonClassExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NewAnonClassExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
 	this(Loc loc, Expression thisexp, Expressions newargs, ClassDeclaration cd, Expressions arguments)
 	{
+		register();
 		super(loc, TOKnewanonclass, NewAnonClassExp.sizeof);
 		this.thisexp = thisexp;
 		this.newargs = newargs;
--- a/dmd/NewDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NewDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 
     this(Loc loc, Loc endloc, Parameters arguments, int varargs)
 	{
+		register();
 		super(loc, endloc, Id.classNew, STCstatic, null);
 		this.arguments = arguments;
 		this.varargs = varargs;
--- a/dmd/NewExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NewExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -61,6 +61,7 @@
 
 	this(Loc loc, Expression thisexp, Expressions newargs, Type newtype, Expressions arguments)
 	{
+		register();
 		super(loc, TOK.TOKnew, NewExp.sizeof);
 		this.thisexp = thisexp;
 		this.newargs = newargs;
--- a/dmd/NotExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NotExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKnot, NotExp.sizeof, e);
 	}
 
--- a/dmd/NullExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/NullExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 
 	this(Loc loc, Type type = null)
 	{
+		register();
 		super(loc, TOK.TOKnull, NullExp.sizeof);
         this.type = type;
 	}
--- a/dmd/OnScopeStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OnScopeStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -31,6 +31,7 @@
 
     this(Loc loc, TOK tok, Statement statement)
 	{
+		register();
 		super(loc);
 
 		this.tok = tok;
--- a/dmd/OrAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OrAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKorass, OrAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/OrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKor, OrExp.sizeof, e1, e2);
 	}
 
--- a/dmd/OrOrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OrOrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKoror, OrOrExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/OutBuffer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OutBuffer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,7 +10,9 @@
 import core.memory;
 import core.stdc.stdlib;
 
-class OutBuffer
+import dmd.TObject;
+
+class OutBuffer : TObject
 {
     ubyte* data;
     uint offset;
@@ -18,6 +20,7 @@
 
     this()
 	{
+		register();
 		// do nothing
 	}
 
--- a/dmd/OverExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OverExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,6 +16,7 @@
 
 	this(OverloadSet s)
 	{
+		register();
 		super(loc, TOKoverloadset, OverExp.sizeof);
 		//printf("OverExp(this = %p, '%s')\n", this, var.toChars());
 		vars = s;
--- a/dmd/OverloadSet.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/OverloadSet.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,6 +10,7 @@
 
     this()
 	{
+		register();
 		a = new Dsymbols();
 	}
 	
--- a/dmd/Package.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Package.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 {
     this(Identifier ident)
 	{
+		register();
 		super(ident);
 	}
 	
--- a/dmd/Param.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Param.d	Sun Oct 17 07:42:00 2010 +0400
@@ -70,7 +70,7 @@
     Vector!string debugids;		// debug identifiers
 
     uint versionlevel;	// version level
-    Array versionids;		// version identifiers
+    Vector!(string) versionids;		// version identifiers
 
     bool dump_source;
 
@@ -101,4 +101,4 @@
     string deffile;
     string resfile;
     string exefile;
-}
\ No newline at end of file
+}
--- a/dmd/Parameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Parameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,7 +18,9 @@
 import dmd.CppMangleState;
 import dmd.STC;
 
-class Parameter
+import dmd.TObject;
+
+class Parameter : TObject
 {
     //enum InOut inout;
     StorageClass storageClass;
@@ -28,6 +30,7 @@
 
     this(StorageClass storageClass, Type type, Identifier ident, Expression defaultArg)
 	{
+		register();
 		this.type = type;
 		this.ident = ident;
 		this.storageClass = storageClass;
--- a/dmd/Parser.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Parser.d	Sun Oct 17 07:42:00 2010 +0400
@@ -221,6 +221,7 @@
 
     this(Module module_, ubyte* base, uint length, int doDocComment)
 	{
+		register();
 		super(module_, base, 0, length, doDocComment, 0);
 		//printf("Parser.Parser()\n");
 		linkage = LINK.LINKd;
--- a/dmd/PeelStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PeelStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -11,6 +11,7 @@
 
 	this(Statement s)
 	{
+		register();
 		assert(false);
 		super(Loc(0));
 	}
--- a/dmd/PostBlitDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PostBlitDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,11 +22,13 @@
 {
 	this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, Id._postblit, STCundefined, null);
 	}
 	
 	this(Loc loc, Loc endloc, Identifier id)
 	{
+		register();
 		super(loc, loc, id, STCundefined, null);
 	}
 	
--- a/dmd/PostExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PostExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 {
 	this(TOK op, Loc loc, Expression e)
 	{
+		register();
 		super(loc, op, PostExp.sizeof, e, new IntegerExp(loc, 1, Type.tint32));
 	}
 
--- a/dmd/PowAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PowAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
     {
+		register();
         super(loc, TOK.TOKpowass, PowAssignExp.sizeof, e1, e2);
     }
     
--- a/dmd/PowExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PowExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,6 +32,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
     {
+		register();
         super(loc, TOK.TOKpow, PowExp.sizeof, e1, e2);
     }
         
--- a/dmd/PragmaDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PragmaDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
     this(Loc loc, Identifier ident, Expressions args, Dsymbols decl)
 	{
+		register();
 		super(decl);
 		this.loc = loc;
 		this.ident = ident;
--- a/dmd/PragmaStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PragmaStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
 	this(Loc loc, Identifier ident, Expressions args, Statement body_)
 	{
+		register();
 		super(loc);
 		this.ident = ident;
 		this.args = args;
--- a/dmd/ProtDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ProtDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
     this(PROT p, Dsymbols decl)
 	{
+		register();
 		super(decl);
 
 		protection = p;
--- a/dmd/PtrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/PtrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -35,6 +35,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKstar, PtrExp.sizeof, e);
 		//    if (e.type)
 		//		type = ((TypePointer *)e.type).next;
@@ -42,6 +43,7 @@
 
 	this(Loc loc, Expression e, Type t)
 	{
+		register();
 		super(loc, TOKstar, PtrExp.sizeof, e);
 		type = t;
 	}
--- a/dmd/RealExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/RealExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,6 +32,7 @@
 
 	this(Loc loc, real value, Type type)
 	{
+		register();
 		super(loc, TOK.TOKfloat64, RealExp.sizeof);
 		//printf("RealExp.RealExp(%Lg)\n", value);
 		this.value = value;
--- a/dmd/RemoveExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/RemoveExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOKremove, RemoveExp.sizeof, e1, e2);
 		type = Type.tvoid;
 	}
--- a/dmd/ReturnStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ReturnStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -55,6 +55,7 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
--- a/dmd/Scope.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Scope.d	Sun Oct 17 07:42:00 2010 +0400
@@ -36,7 +36,9 @@
 	SCOPEfree = 4,	// is on free list
 }
 
-class Scope
+import dmd.TObject;
+
+class Scope : TObject
 {
     Scope enclosing;		// enclosing Scope
 
@@ -112,6 +114,7 @@
 
     this()
 	{
+		register();
 		// Create root scope
 
 		//printf("Scope.Scope() %p\n", this);
@@ -121,12 +124,14 @@
 	
     this(Module module_)
 	{
+		register();
 		assert(false);
 		this.docbuf = new OutBuffer;
 	}
 	
     this(Scope enclosing)
 	{
+		register();
 		//printf("Scope.Scope(enclosing = %p) %p\n", enclosing, this);
 		assert(!(enclosing.flags & SCOPE.SCOPEfree));
 		this.module_ = enclosing.module_;
--- a/dmd/ScopeDsymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ScopeDsymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,11 +30,13 @@
 
     this()
 	{
+		register();
 		// do nothing
 	}
 	
     this(Identifier id)
 	{
+		register();
 		super(id);
 	}
 	
--- a/dmd/ScopeExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ScopeExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 
 	this(Loc loc, ScopeDsymbol pkg)
 	{
+		register();
 		super(loc, TOK.TOKimport, ScopeExp.sizeof);
 		//printf("ScopeExp.ScopeExp(pkg = '%s')\n", pkg.toChars());
 		//static int count; if (++count == 38) *(char*)0=0;
--- a/dmd/ScopeStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ScopeStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 
     this(Loc loc, Statement s)
 	{
+		register();
 		super(loc);
 		this.statement = s;
 	}
--- a/dmd/Section.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Section.d	Sun Oct 17 07:42:00 2010 +0400
@@ -6,7 +6,9 @@
 import dmd.Dsymbol;
 import dmd.OutBuffer;
 
-class Section
+import dmd.TObject;
+
+class Section : TObject
 {
     ubyte* name;
     uint namelen;
--- a/dmd/ShlAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ShlAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,6 +21,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKshlass, ShlAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/ShlExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ShlExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKshl, ShlExp.sizeof, e1, e2);
 	}
 
--- a/dmd/ShrAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ShrAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -24,6 +24,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKshrass, ShrAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/ShrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ShrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,6 +23,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKshr, ShrExp.sizeof, e1, e2);
 	}
 
--- a/dmd/SliceExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SliceExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -12,6 +12,7 @@
 import dmd.InterState;
 import dmd.ScopeDsymbol;
 import dmd.WANT;
+import dmd.Util;
 import dmd.ArrayScopeSymbol;
 import dmd.CallExp;
 import dmd.DotIdExp;
@@ -64,6 +65,7 @@
 
 	this(Loc loc, Expression e1, Expression lwr, Expression upr)
 	{
+		register();
 		super(loc, TOK.TOKslice, SliceExp.sizeof, e1);
 		this.upr = upr;
 		this.lwr = lwr;
@@ -133,7 +135,7 @@
 					e = new CallExp(loc, e, lwr, upr);
 				}
 				else
-				{	
+				{
 					assert(!upr);
 					e = new CallExp(loc, e);
 				}
@@ -165,13 +167,13 @@
 			}
 
 			if (lwr)
-			{	
+			{
 				lwr = lwr.semantic(sc2);
 				lwr = resolveProperties(sc2, lwr);
 				lwr = lwr.implicitCastTo(sc2, Type.tsize_t);
 			}
 			if (upr)
-			{	
+			{
 				upr = upr.semantic(sc2);
 				upr = resolveProperties(sc2, upr);
 				upr = upr.implicitCastTo(sc2, Type.tsize_t);
@@ -193,12 +195,12 @@
 			TypeTuple tup;
 
 			if (e1.op == TOKtuple)		// slicing an expression tuple
-			{   
+			{
 				te = cast(TupleExp)e1;
 				length = te.exps.dim;
 			}
 			else if (e1.op == TOKtype)	// slicing a type tuple
-			{   
+			{
 				tup = cast(TypeTuple)t;
 				length = Parameter.dim(tup.arguments);
 			}
@@ -206,27 +208,27 @@
 				assert(0);
 
 			if (i1 <= i2 && i2 <= length)
-			{   
+			{
 				size_t j1 = cast(size_t) i1;
 				size_t j2 = cast(size_t) i2;
 
 				if (e1.op == TOKtuple)
-				{	
+				{
 					auto exps = new Expressions;
 					exps.setDim(j2 - j1);
 					for (size_t i = 0; i < j2 - j1; i++)
-					{   
+					{
 						auto e2 = te.exps[j1 + i];
 						exps[i] = e2;
 					}
 					e = new TupleExp(loc, exps);
 				}
 				else
-				{	
+				{
 					auto args = new Parameters;
 					args.reserve(j2 - j1);
 					for (size_t i = j1; i < j2; i++)
-					{   
+					{
 						auto arg = Parameter.getNth(tup.arguments, i);
 						args.push(arg);
 					}
@@ -265,7 +267,7 @@
 	{
 		e1.checkEscape();
 	}
-    
+
     override void checkEscapeRef()
     {
         e1.checkEscapeRef();
@@ -315,9 +317,9 @@
 		e = this;
 		e1 = e1.optimize(WANTvalue | (result & WANTinterpret));
 		if (!lwr)
-		{	
+		{
 			if (e1.op == TOKstring)
-			{   
+			{
 				// Convert slice of string literal into dynamic array
 				Type t = e1.type.toBasetype();
 				if (t.nextOf())
@@ -427,7 +429,7 @@
 					goto L2;
 				}
 				else if (t1.ty == Tsarray)
-				{	
+				{
 					TypeSArray tsa = cast(TypeSArray)t1;
 					ulong length = tsa.dim.toInteger();
 
@@ -488,7 +490,7 @@
 		e1.scanForNestedRef(sc);
 
 		if (lengthVar)
-		{	
+		{
 			//printf("lengthVar\n");
 			lengthVar.parent = sc.parent;
 		}
@@ -534,17 +536,15 @@
 		are.e1 = e1.doInline(ids);
 
 		if (lengthVar)
-		{	
+		{
 			//printf("lengthVar\n");
 			VarDeclaration vd = lengthVar;
 			ExpInitializer ie;
 			ExpInitializer ieto;
 			VarDeclaration vto;
 
-			vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd.init);
-			///*vto = *vd;
-			memcpy(cast(void*)vto, cast(void*)vd, VarDeclaration.classinfo.init.length);
-			
+			vto = cloneThis(vd);
+
 			vto.parent = ids.parent;
 			vto.csym = null;
 			vto.isym = null;
--- a/dmd/Statement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Statement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,12 +37,15 @@
 	}
 `;
 
-class Statement
+import dmd.TObject;
+
+class Statement  : TObject
 {
     Loc loc;
 
     this(Loc loc)
 	{
+		register();
 		this.loc = loc;
 	}
 
--- a/dmd/StaticAssert.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticAssert.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 
 	this(Loc loc, Expression exp, Expression msg)
 	{
+		register();
 		super(Id.empty);
 
 		this.loc = loc;
--- a/dmd/StaticAssertStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticAssertStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 
     this(StaticAssert sa)
 	{
+		register();
 		super(sa.loc);
 		this.sa = sa;
 	}
--- a/dmd/StaticCtorDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticCtorDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,6 +33,7 @@
 {
 	this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, Identifier.generateId("_staticCtor"), STCstatic, null);
 	}
 	
--- a/dmd/StaticDtorDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticDtorDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -36,6 +36,7 @@
 
 	this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, Identifier.generateId("_staticDtor"), STCstatic, null);
 	}
 	
--- a/dmd/StaticIfCondition.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticIfCondition.d	Sun Oct 17 07:42:00 2010 +0400
@@ -17,6 +17,7 @@
 
 	this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
--- a/dmd/StaticIfDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StaticIfDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,6 +16,7 @@
 
 	this(Condition condition, Dsymbols decl, Dsymbols elsedecl)
 	{
+		register();
 		super(condition, decl, elsedecl);
 		//printf("StaticIfDeclaration::StaticIfDeclaration()\n");
 	}
--- a/dmd/StorageClassDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StorageClassDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,7 @@
 
     this(StorageClass stc, Dsymbols decl)
 	{
+		register();
 		super(decl);
 		
 		this.stc = stc;
--- a/dmd/String.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/String.d	Sun Oct 17 07:42:00 2010 +0400
@@ -8,12 +8,15 @@
 
 import std.stdio : writefln;
 
-class String
+import dmd.TObject;
+
+class String : TObject
 {
     string str;
 
     this(string str)
 	{
+		register();
 		this.str = str;
 	}
 
--- a/dmd/StringEntry.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StringEntry.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,16 +14,9 @@
     hash_t hash;
 
     StringValue value;
-	
-	this(StringEntry* other)
-	{
-		hash = other.hash;
-		value = other.value;
-	}
 
 	this(immutable(dchar_t)[] s)
 	{
 		hash = Dchar.calcHash(s.ptr, s.length);
-		value.lstring.string_ = s;
 	}
 }
--- a/dmd/StringExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StringExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -50,11 +50,13 @@
 
 	this(Loc loc, string s)
 	{
+		register();
 		this(loc, s, 0);
 	}
 
 	this(Loc loc, string s, ubyte postfix)
 	{
+		register();
 		super(loc, TOK.TOKstring, StringExp.sizeof);
 		
 		this.string_ = cast(void*)s.ptr;
@@ -856,7 +858,7 @@
 			e.Eoper = OPER.OPstring;
 static if (true) {
 			// Match MEM_PH_FREE for OPstring in ztc\el.c
-			e.EV.ss.Vstring = cast(char*)malloc((len + 1) * sz); /// !
+			e.EV.ss.Vstring = cast(char*)GC.malloc((len + 1) * sz); /// !
 			memcpy(e.EV.ss.Vstring, string_, (len + 1) * sz);
 } else {
 			e.EV.ss.Vstring = cast(char*)string_;
--- a/dmd/StringTable.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StringTable.d	Sun Oct 17 07:42:00 2010 +0400
@@ -12,14 +12,91 @@
 
 import std.stdio;
 
-class StringTable
+struct StringTable
 {
+	Object[string] table;
+
+	~this()
+	{
+		foreach (k, v; table) {
+			delete v;
+		}
+	}
+
+	Object* lookup(string s)
+	{
+		return s in table;
+	}
+
+	Object* insert(string s)
+	{
+		auto value = s in table;
+		if (value !is null) {
+			return null;
+		}
+
+		table[s] = null;
+
+		return s in table;
+	}
+
+	Object* update(string s)
+	{
+		auto value = s in table;
+		if (value !is null) {
+			return value;
+		}
+
+		table[s] = null;
+
+        return s in table;
+	}
+
+    /*
+	StringValue* lookup(string s)
+	{
+		if (auto p = s in table) {
+			return *p;
+		}
+
+		return null;
+	}
+
+	StringValue* insert(string s)
+	{
+		if (auto p = s in table) {
+			return null;
+		}
+
+		auto value = new StringValue();
+		value.lstring.string_ = s;
+		table[s] = value;
+
+		return value;
+	}
+
+	StringValue* update(string s)
+	{
+		if (auto p = s in table) {
+			return *p;
+		}
+
+		auto value = new StringValue();
+		value.lstring.string_ = s;
+		table[s] = value;
+
+		return value;
+	}
+	*/
+
+	/*
     void** table;
     uint count;
     uint tabledim;
 
     this(uint size = 37)
 	{
+		register();
 		table = cast(void**)GC.calloc(size * (void*).sizeof);
 		memset(table, 0, size * (void*).sizeof);
 		tabledim = size;
@@ -63,7 +140,7 @@
 
 		return &se.value;
 	}
-	
+
 	void insertCopy(StringEntry* proto)
 	{
 		StringEntry** pse = search(proto.value.lstring.string_);
@@ -140,4 +217,5 @@
 		//printf("\treturn %p, %p\n",se, (*se));
 		return se;
 	}
+	*/
 }
--- a/dmd/StringValue.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StringValue.d	Sun Oct 17 07:42:00 2010 +0400
@@ -6,12 +6,5 @@
 
 struct StringValue
 {
-    union
-    {
-		int intvalue = 0;
-		void* ptrvalue;
-		dchar_t* string_;
-    }
-
-    Lstring lstring;
+	Object ptrvalue;
 }
\ No newline at end of file
--- a/dmd/StructDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StructDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -82,6 +82,7 @@
 
     this(Loc loc, Identifier id)
 	{
+		register();
 		super(loc, id);
 
 		// For forward references
--- a/dmd/StructInitializer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StructInitializer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -41,6 +41,7 @@
 
     this(Loc loc)
 	{
+		register();
 		super(loc);
 		ad = null;
 		
--- a/dmd/StructLiteralExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/StructLiteralExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -55,6 +55,7 @@
 
 	this(Loc loc, StructDeclaration sd, Expressions elements)
 	{
+		register();
 		super(loc, TOKstructliteral, StructLiteralExp.sizeof);
 		this.sd = sd;
 		this.elements = elements;
--- a/dmd/SuperExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SuperExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc);
 		op = TOK.TOKsuper;
 	}
--- a/dmd/SwitchErrorStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SwitchErrorStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,7 @@
 {
 	this(Loc loc)
 	{
+		register();
 		super(loc);
 	}
 
--- a/dmd/SwitchStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SwitchStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -69,6 +69,7 @@
 
     this(Loc loc, Expression c, Statement b, bool isFinal)
 	{
+		register();
 		super(loc);
 		
 		this.condition = c;
@@ -486,7 +487,7 @@
 		block_next(blx,BCswitch,null);
 
         // Corresponding free is in block_free
-		targ_llong* pu = cast(targ_llong*) malloc(targ_llong.sizeof * (numcases + 1));
+		targ_llong* pu = cast(targ_llong*) GC.malloc(targ_llong.sizeof * (numcases + 1));
 		mystate.switchBlock.Bswitch = pu;
 		/* First pair is the number of cases, and the default block
 		 */
--- a/dmd/SymOffExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SymOffExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,6 +32,7 @@
 
 	this(Loc loc, Declaration var, uint offset, bool hasOverloads = false)
 	{
+		register();
 		super(loc, TOK.TOKsymoff, SymOffExp.sizeof, var, hasOverloads);
 		
 		this.offset = offset;
--- a/dmd/SymbolDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SymbolDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,6 +22,7 @@
 
     this(Loc loc, Symbol* s, StructDeclaration dsym)
 	{
+		register();
 		int len = strlen(s.Sident.ptr);
 		string name = s.Sident.ptr[0..len].idup;
 
--- a/dmd/SymbolExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SymbolExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
 	this(Loc loc, TOK op, int size, Declaration var, bool hasOverloads)
 	{
+		register();
 		super(loc, op, size);
 		assert(var);
 		this.var = var;
--- a/dmd/SynchronizedStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/SynchronizedStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -44,6 +44,7 @@
 
     this(Loc loc, Expression exp, Statement body_)
 	{
+		register();
 		super(loc);
 		
 		this.exp = exp;
@@ -183,6 +184,7 @@
 
 	this(Loc loc, elem *esync, Statement body_)
 	{
+		register();
 		assert(false);
 		super(loc);
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmd/TObject.d	Sun Oct 17 07:42:00 2010 +0400
@@ -0,0 +1,253 @@
+module dmd.TObject;
+/*
+import core.runtime;
+import core.stdc.stdio;
+import core.stdc.string;
+import core.stdc.stdlib;
+
+import dmd.TObject;
+
+import core.sys.windows.windows;
+import core.sys.windows.codeview;
+import core.demangle;
+import core.memory;
+import core.stdc.stdlib;
+
+version = TrackArray;
+
+version (TrackList) {
+    enum mNull = TObject.pack(0);
+    __gshared size_t mHead = mNull;
+} else version (TrackArray) {
+    __gshared size_t[] objects;
+}
+*/
+class TObject
+{
+	void register()
+	{
+	}
+	
+	void forceRegister()
+	{
+	}
+	
+	/*
+    this()
+    {
+        register();
+    }
+
+	~this()
+	{
+	    size_t mThis = pack(this);
+
+        version (TrackList) {
+            if (mPrev != mNull) {
+                unpack(mPrev).mNext = mNext;
+            } else {
+                assert(mHead == mThis);
+                mHead = mNext;
+            }
+
+            if (mNext != mNull) {
+                unpack(mNext).mPrev = mPrev;
+            }
+        } else version (TrackArray) {
+            foreach (i, o; objects) {
+                if (o == mThis) {
+                    size_t newLen = objects.length - 1;
+                    objects[i] = objects[newLen];
+                    objects.length = newLen;
+
+                    alloc = cast(void*)-1;
+                    return;
+                }
+            }
+        }
+	}
+
+    version (TrackList) {
+        size_t mPrev;
+        size_t mNext;
+    }
+
+	void* alloc;
+
+	static TObject unpack(size_t m)
+	{
+        m &= ~(1 << 31);
+        return cast(TObject)cast(void*)m;
+	}
+
+	static size_t pack(size_t m)
+	{
+	    return m |= (1 << 31);
+	}
+
+	static size_t pack(TObject o)
+	{
+	    return pack(cast(size_t)cast(void*)o);
+	}
+
+	void forceRegister()
+	{
+	    version (TrackList) {
+	        alloc = alloc_point();
+            size_t mThis = pack(this);
+
+            mNext = mHead;
+            if (mHead != mNull) {
+                unpack(mHead).mPrev = mThis;
+            }
+
+            mPrev = mNull;
+            mHead = mThis;
+	    } else version (TrackArray) {
+	        alloc = alloc_point();
+            objects ~= pack(this);
+	    }
+	}
+
+	void register()
+	{
+        if (alloc !is null) return;
+        forceRegister();
+	}
+
+	static void dump()
+	{
+		int[void*] allocStat;
+
+        version (TrackList) {
+            auto o = unpack(mHead);
+            while (o !is null) {
+                allocStat[o.alloc]++;
+                o = unpack(o.mNext);
+            }
+        } else version (TrackArray) {
+            foreach (i, m; objects) {
+                allocStat[unpack(m).alloc]++;
+            }
+        }
+
+		FILE* f = fopen("alloc_stat.txt", "wb");
+		if (f is null) return;
+
+		StackFrameInfo* frame = void;
+		DebugImage* imageList, image = void;
+		char[255] buffer = void;
+
+		MEMORY_BASIC_INFORMATION mbi = void;
+
+		void resolve(const(void)* c) {
+			StackFrameInfo frame;
+			frame.va = cast(void*)c;
+
+			// mbi.Allocation base is the handle to stack frame's module
+			VirtualQuery(frame.va, &mbi, MEMORY_BASIC_INFORMATION.sizeof);
+			if (!mbi.AllocationBase) return;
+
+			image = imageList;
+			while(image) {
+				if (image.baseAddress == cast(size_t)mbi.AllocationBase) break;
+				image = image.next;
+			}
+
+			if (!image) {
+				image = new DebugImage;
+
+				with (*image) {
+					next = imageList;
+					imageList = image;
+					baseAddress = cast(size_t)mbi.AllocationBase;
+
+					uint len = GetModuleFileNameA(cast(HMODULE)baseAddress, buffer.ptr, buffer.length);
+					moduleName = buffer[0 .. len].idup;
+
+					if (len != 0) {
+						exeModule = new PEImage(moduleName);
+						rvaOffset = baseAddress + exeModule.codeOffset;
+						debugInfo = exeModule.debugInfo;
+					}
+				}
+			}
+
+			frame.moduleName = image.moduleName;
+
+			size_t va = cast(size_t)frame.va;
+
+			if (image.debugInfo) with (image.debugInfo) {
+				uint rva = va - image.rvaOffset;
+
+				frame.symbol = ResolveSymbol(rva);
+				frame.fileLine = ResolveFileLine(rva);
+			}
+
+			auto s = image.exeModule.closestSymbol(va);
+			printf("%.*s\n", s);
+			auto symbol = demangle(s.symbol);
+
+			if (frame.fileLine.file.length != 0) {
+				fprintf(f, "%.*s %.*s:%d\n", symbol, frame.fileLine.file, frame.fileLine.line);
+//			} else {
+//				if (symbol.length != 0) {
+//					fprintf(f, "%.*s", symbol);
+//				}
+			}
+		}
+
+		while (imageList) {
+			image = imageList.next;
+			delete imageList.debugInfo;
+			delete imageList.exeModule;
+			delete imageList;
+			imageList = image;
+		}
+
+        int max = 0;
+        int total = 0;
+		fprintf(f, "%d\n", allocStat.length);
+		foreach (alloc, count; allocStat) {
+			resolve(alloc);
+
+			fprintf(f, "count: %d\n\n", count);
+			if (count > max) max = count;
+			total += count;
+		}
+		fprintf(f, "max: %d\n\n", max);
+		fprintf(f, "total: %d\n\n", total);
+		fclose(f);
+	}
+	*/
+}
+/*
+void* alloc_point()
+{
+	void** bp = void;
+
+	asm {
+		mov bp, EBP;
+	}
+
+    bp = cast(void**)*bp;
+    bp = cast(void**)*bp;
+    bp = cast(void**)*bp;
+    return *(bp + 1);
+}
+
+void callstack_print(FILE* f, void*[] callstack)
+{
+	char** framelist = backtrace_symbols(callstack.ptr, callstack.length);
+	for( int i = 0; i < callstack.length; ++i )
+	{
+		auto line = framelist[i];
+		if (strcmp(line, "<no debug info found>") == 0) {
+			continue;
+		}
+		fwrite(line, 1, strlen(line), f);
+		fwrite("\n".ptr, 1, 1, f);
+	}
+	free(framelist);
+}
+*/
\ No newline at end of file
--- a/dmd/TemplateAliasParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateAliasParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -8,6 +8,7 @@
 import dmd.TypeIdentifier;
 import dmd.ArrayTypes;
 import dmd.Scope;
+import dmd.Global;
 import dmd.Declaration;
 import dmd.MATCH;
 import dmd.OutBuffer;
@@ -47,13 +48,6 @@
 	return o;
 }
 
-__gshared Dsymbol sdummy;
-
-shared static this()
-{
-	sdummy = new Dsymbol();
-}
-
 class TemplateAliasParameter : TemplateParameter
 {
 	/* Syntax:
@@ -66,6 +60,7 @@
 
 	this(Loc loc, Identifier ident, Type specType, Object specAlias, Object defaultAlias)
 	{
+		register();
 		super(loc, ident);
 
 		this.specType = specType;
@@ -217,10 +212,10 @@
 					}
 					else
 					goto Lnomatch;
-					}	
+					}
 			if (specAlias)
 			{
-				if (sa is sdummy)
+				if (sa is global.sdummy)
 					goto Lnomatch;
 				if (sa != specAlias)
 					goto Lnomatch;
@@ -260,7 +255,7 @@
 	{
 		if (!specAlias)
 		{
-			return sdummy;
+			return global.sdummy;
 		}
 		return specAlias;
 	}
--- a/dmd/TemplateDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -123,6 +123,7 @@
 
 	this(Loc loc, Identifier id, TemplateParameters parameters, Expression constraint, Dsymbols decldefs)
 	{	
+		register();
 		super(id);
 		
 	version (LOG) {
--- a/dmd/TemplateExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 
 	this(Loc loc, TemplateDeclaration td)
 	{
+		register();
 		super(loc, TOK.TOKtemplate, TemplateExp.sizeof);
 		//printf("TemplateExp(): %s\n", td.toChars());
 		this.td = td;
--- a/dmd/TemplateInstance.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateInstance.d	Sun Oct 17 07:42:00 2010 +0400
@@ -199,6 +199,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(null);
 		
 	version (LOG) {
@@ -216,6 +217,7 @@
 	 */
     this(Loc loc, TemplateDeclaration td, Objects tiargs)
 	{
+		register();
 		super(null);
 		
 	version (LOG) {
--- a/dmd/TemplateMixin.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateMixin.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 
 	this(Loc loc, Identifier ident, Type tqual, Array idents, Objects tiargs)
 	{
+		register();
 		super(loc, cast(Identifier)idents.data[idents.dim - 1]);
 		//printf("TemplateMixin(ident = '%s')\n", ident ? ident.toChars() : "");
 		this.ident = ident;
--- a/dmd/TemplateParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,7 +16,9 @@
 import dmd.ArrayTypes;
 import dmd.Array;
 
-class TemplateParameter
+import dmd.TObject;
+
+class TemplateParameter : TObject
 {
     /* For type-parameter:
      *	template Foo(ident)		// specType is set to NULL
@@ -37,6 +39,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		this.loc = loc;
 		this.ident = ident;
 	}
--- a/dmd/TemplateThisParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateThisParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,7 @@
 
     this(Loc loc, Identifier ident, Type specType, Type defaultType)
 	{
+		register();
 		super(loc, ident, specType, defaultType);
 	}
 
--- a/dmd/TemplateTupleParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateTupleParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -28,6 +28,7 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(loc, ident);
 		this.ident = ident;
 	}
--- a/dmd/TemplateTypeParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateTypeParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
     this(Loc loc, Identifier ident, Type specType, Type defaultType)
 	{
+		register();
 		super(loc, ident);
 		this.ident = ident;
 		this.specType = specType;
--- a/dmd/TemplateValueParameter.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TemplateValueParameter.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 import dmd.VarDeclaration;
 import dmd.Initializer;
 import dmd.ExpInitializer;
+import dmd.Global;
 import dmd.DefaultInitExp;
 import dmd.STC;
 import dmd.Util;
@@ -24,12 +25,6 @@
 
 import dmd.Dsymbol : isExpression;
 
-static __gshared Expression edummy;
-shared static this()
-{
-	edummy = new Expression(Loc(0), TOK.init, 0);
-}
-
 class TemplateValueParameter : TemplateParameter
 {
     /* Syntax:
@@ -42,8 +37,9 @@
 
     this(Loc loc, Identifier ident, Type valType, Expression specValue, Expression defaultValue)
 	{
+		register();
 		super(loc, ident);
-		
+
 		this.valType = valType;
 		this.specValue = specValue;
 		this.defaultValue = defaultValue;
@@ -53,7 +49,7 @@
 	{
 		return this;
 	}
-	
+
     override TemplateParameter syntaxCopy()
 	{
 		TemplateValueParameter tp = new TemplateValueParameter(loc, ident, valType, specValue, defaultValue);
@@ -82,7 +78,7 @@
 			error(loc, "arithmetic/string type expected for value-parameter, not %s", valType.toChars());
 
 		if (specValue)
-		{   
+		{
 			Expression e = specValue;
 
 			e = e.semantic(sc);
@@ -96,7 +92,7 @@
 
 static if (false) {	// defer semantic analysis to arg match
 		if (defaultValue)
-		{   
+		{
 			Expression e = defaultValue;
 
 			e = e.semantic(sc);
@@ -182,11 +178,11 @@
 		if (i < tiargs.dim)
 			oarg = tiargs[i];
 		else
-		{	
+		{
 			// Get default argument instead
 			oarg = defaultArg(loc, sc);
 			if (!oarg)
-			{   
+			{
 				assert(i < dedtypes.dim);
 				// It might have already been deduced
 				oarg = dedtypes[i];
@@ -202,14 +198,14 @@
 			goto Lnomatch;
 
 		if (ei && ei.op == TOKvar)
-		{	
+		{
 			// Resolve const variables that we had skipped earlier
 			ei = ei.optimize(WANTvalue | WANTinterpret);
 		}
 
 		if (specValue)
 		{
-			if (!ei || ei is edummy)
+			if (!ei || ei is global.edummy)
 				goto Lnomatch;
 
 			Expression e = specValue;
@@ -265,9 +261,9 @@
 	{
 		if (!specValue)
 		{
-			return edummy;
+			return global.edummy;
 		}
-		
+
 		return specValue;
 	}
 }
--- a/dmd/ThisDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ThisDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
     this(Loc loc, Type t)
 	{
+		register();
 		super(loc, t, Id.This, null);
 		noauto = true;
 	}
--- a/dmd/ThisExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ThisExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,6 +33,7 @@
 
 	this(Loc loc)
 	{
+		register();
 		super(loc, TOK.TOKthis, ThisExp.sizeof);
 		//printf("ThisExp::ThisExp() loc = %d\n", loc.linnum);
 	}
--- a/dmd/ThrowStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/ThrowStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 	}
--- a/dmd/TraitsExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TraitsExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -78,6 +78,7 @@
 
 	this(Loc loc, Identifier ident, Objects args)
 	{
+		register();
 		super(loc, TOK.TOKtraits, this.sizeof);
 		this.ident = ident;
 		this.args = args;
--- a/dmd/TryCatchStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TryCatchStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 
     this(Loc loc, Statement body_, Array catches)
 	{
+		register();
 		super(loc);
 		this.body_ = body_;
 		this.catches = catches;
--- a/dmd/TryFinallyStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TryFinallyStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 
     this(Loc loc, Statement body_, Statement finalbody)
 	{
+		register();
 		super(loc);
 		this.body_ = body_;
 		this.finalbody = finalbody;
--- a/dmd/Tuple.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Tuple.d	Sun Oct 17 07:42:00 2010 +0400
@@ -4,12 +4,15 @@
 import dmd.ArrayTypes;
 import dmd.DYNCAST;
 
-class Tuple
+import dmd.TObject;
+
+class Tuple : TObject
 {
 	Objects objects;
 
 	this()
 	{
+		register();
 		objects = new Objects();
 	}
 
--- a/dmd/TupleDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TupleDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 
 	this(Loc loc, Identifier ident, Objects objects)
 	{
+		register();
 		super(ident);
 		this.type = null;
 		this.objects = objects;
--- a/dmd/TupleExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TupleExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -76,6 +76,7 @@
 
 	this(Loc loc, Expressions exps)
 	{
+		register();
 		super(loc, TOKtuple, TupleExp.sizeof);
 		
 		this.exps = exps;
@@ -84,6 +85,7 @@
 
 	this(Loc loc, TupleDeclaration tup)
 	{
+		register();
 		super(loc, TOKtuple, TupleExp.sizeof);
 		exps = new Expressions();
 		type = null;
--- a/dmd/Type.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Type.d	Sun Oct 17 07:42:00 2010 +0400
@@ -225,7 +225,9 @@
     }
 }
 
-class Type
+import dmd.TObject;
+
+class Type : TObject
 {
     TY ty;
     MOD mod;	// modifiers MODxxxx
@@ -451,6 +453,7 @@
 
     this(TY ty)
 	{
+		register();
 		this.ty = ty;
 	}
 
@@ -831,10 +834,11 @@
 			//if (next)
 				//next = next.merge();
 			toDecoBuffer(buf);
-			StringValue* sv = global.type_stringtable.update(buf.extractString());
-			if (sv.ptrvalue)
+			auto s = buf.extractString();
+			Object* sv = global.type_stringtable.update(s);
+			if (*sv)
 			{
-				t = cast(Type) sv.ptrvalue;
+				t = cast(Type) *sv;
 debug {
 				if (!t.deco)
 					writef("t = %s\n", t.toChars());
@@ -844,8 +848,8 @@
 			}
 			else
 			{
-				sv.ptrvalue = cast(void*)this;
-				deco = sv.lstring.string_;
+				*sv = this;
+				deco = s;
 				//printf("new value, deco = '%s' %p\n", t.deco, t.deco);
 			}
 		}
@@ -864,10 +868,10 @@
 		if (!t.deco)
 			return t.merge();
 
-		StringValue* sv = global.type_stringtable.lookup(t.deco);
-		if (sv && sv.ptrvalue)
+		Object* sv = global.type_stringtable.lookup(t.deco);
+		if (sv && *sv)
 		{
-			t = cast(Type)sv.ptrvalue;
+			t = cast(Type)*sv;
 			assert(t.deco);
 		}
 		else
@@ -1173,9 +1177,7 @@
 
 		if (!t)
 		{
-			uint sz = this.classinfo.init.length;
-			t = cast(Type)GC.malloc(sz);
-			memcpy(cast(void*)t, cast(void*)this, sz);
+			t = cloneThis(this);
 			t.mod = mod & ~MODshared;
 			t.deco = null;
 			t.arrayof = null;
@@ -1709,28 +1711,10 @@
 		assert(false);
 	}
 
-version (DumbClone) {
 	final Type clone()
 	{
-		auto size = this.classinfo.init.length;
-		auto ptr = GC.malloc(size);
-		memcpy(ptr, cast(void*)this, size);
-
-		return cast(Type)ptr;
+		return cloneThis(this);
 	}
-} else {
-	final Type cloneTo(Type t)
-	{
-		t.ctype = ctype;
-		return t;
-	}
-
-	Type clone()
-	{
-		assert(this.classinfo is Type.classinfo);
-		return cloneTo(new Type(ty));
-	}
-}
 
     Type arrayOf()
 	{
@@ -2847,7 +2831,7 @@
 	{
 		return null;
 	}
-	
+
 	@property
 	static ref Type[TY.TMAX] basic()
 	{
--- a/dmd/TypeAArray.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeAArray.d	Sun Oct 17 07:42:00 2010 +0400
@@ -52,6 +52,7 @@
 
     this(Type t, Type index)
 	{
+		register();
 		super(Taarray, t);
 		this.index = index;
 	}
@@ -70,13 +71,6 @@
 		return t;
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override ulong size(Loc loc)
 	{
 		return PTRSIZE /* * 2*/;
--- a/dmd/TypeArray.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeArray.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 {
     this(TY ty, Type next)
 	{
+		register();
 		super(ty, next);
 	}
 
@@ -127,12 +128,4 @@
         e = e.semantic(sc);
 		return e;
 	}
-	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
 }
-}
--- a/dmd/TypeBasic.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeBasic.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 
     this(TY ty)
 	{
+		register();
 		super(ty);
 
 		enum TFLAGSintegral	= 1;
@@ -138,13 +139,6 @@
 		merge();
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Type syntaxCopy()
 	{
 		// No semantic analysis done on basic types, no need to copy
--- a/dmd/TypeClass.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeClass.d	Sun Oct 17 07:42:00 2010 +0400
@@ -68,17 +68,11 @@
 
     this(ClassDeclaration sym)
 	{
+		register();
 		super(TY.Tclass);
 		this.sym = sym;
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override ulong size(Loc loc)
 	{
 		return PTRSIZE;
--- a/dmd/TypeDArray.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeDArray.d	Sun Oct 17 07:42:00 2010 +0400
@@ -43,17 +43,11 @@
 {
     this(Type t)
 	{
+		register();
 		super(TY.Tarray, t);
 		//printf("TypeDArray(t = %p)\n", t);
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Type syntaxCopy()
 	{
 		Type t = next.syntaxCopy();
--- a/dmd/TypeDelegate.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeDelegate.d	Sun Oct 17 07:42:00 2010 +0400
@@ -38,17 +38,11 @@
 
     this(Type t)
 	{
+		register();
 		super(TY.Tfunction, t);
 		ty = TY.Tdelegate;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Type syntaxCopy()
 	{
 		Type t = next.syntaxCopy();
--- a/dmd/TypeEnum.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeEnum.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,17 +32,11 @@
 
     this(EnumDeclaration sym)
 	{
+		register();
 		super(TY.Tenum);
 		this.sym = sym;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Type syntaxCopy()
 	{
 		assert(false);
--- a/dmd/TypeExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -17,18 +17,12 @@
 {
 	this(Loc loc, Type type)
 	{
+		register();
 		super(loc, TOK.TOKtype, TypeExp.sizeof);
 		//printf("TypeExp::TypeExp(%s)\n", type->toChars());
 		this.type = type;
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
 	override Expression syntaxCopy()
 	{
 		//printf("TypeExp.syntaxCopy()\n");
--- a/dmd/TypeFunction.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeFunction.d	Sun Oct 17 07:42:00 2010 +0400
@@ -68,6 +68,7 @@
 
     this(Parameters parameters, Type treturn, int varargs, LINK linkage)
 	{
+		register();
 		super(TY.Tfunction, treturn);
 
 		//if (!treturn) *(char*)0=0;
@@ -95,42 +96,6 @@
 		return t;
 	}
 
-version (DumbClone) {
-} else {
-	final TypeFunction cloneTo(TypeFunction t)
-	{
-		super.cloneTo(t);
-		
-		// these 3 should be set by ctor
-		assert(t.parameters is null);
-		assert(t.varargs == varargs);
-		assert(t.linkage == linkage);
-
-		t.isnothrow = isnothrow;
-		t.ispure = ispure;
-		t.isproperty = isproperty;
-		t.isref = isref;
-		t.inuse = inuse;
-
-		if (parameters)
-		{
-			t.parameters = parameters.copy();
-			foreach (arg; parameters)
-			{   
-				Argument cpy = arg.clone();
-				t.parameters[i] = cpy;
-			}
-		}
-
-		return t;
-	}
-
-	TypeFunction clone()
-	{
-		assert(this.classinfo is TypeFunction.classinfo);
-		return cloneTo(new TypeFunction(null, next, varargs, linkage));
-	}
-}
     override Type semantic(Loc loc, Scope sc)
 	{
 		if (deco)			// if semantic() already run
--- a/dmd/TypeIdentifier.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeIdentifier.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,17 +27,11 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(TY.Tident, loc);
 		this.ident = ident;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Type syntaxCopy()
 	{
 		TypeIdentifier t = new TypeIdentifier(loc, ident);
--- a/dmd/TypeInfoArrayDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoArrayDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,6 +16,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoarray.type;
 	}
--- a/dmd/TypeInfoAssociativeArrayDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoAssociativeArrayDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoassociativearray.type;
 	}
--- a/dmd/TypeInfoClassDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoClassDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -17,6 +17,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoclass.type;
 	}
--- a/dmd/TypeInfoConstDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoConstDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoconst.type;
 	}
--- a/dmd/TypeInfoDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 
 	this(Type tinfo, int internal)
 	{
+		register();
 		super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
 		this.tinfo = tinfo;
 		storage_class = STC.STCstatic | STC.STCgshared;
@@ -37,13 +38,6 @@
 		linkage = LINK.LINKc;
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
 	override Dsymbol syntaxCopy(Dsymbol)
 	{
 		assert(false);		  // should never be produced by syntax
--- a/dmd/TypeInfoDelegateDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoDelegateDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfodelegate.type;
 	}
--- a/dmd/TypeInfoEnumDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoEnumDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoenum.type;
 	}
--- a/dmd/TypeInfoFunctionDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoFunctionDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
         type = global.typeinfofunction.type;
 	}
--- a/dmd/TypeInfoInterfaceDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoInterfaceDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfointerface.type;
 	}
--- a/dmd/TypeInfoInvariantDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoInvariantDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfoinvariant.type;
 	}
--- a/dmd/TypeInfoPointerDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoPointerDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfopointer.type;
 	}
--- a/dmd/TypeInfoSharedDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoSharedDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 		type = global.typeinfoshared.type;
 	}
--- a/dmd/TypeInfoStaticArrayDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoStaticArrayDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -15,6 +15,7 @@
 {
     this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfostaticarray.type;
 	}
--- a/dmd/TypeInfoStructDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoStructDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,6 +29,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfostruct.type;
 	}
--- a/dmd/TypeInfoTupleDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoTupleDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -19,6 +19,7 @@
 {
     this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfotypelist.type;
 	}
--- a/dmd/TypeInfoTypedefDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoTypedefDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 {
 	this(Type tinfo)
 	{
+		register();
 		super(tinfo, 0);
 	    type = global.typeinfotypedef.type;
 	}
--- a/dmd/TypeInfoWildDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInfoWildDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
     this(Type tinfo)
     {
+		register();
         super(tinfo, 0);
         type = global.typeinfowild.type;
     }
--- a/dmd/TypeInstance.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeInstance.d	Sun Oct 17 07:42:00 2010 +0400
@@ -33,18 +33,11 @@
 
 	this(Loc loc, TemplateInstance tempinst)
 	{
+		register();
 		super(Tinstance, loc);
 		this.tempinst = tempinst;
 	}
 
-	version (DumbClone) {
-	} else {
-		Type clone()
-		{
-			assert(false);
-		}
-	}
-
 	override Type syntaxCopy()
 	{
 		//printf("TypeInstance::syntaxCopy() %s, %d\n", toChars(), idents.dim);
--- a/dmd/TypeNewArray.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeNewArray.d	Sun Oct 17 07:42:00 2010 +0400
@@ -14,6 +14,7 @@
 {
 	this(Type next)
 	{
+		register();
 		super(Tnarray, next);
 		//writef("TypeNewArray\n");
 	}
--- a/dmd/TypeNext.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeNext.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,23 +16,11 @@
 
     this(TY ty, Type next)
 	{
+		register();
 		super(ty);
 		this.next = next;
 	}
-version (DumbClone) {
-} else {
-	final TypeNext cloneTo(TypeNext t)
-	{
-		super.cloneTo(t);
-		return t;
-	}
 
-	TypeNext clone()
-	{
-		assert(this.classinfo == TypeNext.classinfo);
-		return cloneTo(new TypeNext(ty, next));
-	}
-}
     override void toDecoBuffer(OutBuffer buf, int flag)
 	{
 		super.toDecoBuffer(buf, flag);
--- a/dmd/TypePointer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypePointer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,22 +26,10 @@
 {
     this(Type t)
 	{
+		register();
 		super(TY.Tpointer, t);
 	}
-version (DumbClone) {
-} else {		
-	final TypePointer cloneTo(TypePointer t)
-	{
-		super.cloneTo(t);
-		return t;
-	}
 
-	TypePointer clone()
-	{
-		assert(this.classinfo == TypePointer.classinfo);
-		return cloneTo(new TypePointer(next));
-	}
-}
     override Type syntaxCopy()
 	{
 		Type t = next.syntaxCopy();
--- a/dmd/TypeQualified.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeQualified.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,19 +32,13 @@
 
     this(TY ty, Loc loc)
 	{
+		register();
 		super(ty);
 		this.loc = loc;
 		
 		idents = new Array();
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}	
     void syntaxCopyHelper(TypeQualified t)
 	{
 		//printf("TypeQualified::syntaxCopyHelper(%s) %s\n", t->toChars(), toChars());
--- a/dmd/TypeReference.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeReference.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,18 +18,11 @@
 {
     this(Type t)
 	{
+		register();
 		super(TY.init, null);
 		assert(false);
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-
     override Type syntaxCopy()
 	{
 		assert(false);
--- a/dmd/TypeReturn.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeReturn.d	Sun Oct 17 07:42:00 2010 +0400
@@ -16,17 +16,10 @@
 {
     this(Loc loc)
 	{
+		register();
 		super(TY.Treturn, loc);
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-	
     override Type syntaxCopy()
 	{
 		TypeReturn t = new TypeReturn(loc);
--- a/dmd/TypeSArray.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeSArray.d	Sun Oct 17 07:42:00 2010 +0400
@@ -53,19 +53,12 @@
 
     this(Type t, Expression dim)
 	{
+		register();
 		super(TY.Tsarray, t);
 		//printf("TypeSArray(%s)\n", dim.toChars());
 		this.dim = dim;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-
     override Type syntaxCopy()
 	{
 		Type t = next.syntaxCopy();
--- a/dmd/TypeSlice.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeSlice.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,20 +29,13 @@
 
     this(Type next, Expression lwr, Expression upr)
 	{
+		register();
 		super(TY.Tslice, next);
 		//printf("TypeSlice[%s .. %s]\n", lwr.toChars(), upr.toChars());
 		this.lwr = lwr;
 		this.upr = upr;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-	
     override Type syntaxCopy()
 	{
 		Type t = new TypeSlice(next.syntaxCopy(), lwr.syntaxCopy(), upr.syntaxCopy());
--- a/dmd/TypeStruct.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeStruct.d	Sun Oct 17 07:42:00 2010 +0400
@@ -66,24 +66,10 @@
 
     this(StructDeclaration sym)
 	{
+		register();
 		super(TY.Tstruct);
 		this.sym = sym;
 	}
-version (DumbClone) {
-} else {
-	final TypeStruct cloneTo(TypeStruct t)
-	{
-		super.cloneTo(t);
-		assert(t.sym is sym);
-		return t;
-	}
-
-	TypeStruct clone()
-	{
-		assert(this.classinfo == TypeStruct.classinfo);
-		return cloneTo(new TypeStruct(sym));
-	}
-}
     override ulong size(Loc loc)
 	{
 		return sym.size(loc);
@@ -416,7 +402,6 @@
         return structinit;
     }
 
-
     override bool isZeroInit(Loc loc)
 	{
 		return sym.zeroInit;
--- a/dmd/TypeTuple.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeTuple.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 
 	this(Parameters arguments)
 	{
+		register();
 		super(TY.Ttuple);
 		//printf("TypeTuple(this = %p)\n", this);
 		this.arguments = arguments;
@@ -40,20 +41,13 @@
 		}
 	}
 
-	version (DumbClone) {
-	} else {
-		Type clone()
-		{
-			assert(false);
-		}
-	}
-
 	/****************
 	 * Form TypeTuple from the types of the expressions.
 	 * Assume exps[] is already tuple expanded.
 	 */
 	this(Expressions exps)
 	{
+		register();
 		super(TY.Ttuple);
 		auto arguments = new Parameters;
 		if (exps)
--- a/dmd/TypeTypedef.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeTypedef.d	Sun Oct 17 07:42:00 2010 +0400
@@ -29,18 +29,11 @@
 
     this(TypedefDeclaration sym)
 	{
+		register();
 		super(Ttypedef);
 		this.sym = sym;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-	
     override Type syntaxCopy()
 	{
 		assert(false);
--- a/dmd/TypeTypeof.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeTypeof.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,18 +22,11 @@
 
     this(Loc loc, Expression exp)
 	{
+		register();
 		super(TY.Ttypeof, loc);
 		this.exp = exp;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
-	
     override Type syntaxCopy()
 	{
 		//printf("TypeTypeof.syntaxCopy() %s\n", toChars());
--- a/dmd/TypedefDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypedefDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,7 @@
 
     this(Loc loc, Identifier id, Type basetype, Initializer init)
 	{
+		register();
 		super(id);
 		
 		this.type = new TypeTypedef(this);
@@ -51,13 +52,6 @@
 		this.sinit = null;
 	}
 	
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
     override Dsymbol syntaxCopy(Dsymbol s)
 	{
 		Type basetype = this.basetype.syntaxCopy();
--- a/dmd/TypeidExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/TypeidExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,17 +22,11 @@
 
 	this(Loc loc, Object o)
 	{
+		register();
 		super(loc, TOK.TOKtypeid, TypeidExp.sizeof);
 		this.obj = o;
 	}
 
-version (DumbClone) {
-} else {
-	Type clone()
-	{
-		assert(false);
-	}
-}
 	override Expression syntaxCopy()
 	{
 		return new TypeidExp(loc, objectSyntaxCopy(obj));
--- a/dmd/UAddExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UAddExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 {
 	this(Loc loc, Expression e)
 	{
+		register();
 		super(loc, TOK.TOKuadd, this.sizeof, e);
 	}
 
--- a/dmd/UnaExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UnaExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 
 	this(Loc loc, TOK op, int size, Expression e1)
 	{
+		register();
 		super(loc, op, size);
 		this.e1 = e1;
 	}
--- a/dmd/UnionDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UnionDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -10,6 +10,7 @@
 {
 	this(Loc loc, Identifier id)
 	{
+		register();
 		super(loc, id);
 	}
 
--- a/dmd/UnitTestDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UnitTestDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 {
     this(Loc loc, Loc endloc)
 	{
+		register();
 		super(loc, endloc, unitTestId(), STC.STCundefined, null);
 	}
 
--- a/dmd/UnrolledLoopStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UnrolledLoopStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -27,6 +27,7 @@
 
 	this(Loc loc, Statements s)
 	{
+		register();
 		super(loc);
 		statements = s;
 	}
--- a/dmd/UshrAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UshrAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -22,6 +22,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKushrass, UshrAssignExp.sizeof, e1, e2);
 	}
 	
--- a/dmd/UshrExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/UshrExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -25,6 +25,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKushr, UshrExp.sizeof, e1, e2);
 	}
 
--- a/dmd/Util.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/Util.d	Sun Oct 17 07:42:00 2010 +0400
@@ -32,7 +32,7 @@
 version (Bug4054) import core.memory;
 
 extern(C) int putenv(char*);
-/+version (LOG) 
+/+version (LOG)
 {
 	static if( !is(typeof(printf)) )
 		extern (C) int printf(const char*,...);
@@ -104,19 +104,21 @@
 
 T cloneThis(T)(T ptr)
 {
-	// similar code is used in Type.clone()
-	// TODO: move to Util or something...
-	size_t size = __traits(classInstanceSize, T);
+	size_t size = ptr.classinfo.init.length;
 	void* mem = GC.malloc(size);
 	memcpy(mem, cast(void*)ptr, size);
-	
-	return cast(T)mem;
+
+	auto result = cast(T)mem;
+
+	result.forceRegister();
+
+	return result;
 }
 
 char* strupr(char* s)
 {
     char* t = s;
-    
+
     while (*s)
     {
 		*s = cast(char)toupper(*s);
@@ -133,7 +135,7 @@
 			return p[i..$];
 		}
 	}
-	
+
 	return null;
 }
 
@@ -141,7 +143,7 @@
 {
     while (isspace(*p))
 		p++;
-		
+
 	return p;
 }
 
@@ -218,7 +220,7 @@
 						if (!filename) {
 							goto Letc;		// argv0 not found on path
 						}
-						
+
 						filename = FileName.replaceName(filename, inifile);
 						if (FileName.exists(filename)) {
 							goto Ldone;
@@ -235,7 +237,7 @@
 			}
 		}
     }
-	
+
     path = cast(char*)toStringz(FileName.path(filename));
 
 version (LOG) {
@@ -247,7 +249,7 @@
     if (file.read()) {
 		return;			// error reading file
 	}
-	
+
 	scope OutBuffer buf = new OutBuffer();
 
     // Parse into lines
@@ -365,7 +367,7 @@
 					for (pn = pp.ptr; isalnum(*pn); pn++) {
 						;
 					}
-					
+
 					if (pn - pp.ptr == 11 &&
 						memicmp(pp.ptr, "Environment", 11) == 0 &&
 						*skipspace(pn) == ']'
@@ -463,7 +465,7 @@
 			slash = 0;
 			instring = 0;
 			c = 0;
-			
+
 			char* ecopy = e;
 
 			while (1)
@@ -641,7 +643,7 @@
     precedence[TOK.TOKdiv] = PREC.PREC_mul;
     precedence[TOK.TOKmod] = PREC.PREC_mul;
     precedence[TOKpow]     = PREC.PREC_mul;
-	
+
     precedence[TOK.TOKadd] = PREC.PREC_add;
     precedence[TOK.TOKmin] = PREC.PREC_add;
     precedence[TOK.TOKcat] = PREC.PREC_add;
@@ -739,7 +741,7 @@
     if (global.params.exefile)
 		writeFilename(cmdbuf, global.params.exefile);
     else
-    {	
+    {
 		/* Generate exe file name from first obj name.
 		 * No need to add it to cmdbuf because the linker will default to it.
 		 */
@@ -750,7 +752,7 @@
     }
 
     // Make sure path to exe file exists
-    {	
+    {
 		string pp = FileName.path(global.params.exefile);
 		FileName.ensurePathExists(pp);
     }
@@ -778,7 +780,7 @@
 
     /* Eliminate unnecessary trailing commas	*/
     while (1)
-    {   
+    {
 		i = cmdbuf.offset;
 		if (!i || cmdbuf.data[i - 1] != ',')
 			break;
@@ -855,7 +857,7 @@
     argv.push(cast(void *)cc);
     Array objfiles = new Array;
     for( i = 0; i < global.params.objfiles.dim; i++ )
-    {   string str = (cast(String)global.params.objfiles.data[i]).str; 
+    {   string str = (cast(String)global.params.objfiles.data[i]).str;
     	objfiles.push(cast(void*)toStringz(str));
     }
     argv.insert(1, objfiles);
@@ -976,7 +978,7 @@
     if (status)
 	printf("--- errorlevel %d\n", status);
     return status;
-	
+
 } else {
     writef ("Linking is not yet supported for this version of DMD.\n");
     return -1;
@@ -1003,7 +1005,7 @@
     /* Loop and see if we need to quote
      */
     for (size_t i = 0; i < len; i++)
-    {	
+    {
 		char c = filename[i];
 
 		if (isalnum(c) || c == '_')
@@ -1042,13 +1044,13 @@
     }
 
     if (len > 255)
-    {   
+    {
 		char* q;
 		char[9] envname = "@_CMDLINE";
 
 		envname[0] = '@';
 		switch (useenv)
-		{   
+		{
 			case 0:	goto L1;
 			case 2: envname[0] = '%';	break;
 			default: break;	///
@@ -1139,42 +1141,43 @@
 }
 }
 }
-/*
+
 extern(C++) void util_assert(char* file,int line)
 {
     fflush(stdout);
     printf("Internal error: %s %d\n",file,line);
     throw new Exception("Internal error");
 }
-
+/*
 extern (C++) {
 	void* mem_malloc(uint size)
 	{
 		return GC.malloc(size);
 	}
-	
+
 	void* mem_calloc(uint size)
 	{
 		return GC.calloc(size);
 	}
-	
+
 	void* mem_realloc(void* ptr, uint size)
 	{
 		return GC.realloc(ptr, size);
 	}
-	
+
 	void mem_free(void* ptr)
 	{
 		GC.free(ptr);
 	}
-	
+
 	void* mem_fmalloc(uint size)
 	{
 		return mem_malloc(size);
 	}
-	
+
 	void* mem_fcalloc(uint size)
 	{
 		return mem_calloc(size);
 	}
-}*/
\ No newline at end of file
+}
+*/
\ No newline at end of file
--- a/dmd/VarDeclaration.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VarDeclaration.d	Sun Oct 17 07:42:00 2010 +0400
@@ -95,6 +95,7 @@
 
     this(Loc loc, Type type, Identifier id, Initializer init)
 	{
+		register();
 		super(id);
 		
 debug
--- a/dmd/VarExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VarExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -30,6 +30,7 @@
 {
 	this(Loc loc, Declaration var, bool hasOverloads = false)
 	{
+		register();
 		super(loc, TOK.TOKvar, VarExp.sizeof, var, hasOverloads);
 		
 		//printf("VarExp(this = %p, '%s', loc = %s)\n", this, var.toChars(), loc.toChars());
--- a/dmd/VersionCondition.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VersionCondition.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,12 +21,11 @@
 
 import std.stdio;
 
-bool findCondition(Array ids, Identifier ident)
+bool findCondition(Vector!(string) ids, Identifier ident)
 {
     if (ids !is null) {
-		foreach (i; 0..ids.dim)
+		foreach (id; ids)
 		{
-			string id = (cast(String)ids.data[i]).str;
 			if (id == ident.toChars()) {
 				return true;
 			}
@@ -42,7 +41,7 @@
 	{
 		global.params.versionlevel = level;
 	}
-	
+
     static void checkPredefined(Loc loc, string ident)
 	{
 version (DMDV2)
@@ -89,20 +88,21 @@
 	  Lerror:
 		error(loc, "version identifier '%s' is reserved and cannot be set", ident);
 	}
-	
+
     static void addGlobalIdent(string ident)
 	{
 		checkPredefined(Loc(0), ident);
 		addPredefinedGlobalIdent(ident);
 	}
-	
+
     static void addPredefinedGlobalIdent(string ident)
 	{
-		global.params.versionids.push(cast(void*)new String(ident));	///
+		global.params.versionids.push(ident);	///
 	}
 
     this(Module mod, uint level, Identifier ident)
 	{
+		register();
 		super(mod, level, ident);
 	}
 
@@ -118,10 +118,7 @@
 				} else if (findCondition(global.params.versionids, ident)) {
 					inc = 1;
 				} else {
-					if (!mod.versionidsNot) {
-						mod.versionidsNot = new Array();
-					}
-					mod.versionidsNot.push(cast(void*)new String(ident.toChars()));	//
+					mod.versionidsNot.push(ident.toChars());
 				}
 			} else if (level <= global.params.versionlevel || level <= mod.versionlevel) {
 				inc = 1;
@@ -130,7 +127,7 @@
 
 		return (inc == 1);
 	}
-	
+
     override final void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		if (ident !is null) {
--- a/dmd/VersionSymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VersionSymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -23,18 +23,20 @@
 
     this(Loc loc, Identifier ident)
 	{
+		register();
 		super(ident);
 		this.loc = loc;
 	}
-	
+
     this(Loc loc, uint level)
 	{
+		register();
 		super();
 
 		this.level = level;
 		this.loc = loc;
 	}
-	
+
     override Dsymbol syntaxCopy(Dsymbol s)
 	{
 		assert(!s);
@@ -42,7 +44,7 @@
 		ds.level = level;
 		return ds;
 	}
-	
+
     override bool addMember(Scope sc, ScopeDsymbol s, bool memnum)
 	{
 		//printf("VersionSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
@@ -59,9 +61,7 @@
 			{
 				if (findCondition(m.versionidsNot, ident))
 					error("defined after use");
-				if (!m.versionids)
-					m.versionids = new Array();
-				m.versionids.push(cast(void*)new String(ident.toChars()));
+				m.versionids.push(ident.toChars());
 			}
 		}
 		else
@@ -74,11 +74,11 @@
 
 		return false;
 	}
-	
+
     override void semantic(Scope sc)
 	{
 	}
-	
+
     override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		buf.writestring("version = ");
@@ -89,7 +89,7 @@
 		buf.writestring(";");
 		buf.writenl();
 	}
-	
+
     override string kind()
 	{
 		return "version";
--- a/dmd/VoidInitializer.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VoidInitializer.d	Sun Oct 17 07:42:00 2010 +0400
@@ -18,6 +18,7 @@
 
     this(Loc loc)
 	{
+		register();
 		super(loc);
 	}
 	
--- a/dmd/VolatileStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/VolatileStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 
     this(Loc loc, Statement statement)
 	{
+		register();
 		super(loc);
 		this.statement = statement;
 	}
--- a/dmd/WhileStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/WhileStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 
     this(Loc loc, Expression c, Statement b)
 	{
+		register();
 		super(loc);
 		condition = c;
 		body_ = b;
--- a/dmd/WithScopeSymbol.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/WithScopeSymbol.d	Sun Oct 17 07:42:00 2010 +0400
@@ -13,6 +13,7 @@
 
     this(WithStatement withstate)
 	{
+		register();
 		this.withstate = withstate;
 	}
 	
--- a/dmd/WithStatement.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/WithStatement.d	Sun Oct 17 07:42:00 2010 +0400
@@ -37,6 +37,7 @@
 
     this(Loc loc, Expression exp, Statement body_)
 	{
+		register();
 		super(loc);
 		this.exp = exp;
 		this.body_ = body_;
--- a/dmd/XorAssignExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/XorAssignExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -20,6 +20,7 @@
 {
     this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKxorass, this.sizeof, e1, e2);
 	}
 	
--- a/dmd/XorExp.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/XorExp.d	Sun Oct 17 07:42:00 2010 +0400
@@ -26,6 +26,7 @@
 {
 	this(Loc loc, Expression e1, Expression e2)
 	{
+		register();
 		super(loc, TOK.TOKxor, XorExp.sizeof, e1, e2);
 	}
 
--- a/dmd/backend/LIST.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/backend/LIST.d	Sun Oct 17 07:42:00 2010 +0400
@@ -21,7 +21,7 @@
 alias list_t symlist_t;		/* pointer to a list entry		*/
 
 extern (C++) extern {
-	extern(C) extern __gshared list_t slist;
 	list_t list_prepend(list_t* plist, void* ptr);
 	void slist_add(Symbol* s);
+	void slist_cleanup();
 }
--- a/dmd/backend/glue.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/backend/glue.d	Sun Oct 17 07:42:00 2010 +0400
@@ -57,11 +57,11 @@
 	{
 		assert(false);
 	}
-	
+
     ~this()
 	{
 	}
-	
+
     void reset()
 	{
 		assert(false);
@@ -252,7 +252,7 @@
 	{
 		assert(false);
 	}
-	
+
     void setsize(uint size)
 	{
 		assert(false);
@@ -262,7 +262,7 @@
 	{
 		assert(false);
 	}
-	
+
     void writeuLEB128(uint value)
 	{
 		assert(false);
@@ -272,7 +272,7 @@
 /**************************************
  * Append s to list of object files to generate later.
  */
- 
+
 void obj_append(Dsymbol s)
 {
     global.obj_symbols_towrite.push(cast(void*)s);
@@ -286,7 +286,7 @@
 else
 {
 	extern (C++) {
-		void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);	
+		void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
 	}
 }
 
@@ -332,7 +332,7 @@
 void obj_end(Library library, File objfile)
 {
 	obj_term();
-	
+
 	auto objbuf = &global.objbuf;
 
     if (library)
@@ -365,13 +365,13 @@
 {
 	auto obj_symbols_towrite = global.obj_symbols_towrite;
 	for (int i = 0; i < obj_symbols_towrite.dim; i++)
-    {	
+    {
 		Dsymbol s = cast(Dsymbol)obj_symbols_towrite.data[i];
 		Module m = s.getModule();
 
 		string mname;
 		if (m)
-		{   
+		{
 			mname = m.srcfile.toChars();
 			global.lastmname = mname;
 		}
@@ -413,7 +413,7 @@
 		 * as mangled symbol names get way too long.
 		 */
 		string fname = FileName.removeExt(mname);
-		
+
 		OutBuffer namebuf = new OutBuffer();
 		uint hash = 0;
 		foreach (char c; s.toChars())
@@ -461,7 +461,7 @@
     else if (params.link && !global.params.deffile)
 		config.wflags |= WFexe;		// EXE file only optimizations
     else if (params.exefile)		// if writing out EXE file
-    {	
+    {
 		size_t len = params.exefile.length;
 		if (len >= 4 && icmp(params.exefile[len-3..len], "exe") == 0)
 			config.wflags |= WFexe;
--- a/dmd/codegen/Util.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/dmd/codegen/Util.d	Sun Oct 17 07:42:00 2010 +0400
@@ -1132,7 +1132,7 @@
 					es.Eoper = OPER.OPstring;
 
 					// Match MEM_PH_FREE for OPstring in ztc\el.c
-					es.EV.ss.Vstring = cast(char*)malloc(len);	/// !
+					es.EV.ss.Vstring = cast(char*)GC.malloc(len);	/// !
 					memcpy(es.EV.ss.Vstring, &e.EV, len);
 
 					es.EV.ss.Vstrlen = len;
--- a/main.d	Sun Oct 10 10:38:55 2010 +0400
+++ b/main.d	Sun Oct 17 07:42:00 2010 +0400
@@ -493,8 +493,6 @@
                 global.params.useUnitTests = 1;
             else if (p[1] == 'I')
             {
-                if (!global.params.imppath)
-                    global.params.imppath = new Array();
                 global.params.imppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$]));	///
             }
             else if (p[1] == 'J')
@@ -977,7 +975,6 @@
         }
 }
 
-		//while (loop) {}
         m.parse();
         if (m.isDocFile)
         {