diff -uNr dmd-0.147/dmd/src/dmd/aggregate.h dmd-0.148/dmd/src/dmd/aggregate.h --- dmd-0.147/dmd/src/dmd/aggregate.h 2006-02-11 17:34:52.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/aggregate.h 2006-02-21 21:53:28.000000000 +0100 @@ -101,8 +101,6 @@ struct StructDeclaration : AggregateDeclaration { - static StructDeclaration *match; // set to object._Match - int zeroInit; // !=0 if initialize with 0 fill StructDeclaration(Loc loc, Identifier *id); diff -uNr dmd-0.147/dmd/src/dmd/cast.c dmd-0.148/dmd/src/dmd/cast.c --- dmd-0.147/dmd/src/dmd/cast.c 2006-02-09 15:20:32.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/cast.c 2006-02-22 09:48:16.000000000 +0100 @@ -103,6 +103,7 @@ switch (ty) { case Tbit: + case Tbool: value &= 1; ty = Tint32; break; @@ -148,6 +149,7 @@ switch (toty) { case Tbit: + case Tbool: if (value & ~1) goto Lno; goto Lyes; @@ -1119,6 +1121,7 @@ case Tint16: case Tuns16: case Tbit: + case Tbool: case Tchar: case Twchar: e = e->castTo(Type::tint32); diff -uNr dmd-0.147/dmd/src/dmd/constfold.c dmd-0.148/dmd/src/dmd/constfold.c --- dmd-0.147/dmd/src/dmd/constfold.c 2006-02-10 23:57:44.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/constfold.c 2006-02-24 00:30:44.000000000 +0100 @@ -126,7 +126,7 @@ } Type *tb = to->toBasetype(); - if (tb->ty == Tbit) + if (tb->ty == Tbit || tb->ty == Tbool) return new IntegerExp(loc, e1->toInteger() != 0, type); if (type->isintegral()) { diff -uNr dmd-0.147/dmd/src/dmd/declaration.c dmd-0.148/dmd/src/dmd/declaration.c --- dmd-0.147/dmd/src/dmd/declaration.c 2006-02-15 01:51:48.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/declaration.c 2006-02-20 13:02:02.000000000 +0100 @@ -505,7 +505,9 @@ */ int inferred = 0; if (!type) - { type = init->inferType(sc); + { inuse++; + type = init->inferType(sc); + inuse--; inferred = 1; /* This is a kludge to support the existing syntax for RAII @@ -707,9 +709,9 @@ global.gag++; //printf("+gag\n"); Expression *e = ei->exp->syntaxCopy(); - inuse = 1; + inuse++; e = e->semantic(sc); - inuse = 0; + inuse--; e = e->implicitCastTo(type); global.gag--; //printf("-gag\n"); @@ -751,7 +753,7 @@ { //printf("VarDeclaration::semantic2('%s')\n", toChars()); if (init && !sc->parent->isFuncDeclaration()) - { inuse = 1; + { inuse++; #if 0 ExpInitializer *ei = init->isExpInitializer(); if (ei) @@ -761,7 +763,7 @@ } #endif init = init->semantic(sc, type); - inuse = 0; + inuse--; } } diff -uNr dmd-0.147/dmd/src/dmd/expression.c dmd-0.148/dmd/src/dmd/expression.c --- dmd-0.147/dmd/src/dmd/expression.c 2006-02-14 23:16:56.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/expression.c 2006-02-25 10:44:00.000000000 +0100 @@ -119,7 +119,7 @@ precedence[TOKneg] = PREC_unary; precedence[TOKuadd] = PREC_unary; precedence[TOKnot] = PREC_unary; - precedence[TOKbool] = PREC_add; + precedence[TOKtobool] = PREC_add; precedence[TOKtilde] = PREC_unary; precedence[TOKdelete] = PREC_unary; precedence[TOKnew] = PREC_unary; @@ -930,7 +930,8 @@ { switch (t->ty) { - case Tbit: value = (value != 0); break; + case Tbit: + case Tbool: value = (value != 0); break; case Tint8: value = (d_int8) value; break; case Tchar: case Tuns8: value = (d_uns8) value; break; @@ -1099,6 +1100,7 @@ break; case Tbit: + case Tbool: buf->writestring((char *)(v ? "true" : "false")); break; @@ -1134,19 +1136,33 @@ { static char buffer[sizeof(value) * 3 + 8 + 1 + 1]; +#ifdef IN_GCC + value.format(buffer, sizeof(buffer)); + if (type->isimaginary()) + strcat(buffer, "i"); +#else sprintf(buffer, type->isimaginary() ? "%Lgi" : "%Lg", value); +#endif assert(strlen(buffer) < sizeof(buffer)); return buffer; } integer_t RealExp::toInteger() { +#ifdef IN_GCC + return toReal().toInt(); +#else return (sinteger_t) toReal(); +#endif } uinteger_t RealExp::toUInteger() { +#ifdef IN_GCC + return (uinteger_t) toReal().toInt(); +#else return (uinteger_t) toReal(); +#endif } real_t RealExp::toReal() @@ -1190,8 +1206,12 @@ int RealExp::isBool(int result) { +#ifdef IN_GCC + return result ? (! value.isZero()) : (value.isZero()); +#else return result ? (value != 0) : (value == 0); +#endif } void floatToBuffer(OutBuffer *buf, Type *type, real_t value) @@ -1250,6 +1270,11 @@ void RealExp::toMangleBuffer(OutBuffer *buf) { unsigned char *p = (unsigned char *)&value; +#ifdef IN_GCC + unsigned char buffer[32]; + value.toBytes(buffer, sizeof(buffer)); + p = buffer; +#endif buf->writeByte('e'); for (int i = 0; i < REALSIZE-REALPAD; i++) buf->printf("%02x", p[i]); @@ -1270,19 +1295,35 @@ { static char buffer[sizeof(value) * 3 + 8 + 1]; +#ifdef IN_GCC + char buf1[sizeof(value) * 3 + 8 + 1]; + char buf2[sizeof(value) * 3 + 8 + 1]; + creall(value).format(buf1, sizeof(buf1)); + cimagl(value).format(buf2, sizeof(buf2)); + sprintf(buffer, "(%s+%si)", buf1, buf2); +#else sprintf(buffer, "(%Lg+%Lgi)", creall(value), cimagl(value)); assert(strlen(buffer) < sizeof(buffer)); +#endif return buffer; } integer_t ComplexExp::toInteger() { +#ifdef IN_GCC + return (sinteger_t) toReal().toInt(); +#else return (sinteger_t) toReal(); +#endif } uinteger_t ComplexExp::toUInteger() { +#ifdef IN_GCC + return (uinteger_t) toReal().toInt(); +#else return (uinteger_t) toReal(); +#endif } real_t ComplexExp::toReal() @@ -1333,11 +1374,19 @@ /* Print as: * (re+imi) */ +#ifdef IN_GCC + char buf1[sizeof(value) * 3 + 8 + 1]; + char buf2[sizeof(value) * 3 + 8 + 1]; + creall(value).format(buf1, sizeof(buf1)); + cimagl(value).format(buf2, sizeof(buf2)); + buf->printf("(%s+%si)", buf1, buf2); +#else buf->writeByte('('); floatToBuffer(buf, type, creall(value)); buf->writeByte('+'); floatToBuffer(buf, type, cimagl(value)); buf->writestring("i)"); +#endif } void ComplexExp::toMangleBuffer(OutBuffer *buf) @@ -3364,6 +3413,12 @@ if (v) { //printf("DotIdExp:: Identifier '%s' is a variable, type '%s'\n", toChars(), v->type->toChars()); + if (v->inuse) + { + error("circular reference to '%s'", v->toChars()); + type = Type::tint32; + return this; + } type = v->type; if (v->isConst()) { @@ -4401,7 +4456,7 @@ /************************************************************/ BoolExp::BoolExp(Loc loc, Expression *e, Type *t) - : UnaExp(loc, TOKbool, sizeof(BoolExp), e) + : UnaExp(loc, TOKtobool, sizeof(BoolExp), e) { type = t; } @@ -5254,7 +5309,7 @@ e1->checkScalar(); if (tb1->ty == Tpointer && tb2->isintegral()) e = scaleFactor(); - else if (tb1->ty == Tbit) + else if (tb1->ty == Tbit || tb1->ty == Tbool) { #if 0 // Need to rethink this @@ -6423,7 +6478,7 @@ if (ve1->var == ve2->var /*|| ve1->var->toSymbol() == ve2->var->toSymbol()*/) { // They are the same, result is 'true' - e = new IntegerExp(loc, 1, Type::tbit); + e = new IntegerExp(loc, 1, Type::tboolean); return e; } } @@ -6504,62 +6559,6 @@ } -/************************************************************/ - -MatchExp::MatchExp(enum TOK op, Loc loc, Expression *e1, Expression *e2) - : BinExp(loc, op, sizeof(MatchExp), e1, e2) -{ - assert(op == TOKmatch || op == TOKnotmatch); -} - -Expression *MatchExp::semantic(Scope *sc) -{ Expression *e; - - if (type) - return this; - - BinExp::semanticp(sc); - - e = op_overload(sc); - if (e) - { - if (op == TOKnotmatch) - { - e = new NotExp(e->loc, e); - e = e->semantic(sc); - } - return e; - } - - // Both operands must be of type char[] - Type *t = Type::tchar->arrayOf(); - e1 = e1->implicitCastTo(t); - e2 = e2->implicitCastTo(t); - - // Call the internal function void* _d_match(e1, e2) - FuncDeclaration *fdmatch = FuncDeclaration::genCfunc(StructDeclaration::match->type->pointerTo(), "_d_match"); - - Expression *ec = new VarExp(0, fdmatch); - Array *args = new Array(); - args->push(e1); - args->push(e2); - e = new CallExp(loc, ec, args); - e->type = fdmatch->type->next; // don't run semantic() on e - - if (op == TOKnotmatch) - { - e = new NotExp(e->loc, e); - e = e->semantic(sc); - } - return e; -} - -int MatchExp::isBit() -{ - return FALSE; -} - - /****************************************************************/ CondExp::CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2) diff -uNr dmd-0.147/dmd/src/dmd/expression.h dmd-0.148/dmd/src/dmd/expression.h --- dmd-0.147/dmd/src/dmd/expression.h 2006-02-15 13:48:22.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/expression.h 2006-02-19 01:32:18.000000000 +0100 @@ -39,14 +39,20 @@ // Back end struct IRState; -struct elem; struct dt_t; +#ifdef IN_GCC +union tree_node; typedef union tree_node elem; +#else +struct elem; +#endif + void initPrecedence(); Expression *resolveProperties(Scope *sc, Expression *e); void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d); FuncDeclaration *search_function(AggregateDeclaration *ad, Identifier *funcid); +void inferApplyArgTypes(Array *arguments, Type *taggr); struct Expression : Object { @@ -1193,20 +1199,6 @@ elem *toElem(IRState *irs); }; -// ~~ and !~ - -struct MatchExp : BinExp -{ - MatchExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); - Expression *semantic(Scope *sc); - int isBit(); - - // For operator overloading - Identifier *opId(); - - elem *toElem(IRState *irs); -}; - /****************************************************************/ struct CondExp : BinExp diff -uNr dmd-0.147/dmd/src/dmd/func.c dmd-0.148/dmd/src/dmd/func.c --- dmd-0.147/dmd/src/dmd/func.c 2006-02-09 14:44:36.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/func.c 2006-02-20 20:06:28.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -25,6 +25,10 @@ #include "template.h" #include "hdrgen.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + /********************************* FuncDeclaration ****************************/ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type) @@ -44,6 +48,9 @@ localsymtab = NULL; vthis = NULL; v_arguments = NULL; +#if IN_GCC + v_argptr = NULL; +#endif parameters = NULL; labtab = NULL; overnext = NULL; @@ -128,6 +135,13 @@ } #endif +#ifdef IN_GCC + AggregateDeclaration *ad; + + ad = parent->isAggregateDeclaration(); + if (ad) + ad->methods.push(this); +#endif sd = parent->isStructDeclaration(); if (sd) { @@ -460,7 +474,11 @@ } if (f->linkage == LINKd || (parameters && parameters->dim)) { // Declare _argptr +#if IN_GCC + t = d_gcc_builtin_va_list_d_type; +#else t = Type::tvoid->pointerTo(); +#endif argptr = new VarDeclaration(0, t, Id::_argptr, NULL); argptr->semantic(sc2); sc2->insert(argptr); @@ -702,7 +720,7 @@ { Expression *e; if (global.params.warnings) - { printf("warning - "); + { fprintf(stdmsg, "warning - "); error("no return at end of function"); } @@ -745,6 +763,11 @@ if (argptr) { // Initialize _argptr to point past non-variadic arg +#if IN_GCC + // Handled in FuncDeclaration::toObjFile + v_argptr = argptr; + v_argptr->init = new VoidInitializer(loc); +#else Expression *e1; Expression *e; Type *t = argptr->type; @@ -762,6 +785,7 @@ e = new AssignExp(0, e1, e); e->type = t; a->push(new ExpStatement(0, e)); +#endif } // Merge contracts together with body into one compound statement @@ -1701,7 +1725,11 @@ if (!m) m = sc->module; if (m) - m->needmoduleinfo = 1; + { m->needmoduleinfo = 1; +#ifdef IN_GCC + m->strictlyneedmoduleinfo = 1; +#endif + } } AggregateDeclaration *StaticCtorDeclaration::isThis() @@ -1772,7 +1800,11 @@ if (!m) m = sc->module; if (m) - m->needmoduleinfo = 1; + { m->needmoduleinfo = 1; +#ifdef IN_GCC + m->strictlyneedmoduleinfo = 1; +#endif + } } AggregateDeclaration *StaticDtorDeclaration::isThis() diff -uNr dmd-0.147/dmd/src/dmd/impcnvgen.c dmd-0.148/dmd/src/dmd/impcnvgen.c --- dmd-0.147/dmd/src/dmd/impcnvgen.c 2005-02-28 22:42:28.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/impcnvgen.c 2006-02-22 09:52:16.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -24,6 +24,7 @@ case Tchar: case Twchar: case Tbit: + case Tbool: case Tint8: case Tuns8: case Tint16: @@ -74,6 +75,28 @@ /* ======================= */ + X(Tbool,Tbool, Tbool,Tbool, Tbool) + X(Tbool,Tint8, Tint32,Tint32, Tint32) + X(Tbool,Tuns8, Tint32,Tint32, Tint32) + X(Tbool,Tint16, Tint32,Tint32, Tint32) + X(Tbool,Tuns16, Tint32,Tint32, Tint32) + X(Tbool,Tint32, Tint32,Tint32, Tint32) + X(Tbool,Tuns32, Tuns32,Tuns32, Tuns32) + X(Tbool,Tint64, Tint64,Tint64, Tint64) + X(Tbool,Tuns64, Tuns64,Tuns64, Tuns64) + + X(Tbool,Tfloat32, Tfloat32,Tfloat32, Tfloat32) + X(Tbool,Tfloat64, Tfloat64,Tfloat64, Tfloat64) + X(Tbool,Tfloat80, Tfloat80,Tfloat80, Tfloat80) + X(Tbool,Timaginary32, Tfloat32,Timaginary32, Tfloat32) + X(Tbool,Timaginary64, Tfloat64,Timaginary64, Tfloat64) + X(Tbool,Timaginary80, Tfloat80,Timaginary80, Tfloat80) + X(Tbool,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32) + X(Tbool,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64) + X(Tbool,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80) + + /* ======================= */ + X(Tint8,Tint8, Tint32,Tint32, Tint32) X(Tint8,Tuns8, Tint32,Tint32, Tint32) X(Tint8,Tint16, Tint32,Tint32, Tint32) diff -uNr dmd-0.147/dmd/src/dmd/lexer.c dmd-0.148/dmd/src/dmd/lexer.c --- dmd-0.147/dmd/src/dmd/lexer.c 2006-02-14 23:12:42.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/lexer.c 2006-02-22 23:42:12.000000000 +0100 @@ -19,6 +19,13 @@ #include #include +#ifdef IN_GCC + +#include +#include "mem.h" + +#else + #if __GNUC__ #include extern "C" long double strtold(const char *p,char **endp); @@ -26,10 +33,9 @@ #if _WIN32 #include "..\root\mem.h" -#elif linux -#include "../root/mem.h" #else -#error "fix this" +#include "../root/mem.h" +#endif #endif #include "stringtable.h" @@ -111,14 +117,22 @@ switch (value) { case TOKint32v: +#if IN_GCC + sprintf(buffer,"%ld",(d_int32)int64value); +#else sprintf(buffer,"%ld",int32value); +#endif break; case TOKuns32v: case TOKcharv: case TOKwcharv: case TOKdcharv: +#if IN_GCC + sprintf(buffer,"%luU",(d_uns32)uns64value); +#else sprintf(buffer,"%luU",uns32value); +#endif break; case TOKint64v: @@ -129,6 +143,20 @@ sprintf(buffer,"%lluUL",uns64value); break; +#if IN_GCC + case TOKfloat32v: + case TOKfloat64v: + case TOKfloat80v: + float80value.format(buffer, sizeof(buffer)); + break; + case TOKimaginary32v: + case TOKimaginary64v: + case TOKimaginary80v: + float80value.format(buffer, sizeof(buffer)); + // %% buffer + strcat(buffer, "i"); + break; +#else case TOKfloat32v: sprintf(buffer,"%Lgf", float80value); break; @@ -152,7 +180,7 @@ case TOKimaginary80v: sprintf(buffer,"%gLi", float80value); break; - +#endif case TOKstring: #if CSTRINGS @@ -280,7 +308,7 @@ } break; } - loc.linnum = 1; + loc.linnum = 2; } } @@ -933,10 +961,6 @@ else t->value = TOKule; // !> } - else if (*p == '~') - { p++; - t->value = TOKnotmatch; // !~ - } else t->value = TOKnot; // ! return; @@ -962,10 +986,6 @@ { p++; t->value = TOKcatass; // ~= } - else if (*p == '~') - { p++; - t->value = TOKmatch; // ~~ - } else t->value = TOKtilde; // ~ return; @@ -2418,8 +2438,9 @@ { "double", TOKfloat64 }, { "real", TOKfloat80 }, - { "bit", TOKbit }, - { "char", TOKchar }, +/* { "bit", TOKbit }, */ + { "bool", TOKbool }, + { "char", TOKchar }, { "wchar", TOKwchar }, { "dchar", TOKdchar }, @@ -2601,8 +2622,6 @@ Token::tochars[TOKcall] = "call"; Token::tochars[TOKidentity] = "is"; Token::tochars[TOKnotidentity] = "!is"; - Token::tochars[TOKmatch] = "~~"; - Token::tochars[TOKnotmatch] = "!~"; Token::tochars[TOKorass] = "|="; diff -uNr dmd-0.147/dmd/src/dmd/lexer.h dmd-0.148/dmd/src/dmd/lexer.h --- dmd-0.147/dmd/src/dmd/lexer.h 2006-02-14 23:14:00.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/lexer.h 2006-02-20 20:34:46.000000000 +0100 @@ -1,6 +1,6 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -35,7 +35,6 @@ ++ -- . -> : , ? && || - ~~ !~ */ enum TOK @@ -73,9 +72,8 @@ TOKle, TOKge, TOKequal, TOKnotequal, TOKidentity, TOKnotidentity, - TOKmatch, TOKnotmatch, TOKindex, TOKis, - TOKbool, + TOKtobool, // NCEG floating point compares // !<>= <> <>= !> !>= !< !<= !<> @@ -118,7 +116,7 @@ TOKfloat32, TOKfloat64, TOKfloat80, TOKimaginary32, TOKimaginary64, TOKimaginary80, TOKcomplex32, TOKcomplex64, TOKcomplex80, - TOKchar, TOKwchar, TOKdchar, TOKbit, + TOKchar, TOKwchar, TOKdchar, TOKbit, TOKbool, TOKcent, TOKucent, // Aggregates @@ -149,7 +147,7 @@ #define CASE_BASIC_TYPES \ case TOKwchar: case TOKdchar: \ - case TOKbit: case TOKchar: \ + case TOKbit: case TOKbool: case TOKchar: \ case TOKint8: case TOKuns8: \ case TOKint16: case TOKuns16: \ case TOKint32: case TOKuns32: \ @@ -179,6 +177,7 @@ case TOKcomplex64: t = Type::tcomplex64; goto LabelX; \ case TOKcomplex80: t = Type::tcomplex80; goto LabelX; \ case TOKbit: t = Type::tbit; goto LabelX; \ + case TOKbool: t = Type::tbool; goto LabelX; \ case TOKchar: t = Type::tchar; goto LabelX; \ case TOKwchar: t = Type::twchar; goto LabelX; \ case TOKdchar: t = Type::tdchar; goto LabelX; \ diff -uNr dmd-0.147/dmd/src/dmd/mars.c dmd-0.148/dmd/src/dmd/mars.c --- dmd-0.147/dmd/src/dmd/mars.c 2006-02-10 17:13:48.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/mars.c 2006-02-23 00:00:58.000000000 +0100 @@ -53,7 +53,7 @@ copyright = "Copyright (c) 1999-2006 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.147"; + version = "v0.148"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -219,6 +219,7 @@ #endif /* linux */ VersionCondition::addPredefinedGlobalIdent("X86"); VersionCondition::addPredefinedGlobalIdent("LittleEndian"); + //VersionCondition::addPredefinedGlobalIdent("D_Bits"); VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); VersionCondition::addPredefinedGlobalIdent("all"); diff -uNr dmd-0.147/dmd/src/dmd/mars.h dmd-0.148/dmd/src/dmd/mars.h --- dmd-0.147/dmd/src/dmd/mars.h 2006-02-14 22:56:14.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/mars.h 2006-02-20 20:18:26.000000000 +0100 @@ -69,6 +69,8 @@ unsigned versionlevel; // version level Array *versionids; // version identifiers + bool dump_source; + // Hidden debug switches char debuga; char debugb; @@ -122,10 +124,11 @@ #ifdef __DMC__ typedef _Complex long double complex_t; +#elif IN_GCC #else #include "complex_t.h" #ifdef __APPLE__ -#include "complex.h" +//#include "complex.h"//This causes problems with include the c++ and not the C "complex.h" #define integer_t dmd_integer_t #endif #endif @@ -137,8 +140,6 @@ typedef long long sinteger_t; typedef unsigned long long uinteger_t; -typedef long double real_t; - typedef signed char d_int8; typedef unsigned char d_uns8; typedef short d_int16; @@ -156,15 +157,23 @@ typedef d_uns16 d_wchar; typedef d_uns32 d_dchar; +#ifdef IN_GCC +#include "d-gcc-real.h" +#else +typedef long double real_t; +#endif + // Modify OutBuffer::writewchar to write the correct size of wchar #if _WIN32 #define writewchar writeword -#endif - -#if linux +#else +// This needs a configuration test... #define writewchar write4 #endif +#ifdef IN_GCC +#include "d-gcc-complex_t.h" +#endif struct Module; @@ -191,8 +200,10 @@ char *toChars(); }; +#ifndef GCC_SAFE_DMD #define TRUE 1 #define FALSE 0 +#endif #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry // in interface vtbl[]'s diff -uNr dmd-0.147/dmd/src/dmd/module.c dmd-0.148/dmd/src/dmd/module.c --- dmd-0.147/dmd/src/dmd/module.c 2006-01-21 13:47:24.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/module.c 2006-02-20 20:25:42.000000000 +0100 @@ -15,6 +15,10 @@ #include #endif +#if IN_GCC +#include "gdc_alloca.h" +#endif + #include "mem.h" #include "mars.h" @@ -30,6 +34,10 @@ #define MARS 1 #include "html.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + ClassDeclaration *Module::moduleinfo; DsymbolTable *Module::modules; @@ -59,6 +67,9 @@ isHtml = 0; isDocFile = 0; needmoduleinfo = 0; +#ifdef IN_GCC + strictlyneedmoduleinfo = 0; +#endif insearch = 0; searchCacheIdent = NULL; searchCacheSymbol = NULL; @@ -274,6 +285,10 @@ m->read(loc); m->parse(); +#ifdef IN_GCC + d_gcc_magic_module(m); +#endif + return m; } @@ -320,7 +335,11 @@ (((unsigned char *)p)[0] << 24); } +#if IN_GCC +void Module::parse(bool dump_source) +#else void Module::parse() +#endif { char *srcname; unsigned char *buf; unsigned buflen; @@ -491,6 +510,14 @@ } } +#ifdef IN_GCC + // dump utf-8 encoded source + if (dump_source) + { // %% srcname could contain a path ... + d_gcc_dump_source(srcname, "utf-8", buf, buflen); + } +#endif + /* If it starts with the string "Ddoc", then it's a documentation * source file. */ @@ -509,6 +536,11 @@ h.extractCode(dbuf); buf = dbuf->data; buflen = dbuf->offset; +#ifdef IN_GCC + // dump extracted source + if (dump_source) + d_gcc_dump_source(srcname, "d.utf-8", buf, buflen); +#endif } Parser p(this, buf, buflen, docfile != NULL); members = p.parseModule(); diff -uNr dmd-0.147/dmd/src/dmd/module.h dmd-0.148/dmd/src/dmd/module.h --- dmd-0.147/dmd/src/dmd/module.h 2005-12-22 20:18:42.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/module.h 2006-02-22 00:08:06.000000000 +0100 @@ -24,7 +24,11 @@ struct VarDeclaration; // Back end +#if IN_GCC +union tree_node; typedef union tree_node elem; +#else struct elem; +#endif struct Package : ScopeDsymbol { @@ -59,6 +63,9 @@ int isHtml; // if it is an HTML file int isDocFile; // if it is a documentation input file, not D source int needmoduleinfo; +#ifdef IN_GCC + int strictlyneedmoduleinfo; +#endif int insearch; Identifier *searchCacheIdent; @@ -95,7 +102,11 @@ char *kind(); void setDocfile(); // set docfile member void read(Loc loc); // read file +#if IN_GCC + void parse(bool dump_source = false); // syntactic parse +#else void parse(); // syntactic parse +#endif void semantic(); // semantic analysis void semantic2(); // pass 2 semantic analysis void semantic3(); // pass 3 semantic analysis diff -uNr dmd-0.147/dmd/src/dmd/mtype.c dmd-0.148/dmd/src/dmd/mtype.c --- dmd-0.147/dmd/src/dmd/mtype.c 2006-02-14 01:33:14.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/mtype.c 2006-02-25 17:38:40.000000000 +0100 @@ -7,6 +7,9 @@ // in artistic.txt, or the GNU General Public License in gnu.txt. // See the included readme.txt for details. +#define __USE_ISOC99 1 // so signbit() gets defined +#include + #include #include #include @@ -19,11 +22,13 @@ #include #include #include -#else +#elif __DMC__ #include +#else +//#define signbit 56 #endif -#ifdef __APPLE__ +#if __APPLE__ #include static double zero = 0; #elif __GNUC__ @@ -105,7 +110,7 @@ Type *Type::syntaxCopy() { print(); - printf("ty = %d\n", ty); + fprintf(stdmsg, "ty = %d\n", ty); assert(0); return this; } @@ -166,6 +171,7 @@ mangleChar[Tcomplex80] = 'c'; mangleChar[Tbit] = 'b'; + mangleChar[Tbool] = 'x'; mangleChar[Tascii] = 'a'; mangleChar[Twchar] = 'u'; mangleChar[Tdchar] = 'w'; @@ -176,7 +182,7 @@ for (i = 0; i < TMAX; i++) { if (!mangleChar[i]) - printf("ty = %d\n", i); + fprintf(stdmsg, "ty = %d\n", i); assert(mangleChar[i]); } @@ -186,7 +192,7 @@ Tfloat32, Tfloat64, Tfloat80, Timaginary32, Timaginary64, Timaginary80, Tcomplex32, Tcomplex64, Tcomplex80, - Tbit, + Tbit, Tbool, Tascii, Twchar, Tdchar }; for (i = 0; i < sizeof(basetab) / sizeof(basetab[0]); i++) @@ -599,16 +605,16 @@ { char *p = loc.toChars(); if (*p) - printf("%s: ", p); + fprintf(stdmsg, "%s: ", p); mem.free(p); va_list ap; va_start(ap, format); - vprintf(format, ap); + vfprintf(stdmsg, format, ap); va_end(ap); - printf("\n"); - fflush(stdout); + fprintf(stdmsg, "\n"); + fflush(stdmsg); } global.errors++; } @@ -766,6 +772,11 @@ flags |= TFLAGSintegral | TFLAGSunsigned; break; + case Tbool: d = Token::toChars(TOKbool); + c = "bool"; + flags |= TFLAGSintegral | TFLAGSunsigned; + break; + case Tascii: d = Token::toChars(TOKchar); c = "char"; flags |= TFLAGSintegral | TFLAGSunsigned; @@ -846,6 +857,7 @@ break; case Tbit: size = 1; break; + case Tbool: size = 1; break; case Tascii: size = 1; break; case Twchar: size = 2; break; case Tdchar: size = 4; break; @@ -881,7 +893,11 @@ { Expression *e; d_int64 ivalue; +#ifdef IN_GCC + real_t fvalue; +#else d_float80 fvalue; +#endif //printf("TypeBasic::getProperty('%s')\n", ident->toChars()); if (ident == Id::max) @@ -897,7 +913,8 @@ case Tint64: ivalue = 0x7FFFFFFFFFFFFFFFLL; goto Livalue; case Tuns64: ivalue = 0xFFFFFFFFFFFFFFFFULL; goto Livalue; case Tbit: ivalue = 1; goto Livalue; - case Tascii: ivalue = 0xFF; goto Livalue; + case Tbool: ivalue = 1; goto Livalue; + case Tchar: ivalue = 0xFF; goto Livalue; case Twchar: ivalue = 0xFFFFUL; goto Livalue; case Tdchar: ivalue = 0x10FFFFUL; goto Livalue; @@ -925,7 +942,8 @@ case Tint64: ivalue = (-9223372036854775807LL-1LL); goto Livalue; case Tuns64: ivalue = 0; goto Livalue; case Tbit: ivalue = 0; goto Livalue; - case Tascii: ivalue = 0; goto Livalue; + case Tbool: ivalue = 0; goto Livalue; + case Tchar: ivalue = 0; goto Livalue; case Twchar: ivalue = 0; goto Livalue; case Tdchar: ivalue = 0; goto Livalue; @@ -953,24 +971,27 @@ case Tfloat32: case Tfloat64: case Tfloat80: -#if __GNUC__ - { // gcc nan's have the sign bit set by default, so turn it off + { +#if IN_GCC + // mode doesn't matter, will be converted in RealExp anyway + fvalue = real_t::getnan(real_t::LongDouble); +#elif __GNUC__ + // gcc nan's have the sign bit set by default, so turn it off // Need the volatile to prevent gcc from doing incorrect // constant folding. volatile d_float80 foo; foo = NAN; - foo = -foo; + if (signbit(foo)) // signbit sometimes, not always, set + foo = -foo; // turn off sign bit fvalue = foo; - } #elif _MSC_VER - { unsigned long nan[2]= { 0xFFFFFFFF, 0x7FFFFFFF }; fvalue = *(double*)nan; - } #else fvalue = NAN; #endif goto Lfvalue; + } } } else if (ident == Id::infinity) @@ -986,7 +1007,9 @@ case Tfloat32: case Tfloat64: case Tfloat80: -#if __GNUC__ +#if IN_GCC + fvalue = real_t::getinfinity(); +#elif __GNUC__ fvalue = 1 / zero; #elif _MSC_VER fvalue = std::numeric_limits::infinity(); @@ -1472,7 +1495,7 @@ buf->writeByte('['); dim = ((TypeSArray *)t)->dim; if (dim) - buf->printf("%d", dim->toInteger()); + buf->printf("%lld", dim->toInteger()); buf->writeByte(']'); t = t->next; } while (t->ty == Tsarray); @@ -1885,6 +1908,7 @@ break; #endif case Tbit: + case Tbool: case Tfunction: case Tvoid: case Tnone: diff -uNr dmd-0.147/dmd/src/dmd/mtype.h dmd-0.148/dmd/src/dmd/mtype.h --- dmd-0.147/dmd/src/dmd/mtype.h 2006-02-11 19:05:30.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/mtype.h 2006-02-22 23:42:42.000000000 +0100 @@ -36,7 +36,12 @@ struct HdrGenState; // Back end +#if IN_GCC +union tree_node; typedef union tree_node TYPE; +typedef TYPE type; +#else typedef struct TYPE type; +#endif struct Symbol; enum TY @@ -77,6 +82,7 @@ Tcomplex80, Tbit, + Tbool, Tchar, Twchar, Tdchar, @@ -134,13 +140,15 @@ #define tcomplex80 basic[Tcomplex80] #define tbit basic[Tbit] + #define tbool basic[Tbool] #define tchar basic[Tchar] #define twchar basic[Twchar] #define tdchar basic[Tdchar] // Some special types #define tshiftcnt tint32 // right side of shift expression - #define tboolean tint32 // result of boolean expression +// #define tboolean tint32 // result of boolean expression + #define tboolean tbool // result of boolean expression #define tindex tint32 // array/ptr index static Type *tvoidptr; // void* #define terror basic[Terror] // for error recovery diff -uNr dmd-0.147/dmd/src/dmd/opover.c dmd-0.148/dmd/src/dmd/opover.c --- dmd-0.147/dmd/src/dmd/opover.c 2006-02-11 00:17:18.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/opover.c 2006-02-22 00:21:26.000000000 +0100 @@ -1,4 +1,4 @@ -// Copyright (c) 1999-2004 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -12,10 +12,15 @@ #include #include -#if linux -#include "../root/mem.h" +#ifdef __APPLE__ +#define integer_t dmd_integer_t #endif -#if _WIN32 + +#if IN_GCC +#include "mem.h" +#elif linux +#include "../root/mem.h" +#elif _WIN32 #include "..\root\mem.h" #endif @@ -28,6 +33,7 @@ #include "aggregate.h" static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id); +static void inferApplyArgTypesX(FuncDeclaration *fstart, Array *arguments); /******************************** Expression **************************/ @@ -133,8 +139,6 @@ int EqualExp::isCommutative() { return TRUE; } Identifier *EqualExp::opId() { return Id::eq; } -Identifier *MatchExp::opId() { return Id::match; } - int CmpExp::isCommutative() { return TRUE; } Identifier *CmpExp::opId() { return Id::cmp; } @@ -412,3 +416,178 @@ } return NULL; } + + +/***************************************** + * Given array of arguments and an aggregate type, + * if any of the argument types are missing, attempt to infer + * them from the aggregate type. + */ + +void inferApplyArgTypes(Array *arguments, Type *taggr) +{ + if (!arguments || !arguments->dim) + return; + + /* Return if no arguments need types. + */ + for (size_t u = 0; 1; u++) + { if (u == arguments->dim) + return; + Argument *arg = (Argument *)arguments->data[u]; + if (!arg->type) + break; + } + + AggregateDeclaration *ad; + FuncDeclaration *fd; + + Argument *arg = (Argument *)arguments->data[0]; + Type *tab = taggr->toBasetype(); + switch (tab->ty) + { + case Tarray: + case Tsarray: + if (arguments->dim == 2) + { + if (!arg->type) + arg->type = Type::tsize_t; // key type + arg = (Argument *)arguments->data[1]; + } + if (!arg->type) + arg->type = tab->next; // value type + break; + + case Taarray: + { TypeAArray *taa = (TypeAArray *)tab; + + if (arguments->dim == 2) + { + if (!arg->type) + arg->type = taa->index; // key type + arg = (Argument *)arguments->data[1]; + } + if (!arg->type) + arg->type = taa->next; // value type + break; + } + + case Tclass: + ad = ((TypeClass *)tab)->sym; + goto Laggr; + + case Tstruct: + ad = ((TypeStruct *)tab)->sym; + goto Laggr; + + Laggr: +#if 0 + if (arguments->dim == 1) + { + if (!arg->type) + { + /* Look for an opNext() overload + */ + fd = search_function(ad, Id::next); + if (!fd) + goto Lapply; + arg->type = fd->type->next; + } + break; + } +#endif + Lapply: + /* Look for an + * int opApply(int delegate(inout Type [, ...]) dg); + * overload + */ + fd = search_function(ad, Id::apply); + if (!fd) + break; + inferApplyArgTypesX(fd, arguments); + break; + + default: + break; // ignore error, caught later + } +} + +/******************************** + * Recursive helper function, + * analogous to func.overloadResolveX(). + */ + +static void inferApplyArgTypesX(FuncDeclaration *fstart, Array *arguments) +{ + Declaration *d; + Declaration *next; + + for (d = fstart; d; d = next) + { + FuncDeclaration *f; + FuncAliasDeclaration *fa; + AliasDeclaration *a; + + fa = d->isFuncAliasDeclaration(); + if (fa) + { + inferApplyArgTypesX(fa->funcalias, arguments); + next = fa->overnext; + } + else if ((f = d->isFuncDeclaration()) != NULL) + { + next = f->overnext; + + TypeFunction *tf = (TypeFunction *)f->type; + if (!tf->arguments || tf->arguments->dim != 1) + continue; + Argument *p = (Argument *)tf->arguments->data[0]; + if (p->type->ty != Tdelegate) + continue; + tf = (TypeFunction *)p->type->next; + assert(tf->ty == Tfunction); + + /* We now have tf, the type of the delegate. Match it against + * the arguments, filling in missing argument types. + */ + if (!tf->arguments || tf->varargs) + continue; // not enough parameters + unsigned nparams = tf->arguments->dim; + if (arguments->dim != nparams) + continue; // not enough parameters + + for (unsigned u = 0; u < nparams; u++) + { + p = (Argument *)arguments->data[u]; + Argument *tp = (Argument *)tf->arguments->data[u]; + if (p->type) + { if (!p->type->equals(tp->type)) + { + /* Cannot resolve argument types. Indicate an + * error by setting the number of arguments to 0. + */ + arguments->dim = 0; + return; + } + continue; + } + p->type = tp->type; + } + } + else if ((a = d->isAliasDeclaration()) != NULL) + { + Dsymbol *s = a->toAlias(); + next = s->isDeclaration(); + if (next == a) + break; + if (next == fstart) + break; + } + else + { d->error("is aliased to a function"); + break; + } + } +} + + diff -uNr dmd-0.147/dmd/src/dmd/parse.c dmd-0.148/dmd/src/dmd/parse.c --- dmd-0.147/dmd/src/dmd/parse.c 2006-02-11 00:36:52.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/parse.c 2006-02-24 01:15:58.000000000 +0100 @@ -2645,10 +2645,21 @@ { inout = InOut; nextToken(); } + if (token.value == TOKidentifier) + { + Token *t = peek(&token); + if (t->value == TOKcomma || t->value == TOKsemicolon) + { ai = token.ident; + at = NULL; // infer argument type + nextToken(); + goto Larg; + } + } tb = parseBasicType(); at = parseDeclarator(tb, &ai); if (!ai) error("no identifier for declarator %s", at->toChars()); + Larg: a = new Argument(inout, at, ai, NULL); arguments->push(a); if (token.value == TOKcomma) @@ -2667,12 +2678,26 @@ } case TOKif: - { Expression *condition; + { Argument *arg = NULL; + Expression *condition; Statement *ifbody; Statement *elsebody; nextToken(); check(TOKlparen); + + // Check for " ident;" + if (token.value == TOKidentifier) + { + Token *t = peek(&token); + if (t->value == TOKcomma || t->value == TOKsemicolon) + { + arg = new Argument(In, NULL, token.ident, NULL); + nextToken(); + nextToken(); + } + } + condition = parseExpression(); check(TOKrparen); ifbody = parseStatement(PSscope); @@ -2683,7 +2708,7 @@ } else elsebody = NULL; - s = new IfStatement(loc, condition, ifbody, elsebody); + s = new IfStatement(loc, arg, condition, ifbody, elsebody); break; } @@ -3668,12 +3693,12 @@ break; case TOKtrue: - e = new IntegerExp(loc, 1, Type::tbit); + e = new IntegerExp(loc, 1, Type::tbool); nextToken(); break; case TOKfalse: - e = new IntegerExp(loc, 0, Type::tbit); + e = new IntegerExp(loc, 0, Type::tbool); nextToken(); break; @@ -4281,13 +4306,6 @@ e = new EqualExp(value, loc, e, e2); continue; - case TOKmatch: - case TOKnotmatch: - nextToken(); - e2 = parseRelExp(); - e = new MatchExp(value, loc, e, e2); - continue; - case TOKidentity: if (!global.params.useDeprecated) error("'===' is deprecated, use 'is' instead"); diff -uNr dmd-0.147/dmd/src/dmd/scope.c dmd-0.148/dmd/src/dmd/scope.c --- dmd-0.147/dmd/src/dmd/scope.c 2006-01-21 13:47:44.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/scope.c 2006-02-22 00:22:04.000000000 +0100 @@ -226,7 +226,7 @@ sc->enclosing && sc->enclosing->search(ident, NULL)) { - printf("warning - "); + fprintf(stdmsg, "warning - "); error("array 'length' hides other 'length' name in outer scope"); } diff -uNr dmd-0.147/dmd/src/dmd/statement.c dmd-0.148/dmd/src/dmd/statement.c --- dmd-0.147/dmd/src/dmd/statement.c 2006-02-11 20:31:06.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/statement.c 2006-02-22 12:13:50.000000000 +0100 @@ -45,8 +45,8 @@ void Statement::print() { - printf("%s\n", toChars()); - fflush(stdout); + fprintf(stdmsg, "%s\n", toChars()); + fflush(stdmsg); } char *Statement::toChars() @@ -91,16 +91,16 @@ { char *p = loc.toChars(); if (*p) - printf("%s: ", p); + fprintf(stdmsg, "%s: ", p); mem.free(p); va_list ap; va_start(ap, format); - vprintf(format, ap); + vfprintf(stdmsg, format, ap); va_end(ap); - printf("\n"); - fflush(stdout); + fprintf(stdmsg, "\n"); + fflush(stdmsg); } global.errors++; } @@ -140,6 +140,10 @@ * 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 * a Statement. + * Output: + * *sentry code executed upon entry to the scope + * *sexit code executed upon exit from the scope + * *sfinally code executed in finally block */ void Statement::scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally) @@ -296,6 +300,10 @@ { Statement *s; //printf("CompoundStatement::semantic(this = %p, sc = %p)\n", this, sc); + + /* Start by flattening it + */ + for (int i = 0; i < statements->dim; i++) { L1: @@ -311,7 +319,14 @@ break; goto L1; } + } + } + for (int i = 0; i < statements->dim; i++) + { + s = (Statement *) statements->data[i]; + if (s) + { s = s->semantic(sc); statements->data[i] = s; if (s) @@ -321,7 +336,41 @@ Statement *sfinally; s->scopeCode(&sentry, &sexit, &sfinally); - if (sfinally) + if (sentry) + { + sentry = sentry->semantic(sc); + statements->data[i] = sentry; + } + if (sexit && !sfinally) + { + if (i + 1 == statements->dim) + { + statements->push(sexit); + } + else + { + /* Rewrite: + * s; s1; s2; + * As: + * s; { s1; s2; } sexit; + */ + Statement *body; + Array *a = new Array(); + + for (int j = i + 1; j < statements->dim; j++) + { + a->push(statements->data[j]); + } + body = new CompoundStatement(0, a); + body = new ScopeStatement(0, body); + s = new CompoundStatement(0, body, sexit); + s = s->semantic(sc); + statements->data[i + 1] = s; + statements->setDim(i + 2); + break; + } + } + else if (!sexit && sfinally) { if (i + 1 == statements->dim) { @@ -329,7 +378,41 @@ } else { - // The rest of the statements form the body of a try-finally + /* Rewrite: + * s; s1; s2; + * As: + * s; try { s1; s2; } finally { sfinally; } + */ + Statement *body; + Array *a = new Array(); + + for (int j = i + 1; j < statements->dim; j++) + { + a->push(statements->data[j]); + } + body = new CompoundStatement(0, a); + s = new TryFinallyStatement(0, body, sfinally); + s = s->semantic(sc); + statements->data[i + 1] = s; + statements->setDim(i + 2); + break; + } + } + else if (sexit && sfinally) + { + if (i + 1 == statements->dim) + { /* Assume sexit cannot throw an exception + */ + statements->push(sexit); + statements->push(sfinally); + } + else + { + /* Rewrite: + * s; s1; s2; + * As: + * s; try { { s1; s2; } sexit; } finally { sfinally; } + */ Statement *body; Array *a = new Array(); @@ -338,6 +421,8 @@ a->push(statements->data[j]); } body = new CompoundStatement(0, a); + body = new ScopeStatement(0, body); + body = new CompoundStatement(0, body, sexit); s = new TryFinallyStatement(0, body, sfinally); s = s->semantic(sc); statements->data[i + 1] = s; @@ -412,7 +497,7 @@ if (!falloff && global.params.warnings && !s->comeFrom()) { - printf("warning - "); + fprintf(stdmsg, "warning - "); s->error("statement is not reachable"); } falloff = s->fallOffEnd(); @@ -512,6 +597,7 @@ Statement *WhileStatement::semantic(Scope *sc) { +#if 0 if (condition->op == TOKmatch) { /* Rewrite while (condition) body as: @@ -532,6 +618,7 @@ Statement *si = new IfStatement(loc, condition, sw, NULL); return si->semantic(sc); } +#endif condition = condition->semantic(sc); condition = resolveProperties(sc, condition); @@ -774,6 +861,7 @@ Statement *ForeachStatement::semantic(Scope *sc) { + //printf("ForeachStatement::semantic() %p\n", this); ScopeDsymbol *sym; Statement *s = this; int dim = arguments->dim; @@ -786,6 +874,25 @@ aggr = aggr->semantic(sc); aggr = resolveProperties(sc, aggr); + inferApplyArgTypes(arguments, aggr->type); + + /* Check for inference errors + */ + if (dim != arguments->dim) + { + //printf("dim = %d, arguments->dim = %d\n", dim, arguments->dim); + error("cannot uniquely infer foreach argument types"); + return this; + } + for (i = 0; i < dim; i++) + { Argument *arg = (Argument *)arguments->data[i]; + if (!arg->type) + { + error("cannot infer type for %s", arg->ident->toChars()); + return this; + } + } + sym = new ScopeDsymbol(); sym->parent = sc->scopesym; sc = sc->push(sym); @@ -1036,7 +1143,7 @@ e = new CallExp(loc, ec, args); e = e->semantic(sc); if (e->type != Type::tint32) - error("apply() function for %s must return an int", tab->toChars()); + error("opApply() function for %s must return an int", tab->toChars()); } if (!cases.dim) @@ -1109,7 +1216,10 @@ buf->writestring(", "); if (a->inout == InOut) buf->writestring("inout "); - a->type->toCBuffer(buf, a->ident, hgs); + if (a->type) + a->type->toCBuffer(buf, a->ident, hgs); + else + buf->writestring(a->ident->toChars()); } buf->writestring("; "); aggr->toCBuffer(buf, hgs); @@ -1125,9 +1235,10 @@ /******************************** IfStatement ***************************/ -IfStatement::IfStatement(Loc loc, Expression *condition, Statement *ifbody, Statement *elsebody) +IfStatement::IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody) : Statement(loc) { + this->arg = arg; this->condition = condition; this->ifbody = ifbody; this->elsebody = elsebody; @@ -1144,18 +1255,16 @@ if (elsebody) e = elsebody->syntaxCopy(); - IfStatement *s = new IfStatement(loc, condition->syntaxCopy(), i, e); + Argument *a = arg ? arg->syntaxCopy() : NULL; + IfStatement *s = new IfStatement(loc, a, condition->syntaxCopy(), i, e); return s; } Statement *IfStatement::semantic(Scope *sc) { - int domatch = (condition->op == TOKmatch); - condition = condition->semantic(sc); condition = resolveProperties(sc, condition); - if (!domatch) - condition = condition->checkToBoolean(); + condition = condition->checkToBoolean(); // If we can short-circuit evaluate the if statement, don't do the // semantic analysis of the skipped code. @@ -1167,16 +1276,15 @@ unsigned cs1; Scope *scd; - if (domatch) - { /* Declare _match, which we will set to be the - * result of condition. _match will give us access to the - * regular expression match strings in the scope of ifbody. + if (arg) + { /* Declare arg, which we will set to be the + * result of condition. */ ScopeDsymbol *sym = new ScopeDsymbol(); sym->parent = sc->scopesym; scd = sc->push(sym); - match = new VarDeclaration(loc, condition->type, Id::_match, NULL); + match = new VarDeclaration(loc, condition->type, arg->ident, NULL); match->noauto = 1; match->semantic(scd); if (!scd->insert(match)) @@ -1184,11 +1292,10 @@ match->parent = sc->func; /* Generate: - * (_match = condition), _match + * (arg = condition) */ VarExp *v = new VarExp(0, match); condition = new AssignExp(loc, v, condition); - //condition = new CastExp(0, condition, Type::tvoidptr); condition = condition->semantic(scd); } else @@ -1222,6 +1329,14 @@ void IfStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writestring("if ("); + if (arg) + { + if (arg->type) + arg->type->toCBuffer(buf, arg->ident, hgs); + else + buf->writestring(arg->ident->toChars()); + buf->writebyte(';'); + } condition->toCBuffer(buf, hgs); buf->writebyte(')'); buf->writenl(); @@ -1328,12 +1443,12 @@ if (e->op == TOKstring) { StringExp *se = (StringExp *)e; - printf("%.*s", se->len, se->string); + fprintf(stdmsg, "%.*s", se->len, se->string); } else error("string expected for message, not '%s'", e->toChars()); } - printf("\n"); + fprintf(stdmsg, "\n"); } } else if (ident == Id::lib) @@ -1486,7 +1601,7 @@ if (!sc->sw->sdefault) { if (global.params.warnings) - { printf("warning - "); + { fprintf(stdmsg, "warning - "); error("switch statement has no default"); } @@ -1653,6 +1768,9 @@ : Statement(loc) { this->statement = s; +#if IN_GCC ++ cblock = NULL; +#endif } Statement *DefaultStatement::syntaxCopy() @@ -2092,6 +2210,7 @@ Statement *ContinueStatement::semantic(Scope *sc) { + //printf("ContinueStatement::semantic() %p\n", this); if (ident) { Scope *scx; @@ -2105,6 +2224,16 @@ { if (sc->fes) // if this is the body of a foreach { + for (; scx; scx = scx->enclosing) + { + ls = scx->slabel; + if (ls && ls->ident == ident && ls->statement == sc->fes) + { + // Replace continue ident; with return 0; + return new ReturnStatement(0, new IntegerExp(0)); + } + } + /* Post this statement to the fes, and replace * it with a return value that caller will put into * a switch. Caller will figure out where the break @@ -2441,6 +2570,7 @@ //printf("Catch::semantic()\n"); +#ifndef IN_GCC if (sc->tf) { /* This is because the _d_local_unwind() gets the stack munged @@ -2451,6 +2581,7 @@ */ error(loc, "cannot put catch statement inside finally block"); } +#endif sym = new ScopeDsymbol(); sym->parent = sc->scopesym; @@ -2568,7 +2699,7 @@ Statement *OnScopeStatement::semantic(Scope *sc) { - statement = statement->semantic(sc); + /* semantic is called on results of scopeCode() */ return this; } @@ -2581,7 +2712,7 @@ int OnScopeStatement::usesEH() { - return TRUE; + return (tok != TOKon_scope_success); } void OnScopeStatement::scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally) @@ -2591,6 +2722,46 @@ *sentry = NULL; *sexit = NULL; *sfinally = NULL; + switch (tok) + { + case TOKon_scope_exit: + *sfinally = statement; + break; + + case TOKon_scope_failure: + { + /* Create: + * sentry: int x = 0; + * sexit: x = 1; + * sfinally: if (!x) statement; + */ + char name[5 + sizeof(int) * 3 + 1]; + static int num; + sprintf(name, "__osf%d", ++num); + Identifier *id = Lexer::idPool(name); + + ExpInitializer *ie = new ExpInitializer(loc, new IntegerExp(0)); + VarDeclaration *v = new VarDeclaration(loc, Type::tint32, id, ie); + *sentry = new DeclarationStatement(loc, v); + + Expression *e = new IntegerExp(1); + e = new AssignExp(0, new VarExp(0, v), e); + *sexit = new ExpStatement(0, e); + + e = new VarExp(0, v); + e = new NotExp(0, e); + *sfinally = new IfStatement(0, NULL, e, statement, NULL); + + break; + } + + case TOKon_scope_success: + *sexit = statement; + break; + + default: + assert(0); + } } /******************************** ThrowStatement ***************************/ @@ -2834,6 +3005,9 @@ : Dsymbol(ident) { statement = NULL; +#if IN_GCC + asmLabelNum = 0; +#endif } LabelDsymbol *LabelDsymbol::isLabel() // is this a LabelDsymbol()? diff -uNr dmd-0.147/dmd/src/dmd/statement.h dmd-0.148/dmd/src/dmd/statement.h --- dmd-0.147/dmd/src/dmd/statement.h 2006-02-11 12:54:08.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/statement.h 2006-02-22 11:33:18.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -45,8 +45,13 @@ // Back end struct IRState; struct Blockx; +#if IN_GCC +union tree_node; typedef union tree_node block; +union tree_node; typedef union tree_node elem; +#else struct block; struct elem; +#endif struct code; struct Statement : Object @@ -265,13 +270,14 @@ struct IfStatement : Statement { + Argument *arg; Expression *condition; Statement *ifbody; Statement *elsebody; VarDeclaration *match; // for MatchExpression results - IfStatement(Loc loc, Expression *condition, Statement *ifbody, Statement *elsebody); + IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); Statement *syntaxCopy(); Statement *semantic(Scope *sc); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); @@ -371,6 +377,9 @@ struct DefaultStatement : Statement { Statement *statement; +#if IN_GCC + block *cblock; // back end: label for the block +#endif DefaultStatement(Loc loc, Statement *s); Statement *syntaxCopy(); @@ -569,6 +578,8 @@ Statement *semantic(Scope *sc); int usesEH(); void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); + + void toIR(IRState *irs); }; struct ThrowStatement : Statement @@ -643,6 +654,9 @@ struct LabelDsymbol : Dsymbol { LabelStatement *statement; +#if IN_GCC + unsigned asmLabelNum; // GCC-specific +#endif LabelDsymbol(Identifier *ident); LabelDsymbol *isLabel(); diff -uNr dmd-0.147/dmd/src/dmd/struct.c dmd-0.148/dmd/src/dmd/struct.c --- dmd-0.147/dmd/src/dmd/struct.c 2006-02-11 17:34:48.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/struct.c 2006-02-21 21:53:18.000000000 +0100 @@ -193,8 +193,6 @@ /********************************* StructDeclaration ****************************/ -StructDeclaration *StructDeclaration::match; - StructDeclaration::StructDeclaration(Loc loc, Identifier *id) : AggregateDeclaration(loc, id) { @@ -202,10 +200,6 @@ // For forward references type = new TypeStruct(this); - - // BUG: What if this is the wrong _Match, i.e. it is nested? - if (!match && id == Id::_Match) - match = this; } Dsymbol *StructDeclaration::syntaxCopy(Dsymbol *s) diff -uNr dmd-0.147/dmd/src/dmd/template.h dmd-0.148/dmd/src/dmd/template.h --- dmd-0.147/dmd/src/dmd/template.h 2006-02-08 19:26:06.000000000 +0100 +++ dmd-0.148/dmd/src/dmd/template.h 2006-02-22 00:43:02.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2005 by Digital Mars +// Copyright (c) 1999-2006 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -186,6 +186,12 @@ WithScopeSymbol *withsym; // if a member of a with statement int semanticdone; // has semantic() been done? int nest; // for recursion detection +#ifdef IN_GCC + /* On some targets, it is necessary to know whether a symbol + will be emitted in the output or not before the symbol + is used. This can be different from getModule(). */ + Module * objFileModule; +#endif TemplateInstance(Loc loc, Identifier *temp_id); Dsymbol *syntaxCopy(Dsymbol *); diff -uNr dmd-0.147/dmd/src/phobos/internal/arraycast.d dmd-0.148/dmd/src/phobos/internal/arraycast.d --- dmd-0.147/dmd/src/phobos/internal/arraycast.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/internal/arraycast.d 2006-02-25 17:39:18.000000000 +0100 @@ -87,6 +87,8 @@ unittest { + version (D_Bits) + { bit[int.sizeof * 3 * 8] b; int[] i; short[] s; @@ -96,6 +98,7 @@ s = cast(short[])b; assert(s.length == 6); + } } diff -uNr dmd-0.147/dmd/src/phobos/internal/dmain2.d dmd-0.148/dmd/src/phobos/internal/dmain2.d --- dmd-0.147/dmd/src/phobos/internal/dmain2.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/internal/dmain2.d 2006-02-25 17:39:18.000000000 +0100 @@ -20,6 +20,8 @@ extern (C) void _moduleDtor(); extern (C) void _moduleUnitTests(); +extern (C) bool no_catch_exceptions = false; + /*********************************** * The D main() function supplied by the user's program */ @@ -56,7 +58,7 @@ am = cast(char[] *) alloca(argc * (char[]).sizeof); } - try + if (no_catch_exceptions) { _moduleCtor(); _moduleUnitTests(); @@ -73,12 +75,33 @@ _moduleDtor(); gc_term(); } - catch (Object o) + else { - printf("Error: "); - o.print(); - exit(EXIT_FAILURE); + try + { + _moduleCtor(); + _moduleUnitTests(); + + for (i = 0; i < argc; i++) + { + int len = strlen(argv[i]); + am[i] = argv[i][0 .. len]; + } + + args = am[0 .. argc]; + + result = main(args); + _moduleDtor(); + gc_term(); + } + catch (Object o) + { + printf("Error: "); + o.print(); + exit(EXIT_FAILURE); + } } + version (linux) { free(am); diff -uNr dmd-0.147/dmd/src/phobos/internal/match.d dmd-0.148/dmd/src/phobos/internal/match.d --- dmd-0.147/dmd/src/phobos/internal/match.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/internal/match.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,47 +0,0 @@ - -/* - * Copyright (C) 2006 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. - */ - -module internal.match; - -import std.regexp; - -/****************************** - * Return handle to results if input[] matches regular expression pattern[], - * null if not. - */ - -extern (C) _Match* _d_match(char[] pattern, char[] input) -{ - return cast(_Match*)std.regexp.search(input, pattern); -} - -/****************************** - * Returns !=null for next match. - */ - -extern (C) _Match* _d_match_next(_Match* h) -{ - RegExp r = cast(RegExp)h; - return r.test() ? h : null; -} diff -uNr dmd-0.147/dmd/src/phobos/internal/object.d dmd-0.148/dmd/src/phobos/internal/object.d --- dmd-0.147/dmd/src/phobos/internal/object.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/internal/object.d 2006-02-25 17:39:18.000000000 +0100 @@ -43,7 +43,7 @@ } /// Standard boolean type. Implemented as a $(B bit) type. -alias bit bool; +alias bool bit; version (X86_64) { @@ -612,42 +612,3 @@ //extern (C) int nullext = 0; -/* ***************************** _Match **************************** */ - -/* ** - * Default type for _match. - * Implemented as a proxy for RegExp, so that object doesn't pull in - * the entire std.regexp. - */ - -import std.regexp; - -struct _Match -{ - char[] match(size_t n) - { - return (cast(RegExp)this).match(n); - } - - _Match* opNext() - { - RegExp r = (cast(RegExp)this).opNext(); - if (r) - return cast(_Match*)this; - r = cast(RegExp)this; - delete r; - return null; - } - - char[] pre() - { - return (cast(RegExp)this).pre(); - } - - char[] post() - { - return (cast(RegExp)this).post(); - } -} - - diff -uNr dmd-0.147/dmd/src/phobos/linux.mak dmd-0.148/dmd/src/phobos/linux.mak --- dmd-0.147/dmd/src/phobos/linux.mak 2006-02-15 13:48:52.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/linux.mak 2006-02-25 17:39:18.000000000 +0100 @@ -57,18 +57,18 @@ process.o syserror.o \ socket.o socketstream.o stdarg.o stdio.o format.o \ perf.o openrj.o uni.o trace.o boxer.o \ - demangle.o cover.o mangle.o \ + demangle.o cover.o bitarray.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 \ ti_creal.o ti_ireal.o ti_cfloat.o ti_ifloat.o \ ti_cdouble.o ti_idouble.o \ ti_Aa.o ti_AC.o ti_Ag.o ti_Aubyte.o ti_Aushort.o ti_Ashort.o \ - ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o ti_bit.o \ + ti_C.o ti_int.o ti_char.o ti_dchar.o ti_Adchar.o \ ti_Aint.o ti_Auint.o ti_Along.o ti_Aulong.o ti_Awchar.o \ ti_Afloat.o ti_Adouble.o ti_Areal.o \ ti_Acfloat.o ti_Acdouble.o ti_Acreal.o \ - ti_Abit.o ti_void.o \ + ti_void.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 \ @@ -100,7 +100,7 @@ std/regexp.d std/random.d std/stream.d std/process.d std/recls.d \ std/socket.d std/socketstream.d std/loader.d std/stdarg.d \ std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \ - std/boxer.d std/cstream.d std/demangle.d std/cover.d + std/boxer.d std/cstream.d std/demangle.d std/cover.d std/bitarray.d SRC_STD_C= std/c/process.d std/c/stdlib.d std/c/time.d std/c/stdio.d \ std/c/math.d std/c/stdarg.d std/c/stddef.d @@ -110,7 +110,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_bit.d \ + std/typeinfo/ti_ptr.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 \ @@ -127,7 +127,7 @@ std/typeinfo/ti_Areal.d \ std/typeinfo/ti_Acfloat.d std/typeinfo/ti_Acdouble.d \ std/typeinfo/ti_Acreal.d \ - std/typeinfo/ti_Abit.d std/typeinfo/ti_void.d \ + std/typeinfo/ti_void.d \ std/typeinfo/ti_Awchar.d std/typeinfo/ti_dchar.d SRC_INT= \ @@ -137,7 +137,7 @@ internal/memset.d internal/arraycast.d internal/aaA.d internal/adi.d \ internal/dmain2.d internal/cast.d internal/qsort.d internal/deh2.d \ internal/cmath2.d internal/obj.d internal/mars.h internal/aApply.d \ - internal/object.d internal/trace.d internal/qsort2.d internal/match.d + internal/object.d internal/trace.d internal/qsort2.d SRC_STD_WIN= std/windows/registry.d \ std/windows/iunknown.d std/windows/charset.d @@ -438,9 +438,6 @@ llmath.o : internal/llmath.d $(DMD) -c $(DFLAGS) internal/llmath.d -match.o : internal/match.d - $(DMD) -c $(DFLAGS) internal/match.d - memset.o : internal/memset.d $(DMD) -c $(DFLAGS) internal/memset.d @@ -476,6 +473,9 @@ base64.o : std/base64.d $(DMD) -c $(DFLAGS) std/base64.d +bitarray.o : std/bitarray.d + $(DMD) -c $(DFLAGS) std/bitarray.d + boxer.o : std/boxer.d $(DMD) -c $(DFLAGS) std/boxer.d diff -uNr dmd-0.147/dmd/src/phobos/object.d dmd-0.148/dmd/src/phobos/object.d --- dmd-0.147/dmd/src/phobos/object.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/object.d 2006-02-25 17:39:18.000000000 +0100 @@ -3,7 +3,8 @@ module object; -alias bit bool; +//alias bit bool; +alias bool bit; alias typeof(int.sizeof) size_t; alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; @@ -129,14 +130,3 @@ this(char[] msg, Error next); } -// Default type for _match - -struct _Match -{ - void* handle; - - char[] match(size_t n); - _Match* opNext(); - char[] pre(); - char[] post(); -} diff -uNr dmd-0.147/dmd/src/phobos/std/bitarray.d dmd-0.148/dmd/src/phobos/std/bitarray.d --- dmd-0.147/dmd/src/phobos/std/bitarray.d 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/bitarray.d 2006-02-25 17:39:18.000000000 +0100 @@ -0,0 +1,935 @@ +/*********************** + * Macros: + * WIKI = StdBitarray + */ + +module std.bitarray; + +//debug = bitarray; // uncomment to turn on debugging printf's + +private import std.intrinsic; + +/** + * An array of bits. + */ + +struct BitArray +{ + size_t len; + uint* ptr; + + size_t dim() + { + return (len + 31) / 32; + } + + size_t length() + { + return len; + } + + void length(size_t newlen) + { + if (newlen != len) + { + size_t olddim = dim(); + size_t newdim = (newlen + 31) / 32; + + if (newdim != olddim) + { + // Create a fake array so we can use D's realloc machinery + uint[] b = ptr[0 .. olddim]; + b.length = newdim; // realloc + ptr = b.ptr; + if (newdim & 31) + { // Set any pad bits to 0 + ptr[newdim - 1] &= ~(~0 << (newdim & 31)); + } + } + + len = newlen; + } + } + + /********************************************** + * Support for [$(I index)] operation for BitArray. + */ + bool opIndex(size_t i) + in + { + assert(i < len); + } + body + { + return cast(bool)bt(ptr, i); + } + + /** ditto */ + bool opIndexAssign(bool b, size_t i) + in + { + assert(i < len); + } + body + { + if (b) + bts(ptr, i); + else + btr(ptr, i); + return b; + } + + /********************************************** + * Support for array.dup property for BitArray. + */ + BitArray dup() + { + BitArray ba; + + uint[] b = ptr[0 .. dim].dup; + ba.len = len; + ba.ptr = b.ptr; + return ba; + } + + unittest + { + BitArray a; + BitArray b; + int i; + + debug(bitarray) printf("BitArray.dup.unittest\n"); + + a.length = 3; + a[0] = 1; a[1] = 0; a[2] = 1; + b = a.dup; + assert(b.length == 3); + for (i = 0; i < 3; i++) + { debug(bitarray) printf("b[%d] = %d\n", i, b[i]); + assert(b[i] == (((i ^ 1) & 1) ? true : false)); + } + } + + /********************************************** + * Support for foreach loops for BitArray. + */ + int opApply(int delegate(inout bool) dg) + { + int result; + + for (size_t i = 0; i < len; i++) + { bool b = opIndex(i); + result = dg(b); + if (result) + break; + } + return result; + } + + /** ditto */ + int opApply(int delegate(inout size_t, inout bool) dg) + { + int result; + + for (size_t i = 0; i < len; i++) + { bool b = opIndex(i); + result = dg(i, b); + if (result) + break; + } + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opApply unittest\n"); + + static bool[] ba = [1,0,1]; + + BitArray a; a.init(ba); + + int i; + foreach (b;a) + { + switch (i) + { case 0: assert(b == true); break; + case 1: assert(b == false); break; + case 2: assert(b == true); break; + } + i++; + } + + foreach (j,b;a) + { + switch (j) + { case 0: assert(b == true); break; + case 1: assert(b == false); break; + case 2: assert(b == true); break; + } + } + } + + + /********************************************** + * Support for array.reverse property for BitArray. + */ + + BitArray reverse() + out (result) + { + assert(result == *this); + } + body + { + if (len >= 2) + { + bool t; + size_t lo, hi; + + lo = 0; + hi = len - 1; + for (; lo < hi; lo++, hi--) + { + t = (*this)[lo]; + (*this)[lo] = (*this)[hi]; + (*this)[hi] = t; + } + } + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.reverse.unittest\n"); + + BitArray b; + static bool[5] data = [1,0,1,1,0]; + int i; + + b.init(data); + b.reverse; + for (i = 0; i < data.length; i++) + { + assert(b[i] == data[4 - i]); + } + } + + + /********************************************** + * Support for array.sort property for BitArray. + */ + + BitArray sort() + out (result) + { + assert(result == *this); + } + body + { + if (len >= 2) + { + size_t lo, hi; + + lo = 0; + hi = len - 1; + while (1) + { + while (1) + { + if (lo >= hi) + goto Ldone; + if ((*this)[lo] == true) + break; + lo++; + } + + while (1) + { + if (lo >= hi) + goto Ldone; + if ((*this)[hi] == false) + break; + hi--; + } + + (*this)[lo] = false; + (*this)[hi] = true; + + lo++; + hi--; + } + Ldone: + ; + } + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.sort.unittest\n"); + + static uint x = 0b1100011000; + static BitArray ba = { 10, &x }; + ba.sort; + for (size_t i = 0; i < 6; i++) + assert(ba[i] == false); + for (size_t i = 6; i < 10; i++) + assert(ba[i] == true); + } + + + /*************************************** + * Support for operators == and != for bit arrays. + */ + + int opEquals(BitArray a2) + { int i; + + if (this.length != a2.length) + return 0; // not equal + byte *p1 = cast(byte*)this.ptr; + byte *p2 = cast(byte*)a2.ptr; + uint n = this.length / 8; + for (i = 0; i < n; i++) + { + if (p1[i] != p2[i]) + return 0; // not equal + } + + ubyte mask; + + n = this.length & 7; + mask = (1 << n) - 1; + //printf("i = %d, n = %d, mask = %x, %x, %x\n", i, n, mask, p1[i], p2[i]); + return (mask == 0) || (p1[i] & mask) == (p2[i] & mask); + } + + unittest + { + debug(bitarray) printf("BitArray.opEquals unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1]; + static bool[] bc = [1,0,1,0,1,0,1]; + static bool[] bd = [1,0,1,1,1]; + static bool[] be = [1,0,1,0,1]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + BitArray c; c.init(bc); + BitArray d; d.init(bd); + BitArray e; e.init(be); + + assert(a != b); + assert(a != c); + assert(a != d); + assert(a == e); + } + + /*************************************** + * Implement comparison operators. + */ + + int opCmp(BitArray a2) + { + uint len; + uint i; + + len = this.length; + if (a2.length < len) + len = a2.length; + ubyte* p1 = cast(ubyte*)this.ptr; + ubyte* p2 = cast(ubyte*)a2.ptr; + uint n = len / 8; + for (i = 0; i < n; i++) + { + if (p1[i] != p2[i]) + break; // not equal + } + for (uint j = i * 8; j < len; j++) + { ubyte mask = 1 << j; + int c; + + c = cast(int)(p1[i] & mask) - cast(int)(p2[i] & mask); + if (c) + return c; + } + return cast(int)this.len - cast(int)a2.length; + } + + unittest + { + debug(bitarray) printf("BitArray.opCmp unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1]; + static bool[] bc = [1,0,1,0,1,0,1]; + static bool[] bd = [1,0,1,1,1]; + static bool[] be = [1,0,1,0,1]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + BitArray c; c.init(bc); + BitArray d; d.init(bd); + BitArray e; e.init(be); + + assert(a > b); + assert(a >= b); + assert(a < c); + assert(a <= c); + assert(a < d); + assert(a <= d); + assert(a == e); + assert(a <= e); + assert(a >= e); + } + + /*************************************** + * Set BitArray to contents of ba[] + */ + + void init(bool[] ba) + { + length = ba.length; + foreach (i, b; ba) + { + (*this)[i] = b; + } + } + + + /*************************************** + * Map BitArray onto v[], with numbits being the number of bits + * in the array. Does not copy the data. + * + * This is the inverse of opCast. + */ + void init(void[] v, size_t numbits) + in + { + assert(numbits <= v.length * 8); + assert((v.length & 3) == 0); + } + body + { + ptr = cast(uint*)v.ptr; + len = numbits; + } + + unittest + { + debug(bitarray) printf("BitArray.init unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + + BitArray a; a.init(ba); + BitArray b; + void[] v; + + v = cast(void[])a; + b.init(v, a.length); + + assert(b[0] == 1); + assert(b[1] == 0); + assert(b[2] == 1); + assert(b[3] == 0); + assert(b[4] == 1); + + a[0] = 0; + assert(b[0] == 0); + + assert(a == b); + } + + /*************************************** + * Convert to void[]. + */ + void[] opCast() + { + return cast(void[])ptr[0 .. dim]; + } + + unittest + { + debug(bitarray) printf("BitArray.opCast unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + + BitArray a; a.init(ba); + void[] v = cast(void[])a; + + assert(v.length == a.dim * uint.sizeof); + } + + /*************************************** + * Support for unary operator ~ for bit arrays. + */ + BitArray opCom() + { + auto dim = this.dim(); + + BitArray result; + + result.length = len; + for (size_t i = 0; i < dim; i++) + result.ptr[i] = ~this.ptr[i]; + if (len & 31) + result.ptr[dim - 1] &= ~(~0 << (len & 31)); + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opCom unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + + BitArray a; a.init(ba); + BitArray b = ~a; + + assert(b[0] == 0); + assert(b[1] == 1); + assert(b[2] == 0); + assert(b[3] == 1); + assert(b[4] == 0); + } + + + /*************************************** + * Support for binary operator & for bit arrays. + */ + BitArray opAnd(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + BitArray result; + + result.length = len; + for (size_t i = 0; i < dim; i++) + result.ptr[i] = this.ptr[i] & e2.ptr[i]; + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opAnd unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + BitArray c = a & b; + + assert(c[0] == 1); + assert(c[1] == 0); + assert(c[2] == 1); + assert(c[3] == 0); + assert(c[4] == 0); + } + + + /*************************************** + * Support for binary operator | for bit arrays. + */ + BitArray opOr(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + BitArray result; + + result.length = len; + for (size_t i = 0; i < dim; i++) + result.ptr[i] = this.ptr[i] | e2.ptr[i]; + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opOr unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + BitArray c = a | b; + + assert(c[0] == 1); + assert(c[1] == 0); + assert(c[2] == 1); + assert(c[3] == 1); + assert(c[4] == 1); + } + + + /*************************************** + * Support for binary operator ^ for bit arrays. + */ + BitArray opXor(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + BitArray result; + + result.length = len; + for (size_t i = 0; i < dim; i++) + result.ptr[i] = this.ptr[i] ^ e2.ptr[i]; + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opXor unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + BitArray c = a ^ b; + + assert(c[0] == 0); + assert(c[1] == 0); + assert(c[2] == 0); + assert(c[3] == 1); + assert(c[4] == 1); + } + + + /*************************************** + * Support for binary operator - for bit arrays. + * + * $(I a - b) for BitArrays means the same thing as $(I a & ~b). + */ + BitArray opSub(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + BitArray result; + + result.length = len; + for (size_t i = 0; i < dim; i++) + result.ptr[i] = this.ptr[i] & ~e2.ptr[i]; + return result; + } + + unittest + { + debug(bitarray) printf("BitArray.opSub unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + BitArray c = a - b; + + assert(c[0] == 0); + assert(c[1] == 0); + assert(c[2] == 0); + assert(c[3] == 0); + assert(c[4] == 1); + } + + + /*************************************** + * Support for operator &= bit arrays. + */ + BitArray opAndAssign(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + for (size_t i = 0; i < dim; i++) + ptr[i] &= e2.ptr[i]; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opAndAssign unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + a &= b; + assert(a[0] == 1); + assert(a[1] == 0); + assert(a[2] == 1); + assert(a[3] == 0); + assert(a[4] == 0); + } + + + /*************************************** + * Support for operator |= for bit arrays. + */ + BitArray opOrAssign(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + for (size_t i = 0; i < dim; i++) + ptr[i] |= e2.ptr[i]; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opOrAssign unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + a |= b; + assert(a[0] == 1); + assert(a[1] == 0); + assert(a[2] == 1); + assert(a[3] == 1); + assert(a[4] == 1); + } + + /*************************************** + * Support for operator ^= for bit arrays. + */ + BitArray opXorAssign(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + for (size_t i = 0; i < dim; i++) + ptr[i] ^= e2.ptr[i]; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opXorAssign unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + a ^= b; + assert(a[0] == 0); + assert(a[1] == 0); + assert(a[2] == 0); + assert(a[3] == 1); + assert(a[4] == 1); + } + + /*************************************** + * Support for operator -= for bit arrays. + * + * $(I a -= b) for BitArrays means the same thing as $(I a &= ~b). + */ + BitArray opSubAssign(BitArray e2) + in + { + assert(len == e2.length); + } + body + { + auto dim = this.dim(); + + for (size_t i = 0; i < dim; i++) + ptr[i] &= ~e2.ptr[i]; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opSubAssign unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + static bool[] bb = [1,0,1,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + + a -= b; + assert(a[0] == 0); + assert(a[1] == 0); + assert(a[2] == 0); + assert(a[3] == 0); + assert(a[4] == 1); + } + + /*************************************** + * Support for operator ~= for bit arrays. + */ + + BitArray opCatAssign(bool b) + { + length = len + 1; + (*this)[len - 1] = b; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opCatAssign unittest\n"); + + static bool[] ba = [1,0,1,0,1]; + + BitArray a; a.init(ba); + BitArray b; + + b = (a ~= true); + assert(a[0] == 1); + assert(a[1] == 0); + assert(a[2] == 1); + assert(a[3] == 0); + assert(a[4] == 1); + assert(a[5] == 1); + + assert(b == a); + } + + /*************************************** + * ditto + */ + + BitArray opCatAssign(BitArray b) + { + auto istart = len; + length = len + b.length; + for (auto i = istart; i < len; i++) + (*this)[i] = b[i - istart]; + return *this; + } + + unittest + { + debug(bitarray) printf("BitArray.opCatAssign unittest\n"); + + static bool[] ba = [1,0]; + static bool[] bb = [0,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + BitArray c; + + c = (a ~= b); + assert(a.length == 5); + assert(a[0] == 1); + assert(a[1] == 0); + assert(a[2] == 0); + assert(a[3] == 1); + assert(a[4] == 0); + + assert(c == a); + } + + /*************************************** + * Support for binary operator ~ for bit arrays. + */ + BitArray opCat(bool b) + { + BitArray r; + + r = this.dup; + r.length = len + 1; + r[len] = b; + return r; + } + + /** ditto */ + BitArray opCat_r(bool b) + { + BitArray r; + + r.length = len + 1; + r[0] = b; + for (size_t i = 0; i < len; i++) + r[1 + i] = (*this)[i]; + return r; + } + + /** ditto */ + BitArray opCat(BitArray b) + { + BitArray r; + + r = this.dup(); + r ~= b; + return r; + } + + unittest + { + debug(bitarray) printf("BitArray.opCat unittest\n"); + + static bool[] ba = [1,0]; + static bool[] bb = [0,1,0]; + + BitArray a; a.init(ba); + BitArray b; b.init(bb); + BitArray c; + + c = (a ~ b); + assert(c.length == 5); + assert(c[0] == 1); + assert(c[1] == 0); + assert(c[2] == 0); + assert(c[3] == 1); + assert(c[4] == 0); + + c = (a ~ true); + assert(c.length == 3); + assert(c[0] == 1); + assert(c[1] == 0); + assert(c[2] == 1); + + c = (false ~ a); + assert(c.length == 3); + assert(c[0] == 0); + assert(c[1] == 1); + assert(c[2] == 0); + } +} diff -uNr dmd-0.147/dmd/src/phobos/std/boxer.d dmd-0.148/dmd/src/phobos/std/boxer.d --- dmd-0.147/dmd/src/phobos/std/boxer.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/boxer.d 2006-02-25 17:39:18.000000000 +0100 @@ -49,12 +49,12 @@ * Finally, you can discover whether unboxing as a certain type is legal by * using the unboxable template or method: * - * bit unboxable!(T) (Box value); - * bit Box.unboxable(TypeInfo T); + * bool unboxable!(T) (Box value); + * bool Box.unboxable(TypeInfo T); */ /** Return the next type in an array typeinfo, or null if there is none. */ -private bit isArrayTypeInfo(TypeInfo type) +private bool isArrayTypeInfo(TypeInfo type) { char[] name = type.classinfo.name; return name.length >= 10 && name[9] == 'A' && name != "TypeInfo_AssociativeArray"; @@ -63,7 +63,8 @@ /** The type class returned from Box.findTypeClass; the order of entries is important. */ private enum TypeClass { - Bit, /**< bit */ + Bool, /**< bool */ + Bit = Bool, // for backwards compatibility Integer, /**< byte, ubyte, short, ushort, int, uint, long, ulong */ Float, /**< float, double, real */ Complex, /**< cfloat, cdouble, creal */ @@ -105,7 +106,8 @@ return TypeClass.Other; switch (type.classinfo.name[9]) { - case 'b': return TypeClass.Bit; + //case 'b': return TypeClass.Bit; + case 'x': return TypeClass.Bool; case 'g', 'h', 's', 't', 'i', 'k', 'l', 'm': return TypeClass.Integer; case 'f', 'd', 'e': return TypeClass.Float; case 'q', 'r', 'c': return TypeClass.Complex; @@ -118,7 +120,7 @@ /* Use the name returned from toString, which might (but hopefully doesn't) include an allocation. */ switch (type.toString) { - case "bit": return TypeClass.Bit; + case "bool": return TypeClass.Bool; case "byte", "ubyte", "short", "ushort", "int", "uint", "long", "ulong": return TypeClass.Integer; case "float", "real", "double": return TypeClass.Float; case "cfloat", "cdouble", "creal": return TypeClass.Complex; @@ -129,7 +131,7 @@ } /** Return whether this value could be unboxed as the given type without throwing. */ - bit unboxable(TypeInfo test) + bool unboxable(TypeInfo test) { if (type is test) return true; @@ -158,7 +160,7 @@ return (cast(TypeInfo_Pointer)type).next is (cast(TypeInfo_Pointer)test).next; if ((ta == tb && ta != TypeClass.Other) - || (ta == TypeClass.Bit && tb == TypeClass.Integer) + || (ta == TypeClass.Bool && tb == TypeClass.Integer) || (ta <= TypeClass.Integer && tb == TypeClass.Float) || (ta <= TypeClass.Imaginary && tb == TypeClass.Complex)) return true; @@ -207,7 +209,7 @@ return string; } - private bit opEqualsInternal(Box other, bit inverted) + private bool opEqualsInternal(Box other, bool inverted) { if (type != other.type) { @@ -238,16 +240,16 @@ assert (0); } - return cast(bit)type.equals(data, other.data); + return cast(bool)type.equals(data, other.data); } /** Implement the equals operator. */ - bit opEquals(Box other) + bool opEquals(Box other) { return opEqualsInternal(other, false); } - private float opCmpInternal(Box other, bit inverted) + private float opCmpInternal(Box other, bool inverted) { if (type != other.type) { @@ -434,8 +436,8 @@ return cast(T) *cast(long*) value.data; if (value.type is typeid(ulong)) return cast(T) *cast(ulong*) value.data; - if (value.type is typeid(bit)) - return cast(T) *cast(bit*) value.data; + if (value.type is typeid(bool)) + return cast(T) *cast(bool*) value.data; if (value.type is typeid(byte)) return cast(T) *cast(byte*) value.data; if (value.type is typeid(ubyte)) @@ -602,7 +604,7 @@ */ template unboxable(T) { - bit unboxable(Box value) + bool unboxable(Box value) { return value.unboxable(typeid(T)); } @@ -614,7 +616,7 @@ T unboxTest(Box value) { T result; - bit unboxable = value.unboxable(typeid(T)); + bool unboxable = value.unboxable(typeid(T)); try result = unbox!(T) (value); catch (UnboxException error) @@ -641,7 +643,7 @@ Box a, b; /* Call the function, catch UnboxException, return that it threw correctly. */ - bit fails(void delegate()func) + bool fails(void delegate()func) { try func(); catch (UnboxException error) @@ -719,7 +721,7 @@ assert (box(4) > box(3.0)); assert (box(0+3i) < box(0+4i)); - /* Assert that casting from bit to int works. */ + /* Assert that casting from bool to int works. */ assert (1 == unboxTest!(int)(box(true))); assert (box(1) == box(true)); @@ -746,8 +748,8 @@ assert (unboxTest!(void*)(box(p))); // int[] assert (unboxTest!(void*)(box(new A))); // Object - /* Assert that we can't unbox an integer as bit. */ - assert (!unboxable!(bit) (box(4))); + /* Assert that we can't unbox an integer as bool. */ + assert (!unboxable!(bool) (box(4))); /* Assert that we can't unbox a struct as another struct. */ SA sa; diff -uNr dmd-0.147/dmd/src/phobos/std/conv.d dmd-0.148/dmd/src/phobos/std/conv.d --- dmd-0.147/dmd/src/phobos/std/conv.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/conv.d 2006-02-25 17:39:18.000000000 +0100 @@ -1,6 +1,6 @@ // Written by Walter Bright -// Copyright (c) 2002-2003 Digital Mars +// Copyright (c) 2002-2006 Digital Mars // All Rights Reserved // www.digitalmars.com // Some parts contributed by David L. Davis @@ -1174,7 +1174,7 @@ real r1; real r2; cfloat cf; - bit b = 0; + bool b = 0; char* endptr; if (!s.length) @@ -1255,7 +1255,7 @@ real r1; real r2; cdouble cd; - bit b = 0; + bool b = 0; char* endptr; if (!s.length) @@ -1332,7 +1332,7 @@ real r1; real r2; creal cr; - bit b = 0; + bool b = 0; char* endptr; if (!s.length) @@ -1419,7 +1419,7 @@ * Grammar: * ['+'|'-'] string floating-point digit {digit} */ -private bit getComplexStrings(in char[] s, out char[] s1, out char[] s2) +private bool getComplexStrings(in char[] s, out char[] s1, out char[] s2) { int len = s.length; @@ -1471,18 +1471,18 @@ /**************************************** * Main function to compare reals with given precision */ -private bit feq(in real rx, in real ry, in real precision) +private bool feq(in real rx, in real ry, in real precision) { if (rx == ry) return 1; if (isnan(rx)) - return cast(bit)isnan(ry); + return cast(bool)isnan(ry); if (isnan(ry)) return 0; - return cast(bit)(fabs(rx - ry) <= precision); + return cast(bool)(fabs(rx - ry) <= precision); } /**************************************** @@ -1493,24 +1493,24 @@ * 1 match * 0 nomatch */ -private bit feq(in real r1, in real r2) +private bool feq(in real r1, in real r2) { if (r1 == r2) return 1; if (isnan(r1)) - return cast(bit)isnan(r2); + return cast(bool)isnan(r2); if (isnan(r2)) return 0; - return cast(bit)(feq(r1, r2, 0.000001L)); + return cast(bool)(feq(r1, r2, 0.000001L)); } /**************************************** * compare ireals with given precision */ -private bit feq(in ireal r1, in ireal r2) +private bool feq(in ireal r1, in ireal r2) { real rx = cast(real)r1; real ry = cast(real)r2; @@ -1519,7 +1519,7 @@ return 1; if (isnan(rx)) - return cast(bit)isnan(ry); + return cast(bool)isnan(ry); if (isnan(ry)) return 0; @@ -1530,7 +1530,7 @@ /**************************************** * compare creals with given precision */ -private bit feq(in creal r1, in creal r2) +private bool feq(in creal r1, in creal r2) { real r1a = fabs(cast(real)r1.re - cast(real)r2.re); real r2b = fabs(cast(real)r1.im - cast(real)r2.im); @@ -1540,7 +1540,7 @@ return 1; if (isnan(r1a)) - return cast(bit)isnan(r2b); + return cast(bool)isnan(r2b); if (isnan(r2b)) return 0; diff -uNr dmd-0.147/dmd/src/phobos/std/cover.d dmd-0.148/dmd/src/phobos/std/cover.d --- dmd-0.147/dmd/src/phobos/std/cover.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/cover.d 2006-02-25 17:39:18.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 by Digital Mars, www.digitalmars.com + * Copyright (C) 2005-2006 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -36,20 +36,21 @@ private import std.stdio; private import std.file; +private import std.bitarray; private { struct Cover { char[] filename; - bit[] valid; + BitArray valid; uint[] data; } Cover[] gdata; char[] srcpath; char[] dstpath; - bit merge; + bool merge; } /*********************************** @@ -78,12 +79,12 @@ * created. */ -void setMerge(bit flag) +void setMerge(bool flag) { merge = flag; } -extern (C) void _d_cover_register(char[] filename, bit[] valid, uint[] data) +extern (C) void _d_cover_register(char[] filename, BitArray valid, uint[] data) { //printf("_d_cover_register()\n"); //printf("\tfilename = '%.*s'\n", filename); diff -uNr dmd-0.147/dmd/src/phobos/std/cstream.d dmd-0.148/dmd/src/phobos/std/cstream.d --- dmd-0.147/dmd/src/phobos/std/cstream.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/cstream.d 2006-02-25 17:39:18.000000000 +0100 @@ -16,8 +16,8 @@ this(FILE* cfile, FileMode mode, bool seekable = false) { super(); this.file = cfile; - readable = cast(bit)(mode & FileMode.In); - writeable = cast(bit)(mode & FileMode.Out); + readable = cast(bool)(mode & FileMode.In); + writeable = cast(bool)(mode & FileMode.Out); this.seekable = seekable; } @@ -46,7 +46,7 @@ } override size_t readBlock(void* buffer, size_t size) { size_t n = fread(buffer,1,size,cfile); - readEOF = cast(bit)(n == 0); + readEOF = cast(bool)(n == 0); return n; } override size_t writeBlock(void* buffer, size_t size) { diff -uNr dmd-0.147/dmd/src/phobos/std/demangle.d dmd-0.148/dmd/src/phobos/std/demangle.d --- dmd-0.147/dmd/src/phobos/std/demangle.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/demangle.d 2006-02-25 17:39:18.000000000 +0100 @@ -40,7 +40,7 @@ int main() { char[] buffer; - bit inword; + bool inword; int c; while ((c = fgetc(stdin)) != EOF) @@ -120,7 +120,7 @@ name[ni + 2] == 'T') { size_t nisave = ni; - bit err; + bool err; ni += 3; try { @@ -170,6 +170,7 @@ { case 'v': p = "void"; goto L1; case 'b': p = "bit"; goto L1; + case 'x': p = "bool"; goto L1; case 'g': p = "byte"; goto L1; case 'h': p = "ubyte"; goto L1; case 's': p = "short"; goto L1; diff -uNr dmd-0.147/dmd/src/phobos/std/file.d dmd-0.148/dmd/src/phobos/std/file.d --- dmd-0.147/dmd/src/phobos/std/file.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/file.d 2006-02-25 17:39:18.000000000 +0100 @@ -1164,6 +1164,7 @@ { size_t len = std.string.strlen(fd.d_name); name = std.path.join(path, fd.d_name[0 .. len]); d_type = fd.d_type; + didstat = 0; } int isdir() diff -uNr dmd-0.147/dmd/src/phobos/std/format.d dmd-0.148/dmd/src/phobos/std/format.d --- dmd-0.147/dmd/src/phobos/std/format.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/format.d 2006-02-25 17:39:18.000000000 +0100 @@ -38,6 +38,8 @@ private import std.c.stdlib; private import std.string; +alias bool bit; + version (Windows) { version (DigitalMars) @@ -81,6 +83,7 @@ { Tvoid = 'v', Tbit = 'b', + Tbool = 'x', Tbyte = 'g', Tubyte = 'h', Tshort = 's', @@ -130,6 +133,8 @@ ti = typeid(void);break; case Mangle.Tbit: ti = typeid(bit);break; + case Mangle.Tbool: + ti = typeid(bool);break; case Mangle.Tbyte: ti = typeid(byte);break; case Mangle.Tubyte: @@ -325,7 +330,7 @@
The corresponding argument is formatted in a manner consistent with its type:
-
$(B bit) +
$(B bool)
The result is 'true' or 'false'.
integral types
The $(B %d) format is used. @@ -351,7 +356,7 @@ and is formatted as an integer. If the argument is a signed type and the $(I FormatChar) is $(B d) it is converted to a signed string of characters, otherwise it is treated as - unsigned. An argument of type $(B bit) is formatted as '1' + unsigned. An argument of type $(B bool) is formatted as '1' or '0'. The base used is binary for $(B b), octal for $(B o), decimal for $(B d), and hexadecimal for $(B x) or $(B X). @@ -456,7 +461,7 @@ void formatArg(char fc) { - bit vbit; + bool vbit; ulong vnumber; char vchar; dchar vdchar; @@ -604,7 +609,8 @@ switch (m) { case Mangle.Tbit: - vbit = va_arg!(bit)(argptr); + case Mangle.Tbool: + vbit = va_arg!(bool)(argptr); if (fc != 's') { vnumber = vbit; goto Lnumber; diff -uNr dmd-0.147/dmd/src/phobos/std/intrinsic.d dmd-0.148/dmd/src/phobos/std/intrinsic.d --- dmd-0.147/dmd/src/phobos/std/intrinsic.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/intrinsic.d 2006-02-25 17:39:18.000000000 +0100 @@ -1,11 +1,10 @@ -// Copyright (c) 1999-2003 by Digital Mars -// All Rights Reserved // written by Walter Bright // www.digitalmars.com +// Placed into the public domain -/* These functions are built-in intrinsics to the compiler. +/** These functions are built-in intrinsics to the compiler. */ module std.intrinsic; diff -uNr dmd-0.147/dmd/src/phobos/std/math2.d dmd-0.148/dmd/src/phobos/std/math2.d --- dmd-0.147/dmd/src/phobos/std/math2.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/math2.d 2006-02-25 17:39:18.000000000 +0100 @@ -20,12 +20,12 @@ * compare floats with given precision */ -bit feq(real a, real b) +bool feq(real a, real b) { return feq(a, b, 0.000001); } -bit feq(real a, real b, real eps) +bool feq(real a, real b, real eps) { return abs(a - b) <= eps; } @@ -761,7 +761,7 @@ while (s[i] == '\t' || s[i] == ' ') if (++i >= s.length) return real.nan; - bit neg = false; + bool neg = false; if (s[i] == '-') { neg = true; @@ -771,7 +771,7 @@ i++; if (i >= s.length) return real.nan; - bit hex; + bool hex; if (s[s.length - 1] == 'h') { hex = true; @@ -859,7 +859,7 @@ } if (++i >= s.length) return real.nan; - bit eneg = false; + bool eneg = false; if (s[i] == '-') { eneg = true; diff -uNr dmd-0.147/dmd/src/phobos/std/math.d dmd-0.148/dmd/src/phobos/std/math.d --- dmd-0.147/dmd/src/phobos/std/math.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/math.d 2006-02-25 17:39:18.000000000 +0100 @@ -1677,13 +1677,13 @@ } // Returns true if x is +0.0 (This function is used in unit tests) -bit isPosZero(real x) +bool isPosZero(real x) { return (x == 0) && (signbit(x) == 0); } // Returns true if x is -0.0 (This function is used in unit tests) -bit isNegZero(real x) +bool isNegZero(real x) { return (x == 0) && signbit(x); } diff -uNr dmd-0.147/dmd/src/phobos/std/mmfile.d dmd-0.148/dmd/src/phobos/std/mmfile.d --- dmd-0.147/dmd/src/phobos/std/mmfile.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/mmfile.d 2006-02-25 17:39:18.000000000 +0100 @@ -259,7 +259,7 @@ errNo(); } - data = p[0 .. size]; + data = p[0 .. initial_map]; } else { diff -uNr dmd-0.147/dmd/src/phobos/std/path.d dmd-0.148/dmd/src/phobos/std/path.d --- dmd-0.147/dmd/src/phobos/std/path.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/path.d 2006-02-25 17:39:18.000000000 +0100 @@ -3,8 +3,7 @@ * Macros: * WIKI = StdPath * Copyright: - * Copyright (c) 2001-2006 by Digital Mars - * All Rights Reserved + * Placed into public domain. * www.digitalmars.com * * Grzegorz Adam Hankiewicz added some documentation. @@ -537,7 +536,12 @@ { char[] d = getDrive(path); - return d.length < path.length && path[d.length] == sep[0]; + version (Windows) + { + return d.length && d.length < path.length && path[d.length] == sep[0]; + } + else + return d.length < path.length && path[d.length] == sep[0]; } unittest diff -uNr dmd-0.147/dmd/src/phobos/std/regexp.d dmd-0.148/dmd/src/phobos/std/regexp.d --- dmd-0.147/dmd/src/phobos/std/regexp.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/regexp.d 2006-02-25 17:39:18.000000000 +0100 @@ -100,6 +100,7 @@ import std.string; import std.ctype; import std.outbuffer; + import std.bitarray; } /** Regular expression to extract an _email address */ @@ -335,6 +336,21 @@ * attributes = Regular expression attributes. * Returns: * corresponding RegExp if found, null if not. + * Example: + * --- + * import std.stdio; + * import std.regexp; + * + * void main() + * { + * if (m; std.regexp.search("abcdef", "c")) + * { + * writefln("%s[%s]%s", m.pre, m.match(0), m.post); + * } + * } + * // Prints: + * // ab[c]def + * --- */ RegExp search(char[] string, char[] pattern, char[] attributes = null) @@ -388,41 +404,51 @@ return new RegExp(pattern, attributes); } - /********** - * Determine if there is an initial match with string[]. + /************************************ + * Set up for start of foreach loop. * Returns: - * $(B this) if there is a match, null if not + * search() returns instance of RegExp set up to _search string[]. * Example: - * This makes it possible - * to use RegExp's in a $(I MatchExpression): * --- - * if (RegExp("^abc") ~~ string) - * writefln("string starts with 'abc'"); + * import std.stdio; + * import std.regexp; + * + * void main() + * { + * foreach(m; RegExp("ab").search("abcabcabab")) + * { + * writefln("%s[%s]%s", m.pre, m.match(0), m.post); + * } + * } + * // Prints: + * // [ab]cabcabab + * // abc[ab]cabab + * // abcabc[ab]ab + * // abcabcab[ab] * --- */ - public RegExp opMatch(char[] string) + + public RegExp search(rchar[] string) { - return test(input, 0) ? this : null; + input = string; + pmatch[0].rm_eo = 0; + return this; } - /************ - * Determine next match in string. - * Returns: - * $(B this) if there is a match, null if not - * Example: - * This makes it possible, along with $(B opMatch) operator overload, - * to use RegExp's in a $(I WhileStatement): - * --- - * RegExp r = new RegExp("[a..c]"); - * writef("'"); - * while (r ~~ "abdd3cce") - * writef(_match.match(0)); - * writefln("'"); // writes 'abcc' - * --- - */ - public RegExp opNext() + /** ditto */ + public int opApply(int delegate(inout RegExp) dg) { - return test(input, pmatch[0].rm_eo) ? this : null; + int result; + RegExp r = this; + + while (test()) + { + result = dg(r); + if (result) + break; + } + + return result; } /****************** @@ -725,7 +751,7 @@ return i; } -deprecated alias find search; +//deprecated alias find search; unittest { @@ -2090,7 +2116,7 @@ uint maxb; OutBuffer buf; ubyte* base; - bit[] bits; + BitArray bits; this(OutBuffer buf) { @@ -2102,6 +2128,7 @@ void setbitmax(uint u) { uint b; + //printf("setbitmax(x%x), maxc = x%x\n", u, maxc); if (u > maxc) { maxc = u; @@ -2113,8 +2140,10 @@ buf.fill0(b - maxb + 1); base = &buf.data[u]; maxb = b + 1; - bits = (cast(bit*)this.base)[0 .. maxc + 1]; + //bits = (cast(bit*)this.base)[0 .. maxc + 1]; + bits.ptr = cast(uint*)this.base; } + bits.len = maxc + 1; } } diff -uNr dmd-0.147/dmd/src/phobos/std/socket.d dmd-0.148/dmd/src/phobos/std/socket.d --- dmd-0.147/dmd/src/phobos/std/socket.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/socket.d 2006-02-25 17:39:18.000000000 +0100 @@ -197,7 +197,7 @@ } - bit getProtocolByName(char[] name) + bool getProtocolByName(char[] name) { protoent* proto; proto = getprotobyname(toStringz(name)); @@ -209,7 +209,7 @@ // Same as getprotobynumber(). - bit getProtocolByType(ProtocolType type) + bool getProtocolByType(ProtocolType type) { protoent* proto; proto = getprotobynumber(type); @@ -269,7 +269,7 @@ } - bit getServiceByName(char[] name, char[] protocolName) + bool getServiceByName(char[] name, char[] protocolName) { servent* serv; serv = getservbyname(toStringz(name), toStringz(protocolName)); @@ -281,7 +281,7 @@ // Any protocol name will be matched. - bit getServiceByName(char[] name) + bool getServiceByName(char[] name) { servent* serv; serv = getservbyname(toStringz(name), null); @@ -292,7 +292,7 @@ } - bit getServiceByPort(ushort port, char[] protocolName) + bool getServiceByPort(ushort port, char[] protocolName) { servent* serv; serv = getservbyport(port, toStringz(protocolName)); @@ -304,7 +304,7 @@ // Any protocol name will be matched. - bit getServiceByPort(ushort port) + bool getServiceByPort(ushort port) { servent* serv; serv = getservbyport(port, null); @@ -411,7 +411,7 @@ } - bit getHostByName(char[] name) + bool getHostByName(char[] name) { hostent* he = gethostbyname(toStringz(name)); if(!he) @@ -422,7 +422,7 @@ } - bit getHostByAddr(uint addr) + bool getHostByAddr(uint addr) { uint x = htonl(addr); hostent* he = gethostbyaddr(&x, 4, cast(int)AddressFamily.INET); @@ -435,7 +435,7 @@ //shortcut - bit getHostByAddr(char[] addr) + bool getHostByAddr(char[] addr) { uint x = inet_addr(std.string.toStringz(addr)); hostent* he = gethostbyaddr(&x, 4, cast(int)AddressFamily.INET); @@ -922,7 +922,7 @@ AddressFamily _family; version(Win32) - bit _blocking = false; + bool _blocking = false; // For use with accepting(). @@ -972,7 +972,7 @@ } - bit blocking() // getter + bool blocking() // getter { version(Win32) { @@ -985,7 +985,7 @@ } - void blocking(bit byes) // setter + void blocking(bool byes) // setter { version(Win32) { @@ -1019,7 +1019,7 @@ } - bit isAlive() // getter + bool isAlive() // getter { int type, typesize = type.sizeof; return !getsockopt(sock, SOL_SOCKET, SO_TYPE, cast(char*)&type, &typesize); @@ -1439,7 +1439,7 @@ /+ - bit poll(events) + bool poll(events) { int WSAEventSelect(socket_t s, WSAEVENT hEventObject, int lNetworkEvents); // Winsock 2 ? int poll(pollfd* fds, int nfds, int timeout); // Unix ? diff -uNr dmd-0.147/dmd/src/phobos/std/socketstream.d dmd-0.148/dmd/src/phobos/std/socketstream.d --- dmd-0.147/dmd/src/phobos/std/socketstream.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/socketstream.d 2006-02-25 17:39:18.000000000 +0100 @@ -62,7 +62,7 @@ return size; len = sock.receive(buffer[0 .. size]); - readEOF = cast(bit)(len == 0); + readEOF = cast(bool)(len == 0); if(len < 0) len = 0; return len; @@ -78,7 +78,7 @@ return size; len = sock.send(buffer[0 .. size]); - readEOF = cast(bit)(len == 0); + readEOF = cast(bool)(len == 0); if(len < 0) len = 0; return len; diff -uNr dmd-0.147/dmd/src/phobos/std/stream.d dmd-0.148/dmd/src/phobos/std/stream.d --- dmd-0.147/dmd/src/phobos/std/stream.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/stream.d 2006-02-25 17:39:18.000000000 +0100 @@ -380,15 +380,15 @@ private import std.string, crc32, std.c.stdlib, std.c.stdio; // stream abilities - bit readable = false; /// Indicates whether this stream can be read from. - bit writeable = false; /// Indicates whether this stream can be written to. - bit seekable = false; /// Indicates whether this stream can be seeked within. - protected bit isopen = true; /// Indicates whether this stream is open. + bool readable = false; /// Indicates whether this stream can be read from. + bool writeable = false; /// Indicates whether this stream can be written to. + bool seekable = false; /// Indicates whether this stream can be seeked within. + protected bool isopen = true; /// Indicates whether this stream is open. - protected bit readEOF = false; /// Indicates whether this stream is at eof + protected bool readEOF = false; /// Indicates whether this stream is at eof /// after the last read attempt. - protected bit prevCr = false; /// For a non-seekable stream indicates that + protected bool prevCr = false; /// For a non-seekable stream indicates that /// the last readLine or readLineW ended on a /// '\r' character. @@ -712,7 +712,7 @@ } if (fmt[i] == '%') { // a field i++; - bit suppress = false; + bool suppress = false; if (fmt[i] == '*') { // suppress assignment suppress = true; i++; @@ -745,7 +745,7 @@ c = getc(); count++; } - bit neg = false; + bool neg = false; if (c == '-') { neg = true; c = getc(); @@ -846,7 +846,7 @@ c = getc(); count++; } - bit neg = false; + bool neg = false; if (c == '-') { neg = true; c = getc(); @@ -881,7 +881,7 @@ c = getc(); count++; if (width) { - bit expneg = false; + bool expneg = false; if (c == '-') { expneg = true; width--; @@ -1249,7 +1249,7 @@ } // returns true if end of stream is reached, false otherwise - bit eof() { + bool eof() { // for unseekable streams we only know the end when we read it if (readEOF && !ungetAvailable()) return true; @@ -1366,7 +1366,7 @@ /// Property indicating when this stream closes to close the source stream as /// well. /// Defaults to true. - bit nestClose = true; + bool nestClose = true; /// Construct a FilterStream for the given source. this(Stream source) { @@ -1455,7 +1455,7 @@ ubyte[] buffer; // buffer, if any uint bufferCurPos; // current position in buffer uint bufferLen; // amount of data in buffer - bit bufferDirty = false; + bool bufferDirty = false; uint bufferSourcePos; // position in buffer of source stream position ulong streamPos; // absolute position in source stream @@ -1796,8 +1796,8 @@ this(HANDLE hFile, FileMode mode) { super(); this.hFile = hFile; - readable = cast(bit)(mode & FileMode.In); - writeable = cast(bit)(mode & FileMode.Out); + readable = cast(bool)(mode & FileMode.In); + writeable = cast(bool)(mode & FileMode.Out); version(Windows) { seekable = GetFileType(hFile) == 1; // FILE_TYPE_DISK } else { @@ -1831,8 +1831,8 @@ int access, share, createMode; parseMode(mode, access, share, createMode); seekable = true; - readable = cast(bit)(mode & FileMode.In); - writeable = cast(bit)(mode & FileMode.Out); + readable = cast(bool)(mode & FileMode.In); + writeable = cast(bool)(mode & FileMode.Out); version (Win32) { if (std.file.useWfuncs) { hFile = CreateFileW(std.utf.toUTF16z(filename), access, share, @@ -2737,7 +2737,7 @@ ulong pos; // our position relative to low ulong low; // low stream offset. ulong high; // high stream offset. - bit bounded; // upper-bounded by high. + bool bounded; // upper-bounded by high. } /*** @@ -2905,18 +2905,18 @@ } // helper functions -private bit iswhite(char c) { +private bool iswhite(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } -private bit isdigit(char c) { +private bool isdigit(char c) { return c >= '0' && c <= '9'; } -private bit isoctdigit(char c) { +private bool isoctdigit(char c) { return c >= '0' && c <= '7'; } -private bit ishexdigit(char c) { +private bool ishexdigit(char c) { return isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); } diff -uNr dmd-0.147/dmd/src/phobos/std/string.d dmd-0.148/dmd/src/phobos/std/string.d --- dmd-0.147/dmd/src/phobos/std/string.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/string.d 2006-02-25 17:39:18.000000000 +0100 @@ -1730,6 +1730,8 @@ int istart; //printf("replace('%.*s','%.*s','%.*s')\n", s, from, to); + if (from.length == 0) + return s; istart = 0; while (istart < s.length) { @@ -1759,6 +1761,10 @@ r = replace(s, from, to); i = cmp(r, "This is a silly silly list"); assert(i == 0); + + r = replace(s, "", to); + i = cmp(r, "This is a foo foo list"); + assert(i == 0); } /***************************** @@ -2168,7 +2174,7 @@ { char[] r; int count; - bit[256] deltab; + bool[256] deltab; deltab[] = false; foreach (char c; delchars) @@ -2220,7 +2226,7 @@ * Convert to char[]. */ -char[] toString(bit b) +char[] toString(bool b) { return b ? "true" : "false"; } diff -uNr dmd-0.147/dmd/src/phobos/std/typeinfo/ti_Abit.d dmd-0.148/dmd/src/phobos/std/typeinfo/ti_Abit.d --- dmd-0.147/dmd/src/phobos/std/typeinfo/ti_Abit.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/typeinfo/ti_Abit.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,97 +0,0 @@ - -module std.typeinfo.ti_Abit; - -private import std.string; - -// bit[] - -class TypeInfo_Ab : TypeInfo -{ - char[] toString() { return "bit[]"; } - - uint getHash(void *p) - { ubyte[] s = *cast(ubyte[]*)p; - size_t len = (s.length + 7) / 8; - ubyte *str = s; - uint hash = 0; - - while (1) - { - switch (len) - { - case 0: - return hash; - - case 1: - hash *= 9; - hash += *cast(ubyte *)str; - return hash; - - case 2: - hash *= 9; - hash += *cast(ushort *)str; - return hash; - - case 3: - hash *= 9; - hash += (*cast(ushort *)str << 8) + - (cast(ubyte *)str)[2]; - return hash; - - default: - hash *= 9; - hash += *cast(uint *)str; - str += 4; - len -= 4; - break; - } - } - - return hash; - } - - int equals(void *p1, void *p2) - { - bit[] s1 = *cast(bit[]*)p1; - bit[] s2 = *cast(bit[]*)p2; - - size_t len = s1.length; - - if (s2.length != len) - return 0;; - - // Woefully inefficient bit-by-bit comparison - for (size_t u = 0; u < len; u++) - { - if (s1[u] != s2[u]) - return 0; - } - return 1; - } - - int compare(void *p1, void *p2) - { - bit[] s1 = *cast(bit[]*)p1; - bit[] s2 = *cast(bit[]*)p2; - - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - - // Woefully inefficient bit-by-bit comparison - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - return cast(int)s1.length - cast(int)s2.length; - } - - size_t tsize() - { - return (bit[]).sizeof; - } -} - diff -uNr dmd-0.147/dmd/src/phobos/std/typeinfo/ti_Aubyte.d dmd-0.148/dmd/src/phobos/std/typeinfo/ti_Aubyte.d --- dmd-0.147/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/typeinfo/ti_Aubyte.d 2006-02-25 17:39:18.000000000 +0100 @@ -79,3 +79,10 @@ { char[] toString() { return "void[]"; } } + +// bool[] + +class TypeInfo_Ax : TypeInfo_Ah +{ + char[] toString() { return "bool[]"; } +} diff -uNr dmd-0.147/dmd/src/phobos/std/typeinfo/ti_bit.d dmd-0.148/dmd/src/phobos/std/typeinfo/ti_bit.d --- dmd-0.147/dmd/src/phobos/std/typeinfo/ti_bit.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/typeinfo/ti_bit.d 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ - -// bit - -module std.typeinfo.ti_bit; - -class TypeInfo_b : TypeInfo -{ - char[] toString() { return "bit"; } - - uint getHash(void *p) - { - return *cast(bit *)p; - } - - int equals(void *p1, void *p2) - { - return *cast(bit *)p1 == *cast(bit *)p2; - } - - int compare(void *p1, void *p2) - { - if (*cast(bit*) p1 < *cast(bit*) p2) - return -1; - else if (*cast(bit*) p1 > *cast(bit*) p2) - return 1; - return 0; - } - - size_t tsize() - { - return bit.sizeof; - } - - void swap(void *p1, void *p2) - { - bit t; - - t = *cast(bit *)p1; - *cast(bit *)p1 = *cast(bit *)p2; - *cast(bit *)p2 = t; - } -} - diff -uNr dmd-0.147/dmd/src/phobos/std/typeinfo/ti_ubyte.d dmd-0.148/dmd/src/phobos/std/typeinfo/ti_ubyte.d --- dmd-0.147/dmd/src/phobos/std/typeinfo/ti_ubyte.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/typeinfo/ti_ubyte.d 2006-02-25 17:39:18.000000000 +0100 @@ -37,3 +37,7 @@ } } +class TypeInfo_x : TypeInfo_h +{ + char[] toString() { return "bool"; } +} diff -uNr dmd-0.147/dmd/src/phobos/std/utf.d dmd-0.148/dmd/src/phobos/std/utf.d --- dmd-0.147/dmd/src/phobos/std/utf.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/std/utf.d 2006-02-25 17:39:18.000000000 +0100 @@ -82,7 +82,7 @@ * Returns: true if it is, false if not. */ -bit isValidDchar(dchar c) +bool isValidDchar(dchar c) { /* Note: FFFE and FFFF are specifically permitted by the * Unicode standard for application internal use, but are not diff -uNr dmd-0.147/dmd/src/phobos/unittest.d dmd-0.148/dmd/src/phobos/unittest.d --- dmd-0.147/dmd/src/phobos/unittest.d 2006-02-15 13:48:54.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/unittest.d 2006-02-25 17:39:18.000000000 +0100 @@ -47,6 +47,7 @@ import std.stdio; import std.conv; import std.boxer; +import std.bitarray; int main(char[][] args) { @@ -103,6 +104,10 @@ std.demangle.demangle("hello"); + BitArray ba; // std.bitarray + ba.length = 3; + ba[0] = true; + printf("Success\n!"); return 0; } diff -uNr dmd-0.147/dmd/src/phobos/win32.mak dmd-0.148/dmd/src/phobos/win32.mak --- dmd-0.147/dmd/src/phobos/win32.mak 2006-02-15 13:48:52.000000000 +0100 +++ dmd-0.148/dmd/src/phobos/win32.mak 2006-02-25 17:39:18.000000000 +0100 @@ -73,7 +73,7 @@ socket.obj socketstream.obj loader.obj stdarg.obj format.obj stdio.obj \ perf.obj openrj.obj uni.obj winsock.obj oldsyserror.obj \ errno.obj boxer.obj cstream.obj charset.obj \ - realtest.obj gamma.obj demangle.obj cover.obj match.obj \ + realtest.obj gamma.obj demangle.obj cover.obj \ ti_Aa.obj ti_Ag.obj ti_C.obj ti_int.obj ti_char.obj \ ti_wchar.obj ti_uint.obj ti_short.obj ti_ushort.obj \ ti_byte.obj ti_ubyte.obj ti_long.obj ti_ulong.obj ti_ptr.obj \ @@ -148,7 +148,7 @@ internal\memset.d internal\arraycast.d internal\aaA.d internal\adi.d \ internal\dmain2.d internal\cast.d internal\qsort.d internal\deh2.d \ internal\cmath2.d internal\obj.d internal\mars.h internal\aApply.d \ - internal\object.d internal\trace.d internal\qsort2.d internal\match.d + internal\object.d internal\trace.d internal\qsort2.d SRC_STD_WIN= std\windows\registry.d \ std\windows\iunknown.d std\windows\syserror.d std\windows\charset.d @@ -427,9 +427,6 @@ invariant.obj : internal\invariant.d $(DMD) -c $(DFLAGS) internal\invariant.d -match.obj : internal\match.d - $(DMD) -c $(DFLAGS) internal\match.d - memset.obj : internal\memset.d $(DMD) -c $(DFLAGS) internal\memset.d