diff -uNr gdc-0.9/d/d-backend.h gdc-0.10/d/d-backend.h --- gdc-0.9/d/d-backend.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/d-backend.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,24 +0,0 @@ -/* GDC -- D front-end for GCC - Copyright (C) 2004 David Friedman - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef GCC_DCMPLR_DC_BE_H -#define GCC_DCMPLR_DC_BE_H - -extern void gcc_d_backend_init(); -extern void gcc_d_backend_term(); - -#endif diff -uNr gdc-0.9/d/d-builtins2.cc gdc-0.10/d/d-builtins2.cc --- gdc-0.9/d/d-builtins2.cc 2004-12-02 02:12:02.000000000 +0100 +++ gdc-0.10/d/d-builtins2.cc 2005-01-09 01:40:20.000000000 +0100 @@ -43,7 +43,7 @@ d_gcc_builtin_va_list_d_type = gcc_type_to_d_type(va_list_type_node); if (! d_gcc_builtin_va_list_d_type) { // fallback to array of byte of the same size? - error("can not represent built in va_list type in D"); + error("cannot represent built in va_list type in D"); abort(); } TYPE_MAIN_VARIANT( d_gcc_builtin_va_list_d_type->toCtype() ) = @@ -160,7 +160,7 @@ if (d) { d_bi_types.data[ti] = d; } else { - // warning("can not create builtin type %d\n", ti); + // warning("cannot create builtin type %d\n", ti); } } @@ -209,7 +209,7 @@ { TypeFunction * df = (TypeFunction *) d_bi_types.data[ti]; if (! df) { - // warning("can not create builtin %s\n", name); + // warning("cannot create builtin %s\n", name); return; } FuncDeclaration * func = new FuncDeclaration(0, 0, @@ -290,6 +290,27 @@ Lexer::idPool("__builtin_va_list"), d) ); } + // These four types are an experiment. This allows Phobos (deh.d/unwind.d) to + // be compiled correctly on 64-bit machines in a 32-bit environment + + // Don't know if 'long integer' is really the ABI word size -- it's a best guess + d = gcc_type_to_d_type(long_integer_type_node); + if (d) + funcs->push( new AliasDeclaration(0, + Lexer::idPool("__builtin_abi_int"), d) ); + d = gcc_type_to_d_type(long_unsigned_type_node); + if (d) + funcs->push( new AliasDeclaration(0, + Lexer::idPool("__builtin_abi_uint"), d) ); + d = gcc_type_to_d_type(d_type_for_size(UNITS_PER_WORD*BITS_PER_UNIT, 0)); + if (d) + funcs->push( new AliasDeclaration(0, + Lexer::idPool("__builtin_machine_int"), d) ); + d = gcc_type_to_d_type(d_type_for_size(UNITS_PER_WORD*BITS_PER_UNIT, 1)); + if (d) + funcs->push( new AliasDeclaration(0, + Lexer::idPool("__builtin_machine_uint"), d) ); + m->members->push( new LinkDeclaration(LINKc, funcs) ); } diff -uNr gdc-0.9/d/d-codegen.cc gdc-0.10/d/d-codegen.cc --- gdc-0.9/d/d-codegen.cc 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/d-codegen.cc 2005-01-09 19:43:17.000000000 +0100 @@ -514,8 +514,7 @@ bool use_dynamic = false; int offset; - if (target_class_decl == obj_class_decl || - target_class_decl->isBaseOf(obj_class_decl, & offset)) { + if (target_class_decl->isBaseOf(obj_class_decl, & offset)) { // Casting up the inheritance tree: Don't do anything special. // Cast to an implemented interface: Handle at compile time. if (offset == OFFSET_RUNTIME) { @@ -531,6 +530,9 @@ // d_convert will make a NOP cast break; } + } else if ( target_class_decl == obj_class_decl ) { + // d_convert will make a NOP cast + break; } else if ( ! obj_class_decl->isCOMclass() ) { use_dynamic = true; } @@ -2222,7 +2224,7 @@ tree IRState::typeinfoReference(Type * t) { - tree ti_ref = t->getInternalTypeInfo()->toElem(this); + tree ti_ref = t->getInternalTypeInfo(NULL)->toElem(this); assert( POINTER_TYPE_P( TREE_TYPE( ti_ref )) ); return ti_ref; } @@ -2297,14 +2299,23 @@ { Type * obj_type = obj_exp->type->toBasetype(); if (func->isThis()) { - tree this_expr = obj_exp->toElem( this ); + tree this_expr; + + // DotTypeExp cannot be evaluated + if (obj_exp->op != TOKdottype) + this_expr = obj_exp->toElem( this ); + else + this_expr = ((DotTypeExp *) obj_exp)->e1->toElem( this ); // Calls to super are static (func is the super's method) // Structs don't have vtables. // Final and non-virtual methods can be called directly. + // DotTypeExp means non-virtual + if (obj_exp->op == TOKsuper || obj_type->ty == Tstruct || obj_type->ty == Tpointer || - func->isFinal() || ! func->isVirtual()) { + func->isFinal() || ! func->isVirtual() || + obj_exp->op == TOKdottype) { if (obj_type->ty == Tstruct) this_expr = addressOf(this_expr); @@ -2590,6 +2601,22 @@ DECL_ATTRIBUTES( type )); } +tree +IRState::integerConstant(xdmd_integer_t value, tree type) { + // Assuming xdmd_integer_t is 64 bits +#if HOST_BITS_PER_WIDE_INT == 32 + tree tree_value = build_int_2(value & 0xffffffff, (value >> 32) & 0xffffffff); +#elif HOST_BITS_PER_WIDE_INT == 64 + tree tree_value = build_int_2(value, + type && ! TREE_UNSIGNED(type) && value & 0x8000000000000000ULL ? + 0xffffffffffffffffULL : 0); +#else +#error Fix This +#endif + if (type) + TREE_TYPE( tree_value ) = type; + return tree_value; +} tree IRState::vtable(Array * vtbl, ClassDeclaration * ci_override) @@ -2925,12 +2952,13 @@ break; case DT_abytes: case DT_xoff: - size += POINTER_SIZE / BITS_PER_UNIT; + size += PTRSIZE; break; case DT_word: - // %% currently assuming word==pointer, tho.. - // %% maker sure this is the target word type - size += UNITS_PER_WORD; + // This may cause problems for 64-bit since dtdword is used for + // (uint? / size_t?) and pointers... Nearly all cases are for size_t + // and pointer, though. + size += PTRSIZE; break; case DT_tree: size += tree_low_cst( TYPE_SIZE_UNIT( TREE_TYPE( dt->DTtree )), 1 ); diff -uNr gdc-0.9/d/d-codegen.h gdc-0.10/d/d-codegen.h --- gdc-0.9/d/d-codegen.h 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/d-codegen.h 2004-12-26 17:15:05.000000000 +0100 @@ -219,19 +219,7 @@ // ** Simple constants static tree nullPointer() { return d_null_pointer; } - static tree integerConstant(xdmd_integer_t value, tree type = 0) { - // Assuming xdmd_integer_t is 64 bits -#if HOST_BITS_PER_WIDE_INT == 32 - tree tree_value = build_int_2(value & 0xffffffff, (value >> 32) & 0xffffffff); -#elif HOST_BITS_PER_WIDE_INT == 64 - tree tree_value = build_int_2(value, 0); -#else -#error Fix This -#endif - if (type) - TREE_TYPE( tree_value ) = type; - return tree_value; - } + static tree integerConstant(xdmd_integer_t value, tree type = 0); static tree integerConstant(xdmd_integer_t value, Type * type) { return integerConstant(value, type->toCtype()); } diff -uNr gdc-0.9/d/d-decls.cc gdc-0.10/d/d-decls.cc --- gdc-0.9/d/d-decls.cc 2004-12-02 02:49:03.000000000 +0100 +++ gdc-0.10/d/d-decls.cc 2005-01-09 22:08:32.000000000 +0100 @@ -242,7 +242,7 @@ TREE_ADDRESSABLE( var_decl ) = 1; } - TREE_ADDRESSABLE( var_decl ) = 1; + // %%EXPER%% TREE_ADDRESSABLE( var_decl ) = 1; TREE_USED( var_decl ) = 1; csym = new Symbol(); @@ -601,7 +601,7 @@ TREE_TYPE(some_type->toCtype())); // want the RECORD_TYPE, not the REFERENCE_TYPE csym->Stree = decl; #if D_GCC_VER >= 34 - // EXPER, what have you done for me lately? + // EXPER /* csym->ScontextDecl = build_decl(TRANSLATION_UNIT_DECL, NULL, NULL); dkeep(csym->ScontextDecl); diff -uNr gdc-0.9/d/d-dmd-gcc.h gdc-0.10/d/d-dmd-gcc.h --- gdc-0.9/d/d-dmd-gcc.h 1970-01-01 01:00:00.000000000 +0100 +++ gdc-0.10/d/d-dmd-gcc.h 2004-12-26 17:15:05.000000000 +0100 @@ -0,0 +1,42 @@ +/* GDC -- D front-end for GCC + Copyright (C) 2004 David Friedman + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* This file contains declarations used by the modified DMD front-end to + interact with GCC-specific code. */ + +#ifndef GCC_DCMPLR_DMD_GCC_H +#define GCC_DCMPLR_DMD_GCC_H + +#ifdef __cplusplus + +/* used in module.c */ +struct Module; +extern void d_gcc_magic_module(Module *m); +extern void d_gcc_dump_source(const char * filename, const char * ext, unsigned char * data, unsigned len); + +/* used in func.c */ +struct Type; +extern Type * d_gcc_builtin_va_list_d_type; + +/* used in toobj.c */ +struct VarDeclaration; +extern void d_gcc_emit_local_variable(VarDeclaration *); + +#endif + +#endif diff -uNr gdc-0.9/d/d-glue.cc gdc-0.10/d/d-glue.cc --- gdc-0.9/d/d-glue.cc 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/d-glue.cc 2005-01-09 22:08:32.000000000 +0100 @@ -112,16 +112,94 @@ out_code = TRUTH_ORIF_EXPR; break; default: + /* + // ordering for complex isn't defined, all that is guaranteed is the 'unordered part' + case TOKule: + case TOKul: + case TOKuge: + case TOKug: + */ if ( COMPLEX_FLOAT_TYPE_P( TREE_TYPE( e1 )) ) { // GCC doesn't handle these. - // From cmath2.d: if imaginary parts are equal, - // result is comparison of real parts; otherwise, result false - // %% Not sure how unordered is handled. e1 = irs->maybeMakeTemp(e1); e2 = irs->maybeMakeTemp(e2); - return irs->boolOp(TRUTH_ANDIF_EXPR, - irs->boolOp(EQ_EXPR, irs->imagPart(e1), irs->imagPart(e2)), - make_bool_binop(op, irs->realPart(e1), irs->realPart(e2), irs)); + switch (op) { + case TOKleg: + return irs->boolOp(TRUTH_ANDIF_EXPR, + make_bool_binop(TOKleg, irs->realPart(e1), irs->realPart(e2), irs), + make_bool_binop(TOKleg, irs->imagPart(e1), irs->imagPart(e2), irs)); + case TOKunord: + return irs->boolOp(TRUTH_ORIF_EXPR, + make_bool_binop(TOKunord, irs->realPart(e1), irs->realPart(e2), irs), + make_bool_binop(TOKunord, irs->imagPart(e1), irs->imagPart(e2), irs)); + case TOKlg: + return irs->boolOp(TRUTH_ANDIF_EXPR, + make_bool_binop(TOKleg, e1, e2, irs), + make_bool_binop(TOKnotequal, e1, e2, irs)); + case TOKue: + return irs->boolOp(TRUTH_ORIF_EXPR, + make_bool_binop(TOKunord, e1, e2, irs), + make_bool_binop(TOKequal, e1, e2, irs)); + default: + { + // From cmath2.d: if imaginary parts are equal, + // result is comparison of real parts; otherwise, result false + // + // Does D define an ordering for complex numbers? + + // make a target-independent _cmplxCmp ? + tree it, rt; + TOK hard, soft; + bool unordered = false; + switch (op) { + case TOKule: + case TOKul: + case TOKuge: + case TOKug: + unordered = true; + default: + break; + } + + switch (op) { + case TOKule: + case TOKle: + hard = TOKlt; + soft = TOKle; + break; + case TOKul: + case TOKlt: + hard = soft = TOKlt; + break; + case TOKuge: + case TOKge: + hard = TOKlt; + soft = TOKle; + break; + case TOKug: + case TOKgt: + hard = soft = TOKgt; + break; + default: + assert(0); + } + + it = make_bool_binop(hard, irs->imagPart(e2), irs->imagPart(e1), irs); + if (! unordered) + it = irs->boolOp(TRUTH_ANDIF_EXPR, + make_bool_binop(TOKleg, irs->realPart(e2), irs->realPart(e1), irs), + it); + rt = irs->boolOp(TRUTH_ANDIF_EXPR, + make_bool_binop(TOKequal, irs->imagPart(e2), irs->imagPart(e1), irs), + make_bool_binop(soft, irs->realPart(e2), irs->realPart(e1), irs)); + it = irs->boolOp(TRUTH_ANDIF_EXPR, it, rt); + if (unordered) + it = irs->boolOp(TRUTH_ORIF_EXPR, + make_bool_binop(TOKunord, e1, e2, irs), + it); + return it; + } + } } // else, normal @@ -1113,9 +1191,12 @@ VarDeclaration * field = (VarDeclaration *) sd->fields.data[i]; if (field->offset == the_offset && field->type->equals(this->type)) { + tree rec_tree = rec_exp->toElem(irs); + if (rec_tree == error_mark_node) + return error_mark_node; // backend will ICE otherwise return build(COMPONENT_REF, type->toCtype(), - rec_exp->toElem(irs), field->toSymbol()->Stree); + rec_tree, field->toSymbol()->Stree); } else if (field->offset > the_offset) { break; } @@ -1158,9 +1239,15 @@ } elem * -DotTypeExp::toElem(IRState*) +DotTypeExp::toElem(IRState* irs) { - ::error("DotTypeExp::toElem: don't know what to do (%s)", toChars()); + // The only case in which this seems to be a valid expression is when + // it is used to specify a non-virtual call ( SomeClass.func(...) ). + // This case is handled in IRState::objectInstanceMethod. + + error("cannot use \"%s\" as an expression", toChars()); + + // Can cause ICEs later; should just exit now. return error_mark_node; } @@ -1170,9 +1257,14 @@ { Type * t = e1->type->toBasetype(); if (t->ty == Tclass || t->ty == Tstruct) { + // %% Need to see if DotVarExp ever has legitimate + // .. If not, move this test + // to objectInstanceMethod. + if (! func->isThis()) + error("delegates are only for non-static functions"); return irs->objectInstanceMethod(e1, func, type); } else { - assert(func->isNested()); // %% check + assert(func->isNested()); return irs->methodCallExpr(irs->functionPointer(func), func->isNested() ? d_null_pointer : e1->toElem(irs), type); } @@ -1260,14 +1352,26 @@ elem * DeclarationExp::toElem(IRState* irs) { +#ifdef OLD VarDeclaration * v = declaration->isVarDeclaration(); if ( v && ! v->isDataseg() ) irs->emitLocalVar(v); else - declaration->toObjFile(); + declaration->toObjFile(); +#else + // VarDeclaration::toObjFile was modified to call d_gcc_emit_local_variable + // if needed. This assumes irs == cur_irs + declaration->toObjFile(); +#endif return d_void_zero_node; } +void d_gcc_emit_local_variable(VarDeclaration * v) +{ + cur_irs->emitLocalVar(v); +} + + // %% check calling this directly? elem * FuncExp::toElem(IRState * irs) @@ -2043,7 +2147,7 @@ // %% c-decl.c: if (flag_short_enums) TYPE_PACKED(enumtype) = 1; TYPE_MIN_VALUE( ctype ) = gen.integerConstant(sym->minval, enum_mem_type_node); TYPE_MAX_VALUE( ctype ) = gen.integerConstant(sym->maxval, enum_mem_type_node); - TYPE_PRECISION( ctype ) = size() * 8; + TYPE_PRECISION( ctype ) = size(0) * 8; TYPE_SIZE( ctype ) = 0; // as in c-decl.c if (sym->ident) TYPE_NAME( ctype ) = get_identifier(sym->ident->string); @@ -2409,18 +2513,28 @@ { FuncDeclaration * func = irs->getCurrentFunction(); LabelDsymbol * label = isReturnLabel ? func->returnLabel : func->searchLabel(ident); - expand_label( irs->getLabelTree( label ) ); + tree t = irs->getLabelTree( label ); + + if (t) { + expand_label( t ); - if (isReturnLabel && func->fensure) - func->fensure->toIR(irs); - else if (statement) // %% really else? - statement->toIR(irs); + if (isReturnLabel && func->fensure) + func->fensure->toIR(irs); + else if (statement) // %% really else? + statement->toIR(irs); + } + // else, there was an error } void GotoStatement::toIR(IRState* irs) { - gen.doJump(this, irs->getLabelTree( label )); + gen.doLineNote(loc); /* This makes the 'undefined label' error show up on the correct line... + The extra doLineNote in doJump shouldn't cause a problem. */ + tree t = irs->getLabelTree( label ); + if (t) + gen.doJump(this, t); + // else, there was an error } void @@ -2465,7 +2579,7 @@ if ( ! intfc_decl->isCOMclass()) { arg = irs->convertTo(arg, exp->type, irs->getObjectType()); } else { - error("can not throw COM interfaces"); + error("cannot throw COM interfaces"); } } @@ -2556,7 +2670,7 @@ if (! iface->isCOMclass()) { init_exp = irs->convertTo(exp, irs->getObjectType()); } else { - error("can not synchronize on a COM interface"); + error("cannot synchronize on a COM interface"); init_exp = error_mark_node; } } else { @@ -2615,17 +2729,23 @@ ContinueStatement::toIR(IRState* irs) { gen.doLineNote(loc); +#ifdef OLD expand_continue_loop( irs->getLoopForLabel( ident ) ); +#endif + irs->continueLoop(ident); } void BreakStatement::toIR(IRState* irs) { gen.doLineNote(loc); +#ifdef OLD if (ident) expand_exit_loop( irs->getLoopForLabel( ident ) ); else expand_exit_something(); +#endif + irs->exitLoop(ident); } void @@ -2750,9 +2870,11 @@ genrtl_do_pushlevel(); // %% see where else this is needed(is it?) // %% C does this in other places gen.doLineNote(loc); expand_start_case( 1, cond_tree, TREE_TYPE( cond_tree ), "switch statement" ); + irs->beginLoop(this, NULL); if (body) body->toIR( irs ); expand_end_case( cond_tree ); + irs->endLoop(); } diff -uNr gdc-0.9/d/d-irstate.cc gdc-0.10/d/d-irstate.cc --- gdc-0.9/d/d-irstate.cc 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/d-irstate.cc 2005-01-08 20:21:39.000000000 +0100 @@ -32,7 +32,6 @@ { parentIRState = 0; thisFunction = 0; - loops = new Array(); volatileDepth = 0; // declContextStack is composed... choose one.. @@ -109,6 +108,11 @@ tree IRBase::getLabelTree(LabelDsymbol * label) { + if (! label->statement) { + error("undefined label %s", label->ident->string); // %% ident okay? + return NULL_TREE; + } + if (! label->statement->lblock) { tree label_decl = build_decl (LABEL_DECL, get_identifier(label->ident->string), void_type_node); @@ -123,9 +127,10 @@ return label->statement->lblock; } -nesting * -IRBase::getLoopForLabel(Identifier * ident) +IRBase::Flow * +IRBase::getLoopForLabel(Identifier * ident, bool want_continue) { +#ifdef OLD if (ident) { LabelStatement * lbl_stmt = getCurrentFunction()->searchLabel(ident)->statement; assert(lbl_stmt != 0); @@ -140,23 +145,92 @@ assert(loops->dim >= 2); return (nesting *) loops->tos(); } +#endif + if (ident) { + LabelStatement * lbl_stmt = getCurrentFunction()->searchLabel(ident)->statement; + assert(lbl_stmt != 0); + Statement * stmt = lbl_stmt->statement; + + for (int i = loops.dim - 1; i >= 0; i--) { + Flow * flow = (Flow *) loops.data[i]; + + if (flow->statement == stmt) { + if (want_continue) + assert(stmt->hasContinue()); + return flow; + } + } + assert(0); + } else { + for (int i = loops.dim - 1; i >= 0; i--) { + Flow * flow = (Flow *) loops.data[i]; + + if ( ! want_continue || flow->statement->hasContinue()) + return flow; + } + assert(0); + } } void IRBase::beginLoop(Statement * stmt, nesting * loop) { - loops->push(stmt); - loops->push(loop); + Flow * flow = new Flow; + + flow->statement = stmt; + flow->loop = loop; + flow->exitLabel = NULL; + + loops.push(flow); } void IRBase::endLoop() { - assert(loops->dim > 1); - loops->pop(); - loops->pop(); + Flow * flow; + + assert(loops.dim); + + flow = (Flow *) loops.pop(); + if (flow->exitLabel) + expand_label(flow->exitLabel); // %% need something after this? +} + +void +IRBase::continueLoop(Identifier * ident) +{ + expand_continue_loop( getLoopForLabel( ident )->loop ); } +void +IRBase::exitLoop(Identifier * ident) +{ + if (ident) { + Flow * flow = getLoopForLabel( ident ); + if (flow->loop) + expand_exit_loop( flow->loop ); + else { + if (! flow->exitLabel) { + tree label_decl = build_decl (LABEL_DECL, NULL, void_type_node); + + //assert(current_function_decl != 0); + TREE_USED( label_decl ) = 1 ; + DECL_CONTEXT( label_decl ) = current_function_decl; + DECL_MODE( label_decl ) = VOIDmode; + // statement->loc is at the top.... + if (flow->statement->loc.filename) + gen.setDeclLoc( label_decl, flow->statement->loc ); + flow->exitLabel = label_decl; + } + expand_goto( flow->exitLabel ); + } + } else { + expand_exit_something(); + } +} + + + tree IRBase::getDeclContext() { diff -uNr gdc-0.9/d/d-irstate.h gdc-0.10/d/d-irstate.h --- gdc-0.9/d/d-irstate.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/d-irstate.h 2004-12-26 17:15:05.000000000 +0100 @@ -32,7 +32,6 @@ #include "aggregate.h" #include "symbol.h" - // IRBase contains the core functionality of IRState. The actual IRState class // extends this with lots of code generation utilities. // @@ -70,16 +69,25 @@ // is being compiled. tree getLabelTree(LabelDsymbol * label); - // ** Loops + // ** Loops (and case statements) + + typedef struct + { + Statement * statement; + // expand_start_case doesn't return a nesting structure, so + // we have to generate our own label for 'break' + nesting * loop; + tree exitLabel; + } Flow; - Array * loops; // array of [ Statement 1, nesting 1, Satement 2, nesting 2 ... ] + Array loops; // of Flow // These routines don't generate code. They are for tracking labeled loops. - nesting * getCurrentLoop() { return getLoopForLabel( (Identifier *) 0 ); } - // ident == 0 means current loop - nesting * getLoopForLabel(Identifier * ident); + Flow * getLoopForLabel(Identifier * ident, bool want_continue = false); void beginLoop(Statement * stmt, nesting * loop); void endLoop(); + void continueLoop(Identifier * ident); + void exitLoop(Identifier * ident); // ** DECL_CONTEXT support diff -uNr gdc-0.9/d/d-lang.cc gdc-0.10/d/d-lang.cc --- gdc-0.9/d/d-lang.cc 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/d-lang.cc 2005-01-09 19:43:17.000000000 +0100 @@ -24,7 +24,6 @@ #include "mtype.h" #include "id.h" #include "module.h" -#include "d-backend.h" #include "debcond.h" #include @@ -289,7 +288,8 @@ OPT_femit_templates, OPT_femit_templates_, OPT_nostdinc, - OPT_Wsign_compare + OPT_Wsign_compare, + OPT_fdump_source }; #endif @@ -386,6 +386,9 @@ case OPT_Wsign_compare: gen.warnSignCompare = value; break; + case OPT_fdump_source: + global.params.dump_source = value; + break; default: break; } @@ -443,7 +446,9 @@ } else { d_handle_option(OPT_femit_templates, NULL, value); } - } else + } else if (strcmp(p_arg, "dump-source") == 0) + d_handle_option(OPT_fdump_source, NULL, value); + else return 0; return 1; } else if (strcmp(p_arg, "-nostdinc") == 0) { @@ -673,7 +678,7 @@ printf("parse %s\n", m->toChars()); //m->deleteObjFile(); // %% driver does this m->read(); - m->parse(); + m->parse(global.params.dump_source); } if (global.errors) goto had_errors; @@ -798,6 +803,39 @@ gcc_d_backend_term(); } +void +d_gcc_dump_source(const char * srcname, const char * ext, unsigned char * data, unsigned len) +{ + // Note: There is a dump_base_name variable, but as long as the all-sources hack is in + // around, the base name has to be determined here. + + /* construct output name */ + char* base = (char*) alloca(strlen(srcname)+1); + base = strcpy(base, srcname); + base = basename(base); + + char* name = (char*) alloca(strlen(base)+strlen(ext)+2); + name = strcpy(name, base); + if(strlen(ext)>0){ + name = strcat(name, "."); + name = strcat(name, ext); + } + + /* output + * ignores if the output file exists + * ignores if the output fails + */ + FILE* output = fopen(name, "w"); + if(output){ + fwrite(data, 1, len, output); + fclose(output); + } + + /* cleanup */ + errno=0; +} + + bool d_mark_addressable (tree t) { diff -uNr gdc-0.9/d/d-lang.h gdc-0.10/d/d-lang.h --- gdc-0.9/d/d-lang.h 2004-12-02 03:38:49.000000000 +0100 +++ gdc-0.10/d/d-lang.h 2004-12-26 17:15:05.000000000 +0100 @@ -151,6 +151,9 @@ extern rtx d_expand_expr(tree, rtx, enum machine_mode, int, rtx *); #endif +extern void gcc_d_backend_init(); +extern void gcc_d_backend_term(); + extern struct lang_type * build_d_type_lang_specific(Type * t); struct Module; struct Module * getCurrentModule(void); @@ -185,4 +188,6 @@ extern void dkeep(tree t); #endif +#include "d-dmd-gcc.h" + #endif diff -uNr gdc-0.9/d/dmd/aggregate.h gdc-0.10/d/dmd/aggregate.h --- gdc-0.9/d/dmd/aggregate.h 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/aggregate.h 2005-01-09 01:40:20.000000000 +0100 @@ -48,6 +48,10 @@ unsigned structalign; // struct member alignment in effect Array fields; // VarDeclaration fields unsigned sizeok; // set when structsize contains valid data + // 0: no size + // 1: size is correct + // 2: cannot determine size; fwd referenced + Scope *scope; // !=NULL means context to use // Special member functions InvariantDeclaration *inv; // invariant @@ -63,7 +67,7 @@ void semantic2(Scope *sc); void semantic3(Scope *sc); void inlineScan(); - unsigned size(); + unsigned size(Loc loc); static void alignmember(unsigned salign, unsigned size, unsigned *poffset); Type *getType(); void addField(Scope *sc, VarDeclaration *v); @@ -160,7 +164,6 @@ ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration int com; // !=0 if this is a COM class int isauto; // !=0 if this is an auto class - Scope *scope; // !=NULL means context to use ClassDeclaration(Loc loc, Identifier *id, Array *baseclasses); Dsymbol *syntaxCopy(Dsymbol *s); diff -uNr gdc-0.9/d/dmd/cast.c gdc-0.10/d/dmd/cast.c --- gdc-0.9/d/dmd/cast.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/cast.c 2005-01-09 01:40:20.000000000 +0100 @@ -45,6 +45,8 @@ type->print(); printf("to:\n"); t->print(); +printf("%p %p %s %s\n", type->deco, t->deco, type->deco, t->deco); +printf("%p %p %p\n", type->next->arrayOf(), type, t); #endif //*(char*)0=0; error("cannot implicitly convert expression %s of type %s to %s", toChars(), type->toChars(), t->toChars()); diff -uNr gdc-0.9/d/dmd/class.c gdc-0.10/d/dmd/class.c --- gdc-0.9/d/dmd/class.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/class.c 2005-01-09 01:40:20.000000000 +0100 @@ -57,6 +57,9 @@ vtblsym = NULL; vclassinfo = NULL; + if (id == Id::__sizeof) + error("illegal class name"); + // BUG: What if this is the wrong ClassInfo, i.e. it is nested? if (!classinfo && id == Id::ClassInfo) classinfo = this; @@ -72,6 +75,9 @@ if (!Type::typeinfoclass && id == Id::TypeInfo_Class) Type::typeinfoclass = this; + if (!Type::typeinfostruct && id == Id::TypeInfo_Struct) + Type::typeinfostruct = this; + if (!Type::typeinfotypedef && id == Id::TypeInfo_Typedef) Type::typeinfotypedef = this; @@ -81,7 +87,6 @@ com = 1; #endif isauto = 0; - scope = NULL; } Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s) @@ -110,7 +115,7 @@ { int i; unsigned offset; - //printf("ClassDeclaration::semantic(%s), type = %p\n", toChars(), type); + //printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d\n", toChars(), type, sizeok); //{ static int n; if (++n == 20) *(char*)0=0; } @@ -119,12 +124,14 @@ handle = handle->semantic(loc, sc); } if (!members) // if forward reference - { //printf("\tclass '%s' is forward referenced\n", toChars()); + { printf("\tclass '%s' is forward referenced\n", toChars()); return; } if (symtab) { if (!scope) + { //printf("\tsemantic for '%s' is already completed\n", toChars()); return; // semantic() already completed + } } else symtab = new DsymbolTable(); @@ -165,7 +172,7 @@ { //error("forward reference of base class %s", baseClass->toChars()); // Forward reference of base class, try again later - //printf("\ttry later, forward reference of base class %s\n", baseClass->toChars()); + //printf("\ttry later, forward reference of base class %s\n", tc->sym->toChars()); scope = scx ? scx : new Scope(*sc); scope->setNoFree(); scope->module->addDeferredSemantic(this); @@ -255,24 +262,28 @@ else { // No base class, so this is the root of the class heirarchy + vtbl.setDim(0); vtbl.push(this); // leave room for classinfo as first member } + if (sizeok == 0) + { + interfaceSemantic(sc); + + for (i = 0; i < members->dim; i++) + { + Dsymbol *s = (Dsymbol *)members->data[i]; + s->addMember(this); + } + } + if (sc->stc & STCauto) isauto = 1; - interfaceSemantic(sc); - sc = sc->push(this); sc->stc &= ~(STCauto | STCstatic); sc->parent = this; - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - s->addMember(this); - } - if (isCOMclass()) sc->linkage = LINKwindows; sc->protection = PROTpublic; @@ -289,11 +300,31 @@ structsize = sc->offset; Scope scsave = *sc; int members_dim = members->dim; + sizeok = 0; for (i = 0; i < members_dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; s->semantic(sc); } + + if (sizeok == 2) + { // semantic() failed because of forward references. + // Unwind what we did, and defer it for later + fields.setDim(0); + structsize = 0; + alignsize = 0; + structalign = 0; + + sc->pop(); + + scope = scx ? scx : new Scope(*sc); + scope->setNoFree(); + scope->module->addDeferredSemantic(this); + return; + } + + //printf("\tsemantic('%s') successful\n", toChars()); + structsize = sc->offset; //members->print(); diff -uNr gdc-0.9/d/dmd/declaration.c gdc-0.10/d/dmd/declaration.c --- gdc-0.9/d/dmd/declaration.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/declaration.c 2005-01-09 01:40:20.000000000 +0100 @@ -41,7 +41,7 @@ return "declaration"; } -unsigned Declaration::size() +unsigned Declaration::size(Loc loc) { assert(type); return type->size(); @@ -706,6 +706,13 @@ assert(linkage == LINKc); } +/***************************** TypeInfoStructDeclaration ***********************/ + +TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) + : TypeInfoDeclaration(tinfo, 0) +{ +} + /***************************** TypeInfoClassDeclaration ***********************/ TypeInfoClassDeclaration::TypeInfoClassDeclaration(Type *tinfo) diff -uNr gdc-0.9/d/dmd/declaration.h gdc-0.10/d/dmd/declaration.h --- gdc-0.9/d/dmd/declaration.h 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/dmd/declaration.h 2005-01-09 01:40:20.000000000 +0100 @@ -80,7 +80,7 @@ Declaration(Identifier *id); void semantic(Scope *sc); char *kind(); - unsigned size(); + unsigned size(Loc loc); char *mangle(); int isStatic() { return storage_class & STCstatic; } @@ -221,6 +221,13 @@ virtual void toDt(dt_t **pdt); }; +struct TypeInfoStructDeclaration : TypeInfoDeclaration +{ + TypeInfoStructDeclaration(Type *tinfo); + + void toDt(dt_t **pdt); +}; + struct TypeInfoClassDeclaration : TypeInfoDeclaration { TypeInfoClassDeclaration(Type *tinfo); diff -uNr gdc-0.9/d/dmd/dsymbol.c gdc-0.10/d/dmd/dsymbol.c --- gdc-0.9/d/dmd/dsymbol.c 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/dmd/dsymbol.c 2005-01-09 01:40:20.000000000 +0100 @@ -192,7 +192,7 @@ buf->writenl(); } -unsigned Dsymbol::size() +unsigned Dsymbol::size(Loc loc) { error("Dsymbol '%s' has no size\n", toChars()); return 0; @@ -274,6 +274,11 @@ sd->multiplyDefined(this, s2); } } + if (sd->isAggregateDeclaration() || sd->isEnumDeclaration()) + { + if (ident == Id::__sizeof) + error(".sizeof property cannot be redefined"); + } } } @@ -611,7 +616,7 @@ assert(ident); assert(tab); //#endif - sv = tab->lookup(ident->toChars(),strlen(ident->toChars())); + sv = tab->lookup((char*)ident->string, ident->len); return (Dsymbol *)(sv ? sv->ptrvalue : NULL); } @@ -625,7 +630,7 @@ assert(ident); assert(tab); #endif - sv = tab->insert(ident->toChars(),strlen(ident->toChars())); + sv = tab->insert(ident->toChars(), ident->len); if (!sv) return NULL; // already in table sv->ptrvalue = s; @@ -636,7 +641,7 @@ { StringValue *sv; //printf("DsymbolTable::insert()\n"); - sv = tab->insert(ident->toChars(),strlen(ident->toChars())); + sv = tab->insert(ident->toChars(), ident->len); if (!sv) return NULL; // already in table sv->ptrvalue = s; @@ -648,7 +653,7 @@ Identifier *ident; ident = s->ident; - sv = tab->update(ident->toChars(),strlen(ident->toChars())); + sv = tab->update(ident->toChars(), ident->len); sv->ptrvalue = s; return s; } diff -uNr gdc-0.9/d/dmd/dsymbol.h gdc-0.10/d/dmd/dsymbol.h --- gdc-0.9/d/dmd/dsymbol.h 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/dmd/dsymbol.h 2005-01-09 01:40:20.000000000 +0100 @@ -32,6 +32,7 @@ struct TypedefDeclaration; struct AliasDeclaration; struct AggregateDeclaration; +struct EnumDeclaration; struct ClassDeclaration; struct InterfaceDeclaration; struct StructDeclaration; @@ -113,7 +114,7 @@ virtual Dsymbol *search(Identifier *ident, int flags); virtual int overloadInsert(Dsymbol *s); virtual void toCBuffer(OutBuffer *buf); - virtual unsigned size(); + virtual unsigned size(Loc loc); virtual int isforwardRef(); virtual void defineRef(Dsymbol *s); virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member @@ -171,6 +172,7 @@ virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; } virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; } virtual Import *isImport() { return NULL; } + virtual EnumDeclaration *isEnumDeclaration() { return NULL; } }; // Dsymbol that generates a scope diff -uNr gdc-0.9/d/dmd/enum.c gdc-0.10/d/dmd/enum.c --- gdc-0.9/d/dmd/enum.c 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/enum.c 2005-01-09 01:40:20.000000000 +0100 @@ -44,14 +44,6 @@ return ed; } -void EnumDeclaration::addMember(ScopeDsymbol *sd) -{ int i; - - //printf("EnumDeclaration::addMember(sd = %p, '%s')\n", sd, sd->toChars()); - if (!isAnonymous()) - Dsymbol::addMember(sd); -} - void EnumDeclaration::semantic(Scope *sc) { int i; integer_t number; diff -uNr gdc-0.9/d/dmd/enum.h gdc-0.10/d/dmd/enum.h --- gdc-0.9/d/dmd/enum.h 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/dmd/enum.h 2005-01-09 01:40:20.000000000 +0100 @@ -31,13 +31,14 @@ EnumDeclaration(Identifier *id, Type *memtype); Dsymbol *syntaxCopy(Dsymbol *s); - void addMember(ScopeDsymbol *s); void semantic(Scope *sc); Dsymbol *oneMember(); void toCBuffer(OutBuffer *buf); Type *getType(); char *kind(); + EnumDeclaration *isEnumDeclaration() { return this; } + void toObjFile(); // compile to .obj file void toDebug(); int cvMember(unsigned char *p); diff -uNr gdc-0.9/d/dmd/expression.c gdc-0.10/d/dmd/expression.c --- gdc-0.9/d/dmd/expression.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/expression.c 2005-01-09 01:40:20.000000000 +0100 @@ -1700,7 +1700,9 @@ //printf("tb: %s, deco = %s\n", tb->toChars(), tb->deco); arrayExpressionSemantic(newargs, sc); + preFunctionArguments(loc, sc, newargs); arrayExpressionSemantic(arguments, sc); + preFunctionArguments(loc, sc, arguments); if (tb->ty == Tclass) { ClassDeclaration *cd; @@ -1743,7 +1745,7 @@ f = cd->aggNew; // Prepend the uint size argument to newargs[] - e = new IntegerExp(loc, cd->size(), Type::tuns32); + e = new IntegerExp(loc, cd->size(loc), Type::tuns32); if (!newargs) newargs = new Array(); newargs->shift(e); @@ -1775,7 +1777,7 @@ Expression *e; // Prepend the uint size argument to newargs[] - e = new IntegerExp(loc, sd->size(), Type::tuns32); + e = new IntegerExp(loc, sd->size(loc), Type::tuns32); if (!newargs) newargs = new Array(); newargs->shift(e); @@ -2338,31 +2340,34 @@ AggregateDeclaration *ad; ad = sc->getStructClassScope(); - cd = ad->isClassDeclaration(); - if (cd) + if (ad) { - if (e1->op == TOKthis) - { - e = new TypeDotIdExp(loc, cd->type, ident); - return e->semantic(sc); - } - else if (cd->baseClass && e1->op == TOKsuper) - { - e = new TypeDotIdExp(loc, cd->baseClass->type, ident); - return e->semantic(sc); - } - } - else - { - sd = ad->isStructDeclaration(); - if (sd) + cd = ad->isClassDeclaration(); + if (cd) { if (e1->op == TOKthis) { - e = new TypeDotIdExp(loc, sd->type, ident); + e = new TypeDotIdExp(loc, cd->type, ident); + return e->semantic(sc); + } + else if (cd->baseClass && e1->op == TOKsuper) + { + e = new TypeDotIdExp(loc, cd->baseClass->type, ident); return e->semantic(sc); } } + else + { + sd = ad->isStructDeclaration(); + if (sd) + { + if (e1->op == TOKthis) + { + e = new TypeDotIdExp(loc, sd->type, ident); + return e->semantic(sc); + } + } + } } } @@ -5009,6 +5014,9 @@ e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); + e1 = resolveProperties(sc, e1); + e2 = resolveProperties(sc, e2); + e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); e1 = e1->checkToBoolean(); @@ -5047,6 +5055,9 @@ e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); + e1 = resolveProperties(sc, e1); + e2 = resolveProperties(sc, e2); + e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); e1 = e1->checkToBoolean(); diff -uNr gdc-0.9/d/dmd/func.c gdc-0.10/d/dmd/func.c --- gdc-0.9/d/dmd/func.c 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/dmd/func.c 2005-01-09 01:40:20.000000000 +0100 @@ -30,6 +30,10 @@ #include "statement.h" #include "template.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + /********************************* FuncDeclaration ****************************/ @@ -92,12 +96,13 @@ InterfaceDeclaration *id; #if 0 - printf("FuncDeclaration::semantic(sc = %p, this = %p, '%s', linkage = %d)\n", sc, this, toChars(), sc->linkage); + printf("FuncDeclaration::semantic(sc = %p, this = %p, '%s', linkage = %d)\n", sc, this, toPrettyChars(), sc->linkage); if (isFuncLiteralDeclaration()) printf("\tFuncLiteralDeclaration()\n"); #endif type = type->semantic(loc, sc); + //type->print(); if (type->ty != Tfunction) { error("%s must be a function", toChars()); @@ -248,9 +253,15 @@ // Override //printf("\toverride %p with %p\n", fdv, this); if (cov == 2) - error("overrides but is not covariant with %s", fdv->toChars()); + { + //type->print(); + //fdv->type->print(); + //printf("%s %s\n", type->deco, fdv->type->deco); + error("of type %s overrides but is not covariant with %s of type %s", + type->toChars(), fdv->toPrettyChars(), fdv->type->toChars()); + } if (fdv->isFinal()) - error("cannot override final function %s", fdv->toChars()); + error("cannot override final function %s", fdv->toPrettyChars()); if (fdv->toParent() == parent) { // If both are mixins, then error. @@ -350,6 +361,11 @@ AggregateDeclaration *ad; VarDeclaration *argptr = NULL; + if (!parent) + { + printf("FuncDeclaration::semantic3(%s '%s', sc = %p)\n", kind(), toChars(), sc); + assert(0); + } //printf("FuncDeclaration::semantic3('%s.%s', sc = %p)\n", parent->toChars(), toChars(), sc); //fflush(stdout); //{ static int x; if (++x == 2) *(char*)0=0; } @@ -451,7 +467,6 @@ #ifndef IN_GCC t = Type::tvoid->pointerTo(); #else - extern Type * d_gcc_builtin_va_list_d_type; t = d_gcc_builtin_va_list_d_type; #endif argptr = new VarDeclaration(0, t, Id::_argptr, NULL); @@ -1157,7 +1172,7 @@ int FuncDeclaration::isNested() { - //printf("FuncDeclaration::isNested() '%s'\n", toChars()); +// if (!toParent()) printf("FuncDeclaration::isNested('%s') parent=%p\n", toChars(), parent); //printf("\ttoParent() = '%s'\n", toParent()->toChars()); return ((storage_class & STCstatic) == 0) && (toParent()->isFuncDeclaration() != NULL); diff -uNr gdc-0.9/d/dmd/html.c gdc-0.10/d/dmd/html.c --- gdc-0.9/d/dmd/html.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/dmd/html.c 2004-12-26 17:15:05.000000000 +0100 @@ -11,6 +11,7 @@ work with the GDC compiler. Modified by David Friedman, September 2004 + Modified by Thomas Kuehne, November 2004 */ /* HTML parser @@ -41,6 +42,36 @@ return (isalnum(c) || c == '_'); } +/** + * identify DOS, Linux, Mac, Next and Unicode line endings + * 0 if this is no line seperator + * >0 the length of the seperator + * Note: input has to be UTF-8 + */ +static int isLineSeperator(const unsigned char* p){ + // Linux + if( p[0]=='\n'){ + return 1; + } + + // Mac & Dos + if( p[0]=='\r'){ + return (p[1]=='\n') ? 2 : 1; + } + + // Unicode (line || paragarph sep.) + if( p[0]==0xE2 && p[1]==0x80 && (p[2]==0xA8 || p[2]==0xA9)){ + return 3; + } + + // Next + if( p[0]==0xC2 && p[1]==0x85){ + return 2; + } + + return 0; +} + /********************************************** */ @@ -122,21 +153,23 @@ int c; c = charEntity(); - buf->writeByte(c); // BUG: wchar + buf->writeUTF8(c); } else p++; continue; - case '\n': - linnum++; - // Always extract new lines, so that D lexer counts the - // lines right. - buf->writeByte(*p); // BUG: wchar - p++; - continue; - default: + int lineSepLength=isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that the D lexer + // counts the lines right. + buf->writeByte('\n'); // BUG: wchar + p+=lineSepLength; + continue; + } + if (inCode) buf->writeByte(*p); // BUG: wchar p++; @@ -214,23 +247,24 @@ error("end of file before end of tag"); break; // end of file - case '\n': - linnum++; - // Always extract new lines, so that code lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - state = TSrest; // end of tag - p++; - continue; - default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that code lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + state = TSrest; + p+=lineSepLength; + continue; + } switch (state) { case TStagstart: // start of tag name assert(istagstart(*p)); state = TStag; tagstart = p; - taglen = 0; + taglen = 1; break; case TStag: @@ -254,7 +288,8 @@ } // See if we parsed a or tag - if (taglen && memicmp((const char *)tagstart, "CODE", taglen) == 0) + if (taglen == 4 && memicmp((const char *)tagstart, "CODE", taglen) == 0 && + *(p - 2) != '/') { if (nottag) { inCode--; @@ -287,13 +322,6 @@ } continue; - case '\n': - linnum++; - // Always extract new lines, so that D lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - continue; - case 0: case 0x1a: Leof: @@ -301,6 +329,14 @@ break; default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that D lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + continue; + } continue; } break; @@ -353,25 +389,26 @@ case ' ': case '\t': - case '\r': case '\f': case '\v': // skip white space continue; - case '\n': - linnum++; // remember to count lines - // Always extract new lines, so that D lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - continue; - case 0: case 0x1a: error("end of file before closing --> of comment"); break; default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; // remember to count lines + // Always extract new lines, so that D lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + p+=lineSepLength-1; + continue; + } scangt = 0; // it's not --> continue; } @@ -449,7 +486,7 @@ c = (c << 4) + v; else c = (c * 10) + v; - if (c > 0xFFFF) + if (c > 0x10FFFF) error("character entity out of range"); continue; @@ -458,11 +495,8 @@ error("invalid numeric character reference"); break; } + break; } - - // Kludge to convert non-breaking space to ascii space - if (c == 160) - c = 32; } else { @@ -498,6 +532,10 @@ break; } } + + // Kludge to convert non-breaking space to ascii space + if (c == 160) + c = 32; return c; } @@ -511,36 +549,1049 @@ int value; }; -static NameId names[] = -{ - "quot", 34, - "amp", 38, - "apos", 39, - "lt", 60, - "gt", 62, -// "nbsp", 160, - "nbsp", 32, // make non-breaking space appear as space - "iexcl", 161, - "cent", 162, - "pound", 163, - "curren", 164, - "yen", 165, - "brvbar", 166, - "sect", 167, - "uml", 168, - "copy", 169, - "ordf", 170, - "laquo", 171, - "not", 172, - "shy", 173, - "reg", 174, - NULL, 0 - - // BUG: This is only a partial list. - // For the rest, consult: - // http://www.w3.org/TR/1999/REC-html401-19991224/sgml/entities.html +static NameId namesA[]={ + "Aacgr", 0x0386, + "aacgr", 0x03AC, + "Aacute", 0x00C1, + "aacute", 0x00E1, + "Abreve", 0x0102, + "abreve", 0x0103, + "Acirc", 0x00C2, + "acirc", 0x00E2, + "acute", 0x00B4, + "Acy", 0x0410, + "acy", 0x0430, + "AElig", 0x00C6, + "aelig", 0x00E6, + "Agr", 0x0391, + "agr", 0x03B1, + "Agrave", 0x00C0, + "agrave", 0x00E0, + "aleph", 0x2135, + "alpha", 0x03B1, + "Amacr", 0x0100, + "amacr", 0x0101, + "amalg", 0x2210, + "amp", 0x0026, + "and", 0x2227, + "ang", 0x2220, + "ang90", 0x221F, + "angmsd", 0x2221, + "angsph", 0x2222, + "angst", 0x212B, + "Aogon", 0x0104, + "aogon", 0x0105, + "ap", 0x2248, + "ape", 0x224A, + "apos", 0x0027, + "Aring", 0x00C5, + "aring", 0x00E5, + "ast", 0x002A, + "asymp", 0x224D, + "Atilde", 0x00C3, + "atilde", 0x00E3, + "Auml", 0x00C4, + "auml", 0x00E4, + NULL, 0 +}; + +static NameId namesB[]={ + "barwed", 0x22BC, + "Barwed", 0x2306, + "bcong", 0x224C, + "Bcy", 0x0411, + "bcy", 0x0431, + "becaus", 0x2235, + "bepsi", 0x220D, + "bernou", 0x212C, + "beta", 0x03B2, + "beth", 0x2136, + "Bgr", 0x0392, + "bgr", 0x03B2, + "blank", 0x2423, + "blk12", 0x2592, + "blk14", 0x2591, + "blk34", 0x2593, + "block", 0x2588, + "bottom", 0x22A5, + "bowtie", 0x22C8, + "boxdl", 0x2510, + "boxDL", 0x2555, + "boxdL", 0x2556, + "boxDl", 0x2557, + "boxdr", 0x250C, + "boxDR", 0x2552, + "boxDr", 0x2553, + "boxdR", 0x2554, + "boxh", 0x2500, + "boxH", 0x2550, + "boxhd", 0x252C, + "boxhD", 0x2564, + "boxHD", 0x2565, + "boxHd", 0x2566, + "boxhu", 0x2534, + "boxhU", 0x2567, + "boxHU", 0x2568, + "boxHu", 0x2569, + "boxul", 0x2518, + "boxUL", 0x255B, + "boxUl", 0x255C, + "boxuL", 0x255D, + "boxur", 0x2514, + "boxUR", 0x2558, + "boxuR", 0x2559, + "boxUr", 0x255A, + "boxv", 0x2502, + "boxV", 0x2551, + "boxvh", 0x253C, + "boxvH", 0x256A, + "boxVH", 0x256B, + "boxVh", 0x256C, + "boxvl", 0x2524, + "boxvL", 0x2561, + "boxVL", 0x2562, + "boxVl", 0x2563, + "boxvr", 0x251C, + "boxvR", 0x255E, + "boxVR", 0x255F, + "boxVr", 0x2560, + "bprime", 0x2035, + "breve", 0x02D8, + "brvbar", 0x00A6, + "bsim", 0x223D, + "bsime", 0x22CD, + "bsol", 0x005C, + "bull", 0x2022, + "bump", 0x224E, + "bumpe", 0x224F, + NULL, 0 +}; + +static NameId namesC[]={ + "Cacute", 0x0106, + "cacute", 0x0107, + "cap", 0x2229, + "Cap", 0x22D2, + "caret", 0x2041, + "caron", 0x02C7, + "Ccaron", 0x010C, + "ccaron", 0x010D, + "Ccedil", 0x00C7, + "ccedil", 0x00E7, + "Ccirc", 0x0108, + "ccirc", 0x0109, + "Cdot", 0x010A, + "cdot", 0x010B, + "cedil", 0x00B8, + "cent", 0x00A2, + "CHcy", 0x0427, + "chcy", 0x0447, + "check", 0x2713, + "chi", 0x03C7, + "cir", 0x25CB, + "circ", 0x005E, + "cire", 0x2257, + "clubs", 0x2663, + "colon", 0x003A, + "colone", 0x2254, + "comma", 0x002C, + "commat", 0x0040, + "comp", 0x2201, + "compfn", 0x2218, + "cong", 0x2245, + "conint", 0x222E, + "coprod", 0x2210, + "copy", 0x00A9, + "copysr", 0x2117, + "cross", 0x2717, + "cuepr", 0x22DE, + "cuesc", 0x22DF, + "cularr", 0x21B6, + "cup", 0x222A, + "Cup", 0x22D3, + "cupre", 0x227C, + "curarr", 0x21B7, + "curren", 0x00A4, + "cuvee", 0x22CE, + "cuwed", 0x22CF, + NULL, 0 +}; + +static NameId namesD[]={ + "dagger", 0x2020, + "Dagger", 0x2021, + "daleth", 0x2138, + "darr", 0x2193, + "dArr", 0x21D3, + "darr2", 0x21CA, + "dash", 0x2010, + "dashv", 0x22A3, + "dblac", 0x02DD, + "Dcaron", 0x010E, + "dcaron", 0x010F, + "Dcy", 0x0414, + "dcy", 0x0434, + "deg", 0x00B0, + "Delta", 0x0394, + "delta", 0x03B4, + "Dgr", 0x0394, + "dgr", 0x03B4, + "dharl", 0x21C3, + "dharr", 0x21C2, + "diam", 0x22C4, + "diams", 0x2666, + "die", 0x00A8, + "divide", 0x00F7, + "divonx", 0x22C7, + "DJcy", 0x0402, + "djcy", 0x0452, + "dlarr", 0x2199, + "dlcorn", 0x231E, + "dlcrop", 0x230D, + "dollar", 0x0024, + "Dot", 0x00A8, + "dot", 0x02D9, + "DotDot", 0x20DC, + "drarr", 0x2198, + "drcorn", 0x231F, + "drcrop", 0x230C, + "DScy", 0x0405, + "dscy", 0x0455, + "Dstrok", 0x0110, + "dstrok", 0x0111, + "dtri", 0x25BF, + "dtrif", 0x25BE, + "DZcy", 0x040F, + "dzcy", 0x045F, + NULL, 0 +}; + +static NameId namesE[]={ + "Eacgr", 0x0388, + "eacgr", 0x03AD, + "Eacute", 0x00C9, + "eacute", 0x00E9, + "Ecaron", 0x011A, + "ecaron", 0x011B, + "ecir", 0x2256, + "Ecirc", 0x00CA, + "ecirc", 0x00EA, + "ecolon", 0x2255, + "Ecy", 0x042D, + "ecy", 0x044D, + "Edot", 0x0116, + "edot", 0x0117, + "eDot", 0x2251, + "EEacgr", 0x0389, + "eeacgr", 0x03AE, + "EEgr", 0x0397, + "eegr", 0x03B7, + "efDot", 0x2252, + "Egr", 0x0395, + "egr", 0x03B5, + "Egrave", 0x00C8, + "egrave", 0x00E8, + "egs", 0x22DD, + "ell", 0x2113, + "els", 0x22DC, + "Emacr", 0x0112, + "emacr", 0x0113, + "empty", 0x2205, + "emsp", 0x2003, + "emsp13", 0x2004, + "emsp14", 0x2005, + "ENG", 0x014A, + "eng", 0x014B, + "ensp", 0x2002, + "Eogon", 0x0118, + "eogon", 0x0119, + "epsi", 0x220A, + "epsis", 0x220A, + "epsiv", 0x03B5, + "equals", 0x003D, + "equiv", 0x2261, + "erDot", 0x2253, + "esdot", 0x2250, + "eta", 0x03B7, + "ETH", 0x00D0, + "eth", 0x00F0, + "Euml", 0x00CB, + "euml", 0x00EB, + "excl", 0x0021, + "exist", 0x2203, + NULL, 0 +}; + +static NameId namesF[]={ + "Fcy", 0x0424, + "fcy", 0x0444, + "female", 0x2640, + "ffilig", 0xFB03, + "fflig", 0xFB00, + "ffllig", 0xFB04, + "filig", 0xFB01, + "flat", 0x266D, + "fllig", 0xFB02, + "fnof", 0x0192, + "forall", 0x2200, + "fork", 0x22D4, + "frac12", 0x00BD, + "frac13", 0x2153, + "frac14", 0x00BC, + "frac15", 0x2155, + "frac16", 0x2159, + "frac18", 0x215B, + "frac23", 0x2154, + "frac25", 0x2156, + "frac34", 0x00BE, + "frac35", 0x2157, + "frac38", 0x215C, + "frac45", 0x2158, + "frac56", 0x215A, + "frac58", 0x215D, + "frac78", 0x215E, + "frown", 0x2322, + NULL, 0 +}; + +static NameId namesG[]={ + "gacute", 0x01F5, + "Gamma", 0x0393, + "gamma", 0x03B3, + "gammad", 0x03DC, + "gap", 0x2273, + "Gbreve", 0x011E, + "gbreve", 0x011F, + "Gcedil", 0x0122, + "Gcirc", 0x011C, + "gcirc", 0x011D, + "Gcy", 0x0413, + "gcy", 0x0433, + "Gdot", 0x0120, + "gdot", 0x0121, + "ge", 0x2265, + "gE", 0x2267, + "gel", 0x22DB, + "gEl", 0x22DB, + "ges", 0x2265, + "Gg", 0x22D9, + "Ggr", 0x0393, + "ggr", 0x03B3, + "gimel", 0x2137, + "GJcy", 0x0403, + "gjcy", 0x0453, + "gl", 0x2277, + "gnap", 0xE411, + "gne", 0x2269, + "gnE", 0x2269, + "gnsim", 0x22E7, + "grave", 0x0060, + "gsdot", 0x22D7, + "gsim", 0x2273, + "gt", 0x003E, + "Gt", 0x226B, + "gvnE", 0x2269, + NULL, 0 +}; + +static NameId namesH[]={ + "hairsp", 0x200A, + "half", 0x00BD, + "hamilt", 0x210B, + "HARDcy", 0x042A, + "hardcy", 0x044A, + "harr", 0x2194, + "hArr", 0x21D4, + "harrw", 0x21AD, + "Hcirc", 0x0124, + "hcirc", 0x0125, + "hearts", 0x2665, + "hellip", 0x2026, + "horbar", 0x2015, + "Hstrok", 0x0126, + "hstrok", 0x0127, + "hybull", 0x2043, + "hyphen", 0x002D, + NULL, 0 +}; + +static NameId namesI[]={ + "Iacgr", 0x038A, + "iacgr", 0x03AF, + "Iacute", 0x00CD, + "iacute", 0x00ED, + "Icirc", 0x00CE, + "icirc", 0x00EE, + "Icy", 0x0418, + "icy", 0x0438, + "idiagr", 0x0390, + "Idigr", 0x03AA, + "idigr", 0x03CA, + "Idot", 0x0130, + "IEcy", 0x0415, + "iecy", 0x0435, + "iexcl", 0x00A1, + "iff", 0x21D4, + "Igr", 0x0399, + "igr", 0x03B9, + "Igrave", 0x00CC, + "igrave", 0x00EC, + "IJlig", 0x0132, + "ijlig", 0x0133, + "Imacr", 0x012A, + "imacr", 0x012B, + "image", 0x2111, + "incare", 0x2105, + "infin", 0x221E, + "inodot", 0x0131, + "int", 0x222B, + "intcal", 0x22BA, + "IOcy", 0x0401, + "iocy", 0x0451, + "Iogon", 0x012E, + "iogon", 0x012F, + "iota", 0x03B9, + "iquest", 0x00BF, + "isin", 0x220A, + "Itilde", 0x0128, + "itilde", 0x0129, + "Iukcy", 0x0406, + "iukcy", 0x0456, + "Iuml", 0x00CF, + "iuml", 0x00EF, + NULL, 0 +}; + +static NameId namesJ[]={ + "Jcirc", 0x0134, + "jcirc", 0x0135, + "Jcy", 0x0419, + "jcy", 0x0439, + "Jsercy", 0x0408, + "jsercy", 0x0458, + "Jukcy", 0x0404, + "jukcy", 0x0454, + NULL, 0 +}; + +static NameId namesK[]={ + "kappa", 0x03BA, + "kappav", 0x03F0, + "Kcedil", 0x0136, + "kcedil", 0x0137, + "Kcy", 0x041A, + "kcy", 0x043A, + "Kgr", 0x039A, + "kgr", 0x03BA, + "kgreen", 0x0138, + "KHcy", 0x0425, + "khcy", 0x0445, + "KHgr", 0x03A7, + "khgr", 0x03C7, + "KJcy", 0x040C, + "kjcy", 0x045C, + NULL, 0 +}; + +static NameId namesL[]={ + "lAarr", 0x21DA, + "Lacute", 0x0139, + "lacute", 0x013A, + "lagran", 0x2112, + "Lambda", 0x039B, + "lambda", 0x03BB, + "lang", 0x3008, + "lap", 0x2272, + "laquo", 0x00AB, + "larr", 0x2190, + "Larr", 0x219E, + "lArr", 0x21D0, + "larr2", 0x21C7, + "larrhk", 0x21A9, + "larrlp", 0x21AB, + "larrtl", 0x21A2, + "Lcaron", 0x013D, + "lcaron", 0x013E, + "Lcedil", 0x013B, + "lcedil", 0x013C, + "lceil", 0x2308, + "lcub", 0x007B, + "Lcy", 0x041B, + "lcy", 0x043B, + "ldot", 0x22D6, + "ldquo", 0x201C, + "ldquor", 0x201E, + "le", 0x2264, + "lE", 0x2266, + "leg", 0x22DA, + "lEg", 0x22DA, + "les", 0x2264, + "lfloor", 0x230A, + "lg", 0x2276, + "Lgr", 0x039B, + "lgr", 0x03BB, + "lhard", 0x21BD, + "lharu", 0x21BC, + "lhblk", 0x2584, + "LJcy", 0x0409, + "ljcy", 0x0459, + "Ll", 0x22D8, + "Lmidot", 0x013F, + "lmidot", 0x0140, + "lnap", 0xE2A2, + "lne", 0x2268, + "lnE", 0x2268, + "lnsim", 0x22E6, + "lowast", 0x2217, + "lowbar", 0x005F, + "loz", 0x25CA, + "lozf", 0x2726, + "lpar", 0x0028, + "lrarr2", 0x21C6, + "lrhar2", 0x21CB, + "lsh", 0x21B0, + "lsim", 0x2272, + "lsqb", 0x005B, + "lsquo", 0x2018, + "lsquor", 0x201A, + "Lstrok", 0x0141, + "lstrok", 0x0142, + "lt", 0x003C, + "Lt", 0x226A, + "lthree", 0x22CB, + "ltimes", 0x22C9, + "ltri", 0x25C3, + "ltrie", 0x22B4, + "ltrif", 0x25C2, + "lvnE", 0x2268, + NULL, 0 +}; + +static NameId namesM[]={ + "macr", 0x00AF, + "male", 0x2642, + "malt", 0x2720, + "map", 0x21A6, + "marker", 0x25AE, + "Mcy", 0x041C, + "mcy", 0x043C, + "mdash", 0x2014, + "Mgr", 0x039C, + "mgr", 0x03BC, + "micro", 0x00B5, + "mid", 0x2223, + "middot", 0x00B7, + "minus", 0x2212, + "minusb", 0x229F, + "mldr", 0x2026, + "mnplus", 0x2213, + "models", 0x22A7, + "mu", 0x03BC, + "mumap", 0x22B8, + NULL, 0 +}; + +static NameId namesN[]={ + "nabla", 0x2207, + "Nacute", 0x0143, + "nacute", 0x0144, + "nap", 0x2249, + "napos", 0x0149, + "natur", 0x266E, + "nbsp", 0x00A0, + "Ncaron", 0x0147, + "ncaron", 0x0148, + "Ncedil", 0x0145, + "ncedil", 0x0146, + "ncong", 0x2247, + "Ncy", 0x041D, + "ncy", 0x043D, + "ndash", 0x2013, + "ne", 0x2260, + "nearr", 0x2197, + "nequiv", 0x2262, + "nexist", 0x2204, + "nge", 0x2271, + "ngE", 0x2271, + "nges", 0x2271, + "Ngr", 0x039D, + "ngr", 0x03BD, + "ngt", 0x226F, + "nharr", 0x21AE, + "nhArr", 0x21CE, + "ni", 0x220D, + "NJcy", 0x040A, + "njcy", 0x045A, + "nlarr", 0x219A, + "nlArr", 0x21CD, + "nldr", 0x2025, + "nle", 0x2270, + "nlE", 0x2270, + "nles", 0x2270, + "nlt", 0x226E, + "nltri", 0x22EA, + "nltrie", 0x22EC, + "nmid", 0x2224, + "not", 0x00AC, + "notin", 0x2209, + "npar", 0x2226, + "npr", 0x2280, + "npre", 0x22E0, + "nrarr", 0x219B, + "nrArr", 0x21CF, + "nrtri", 0x22EB, + "nrtrie", 0x22ED, + "nsc", 0x2281, + "nsce", 0x22E1, + "nsim", 0x2241, + "nsime", 0x2244, + "nsmid", 0xE2AA, + "nspar", 0x2226, + "nsub", 0x2284, + "nsube", 0x2288, + "nsubE", 0x2288, + "nsup", 0x2285, + "nsupe", 0x2289, + "nsupE", 0x2289, + "Ntilde", 0x00D1, + "ntilde", 0x00F1, + "nu", 0x03BD, + "num", 0x0023, + "numero", 0x2116, + "numsp", 0x2007, + "nvdash", 0x22AC, + "nvDash", 0x22AD, + "nVdash", 0x22AE, + "nVDash", 0x22AF, + "nwarr", 0x2196, + NULL, 0 +}; + +static NameId namesO[]={ + "Oacgr", 0x038C, + "oacgr", 0x03CC, + "Oacute", 0x00D3, + "oacute", 0x00F3, + "oast", 0x229B, + "ocir", 0x229A, + "Ocirc", 0x00D4, + "ocirc", 0x00F4, + "Ocy", 0x041E, + "ocy", 0x043E, + "odash", 0x229D, + "Odblac", 0x0150, + "odblac", 0x0151, + "odot", 0x2299, + "OElig", 0x0152, + "oelig", 0x0153, + "ogon", 0x02DB, + "Ogr", 0x039F, + "ogr", 0x03BF, + "Ograve", 0x00D2, + "ograve", 0x00F2, + "OHacgr", 0x038F, + "ohacgr", 0x03CE, + "OHgr", 0x03A9, + "ohgr", 0x03C9, + "ohm", 0x2126, + "olarr", 0x21BA, + "Omacr", 0x014C, + "omacr", 0x014D, + "Omega", 0x03A9, + "omega", 0x03C9, + "ominus", 0x2296, + "oplus", 0x2295, + "or", 0x2228, + "orarr", 0x21BB, + "order", 0x2134, + "ordf", 0x00AA, + "ordm", 0x00BA, + "oS", 0x24C8, + "Oslash", 0x00D8, + "oslash", 0x00F8, + "osol", 0x2298, + "Otilde", 0x00D5, + "otilde", 0x00F5, + "otimes", 0x2297, + "Ouml", 0x00D6, + "ouml", 0x00F6, + NULL, 0 +}; + +static NameId namesP[]={ + "par", 0x2225, + "para", 0x00B6, + "part", 0x2202, + "Pcy", 0x041F, + "pcy", 0x043F, + "percnt", 0x0025, + "period", 0x002E, + "permil", 0x2030, + "perp", 0x22A5, + "Pgr", 0x03A0, + "pgr", 0x03C0, + "PHgr", 0x03A6, + "phgr", 0x03C6, + "Phi", 0x03A6, + "phis", 0x03C6, + "phiv", 0x03D5, + "phmmat", 0x2133, + "phone", 0x260E, + "Pi", 0x03A0, + "pi", 0x03C0, + "piv", 0x03D6, + "planck", 0x210F, + "plus", 0x002B, + "plusb", 0x229E, + "plusdo", 0x2214, + "plusmn", 0x00B1, + "pound", 0x00A3, + "pr", 0x227A, + "prap", 0x227E, + "pre", 0x227C, + "prime", 0x2032, + "Prime", 0x2033, + "prnap", 0x22E8, + "prnE", 0xE2B3, + "prnsim", 0x22E8, + "prod", 0x220F, + "prop", 0x221D, + "prsim", 0x227E, + "PSgr", 0x03A8, + "psgr", 0x03C8, + "Psi", 0x03A8, + "psi", 0x03C8, + "puncsp", 0x2008, + NULL, 0 +}; + +static NameId namesQ[]={ + "quest", 0x003F, + "quot", 0x0022, + NULL, 0 +}; + +static NameId namesR[]={ + "rAarr", 0x21DB, + "Racute", 0x0154, + "racute", 0x0155, + "radic", 0x221A, + "rang", 0x3009, + "raquo", 0x00BB, + "rarr", 0x2192, + "Rarr", 0x21A0, + "rArr", 0x21D2, + "rarr2", 0x21C9, + "rarrhk", 0x21AA, + "rarrlp", 0x21AC, + "rarrtl", 0x21A3, + "rarrw", 0x219D, + "Rcaron", 0x0158, + "rcaron", 0x0159, + "Rcedil", 0x0156, + "rcedil", 0x0157, + "rceil", 0x2309, + "rcub", 0x007D, + "Rcy", 0x0420, + "rcy", 0x0440, + "rdquo", 0x201D, + "rdquor", 0x201C, + "real", 0x211C, + "rect", 0x25AD, + "reg", 0x00AE, + "rfloor", 0x230B, + "Rgr", 0x03A1, + "rgr", 0x03C1, + "rhard", 0x21C1, + "rharu", 0x21C0, + "rho", 0x03C1, + "rhov", 0x03F1, + "ring", 0x02DA, + "rlarr2", 0x21C4, + "rlhar2", 0x21CC, + "rpar", 0x0029, + "rpargt", 0xE291, + "rsh", 0x21B1, + "rsqb", 0x005D, + "rsquo", 0x2019, + "rsquor", 0x2018, + "rthree", 0x22CC, + "rtimes", 0x22CA, + "rtri", 0x25B9, + "rtrie", 0x22B5, + "rtrif", 0x25B8, + "rx", 0x211E, + NULL, 0 +}; + +static NameId namesS[]={ + "Sacute", 0x015A, + "sacute", 0x015B, + "samalg", 0x2210, + "sbsol", 0xFE68, + "sc", 0x227B, + "scap", 0x227F, + "Scaron", 0x0160, + "scaron", 0x0161, + "sccue", 0x227D, + "sce", 0x227D, + "Scedil", 0x015E, + "scedil", 0x015F, + "Scirc", 0x015C, + "scirc", 0x015D, + "scnap", 0x22E9, + "scnE", 0xE2B5, + "scnsim", 0x22E9, + "scsim", 0x227F, + "Scy", 0x0421, + "scy", 0x0441, + "sdot", 0x22C5, + "sdotb", 0x22A1, + "sect", 0x00A7, + "semi", 0x003B, + "setmn", 0x2216, + "sext", 0x2736, + "sfgr", 0x03C2, + "sfrown", 0x2322, + "Sgr", 0x03A3, + "sgr", 0x03C3, + "sharp", 0x266F, + "SHCHcy", 0x0429, + "shchcy", 0x0449, + "SHcy", 0x0428, + "shcy", 0x0448, + "shy", 0x00AD, + "Sigma", 0x03A3, + "sigma", 0x03C3, + "sigmav", 0x03C2, + "sim", 0x223C, + "sime", 0x2243, + "smid", 0xE301, + "smile", 0x2323, + "SOFTcy", 0x042C, + "softcy", 0x044C, + "sol", 0x002F, + "spades", 0x2660, + "spar", 0x2225, + "sqcap", 0x2293, + "sqcup", 0x2294, + "sqsub", 0x228F, + "sqsube", 0x2291, + "sqsup", 0x2290, + "sqsupe", 0x2292, + "squ", 0x25A1, + "square", 0x25A1, + "squf", 0x25AA, + "ssetmn", 0x2216, + "ssmile", 0x2323, + "sstarf", 0x22C6, + "star", 0x22C6, + "starf", 0x2605, + "sub", 0x2282, + "Sub", 0x22D0, + "sube", 0x2286, + "subE", 0x2286, + "subne", 0x228A, + "subnE", 0x228A, + "sum", 0x2211, + "sung", 0x2669, + "sup", 0x2283, + "Sup", 0x22D1, + "sup1", 0x00B9, + "sup2", 0x00B2, + "sup3", 0x00B3, + "supe", 0x2287, + "supE", 0x2287, + "supne", 0x228B, + "supnE", 0x228B, + "szlig", 0x00DF, + NULL, 0 +}; + +static NameId namesT[]={ + "target", 0x2316, + "tau", 0x03C4, + "Tcaron", 0x0164, + "tcaron", 0x0165, + "Tcedil", 0x0162, + "tcedil", 0x0163, + "Tcy", 0x0422, + "tcy", 0x0442, + "tdot", 0x20DB, + "telrec", 0x2315, + "Tgr", 0x03A4, + "tgr", 0x03C4, + "there4", 0x2234, + "Theta", 0x0398, + "thetas", 0x03B8, + "thetav", 0x03D1, + "THgr", 0x0398, + "thgr", 0x03B8, + "thinsp", 0x2009, + "thkap", 0x2248, + "thksim", 0x223C, + "THORN", 0x00DE, + "thorn", 0x00FE, + "tilde", 0x02DC, + "times", 0x00D7, + "timesb", 0x22A0, + "top", 0x22A4, + "tprime", 0x2034, + "trade", 0x2122, + "trie", 0x225C, + "TScy", 0x0426, + "tscy", 0x0446, + "TSHcy", 0x040B, + "tshcy", 0x045B, + "Tstrok", 0x0166, + "tstrok", 0x0167, + "twixt", 0x226C, + NULL, 0 }; +static NameId namesU[]={ + "Uacgr", 0x038E, + "uacgr", 0x03CD, + "Uacute", 0x00DA, + "uacute", 0x00FA, + "uarr", 0x2191, + "uArr", 0x21D1, + "uarr2", 0x21C8, + "Ubrcy", 0x040E, + "ubrcy", 0x045E, + "Ubreve", 0x016C, + "ubreve", 0x016D, + "Ucirc", 0x00DB, + "ucirc", 0x00FB, + "Ucy", 0x0423, + "ucy", 0x0443, + "Udblac", 0x0170, + "udblac", 0x0171, + "udiagr", 0x03B0, + "Udigr", 0x03AB, + "udigr", 0x03CB, + "Ugr", 0x03A5, + "ugr", 0x03C5, + "Ugrave", 0x00D9, + "ugrave", 0x00F9, + "uharl", 0x21BF, + "uharr", 0x21BE, + "uhblk", 0x2580, + "ulcorn", 0x231C, + "ulcrop", 0x230F, + "Umacr", 0x016A, + "umacr", 0x016B, + "uml", 0x00A8, + "Uogon", 0x0172, + "uogon", 0x0173, + "uplus", 0x228E, + "upsi", 0x03C5, + "Upsi", 0x03D2, + "urcorn", 0x231D, + "urcrop", 0x230E, + "Uring", 0x016E, + "uring", 0x016F, + "Utilde", 0x0168, + "utilde", 0x0169, + "utri", 0x25B5, + "utrif", 0x25B4, + "Uuml", 0x00DC, + "uuml", 0x00FC, + NULL, 0 +}; + +static NameId namesV[]={ + "varr", 0x2195, + "vArr", 0x21D5, + "Vcy", 0x0412, + "vcy", 0x0432, + "vdash", 0x22A2, + "vDash", 0x22A8, + "Vdash", 0x22A9, + "veebar", 0x22BB, + "vellip", 0x22EE, + "verbar", 0x007C, + "Verbar", 0x2016, + "vltri", 0x22B2, + "vprime", 0x2032, + "vprop", 0x221D, + "vrtri", 0x22B3, + "vsubne", 0x228A, + "vsubnE", 0xE2B8, + "vsupne", 0x228B, + "vsupnE", 0x228B, + "Vvdash", 0x22AA, + NULL, 0 +}; + +static NameId namesW[]={ + "Wcirc", 0x0174, + "wcirc", 0x0175, + "wedgeq", 0x2259, + "weierp", 0x2118, + "wreath", 0x2240, + NULL, 0 +}; + +static NameId namesX[]={ + "xcirc", 0x25CB, + "xdtri", 0x25BD, + "Xgr", 0x039E, + "xgr", 0x03BE, + "xharr", 0x2194, + "xhArr", 0x2194, + "Xi", 0x039E, + "xi", 0x03BE, + "xlArr", 0x21D0, + "xrArr", 0x21D2, + "xutri", 0x25B3, + NULL, 0 +}; + +static NameId namesY[]={ + "Yacute", 0x00DD, + "yacute", 0x00FD, + "YAcy", 0x042F, + "yacy", 0x044F, + "Ycirc", 0x0176, + "ycirc", 0x0177, + "Ycy", 0x042B, + "ycy", 0x044B, + "yen", 0x00A5, + "YIcy", 0x0407, + "yicy", 0x0457, + "YUcy", 0x042E, + "yucy", 0x044E, + "yuml", 0x00FF, + "Yuml", 0x0178, + NULL, 0 +}; + +static NameId namesZ[]={ + "Zacute", 0x0179, + "zacute", 0x017A, + "Zcaron", 0x017D, + "zcaron", 0x017E, + "Zcy", 0x0417, + "zcy", 0x0437, + "Zdot", 0x017B, + "zdot", 0x017C, + "zeta", 0x03B6, + "Zgr", 0x0396, + "zgr", 0x03B6, + "ZHcy", 0x0416, + "zhcy", 0x0436, + NULL, 0 +}; + +// @todo@ order namesTable and names? by frequency +static NameId* namesTable[] = { + namesA, namesB, namesC, namesD, namesE, namesF, namesG, namesH, namesI, + namesJ, namesK, namesL, namesM, namesN, namesO, namesP, namesQ, namesR, + namesS, namesT, namesU, namesV, namesW, namesX, namesY, namesZ, NULL +}; + +#ifdef OLD int Html::namedEntity(unsigned char *p, int length) { int i; @@ -555,3 +1606,21 @@ error("unrecognized character entity"); return 0; } +#endif + +int Html::namedEntity(unsigned char *p, int length) +{ + int tableIndex = tolower(*p) - 'a'; + if (tableIndex >= 0 && tableIndex < 26) { + NameId* names = namesTable[tableIndex]; + int i; + + for (i = 0; names[i].name; i++){ + if (strncmp(names[i].name, (char *)p, length) == 0){ + return names[i].value; + } + } + } + error("unrecognized character entity \"%.*s\"", length, p); + return 0; +} diff -uNr gdc-0.9/d/dmd/identifier.c gdc-0.10/d/dmd/identifier.c --- gdc-0.9/d/dmd/identifier.c 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/identifier.c 2005-01-09 01:40:20.000000000 +0100 @@ -19,6 +19,7 @@ //printf("Identifier('%s', %d)\n", string, value); this->string = string; this->value = value; + this->len = strlen(string); } unsigned Identifier::hashCode() @@ -28,12 +29,12 @@ int Identifier::equals(Object *o) { - return this == o || strcmp(string,o->toChars()) == 0; + return this == o || memcmp(string,o->toChars(),len+1) == 0; } int Identifier::compare(Object *o) { - return strcmp(string,o->toChars()); + return memcmp(string, o->toChars(), len + 1); } char *Identifier::toChars() diff -uNr gdc-0.9/d/dmd/identifier.h gdc-0.10/d/dmd/identifier.h --- gdc-0.9/d/dmd/identifier.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/identifier.h 2005-01-09 01:40:20.000000000 +0100 @@ -20,6 +20,7 @@ { int value; const char *string; + unsigned len; Identifier(const char *string, int value); int equals(Object *o); diff -uNr gdc-0.9/d/dmd/idgen.c gdc-0.10/d/dmd/idgen.c --- gdc-0.9/d/dmd/idgen.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/idgen.c 2005-01-09 01:40:20.000000000 +0100 @@ -61,6 +61,7 @@ { "TypeInfo" }, { "TypeInfo_Class" }, + { "TypeInfo_Struct" }, { "TypeInfo_Typedef" }, { "_arguments" }, { "_argptr" }, @@ -156,6 +157,9 @@ // For pragma's { "msg" }, + // For toHash + { "tohash", "toHash" }, + // Special functions { "alloca" }, }; diff -uNr gdc-0.9/d/dmd/init.h gdc-0.10/d/dmd/init.h --- gdc-0.9/d/dmd/init.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/init.h 2005-01-09 01:40:20.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2004 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr gdc-0.9/d/dmd/lexer.c gdc-0.10/d/dmd/lexer.c --- gdc-0.9/d/dmd/lexer.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/lexer.c 2005-01-09 01:40:20.000000000 +0100 @@ -2128,6 +2128,7 @@ Token::tochars[TOKdotexp] = "dotexp"; Token::tochars[TOKdotti] = "dotti"; Token::tochars[TOKdotvar] = "dotvar"; + Token::tochars[TOKdottype] = "dottype"; Token::tochars[TOKsymoff] = "symoff"; Token::tochars[TOKtypedot] = "typedot"; Token::tochars[TOKarraylength] = "arraylength"; diff -uNr gdc-0.9/d/dmd/mangle.c gdc-0.10/d/dmd/mangle.c --- gdc-0.9/d/dmd/mangle.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/mangle.c 2005-01-09 01:40:20.000000000 +0100 @@ -137,6 +137,7 @@ * names for them. */ if (ident == Id::TypeInfo || + ident == Id::TypeInfo_Struct || ident == Id::TypeInfo_Class || ident == Id::TypeInfo_Typedef || ident == Id::Exception || diff -uNr gdc-0.9/d/dmd/mars.c gdc-0.10/d/dmd/mars.c --- gdc-0.9/d/dmd/mars.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/mars.c 2005-01-09 01:40:20.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2004 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.109"; + version = "v0.110"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -570,6 +570,8 @@ printf("code %s\n", m->toChars()); m->genobjfile(); // m->gensymfile(); + if (global.errors) + m->deleteObjFile(); } backend_term(); diff -uNr gdc-0.9/d/dmd/mars.h gdc-0.10/d/dmd/mars.h --- gdc-0.9/d/dmd/mars.h 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/mars.h 2005-01-09 01:40:20.000000000 +0100 @@ -57,6 +57,8 @@ unsigned versionlevel; // version level Array *versionids; // version identifiers + bool dump_source; + // Hidden debug switches char debuga; char debugb; @@ -167,7 +169,7 @@ Loc(int x) { - linnum = 0; + linnum = x; filename = NULL; } diff -uNr gdc-0.9/d/dmd/module.c gdc-0.10/d/dmd/module.c --- gdc-0.9/d/dmd/module.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/module.c 2005-01-09 01:40:20.000000000 +0100 @@ -29,6 +29,10 @@ #define MARS 1 #include "html.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + ClassDeclaration *Module::moduleinfo; DsymbolTable *Module::modules; @@ -49,7 +53,7 @@ FileName *objfilename; FileName *symfilename; - //printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); +// printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); this->arg = filename; md = NULL; errors = 0; @@ -57,6 +61,9 @@ isHtml = 0; needmoduleinfo = 0; insearch = 0; + searchCacheIdent = NULL; + searchCacheSymbol = NULL; + searchCacheFlags = 0; semanticdone = 0; decldefs = NULL; vmoduleinfo = NULL; @@ -119,10 +126,6 @@ return "module"; } -#ifdef IN_GCC -extern void d_gcc_magic_module(Module *m); -#endif - Module *Module::load(Loc loc, Array *packages, Identifier *ident) { Module *m; char *filename; @@ -216,7 +219,7 @@ (((unsigned char *)p)[0] << 24); } -void Module::parse() +void Module::parse(bool dump_source) { char *srcname; unsigned char *buf; unsigned buflen; @@ -387,6 +390,13 @@ } } +#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 /* IN_GCC */ if (isHtml) { OutBuffer *dbuf = new OutBuffer(); @@ -394,6 +404,12 @@ 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); members = p.parseModule(); @@ -431,9 +447,10 @@ void Module::semantic() { int i; - //printf("Module::semantic('%s'): parent = %p\n", toChars(), parent); if (semanticdone) return; + + //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); semanticdone = 1; // Note that modules get their own scope, from scratch. @@ -464,6 +481,7 @@ { Dsymbol *s; s = (Dsymbol *)members->data[i]; + //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); s->semantic(sc); runDeferredSemantic(); @@ -471,12 +489,13 @@ sc = sc->pop(); sc->pop(); - //printf("-Module::semantic('%s'): parent = %p\n", toChars(), parent); + //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); } void Module::semantic2() { int i; + assert(!deferred.dim); //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); if (semanticdone >= 2) return; @@ -594,11 +613,17 @@ Dsymbol *s; if (insearch) s = NULL; + else if (searchCacheIdent == ident && searchCacheFlags == flags) + s = searchCacheSymbol; else { insearch = 1; s = ScopeDsymbol::search(ident, flags); insearch = 0; + + searchCacheIdent = ident; + searchCacheSymbol = s; + searchCacheFlags = flags; } return s; } @@ -609,6 +634,16 @@ void Module::addDeferredSemantic(Dsymbol *s) { + // Don't add it if it is already there + for (int i = 0; i < deferred.dim; i++) + { + Dsymbol *sd = (Dsymbol *)deferred.data[i]; + + if (sd == s) + return; + } + +// printf("Module::addDeferredSemantic('%s')\n", s->toChars()); deferred.push(s); } @@ -618,12 +653,12 @@ void Module::runDeferredSemantic() { - int len; - int newlen; + size_t len; static int nested; if (nested) return; +// if (deferred.dim) printf("Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); nested++; do @@ -632,18 +667,27 @@ if (!len) break; + Dsymbol **todo; + Dsymbol *tmp; + if (len == 1) + { + todo = &tmp; + } + else + { + todo = (Dsymbol **)alloca(len * sizeof(Dsymbol *)); + assert(todo); + } + memcpy(todo, deferred.data, len * sizeof(Dsymbol *)); + deferred.setDim(0); + for (int i = 0; i < len; i++) { - Dsymbol *s = (Dsymbol *)deferred.data[i]; + Dsymbol *s = todo[i]; s->semantic(NULL); } - - newlen = deferred.dim - len; - memmove(deferred.data, deferred.data + len, - newlen * sizeof(deferred.data[0])); - deferred.setDim(newlen); - } while (newlen < len); + } while (deferred.dim < len); // while making progress nested--; } diff -uNr gdc-0.9/d/dmd/module.h gdc-0.10/d/dmd/module.h --- gdc-0.9/d/dmd/module.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/module.h 2005-01-09 01:40:20.000000000 +0100 @@ -59,7 +59,12 @@ unsigned errors; // if any errors in file int isHtml; // if it is an HTML file int needmoduleinfo; + int insearch; + Identifier *searchCacheIdent; + Dsymbol *searchCacheSymbol; // cached value of search + int searchCacheFlags; // cached flags + int semanticdone; // has semantic() been done? Module *importedFrom; // module from command line we're imported from, // i.e. a module that will be taken all the @@ -85,7 +90,7 @@ char *kind(); void read(); // read file - void parse(); // syntactic parse + void parse(bool dump_source = false); // syntactic parse void semantic(); // semantic analysis void semantic2(); // pass 2 semantic analysis void semantic3(); // pass 3 semantic analysis diff -uNr gdc-0.9/d/dmd/mtype.c gdc-0.10/d/dmd/mtype.c --- gdc-0.9/d/dmd/mtype.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/mtype.c 2005-01-09 01:40:20.000000000 +0100 @@ -88,6 +88,7 @@ ClassDeclaration *Type::typeinfo; ClassDeclaration *Type::typeinfoclass; +ClassDeclaration *Type::typeinfostruct; ClassDeclaration *Type::typeinfotypedef; Type *Type::basic[TMAX]; @@ -219,15 +220,18 @@ d_uns64 Type::size() { - Loc loc; + return size(0); +} +d_uns64 Type::size(Loc loc) +{ error(loc, "no size for type %s", toChars()); return 0; } unsigned Type::alignsize() { - return size(); + return size(0); } Type *Type::semantic(Loc loc, Scope *sc) @@ -476,13 +480,13 @@ if (ident == Id::__sizeof) { - e = new IntegerExp(loc, size(), Type::tsize_t); + e = new IntegerExp(loc, size(loc), Type::tsize_t); } else if (ident == Id::size) { if (!global.params.useDeprecated) error(loc, ".size property is deprecated, use .sizeof"); - e = new IntegerExp(loc, size(), Type::tsize_t); + e = new IntegerExp(loc, size(loc), Type::tsize_t); } else if (ident == Id::alignof) { @@ -573,7 +577,7 @@ fflush(stdout); global.errors++; - fatal(); + //fatal(); } Identifier *Type::getTypeInfoIdent(int internal) @@ -773,7 +777,7 @@ } } -d_uns64 TypeBasic::size() +d_uns64 TypeBasic::size(Loc loc) { unsigned size; //printf("TypeBasic::size()\n"); @@ -833,7 +837,7 @@ break; default: - sz = size(); + sz = size(0); break; } return sz; @@ -1339,7 +1343,7 @@ Expression *ec; FuncDeclaration *fd; Array *arguments; - int size = next->size(); + int size = next->size(e->loc); char *nm; static char *name[2][2] = { { "_adReverse", "_adDup" }, { "_adReverseBit", "_adDupBit" } }; @@ -1368,7 +1372,7 @@ arguments = new Array(); arguments->push(e); arguments->push(n->ty == Tsarray ? n->getTypeInfo(sc) // don't convert to dynamic array - : n->getInternalTypeInfo()); + : n->getInternalTypeInfo(sc)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } @@ -1447,11 +1451,11 @@ return t; } -d_uns64 TypeSArray::size() +d_uns64 TypeSArray::size(Loc loc) { integer_t sz; if (!dim) - return Type::size(); + return Type::size(loc); sz = dim->toInteger(); if (next->toBasetype()->ty == Tbit) // if array of bits { @@ -1471,7 +1475,7 @@ return sz; Loverflow: - error(0, "index %lld overflow for static array", sz); + error(loc, "index %lld overflow for static array", sz); return 1; } @@ -1509,7 +1513,7 @@ /* Only do this for types that don't need to have semantic() * run on them for the size, since they may be forward referenced. */ - n = next->size(); + n = next->size(loc); n2 = n * d2; if ((int)n2 < 0) goto Loverflow; @@ -1635,7 +1639,7 @@ return t; } -d_uns64 TypeDArray::size() +d_uns64 TypeDArray::size(Loc loc) { //printf("TypeDArray::size()\n"); return PTRSIZE * 2; @@ -1649,17 +1653,21 @@ } Type *TypeDArray::semantic(Loc loc, Scope *sc) -{ - next = next->semantic(loc,sc); - switch (next->ty) +{ Type *tn = next; + + tn = next->semantic(loc,sc); + switch (tn->ty) { case Tfunction: case Tnone: - error(loc, "can't have array of %s", next->toChars()); + error(loc, "can't have array of %s", tn->toChars()); break; } - if (next->isauto()) - error(loc, "cannot have array of auto %s", next->toChars()); + if (tn->isauto()) + error(loc, "cannot have array of auto %s", tn->toChars()); + if (next != tn) + //deco = NULL; // redo + return tn->arrayOf(); return merge(); } @@ -1768,7 +1776,7 @@ return t; } -d_uns64 TypeAArray::size() +d_uns64 TypeAArray::size(Loc loc) { return PTRSIZE * 2; } @@ -1869,7 +1877,7 @@ FuncDeclaration *fd; Array *arguments; char aakeys[7+3*sizeof(int)+1]; - int size = key->size(); + int size = key->size(e->loc); assert(size); #if 0 @@ -1900,8 +1908,8 @@ ec = new VarExp(0, fd); arguments = new Array(); arguments->push(e); - arguments->push(new IntegerExp(0, key->size(), Type::tint32)); - arguments->push(new IntegerExp(0, next->size(), Type::tint32)); + arguments->push(new IntegerExp(0, key->size(e->loc), Type::tint32)); + arguments->push(new IntegerExp(0, next->size(e->loc), Type::tint32)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } @@ -1915,7 +1923,7 @@ ec = new VarExp(0, fd); arguments = new Array(); arguments->push(e->addressOf()); - arguments->push(key->getInternalTypeInfo()); + arguments->push(key->getInternalTypeInfo(sc)); e = new CallExp(e->loc, ec, arguments); e->type = this; } @@ -1985,7 +1993,7 @@ } -d_uns64 TypePointer::size() +d_uns64 TypePointer::size(Loc loc) { return PTRSIZE; } @@ -2073,7 +2081,7 @@ return t; } -d_uns64 TypeReference::size() +d_uns64 TypeReference::size(Loc loc) { return PTRSIZE; } @@ -2180,9 +2188,15 @@ goto Lnotcovariant; if (t1->linkage != t2->linkage) goto Lnotcovariant; - if (t1->next->ty != Tclass || t2->next->ty != Tclass) + + Type *t1n = t1->next; + Type *t2n = t2->next; + + if (t1n->equals(t2n)) + goto Lcovariant; + if (t1n->ty != Tclass || t2n->ty != Tclass) goto Lnotcovariant; - if (t1->next->implicitConvTo(t2->next)) + if (t1n->implicitConvTo(t2n)) goto Lcovariant; goto Lnotcovariant; } @@ -2453,7 +2467,7 @@ return merge(); } -d_uns64 TypeDelegate::size() +d_uns64 TypeDelegate::size(Loc loc) { return PTRSIZE * 2; } @@ -2554,9 +2568,9 @@ } } -d_uns64 TypeQualified::size() +d_uns64 TypeQualified::size(Loc loc) { - error(loc, "size of type %s is not known", toChars()); + error(this->loc, "size of type %s is not known", toChars()); return 1; } @@ -2851,6 +2865,7 @@ error(loc, "%s is used as a type", toChars()); t = tvoid; } + //t->print(); return t; } @@ -3063,14 +3078,14 @@ return merge(); } -d_uns64 TypeEnum::size() +d_uns64 TypeEnum::size(Loc loc) { if (!sym->memtype) { - error(0, "enum %s is forward referenced", sym->toChars()); + error(loc, "enum %s is forward referenced", sym->toChars()); return 4; } - return sym->memtype->size(); + return sym->memtype->size(loc); } unsigned TypeEnum::alignsize() @@ -3229,9 +3244,9 @@ return merge(); } -d_uns64 TypeTypedef::size() +d_uns64 TypeTypedef::size(Loc loc) { - return sym->basetype->size(); + return sym->basetype->size(loc); } unsigned TypeTypedef::alignsize() @@ -3402,15 +3417,15 @@ return merge(); } -d_uns64 TypeStruct::size() +d_uns64 TypeStruct::size(Loc loc) { - return sym->size(); + return sym->size(loc); } unsigned TypeStruct::alignsize() { unsigned sz; - sym->size(); // give error for forward references + sym->size(0); // give error for forward references sz = sym->alignsize; if (sz > sym->structalign) sz = sym->structalign; @@ -3564,7 +3579,7 @@ unsigned TypeStruct::memalign(unsigned salign) { - sym->size(); // give error for forward references + sym->size(0); // give error for forward references return sym->structalign; } @@ -3614,7 +3629,7 @@ return merge(); } -d_uns64 TypeClass::size() +d_uns64 TypeClass::size(Loc loc) { return PTRSIZE; } diff -uNr gdc-0.9/d/dmd/mtype.h gdc-0.10/d/dmd/mtype.h --- gdc-0.9/d/dmd/mtype.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/dmd/mtype.h 2005-01-09 01:40:20.000000000 +0100 @@ -156,6 +156,7 @@ static ClassDeclaration *typeinfo; static ClassDeclaration *typeinfoclass; + static ClassDeclaration *typeinfostruct; static ClassDeclaration *typeinfotypedef; static Type *basic[TMAX]; @@ -175,7 +176,8 @@ int covariant(Type *t); char *toChars(); static void init(); - virtual d_uns64 size(); + d_uns64 size(); + virtual d_uns64 size(Loc loc); virtual unsigned alignsize(); virtual Type *semantic(Loc loc, Scope *sc); virtual void toDecoBuffer(OutBuffer *buf); @@ -211,7 +213,7 @@ Identifier *getTypeInfoIdent(int internal); virtual MATCH deduceType(Type *tparam, Array *parameters, Array *atypes); virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); - Expression *getInternalTypeInfo(); + Expression *getInternalTypeInfo(Scope *sc); Expression *getTypeInfo(Scope *sc); virtual TypeInfoDeclaration *getTypeInfoDeclaration(); virtual int builtinTypeInfo(); @@ -236,7 +238,7 @@ TypeBasic(TY ty); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Expression *getProperty(Loc loc, Identifier *ident); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); @@ -274,7 +276,7 @@ TypeSArray(Type *t, Expression *dim); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); @@ -297,7 +299,7 @@ { TypeDArray(Type *t); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); @@ -320,7 +322,7 @@ TypeAArray(Type *t, Type *index); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); void toPrettyBracket(OutBuffer *buf); @@ -340,7 +342,7 @@ TypePointer(Type *t); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); int implicitConvTo(Type *to); int isscalar(); @@ -354,7 +356,7 @@ { TypeReference(Type *t); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); Expression *defaultInit(); @@ -393,7 +395,7 @@ TypeDelegate(Type *t); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); Expression *defaultInit(); int isZeroInit(); @@ -411,7 +413,7 @@ void syntaxCopyHelper(TypeQualified *t); void addIdent(Identifier *ident); void toCBuffer2Helper(OutBuffer *buf, Identifier *ident); - d_uns64 size(); + d_uns64 size(Loc loc); void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym, Expression **pe, Type **pt, Dsymbol **ps); }; @@ -462,7 +464,7 @@ StructDeclaration *sym; TypeStruct(StructDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *syntaxCopy(); @@ -477,6 +479,7 @@ int isZeroInit(); dt_t **toDt(dt_t **pdt); MATCH deduceType(Type *tparam, Array *parameters, Array *atypes); + TypeInfoDeclaration *getTypeInfoDeclaration(); type *toCtype(); }; @@ -486,7 +489,7 @@ EnumDeclaration *sym; TypeEnum(EnumDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *semantic(Loc loc, Scope *sc); @@ -515,7 +518,7 @@ TypeTypedef(TypedefDeclaration *sym); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *semantic(Loc loc, Scope *sc); @@ -547,7 +550,7 @@ ClassDeclaration *sym; TypeClass(ClassDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); char *toChars(); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); diff -uNr gdc-0.9/d/dmd/parse.c gdc-0.10/d/dmd/parse.c --- gdc-0.9/d/dmd/parse.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/parse.c 2005-01-09 01:40:20.000000000 +0100 @@ -485,7 +485,7 @@ continue; default: - error("Declaration expected, not '%s'\n",token.toChars()); + error("Declaration expected, not '%s'",token.toChars()); Lerror: while (token.value != TOKsemicolon && token.value != TOKeof) nextToken(); @@ -1886,7 +1886,7 @@ error("multiple declarations must have the same type, not %s and %s", tfirst->toChars(), t->toChars()); if (!ident) - error("no identifier for declarator"); + error("no identifier for declarator %s", t->toChars()); if (tok == TOKtypedef || tok == TOKalias) { Declaration *v; @@ -2490,7 +2490,7 @@ tb = parseBasicType(); at = parseDeclarator(tb, &ai); if (!ai) - error("no identifier for declarator"); + error("no identifier for declarator %s", at->toChars()); a = new Argument(inout, at, ai, NULL); arguments->push(a); if (token.value == TOKcomma) diff -uNr gdc-0.9/d/dmd/statement.c gdc-0.10/d/dmd/statement.c --- gdc-0.9/d/dmd/statement.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/statement.c 2005-01-09 01:40:20.000000000 +0100 @@ -597,6 +597,7 @@ Type *tnv = NULL; aggr = aggr->semantic(sc); + aggr = resolveProperties(sc, aggr); sym = new ScopeDsymbol(); sym->parent = sc->scopesym; @@ -1147,6 +1148,7 @@ Statement *SwitchStatement::semantic(Scope *sc) { condition = condition->semantic(sc); + condition = resolveProperties(sc, condition); if (condition->type->isString()) { // If it's not an array, cast it to one @@ -1977,6 +1979,7 @@ if (sc->incontract) error("Throw statements cannot be in contracts"); exp = exp->semantic(sc); + exp = resolveProperties(sc, exp); if (!exp->type->isClassHandle()) error("can only throw class objects, not type %s", exp->type->toChars()); return this; diff -uNr gdc-0.9/d/dmd/struct.c gdc-0.10/d/dmd/struct.c --- gdc-0.9/d/dmd/struct.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/dmd/struct.c 2005-01-09 01:40:20.000000000 +0100 @@ -35,6 +35,7 @@ stag = NULL; sinit = NULL; + scope = NULL; } void AggregateDeclaration::semantic2(Scope *sc) @@ -83,13 +84,15 @@ } } -unsigned AggregateDeclaration::size() +unsigned AggregateDeclaration::size(Loc loc) { //printf("AggregateDeclaration::size() = %d\n", structsize); if (!members) - error("unknown size"); - if (!sizeok) - error("no size yet for forward reference"); + error(loc, "unknown size"); + if (sizeok != 1) + { error(loc, "no size yet for forward reference"); + //*(char*)0=0; + } return structsize; } @@ -138,7 +141,19 @@ unsigned memalignsize; // size of member for alignment purposes unsigned xalign; // alignment boundaries - memsize = v->type->size(); + // Check for forward referenced types which will fail the size() call + Type *t = v->type->toBasetype(); + if (t->ty == Tstruct /*&& isStructDeclaration()*/) + { TypeStruct *ts = (TypeStruct *)t; + + if (ts->sym->sizeok != 1) + { + sizeok = 2; // cannot finish; flag as forward referenced + return; + } + } + + memsize = v->type->size(loc); memalignsize = v->type->alignsize(); xalign = v->type->memalign(sc->structalign); alignmember(xalign, memalignsize, &sc->offset); @@ -183,104 +198,82 @@ Scope *sc2; //printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars()); - if (!type) - type = new TypeStruct(this); + assert(type); if (!members) // if forward reference return; - if (!symtab) // if not already done semantic() - { - parent = sc->parent; - handle = type->pointerTo(); - symtab = new DsymbolTable(); - structalign = sc->structalign; - if (!isAnonymous()) - { - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); - s->addMember(this); - } - } - sc2 = sc->push(this); - sc2->parent = this; - if (isUnionDeclaration()) - sc2->inunion = 1; - sc2->stc &= ~(STCauto | STCstatic); - int members_dim = members->dim; - for (i = 0; i < members_dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - s->semantic(sc2); - if (isUnionDeclaration()) - sc2->offset = 0; - } - sc2->pop(); - // 0 sized struct's are set to 1 byte - if (structsize == 0) - { - structsize = 1; - alignsize = 1; - } - sizeok = 1; + if (symtab) + { if (!scope) + return; // semantic() already completed } + else + symtab = new DsymbolTable(); - AggregateDeclaration *sd; + Scope *scx = NULL; + if (scope) + { sc = scope; + scx = scope; // save so we don't make redundant copies + scope = NULL; + } -#if 0 - if (isAnonymous()) - { // Anonymous structures aren't independent, all their members are - // added to the enclosing struct. - unsigned offset; - int isunionsave; + parent = sc->parent; + handle = type->pointerTo(); + structalign = sc->structalign; + assert(!isAnonymous()); - sd = isMember(); - if (!sd) + if (sizeok == 0) // if not already done the addMember step + { + for (i = 0; i < members->dim; i++) { - error("anonymous struct can only be member of an aggregate"); + Dsymbol *s = (Dsymbol *)members->data[i]; + //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); + s->addMember(this); } - else - { - // Align size of enclosing struct - sd->alignmember(structalign, alignsize, &sd->structsize); + } - // Add members to enclosing struct - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - VarDeclaration *vd = s->isVarDeclaration(); - if (vd && vd->storage_class & STCfield) - { - vd->addMember(sd); - if (!sd->isUnionDeclaration()) - vd->offset += sd->structsize; - sd->fields.push(vd); - sd->members->push(s); - } - else if (!s->isAnonymous()) - { - sd->members->push(s); - } - } + sizeok = 0; + sc2 = sc->push(this); + sc2->parent = this; + if (isUnionDeclaration()) + sc2->inunion = 1; + sc2->stc &= ~(STCauto | STCstatic); + int members_dim = members->dim; + for (i = 0; i < members_dim; i++) + { + Dsymbol *s = (Dsymbol *)members->data[i]; + s->semantic(sc2); + if (isUnionDeclaration()) + sc2->offset = 0; + if (sizeok == 2) + break; + } + sc2->pop(); - if (sd->isUnionDeclaration()) - { - if (structsize > sd->structsize) - sd->structsize = structsize; - sc->offset = 0; - } - else - { - sd->structsize += structsize; - sc->offset = sd->structsize; - } + if (sizeok == 2) + { // semantic() failed because of forward references. + // Unwind what we did, and defer it for later + fields.setDim(0); + structsize = 0; + alignsize = 0; + structalign = 0; + + scope = scx ? scx : new Scope(*sc); + scope->setNoFree(); + scope->module->addDeferredSemantic(this); + return; + } - if (sd->alignsize < alignsize) - sd->alignsize = alignsize; - } + // 0 sized struct's are set to 1 byte + if (structsize == 0) + { + structsize = 1; + alignsize = 1; } -#endif + + sizeok = 1; + + AggregateDeclaration *sd; + //printf("-StructDeclaration::semantic(this=%p, '%s')\n", this, toChars()); // Determine if struct is all zeros or not diff -uNr gdc-0.9/d/dmd/toobj.c gdc-0.10/d/dmd/toobj.c --- gdc-0.9/d/dmd/toobj.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/dmd/toobj.c 2004-12-26 17:15:05.000000000 +0100 @@ -46,6 +46,10 @@ #include "dt.h" #endif +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + /* ================================================================== */ // Put out instance of ModuleInfo for this Module @@ -900,6 +904,15 @@ if (isExport()) obj_export(s,0); } +#ifdef IN_GCC + else { + // This is needed for VarDeclarations in mixins that are to be + // local variables of that function. Otherwise, it would be + // enough to make a check for VarDeclaration in + // DeclarationExp::toElem. + d_gcc_emit_local_variable(this); + } +#endif } /* ================================================================== */ diff -uNr gdc-0.9/d/dmd/typinf.c gdc-0.10/d/dmd/typinf.c --- gdc-0.9/d/dmd/typinf.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/dmd/typinf.c 2005-01-09 01:40:20.000000000 +0100 @@ -57,7 +57,7 @@ * so we can use the custom internal ones more. */ -Expression *Type::getInternalTypeInfo() +Expression *Type::getInternalTypeInfo(Scope *sc) { TypeInfoDeclaration *tid; Expression *e; Type *t; @@ -92,7 +92,7 @@ break; } //printf("\tcalling getTypeInfo() %s\n", t->toChars()); - return t->getTypeInfo(NULL); + return t->getTypeInfo(sc); } @@ -136,6 +136,11 @@ return new TypeInfoTypedefDeclaration(this); } +TypeInfoDeclaration *TypeStruct::getTypeInfoDeclaration() +{ + return new TypeInfoStructDeclaration(this); +} + TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() { return new TypeInfoClassDeclaration(this); @@ -168,6 +173,93 @@ dtxoff(pdt, tc->sym->basetype->vtinfo->toSymbol(), 0, TYnptr); // TypeInfo for basetype } +void TypeInfoStructDeclaration::toDt(dt_t **pdt) +{ + //printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars()); + + dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Struct + dtdword(pdt, 0); // monitor + + assert(tinfo->ty == Tstruct); + + TypeStruct *tc = (TypeStruct *)tinfo; + StructDeclaration *sd = tc->sym; + + /* Put out: + * char[] name; + * uint xsize; + * uint function(void*) xtoHash; + * int function(void*,void*) xopEquals; + * int function(void*,void*) xopCmp; + */ + + char *name = sd->toPrettyChars(); + size_t namelen = strlen(name); + dtdword(pdt, namelen); + dtabytes(pdt, TYnptr, 0, namelen + 1, name); + + dtdword(pdt, sd->structsize); // xsize + + FuncDeclaration *fd; + FuncDeclaration *fdx; + TypeFunction *tf; + Type *ta; + + static TypeFunction *tftohash; + + if (!tftohash) + { + Scope sc; + tftohash = new TypeFunction(NULL, Type::tuns32, 0, LINKd); + tftohash = (TypeFunction *)tftohash->semantic(0, &sc); + } + + TypeFunction *tfeq; + { + Scope sc; + Array *arguments = new Array; + Argument *arg = new Argument(In, tc->pointerTo(), NULL, NULL); + + arguments->push(arg); + tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd); + tfeq = (TypeFunction *)tfeq->semantic(0, &sc); + } + + fdx = search_function(sd, Id::tohash); + if (fdx) + { fd = fdx->overloadExactMatch(tftohash); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) uint toHash()"); + } + else + dtdword(pdt, 0); + + fdx = search_function(sd, Id::eq); + if (fdx) + { fd = fdx->overloadExactMatch(tfeq); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars()); + } + else + dtdword(pdt, 0); + + fdx = search_function(sd, Id::cmp); + if (fdx) + { + fd = fdx->overloadExactMatch(tfeq); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars()); + } + else + dtdword(pdt, 0); +} + void TypeInfoClassDeclaration::toDt(dt_t **pdt) { //printf("TypeInfoClassDeclaration::toDt()\n"); diff -uNr gdc-0.9/d/dmd-script gdc-0.10/d/dmd-script --- gdc-0.9/d/dmd-script 2004-12-02 02:12:02.000000000 +0100 +++ gdc-0.10/d/dmd-script 2005-01-08 20:21:39.000000000 +0100 @@ -45,6 +45,20 @@ return $^O =~ m/MS(DOS|Win32)|os2/i; # taken from File::Basename } +sub pathSep() { + return ";" if $^O =~ m/MS(DOS|Win32)/i; + return "," if $^O =~ m/MacOS/i; + return ":"; +} + +sub expandHome($) { + my ($path) = (@_); + if ( $^O !~ m/MS(DOS|Win32)|MacOS/i ) { + $path =~ s/^~/$ENV{HOME}/; + } + return $path; +} + sub errorExit(@) { print STDERR "dmd: ", @_, "\n" if @_; exit 1; @@ -75,7 +89,9 @@ } elsif ( $arg =~ m/^-inline$/ ) { push @out, '-finline-functions'; } elsif ( $arg =~ m/^-I(.*)$/ ) { - push @out, '-I', $1; # TODO: expand '~' + foreach my $i (split pathSep, $1) { + push @out, '-I', expandHome $i; + } } elsif ( $arg =~ m/^-L(.*)$/ ) { push @out, '-L', $1; # TODO: expand '~' } elsif ( $arg =~ m/^-O$/ ) { diff -uNr gdc-0.9/d/d-misc.c gdc-0.10/d/d-misc.c --- gdc-0.9/d/d-misc.c 2004-12-02 03:38:49.000000000 +0100 +++ gdc-0.10/d/d-misc.c 2005-01-09 01:40:20.000000000 +0100 @@ -32,7 +32,7 @@ /* The value of USING_SJLJ_EXCEPTIONS relies on insn-flags.h, but insn-flags.h - can not be compiled by C++. */ + cannot be compiled by C++. */ int d_using_sjlj_exceptions(void) diff -uNr gdc-0.9/d/lang.opt gdc-0.10/d/lang.opt --- gdc-0.9/d/lang.opt 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/lang.opt 2005-01-09 22:08:32.000000000 +0100 @@ -58,7 +58,7 @@ femit-templates D --femit-templates Emit templates code and data even if the linker can not merge multiple copies +-femit-templates Emit templates code and data even if the linker cannot merge multiple copies nostdinc D @@ -79,3 +79,7 @@ Wsign-compare D Warn about signed-unsigned comparisons + +fdump-source +D RejectNegative +Dump decoded UTF-8 text and source from HTML diff -uNr gdc-0.9/d/Make-lang.in gdc-0.10/d/Make-lang.in --- gdc-0.9/d/Make-lang.in 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/Make-lang.in 2005-01-09 16:52:07.000000000 +0100 @@ -40,7 +40,7 @@ # configurate? gcc_d_include_dir = $(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include/d -D_TREE_H = $(TREE_H) d/d-lang.h d/d-codegen.h d/d-irstate.h d/d-backend.h d/d-gcc-includes.h \ +D_TREE_H = $(TREE_H) d/d-lang.h d/d-codegen.h d/d-irstate.h d/d-dmd-gcc.h d/d-gcc-includes.h \ d/d-gcc-real.h d/symbol.h d/dt.h d/id.h \ function.h varray.h $(SYSTEM_H) $(CONFIG_H) $(TARGET_H) \ $(GGC_H) \ @@ -76,9 +76,7 @@ D_INCLUDES = -I$(srcdir)/d -I$(srcdir)/d/dmd -Id # -Wno-long-double is for MacOS X -- needs to be configurated -#D_CC_FLAGS = -fmessage-length=0 -Wno-long-double -D_CC_FLAGS = -# -fmessage-length=0 -O0 -g +D_CC_FLAGS = -Wno-missing-braces ALL_D_COMPILER_FLAGS = $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(D_INCLUDES) $(D_EXTRA_DEFINES) $(D_CC_FLAGS) # Somehow, I started getting problems with the C++ being included.. @@ -109,7 +107,8 @@ # The full path for -include ...total.h is only needed for g++ < 3.x # ALL_D_COMPILER_FLAGS causes issues -- c++ instead of C -d/%.dmd.o: $(srcdir)/d/dmd/%.c d/id.h +# Not all DMD sources depend on d-dmd-gcc.h +d/%.dmd.o: $(srcdir)/d/dmd/%.c d/id.h d/d-dmd-gcc.h $(CXX) $(ALL_DMD_COMPILER_FLAGS) -include $(srcdir)/d/dmd/total.h -o d/$*.dmd.o -c $< #hmm $(CC) $(ALL_DMD_COMPILER_FLAGS) -include $(srcdir)/d/dmd/total.h -o d/$*.dmd.o -c -x c++ $< diff -uNr gdc-0.9/d/phobos/internal/aaA.d gdc-0.10/d/phobos/internal/aaA.d --- gdc-0.9/d/phobos/internal/aaA.d 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/phobos/internal/aaA.d 2005-01-09 01:40:20.000000000 +0100 @@ -293,7 +293,7 @@ { c = keyti.compare(pkey, e + 1); if (c == 0) - return cast(void *)(e + 1) + keyti.sizeof; + return cast(void *)(e + 1) + keyti.tsize(); } if (c < 0) diff -uNr gdc-0.9/d/phobos/internal/critical.c gdc-0.10/d/phobos/internal/critical.c --- gdc-0.9/d/phobos/internal/critical.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/phobos/internal/critical.c 2005-01-09 01:40:20.000000000 +0100 @@ -60,6 +60,7 @@ { if (!inited) { InitializeCriticalSection(&critical_section.cs); + dcs_list = &critical_section; inited = 1; } } @@ -73,7 +74,6 @@ DeleteCriticalSection(&dcs_list->cs); dcs_list = dcs_list->next; } - DeleteCriticalSection(&critical_section.cs); } } diff -uNr gdc-0.9/d/phobos/internal/dmain2.d gdc-0.10/d/phobos/internal/dmain2.d --- gdc-0.9/d/phobos/internal/dmain2.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/internal/dmain2.d 2005-01-09 01:40:20.000000000 +0100 @@ -105,7 +105,7 @@ { printf("Error: "); o.print(); - result = EXIT_FAILURE; + exit(EXIT_FAILURE); } _moduleDtor(); diff -uNr gdc-0.9/d/phobos/internal/object.d gdc-0.10/d/phobos/internal/object.d --- gdc-0.9/d/phobos/internal/object.d 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/phobos/internal/object.d 2005-01-09 01:40:20.000000000 +0100 @@ -3,6 +3,7 @@ extern (C) { int printf(char *, ...); + int memcmp(void *, void *, size_t); } alias bit bool; @@ -172,6 +173,79 @@ ClassInfo info; } +class TypeInfo_Struct : TypeInfo +{ + char[] toString() { return name; } + + uint getHash(void *p) + { uint h; + + assert(p); + if (xtoHash) + h = (*xtoHash)(p); + else + { + // A sorry hash algorithm. + // Should use the one for strings. + // BUG: relies on the GC not moving objects + for (size_t i = 0; i < xsize; i++) + { h = h * 9 + *cast(ubyte*)p; + p++; + } + } + return h; + } + + int equals(void *p2, void *p1) + { int c; + + if (p1 == p2) + c = 1; + else if (!p1 || !p2) + c = 0; + else if (xopEquals) + c = (*xopEquals)(p1, p2); + else + // BUG: relies on the GC not moving objects + c = (memcmp(p1, p2, xsize) == 0); + return c; + } + + int compare(void *p2, void *p1) + { + int c = 0; + + // Regard null references as always being "less than" + if (p1 != p2) + { + if (p1) + { if (!p2) + c = 1; + else if (xopCmp) + c = (*xopCmp)(p1, p2); + else + // BUG: relies on the GC not moving objects + c = memcmp(p1, p2, xsize); + } + else + c = -1; + } + return c; + } + + int tsize() + { + return xsize; + } + + char[] name; + uint xsize; + + uint function(void*) xtoHash; + int function(void*,void*) xopEquals; + int function(void*,void*) xopCmp; +} + class Exception : Object { char[] msg; diff -uNr gdc-0.9/d/phobos/Makefile.in gdc-0.10/d/phobos/Makefile.in --- gdc-0.9/d/phobos/Makefile.in 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/phobos/Makefile.in 2005-01-08 20:21:39.000000000 +0100 @@ -24,6 +24,11 @@ # to prevent this build from getting tripped up on an already installed # version. Add -nostdinc to handle this. DFLAGS=@DFLAGS@ -nostdinc +INSTALL=@INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_HEADER = $(INSTALL_DATA) +# %% fix when part of normal build process +mkinstalldirs = $(INSTALL) -d # Not used since it goes into libphobos.spec LIBS=@LIBS@ @@ -41,12 +46,14 @@ libdir=@libdir@ includedir=@includedir@ +gdc_include_dir = $(includedir)/d + all: libphobos.a %.o : %.c $(CC) -o $@ $(CFLAGS) -c $< -%.o : %.d +%.o : %.d gcc/config.d $(DMD) -o $@ $(DFLAGS) -I $(srcdir) -I $(srcdir)/internal/gc -c $< Makefile: Makefile.in @@ -155,8 +162,8 @@ # GCC_OBJS (gcc/config.o) first so I don't have to write more deps -libphobos.a : $(D_EXTRA_OBJS) $(GCC_OBJS) $(INIT_MAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) - $(AR) -r $@ $(D_EXTRA_OBJS) $(GCC_OBJS) $(INIT_MAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) +libphobos.a : $(D_EXTRA_OBJS) $(GCC_OBJS) $(INIT_MAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) + $(AR) -r $@ $(D_EXTRA_OBJS) $(GCC_OBJS) $(INIT_MAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) $(RANLIB) $@ internal/dnomain2.o: internal/dmain2.d @@ -164,26 +171,28 @@ libphobosnm.a: $(GCC_OBJS) $(INIT_NOMAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) $(D_EXTRA_OBJS) $(AR) -r $@ $(GCC_OBJS) $(INIT_NOMAIN_OBJ) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) $(D_EXTRA_OBJS) - $(RANLIB) $@ + $(RANLIB) $@ install: gcc/config.d libphobos.a - rm -r -f $(includedir)/d - mkdir -p $(includedir)/d - cp -p -R $(srcdir)/*.d $(includedir)/d - cp -p -R $(srcdir)/etc $(includedir)/d - cp -p -R $(srcdir)/gcc $(includedir)/d - cp -p -R $(srcdir)/internal $(includedir)/d - cp -p -R $(srcdir)/std $(includedir)/d - cp -p gcc/config.d $(includedir)/d/gcc - if test -f gcc/configunix.d; then cp -p gcc/configunix.d $(includedir)/d/gcc; fi - cp -p phobos-ver-syms $(includedir)/d - cp -p libphobos.a $(libdir) - cp -p libphobos.spec $(libdir) + for i in etc/c/recls etc/c/stlsoft etc/c/zlib \ + gcc internal internal/gc std std/c \ + std/c/darwin std/c/linux std/c/mach std/c/windows \ + std/typeinfo std/windows; do \ + $(mkinstalldirs) $(DESTDIR)$(gdc_include_dir)/$$i; \ + $(INSTALL_HEADER) $(srcdir)/$$i/*.[hd] $(DESTDIR)$(gdc_include_dir)/$$i; done + for i in crc32.d gcstats.d object.d; do \ + $(INSTALL_HEADER) $(srcdir)/$$i $(DESTDIR)$(gdc_include_dir); done + $(INSTALL_HEADER) gcc/config.d $(DESTDIR)$(gdc_include_dir)/gcc + if test -f gcc/configunix.d; then $(INSTALL_HEADER) gcc/configunix.d $(DESTDIR)$(gdc_include_dir)/gcc; fi + $(INSTALL) phobos-ver-syms $(DESTDIR)$(gdc_include_dir) + $(mkinstalldirs) $(DESTDIR)$(libdir) + $(INSTALL) libphobos.a $(DESTDIR)$(libdir) + $(RANLIB) $(DESTDIR)$(libdir)/libphobos.a + $(INSTALL) libphobos.spec $(DESTDIR)$(libdir) clean: echo 'Removing files...' rm -f $(GCC_OBJS) $(MAIN_OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) $(INIT_MAIN_OBJ) $(INIT_NOMAIN_OBJ) $(D_EXTRA_OBJS) - rm -f unittest.o rm -f unittest rm -f config/gen_config1.o config/gen_unix.o config/gen_math.o gen_config1 gen_unix gen_math diff -uNr gdc-0.9/d/phobos/object.d gdc-0.10/d/phobos/object.d --- gdc-0.9/d/phobos/object.d 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/phobos/object.d 2005-01-09 01:40:20.000000000 +0100 @@ -90,6 +90,16 @@ ClassInfo info; } +class TypeInfo_Struct : TypeInfo +{ + char[] name; + uint xsize; + + uint function(void*) xtoHash; + int function(void*,void*) xopEquals; + int function(void*,void*) xopCmp; +} + // Recoverable errors class Exception : Object diff -uNr gdc-0.9/d/phobos/phobos-ver-syms.in gdc-0.10/d/phobos/phobos-ver-syms.in --- gdc-0.9/d/phobos/phobos-ver-syms.in 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/phobos-ver-syms.in 2005-01-08 20:21:39.000000000 +0100 @@ -1,6 +1,5 @@ @DCFG_UNIX@ @DCFG_MUST_GUESS_STACK_BOTTOM@ -@DCFG_HAVE_DATA_START_END@ @DCFG_SEMAPHORE_IMPL@ @DCFG_GC_BITS@ @DCFG_TRUNC@ diff -uNr gdc-0.9/d/phobos/std/c/mach/mach.d gdc-0.10/d/phobos/std/c/mach/mach.d --- gdc-0.9/d/phobos/std/c/mach/mach.d 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/phobos/std/c/mach/mach.d 2005-01-09 01:40:20.000000000 +0100 @@ -18,19 +18,14 @@ module std.c.mach.mach; +private import gcc.builtins; + +private alias __builtin_abi_uint natural_t; + private import std.c.mach.mach_extern; extern(C): -version (GNU_BitsPerWord32) -{ - private alias uint natural_t; -} -else version (GNU_BitsPerWord64) -{ - private alias ulong natural_t; -} - enum { SYNC_POLICY_FIFO = 0x0, SYNC_POLICY_FIXED_PRIORITY = 0x1, diff -uNr gdc-0.9/d/phobos/std/c/stdarg.d gdc-0.10/d/phobos/std/c/stdarg.d --- gdc-0.9/d/phobos/std/c/stdarg.d 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/phobos/std/c/stdarg.d 2005-01-09 01:40:20.000000000 +0100 @@ -4,6 +4,8 @@ * Written by Hauke Duden and Walter Bright */ +/* This is for use with extern(C) variable argument lists. */ + /* NOTE: This file has been patched from the original DMD distribution to work with the GDC compiler. diff -uNr gdc-0.9/d/phobos/std/c/stdlib.d gdc-0.10/d/phobos/std/c/stdlib.d --- gdc-0.9/d/phobos/std/c/stdlib.d 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/phobos/std/c/stdlib.d 2005-01-09 01:40:20.000000000 +0100 @@ -72,3 +72,6 @@ long strtoll(char *,char **,int); ulong strtoull(char *,char **,int); +char* itoa(int, char*, int); +char* ultoa(uint, char*, int); + diff -uNr gdc-0.9/d/phobos/std/c/windows/windows.d gdc-0.10/d/phobos/std/c/windows/windows.d --- gdc-0.9/d/phobos/std/c/windows/windows.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/std/c/windows/windows.d 2005-01-09 01:40:20.000000000 +0100 @@ -1,6 +1,14 @@ module std.c.windows.windows; +version (Windows) +{ +} +else +{ + static assert(0); // Windows only +} + extern (Windows) { alias uint ULONG; diff -uNr gdc-0.9/d/phobos/std/date.d gdc-0.10/d/phobos/std/date.d --- gdc-0.9/d/phobos/std/date.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/std/date.d 2005-01-09 01:40:20.000000000 +0100 @@ -354,6 +354,12 @@ return d_time_nan; +/ + if (hour == d_time_nan || + min == d_time_nan || + sec == d_time_nan || + ms == d_time_nan) + return d_time_nan; + hour = toInteger(hour); min = toInteger(min); sec = toInteger(sec); @@ -381,6 +387,11 @@ return d_time.init; +/ + if (year == d_time_nan || + month == d_time_nan || + date == d_time_nan) + return d_time_nan; + year = toInteger(year); month = toInteger(month); date = toInteger(date); @@ -483,10 +494,8 @@ // "Tue Apr 02 1996" char[] buffer = new char[29 + 7 + 1]; - /+ - if (Port::isnan(time)) + if (time == d_time_nan) return "Invalid Date"; - +/ dst = DaylightSavingTA(time); offset = LocalTZA + dst; @@ -517,10 +526,8 @@ // "02:04:57 GMT-0800" char[] buffer = new char[17 + 1]; - /+ - if (Port::isnan(time)) + if (time == d_time_nan) return "Invalid Date"; - +/ dst = DaylightSavingTA(time); offset = LocalTZA + dst; diff -uNr gdc-0.9/d/phobos/std/format.d gdc-0.10/d/phobos/std/format.d --- gdc-0.9/d/phobos/std/format.d 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/phobos/std/format.d 2005-01-09 01:40:20.000000000 +0100 @@ -266,9 +266,11 @@ case Mangle.Tchar: - if (fc != 's') - goto Lerror; vchar = va_arg!(char)(argptr); + if (fc != 's') + { vnumber = vchar; + goto Lnumber; + } L2: putstr((&vchar)[0 .. 1]); return; @@ -281,7 +283,9 @@ vdchar = va_arg!(dchar)(argptr); L1: if (fc != 's') - goto Lerror; + { vnumber = vdchar; + goto Lnumber; + } if (vdchar <= 0x7F) { vchar = cast(char)vdchar; goto L2; diff -uNr gdc-0.9/d/phobos/std/regexp.d gdc-0.10/d/phobos/std/regexp.d --- gdc-0.9/d/phobos/std/regexp.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/std/regexp.d 2005-01-09 01:40:20.000000000 +0100 @@ -87,11 +87,11 @@ int rm_eo; // index past end of match } -alias char tchar; // so we can make a wchar version +private alias char rchar; // so we can make a wchar version class RegExp { - public this(tchar[] pattern, tchar[] attributes) + public this(rchar[] pattern, rchar[] attributes) { pmatch = (&gmatch)[0 .. 1]; compile(pattern, attributes); @@ -100,13 +100,13 @@ uint re_nsub; // number of parenthesized subexpression matches regmatch_t[] pmatch; // array [re_nsub + 1] - tchar[] input; // the string to search + rchar[] input; // the string to search // per instance: - tchar[] pattern; // source text of the regular expression + rchar[] pattern; // source text of the regular expression - tchar[] flags; // source text of the attributes parameter + rchar[] flags; // source text of the attributes parameter int errors; @@ -178,7 +178,7 @@ }; // BUG: should this include '$'? -private int isword(tchar c) { return isalnum(c) || c == '_'; } +private int isword(rchar c) { return isalnum(c) || c == '_'; } private uint inf = ~0u; @@ -186,7 +186,7 @@ * Throws RegExpError on error */ -void compile(tchar[] pattern, tchar[] attributes) +public void compile(rchar[] pattern, rchar[] attributes) { //printf("RegExp.compile('%.*s', '%.*s')\n", pattern, attributes); @@ -247,11 +247,11 @@ * array of slices into string[] */ -public tchar[][] split(tchar[] string) +public rchar[][] split(rchar[] string) { debug(regexp) printf("regexp.split()\n"); - tchar[][] result; + rchar[][] result; if (string.length) { @@ -295,8 +295,8 @@ debug(regexp) printf("regexp.split.unittest()\n"); RegExp r = new RegExp("a*?", null); - tchar[][] result; - tchar[] j; + rchar[][] result; + rchar[] j; int i; result = r.split("ab"); @@ -347,7 +347,7 @@ * -1 no match */ -public int search(tchar[] string) +public int search(rchar[] string) { int i; @@ -379,9 +379,9 @@ * if not global, return array of all matches */ -public tchar[][] match(tchar[] string) +public rchar[][] match(rchar[] string) { - tchar[][] result; + rchar[][] result; if (attributes & REA.global) { @@ -409,8 +409,8 @@ debug(regexp) printf("regexp.match.unittest()\n"); int i; - tchar[][] result; - tchar[] j; + rchar[][] result; + rchar[] j; RegExp r; r = new RegExp("a[bc]", null); @@ -435,9 +435,9 @@ * Return the new string. */ -public tchar[] replace(tchar[] string, tchar[] format) +public rchar[] replace(rchar[] string, rchar[] format) { - tchar[] result; + rchar[] result; int lastindex; int offset; @@ -452,7 +452,7 @@ int so = pmatch[0].rm_so; int eo = pmatch[0].rm_eo; - tchar[] replacement = replace(format); + rchar[] replacement = replace(format); result = replaceSlice(result, result[offset + so .. offset + eo], replacement); if (attributes & REA.global) @@ -476,7 +476,7 @@ debug(regexp) printf("regexp.replace.unittest()\n"); int i; - tchar[] result; + rchar[] result; RegExp r; r = new RegExp("a[bc]", "g"); @@ -492,7 +492,7 @@ * array of slices into string[] representing matches */ -public tchar[][] exec(tchar[] string) +public rchar[][] exec(rchar[] string) { debug(regexp) printf("regexp.exec(string = '%.*s')\n", string); input = string; @@ -507,14 +507,14 @@ * array of slices into string[] representing matches */ -public tchar[][] exec() +public rchar[][] exec() { if (!test()) return null; - tchar[][] result; + rchar[][] result; - result = new tchar[][pmatch.length]; + result = new rchar[][pmatch.length]; for (int i = 0; i < pmatch.length; i++) { if (pmatch[i].rm_so == pmatch[i].rm_eo) @@ -533,7 +533,7 @@ * !=0 match */ -public int test(tchar[] string) +public int test(rchar[] string) { return test(string, 0 /*pmatch[0].rm_eo*/); } @@ -557,9 +557,9 @@ * !=0 match */ -int test(char[] string, int startindex) +public int test(char[] string, int startindex) { - tchar firstc; + rchar firstc; uint si; input = string; @@ -626,7 +626,7 @@ return 0; // no match } -int chr(inout uint si, tchar c) +int chr(inout uint si, rchar c) { for (; si < input.length; si++) { @@ -685,14 +685,14 @@ len = *cast(uint *)&prog[pc + 1]; printf("\tREstring x%x, '%.*s'\n", len, (&prog[pc + 1 + uint.sizeof])[0 .. len]); - pc += 1 + uint.sizeof + len * tchar.sizeof; + pc += 1 + uint.sizeof + len * rchar.sizeof; break; case REistring: len = *cast(uint *)&prog[pc + 1]; printf("\tREistring x%x, '%.*s'\n", len, (&prog[pc + 1 + uint.sizeof])[0 .. len]); - pc += 1 + uint.sizeof + len * tchar.sizeof; + pc += 1 + uint.sizeof + len * rchar.sizeof; break; case REtestbit: @@ -893,8 +893,8 @@ c2 = input[src]; if (c1 != c2) { - if (islower(cast(tchar)c2)) - c2 = std.ctype.toupper(cast(tchar)c2); + if (islower(cast(rchar)c2)) + c2 = std.ctype.toupper(cast(rchar)c2); else goto Lnomatch; if (c1 != c2) @@ -922,8 +922,8 @@ c2 = input[src]; if (c1 != c2) { - if (islower(cast(tchar)c2)) - c2 = std.ctype.toupper(cast(tchar)c2); + if (islower(cast(rchar)c2)) + c2 = std.ctype.toupper(cast(rchar)c2); else goto Lnomatch; if (c1 != c2) @@ -937,7 +937,7 @@ debug(regexp) printf("\tREanychar\n"); if (src == input.length) goto Lnomatch; - if (!(attributes & REA.dotmatchlf) && input[src] == cast(tchar)'\n') + if (!(attributes & REA.dotmatchlf) && input[src] == cast(rchar)'\n') goto Lnomatch; src++; pc++; @@ -949,10 +949,10 @@ (&program[pc + 1 + uint.sizeof])[0 .. len]); if (src + len > input.length) goto Lnomatch; - if (memcmp(&program[pc + 1 + uint.sizeof], &input[src], len * tchar.sizeof)) + if (memcmp(&program[pc + 1 + uint.sizeof], &input[src], len * rchar.sizeof)) goto Lnomatch; src += len; - pc += 1 + uint.sizeof + len * tchar.sizeof; + pc += 1 + uint.sizeof + len * rchar.sizeof; break; case REistring: @@ -963,7 +963,7 @@ goto Lnomatch; version (Win32) { - if (memicmp(cast(char*)&program[pc + 1 + uint.sizeof], &input[src], len * tchar.sizeof)) + if (memicmp(cast(char*)&program[pc + 1 + uint.sizeof], &input[src], len * rchar.sizeof)) goto Lnomatch; } else @@ -973,7 +973,7 @@ goto Lnomatch; } src += len; - pc += 1 + uint.sizeof + len * tchar.sizeof; + pc += 1 + uint.sizeof + len * rchar.sizeof; break; case REtestbit: @@ -1262,8 +1262,8 @@ c1 = input[src - 1]; c2 = input[src]; if (!( - (isword(cast(tchar)c1) && !isword(cast(tchar)c2)) || - (!isword(cast(tchar)c1) && isword(cast(tchar)c2)) + (isword(cast(rchar)c1) && !isword(cast(rchar)c2)) || + (!isword(cast(rchar)c1) && isword(cast(rchar)c2)) ) ) goto Lnomatch; @@ -1278,8 +1278,8 @@ c1 = input[src - 1]; c2 = input[src]; if ( - (isword(cast(tchar)c1) && !isword(cast(tchar)c2)) || - (!isword(cast(tchar)c1) && isword(cast(tchar)c2)) + (isword(cast(rchar)c1) && !isword(cast(rchar)c2)) || + (!isword(cast(rchar)c1) && isword(cast(rchar)c2)) ) goto Lnomatch; pc++; @@ -1360,7 +1360,7 @@ if (icmp(input[src .. src + len], input[so .. eo])) goto Lnomatch; } - else if (memcmp(&input[src], &input[so], len * tchar.sizeof)) + else if (memcmp(&input[src], &input[so], len * rchar.sizeof)) goto Lnomatch; src += len; pc += 2; @@ -1532,7 +1532,7 @@ int parseAtom() { ubyte op; uint offset; - tchar c; + rchar c; //printf("parseAtom() '%.*s'\n", pattern[p .. pattern.length]); if (p < pattern.length) @@ -1661,7 +1661,7 @@ int len; for (q = p; q < pattern.length; ++q) - { tchar qc = pattern[q]; + { rchar qc = pattern[q]; switch (qc) { @@ -1691,7 +1691,7 @@ if (len > 0) { debug(regexp) printf("writing string len %d, c = '%c', pattern[p] = '%c'\n", len+1, c, pattern[p]); - buf.reserve(5 + (1 + len) * tchar.sizeof); + buf.reserve(5 + (1 + len) * rchar.sizeof); buf.write((attributes & REA.ignoreCase) ? REistring : REstring); buf.write(len + 1); buf.write(c); @@ -1860,13 +1860,13 @@ case 'w': for (i = 0; i <= cmax; i++) - if (isword(cast(tchar)i)) + if (isword(cast(rchar)i)) r.bits[i] = 1; goto Lrs; case 'W': for (i = 1; i <= cmax; i++) - if (!isword(cast(tchar)i)) + if (!isword(cast(rchar)i)) r.bits[i] = 1; goto Lrs; @@ -1969,7 +1969,7 @@ body { int c; int i; - tchar tc; + rchar tc; c = pattern[p]; // none of the cases are multibyte switch (c) @@ -2136,7 +2136,7 @@ uint offset; offset = i; - if (startchars(r, prog[i .. prog.length])) + if (starrchars(r, prog[i .. prog.length])) { debug(regexp) printf("\tfilter built\n"); buf.spread(offset, 1 + 4 + r.maxb); @@ -2161,8 +2161,8 @@ // Return 1 if success, 0 if we can't build a filter or // if there is no point to one. -int startchars(Range r, ubyte[] prog) -{ tchar c; +int starrchars(Range r, ubyte[] prog) +{ rchar c; uint maxc; uint maxb; uint len; @@ -2172,7 +2172,7 @@ ubyte* pop; int i; - //printf("RegExp.startchars(prog = %p, progend = %p)\n", prog, progend); + //printf("RegExp.starrchars(prog = %p, progend = %p)\n", prog, progend); for (i = 0; i < prog.length;) { switch (prog[i]) @@ -2187,7 +2187,7 @@ c = prog[i + 1]; if (c <= 0x7F) { r.setbit2(c); - r.setbit2(std.ctype.tolower(cast(tchar)c)); + r.setbit2(std.ctype.tolower(cast(rchar)c)); } return 1; @@ -2201,7 +2201,7 @@ case REstring: len = *cast(uint *)&prog[i + 1]; assert(len); - c = *cast(tchar *)&prog[i + 1 + uint.sizeof]; + c = *cast(rchar *)&prog[i + 1 + uint.sizeof]; debug(regexp) printf("\tREstring %d, '%c'\n", len, c); if (c <= 0x7F) r.setbit2(c); @@ -2210,11 +2210,11 @@ case REistring: len = *cast(uint *)&prog[i + 1]; assert(len); - c = *cast(tchar *)&prog[i + 1 + uint.sizeof]; + c = *cast(rchar *)&prog[i + 1 + uint.sizeof]; debug(regexp) printf("\tREistring %d, '%c'\n", len, c); if (c <= 0x7F) - { r.setbit2(std.ctype.toupper(cast(tchar)c)); - r.setbit2(std.ctype.tolower(cast(tchar)c)); + { r.setbit2(std.ctype.toupper(cast(rchar)c)); + r.setbit2(std.ctype.tolower(cast(rchar)c)); } return 1; @@ -2247,8 +2247,8 @@ case REor: len = (cast(uint *)&prog[i + 1])[0]; - return startchars(r, prog[i + 1 + uint.sizeof .. prog.length]) && - startchars(r, prog[i + 1 + uint.sizeof + len .. prog.length]); + return starrchars(r, prog[i + 1 + uint.sizeof .. prog.length]) && + starrchars(r, prog[i + 1 + uint.sizeof + len .. prog.length]); case REgoto: len = (cast(uint *)&prog[i + 1])[0]; @@ -2265,7 +2265,7 @@ n = (cast(uint *)&prog[i + 1])[1]; m = (cast(uint *)&prog[i + 1])[2]; pop = &prog[i + 1 + uint.sizeof * 3]; - if (!startchars(r, pop[0 .. len])) + if (!starrchars(r, pop[0 .. len])) return 0; if (n) return 1; @@ -2277,7 +2277,7 @@ len = (cast(uint *)&prog[i + 1])[0]; n = (cast(uint *)&prog[i + 1])[1]; pop = &prog[0] + i + 1 + uint.sizeof * 2; - return startchars(r, pop[0 .. len]); + return starrchars(r, pop[0 .. len]); case REend: return 0; @@ -2317,14 +2317,14 @@ case REword: r.setbitmax(0x7F); for (c = 0; c <= r.maxc; c++) - if (isword(cast(tchar)c)) + if (isword(cast(rchar)c)) r.bits[c] = 1; return 1; case REnotword: r.setbitmax(0x7F); for (c = 0; c <= r.maxc; c++) - if (!isword(cast(tchar)c)) + if (!isword(cast(rchar)c)) r.bits[c] = 1; return 1; @@ -2344,16 +2344,16 @@ * \c replace with char c */ -public tchar[] replaceOld(tchar[] format) +public rchar[] replaceOld(rchar[] format) { OutBuffer buf; - tchar[] result; - tchar c; + rchar[] result; + rchar c; //printf("replace: this = %p so = %d, eo = %d\n", this, pmatch[0].rm_so, pmatch[0].rm_eo); //printf("3input = '%.*s'\n", input); buf = new OutBuffer(); - buf.reserve(format.length * tchar.sizeof); + buf.reserve(format.length * rchar.sizeof); for (uint i; i < format.length; i++) { c = format[i]; @@ -2385,7 +2385,7 @@ break; } } - result = cast(tchar[])buf.toBytes(); + result = cast(rchar[])buf.toBytes(); return result; } @@ -2404,18 +2404,18 @@ // // Any other $ are left as is. -public tchar[] replace(tchar[] format) +public rchar[] replace(rchar[] format) { return replace3(format, input, pmatch[0 .. re_nsub + 1]); } // Static version that doesn't require a RegExp object to be created -private tchar[] replace3(tchar[] format, tchar[] input, regmatch_t[] pmatch) +private static rchar[] replace3(rchar[] format, rchar[] input, regmatch_t[] pmatch) { OutBuffer buf; - tchar[] result; - tchar c; + rchar[] result; + rchar c; uint c2; int rm_so; int rm_eo; @@ -2424,7 +2424,7 @@ // printf("replace3(format = '%.*s', input = '%.*s')\n", format, input); buf = new OutBuffer(); - buf.reserve(format.length * tchar.sizeof); + buf.reserve(format.length * rchar.sizeof); for (f = 0; f < format.length; f++) { c = format[f]; @@ -2437,7 +2437,7 @@ ++f; if (f == format.length) { - buf.write(cast(tchar)'$'); + buf.write(cast(rchar)'$'); break; } c = format[f]; @@ -2465,7 +2465,7 @@ { if (i == 0) { - buf.write(cast(tchar)'$'); + buf.write(cast(rchar)'$'); buf.write(c); continue; } @@ -2479,7 +2479,7 @@ } if (i == 0) { - buf.write(cast(tchar)'$'); + buf.write(cast(rchar)'$'); buf.write(c); c = c2; goto L1; @@ -2499,12 +2499,12 @@ break; default: - buf.write(cast(tchar)'$'); + buf.write(cast(rchar)'$'); buf.write(c); break; } } - result = cast(tchar[])buf.toBytes(); + result = cast(rchar[])buf.toBytes(); return result; } diff -uNr gdc-0.9/d/phobos/std/stdarg.d gdc-0.10/d/phobos/std/stdarg.d --- gdc-0.9/d/phobos/std/stdarg.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/std/stdarg.d 2005-01-09 01:40:20.000000000 +0100 @@ -4,6 +4,8 @@ * Written by Hauke Duden and Walter Bright */ +/* This is for use with variable argument lists with extern(D) linkage. */ + /* NOTE: This file has been patched from the original DMD distribution to work with the GDC compiler. diff -uNr gdc-0.9/d/phobos/std/uri.d gdc-0.10/d/phobos/std/uri.d --- gdc-0.9/d/phobos/std/uri.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/std/uri.d 2005-01-09 01:40:20.000000000 +0100 @@ -368,4 +368,8 @@ r = encode( decode("%E3%81%82%E3%81%82") ); assert(r == "%E3%81%82%E3%81%82"); + + r = encodeComponent("c++"); + //printf("r = '%.*s'\n", r); + assert(r == "c%2B%2B"); } diff -uNr gdc-0.9/d/phobos/unittest.d gdc-0.10/d/phobos/unittest.d --- gdc-0.9/d/phobos/unittest.d 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/phobos/unittest.d 2005-01-09 01:40:20.000000000 +0100 @@ -24,6 +24,7 @@ import std.uri; import std.zlib; import std.md5; +import std.stdio; int main(char[][] args) { @@ -53,6 +54,8 @@ ubyte[16] buf; std.md5.sum(buf,""); + writefln("hello world!"); // std.format + { creal c = 3.0 + 4.0i; c = sqrt(c); diff -uNr gdc-0.9/d/README gdc-0.10/d/README --- gdc-0.9/d/README 2004-12-19 17:25:21.000000000 +0100 +++ gdc-0.10/d/README 2005-01-09 22:08:32.000000000 +0100 @@ -1,6 +1,6 @@ -D Front End for GCC - Release 0.9 +D Front End for GCC - Release 0.10 -Last update: December 19, 2004 +Last update: January 9, 2005 Supported Systems * GCC 3.3.x, 3.4.x @@ -15,9 +15,9 @@ Downloads - * Main package (Release 0.9) - http://home.earthlink.net/~dvdfrdmn/d/gdc-0.9.tgz - http://home.earthlink.net/~dvdfrdmn/d/gdc-0.9.tar.bz2 + * Main package (Release 0.10) + http://home.earthlink.net/~dvdfrdmn/d/gdc-0.10.tgz + http://home.earthlink.net/~dvdfrdmn/d/gdc-0.10.tar.bz2 * Build Instructions http://home.earthlink.net/~dvdfrdmn/d/INSTALL.html (or see INSTALL included in the main package) @@ -26,7 +26,10 @@ * This Project -- http://home.earthlink.net/~dvdfrdmn/d * The D Programming Language -- http://www.digitalmars.com/d/ + * D Links Page -- http://digitalmars.com/d/dlinks.html * The D.gnu newsgroup -- news://news.digitalmars.com/D.gnu + * For general D discussion, the digitalmars.D and + digitalmars.D.bugs newsgroups * The GNU Compiler Collection -- http://gcc.gnu.org/ Contact @@ -36,7 +39,7 @@ Status What's Working - * Most features of Digital Mars D version 0.109 + * Most features of Digital Mars D version 0.110 What's not Working @@ -115,27 +118,49 @@ Other options: -f[no-]bounds-check Controls array bounds checking + -femit-templates[=full|private|none|auto] -f[no-]emit-templates Controls whether or not template code is emitted. -"full" Emit templates, expecting multiple copies to be merged by the linker. -"private" -- Emit templates, but make them private to the translation unit. - The executable will have multiple copies of code and data. -"none" Do not emit templates at all. -"auto" -- For targets that support templates, the "full" mode is used. - Otherwise, the "private" mode is used. + "full" Emit templates, expecting multiple copies to be merged by + linker. + "private" Emit templates, but make them private to the translation + unit. The executable will have multiple copies of code + and data. + "none" Do not emit templates at all. + "auto" For targets that support templates, the "full" mode is + used. Otherwise, the "private" mode is used. + + "none" and -fno-emit-templates are synonyms. + "full" and -femit-templates are synonyms. -"none" and -fno-emit-templates are synonyms. -"full" and -femit-templates are synonyms. -fall-sources For each source file on the command line, semantically process each file preceding it. Use this if compilation errors occur due to complicated circular module references. This will slow compilation noticeably. +-fdump-source + Dump decoded UTF-8 text and source from HTML to .utf-8 + and .d.utf-8. + Changes +0.10: + + * Fixes + o Complex number comparisons with NAN operands + o Cleaned up Phobos installation. + o Non-virtual method calls + o Code generation with -mpowerpc64 + o Break in labeled switch statement + * Improvements + o Updated to DMD 0.110 + o Applied Thomas KŸhne's and Anders Bjšrklund's HTML patches. + o Added Thomas KŸhne's "dump source" code + o Phobos Makefile now supports the DESTDIR variable + 0.9: * Fixes diff -uNr gdc-0.9/d/root/aggregate.h gdc-0.10/d/root/aggregate.h --- gdc-0.9/d/root/aggregate.h 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/aggregate.h 2005-01-09 01:40:20.000000000 +0100 @@ -48,6 +48,10 @@ unsigned structalign; // struct member alignment in effect Array fields; // VarDeclaration fields unsigned sizeok; // set when structsize contains valid data + // 0: no size + // 1: size is correct + // 2: cannot determine size; fwd referenced + Scope *scope; // !=NULL means context to use // Special member functions InvariantDeclaration *inv; // invariant @@ -63,7 +67,7 @@ void semantic2(Scope *sc); void semantic3(Scope *sc); void inlineScan(); - unsigned size(); + unsigned size(Loc loc); static void alignmember(unsigned salign, unsigned size, unsigned *poffset); Type *getType(); void addField(Scope *sc, VarDeclaration *v); @@ -160,7 +164,6 @@ ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration int com; // !=0 if this is a COM class int isauto; // !=0 if this is an auto class - Scope *scope; // !=NULL means context to use ClassDeclaration(Loc loc, Identifier *id, Array *baseclasses); Dsymbol *syntaxCopy(Dsymbol *s); diff -uNr gdc-0.9/d/root/cast.c gdc-0.10/d/root/cast.c --- gdc-0.9/d/root/cast.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/cast.c 2005-01-09 01:40:20.000000000 +0100 @@ -45,6 +45,8 @@ type->print(); printf("to:\n"); t->print(); +printf("%p %p %s %s\n", type->deco, t->deco, type->deco, t->deco); +printf("%p %p %p\n", type->next->arrayOf(), type, t); #endif //*(char*)0=0; error("cannot implicitly convert expression %s of type %s to %s", toChars(), type->toChars(), t->toChars()); diff -uNr gdc-0.9/d/root/class.c gdc-0.10/d/root/class.c --- gdc-0.9/d/root/class.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/class.c 2005-01-09 01:40:20.000000000 +0100 @@ -57,6 +57,9 @@ vtblsym = NULL; vclassinfo = NULL; + if (id == Id::__sizeof) + error("illegal class name"); + // BUG: What if this is the wrong ClassInfo, i.e. it is nested? if (!classinfo && id == Id::ClassInfo) classinfo = this; @@ -72,6 +75,9 @@ if (!Type::typeinfoclass && id == Id::TypeInfo_Class) Type::typeinfoclass = this; + if (!Type::typeinfostruct && id == Id::TypeInfo_Struct) + Type::typeinfostruct = this; + if (!Type::typeinfotypedef && id == Id::TypeInfo_Typedef) Type::typeinfotypedef = this; @@ -81,7 +87,6 @@ com = 1; #endif isauto = 0; - scope = NULL; } Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s) @@ -110,7 +115,7 @@ { int i; unsigned offset; - //printf("ClassDeclaration::semantic(%s), type = %p\n", toChars(), type); + //printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d\n", toChars(), type, sizeok); //{ static int n; if (++n == 20) *(char*)0=0; } @@ -119,12 +124,14 @@ handle = handle->semantic(loc, sc); } if (!members) // if forward reference - { //printf("\tclass '%s' is forward referenced\n", toChars()); + { printf("\tclass '%s' is forward referenced\n", toChars()); return; } if (symtab) { if (!scope) + { //printf("\tsemantic for '%s' is already completed\n", toChars()); return; // semantic() already completed + } } else symtab = new DsymbolTable(); @@ -165,7 +172,7 @@ { //error("forward reference of base class %s", baseClass->toChars()); // Forward reference of base class, try again later - //printf("\ttry later, forward reference of base class %s\n", baseClass->toChars()); + //printf("\ttry later, forward reference of base class %s\n", tc->sym->toChars()); scope = scx ? scx : new Scope(*sc); scope->setNoFree(); scope->module->addDeferredSemantic(this); @@ -255,24 +262,28 @@ else { // No base class, so this is the root of the class heirarchy + vtbl.setDim(0); vtbl.push(this); // leave room for classinfo as first member } + if (sizeok == 0) + { + interfaceSemantic(sc); + + for (i = 0; i < members->dim; i++) + { + Dsymbol *s = (Dsymbol *)members->data[i]; + s->addMember(this); + } + } + if (sc->stc & STCauto) isauto = 1; - interfaceSemantic(sc); - sc = sc->push(this); sc->stc &= ~(STCauto | STCstatic); sc->parent = this; - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - s->addMember(this); - } - if (isCOMclass()) sc->linkage = LINKwindows; sc->protection = PROTpublic; @@ -289,11 +300,31 @@ structsize = sc->offset; Scope scsave = *sc; int members_dim = members->dim; + sizeok = 0; for (i = 0; i < members_dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; s->semantic(sc); } + + if (sizeok == 2) + { // semantic() failed because of forward references. + // Unwind what we did, and defer it for later + fields.setDim(0); + structsize = 0; + alignsize = 0; + structalign = 0; + + sc->pop(); + + scope = scx ? scx : new Scope(*sc); + scope->setNoFree(); + scope->module->addDeferredSemantic(this); + return; + } + + //printf("\tsemantic('%s') successful\n", toChars()); + structsize = sc->offset; //members->print(); diff -uNr gdc-0.9/d/root/declaration.c gdc-0.10/d/root/declaration.c --- gdc-0.9/d/root/declaration.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/declaration.c 2005-01-09 01:40:20.000000000 +0100 @@ -41,7 +41,7 @@ return "declaration"; } -unsigned Declaration::size() +unsigned Declaration::size(Loc loc) { assert(type); return type->size(); @@ -706,6 +706,13 @@ assert(linkage == LINKc); } +/***************************** TypeInfoStructDeclaration ***********************/ + +TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) + : TypeInfoDeclaration(tinfo, 0) +{ +} + /***************************** TypeInfoClassDeclaration ***********************/ TypeInfoClassDeclaration::TypeInfoClassDeclaration(Type *tinfo) diff -uNr gdc-0.9/d/root/declaration.h gdc-0.10/d/root/declaration.h --- gdc-0.9/d/root/declaration.h 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/root/declaration.h 2005-01-09 01:40:20.000000000 +0100 @@ -80,7 +80,7 @@ Declaration(Identifier *id); void semantic(Scope *sc); char *kind(); - unsigned size(); + unsigned size(Loc loc); char *mangle(); int isStatic() { return storage_class & STCstatic; } @@ -221,6 +221,13 @@ virtual void toDt(dt_t **pdt); }; +struct TypeInfoStructDeclaration : TypeInfoDeclaration +{ + TypeInfoStructDeclaration(Type *tinfo); + + void toDt(dt_t **pdt); +}; + struct TypeInfoClassDeclaration : TypeInfoDeclaration { TypeInfoClassDeclaration(Type *tinfo); diff -uNr gdc-0.9/d/root/dsymbol.c gdc-0.10/d/root/dsymbol.c --- gdc-0.9/d/root/dsymbol.c 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/root/dsymbol.c 2005-01-09 01:40:20.000000000 +0100 @@ -192,7 +192,7 @@ buf->writenl(); } -unsigned Dsymbol::size() +unsigned Dsymbol::size(Loc loc) { error("Dsymbol '%s' has no size\n", toChars()); return 0; @@ -274,6 +274,11 @@ sd->multiplyDefined(this, s2); } } + if (sd->isAggregateDeclaration() || sd->isEnumDeclaration()) + { + if (ident == Id::__sizeof) + error(".sizeof property cannot be redefined"); + } } } @@ -611,7 +616,7 @@ assert(ident); assert(tab); //#endif - sv = tab->lookup(ident->toChars(),strlen(ident->toChars())); + sv = tab->lookup((char*)ident->string, ident->len); return (Dsymbol *)(sv ? sv->ptrvalue : NULL); } @@ -625,7 +630,7 @@ assert(ident); assert(tab); #endif - sv = tab->insert(ident->toChars(),strlen(ident->toChars())); + sv = tab->insert(ident->toChars(), ident->len); if (!sv) return NULL; // already in table sv->ptrvalue = s; @@ -636,7 +641,7 @@ { StringValue *sv; //printf("DsymbolTable::insert()\n"); - sv = tab->insert(ident->toChars(),strlen(ident->toChars())); + sv = tab->insert(ident->toChars(), ident->len); if (!sv) return NULL; // already in table sv->ptrvalue = s; @@ -648,7 +653,7 @@ Identifier *ident; ident = s->ident; - sv = tab->update(ident->toChars(),strlen(ident->toChars())); + sv = tab->update(ident->toChars(), ident->len); sv->ptrvalue = s; return s; } diff -uNr gdc-0.9/d/root/dsymbol.h gdc-0.10/d/root/dsymbol.h --- gdc-0.9/d/root/dsymbol.h 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/root/dsymbol.h 2005-01-09 01:40:20.000000000 +0100 @@ -32,6 +32,7 @@ struct TypedefDeclaration; struct AliasDeclaration; struct AggregateDeclaration; +struct EnumDeclaration; struct ClassDeclaration; struct InterfaceDeclaration; struct StructDeclaration; @@ -113,7 +114,7 @@ virtual Dsymbol *search(Identifier *ident, int flags); virtual int overloadInsert(Dsymbol *s); virtual void toCBuffer(OutBuffer *buf); - virtual unsigned size(); + virtual unsigned size(Loc loc); virtual int isforwardRef(); virtual void defineRef(Dsymbol *s); virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member @@ -171,6 +172,7 @@ virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; } virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; } virtual Import *isImport() { return NULL; } + virtual EnumDeclaration *isEnumDeclaration() { return NULL; } }; // Dsymbol that generates a scope diff -uNr gdc-0.9/d/root/enum.c gdc-0.10/d/root/enum.c --- gdc-0.9/d/root/enum.c 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/enum.c 2005-01-09 01:40:20.000000000 +0100 @@ -44,14 +44,6 @@ return ed; } -void EnumDeclaration::addMember(ScopeDsymbol *sd) -{ int i; - - //printf("EnumDeclaration::addMember(sd = %p, '%s')\n", sd, sd->toChars()); - if (!isAnonymous()) - Dsymbol::addMember(sd); -} - void EnumDeclaration::semantic(Scope *sc) { int i; integer_t number; diff -uNr gdc-0.9/d/root/enum.h gdc-0.10/d/root/enum.h --- gdc-0.9/d/root/enum.h 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/root/enum.h 2005-01-09 01:40:20.000000000 +0100 @@ -31,13 +31,14 @@ EnumDeclaration(Identifier *id, Type *memtype); Dsymbol *syntaxCopy(Dsymbol *s); - void addMember(ScopeDsymbol *s); void semantic(Scope *sc); Dsymbol *oneMember(); void toCBuffer(OutBuffer *buf); Type *getType(); char *kind(); + EnumDeclaration *isEnumDeclaration() { return this; } + void toObjFile(); // compile to .obj file void toDebug(); int cvMember(unsigned char *p); diff -uNr gdc-0.9/d/root/expression.c gdc-0.10/d/root/expression.c --- gdc-0.9/d/root/expression.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/expression.c 2005-01-09 01:40:20.000000000 +0100 @@ -1700,7 +1700,9 @@ //printf("tb: %s, deco = %s\n", tb->toChars(), tb->deco); arrayExpressionSemantic(newargs, sc); + preFunctionArguments(loc, sc, newargs); arrayExpressionSemantic(arguments, sc); + preFunctionArguments(loc, sc, arguments); if (tb->ty == Tclass) { ClassDeclaration *cd; @@ -1743,7 +1745,7 @@ f = cd->aggNew; // Prepend the uint size argument to newargs[] - e = new IntegerExp(loc, cd->size(), Type::tuns32); + e = new IntegerExp(loc, cd->size(loc), Type::tuns32); if (!newargs) newargs = new Array(); newargs->shift(e); @@ -1775,7 +1777,7 @@ Expression *e; // Prepend the uint size argument to newargs[] - e = new IntegerExp(loc, sd->size(), Type::tuns32); + e = new IntegerExp(loc, sd->size(loc), Type::tuns32); if (!newargs) newargs = new Array(); newargs->shift(e); @@ -2338,31 +2340,34 @@ AggregateDeclaration *ad; ad = sc->getStructClassScope(); - cd = ad->isClassDeclaration(); - if (cd) + if (ad) { - if (e1->op == TOKthis) - { - e = new TypeDotIdExp(loc, cd->type, ident); - return e->semantic(sc); - } - else if (cd->baseClass && e1->op == TOKsuper) - { - e = new TypeDotIdExp(loc, cd->baseClass->type, ident); - return e->semantic(sc); - } - } - else - { - sd = ad->isStructDeclaration(); - if (sd) + cd = ad->isClassDeclaration(); + if (cd) { if (e1->op == TOKthis) { - e = new TypeDotIdExp(loc, sd->type, ident); + e = new TypeDotIdExp(loc, cd->type, ident); + return e->semantic(sc); + } + else if (cd->baseClass && e1->op == TOKsuper) + { + e = new TypeDotIdExp(loc, cd->baseClass->type, ident); return e->semantic(sc); } } + else + { + sd = ad->isStructDeclaration(); + if (sd) + { + if (e1->op == TOKthis) + { + e = new TypeDotIdExp(loc, sd->type, ident); + return e->semantic(sc); + } + } + } } } @@ -5009,6 +5014,9 @@ e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); + e1 = resolveProperties(sc, e1); + e2 = resolveProperties(sc, e2); + e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); e1 = e1->checkToBoolean(); @@ -5047,6 +5055,9 @@ e2 = e2->semantic(sc); sc->mergeCallSuper(loc, cs1); + e1 = resolveProperties(sc, e1); + e2 = resolveProperties(sc, e2); + e1 = e1->checkToPointer(); e2 = e2->checkToPointer(); e1 = e1->checkToBoolean(); diff -uNr gdc-0.9/d/root/func.c gdc-0.10/d/root/func.c --- gdc-0.9/d/root/func.c 2004-11-13 17:29:15.000000000 +0100 +++ gdc-0.10/d/root/func.c 2005-01-09 01:40:20.000000000 +0100 @@ -30,6 +30,10 @@ #include "statement.h" #include "template.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + /********************************* FuncDeclaration ****************************/ @@ -92,12 +96,13 @@ InterfaceDeclaration *id; #if 0 - printf("FuncDeclaration::semantic(sc = %p, this = %p, '%s', linkage = %d)\n", sc, this, toChars(), sc->linkage); + printf("FuncDeclaration::semantic(sc = %p, this = %p, '%s', linkage = %d)\n", sc, this, toPrettyChars(), sc->linkage); if (isFuncLiteralDeclaration()) printf("\tFuncLiteralDeclaration()\n"); #endif type = type->semantic(loc, sc); + //type->print(); if (type->ty != Tfunction) { error("%s must be a function", toChars()); @@ -248,9 +253,15 @@ // Override //printf("\toverride %p with %p\n", fdv, this); if (cov == 2) - error("overrides but is not covariant with %s", fdv->toChars()); + { + //type->print(); + //fdv->type->print(); + //printf("%s %s\n", type->deco, fdv->type->deco); + error("of type %s overrides but is not covariant with %s of type %s", + type->toChars(), fdv->toPrettyChars(), fdv->type->toChars()); + } if (fdv->isFinal()) - error("cannot override final function %s", fdv->toChars()); + error("cannot override final function %s", fdv->toPrettyChars()); if (fdv->toParent() == parent) { // If both are mixins, then error. @@ -350,6 +361,11 @@ AggregateDeclaration *ad; VarDeclaration *argptr = NULL; + if (!parent) + { + printf("FuncDeclaration::semantic3(%s '%s', sc = %p)\n", kind(), toChars(), sc); + assert(0); + } //printf("FuncDeclaration::semantic3('%s.%s', sc = %p)\n", parent->toChars(), toChars(), sc); //fflush(stdout); //{ static int x; if (++x == 2) *(char*)0=0; } @@ -451,7 +467,6 @@ #ifndef IN_GCC t = Type::tvoid->pointerTo(); #else - extern Type * d_gcc_builtin_va_list_d_type; t = d_gcc_builtin_va_list_d_type; #endif argptr = new VarDeclaration(0, t, Id::_argptr, NULL); @@ -1157,7 +1172,7 @@ int FuncDeclaration::isNested() { - //printf("FuncDeclaration::isNested() '%s'\n", toChars()); +// if (!toParent()) printf("FuncDeclaration::isNested('%s') parent=%p\n", toChars(), parent); //printf("\ttoParent() = '%s'\n", toParent()->toChars()); return ((storage_class & STCstatic) == 0) && (toParent()->isFuncDeclaration() != NULL); diff -uNr gdc-0.9/d/root/html.c gdc-0.10/d/root/html.c --- gdc-0.9/d/root/html.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/root/html.c 2004-12-26 17:15:05.000000000 +0100 @@ -11,6 +11,7 @@ work with the GDC compiler. Modified by David Friedman, September 2004 + Modified by Thomas Kuehne, November 2004 */ /* HTML parser @@ -41,6 +42,36 @@ return (isalnum(c) || c == '_'); } +/** + * identify DOS, Linux, Mac, Next and Unicode line endings + * 0 if this is no line seperator + * >0 the length of the seperator + * Note: input has to be UTF-8 + */ +static int isLineSeperator(const unsigned char* p){ + // Linux + if( p[0]=='\n'){ + return 1; + } + + // Mac & Dos + if( p[0]=='\r'){ + return (p[1]=='\n') ? 2 : 1; + } + + // Unicode (line || paragarph sep.) + if( p[0]==0xE2 && p[1]==0x80 && (p[2]==0xA8 || p[2]==0xA9)){ + return 3; + } + + // Next + if( p[0]==0xC2 && p[1]==0x85){ + return 2; + } + + return 0; +} + /********************************************** */ @@ -122,21 +153,23 @@ int c; c = charEntity(); - buf->writeByte(c); // BUG: wchar + buf->writeUTF8(c); } else p++; continue; - case '\n': - linnum++; - // Always extract new lines, so that D lexer counts the - // lines right. - buf->writeByte(*p); // BUG: wchar - p++; - continue; - default: + int lineSepLength=isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that the D lexer + // counts the lines right. + buf->writeByte('\n'); // BUG: wchar + p+=lineSepLength; + continue; + } + if (inCode) buf->writeByte(*p); // BUG: wchar p++; @@ -214,23 +247,24 @@ error("end of file before end of tag"); break; // end of file - case '\n': - linnum++; - // Always extract new lines, so that code lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - state = TSrest; // end of tag - p++; - continue; - default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that code lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + state = TSrest; + p+=lineSepLength; + continue; + } switch (state) { case TStagstart: // start of tag name assert(istagstart(*p)); state = TStag; tagstart = p; - taglen = 0; + taglen = 1; break; case TStag: @@ -254,7 +288,8 @@ } // See if we parsed a or tag - if (taglen && memicmp((const char *)tagstart, "CODE", taglen) == 0) + if (taglen == 4 && memicmp((const char *)tagstart, "CODE", taglen) == 0 && + *(p - 2) != '/') { if (nottag) { inCode--; @@ -287,13 +322,6 @@ } continue; - case '\n': - linnum++; - // Always extract new lines, so that D lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - continue; - case 0: case 0x1a: Leof: @@ -301,6 +329,14 @@ break; default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; + // Always extract new lines, so that D lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + continue; + } continue; } break; @@ -353,25 +389,26 @@ case ' ': case '\t': - case '\r': case '\f': case '\v': // skip white space continue; - case '\n': - linnum++; // remember to count lines - // Always extract new lines, so that D lexer counts the - // lines right. - dbuf->writeByte(*p); // BUG: wchar - continue; - case 0: case 0x1a: error("end of file before closing --> of comment"); break; default: + int lineSepLength = isLineSeperator(p); + if( lineSepLength>0 ){ + linnum++; // remember to count lines + // Always extract new lines, so that D lexer counts + // the lines right. + dbuf->writeByte('\n'); // BUG: wchar + p+=lineSepLength-1; + continue; + } scangt = 0; // it's not --> continue; } @@ -449,7 +486,7 @@ c = (c << 4) + v; else c = (c * 10) + v; - if (c > 0xFFFF) + if (c > 0x10FFFF) error("character entity out of range"); continue; @@ -458,11 +495,8 @@ error("invalid numeric character reference"); break; } + break; } - - // Kludge to convert non-breaking space to ascii space - if (c == 160) - c = 32; } else { @@ -498,6 +532,10 @@ break; } } + + // Kludge to convert non-breaking space to ascii space + if (c == 160) + c = 32; return c; } @@ -511,36 +549,1049 @@ int value; }; -static NameId names[] = -{ - "quot", 34, - "amp", 38, - "apos", 39, - "lt", 60, - "gt", 62, -// "nbsp", 160, - "nbsp", 32, // make non-breaking space appear as space - "iexcl", 161, - "cent", 162, - "pound", 163, - "curren", 164, - "yen", 165, - "brvbar", 166, - "sect", 167, - "uml", 168, - "copy", 169, - "ordf", 170, - "laquo", 171, - "not", 172, - "shy", 173, - "reg", 174, - NULL, 0 - - // BUG: This is only a partial list. - // For the rest, consult: - // http://www.w3.org/TR/1999/REC-html401-19991224/sgml/entities.html +static NameId namesA[]={ + "Aacgr", 0x0386, + "aacgr", 0x03AC, + "Aacute", 0x00C1, + "aacute", 0x00E1, + "Abreve", 0x0102, + "abreve", 0x0103, + "Acirc", 0x00C2, + "acirc", 0x00E2, + "acute", 0x00B4, + "Acy", 0x0410, + "acy", 0x0430, + "AElig", 0x00C6, + "aelig", 0x00E6, + "Agr", 0x0391, + "agr", 0x03B1, + "Agrave", 0x00C0, + "agrave", 0x00E0, + "aleph", 0x2135, + "alpha", 0x03B1, + "Amacr", 0x0100, + "amacr", 0x0101, + "amalg", 0x2210, + "amp", 0x0026, + "and", 0x2227, + "ang", 0x2220, + "ang90", 0x221F, + "angmsd", 0x2221, + "angsph", 0x2222, + "angst", 0x212B, + "Aogon", 0x0104, + "aogon", 0x0105, + "ap", 0x2248, + "ape", 0x224A, + "apos", 0x0027, + "Aring", 0x00C5, + "aring", 0x00E5, + "ast", 0x002A, + "asymp", 0x224D, + "Atilde", 0x00C3, + "atilde", 0x00E3, + "Auml", 0x00C4, + "auml", 0x00E4, + NULL, 0 +}; + +static NameId namesB[]={ + "barwed", 0x22BC, + "Barwed", 0x2306, + "bcong", 0x224C, + "Bcy", 0x0411, + "bcy", 0x0431, + "becaus", 0x2235, + "bepsi", 0x220D, + "bernou", 0x212C, + "beta", 0x03B2, + "beth", 0x2136, + "Bgr", 0x0392, + "bgr", 0x03B2, + "blank", 0x2423, + "blk12", 0x2592, + "blk14", 0x2591, + "blk34", 0x2593, + "block", 0x2588, + "bottom", 0x22A5, + "bowtie", 0x22C8, + "boxdl", 0x2510, + "boxDL", 0x2555, + "boxdL", 0x2556, + "boxDl", 0x2557, + "boxdr", 0x250C, + "boxDR", 0x2552, + "boxDr", 0x2553, + "boxdR", 0x2554, + "boxh", 0x2500, + "boxH", 0x2550, + "boxhd", 0x252C, + "boxhD", 0x2564, + "boxHD", 0x2565, + "boxHd", 0x2566, + "boxhu", 0x2534, + "boxhU", 0x2567, + "boxHU", 0x2568, + "boxHu", 0x2569, + "boxul", 0x2518, + "boxUL", 0x255B, + "boxUl", 0x255C, + "boxuL", 0x255D, + "boxur", 0x2514, + "boxUR", 0x2558, + "boxuR", 0x2559, + "boxUr", 0x255A, + "boxv", 0x2502, + "boxV", 0x2551, + "boxvh", 0x253C, + "boxvH", 0x256A, + "boxVH", 0x256B, + "boxVh", 0x256C, + "boxvl", 0x2524, + "boxvL", 0x2561, + "boxVL", 0x2562, + "boxVl", 0x2563, + "boxvr", 0x251C, + "boxvR", 0x255E, + "boxVR", 0x255F, + "boxVr", 0x2560, + "bprime", 0x2035, + "breve", 0x02D8, + "brvbar", 0x00A6, + "bsim", 0x223D, + "bsime", 0x22CD, + "bsol", 0x005C, + "bull", 0x2022, + "bump", 0x224E, + "bumpe", 0x224F, + NULL, 0 +}; + +static NameId namesC[]={ + "Cacute", 0x0106, + "cacute", 0x0107, + "cap", 0x2229, + "Cap", 0x22D2, + "caret", 0x2041, + "caron", 0x02C7, + "Ccaron", 0x010C, + "ccaron", 0x010D, + "Ccedil", 0x00C7, + "ccedil", 0x00E7, + "Ccirc", 0x0108, + "ccirc", 0x0109, + "Cdot", 0x010A, + "cdot", 0x010B, + "cedil", 0x00B8, + "cent", 0x00A2, + "CHcy", 0x0427, + "chcy", 0x0447, + "check", 0x2713, + "chi", 0x03C7, + "cir", 0x25CB, + "circ", 0x005E, + "cire", 0x2257, + "clubs", 0x2663, + "colon", 0x003A, + "colone", 0x2254, + "comma", 0x002C, + "commat", 0x0040, + "comp", 0x2201, + "compfn", 0x2218, + "cong", 0x2245, + "conint", 0x222E, + "coprod", 0x2210, + "copy", 0x00A9, + "copysr", 0x2117, + "cross", 0x2717, + "cuepr", 0x22DE, + "cuesc", 0x22DF, + "cularr", 0x21B6, + "cup", 0x222A, + "Cup", 0x22D3, + "cupre", 0x227C, + "curarr", 0x21B7, + "curren", 0x00A4, + "cuvee", 0x22CE, + "cuwed", 0x22CF, + NULL, 0 +}; + +static NameId namesD[]={ + "dagger", 0x2020, + "Dagger", 0x2021, + "daleth", 0x2138, + "darr", 0x2193, + "dArr", 0x21D3, + "darr2", 0x21CA, + "dash", 0x2010, + "dashv", 0x22A3, + "dblac", 0x02DD, + "Dcaron", 0x010E, + "dcaron", 0x010F, + "Dcy", 0x0414, + "dcy", 0x0434, + "deg", 0x00B0, + "Delta", 0x0394, + "delta", 0x03B4, + "Dgr", 0x0394, + "dgr", 0x03B4, + "dharl", 0x21C3, + "dharr", 0x21C2, + "diam", 0x22C4, + "diams", 0x2666, + "die", 0x00A8, + "divide", 0x00F7, + "divonx", 0x22C7, + "DJcy", 0x0402, + "djcy", 0x0452, + "dlarr", 0x2199, + "dlcorn", 0x231E, + "dlcrop", 0x230D, + "dollar", 0x0024, + "Dot", 0x00A8, + "dot", 0x02D9, + "DotDot", 0x20DC, + "drarr", 0x2198, + "drcorn", 0x231F, + "drcrop", 0x230C, + "DScy", 0x0405, + "dscy", 0x0455, + "Dstrok", 0x0110, + "dstrok", 0x0111, + "dtri", 0x25BF, + "dtrif", 0x25BE, + "DZcy", 0x040F, + "dzcy", 0x045F, + NULL, 0 +}; + +static NameId namesE[]={ + "Eacgr", 0x0388, + "eacgr", 0x03AD, + "Eacute", 0x00C9, + "eacute", 0x00E9, + "Ecaron", 0x011A, + "ecaron", 0x011B, + "ecir", 0x2256, + "Ecirc", 0x00CA, + "ecirc", 0x00EA, + "ecolon", 0x2255, + "Ecy", 0x042D, + "ecy", 0x044D, + "Edot", 0x0116, + "edot", 0x0117, + "eDot", 0x2251, + "EEacgr", 0x0389, + "eeacgr", 0x03AE, + "EEgr", 0x0397, + "eegr", 0x03B7, + "efDot", 0x2252, + "Egr", 0x0395, + "egr", 0x03B5, + "Egrave", 0x00C8, + "egrave", 0x00E8, + "egs", 0x22DD, + "ell", 0x2113, + "els", 0x22DC, + "Emacr", 0x0112, + "emacr", 0x0113, + "empty", 0x2205, + "emsp", 0x2003, + "emsp13", 0x2004, + "emsp14", 0x2005, + "ENG", 0x014A, + "eng", 0x014B, + "ensp", 0x2002, + "Eogon", 0x0118, + "eogon", 0x0119, + "epsi", 0x220A, + "epsis", 0x220A, + "epsiv", 0x03B5, + "equals", 0x003D, + "equiv", 0x2261, + "erDot", 0x2253, + "esdot", 0x2250, + "eta", 0x03B7, + "ETH", 0x00D0, + "eth", 0x00F0, + "Euml", 0x00CB, + "euml", 0x00EB, + "excl", 0x0021, + "exist", 0x2203, + NULL, 0 +}; + +static NameId namesF[]={ + "Fcy", 0x0424, + "fcy", 0x0444, + "female", 0x2640, + "ffilig", 0xFB03, + "fflig", 0xFB00, + "ffllig", 0xFB04, + "filig", 0xFB01, + "flat", 0x266D, + "fllig", 0xFB02, + "fnof", 0x0192, + "forall", 0x2200, + "fork", 0x22D4, + "frac12", 0x00BD, + "frac13", 0x2153, + "frac14", 0x00BC, + "frac15", 0x2155, + "frac16", 0x2159, + "frac18", 0x215B, + "frac23", 0x2154, + "frac25", 0x2156, + "frac34", 0x00BE, + "frac35", 0x2157, + "frac38", 0x215C, + "frac45", 0x2158, + "frac56", 0x215A, + "frac58", 0x215D, + "frac78", 0x215E, + "frown", 0x2322, + NULL, 0 +}; + +static NameId namesG[]={ + "gacute", 0x01F5, + "Gamma", 0x0393, + "gamma", 0x03B3, + "gammad", 0x03DC, + "gap", 0x2273, + "Gbreve", 0x011E, + "gbreve", 0x011F, + "Gcedil", 0x0122, + "Gcirc", 0x011C, + "gcirc", 0x011D, + "Gcy", 0x0413, + "gcy", 0x0433, + "Gdot", 0x0120, + "gdot", 0x0121, + "ge", 0x2265, + "gE", 0x2267, + "gel", 0x22DB, + "gEl", 0x22DB, + "ges", 0x2265, + "Gg", 0x22D9, + "Ggr", 0x0393, + "ggr", 0x03B3, + "gimel", 0x2137, + "GJcy", 0x0403, + "gjcy", 0x0453, + "gl", 0x2277, + "gnap", 0xE411, + "gne", 0x2269, + "gnE", 0x2269, + "gnsim", 0x22E7, + "grave", 0x0060, + "gsdot", 0x22D7, + "gsim", 0x2273, + "gt", 0x003E, + "Gt", 0x226B, + "gvnE", 0x2269, + NULL, 0 +}; + +static NameId namesH[]={ + "hairsp", 0x200A, + "half", 0x00BD, + "hamilt", 0x210B, + "HARDcy", 0x042A, + "hardcy", 0x044A, + "harr", 0x2194, + "hArr", 0x21D4, + "harrw", 0x21AD, + "Hcirc", 0x0124, + "hcirc", 0x0125, + "hearts", 0x2665, + "hellip", 0x2026, + "horbar", 0x2015, + "Hstrok", 0x0126, + "hstrok", 0x0127, + "hybull", 0x2043, + "hyphen", 0x002D, + NULL, 0 +}; + +static NameId namesI[]={ + "Iacgr", 0x038A, + "iacgr", 0x03AF, + "Iacute", 0x00CD, + "iacute", 0x00ED, + "Icirc", 0x00CE, + "icirc", 0x00EE, + "Icy", 0x0418, + "icy", 0x0438, + "idiagr", 0x0390, + "Idigr", 0x03AA, + "idigr", 0x03CA, + "Idot", 0x0130, + "IEcy", 0x0415, + "iecy", 0x0435, + "iexcl", 0x00A1, + "iff", 0x21D4, + "Igr", 0x0399, + "igr", 0x03B9, + "Igrave", 0x00CC, + "igrave", 0x00EC, + "IJlig", 0x0132, + "ijlig", 0x0133, + "Imacr", 0x012A, + "imacr", 0x012B, + "image", 0x2111, + "incare", 0x2105, + "infin", 0x221E, + "inodot", 0x0131, + "int", 0x222B, + "intcal", 0x22BA, + "IOcy", 0x0401, + "iocy", 0x0451, + "Iogon", 0x012E, + "iogon", 0x012F, + "iota", 0x03B9, + "iquest", 0x00BF, + "isin", 0x220A, + "Itilde", 0x0128, + "itilde", 0x0129, + "Iukcy", 0x0406, + "iukcy", 0x0456, + "Iuml", 0x00CF, + "iuml", 0x00EF, + NULL, 0 +}; + +static NameId namesJ[]={ + "Jcirc", 0x0134, + "jcirc", 0x0135, + "Jcy", 0x0419, + "jcy", 0x0439, + "Jsercy", 0x0408, + "jsercy", 0x0458, + "Jukcy", 0x0404, + "jukcy", 0x0454, + NULL, 0 +}; + +static NameId namesK[]={ + "kappa", 0x03BA, + "kappav", 0x03F0, + "Kcedil", 0x0136, + "kcedil", 0x0137, + "Kcy", 0x041A, + "kcy", 0x043A, + "Kgr", 0x039A, + "kgr", 0x03BA, + "kgreen", 0x0138, + "KHcy", 0x0425, + "khcy", 0x0445, + "KHgr", 0x03A7, + "khgr", 0x03C7, + "KJcy", 0x040C, + "kjcy", 0x045C, + NULL, 0 +}; + +static NameId namesL[]={ + "lAarr", 0x21DA, + "Lacute", 0x0139, + "lacute", 0x013A, + "lagran", 0x2112, + "Lambda", 0x039B, + "lambda", 0x03BB, + "lang", 0x3008, + "lap", 0x2272, + "laquo", 0x00AB, + "larr", 0x2190, + "Larr", 0x219E, + "lArr", 0x21D0, + "larr2", 0x21C7, + "larrhk", 0x21A9, + "larrlp", 0x21AB, + "larrtl", 0x21A2, + "Lcaron", 0x013D, + "lcaron", 0x013E, + "Lcedil", 0x013B, + "lcedil", 0x013C, + "lceil", 0x2308, + "lcub", 0x007B, + "Lcy", 0x041B, + "lcy", 0x043B, + "ldot", 0x22D6, + "ldquo", 0x201C, + "ldquor", 0x201E, + "le", 0x2264, + "lE", 0x2266, + "leg", 0x22DA, + "lEg", 0x22DA, + "les", 0x2264, + "lfloor", 0x230A, + "lg", 0x2276, + "Lgr", 0x039B, + "lgr", 0x03BB, + "lhard", 0x21BD, + "lharu", 0x21BC, + "lhblk", 0x2584, + "LJcy", 0x0409, + "ljcy", 0x0459, + "Ll", 0x22D8, + "Lmidot", 0x013F, + "lmidot", 0x0140, + "lnap", 0xE2A2, + "lne", 0x2268, + "lnE", 0x2268, + "lnsim", 0x22E6, + "lowast", 0x2217, + "lowbar", 0x005F, + "loz", 0x25CA, + "lozf", 0x2726, + "lpar", 0x0028, + "lrarr2", 0x21C6, + "lrhar2", 0x21CB, + "lsh", 0x21B0, + "lsim", 0x2272, + "lsqb", 0x005B, + "lsquo", 0x2018, + "lsquor", 0x201A, + "Lstrok", 0x0141, + "lstrok", 0x0142, + "lt", 0x003C, + "Lt", 0x226A, + "lthree", 0x22CB, + "ltimes", 0x22C9, + "ltri", 0x25C3, + "ltrie", 0x22B4, + "ltrif", 0x25C2, + "lvnE", 0x2268, + NULL, 0 +}; + +static NameId namesM[]={ + "macr", 0x00AF, + "male", 0x2642, + "malt", 0x2720, + "map", 0x21A6, + "marker", 0x25AE, + "Mcy", 0x041C, + "mcy", 0x043C, + "mdash", 0x2014, + "Mgr", 0x039C, + "mgr", 0x03BC, + "micro", 0x00B5, + "mid", 0x2223, + "middot", 0x00B7, + "minus", 0x2212, + "minusb", 0x229F, + "mldr", 0x2026, + "mnplus", 0x2213, + "models", 0x22A7, + "mu", 0x03BC, + "mumap", 0x22B8, + NULL, 0 +}; + +static NameId namesN[]={ + "nabla", 0x2207, + "Nacute", 0x0143, + "nacute", 0x0144, + "nap", 0x2249, + "napos", 0x0149, + "natur", 0x266E, + "nbsp", 0x00A0, + "Ncaron", 0x0147, + "ncaron", 0x0148, + "Ncedil", 0x0145, + "ncedil", 0x0146, + "ncong", 0x2247, + "Ncy", 0x041D, + "ncy", 0x043D, + "ndash", 0x2013, + "ne", 0x2260, + "nearr", 0x2197, + "nequiv", 0x2262, + "nexist", 0x2204, + "nge", 0x2271, + "ngE", 0x2271, + "nges", 0x2271, + "Ngr", 0x039D, + "ngr", 0x03BD, + "ngt", 0x226F, + "nharr", 0x21AE, + "nhArr", 0x21CE, + "ni", 0x220D, + "NJcy", 0x040A, + "njcy", 0x045A, + "nlarr", 0x219A, + "nlArr", 0x21CD, + "nldr", 0x2025, + "nle", 0x2270, + "nlE", 0x2270, + "nles", 0x2270, + "nlt", 0x226E, + "nltri", 0x22EA, + "nltrie", 0x22EC, + "nmid", 0x2224, + "not", 0x00AC, + "notin", 0x2209, + "npar", 0x2226, + "npr", 0x2280, + "npre", 0x22E0, + "nrarr", 0x219B, + "nrArr", 0x21CF, + "nrtri", 0x22EB, + "nrtrie", 0x22ED, + "nsc", 0x2281, + "nsce", 0x22E1, + "nsim", 0x2241, + "nsime", 0x2244, + "nsmid", 0xE2AA, + "nspar", 0x2226, + "nsub", 0x2284, + "nsube", 0x2288, + "nsubE", 0x2288, + "nsup", 0x2285, + "nsupe", 0x2289, + "nsupE", 0x2289, + "Ntilde", 0x00D1, + "ntilde", 0x00F1, + "nu", 0x03BD, + "num", 0x0023, + "numero", 0x2116, + "numsp", 0x2007, + "nvdash", 0x22AC, + "nvDash", 0x22AD, + "nVdash", 0x22AE, + "nVDash", 0x22AF, + "nwarr", 0x2196, + NULL, 0 +}; + +static NameId namesO[]={ + "Oacgr", 0x038C, + "oacgr", 0x03CC, + "Oacute", 0x00D3, + "oacute", 0x00F3, + "oast", 0x229B, + "ocir", 0x229A, + "Ocirc", 0x00D4, + "ocirc", 0x00F4, + "Ocy", 0x041E, + "ocy", 0x043E, + "odash", 0x229D, + "Odblac", 0x0150, + "odblac", 0x0151, + "odot", 0x2299, + "OElig", 0x0152, + "oelig", 0x0153, + "ogon", 0x02DB, + "Ogr", 0x039F, + "ogr", 0x03BF, + "Ograve", 0x00D2, + "ograve", 0x00F2, + "OHacgr", 0x038F, + "ohacgr", 0x03CE, + "OHgr", 0x03A9, + "ohgr", 0x03C9, + "ohm", 0x2126, + "olarr", 0x21BA, + "Omacr", 0x014C, + "omacr", 0x014D, + "Omega", 0x03A9, + "omega", 0x03C9, + "ominus", 0x2296, + "oplus", 0x2295, + "or", 0x2228, + "orarr", 0x21BB, + "order", 0x2134, + "ordf", 0x00AA, + "ordm", 0x00BA, + "oS", 0x24C8, + "Oslash", 0x00D8, + "oslash", 0x00F8, + "osol", 0x2298, + "Otilde", 0x00D5, + "otilde", 0x00F5, + "otimes", 0x2297, + "Ouml", 0x00D6, + "ouml", 0x00F6, + NULL, 0 +}; + +static NameId namesP[]={ + "par", 0x2225, + "para", 0x00B6, + "part", 0x2202, + "Pcy", 0x041F, + "pcy", 0x043F, + "percnt", 0x0025, + "period", 0x002E, + "permil", 0x2030, + "perp", 0x22A5, + "Pgr", 0x03A0, + "pgr", 0x03C0, + "PHgr", 0x03A6, + "phgr", 0x03C6, + "Phi", 0x03A6, + "phis", 0x03C6, + "phiv", 0x03D5, + "phmmat", 0x2133, + "phone", 0x260E, + "Pi", 0x03A0, + "pi", 0x03C0, + "piv", 0x03D6, + "planck", 0x210F, + "plus", 0x002B, + "plusb", 0x229E, + "plusdo", 0x2214, + "plusmn", 0x00B1, + "pound", 0x00A3, + "pr", 0x227A, + "prap", 0x227E, + "pre", 0x227C, + "prime", 0x2032, + "Prime", 0x2033, + "prnap", 0x22E8, + "prnE", 0xE2B3, + "prnsim", 0x22E8, + "prod", 0x220F, + "prop", 0x221D, + "prsim", 0x227E, + "PSgr", 0x03A8, + "psgr", 0x03C8, + "Psi", 0x03A8, + "psi", 0x03C8, + "puncsp", 0x2008, + NULL, 0 +}; + +static NameId namesQ[]={ + "quest", 0x003F, + "quot", 0x0022, + NULL, 0 +}; + +static NameId namesR[]={ + "rAarr", 0x21DB, + "Racute", 0x0154, + "racute", 0x0155, + "radic", 0x221A, + "rang", 0x3009, + "raquo", 0x00BB, + "rarr", 0x2192, + "Rarr", 0x21A0, + "rArr", 0x21D2, + "rarr2", 0x21C9, + "rarrhk", 0x21AA, + "rarrlp", 0x21AC, + "rarrtl", 0x21A3, + "rarrw", 0x219D, + "Rcaron", 0x0158, + "rcaron", 0x0159, + "Rcedil", 0x0156, + "rcedil", 0x0157, + "rceil", 0x2309, + "rcub", 0x007D, + "Rcy", 0x0420, + "rcy", 0x0440, + "rdquo", 0x201D, + "rdquor", 0x201C, + "real", 0x211C, + "rect", 0x25AD, + "reg", 0x00AE, + "rfloor", 0x230B, + "Rgr", 0x03A1, + "rgr", 0x03C1, + "rhard", 0x21C1, + "rharu", 0x21C0, + "rho", 0x03C1, + "rhov", 0x03F1, + "ring", 0x02DA, + "rlarr2", 0x21C4, + "rlhar2", 0x21CC, + "rpar", 0x0029, + "rpargt", 0xE291, + "rsh", 0x21B1, + "rsqb", 0x005D, + "rsquo", 0x2019, + "rsquor", 0x2018, + "rthree", 0x22CC, + "rtimes", 0x22CA, + "rtri", 0x25B9, + "rtrie", 0x22B5, + "rtrif", 0x25B8, + "rx", 0x211E, + NULL, 0 +}; + +static NameId namesS[]={ + "Sacute", 0x015A, + "sacute", 0x015B, + "samalg", 0x2210, + "sbsol", 0xFE68, + "sc", 0x227B, + "scap", 0x227F, + "Scaron", 0x0160, + "scaron", 0x0161, + "sccue", 0x227D, + "sce", 0x227D, + "Scedil", 0x015E, + "scedil", 0x015F, + "Scirc", 0x015C, + "scirc", 0x015D, + "scnap", 0x22E9, + "scnE", 0xE2B5, + "scnsim", 0x22E9, + "scsim", 0x227F, + "Scy", 0x0421, + "scy", 0x0441, + "sdot", 0x22C5, + "sdotb", 0x22A1, + "sect", 0x00A7, + "semi", 0x003B, + "setmn", 0x2216, + "sext", 0x2736, + "sfgr", 0x03C2, + "sfrown", 0x2322, + "Sgr", 0x03A3, + "sgr", 0x03C3, + "sharp", 0x266F, + "SHCHcy", 0x0429, + "shchcy", 0x0449, + "SHcy", 0x0428, + "shcy", 0x0448, + "shy", 0x00AD, + "Sigma", 0x03A3, + "sigma", 0x03C3, + "sigmav", 0x03C2, + "sim", 0x223C, + "sime", 0x2243, + "smid", 0xE301, + "smile", 0x2323, + "SOFTcy", 0x042C, + "softcy", 0x044C, + "sol", 0x002F, + "spades", 0x2660, + "spar", 0x2225, + "sqcap", 0x2293, + "sqcup", 0x2294, + "sqsub", 0x228F, + "sqsube", 0x2291, + "sqsup", 0x2290, + "sqsupe", 0x2292, + "squ", 0x25A1, + "square", 0x25A1, + "squf", 0x25AA, + "ssetmn", 0x2216, + "ssmile", 0x2323, + "sstarf", 0x22C6, + "star", 0x22C6, + "starf", 0x2605, + "sub", 0x2282, + "Sub", 0x22D0, + "sube", 0x2286, + "subE", 0x2286, + "subne", 0x228A, + "subnE", 0x228A, + "sum", 0x2211, + "sung", 0x2669, + "sup", 0x2283, + "Sup", 0x22D1, + "sup1", 0x00B9, + "sup2", 0x00B2, + "sup3", 0x00B3, + "supe", 0x2287, + "supE", 0x2287, + "supne", 0x228B, + "supnE", 0x228B, + "szlig", 0x00DF, + NULL, 0 +}; + +static NameId namesT[]={ + "target", 0x2316, + "tau", 0x03C4, + "Tcaron", 0x0164, + "tcaron", 0x0165, + "Tcedil", 0x0162, + "tcedil", 0x0163, + "Tcy", 0x0422, + "tcy", 0x0442, + "tdot", 0x20DB, + "telrec", 0x2315, + "Tgr", 0x03A4, + "tgr", 0x03C4, + "there4", 0x2234, + "Theta", 0x0398, + "thetas", 0x03B8, + "thetav", 0x03D1, + "THgr", 0x0398, + "thgr", 0x03B8, + "thinsp", 0x2009, + "thkap", 0x2248, + "thksim", 0x223C, + "THORN", 0x00DE, + "thorn", 0x00FE, + "tilde", 0x02DC, + "times", 0x00D7, + "timesb", 0x22A0, + "top", 0x22A4, + "tprime", 0x2034, + "trade", 0x2122, + "trie", 0x225C, + "TScy", 0x0426, + "tscy", 0x0446, + "TSHcy", 0x040B, + "tshcy", 0x045B, + "Tstrok", 0x0166, + "tstrok", 0x0167, + "twixt", 0x226C, + NULL, 0 }; +static NameId namesU[]={ + "Uacgr", 0x038E, + "uacgr", 0x03CD, + "Uacute", 0x00DA, + "uacute", 0x00FA, + "uarr", 0x2191, + "uArr", 0x21D1, + "uarr2", 0x21C8, + "Ubrcy", 0x040E, + "ubrcy", 0x045E, + "Ubreve", 0x016C, + "ubreve", 0x016D, + "Ucirc", 0x00DB, + "ucirc", 0x00FB, + "Ucy", 0x0423, + "ucy", 0x0443, + "Udblac", 0x0170, + "udblac", 0x0171, + "udiagr", 0x03B0, + "Udigr", 0x03AB, + "udigr", 0x03CB, + "Ugr", 0x03A5, + "ugr", 0x03C5, + "Ugrave", 0x00D9, + "ugrave", 0x00F9, + "uharl", 0x21BF, + "uharr", 0x21BE, + "uhblk", 0x2580, + "ulcorn", 0x231C, + "ulcrop", 0x230F, + "Umacr", 0x016A, + "umacr", 0x016B, + "uml", 0x00A8, + "Uogon", 0x0172, + "uogon", 0x0173, + "uplus", 0x228E, + "upsi", 0x03C5, + "Upsi", 0x03D2, + "urcorn", 0x231D, + "urcrop", 0x230E, + "Uring", 0x016E, + "uring", 0x016F, + "Utilde", 0x0168, + "utilde", 0x0169, + "utri", 0x25B5, + "utrif", 0x25B4, + "Uuml", 0x00DC, + "uuml", 0x00FC, + NULL, 0 +}; + +static NameId namesV[]={ + "varr", 0x2195, + "vArr", 0x21D5, + "Vcy", 0x0412, + "vcy", 0x0432, + "vdash", 0x22A2, + "vDash", 0x22A8, + "Vdash", 0x22A9, + "veebar", 0x22BB, + "vellip", 0x22EE, + "verbar", 0x007C, + "Verbar", 0x2016, + "vltri", 0x22B2, + "vprime", 0x2032, + "vprop", 0x221D, + "vrtri", 0x22B3, + "vsubne", 0x228A, + "vsubnE", 0xE2B8, + "vsupne", 0x228B, + "vsupnE", 0x228B, + "Vvdash", 0x22AA, + NULL, 0 +}; + +static NameId namesW[]={ + "Wcirc", 0x0174, + "wcirc", 0x0175, + "wedgeq", 0x2259, + "weierp", 0x2118, + "wreath", 0x2240, + NULL, 0 +}; + +static NameId namesX[]={ + "xcirc", 0x25CB, + "xdtri", 0x25BD, + "Xgr", 0x039E, + "xgr", 0x03BE, + "xharr", 0x2194, + "xhArr", 0x2194, + "Xi", 0x039E, + "xi", 0x03BE, + "xlArr", 0x21D0, + "xrArr", 0x21D2, + "xutri", 0x25B3, + NULL, 0 +}; + +static NameId namesY[]={ + "Yacute", 0x00DD, + "yacute", 0x00FD, + "YAcy", 0x042F, + "yacy", 0x044F, + "Ycirc", 0x0176, + "ycirc", 0x0177, + "Ycy", 0x042B, + "ycy", 0x044B, + "yen", 0x00A5, + "YIcy", 0x0407, + "yicy", 0x0457, + "YUcy", 0x042E, + "yucy", 0x044E, + "yuml", 0x00FF, + "Yuml", 0x0178, + NULL, 0 +}; + +static NameId namesZ[]={ + "Zacute", 0x0179, + "zacute", 0x017A, + "Zcaron", 0x017D, + "zcaron", 0x017E, + "Zcy", 0x0417, + "zcy", 0x0437, + "Zdot", 0x017B, + "zdot", 0x017C, + "zeta", 0x03B6, + "Zgr", 0x0396, + "zgr", 0x03B6, + "ZHcy", 0x0416, + "zhcy", 0x0436, + NULL, 0 +}; + +// @todo@ order namesTable and names? by frequency +static NameId* namesTable[] = { + namesA, namesB, namesC, namesD, namesE, namesF, namesG, namesH, namesI, + namesJ, namesK, namesL, namesM, namesN, namesO, namesP, namesQ, namesR, + namesS, namesT, namesU, namesV, namesW, namesX, namesY, namesZ, NULL +}; + +#ifdef OLD int Html::namedEntity(unsigned char *p, int length) { int i; @@ -555,3 +1606,21 @@ error("unrecognized character entity"); return 0; } +#endif + +int Html::namedEntity(unsigned char *p, int length) +{ + int tableIndex = tolower(*p) - 'a'; + if (tableIndex >= 0 && tableIndex < 26) { + NameId* names = namesTable[tableIndex]; + int i; + + for (i = 0; names[i].name; i++){ + if (strncmp(names[i].name, (char *)p, length) == 0){ + return names[i].value; + } + } + } + error("unrecognized character entity \"%.*s\"", length, p); + return 0; +} diff -uNr gdc-0.9/d/root/identifier.c gdc-0.10/d/root/identifier.c --- gdc-0.9/d/root/identifier.c 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/identifier.c 2005-01-09 01:40:20.000000000 +0100 @@ -19,6 +19,7 @@ //printf("Identifier('%s', %d)\n", string, value); this->string = string; this->value = value; + this->len = strlen(string); } unsigned Identifier::hashCode() @@ -28,12 +29,12 @@ int Identifier::equals(Object *o) { - return this == o || strcmp(string,o->toChars()) == 0; + return this == o || memcmp(string,o->toChars(),len+1) == 0; } int Identifier::compare(Object *o) { - return strcmp(string,o->toChars()); + return memcmp(string, o->toChars(), len + 1); } char *Identifier::toChars() diff -uNr gdc-0.9/d/root/identifier.h gdc-0.10/d/root/identifier.h --- gdc-0.9/d/root/identifier.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/identifier.h 2005-01-09 01:40:20.000000000 +0100 @@ -20,6 +20,7 @@ { int value; const char *string; + unsigned len; Identifier(const char *string, int value); int equals(Object *o); diff -uNr gdc-0.9/d/root/idgen.c gdc-0.10/d/root/idgen.c --- gdc-0.9/d/root/idgen.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/idgen.c 2005-01-09 01:40:20.000000000 +0100 @@ -61,6 +61,7 @@ { "TypeInfo" }, { "TypeInfo_Class" }, + { "TypeInfo_Struct" }, { "TypeInfo_Typedef" }, { "_arguments" }, { "_argptr" }, @@ -156,6 +157,9 @@ // For pragma's { "msg" }, + // For toHash + { "tohash", "toHash" }, + // Special functions { "alloca" }, }; diff -uNr gdc-0.9/d/root/init.h gdc-0.10/d/root/init.h --- gdc-0.9/d/root/init.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/init.h 2005-01-09 01:40:20.000000000 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2002 by Digital Mars +// Copyright (c) 1999-2004 by Digital Mars // All Rights Reserved // written by Walter Bright // www.digitalmars.com diff -uNr gdc-0.9/d/root/lexer.c gdc-0.10/d/root/lexer.c --- gdc-0.9/d/root/lexer.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/lexer.c 2005-01-09 01:40:20.000000000 +0100 @@ -2128,6 +2128,7 @@ Token::tochars[TOKdotexp] = "dotexp"; Token::tochars[TOKdotti] = "dotti"; Token::tochars[TOKdotvar] = "dotvar"; + Token::tochars[TOKdottype] = "dottype"; Token::tochars[TOKsymoff] = "symoff"; Token::tochars[TOKtypedot] = "typedot"; Token::tochars[TOKarraylength] = "arraylength"; diff -uNr gdc-0.9/d/root/mangle.c gdc-0.10/d/root/mangle.c --- gdc-0.9/d/root/mangle.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/mangle.c 2005-01-09 01:40:20.000000000 +0100 @@ -137,6 +137,7 @@ * names for them. */ if (ident == Id::TypeInfo || + ident == Id::TypeInfo_Struct || ident == Id::TypeInfo_Class || ident == Id::TypeInfo_Typedef || ident == Id::Exception || diff -uNr gdc-0.9/d/root/mars.c gdc-0.10/d/root/mars.c --- gdc-0.9/d/root/mars.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/mars.c 2005-01-09 01:40:20.000000000 +0100 @@ -49,7 +49,7 @@ copyright = "Copyright (c) 1999-2004 by Digital Mars"; written = "written by Walter Bright"; - version = "v0.109"; + version = "v0.110"; global.structalign = 8; memset(¶ms, 0, sizeof(Param)); @@ -570,6 +570,8 @@ printf("code %s\n", m->toChars()); m->genobjfile(); // m->gensymfile(); + if (global.errors) + m->deleteObjFile(); } backend_term(); diff -uNr gdc-0.9/d/root/mars.h gdc-0.10/d/root/mars.h --- gdc-0.9/d/root/mars.h 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/mars.h 2005-01-09 01:40:20.000000000 +0100 @@ -57,6 +57,8 @@ unsigned versionlevel; // version level Array *versionids; // version identifiers + bool dump_source; + // Hidden debug switches char debuga; char debugb; @@ -167,7 +169,7 @@ Loc(int x) { - linnum = 0; + linnum = x; filename = NULL; } diff -uNr gdc-0.9/d/root/module.c gdc-0.10/d/root/module.c --- gdc-0.9/d/root/module.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/module.c 2005-01-09 01:40:20.000000000 +0100 @@ -29,6 +29,10 @@ #define MARS 1 #include "html.h" +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + ClassDeclaration *Module::moduleinfo; DsymbolTable *Module::modules; @@ -49,7 +53,7 @@ FileName *objfilename; FileName *symfilename; - //printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); +// printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars()); this->arg = filename; md = NULL; errors = 0; @@ -57,6 +61,9 @@ isHtml = 0; needmoduleinfo = 0; insearch = 0; + searchCacheIdent = NULL; + searchCacheSymbol = NULL; + searchCacheFlags = 0; semanticdone = 0; decldefs = NULL; vmoduleinfo = NULL; @@ -119,10 +126,6 @@ return "module"; } -#ifdef IN_GCC -extern void d_gcc_magic_module(Module *m); -#endif - Module *Module::load(Loc loc, Array *packages, Identifier *ident) { Module *m; char *filename; @@ -216,7 +219,7 @@ (((unsigned char *)p)[0] << 24); } -void Module::parse() +void Module::parse(bool dump_source) { char *srcname; unsigned char *buf; unsigned buflen; @@ -387,6 +390,13 @@ } } +#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 /* IN_GCC */ if (isHtml) { OutBuffer *dbuf = new OutBuffer(); @@ -394,6 +404,12 @@ 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); members = p.parseModule(); @@ -431,9 +447,10 @@ void Module::semantic() { int i; - //printf("Module::semantic('%s'): parent = %p\n", toChars(), parent); if (semanticdone) return; + + //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); semanticdone = 1; // Note that modules get their own scope, from scratch. @@ -464,6 +481,7 @@ { Dsymbol *s; s = (Dsymbol *)members->data[i]; + //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); s->semantic(sc); runDeferredSemantic(); @@ -471,12 +489,13 @@ sc = sc->pop(); sc->pop(); - //printf("-Module::semantic('%s'): parent = %p\n", toChars(), parent); + //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); } void Module::semantic2() { int i; + assert(!deferred.dim); //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); if (semanticdone >= 2) return; @@ -594,11 +613,17 @@ Dsymbol *s; if (insearch) s = NULL; + else if (searchCacheIdent == ident && searchCacheFlags == flags) + s = searchCacheSymbol; else { insearch = 1; s = ScopeDsymbol::search(ident, flags); insearch = 0; + + searchCacheIdent = ident; + searchCacheSymbol = s; + searchCacheFlags = flags; } return s; } @@ -609,6 +634,16 @@ void Module::addDeferredSemantic(Dsymbol *s) { + // Don't add it if it is already there + for (int i = 0; i < deferred.dim; i++) + { + Dsymbol *sd = (Dsymbol *)deferred.data[i]; + + if (sd == s) + return; + } + +// printf("Module::addDeferredSemantic('%s')\n", s->toChars()); deferred.push(s); } @@ -618,12 +653,12 @@ void Module::runDeferredSemantic() { - int len; - int newlen; + size_t len; static int nested; if (nested) return; +// if (deferred.dim) printf("Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); nested++; do @@ -632,18 +667,27 @@ if (!len) break; + Dsymbol **todo; + Dsymbol *tmp; + if (len == 1) + { + todo = &tmp; + } + else + { + todo = (Dsymbol **)alloca(len * sizeof(Dsymbol *)); + assert(todo); + } + memcpy(todo, deferred.data, len * sizeof(Dsymbol *)); + deferred.setDim(0); + for (int i = 0; i < len; i++) { - Dsymbol *s = (Dsymbol *)deferred.data[i]; + Dsymbol *s = todo[i]; s->semantic(NULL); } - - newlen = deferred.dim - len; - memmove(deferred.data, deferred.data + len, - newlen * sizeof(deferred.data[0])); - deferred.setDim(newlen); - } while (newlen < len); + } while (deferred.dim < len); // while making progress nested--; } diff -uNr gdc-0.9/d/root/module.h gdc-0.10/d/root/module.h --- gdc-0.9/d/root/module.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/module.h 2005-01-09 01:40:20.000000000 +0100 @@ -59,7 +59,12 @@ unsigned errors; // if any errors in file int isHtml; // if it is an HTML file int needmoduleinfo; + int insearch; + Identifier *searchCacheIdent; + Dsymbol *searchCacheSymbol; // cached value of search + int searchCacheFlags; // cached flags + int semanticdone; // has semantic() been done? Module *importedFrom; // module from command line we're imported from, // i.e. a module that will be taken all the @@ -85,7 +90,7 @@ char *kind(); void read(); // read file - void parse(); // syntactic parse + void parse(bool dump_source = false); // syntactic parse void semantic(); // semantic analysis void semantic2(); // pass 2 semantic analysis void semantic3(); // pass 3 semantic analysis diff -uNr gdc-0.9/d/root/mtype.c gdc-0.10/d/root/mtype.c --- gdc-0.9/d/root/mtype.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/mtype.c 2005-01-09 01:40:20.000000000 +0100 @@ -88,6 +88,7 @@ ClassDeclaration *Type::typeinfo; ClassDeclaration *Type::typeinfoclass; +ClassDeclaration *Type::typeinfostruct; ClassDeclaration *Type::typeinfotypedef; Type *Type::basic[TMAX]; @@ -219,15 +220,18 @@ d_uns64 Type::size() { - Loc loc; + return size(0); +} +d_uns64 Type::size(Loc loc) +{ error(loc, "no size for type %s", toChars()); return 0; } unsigned Type::alignsize() { - return size(); + return size(0); } Type *Type::semantic(Loc loc, Scope *sc) @@ -476,13 +480,13 @@ if (ident == Id::__sizeof) { - e = new IntegerExp(loc, size(), Type::tsize_t); + e = new IntegerExp(loc, size(loc), Type::tsize_t); } else if (ident == Id::size) { if (!global.params.useDeprecated) error(loc, ".size property is deprecated, use .sizeof"); - e = new IntegerExp(loc, size(), Type::tsize_t); + e = new IntegerExp(loc, size(loc), Type::tsize_t); } else if (ident == Id::alignof) { @@ -573,7 +577,7 @@ fflush(stdout); global.errors++; - fatal(); + //fatal(); } Identifier *Type::getTypeInfoIdent(int internal) @@ -773,7 +777,7 @@ } } -d_uns64 TypeBasic::size() +d_uns64 TypeBasic::size(Loc loc) { unsigned size; //printf("TypeBasic::size()\n"); @@ -833,7 +837,7 @@ break; default: - sz = size(); + sz = size(0); break; } return sz; @@ -1339,7 +1343,7 @@ Expression *ec; FuncDeclaration *fd; Array *arguments; - int size = next->size(); + int size = next->size(e->loc); char *nm; static char *name[2][2] = { { "_adReverse", "_adDup" }, { "_adReverseBit", "_adDupBit" } }; @@ -1368,7 +1372,7 @@ arguments = new Array(); arguments->push(e); arguments->push(n->ty == Tsarray ? n->getTypeInfo(sc) // don't convert to dynamic array - : n->getInternalTypeInfo()); + : n->getInternalTypeInfo(sc)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } @@ -1447,11 +1451,11 @@ return t; } -d_uns64 TypeSArray::size() +d_uns64 TypeSArray::size(Loc loc) { integer_t sz; if (!dim) - return Type::size(); + return Type::size(loc); sz = dim->toInteger(); if (next->toBasetype()->ty == Tbit) // if array of bits { @@ -1471,7 +1475,7 @@ return sz; Loverflow: - error(0, "index %lld overflow for static array", sz); + error(loc, "index %lld overflow for static array", sz); return 1; } @@ -1509,7 +1513,7 @@ /* Only do this for types that don't need to have semantic() * run on them for the size, since they may be forward referenced. */ - n = next->size(); + n = next->size(loc); n2 = n * d2; if ((int)n2 < 0) goto Loverflow; @@ -1635,7 +1639,7 @@ return t; } -d_uns64 TypeDArray::size() +d_uns64 TypeDArray::size(Loc loc) { //printf("TypeDArray::size()\n"); return PTRSIZE * 2; @@ -1649,17 +1653,21 @@ } Type *TypeDArray::semantic(Loc loc, Scope *sc) -{ - next = next->semantic(loc,sc); - switch (next->ty) +{ Type *tn = next; + + tn = next->semantic(loc,sc); + switch (tn->ty) { case Tfunction: case Tnone: - error(loc, "can't have array of %s", next->toChars()); + error(loc, "can't have array of %s", tn->toChars()); break; } - if (next->isauto()) - error(loc, "cannot have array of auto %s", next->toChars()); + if (tn->isauto()) + error(loc, "cannot have array of auto %s", tn->toChars()); + if (next != tn) + //deco = NULL; // redo + return tn->arrayOf(); return merge(); } @@ -1768,7 +1776,7 @@ return t; } -d_uns64 TypeAArray::size() +d_uns64 TypeAArray::size(Loc loc) { return PTRSIZE * 2; } @@ -1869,7 +1877,7 @@ FuncDeclaration *fd; Array *arguments; char aakeys[7+3*sizeof(int)+1]; - int size = key->size(); + int size = key->size(e->loc); assert(size); #if 0 @@ -1900,8 +1908,8 @@ ec = new VarExp(0, fd); arguments = new Array(); arguments->push(e); - arguments->push(new IntegerExp(0, key->size(), Type::tint32)); - arguments->push(new IntegerExp(0, next->size(), Type::tint32)); + arguments->push(new IntegerExp(0, key->size(e->loc), Type::tint32)); + arguments->push(new IntegerExp(0, next->size(e->loc), Type::tint32)); e = new CallExp(e->loc, ec, arguments); e->type = next->arrayOf(); } @@ -1915,7 +1923,7 @@ ec = new VarExp(0, fd); arguments = new Array(); arguments->push(e->addressOf()); - arguments->push(key->getInternalTypeInfo()); + arguments->push(key->getInternalTypeInfo(sc)); e = new CallExp(e->loc, ec, arguments); e->type = this; } @@ -1985,7 +1993,7 @@ } -d_uns64 TypePointer::size() +d_uns64 TypePointer::size(Loc loc) { return PTRSIZE; } @@ -2073,7 +2081,7 @@ return t; } -d_uns64 TypeReference::size() +d_uns64 TypeReference::size(Loc loc) { return PTRSIZE; } @@ -2180,9 +2188,15 @@ goto Lnotcovariant; if (t1->linkage != t2->linkage) goto Lnotcovariant; - if (t1->next->ty != Tclass || t2->next->ty != Tclass) + + Type *t1n = t1->next; + Type *t2n = t2->next; + + if (t1n->equals(t2n)) + goto Lcovariant; + if (t1n->ty != Tclass || t2n->ty != Tclass) goto Lnotcovariant; - if (t1->next->implicitConvTo(t2->next)) + if (t1n->implicitConvTo(t2n)) goto Lcovariant; goto Lnotcovariant; } @@ -2453,7 +2467,7 @@ return merge(); } -d_uns64 TypeDelegate::size() +d_uns64 TypeDelegate::size(Loc loc) { return PTRSIZE * 2; } @@ -2554,9 +2568,9 @@ } } -d_uns64 TypeQualified::size() +d_uns64 TypeQualified::size(Loc loc) { - error(loc, "size of type %s is not known", toChars()); + error(this->loc, "size of type %s is not known", toChars()); return 1; } @@ -2851,6 +2865,7 @@ error(loc, "%s is used as a type", toChars()); t = tvoid; } + //t->print(); return t; } @@ -3063,14 +3078,14 @@ return merge(); } -d_uns64 TypeEnum::size() +d_uns64 TypeEnum::size(Loc loc) { if (!sym->memtype) { - error(0, "enum %s is forward referenced", sym->toChars()); + error(loc, "enum %s is forward referenced", sym->toChars()); return 4; } - return sym->memtype->size(); + return sym->memtype->size(loc); } unsigned TypeEnum::alignsize() @@ -3229,9 +3244,9 @@ return merge(); } -d_uns64 TypeTypedef::size() +d_uns64 TypeTypedef::size(Loc loc) { - return sym->basetype->size(); + return sym->basetype->size(loc); } unsigned TypeTypedef::alignsize() @@ -3402,15 +3417,15 @@ return merge(); } -d_uns64 TypeStruct::size() +d_uns64 TypeStruct::size(Loc loc) { - return sym->size(); + return sym->size(loc); } unsigned TypeStruct::alignsize() { unsigned sz; - sym->size(); // give error for forward references + sym->size(0); // give error for forward references sz = sym->alignsize; if (sz > sym->structalign) sz = sym->structalign; @@ -3564,7 +3579,7 @@ unsigned TypeStruct::memalign(unsigned salign) { - sym->size(); // give error for forward references + sym->size(0); // give error for forward references return sym->structalign; } @@ -3614,7 +3629,7 @@ return merge(); } -d_uns64 TypeClass::size() +d_uns64 TypeClass::size(Loc loc) { return PTRSIZE; } diff -uNr gdc-0.9/d/root/mtype.h gdc-0.10/d/root/mtype.h --- gdc-0.9/d/root/mtype.h 2004-10-26 02:41:27.000000000 +0200 +++ gdc-0.10/d/root/mtype.h 2005-01-09 01:40:20.000000000 +0100 @@ -156,6 +156,7 @@ static ClassDeclaration *typeinfo; static ClassDeclaration *typeinfoclass; + static ClassDeclaration *typeinfostruct; static ClassDeclaration *typeinfotypedef; static Type *basic[TMAX]; @@ -175,7 +176,8 @@ int covariant(Type *t); char *toChars(); static void init(); - virtual d_uns64 size(); + d_uns64 size(); + virtual d_uns64 size(Loc loc); virtual unsigned alignsize(); virtual Type *semantic(Loc loc, Scope *sc); virtual void toDecoBuffer(OutBuffer *buf); @@ -211,7 +213,7 @@ Identifier *getTypeInfoIdent(int internal); virtual MATCH deduceType(Type *tparam, Array *parameters, Array *atypes); virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); - Expression *getInternalTypeInfo(); + Expression *getInternalTypeInfo(Scope *sc); Expression *getTypeInfo(Scope *sc); virtual TypeInfoDeclaration *getTypeInfoDeclaration(); virtual int builtinTypeInfo(); @@ -236,7 +238,7 @@ TypeBasic(TY ty); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Expression *getProperty(Loc loc, Identifier *ident); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); @@ -274,7 +276,7 @@ TypeSArray(Type *t, Expression *dim); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); @@ -297,7 +299,7 @@ { TypeDArray(Type *t); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); @@ -320,7 +322,7 @@ TypeAArray(Type *t, Type *index); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); Type *semantic(Loc loc, Scope *sc); void toDecoBuffer(OutBuffer *buf); void toPrettyBracket(OutBuffer *buf); @@ -340,7 +342,7 @@ TypePointer(Type *t); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); int implicitConvTo(Type *to); int isscalar(); @@ -354,7 +356,7 @@ { TypeReference(Type *t); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); Expression *defaultInit(); @@ -393,7 +395,7 @@ TypeDelegate(Type *t); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); - d_uns64 size(); + d_uns64 size(Loc loc); void toCBuffer2(OutBuffer *buf, Identifier *ident); Expression *defaultInit(); int isZeroInit(); @@ -411,7 +413,7 @@ void syntaxCopyHelper(TypeQualified *t); void addIdent(Identifier *ident); void toCBuffer2Helper(OutBuffer *buf, Identifier *ident); - d_uns64 size(); + d_uns64 size(Loc loc); void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym, Expression **pe, Type **pt, Dsymbol **ps); }; @@ -462,7 +464,7 @@ StructDeclaration *sym; TypeStruct(StructDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *syntaxCopy(); @@ -477,6 +479,7 @@ int isZeroInit(); dt_t **toDt(dt_t **pdt); MATCH deduceType(Type *tparam, Array *parameters, Array *atypes); + TypeInfoDeclaration *getTypeInfoDeclaration(); type *toCtype(); }; @@ -486,7 +489,7 @@ EnumDeclaration *sym; TypeEnum(EnumDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *semantic(Loc loc, Scope *sc); @@ -515,7 +518,7 @@ TypeTypedef(TypedefDeclaration *sym); Type *syntaxCopy(); - d_uns64 size(); + d_uns64 size(Loc loc); unsigned alignsize(); char *toChars(); Type *semantic(Loc loc, Scope *sc); @@ -547,7 +550,7 @@ ClassDeclaration *sym; TypeClass(ClassDeclaration *sym); - d_uns64 size(); + d_uns64 size(Loc loc); char *toChars(); Type *syntaxCopy(); Type *semantic(Loc loc, Scope *sc); diff -uNr gdc-0.9/d/root/parse.c gdc-0.10/d/root/parse.c --- gdc-0.9/d/root/parse.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/parse.c 2005-01-09 01:40:20.000000000 +0100 @@ -485,7 +485,7 @@ continue; default: - error("Declaration expected, not '%s'\n",token.toChars()); + error("Declaration expected, not '%s'",token.toChars()); Lerror: while (token.value != TOKsemicolon && token.value != TOKeof) nextToken(); @@ -1886,7 +1886,7 @@ error("multiple declarations must have the same type, not %s and %s", tfirst->toChars(), t->toChars()); if (!ident) - error("no identifier for declarator"); + error("no identifier for declarator %s", t->toChars()); if (tok == TOKtypedef || tok == TOKalias) { Declaration *v; @@ -2490,7 +2490,7 @@ tb = parseBasicType(); at = parseDeclarator(tb, &ai); if (!ai) - error("no identifier for declarator"); + error("no identifier for declarator %s", at->toChars()); a = new Argument(inout, at, ai, NULL); arguments->push(a); if (token.value == TOKcomma) diff -uNr gdc-0.9/d/root/statement.c gdc-0.10/d/root/statement.c --- gdc-0.9/d/root/statement.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/statement.c 2005-01-09 01:40:20.000000000 +0100 @@ -597,6 +597,7 @@ Type *tnv = NULL; aggr = aggr->semantic(sc); + aggr = resolveProperties(sc, aggr); sym = new ScopeDsymbol(); sym->parent = sc->scopesym; @@ -1147,6 +1148,7 @@ Statement *SwitchStatement::semantic(Scope *sc) { condition = condition->semantic(sc); + condition = resolveProperties(sc, condition); if (condition->type->isString()) { // If it's not an array, cast it to one @@ -1977,6 +1979,7 @@ if (sc->incontract) error("Throw statements cannot be in contracts"); exp = exp->semantic(sc); + exp = resolveProperties(sc, exp); if (!exp->type->isClassHandle()) error("can only throw class objects, not type %s", exp->type->toChars()); return this; diff -uNr gdc-0.9/d/root/struct.c gdc-0.10/d/root/struct.c --- gdc-0.9/d/root/struct.c 2004-12-18 21:22:55.000000000 +0100 +++ gdc-0.10/d/root/struct.c 2005-01-09 01:40:20.000000000 +0100 @@ -35,6 +35,7 @@ stag = NULL; sinit = NULL; + scope = NULL; } void AggregateDeclaration::semantic2(Scope *sc) @@ -83,13 +84,15 @@ } } -unsigned AggregateDeclaration::size() +unsigned AggregateDeclaration::size(Loc loc) { //printf("AggregateDeclaration::size() = %d\n", structsize); if (!members) - error("unknown size"); - if (!sizeok) - error("no size yet for forward reference"); + error(loc, "unknown size"); + if (sizeok != 1) + { error(loc, "no size yet for forward reference"); + //*(char*)0=0; + } return structsize; } @@ -138,7 +141,19 @@ unsigned memalignsize; // size of member for alignment purposes unsigned xalign; // alignment boundaries - memsize = v->type->size(); + // Check for forward referenced types which will fail the size() call + Type *t = v->type->toBasetype(); + if (t->ty == Tstruct /*&& isStructDeclaration()*/) + { TypeStruct *ts = (TypeStruct *)t; + + if (ts->sym->sizeok != 1) + { + sizeok = 2; // cannot finish; flag as forward referenced + return; + } + } + + memsize = v->type->size(loc); memalignsize = v->type->alignsize(); xalign = v->type->memalign(sc->structalign); alignmember(xalign, memalignsize, &sc->offset); @@ -183,104 +198,82 @@ Scope *sc2; //printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars()); - if (!type) - type = new TypeStruct(this); + assert(type); if (!members) // if forward reference return; - if (!symtab) // if not already done semantic() - { - parent = sc->parent; - handle = type->pointerTo(); - symtab = new DsymbolTable(); - structalign = sc->structalign; - if (!isAnonymous()) - { - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); - s->addMember(this); - } - } - sc2 = sc->push(this); - sc2->parent = this; - if (isUnionDeclaration()) - sc2->inunion = 1; - sc2->stc &= ~(STCauto | STCstatic); - int members_dim = members->dim; - for (i = 0; i < members_dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - s->semantic(sc2); - if (isUnionDeclaration()) - sc2->offset = 0; - } - sc2->pop(); - // 0 sized struct's are set to 1 byte - if (structsize == 0) - { - structsize = 1; - alignsize = 1; - } - sizeok = 1; + if (symtab) + { if (!scope) + return; // semantic() already completed } + else + symtab = new DsymbolTable(); - AggregateDeclaration *sd; + Scope *scx = NULL; + if (scope) + { sc = scope; + scx = scope; // save so we don't make redundant copies + scope = NULL; + } -#if 0 - if (isAnonymous()) - { // Anonymous structures aren't independent, all their members are - // added to the enclosing struct. - unsigned offset; - int isunionsave; + parent = sc->parent; + handle = type->pointerTo(); + structalign = sc->structalign; + assert(!isAnonymous()); - sd = isMember(); - if (!sd) + if (sizeok == 0) // if not already done the addMember step + { + for (i = 0; i < members->dim; i++) { - error("anonymous struct can only be member of an aggregate"); + Dsymbol *s = (Dsymbol *)members->data[i]; + //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); + s->addMember(this); } - else - { - // Align size of enclosing struct - sd->alignmember(structalign, alignsize, &sd->structsize); + } - // Add members to enclosing struct - for (i = 0; i < members->dim; i++) - { - Dsymbol *s = (Dsymbol *)members->data[i]; - VarDeclaration *vd = s->isVarDeclaration(); - if (vd && vd->storage_class & STCfield) - { - vd->addMember(sd); - if (!sd->isUnionDeclaration()) - vd->offset += sd->structsize; - sd->fields.push(vd); - sd->members->push(s); - } - else if (!s->isAnonymous()) - { - sd->members->push(s); - } - } + sizeok = 0; + sc2 = sc->push(this); + sc2->parent = this; + if (isUnionDeclaration()) + sc2->inunion = 1; + sc2->stc &= ~(STCauto | STCstatic); + int members_dim = members->dim; + for (i = 0; i < members_dim; i++) + { + Dsymbol *s = (Dsymbol *)members->data[i]; + s->semantic(sc2); + if (isUnionDeclaration()) + sc2->offset = 0; + if (sizeok == 2) + break; + } + sc2->pop(); - if (sd->isUnionDeclaration()) - { - if (structsize > sd->structsize) - sd->structsize = structsize; - sc->offset = 0; - } - else - { - sd->structsize += structsize; - sc->offset = sd->structsize; - } + if (sizeok == 2) + { // semantic() failed because of forward references. + // Unwind what we did, and defer it for later + fields.setDim(0); + structsize = 0; + alignsize = 0; + structalign = 0; + + scope = scx ? scx : new Scope(*sc); + scope->setNoFree(); + scope->module->addDeferredSemantic(this); + return; + } - if (sd->alignsize < alignsize) - sd->alignsize = alignsize; - } + // 0 sized struct's are set to 1 byte + if (structsize == 0) + { + structsize = 1; + alignsize = 1; } -#endif + + sizeok = 1; + + AggregateDeclaration *sd; + //printf("-StructDeclaration::semantic(this=%p, '%s')\n", this, toChars()); // Determine if struct is all zeros or not diff -uNr gdc-0.9/d/root/toobj.c gdc-0.10/d/root/toobj.c --- gdc-0.9/d/root/toobj.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/root/toobj.c 2004-12-26 17:15:05.000000000 +0100 @@ -46,6 +46,10 @@ #include "dt.h" #endif +#ifdef IN_GCC +#include "d-dmd-gcc.h" +#endif + /* ================================================================== */ // Put out instance of ModuleInfo for this Module @@ -900,6 +904,15 @@ if (isExport()) obj_export(s,0); } +#ifdef IN_GCC + else { + // This is needed for VarDeclarations in mixins that are to be + // local variables of that function. Otherwise, it would be + // enough to make a check for VarDeclaration in + // DeclarationExp::toElem. + d_gcc_emit_local_variable(this); + } +#endif } /* ================================================================== */ diff -uNr gdc-0.9/d/root/typinf.c gdc-0.10/d/root/typinf.c --- gdc-0.9/d/root/typinf.c 2004-11-23 01:03:10.000000000 +0100 +++ gdc-0.10/d/root/typinf.c 2005-01-09 01:40:20.000000000 +0100 @@ -57,7 +57,7 @@ * so we can use the custom internal ones more. */ -Expression *Type::getInternalTypeInfo() +Expression *Type::getInternalTypeInfo(Scope *sc) { TypeInfoDeclaration *tid; Expression *e; Type *t; @@ -92,7 +92,7 @@ break; } //printf("\tcalling getTypeInfo() %s\n", t->toChars()); - return t->getTypeInfo(NULL); + return t->getTypeInfo(sc); } @@ -136,6 +136,11 @@ return new TypeInfoTypedefDeclaration(this); } +TypeInfoDeclaration *TypeStruct::getTypeInfoDeclaration() +{ + return new TypeInfoStructDeclaration(this); +} + TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() { return new TypeInfoClassDeclaration(this); @@ -168,6 +173,93 @@ dtxoff(pdt, tc->sym->basetype->vtinfo->toSymbol(), 0, TYnptr); // TypeInfo for basetype } +void TypeInfoStructDeclaration::toDt(dt_t **pdt) +{ + //printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars()); + + dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Struct + dtdword(pdt, 0); // monitor + + assert(tinfo->ty == Tstruct); + + TypeStruct *tc = (TypeStruct *)tinfo; + StructDeclaration *sd = tc->sym; + + /* Put out: + * char[] name; + * uint xsize; + * uint function(void*) xtoHash; + * int function(void*,void*) xopEquals; + * int function(void*,void*) xopCmp; + */ + + char *name = sd->toPrettyChars(); + size_t namelen = strlen(name); + dtdword(pdt, namelen); + dtabytes(pdt, TYnptr, 0, namelen + 1, name); + + dtdword(pdt, sd->structsize); // xsize + + FuncDeclaration *fd; + FuncDeclaration *fdx; + TypeFunction *tf; + Type *ta; + + static TypeFunction *tftohash; + + if (!tftohash) + { + Scope sc; + tftohash = new TypeFunction(NULL, Type::tuns32, 0, LINKd); + tftohash = (TypeFunction *)tftohash->semantic(0, &sc); + } + + TypeFunction *tfeq; + { + Scope sc; + Array *arguments = new Array; + Argument *arg = new Argument(In, tc->pointerTo(), NULL, NULL); + + arguments->push(arg); + tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd); + tfeq = (TypeFunction *)tfeq->semantic(0, &sc); + } + + fdx = search_function(sd, Id::tohash); + if (fdx) + { fd = fdx->overloadExactMatch(tftohash); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) uint toHash()"); + } + else + dtdword(pdt, 0); + + fdx = search_function(sd, Id::eq); + if (fdx) + { fd = fdx->overloadExactMatch(tfeq); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars()); + } + else + dtdword(pdt, 0); + + fdx = search_function(sd, Id::cmp); + if (fdx) + { + fd = fdx->overloadExactMatch(tfeq); + if (fd) + dtxoff(pdt, fd->toSymbol(), 0, TYnptr); + else + fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars()); + } + else + dtdword(pdt, 0); +} + void TypeInfoClassDeclaration::toDt(dt_t **pdt) { //printf("TypeInfoClassDeclaration::toDt()\n");