diff -uNr dmd-0.127/dmd/src/dmd/expression.c dmd-0.128/dmd/src/dmd/expression.c --- dmd-0.127/dmd/src/dmd/expression.c 2005-06-14 01:15:06.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/expression.c 2005-07-01 22:21:16.000000000 +0200 @@ -269,7 +269,7 @@ break; } default: - assert(0); + break; } arg = arg->semantic(sc); //printf("\targ = '%s'\n", arg->toChars()); @@ -514,6 +514,7 @@ else if (!loc.filename) loc = e->loc; error("%s is not an lvalue", e->toChars()); +*(char*)0=0; return this; } diff -uNr dmd-0.127/dmd/src/dmd/inline.c dmd-0.128/dmd/src/dmd/inline.c --- dmd-0.127/dmd/src/dmd/inline.c 2005-05-21 01:39:20.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/inline.c 2005-06-30 01:44:38.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2004 by Digital Mars +// Copyright (c) 1999-2005 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com @@ -264,6 +264,7 @@ { Expression *e = NULL; + //printf("CompoundStatement::doInline() %d\n", statements->dim); for (int i = 0; i < statements->dim; i++) { Statement *s; Expression *e2; @@ -321,6 +322,7 @@ Expression *ReturnStatement::doInline(InlineDoState *ids) { + //printf("ReturnStatement::doInline() '%s'\n", exp ? exp->toChars() : ""); return exp ? exp->doInline(ids) : 0; } @@ -857,7 +859,17 @@ if (fd && fd != iss->fd && fd->canInline(1)) { - e = fd->doInline(iss, dve->e1, arguments); + if (dve->e1->op == TOKcall && + dve->e1->type->toBasetype()->ty == Tstruct) + { + /* To create ethis, we'll need to take the address + * of dve->e1, but this won't work if dve->e1 is + * a function call. + */ + ; + } + else + e = fd->doInline(iss, dve->e1, arguments); } } diff -uNr dmd-0.127/dmd/src/dmd/mars.c dmd-0.128/dmd/src/dmd/mars.c --- dmd-0.127/dmd/src/dmd/mars.c 2005-06-07 22:34:32.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/mars.c 2005-06-25 15:10:06.000000000 +0200 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2005 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.127"; + version = "v0.128"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); diff -uNr dmd-0.127/dmd/src/dmd/parse.c dmd-0.128/dmd/src/dmd/parse.c --- dmd-0.127/dmd/src/dmd/parse.c 2005-06-15 12:52:18.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/parse.c 2005-07-01 22:13:12.000000000 +0200 @@ -3754,7 +3754,7 @@ } else { error("(type identifier : specialization) expected following is"); - return NULL; + goto Lerr; } e = new IftypeExp(loc, targ, ident, tok, tspec, tok2); break; @@ -3773,7 +3773,7 @@ tempinst = parseTemplateInstance(); if (!tempinst) - return NULL; + goto Lerr; e = new ScopeExp(loc, tempinst); break; } diff -uNr dmd-0.127/dmd/src/dmd/statement.c dmd-0.128/dmd/src/dmd/statement.c --- dmd-0.127/dmd/src/dmd/statement.c 2005-05-25 21:54:12.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/statement.c 2005-06-30 01:43:14.000000000 +0200 @@ -342,6 +342,24 @@ return statements; } +ReturnStatement *CompoundStatement::isReturnStatement() +{ int i; + ReturnStatement *rs = NULL; + + for (i = 0; i < statements->dim; i++) + { Statement *s; + + s = (Statement *) statements->data[i]; + if (s) + { + rs = s->isReturnStatement(); + if (rs) + break; + } + } + return rs; +} + void CompoundStatement::toCBuffer(OutBuffer *buf) { int i; @@ -1964,6 +1982,7 @@ { ScopeDsymbol *sym; Initializer *init; + //printf("WithStatement::semantic()\n"); exp = exp->semantic(sc); if (exp->op == TOKimport) { ScopeExp *es = (ScopeExp *)exp; diff -uNr dmd-0.127/dmd/src/dmd/statement.h dmd-0.128/dmd/src/dmd/statement.h --- dmd-0.127/dmd/src/dmd/statement.h 2005-03-21 11:43:16.000000000 +0100 +++ dmd-0.128/dmd/src/dmd/statement.h 2005-06-30 01:41:36.000000000 +0200 @@ -122,6 +122,7 @@ int usesEH(); int fallOffEnd(); Array *flatten(); + ReturnStatement *isReturnStatement(); int inlineCost(InlineCostState *ics); Expression *doInline(InlineDoState *ids); diff -uNr dmd-0.127/dmd/src/dmd/template.c dmd-0.128/dmd/src/dmd/template.c --- dmd-0.127/dmd/src/dmd/template.c 2005-05-12 21:21:52.000000000 +0200 +++ dmd-0.128/dmd/src/dmd/template.c 2005-07-08 11:49:02.000000000 +0200 @@ -1489,6 +1489,7 @@ { Dsymbol *s = (Dsymbol *)members->data[i]; s->semantic(sc2); + sc2->module->runDeferredSemantic(); } /* The problem is when to parse the initializer for a variable. diff -uNr dmd-0.127/dmd/src/phobos/etc/c/zlib/inftrees.c dmd-0.128/dmd/src/phobos/etc/c/zlib/inftrees.c --- dmd-0.127/dmd/src/phobos/etc/c/zlib/inftrees.c 2005-06-16 21:54:04.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/etc/c/zlib/inftrees.c 2005-07-10 23:31:58.000000000 +0200 @@ -126,7 +126,8 @@ left -= count[len]; if (left < 0) return -1; /* over-subscribed */ } - if (left > 0 && (type == CODES || (codes - count[0] != 1))) + if (left > 0 && (type == CODES || max != 1)) + //if (left > 0 && (type == CODES || (codes - count[0] != 1))) return -1; /* incomplete set */ /* generate offsets into symbol table for each length for sorting */ diff -uNr dmd-0.127/dmd/src/phobos/internal/gc/gc.d dmd-0.128/dmd/src/phobos/internal/gc/gc.d --- dmd-0.127/dmd/src/phobos/internal/gc/gc.d 2005-06-16 21:54:04.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/internal/gc/gc.d 2005-07-10 23:32:00.000000000 +0200 @@ -598,22 +598,34 @@ assert(!cap || cap > result.length * size); } body -{ byte[] a; - uint len; +{ + version (none) + { + /* Cannot use this optimization because: + * char[] a, b; + * char c = 'a'; + * b = a ~ c; + * c = 'b'; + * will change the contents of b. + */ + if (!y.length) + return x; + if (!x.length) + return y; + } + + size_t xlen = x.length * size; + size_t ylen = y.length * size; + size_t len = xlen + ylen; + if (!len) + return null; + + byte* p = cast(byte*)_gc.malloc(len + 1); + memcpy(p, x, xlen); + memcpy(p + xlen, y, ylen); + p[len] = 0; - if (!y.length) - return x; - if (!x.length) - return y; - - len = x.length + y.length; - a = new byte[len * size]; - memcpy(a, x, x.length * size); - //a[0 .. x.length * size] = x[]; - memcpy(&a[x.length * size], y, y.length * size); - *cast(int *)&a = len; // jam length - //a.length = len; - return a; + return p[0 .. x.length + y.length]; } diff -uNr dmd-0.127/dmd/src/phobos/std/c/linux/linux.d dmd-0.128/dmd/src/phobos/std/c/linux/linux.d --- dmd-0.127/dmd/src/phobos/std/c/linux/linux.d 2005-06-16 21:54:02.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/std/c/linux/linux.d 2005-07-10 23:31:58.000000000 +0200 @@ -104,6 +104,7 @@ extern (C) { + int access(char*, int); int open(char*, int, ...); int read(int, void*, int); int write(int, void*, int); diff -uNr dmd-0.127/dmd/src/phobos/std/file.d dmd-0.128/dmd/src/phobos/std/file.d --- dmd-0.127/dmd/src/phobos/std/file.d 2005-06-16 21:53:58.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/std/file.d 2005-07-10 23:31:52.000000000 +0200 @@ -804,6 +804,9 @@ int exists(char[] name) { + return access(toStringz(name),0) != 0; + +/+ struct_stat statbuf; char *namez; @@ -812,8 +815,8 @@ { return 0; } - return 1; ++/ } /**************************************************** diff -uNr dmd-0.127/dmd/src/phobos/std/stream.d dmd-0.128/dmd/src/phobos/std/stream.d --- dmd-0.127/dmd/src/phobos/std/stream.d 2005-06-16 21:53:58.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/std/stream.d 2005-07-10 23:31:54.000000000 +0200 @@ -1,3 +1,4 @@ + /* * Copyright (c) 2001-2005 * Pavel "EvilOne" Minayev @@ -162,9 +163,9 @@ // has effect on further calls to getc() and getcw() wchar ungetcw(wchar c); - int vscanf(char[] fmt, va_list args); + int vreadf(TypeInfo[] arguments, va_list args); - int scanf(char[] format, ...); + int readf(...); size_t available(); bool eof(); @@ -231,10 +232,10 @@ size_t printf(char[] format, ...); // writes data to stream using writef() syntax and returns self - Stream writef(...); + OutputStream writef(...); // writes data with trailing newline and returns self - Stream writefln(...); + OutputStream writefln(...); void flush(); void close(); @@ -541,11 +542,40 @@ return c; } - int vscanf(char[] fmt, va_list args) { - void** arg = cast(void**) args; + int vreadf(TypeInfo[] arguments, va_list args) { + char[] fmt; + int j = 0; int count = 0, i = 0; char c = getc(); - while (i < fmt.length && !eof()) { + while ((j < arguments.length || i < fmt.length) && !eof()) { + if (fmt.length == 0 || i == fmt.length) { + i = 0; + if (arguments[j] is typeid(char[])) { + fmt = va_arg!(char[])(args); + j++; + continue; + } else if (arguments[j] is typeid(int*) || + arguments[j] is typeid(byte*) || + arguments[j] is typeid(short*) || + arguments[j] is typeid(long*)) { + fmt = "%d"; + } else if (arguments[j] is typeid(uint*) || + arguments[j] is typeid(ubyte*) || + arguments[j] is typeid(ushort*) || + arguments[j] is typeid(ulong*)) { + fmt = "%d"; + } else if (arguments[j] is typeid(float*) || + arguments[j] is typeid(double*) || + arguments[j] is typeid(real*)) { + fmt = "%f"; + } else if (arguments[j] is typeid(char[]*) || + arguments[j] is typeid(wchar[]*) || + arguments[j] is typeid(dchar[]*)) { + fmt = "%s"; + } else if (arguments[j] is typeid(char*)) { + fmt = "%c"; + } + } if (fmt[i] == '%') { // a field i++; bit suppress = false; @@ -561,21 +591,9 @@ } if (width == 0) width = -1; - // D string? - bit dstr = false; - if (fmt[i] == '.') { + // skip any modifier if present + if (fmt[i] == 'h' || fmt[i] == 'l' || fmt[i] == 'L') i++; - if (fmt[i] == '*') { - dstr = true; - i++; - } - } - // read the modifier - char modifier = fmt[i]; - if (modifier == 'h' || modifier == 'l' || modifier == 'L') - i++; - else - modifier = 0; // check the typechar and act accordingly switch (fmt[i]) { case 'd': // decimal/hexadecimal/octal integer @@ -654,20 +672,32 @@ } if (neg) n = -n; - // check the modifier and cast the pointer - // to appropriate type - switch (modifier) { - case 'h': { // short - *cast(short*)*arg = n; - } break; - - case 'L': { // long - *cast(long*)*arg = n; - } break; - - default: // int - *cast(int*)*arg = n; + if (arguments[j] is typeid(int*)) { + int* p = va_arg!(int*)(args); + *p = n; + } else if (arguments[j] is typeid(short*)) { + short* p = va_arg!(short*)(args); + *p = n; + } else if (arguments[j] is typeid(byte*)) { + byte* p = va_arg!(byte*)(args); + *p = n; + } else if (arguments[j] is typeid(long*)) { + long* p = va_arg!(long*)(args); + *p = n; + } else if (arguments[j] is typeid(uint*)) { + uint* p = va_arg!(uint*)(args); + *p = n; + } else if (arguments[j] is typeid(ushort*)) { + ushort* p = va_arg!(ushort*)(args); + *p = n; + } else if (arguments[j] is typeid(ubyte*)) { + ubyte* p = va_arg!(ubyte*)(args); + *p = n; + } else if (arguments[j] is typeid(ulong*)) { + ulong* p = va_arg!(ulong*)(args); + *p = n; } + j++; i++; } break; @@ -746,45 +776,62 @@ } if (neg) n = -n; - // check the modifier and cast the pointer - // to appropriate type - switch (modifier) { - case 'l': { // double - *cast(double*)*arg = n; - } break; - - case 'L': { // real - *cast(real*)*arg = n; - } break; - - default: // float - *cast(float*)*arg = n; + if (arguments[j] is typeid(float*)) { + float* p = va_arg!(float*)(args); + *p = n; + } else if (arguments[j] is typeid(double*)) { + double* p = va_arg!(double*)(args); + *p = n; + } else if (arguments[j] is typeid(real*)) { + real* p = va_arg!(real*)(args); + *p = n; } + j++; i++; } break; - case 's': { // ANSI string + case 's': { // string while (iswhite(c)) { c = getc(); count++; } char[] s; + char[]* p; + size_t strlen; + if (arguments[j] is typeid(char[]*)) { + p = va_arg!(char[]*)(args); + s = *p; + } while (!iswhite(c) && c != char.init) { - s ~= c; + if (strlen < s.length) { + s[strlen] = c; + } else { + s ~= c; + } + strlen++; c = getc(); count++; } - if (dstr) // D string (char[]) - *cast(char[]*)*arg = s; - else { // C string (char*) + s = s[0 .. strlen]; + if (arguments[j] is typeid(char[]*)) { + *p = s; + } else if (arguments[j] is typeid(char*)) { s ~= 0; - (cast(char*)*arg)[0 .. s.length] = s[]; + char* p = va_arg!(char*)(args); + p[0 .. s.length] = s[]; + } else if (arguments[j] is typeid(wchar[]*)) { + wchar[]* p = va_arg!(wchar[]*)(args); + *p = toUTF16(s); + } else if (arguments[j] is typeid(dchar[]*)) { + dchar[]* p = va_arg!(dchar[]*)(args); + *p = toUTF32(s); } + j++; i++; } break; case 'c': { // character(s) - char* s = cast(char*)*arg; + char* s = va_arg!(char*)(args); if (width < 0) width = 1; else @@ -797,18 +844,20 @@ c = getc(); count++; } + j++; i++; } break; case 'n': { // number of chars read so far - *cast(int*)*arg = count; + int* p = va_arg!(int*)(args); + *p = count; + j++; i++; } break; default: // read character as is goto nws; } - arg++; } else if (iswhite(fmt[i])) { // skip whitespace while (iswhite(c)) c = getc(); @@ -825,11 +874,8 @@ return count; } - int scanf(char[] format, ...) { - va_list ap; - ap = cast(va_list) &format; - ap += format.sizeof; - return vscanf(format, ap); + int readf(...) { + return vreadf(_arguments, _argptr); } // returns estimated number of bytes available for immediate reading @@ -976,13 +1022,13 @@ } // writes data to stream using writef() syntax, - Stream writef(...) { + OutputStream writef(...) { doFormat(&doFormatCallback,_arguments,_argptr); return this; } // writes data with trailing newline - Stream writefln(...) { + OutputStream writefln(...) { doFormat(&doFormatCallback,_arguments,_argptr); writeLine(""); return this; diff -uNr dmd-0.127/dmd/src/phobos/std/string.d dmd-0.128/dmd/src/phobos/std/string.d --- dmd-0.127/dmd/src/phobos/std/string.d 2005-06-16 21:53:58.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/std/string.d 2005-07-10 23:31:52.000000000 +0200 @@ -2046,7 +2046,7 @@ char[] toString(ushort us) { return toString(cast(uint) us); } char[] toString(uint u) -{ char[uint.sizeof * 3] buffer; +{ char[uint.sizeof * 3] buffer = void; int ndigits; char c; char[] result; diff -uNr dmd-0.127/dmd/src/phobos/std/typeinfo/ti_Aa.d dmd-0.128/dmd/src/phobos/std/typeinfo/ti_Aa.d --- dmd-0.127/dmd/src/phobos/std/typeinfo/ti_Aa.d 2005-06-16 21:54:00.000000000 +0200 +++ dmd-0.128/dmd/src/phobos/std/typeinfo/ti_Aa.d 2005-07-10 23:31:56.000000000 +0200 @@ -9,17 +9,18 @@ uint getHash(void *p) { char[] s = *cast(char[]*)p; - uint len = s.length; - char *str = s; uint hash = 0; -version (none) +version (all) { foreach (char c; s) - hash = hash * 31 + c; + hash = hash * 11 + c; } else { + uint len = s.length; + char *str = s; + while (1) { switch (len)