diff -uNr dmd-0.137/dmd/src/dmd/doc.c dmd-0.138/dmd/src/dmd/doc.c --- dmd-0.137/dmd/src/dmd/doc.c 2005-10-14 21:47:42.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/doc.c 2005-11-05 15:37:56.000000000 +0100 @@ -147,6 +147,11 @@ DDOC_SECTION_H = $(B $0)$(BR)\n\ DDOC_SECTION = $0$(BR)$(BR)\n\ DDOC_MEMBERS = $(DL $0)\n\ +DDOC_MODULE_MEMBERS = $(DDOC_MEMBERS $0)\n\ +DDOC_CLASS_MEMBERS = $(DDOC_MEMBERS $0)\n\ +DDOC_STRUCT_MEMBERS = $(DDOC_MEMBERS $0)\n\ +DDOC_ENUM_MEMBERS = $(DDOC_MEMBERS $0)\n\ +DDOC_TEMPLATE_MEMBERS = $(DDOC_MEMBERS $0)\n\ DDOC_PARAMS = $(B Params:)$(BR)\n$(TABLE $0)$(BR)\n\ DDOC_PARAM_ROW = $(TR $0)\n\ DDOC_PARAM_ID = $(TD $0)\n\ @@ -345,9 +350,21 @@ OutBuffer *buf = sc->docbuf; if (members) - { + { char *m = "$(DDOC_MEMBERS \n"; + + if (isModule()) + m = "$(DDOC_MODULE_MEMBERS \n"; + else if (isClassDeclaration()) + m = "$(DDOC_CLASS_MEMBERS \n"; + else if (isStructDeclaration()) + m = "$(DDOC_STRUCT_MEMBERS \n"; + else if (isEnumDeclaration()) + m = "$(DDOC_ENUM_MEMBERS \n"; + else if (isTemplateDeclaration()) + m = "$(DDOC_TEMPLATE_MEMBERS \n"; + // BUG: if no members are actually printed, we should not emit DDOC_MEMBERS - buf->writestring("$(DDOC_MEMBERS \n"); + buf->writestring(m); sc = sc->push(this); for (int i = 0; i < members->dim; i++) { @@ -469,7 +486,8 @@ ScopeDsymbol *ss = this; if (onemember) - { ss = onemember->isAggregateDeclaration(); + { + ss = onemember->isAggregateDeclaration(); if (!ss) ss = this; } @@ -483,7 +501,7 @@ buf->writestring(ddoc_decl_dd_s); dc->writeSections(sc, this, buf); - emitMemberComments(sc); + ss->emitMemberComments(sc); buf->writestring(ddoc_decl_dd_e); } diff -uNr dmd-0.137/dmd/src/dmd/expression.h dmd-0.138/dmd/src/dmd/expression.h --- dmd-0.137/dmd/src/dmd/expression.h 2005-07-19 16:14:20.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/expression.h 2005-10-30 15:00:00.000000000 +0100 @@ -711,6 +711,7 @@ Expression *toLvalue(Expression *e); Expression *modifiableLvalue(Scope *sc, Expression *e); void toCBuffer(OutBuffer *buf); + Expression *optimize(int result); void dump(int indent); elem *toElem(IRState *irs); @@ -777,6 +778,7 @@ Expression *toLvalue(Expression *e); Expression *modifiableLvalue(Scope *sc, Expression *e); void toCBuffer(OutBuffer *buf); + Expression *optimize(int result); Expression *doInline(InlineDoState *ids); elem *toElem(IRState *irs); diff -uNr dmd-0.137/dmd/src/dmd/mars.c dmd-0.138/dmd/src/dmd/mars.c --- dmd-0.137/dmd/src/dmd/mars.c 2005-10-17 20:39:24.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/mars.c 2005-11-02 13:30:40.000000000 +0100 @@ -51,7 +51,7 @@ copyright = "Copyright (c) 1999-2005 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.137"; + version = "v0.138"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -139,6 +139,7 @@ -debug=level compile in debug code <= level\n\ -debug=ident compile in debug code identified by ident\n\ -g add symbolic debug info\n\ + --help print help\n\ -Ipath where to look for imports\n\ -inline do function inlining\n\ -Llinkerflag pass linkerflag to link\n\ @@ -236,6 +237,8 @@ global.params.useDeprecated = 1; else if (strcmp(p + 1, "c") == 0) global.params.link = 0; + else if (strcmp(p + 1, "fPIC") == 0) + global.params.pic = 1; else if (strcmp(p + 1, "g") == 0) global.params.symdebug = 1; else if (strcmp(p + 1, "gc") == 0) @@ -379,6 +382,8 @@ global.params.debugc = 1; else if (strcmp(p + 1, "-f") == 0) global.params.debugf = 1; + else if (strcmp(p + 1, "--help") == 0) + usage(); else if (strcmp(p + 1, "-r") == 0) global.params.debugr = 1; else if (strcmp(p + 1, "-x") == 0) diff -uNr dmd-0.137/dmd/src/dmd/mars.h dmd-0.138/dmd/src/dmd/mars.h --- dmd-0.137/dmd/src/dmd/mars.h 2005-09-21 15:05:40.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/mars.h 2005-10-26 00:38:00.000000000 +0200 @@ -42,6 +42,7 @@ char release; // build release version char preservePaths; // !=0 means don't strip path from source file char warnings; // enable warnings + char pic; // generate position-independent-code for shared libs char *argv0; // program name Array *imppath; // array of char*'s of where to look for import modules diff -uNr dmd-0.137/dmd/src/dmd/mtype.c dmd-0.138/dmd/src/dmd/mtype.c --- dmd-0.137/dmd/src/dmd/mtype.c 2005-10-15 00:15:32.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/mtype.c 2005-10-25 14:50:42.000000000 +0200 @@ -3144,6 +3144,15 @@ return tvoid; } +d_uns64 TypeTypeof::size(Loc loc) +{ + if (exp->type) + return exp->type->size(loc); + else + return TypeQualified::size(loc); +} + + /***************************** TypeEnum *****************************/ diff -uNr dmd-0.137/dmd/src/dmd/mtype.h dmd-0.138/dmd/src/dmd/mtype.h --- dmd-0.137/dmd/src/dmd/mtype.h 2005-05-21 01:36:02.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/mtype.h 2005-10-25 14:50:42.000000000 +0200 @@ -469,6 +469,7 @@ Dsymbol *toDsymbol(Scope *sc); void toCBuffer2(OutBuffer *buf, Identifier *ident); Type *semantic(Loc loc, Scope *sc); + d_uns64 size(Loc loc); }; struct TypeStruct : Type diff -uNr dmd-0.137/dmd/src/dmd/optimize.c dmd-0.138/dmd/src/dmd/optimize.c --- dmd-0.137/dmd/src/dmd/optimize.c 2005-05-12 21:21:30.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/optimize.c 2005-10-31 00:34:46.000000000 +0100 @@ -67,7 +67,7 @@ } } if (e1->op == TOKindex) - { // Convert &array[n] to #array+n + { // Convert &array[n] to &array+n IndexExp *ae = (IndexExp *)e1; if (ae->e2->op == TOKint64 && ae->e1->op == TOKvar) @@ -207,6 +207,84 @@ return e; } +Expression *IndexExp::optimize(int result) +{ Expression *e; + + //printf("IndexExp::optimize(result = %d) %s\n", result, toChars()); + e1 = e1->optimize(WANTvalue); + e2 = e2->optimize(WANTvalue); + e = this; + if (e1->op == TOKstring && e2->op == TOKint64) + { StringExp *es1 = (StringExp *)e1; + uinteger_t i = e2->toInteger(); + + if (i >= es1->len) + error("string index %llu is out of bounds", i); + else + { integer_t value; + + switch (es1->sz) + { + case 1: + value = ((unsigned char *)es1->string)[i]; + break; + + case 2: + value = ((unsigned short *)es1->string)[i]; + break; + + case 4: + value = ((unsigned int *)es1->string)[i]; + break; + + default: + assert(0); + break; + } + e = new IntegerExp(loc, value, type); + } + } + return e; +} + +Expression *SliceExp::optimize(int result) +{ Expression *e; + + //printf("SliceExp::optimize(result = %d) %s\n", result, toChars()); + e = this; + e1 = e1->optimize(WANTvalue); + if (!lwr) + return e; + lwr = lwr->optimize(WANTvalue); + upr = upr->optimize(WANTvalue); + if (e1->op == TOKstring && lwr->op == TOKint64 && upr->op == TOKint64) + { StringExp *es1 = (StringExp *)e1; + uinteger_t ilwr = lwr->toInteger(); + uinteger_t iupr = upr->toInteger(); + + if (iupr > es1->len || ilwr > iupr) + error("string slice [%llu .. %llu] is out of bounds", ilwr, iupr); + else + { integer_t value; + void *s; + size_t len = iupr - ilwr; + int sz = es1->sz; + StringExp *es; + + s = mem.malloc((len + 1) * sz); + memcpy((unsigned char *)s, (unsigned char *)es1->string + ilwr * sz, len * sz); + memset((unsigned char *)s + len * sz, 0, sz); + + es = new StringExp(loc, s, len, es1->postfix); + es->sz = sz; + es->committed = 1; + es->type = type; + e = es; + } + } + return e; +} + Expression *AndAndExp::optimize(int result) { Expression *e; @@ -257,23 +335,25 @@ StringExp *es2 = (StringExp *)e2; StringExp *es; Type *t; + size_t len = es1->len + es2->len; + int sz = es1->sz; - assert(es1->sz == es2->sz); - s = mem.malloc((es1->len + es2->len + 1) * es1->sz); - memcpy(s, es1->string, es1->len * es1->sz); - memcpy((unsigned char *)s + es1->len, es2->string, es2->len * es1->sz); + assert(sz == es2->sz); + s = mem.malloc((len + 1) * sz); + memcpy(s, es1->string, es1->len * sz); + memcpy((unsigned char *)s + es1->len * sz, es2->string, es2->len * sz); // Add terminating 0 - memset((unsigned char *)s + es1->len + es2->len, 0, es1->sz); + memset((unsigned char *)s + len * sz, 0, sz); - es = new StringExp(loc, s, es1->len + es2->len); - es->sz = es1->sz; + es = new StringExp(loc, s, len); + es->sz = sz; es->committed = es1->committed | es2->committed; if (es1->committed) t = es1->type; else t = es2->type; - es->type = new TypeSArray(t->next, new IntegerExp(0, es1->len + es2->len, Type::tindex)); + es->type = new TypeSArray(t->next, new IntegerExp(0, len, Type::tindex)); e = es; } else diff -uNr dmd-0.137/dmd/src/dmd/parse.c dmd-0.138/dmd/src/dmd/parse.c --- dmd-0.137/dmd/src/dmd/parse.c 2005-10-24 12:42:58.000000000 +0200 +++ dmd-0.138/dmd/src/dmd/parse.c 2005-10-25 00:09:54.000000000 +0200 @@ -292,20 +292,14 @@ if (token.value == TOKidentifier && peek(&token)->value == TOKassign) { - a = new Array(); Identifier *ident = token.ident; nextToken(); nextToken(); Initializer *init = parseInitializer(); VarDeclaration *v = new VarDeclaration(loc, NULL, ident, init); v->storage_class = stc; - a->push(v); - if (token.value == TOKsemicolon) - { - nextToken(); - addComment(v, comment); - } - else + s = v; + if (token.value != TOKsemicolon) error("semicolon expected following auto declaration, not '%s'", token.toChars()); } else diff -uNr dmd-0.137/dmd/src/phobos/std/math2.d dmd-0.138/dmd/src/phobos/std/math2.d --- dmd-0.137/dmd/src/phobos/std/math2.d 2005-10-24 15:58:08.000000000 +0200 +++ dmd-0.138/dmd/src/phobos/std/math2.d 2005-11-06 11:16:18.000000000 +0100 @@ -115,28 +115,6 @@ } /********************************* - * Polynomial of X - */ - -real poly(real x, real[] coefficients) -{ - debug (math2) printf("poly(), coefficients.length = %d\n", coefficients.length); - if (!coefficients.length) - return 0; - real result = coefficients[coefficients.length - 1]; - for (int i = coefficients.length - 2; i >= 0; i--) - result = result * x + coefficients[i]; - return result; -} - -unittest -{ - debug (math2) printf("unittest.poly()\n"); - static real[4] k = [ 4, 3, 2, 1 ]; - assert(feq(poly(2, k), cast(real) 8 * 1 + 4 * 2 + 2 * 3 + 4)); -} - -/********************************* * Sign */ diff -uNr dmd-0.137/dmd/src/phobos/std/math.d dmd-0.138/dmd/src/phobos/std/math.d --- dmd-0.137/dmd/src/phobos/std/math.d 2005-10-24 15:58:08.000000000 +0200 +++ dmd-0.138/dmd/src/phobos/std/math.d 2005-11-06 11:16:16.000000000 +0100 @@ -50,6 +50,7 @@ //debug=math; // uncomment to turn on debugging printf's +private import std.stdio; private import std.c.stdio; private import std.string; private import std.c.math; @@ -1641,7 +1642,7 @@ } else { - i = A.length - 1; + int i = A.length - 1; real r = A[i]; while (--i >= 0) {