diff -uNr dmd-1.00/dmd/src/dmd/declaration.c dmd-1.001/dmd/src/dmd/declaration.c --- dmd-1.00/dmd/src/dmd/declaration.c 2006-12-31 22:25:58.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/declaration.c 2007-01-14 22:38:50.000000000 +0100 @@ -164,6 +164,7 @@ this->sem = 0; this->inuse = 0; this->loc = loc; + this->sinit = NULL; } Dsymbol *TypedefDeclaration::syntaxCopy(Dsymbol *s) diff -uNr dmd-1.00/dmd/src/dmd/declaration.h dmd-1.001/dmd/src/dmd/declaration.h --- dmd-1.00/dmd/src/dmd/declaration.h 2006-12-10 20:06:22.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/declaration.h 2007-01-14 22:38:58.000000000 +0100 @@ -165,6 +165,9 @@ int cvMember(unsigned char *p); TypedefDeclaration *isTypedefDeclaration() { return this; } + + Symbol *sinit; + Symbol *toInitializer(); }; /**************************************************************/ diff -uNr dmd-1.00/dmd/src/dmd/expression.c dmd-1.001/dmd/src/dmd/expression.c --- dmd-1.00/dmd/src/dmd/expression.c 2006-12-30 18:15:16.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/expression.c 2007-01-23 13:43:14.000000000 +0100 @@ -1286,7 +1286,10 @@ int RealEquals(real_t x1, real_t x2) { return (isnan(x1) && isnan(x2)) || - memcmp(&x1, &x2, sizeof(real_t)) == 0; + /* In some cases, the REALPAD bytes get garbage in them, + * so be sure and ignore them. + */ + memcmp(&x1, &x2, REALSIZE - REALPAD) == 0; } int RealExp::equals(Object *o) diff -uNr dmd-1.00/dmd/src/dmd/import.c dmd-1.001/dmd/src/dmd/import.c --- dmd-1.00/dmd/src/dmd/import.c 2006-10-16 00:10:10.000000000 +0200 +++ dmd-1.001/dmd/src/dmd/import.c 2007-01-22 20:51:20.000000000 +0100 @@ -77,7 +77,7 @@ return si; } -void Import::load() +void Import::load(Scope *sc) { DsymbolTable *dst; Dsymbol *s; @@ -102,6 +102,8 @@ mod = Module::load(loc, packages, id); dst->insert(id, mod); // id may be different from mod->ident, // if so then insert alias + if (!mod->importedFrom) + mod->importedFrom = sc ? sc->module->importedFrom : Module::rootModule; } if (!pkg) pkg = mod; @@ -115,16 +117,19 @@ { //printf("Import::semantic('%s')\n", toChars()); - load(); + load(sc); if (mod) { +#if 0 if (mod->loc.linnum != 0) { /* If the line number is not 0, then this is not * a 'root' module, i.e. it was not specified on the command line. */ mod->importedFrom = sc->module->importedFrom; + assert(mod->importedFrom); } +#endif if (!isstatic && !aliasId && !names.dim) { @@ -225,7 +230,7 @@ //printf("%s.Import::search(ident = '%s', flags = x%x)\n", toChars(), ident->toChars(), flags); if (!pkg) - load(); + load(NULL); // Forward it to the package/module return pkg->search(loc, ident, flags); diff -uNr dmd-1.00/dmd/src/dmd/import.h dmd-1.001/dmd/src/dmd/import.h --- dmd-1.00/dmd/src/dmd/import.h 2006-10-05 16:01:48.000000000 +0200 +++ dmd-1.001/dmd/src/dmd/import.h 2007-01-22 20:47:20.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -50,7 +50,7 @@ char *kind(); Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees - void load(); + void load(Scope *sc); void semantic(Scope *sc); void semantic2(Scope *sc); Dsymbol *toAlias(); diff -uNr dmd-1.00/dmd/src/dmd/inline.c dmd-1.001/dmd/src/dmd/inline.c --- dmd-1.00/dmd/src/dmd/inline.c 2006-12-30 11:54:36.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/inline.c 2007-01-16 00:56:06.000000000 +0100 @@ -233,6 +233,7 @@ if (declaration->isStructDeclaration() || declaration->isClassDeclaration() || declaration->isFuncDeclaration() || + declaration->isTypedefDeclaration() || declaration->isTemplateMixin()) return COST_MAX; diff -uNr dmd-1.00/dmd/src/dmd/mars.c dmd-1.001/dmd/src/dmd/mars.c --- dmd-1.00/dmd/src/dmd/mars.c 2007-01-02 12:04:58.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/mars.c 2007-01-22 20:49:24.000000000 +0100 @@ -60,7 +60,7 @@ copyright = "Copyright (c) 1999-2007 by Digital Mars"; written = "written by Walter Bright"; - version = "v1.0"; + version = "v1.001"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -126,7 +126,7 @@ void fatal() { #if 0 - *(char *)0 = 0; + halt(); #endif exit(EXIT_FAILURE); } @@ -154,7 +154,7 @@ Usage:\n\ dmd files.d ... { -switch }\n\ \n\ - files.d D source files\n\ + files.d D source files\n%s\ -c do not link\n\ -cov do code coverage analysis\n\ -D generate documentation\n\ @@ -189,7 +189,13 @@ -version=level compile in version code >= level\n\ -version=ident compile in version code identified by ident\n\ -w enable warnings\n\ -"); +", +#if WIN32 +" @cmdfile read arguments from cmdfile\n" +#else +"" +#endif +); } int main(int argc, char *argv[]) @@ -692,6 +698,9 @@ m = (Module *)modules.data[i]; if (global.params.verbose) printf("parse %s\n", m->toChars()); + if (!Module::rootModule) + Module::rootModule = m; + m->importedFrom = m; m->deleteObjFile(); m->read(0); m->parse(); diff -uNr dmd-1.00/dmd/src/dmd/mars.h dmd-1.001/dmd/src/dmd/mars.h --- dmd-1.00/dmd/src/dmd/mars.h 2006-12-14 18:38:38.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/mars.h 2007-01-09 13:34:04.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -16,6 +16,7 @@ #endif /* __DMC__ */ #include +#include #ifdef IN_GCC /* Changes for the GDC compiler by David Friedman */ @@ -241,7 +242,7 @@ }; void error(Loc loc, const char *format, ...); -void verror(Loc loc, const char *format, char *); +void verror(Loc loc, const char *format, va_list); void fatal(); void err_nomem(); int runLINK(); diff -uNr dmd-1.00/dmd/src/dmd/module.c dmd-1.001/dmd/src/dmd/module.c --- dmd-1.00/dmd/src/dmd/module.c 2006-12-29 11:08:42.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/module.c 2007-01-22 20:50:48.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -42,6 +42,7 @@ ClassDeclaration *Module::moduleinfo; +Module *Module::rootModule; DsymbolTable *Module::modules; Array Module::amodules; @@ -88,7 +89,8 @@ sdtor = NULL; stest = NULL; sfilename = NULL; - importedFrom = this; + root = 0; + importedFrom = NULL; srcfile = NULL; docfile = NULL; diff -uNr dmd-1.00/dmd/src/dmd/module.h dmd-1.001/dmd/src/dmd/module.h --- dmd-1.00/dmd/src/dmd/module.h 2006-12-29 11:06:46.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/module.h 2007-01-22 20:49:26.000000000 +0100 @@ -46,6 +46,7 @@ struct Module : Package { + static Module *rootModule; static DsymbolTable *modules; // symbol table of all modules static Array amodules; // array of all modules static Array deferred; // deferred Dsymbol's needing semantic() run on them @@ -78,6 +79,9 @@ int semanticstarted; // has semantic() been started? int semanticdone; // has semantic() been done? + int root; // != 0 if this is a 'root' module, + // i.e. a module that will be taken all the + // way to an object file Module *importedFrom; // module from command line we're imported from, // i.e. a module that will be taken all the // way to an object file diff -uNr dmd-1.00/dmd/src/dmd/mtype.c dmd-1.001/dmd/src/dmd/mtype.c --- dmd-1.00/dmd/src/dmd/mtype.c 2007-01-01 21:46:54.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/mtype.c 2007-01-22 13:17:14.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -710,6 +710,16 @@ return NULL; } +/*************************************** + * Return !=0 if type has pointers that need to + * be scanned by the GC during a collection cycle. + */ + +int Type::hasPointers() +{ + return FALSE; +} + /* ============================= TypeBasic =========================== */ TypeBasic::TypeBasic(TY ty) @@ -1478,18 +1488,21 @@ FuncDeclaration *fd; Expressions *arguments; int size = next->size(e->loc); + int dup; char *nm; - static char *name[2][2] = { { "_adReverse", "_adDup" }, - { "_adReverseBit", "_adDupBit" } }; + static char *name[2] = { "_adReverse", "_adDupT" }; assert(size); - nm = name[n->ty == Tbit][ident == Id::dup]; + dup = (ident == Id::dup); + nm = name[dup]; fd = FuncDeclaration::genCfunc(Type::tindex, nm); ec = new VarExp(0, fd); e = e->castTo(sc, n->arrayOf()); // convert to dynamic array arguments = new Expressions(); + if (dup) + arguments->push(getTypeInfo(sc)); arguments->push(e); - if (next->ty != Tbit) + if (!dup) arguments->push(new IntegerExp(0, size, Type::tint32)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); @@ -1572,6 +1585,7 @@ #endif } + /***************************** TypeSArray *****************************/ TypeSArray::TypeSArray(Type *t, Expression *dim) @@ -1839,6 +1853,11 @@ return e; } +int TypeSArray::hasPointers() +{ + return next->hasPointers(); +} + /***************************** TypeDArray *****************************/ TypeDArray::TypeDArray(Type *t) @@ -1977,11 +1996,21 @@ return e; } +int TypeDArray::isZeroInit() +{ + return 1; +} + int TypeDArray::checkBoolean() { return TRUE; } +int TypeDArray::hasPointers() +{ + return TRUE; +} + /***************************** TypeAArray *****************************/ TypeAArray::TypeAArray(Type *t, Type *index) @@ -2197,6 +2226,11 @@ return TRUE; } +int TypeAArray::hasPointers() +{ + return TRUE; +} + /***************************** TypePointer *****************************/ TypePointer::TypePointer(Type *t) @@ -2293,6 +2327,11 @@ return 1; } +int TypePointer::hasPointers() +{ + return TRUE; +} + /***************************** TypeReference *****************************/ @@ -2865,6 +2904,11 @@ return e; } +int TypeDelegate::hasPointers() +{ + return TRUE; +} + /***************************** TypeQualified *****************************/ @@ -3696,6 +3740,10 @@ return (sym->defaultval == 0); } +int TypeEnum::hasPointers() +{ + return toBasetype()->hasPointers(); +} /***************************** TypeTypedef *****************************/ @@ -3893,13 +3941,19 @@ { if (sym->init->isVoidInitializer()) return 1; // initialize voids to 0 - if (sym->init->toExpression()->isBool(FALSE)) + Expression *e = sym->init->toExpression(); + if (e && e->isBool(FALSE)) return 1; return 0; // assume not } return sym->basetype->isZeroInit(); } +int TypeTypedef::hasPointers() +{ + return toBasetype()->hasPointers(); +} + /***************************** TypeStruct *****************************/ TypeStruct::TypeStruct(StructDeclaration *sym) @@ -4159,6 +4213,23 @@ return FALSE; } +int TypeStruct::hasPointers() +{ + StructDeclaration *s = sym; + + sym->size(0); // give error for forward references + if (s->members) + { + for (size_t i = 0; i < s->members->dim; i++) + { + Dsymbol *sm = (Dsymbol *)s->members->data[i]; + VarDeclaration *v = sm->isVarDeclaration(); + if (v && !v->isDataseg() && v->type->hasPointers()) + return TRUE; + } + } + return FALSE; +} /***************************** TypeClass *****************************/ @@ -4502,6 +4573,11 @@ return TRUE; } +int TypeClass::hasPointers() +{ + return TRUE; +} + /***************************** TypeTuple *****************************/ TypeTuple::TypeTuple(Arguments *arguments) diff -uNr dmd-1.00/dmd/src/dmd/mtype.h dmd-1.001/dmd/src/dmd/mtype.h --- dmd-1.00/dmd/src/dmd/mtype.h 2006-12-05 15:57:36.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/mtype.h 2007-01-13 14:15:48.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -240,6 +240,7 @@ virtual int builtinTypeInfo(); virtual Type *reliesOnTident(); virtual Expression *toExpression(); + virtual int hasPointers(); static void error(Loc loc, const char *format, ...); @@ -317,6 +318,7 @@ MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); TypeInfoDeclaration *getTypeInfoDeclaration(); Expression *toExpression(); + int hasPointers(); type *toCtype(); type *toCParamtype(); @@ -335,11 +337,13 @@ void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); int isString(); + int isZeroInit(); int checkBoolean(); int implicitConvTo(Type *to); Expression *defaultInit(); int builtinTypeInfo(); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); }; @@ -360,6 +364,7 @@ MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); int checkBoolean(); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); // Back end Symbol *aaGetSymbol(char *func, int flags); @@ -379,6 +384,7 @@ Expression *defaultInit(); int isZeroInit(); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); }; @@ -437,6 +443,7 @@ int checkBoolean(); TypeInfoDeclaration *getTypeInfoDeclaration(); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); + int hasPointers(); type *toCtype(); }; @@ -522,6 +529,7 @@ dt_t **toDt(dt_t **pdt); MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); }; @@ -551,6 +559,7 @@ int isZeroInit(); MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); }; @@ -586,6 +595,7 @@ dt_t **toDt(dt_t **pdt); MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); type *toCParamtype(); @@ -613,6 +623,7 @@ int isauto(); int checkBoolean(); TypeInfoDeclaration *getTypeInfoDeclaration(); + int hasPointers(); type *toCtype(); diff -uNr dmd-1.00/dmd/src/dmd/struct.c dmd-1.001/dmd/src/dmd/struct.c --- dmd-1.00/dmd/src/dmd/struct.c 2007-01-01 14:27:38.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/struct.c 2007-01-13 14:16:42.000000000 +0100 @@ -390,7 +390,7 @@ { Dsymbol *s = (Dsymbol *)fields.data[i]; VarDeclaration *vd = s->isVarDeclaration(); - if (vd) + if (vd && !vd->isDataseg()) { if (vd->init) { diff -uNr dmd-1.00/dmd/src/dmd/template.c dmd-1.001/dmd/src/dmd/template.c --- dmd-1.00/dmd/src/dmd/template.c 2006-12-31 23:14:00.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/template.c 2007-01-22 20:28:44.000000000 +0100 @@ -2245,6 +2245,7 @@ this->nest = 0; this->havetempdecl = 0; this->isnested = 0; + this->errors = 0; } @@ -2266,6 +2267,7 @@ this->nest = 0; this->havetempdecl = 1; this->isnested = 0; + this->errors = 0; assert((size_t)tempdecl->scope > 0x10000); } @@ -2436,8 +2438,6 @@ } else { Module *m = sc->module->importedFrom; - while (m->loc.linnum != 0 && m != m->importedFrom) - m = m->importedFrom; //printf("\t2: adding to module %s\n", m->toChars()); a = m->members; if (m->semanticdone >= 3) @@ -2574,6 +2574,7 @@ if (global.errors != errorsave) { error("error instantiating"); + errors = 1; if (global.gag) tempdecl->instances.remove(tempdecl_instance_idx); } @@ -3089,7 +3090,7 @@ #if LOG printf("+TemplateInstance::semantic2('%s')\n", toChars()); #endif - if (members) + if (!errors && members) { sc = tempdecl->scope; assert(sc); @@ -3121,7 +3122,7 @@ if (semanticdone >= 3) return; semanticdone = 3; - if (members) + if (!errors && members) { sc = tempdecl->scope; sc = sc->push(argsym); @@ -3142,7 +3143,7 @@ #if LOG printf("TemplateInstance::toObjFile('%s', this = %p)\n", toChars(), this); #endif - if (members) + if (!errors && members) { for (i = 0; i < members->dim; i++) { @@ -3158,7 +3159,7 @@ #if LOG printf("TemplateInstance::inlineScan('%s')\n", toChars()); #endif - if (members) + if (!errors && members) { for (i = 0; i < members->dim; i++) { diff -uNr dmd-1.00/dmd/src/dmd/template.h dmd-1.001/dmd/src/dmd/template.h --- dmd-1.00/dmd/src/dmd/template.h 2006-11-06 19:56:46.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/template.h 2007-01-09 18:52:58.000000000 +0100 @@ -240,6 +240,7 @@ int nest; // for recursion detection int havetempdecl; // 1 if used second constructor int isnested; // if referencing local symbols + int errors; // 1 if compiled with errors #ifdef IN_GCC /* On some targets, it is necessary to know whether a symbol will be emitted in the output or not before the symbol diff -uNr dmd-1.00/dmd/src/dmd/tocsym.c dmd-1.001/dmd/src/dmd/tocsym.c --- dmd-1.00/dmd/src/dmd/tocsym.c 2006-12-20 19:23:18.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/tocsym.c 2007-01-15 00:57:18.000000000 +0100 @@ -551,6 +551,23 @@ return sinit; } +Symbol *TypedefDeclaration::toInitializer() +{ + Symbol *s; + Classsym *stag; + + if (!sinit) + { + stag = fake_classsym(NULL); + s = toSymbolX("__init", SCextern, stag->Stype, "Z"); + s->Sfl = FLextern; + s->Sflags |= SFLnodebug; + slist_add(s); + sinit = s; + } + return sinit; +} + /****************************************** */ diff -uNr dmd-1.00/dmd/src/dmd/todt.c dmd-1.001/dmd/src/dmd/todt.c --- dmd-1.00/dmd/src/dmd/todt.c 2007-01-02 00:22:08.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/todt.c 2007-01-09 00:54:14.000000000 +0100 @@ -544,7 +544,7 @@ { TypeSArray *tsa = (TypeSArray *)type; integer_t dim; - pdt = dtnbytes(pdt, len * sz, (char *)string); + pdt = dtnbytes(pdt, len * sz, (const char *)string); if (tsa->dim) { dim = tsa->dim->toInteger(); diff -uNr dmd-1.00/dmd/src/dmd/toobj.c dmd-1.001/dmd/src/dmd/toobj.c --- dmd-1.00/dmd/src/dmd/toobj.c 2006-12-23 10:21:26.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/toobj.c 2007-01-15 00:53:48.000000000 +0100 @@ -366,7 +366,23 @@ dtdword(&dt, 0); // flags - dtdword(&dt, com); + int flags = com; + for (ClassDeclaration *cd = this; cd; cd = cd->baseClass) + { + if (cd->members) + { + for (size_t i = 0; i < cd->members->dim; i++) + { + Dsymbol *sm = (Dsymbol *)cd->members->data[i]; + VarDeclaration *v = sm->isVarDeclaration(); + if (v && !v->isDataseg() && v->type->hasPointers()) + goto L2; + } + } + } + flags |= 2; // no pointers + L2: + dtdword(&dt, flags); // deallocator @@ -1007,6 +1023,32 @@ toDebug(); type->getTypeInfo(NULL); // generate TypeInfo + + TypeTypedef *tc = (TypeTypedef *)type; + if (type->isZeroInit() || !tc->sym->init) + ; + else + { + enum_SC scclass = SCglobal; + for (Dsymbol *parent = this->parent; parent; parent = parent->parent) + { + if (parent->isTemplateInstance()) + { + scclass = SCcomdat; + break; + } + } + + // Generate static initializer + toInitializer(); + sinit->Sclass = scclass; + sinit->Sfl = FLdata; +#if ELFOBJ // Burton + sinit->Sseg = CDATA; +#endif /* ELFOBJ */ + sinit->Sdt = tc->sym->init->toDt(); + outdata(sinit); + } } /* ================================================================== */ diff -uNr dmd-1.00/dmd/src/dmd/typinf.c dmd-1.001/dmd/src/dmd/typinf.c --- dmd-1.00/dmd/src/dmd/typinf.c 2006-12-05 21:51:22.000000000 +0100 +++ dmd-1.001/dmd/src/dmd/typinf.c 2007-01-22 20:48:16.000000000 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2006 by Digital Mars +// Copyright (c) 1999-2007 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -116,12 +116,12 @@ if (sc) // if in semantic() pass { // Find module that will go all the way to an object file Module *m = sc->module->importedFrom; - while (m != m->importedFrom) - m = m->importedFrom; m->members->push(t->vtinfo); } else // if in obj generation pass + { t->vtinfo->toObjFile(); + } } } e = new VarExp(0, t->vtinfo); @@ -221,6 +221,7 @@ /* Put out: * TypeInfo base; * char[] name; + * void[] m_init; */ sd->basetype->getTypeInfo(NULL); @@ -230,6 +231,20 @@ size_t namelen = strlen(name); dtdword(pdt, namelen); dtabytes(pdt, TYnptr, 0, namelen + 1, name); + + // void[] init; + if (tinfo->isZeroInit() || !sd->init) + { // 0 initializer, or the same as the base type + dtdword(pdt, 0); // init.length + dtdword(pdt, 0); // init.ptr + } + else + { + dtdword(pdt, sd->type->size()); // init.length + // BUG: should make sd->toInitializer() work + //dtdword(pdt, 0); // init.ptr + dtxoff(pdt, sd->toInitializer(), 0, TYnptr); // init.ptr + } } void TypeInfoEnumDeclaration::toDt(dt_t **pdt) @@ -360,11 +375,12 @@ /* Put out: * char[] name; - * byte[] init; + * void[] init; * hash_t function(void*) xtoHash; * int function(void*,void*) xopEquals; * int function(void*,void*) xopCmp; * char[] function(void*) xtoString; + * uint m_flags; */ char *name = sd->toPrettyChars(); @@ -372,7 +388,7 @@ dtdword(pdt, namelen); dtabytes(pdt, TYnptr, 0, namelen + 1, name); - // byte[] init; + // void[] init; dtdword(pdt, sd->structsize); // init.length if (sd->zeroInit) dtdword(pdt, 0); // NULL for 0 initialization @@ -467,6 +483,9 @@ } else dtdword(pdt, 0); + + // uint m_flags; + dtdword(pdt, tc->hasPointers()); } void TypeInfoClassDeclaration::toDt(dt_t **pdt) diff -uNr dmd-1.00/dmd/src/phobos/internal/aaA.d dmd-1.001/dmd/src/phobos/internal/aaA.d --- dmd-1.00/dmd/src/phobos/internal/aaA.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/aaA.d 2007-01-23 16:01:08.000000000 +0100 @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2000-2006 by Digital Mars, www.digitalmars.com + * Copyright (C) 2000-2007 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -276,7 +276,7 @@ // Not found, create new elem //printf("create new one\n"); - e = cast(aaA *) cast(void*) new byte[aaA.sizeof + keysize + valuesize]; + e = cast(aaA *) cast(void*) new void[aaA.sizeof + keysize + valuesize]; memcpy(e + 1, pkey, keysize); e.hash = key_hash; *pe = e; @@ -478,7 +478,7 @@ if (aa.a) { a.length = _aaLen(aa); - a.ptr = (new byte[a.length * valuesize]).ptr; + a.ptr = (new void[a.length * valuesize]).ptr; resi = 0; foreach (e; aa.a.b) { @@ -613,7 +613,7 @@ auto len = _aaLen(aa); if (!len) return 0; - res = new byte[len * keysize]; + res = cast(byte[])new void[len * keysize]; resi = 0; foreach (e; aa.a.b) { diff -uNr dmd-1.00/dmd/src/phobos/internal/adi.d dmd-1.001/dmd/src/phobos/internal/adi.d --- dmd-1.00/dmd/src/phobos/internal/adi.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/adi.d 2007-01-23 16:01:08.000000000 +0100 @@ -315,6 +315,8 @@ * Support for array.reverse property for bit[]. */ +version (none) +{ extern (C) bit[] _adReverseBit(bit[] a) out (result) { @@ -355,7 +357,7 @@ assert(b[i] == data[4 - i]); } } - +} /********************************************** * Sort array of chars. @@ -456,92 +458,16 @@ } -/********************************** - * Support for array.dup property. - */ - -extern (C) long _adDup(Array a, int szelem) - out (result) - { - assert(memcmp((*cast(Array*)&result).ptr, a.ptr, a.length * szelem) == 0); - } - body - { - Array r; - - auto size = a.length * szelem; - r.ptr = cast(void *) new byte[size]; - r.length = a.length; - memcpy(r.ptr, a.ptr, size); - return *cast(long*)(&r); - } - -unittest -{ - int[] a; - int[] b; - int i; - - debug(adi) printf("array.dup.unittest\n"); - - a = new int[3]; - a[0] = 1; a[1] = 2; a[2] = 3; - b = a.dup; - assert(b.length == 3); - for (i = 0; i < 3; i++) - assert(b[i] == i + 1); -} - -/********************************** - * Support for array.dup property for bit[]. - */ - -extern (C) long _adDupBit(Array a) - out (result) - { - assert(memcmp((*cast(Array*)(&result)).ptr, a.ptr, (a.length + 7) / 8) == 0); - } - body - { - Array r; - - auto size = (a.length + 31) / 32; - r.ptr = cast(void *) new uint[size]; - r.length = a.length; - memcpy(r.ptr, a.ptr, size * uint.sizeof); - return *cast(long*)(&r); - } - -unittest -{ - bit[] a; - bit[] b; - int i; - - debug(adi) printf("array.dupBit[].unittest\n"); - - a = new bit[3]; - a[0] = 1; a[1] = 0; a[2] = 1; - b = a.dup; - assert(b.length == 3); - for (i = 0; i < 3; i++) - { debug(adi) printf("b[%d] = %d\n", i, b[i]); - assert(b[i] == (((i ^ 1) & 1) ? true : false)); - } -} - - /*************************************** * Support for array equality test. */ extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) { - //printf("a1.length = %d, a2.length = %d\n", a1.length, a2.length); + //printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); if (a1.length != a2.length) return 0; // not equal auto sz = ti.tsize(); - //printf("sz = %d\n", sz); auto p1 = a1.ptr; auto p2 = a2.ptr; @@ -581,6 +507,8 @@ * Support for array equality test for bit arrays. */ +version (none) +{ extern (C) int _adEqBit(Array a1, Array a2) { size_t i; @@ -618,6 +546,7 @@ assert(a != d); assert(a == e); } +} /*************************************** * Support for array compare test. @@ -820,6 +749,8 @@ * Support for array compare test. */ +version (none) +{ extern (C) int _adCmpBit(Array a1, Array a2) { int len; @@ -867,5 +798,5 @@ assert(a <= e); assert(a >= e); } - +} diff -uNr dmd-1.00/dmd/src/phobos/internal/arraycast.d dmd-1.001/dmd/src/phobos/internal/arraycast.d --- dmd-1.00/dmd/src/phobos/internal/arraycast.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/arraycast.d 2007-01-23 16:01:08.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 by Digital Mars, www.digitalmars.com + * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -32,18 +32,17 @@ extern (C) -void[] _d_arraycast(uint tsize, uint fsize, void[] a) +void[] _d_arraycast(size_t tsize, size_t fsize, void[] a) { - uint length = a.length; - uint nbytes; + auto length = a.length; - nbytes = length * fsize; + auto nbytes = length * fsize; if (nbytes % tsize != 0) { throw new Error("array cast misalignment"); } length = nbytes / tsize; - *cast(uint *)&a = length; // jam new length + *cast(size_t *)&a = length; // jam new length return a; } @@ -70,6 +69,8 @@ * Throws exception if new length is not aligned. */ +version (none) +{ extern (C) void[] _d_arraycast_frombit(uint tsize, void[] a) @@ -81,7 +82,7 @@ throw new Error("bit[] array cast misalignment"); } length /= 8 * tsize; - *cast(uint *)&a = length; // jam new length + *cast(size_t *)&a = length; // jam new length return a; } @@ -101,4 +102,4 @@ } } - +} diff -uNr dmd-1.00/dmd/src/phobos/internal/arraycat.d dmd-1.001/dmd/src/phobos/internal/arraycat.d --- dmd-1.00/dmd/src/phobos/internal/arraycat.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/arraycat.d 2007-01-23 16:01:08.000000000 +0100 @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2004-2006 by Digital Mars, www.digitalmars.com + * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -33,70 +33,7 @@ import std.c.stdio; import std.c.stdarg; -extern (C): - -byte[] _d_arraycatn(uint size, uint n, ...) -{ byte[] a; - uint length; - byte[]* p; - uint i; - byte[] b; - - p = cast(byte[]*)(&n + 1); - - for (i = 0; i < n; i++) - { - b = *p++; - length += b.length; - } - if (!length) - return null; - - a = new byte[length * size]; - p = cast(byte[]*)(&n + 1); - - uint j = 0; - for (i = 0; i < n; i++) - { - b = *p++; - if (b.length) - { - memcpy(&a[j], b.ptr, b.length * size); - j += b.length * size; - } - } - - *cast(int *)&a = length; // jam length - //a.length = length; - return a; -} - -bit[] _d_arraycatb(bit[] x, bit[] y) -{ bit[] a; - uint a_length; - uint x_bytes; - - //printf("_d_arraycatb(x.ptr = %p, x.length = %d, y.ptr = %p, y.length = %d)\n", x.ptr, x.length, y.ptr, y.length); - if (!x.length) - return y; - if (!y.length) - return x; - - a_length = x.length + y.length; - a = new bit[a_length]; - x_bytes = (x.length + 7) >> 3; - memcpy(a.ptr, x.ptr, x_bytes); - if ((x.length & 7) == 0) - memcpy(cast(void*)a.ptr + x_bytes, y.ptr, (y.length + 7) >> 3); - else - { uint x_length = x.length; - uint y_length = y.length; - for (uint i = 0; i < y_length; i++) - a[x_length + i] = y[i]; - } - return a; -} - +extern (C) byte[] _d_arraycopy(uint size, byte[] from, byte[] to) { //printf("f = %p,%d, t = %p,%d, size = %d\n", (void*)from, from.length, (void*)to, to.length, size); @@ -119,102 +56,3 @@ return to; } -bit[] _d_arraycopybit(bit[] from, bit[] to) -{ - //printf("f = %p,%d, t = %p,%d\n", (void*)from, from.length, (void*)to, to.length); - uint nbytes; - - if (to.length != from.length) - { - throw new Error("lengths don't match for array copy"); - } - else - { - nbytes = (to.length + 7) / 8; - if (cast(void *)to + nbytes <= cast(void *)from || - cast(void *)from + nbytes <= cast(void *)to) - { - nbytes = to.length / 8; - if (nbytes) - memcpy(cast(void *)to, cast(void *)from, nbytes); - - if (to.length & 7) - { - /* Copy trailing bits. - */ - static ubyte[8] masks = [0,1,3,7,0x0F,0x1F,0x3F,0x7F]; - ubyte mask = masks[to.length & 7]; - (cast(ubyte*)to)[nbytes] &= ~mask; - (cast(ubyte*)to)[nbytes] |= (cast(ubyte*)from)[nbytes] & mask; - } - } - else - { - throw new Error("overlapping array copy"); - } - } - return to; -} - -bit[] _d_arraysetbit(bit[] ba, uint lwr, uint upr, bit value) -in -{ - //printf("_d_arraysetbit(ba.length = %d, lwr = %u, upr = %u, value = %d)\n", ba.length, lwr, upr, value); - assert(lwr <= upr); - assert(upr <= ba.length); -} -body -{ - // Inefficient; lots of room for improvement here - for (uint i = lwr; i < upr; i++) - ba[i] = value; - - return ba; -} - -bit[] _d_arraysetbit2(bit[] ba, bit value) -{ - //printf("_d_arraysetbit2(ba.ptr = %p, ba.length = %d, value = %d)\n", ba.ptr, ba.length, value); - size_t len = ba.length; - uint val = -cast(int)value; - memset(ba.ptr, val, len >> 3); - for (uint i = len & ~7; i < len; i++) - ba[i] = value; - //printf("-_d_arraysetbit2(ba.ptr = %p, ba.length = %d, value = %d)\n", ba.ptr, ba.length, ba[0]); - return ba; -} - -void* _d_arrayliteral(size_t size, size_t length, ...) -{ - byte[] result; - - //printf("_d_arrayliteral(size = %d, length = %d)\n", size, length); - if (length == 0 || size == 0) - result = null; - else - { - result = new byte[length * size]; - *cast(size_t *)&result = length; // jam length - - va_list q; - va_start!(size_t)(q, length); - - size_t stacksize = (size + int.sizeof - 1) & ~(int.sizeof - 1); - - if (stacksize == size) - { - memcpy(result.ptr, q, length * size); - } - else - { - for (size_t i = 0; i < length; i++) - { - memcpy(result.ptr + i * size, q, size); - q += stacksize; - } - } - - va_end(q); - } - return result.ptr; -} diff -uNr dmd-1.00/dmd/src/phobos/internal/gc/gc.d dmd-1.001/dmd/src/phobos/internal/gc/gc.d --- dmd-1.00/dmd/src/phobos/internal/gc/gc.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/gc/gc.d 2007-01-23 16:01:08.000000000 +0100 @@ -1,6 +1,9 @@ +/** + * Part of the D programming language runtime library. + */ /* - * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -28,13 +31,13 @@ //debug = PRINTF; -import std.c.stdarg; -import std.c.stdlib; -import std.c.string; -import gcx; -import std.outofmemory; -import gcstats; -import std.thread; +public import std.c.stdarg; +public import std.c.stdlib; +public import std.c.string; +public import gcx; +public import std.outofmemory; +public import gcstats; +public import std.thread; version=GCCLASS; @@ -56,6 +59,17 @@ void disable() { _gc.disable(); } void enable() { _gc.enable(); } void getStats(out GCStats stats) { _gc.getStats(stats); } +void hasPointers(void* p) { _gc.hasPointers(p); } +void hasNoPointers(void* p) { _gc.hasNoPointers(p); } +void setV1_0() { _gc.setV1_0(); } + +void setTypeInfo(TypeInfo ti, void* p) +{ + if (ti.flags() & 1) + hasNoPointers(p); + else + hasPointers(p); +} void* getGCHandle() { @@ -115,7 +129,7 @@ { void *p; - debug(PRINTF) printf("_d_newclass(ci = %p)\n", ci); + debug(PRINTF) printf("_d_newclass(ci = %p, %s)\n", ci, cast(char *)ci.name); if (ci.flags & 1) // if COM object { p = cast(Object)std.c.stdlib.malloc(ci.init.length); @@ -127,6 +141,8 @@ p = _gc.malloc(ci.init.length); debug(PRINTF) printf(" p = %p\n", p); _gc.setFinalizer(p, &new_finalizer); + if (ci.flags & 2) + _gc.hasNoPointers(p); } debug (PRINTF) @@ -193,93 +209,70 @@ } } -ulong _d_new(size_t length, size_t size) -{ - void *p; - ulong result; - - debug(PRINTF) printf("_d_new(length = %d, size = %d)\n", length, size); - if (length == 0 || size == 0) - result = 0; - else - { - p = _gc.malloc(length * size + 1); - debug(PRINTF) printf(" p = %p\n", p); - memset(p, 0, length * size); - result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); - } - return result; -} +/****************************************** + * Allocate a new array of length elements. + * ti is the type of the resulting array, or pointer to element. + */ -ulong _d_newarrayi(size_t length, size_t size, ...) +/* For when the array is initialized to 0 */ +ulong _d_newarrayT(TypeInfo ti, size_t length) { void *p; ulong result; + auto size = ti.next.tsize(); // array element size - //debug(PRINTF) printf("_d_newarrayi(length = %d, size = %d)\n", length, size); + debug(PRINTF) printf("_d_newT(length = %d, size = %d)\n", length, size); if (length == 0 || size == 0) result = 0; else { - //void* q = cast(void*)(&size + 1); // pointer to initializer - va_list q; - va_start!(size_t)(q, size); // q is pointer to ... initializer - p = _gc.malloc(length * size + 1); + size *= length; + p = _gc.malloc(size + 1); debug(PRINTF) printf(" p = %p\n", p); - if (size == 1) - memset(p, *cast(ubyte*)q, length); - else if (size == int.sizeof) - { - int init = *cast(int*)q; - for (uint u = 0; u < length; u++) - { - (cast(int*)p)[u] = init; - } - } - else - { - for (uint u = 0; u < length; u++) - { - memcpy(p + u * size, q, size); - } - } - va_end(q); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(p); + memset(p, 0, size); result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); } return result; } -ulong _d_newarrayii(size_t length, size_t size, size_t isize ...) +/* For when the array has a non-zero initializer. + */ +ulong _d_newarrayiT(TypeInfo ti, size_t length) { - void *p; ulong result; + auto size = ti.next.tsize(); // array element size - //debug(PRINTF) printf("_d_newarrayii(length = %d, size = %d, isize = %d)\n", length, size, isize); + //debug(PRINTF) printf("_d_newarrayiT(length = %d, size = %d, isize = %d)\n", length, size, isize); if (length == 0 || size == 0) result = 0; else { - //void* q = cast(void*)(&size + 1); // pointer to initializer - va_list q; - va_start!(size_t)(q, isize); // q is pointer to ... initializer + auto initializer = ti.next.init(); + auto isize = initializer.length; + auto q = initializer.ptr; size *= length; - p = _gc.malloc(size * isize + 1); + auto p = _gc.malloc(size + 1); debug(PRINTF) printf(" p = %p\n", p); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(p); if (isize == 1) memset(p, *cast(ubyte*)q, size); else if (isize == int.sizeof) { int init = *cast(int*)q; - for (uint u = 0; u < size; u++) + size /= int.sizeof; + for (size_t u = 0; u < size; u++) { (cast(int*)p)[u] = init; } } else { - for (uint u = 0; u < size; u++) + for (size_t u = 0; u < size; u += isize) { - memcpy(p + u * isize, q, isize); + memcpy(p + u, q, isize); } } va_end(q); @@ -288,40 +281,42 @@ return result; } -ulong _d_newm(size_t size, int ndims, ...) +ulong _d_newarraymT(TypeInfo ti, int ndims, ...) { ulong result; //debug(PRINTF) - //printf("_d_newm(size = %d, ndims = %d)\n", size, ndims); - if (size == 0 || ndims == 0) + //printf("_d_newarraymT(ndims = %d)\n", ndims); + if (ndims == 0) result = 0; else { va_list q; va_start!(int)(q, ndims); - void[] foo(size_t* pdim, int ndims) + void[] foo(TypeInfo ti, size_t* pdim, int ndims) { size_t dim = *pdim; void[] p; + //printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, ndims); if (ndims == 1) - { p = _gc.malloc(dim * size + 1)[0 .. dim]; - memset(p.ptr, 0, dim * size + 1); + { + auto r = _d_newarrayT(ti, dim); + p = *cast(void[]*)(&r); } else { p = _gc.malloc(dim * (void[]).sizeof + 1)[0 .. dim]; for (int i = 0; i < dim; i++) { - (cast(void[]*)p.ptr)[i] = foo(pdim + 1, ndims - 1); + (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); } } return p; } size_t* pdim = cast(size_t *)q; - result = cast(ulong)foo(pdim, ndims); + result = cast(ulong)foo(ti, pdim, ndims); //printf("result = %llx\n", result); version (none) @@ -336,50 +331,42 @@ return result; } -ulong _d_newarraymi(size_t size, int ndims, ...) +ulong _d_newarraymiT(TypeInfo ti, int ndims, ...) { ulong result; //debug(PRINTF) //printf("_d_newarraymi(size = %d, ndims = %d)\n", size, ndims); - if (size == 0 || ndims == 0) + if (ndims == 0) result = 0; else - { void* pinit; // pointer to initializer + { va_list q; va_start!(int)(q, ndims); - void[] foo(size_t* pdim, int ndims) + void[] foo(TypeInfo ti, size_t* pdim, int ndims) { size_t dim = *pdim; void[] p; if (ndims == 1) - { p = _gc.malloc(dim * size + 1)[0 .. dim]; - if (size == 1) - memset(p.ptr, *cast(ubyte*)pinit, dim); - else - { - for (size_t u = 0; u < dim; u++) - { - memcpy(p.ptr + u * size, pinit, size); - } - } + { + auto r = _d_newarrayiT(ti, dim); + p = *cast(void[]*)(&r); } else { p = _gc.malloc(dim * (void[]).sizeof + 1)[0 .. dim]; for (int i = 0; i < dim; i++) { - (cast(void[]*)p.ptr)[i] = foo(pdim + 1, ndims - 1); + (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); } } return p; } size_t* pdim = cast(size_t *)q; - pinit = pdim + ndims; - result = cast(ulong)foo(pdim, ndims); + result = cast(ulong)foo(ti, pdim, ndims); //printf("result = %llx\n", result); version (none) @@ -395,26 +382,6 @@ return result; } -ulong _d_newbitarray(size_t length, bit value) -{ - void *p; - ulong result; - - debug(PRINTF) printf("_d_newbitarray(length = %d, value = %d)\n", length, value); - if (length == 0) - result = 0; - else - { size_t size = (length + 8) >> 3; // number of bytes - ubyte fill = value ? 0xFF : 0; - - p = _gc.malloc(size); - debug(PRINTF) printf(" p = %p\n", p); - memset(p, fill, size); - result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); - } - return result; -} - struct Array { size_t length; @@ -496,19 +463,20 @@ */ extern (C) -byte[] _d_arraysetlength(size_t newlength, size_t sizeelem, Array *p) +byte[] _d_arraysetlengthT(TypeInfo ti, size_t newlength, Array *p) in { - assert(sizeelem); + assert(ti); assert(!p.length || p.data); } body { byte* newdata; + size_t sizeelem = ti.next.tsize(); debug(PRINTF) { - printf("_d_arraysetlength(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength); + printf("_d_arraysetlengthT(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength); if (p) printf("\tp.data = %p, p.length = %d\n", p.data, p.length); } @@ -548,6 +516,8 @@ { newdata = cast(byte *)_gc.malloc(newsize + 1); newdata[0 .. size] = p.data[0 .. size]; + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(newdata); } newdata[size .. newsize] = 0; } @@ -555,103 +525,8 @@ else { newdata = cast(byte *)_gc.calloc(newsize + 1, 1); - } - } - else - { - newdata = p.data; - } - - p.data = newdata; - p.length = newlength; - return newdata[0 .. newlength]; - -Loverflow: - _d_OutOfMemory(); -} - -/** - * Resize arrays for non-zero initializers. - * (obsolete, replaced by _d_arraysetlength3) - */ -extern (C) -byte[] _d_arraysetlength2(size_t newlength, size_t sizeelem, Array *p, ...) -in -{ - assert(sizeelem); - assert(!p.length || p.data); -} -body -{ - byte* newdata; - - debug(PRINTF) - { - printf("_d_arraysetlength2(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength); - if (p) - printf("\tp.data = %p, p.length = %d\n", p.data, p.length); - } - - if (newlength) - { - version (D_InlineAsm_X86) - { - size_t newsize = void; - - asm - { - mov EAX,newlength ; - mul EAX,sizeelem ; - mov newsize,EAX ; - jc Loverflow ; - } - } - else - { - size_t newsize = sizeelem * newlength; - - if (newsize / newlength != sizeelem) - goto Loverflow; - } - //printf("newsize = %x, newlength = %x\n", newsize, newlength); - - size_t size = p.length * sizeelem; - if (p.data) - { - newdata = p.data; - if (newlength > p.length) - { - size_t cap = _gc.capacity(p.data); - - if (cap <= newsize) - { - newdata = cast(byte *)_gc.malloc(newsize + 1); - newdata[0 .. size] = p.data[0 .. size]; - } - } - } - else - { - newdata = cast(byte *)_gc.malloc(newsize + 1); - } - - va_list q; - va_start!(Array *)(q, p); // q is pointer to initializer - - if (newsize > size) - { - if (sizeelem == 1) - { - //printf("newdata = %p, size = %d, newsize = %d, *q = %d\n", newdata, size, newsize, *cast(byte*)q); - newdata[size .. newsize] = *(cast(byte*)q); - } - else - { - for (size_t u = size; u < newsize; u += sizeelem) - { - memcpy(newdata + u, q, sizeelem); - } - } + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(newdata); } } else @@ -676,23 +551,26 @@ * ... initializer */ extern (C) -byte[] _d_arraysetlength3(size_t newlength, size_t sizeelem, Array *p, - size_t initsize, ...) +byte[] _d_arraysetlengthiT(TypeInfo ti, size_t newlength, Array *p) in { - assert(sizeelem); - assert(initsize); - assert(initsize <= sizeelem); - assert((sizeelem / initsize) * initsize == sizeelem); assert(!p.length || p.data); } body { byte* newdata; + size_t sizeelem = ti.next.tsize(); + void[] initializer = ti.next.init(); + size_t initsize = initializer.length; + + assert(sizeelem); + assert(initsize); + assert(initsize <= sizeelem); + assert((sizeelem / initsize) * initsize == sizeelem); debug(PRINTF) { - printf("_d_arraysetlength3(p = %p, sizeelem = %d, newlength = %d, initsize = %d)\n", p, sizeelem, newlength, initsize); + printf("_d_arraysetlengthiT(p = %p, sizeelem = %d, newlength = %d, initsize = %d)\n", p, sizeelem, newlength, initsize); if (p) printf("\tp.data = %p, p.length = %d\n", p.data, p.length); } @@ -738,10 +616,11 @@ else { newdata = cast(byte *)_gc.malloc(newsize + 1); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(newdata); } - va_list q; - va_start!(size_t)(q, initsize); // q is pointer to initializer + auto q = initializer.ptr; // pointer to initializer if (newsize > size) { @@ -772,65 +651,15 @@ _d_OutOfMemory(); } -/*************************** - * Resize bit[] arrays. - */ - -version (none) -{ -extern (C) -bit[] _d_arraysetlengthb(size_t newlength, Array *p) -{ - byte* newdata; - size_t newsize; - - debug (PRINTF) - printf("p = %p, newlength = %d\n", p, newlength); - - assert(!p.length || p.data); - if (newlength) - { - newsize = ((newlength + 31) >> 5) * 4; // # bytes rounded up to uint - if (p.length) - { size_t size = ((p.length + 31) >> 5) * 4; - - newdata = p.data; - if (newsize > size) - { - size_t cap = _gc.capacity(p.data); - if (cap <= newsize) - { - newdata = cast(byte *)_gc.malloc(newsize + 1); - newdata[0 .. size] = p.data[0 .. size]; - } - newdata[size .. newsize] = 0; - } - } - else - { - newdata = cast(byte *)_gc.calloc(newsize + 1, 1); - } - } - else - { - newdata = null; - } - - p.data = newdata; - p.length = newlength; - return (cast(bit *)newdata)[0 .. newlength]; -} -} - /**************************************** * Append y[] to array x[]. * size is size of each array element. */ extern (C) -long _d_arrayappend(Array *px, byte[] y, size_t size) +long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y) { - + auto size = ti.next.tsize(); // array element size size_t cap = _gc.capacity(px.data); size_t length = px.length; size_t newlength = length + y.length; @@ -838,6 +667,8 @@ { byte* newdata; newdata = cast(byte *)_gc.malloc(newCapacity(newlength, size) + 1); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(newdata); memcpy(newdata, px.data, length * size); px.data = newdata; } @@ -846,40 +677,6 @@ return *cast(long*)px; } -version (none) -{ -extern (C) -long _d_arrayappendb(Array *px, bit[] y) -{ - - size_t cap = _gc.capacity(px.data); - size_t length = px.length; - size_t newlength = length + y.length; - size_t newsize = (newlength + 7) / 8; - if (newsize > cap) - { void* newdata; - - //newdata = _gc.malloc(newlength * size); - newdata = _gc.malloc(newCapacity(newsize, 1) + 1); - memcpy(newdata, px.data, (length + 7) / 8); - px.data = cast(byte*)newdata; - } - px.length = newlength; - if ((length & 7) == 0) - // byte aligned, straightforward copy - memcpy(px.data + length / 8, y, (y.length + 7) / 8); - else - { bit* x = cast(bit*)px.data; - - for (size_t u = 0; u < y.length; u++) - { - x[length + u] = y[u]; - } - } - return *cast(long*)px; -} -} - size_t newCapacity(size_t newlength, size_t size) { version(none) @@ -948,8 +745,9 @@ } extern (C) -byte[] _d_arrayappendc(inout byte[] x, in size_t size, ...) +byte[] _d_arrayappendcT(TypeInfo ti, inout byte[] x, ...) { + auto size = ti.next.tsize(); // array element size size_t cap = _gc.capacity(x.ptr); size_t length = x.length; size_t newlength = length + 1; @@ -965,10 +763,12 @@ cap = newCapacity(newlength, size); assert(cap >= newlength * size); newdata = cast(byte *)_gc.malloc(cap + 1); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(newdata); memcpy(newdata, x.ptr, length * size); (cast(void **)(&x))[1] = newdata; } - byte *argp = cast(byte *)(&size + 1); + byte *argp = cast(byte *)(&ti + 2); *cast(size_t *)&x = newlength; (cast(byte *)x)[length * size .. newlength * size] = argp[0 .. size]; @@ -978,10 +778,11 @@ } extern (C) -byte[] _d_arraycat(byte[] x, byte[] y, size_t size) +byte[] _d_arraycatT(TypeInfo ti, byte[] x, byte[] y) out (result) { - //printf("_d_arraycat(%d,%p ~ %d,%p size = %d => %d,%p)\n", x.length, x.ptr, y.length, y.ptr, size, result.length, result.ptr); + auto size = ti.next.tsize(); // array element size + //printf("_d_arraycatT(%d,%p ~ %d,%p size = %d => %d,%p)\n", x.length, x.ptr, y.length, y.ptr, size, result.length, result.ptr); assert(result.length == x.length + y.length); for (size_t i = 0; i < x.length * size; i++) assert((cast(byte*)result)[i] == (cast(byte*)x)[i]); @@ -1008,6 +809,9 @@ return y; } + //printf("_d_arraycatT(%d,%p ~ %d,%p)\n", x.length, x.ptr, y.length, y.ptr); + auto size = ti.next.tsize(); // array element size + //printf("_d_arraycatT(%d,%p ~ %d,%p size = %d)\n", x.length, x.ptr, y.length, y.ptr, size); size_t xlen = x.length * size; size_t ylen = y.length * size; size_t len = xlen + ylen; @@ -1015,6 +819,8 @@ return null; byte* p = cast(byte*)_gc.malloc(len + 1); + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(p); memcpy(p, x.ptr, xlen); memcpy(p + xlen, y.ptr, ylen); p[len] = 0; @@ -1023,20 +829,133 @@ } -version (none) -{ extern (C) -bit[] _d_arrayappendcb(inout bit[] x, bit b) -{ - if (x.length & 7) +byte[] _d_arraycatnT(TypeInfo ti, uint n, ...) +{ byte[] a; + size_t length; + byte[]* p; + uint i; + byte[] b; + auto size = ti.next.tsize(); // array element size + + p = cast(byte[]*)(&n + 1); + + for (i = 0; i < n; i++) { - *cast(size_t *)&x = x.length + 1; + b = *p++; + length += b.length; } + if (!length) + return null; + + a = new byte[length * size]; + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(a.ptr); + p = cast(byte[]*)(&n + 1); + + uint j = 0; + for (i = 0; i < n; i++) + { + b = *p++; + if (b.length) + { + memcpy(&a[j], b.ptr, b.length * size); + j += b.length * size; + } + } + + *cast(int *)&a = length; // jam length + //a.length = length; + return a; +} + +extern (C) +void* _d_arrayliteralT(TypeInfo ti, size_t length, ...) +{ + auto size = ti.next.tsize(); // array element size + byte[] result; + + //printf("_d_arrayliteralT(size = %d, length = %d)\n", size, length); + if (length == 0 || size == 0) + result = null; else { - x.length = x.length + 1; + result = new byte[length * size]; + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(result.ptr); + *cast(size_t *)&result = length; // jam length + + va_list q; + va_start!(size_t)(q, length); + + size_t stacksize = (size + int.sizeof - 1) & ~(int.sizeof - 1); + + if (stacksize == size) + { + memcpy(result.ptr, q, length * size); + } + else + { + for (size_t i = 0; i < length; i++) + { + memcpy(result.ptr + i * size, q, size); + q += stacksize; + } + } + + va_end(q); } - x[x.length - 1] = b; - return x; + return result.ptr; } + +/********************************** + * Support for array.dup property. + */ + +struct Array2 +{ + size_t length; + void* ptr; } + +extern (C) +long _adDupT(TypeInfo ti, Array2 a) + out (result) + { + auto szelem = ti.next.tsize(); // array element size + assert(memcmp((*cast(Array2*)&result).ptr, a.ptr, a.length * szelem) == 0); + } + body + { + Array2 r; + + if (a.length) + { + auto szelem = ti.next.tsize(); // array element size + auto size = a.length * szelem; + r.ptr = cast(void *) new void[size]; + if (!(ti.next.flags() & 1)) + _gc.hasNoPointers(r.ptr); + r.length = a.length; + memcpy(r.ptr, a.ptr, size); + } + return *cast(long*)(&r); + } + +unittest +{ + int[] a; + int[] b; + int i; + + debug(adi) printf("array.dup.unittest\n"); + + a = new int[3]; + a[0] = 1; a[1] = 2; a[2] = 3; + b = a.dup; + assert(b.length == 3); + for (i = 0; i < 3; i++) + assert(b[i] == i + 1); +} + + diff -uNr dmd-1.00/dmd/src/phobos/internal/gc/gcold.d dmd-1.001/dmd/src/phobos/internal/gc/gcold.d --- dmd-1.00/dmd/src/phobos/internal/gc/gcold.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/gc/gcold.d 2007-01-23 16:01:08.000000000 +0100 @@ -0,0 +1,1003 @@ +/** + * Part of the D programming language runtime library. + */ + +/* + * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + + +/* Obsolete storage allocation functions, kept for link compatibility with + * older library binaries. + */ + +module std.gcold; + +//debug = PRINTF; + +import gc; + +extern (C) +ulong _d_newarrayi(size_t length, size_t size, ...) +{ + void *p; + ulong result; + + //debug(PRINTF) printf("_d_newarrayi(length = %d, size = %d)\n", length, size); + if (length == 0 || size == 0) + result = 0; + else + { + //void* q = cast(void*)(&size + 1); // pointer to initializer + va_list q; + va_start!(size_t)(q, size); // q is pointer to ... initializer + p = _gc.malloc(length * size + 1); + debug(PRINTF) printf(" p = %p\n", p); + if (size == 1) + memset(p, *cast(ubyte*)q, length); + else if (size == int.sizeof) + { + int init = *cast(int*)q; + for (uint u = 0; u < length; u++) + { + (cast(int*)p)[u] = init; + } + } + else + { + for (uint u = 0; u < length; u++) + { + memcpy(p + u * size, q, size); + } + } + va_end(q); + result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); + } + return result; +} + +extern (C) +ulong _d_newarrayii(size_t length, size_t size, size_t isize ...) +{ + void *p; + ulong result; + + //debug(PRINTF) printf("_d_newarrayii(length = %d, size = %d, isize = %d)\n", length, size, isize); + if (length == 0 || size == 0) + result = 0; + else + { + //void* q = cast(void*)(&size + 1); // pointer to initializer + va_list q; + va_start!(size_t)(q, isize); // q is pointer to ... initializer + size *= length; + p = _gc.malloc(size * isize + 1); + debug(PRINTF) printf(" p = %p\n", p); + if (isize == 1) + memset(p, *cast(ubyte*)q, size); + else if (isize == int.sizeof) + { + int init = *cast(int*)q; + for (uint u = 0; u < size; u++) + { + (cast(int*)p)[u] = init; + } + } + else + { + for (uint u = 0; u < size; u++) + { + memcpy(p + u * isize, q, isize); + } + } + va_end(q); + result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); + } + return result; +} + +extern (C) +ulong _d_newm(size_t size, int ndims, ...) +{ + ulong result; + + //debug(PRINTF) + //printf("_d_newm(size = %d, ndims = %d)\n", size, ndims); + if (size == 0 || ndims == 0) + result = 0; + else + { va_list q; + va_start!(int)(q, ndims); + + void[] foo(size_t* pdim, int ndims) + { + size_t dim = *pdim; + void[] p; + + if (ndims == 1) + { p = _gc.malloc(dim * size + 1)[0 .. dim]; + memset(p.ptr, 0, dim * size + 1); + } + else + { + p = _gc.malloc(dim * (void[]).sizeof + 1)[0 .. dim]; + for (int i = 0; i < dim; i++) + { + (cast(void[]*)p.ptr)[i] = foo(pdim + 1, ndims - 1); + } + } + return p; + } + + size_t* pdim = cast(size_t *)q; + result = cast(ulong)foo(pdim, ndims); + //printf("result = %llx\n", result); + + version (none) + { + for (int i = 0; i < ndims; i++) + { + printf("index %d: %d\n", i, va_arg!(int)(q)); + } + } + va_end(q); + } + return result; +} + +extern (C) +ulong _d_newarraymi(size_t size, int ndims, ...) +{ + ulong result; + + //debug(PRINTF) + //printf("_d_newarraymi(size = %d, ndims = %d)\n", size, ndims); + if (size == 0 || ndims == 0) + result = 0; + else + { void* pinit; // pointer to initializer + va_list q; + va_start!(int)(q, ndims); + + void[] foo(size_t* pdim, int ndims) + { + size_t dim = *pdim; + void[] p; + + if (ndims == 1) + { p = _gc.malloc(dim * size + 1)[0 .. dim]; + if (size == 1) + memset(p.ptr, *cast(ubyte*)pinit, dim); + else + { + for (size_t u = 0; u < dim; u++) + { + memcpy(p.ptr + u * size, pinit, size); + } + } + } + else + { + p = _gc.malloc(dim * (void[]).sizeof + 1)[0 .. dim]; + for (int i = 0; i < dim; i++) + { + (cast(void[]*)p.ptr)[i] = foo(pdim + 1, ndims - 1); + } + } + return p; + } + + size_t* pdim = cast(size_t *)q; + pinit = pdim + ndims; + result = cast(ulong)foo(pdim, ndims); + //printf("result = %llx\n", result); + + version (none) + { + for (int i = 0; i < ndims; i++) + { + printf("index %d: %d\n", i, va_arg!(int)(q)); + printf("init = %d\n", va_arg!(int)(q)); + } + } + va_end(q); + } + return result; +} + +/****************************************** + * Allocate a new array of length elements, each of size size. + * Initialize to 0. + */ + +extern (C) +ulong _d_new(size_t length, size_t size) +{ + void *p; + ulong result; + + debug(PRINTF) printf("_d_new(length = %d, size = %d)\n", length, size); + if (length == 0 || size == 0) + result = 0; + else + { + p = _gc.malloc(length * size + 1); + debug(PRINTF) printf(" p = %p\n", p); + memset(p, 0, length * size); + result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); + } + return result; +} + +extern (C) +byte[] _d_arraysetlength(size_t newlength, size_t sizeelem, Array *p) +in +{ + assert(sizeelem); + assert(!p.length || p.data); +} +body +{ + byte* newdata; + + debug(PRINTF) + { + printf("_d_arraysetlength(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength); + if (p) + printf("\tp.data = %p, p.length = %d\n", p.data, p.length); + } + + if (newlength) + { + version (D_InlineAsm_X86) + { + size_t newsize = void; + + asm + { + mov EAX,newlength ; + mul EAX,sizeelem ; + mov newsize,EAX ; + jc Loverflow ; + } + } + else + { + size_t newsize = sizeelem * newlength; + + if (newsize / newlength != sizeelem) + goto Loverflow; + } + //printf("newsize = %x, newlength = %x\n", newsize, newlength); + + if (p.data) + { + newdata = p.data; + if (newlength > p.length) + { + size_t size = p.length * sizeelem; + size_t cap = _gc.capacity(p.data); + + if (cap <= newsize) + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + newdata[0 .. size] = p.data[0 .. size]; + } + newdata[size .. newsize] = 0; + } + } + else + { + newdata = cast(byte *)_gc.calloc(newsize + 1, 1); + } + } + else + { + newdata = p.data; + } + + p.data = newdata; + p.length = newlength; + return newdata[0 .. newlength]; + +Loverflow: + _d_OutOfMemory(); +} + +/** + * Resize arrays for non-zero initializers. + * (obsolete, replaced by _d_arraysetlength3) + */ +extern (C) +byte[] _d_arraysetlength2(size_t newlength, size_t sizeelem, Array *p, ...) +in +{ + assert(sizeelem); + assert(!p.length || p.data); +} +body +{ + byte* newdata; + + debug(PRINTF) + { + printf("_d_arraysetlength2(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength); + if (p) + printf("\tp.data = %p, p.length = %d\n", p.data, p.length); + } + + if (newlength) + { + version (D_InlineAsm_X86) + { + size_t newsize = void; + + asm + { + mov EAX,newlength ; + mul EAX,sizeelem ; + mov newsize,EAX ; + jc Loverflow ; + } + } + else + { + size_t newsize = sizeelem * newlength; + + if (newsize / newlength != sizeelem) + goto Loverflow; + } + //printf("newsize = %x, newlength = %x\n", newsize, newlength); + + size_t size = p.length * sizeelem; + if (p.data) + { + newdata = p.data; + if (newlength > p.length) + { + size_t cap = _gc.capacity(p.data); + + if (cap <= newsize) + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + newdata[0 .. size] = p.data[0 .. size]; + } + } + } + else + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + } + + va_list q; + va_start!(Array *)(q, p); // q is pointer to initializer + + if (newsize > size) + { + if (sizeelem == 1) + { + //printf("newdata = %p, size = %d, newsize = %d, *q = %d\n", newdata, size, newsize, *cast(byte*)q); + newdata[size .. newsize] = *(cast(byte*)q); + } + else + { + for (size_t u = size; u < newsize; u += sizeelem) + { + memcpy(newdata + u, q, sizeelem); + } + } + } + } + else + { + newdata = p.data; + } + + p.data = newdata; + p.length = newlength; + return newdata[0 .. newlength]; + +Loverflow: + _d_OutOfMemory(); +} + + +version (none) +{ +ulong _d_newbitarray(size_t length, bit value) +{ + void *p; + ulong result; + + debug(PRINTF) printf("_d_newbitarray(length = %d, value = %d)\n", length, value); + if (length == 0) + result = 0; + else + { size_t size = (length + 8) >> 3; // number of bytes + ubyte fill = value ? 0xFF : 0; + + p = _gc.malloc(size); + debug(PRINTF) printf(" p = %p\n", p); + memset(p, fill, size); + result = cast(ulong)length + (cast(ulong)cast(uint)p << 32); + } + return result; +} +} + +/*************************** + * Resize bit[] arrays. + */ + +version (none) +{ +extern (C) +bit[] _d_arraysetlengthb(size_t newlength, Array *p) +{ + byte* newdata; + size_t newsize; + + debug (PRINTF) + printf("p = %p, newlength = %d\n", p, newlength); + + assert(!p.length || p.data); + if (newlength) + { + newsize = ((newlength + 31) >> 5) * 4; // # bytes rounded up to uint + if (p.length) + { size_t size = ((p.length + 31) >> 5) * 4; + + newdata = p.data; + if (newsize > size) + { + size_t cap = _gc.capacity(p.data); + if (cap <= newsize) + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + newdata[0 .. size] = p.data[0 .. size]; + } + newdata[size .. newsize] = 0; + } + } + else + { + newdata = cast(byte *)_gc.calloc(newsize + 1, 1); + } + } + else + { + newdata = null; + } + + p.data = newdata; + p.length = newlength; + return (cast(bit *)newdata)[0 .. newlength]; +} +} + +version (none) +{ +extern (C) +long _d_arrayappendb(Array *px, bit[] y) +{ + + size_t cap = _gc.capacity(px.data); + size_t length = px.length; + size_t newlength = length + y.length; + size_t newsize = (newlength + 7) / 8; + if (newsize > cap) + { void* newdata; + + //newdata = _gc.malloc(newlength * size); + newdata = _gc.malloc(newCapacity(newsize, 1) + 1); + memcpy(newdata, px.data, (length + 7) / 8); + px.data = cast(byte*)newdata; + } + px.length = newlength; + if ((length & 7) == 0) + // byte aligned, straightforward copy + memcpy(px.data + length / 8, y, (y.length + 7) / 8); + else + { bit* x = cast(bit*)px.data; + + for (size_t u = 0; u < y.length; u++) + { + x[length + u] = y[u]; + } + } + return *cast(long*)px; +} +} + +version (none) +{ +extern (C) +bit[] _d_arrayappendcb(inout bit[] x, bit b) +{ + if (x.length & 7) + { + *cast(size_t *)&x = x.length + 1; + } + else + { + x.length = x.length + 1; + } + x[x.length - 1] = b; + return x; +} +} + +/** + * Resize arrays for non-zero initializers. + * p pointer to array lvalue to be updated + * newlength new .length property of array + * sizeelem size of each element of array + * initsize size of initializer + * ... initializer + */ +extern (C) +byte[] _d_arraysetlength3(size_t newlength, size_t sizeelem, Array *p, + size_t initsize, ...) +in +{ + assert(sizeelem); + assert(initsize); + assert(initsize <= sizeelem); + assert((sizeelem / initsize) * initsize == sizeelem); + assert(!p.length || p.data); +} +body +{ + byte* newdata; + + debug(PRINTF) + { + printf("_d_arraysetlength3(p = %p, sizeelem = %d, newlength = %d, initsize = %d)\n", p, sizeelem, newlength, initsize); + if (p) + printf("\tp.data = %p, p.length = %d\n", p.data, p.length); + } + + if (newlength) + { + version (D_InlineAsm_X86) + { + size_t newsize = void; + + asm + { + mov EAX,newlength ; + mul EAX,sizeelem ; + mov newsize,EAX ; + jc Loverflow ; + } + } + else + { + size_t newsize = sizeelem * newlength; + + if (newsize / newlength != sizeelem) + goto Loverflow; + } + //printf("newsize = %x, newlength = %x\n", newsize, newlength); + + size_t size = p.length * sizeelem; + if (p.data) + { + newdata = p.data; + if (newlength > p.length) + { + size_t cap = _gc.capacity(p.data); + + if (cap <= newsize) + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + newdata[0 .. size] = p.data[0 .. size]; + } + } + } + else + { + newdata = cast(byte *)_gc.malloc(newsize + 1); + } + + va_list q; + va_start!(size_t)(q, initsize); // q is pointer to initializer + + if (newsize > size) + { + if (initsize == 1) + { + //printf("newdata = %p, size = %d, newsize = %d, *q = %d\n", newdata, size, newsize, *cast(byte*)q); + newdata[size .. newsize] = *(cast(byte*)q); + } + else + { + for (size_t u = size; u < newsize; u += initsize) + { + memcpy(newdata + u, q, initsize); + } + } + } + } + else + { + newdata = p.data; + } + + p.data = newdata; + p.length = newlength; + return newdata[0 .. newlength]; + +Loverflow: + _d_OutOfMemory(); +} + + +extern (C) +long _d_arrayappend(Array *px, byte[] y, size_t size) +{ + + size_t cap = _gc.capacity(px.data); + size_t length = px.length; + size_t newlength = length + y.length; + if (newlength * size > cap) + { byte* newdata; + + newdata = cast(byte *)_gc.malloc(newCapacity(newlength, size) + 1); + memcpy(newdata, px.data, length * size); + px.data = newdata; + } + px.length = newlength; + memcpy(px.data + length * size, y.ptr, y.length * size); + return *cast(long*)px; +} + + +extern (C) +byte[] _d_arrayappendc(inout byte[] x, in size_t size, ...) +{ + size_t cap = _gc.capacity(x.ptr); + size_t length = x.length; + size_t newlength = length + 1; + + assert(cap == 0 || length * size <= cap); + + //printf("_d_arrayappendc(size = %d, ptr = %p, length = %d, cap = %d)\n", size, x.ptr, x.length, cap); + + if (newlength * size >= cap) + { byte* newdata; + + //printf("_d_arrayappendc(size = %d, newlength = %d, cap = %d)\n", size, newlength, cap); + cap = newCapacity(newlength, size); + assert(cap >= newlength * size); + newdata = cast(byte *)_gc.malloc(cap + 1); + memcpy(newdata, x.ptr, length * size); + (cast(void **)(&x))[1] = newdata; + } + byte *argp = cast(byte *)(&size + 1); + + *cast(size_t *)&x = newlength; + (cast(byte *)x)[length * size .. newlength * size] = argp[0 .. size]; + assert((cast(size_t)x.ptr & 15) == 0); + assert(_gc.capacity(x.ptr) > x.length * size); + return x; +} + + +extern (C) +byte[] _d_arraycat(byte[] x, byte[] y, size_t size) +out (result) +{ + //printf("_d_arraycat(%d,%p ~ %d,%p size = %d => %d,%p)\n", x.length, x.ptr, y.length, y.ptr, size, result.length, result.ptr); + assert(result.length == x.length + y.length); + for (size_t i = 0; i < x.length * size; i++) + assert((cast(byte*)result)[i] == (cast(byte*)x)[i]); + for (size_t i = 0; i < y.length * size; i++) + assert((cast(byte*)result)[x.length * size + i] == (cast(byte*)y)[i]); + + size_t cap = _gc.capacity(result.ptr); + assert(!cap || cap > result.length * size); +} +body +{ + version (none) + { + /* Cannot use this optimization because: + * char[] a, b; + * char c = 'a'; + * b = a ~ c; + * c = 'b'; + * will change the contents of b. + */ + if (!y.length) + return x; + if (!x.length) + return y; + } + + size_t xlen = x.length * size; + size_t ylen = y.length * size; + size_t len = xlen + ylen; + if (!len) + return null; + + byte* p = cast(byte*)_gc.malloc(len + 1); + memcpy(p, x.ptr, xlen); + memcpy(p + xlen, y.ptr, ylen); + p[len] = 0; + + return p[0 .. x.length + y.length]; +} + + +extern (C) +byte[] _d_arraycatn(uint size, uint n, ...) +{ byte[] a; + uint length; + byte[]* p; + uint i; + byte[] b; + + p = cast(byte[]*)(&n + 1); + + for (i = 0; i < n; i++) + { + b = *p++; + length += b.length; + } + if (!length) + return null; + + a = new byte[length * size]; + p = cast(byte[]*)(&n + 1); + + uint j = 0; + for (i = 0; i < n; i++) + { + b = *p++; + if (b.length) + { + memcpy(&a[j], b.ptr, b.length * size); + j += b.length * size; + } + } + + *cast(int *)&a = length; // jam length + //a.length = length; + return a; +} + +version (none) +{ +extern (C) +bit[] _d_arraycatb(bit[] x, bit[] y) +{ bit[] a; + uint a_length; + uint x_bytes; + + //printf("_d_arraycatb(x.ptr = %p, x.length = %d, y.ptr = %p, y.length = %d)\n", x.ptr, x.length, y.ptr, y.length); + if (!x.length) + return y; + if (!y.length) + return x; + + a_length = x.length + y.length; + a = new bit[a_length]; + x_bytes = (x.length + 7) >> 3; + memcpy(a.ptr, x.ptr, x_bytes); + if ((x.length & 7) == 0) + memcpy(cast(void*)a.ptr + x_bytes, y.ptr, (y.length + 7) >> 3); + else + { uint x_length = x.length; + uint y_length = y.length; + for (uint i = 0; i < y_length; i++) + a[x_length + i] = y[i]; + } + return a; +} +} + +version (none) +{ +extern (C) +bit[] _d_arraycopybit(bit[] from, bit[] to) +{ + //printf("f = %p,%d, t = %p,%d\n", (void*)from, from.length, (void*)to, to.length); + uint nbytes; + + if (to.length != from.length) + { + throw new Error("lengths don't match for array copy"); + } + else + { + nbytes = (to.length + 7) / 8; + if (cast(void *)to + nbytes <= cast(void *)from || + cast(void *)from + nbytes <= cast(void *)to) + { + nbytes = to.length / 8; + if (nbytes) + memcpy(cast(void *)to, cast(void *)from, nbytes); + + if (to.length & 7) + { + /* Copy trailing bits. + */ + static ubyte[8] masks = [0,1,3,7,0x0F,0x1F,0x3F,0x7F]; + ubyte mask = masks[to.length & 7]; + (cast(ubyte*)to)[nbytes] &= ~mask; + (cast(ubyte*)to)[nbytes] |= (cast(ubyte*)from)[nbytes] & mask; + } + } + else + { + throw new Error("overlapping array copy"); + } + } + return to; +} + +extern (C) +bit[] _d_arraysetbit(bit[] ba, uint lwr, uint upr, bit value) +in +{ + //printf("_d_arraysetbit(ba.length = %d, lwr = %u, upr = %u, value = %d)\n", ba.length, lwr, upr, value); + assert(lwr <= upr); + assert(upr <= ba.length); +} +body +{ + // Inefficient; lots of room for improvement here + for (uint i = lwr; i < upr; i++) + ba[i] = value; + + return ba; +} + +extern (C) +bit[] _d_arraysetbit2(bit[] ba, bit value) +{ + //printf("_d_arraysetbit2(ba.ptr = %p, ba.length = %d, value = %d)\n", ba.ptr, ba.length, value); + size_t len = ba.length; + uint val = -cast(int)value; + memset(ba.ptr, val, len >> 3); + for (uint i = len & ~7; i < len; i++) + ba[i] = value; + //printf("-_d_arraysetbit2(ba.ptr = %p, ba.length = %d, value = %d)\n", ba.ptr, ba.length, ba[0]); + return ba; +} +} + +extern (C) +void* _d_arrayliteral(size_t size, size_t length, ...) +{ + byte[] result; + + //printf("_d_arrayliteral(size = %d, length = %d)\n", size, length); + if (length == 0 || size == 0) + result = null; + else + { + result = new byte[length * size]; + *cast(size_t *)&result = length; // jam length + + va_list q; + va_start!(size_t)(q, length); + + size_t stacksize = (size + int.sizeof - 1) & ~(int.sizeof - 1); + + if (stacksize == size) + { + memcpy(result.ptr, q, length * size); + } + else + { + for (size_t i = 0; i < length; i++) + { + memcpy(result.ptr + i * size, q, size); + q += stacksize; + } + } + + va_end(q); + } + return result.ptr; +} + +/********************************** + * Support for array.dup property. + */ + +extern (C) long _adDup(Array2 a, int szelem) + out (result) + { + assert(memcmp((*cast(Array2*)&result).ptr, a.ptr, a.length * szelem) == 0); + } + body + { + Array2 r; + + auto size = a.length * szelem; + r.ptr = cast(void *) new byte[size]; + r.length = a.length; + memcpy(r.ptr, a.ptr, size); + return *cast(long*)(&r); + } + +unittest +{ + int[] a; + int[] b; + int i; + + debug(adi) printf("array.dup.unittest\n"); + + a = new int[3]; + a[0] = 1; a[1] = 2; a[2] = 3; + b = a.dup; + assert(b.length == 3); + for (i = 0; i < 3; i++) + assert(b[i] == i + 1); +} + +/********************************** + * Support for array.dup property for bit[]. + */ + +version (none) +{ +extern (C) long _adDupBit(Array a) + out (result) + { + assert(memcmp((*cast(Array*)(&result)).ptr, a.ptr, (a.length + 7) / 8) == 0); + } + body + { + Array r; + + auto size = (a.length + 31) / 32; + r.ptr = cast(void *) new uint[size]; + r.length = a.length; + memcpy(r.ptr, a.ptr, size * uint.sizeof); + return *cast(long*)(&r); + } + +unittest +{ + bit[] a; + bit[] b; + int i; + + debug(adi) printf("array.dupBit[].unittest\n"); + + a = new bit[3]; + a[0] = 1; a[1] = 0; a[2] = 1; + b = a.dup; + assert(b.length == 3); + for (i = 0; i < 3; i++) + { debug(adi) printf("b[%d] = %d\n", i, b[i]); + assert(b[i] == (((i ^ 1) & 1) ? true : false)); + } +} +} + + + diff -uNr dmd-1.00/dmd/src/phobos/internal/gc/gcx.d dmd-1.001/dmd/src/phobos/internal/gc/gcx.d --- dmd-1.00/dmd/src/phobos/internal/gc/gcx.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/gc/gcx.d 2007-01-23 16:01:08.000000000 +0100 @@ -1,10 +1,10 @@ // -// Copyright (C) 2001-2006 by Digital Mars +// Copyright (C) 2001-2007 by Digital Mars // All Rights Reserved // Written by Walter Bright // www.digitalmars.com -// D Garbage Collector implementation +// D Programming Language Garbage Collector implementation /************** Debugging ***************************/ @@ -397,9 +397,10 @@ synchronized (gcLock) { + biti = cast(uint)(p - pool.baseAddr) / 16; + pool.noptrs.clear(biti); if (pool.finals.nbits && gcx.finalizer) { - biti = cast(uint)(p - pool.baseAddr) / 16; if (pool.finals.testClear(biti)) { (*gcx.finalizer)(sentinel_add(p), null); @@ -655,6 +656,29 @@ } } + void hasPointers(void *p) + { + synchronized (gcLock) + { + gcx.HasPointers(p); + } + } + + void hasNoPointers(void *p) + { + if (!gcx.conservative) + { synchronized (gcLock) + { + gcx.HasNoPointers(p); + } + } + } + + void setV1_0() + { + gcx.conservative = 1; + } + void enable() { synchronized (gcLock) @@ -802,6 +826,7 @@ uint rangedim; Range *ranges; + uint conservative; // !=0 means conservative behavior uint noStack; // !=0 means don't scan stack uint log; // turn on logging uint anychanges; @@ -1359,8 +1384,10 @@ { //if (log) debug(PRINTF) printf("\t\tmarking %x\n", p); pool.mark.set(biti); - pool.scan.set(biti); - changes = 1; + if (!pool.noptrs.test(biti)) + { pool.scan.set(biti); + changes = 1; + } log_parent(sentinel_add(pool.baseAddr + biti * 16), sentinel_add(pbot)); } } @@ -1622,6 +1649,7 @@ sentinel_Invariant(sentinel_add(p)); pool.freebits.set(biti); + pool.noptrs.clear(biti); if (finalizer && pool.finals.nbits && pool.finals.testClear(biti)) { @@ -1645,6 +1673,7 @@ { byte *p = pool.baseAddr + pn * PAGESIZE; sentinel_Invariant(sentinel_add(p)); + pool.noptrs.clear(biti); if (finalizer && pool.finals.nbits && pool.finals.testClear(biti)) { @@ -1750,6 +1779,34 @@ } + /********************************* + * Indicate that block pointed to by p has possible pointers + * to GC allocated memory in it. + */ + + void HasPointers(void *p) + { + Pool *pool = findPool(p); + assert(pool); + + pool.noptrs.clear((p - pool.baseAddr) / 16); + } + + + /********************************* + * Indicate that block pointed to by p has no possible pointers + * to GC allocated memory in it. + */ + + void HasNoPointers(void *p) + { + //printf("HasNoPointers(%p)\n", p); + Pool *pool = findPool(p); + assert(pool); + + pool.noptrs.set((p - pool.baseAddr) / 16); + } + /***** Leak Detector ******/ debug (LOGGING) @@ -1883,10 +1940,11 @@ { byte* baseAddr; byte* topAddr; - GCBits mark; - GCBits scan; - GCBits finals; - GCBits freebits; + GCBits mark; // entries already scanned, or should not be scanned + GCBits scan; // entries that need to be scanned + GCBits finals; // entries that need finalizer run on them + GCBits freebits; // entries that are on the free list + GCBits noptrs; // entries that do not contain pointers uint npages; uint ncommitted; // ncommitted <= npages @@ -1918,6 +1976,7 @@ mark.alloc(poolsize / 16); scan.alloc(poolsize / 16); freebits.alloc(poolsize / 16); + noptrs.alloc(poolsize / 16); pagetable = cast(ubyte*)std.c.stdlib.malloc(npages); memset(pagetable, B_UNCOMMITTED, npages); diff -uNr dmd-1.00/dmd/src/phobos/internal/gc/linux.mak dmd-1.001/dmd/src/phobos/internal/gc/linux.mak --- dmd-1.00/dmd/src/phobos/internal/gc/linux.mak 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/gc/linux.mak 2007-01-23 16:01:08.000000000 +0100 @@ -9,9 +9,9 @@ #DFLAGS=-release -inline -O CC=gcc -OBJS= gc.o gcx.o gcbits.o gclinux.o +OBJS= gc.o gcx.o gcbits.o gclinux.o gcold.o -SRC= gc.d gcx.d gcbits.d win32.d gclinux.d testgc.d win32.mak linux.mak +SRC= gc.d gcx.d gcbits.d win32.d gclinux.d gcold.d testgc.d win32.mak linux.mak .c.o: $(CC) -c $(CFLAGS) $* @@ -33,6 +33,9 @@ gc.o : gc.d $(DMD) -c $(DFLAGS) gc.d +gcold.o : gcold.d + $(DMD) -c $(DFLAGS) gcold.d + gcx.o : gcx.d $(DMD) -c $(DFLAGS) gcx.d gcbits.d diff -uNr dmd-1.00/dmd/src/phobos/internal/gc/win32.mak dmd-1.001/dmd/src/phobos/internal/gc/win32.mak --- dmd-1.00/dmd/src/phobos/internal/gc/win32.mak 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/gc/win32.mak 2007-01-23 16:01:08.000000000 +0100 @@ -31,19 +31,22 @@ testgc.obj : testgc.d -OBJS= gc.obj gcx.obj gcbits.obj win32.obj +OBJS= gc.obj gcold.obj gcx.obj gcbits.obj win32.obj -SRC= gc.d gcx.d gcbits.d win32.d gclinux.d testgc.d win32.mak linux.mak +SRC= gc.d gcold.d gcx.d gcbits.d win32.d gclinux.d testgc.d win32.mak linux.mak dmgc.lib : $(OBJS) win32.mak del dmgc.lib - lib dmgc /c/noi +gc+gcx+gcbits+win32; + lib dmgc /c/noi +gc+gcold+gcx+gcbits+win32; gc.obj : gc.d - $(DMD) -c -release -inline -O $* + $(DMD) -c $(DFLAGS) $* + +gcold.obj : gcold.d + $(DMD) -c $(DFLAGS) $* gcx.obj : gcx.d gcbits.d - $(DMD) -c -release -inline -O gcx gcbits + $(DMD) -c $(DFLAGS) gcx gcbits #gcbits.obj : gcbits.d diff -uNr dmd-1.00/dmd/src/phobos/internal/object.d dmd-1.001/dmd/src/phobos/internal/object.d --- dmd-1.00/dmd/src/phobos/internal/object.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/internal/object.d 2007-01-23 16:01:08.000000000 +0100 @@ -261,6 +261,7 @@ void (*classInvariant)(Object); uint flags; // 1: // IUnknown + // 2: // has no possible pointers into GC memory void *deallocator; } @@ -319,6 +320,16 @@ (cast(byte *)p2)[i] = t; } } + + /// Get TypeInfo for 'next' type, as defined by what kind of type this is, + /// null if none. + TypeInfo next() { return null; } + + /// Return default initializer, null if default initialize to 0 + void[] init() { return null; } + + /// Get flags for type: 1 means GC should scan for pointers + uint flags() { return 0; } } class TypeInfo_Typedef : TypeInfo @@ -340,8 +351,13 @@ size_t tsize() { return base.tsize(); } void swap(void *p1, void *p2) { return base.swap(p1, p2); } + TypeInfo next() { return base.next(); } + uint flags() { return base.flags(); } + void[] init() { return m_init.length ? m_init : base.init(); } + TypeInfo base; char[] name; + void[] m_init; } class TypeInfo_Enum : TypeInfo_Typedef @@ -350,14 +366,14 @@ class TypeInfo_Pointer : TypeInfo { - char[] toString() { return next.toString() ~ "*"; } + char[] toString() { return m_next.toString() ~ "*"; } int opEquals(Object o) { TypeInfo_Pointer c; return this is o || ((c = cast(TypeInfo_Pointer)o) !is null && - this.next == c.next); + this.m_next == c.m_next); } hash_t getHash(void *p) @@ -387,27 +403,30 @@ *cast(void**)p2 = tmp; } - TypeInfo next; + TypeInfo next() { return m_next; } + uint flags() { return 1; } + + TypeInfo m_next; } class TypeInfo_Array : TypeInfo { - char[] toString() { return next.toString() ~ "[]"; } + char[] toString() { return value.toString() ~ "[]"; } int opEquals(Object o) { TypeInfo_Array c; return this is o || ((c = cast(TypeInfo_Array)o) !is null && - this.next == c.next); + this.value == c.value); } hash_t getHash(void *p) - { size_t sz = next.tsize(); + { size_t sz = value.tsize(); hash_t hash = 0; void[] a = *cast(void[]*)p; for (size_t i = 0; i < a.length; i++) - hash += next.getHash(a.ptr + i * sz); + hash += value.getHash(a.ptr + i * sz); return hash; } @@ -417,10 +436,10 @@ void[] a2 = *cast(void[]*)p2; if (a1.length != a2.length) return 0; - size_t sz = next.tsize(); + size_t sz = value.tsize(); for (size_t i = 0; i < a1.length; i++) { - if (!next.equals(a1.ptr + i * sz, a2.ptr + i * sz)) + if (!value.equals(a1.ptr + i * sz, a2.ptr + i * sz)) return 0; } return 1; @@ -430,14 +449,14 @@ { void[] a1 = *cast(void[]*)p1; void[] a2 = *cast(void[]*)p2; - size_t sz = next.tsize(); + size_t sz = value.tsize(); size_t len = a1.length; if (a2.length < len) len = a2.length; for (size_t u = 0; u < len; u++) { - int result = next.compare(a1.ptr + u * sz, a2.ptr + u * sz); + int result = value.compare(a1.ptr + u * sz, a2.ptr + u * sz); if (result) return result; } @@ -456,14 +475,21 @@ *cast(void[]*)p2 = tmp; } - TypeInfo next; + TypeInfo value; + + TypeInfo next() + { + return value; + } + + uint flags() { return 1; } } class TypeInfo_StaticArray : TypeInfo { char[] toString() { - return next.toString() ~ "[" ~ std.string.toString(len) ~ "]"; + return value.toString() ~ "[" ~ std.string.toString(len) ~ "]"; } int opEquals(Object o) @@ -472,24 +498,24 @@ return this is o || ((c = cast(TypeInfo_StaticArray)o) !is null && this.len == c.len && - this.next == c.next); + this.value == c.value); } hash_t getHash(void *p) - { size_t sz = next.tsize(); + { size_t sz = value.tsize(); hash_t hash = 0; for (size_t i = 0; i < len; i++) - hash += next.getHash(p + i * sz); + hash += value.getHash(p + i * sz); return hash; } int equals(void *p1, void *p2) { - size_t sz = next.tsize(); + size_t sz = value.tsize(); for (size_t u = 0; u < len; u++) { - if (!next.equals(p1 + u * sz, p2 + u * sz)) + if (!value.equals(p1 + u * sz, p2 + u * sz)) return 0; } return 1; @@ -497,11 +523,11 @@ int compare(void *p1, void *p2) { - size_t sz = next.tsize(); + size_t sz = value.tsize(); for (size_t u = 0; u < len; u++) { - int result = next.compare(p1 + u * sz, p2 + u * sz); + int result = value.compare(p1 + u * sz, p2 + u * sz); if (result) return result; } @@ -510,19 +536,19 @@ size_t tsize() { - return len * next.tsize(); + return len * value.tsize(); } void swap(void *p1, void *p2) - { ubyte* tmp; - size_t sz = next.tsize(); + { void* tmp; + size_t sz = value.tsize(); ubyte[16] buffer; - ubyte* pbuffer; + void* pbuffer; if (sz < buffer.sizeof) tmp = buffer.ptr; else - tmp = pbuffer = (new ubyte[sz]).ptr; + tmp = pbuffer = (new void[sz]).ptr; for (size_t u = 0; u < len; u += sz) { size_t o = u * sz; @@ -534,7 +560,11 @@ delete pbuffer; } - TypeInfo next; + void[] init() { return value.init(); } + TypeInfo next() { return value; } + uint flags() { return value.flags(); } + + TypeInfo value; size_t len; } @@ -542,7 +572,7 @@ { char[] toString() { - return next.toString() ~ "[" ~ key.toString() ~ "]"; + return value.toString() ~ "[" ~ key.toString() ~ "]"; } int opEquals(Object o) @@ -551,7 +581,7 @@ return this is o || ((c = cast(TypeInfo_AssociativeArray)o) !is null && this.key == c.key && - this.next == c.next); + this.value == c.value); } // BUG: need to add the rest of the functions @@ -561,7 +591,10 @@ return (char[int]).sizeof; } - TypeInfo next; + TypeInfo next() { return value; } + uint flags() { return 1; } + + TypeInfo value; TypeInfo key; } @@ -612,6 +645,8 @@ return dg.sizeof; } + uint flags() { return 1; } + TypeInfo next; } @@ -668,6 +703,8 @@ return Object.sizeof; } + uint flags() { return 1; } + ClassInfo info; } @@ -729,6 +766,8 @@ return Object.sizeof; } + uint flags() { return 1; } + ClassInfo info; } @@ -809,13 +848,19 @@ return init.length; } + void[] init() { return m_init; } + + uint flags() { return m_flags; } + char[] name; - byte[] init; // initializer; init.ptr == null if 0 initialize + void[] m_init; // initializer; init.ptr == null if 0 initialize hash_t function(void*) xtoHash; int function(void*,void*) xopEquals; int function(void*,void*) xopCmp; char[] function(void*) xtoString; + + uint m_flags; } class TypeInfo_Tuple : TypeInfo diff -uNr dmd-1.00/dmd/src/phobos/linux.mak dmd-1.001/dmd/src/phobos/linux.mak --- dmd-1.00/dmd/src/phobos/linux.mak 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/linux.mak 2007-01-23 16:01:06.000000000 +0100 @@ -64,9 +64,9 @@ ti_float.o ti_double.o ti_real.o ti_delegate.o \ ti_creal.o ti_ireal.o ti_cfloat.o ti_ifloat.o \ ti_cdouble.o ti_idouble.o \ - ti_Aa.o ti_AC.o ti_Ag.o ti_Aubyte.o ti_Aushort.o ti_Ashort.o \ - ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o \ - ti_Aint.o ti_Auint.o ti_Along.o ti_Aulong.o ti_Awchar.o \ + ti_AC.o ti_Ag.o ti_Ashort.o \ + ti_C.o ti_int.o ti_char.o ti_dchar.o \ + ti_Aint.o ti_Along.o \ ti_Afloat.o ti_Adouble.o ti_Areal.o \ ti_Acfloat.o ti_Acdouble.o ti_Acreal.o \ ti_void.o \ @@ -79,7 +79,7 @@ etc/c/zlib/inflate.o etc/c/zlib/infback.o \ etc/c/zlib/inftrees.o etc/c/zlib/inffast.o -GC_OBJS= internal/gc/gc.o internal/gc/gcx.o \ +GC_OBJS= internal/gc/gc.o internal/gc/gcold.o internal/gc/gcx.o \ internal/gc/gcbits.o internal/gc/gclinux.o SRC= errno.c object.d unittest.d crc32.d gcstats.d @@ -111,19 +111,18 @@ std/typeinfo/ti_creal.d std/typeinfo/ti_ireal.d \ std/typeinfo/ti_cfloat.d std/typeinfo/ti_ifloat.d \ std/typeinfo/ti_cdouble.d std/typeinfo/ti_idouble.d \ - std/typeinfo/ti_Adchar.d std/typeinfo/ti_Aubyte.d \ - std/typeinfo/ti_Aushort.d std/typeinfo/ti_Ashort.d \ - std/typeinfo/ti_Aa.d std/typeinfo/ti_Ag.d \ + std/typeinfo/ti_Adchar.d \ + std/typeinfo/ti_Ashort.d \ + std/typeinfo/ti_Ag.d \ std/typeinfo/ti_AC.d std/typeinfo/ti_C.d \ std/typeinfo/ti_int.d std/typeinfo/ti_char.d \ - std/typeinfo/ti_Aint.d std/typeinfo/ti_Auint.d \ - std/typeinfo/ti_Along.d std/typeinfo/ti_Aulong.d \ + std/typeinfo/ti_Aint.d \ + std/typeinfo/ti_Along.d \ std/typeinfo/ti_Afloat.d std/typeinfo/ti_Adouble.d \ std/typeinfo/ti_Areal.d \ std/typeinfo/ti_Acfloat.d std/typeinfo/ti_Acdouble.d \ std/typeinfo/ti_Acreal.d \ - std/typeinfo/ti_void.d \ - std/typeinfo/ti_Awchar.d std/typeinfo/ti_dchar.d + std/typeinfo/ti_void.d SRC_INT= \ internal/switch.d internal/complex.c internal/critical.c \ @@ -180,6 +179,7 @@ etc/c/zlib\linux.mak SRC_GC= internal/gc/gc.d \ + internal/gc/gcold.d \ internal/gc/gcx.d \ internal/gc/gcstub.d \ internal/gc/gcbits.d \ @@ -196,6 +196,7 @@ #libphobos.a : $(OBJS) internal/gc/dmgc.a linux.mak libphobos.a : $(OBJS) internal/gc/dmgc.a $(ZLIB_OBJS) linux.mak + rm -f libphobos.a ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS) ########################################################### @@ -527,9 +528,6 @@ ti_idouble.o : std/typeinfo/ti_idouble.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_idouble.d -ti_Aa.o : std/typeinfo/ti_Aa.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Aa.d - ti_AC.o : std/typeinfo/ti_AC.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_AC.d @@ -539,24 +537,12 @@ ti_Abit.o : std/typeinfo/ti_Abit.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Abit.d -ti_Aubyte.o : std/typeinfo/ti_Aubyte.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Aubyte.d - -ti_Aushort.o : std/typeinfo/ti_Aushort.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Aushort.d - ti_Ashort.o : std/typeinfo/ti_Ashort.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Ashort.d -ti_Auint.o : std/typeinfo/ti_Auint.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Auint.d - ti_Aint.o : std/typeinfo/ti_Aint.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Aint.d -ti_Aulong.o : std/typeinfo/ti_Aulong.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Aulong.d - ti_Along.o : std/typeinfo/ti_Along.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Along.d @@ -578,12 +564,6 @@ ti_Acreal.o : std/typeinfo/ti_Acreal.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Acreal.d -ti_Awchar.o : std/typeinfo/ti_Awchar.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Awchar.d - -ti_Adchar.o : std/typeinfo/ti_Adchar.d - $(DMD) -c $(DFLAGS) std/typeinfo/ti_Adchar.d - ti_C.o : std/typeinfo/ti_C.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_C.d diff -uNr dmd-1.00/dmd/src/phobos/object.d dmd-1.001/dmd/src/phobos/object.d --- dmd-1.00/dmd/src/phobos/object.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/object.d 2007-01-23 16:01:06.000000000 +0100 @@ -44,6 +44,7 @@ void (*classInvariant)(Object); uint flags; // 1: // IUnknown + // 2: // has no possible pointers into GC memory void *deallocator; } @@ -54,12 +55,17 @@ int compare(void *p1, void *p2); size_t tsize(); void swap(void *p1, void *p2); + TypeInfo next(); + void[] init(); + uint flags(); + // 1: // has possible pointers into GC memory } class TypeInfo_Typedef : TypeInfo { TypeInfo base; char[] name; + void[] m_init; } class TypeInfo_Enum : TypeInfo_Typedef @@ -68,23 +74,23 @@ class TypeInfo_Pointer : TypeInfo { - TypeInfo next; + TypeInfo m_next; } class TypeInfo_Array : TypeInfo { - TypeInfo next; + TypeInfo value; } class TypeInfo_StaticArray : TypeInfo { - TypeInfo next; + TypeInfo value; size_t len; } class TypeInfo_AssociativeArray : TypeInfo { - TypeInfo next; + TypeInfo value; TypeInfo key; } @@ -111,12 +117,14 @@ class TypeInfo_Struct : TypeInfo { char[] name; - byte[] init; + void[] m_init; uint function(void*) xtoHash; int function(void*,void*) xopEquals; int function(void*,void*) xopCmp; char[] function(void*) xtoString; + + uint m_flags; } class TypeInfo_Tuple : TypeInfo diff -uNr dmd-1.00/dmd/src/phobos/std/c/linux/linux.d dmd-1.001/dmd/src/phobos/std/c/linux/linux.d --- dmd-1.00/dmd/src/phobos/std/c/linux/linux.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/c/linux/linux.d 2007-01-23 16:01:08.000000000 +0100 @@ -11,6 +11,8 @@ public import std.c.linux.linuxextern; public import std.c.linux.pthread; +private import std.c.stdio; + alias int pid_t; alias int off_t; alias uint mode_t; @@ -136,6 +138,27 @@ int pipe(int[2]); pid_t wait(int*); int waitpid(pid_t, int*, int); + + uint alarm(uint); + char* basename(char*); + //wint_t btowc(int); + int chown(char*, uid_t, gid_t); + int chroot(char*); + size_t confstr(int, char*, size_t); + int creat(char*, mode_t); + char* ctermid(char*); + int dirfd(DIR*); + char* dirname(char*); + int fattach(int, char*); + int fchmod(int, mode_t); + int fdatasync(int); + int ffs(int); + int fmtmsg(int, char*, int, char*, char*, char*); + int fpathconf(int, int); + int fseeko(FILE*, off_t, int); + off_t ftello(FILE*); + + extern char** environ; } struct timeval diff -uNr dmd-1.00/dmd/src/phobos/std/file.d dmd-1.001/dmd/src/phobos/std/file.d --- dmd-1.00/dmd/src/phobos/std/file.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/file.d 2007-01-23 16:01:06.000000000 +0100 @@ -1,3 +1,5 @@ +// Written in the D programming language. + /** * Macros: * WIKI = Phobos/StdFile @@ -32,6 +34,7 @@ private import std.path; private import std.string; private import std.regexp; +private import std.gc; /* =========================== Win32 ======================= */ @@ -90,10 +93,8 @@ void[] read(char[] name) { - DWORD size; DWORD numread; HANDLE h; - byte[] buf; if (useWfuncs) { @@ -111,11 +112,13 @@ if (h == INVALID_HANDLE_VALUE) goto err1; - size = GetFileSize(h, null); + auto size = GetFileSize(h, null); if (size == INVALID_FILE_SIZE) goto err2; - buf = new byte[size]; + auto buf = new void[size]; + if (buf.ptr) + std.gc.hasNoPointers(buf.ptr); if (ReadFile(h,buf.ptr,size,&numread,null) != 1) goto err2; @@ -454,14 +457,12 @@ { if (useWfuncs) { - wchar[] dir; - int len; wchar c; - len = GetCurrentDirectoryW(0, &c); + auto len = GetCurrentDirectoryW(0, &c); if (!len) goto Lerr; - dir = new wchar[len]; + auto dir = new wchar[len]; len = GetCurrentDirectoryW(len, dir.ptr); if (!len) goto Lerr; @@ -469,14 +470,12 @@ } else { - char[] dir; - int len; char c; - len = GetCurrentDirectoryA(0, &c); + auto len = GetCurrentDirectoryA(0, &c); if (!len) goto Lerr; - dir = new char[len]; + auto dir = new char[len]; len = GetCurrentDirectoryA(len, dir.ptr); if (!len) goto Lerr; @@ -882,16 +881,12 @@ void[] read(char[] name) { - uint size; uint numread; - int fd; struct_stat statbuf; - byte[] buf; - char *namez; - namez = toStringz(name); + auto namez = toStringz(name); //printf("file.read('%s')\n",namez); - fd = std.c.linux.linux.open(namez, O_RDONLY); + auto fd = std.c.linux.linux.open(namez, O_RDONLY); if (fd == -1) { //printf("\topen error, errno = %d\n",getErrno()); @@ -904,8 +899,10 @@ //printf("\tfstat error, errno = %d\n",getErrno()); goto err2; } - size = statbuf.st_size; - buf = new byte[size]; + auto size = statbuf.st_size; + auto buf = new void[size]; + if (buf.ptr) + std.gc.hasNoPointers(buf.ptr); numread = std.c.linux.linux.read(fd, cast(char*)buf, size); if (numread != size) @@ -1189,16 +1186,15 @@ */ char[] getcwd() -{ char* p; - - p = std.c.linux.linux.getcwd(null, 0); +{ + auto p = std.c.linux.linux.getcwd(null, 0); if (!p) { throw new FileException("cannot get cwd", getErrno()); } - size_t len = std.string.strlen(p); - char[] buf = new char[len]; + auto len = std.string.strlen(p); + auto buf = new char[len]; buf[] = p[0 .. len]; std.c.stdlib.free(p); return buf; diff -uNr dmd-1.00/dmd/src/phobos/std/gc.d dmd-1.001/dmd/src/phobos/std/gc.d --- dmd-1.00/dmd/src/phobos/std/gc.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/gc.d 2007-01-23 16:01:06.000000000 +0100 @@ -59,6 +59,27 @@ */ void removeRange(void *pbot); // remove range +/** + * Mark a gc allocated block of memory as possibly containing pointers. + */ +void hasPointers(void* p); + +/** + * Mark a gc allocated block of memory as definitely NOT containing pointers. + */ +void hasNoPointers(void* p); + +/** + * Mark a gc allocated block of memory pointed to by p as being populated with + * an array of TypeInfo ti (as many as will fit). + */ +void setTypeInfo(TypeInfo ti, void* p); + +/** + * Set gc behavior to match that of 1.0. + */ +void setV1_0(); + /*********************************** * Run a full garbage collection cycle. * diff -uNr dmd-1.00/dmd/src/phobos/std/random.d dmd-1.001/dmd/src/phobos/std/random.d --- dmd-1.00/dmd/src/phobos/std/random.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/random.d 2007-01-23 16:01:06.000000000 +0100 @@ -36,6 +36,9 @@ This means that the $(I n)th random number of the sequence can be directly generated by passing index + $(I n) to rand_seed(). + + Note: This is more random, but slower, than C's rand() function. + To use C's rand() instead, import std.c.stdlib. */ void rand_seed(uint seed, uint index) diff -uNr dmd-1.00/dmd/src/phobos/std/regexp.d dmd-1.001/dmd/src/phobos/std/regexp.d --- dmd-1.00/dmd/src/phobos/std/regexp.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/regexp.d 2007-01-23 16:01:06.000000000 +0100 @@ -197,8 +197,8 @@ char[] sub(char[] string, char[] pattern, char[] format, char[] attributes = null) { - RegExp r = new RegExp(pattern, attributes); - char[] result = r.replace(string, format); + auto r = new RegExp(pattern, attributes); + auto result = r.replace(string, format); delete r; return result; } @@ -237,7 +237,7 @@ char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] attributes = null) { - RegExp r = new RegExp(pattern, attributes); + auto r = new RegExp(pattern, attributes); rchar[] result; int lastindex; int offset; @@ -327,7 +327,7 @@ { int i = -1; - RegExp r = new RegExp(pattern, attributes); + auto r = new RegExp(pattern, attributes); if (r.test(string)) { i = r.pmatch[0].rm_so; @@ -370,7 +370,7 @@ int i = -1; int lastindex = 0; - RegExp r = new RegExp(pattern, attributes); + auto r = new RegExp(pattern, attributes); while (r.test(string, lastindex)) { int eo = r.pmatch[0].rm_eo; i = r.pmatch[0].rm_so; @@ -425,8 +425,8 @@ char[][] split(char[] string, char[] pattern, char[] attributes = null) { - RegExp r = new RegExp(pattern, attributes); - char[][] result = r.split(string); + auto r = new RegExp(pattern, attributes); + auto result = r.split(string); delete r; return result; } @@ -478,7 +478,7 @@ RegExp search(char[] string, char[] pattern, char[] attributes = null) { - RegExp r = new RegExp(pattern, attributes); + auto r = new RegExp(pattern, attributes); if (r.test(string)) { @@ -878,7 +878,7 @@ { debug(regexp) printf("regexp.split.unittest()\n"); - RegExp r = new RegExp("a*?", null); + auto r = new RegExp("a*?", null); rchar[][] result; rchar[] j; int i; @@ -1118,9 +1118,7 @@ if (!test()) return null; - rchar[][] result; - - result = new rchar[][pmatch.length]; + auto result = new rchar[][pmatch.length]; for (int i = 0; i < pmatch.length; i++) { if (pmatch[i].rm_so == pmatch[i].rm_eo) @@ -2393,7 +2391,7 @@ offset = buf.offset; buf.write(cast(uint)0); // reserve space for length buf.reserve(128 / 8); - Range r = new Range(buf); + auto r = new Range(buf); if (op == REnotbit) r.setbit2(0); switch (pattern[p]) @@ -2742,8 +2740,8 @@ case REparen: case REgoto: { - OutBuffer bitbuf = new OutBuffer; - Range r = new Range(bitbuf); + auto bitbuf = new OutBuffer; + auto r = new Range(bitbuf); uint offset; offset = i; @@ -3123,23 +3121,23 @@ unittest { // Created and placed in public domain by Don Clugston - auto m = regexp.search("aBC r s", `bc\x20r[\40]s`, "i"); + auto m = search("aBC r s", `bc\x20r[\40]s`, "i"); assert(m.pre=="a"); assert(m.match(0)=="BC r s"); - auto m2 = regexp.search("7xxyxxx", `^\d([a-z]{2})\D\1`); + auto m2 = search("7xxyxxx", `^\d([a-z]{2})\D\1`); assert(m2.match(0)=="7xxyxx"); // Just check the parsing. - auto m3 = regexp.search("dcbxx", `ca|b[\d\]\D\s\S\w-\W]`); - auto m4 = regexp.search("xy", `[^\ca-\xFa\r\n\b\f\t\v\0123]{2,485}$`); - auto m5 = regexp.search("xxx", `^^\r\n\b{13,}\f{4}\t\v\u02aF3a\w\W`); - auto m6 = regexp.search("xxy", `.*y`); + auto m3 = search("dcbxx", `ca|b[\d\]\D\s\S\w-\W]`); + auto m4 = search("xy", `[^\ca-\xFa\r\n\b\f\t\v\0123]{2,485}$`); + auto m5 = search("xxx", `^^\r\n\b{13,}\f{4}\t\v\u02aF3a\w\W`); + auto m6 = search("xxy", `.*y`); assert(m6.match(0)=="xxy"); - auto m7 = regexp.search("QWDEfGH", "(ca|b|defg)+", "i"); + auto m7 = search("QWDEfGH", "(ca|b|defg)+", "i"); assert(m7.match(0)=="DEfG"); - auto m8 = regexp.search("dcbxx", `a?\B\s\S`); - auto m9 = regexp.search("dcbxx", `[-w]`); - auto m10 = regexp.search("dcbsfd", `aB[c-fW]dB|\d|\D|\u012356|\w|\W|\s|\S`, "i"); - auto m11 = regexp.search("dcbsfd", `[]a-]`); + auto m8 = search("dcbxx", `a?\B\s\S`); + auto m9 = search("dcbxx", `[-w]`); + auto m10 = search("dcbsfd", `aB[c-fW]dB|\d|\D|\u012356|\w|\W|\s|\S`, "i"); + auto m11 = search("dcbsfd", `[]a-]`); m.replaceOld(`a&b\1c`); m.replace(`a$&b$'$1c`); } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aa.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aa.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aa.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aa.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ - -module std.typeinfo.Aa; - -private import std.string; -private import std.c.string; - -// char[] - -class TypeInfo_Aa : TypeInfo -{ - char[] toString() { return "char[]"; } - - hash_t getHash(void *p) - { char[] s = *cast(char[]*)p; - hash_t hash = 0; - -version (all) -{ - foreach (char c; s) - hash = hash * 11 + c; -} -else -{ - size_t len = s.length; - char *str = s; - - while (1) - { - switch (len) - { - case 0: - return hash; - - case 1: - hash *= 9; - hash += *cast(ubyte *)str; - return hash; - - case 2: - hash *= 9; - hash += *cast(ushort *)str; - return hash; - - case 3: - hash *= 9; - hash += (*cast(ushort *)str << 8) + - (cast(ubyte *)str)[2]; - return hash; - - default: - hash *= 9; - hash += *cast(uint *)str; - str += 4; - len -= 4; - break; - } - } -} - return hash; - } - - int equals(void *p1, void *p2) - { - char[] s1 = *cast(char[]*)p1; - char[] s2 = *cast(char[]*)p2; - - return s1.length == s2.length && - memcmp(cast(char *)s1, cast(char *)s2, s1.length) == 0; - } - - int compare(void *p1, void *p2) - { - char[] s1 = *cast(char[]*)p1; - char[] s2 = *cast(char[]*)p2; - - return std.string.cmp(s1, s2); - } - - size_t tsize() - { - return (char[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_AC.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_AC.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_AC.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_AC.d 2007-01-23 16:01:06.000000000 +0100 @@ -78,5 +78,15 @@ { return (Object[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(Object); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acdouble.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acdouble.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 2007-01-23 16:01:06.000000000 +0100 @@ -89,5 +89,15 @@ { return (cdouble[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(cdouble); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acfloat.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acfloat.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 2007-01-23 16:01:06.000000000 +0100 @@ -87,5 +87,15 @@ { return (cfloat[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(cfloat); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acreal.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acreal.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Acreal.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Acreal.d 2007-01-23 16:01:06.000000000 +0100 @@ -90,5 +90,15 @@ { return (creal[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(creal); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Adchar.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Adchar.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Adchar.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Adchar.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,60 +0,0 @@ - -module std.typeinfo.ti_Adchar; - -private import std.c.string; - -// dchar[] - -class TypeInfo_Aw : TypeInfo -{ - char[] toString() { return "dchar[]"; } - - hash_t getHash(void *p) - { dchar[] s = *cast(dchar[]*)p; - size_t len = s.length; - dchar *str = s.ptr; - hash_t hash = 0; - - while (len) - { - hash *= 9; - hash += *cast(uint *)str; - str++; - len--; - } - - return hash; - } - - int equals(void *p1, void *p2) - { - dchar[] s1 = *cast(dchar[]*)p1; - dchar[] s2 = *cast(dchar[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * dchar.sizeof) == 0; - } - - int compare(void *p1, void *p2) - { - dchar[] s1 = *cast(dchar[]*)p1; - dchar[] s2 = *cast(dchar[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (dchar[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Adouble.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Adouble.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Adouble.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Adouble.d 2007-01-23 16:01:06.000000000 +0100 @@ -87,6 +87,16 @@ { return (double[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(double); + } } // idouble[] @@ -94,4 +104,9 @@ class TypeInfo_Ap : TypeInfo_Ad { char[] toString() { return "idouble[]"; } + + TypeInfo next() + { + return typeid(idouble); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Afloat.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Afloat.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Afloat.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Afloat.d 2007-01-23 16:01:06.000000000 +0100 @@ -86,6 +86,16 @@ { return (float[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(float); + } } // ifloat[] @@ -93,4 +103,9 @@ class TypeInfo_Ao : TypeInfo_Af { char[] toString() { return "ifloat[]"; } + + TypeInfo next() + { + return typeid(ifloat); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Ag.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Ag.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Ag.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Ag.d 2007-01-23 16:01:06.000000000 +0100 @@ -1,6 +1,7 @@ module std.typeinfo.ti_Ag; +private import std.string; private import std.c.string; // byte[] @@ -80,5 +81,122 @@ { return (byte[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(byte); + } +} + + +// ubyte[] + +class TypeInfo_Ah : TypeInfo_Ag +{ + char[] toString() { return "ubyte[]"; } + + int compare(void *p1, void *p2) + { + char[] s1 = *cast(char[]*)p1; + char[] s2 = *cast(char[]*)p2; + + return std.string.cmp(s1, s2); + } + + TypeInfo next() + { + return typeid(ubyte); + } +} + +// void[] + +class TypeInfo_Av : TypeInfo_Ah +{ + char[] toString() { return "void[]"; } + + TypeInfo next() + { + return typeid(void); + } +} + +// bool[] + +class TypeInfo_Ab : TypeInfo_Ah +{ + char[] toString() { return "bool[]"; } + + TypeInfo next() + { + return typeid(bool); + } +} + +// char[] + +class TypeInfo_Aa : TypeInfo_Ag +{ + char[] toString() { return "char[]"; } + + hash_t getHash(void *p) + { char[] s = *cast(char[]*)p; + hash_t hash = 0; + +version (all) +{ + foreach (char c; s) + hash = hash * 11 + c; } +else +{ + size_t len = s.length; + char *str = s; + + while (1) + { + switch (len) + { + case 0: + return hash; + + case 1: + hash *= 9; + hash += *cast(ubyte *)str; + return hash; + + case 2: + hash *= 9; + hash += *cast(ushort *)str; + return hash; + + case 3: + hash *= 9; + hash += (*cast(ushort *)str << 8) + + (cast(ubyte *)str)[2]; + return hash; + + default: + hash *= 9; + hash += *cast(uint *)str; + str += 4; + len -= 4; + break; + } + } +} + return hash; + } + + TypeInfo next() + { + return typeid(char); + } +} + diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aint.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aint.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aint.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aint.d 2007-01-23 16:01:06.000000000 +0100 @@ -56,5 +56,56 @@ { return (int[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(int); + } +} + +// uint[] + +class TypeInfo_Ak : TypeInfo_Ai +{ + char[] toString() { return "uint[]"; } + + int compare(void *p1, void *p2) + { + uint[] s1 = *cast(uint[]*)p1; + uint[] s2 = *cast(uint[]*)p2; + size_t len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int result = s1[u] - s2[u]; + if (result) + return result; + } + return cast(int)s1.length - cast(int)s2.length; + } + + TypeInfo next() + { + return typeid(uint); + } +} + +// dchar[] + +class TypeInfo_Aw : TypeInfo_Ak +{ + char[] toString() { return "dchar[]"; } + + TypeInfo next() + { + return typeid(dchar); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Along.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Along.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Along.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Along.d 2007-01-23 16:01:06.000000000 +0100 @@ -18,7 +18,7 @@ while (len) { hash *= 9; - hash += *str; + hash += *cast(uint *)str + *(cast(uint *)str + 1); str++; len--; } @@ -57,5 +57,47 @@ { return (long[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(long); + } +} + + +// ulong[] + +class TypeInfo_Am : TypeInfo_Al +{ + char[] toString() { return "ulong[]"; } + + int compare(void *p1, void *p2) + { + ulong[] s1 = *cast(ulong[]*)p1; + ulong[] s2 = *cast(ulong[]*)p2; + size_t len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + if (s1[u] < s2[u]) + return -1; + else if (s1[u] > s2[u]) + return 1; + } + return cast(int)s1.length - cast(int)s2.length; + } + + TypeInfo next() + { + return typeid(ulong); + } } + diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Areal.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Areal.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Areal.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Areal.d 2007-01-23 16:01:06.000000000 +0100 @@ -88,6 +88,16 @@ { return (real[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(real); + } } // ireal[] @@ -95,4 +105,9 @@ class TypeInfo_Aj : TypeInfo_Ae { char[] toString() { return "ireal[]"; } + + TypeInfo next() + { + return typeid(ireal); + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Ashort.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Ashort.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Ashort.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Ashort.d 2007-01-23 16:01:06.000000000 +0100 @@ -24,7 +24,7 @@ case 1: hash *= 9; - hash += *cast(short *)str; + hash += *cast(ushort *)str; return hash; default: @@ -69,5 +69,58 @@ { return (short[]).sizeof; } + + uint flags() + { + return 1; + } + + TypeInfo next() + { + return typeid(short); + } } + +// ushort[] + +class TypeInfo_At : TypeInfo_As +{ + char[] toString() { return "ushort[]"; } + + int compare(void *p1, void *p2) + { + ushort[] s1 = *cast(ushort[]*)p1; + ushort[] s2 = *cast(ushort[]*)p2; + size_t len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int result = s1[u] - s2[u]; + if (result) + return result; + } + return cast(int)s1.length - cast(int)s2.length; + } + + TypeInfo next() + { + return typeid(ushort); + } +} + +// wchar[] + +class TypeInfo_Au : TypeInfo_At +{ + char[] toString() { return "wchar[]"; } + + TypeInfo next() + { + return typeid(wchar); + } +} + + diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aubyte.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aubyte.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,89 +0,0 @@ - -module std.typeinfo.ti_Aubyte; - -private import std.string; -private import std.c.string; - -// ubyte[] - -class TypeInfo_Ah : TypeInfo -{ - char[] toString() { return "ubyte[]"; } - - hash_t getHash(void *p) - { ubyte[] s = *cast(ubyte[]*)p; - size_t len = s.length; - ubyte *str = s.ptr; - hash_t hash = 0; - - while (1) - { - switch (len) - { - case 0: - return hash; - - case 1: - hash *= 9; - hash += *cast(ubyte *)str; - return hash; - - case 2: - hash *= 9; - hash += *cast(ushort *)str; - return hash; - - case 3: - hash *= 9; - hash += (*cast(ushort *)str << 8) + - (cast(ubyte *)str)[2]; - return hash; - - default: - hash *= 9; - hash += *cast(uint *)str; - str += 4; - len -= 4; - break; - } - } - - return hash; - } - - int equals(void *p1, void *p2) - { - ubyte[] s1 = *cast(ubyte[]*)p1; - ubyte[] s2 = *cast(ubyte[]*)p2; - - return s1.length == s2.length && - memcmp(cast(ubyte *)s1, cast(ubyte *)s2, s1.length) == 0; - } - - int compare(void *p1, void *p2) - { - char[] s1 = *cast(char[]*)p1; - char[] s2 = *cast(char[]*)p2; - - return std.string.cmp(s1, s2); - } - - size_t tsize() - { - return (ubyte[]).sizeof; - } -} - -// void[] - -class TypeInfo_Av : TypeInfo_Ah -{ - char[] toString() { return "void[]"; } -} - -// bool[] - -class TypeInfo_Ab : TypeInfo_Ah -{ - char[] toString() { return "bool[]"; } -} diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Auint.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Auint.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Auint.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Auint.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,60 +0,0 @@ - -module std.typeinfo.ti_Auint; - -private import std.c.string; - -// uint[] - -class TypeInfo_Ak : TypeInfo -{ - char[] toString() { return "uint[]"; } - - hash_t getHash(void *p) - { uint[] s = *cast(uint[]*)p; - size_t len = s.length; - auto str = s.ptr; - hash_t hash = 0; - - while (len) - { - hash *= 9; - hash += *cast(uint *)str; - str++; - len--; - } - - return hash; - } - - int equals(void *p1, void *p2) - { - uint[] s1 = *cast(uint[]*)p1; - uint[] s2 = *cast(uint[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * uint.sizeof) == 0; - } - - int compare(void *p1, void *p2) - { - uint[] s1 = *cast(uint[]*)p1; - uint[] s2 = *cast(uint[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (uint[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aulong.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aulong.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aulong.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aulong.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,61 +0,0 @@ - -module std.typeinfo.ti_Aulong; - -private import std.c.string; - -// ulong[] - -class TypeInfo_Am : TypeInfo -{ - char[] toString() { return "ulong[]"; } - - hash_t getHash(void *p) - { ulong[] s = *cast(ulong[]*)p; - size_t len = s.length; - auto str = s.ptr; - hash_t hash = 0; - - while (len) - { - hash *= 9; - hash += *cast(uint *)str; - str += 1; - len -= 1; - } - - return hash; - } - - int equals(void *p1, void *p2) - { - ulong[] s1 = *cast(ulong[]*)p1; - ulong[] s2 = *cast(ulong[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * ulong.sizeof) == 0; - } - - int compare(void *p1, void *p2) - { - ulong[] s1 = *cast(ulong[]*)p1; - ulong[] s2 = *cast(ulong[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (s1[u] < s2[u]) - return -1; - else if (s1[u] > s2[u]) - return 1; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (ulong[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aushort.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aushort.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Aushort.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Aushort.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ - -module std.typeinfo.ti_Aushort; - -private import std.c.string; - -// ushort[] - -class TypeInfo_At : TypeInfo -{ - char[] toString() { return "ushort[]"; } - - hash_t getHash(void *p) - { ushort[] s = *cast(ushort[]*)p; - size_t len = s.length; - ushort *str = s.ptr; - hash_t hash = 0; - - while (1) - { - switch (len) - { - case 0: - return hash; - - case 1: - hash *= 9; - hash += *cast(ushort *)str; - return hash; - - default: - hash *= 9; - hash += *cast(uint *)str; - str += 2; - len -= 2; - break; - } - } - - return hash; - } - - int equals(void *p1, void *p2) - { - ushort[] s1 = *cast(ushort[]*)p1; - ushort[] s2 = *cast(ushort[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * ushort.sizeof) == 0; - } - - int compare(void *p1, void *p2) - { - ushort[] s1 = *cast(ushort[]*)p1; - ushort[] s2 = *cast(ushort[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (ushort[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Awchar.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Awchar.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_Awchar.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_Awchar.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ - -module std.typeinfo.ti_Awchar; - -private import std.c.string; - -// wchar[] - -class TypeInfo_Au : TypeInfo -{ - char[] toString() { return "wchar[]"; } - - hash_t getHash(void *p) - { wchar[] s = *cast(wchar[]*)p; - size_t len = s.length; - auto str = s.ptr; - hash_t hash = 0; - - while (1) - { - switch (len) - { - case 0: - return hash; - - case 1: - hash *= 9; - hash += *cast(wchar *)str; - return hash; - - default: - hash *= 9; - hash += *cast(uint *)str; - str += 2; - len -= 2; - break; - } - } - - return hash; - } - - int equals(void *p1, void *p2) - { - wchar[] s1 = *cast(wchar[]*)p1; - wchar[] s2 = *cast(wchar[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * wchar.sizeof) == 0; - } - - int compare(void *p1, void *p2) - { - wchar[] s1 = *cast(wchar[]*)p1; - wchar[] s2 = *cast(wchar[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (wchar[]).sizeof; - } -} - diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_C.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_C.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_C.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_C.d 2007-01-23 16:01:06.000000000 +0100 @@ -67,5 +67,10 @@ { return Object.sizeof; } + + uint flags() + { + return 1; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_cdouble.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_cdouble.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2007-01-23 16:01:06.000000000 +0100 @@ -57,5 +57,11 @@ *cast(cdouble *)p1 = *cast(cdouble *)p2; *cast(cdouble *)p2 = t; } + + void[] init() + { static cdouble r; + + return (cast(cdouble *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_cfloat.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_cfloat.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2007-01-23 16:01:06.000000000 +0100 @@ -56,5 +56,11 @@ *cast(cfloat *)p1 = *cast(cfloat *)p2; *cast(cfloat *)p2 = t; } + + void[] init() + { static cfloat r; + + return (cast(cfloat *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_char.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_char.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_char.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_char.d 2007-01-23 16:01:06.000000000 +0100 @@ -33,5 +33,11 @@ *cast(char *)p1 = *cast(char *)p2; *cast(char *)p2 = t; } + + void[] init() + { static char c; + + return (cast(char *)&c)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_creal.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_creal.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_creal.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_creal.d 2007-01-23 16:01:06.000000000 +0100 @@ -58,5 +58,11 @@ *cast(creal *)p1 = *cast(creal *)p2; *cast(creal *)p2 = t; } + + void[] init() + { static creal r; + + return (cast(creal *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_dchar.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_dchar.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_dchar.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_dchar.d 2007-01-23 16:01:06.000000000 +0100 @@ -35,5 +35,11 @@ *cast(dchar *)p1 = *cast(dchar *)p2; *cast(dchar *)p2 = t; } + + void[] init() + { static dchar c; + + return (cast(dchar *)&c)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_delegate.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_delegate.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_delegate.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_delegate.d 2007-01-23 16:01:06.000000000 +0100 @@ -31,5 +31,10 @@ *cast(dg *)p1 = *cast(dg *)p2; *cast(dg *)p2 = t; } + + uint flags() + { + return 1; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_double.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_double.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_double.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_double.d 2007-01-23 16:01:06.000000000 +0100 @@ -57,5 +57,11 @@ *cast(double *)p1 = *cast(double *)p2; *cast(double *)p2 = t; } + + void[] init() + { static double r; + + return (cast(double *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_float.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_float.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_float.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_float.d 2007-01-23 16:01:06.000000000 +0100 @@ -57,5 +57,11 @@ *cast(float *)p1 = *cast(float *)p2; *cast(float *)p2 = t; } + + void[] init() + { static float r; + + return (cast(float *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_ptr.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_ptr.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_ptr.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_ptr.d 2007-01-23 16:01:06.000000000 +0100 @@ -33,5 +33,10 @@ *cast(void* *)p1 = *cast(void* *)p2; *cast(void* *)p2 = t; } + + uint flags() + { + return 1; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_real.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_real.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_real.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_real.d 2007-01-23 16:01:06.000000000 +0100 @@ -57,5 +57,11 @@ *cast(real *)p1 = *cast(real *)p2; *cast(real *)p2 = t; } + + void[] init() + { static real r; + + return (cast(real *)&r)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_void.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_void.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_void.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_void.d 2007-01-23 16:01:06.000000000 +0100 @@ -35,5 +35,10 @@ *cast(byte *)p1 = *cast(byte *)p2; *cast(byte *)p2 = t; } + + uint flags() + { + return 1; + } } diff -uNr dmd-1.00/dmd/src/phobos/std/typeinfo/ti_wchar.d dmd-1.001/dmd/src/phobos/std/typeinfo/ti_wchar.d --- dmd-1.00/dmd/src/phobos/std/typeinfo/ti_wchar.d 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/std/typeinfo/ti_wchar.d 2007-01-23 16:01:06.000000000 +0100 @@ -34,5 +34,11 @@ *cast(wchar *)p1 = *cast(wchar *)p2; *cast(wchar *)p2 = t; } + + void[] init() + { static wchar c; + + return (cast(wchar *)&c)[0 .. 1]; + } } diff -uNr dmd-1.00/dmd/src/phobos/win32.mak dmd-1.001/dmd/src/phobos/win32.mak --- dmd-1.00/dmd/src/phobos/win32.mak 2007-01-02 17:53:58.000000000 +0100 +++ dmd-1.001/dmd/src/phobos/win32.mak 2007-01-23 16:01:06.000000000 +0100 @@ -75,18 +75,18 @@ errno.obj boxer.obj cstream.obj charset.obj \ gamma.obj demangle.obj cover.obj bitarray.obj aApplyR.obj \ signals.obj cpuid.obj typetuple.obj traits.obj bind.obj \ - ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \ + ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \ ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \ ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \ ti_float.obj ti_double.obj ti_real.obj ti_delegate.obj \ ti_creal.obj ti_ireal.obj \ ti_cfloat.obj ti_ifloat.obj \ ti_cdouble.obj ti_idouble.obj \ - ti_AC.obj ti_Aubyte.obj ti_Aushort.obj ti_Ashort.obj \ - ti_Aint.obj ti_Auint.obj ti_Along.obj ti_Aulong.obj ti_Awchar.obj \ + ti_AC.obj ti_Ashort.obj \ + ti_Aint.obj ti_Along.obj \ ti_Afloat.obj ti_Adouble.obj ti_Areal.obj \ ti_Acfloat.obj ti_Acdouble.obj ti_Acreal.obj \ - ti_dchar.obj ti_Adchar.obj ti_void.obj + ti_dchar.obj ti_void.obj # ti_bit.obj ti_Abit.obj @@ -160,28 +160,24 @@ std\typeinfo\ti_short.d std\typeinfo\ti_ushort.d \ std\typeinfo\ti_byte.d std\typeinfo\ti_ubyte.d \ std\typeinfo\ti_long.d std\typeinfo\ti_ulong.d \ - std\typeinfo\ti_ptr.d \ + std\typeinfo\ti_ptr.d std\typeinfo\ti_dchar.d \ std\typeinfo\ti_float.d std\typeinfo\ti_double.d \ std\typeinfo\ti_real.d std\typeinfo\ti_delegate.d \ std\typeinfo\ti_creal.d std\typeinfo\ti_ireal.d \ std\typeinfo\ti_cfloat.d std\typeinfo\ti_ifloat.d \ std\typeinfo\ti_cdouble.d std\typeinfo\ti_idouble.d \ - std\typeinfo\ti_Adchar.d std\typeinfo\ti_Aubyte.d \ - std\typeinfo\ti_Aushort.d std\typeinfo\ti_Ashort.d \ - std\typeinfo\ti_Aa.d std\typeinfo\ti_Ag.d \ + std\typeinfo\ti_Ashort.d \ + std\typeinfo\ti_Ag.d \ std\typeinfo\ti_AC.d std\typeinfo\ti_C.d \ std\typeinfo\ti_int.d std\typeinfo\ti_char.d \ - std\typeinfo\ti_Aint.d std\typeinfo\ti_Auint.d \ - std\typeinfo\ti_Along.d std\typeinfo\ti_Aulong.d \ + std\typeinfo\ti_Aint.d \ + std\typeinfo\ti_Along.d \ std\typeinfo\ti_Afloat.d std\typeinfo\ti_Adouble.d \ std\typeinfo\ti_Areal.d \ std\typeinfo\ti_Acfloat.d std\typeinfo\ti_Acdouble.d \ std\typeinfo\ti_Acreal.d \ - std\typeinfo\ti_Awchar.d std\typeinfo\ti_dchar.d \ std\typeinfo\ti_void.d -# std\typeinfo\ti_bit.d std\typeinfo\ti_Abit.d - SRC_INT= \ internal\switch.d internal\complex.c internal\critical.c \ internal\minit.asm internal\alloca.d internal\llmath.d internal\deh.c \ @@ -237,6 +233,7 @@ etc\c\zlib\linux.mak SRC_GC= internal\gc\gc.d \ + internal\gc\gcold.d \ internal\gc\gcx.d \ internal\gc\gcstub.d \ internal\gc\gcbits.d \ @@ -592,9 +589,6 @@ ti_idouble.obj : std\typeinfo\ti_idouble.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_idouble.d -ti_Aa.obj : std\typeinfo\ti_Aa.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Aa.d - ti_AC.obj : std\typeinfo\ti_AC.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_AC.d @@ -604,24 +598,12 @@ ti_Abit.obj : std\typeinfo\ti_Abit.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Abit.d -ti_Aubyte.obj : std\typeinfo\ti_Aubyte.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Aubyte.d - -ti_Aushort.obj : std\typeinfo\ti_Aushort.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Aushort.d - ti_Ashort.obj : std\typeinfo\ti_Ashort.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Ashort.d -ti_Auint.obj : std\typeinfo\ti_Auint.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Auint.d - ti_Aint.obj : std\typeinfo\ti_Aint.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Aint.d -ti_Aulong.obj : std\typeinfo\ti_Aulong.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Aulong.d - ti_Along.obj : std\typeinfo\ti_Along.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Along.d @@ -643,12 +625,6 @@ ti_Acreal.obj : std\typeinfo\ti_Acreal.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Acreal.d -ti_Awchar.obj : std\typeinfo\ti_Awchar.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Awchar.d - -ti_Adchar.obj : std\typeinfo\ti_Adchar.d - $(DMD) -c $(DFLAGS) std\typeinfo\ti_Adchar.d - ti_C.obj : std\typeinfo\ti_C.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_C.d