Mercurial > projects > ddmd
changeset 166:d8565fbd755c
Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
author | korDen |
---|---|
date | Thu, 30 Sep 2010 10:30:15 +0400 |
parents | 25ede4f66bda |
children | 50a6d232176c |
files | dmd/ClassDeclaration.d dmd/ClassInfoDeclaration.d dmd/Global.d dmd/InterfaceDeclaration.d dmd/TypeClass.d |
diffstat | 5 files changed, 32 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/ClassDeclaration.d Thu Sep 30 10:04:32 2010 +0400 +++ b/dmd/ClassDeclaration.d Thu Sep 30 10:30:15 2010 +0400 @@ -71,7 +71,7 @@ enum OFFSET_RUNTIME = 0x76543210; -struct Param +struct FuncDeclarationFinder { bool visit(FuncDeclaration fd2) { @@ -84,9 +84,6 @@ class ClassDeclaration : AggregateDeclaration { - static __gshared ClassDeclaration object; - static __gshared ClassDeclaration classinfo; - ClassDeclaration baseClass; // null only if this is Object version(DMDV1) { CtorDeclaration *ctor; @@ -270,17 +267,17 @@ if (id is Id.Object_) { - if (object) - object.error("%s", msg); - object = this; + if (global.object) + global.object.error("%s", msg); + global.object = this; } // if (id is Id.ClassInfo) if (id is Id.TypeInfo_Class) { - if (classinfo) - classinfo.error("%s", msg); - classinfo = this; + if (global.classinfo) + global.classinfo.error("%s", msg); + global.classinfo = this; } if (id is Id.ModuleInfo) @@ -546,7 +543,7 @@ TypeClass tc; Type bt; - if (!object) + if (!global.object) { error("missing or corrupt object.d"); fatal(); @@ -963,7 +960,7 @@ return false; } - Param p; p.fd = fd; + FuncDeclarationFinder p; p.fd = fd; s = s.toAlias(); OverloadSet os = s.isOverloadSet(); @@ -1116,8 +1113,8 @@ ident is Id.TypeInfo_Class || ident is Id.TypeInfo_Typedef || ident is Id.TypeInfo_Tuple || - this is object || - this is classinfo || + this is global.object || + this is global.classinfo || this is Module.moduleinfo || ident.toChars().startsWith("TypeInfo_") ) @@ -1345,16 +1342,17 @@ */ dt_t* dt = null; offset = CLASSINFO_SIZE; // must be ClassInfo.size - if (classinfo) + if (global.classinfo) { - if (classinfo.structsize != CLASSINFO_SIZE) + if (global.classinfo.structsize != CLASSINFO_SIZE) error("D compiler and phobos' object.d are mismatched"); + + dtxoff(&dt, global.classinfo.toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo } - - if (classinfo) - dtxoff(&dt, classinfo.toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo else + { dtdword(&dt, 0); // BUG: should be an assert() + } dtdword(&dt, 0); // monitor
--- a/dmd/ClassInfoDeclaration.d Thu Sep 30 10:04:32 2010 +0400 +++ b/dmd/ClassInfoDeclaration.d Thu Sep 30 10:30:15 2010 +0400 @@ -3,6 +3,7 @@ import dmd.common; import dmd.VarDeclaration; import dmd.ClassDeclaration; +import dmd.Global; import dmd.Dsymbol; import dmd.Scope; import dmd.Loc; @@ -24,7 +25,7 @@ this(ClassDeclaration cd) { - super(Loc(0), ClassDeclaration.classinfo.type, cd.ident, null); + super(Loc(0), global.classinfo.type, cd.ident, null); this.cd = cd; storage_class = STC.STCstatic | STC.STCgshared;
--- a/dmd/Global.d Thu Sep 30 10:04:32 2010 +0400 +++ b/dmd/Global.d Thu Sep 30 10:30:15 2010 +0400 @@ -3,6 +3,7 @@ import dmd.common; import dmd.Array; import dmd.Param; +import dmd.ClassDeclaration; class Global { @@ -45,6 +46,9 @@ uint errors; // number of errors reported so far uint gag; // !=0 means gag reporting of errors + ClassDeclaration object; + ClassDeclaration classinfo; + this() { params.versionids = new Array();
--- a/dmd/InterfaceDeclaration.d Thu Sep 30 10:04:32 2010 +0400 +++ b/dmd/InterfaceDeclaration.d Thu Sep 30 10:30:15 2010 +0400 @@ -306,18 +306,18 @@ if (j && bc.base.isInterfaceDeclaration()) *poffset = OFFSET_RUNTIME; } - return 1; + return true; } if (isBaseOf(b, poffset)) { if (j && poffset && bc.base.isInterfaceDeclaration()) *poffset = OFFSET_RUNTIME; - return 1; + return true; } } if (poffset) *poffset = 0; - return 0; + return false; } override string kind() @@ -412,8 +412,8 @@ */ dt_t *dt = null; - if (classinfo) - dtxoff(&dt, classinfo.toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo + if (global.classinfo) + dtxoff(&dt, global.classinfo.toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo else dtdword(&dt, 0); // BUG: should be an assert() dtdword(&dt, 0); // monitor @@ -436,8 +436,8 @@ dtdword(&dt, vtblInterfaces.dim); if (vtblInterfaces.dim) { - if (classinfo) - assert(classinfo.structsize == CLASSINFO_SIZE); + if (global.classinfo) + assert(global.classinfo.structsize == CLASSINFO_SIZE); offset = CLASSINFO_SIZE; dtxoff(&dt, csym, offset, TYnptr); // (*) }
--- a/dmd/TypeClass.d Thu Sep 30 10:04:32 2010 +0400 +++ b/dmd/TypeClass.d Thu Sep 30 10:30:15 2010 +0400 @@ -192,8 +192,8 @@ if (ident is Id.classinfo_) { - assert(ClassDeclaration.classinfo); - Type t = ClassDeclaration.classinfo.type; + assert(global.classinfo); + Type t = global.classinfo.type; if (e.op == TOK.TOKtype || e.op == TOK.TOKdottype) { /* For type.classinfo, we know the classinfo