diff -uNr dmd-0.178/dmd/src/dmd/cond.c dmd-1.00/dmd/src/dmd/cond.c --- dmd-0.178/dmd/src/dmd/cond.c 2006-11-30 01:14:36.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/cond.c 2006-12-31 22:27:48.000000000 +0100 @@ -247,7 +247,7 @@ inc = 2; else { - e->error("expression %s does not evaluate to a boolean", e->toChars()); + e->error("expression %s is not constant or does not evaluate to a bool", e->toChars()); inc = 2; } } diff -uNr dmd-0.178/dmd/src/dmd/constfold.c dmd-1.00/dmd/src/dmd/constfold.c --- dmd-0.178/dmd/src/dmd/constfold.c 2006-12-06 11:38:50.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/constfold.c 2006-12-27 11:30:02.000000000 +0100 @@ -574,8 +574,8 @@ e = new RealExp(loc, creall(c), type); else if (type->isimaginary()) e = new RealExp(loc, cimagl(c), type); - //else if (type->iscomplex()) - //e = new ComplexExp(loc, c, type); + else if (type->iscomplex()) + e = new ComplexExp(loc, c, type); else assert(0); } diff -uNr dmd-0.178/dmd/src/dmd/delegatize.c dmd-1.00/dmd/src/dmd/delegatize.c --- dmd-0.178/dmd/src/dmd/delegatize.c 2006-11-20 00:15:04.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/delegatize.c 2007-01-01 20:32:02.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 @@ -100,13 +100,13 @@ void SuperExp::scanForNestedRef(Scope *sc) { - assert(0); + ThisExp::scanForNestedRef(sc); } void FuncExp::scanForNestedRef(Scope *sc) { //printf("FuncExp::scanForNestedRef(%s)\n", toChars()); - fd->parent = sc->parent; + //fd->parent = sc->parent; } void DeclarationExp::scanForNestedRef(Scope *sc) diff -uNr dmd-0.178/dmd/src/dmd/dsymbol.c dmd-1.00/dmd/src/dmd/dsymbol.c --- dmd-0.178/dmd/src/dmd/dsymbol.c 2006-11-24 00:49:58.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/dsymbol.c 2006-12-29 19:34:48.000000000 +0100 @@ -742,6 +742,7 @@ { VarDeclaration **pvar; Expression *ce; + L1: if (type) { VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::dollar, NULL); @@ -767,6 +768,16 @@ } else return NULL; + + if (ce->op == TOKtype) + { + Type *t = ((TypeExp *)ce)->type; + if (t->ty == Ttuple) + { type = (TypeTuple *)t; + goto L1; + } + } + if (!*pvar) { VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::dollar, NULL); diff -uNr dmd-0.178/dmd/src/dmd/enum.c dmd-1.00/dmd/src/dmd/enum.c --- dmd-0.178/dmd/src/dmd/enum.c 2006-11-19 19:43:46.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/enum.c 2007-01-01 00:39:58.000000000 +0100 @@ -102,6 +102,9 @@ { assert(e->dyncast() == DYNCAST_EXPRESSION); e = e->semantic(sce); + e = e->optimize(WANTvalue); + // Need to copy it because we're going to change the type + e = e->copy(); e = e->implicitCastTo(sc, memtype); e = e->optimize(WANTvalue); number = e->toInteger(); diff -uNr dmd-0.178/dmd/src/dmd/expression.c dmd-1.00/dmd/src/dmd/expression.c --- dmd-0.178/dmd/src/dmd/expression.c 2006-12-23 10:19:40.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/expression.c 2006-12-30 18:15:16.000000000 +0100 @@ -1277,13 +1277,27 @@ #endif } +/******************************** + * Test to see if two reals are the same. + * Regard NaN's as equivalent. + * Regard +0 and -0 as different. + */ + +int RealEquals(real_t x1, real_t x2) +{ + return (isnan(x1) && isnan(x2)) || + memcmp(&x1, &x2, sizeof(real_t)) == 0; +} + int RealExp::equals(Object *o) { RealExp *ne; if (this == o || (((Expression *)o)->op == TOKfloat64 && ((ne = (RealExp *)o), type->equals(ne->type)) && - memcmp(&value, &ne->value, sizeof(value)) == 0)) + RealEquals(value, ne->value) + ) + ) return 1; return 0; } @@ -1478,7 +1492,10 @@ if (this == o || (((Expression *)o)->op == TOKcomplex80 && ((ne = (ComplexExp *)o), type->equals(ne->type)) && - memcmp(&value, &ne->value, sizeof(value)) == 0)) + RealEquals(creall(value), creall(ne->value)) && + RealEquals(cimagl(value), cimagl(ne->value)) + ) + ) return 1; return 0; } @@ -2293,49 +2310,44 @@ } void StringExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) -{ size_t i; - +{ buf->writeByte('"'); - for (i = 0; i < len;) + for (size_t i = 0; i < len; i++) { unsigned c; - char *p; switch (sz) { case 1: - p = utf_decodeChar((unsigned char *)string, len, &i, &c); + c = ((unsigned char *)string)[i]; break; case 2: - p = utf_decodeWchar((unsigned short *)string, len, &i, &c); + c = ((unsigned short *)string)[i]; break; case 4: - p = NULL; c = ((unsigned *)string)[i]; - i++; break; default: assert(0); } switch (c) { - case 0: - break; - case '"': case '\\': buf->writeByte('\\'); default: - if (isprint(c)) - buf->writeByte(c); - else if (c <= 0x7F) - buf->printf("\\x%02x", c); + if (c <= 0xFF) + { if (c <= 0x7F && isprint(c)) + buf->writeByte(c); + else + buf->printf("\\x%02x", c); + } else if (c <= 0xFFFF) - buf->printf("\\u%04x", c); + buf->printf("\\x%02x\\x%02x", c & 0xFF, c >> 8); else - buf->printf("\\U%08x", c); - continue; + buf->printf("\\x%02x\\x%02x\\x%02x\\x%02x", + c & 0xFF, (c >> 8) & 0xFF, (c >> 16) & 0xFF, c >> 24); + break; } - break; } buf->writeByte('"'); if (postfix) @@ -2454,7 +2466,7 @@ int ArrayLiteralExp::checkSideEffect(int flag) { int f = 0; - for (int i = 0; i < elements->dim; i++) + for (size_t i = 0; i < elements->dim; i++) { Expression *e = (Expression *)elements->data[i]; f |= e->checkSideEffect(2); @@ -2471,13 +2483,22 @@ } void ArrayLiteralExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) -{ int i; - +{ buf->writeByte('['); argsToCBuffer(buf, elements, hgs); buf->writeByte(']'); } +void ArrayLiteralExp::toMangleBuffer(OutBuffer *buf) +{ + size_t dim = elements ? elements->dim : 0; + buf->printf("A%u", dim); + for (size_t i = 0; i < dim; i++) + { Expression *e = (Expression *)elements->data[i]; + e->toMangleBuffer(buf); + } +} + /************************ TypeDotIdExp ************************************/ /* Things like: @@ -2531,6 +2552,13 @@ this->type = type; } +Expression *TypeExp::semantic(Scope *sc) +{ + //printf("TypeExp::semantic(%s)\n", type->toChars()); + type = type->semantic(loc, sc); + return this; +} + void TypeExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { type->toCBuffer(buf, NULL, hgs); @@ -3269,9 +3297,8 @@ void TupleExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { - buf->writestring("tuple("); + buf->writestring("tuple"); argsToCBuffer(buf, exps, hgs); - buf->writestring(")"); } int TupleExp::checkSideEffect(int flag) diff -uNr dmd-0.178/dmd/src/dmd/expression.h dmd-1.00/dmd/src/dmd/expression.h --- dmd-0.178/dmd/src/dmd/expression.h 2006-12-23 10:19:50.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/expression.h 2006-12-30 18:15:14.000000000 +0100 @@ -342,6 +342,7 @@ elem *toElem(IRState *irs); int checkSideEffect(int flag); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); + void toMangleBuffer(OutBuffer *buf); void scanForNestedRef(Scope *sc); Expression *optimize(int result); int implicitConvTo(Type *t); @@ -366,6 +367,7 @@ struct TypeExp : Expression { TypeExp(Loc loc, Type *type); + Expression *semantic(Scope *sc); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); Expression *optimize(int result); elem *toElem(IRState *irs); @@ -624,6 +626,11 @@ Expression *semantic(Scope *sc); int checkSideEffect(int flag); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); + + int inlineCost(InlineCostState *ics); + Expression *doInline(InlineDoState *ids); + Expression *inlineScan(InlineScanState *iss); + elem *toElem(IRState *irs); }; diff -uNr dmd-0.178/dmd/src/dmd/init.c dmd-1.00/dmd/src/dmd/init.c --- dmd-0.178/dmd/src/dmd/init.c 2006-12-23 10:20:58.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/init.c 2006-12-30 11:42:56.000000000 +0100 @@ -97,11 +97,8 @@ Expression *VoidInitializer::toExpression() { -#ifdef DEBUG - halt(); -#endif - assert(0); - return NULL; + error(loc, "void initializer has no value"); + return new IntegerExp(0); } diff -uNr dmd-0.178/dmd/src/dmd/inline.c dmd-1.00/dmd/src/dmd/inline.c --- dmd-0.178/dmd/src/dmd/inline.c 2006-11-14 02:46:08.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/inline.c 2006-12-30 11:54:36.000000000 +0100 @@ -245,6 +245,11 @@ return 1 + e1->inlineCost(ics); } +int AssertExp::inlineCost(InlineCostState *ics) +{ + return 1 + e1->inlineCost(ics) + (msg ? msg->inlineCost(ics) : 0); +} + int BinExp::inlineCost(InlineCostState *ics) { return 1 + e1->inlineCost(ics) + e2->inlineCost(ics); @@ -558,6 +563,16 @@ return ue; } +Expression *AssertExp::doInline(InlineDoState *ids) +{ + AssertExp *ae = (AssertExp *)copy(); + + ae->e1 = e1->doInline(ids); + if (msg) + ae->msg = msg->doInline(ids); + return ae; +} + Expression *BinExp::doInline(InlineDoState *ids) { BinExp *be = (BinExp *)copy(); @@ -980,6 +995,14 @@ return this; } +Expression *AssertExp::inlineScan(InlineScanState *iss) +{ + e1 = e1->inlineScan(iss); + if (msg) + msg = msg->inlineScan(iss); + return this; +} + Expression *BinExp::inlineScan(InlineScanState *iss) { e1 = e1->inlineScan(iss); diff -uNr dmd-0.178/dmd/src/dmd/mars.c dmd-1.00/dmd/src/dmd/mars.c --- dmd-0.178/dmd/src/dmd/mars.c 2006-12-23 20:41:44.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/mars.c 2007-01-02 12:04:58.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 @@ -58,9 +58,9 @@ #error "fix this" #endif - copyright = "Copyright (c) 1999-2006 by Digital Mars"; + copyright = "Copyright (c) 1999-2007 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.178"; + version = "v1.0"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); diff -uNr dmd-0.178/dmd/src/dmd/module.c dmd-1.00/dmd/src/dmd/module.c --- dmd-0.178/dmd/src/dmd/module.c 2006-11-30 02:09:36.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/module.c 2006-12-29 11:08:42.000000000 +0100 @@ -78,6 +78,7 @@ searchCacheIdent = NULL; searchCacheSymbol = NULL; searchCacheFlags = 0; + semanticstarted = 0; semanticdone = 0; decldefs = NULL; vmoduleinfo = NULL; @@ -230,6 +231,19 @@ //printf("Module::load(ident = '%s')\n", ident->toChars()); + if (global.params.verbose) + { + printf("import "); + if (packages) + { + for (size_t i = 0; i < packages->dim; i++) + { Identifier *pid = (Identifier *)packages->data[i]; + printf("%s.", pid->toChars()); + } + } + printf("%s\n", ident->toChars()); + } + // Build module filename by turning: // foo.bar.baz // into: @@ -598,11 +612,11 @@ void Module::semantic() { int i; - if (semanticdone) + if (semanticstarted) return; //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); - semanticdone = 1; + semanticstarted = 1; // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module @@ -639,6 +653,7 @@ sc = sc->pop(); sc->pop(); + semanticdone = semanticstarted; //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); } @@ -656,10 +671,10 @@ return; } //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); - if (semanticdone >= 2) + if (semanticstarted >= 2) return; - assert(semanticdone == 1); - semanticdone = 2; + assert(semanticstarted == 1); + semanticstarted = 2; // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module @@ -677,6 +692,7 @@ sc = sc->pop(); sc->pop(); + semanticdone = semanticstarted; //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); } @@ -684,10 +700,10 @@ { int i; //printf("Module::semantic3('%s'): parent = %p\n", toChars(), parent); - if (semanticdone >= 3) + if (semanticstarted >= 3) return; - assert(semanticdone == 2); - semanticdone = 3; + assert(semanticstarted == 2); + semanticstarted = 3; // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module @@ -706,15 +722,16 @@ sc = sc->pop(); sc->pop(); + semanticdone = semanticstarted; } void Module::inlineScan() { int i; - if (semanticdone >= 4) + if (semanticstarted >= 4) return; - assert(semanticdone == 3); - semanticdone = 4; + assert(semanticstarted == 3); + semanticstarted = 4; // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module @@ -730,6 +747,7 @@ s->inlineScan(); } + semanticdone = semanticstarted; } /**************************************************** diff -uNr dmd-0.178/dmd/src/dmd/module.h dmd-1.00/dmd/src/dmd/module.h --- dmd-0.178/dmd/src/dmd/module.h 2006-10-05 16:01:40.000000000 +0200 +++ dmd-1.00/dmd/src/dmd/module.h 2006-12-29 11:06:46.000000000 +0100 @@ -76,6 +76,7 @@ Dsymbol *searchCacheSymbol; // cached value of search int searchCacheFlags; // cached flags + int semanticstarted; // has semantic() been started? int semanticdone; // has semantic() been done? Module *importedFrom; // module from command line we're imported from, // i.e. a module that will be taken all the diff -uNr dmd-0.178/dmd/src/dmd/mtype.c dmd-1.00/dmd/src/dmd/mtype.c --- dmd-0.178/dmd/src/dmd/mtype.c 2006-12-23 10:21:14.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/mtype.c 2007-01-01 21:46:54.000000000 +0100 @@ -2469,7 +2469,7 @@ void TypeFunction::toDecoBuffer(OutBuffer *buf) { unsigned char mc; - //printf("TypeFunction::toDecoBuffer() this = %p\n", this); + //printf("TypeFunction::toDecoBuffer() this = %p %s\n", this, toChars()); //static int nest; if (++nest == 50) *(char*)0=0; if (inuse) { inuse = 2; // flag error to caller @@ -2489,6 +2489,7 @@ buf->writeByte(mc); // Write argument types Argument::argsToDecoBuffer(buf, parameters); + //if (buf->data[buf->offset - 1] == '@') halt(); buf->writeByte('Z' - varargs); // mark end of arg list next->toDecoBuffer(buf); inuse--; @@ -2498,6 +2499,11 @@ { char *p = NULL; + if (inuse) + { inuse = 2; // flag error to caller + return; + } + inuse++; if (hgs->ddoc != 1) { switch (linkage) @@ -2531,6 +2537,7 @@ Argument::argsToCBuffer(buf, hgs, parameters, varargs); if (next && (!ident || ident->toHChars2() == ident->toChars())) next->toCBuffer2(buf, NULL, hgs); + inuse--; } Type *TypeFunction::semantic(Loc loc, Scope *sc) @@ -2571,8 +2578,17 @@ { Argument *arg = Argument::getNth(parameters, i); Type *t; + inuse++; arg->type = arg->type->semantic(loc,sc); + if (inuse == 1) inuse--; t = arg->type->toBasetype(); + + /* If arg turns out to be a tuple, the number of parameters may + * change. + */ + if (t->ty == Ttuple) + dim = Argument::dim(parameters); + if (arg->inout != In) { if (t->ty == Tsarray) @@ -3762,7 +3778,11 @@ assert(v); if (v->init) - return v->init->toExpression(); + { if (v->init->isVoidInitializer()) + error(e->loc, "%s.init is void", v->toChars()); + else + return v->init->toExpression(); + } } return defaultInit(); } @@ -4515,7 +4535,8 @@ arguments->setDim(exps->dim); for (size_t i = 0; i < exps->dim; i++) { Expression *e = (Expression *)exps->data[i]; - assert(e->type->ty != Ttuple); + if (e->type->ty == Ttuple) + e->error("cannot form tuple of tuples"); Argument *arg = new Argument(In, e->type, NULL, NULL); arguments->data[i] = (void *)arg; } @@ -4815,7 +4836,7 @@ void Argument::argsToDecoBuffer(OutBuffer *buf, Arguments *arguments) { - //printf("Argument::argsToDecoBuffer() this = %p\n", this); + //printf("Argument::argsToDecoBuffer()\n"); // Write argument types if (arguments) diff -uNr dmd-0.178/dmd/src/dmd/parse.c dmd-1.00/dmd/src/dmd/parse.c --- dmd-0.178/dmd/src/dmd/parse.c 2006-12-15 00:57:22.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/parse.c 2006-12-29 01:56:46.000000000 +0100 @@ -4304,6 +4304,7 @@ } e = new TypeDotIdExp(loc, t, token.ident); nextToken(); + e = parsePostExp(e); } else { diff -uNr dmd-0.178/dmd/src/dmd/statement.c dmd-1.00/dmd/src/dmd/statement.c --- dmd-0.178/dmd/src/dmd/statement.c 2006-12-20 19:27:36.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/statement.c 2006-12-30 17:07:58.000000000 +0100 @@ -1678,7 +1678,7 @@ Statement *ConditionalStatement::semantic(Scope *sc) { - printf("ConditionalStatement::semantic()\n"); + //printf("ConditionalStatement::semantic()\n"); // If we can short-circuit evaluate the if statement, don't do the // semantic analysis of the skipped code. @@ -2344,7 +2344,9 @@ { VarExp *ve = (VarExp *)exp; VarDeclaration *v = ve->var->isVarDeclaration(); - if (fd->nrvo_var == NULL) + if (!v) + fd->nrvo_can = 0; + else if (fd->nrvo_var == NULL) { if (!v->isDataseg() && !v->isParameter() && v->toParent2() == fd) fd->nrvo_var = v; else diff -uNr dmd-0.178/dmd/src/dmd/struct.c dmd-1.00/dmd/src/dmd/struct.c --- dmd-0.178/dmd/src/dmd/struct.c 2006-11-08 19:03:36.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/struct.c 2007-01-01 14:27:38.000000000 +0100 @@ -51,13 +51,16 @@ } void AggregateDeclaration::semantic2(Scope *sc) -{ int i; - +{ //printf("AggregateDeclaration::semantic2(%s)\n", toChars()); + if (scope) + { error("has forward references"); + return; + } if (members) { sc = sc->push(this); - for (i = 0; i < members->dim; i++) + for (size_t i = 0; i < members->dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; s->semantic2(sc); diff -uNr dmd-0.178/dmd/src/dmd/template.c dmd-1.00/dmd/src/dmd/template.c --- dmd-0.178/dmd/src/dmd/template.c 2006-12-20 19:42:46.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/template.c 2006-12-31 23:14:00.000000000 +0100 @@ -792,6 +792,7 @@ if (targ) { + //printf("type %s\n", targ->toChars()); s = new AliasDeclaration(0, tp->ident, targ); } else if (sa) @@ -2424,6 +2425,7 @@ // Add 'this' to the enclosing scope's members[] so the semantic routines // will get called on the instance members #if 1 + int dosemantic3 = 0; { Array *a; int i; @@ -2438,6 +2440,8 @@ m = m->importedFrom; //printf("\t2: adding to module %s\n", m->toChars()); a = m->members; + if (m->semanticdone >= 3) + dosemantic3 = 1; } for (i = 0; 1; i++) { @@ -2551,9 +2555,13 @@ */ // if (sc->parent->isFuncDeclaration()) + /* BUG 782: this has problems if the classes this depends on + * are forward referenced. Find a way to defer semantic() + * on this template. + */ semantic2(sc2); - if (sc->func) + if (sc->func || dosemantic3) { semantic3(sc2); } @@ -2975,6 +2983,7 @@ Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); Tuple *va = isTuple(o); + //printf("\to %p ta %p ea %p sa %p va %p\n", o, ta, ea, sa, va); if (ta) { buf.writeByte('T'); @@ -3006,6 +3015,10 @@ goto Lsa; } buf.writeByte('V'); + if (ea->op == TOKtuple) + { ea->error("tuple is not a valid template value argument"); + continue; + } #if 1 buf.writestring(ea->type->deco); #else diff -uNr dmd-0.178/dmd/src/dmd/todt.c dmd-1.00/dmd/src/dmd/todt.c --- dmd-0.178/dmd/src/dmd/todt.c 2006-11-29 20:26:12.000000000 +0100 +++ dmd-1.00/dmd/src/dmd/todt.c 2007-01-02 00:22:08.000000000 +0100 @@ -124,7 +124,8 @@ for (k = j + 1; 1; k++) { if (k == dts.dim) // didn't find any overlap - { v->type->toDt(&d); // provide default initializer + { + v->type->toDt(&d); break; } VarDeclaration *v2 = (VarDeclaration *)ad->fields.data[k]; @@ -140,12 +141,36 @@ error(loc, "duplicate union initialization for %s", v->toChars()); else { unsigned sz = dt_size(d); + unsigned vsz = v->type->size(); + unsigned voffset = v->offset; + assert(sz <= vsz); + + unsigned dim = 1; + for (Type *vt = v->type->toBasetype(); + vt->ty == Tsarray; + vt = vt->next->toBasetype()) + { TypeSArray *tsa = (TypeSArray *)vt; + dim *= tsa->dim->toInteger(); + } - if (offset < v->offset) - pdtend = dtnzeros(pdtend, v->offset - offset); - pdtend = dtcat(pdtend, d); - assert(sz <= v->type->size()); - offset = v->offset + sz; + for (size_t i = 0; i < dim; i++) + { + if (offset < voffset) + pdtend = dtnzeros(pdtend, voffset - offset); + if (!d) + { + if (v->init) + d = v->init->toDt(); + else + v->type->toDt(&d); + } + pdtend = dtcat(pdtend, d); + d = NULL; + offset = voffset + sz; + voffset += vsz / dim; + if (sz == vsz) + break; + } } } } diff -uNr dmd-0.178/dmd/src/phobos/internal/gc/gc.d dmd-1.00/dmd/src/phobos/internal/gc/gc.d --- dmd-0.178/dmd/src/phobos/internal/gc/gc.d 2006-12-23 20:43:28.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/internal/gc/gc.d 2007-01-02 17:53:58.000000000 +0100 @@ -228,6 +228,14 @@ 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++) @@ -241,6 +249,45 @@ return result; } +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; +} + ulong _d_newm(size_t size, int ndims, ...) { ulong result; diff -uNr dmd-0.178/dmd/src/phobos/linux.mak dmd-1.00/dmd/src/phobos/linux.mak --- dmd-0.178/dmd/src/phobos/linux.mak 2006-12-23 20:43:22.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/linux.mak 2007-01-02 17:53:58.000000000 +0100 @@ -141,7 +141,7 @@ std/c/windows/winsock.d std/c/windows/stat.d SRC_STD_C_LINUX= std/c/linux/linux.d std/c/linux/linuxextern.d \ - std/c/linux/socket.d + std/c/linux/socket.d std/c/linux/pthread.d SRC_ETC= etc/gamma.d diff -uNr dmd-0.178/dmd/src/phobos/std/c/linux/linux.d dmd-1.00/dmd/src/phobos/std/c/linux/linux.d --- dmd-0.178/dmd/src/phobos/std/c/linux/linux.d 2006-12-23 20:43:26.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/std/c/linux/linux.d 2007-01-02 17:53:58.000000000 +0100 @@ -9,6 +9,7 @@ module std.c.linux.linux; public import std.c.linux.linuxextern; +public import std.c.linux.pthread; alias int pid_t; alias int off_t; @@ -419,97 +420,6 @@ extern (C) { - /* pthread declarations taken from pthread headers and - http://svn.dsource.org/projects/bindings/trunk/pthreads.d - */ - - /* from bits/types.h - */ - - typedef int __time_t; - - /* from time.h - */ - - struct timespec - { - __time_t tv_sec; /* seconds */ - int tv_nsec; /* nanosecs. */ - } - - /* from bits/pthreadtypes.h - */ - - struct _pthread_descr_struct - { - /* Not defined in the headers ??? - Just needed here to typedef - the _pthread_descr pointer - */ - } - - typedef _pthread_descr_struct* _pthread_descr; - - struct _pthread_fastlock - { - int __status; - int __spinlock; - } - - typedef long __pthread_cond_align_t; - - struct pthread_cond_t - { - _pthread_fastlock __c_lock; - _pthread_descr __c_waiting; - char[48 - - _pthread_fastlock.sizeof - - _pthread_descr.sizeof - - __pthread_cond_align_t.sizeof - ] __padding; - __pthread_cond_align_t __align; - } - - struct pthread_condattr_t - { - int __dummy; - } - - struct pthread_mutex_t - { - int __m_reserved; - int __m_count; - _pthread_descr __m_owner; - int __m_kind; - _pthread_fastlock __m_lock; - } - - struct pthread_mutexattr_t - { - int __mutexkind; - } - - /* from pthread.h - */ - - int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*); - int pthread_mutex_destroy(pthread_mutex_t*); - int pthread_mutex_trylock(pthread_mutex_t*); - int pthread_mutex_lock(pthread_mutex_t*); - int pthread_mutex_unlock(pthread_mutex_t*); - - int pthread_mutexattr_init(pthread_mutexattr_t*); - int pthread_mutexattr_destroy(pthread_mutexattr_t*); - - int pthread_cond_init(pthread_cond_t*, pthread_condattr_t*); - int pthread_cond_destroy(pthread_cond_t*); - int pthread_cond_signal(pthread_cond_t*); - int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); - int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, timespec*); -} - -extern (C) -{ /* from semaphore.h */ diff -uNr dmd-0.178/dmd/src/phobos/std/c/linux/pthread.d dmd-1.00/dmd/src/phobos/std/c/linux/pthread.d --- dmd-0.178/dmd/src/phobos/std/c/linux/pthread.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/std/c/linux/pthread.d 2007-01-02 17:53:58.000000000 +0100 @@ -0,0 +1,257 @@ +/* Written by Walter Bright, Christopher E. Miller, and many others. + * www.digitalmars.com + * Placed into public domain. + */ + +module std.c.linux.pthread; + +extern (C) +{ + /* pthread declarations taken from pthread headers and + http://svn.dsource.org/projects/bindings/trunk/pthreads.d + */ + + /* from bits/types.h + */ + + typedef int __time_t; + + /* from time.h + */ + + struct timespec + { + __time_t tv_sec; /* seconds */ + int tv_nsec; /* nanosecs. */ + } + + /* from bits/pthreadtypes.h + */ + + alias uint pthread_t; + alias uint pthread_key_t; + alias int pthread_once_t; + alias int clockid_t; + alias int pthread_spinlock_t; // volatile + + struct _pthread_descr_struct + { + /* Not defined in the headers ??? + Just needed here to typedef + the _pthread_descr pointer + */ + } + + typedef _pthread_descr_struct* _pthread_descr; + + struct _pthread_fastlock + { + int __status; + int __spinlock; + } + + typedef long __pthread_cond_align_t; + + struct pthread_cond_t + { + _pthread_fastlock __c_lock; + _pthread_descr __c_waiting; + char[48 + - _pthread_fastlock.sizeof + - _pthread_descr.sizeof + - __pthread_cond_align_t.sizeof + ] __padding; + __pthread_cond_align_t __align; + } + + struct pthread_condattr_t + { + int __dummy; + } + + struct pthread_mutex_t + { + int __m_reserved; + int __m_count; + _pthread_descr __m_owner; + int __m_kind; + _pthread_fastlock __m_lock; + } + + struct pthread_mutexattr_t + { + int __mutexkind; + } + + /* from pthread.h + */ + + struct _pthread_cleanup_buffer + { + void function(void*) __routine; + void* __arg; + int __canceltype; + _pthread_cleanup_buffer* __prev; + } + + struct __sched_param // bits/sched.h + { + int __sched_priority; + } + + struct pthread_attr_t + { + int __detachstate; + int __schedpolicy; + __sched_param schedparam; + int __inheritshed; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void* __stackaddr; + size_t __stacksize; + } + + struct pthread_barrier_t + { + _pthread_fastlock __ba_lock; + int __ba_required; + int __ba_present; + _pthread_descr __ba_waiting; + } + + struct pthread_barrierattr_t + { + int __pshared; + } + + struct pthread_rwlockattr_t + { + int __lockkind; + int __pshared; + } + + struct pthread_rwlock_t + { + _pthread_fastlock __rw_lock; + int __rw_readers; + _pthread_descr __rw_writer; + _pthread_descr __rw_read_waiting; + _pthread_descr __rw_write_waiting; + int __rw_kind; + int __rw_pshared; + } + + int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*); + int pthread_mutex_destroy(pthread_mutex_t*); + int pthread_mutex_trylock(pthread_mutex_t*); + int pthread_mutex_lock(pthread_mutex_t*); + int pthread_mutex_unlock(pthread_mutex_t*); + + int pthread_mutexattr_init(pthread_mutexattr_t*); + int pthread_mutexattr_destroy(pthread_mutexattr_t*); + + int pthread_cond_init(pthread_cond_t*, pthread_condattr_t*); + int pthread_cond_destroy(pthread_cond_t*); + int pthread_cond_signal(pthread_cond_t*); + int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); + int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, timespec*); + + int pthread_attr_init(pthread_attr_t*); + int pthread_attr_destroy(pthread_attr_t*); + int pthread_attr_setdetachstate(pthread_attr_t*, int); + int pthread_attr_getdetachstate(pthread_attr_t*, int*); + int pthread_attr_setinheritsched(pthread_attr_t*, int); + int pthread_attr_getinheritsched(pthread_attr_t*, int*); + int pthread_attr_setschedparam(pthread_attr_t*, __sched_param*); + int pthread_attr_getschedparam(pthread_attr_t*, __sched_param*); + int pthread_attr_setschedpolicy(pthread_attr_t*, int); + int pthread_attr_getschedpolicy(pthread_attr_t*, int*); + int pthread_attr_setscope(pthread_attr_t*, int); + int pthread_attr_getscope(pthread_attr_t*, int*); + int pthread_attr_setguardsize(pthread_attr_t*, size_t); + int pthread_attr_getguardsize(pthread_attr_t*, size_t*); + int pthread_attr_setstack(pthread_attr_t*, void*, size_t); + int pthread_attr_getstack(pthread_attr_t*, void**, size_t*); + int pthread_attr_setstackaddr(pthread_attr_t*, void*); + int pthread_attr_getstackaddr(pthread_attr_t*, void**); + int pthread_attr_setstacksize(pthread_attr_t*, size_t); + int pthread_attr_getstacksize(pthread_attr_t*, size_t*); + + int pthread_barrierattr_init(pthread_barrierattr_t*); + int pthread_barrierattr_getpshared(pthread_barrierattr_t*, int*); + int pthread_barrierattr_destroy(pthread_barrierattr_t*); + int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); + + int pthread_barrier_init(pthread_barrier_t*, pthread_barrierattr_t*, uint); + int pthread_barrier_destroy(pthread_barrier_t*); + int pthread_barrier_wait(pthread_barrier_t*); + + int pthread_condattr_init(pthread_condattr_t*); + int pthread_condattr_destroy(pthread_condattr_t*); + int pthread_condattr_getpshared(pthread_condattr_t*, int*); + int pthread_condattr_setpshared(pthread_condattr_t*, int); + + int pthread_detach(pthread_t); + void pthread_exit(void*); + int pthread_getattr_np(pthread_t, pthread_attr_t*); + int pthread_getconcurrency(); + int pthread_getcpuclockid(pthread_t, clockid_t*); + + int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*); + int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int); + int pthread_mutexattr_settype(pthread_mutexattr_t*, int); + int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*); + int pthread_mutex_timedlock(pthread_mutex_t*, timespec*); + int pthread_yield(); + + int pthread_rwlock_init(pthread_rwlock_t*, pthread_rwlockattr_t*); + int pthread_rwlock_destroy(pthread_rwlock_t*); + int pthread_rwlock_rdlock(pthread_rwlock_t*); + int pthread_rwlock_tryrdlock(pthread_rwlock_t*); + int pthread_rwlock_timedrdlock(pthread_rwlock_t*, timespec*); + int pthread_rwlock_wrlock(pthread_rwlock_t*); + int pthread_rwlock_trywrlock(pthread_rwlock_t*); + int pthread_rwlock_timedwrlock(pthread_rwlock_t*, timespec*); + int pthread_rwlock_unlock(pthread_rwlock_t*); + + int pthread_rwlockattr_init(pthread_rwlockattr_t*); + int pthread_rwlockattr_destroy(pthread_rwlockattr_t*); + int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*); + int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int); + int pthread_rwlockattr_getkind_np(pthread_rwlockattr_t*, int*); + int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t*, int); + + int pthread_spin_init(pthread_spinlock_t*, int); + int pthread_spin_destroy(pthread_spinlock_t*); + int pthread_spin_lock(pthread_spinlock_t*); + int pthread_spin_trylock(pthread_spinlock_t*); + int pthread_spin_unlock(pthread_spinlock_t*); + + int pthread_cancel(pthread_t); + void pthread_testcancel(); + int pthread_once(pthread_once_t*, void function()); + + int pthread_join(pthread_t, void**); + int pthread_create(pthread_t*, pthread_attr_t*, void*function(void*), void*); + pthread_t pthread_self(); + int pthread_equal(pthread_t, pthread_t); + int pthread_atfork(void function(), void function(), void function()); + void pthread_kill_other_threads_np(); + int pthread_setschedparam(pthread_t, int, __sched_param*); + int pthread_getschedparam(pthread_t, int*, __sched_param*); + int pthread_cond_broadcast(pthread_cond_t*); + int pthread_key_create(pthread_key_t*, void function(void*)); + int pthread_key_delete(pthread_key_t); + int pthread_setconcurrency(int); + int pthread_setspecific(pthread_key_t, void*); + void* pthread_getspecific(pthread_key_t); + int pthread_setcanceltype(int, int*); + int pthread_setcancelstate(int, int*); + + void _pthread_cleanup_push(_pthread_cleanup_buffer*, void function(void*), void*); + void _pthread_cleanup_push_defer(_pthread_cleanup_buffer*, void function(void*), void*); + void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int); + void _pthread_cleanup_pop_restore(_pthread_cleanup_buffer*, int); +} + diff -uNr dmd-0.178/dmd/src/phobos/std/c/stdlib.d dmd-1.00/dmd/src/phobos/std/c/stdlib.d --- dmd-0.178/dmd/src/phobos/std/c/stdlib.d 2006-12-23 20:43:24.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/std/c/stdlib.d 2007-01-02 17:53:58.000000000 +0100 @@ -40,6 +40,8 @@ void exit(int); /// ditto void _exit(int); /// ditto + int system(char *); + void *alloca(uint); /// void *calloc(size_t, size_t); /// diff -uNr dmd-0.178/dmd/src/phobos/std/conv.d dmd-1.00/dmd/src/phobos/std/conv.d --- dmd-0.178/dmd/src/phobos/std/conv.d 2006-12-23 20:43:22.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/std/conv.d 2007-01-02 17:53:58.000000000 +0100 @@ -1,8 +1,10 @@ +// Written in the D programming language. + /* * Copyright (C) 2002-2006 by Digital Mars, www.digitalmars.com * Written by Walter Bright - * Some parts contributed by David L. Davis + * Some parts contributed by David L. Davis * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages @@ -66,7 +68,7 @@ { this(char[] s) { - super("Error: conversion " ~ s); + super("conversion " ~ s); } } diff -uNr dmd-0.178/dmd/src/phobos/win32.mak dmd-1.00/dmd/src/phobos/win32.mak --- dmd-0.178/dmd/src/phobos/win32.mak 2006-12-23 20:43:22.000000000 +0100 +++ dmd-1.00/dmd/src/phobos/win32.mak 2007-01-02 17:53:58.000000000 +0100 @@ -198,7 +198,7 @@ std\c\windows\winsock.d std\c\windows\stat.d SRC_STD_C_LINUX= std\c\linux\linux.d std\c\linux\linuxextern.d \ - std\c\linux\socket.d + std\c\linux\socket.d std\c\linux\pthread.d SRC_ETC= etc\gamma.d