diff -uNr dmd-0.115/dmd/src/dmd/cast.c dmd-0.116/dmd/src/dmd/cast.c --- dmd-0.115/dmd/src/dmd/cast.c 2005-02-27 19:02:40.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/cast.c 2005-03-01 10:28:28.000000000 +0100 @@ -31,9 +31,24 @@ Expression *Expression::implicitCastTo(Type *t) { - //printf("implicitCastTo()\n"); + //printf("implicitCastTo(%s) => %s\n", type->toChars(), t->toChars()); if (implicitConvTo(t)) + { + if (global.params.warnings && + Type::impcnvWarn[type->toBasetype()->ty][t->toBasetype()->ty] && + op != TOKint64) + { + Expression *e = optimize(WANTflags | WANTvalue); + + if (e->op == TOKint64) + return e->implicitCastTo(t); + + printf("warning - "); + error("implicit conversion of expression (%s) of type %s to %s can cause loss of data", + toChars(), type->toChars(), t->toChars()); + } return castTo(t); + } #if 0 print(); type->print(); @@ -43,7 +58,8 @@ printf("%p %p %p\n", type->next->arrayOf(), type, t); #endif //*(char*)0=0; - error("cannot implicitly convert expression %s of type %s to %s", toChars(), type->toChars(), t->toChars()); + error("cannot implicitly convert expression (%s) of type %s to %s", + toChars(), type->toChars(), t->toChars()); return castTo(t); } @@ -120,7 +136,7 @@ } // Only allow conversion if no change in value - switch(t->ty) + switch (t->toBasetype()->ty) { case Tbit: if (value & ~1) diff -uNr dmd-0.115/dmd/src/dmd/dsymbol.c dmd-0.116/dmd/src/dmd/dsymbol.c --- dmd-0.115/dmd/src/dmd/dsymbol.c 2005-02-14 17:44:56.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/dsymbol.c 2005-03-07 12:10:34.000000000 +0100 @@ -571,7 +571,7 @@ Dsymbol *ArrayScopeSymbol::search(Identifier *ident, int flags) { - if (ident == Id::length) + if (ident == Id::length || ident == Id::dollar) { VarDeclaration **pvar; if (exp->op == TOKindex) @@ -590,7 +590,7 @@ return NULL; if (!*pvar) { - VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::length, NULL); + VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::dollar, NULL); *pvar = v; } @@ -599,6 +599,7 @@ return NULL; } + /****************************** DsymbolTable ******************************/ DsymbolTable::DsymbolTable() diff -uNr dmd-0.115/dmd/src/dmd/entity.c dmd-0.116/dmd/src/dmd/entity.c --- dmd-0.115/dmd/src/dmd/entity.c 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/entity.c 2005-03-03 23:28:16.000000000 +0100 @@ -0,0 +1,300 @@ + +// Copyright (c) 1999-2005 by Digital Mars +// All Rights Reserved +// written by Walter Bright +// www.digitalmars.com +// License for redistribution is by either the Artistic License +// in artistic.txt, or the GNU General Public License in gnu.txt. +// See the included readme.txt for details. + + +#include + +/********************************************* + * Convert from named entity to its encoding. + * For reference: + * http://www.htmlhelp.com/reference/html40/entities/ + * http://www.w3.org/TR/1999/REC-html401-19991224/sgml/entities.html + */ + +struct NameId +{ + char *name; + unsigned short value; +}; + +static NameId names[] = +{ + // Entities + "quot", 34, + "amp", 38, + "lt", 60, + "gt", 62, + + "OElig", 338, + "oelig", 339, + "Scaron", 352, + "scaron", 353, + "Yuml", 376, + "circ", 710, + "tilde", 732, + "ensp", 8194, + "emsp", 8195, + "thinsp", 8201, + "zwnj", 8204, + "zwj", 8205, + "lrm", 8206, + "rlm", 8207, + "ndash", 8211, + "mdash", 8212, + "lsquo", 8216, + "rsquo", 8217, + "sbquo", 8218, + "ldquo", 8220, + "rdquo", 8221, + "bdquo", 8222, + "dagger", 8224, + "Dagger", 8225, + "permil", 8240, + "lsquo", 8249, + "rsaquo", 8250, + "euro", 8364, + + // Latin-1 (ISO-8859-1) Entities + "nbsp", 160, + "iexcl", 161, + "cent", 162, + "pound", 163, + "curren", 164, + "yen", 165, + "brvbar", 166, + "sect", 167, + "uml", 168, + "copy", 169, + "ordf", 170, + "laquo", 171, + "not", 172, + "shy", 173, + "reg", 174, + "macr", 175, + "deg", 176, + "plusmn", 177, + "sup2", 178, + "sup3", 179, + "acute", 180, + "micro", 181, + "para", 182, + "middot", 183, + "cedil", 184, + "sup1", 185, + "ordm", 186, + "raquo", 187, + "frac14", 188, + "frac12", 189, + "frac34", 190, + "iquest", 191, + "Agrave", 192, + "Aacute", 193, + "Acirc", 194, + "Atilde", 195, + "Auml", 196, + "Aring", 197, + "AElig", 198, + "Ccedil", 199, + "Egrave", 200, + "Eacute", 201, + "Ecirc", 202, + "Euml", 203, + "Igrave", 204, + "Iacute", 205, + "Icirc", 206, + "Iuml", 207, + "ETH", 208, + "Ntilde", 209, + "Ograve", 210, + "Oacute", 211, + "Ocirc", 212, + "Otilde", 213, + "Ouml", 214, + "times", 215, + "Oslash", 216, + "Ugrave", 217, + "Uacute", 218, + "Ucirc", 219, + "Uuml", 220, + "Yacute", 221, + "THORN", 222, + "szlig", 223, + "agrave", 224, + "aacute", 225, + "acirc", 226, + "atilde", 227, + "auml", 228, + "aring", 229, + "aelig", 230, + "ccedil", 231, + "egrave", 232, + "eacute", 233, + "ecirc", 234, + "euml", 235, + "igrave", 236, + "iacute", 237, + "icirc", 238, + "iuml", 239, + "eth", 240, + "ntilde", 241, + "ograve", 242, + "oacute", 243, + "ocirc", 244, + "otilde", 245, + "ouml", 246, + "divide", 247, + "oslash", 248, + "ugrave", 249, + "uacute", 250, + "ucirc", 251, + "uuml", 252, + "yacute", 253, + "thorn", 254, + "yuml", 255, + + // Symbols and Greek letter entities + "fnof", 402, + "Alpha", 913, + "Beta", 914, + "Gamma", 915, + "Delta", 916, + "Epsilon", 917, + "Zeta", 918, + "Eta", 919, + "Theta", 920, + "Iota", 921, + "Kappa", 922, + "Lambda", 923, + "Mu", 924, + "Nu", 925, + "Xi", 926, + "Omicron", 927, + "Pi", 928, + "Rho", 929, + "Sigma", 931, + "Tau", 932, + "Upsilon", 933, + "Phi", 934, + "Chi", 935, + "Psi", 936, + "Omega", 937, + "alpha", 945, + "beta", 946, + "gamma", 947, + "delta", 948, + "epsilon", 949, + "zeta", 950, + "eta", 951, + "theta", 952, + "iota", 953, + "kappa", 954, + "lambda", 955, + "mu", 956, + "nu", 957, + "xi", 958, + "omicron", 959, + "pi", 960, + "rho", 961, + "sigmaf", 962, + "sigma", 963, + "tau", 964, + "upsilon", 965, + "phi", 966, + "chi", 967, + "psi", 968, + "omega", 969, + "thetasym", 977, + "upsih", 978, + "piv", 982, + "bull", 8226, + "hellip", 8230, + "prime", 8242, + "Prime", 8243, + "oline", 8254, + "frasl", 8260, + "weierp", 8472, + "image", 8465, + "real", 8476, + "trade", 8482, + "alefsym", 8501, + "larr", 8592, + "uarr", 8593, + "rarr", 8594, + "darr", 8595, + "harr", 8596, + "crarr", 8629, + "lArr", 8656, + "uArr", 8657, + "rArr", 8658, + "dArr", 8659, + "hArr", 8660, + "forall", 8704, + "part", 8706, + "exist", 8707, + "empty", 8709, + "nabla", 8711, + "isin", 8712, + "notin", 8713, + "ni", 8715, + "prod", 8719, + "sum", 8721, + "minus", 8722, + "lowast", 8727, + "radic", 8730, + "prop", 8733, + "infin", 8734, + "ang", 8736, + "and", 8743, + "or", 8744, + "cap", 8745, + "cup", 8746, + "int", 8747, + "there4", 8756, + "sim", 8764, + "cong", 8773, + "asymp", 8776, + "ne", 8800, + "equiv", 8801, + "le", 8804, + "ge", 8805, + "sub", 8834, + "sup", 8835, + "nsub", 8836, + "sube", 8838, + "supe", 8839, + "oplus", 8853, + "otimes", 8855, + "perp", 8869, + "sdot", 8901, + "lceil", 8968, + "rceil", 8969, + "lfloor", 8970, + "rfloor", 8971, + "lang", 9001, + "rang", 9002, + "loz", 9674, + "spades", 9824, + "clubs", 9827, + "hearts", 9829, + "diams", 9830, +}; + +int HtmlNamedEntity(unsigned char *p, int length) +{ + int i; + + // BUG: this is a dumb, slow linear search + for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) + { + // Entries are case sensitive + if (memcmp(names[i].name, (char *)p, length) == 0) + return names[i].value; + } + return -1; +} diff -uNr dmd-0.115/dmd/src/dmd/expression.c dmd-0.116/dmd/src/dmd/expression.c --- dmd-0.115/dmd/src/dmd/expression.c 2005-02-27 18:34:10.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/expression.c 2005-03-07 12:16:02.000000000 +0100 @@ -991,6 +991,13 @@ return this; } +/******************************** DollarExp **************************/ + +DollarExp::DollarExp(Loc loc) + : IdentifierExp(loc, Id::dollar) +{ +} + /******************************** DsymbolExp **************************/ DsymbolExp::DsymbolExp(Loc loc, Dsymbol *s) @@ -1015,6 +1022,7 @@ ClassDeclaration *cd; ClassDeclaration *thiscd = NULL; Import *imp; + Package *pkg; Type *t; //printf("DsymbolExp:: '%s' is a symbol\n", toChars()); @@ -1108,6 +1116,14 @@ ie = new ScopeExp(loc, imp->pkg); return ie->semantic(sc); } + pkg = s->isPackage(); + if (pkg) + { + ScopeExp *ie; + + ie = new ScopeExp(loc, pkg); + return ie->semantic(sc); + } Module *mod = s->isModule(); if (mod) { diff -uNr dmd-0.115/dmd/src/dmd/expression.h dmd-0.116/dmd/src/dmd/expression.h --- dmd-0.115/dmd/src/dmd/expression.h 2005-02-08 15:38:22.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/expression.h 2005-03-07 12:22:28.000000000 +0100 @@ -199,6 +199,11 @@ Expression *toLvalue(Expression *e); }; +struct DollarExp : IdentifierExp +{ + DollarExp(Loc loc); +}; + struct DsymbolExp : Expression { Dsymbol *s; diff -uNr dmd-0.115/dmd/src/dmd/func.c dmd-0.116/dmd/src/dmd/func.c --- dmd-0.115/dmd/src/dmd/func.c 2005-02-27 19:44:12.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/func.c 2005-03-07 14:52:12.000000000 +0100 @@ -580,6 +580,7 @@ if (fbody) { fbody = fbody->semantic(sc2); + int offend = fbody ? fbody->fallOffEnd() : TRUE; if (isCtorDeclaration()) { @@ -606,17 +607,28 @@ fbody = new CompoundStatement(0, fbody, s); assert(!returnLabel); } - else if (!hasReturnExp && type->next->ty != Tvoid) - error("function expected to return a value of type %s", type->next->toChars()); - else if (global.params.useAssert && - !global.params.useInline && - type->next->ty != Tvoid && - !inlineAsm) +// else if (!hasReturnExp && type->next->ty != Tvoid) +// error("expected to return a value of type %s", type->next->toChars()); + else if (type->next->ty != Tvoid && !inlineAsm) { - Expression *e = new AssertExp(endloc, new IntegerExp(0, 0, Type::tint32)); - e = e->semantic(sc2); - Statement *s = new ExpStatement(0, e); - fbody = new CompoundStatement(0, fbody, s); + if (offend) + { + if (global.params.warnings) + { printf("warning - "); + error("no return at end of function"); + } + + if (global.params.useAssert && + !global.params.useInline) + { /* Add an assert(0); where the missing return + * should be. + */ + Expression *e = new AssertExp(endloc, new IntegerExp(0, 0, Type::tint32)); + e = e->semantic(sc2); + Statement *s = new ExpStatement(0, e); + fbody = new CompoundStatement(0, fbody, s); + } + } } } @@ -1105,7 +1117,7 @@ int FuncDeclaration::isMain() { return ident && strcmp(ident->toChars(), "main") == 0 && - linkage != LINKc && !isMember(); + linkage != LINKc && !isMember() && !isNested(); } int FuncDeclaration::isWinMain() diff -uNr dmd-0.115/dmd/src/dmd/html.c dmd-0.116/dmd/src/dmd/html.c --- dmd-0.115/dmd/src/dmd/html.c 2004-02-21 11:30:42.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/html.c 2005-03-07 14:41:14.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -7,6 +7,7 @@ // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. + /* HTML parser */ @@ -17,9 +18,18 @@ #include #include -#include "root.h" #include "html.h" +#include +#include "root.h" +#include "../mars/mars.h" + +#if __GNUC__ +int memicmp(const char *s1, const char *s2, int n); +#endif + +extern int HtmlNamedEntity(unsigned char *p, int length); + /********************************** * Determine if beginning of tag identifier * or a continuation of a tag identifier. @@ -40,11 +50,12 @@ Html::Html(const char *sourcename, unsigned char *base, unsigned length) { + //printf("Html::Html()\n"); this->sourcename = sourcename; this->base = base; p = base; end = base + length; - linnum = 0; + linnum = 1; dbuf = NULL; inCode = 0; } @@ -66,7 +77,6 @@ fflush(stdout); global.errors++; - fatal(); } /********************************************** @@ -76,27 +86,32 @@ void Html::extractCode(OutBuffer *buf) { + //printf("Html::extractCode()\n"); dbuf = buf; // save for other routines buf->reserve(end - p); inCode = 0; while (1) { + //printf("p = %p, *p = x%x\n", p, *p); switch (*p) { +#if 0 // strings are not recognized outside of tags case '"': case '\'': skipString(); continue; - +#endif case '<': - if (p[1] == '!' && p[2] == '-' && p[3] == '-') + if (p[1] == '!' && isCommentStart()) { // Comments start with continue; } break; } + //printf("*p = '%c'\n", *p); } /******************************************** + * Determine if we are at the start of a comment. + * Input: + * p is on the opening '<' + * Returns: + * 0 if not start of a comment + * 1 if start of a comment, p is adjusted to point past -- + */ + +int Html::isCommentStart() +#ifdef __DMC__ + __out(result) + { + if (result == 0) + ; + else if (result == 1) + { + assert(p[-2] == '-' && p[-1] == '-'); + } + else + assert(0); + } + __body +#endif /* __DMC__ */ + { unsigned char *s; + + if (p[0] == '<' && p[1] == '!') + { + for (s = p + 2; 1; s++) + { + switch (*s) + { + case ' ': + case '\t': + case '\r': + case '\f': + case '\v': + // skip white space, even though spec says no + // white space is allowed + continue; + + case '-': + if (s[1] == '-') + { + p = s + 2; + return 1; + } + goto No; + + default: + goto No; + } + } + } + No: + return 0; + } + +/******************************************** * Convert an HTML character entity into a character. * Forms are: * &name; named entity @@ -379,7 +505,9 @@ { int c = 0; int v; int hex; + unsigned char *pstart = p; + //printf("Html::charEntity('%c')\n", *p); if (p[1] == '#') { p++; @@ -389,7 +517,8 @@ } else hex = 0; - + if (p[1] == ';') + goto Linvalid; while (1) { p++; @@ -398,7 +527,7 @@ case 0: case 0x1a: error("end of file before end of character entity"); - break; + goto Lignore; case '\n': case '\r': @@ -435,20 +564,20 @@ c = (c << 4) + v; else c = (c * 10) + v; - if (c > 0xFFFF) + if (c > 0x10FFFF) + { error("character entity out of range"); + goto Lignore; + } continue; default: Linvalid: error("invalid numeric character reference"); - break; + goto Lignore; } + break; } - - // Kludge to convert non-breaking space to ascii space - if (c == 160) - c = 32; } else { @@ -469,12 +598,16 @@ case '\r': case '<': // tag start // Termination is assumed - c = namedEntity(idstart, p - idstart); + c = HtmlNamedEntity(idstart, p - idstart); + if (c == -1) + goto Lignore; break; case ';': // Termination is explicit - c = namedEntity(idstart, p - idstart); + c = HtmlNamedEntity(idstart, p - idstart); + if (c == -1) + goto Lignore; p++; break; @@ -484,58 +617,16 @@ break; } } - return c; -} -/********************************************* - * Convert from named entity to its encoding. - */ - -struct NameId -{ - char *name; - int value; -}; - -static NameId names[] = -{ - "quot", 34, - "amp", 38, - "lt", 60, - "gt", 62, -// "nbsp", 160, - "nbsp", 32, // make non-breaking space appear as space - "iexcl", 161, - "cent", 162, - "pound", 163, - "curren", 164, - "yen", 165, - "brvbar", 166, - "sect", 167, - "uml", 168, - "copy", 169, - "ordf", 170, - "laquo", 171, - "not", 172, - "shy", 173, - "reg", 174, - - // BUG: This is only a partial list. - // For the rest, consult: - // http://www.w3.org/TR/1999/REC-html401-19991224/sgml/entities.html -}; + // Kludge to convert non-breaking space to ascii space + if (c == 160) + c = ' '; -int Html::namedEntity(unsigned char *p, int length) -{ - int i; + return c; - // BUG: this is a dumb, slow linear search - for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) - { - // Do case insensitive compare - if (memicmp(names[i].name, (char *)p, length) == 0) - return names[i].value; - } - error("unrecognized character entity"); - return 0; +Lignore: + //printf("Lignore\n"); + p = pstart + 1; + return '&'; } + diff -uNr dmd-0.115/dmd/src/dmd/html.h dmd-0.116/dmd/src/dmd/html.h --- dmd-0.115/dmd/src/dmd/html.h 2002-04-22 23:14:54.000000000 +0200 +++ dmd-0.116/dmd/src/dmd/html.h 2005-03-03 19:37:34.000000000 +0100 @@ -29,5 +29,5 @@ void skipString(); void scanComment(); int charEntity(); - int namedEntity(unsigned char *p, int length); + static int namedEntity(unsigned char *p, int length); }; diff -uNr dmd-0.115/dmd/src/dmd/idgen.c dmd-0.116/dmd/src/dmd/idgen.c --- dmd-0.115/dmd/src/dmd/idgen.c 2004-12-14 01:49:28.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/idgen.c 2005-03-07 12:09:02.000000000 +0100 @@ -45,6 +45,7 @@ { "alignof" }, { "length" }, { "ptr" }, + { "dollar", "__dollar" }, { "offset" }, { "offsetof" }, { "ModuleInfo" }, @@ -66,6 +67,12 @@ { "_arguments" }, { "_argptr" }, + { "LINE", "__LINE__" }, + { "FILE", "__FILE__" }, + { "DATE", "__DATE__" }, + { "TIME", "__TIME__" }, + { "TIMESTAMP", "__TIMESTAMP__" }, + { "nan" }, { "infinity" }, { "dig" }, diff -uNr dmd-0.115/dmd/src/dmd/impcnvgen.c dmd-0.116/dmd/src/dmd/impcnvgen.c --- dmd-0.115/dmd/src/dmd/impcnvgen.c 2004-11-29 03:05:20.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/impcnvgen.c 2005-02-28 22:42:28.000000000 +0100 @@ -15,6 +15,7 @@ enum TY impcnvResult[TMAX][TMAX]; enum TY impcnvType1[TMAX][TMAX]; enum TY impcnvType2[TMAX][TMAX]; +int impcnvWarn[TMAX][TMAX]; int integral_promotion(int t) { @@ -41,6 +42,7 @@ { impcnvResult[i][j] = Terror; impcnvType1[i][j] = Terror; impcnvType2[i][j] = Terror; + impcnvWarn[i][j] = 0; } #define X(t1,t2, nt1,nt2, rt) \ @@ -291,6 +293,57 @@ X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80) +#undef X + +#define Y(t1,t2) impcnvWarn[t1][t2] = 1; + Y(Tint8, Tbit) + Y(Tuns8, Tbit) + Y(Tint16, Tbit) + Y(Tuns16, Tbit) + Y(Tint32, Tbit) + Y(Tuns32, Tbit) + Y(Tint64, Tbit) + Y(Tuns64, Tbit) + + Y(Tuns8, Tint8) + Y(Tint16, Tint8) + Y(Tuns16, Tint8) + Y(Tint32, Tint8) + Y(Tuns32, Tint8) + Y(Tint64, Tint8) + Y(Tuns64, Tint8) + + Y(Tint8, Tuns8) + Y(Tint16, Tuns8) + Y(Tuns16, Tuns8) + Y(Tint32, Tuns8) + Y(Tuns32, Tuns8) + Y(Tint64, Tuns8) + Y(Tuns64, Tuns8) + + Y(Tuns16, Tint16) + Y(Tint32, Tint16) + Y(Tuns32, Tint16) + Y(Tint64, Tint16) + Y(Tuns64, Tint16) + + Y(Tint16, Tuns16) + Y(Tint32, Tuns16) + Y(Tuns32, Tuns16) + Y(Tint64, Tuns16) + Y(Tuns64, Tuns16) + +// Y(Tuns32, Tint32) + Y(Tint64, Tint32) + Y(Tuns64, Tint32) + +// Y(Tint32, Tuns32) + Y(Tint64, Tuns32) + Y(Tuns64, Tuns32) + + Y(Tint64, Tuns64) + Y(Tuns64, Tint64) + for (i = 0; i < TMAX; i++) for (j = 0; j < TMAX; j++) { @@ -348,6 +401,17 @@ } fprintf(fp,"};\n"); + fprintf(fp,"unsigned char Type::impcnvWarn[TMAX][TMAX] =\n{\n"); + for (i = 0; i < TMAX; i++) + { + for (j = 0; j < TMAX; j++) + { + fprintf(fp, "%d,",impcnvWarn[i][j]); + } + fprintf(fp, "\n"); + } + fprintf(fp,"};\n"); + fclose(fp); return EXIT_SUCCESS; } diff -uNr dmd-0.115/dmd/src/dmd/lexer.c dmd-0.116/dmd/src/dmd/lexer.c --- dmd-0.115/dmd/src/dmd/lexer.c 2004-12-21 13:47:50.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/lexer.c 2005-03-07 14:35:16.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2003 by Digital Mars +// Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -17,8 +17,10 @@ #include #include #include +#include #if __GNUC__ +#include extern "C" long double strtold(const char *p,char **endp); #endif @@ -43,6 +45,7 @@ #endif extern int isUniAlpha(unsigned u); +extern int HtmlNamedEntity(unsigned char *p, int length); /******************************************** * Do our own char maps @@ -289,8 +292,13 @@ case '\t': case '\v': case '\f': + p++; + continue; // skip white space + case '\r': p++; + if (*p != '\n') // if CR stands by itself + loc.linnum++; continue; // skip white space case '\n': @@ -402,6 +410,55 @@ } t->ident = id; t->value = (enum TOK) id->value; + if (*t->ptr == '_') // if special identifier token + { + static char date[11+1]; + static char time[8+1]; + static char timestamp[24+1]; + + if (!date[0]) // lazy evaluation + { time_t t; + char *p; + + ::time(&t); + p = ctime(&t); + assert(p); + sprintf(date, "%.6s %.4s", p + 4, p + 20); + sprintf(time, "%.8s", p + 11); + sprintf(timestamp, "%.24s", p); + } + + if (id == Id::FILE) + { + t->value = TOKstring; + t->ustring = (unsigned char *)(loc.filename ? loc.filename : mod->ident->toChars()); + goto Llen; + } + else if (id == Id::LINE) + { + t->value = TOKint64v; + t->uns64value = loc.linnum; + } + else if (id == Id::DATE) + { + t->value = TOKstring; + t->ustring = (unsigned char *)date; + goto Llen; + } + else if (id == Id::TIME) + { + t->value = TOKstring; + t->ustring = (unsigned char *)time; + goto Llen; + } + else if (id == Id::TIMESTAMP) + { + t->value = TOKstring; + t->ustring = (unsigned char *)timestamp; + Llen: + t->len = strlen((char *)t->ustring); + } + } //printf("t->value = %d\n",t->value); return; } @@ -431,6 +488,12 @@ p++; continue; + case '\r': + p++; + if (*p != '\n') + loc.linnum++; + continue; + case 0: case 0x1A: error("unterminated /* */ comment"); @@ -451,13 +514,28 @@ continue; case '/': - p++; - p = (unsigned char *) memchr(p, '\n', end - p); - if (p == NULL) + while (1) { - p = end; - t->value = TOKeof; - return; + switch (*++p) + { + case '\n': + break; + + case '\r': + if (p[1] == '\n') + p++; + break; + + case 0: + case 0x1A: + p = end; + t->value = TOKeof; + return; + + default: + continue; + } + break; } p++; loc.linnum++; @@ -491,6 +569,12 @@ } continue; + case '\r': + p++; + if (*p != '\n') + loc.linnum++; + continue; + case '\n': loc.linnum++; p++; @@ -839,6 +923,30 @@ error("undefined escape hex sequence \\%c\n",c); break; + case '&': // named character entity + for (unsigned char *idstart = ++p; 1; p++) + { + switch (*p) + { + case ';': + c = HtmlNamedEntity(idstart, p - idstart); + if (c == ~0) + { error("unnamed character entity &%.*s;", p - idstart, idstart); + c = ' '; + } + p++; + break; + + default: + if (isalpha(*p)) + continue; + error("unterminated named entity"); + break; + } + break; + } + break; + case 0: case 0x1A: // end of file c = '\\'; @@ -1005,6 +1113,7 @@ { case 'u': case 'U': + case '&': c = escapeSequence(); stringbuffer.writeUTF8(c); continue; @@ -1099,6 +1208,7 @@ break; case 'U': + case '&': t->uns64value = escapeSequence(); tk = TOKdcharv; break; @@ -1776,11 +1886,16 @@ loc.linnum = linnum; return; + case '\r': + p++; + if (*p != '\n') + loc.linnum = linnum; + continue; + case ' ': case '\t': case '\v': case '\f': - case '\r': p++; continue; // skip white space @@ -2069,6 +2184,7 @@ Token::tochars[TOKaddress] = "#"; Token::tochars[TOKstar] = "*"; Token::tochars[TOKtilde] = "~"; + Token::tochars[TOKdollar] = "$"; Token::tochars[TOKcast] = "cast"; Token::tochars[TOKplusplus] = "++"; Token::tochars[TOKminusminus] = "--"; diff -uNr dmd-0.115/dmd/src/dmd/mangle.c dmd-0.116/dmd/src/dmd/mangle.c --- dmd-0.115/dmd/src/dmd/mangle.c 2004-12-14 01:08:28.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/mangle.c 2005-03-05 11:12:00.000000000 +0100 @@ -31,7 +31,7 @@ //printf("mangle: '%s' => '%s'\n", toChars(), result); for (int i = 0; i < len; i++) { - assert(result[i] == '_' || isalnum(result[i])); + assert(result[i] == '_' || isalnum(result[i]) || result[i] & 0x80); } } __body diff -uNr dmd-0.115/dmd/src/dmd/mars.c dmd-0.116/dmd/src/dmd/mars.c --- dmd-0.115/dmd/src/dmd/mars.c 2005-02-14 17:42:54.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/mars.c 2005-03-03 16:26:08.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2005 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.114"; + version = "v0.116"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -145,6 +145,7 @@ -unittest compile in unit tests\n\ -version=level compile in version code >= level\n\ -version=ident compile in version code identified by ident\n\ + -w enable warnings\n\ "); } @@ -230,6 +231,8 @@ global.params.trace = 1; else if (strcmp(p + 1, "v") == 0) global.params.verbose = 1; + else if (strcmp(p + 1, "w") == 0) + global.params.warnings = 1; else if (strcmp(p + 1, "O") == 0) global.params.optimize = 1; else if (p[1] == 'o') @@ -470,7 +473,9 @@ } #endif - if (stricmp(ext, "d") == 0 || stricmp(ext, "html") == 0) + if (stricmp(ext, "d") == 0 || + stricmp(ext, "htm") == 0 || + stricmp(ext, "html") == 0) { ext--; // skip onto '.' assert(*ext == '.'); diff -uNr dmd-0.115/dmd/src/dmd/mars.h dmd-0.116/dmd/src/dmd/mars.h --- dmd-0.115/dmd/src/dmd/mars.h 2004-12-08 16:13:54.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/mars.h 2005-02-28 21:15:10.000000000 +0100 @@ -39,6 +39,7 @@ char useInline; // inline expand functions char release; // build release version char preservePaths; // !=0 means don't strip path from source file + char warnings; // enable warnings char *argv0; // program name Array *imppath; // array of char*'s of where to look for import modules diff -uNr dmd-0.115/dmd/src/dmd/module.c dmd-0.116/dmd/src/dmd/module.c --- dmd-0.115/dmd/src/dmd/module.c 2005-02-10 13:46:22.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/module.c 2005-03-05 09:22:46.000000000 +0100 @@ -413,7 +413,7 @@ if (md) error(loc, "is in multiple packages %s", md->toChars()); else - error(loc, "is in multiply defined"); + error(loc, "is in multiple defined"); } } diff -uNr dmd-0.115/dmd/src/dmd/mtype.c dmd-0.116/dmd/src/dmd/mtype.c --- dmd-0.115/dmd/src/dmd/mtype.c 2005-02-27 19:57:04.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/mtype.c 2005-03-07 14:36:22.000000000 +0100 @@ -1308,19 +1308,22 @@ e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } - else if (ident == Id::sort && n->ty != Tbit) + else if (ident == Id::sort) { Expression *ec; FuncDeclaration *fd; Array *arguments; - fd = FuncDeclaration::genCfunc(tint32->arrayOf(), "_adSort"); + fd = FuncDeclaration::genCfunc(tint32->arrayOf(), + (char*)(n->ty == Tbit ? "_adSortBit" : "_adSort")); ec = new VarExp(0, fd); e = e->castTo(n->arrayOf()); // convert to dynamic array arguments = new Array(); arguments->push(e); - arguments->push(n->ty == Tsarray ? n->getTypeInfo(sc) // don't convert to dynamic array - : n->getInternalTypeInfo(sc)); + if (next->ty != Tbit) + arguments->push(n->ty == Tsarray + ? n->getTypeInfo(sc) // don't convert to dynamic array + : n->getInternalTypeInfo(sc)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } diff -uNr dmd-0.115/dmd/src/dmd/mtype.h dmd-0.116/dmd/src/dmd/mtype.h --- dmd-0.115/dmd/src/dmd/mtype.h 2005-02-27 10:54:34.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/mtype.h 2005-02-28 21:11:54.000000000 +0100 @@ -162,6 +162,9 @@ static unsigned char impcnvType1[TMAX][TMAX]; static unsigned char impcnvType2[TMAX][TMAX]; + // If !=0, give warning on implicit conversion + static unsigned char impcnvWarn[TMAX][TMAX]; + Type(TY ty, Type *next); virtual Type *syntaxCopy(); int equals(Object *o); diff -uNr dmd-0.115/dmd/src/dmd/parse.c dmd-0.116/dmd/src/dmd/parse.c --- dmd-0.115/dmd/src/dmd/parse.c 2004-12-16 15:14:28.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/parse.c 2005-03-07 12:24:44.000000000 +0100 @@ -77,6 +77,7 @@ md = NULL; linkage = LINKd; endloc = 0; + inBrackets = 0; nextToken(); // start up the scanner } @@ -3419,6 +3420,13 @@ e = new IdentifierExp(loc, id); break; + case TOKdollar: + if (!inBrackets) + error("'$' is valid only inside [] of index or slice"); + e = new DollarExp(loc); + nextToken(); + break; + case TOKdot: // Signal global scope '.' operator with "" identifier e = new IdentifierExp(loc, Id::empty); @@ -3706,6 +3714,7 @@ Expression *index; Expression *upr; + inBrackets++; nextToken(); if (token.value == TOKrbracket) { // array[] @@ -3741,6 +3750,7 @@ e = new ArrayExp(loc, e, arguments); } check(TOKrbracket); + inBrackets--; } continue; } diff -uNr dmd-0.115/dmd/src/dmd/parse.h dmd-0.116/dmd/src/dmd/parse.h --- dmd-0.115/dmd/src/dmd/parse.h 2004-06-11 17:52:02.000000000 +0200 +++ dmd-0.116/dmd/src/dmd/parse.h 2005-03-07 12:21:44.000000000 +0100 @@ -45,6 +45,7 @@ ModuleDeclaration *md; enum LINK linkage; Loc endloc; // set to location of last right curly + int inBrackets; // inside [] of array index or slice Parser(Module *module, unsigned char *base, unsigned length); diff -uNr dmd-0.115/dmd/src/dmd/scope.c dmd-0.116/dmd/src/dmd/scope.c --- dmd-0.115/dmd/src/dmd/scope.c 2004-12-02 19:35:46.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/scope.c 2005-03-05 09:25:02.000000000 +0100 @@ -93,15 +93,20 @@ Scope *Scope::createGlobal(Module *module) { Scope *sc; - Dsymbol *p = module->parent; sc = new Scope(); sc->module = module; sc->scopesym = new ScopeDsymbol(); sc->scopesym->symtab = new DsymbolTable(); - module->addMember(sc->scopesym); - module->parent = p; // got changed by addMember() + // Add top level package as member of this global scope + Dsymbol *m = module; + while (m->parent) + m = m->parent; + m->addMember(sc->scopesym); + m->parent = NULL; // got changed by addMember() + + // Create the module scope underneath the global scope sc = sc->push(module); sc->parent = module; return sc; @@ -203,6 +208,16 @@ s = sc->scopesym->search(ident, 0); if (s) { + if (global.params.warnings && + ident == Id::length && + sc->scopesym->isArrayScopeSymbol() && + sc->enclosing && + sc->enclosing->search(ident, NULL)) + { + printf("warning - "); + error("array 'length' hides other 'length' name in outer scope"); + } + //printf("\tfound %s.%s, kind = '%s'\n", s->parent ? s->parent->toChars() : "", s->toChars(), s->kind()); if (pscopesym) *pscopesym = sc->scopesym; diff -uNr dmd-0.115/dmd/src/dmd/statement.c dmd-0.116/dmd/src/dmd/statement.c --- dmd-0.115/dmd/src/dmd/statement.c 2005-02-27 20:07:08.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/statement.c 2005-03-05 15:51:12.000000000 +0100 @@ -115,6 +115,20 @@ return FALSE; } +// TRUE if statement may fall off the end without a throw or return + +int Statement::fallOffEnd() +{ + return TRUE; +} + +// TRUE if statement 'comes from' somewhere else, like a goto + +int Statement::comeFrom() +{ + return FALSE; +} + /**************************************** * If this statement has code that needs to run in a finally clause * at the end of the current scope, return that code in the form of @@ -169,6 +183,17 @@ return this; } +int ExpStatement::fallOffEnd() +{ + if (exp && exp->op == TOKassert) + { AssertExp *a = (AssertExp *)exp; + + if (a->e1->isBool(FALSE)) // if it's an assert(0) + return FALSE; + } + return TRUE; +} + /******************************** DeclarationStatement ***************************/ DeclarationStatement::DeclarationStatement(Loc loc, Dsymbol *declaration) @@ -338,6 +363,26 @@ return FALSE; } +int CompoundStatement::fallOffEnd() +{ int falloff = TRUE; + + //printf("CompoundStatement::fallOffEnd()\n"); + for (int i = 0; i < statements->dim; i++) + { Statement *s = (Statement *)statements->data[i]; + + if (!s) + continue; + + if (!falloff && global.params.warnings && !s->comeFrom()) + { + printf("warning - "); + s->error("statement is not reachable"); + } + falloff = s->fallOffEnd(); + } + return falloff; +} + /******************************** ScopeStatement ***************************/ @@ -391,6 +436,11 @@ return this; } +int ScopeStatement::fallOffEnd() +{ + return statement ? statement->fallOffEnd() : TRUE; +} + void ScopeStatement::toCBuffer(OutBuffer *buf) { buf->writeByte('{'); @@ -447,6 +497,12 @@ return body->usesEH(); } +int WhileStatement::fallOffEnd() +{ + body->fallOffEnd(); + return TRUE; +} + /******************************** DoStatement ***************************/ DoStatement::DoStatement(Loc loc, Statement *b, Expression *c) @@ -489,6 +545,12 @@ return body->usesEH(); } +int DoStatement::fallOffEnd() +{ + body->fallOffEnd(); + return TRUE; +} + /******************************** ForStatement ***************************/ ForStatement::ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body) @@ -557,6 +619,12 @@ return (init && init->usesEH()) || body->usesEH(); } +int ForStatement::fallOffEnd() +{ + body->fallOffEnd(); + return TRUE; +} + /******************************** ForeachStatement ***************************/ ForeachStatement::ForeachStatement(Loc loc, Array *arguments, @@ -897,6 +965,12 @@ return body->usesEH(); } +int ForeachStatement::fallOffEnd() +{ + body->fallOffEnd(); + return TRUE; +} + /******************************** IfStatement ***************************/ IfStatement::IfStatement(Loc loc, Expression *condition, Statement *ifbody, Statement *elsebody) @@ -964,6 +1038,15 @@ return (ifbody && ifbody->usesEH()) || (elsebody && elsebody->usesEH()); } +int IfStatement::fallOffEnd() +{ + if ((!ifbody || !ifbody->fallOffEnd()) && + (!elsebody || !elsebody->fallOffEnd())) + return FALSE; + return TRUE; +} + + void IfStatement::toCBuffer(OutBuffer *buf) { buf->printf("IfStatement::toCBuffer()"); @@ -1088,6 +1171,13 @@ return body && body->usesEH(); } +int PragmaStatement::fallOffEnd() +{ + if (body) + return body->fallOffEnd(); + return TRUE; +} + void PragmaStatement::toCBuffer(OutBuffer *buf) { buf->printf("PragmaStatement::toCBuffer()"); @@ -1193,18 +1283,27 @@ } } - if (!sc->sw->sdefault && global.params.useSwitchError) + if (!sc->sw->sdefault) { - Array *a = new Array(); - CompoundStatement *cs; - - a->reserve(4); - a->push(body); - a->push(new BreakStatement(loc, NULL)); - sc->sw->sdefault = new DefaultStatement(loc, new SwitchErrorStatement(loc)); - a->push(sc->sw->sdefault); - cs = new CompoundStatement(loc, a); - body = cs; + if (global.params.warnings) + { printf("warning - "); + error("switch statement has no default"); + } + + // Generate runtime error if the default is hit + if (global.params.useSwitchError) + { + Array *a = new Array(); + CompoundStatement *cs; + + a->reserve(4); + a->push(body); + a->push(new BreakStatement(loc, NULL)); + sc->sw->sdefault = new DefaultStatement(loc, new SwitchErrorStatement(loc)); + a->push(sc->sw->sdefault); + cs = new CompoundStatement(loc, a); + body = cs; + } } sc->pop(); @@ -1221,6 +1320,12 @@ return body->usesEH(); } +int SwitchStatement::fallOffEnd() +{ + body->fallOffEnd(); + return TRUE; +} + /******************************** CaseStatement ***************************/ CaseStatement::CaseStatement(Loc loc, Expression *exp, Statement *s) @@ -1296,6 +1401,16 @@ return statement->usesEH(); } +int CaseStatement::fallOffEnd() +{ + return statement->fallOffEnd(); +} + +int CaseStatement::comeFrom() +{ + return TRUE; +} + /******************************** DefaultStatement ***************************/ DefaultStatement::DefaultStatement(Loc loc, Statement *s) @@ -1329,6 +1444,16 @@ return statement->usesEH(); } +int DefaultStatement::fallOffEnd() +{ + return statement->fallOffEnd(); +} + +int DefaultStatement::comeFrom() +{ + return TRUE; +} + /******************************** GotoDefaultStatement ***************************/ GotoDefaultStatement::GotoDefaultStatement(Loc loc) @@ -1351,6 +1476,11 @@ return this; } +int GotoDefaultStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** GotoCaseStatement ***************************/ GotoCaseStatement::GotoCaseStatement(Loc loc, Expression *exp) @@ -1386,6 +1516,11 @@ return this; } +int GotoCaseStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** SwitchErrorStatement ***************************/ SwitchErrorStatement::SwitchErrorStatement(Loc loc) @@ -1393,6 +1528,11 @@ { } +int SwitchErrorStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** ReturnStatement ***************************/ ReturnStatement::ReturnStatement(Loc loc, Expression *exp) @@ -1510,7 +1650,8 @@ { exp = exp->semantic(sc); exp = resolveProperties(sc, exp); - exp = exp->implicitCastTo(tret); + if (tbret->ty != Tvoid) + exp = exp->implicitCastTo(tret); } } else if (tbret->ty != Tvoid) // if non-void return @@ -1547,6 +1688,11 @@ return this; } +int ReturnStatement::fallOffEnd() +{ + return FALSE; +} + void ReturnStatement::toCBuffer(OutBuffer *buf) { buf->printf("return "); @@ -1626,6 +1772,11 @@ return this; } +int BreakStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** ContinueStatement ***************************/ ContinueStatement::ContinueStatement(Loc loc, Identifier *ident) @@ -1696,6 +1847,11 @@ return this; } +int ContinueStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** SynchronizedStatement ***************************/ SynchronizedStatement::SynchronizedStatement(Loc loc, Expression *exp, Statement *body) @@ -1758,6 +1914,11 @@ return TRUE; } +int SynchronizedStatement::fallOffEnd() +{ + return body->fallOffEnd(); +} + /******************************** WithStatement ***************************/ WithStatement::WithStatement(Loc loc, Expression *exp, Statement *body) @@ -1835,6 +1996,11 @@ return body->usesEH(); } +int WithStatement::fallOffEnd() +{ + return body->fallOffEnd(); +} + /******************************** TryCatchStatement ***************************/ TryCatchStatement::TryCatchStatement(Loc loc, Statement *body, Array *catches) @@ -1882,6 +2048,17 @@ return TRUE; } +int TryCatchStatement::fallOffEnd() +{ + for (int i = 0; i < catches->dim; i++) + { Catch *c; + + c = (Catch *)catches->data[i]; + c->handler->fallOffEnd(); + } + return body->fallOffEnd(); +} + /******************************** Catch ***************************/ Catch::Catch(Loc loc, Type *t, Identifier *id, Statement *handler) @@ -1970,6 +2147,15 @@ return TRUE; } +int TryFinallyStatement::fallOffEnd() +{ int result; + + result = body->fallOffEnd(); + if (finalbody) + result = finalbody->fallOffEnd(); + return result; +} + /******************************** ThrowStatement ***************************/ ThrowStatement::ThrowStatement(Loc loc, Expression *exp) @@ -1996,6 +2182,11 @@ return this; } +int ThrowStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** VolatileStatement **************************/ VolatileStatement::VolatileStatement(Loc loc, Statement *statement) @@ -2033,6 +2224,11 @@ return a; } +int VolatileStatement::fallOffEnd() +{ + return statement->fallOffEnd(); +} + /******************************** GotoStatement ***************************/ @@ -2074,6 +2270,11 @@ return this; } +int GotoStatement::fallOffEnd() +{ + return FALSE; +} + /******************************** LabelStatement ***************************/ LabelStatement::LabelStatement(Loc loc, Identifier *ident, Statement *statement) @@ -2135,6 +2336,17 @@ return statement->usesEH(); } +int LabelStatement::fallOffEnd() +{ + return statement ? statement->fallOffEnd() : TRUE; +} + +int LabelStatement::comeFrom() +{ + return TRUE; +} + + /******************************** LabelDsymbol ***************************/ LabelDsymbol::LabelDsymbol(Identifier *ident) diff -uNr dmd-0.115/dmd/src/dmd/statement.h dmd-0.116/dmd/src/dmd/statement.h --- dmd-0.115/dmd/src/dmd/statement.h 2005-01-12 02:40:22.000000000 +0100 +++ dmd-0.116/dmd/src/dmd/statement.h 2005-03-01 02:08:46.000000000 +0100 @@ -61,6 +61,8 @@ virtual int hasBreak(); virtual int hasContinue(); virtual int usesEH(); + virtual int fallOffEnd(); + virtual int comeFrom(); virtual Statement *callAutoDtor(); virtual Array *flatten(); @@ -85,6 +87,7 @@ Statement *syntaxCopy(); void toCBuffer(OutBuffer *buf); Statement *semantic(Scope *sc); + int fallOffEnd(); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); @@ -117,6 +120,7 @@ void toCBuffer(OutBuffer *buf); Statement *semantic(Scope *sc); int usesEH(); + int fallOffEnd(); Array *flatten(); int inlineCost(InlineCostState *ics); @@ -151,6 +155,7 @@ Statement *syntaxCopy(); void toCBuffer(OutBuffer *buf); Statement *semantic(Scope *sc); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -168,6 +173,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -185,6 +191,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -204,6 +211,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -228,6 +236,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -245,6 +254,7 @@ Statement *semantic(Scope *sc); void toCBuffer(OutBuffer *buf); int usesEH(); + int fallOffEnd(); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); @@ -277,6 +287,7 @@ Statement *syntaxCopy(); Statement *semantic(Scope *sc); int usesEH(); + int fallOffEnd(); void toCBuffer(OutBuffer *buf); }; @@ -306,6 +317,7 @@ Statement *semantic(Scope *sc); int hasBreak(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -324,6 +336,8 @@ Statement *semantic(Scope *sc); int compare(Object *obj); int usesEH(); + int fallOffEnd(); + int comeFrom(); Statement *inlineScan(InlineScanState *iss); @@ -338,6 +352,8 @@ Statement *syntaxCopy(); Statement *semantic(Scope *sc); int usesEH(); + int fallOffEnd(); + int comeFrom(); Statement *inlineScan(InlineScanState *iss); @@ -351,6 +367,7 @@ GotoDefaultStatement(Loc loc); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -363,6 +380,7 @@ GotoCaseStatement(Loc loc, Expression *exp); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -370,6 +388,7 @@ struct SwitchErrorStatement : Statement { SwitchErrorStatement(Loc loc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -382,6 +401,7 @@ Statement *syntaxCopy(); void toCBuffer(OutBuffer *buf); Statement *semantic(Scope *sc); + int fallOffEnd(); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); @@ -399,6 +419,7 @@ BreakStatement(Loc loc, Identifier *ident); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -410,6 +431,7 @@ ContinueStatement(Loc loc, Identifier *ident); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -425,6 +447,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -445,6 +468,7 @@ Statement *semantic(Scope *sc); void toCBuffer(OutBuffer *buf); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -461,6 +485,7 @@ Statement *semantic(Scope *sc); int hasBreak(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -492,6 +517,7 @@ int hasBreak(); int hasContinue(); int usesEH(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -505,6 +531,7 @@ ThrowStatement(Loc loc, Expression *exp); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -519,6 +546,7 @@ Statement *syntaxCopy(); Statement *semantic(Scope *sc); Array *flatten(); + int fallOffEnd(); Statement *inlineScan(InlineScanState *iss); @@ -533,6 +561,7 @@ GotoStatement(Loc loc, Identifier *ident); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int fallOffEnd(); void toIR(IRState *irs); }; @@ -549,6 +578,8 @@ Statement *semantic(Scope *sc); Array *flatten(); int usesEH(); + int fallOffEnd(); + int comeFrom(); Statement *inlineScan(InlineScanState *iss); @@ -575,6 +606,7 @@ AsmStatement(Loc loc, Token *tokens); Statement *syntaxCopy(); Statement *semantic(Scope *sc); + int comeFrom(); void toCBuffer(OutBuffer *buf); diff -uNr dmd-0.115/dmd/src/dmd/unialpha.c dmd-0.116/dmd/src/dmd/unialpha.c --- dmd-0.115/dmd/src/dmd/unialpha.c 2003-10-07 11:29:32.000000000 +0200 +++ dmd-0.116/dmd/src/dmd/unialpha.c 2005-03-05 01:25:42.000000000 +0100 @@ -187,7 +187,7 @@ { 0x0D66, 0x0D6F }, { 0x0E01, 0x0E3A }, { 0x0E40, 0x0E5B }, - { 0x0E50, 0x0E59 }, +// { 0x0E50, 0x0E59 }, { 0x0E81, 0x0E82 }, { 0x0E84, 0x0E84 }, { 0x0E87, 0x0E88 }, @@ -272,6 +272,7 @@ #ifdef DEBUG for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++) { + //printf("%x\n", table[i][0]); assert(table[i][0] <= table[i][1]); if (i < sizeof(table) / sizeof(table[0]) - 1) assert(table[i][1] < table[i + 1][0]); diff -uNr dmd-0.115/dmd/src/phobos/internal/adi.d dmd-0.116/dmd/src/phobos/internal/adi.d --- dmd-0.115/dmd/src/phobos/internal/adi.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/internal/adi.d 2005-03-07 16:13:42.000000000 +0100 @@ -345,6 +345,61 @@ } +/********************************************** + * Support for array.sort property for bit[]. + */ + +extern (C) bit[] _adSortBit(bit[] a) + out (result) + { + assert(result is a); + } + body + { + if (a.length >= 2) + { + size_t lo, hi; + + lo = 0; + hi = a.length - 1; + while (1) + { + while (1) + { + if (lo >= hi) + goto Ldone; + if (a[lo] == true) + break; + lo++; + } + + while (1) + { + if (lo >= hi) + goto Ldone; + if (a[hi] == false) + break; + hi--; + } + + a[lo] = false; + a[hi] = true; + + lo++; + hi--; + } + Ldone: + ; + } + return a; + } + +unittest +{ + debug(adi) printf("array.sort_Bit[].unittest\n"); +} + + /********************************** * Support for array.dup property. */ diff -uNr dmd-0.115/dmd/src/phobos/linux.mak dmd-0.116/dmd/src/phobos/linux.mak --- dmd-0.115/dmd/src/phobos/linux.mak 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/linux.mak 2005-03-07 16:13:40.000000000 +0100 @@ -65,6 +65,8 @@ ti_Aa.o ti_AC.o ti_Ag.o ti_Aubyte.o ti_Aushort.o ti_Ashort.o \ ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o ti_bit.o \ ti_Aint.o ti_Auint.o ti_Along.o ti_Aulong.o ti_Awchar.o \ + ti_Afloat.o ti_Adouble.o ti_Areal.o \ + ti_Acfloat.o ti_Acdouble.o ti_Acreal.o \ date.o dateparse.o llmath.o math2.o Czlib.o Dzlib.o zip.o recls.o ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \ @@ -105,7 +107,7 @@ std/typeinfo/ti_short.d std/typeinfo/ti_ushort.d \ std/typeinfo/ti_byte.d std/typeinfo/ti_ubyte.d \ std/typeinfo/ti_long.d std/typeinfo/ti_ulong.d \ - std/typeinfo/ti_ptr.d \ + std/typeinfo/ti_ptr.d std/typeinfo/ti_bit.d \ std/typeinfo/ti_float.d std/typeinfo/ti_double.d \ std/typeinfo/ti_real.d std/typeinfo/ti_delegate.d \ std/typeinfo/ti_creal.d std/typeinfo/ti_ireal.d \ @@ -118,8 +120,11 @@ std/typeinfo/ti_int.d std/typeinfo/ti_char.d \ std/typeinfo/ti_Aint.d std/typeinfo/ti_Auint.d \ std/typeinfo/ti_Along.d std/typeinfo/ti_Aulong.d \ - std/typeinfo/ti_Awchar.d std/typeinfo/ti_dchar.d \ - std/typeinfo/ti_bit.d + std\typeinfo/ti_Afloat.d std\typeinfo/ti_Adouble.d \ + std\typeinfo/ti_Areal.d \ + std\typeinfo/ti_Acfloat.d std\typeinfo/ti_Acdouble.d \ + std\typeinfo/ti_Acreal.d \ + std/typeinfo/ti_Awchar.d std/typeinfo/ti_dchar.d SRC_INT= \ internal/switch.d internal/complex.c internal/critical.c \ @@ -684,6 +689,24 @@ ti_Along.o : std/typeinfo/ti_Along.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Along.d +ti_Afloat.o : std/typeinfo/ti_Afloat.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Afloat.d + +ti_Adouble.o : std/typeinfo/ti_Adouble.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Adouble.d + +ti_Areal.o : std/typeinfo/ti_Areal.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Areal.d + +ti_Acfloat.o : std/typeinfo/ti_Acfloat.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Acfloat.d + +ti_Acdouble.o : std/typeinfo/ti_Acdouble.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Acdouble.d + +ti_Acreal.o : std/typeinfo/ti_Acreal.d + $(DMD) -c $(DFLAGS) std/typeinfo/ti_Acreal.d + ti_Awchar.o : std/typeinfo/ti_Awchar.d $(DMD) -c $(DFLAGS) std/typeinfo/ti_Awchar.d diff -uNr dmd-0.115/dmd/src/phobos/std/c/windows/windows.d dmd-0.116/dmd/src/phobos/std/c/windows/windows.d --- dmd-0.115/dmd/src/phobos/std/c/windows/windows.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/c/windows/windows.d 2005-03-07 16:13:42.000000000 +0100 @@ -400,10 +400,10 @@ KEY_NOTIFY = 0x0010, KEY_CREATE_LINK = 0x0020, - KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & ~SYNCHRONIZE), - KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~SYNCHRONIZE), - KEY_EXECUTE = (KEY_READ & ~SYNCHRONIZE), - KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~SYNCHRONIZE), + KEY_READ = cast(int)((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & ~SYNCHRONIZE), + KEY_WRITE = cast(int)((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~SYNCHRONIZE), + KEY_EXECUTE = cast(int)(KEY_READ & ~SYNCHRONIZE), + KEY_ALL_ACCESS = cast(int)((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~SYNCHRONIZE), } // @@ -517,10 +517,10 @@ KEY_NOTIFY = (0x0010), KEY_CREATE_LINK = (0x0020), - KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE)), - KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE)), - KEY_EXECUTE = (KEY_READ & ~SYNCHRONIZE), - KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & (~SYNCHRONIZE)), + KEY_READ = cast(int)((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE)), + KEY_WRITE = cast(int)((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE)), + KEY_EXECUTE = cast(int)(KEY_READ & ~SYNCHRONIZE), + KEY_ALL_ACCESS = cast(int)((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & (~SYNCHRONIZE)), } enum @@ -608,7 +608,7 @@ SECTION_MAP_EXECUTE = 0x0008, SECTION_EXTEND_SIZE = 0x0010, - SECTION_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE), + SECTION_ALL_ACCESS = cast(int)(STANDARD_RIGHTS_REQUIRED|SECTION_QUERY| SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE | SECTION_EXTEND_SIZE), PAGE_NOACCESS = 0x01, PAGE_READONLY = 0x02, PAGE_READWRITE = 0x04, @@ -682,15 +682,13 @@ FILE_WRITE_ATTRIBUTES = ( 0x0100 ), // all - FILE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF), + FILE_ALL_ACCESS = cast(int)(STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF), - FILE_GENERIC_READ = (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE), + FILE_GENERIC_READ = cast(int)(STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE), + FILE_GENERIC_WRITE = cast(int)(STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE), - FILE_GENERIC_WRITE = (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE), - - - FILE_GENERIC_EXECUTE = (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE), + FILE_GENERIC_EXECUTE = cast(int)(STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE), } export diff -uNr dmd-0.115/dmd/src/phobos/std/date.d dmd-0.116/dmd/src/phobos/std/date.d --- dmd-0.115/dmd/src/phobos/std/date.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/date.d 2005-03-07 16:13:40.000000000 +0100 @@ -821,8 +821,8 @@ d_time t; - t = date.MakeDate(date.MakeDay(year, month, dayofmonth), - date.MakeTime(hour, minute, second, 0)); + t = std.date.MakeDate(std.date.MakeDay(year, month, dayofmonth), + std.date.MakeTime(hour, minute, second, 0)); assert(YearFromTime(t) == year); assert(MonthFromTime(t) == month); diff -uNr dmd-0.115/dmd/src/phobos/std/regexp.d dmd-0.116/dmd/src/phobos/std/regexp.d --- dmd-0.115/dmd/src/phobos/std/regexp.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/regexp.d 2005-03-07 16:13:40.000000000 +0100 @@ -48,6 +48,10 @@ [a-b], where a is greater than b, will produce an error. + + References: + + http://www.unicode.org/unicode/reports/tr18/ */ module std.regexp; diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acdouble.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acdouble.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acdouble.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_cdouble; + +// cdouble[] + +class TypeInfo_Ar : TypeInfo +{ + char[] toString() { return "cdouble[]"; } + + uint getHash(void *p) + { cdouble[] s = *cast(cdouble[]*)p; + uint len = s.length; + cdouble *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += (cast(uint *)str)[0]; + hash += (cast(uint *)str)[1]; + hash += (cast(uint *)str)[2]; + hash += (cast(uint *)str)[3]; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + cdouble[] s1 = *cast(cdouble[]*)p1; + cdouble[] s2 = *cast(cdouble[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_r._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + cdouble[] s1 = *cast(cdouble[]*)p1; + cdouble[] s2 = *cast(cdouble[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_r._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (cdouble[]).sizeof; + } +} + diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acfloat.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acfloat.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acfloat.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_cfloat; + +// cfloat[] + +class TypeInfo_Aq : TypeInfo +{ + char[] toString() { return "cfloat[]"; } + + uint getHash(void *p) + { cfloat[] s = *cast(cfloat[]*)p; + uint len = s.length; + cfloat *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += (cast(uint *)str)[0]; + hash += (cast(uint *)str)[1]; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + cfloat[] s1 = *cast(cfloat[]*)p1; + cfloat[] s2 = *cast(cfloat[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_q._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + cfloat[] s1 = *cast(cfloat[]*)p1; + cfloat[] s2 = *cast(cfloat[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_q._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (cfloat[]).sizeof; + } +} + diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acreal.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acreal.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Acreal.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Acreal.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_creal; + +// creal[] + +class TypeInfo_Ac : TypeInfo +{ + char[] toString() { return "creal[]"; } + + uint getHash(void *p) + { creal[] s = *cast(creal[]*)p; + uint len = s.length; + creal *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += (cast(uint *)str)[0]; + hash += (cast(uint *)str)[1]; + hash += (cast(uint *)str)[2]; + hash += (cast(uint *)str)[3]; + hash += (cast(uint *)str)[4]; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + creal[] s1 = *cast(creal[]*)p1; + creal[] s2 = *cast(creal[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_c._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + creal[] s1 = *cast(creal[]*)p1; + creal[] s2 = *cast(creal[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_c._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (creal[]).sizeof; + } +} + diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Adouble.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Adouble.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Adouble.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Adouble.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_double; + +// double[] + +class TypeInfo_Ad : TypeInfo +{ + char[] toString() { return "double[]"; } + + uint getHash(void *p) + { double[] s = *cast(double[]*)p; + uint len = s.length; + double *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += (cast(uint *)str)[0]; + hash += (cast(uint *)str)[1]; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + double[] s1 = *cast(double[]*)p1; + double[] s2 = *cast(double[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_d._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + double[] s1 = *cast(double[]*)p1; + double[] s2 = *cast(double[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_d._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (double[]).sizeof; + } +} + +// idouble[] + +class TypeInfo_Ap : TypeInfo_Ad +{ + char[] toString() { return "idouble[]"; } +} diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Afloat.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Afloat.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Afloat.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Afloat.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_float; + +// float[] + +class TypeInfo_Af : TypeInfo +{ + char[] toString() { return "float[]"; } + + uint getHash(void *p) + { float[] s = *cast(float[]*)p; + uint len = s.length; + float *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += *cast(uint *)str; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + float[] s1 = *cast(float[]*)p1; + float[] s2 = *cast(float[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_f._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + float[] s1 = *cast(float[]*)p1; + float[] s2 = *cast(float[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_f._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (float[]).sizeof; + } +} + +// ifloat[] + +class TypeInfo_Ao : TypeInfo_Af +{ + char[] toString() { return "ifloat[]"; } +} diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Areal.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Areal.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_Areal.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_Areal.d 2005-03-07 16:13:42.000000000 +0100 @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com + * Written by Walter Bright + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, in both source and binary form, subject to the following + * restrictions: + * + * o The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * o Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * o This notice may not be removed or altered from any source + * distribution. + */ + +private import std.string; +private import std.typeinfo.ti_real; + +// real[] + +class TypeInfo_Ae : TypeInfo +{ + char[] toString() { return "real[]"; } + + uint getHash(void *p) + { real[] s = *cast(real[]*)p; + uint len = s.length; + real *str = s; + uint hash = 0; + + while (len) + { + hash *= 9; + hash += (cast(uint *)str)[0]; + hash += (cast(uint *)str)[1]; + hash += (cast(ushort *)str)[4]; + str++; + len--; + } + + return hash; + } + + int equals(void *p1, void *p2) + { + real[] s1 = *cast(real[]*)p1; + real[] s2 = *cast(real[]*)p2; + uint len = s1.length; + + if (len != s2.length) + return 0; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_e._equals(s1[u], s2[u]); + if (c == 0) + return 0; + } + return 1; + } + + int compare(void *p1, void *p2) + { + real[] s1 = *cast(real[]*)p1; + real[] s2 = *cast(real[]*)p2; + uint len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + int c = TypeInfo_e._compare(s1[u], s2[u]); + if (c) + return c; + } + return cast(int)s1.length - cast(int)s2.length; + } + + int tsize() + { + return (real[]).sizeof; + } +} + +// ireal[] + +class TypeInfo_Aj : TypeInfo_Ae +{ + char[] toString() { return "ireal[]"; } +} diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_cdouble.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_cdouble.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_cdouble.d 2005-03-07 16:13:42.000000000 +0100 @@ -11,16 +11,24 @@ (cast(uint *)p)[2] + (cast(uint *)p)[3]; } + static int _equals(cdouble f1, cdouble f2) + { + return f1 == f2; + } + + static int _compare(cdouble f1, cdouble f2) + { + return f1 < f2 ? -1 : f1 > f2 ? 1 : 0; + } + int equals(void *p1, void *p2) { - return *cast(cdouble *)p1 == *cast(cdouble *)p2; + return _equals(*cast(cdouble *)p1, *cast(cdouble *)p2); } int compare(void *p1, void *p2) { - cdouble a = *cast(cdouble *) p1; - cdouble b = *cast(cdouble *) p2; - return a < b ? -1 : a > b ? 1 : 0; + return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_cfloat.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_cfloat.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_cfloat.d 2005-03-07 16:13:42.000000000 +0100 @@ -10,16 +10,24 @@ return (cast(uint *)p)[0] + (cast(uint *)p)[1]; } + static int _equals(cfloat f1, cfloat f2) + { + return f1 == f2; + } + + static int _compare(cfloat f1, cfloat f2) + { + return f1 < f2 ? -1 : f1 > f2 ? 1 : 0; + } + int equals(void *p1, void *p2) { - return *cast(cfloat *)p1 == *cast(cfloat *)p2; + return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); } int compare(void *p1, void *p2) { - cfloat a = *cast(cfloat *) p1; - cfloat b = *cast(cfloat *) p2; - return a < b ? -1 : a > b ? 1 : 0; + return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_creal.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_creal.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_creal.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_creal.d 2005-03-07 16:13:42.000000000 +0100 @@ -12,16 +12,24 @@ (cast(uint *)p)[4]; } + static int _equals(creal f1, creal f2) + { + return f1 == f2; + } + + static int _compare(creal f1, creal f2) + { + return f1 < f2 ? -1 : f1 > f2 ? 1 : 0; + } + int equals(void *p1, void *p2) { - return *cast(creal *)p1 == *cast(creal *)p2; + return _equals(*cast(creal *)p1, *cast(creal *)p2); } int compare(void *p1, void *p2) { - creal a = *cast(creal *) p1; - creal b = *cast(creal *) p2; - return a < b ? -1 : a > b ? 1 : 0; + return _compare(*cast(creal *)p1, *cast(creal *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_double.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_double.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_double.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_double.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,6 +1,8 @@ // double +private import std.math; + class TypeInfo_d : TypeInfo { char[] toString() { return "double"; } @@ -10,14 +12,34 @@ return (cast(uint *)p)[0] + (cast(uint *)p)[1]; } + static int _equals(double f1, double f2) + { + return f1 == f2 || + (isnan(f1) && isnan(f2)); + } + + static int _compare(double d1, double d2) + { + if (d1 !<>= d2) // if either are NaN + { + if (isnan(d1)) + { if (isnan(d2)) + return 0; + return -1; + } + return 1; + } + return (d1 < d2) ? -1 : 1; + } + int equals(void *p1, void *p2) { - return *cast(double *)p1 == *cast(double *)p2; + return _equals(*cast(double *)p1, *cast(double *)p2); } int compare(void *p1, void *p2) { - return cast(int)(*cast(double *)p1 - *cast(double *)p2); + return _compare(*cast(double *)p1, *cast(double *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_float.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_float.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_float.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_float.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,6 +1,8 @@ // float +private import std.math; + class TypeInfo_f : TypeInfo { char[] toString() { return "float"; } @@ -10,14 +12,34 @@ return *cast(uint *)p; } + static int _equals(float f1, float f2) + { + return f1 == f2 || + (isnan(f1) && isnan(f2)); + } + + static int _compare(float d1, float d2) + { + if (d1 !<>= d2) // if either are NaN + { + if (isnan(d1)) + { if (isnan(d2)) + return 0; + return -1; + } + return 1; + } + return (d1 < d2) ? -1 : 1; + } + int equals(void *p1, void *p2) { - return *cast(float *)p1 == *cast(float *)p2; + return _equals(*cast(float *)p1, *cast(float *)p2); } int compare(void *p1, void *p2) { - return cast(int)(*cast(float *)p1 - *cast(float *)p2); + return _compare(*cast(float *)p1, *cast(float *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_idouble.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_idouble.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_idouble.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_idouble.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,37 +1,10 @@ // idouble -class TypeInfo_p : TypeInfo +private import std.typeinfo.ti_double; + +class TypeInfo_p : TypeInfo_d { char[] toString() { return "idouble"; } - - uint getHash(void *p) - { - return (cast(uint *)p)[0] + (cast(uint *)p)[1]; - } - - int equals(void *p1, void *p2) - { - return *cast(idouble *)p1 == *cast(idouble *)p2; - } - - int compare(void *p1, void *p2) - { - return cast(int)(*cast(double *)p1 - *cast(double *)p2); - } - - int tsize() - { - return idouble.sizeof; - } - - void swap(void *p1, void *p2) - { - idouble t; - - t = *cast(idouble *)p1; - *cast(idouble *)p1 = *cast(idouble *)p2; - *cast(idouble *)p2 = t; - } } diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_ifloat.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_ifloat.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_ifloat.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_ifloat.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,37 +1,10 @@ // ifloat -class TypeInfo_o : TypeInfo +private import std.typeinfo.ti_float; + +class TypeInfo_o : TypeInfo_f { char[] toString() { return "ifloat"; } - - uint getHash(void *p) - { - return *cast(uint *)p; - } - - int equals(void *p1, void *p2) - { - return *cast(ifloat *)p1 == *cast(ifloat *)p2; - } - - int compare(void *p1, void *p2) - { - return cast(int)(*cast(float *)p1 - *cast(float *)p2); - } - - int tsize() - { - return ifloat.sizeof; - } - - void swap(void *p1, void *p2) - { - ifloat t; - - t = *cast(ifloat *)p1; - *cast(ifloat *)p1 = *cast(ifloat *)p2; - *cast(ifloat *)p2 = t; - } } diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_ireal.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_ireal.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_ireal.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_ireal.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,37 +1,10 @@ // ireal -class TypeInfo_j : TypeInfo +private import std.typeinfo.ti_real; + +class TypeInfo_j : TypeInfo_e { char[] toString() { return "ireal"; } - - uint getHash(void *p) - { - return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; - } - - int equals(void *p1, void *p2) - { - return *cast(ireal *)p1 == *cast(ireal *)p2; - } - - int compare(void *p1, void *p2) - { - return cast(int)(*cast(real *)p1 - *cast(real *)p2); - } - - int tsize() - { - return ireal.sizeof; - } - - void swap(void *p1, void *p2) - { - ireal t; - - t = *cast(ireal *)p1; - *cast(ireal *)p1 = *cast(ireal *)p2; - *cast(ireal *)p2 = t; - } } diff -uNr dmd-0.115/dmd/src/phobos/std/typeinfo/ti_real.d dmd-0.116/dmd/src/phobos/std/typeinfo/ti_real.d --- dmd-0.115/dmd/src/phobos/std/typeinfo/ti_real.d 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/std/typeinfo/ti_real.d 2005-03-07 16:13:42.000000000 +0100 @@ -1,6 +1,8 @@ // real +private import std.math; + class TypeInfo_e : TypeInfo { char[] toString() { return "real"; } @@ -10,14 +12,34 @@ return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; } + static int _equals(real f1, real f2) + { + return f1 == f2 || + (isnan(f1) && isnan(f2)); + } + + static int _compare(real d1, real d2) + { + if (d1 !<>= d2) // if either are NaN + { + if (isnan(d1)) + { if (isnan(d2)) + return 0; + return -1; + } + return 1; + } + return (d1 < d2) ? -1 : 1; + } + int equals(void *p1, void *p2) { - return *cast(real *)p1 == *cast(real *)p2; + return _equals(*cast(real *)p1, *cast(real *)p2); } int compare(void *p1, void *p2) { - return cast(int)(*cast(real *)p1 - *cast(real *)p2); + return _compare(*cast(real *)p1, *cast(real *)p2); } int tsize() diff -uNr dmd-0.115/dmd/src/phobos/win32.mak dmd-0.116/dmd/src/phobos/win32.mak --- dmd-0.115/dmd/src/phobos/win32.mak 2005-02-28 18:53:06.000000000 +0100 +++ dmd-0.116/dmd/src/phobos/win32.mak 2005-03-07 16:13:40.000000000 +0100 @@ -74,6 +74,8 @@ ti_cdouble.obj ti_idouble.obj \ ti_AC.obj ti_Aubyte.obj ti_Aushort.obj ti_Ashort.obj \ ti_Aint.obj ti_Auint.obj ti_Along.obj ti_Aulong.obj ti_Awchar.obj \ + ti_Afloat.obj ti_Adouble.obj ti_Areal.obj \ + ti_Acfloat.obj ti_Acdouble.obj ti_Acreal.obj \ ti_dchar.obj ti_Adchar.obj ti_bit.obj @@ -110,6 +112,10 @@ std\typeinfo\ti_int.d std\typeinfo\ti_char.d \ std\typeinfo\ti_Aint.d std\typeinfo\ti_Auint.d \ std\typeinfo\ti_Along.d std\typeinfo\ti_Aulong.d \ + std\typeinfo\ti_Afloat.d std\typeinfo\ti_Adouble.d \ + std\typeinfo\ti_Areal.d \ + std\typeinfo\ti_Acfloat.d std\typeinfo\ti_Acdouble.d \ + std\typeinfo\ti_Acreal.d \ std\typeinfo\ti_Awchar.d std\typeinfo\ti_dchar.d SRC_INT= \ @@ -666,6 +672,24 @@ ti_Along.obj : std\typeinfo\ti_Along.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Along.d +ti_Afloat.obj : std\typeinfo\ti_Afloat.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Afloat.d + +ti_Adouble.obj : std\typeinfo\ti_Adouble.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Adouble.d + +ti_Areal.obj : std\typeinfo\ti_Areal.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Areal.d + +ti_Acfloat.obj : std\typeinfo\ti_Acfloat.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Acfloat.d + +ti_Acdouble.obj : std\typeinfo\ti_Acdouble.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Acdouble.d + +ti_Acreal.obj : std\typeinfo\ti_Acreal.d + $(DMD) -c $(DFLAGS) std\typeinfo\ti_Acreal.d + ti_Awchar.obj : std\typeinfo\ti_Awchar.d $(DMD) -c $(DFLAGS) std\typeinfo\ti_Awchar.d