# HG changeset patch # User korDen # Date 1287286920 -14400 # Node ID e3afd1303184270eee02f65018cdb0f5cee39d97 # Parent 1475fd394c9e7926ca87d9c20879779b905a2803 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) diff -r 1475fd394c9e -r e3afd1303184 commands.linux.txt --- 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 diff -r 1475fd394c9e -r e3afd1303184 commands.txt --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/AddAssignExp.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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AddExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AddrExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AggregateDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/AliasDeclaration.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/AliasThis.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/AlignDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/AndAndExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AndAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AndExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AnonDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/AnonymousAggregateDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Array.d --- 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() diff -r 1475fd394c9e -r e3afd1303184 dmd/ArrayExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ArrayInitializer.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/ArrayLengthExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ArrayLiteralExp.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/ArrayScopeSymbol.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/AsmStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/AssertExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/AssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/AssocArrayLiteralExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/AttribDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/BaseClass.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/BinExp.d --- 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) diff -r 1475fd394c9e -r e3afd1303184 dmd/BoolExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/BreakStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/CallExp.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/CaseRangeStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CaseStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CastExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CatAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/CatExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Catch.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ClassDeclaration.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/ClassInfoDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CmpExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ComExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/CommaExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/CompileDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CompileExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/CompileStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ComplexExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/CompoundDeclarationStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/CompoundStatement.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/CondExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/Condition.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ConditionalDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ConditionalStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ContinueStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/CtorDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DVCondition.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DebugCondition.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DebugSymbol.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/Declaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DeclarationExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DeclarationStatement.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DefaultInitExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DefaultStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DelegateExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DeleteDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DeleteExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DivAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DivExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DoStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DocComment.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DollarExp.d --- 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); } } diff -r 1475fd394c9e -r e3afd1303184 dmd/DotExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/DotIdExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DotTemplateExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DotTemplateInstanceExp.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/DotTypeExp.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/Dsymbol.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/DsymbolExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/DsymbolTable.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/DtorDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/EnumDeclaration.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/EnumMember.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/EqualExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ErrorExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ExpInitializer.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ExpStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Expression.d --- 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() diff -r 1475fd394c9e -r e3afd1303184 dmd/File.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/FileExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/FileInitExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/FileName.d --- 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)); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ForStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ForeachRangeStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ForeachStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/FuncAliasDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/FuncDeclaration.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/FuncExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/FuncLiteralDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Global.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/GotoCaseStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/GotoDefaultStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/GotoStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/HaltExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IRState.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/Identifier.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/IdentifierExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IdentityExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IfStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Import.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/InExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IndexExp.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Initializer.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/InlineDoState.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IntegerExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/InterState.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/InterfaceDeclaration.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/InvariantDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/IsExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/LabelDsymbol.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/LabelStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Lexer.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/Library.d --- 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); } - + } } diff -r 1475fd394c9e -r e3afd1303184 dmd/LineInitExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/LinkDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Loc.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/MinAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/MinExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ModAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ModExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Module.d --- 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) diff -r 1475fd394c9e -r e3afd1303184 dmd/ModuleDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ModuleInfoDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/MulAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/MulExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/NegExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/NewAnonClassExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/NewDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/NewExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/NotExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/NullExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/OnScopeStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/OrAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/OrExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/OrOrExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/OutBuffer.d --- 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 } diff -r 1475fd394c9e -r e3afd1303184 dmd/OverExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/OverloadSet.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Package.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Param.d --- 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 +} diff -r 1475fd394c9e -r e3afd1303184 dmd/Parameter.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Parser.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/PeelStatement.d --- 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)); } diff -r 1475fd394c9e -r e3afd1303184 dmd/PostBlitDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/PostExp.d --- 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)); } diff -r 1475fd394c9e -r e3afd1303184 dmd/PowAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/PowExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/PragmaDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/PragmaStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ProtDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/PtrExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/RealExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/RemoveExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ReturnStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/Scope.d --- 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_; diff -r 1475fd394c9e -r e3afd1303184 dmd/ScopeDsymbol.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ScopeExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ScopeStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/Section.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/ShlAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ShlExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ShrAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ShrExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/SliceExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Statement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticAssert.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticAssertStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticCtorDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticDtorDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticIfCondition.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/StaticIfDeclaration.d --- 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"); } diff -r 1475fd394c9e -r e3afd1303184 dmd/StorageClassDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/String.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/StringEntry.d --- 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; } } diff -r 1475fd394c9e -r e3afd1303184 dmd/StringExp.d --- 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_; diff -r 1475fd394c9e -r e3afd1303184 dmd/StringTable.d --- 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; } + */ } diff -r 1475fd394c9e -r e3afd1303184 dmd/StringValue.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/StructDeclaration.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/StructInitializer.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/StructLiteralExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/SuperExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/SwitchErrorStatement.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/SwitchStatement.d --- 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 */ diff -r 1475fd394c9e -r e3afd1303184 dmd/SymOffExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/SymbolDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/SymbolExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/SynchronizedStatement.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/TObject.d --- /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, "") == 0) { + continue; + } + fwrite(line, 1, strlen(line), f); + fwrite("\n".ptr, 1, 1, f); + } + free(framelist); +} +*/ \ No newline at end of file diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateAliasParameter.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateDeclaration.d --- 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) { diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateInstance.d --- 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) { diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateMixin.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateParameter.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateThisParameter.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateTupleParameter.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateTypeParameter.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TemplateValueParameter.d --- 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; } } diff -r 1475fd394c9e -r e3afd1303184 dmd/ThisDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/ThisExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/ThrowStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TraitsExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TryCatchStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TryFinallyStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Tuple.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/TupleDeclaration.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TupleExp.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/Type.d --- 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() { diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeAArray.d --- 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*/; diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeArray.d --- 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); - } } -} diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeBasic.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeClass.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeDArray.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeDelegate.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeEnum.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeExp.d --- 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"); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeFunction.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeIdentifier.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoArrayDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoAssociativeArrayDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoClassDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoConstDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoDeclaration.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoDelegateDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoEnumDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoFunctionDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoInterfaceDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoInvariantDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoPointerDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoSharedDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoStaticArrayDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoStructDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoTupleDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoTypedefDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInfoWildDeclaration.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeInstance.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeNewArray.d --- 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"); } diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeNext.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypePointer.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeQualified.d --- 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()); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeReference.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeReturn.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeSArray.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeSlice.d --- 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()); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeStruct.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeTuple.d --- 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) diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeTypedef.d --- 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); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeTypeof.d --- 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()); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypedefDeclaration.d --- 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(); diff -r 1475fd394c9e -r e3afd1303184 dmd/TypeidExp.d --- 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)); diff -r 1475fd394c9e -r e3afd1303184 dmd/UAddExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/UnaExp.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/UnionDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/UnitTestDeclaration.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/UnrolledLoopStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/UshrAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/UshrExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/Util.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/VarDeclaration.d --- 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 diff -r 1475fd394c9e -r e3afd1303184 dmd/VarExp.d --- 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()); diff -r 1475fd394c9e -r e3afd1303184 dmd/VersionCondition.d --- 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) { diff -r 1475fd394c9e -r e3afd1303184 dmd/VersionSymbol.d --- 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"; diff -r 1475fd394c9e -r e3afd1303184 dmd/VoidInitializer.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/VolatileStatement.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/WhileStatement.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/WithScopeSymbol.d --- 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; } diff -r 1475fd394c9e -r e3afd1303184 dmd/WithStatement.d --- 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_; diff -r 1475fd394c9e -r e3afd1303184 dmd/XorAssignExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/XorExp.d --- 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); } diff -r 1475fd394c9e -r e3afd1303184 dmd/backend/LIST.d --- 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(); } diff -r 1475fd394c9e -r e3afd1303184 dmd/backend/glue.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 dmd/codegen/Util.d --- 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; diff -r 1475fd394c9e -r e3afd1303184 main.d --- 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) {