diff -uNr dmd-1.018/dmd/src/dmd/attrib.c dmd-1.019/dmd/src/dmd/attrib.c --- dmd-1.018/dmd/src/dmd/attrib.c 2007-06-29 15:32:04.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/attrib.c 2007-07-11 09:30:52.000000000 +0200 @@ -292,7 +292,7 @@ buf->writeByte('}'); } else - buf->writeByte(':'); + buf->writeByte(';'); buf->writenl(); } diff -uNr dmd-1.018/dmd/src/dmd/cast.c dmd-1.019/dmd/src/dmd/cast.c --- dmd-1.018/dmd/src/dmd/cast.c 2007-05-24 10:51:20.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/cast.c 2007-07-21 23:10:28.000000000 +0200 @@ -87,7 +87,7 @@ * Don't do the actual cast. */ -int Expression::implicitConvTo(Type *t) +MATCH Expression::implicitConvTo(Type *t) { #if 0 printf("Expression::implicitConvTo(this=%s, type=%s, t=%s)\n", @@ -104,7 +104,7 @@ { //printf("optimzed to %s\n", e->toChars()); return e->implicitConvTo(t); } - int match = type->implicitConvTo(t); + MATCH match = type->implicitConvTo(t); if (match) return match; #if 0 @@ -129,7 +129,7 @@ } -int IntegerExp::implicitConvTo(Type *t) +MATCH IntegerExp::implicitConvTo(Type *t) { #if 0 printf("IntegerExp::implicitConvTo(this=%s, type=%s, t=%s)\n", @@ -142,7 +142,9 @@ enum TY toty = t->toBasetype()->ty; if (type->implicitConvTo(t) == MATCHnomatch && t->ty == Tenum) + { return MATCHnomatch; + } switch (ty) { @@ -302,13 +304,15 @@ return Expression::implicitConvTo(t); Lyes: + //printf("MATCHconvert\n"); return MATCHconvert; Lno: + //printf("MATCHnomatch\n"); return MATCHnomatch; } -int NullExp::implicitConvTo(Type *t) +MATCH NullExp::implicitConvTo(Type *t) { #if 0 printf("NullExp::implicitConvTo(this=%s, type=%s, t=%s)\n", @@ -329,7 +333,7 @@ return Expression::implicitConvTo(t); } -int StringExp::implicitConvTo(Type *t) +MATCH StringExp::implicitConvTo(Type *t) { MATCH m; #if 0 @@ -381,7 +385,7 @@ #endif } -int ArrayLiteralExp::implicitConvTo(Type *t) +MATCH ArrayLiteralExp::implicitConvTo(Type *t) { MATCH result = MATCHexact; Type *typeb = type->toBasetype(); @@ -409,7 +413,7 @@ return Expression::implicitConvTo(t); } -int AssocArrayLiteralExp::implicitConvTo(Type *t) +MATCH AssocArrayLiteralExp::implicitConvTo(Type *t) { MATCH result = MATCHexact; Type *typeb = type->toBasetype(); @@ -436,13 +440,13 @@ return Expression::implicitConvTo(t); } -int AddrExp::implicitConvTo(Type *t) +MATCH AddrExp::implicitConvTo(Type *t) { #if 0 printf("AddrExp::implicitConvTo(this=%s, type=%s, t=%s)\n", toChars(), type->toChars(), t->toChars()); #endif - int result; + MATCH result; result = type->implicitConvTo(t); //printf("\tresult = %d\n", result); @@ -468,13 +472,13 @@ return result; } -int SymOffExp::implicitConvTo(Type *t) +MATCH SymOffExp::implicitConvTo(Type *t) { #if 0 printf("SymOffExp::implicitConvTo(this=%s, type=%s, t=%s)\n", toChars(), type->toChars(), t->toChars()); #endif - int result; + MATCH result; result = type->implicitConvTo(t); //printf("\tresult = %d\n", result); @@ -497,13 +501,13 @@ return result; } -int DelegateExp::implicitConvTo(Type *t) +MATCH DelegateExp::implicitConvTo(Type *t) { #if 0 printf("DelegateExp::implicitConvTo(this=%s, type=%s, t=%s)\n", toChars(), type->toChars(), t->toChars()); #endif - int result; + MATCH result; result = type->implicitConvTo(t); @@ -517,16 +521,16 @@ t->ty == Tdelegate && t->next->ty == Tfunction) { if (func && func->overloadExactMatch(t->next)) - result = 2; + result = MATCHexact; } } return result; } -int CondExp::implicitConvTo(Type *t) +MATCH CondExp::implicitConvTo(Type *t) { - int m1; - int m2; + MATCH m1; + MATCH m2; m1 = e1->implicitConvTo(t); m2 = e2->implicitConvTo(t); diff -uNr dmd-1.018/dmd/src/dmd/constfold.c dmd-1.019/dmd/src/dmd/constfold.c --- dmd-1.018/dmd/src/dmd/constfold.c 2007-04-24 15:12:30.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/constfold.c 2007-07-02 22:34:20.000000000 +0200 @@ -22,6 +22,8 @@ #include "mtype.h" #include "expression.h" +#include "aggregate.h" +#include "declaration.h" #ifdef IN_GCC #include "d-gcc-real.h" @@ -1026,14 +1028,31 @@ } else if (tb->isscalar()) e = new IntegerExp(loc, e1->toInteger(), type); + else if (tb->ty == Tvoid) + e = EXP_CANT_INTERPRET; + else if (tb->ty == Tstruct && e1->op == TOKint64) + { // Struct = 0; + StructDeclaration *sd = tb->toDsymbol(NULL)->isStructDeclaration(); + assert(sd); + Expressions *elements = new Expressions; + for (size_t i = 0; i < sd->fields.dim; i++) + { Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + VarDeclaration *v = s->isVarDeclaration(); + assert(v); + + Expression *exp = new IntegerExp(0); + exp = Cast(v->type, v->type, exp); + if (exp == EXP_CANT_INTERPRET) + return exp; + elements->push(exp); + } + e = new StructLiteralExp(loc, sd, elements); + e->type = type; + } else { - if (tb->ty == Tvoid) - e = EXP_CANT_INTERPRET; - else - { error("cannot cast %s to %s", e1->type->toChars(), type->toChars()); - e = new IntegerExp(loc, 0, type); - } + error("cannot cast %s to %s", e1->type->toChars(), type->toChars()); + e = new IntegerExp(loc, 0, type); } return e; } @@ -1079,7 +1098,7 @@ uinteger_t i = e2->toInteger(); if (i >= es1->len) - e1->error("string index %ju is out of bounds [0 .. %ju]", i, es1->len); + e1->error("string index %ju is out of bounds [0 .. %zu]", i, es1->len); else { integer_t value; diff -uNr dmd-1.018/dmd/src/dmd/declaration.h dmd-1.019/dmd/src/dmd/declaration.h --- dmd-1.018/dmd/src/dmd/declaration.h 2007-04-10 14:38:56.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/declaration.h 2007-07-11 11:20:50.000000000 +0200 @@ -74,6 +74,9 @@ }; void overloadResolveX(Match *m, FuncDeclaration *f, Expressions *arguments); +int overloadApply(FuncDeclaration *fstart, + int (*fp)(void *, FuncDeclaration *), + void *param); /**************************************************************/ diff -uNr dmd-1.018/dmd/src/dmd/expression.c dmd-1.019/dmd/src/dmd/expression.c --- dmd-1.018/dmd/src/dmd/expression.c 2007-07-01 00:20:34.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/expression.c 2007-07-15 12:17:26.000000000 +0200 @@ -3122,7 +3122,7 @@ ClassDeclaration *cd = tc->sym->isClassDeclaration(); if (cd->isInterfaceDeclaration()) error("cannot create instance of interface %s", cd->toChars()); - if (cd->isAbstract()) + else if (cd->isAbstract()) error("cannot create instance of abstract class %s", cd->toChars()); checkDeprecated(sc, cd); if (cd->isNested()) diff -uNr dmd-1.018/dmd/src/dmd/expression.h dmd-1.019/dmd/src/dmd/expression.h --- dmd-1.018/dmd/src/dmd/expression.h 2007-06-30 23:56:26.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/expression.h 2007-07-20 12:39:02.000000000 +0200 @@ -99,7 +99,7 @@ virtual Expression *toLvalue(Scope *sc, Expression *e); virtual Expression *modifiableLvalue(Scope *sc, Expression *e); Expression *implicitCastTo(Scope *sc, Type *t); - virtual int implicitConvTo(Type *t); + virtual MATCH implicitConvTo(Type *t); virtual Expression *castTo(Scope *sc, Type *t); virtual void checkEscape(); void checkScalar(); @@ -159,7 +159,7 @@ complex_t toComplex(); int isConst(); int isBool(int result); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); void toMangleBuffer(OutBuffer *buf); Expression *toLvalue(Scope *sc, Expression *e); @@ -286,7 +286,7 @@ int isBool(int result); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); void toMangleBuffer(OutBuffer *buf); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); Expression *interpret(InterState *istate); elem *toElem(IRState *irs); @@ -310,7 +310,7 @@ Expression *semantic(Scope *sc); Expression *interpret(InterState *istate); StringExp *toUTF8(Scope *sc); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); int compare(Object *obj); int isBool(int result); @@ -361,7 +361,7 @@ void scanForNestedRef(Scope *sc); Expression *optimize(int result); Expression *interpret(InterState *istate); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); dt_t **toDt(dt_t **pdt); @@ -387,7 +387,7 @@ void scanForNestedRef(Scope *sc); Expression *optimize(int result); Expression *interpret(InterState *istate); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); int inlineCost(InlineCostState *ics); @@ -524,7 +524,7 @@ int isConst(); int isBool(int result); Expression *doInline(InlineDoState *ids); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); void scanForNestedRef(Scope *sc); @@ -678,7 +678,7 @@ void scanForNestedRef(Scope *sc); Expression *interpretCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); Expression *interpretCommon2(InterState *istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)); - Expression *interpretAssignCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *)); + Expression *interpretAssignCommon(InterState *istate, Expression *(*fp)(Type *, Expression *, Expression *), int post = 0); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); @@ -777,7 +777,7 @@ DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); Expression *semantic(Scope *sc); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); void dump(int indent); @@ -826,7 +826,7 @@ AddrExp(Loc loc, Expression *e); Expression *semantic(Scope *sc); elem *toElem(IRState *irs); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); Expression *optimize(int result); }; @@ -1350,7 +1350,7 @@ Expression *checkToBoolean(); int checkSideEffect(int flag); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); - int implicitConvTo(Type *t); + MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); void scanForNestedRef(Scope *sc); diff -uNr dmd-1.018/dmd/src/dmd/func.c dmd-1.019/dmd/src/dmd/func.c --- dmd-1.018/dmd/src/dmd/func.c 2007-06-30 23:30:48.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/func.c 2007-07-11 11:07:12.000000000 +0200 @@ -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 // http://www.digitalmars.com @@ -67,7 +67,7 @@ fes = NULL; introducing = 0; tintro = NULL; - inferRetType = (type && type->next == NULL); + inferRetType = (type && type->nextOf() == NULL); scope = NULL; hasReturnExp = 0; nrvo_can = 1; @@ -109,7 +109,7 @@ printf("type: %s\n", type->toChars()); #endif - if (type->next) + if (type->nextOf()) type = type->semantic(loc, sc); //type->print(); if (type->ty != Tfunction) @@ -144,7 +144,7 @@ #if 0 if (isStaticConstructor() || isStaticDestructor()) { - if (!isStatic() || type->next->ty != Tvoid) + if (!isStatic() || type->nextOf()->ty != Tvoid) error("static constructors / destructors must be static void"); if (f->arguments && f->arguments->dim) error("static constructors / destructors must have empty parameter list"); @@ -316,7 +316,7 @@ * offsets differ */ int offset; - if (fdv->type->next->isBaseOf(type->next, &offset)) + if (fdv->type->nextOf()->isBaseOf(type->nextOf(), &offset)) { tintro = fdv->type; } @@ -397,7 +397,7 @@ * offsets differ */ int offset; - if (fdv->type->next->isBaseOf(type->next, &offset)) + if (fdv->type->nextOf()->isBaseOf(type->nextOf(), &offset)) { ti = fdv->type; #if 0 @@ -489,8 +489,8 @@ goto Lmainerr; } - if (f->next->ty != Tint32 && f->next->ty != Tvoid) - error("must return int or void, not %s", f->next->toChars()); + if (f->nextOf()->ty != Tint32 && f->nextOf()->ty != Tvoid) + error("must return int or void, not %s", f->nextOf()->toChars()); if (f->varargs) { Lmainerr: @@ -512,7 +512,7 @@ Type *t0 = arg0->type->toBasetype(); Type *tb = sd ? sd->type : cd->type; if (arg0->type->implicitConvTo(tb) || - (sd && t0->ty == Tpointer && t0->next->implicitConvTo(tb)) + (sd && t0->ty == Tpointer && t0->nextOf()->implicitConvTo(tb)) ) { if (nparams == 1) @@ -793,8 +793,8 @@ sym->parent = sc2->scopesym; sc2 = sc2->push(sym); - assert(type->next); - if (type->next->ty == Tvoid) + assert(type->nextOf()); + if (type->nextOf()->ty == Tvoid) { if (outId) error("void functions have no result"); @@ -813,7 +813,7 @@ if (fensure) loc = fensure->loc; - v = new VarDeclaration(loc, type->next, outId, NULL); + v = new VarDeclaration(loc, type->nextOf(), outId, NULL); v->noauto = 1; sc2->incontract--; v->semantic(sc2); @@ -909,7 +909,7 @@ if (inferRetType) { // If no return type inferred yet, then infer a void - if (!type->next) + if (!type->nextOf()) { type->next = Type::tvoid; type = type->semantic(loc, sc); @@ -975,11 +975,11 @@ fbody = new CompoundStatement(0, fbody, s); assert(!returnLabel); } - else if (!hasReturnExp && type->next->ty != Tvoid) - error("expected to return a value of type %s", type->next->toChars()); + else if (!hasReturnExp && type->nextOf()->ty != Tvoid) + error("expected to return a value of type %s", type->nextOf()->toChars()); else if (!inlineAsm) { - if (type->next->ty == Tvoid) + if (type->nextOf()->ty == Tvoid) { if (offend && isMain()) { // Add a return 0; statement @@ -1005,12 +1005,12 @@ e = new AssertExp( endloc, new IntegerExp(0), - new StringExp(0, "missing return expression") + new StringExp(loc, "missing return expression") ); } else e = new HaltExp(endloc); - e = new CommaExp(0, e, type->next->defaultInit()); + e = new CommaExp(0, e, type->nextOf()->defaultInit()); e = e->semantic(sc2); Statement *s = new ExpStatement(0, e); fbody = new CompoundStatement(0, fbody, s); @@ -1137,13 +1137,13 @@ { a->push(returnLabel->statement); - if (type->next->ty != Tvoid) + if (type->nextOf()->ty != Tvoid) { // Create: return vresult; assert(vresult); Expression *e = new VarExp(0, vresult); if (tintro) - { e = e->implicitCastTo(sc, tintro->next); + { e = e->implicitCastTo(sc, tintro->nextOf()); e = e->semantic(sc); } ReturnStatement *s = new ReturnStatement(0, e); @@ -1282,6 +1282,108 @@ * Find function in overload list that exactly matches t. */ +/*************************************************** + * Visit each overloaded function in turn, and call + * (*fp)(param, f) on it. + * Exit when no more, or (*fp)(param, f) returns 1. + * Returns: + * 0 continue + * 1 done + */ + +int overloadApply(FuncDeclaration *fstart, + int (*fp)(void *, FuncDeclaration *), + void *param) +{ + FuncDeclaration *f; + Declaration *d; + Declaration *next; + + for (d = fstart; d; d = next) + { FuncAliasDeclaration *fa = d->isFuncAliasDeclaration(); + + if (fa) + { + if (overloadApply(fa->funcalias, fp, param)) + return 1; + next = fa->overnext; + } + else + { + AliasDeclaration *a = d->isAliasDeclaration(); + + if (a) + { + Dsymbol *s = a->toAlias(); + next = s->isDeclaration(); + if (next == a) + break; + if (next == fstart) + break; + } + else + { + f = d->isFuncDeclaration(); + if (!f) + { d->error("is aliased to a function"); + break; // BUG: should print error message? + } + if ((*fp)(param, f)) + return 1; + + next = f->overnext; + } + } + } + return 0; +} + +/******************************************** + * Find function in overload list that exactly matches t. + */ + +struct Param1 +{ + Type *t; // type to match + FuncDeclaration *f; // return value +}; + +int fp1(void *param, FuncDeclaration *f) +{ Param1 *p = (Param1 *)param; + Type *t = p->t; + + if (t->equals(f->type)) + { p->f = f; + return 1; + } + +#if V2 + /* Allow covariant matches, if it's just a const conversion + * of the return type + */ + if (t->ty == Tfunction) + { TypeFunction *tf = (TypeFunction *)f->type; + if (tf->covariant(t) == 1 && + tf->nextOf()->implicitConvTo(t->nextOf()) >= MATCHconst) + { + p->f = f; + return 1; + } + } +#endif + return 0; +} + +FuncDeclaration *FuncDeclaration::overloadExactMatch(Type *t) +{ + Param1 p; + p.t = t; + p.f = NULL; + overloadApply(this, &fp1, &p); + return p.f; +} + +#if 0 FuncDeclaration *FuncDeclaration::overloadExactMatch(Type *t) { FuncDeclaration *f; @@ -1322,11 +1424,75 @@ } return NULL; } +#endif /******************************************** * Decide which function matches the arguments best. */ +struct Param2 +{ + Match *m; + Expressions *arguments; +}; + +int fp2(void *param, FuncDeclaration *f) +{ Param2 *p = (Param2 *)param; + Match *m = p->m; + Expressions *arguments = p->arguments; + MATCH match; + + if (f != m->lastf) // skip duplicates + { + TypeFunction *tf; + + m->anyf = f; + tf = (TypeFunction *)f->type; + match = (MATCH) tf->callMatch(arguments); + //printf("match = %d\n", match); + if (match != MATCHnomatch) + { + if (match > m->last) + goto LfIsBetter; + + if (match < m->last) + goto LlastIsBetter; + + /* See if one of the matches overrides the other. + */ + if (m->lastf->overrides(f)) + goto LlastIsBetter; + else if (f->overrides(m->lastf)) + goto LfIsBetter; + + Lambiguous: + m->nextf = f; + m->count++; + return 0; + + LfIsBetter: + m->last = match; + m->lastf = f; + m->count = 1; + return 0; + + LlastIsBetter: + return 0; + } + } + return 0; +} + + +void overloadResolveX(Match *m, FuncDeclaration *fstart, Expressions *arguments) +{ + Param2 p; + p.m = m; + p.arguments = arguments; + overloadApply(fstart, &fp2, &p); +} + +#if 0 // Recursive helper function void overloadResolveX(Match *m, FuncDeclaration *fstart, Expressions *arguments) @@ -1406,6 +1572,7 @@ } } } +#endif FuncDeclaration *FuncDeclaration::overloadResolve(Loc loc, Expressions *arguments) { @@ -1731,7 +1898,7 @@ { fd = s->isFuncDeclaration(); assert(fd); - assert(fd->type->next->equals(treturn)); + assert(fd->type->nextOf()->equals(treturn)); } else { @@ -2076,7 +2243,9 @@ void StaticCtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { if (hgs->hdrgen) + { buf->writestring("static this(){}\n"); return; + } buf->writestring("static this()"); bodyToCBuffer(buf, hgs); } diff -uNr dmd-1.018/dmd/src/dmd/inline.c dmd-1.019/dmd/src/dmd/inline.c --- dmd-1.018/dmd/src/dmd/inline.c 2007-06-30 18:55:10.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/inline.c 2007-07-12 14:12:54.000000000 +0200 @@ -502,7 +502,10 @@ { //if (!ids->vthis) //error("no 'this' when inlining %s", ids->parent->toChars()); - assert(ids->vthis); + if (!ids->vthis) + { + return this; + } VarExp *ve = new VarExp(loc, ids->vthis); ve->type = type; @@ -856,6 +859,17 @@ } +#if V2 +Statement *ForeachRangeStatement::inlineScan(InlineScanState *iss) +{ + lwr = lwr->inlineScan(iss); + upr = upr->inlineScan(iss); + body = body->inlineScan(iss); + return this; +} +#endif + + Statement *IfStatement::inlineScan(InlineScanState *iss) { condition = condition->inlineScan(iss); diff -uNr dmd-1.018/dmd/src/dmd/interpret.c dmd-1.019/dmd/src/dmd/interpret.c --- dmd-1.018/dmd/src/dmd/interpret.c 2007-06-30 22:32:38.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/interpret.c 2007-07-09 17:00:24.000000000 +0200 @@ -635,6 +635,9 @@ if (dim == EXP_CANT_INTERPRET) return EXP_CANT_INTERPRET; + Expression *keysave = key ? key->value : NULL; + Expression *valuesave = value->value; + uinteger_t d = dim->toUInteger(); uinteger_t index; @@ -645,9 +648,10 @@ Expression *ekey = new IntegerExp(loc, index, Type::tsize_t); if (key) key->value = ekey; - value->value = Index(value->type, eaggr, ekey); - if (value->value == EXP_CANT_INTERPRET) - return EXP_CANT_INTERPRET; + e = Index(value->type, eaggr, ekey); + if (e == EXP_CANT_INTERPRET) + break; + value->value = e; e = body ? body->interpret(istate) : NULL; if (e == EXP_CANT_INTERPRET) @@ -669,9 +673,10 @@ Expression *ekey = new IntegerExp(loc, index, Type::tsize_t); if (key) key->value = ekey; - value->value = Index(value->type, eaggr, ekey); - if (value->value == EXP_CANT_INTERPRET) - return EXP_CANT_INTERPRET; + e = Index(value->type, eaggr, ekey); + if (e == EXP_CANT_INTERPRET) + break; + value->value = e; e = body ? body->interpret(istate) : NULL; if (e == EXP_CANT_INTERPRET) @@ -686,8 +691,93 @@ break; } } + value->value = valuesave; + if (key) + key->value = keysave; + return e; +} + +#if V2 +Expression *ForeachRangeStatement::interpret(InterState *istate) +{ +#if LOG + printf("ForeachRangeStatement::interpret()\n"); +#endif + if (istate->start == this) + istate->start = NULL; + if (istate->start) + return NULL; + + Expression *e = NULL; + Expression *elwr = lwr->interpret(istate); + if (elwr == EXP_CANT_INTERPRET) + return EXP_CANT_INTERPRET; + + Expression *eupr = upr->interpret(istate); + if (eupr == EXP_CANT_INTERPRET) + return EXP_CANT_INTERPRET; + + Expression *keysave = key->value; + + if (op == TOKforeach) + { + key->value = elwr; + + while (1) + { + e = Cmp(TOKlt, key->value->type, key->value, upr); + if (e == EXP_CANT_INTERPRET) + break; + if (e->isBool(TRUE) == FALSE) + { e = NULL; + break; + } + + e = body ? body->interpret(istate) : NULL; + if (e == EXP_CANT_INTERPRET) + break; + if (e == EXP_BREAK_INTERPRET) + { e = NULL; + break; + } + e = Add(key->value->type, key->value, new IntegerExp(loc, 1, key->value->type)); + if (e == EXP_CANT_INTERPRET) + break; + key->value = e; + } + } + else // TOKforeach_reverse + { + key->value = eupr; + + while (1) + { + e = Cmp(TOKgt, key->value->type, key->value, lwr); + if (e == EXP_CANT_INTERPRET) + break; + if (e->isBool(TRUE) == FALSE) + { e = NULL; + break; + } + + e = Min(key->value->type, key->value, new IntegerExp(loc, 1, key->value->type)); + if (e == EXP_CANT_INTERPRET) + break; + key->value = e; + + e = body ? body->interpret(istate) : NULL; + if (e == EXP_CANT_INTERPRET) + break; + if (e == EXP_BREAK_INTERPRET) + { e = NULL; + break; + } + } + } + key->value = keysave; return e; } +#endif Expression *SwitchStatement::interpret(InterState *istate) { @@ -1283,7 +1373,7 @@ BIN_INTERPRET2(Identity) BIN_INTERPRET2(Cmp) -Expression *BinExp::interpretAssignCommon(InterState *istate, fp_t fp) +Expression *BinExp::interpretAssignCommon(InterState *istate, fp_t fp, int post) { #if LOG printf("BinExp::interpretAssignCommon() %s\n", toChars()); @@ -1322,12 +1412,13 @@ assert(v); } - if (fp && !v->value) + Expression *ev = v->value; + if (fp && !ev) { error("variable %s is used before initialization", v->toChars()); return e; } if (fp) - e2 = (*fp)(v->type, v->value, e2); + e2 = (*fp)(v->type, ev, e2); else e2 = Cast(v->type, v->type, e2); if (e2 != EXP_CANT_INTERPRET) @@ -1345,7 +1436,7 @@ } } v->value = e2; - e = Cast(type, type, e2); + e = Cast(type, type, post ? ev : e2); } } } @@ -1401,8 +1492,9 @@ expsx->data[j] = se->elements->data[j]; } v->value = new StructLiteralExp(se->loc, se->sd, expsx); + v->value->type = se->type; - e = Cast(type, type, e2); + e = Cast(type, type, post ? ev : e2); } /* Assignment to array element of the form: * a[i] = e2 @@ -1562,7 +1654,7 @@ else assert(0); - e = Cast(type, type, e2); + e = Cast(type, type, post ? ev : e2); } else { @@ -1602,52 +1694,15 @@ #if LOG printf("PostExp::interpret() %s\n", toChars()); #endif - Expression *e = EXP_CANT_INTERPRET; - - if (e1->op == TOKvar) - { - VarExp *ve = (VarExp *)e1; - VarDeclaration *v = ve->var->isVarDeclaration(); - if (v && !v->isDataseg()) - { - /* Chase down rebinding of out and ref - */ - if (v->value && v->value->op == TOKvar) - { - ve = (VarExp *)v->value; - v = ve->var->isVarDeclaration(); - assert(v); - } - - if (!v->value) - { error("variable %s is used before initialization", v->toChars()); - return e; - } - Expression *e2 = this->e2->interpret(istate); - if (e2 != EXP_CANT_INTERPRET) - { - e = ((op == TOKplusplus) ? &Add : &Min)(v->type, v->value, e2); - if (e != EXP_CANT_INTERPRET) - { - if (v->isAuto()) - { - for (size_t i = 0; 1; i++) - { - if (i == istate->vars.dim) - { istate->vars.push(v); - break; - } - if (v == (VarDeclaration *)istate->vars.data[i]) - break; - } - } - Expression *eold = v->value; - v->value = e; - e = Cast(type, type, eold); - } - } - } - } + Expression *e; + if (op == TOKplusplus) + e = interpretAssignCommon(istate, &Add, 1); + else + e = interpretAssignCommon(istate, &Min, 1); +#if LOG + if (e == EXP_CANT_INTERPRET) + printf("PostExp::interpret() CANT\n"); +#endif return e; } @@ -1960,7 +2015,23 @@ // Constant fold *(&structliteral + offset) if (e1->op == TOKadd) - { + { AddExp *ae = (AddExp *)e1; + if (ae->e1->op == TOKaddress && ae->e2->op == TOKint64) + { AddrExp *ade = (AddrExp *)ae->e1; + Expression *ex = ade->e1; + ex = ex->interpret(istate); + if (ex != EXP_CANT_INTERPRET) + { + if (ex->op == TOKstructliteral) + { StructLiteralExp *se = (StructLiteralExp *)ex; + unsigned offset = ae->e2->toInteger(); + e = se->getField(type, offset); + if (!e) + e = EXP_CANT_INTERPRET; + return e; + } + } + } e = Ptr(type, e1); } else if (e1->op == TOKsymoff) diff -uNr dmd-1.018/dmd/src/dmd/mars.c dmd-1.019/dmd/src/dmd/mars.c --- dmd-1.018/dmd/src/dmd/mars.c 2007-06-26 16:48:26.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/mars.c 2007-07-01 21:52:26.000000000 +0200 @@ -60,7 +60,7 @@ copyright = "Copyright (c) 1999-2007 by Digital Mars"; written = "written by Walter Bright"; - version = "v1.018"; + version = "v1.019"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); diff -uNr dmd-1.018/dmd/src/dmd/mars.h dmd-1.019/dmd/src/dmd/mars.h --- dmd-1.018/dmd/src/dmd/mars.h 2007-06-30 12:28:00.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/mars.h 2007-07-20 13:09:38.000000000 +0200 @@ -251,6 +251,16 @@ DYNCAST_TUPLE, }; +enum MATCH +{ + MATCHnomatch, // no match + MATCHconvert, // match with conversions +#if V2 + MATCHconst, // match with conversion to const +#endif + MATCHexact // exact match +}; + void error(Loc loc, const char *format, ...); void verror(Loc loc, const char *format, va_list); void fatal(); diff -uNr dmd-1.018/dmd/src/dmd/mtype.c dmd-1.019/dmd/src/dmd/mtype.c --- dmd-1.018/dmd/src/dmd/mtype.c 2007-07-01 01:24:40.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/mtype.c 2007-07-21 23:10:02.000000000 +0200 @@ -504,7 +504,7 @@ * 2 this and to are the same type */ -int Type::implicitConvTo(Type *to) +MATCH Type::implicitConvTo(Type *to) { //printf("Type::implicitConvTo(this=%p, to=%p)\n", this, to); //printf("\tthis->next=%p, to->next=%p\n", this->next, to->next); @@ -512,7 +512,7 @@ return MATCHexact; // if (to->ty == Tvoid) // return 1; - return 0; + return MATCHnomatch; } Expression *Type::getProperty(Loc loc, Identifier *ident) @@ -1404,7 +1404,7 @@ return flags & (TFLAGSintegral | TFLAGSfloating); } -int TypeBasic::implicitConvTo(Type *to) +MATCH TypeBasic::implicitConvTo(Type *to) { //printf("TypeBasic::implicitConvTo(%s) from %s\n", to->toChars(), toChars()); if (this == to) @@ -1920,7 +1920,7 @@ return next->memalign(salign); } -int TypeSArray::implicitConvTo(Type *to) +MATCH TypeSArray::implicitConvTo(Type *to) { //printf("TypeSArray::implicitConvTo()\n"); @@ -1929,7 +1929,7 @@ (to->next->ty == Tvoid || next->equals(to->next) /*|| to->next->isBaseOf(next)*/)) { - return 1; + return MATCHconvert; } if (to->ty == Tarray) { int offset = 0; @@ -1946,7 +1946,7 @@ if (next->equals(tsa->next) && dim->equals(tsa->dim)) { - return 1; + return MATCHconvert; } } #endif @@ -2089,7 +2089,7 @@ return nty == Tchar || nty == Twchar || nty == Tdchar; } -int TypeDArray::implicitConvTo(Type *to) +MATCH TypeDArray::implicitConvTo(Type *to) { //printf("TypeDArray::implicitConvTo()\n"); @@ -2398,7 +2398,7 @@ next->toCBuffer2(buf, NULL, hgs); } -int TypePointer::implicitConvTo(Type *to) +MATCH TypePointer::implicitConvTo(Type *to) { //printf("TypePointer::implicitConvTo()\n"); @@ -3810,16 +3810,16 @@ //return sym->memtype->isscalar(); } -int TypeEnum::implicitConvTo(Type *to) -{ int m; +MATCH TypeEnum::implicitConvTo(Type *to) +{ MATCH m; //printf("TypeEnum::implicitConvTo()\n"); if (this->equals(to)) - m = 2; // exact match + m = MATCHexact; // exact match else if (sym->memtype->implicitConvTo(to)) - m = 1; // match with conversions + m = MATCHconvert; // match with conversions else - m = 0; // no match + m = MATCHnomatch; // no match return m; } @@ -3985,16 +3985,16 @@ return t; } -int TypeTypedef::implicitConvTo(Type *to) -{ int m; +MATCH TypeTypedef::implicitConvTo(Type *to) +{ MATCH m; //printf("TypeTypedef::implicitConvTo()\n"); if (this->equals(to)) - m = 2; // exact match + m = MATCHexact; // exact match else if (sym->basetype->implicitConvTo(to)) - m = 1; // match with conversions + m = MATCHconvert; // match with conversions else - m = 0; // no match + m = MATCHnomatch; // no match return m; } @@ -4636,26 +4636,26 @@ return 0; } -int TypeClass::implicitConvTo(Type *to) +MATCH TypeClass::implicitConvTo(Type *to) { //printf("TypeClass::implicitConvTo('%s')\n", to->toChars()); if (this == to) - return 2; + return MATCHexact; ClassDeclaration *cdto = to->isClassHandle(); if (cdto && cdto->isBaseOf(sym, NULL)) { //printf("is base\n"); - return 1; + return MATCHconvert; } if (global.params.Dversion == 1) { // Allow conversion to (void *) if (to->ty == Tpointer && to->next->ty == Tvoid) - return 1; + return MATCHconvert; } - return 0; + return MATCHnomatch; } Expression *TypeClass::defaultInit() diff -uNr dmd-1.018/dmd/src/dmd/mtype.h dmd-1.019/dmd/src/dmd/mtype.h --- dmd-1.018/dmd/src/dmd/mtype.h 2007-06-23 23:27:58.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/mtype.h 2007-07-20 12:43:22.000000000 +0200 @@ -102,14 +102,6 @@ extern int Tsize_t; extern int Tptrdiff_t; -enum MATCH -{ - MATCHnomatch, // no match - MATCHconvert, // match with conversions - MATCHexact // exact match -}; - - struct Type : Object { TY ty; @@ -223,7 +215,7 @@ virtual Dsymbol *toDsymbol(Scope *sc); virtual Type *toBasetype(); virtual int isBaseOf(Type *t, int *poffset); - virtual int implicitConvTo(Type *to); + virtual MATCH implicitConvTo(Type *to); virtual ClassDeclaration *isClassHandle(); virtual Expression *getProperty(Loc loc, Identifier *ident); virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); @@ -277,7 +269,7 @@ int iscomplex(); int isscalar(); int isunsigned(); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Expression *defaultInit(); int isZeroInit(); int builtinTypeInfo(); @@ -312,7 +304,7 @@ int isString(); int isZeroInit(); unsigned memalign(unsigned salign); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Expression *defaultInit(); dt_t **toDt(dt_t **pdt); dt_t **toDtElem(dt_t **pdt, Expression *e); @@ -340,7 +332,7 @@ int isString(); int isZeroInit(); int checkBoolean(); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Expression *defaultInit(); int builtinTypeInfo(); TypeInfoDeclaration *getTypeInfoDeclaration(); @@ -380,7 +372,7 @@ Type *semantic(Loc loc, Scope *sc); d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); int isscalar(); Expression *defaultInit(); int isZeroInit(); @@ -554,7 +546,7 @@ int isfloating(); int isscalar(); int isunsigned(); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Type *toBasetype(); Expression *defaultInit(); int isZeroInit(); @@ -590,7 +582,7 @@ int isunsigned(); int checkBoolean(); Type *toBasetype(); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Expression *defaultInit(); int isZeroInit(); dt_t **toDt(dt_t **pdt); @@ -617,7 +609,7 @@ Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); ClassDeclaration *isClassHandle(); int isBaseOf(Type *t, int *poffset); - int implicitConvTo(Type *to); + MATCH implicitConvTo(Type *to); Expression *defaultInit(); int isZeroInit(); MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); diff -uNr dmd-1.018/dmd/src/dmd/opover.c dmd-1.019/dmd/src/dmd/opover.c --- dmd-1.018/dmd/src/dmd/opover.c 2007-04-19 02:04:50.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/opover.c 2007-07-11 11:29:28.000000000 +0200 @@ -523,7 +523,7 @@ arg = (Argument *)arguments->data[1]; } if (!arg->type && tab->ty != Ttuple) - arg->type = tab->next; // value type + arg->type = tab->nextOf(); // value type break; case Taarray: @@ -593,7 +593,7 @@ } else { - inferApplyArgTypesY((TypeFunction *)tab->next, arguments); + inferApplyArgTypesY((TypeFunction *)tab->nextOf(), arguments); } break; } @@ -608,6 +608,23 @@ * analogous to func.overloadResolveX(). */ +int fp3(void *param, FuncDeclaration *f) +{ + Arguments *arguments = (Arguments *)param; + TypeFunction *tf = (TypeFunction *)f->type; + if (inferApplyArgTypesY(tf, arguments) == 1) + return 0; + if (arguments->dim == 0) + return 1; + return 0; +} + +static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) +{ + overloadApply(fstart, &fp3, arguments); +} + +#if 0 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) { Declaration *d; @@ -650,6 +667,7 @@ } } } +#endif /****************************** * Infer arguments from type of function. @@ -667,7 +685,7 @@ p = Argument::getNth(tf->parameters, 0); if (p->type->ty != Tdelegate) goto Lnomatch; - tf = (TypeFunction *)p->type->next; + tf = (TypeFunction *)p->type->nextOf(); assert(tf->ty == Tfunction); /* We now have tf, the type of the delegate. Match it against diff -uNr dmd-1.018/dmd/src/dmd/template.c dmd-1.019/dmd/src/dmd/template.c --- dmd-1.018/dmd/src/dmd/template.c 2007-06-29 15:35:40.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/template.c 2007-07-11 00:58:32.000000000 +0200 @@ -75,6 +75,45 @@ return (Tuple *)o; } +/*********************** + * Try to get arg as a type. + */ + +Type *getType(Object *o) +{ + Type *t = isType(o); + if (!t) + { Expression *e = isExpression(o); + if (e) + t = e->type; + } + return t; +} + +Dsymbol *getDsymbol(Object *oarg) +{ + Dsymbol *sa; + Expression *ea = isExpression(oarg); + if (ea) + { // Try to convert Expression to symbol + if (ea->op == TOKvar) + sa = ((VarExp *)ea)->var; + else if (ea->op == TOKfunction) + sa = ((FuncExp *)ea)->fd; + else + sa = NULL; + } + else + { // Try to convert Type to symbol + Type *ta = isType(oarg); + if (ta) + sa = ta->toDsymbol(NULL); + else + sa = isDsymbol(oarg); // if already a symbol + } + return sa; +} + /****************************** * If o1 matches o2, return 1. * Else, return 0. @@ -158,6 +197,50 @@ return 0; // nomatch; } +/**************************************** + */ + +void ObjectToCBuffer(OutBuffer *buf, HdrGenState *hgs, Object *oarg) +{ + Type *t = isType(oarg); + Expression *e = isExpression(oarg); + Dsymbol *s = isDsymbol(oarg); + Tuple *v = isTuple(oarg); + if (t) + t->toCBuffer(buf, NULL, hgs); + else if (e) + e->toCBuffer(buf, hgs); + else if (s) + { + char *p = s->ident ? s->ident->toChars() : s->toChars(); + buf->writestring(p); + } + else if (v) + { + Objects *args = &v->objects; + for (size_t i = 0; i < args->dim; i++) + { + if (i) + buf->writeByte(','); + Object *o = (Object *)args->data[i]; + ObjectToCBuffer(buf, hgs, o); + } + } + else if (!oarg) + { + buf->writestring("NULL"); + } + else + { +#ifdef DEBUG + printf("bad Object = %p\n", oarg); +#endif + assert(0); + } +} + + + /* ======================== TemplateDeclaration ============================= */ TemplateDeclaration::TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters, Array *decldefs) @@ -720,12 +803,12 @@ if (!m && fparam->type->toBasetype()->ty == Tdelegate) { TypeDelegate *td = (TypeDelegate *)fparam->type->toBasetype(); - TypeFunction *tf = (TypeFunction *)td->next; + TypeFunction *tf = (TypeFunction *)td->nextOf(); if (!tf->varargs && Argument::dim(tf->parameters) == 0) { - m = farg->type->deduceType(scope, tf->next, parameters, &dedtypes); - if (!m && tf->next->toBasetype()->ty == Tvoid) + m = farg->type->deduceType(scope, tf->nextOf(), parameters, &dedtypes); + if (!m && tf->nextOf()->toBasetype()->ty == Tvoid) m = MATCHconvert; } //printf("\tm2 = %d\n", m); @@ -1149,7 +1232,7 @@ return (MATCH) implicitConvTo(at); } else if (ty == Tsarray && at->ty == Tarray && - next->equals(at->next)) + next->equals(at->nextOf())) { goto Lexact; } @@ -1160,8 +1243,8 @@ if (ty != tparam->ty) goto Lnomatch; - if (next) - return next->deduceType(sc, tparam->next, parameters, dedtypes); + if (nextOf()) + return nextOf()->deduceType(sc, tparam->nextOf(), parameters, dedtypes); Lexact: return MATCHexact; @@ -1215,7 +1298,7 @@ else { dedtypes->data[i] = (void *)dim; } - return next->deduceType(sc, tparam->next, parameters, dedtypes); + return next->deduceType(sc, tparam->nextOf(), parameters, dedtypes); } } } @@ -1224,7 +1307,7 @@ else if (tparam->ty == Tarray) { MATCH m; - m = next->deduceType(sc, tparam->next, parameters, dedtypes); + m = next->deduceType(sc, tparam->nextOf(), parameters, dedtypes); if (m == MATCHexact) m = MATCHconvert; return m; @@ -1530,7 +1613,7 @@ MATCH TypeClass::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes) { - //printf("TypeClass::deduceType()\n"); + //printf("TypeClass::deduceType(this = %s)\n", toChars()); /* If this class is a template class, and we're matching * it against a template instance, convert the class type @@ -1724,6 +1807,7 @@ ta = isType(oarg); if (!ta) goto Lnomatch; + //printf("ta is %s\n", ta->toChars()); t = (Type *)dedtypes->data[i]; @@ -1926,25 +2010,7 @@ } } - ea = isExpression(oarg); - if (ea) - { // Try to convert Expression to symbol - if (ea->op == TOKvar) - sa = ((VarExp *)ea)->var; - else if (ea->op == TOKfunction) - sa = ((FuncExp *)ea)->fd; - else - goto Lnomatch; - } - else - { // Try to convert Type to symbol - Type *ta = isType(oarg); - if (ta) - sa = ta->toDsymbol(NULL); - else - sa = isDsymbol(oarg); // if already a symbol - } - + sa = getDsymbol(oarg); if (!sa) goto Lnomatch; @@ -2459,6 +2525,28 @@ } +Objects *TemplateInstance::arraySyntaxCopy(Objects *objs) +{ + Objects *a = NULL; + if (objs) + { a = new Objects(); + a->setDim(objs->dim); + for (size_t i = 0; i < objs->dim; i++) + { + Type *ta = isType((Object *)objs->data[i]); + if (ta) + a->data[i] = ta->syntaxCopy(); + else + { + Expression *ea = isExpression((Object *)objs->data[i]); + assert(ea); + a->data[i] = ea->syntaxCopy(); + } + } + } + return a; +} + Dsymbol *TemplateInstance::syntaxCopy(Dsymbol *s) { TemplateInstance *ti; @@ -2469,20 +2557,7 @@ else ti = new TemplateInstance(loc, name); - ti->tiargs = new Objects(); - ti->tiargs->setDim(tiargs->dim); - for (i = 0; i < tiargs->dim; i++) - { - Type *ta = isType((Object *)tiargs->data[i]); - if (ta) - ti->tiargs->data[i] = ta->syntaxCopy(); - else - { - Expression *ea = isExpression((Object *)tiargs->data[i]); - assert(ea); - ti->tiargs->data[i] = ea->syntaxCopy(); - } - } + ti->tiargs = arraySyntaxCopy(tiargs); ScopeDsymbol::syntaxCopy(ti); return ti; @@ -2786,8 +2861,16 @@ void TemplateInstance::semanticTiargs(Scope *sc) { + //printf("+TemplateInstance::semanticTiargs() %s\n", toChars()); + semanticTiargs(loc, sc, tiargs); +} + +void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs) +{ // Run semantic on each argument, place results in tiargs[] //printf("+TemplateInstance::semanticTiargs() %s\n", toChars()); + if (!tiargs) + return; for (size_t j = 0; j < tiargs->dim; j++) { Object *o = (Object *)tiargs->data[j]; @@ -3381,35 +3464,7 @@ if (i) buf->writeByte(','); Object *oarg = (Object *)args->data[i]; - Type *t = isType(oarg); - Expression *e = isExpression(oarg); - Dsymbol *s = isDsymbol(oarg); - Tuple *v = isTuple(oarg); - if (t) - t->toCBuffer(buf, NULL, hgs); - else if (e) - e->toCBuffer(buf, hgs); - else if (s) - { - char *p = s->ident ? s->ident->toChars() : s->toChars(); - buf->writestring(p); - } - else if (v) - { assert(i + 1 == args->dim); - args = &v->objects; - i = -1; - } - else if (!oarg) - { - buf->writestring("NULL"); - } - else - { -#ifdef DEBUG - printf("tiargs[%d] = %p\n", i, oarg); -#endif - assert(0); - } + ObjectToCBuffer(buf, hgs, oarg); } nest--; } diff -uNr dmd-1.018/dmd/src/dmd/template.h dmd-1.019/dmd/src/dmd/template.h --- dmd-1.018/dmd/src/dmd/template.h 2007-04-12 02:36:34.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/template.h 2007-07-10 15:36:18.000000000 +0200 @@ -259,6 +259,7 @@ TemplateInstance(Loc loc, Identifier *temp_id); TemplateInstance(Loc loc, TemplateDeclaration *tempdecl, Objects *tiargs); + static Objects *arraySyntaxCopy(Objects *objs); Dsymbol *syntaxCopy(Dsymbol *); void semantic(Scope *sc); void semantic2(Scope *sc); @@ -274,6 +275,7 @@ void toObjFile(); // compile to .obj file // Internal + static void semanticTiargs(Loc loc, Scope *sc, Objects *tiargs); void semanticTiargs(Scope *sc); TemplateDeclaration *findTemplateDeclaration(Scope *sc); TemplateDeclaration *findBestMatch(Scope *sc); @@ -313,5 +315,9 @@ Dsymbol *isDsymbol(Object *o); Type *isType(Object *o); Tuple *isTuple(Object *o); +Type *getType(Object *o); +Dsymbol *getDsymbol(Object *o); + +void ObjectToCBuffer(OutBuffer *buf, HdrGenState *hgs, Object *oarg); #endif /* DMD_TEMPLATE_H */ diff -uNr dmd-1.018/dmd/src/dmd/tocsym.c dmd-1.019/dmd/src/dmd/tocsym.c --- dmd-1.018/dmd/src/dmd/tocsym.c 2007-04-26 21:01:52.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/tocsym.c 2007-07-14 12:55:38.000000000 +0200 @@ -133,7 +133,7 @@ //printf("Dsymbol::toImport('%s')\n", sym->Sident); n = sym->Sident; id = (char *) alloca(6 + strlen(n) + 1 + sizeof(type_paramsize(sym->Stype))*3 + 1); - if (sym->Stype->Tmangle == mTYman_std) + if (sym->Stype->Tmangle == mTYman_std && tyfunc(sym->Stype->Tty)) { sprintf(id,"_imp__%s@%d",n,type_paramsize(sym->Stype)); } @@ -178,7 +178,7 @@ { if (global.params.symdebug && storage_class & STCparameter) { - t = type_alloc(TYref); + t = type_alloc(TYnptr); // should be TYref, but problems in back end t->Tnext = type->toCtype(); t->Tnext->Tcount++; } diff -uNr dmd-1.018/dmd/src/dmd/toir.c dmd-1.019/dmd/src/dmd/toir.c --- dmd-1.018/dmd/src/dmd/toir.c 2007-04-10 14:39:00.000000000 +0200 +++ dmd-1.019/dmd/src/dmd/toir.c 2007-07-12 11:02:08.000000000 +0200 @@ -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 // http://www.digitalmars.com @@ -179,7 +179,11 @@ fd->isClassDeclaration() && fd->isClassDeclaration()->isBaseOf(cd, NULL)) break; - assert(cd->isNested() && cd->vthis); + if (!cd->isNested() || !cd->vthis) + { + irs->getFunc()->error(loc, "cannot get frame pointer to %s", fd->toChars()); + return el_long(TYnptr, 0); // error recovery + } ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYint, cd->vthis->offset)); ethis = el_una(OPind, TYnptr, ethis); if (fdparent == s->toParent2()) diff -uNr dmd-1.018/dmd/src/phobos/internal/gc/gc.d dmd-1.019/dmd/src/phobos/internal/gc/gc.d --- dmd-1.018/dmd/src/phobos/internal/gc/gc.d 2007-07-01 11:10:42.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/internal/gc/gc.d 2007-07-22 09:44:16.000000000 +0200 @@ -145,6 +145,7 @@ void gc_term() { _gc.fullCollectNoStack(); + _gc.Dtor(); } Object _d_newclass(ClassInfo ci) @@ -157,6 +158,7 @@ p = std.c.stdlib.malloc(ci.init.length); if (!p) _d_OutOfMemory(); + debug(PRINTF) printf(" COM object p = %p\n", p); } else { diff -uNr dmd-1.018/dmd/src/phobos/linux.mak dmd-1.019/dmd/src/phobos/linux.mak --- dmd-1.018/dmd/src/phobos/linux.mak 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/linux.mak 2007-07-22 09:44:12.000000000 +0200 @@ -9,6 +9,8 @@ # make unittest # Build libphobos.a, build and run unit tests +LIB=libphobos.a + CFLAGS=-O -m32 #CFLAGS=-g -m32 @@ -36,11 +38,11 @@ test.o : test.d $(DMD) -c test -g -test : test.o libphobos.a - $(CC) -o $@ test.o libphobos.a -lpthread -lm -g +test : test.o $(LIB) + $(CC) -o $@ test.o $(LIB) -lpthread -lm -g -unittest : unittest.o libphobos.a - $(CC) -o $@ unittest.o libphobos.a -lpthread -lm -g +unittest : unittest.o $(LIB) + $(CC) -o $@ unittest.o $(LIB) -lpthread -lm -g unittest.o : unittest.d $(DMD) -c unittest @@ -58,7 +60,7 @@ socket.o socketstream.o stdarg.o stdio.o format.o \ perf.o openrj.o uni.o trace.o boxer.o \ demangle.o cover.o bitarray.o bind.o aApplyR.o \ - signals.o cpuid.o traits.o typetuple.o \ + signals.o cpuid.o traits.o typetuple.o loader.o \ ti_wchar.o ti_uint.o ti_short.o ti_ushort.o \ ti_byte.o ti_ubyte.o ti_long.o ti_ulong.o ti_ptr.o \ ti_float.o ti_double.o ti_real.o ti_delegate.o \ @@ -195,9 +197,9 @@ $(SRC_ZLIB) $(SRC_GC) -#libphobos.a : $(OBJS) internal/gc/dmgc.a linux.mak -libphobos.a : $(OBJS) internal/gc/dmgc.a $(ZLIB_OBJS) linux.mak - rm -f libphobos.a +#$(LIB) : $(OBJS) internal/gc/dmgc.a linux.mak +$(LIB) : $(OBJS) internal/gc/dmgc.a $(ZLIB_OBJS) linux.mak + rm -f $(LIB) ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS) ########################################################### @@ -354,6 +356,9 @@ gc.o : std/gc.d $(DMD) -c $(DFLAGS) std/gc.d +loader.o : std/loader.d + $(DMD) -c $(DFLAGS) std/loader.d + math.o : std/math.d $(DMD) -c $(DFLAGS) std/math.d @@ -588,4 +593,4 @@ zip phobos $(ALLSRCS) linux.mak win32.mak phoboslicense.txt clean: - $(RM) libphobos.a $(OBJS) unittest unittest.o + $(RM) $(LIB) $(OBJS) unittest unittest.o diff -uNr dmd-1.018/dmd/src/phobos/std/demangle.d dmd-1.019/dmd/src/phobos/std/demangle.d --- dmd-1.018/dmd/src/phobos/std/demangle.d 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/std/demangle.d 2007-07-22 09:44:14.000000000 +0200 @@ -1,4 +1,3 @@ - // Written in the D programming language. /* @@ -14,6 +13,7 @@ /* Authors: * Walter Bright, Digital Mars, www.digitalmars.com * Thomas Kuehne + * Frits van Bommel */ module std.demangle; @@ -80,10 +80,10 @@ ------------------- */ -char[] demangle(char[] name) +string demangle(string name) { size_t ni = 2; - char[] delegate() fparseTemplateInstanceName; + string delegate() fparseTemplateInstanceName; static void error() { @@ -97,7 +97,7 @@ error(); return cast(ubyte) ( (c >= 'a') ? c - 'a' + 10 : - (c >= 'A') ? c - 'A' + 10 : + (c >= 'A') ? c - 'A' + 10 : c - '0' ); } @@ -117,13 +117,13 @@ return result; } - char[] parseSymbolName() + string parseSymbolName() { //writefln("parseSymbolName() %d", ni); size_t i = parseNumber(); if (ni + i > name.length) error(); - char[] result; + string result; if (i >= 5 && name[ni] == '_' && name[ni + 1] == '_' && @@ -154,10 +154,10 @@ return result; } - char[] parseQualifiedName() + string parseQualifiedName() { //writefln("parseQualifiedName() %d", ni); - char[] result; + string result; while (ni < name.length && isdigit(name[ni])) { @@ -168,19 +168,19 @@ return result; } - char[] parseType(char[] identifier = null) + string parseType(string identifier = null) { //writefln("parseType() %d", ni); int isdelegate = 0; + bool hasthisptr = false; /// For function/delegate types: expects a 'this' pointer as last argument Lagain: if (ni >= name.length) error(); - char[] p; + string p; switch (name[ni++]) { case 'v': p = "void"; goto L1; - case 'b': p = "bit"; goto L1; - case 'x': p = "bool"; goto L1; + case 'b': p = "bool"; goto L1; case 'g': p = "byte"; goto L1; case 'h': p = "ubyte"; goto L1; case 's': p = "short"; goto L1; @@ -227,13 +227,17 @@ isdelegate = 1; goto Lagain; + case 'M': + hasthisptr = true; + goto Lagain; + case 'F': // D function case 'U': // C function case 'W': // Windows function case 'V': // Pascal function case 'R': // C++ function { char mc = name[ni - 1]; - char[] args; + string args; while (1) { @@ -244,7 +248,8 @@ break; if (c == 'X') { - args ~= " ..."; + if (!args.length) error(); + args ~= " ..."; break; } if (args.length) @@ -276,6 +281,12 @@ } break; } + if (hasthisptr || isdelegate) { + // add implicit 'this'/context pointer + if (args.length) + args ~= ", "; + args ~= "void*"; + } ni++; if (!isdelegate && identifier.length) { @@ -322,9 +333,9 @@ assert(0); } - char[] parseTemplateInstanceName() + string parseTemplateInstanceName() { - char[] result = parseSymbolName() ~ "!("; + auto result = parseSymbolName() ~ "!("; int nargs; while (1) @@ -414,9 +425,8 @@ for (i = 0; i < n; i++) { char c; - c = cast(char) - ((ascii2hex(name[ni + i * 2]) << 4) + - ascii2hex(name[ni + i * 2 + 1])); + c = (ascii2hex(name[ni + i * 2]) << 4) + + ascii2hex(name[ni + i * 2 + 1]); result ~= c; } ni += n * 2; @@ -459,8 +469,12 @@ try { - char[] result = parseQualifiedName(); + auto result = parseQualifiedName(); result = parseType(result); + while(ni < name.length){ + result ~= " . " ~ parseType(parseQualifiedName()); + } + if (ni != name.length) goto Lnot; return result; @@ -479,7 +493,7 @@ { debug(demangle) printf("demangle.demangle.unittest\n"); - static char[][2][] table = + static string[2][] table = [ [ "printf", "printf" ], [ "_foo", "_foo" ], @@ -496,12 +510,14 @@ [ "_D8demangle4testFLAiXi", "int demangle.test(lazy int[] ...)"] ]; - foreach (char[][2] name; table) + foreach (string[2] name; table) { - char[] r = demangle(name[0]); + string r = demangle(name[0]); //writefln("[ \"%s\", \"%s\" ],", name[0], r); assert(r == name[1]); } } + + diff -uNr dmd-1.018/dmd/src/phobos/std/format.d dmd-1.019/dmd/src/phobos/std/format.d --- dmd-1.018/dmd/src/phobos/std/format.d 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/std/format.d 2007-07-22 09:44:12.000000000 +0200 @@ -1,3 +1,6 @@ + +// Written in the D programming language. + /** * This module implements the workhorse functionality for string and I/O formatting. * It's comparable to C99's vsprintf(). @@ -120,6 +123,9 @@ Tenum = 'E', Ttypedef = 'T', Tdelegate = 'D', + + Tconst = 'x', + Tinvariant = 'y', } // return the TypeInfo for a primitive type and null otherwise. @@ -874,6 +880,8 @@ case Mangle.Tstruct: { TypeInfo_Struct tis = cast(TypeInfo_Struct)ti; + if (tis.xtoString is null) + throw new FormatError("Can't convert " ~ tis.toString() ~ " to string: \"string toString()\" not defined"); s = tis.xtoString(argptr); argptr += (tis.tsize() + 3) & ~3; goto Lputstr; @@ -1026,9 +1034,9 @@ if (m == Mangle.Tarray) { Mangle m2 = cast(Mangle)ti.classinfo.name[10]; - char[] fmt; // format string - wchar[] wfmt; - dchar[] dfmt; + string fmt; // format string + wstring wfmt; + dstring dfmt; /* For performance reasons, this code takes advantage of the * fact that most format strings will be ASCII, and that the @@ -1194,7 +1202,7 @@ unittest { int i; - char[] s; + string s; debug(format) printf("std.format.format.unittest\n"); @@ -1280,7 +1288,7 @@ assert(s == "0.00001000"); s = "helloworld"; - char[] r; + string r; r = std.string.format("%.2s", s[0..5]); assert(r == "he"); r = std.string.format("%.20s", s[0..5]); @@ -1343,7 +1351,7 @@ r = std.string.format(arrulong); assert(r == "[100,999,0,0]"); - char[][] arr2 = new char[][4]; + string[] arr2 = new char[][4]; arr2[0] = "hello"; arr2[1] = "world"; arr2[3] = "foo"; diff -uNr dmd-1.018/dmd/src/phobos/std/loader.d dmd-1.019/dmd/src/phobos/std/loader.d --- dmd-1.018/dmd/src/phobos/std/loader.d 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/std/loader.d 2007-07-22 09:44:12.000000000 +0200 @@ -1,3 +1,6 @@ + +// Written in the D programming language. + /* ///////////////////////////////////////////////////////////////////////////// * File: loader.d (originally from synsoft.win32.loader) * @@ -71,18 +74,11 @@ } else version(linux) { + private import std.c.linux.linux; + extern(C) { - const int RTLD_NOW = 0x00002; /* Correct for Red Hat 8 */ - - typedef void *HModule_; - - HModule_ dlopen(char *path, int mode); - int dlclose(HModule_ handle); - void *dlsym(HModule_ handle, char *symbolName); - char *dlerror(); - - char* strerror(int); + alias void* HModule_; } } else @@ -132,12 +128,12 @@ * system, and you must not attempt to use it with any other operating system * or other APIs. It is only valid for use with the ExeModule library. */ -public HXModule ExeModule_Load(in char[] moduleName) +public HXModule ExeModule_Load(in string moduleName) { return ExeModule_Load_(moduleName); } -public HXModule ExeModule_AddRef(in HXModule hModule) +public HXModule ExeModule_AddRef(HXModule hModule) { return ExeModule_AddRef_(hModule); } @@ -151,12 +147,12 @@ ExeModule_Release_(hModule); } -public void *ExeModule_GetSymbol(inout HXModule hModule, in char[] symbolName) +public void *ExeModule_GetSymbol(inout HXModule hModule, in string symbolName) { return ExeModule_GetSymbol_(hModule, symbolName); } -public char[] ExeModule_Error() +public string ExeModule_Error() { return ExeModule_Error_(); } @@ -183,7 +179,7 @@ --s_init; } - private HXModule ExeModule_Load_(in char[] moduleName) + private HXModule ExeModule_Load_(in string moduleName) in { assert(null !is moduleName); @@ -200,7 +196,7 @@ return hmod; } - private HXModule ExeModule_AddRef_(in HXModule hModule) + private HXModule ExeModule_AddRef_(HXModule hModule) in { assert(null !is hModule); @@ -224,7 +220,7 @@ hModule = null; } - private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName) + private void *ExeModule_GetSymbol_(inout HXModule hModule, in string symbolName) in { assert(null !is hModule); @@ -241,12 +237,12 @@ return symbol; } - private char[] ExeModule_Error_() + private string ExeModule_Error_() { return sysErrorString(s_lastError); } - private char[] ExeModule_GetPath_(HXModule hModule) + private string ExeModule_GetPath_(HXModule hModule) { char szFileName[260]; // Need to use a constant here @@ -267,9 +263,9 @@ public: int m_cRefs; HModule_ m_hmod; - char[] m_name; + string m_name; - this(HModule_ hmod, char[] name) + this(HModule_ hmod, string name) { m_cRefs = 1; m_hmod = hmod; @@ -278,8 +274,8 @@ }; private int s_init; - private ExeModuleInfo [char[]] s_modules; - private char[] s_lastError; // This is NOT thread-specific + private ExeModuleInfo [string] s_modules; + private string s_lastError; // This is NOT thread-specific private void record_error_() { @@ -305,14 +301,15 @@ } } - private HXModule ExeModule_Load_(in char[] moduleName) + private HXModule ExeModule_Load_(in string moduleName) in { assert(null !is moduleName); } body { - ExeModuleInfo mi = s_modules[moduleName]; + ExeModuleInfo* mi_p = moduleName in s_modules; + ExeModuleInfo mi = mi_p is null ? null : *mi_p; if(null !is mi) { @@ -330,16 +327,16 @@ } else { - ExeModuleInfo mi = new ExeModuleInfo(hmod, moduleName); + ExeModuleInfo mi2 = new ExeModuleInfo(hmod, moduleName); - s_modules[moduleName] = mi; + s_modules[moduleName] = mi2; - return cast(HXModule)mi; + return cast(HXModule)mi2; } } } - private HXModule ExeModule_AddRef_(in HXModule hModule) + private HXModule ExeModule_AddRef_(HXModule hModule) in { assert(null !is hModule); @@ -385,20 +382,20 @@ if(0 == --mi.m_cRefs) { - char[] name = mi.m_name; + string name = mi.m_name; if (dlclose(mi.m_hmod)) { record_error_(); } - delete s_modules[name]; + s_modules.remove(name); delete mi; } hModule = null; } - private void *ExeModule_GetSymbol_(inout HXModule hModule, in char[] symbolName) + private void *ExeModule_GetSymbol_(inout HXModule hModule, in string symbolName) in { assert(null !is hModule); @@ -424,12 +421,12 @@ return symbol; } - private char[] ExeModule_Error_() + private string ExeModule_Error_() { return s_lastError; } - private char[] ExeModule_GetPath_(HXModule hModule) + private string ExeModule_GetPath_(HXModule hModule) in { assert(null !is hModule); @@ -464,7 +461,7 @@ : Exception { public: - this(char[] message) + this(string message) { super(message); } @@ -482,7 +479,7 @@ /// @{ public: /// Constructs from an existing image handle - this(in HXModule hModule, boolean bTakeOwnership) + this(HXModule hModule, boolean bTakeOwnership) in { assert(null !is hModule); @@ -497,7 +494,7 @@ { version (Windows) { - char[] path = Path(); + string path = Path(); m_hModule = cast(HXModule)LoadLibraryA(toStringz(path)); if (m_hModule == null) throw new ExeModuleException(GetLastError()); @@ -511,7 +508,7 @@ } } - this(char[] moduleName) + this(string moduleName) in { assert(null !is moduleName); @@ -575,7 +572,7 @@ * \return A pointer to the symbol. There is no null return - failure to retrieve the symbol * results in an ExeModuleException exception being thrown. */ - void *getSymbol(in char[] symbolName) + void *getSymbol(in string symbolName) { version (Windows) { @@ -606,7 +603,7 @@ * * \return A pointer to the symbol, or null if it does not exist */ - void *findSymbol(in char[] symbolName) + void *findSymbol(in string symbolName) { return ExeModule_GetSymbol(m_hModule, symbolName); } @@ -626,7 +623,7 @@ /// The handle of the module /// /// \note Will be \c null if the module load in the constructor failed - char[] Path() + string Path() { assert(null != m_hModule); @@ -658,7 +655,7 @@ version(TestMain) { - int main(char[][] args) + int main(string[] args) { if(args.length < 3) { @@ -666,8 +663,8 @@ } else { - char[] moduleName = args[1]; - char[] symbolName = args[2]; + string moduleName = args[1]; + string symbolName = args[2]; try { diff -uNr dmd-1.018/dmd/src/phobos/std/socket.d dmd-1.019/dmd/src/phobos/std/socket.d --- dmd-1.018/dmd/src/phobos/std/socket.d 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/std/socket.d 2007-07-22 09:44:12.000000000 +0200 @@ -1,3 +1,5 @@ +// Written in the D programming language + /* Copyright (C) 2004-2005 Christopher E. Miller @@ -84,7 +86,7 @@ { int errorCode; /// Platform-specific error code. - this(char[] msg, int err = 0) + this(string msg, int err = 0) { errorCode = err; @@ -185,8 +187,8 @@ class Protocol { ProtocolType type; /// These members are populated when one of the following functions are called without failure: - char[] name; /// ditto - char[][] aliases; /// ditto + string name; /// ditto + string[] aliases; /// ditto void populate(protoent* proto) @@ -203,7 +205,7 @@ if(i) { - aliases = new char[][i]; + aliases = new string[i]; for(i = 0; i != aliases.length; i++) { aliases[i] = std.string.toString(proto.p_aliases[i]).dup; @@ -216,7 +218,7 @@ } /** Returns false on failure */ - bool getProtocolByName(char[] name) + bool getProtocolByName(string name) { protoent* proto; proto = getprotobyname(toStringz(name)); @@ -246,7 +248,7 @@ Protocol proto = new Protocol; assert(proto.getProtocolByType(ProtocolType.TCP)); printf("About protocol TCP:\n\tName: %.*s\n", proto.name); - foreach(char[] s; proto.aliases) + foreach(string s; proto.aliases) { printf("\tAlias: %.*s\n", s); } @@ -259,10 +261,10 @@ class Service { /** These members are populated when one of the following functions are called without failure: */ - char[] name; - char[][] aliases; /// ditto + string name; + string[] aliases; /// ditto ushort port; /// ditto - char[] protocolName; /// ditto + string protocolName; /// ditto void populate(servent* serv) @@ -280,7 +282,7 @@ if(i) { - aliases = new char[][i]; + aliases = new string[i]; for(i = 0; i != aliases.length; i++) { aliases[i] = std.string.toString(serv.s_aliases[i]).dup; @@ -296,7 +298,7 @@ * If a protocol name is omitted, any protocol will be matched. * Returns: false on failure. */ - bool getServiceByName(char[] name, char[] protocolName) + bool getServiceByName(string name, string protocolName) { servent* serv; serv = getservbyname(toStringz(name), toStringz(protocolName)); @@ -309,7 +311,7 @@ // Any protocol name will be matched. /// ditto - bool getServiceByName(char[] name) + bool getServiceByName(string name) { servent* serv; serv = getservbyname(toStringz(name), null); @@ -321,7 +323,7 @@ /// ditto - bool getServiceByPort(ushort port, char[] protocolName) + bool getServiceByPort(ushort port, string protocolName) { servent* serv; serv = getservbyport(port, toStringz(protocolName)); @@ -353,7 +355,7 @@ { printf("About service epmap:\n\tService: %.*s\n\tPort: %d\n\tProtocol: %.*s\n", serv.name, serv.port, serv.protocolName); - foreach(char[] s; serv.aliases) + foreach(string s; serv.aliases) { printf("\tAlias: %.*s\n", s); } @@ -373,7 +375,7 @@ int errorCode; /// Platform-specific error code. - this(char[] msg, int err = 0) + this(string msg, int err = 0) { errorCode = err; super(msg); @@ -386,8 +388,8 @@ class InternetHost { /** These members are populated when one of the following functions are called without failure: */ - char[] name; - char[][] aliases; /// ditto + string name; + string[] aliases; /// ditto uint32_t[] addrList; /// ditto @@ -414,7 +416,7 @@ if(i) { - aliases = new char[][i]; + aliases = new string[i]; for(i = 0; i != aliases.length; i++) { aliases[i] = std.string.toString(he.h_aliases[i]).dup; @@ -449,7 +451,7 @@ /** * Resolve host name. Returns false if unable to resolve. */ - bool getHostByName(char[] name) + bool getHostByName(string name) { hostent* he = gethostbyname(toStringz(name)); if(!he) @@ -480,7 +482,7 @@ * dotted-decimal form $(I a.b.c.d). * Returns false if unable to resolve. */ - bool getHostByAddr(char[] addr) + bool getHostByAddr(string addr) { uint x = inet_addr(std.string.toStringz(addr)); hostent* he = gethostbyaddr(&x, 4, cast(int)AddressFamily.INET); @@ -501,7 +503,7 @@ assert(ih.addrList.length); InternetAddress ia = new InternetAddress(ih.addrList[0], InternetAddress.PORT_ANY); printf("IP address = %.*s\nname = %.*s\n", ia.toAddrString(), ih.name); - foreach(int i, char[] s; ih.aliases) + foreach(int i, string s; ih.aliases) { printf("aliases[%d] = %.*s\n", i, s); } @@ -510,7 +512,7 @@ assert(ih.getHostByAddr(ih.addrList[0])); printf("name = %.*s\n", ih.name); - foreach(int i, char[] s; ih.aliases) + foreach(int i, string s; ih.aliases) { printf("aliases[%d] = %.*s\n", i, s); } @@ -522,7 +524,7 @@ */ class AddressException: Exception { - this(char[] msg) + this(string msg) { super(msg); } @@ -537,7 +539,7 @@ protected sockaddr* name(); protected int nameLen(); AddressFamily addressFamily(); /// Family of this address. - char[] toString(); /// Human readable string representing this address. + string toString(); /// Human readable string representing this address. } /** @@ -568,7 +570,7 @@ } - char[] toString() + string toString() { return "Unknown"; } @@ -632,7 +634,7 @@ * object. * port = may be PORT_ANY as stated below. */ - this(char[] addr, ushort port) + this(string addr, ushort port) { uint uiaddr = parse(addr); if(ADDR_NONE == uiaddr) @@ -666,19 +668,19 @@ } /// Human readable string representing the IPv4 address in dotted-decimal form. - char[] toAddrString() + string toAddrString() { return std.string.toString(inet_ntoa(sin.sin_addr)).dup; } /// Human readable string representing the IPv4 port. - char[] toPortString() + string toPortString() { return std.string.toString(port()); } /// Human readable string representing the IPv4 address and port in the form $(I a.b.c.d:e). - char[] toString() + string toString() { return toAddrString() ~ ":" ~ toPortString(); } @@ -689,7 +691,7 @@ * If the string is not a legitimate IPv4 address, * ADDR_NONE is returned. */ - static uint parse(char[] addr) + static uint parse(string addr) { return ntohl(inet_addr(std.string.toStringz(addr))); } @@ -706,7 +708,7 @@ /** */ class SocketAcceptException: SocketException { - this(char[] msg, int err = 0) + this(string msg, int err = 0) { super(msg, err); } @@ -752,44 +754,21 @@ class SocketSet { private: - uint nbytes; // Win32: excludes uint.sizeof "count". - byte* buf; + uint maxsockets; /// max desired sockets, the fd_set might be capable of holding more + fd_set set; version(Win32) { uint count() { - return *(cast(uint*)buf); - } - - - void count(int setter) - { - *(cast(uint*)buf) = setter; - } - - - socket_t* first() - { - return cast(socket_t*)(buf + uint.sizeof); + return set.fd_count; } } else version(BsdSockets) { - int maxfd = -1; - - - socket_t* first() - { - return cast(socket_t*)buf; - } - } - - - fd_set* _fd_set() - { - return cast(fd_set*)buf; + int maxfd; + uint count; } @@ -798,19 +777,8 @@ /// Set the maximum amount of sockets that may be added. this(uint max) { - version(Win32) - { - nbytes = max * socket_t.sizeof; - buf = (new byte[nbytes + uint.sizeof]).ptr; - count = 0; - } - else version(BsdSockets) - { - nbytes = max / NFDBITS * socket_t.sizeof; - if(max % NFDBITS) - nbytes += socket_t.sizeof; - buf = (new byte[nbytes]).ptr; // new initializes to 0. - } + maxsockets = max; + reset(); } /// Uses the default maximum for the system. @@ -822,14 +790,12 @@ /// Reset the SocketSet so that there are 0 Sockets in the collection. void reset() { - version(Win32) - { - count = 0; - } - else version(BsdSockets) + FD_ZERO(&set); + + version(BsdSockets) { maxfd = -1; - buf[0 .. nbytes] = 0; + count = 0; } } @@ -838,21 +804,19 @@ in { // Make sure too many sockets don't get added. - version(Win32) - { - assert(count < max); - } - else version(BsdSockets) + assert(count < maxsockets); + version(BsdSockets) { - assert(FDELT(s) < nbytes / socket_t.sizeof); + assert(FDELT(s) < (FD_SETSIZE / NFDBITS)); } } body { - FD_SET(s, _fd_set); + FD_SET(s, &set); version(BsdSockets) { + ++count; if(s > maxfd) maxfd = s; } @@ -866,7 +830,12 @@ void remove(socket_t s) { - FD_CLR(s, _fd_set); + FD_CLR(s, &set); + version(BsdSockets) + { + --count; + // note: adjusting maxfd would require scanning the set, not worth it + } } @@ -878,7 +847,7 @@ int isSet(socket_t s) { - return FD_ISSET(s, _fd_set); + return FD_ISSET(s, &set); } @@ -892,24 +861,13 @@ /// Return maximum amount of sockets that can be added, like FD_SETSIZE. uint max() { - version(Win32) - { - return nbytes / socket_t.sizeof; - } - else version(BsdSockets) - { - return nbytes / socket_t.sizeof * NFDBITS; - } - else - { - static assert(0); - } + return maxsockets; } fd_set* toFd_set() { - return _fd_set; + return &set; } @@ -917,7 +875,7 @@ { version(Win32) { - return 0; + return count; } else version(BsdSockets) { @@ -1036,7 +994,7 @@ /// ditto - this(AddressFamily af, SocketType type, char[] protocolName) + this(AddressFamily af, SocketType type, string protocolName) { protoent* proto; proto = getprotobyname(toStringz(protocolName)); @@ -1268,7 +1226,7 @@ /// Returns the local machine's host name. Idea from mango. - static char[] hostName() // getter + static string hostName() // getter { char[256] result; // Host names are limited to 255 chars. if(_SOCKET_ERROR == .gethostname(result.ptr, result.length)) diff -uNr dmd-1.018/dmd/src/phobos/std/uni.d dmd-1.019/dmd/src/phobos/std/uni.d --- dmd-1.018/dmd/src/phobos/std/uni.d 2007-07-01 11:10:38.000000000 +0200 +++ dmd-1.019/dmd/src/phobos/std/uni.d 2007-07-22 09:44:12.000000000 +0200 @@ -180,91 +180,73 @@ /******************************* * Return !=0 if u is a Unicode alpha character. + * (general Unicode category: Lu, Ll, Lt, Lm and Lo) + * + * Standards: Unicode 5.0.0 */ int isUniAlpha(dchar u) { - static ushort table[][2] = + static dchar table[][2] = [ [ 'A', 'Z' ], [ 'a', 'z' ], [ 0x00AA, 0x00AA ], [ 0x00B5, 0x00B5 ], - [ 0x00B7, 0x00B7 ], [ 0x00BA, 0x00BA ], [ 0x00C0, 0x00D6 ], [ 0x00D8, 0x00F6 ], - [ 0x00F8, 0x01F5 ], - [ 0x01FA, 0x0217 ], - [ 0x0250, 0x02A8 ], - [ 0x02B0, 0x02B8 ], - [ 0x02BB, 0x02BB ], - [ 0x02BD, 0x02C1 ], - [ 0x02D0, 0x02D1 ], + [ 0x00F8, 0x02C1 ], + [ 0x02C6, 0x02D1 ], [ 0x02E0, 0x02E4 ], - [ 0x037A, 0x037A ], + [ 0x02EE, 0x02EE ], + [ 0x037A, 0x037D ], [ 0x0386, 0x0386 ], [ 0x0388, 0x038A ], [ 0x038C, 0x038C ], [ 0x038E, 0x03A1 ], [ 0x03A3, 0x03CE ], - [ 0x03D0, 0x03D6 ], - [ 0x03DA, 0x03DA ], - [ 0x03DC, 0x03DC ], - [ 0x03DE, 0x03DE ], - [ 0x03E0, 0x03E0 ], - [ 0x03E2, 0x03F3 ], - [ 0x0401, 0x040C ], - [ 0x040E, 0x044F ], - [ 0x0451, 0x045C ], - [ 0x045E, 0x0481 ], - [ 0x0490, 0x04C4 ], - [ 0x04C7, 0x04C8 ], - [ 0x04CB, 0x04CC ], - [ 0x04D0, 0x04EB ], - [ 0x04EE, 0x04F5 ], - [ 0x04F8, 0x04F9 ], + [ 0x03D0, 0x03F5 ], + [ 0x03F7, 0x0481 ], + [ 0x048A, 0x0513 ], [ 0x0531, 0x0556 ], [ 0x0559, 0x0559 ], [ 0x0561, 0x0587 ], - [ 0x05B0, 0x05B9 ], - [ 0x05BB, 0x05BD ], - [ 0x05BF, 0x05BF ], - [ 0x05C1, 0x05C2 ], [ 0x05D0, 0x05EA ], [ 0x05F0, 0x05F2 ], [ 0x0621, 0x063A ], - [ 0x0640, 0x0652 ], - [ 0x0660, 0x0669 ], - [ 0x0670, 0x06B7 ], - [ 0x06BA, 0x06BE ], - [ 0x06C0, 0x06CE ], - [ 0x06D0, 0x06DC ], - [ 0x06E5, 0x06E8 ], - [ 0x06EA, 0x06ED ], - [ 0x06F0, 0x06F9 ], - [ 0x0901, 0x0903 ], - [ 0x0905, 0x0939 ], + [ 0x0640, 0x064A ], + [ 0x066E, 0x066F ], + [ 0x0671, 0x06D3 ], + [ 0x06D5, 0x06D5 ], + [ 0x06E5, 0x06E6 ], + [ 0x06EE, 0x06EF ], + [ 0x06FA, 0x06FC ], + [ 0x06FF, 0x06FF ], + [ 0x0710, 0x0710 ], + [ 0x0712, 0x072F ], + [ 0x074D, 0x076D ], + [ 0x0780, 0x07A5 ], + [ 0x07B1, 0x07B1 ], + [ 0x07CA, 0x07EA ], + [ 0x07F4, 0x07F5 ], + [ 0x07FA, 0x07FA ], + [ 0x0904, 0x0939 ], [ 0x093D, 0x093D ], - [ 0x093E, 0x094D ], - [ 0x0950, 0x0952 ], - [ 0x0958, 0x0963 ], - [ 0x0966, 0x096F ], - [ 0x0981, 0x0983 ], + [ 0x0950, 0x0950 ], + [ 0x0958, 0x0961 ], + [ 0x097B, 0x097F ], [ 0x0985, 0x098C ], [ 0x098F, 0x0990 ], [ 0x0993, 0x09A8 ], [ 0x09AA, 0x09B0 ], [ 0x09B2, 0x09B2 ], [ 0x09B6, 0x09B9 ], - [ 0x09BE, 0x09C4 ], - [ 0x09C7, 0x09C8 ], - [ 0x09CB, 0x09CD ], + [ 0x09BD, 0x09BD ], + [ 0x09CE, 0x09CE ], [ 0x09DC, 0x09DD ], - [ 0x09DF, 0x09E3 ], - [ 0x09E6, 0x09EF ], + [ 0x09DF, 0x09E1 ], [ 0x09F0, 0x09F1 ], - [ 0x0A02, 0x0A02 ], [ 0x0A05, 0x0A0A ], [ 0x0A0F, 0x0A10 ], [ 0x0A13, 0x0A28 ], @@ -272,42 +254,29 @@ [ 0x0A32, 0x0A33 ], [ 0x0A35, 0x0A36 ], [ 0x0A38, 0x0A39 ], - [ 0x0A3E, 0x0A42 ], - [ 0x0A47, 0x0A48 ], - [ 0x0A4B, 0x0A4D ], [ 0x0A59, 0x0A5C ], [ 0x0A5E, 0x0A5E ], - [ 0x0A66, 0x0A6F ], - [ 0x0A74, 0x0A74 ], - [ 0x0A81, 0x0A83 ], - [ 0x0A85, 0x0A8B ], - [ 0x0A8D, 0x0A8D ], + [ 0x0A72, 0x0A74 ], + [ 0x0A85, 0x0A8D ], [ 0x0A8F, 0x0A91 ], [ 0x0A93, 0x0AA8 ], [ 0x0AAA, 0x0AB0 ], [ 0x0AB2, 0x0AB3 ], [ 0x0AB5, 0x0AB9 ], - [ 0x0ABD, 0x0AC5 ], - [ 0x0AC7, 0x0AC9 ], - [ 0x0ACB, 0x0ACD ], + [ 0x0ABD, 0x0ABD ], [ 0x0AD0, 0x0AD0 ], - [ 0x0AE0, 0x0AE0 ], - [ 0x0AE6, 0x0AEF ], - [ 0x0B01, 0x0B03 ], + [ 0x0AE0, 0x0AE1 ], [ 0x0B05, 0x0B0C ], [ 0x0B0F, 0x0B10 ], [ 0x0B13, 0x0B28 ], [ 0x0B2A, 0x0B30 ], [ 0x0B32, 0x0B33 ], - [ 0x0B36, 0x0B39 ], + [ 0x0B35, 0x0B39 ], [ 0x0B3D, 0x0B3D ], - [ 0x0B3E, 0x0B43 ], - [ 0x0B47, 0x0B48 ], - [ 0x0B4B, 0x0B4D ], [ 0x0B5C, 0x0B5D ], [ 0x0B5F, 0x0B61 ], - [ 0x0B66, 0x0B6F ], - [ 0x0B82, 0x0B83 ], + [ 0x0B71, 0x0B71 ], + [ 0x0B83, 0x0B83 ], [ 0x0B85, 0x0B8A ], [ 0x0B8E, 0x0B90 ], [ 0x0B92, 0x0B95 ], @@ -316,50 +285,34 @@ [ 0x0B9E, 0x0B9F ], [ 0x0BA3, 0x0BA4 ], [ 0x0BA8, 0x0BAA ], - [ 0x0BAE, 0x0BB5 ], - [ 0x0BB7, 0x0BB9 ], - [ 0x0BBE, 0x0BC2 ], - [ 0x0BC6, 0x0BC8 ], - [ 0x0BCA, 0x0BCD ], - [ 0x0BE7, 0x0BEF ], - [ 0x0C01, 0x0C03 ], + [ 0x0BAE, 0x0BB9 ], [ 0x0C05, 0x0C0C ], [ 0x0C0E, 0x0C10 ], [ 0x0C12, 0x0C28 ], [ 0x0C2A, 0x0C33 ], [ 0x0C35, 0x0C39 ], - [ 0x0C3E, 0x0C44 ], - [ 0x0C46, 0x0C48 ], - [ 0x0C4A, 0x0C4D ], [ 0x0C60, 0x0C61 ], - [ 0x0C66, 0x0C6F ], - [ 0x0C82, 0x0C83 ], [ 0x0C85, 0x0C8C ], [ 0x0C8E, 0x0C90 ], [ 0x0C92, 0x0CA8 ], [ 0x0CAA, 0x0CB3 ], [ 0x0CB5, 0x0CB9 ], - [ 0x0CBE, 0x0CC4 ], - [ 0x0CC6, 0x0CC8 ], - [ 0x0CCA, 0x0CCD ], + [ 0x0CBD, 0x0CBD ], [ 0x0CDE, 0x0CDE ], [ 0x0CE0, 0x0CE1 ], - [ 0x0CE6, 0x0CEF ], - [ 0x0D02, 0x0D03 ], [ 0x0D05, 0x0D0C ], [ 0x0D0E, 0x0D10 ], [ 0x0D12, 0x0D28 ], [ 0x0D2A, 0x0D39 ], - [ 0x0D3E, 0x0D43 ], - [ 0x0D46, 0x0D48 ], - [ 0x0D4A, 0x0D4D ], [ 0x0D60, 0x0D61 ], - [ 0x0D66, 0x0D6F ], - [ 0x0E01, 0x0E3A ], - - [ 0x0E40, 0x0E5B ], -// [ 0x0E50, 0x0E59 ], // Digits? Why does this overlap previous? - + [ 0x0D85, 0x0D96 ], + [ 0x0D9A, 0x0DB1 ], + [ 0x0DB3, 0x0DBB ], + [ 0x0DBD, 0x0DBD ], + [ 0x0DC0, 0x0DC6 ], + [ 0x0E01, 0x0E30 ], + [ 0x0E32, 0x0E33 ], + [ 0x0E40, 0x0E46 ], [ 0x0E81, 0x0E82 ], [ 0x0E84, 0x0E84 ], [ 0x0E87, 0x0E88 ], @@ -371,31 +324,68 @@ [ 0x0EA5, 0x0EA5 ], [ 0x0EA7, 0x0EA7 ], [ 0x0EAA, 0x0EAB ], - [ 0x0EAD, 0x0EAE ], - [ 0x0EB0, 0x0EB9 ], - [ 0x0EBB, 0x0EBD ], + [ 0x0EAD, 0x0EB0 ], + [ 0x0EB2, 0x0EB3 ], + [ 0x0EBD, 0x0EBD ], [ 0x0EC0, 0x0EC4 ], [ 0x0EC6, 0x0EC6 ], - [ 0x0EC8, 0x0ECD ], - [ 0x0ED0, 0x0ED9 ], [ 0x0EDC, 0x0EDD ], [ 0x0F00, 0x0F00 ], - [ 0x0F18, 0x0F19 ], - [ 0x0F20, 0x0F33 ], - [ 0x0F35, 0x0F35 ], - [ 0x0F37, 0x0F37 ], - [ 0x0F39, 0x0F39 ], - [ 0x0F3E, 0x0F47 ], - [ 0x0F49, 0x0F69 ], - [ 0x0F71, 0x0F84 ], - [ 0x0F86, 0x0F8B ], - [ 0x0F90, 0x0F95 ], - [ 0x0F97, 0x0F97 ], - [ 0x0F99, 0x0FAD ], - [ 0x0FB1, 0x0FB7 ], - [ 0x0FB9, 0x0FB9 ], + [ 0x0F40, 0x0F47 ], + [ 0x0F49, 0x0F6A ], + [ 0x0F88, 0x0F8B ], + [ 0x1000, 0x1021 ], + [ 0x1023, 0x1027 ], + [ 0x1029, 0x102A ], + [ 0x1050, 0x1055 ], [ 0x10A0, 0x10C5 ], - [ 0x10D0, 0x10F6 ], + [ 0x10D0, 0x10FA ], + [ 0x10FC, 0x10FC ], + [ 0x1100, 0x1159 ], + [ 0x115F, 0x11A2 ], + [ 0x11A8, 0x11F9 ], + [ 0x1200, 0x1248 ], + [ 0x124A, 0x124D ], + [ 0x1250, 0x1256 ], + [ 0x1258, 0x1258 ], + [ 0x125A, 0x125D ], + [ 0x1260, 0x1288 ], + [ 0x128A, 0x128D ], + [ 0x1290, 0x12B0 ], + [ 0x12B2, 0x12B5 ], + [ 0x12B8, 0x12BE ], + [ 0x12C0, 0x12C0 ], + [ 0x12C2, 0x12C5 ], + [ 0x12C8, 0x12D6 ], + [ 0x12D8, 0x1310 ], + [ 0x1312, 0x1315 ], + [ 0x1318, 0x135A ], + [ 0x1380, 0x138F ], + [ 0x13A0, 0x13F4 ], + [ 0x1401, 0x166C ], + [ 0x166F, 0x1676 ], + [ 0x1681, 0x169A ], + [ 0x16A0, 0x16EA ], + [ 0x1700, 0x170C ], + [ 0x170E, 0x1711 ], + [ 0x1720, 0x1731 ], + [ 0x1740, 0x1751 ], + [ 0x1760, 0x176C ], + [ 0x176E, 0x1770 ], + [ 0x1780, 0x17B3 ], + [ 0x17D7, 0x17D7 ], + [ 0x17DC, 0x17DC ], + [ 0x1820, 0x1877 ], + [ 0x1880, 0x18A8 ], + [ 0x1900, 0x191C ], + [ 0x1950, 0x196D ], + [ 0x1970, 0x1974 ], + [ 0x1980, 0x19A9 ], + [ 0x19C1, 0x19C7 ], + [ 0x1A00, 0x1A16 ], + [ 0x1B05, 0x1B33 ], + [ 0x1B45, 0x1B4B ], + [ 0x1D00, 0x1DBF ], [ 0x1E00, 0x1E9B ], [ 0x1EA0, 0x1EF9 ], [ 0x1F00, 0x1F15 ], @@ -417,30 +407,145 @@ [ 0x1FE0, 0x1FEC ], [ 0x1FF2, 0x1FF4 ], [ 0x1FF6, 0x1FFC ], - [ 0x203F, 0x2040 ], + [ 0x2071, 0x2071 ], [ 0x207F, 0x207F ], + [ 0x2090, 0x2094 ], [ 0x2102, 0x2102 ], [ 0x2107, 0x2107 ], [ 0x210A, 0x2113 ], [ 0x2115, 0x2115 ], - [ 0x2118, 0x211D ], + [ 0x2119, 0x211D ], [ 0x2124, 0x2124 ], [ 0x2126, 0x2126 ], [ 0x2128, 0x2128 ], - [ 0x212A, 0x2131 ], - [ 0x2133, 0x2138 ], - [ 0x2160, 0x2182 ], - [ 0x3005, 0x3007 ], - [ 0x3021, 0x3029 ], - [ 0x3041, 0x3093 ], - [ 0x309B, 0x309C ], - [ 0x30A1, 0x30F6 ], - [ 0x30FB, 0x30FC ], + [ 0x212A, 0x212D ], + [ 0x212F, 0x2139 ], + [ 0x213C, 0x213F ], + [ 0x2145, 0x2149 ], + [ 0x214E, 0x214E ], + [ 0x2183, 0x2184 ], + [ 0x2C00, 0x2C2E ], + [ 0x2C30, 0x2C5E ], + [ 0x2C60, 0x2C6C ], + [ 0x2C74, 0x2C77 ], + [ 0x2C80, 0x2CE4 ], + [ 0x2D00, 0x2D25 ], + [ 0x2D30, 0x2D65 ], + [ 0x2D6F, 0x2D6F ], + [ 0x2D80, 0x2D96 ], + [ 0x2DA0, 0x2DA6 ], + [ 0x2DA8, 0x2DAE ], + [ 0x2DB0, 0x2DB6 ], + [ 0x2DB8, 0x2DBE ], + [ 0x2DC0, 0x2DC6 ], + [ 0x2DC8, 0x2DCE ], + [ 0x2DD0, 0x2DD6 ], + [ 0x2DD8, 0x2DDE ], + [ 0x3005, 0x3006 ], + [ 0x3031, 0x3035 ], + [ 0x303B, 0x303C ], + [ 0x3041, 0x3096 ], + [ 0x309D, 0x309F ], + [ 0x30A1, 0x30FA ], + [ 0x30FC, 0x30FF ], [ 0x3105, 0x312C ], - [ 0x4E00, 0x9FA5 ], + [ 0x3131, 0x318E ], + [ 0x31A0, 0x31B7 ], + [ 0x31F0, 0x31FF ], + [ 0x3400, 0x4DB5 ], + [ 0x4E00, 0x9FBB ], + [ 0xA000, 0xA48C ], + [ 0xA717, 0xA71A ], + [ 0xA800, 0xA801 ], + [ 0xA803, 0xA805 ], + [ 0xA807, 0xA80A ], + [ 0xA80C, 0xA822 ], + [ 0xA840, 0xA873 ], [ 0xAC00, 0xD7A3 ], + [ 0xF900, 0xFA2D ], + [ 0xFA30, 0xFA6A ], + [ 0xFA70, 0xFAD9 ], + [ 0xFB00, 0xFB06 ], + [ 0xFB13, 0xFB17 ], + [ 0xFB1D, 0xFB1D ], + [ 0xFB1F, 0xFB28 ], + [ 0xFB2A, 0xFB36 ], + [ 0xFB38, 0xFB3C ], + [ 0xFB3E, 0xFB3E ], + [ 0xFB40, 0xFB41 ], + [ 0xFB43, 0xFB44 ], + [ 0xFB46, 0xFBB1 ], + [ 0xFBD3, 0xFD3D ], + [ 0xFD50, 0xFD8F ], + [ 0xFD92, 0xFDC7 ], + [ 0xFDF0, 0xFDFB ], + [ 0xFE70, 0xFE74 ], + [ 0xFE76, 0xFEFC ], [ 0xFF21, 0xFF3A ], [ 0xFF41, 0xFF5A ], + [ 0xFF66, 0xFFBE ], + [ 0xFFC2, 0xFFC7 ], + [ 0xFFCA, 0xFFCF ], + [ 0xFFD2, 0xFFD7 ], + [ 0xFFDA, 0xFFDC ], + [ 0x10000, 0x1000B ], + [ 0x1000D, 0x10026 ], + [ 0x10028, 0x1003A ], + [ 0x1003C, 0x1003D ], + [ 0x1003F, 0x1004D ], + [ 0x10050, 0x1005D ], + [ 0x10080, 0x100FA ], + [ 0x10300, 0x1031E ], + [ 0x10330, 0x10340 ], + [ 0x10342, 0x10349 ], + [ 0x10380, 0x1039D ], + [ 0x103A0, 0x103C3 ], + [ 0x103C8, 0x103CF ], + [ 0x10400, 0x1049D ], + [ 0x10800, 0x10805 ], + [ 0x10808, 0x10808 ], + [ 0x1080A, 0x10835 ], + [ 0x10837, 0x10838 ], + [ 0x1083C, 0x1083C ], + [ 0x1083F, 0x1083F ], + [ 0x10900, 0x10915 ], + [ 0x10A00, 0x10A00 ], + [ 0x10A10, 0x10A13 ], + [ 0x10A15, 0x10A17 ], + [ 0x10A19, 0x10A33 ], + [ 0x12000, 0x1236E ], + [ 0x1D400, 0x1D454 ], + [ 0x1D456, 0x1D49C ], + [ 0x1D49E, 0x1D49F ], + [ 0x1D4A2, 0x1D4A2 ], + [ 0x1D4A5, 0x1D4A6 ], + [ 0x1D4A9, 0x1D4AC ], + [ 0x1D4AE, 0x1D4B9 ], + [ 0x1D4BB, 0x1D4BB ], + [ 0x1D4BD, 0x1D4C3 ], + [ 0x1D4C5, 0x1D505 ], + [ 0x1D507, 0x1D50A ], + [ 0x1D50D, 0x1D514 ], + [ 0x1D516, 0x1D51C ], + [ 0x1D51E, 0x1D539 ], + [ 0x1D53B, 0x1D53E ], + [ 0x1D540, 0x1D544 ], + [ 0x1D546, 0x1D546 ], + [ 0x1D54A, 0x1D550 ], + [ 0x1D552, 0x1D6A5 ], + [ 0x1D6A8, 0x1D6C0 ], + [ 0x1D6C2, 0x1D6DA ], + [ 0x1D6DC, 0x1D6FA ], + [ 0x1D6FC, 0x1D714 ], + [ 0x1D716, 0x1D734 ], + [ 0x1D736, 0x1D74E ], + [ 0x1D750, 0x1D76E ], + [ 0x1D770, 0x1D788 ], + [ 0x1D78A, 0x1D7A8 ], + [ 0x1D7AA, 0x1D7C2 ], + [ 0x1D7C4, 0x1D7CB ], + [ 0x20000, 0x2A6D6 ], + [ 0x2F800, 0x2FA1D ], ]; debug @@ -457,8 +562,18 @@ } } - if (u > 0xD7A3 && u < 0xFF21) + if (u < 0xAA) + { + if (u < 'A') + goto Lisnot; + if (u <= 'Z') + goto Lis; + if (u < 'a') + goto Lisnot; + if (u <= 'z') + goto Lis; goto Lisnot; + } // Binary search uint mid; @@ -491,12 +606,12 @@ Lis: debug { - for (int i = 0; 1; i++) + for (int i = 0; i < table.length; i++) { - assert(i < table.length); // should have been in table if (u >= table[i][0] && u <= table[i][1]) - break; + return 1; } + assert(0); // should have been in table } return 1; }