Changeset 311
- Timestamp:
- 02/06/07 01:11:12 (2 years ago)
- Files:
-
- branches/rebuild/rebuild/Makefile (modified) (2 diffs)
- branches/rebuild/rebuild/attrib.c (modified) (4 diffs)
- branches/rebuild/rebuild/attrib.h (modified) (1 diff)
- branches/rebuild/rebuild/cast.c (modified) (3 diffs)
- branches/rebuild/rebuild/cond.c (modified) (1 diff)
- branches/rebuild/rebuild/constfold.c (modified) (1 diff)
- branches/rebuild/rebuild/dsymbol.c (modified) (4 diffs)
- branches/rebuild/rebuild/dsymbol.h (modified) (2 diffs)
- branches/rebuild/rebuild/expression.c (modified) (11 diffs)
- branches/rebuild/rebuild/expression.h (modified) (5 diffs)
- branches/rebuild/rebuild/func.c (modified) (5 diffs)
- branches/rebuild/rebuild/idgen.c (modified) (1 diff)
- branches/rebuild/rebuild/inline.c (modified) (3 diffs)
- branches/rebuild/rebuild/lexer.c (modified) (7 diffs)
- branches/rebuild/rebuild/lexer.h (modified) (1 diff)
- branches/rebuild/rebuild/mars.c (modified) (2 diffs)
- branches/rebuild/rebuild/module.c (modified) (1 diff)
- branches/rebuild/rebuild/mtype.c (modified) (8 diffs)
- branches/rebuild/rebuild/mtype.h (modified) (10 diffs)
- branches/rebuild/rebuild/optimize.c (modified) (1 diff)
- branches/rebuild/rebuild/parse.c (modified) (9 diffs)
- branches/rebuild/rebuild/parse.h (modified) (2 diffs)
- branches/rebuild/rebuild/scope.c (modified) (5 diffs)
- branches/rebuild/rebuild/statement.c (modified) (10 diffs)
- branches/rebuild/rebuild/statement.h (modified) (2 diffs)
- branches/rebuild/rebuild/template.c (modified) (20 diffs)
- branches/rebuild/rebuild/template.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/rebuild/rebuild/Makefile
r304 r311 13 13 ARFLAGS=rc 14 14 RANLIB=$(CROSS)ranlib 15 16 PREFIX=/usr 15 17 16 18 OBJS=\ … … 111 113 $(CXX) $(CXXFLAGS) -D_DH -DIN_DMDFE -c $< -o $@ 112 114 115 install: 116 mkdir -p $(PREFIX)/bin 117 mkdir -p $(PREFIX)/etc/rebuild 118 cp -pf rebuild$(EXEEXT) $(PREFIX)/bin 119 cp -pRf rebuild.conf/* $(PREFIX)/etc/rebuild/ 120 113 121 clean: 114 122 rm -f rebuild$(EXEEXT) libdmd.a $(OBJS) branches/rebuild/rebuild/attrib.c
r305 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 30 30 #include "aggregate.h" 31 31 #include "module.h" 32 #include "parse.h" 32 33 #include "config.h" 33 34 … … 765 766 if (e->op != TOKstring) 766 767 error("string expected for library name, not '%s'", e->toChars()); 768 else if (global.params.verbose) 769 { 770 StringExp *se = (StringExp *)e; 771 char *name = (char *)mem.malloc(se->len + 1); 772 memcpy(name, se->string, se->len); 773 name[se->len] = 0; 774 printf("library %s\n", name); 775 mem.free(name); 776 } 767 777 } 768 778 goto Lnodecl; … … 1128 1138 1129 1139 1140 /***************************** CompileDeclaration *****************************/ 1141 1142 CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp) 1143 : AttribDeclaration(NULL) 1144 { 1145 this->exp = exp; 1146 this->sd = NULL; 1147 } 1148 1149 Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s) 1150 { 1151 //printf("CompileDeclaration::syntaxCopy('%s')\n", toChars()); 1152 CompileDeclaration *sc = new CompileDeclaration(loc, exp->syntaxCopy()); 1153 return sc; 1154 } 1155 1156 int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 1157 { 1158 this->sd = sd; 1159 return memnum; 1160 } 1161 1162 void CompileDeclaration::semantic(Scope *sc) 1163 { 1164 //printf("CompileDeclaration::semantic()\n"); 1165 exp = exp->semantic(sc); 1166 exp = resolveProperties(sc, exp); 1167 exp = exp->optimize(WANTvalue); 1168 if (exp->op != TOKstring) 1169 { error("argument to mixin must be a string, not (%s)", exp->toChars()); 1170 return; 1171 } 1172 StringExp *se = (StringExp *)exp; 1173 se = se->toUTF8(sc); 1174 Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 1175 p.loc = loc; 1176 decl = p.parseDeclDefs(0); 1177 if (p.token.value != TOKeof) 1178 { 1179 error("incomplete mixin declaration (%s)", se->toChars()); 1180 } 1181 1182 AttribDeclaration::addMember(sc, sd, 0); 1183 AttribDeclaration::semantic(sc); 1184 } 1185 1186 void CompileDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 1187 { 1188 buf->writestring("mixin("); 1189 exp->toCBuffer(buf, hgs); 1190 buf->writestring(");"); 1191 buf->writenl(); 1192 } branches/rebuild/rebuild/attrib.h
r298 r311 151 151 }; 152 152 153 // Mixin declarations 154 155 struct CompileDeclaration : AttribDeclaration 156 { 157 Expression *exp; 158 159 ScopeDsymbol *sd; 160 161 CompileDeclaration(Loc loc, Expression *exp); 162 Dsymbol *syntaxCopy(Dsymbol *s); 163 int addMember(Scope *sc, ScopeDsymbol *sd, int memnum); 164 void semantic(Scope *sc); 165 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 166 }; 167 153 168 #endif /* DMD_ATTRIB_H */ branches/rebuild/rebuild/cast.c
r297 r311 50 50 return castTo(sc, t); 51 51 } 52 53 Expression *e = optimize(WANTflags | WANTvalue); 54 if (e != this) 55 return e->implicitCastTo(sc, t); 56 52 57 #if 0 53 58 print(); … … 70 75 //error("forward reference to type %s", t->toChars()); 71 76 } 72 /*else 73 error("cannot implicitly convert expression (%s) of type %s to %s", 74 toChars(), type->toChars(), t->toChars()); */ 75 //*(char*)0=0; 77 /*else if (t->reliesOnTident()) 78 error("forward reference to type %s", t->reliesOnTident()->toChars()); */ 79 80 error("cannot implicitly convert expression (%s) of type %s to %s", 81 toChars(), type->toChars(), t->toChars()); 76 82 return castTo(sc, t); 77 83 } … … 628 634 629 635 tb = t->toBasetype(); 636 //printf("\ttype = %s\n", type->toChars()); 630 637 if (tb->ty == Tdelegate && type->toBasetype()->ty != Tdelegate) 631 638 return Expression::castTo(sc, t); branches/rebuild/rebuild/cond.c
r297 r311 320 320 parameters.data[0] = (void *)&tp; 321 321 322 Arraydedtypes;322 Objects dedtypes; 323 323 dedtypes.setDim(1); 324 324 branches/rebuild/rebuild/constfold.c
r297 r311 907 907 real_t r2; 908 908 909 //printf("EqualExp::constFold() %s\n", toChars()); 909 910 assert(op == TOKequal || op == TOKnotequal); 910 911 e1 = e1->constFold(); branches/rebuild/rebuild/dsymbol.c
r297 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 737 737 exp = e; 738 738 type = NULL; 739 td = NULL; 739 740 } 740 741 … … 744 745 exp = NULL; 745 746 type = t; 747 td = NULL; 748 } 749 750 ArrayScopeSymbol::ArrayScopeSymbol(TupleDeclaration *s) 751 : ScopeDsymbol() 752 { 753 exp = NULL; 754 type = NULL; 755 td = s; 746 756 } 747 757 … … 754 764 755 765 L1: 766 767 if (td) 768 { 769 VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::dollar, NULL); 770 Expression *e = new IntegerExp(0, td->objects->dim, Type::tsize_t); 771 v->init = new ExpInitializer(0, e); 772 v->storage_class |= STCconst; 773 return v; 774 } 775 756 776 if (type) 757 777 { branches/rebuild/rebuild/dsymbol.h
r291 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 250 250 Expression *exp; // IndexExp or SliceExp 251 251 TypeTuple *type; // for tuple[length] 252 TupleDeclaration *td; // for tuples of objects 252 253 253 254 ArrayScopeSymbol(Expression *e); 254 255 ArrayScopeSymbol(TypeTuple *t); 256 ArrayScopeSymbol(TupleDeclaration *td); 255 257 Dsymbol *search(Loc loc, Identifier *ident, int flags); 256 258 branches/rebuild/rebuild/expression.c
r297 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 58 58 #include "attrib.h" 59 59 #include "hdrgen.h" 60 #include "parse.h" 60 61 61 62 //Expression *createTypeInfoArray(Scope *sc, Expression *args[], int dim); … … 1913 1914 #endif 1914 1915 if (type) 1915 { assert(global.errors || var);1916 { //assert(global.errors || var); 1916 1917 return this; 1917 1918 } … … 2258 2259 } 2259 2260 type = type->semantic(loc, sc); 2261 } 2262 return this; 2263 } 2264 2265 /**************************************** 2266 * Convert string to char[]. 2267 */ 2268 2269 StringExp *StringExp::toUTF8(Scope *sc) 2270 { 2271 if (sz != 1) 2272 { // Convert to UTF-8 string 2273 committed = 0; 2274 Expression *e = castTo(sc, Type::tchar->arrayOf()); 2275 e = e->optimize(WANTvalue); 2276 assert(e->op == TOKstring); 2277 StringExp *se = (StringExp *)e; 2278 assert(se->sz == 1); 2279 return se; 2260 2280 } 2261 2281 return this; … … 3134 3154 { 3135 3155 //ei->exp->implicitCastTo(sc, type)->print(); 3136 printf("test3: %s\n", ei->exp->toChars());3137 3156 return ei->exp->implicitCastTo(sc, type); 3138 3157 } … … 3728 3747 parameters.data[0] = (void *)&tp; 3729 3748 3730 Arraydedtypes;3749 Objects dedtypes; 3731 3750 dedtypes.setDim(1); 3732 3751 dedtypes.data[0] = NULL; … … 3994 4013 /************************************************************/ 3995 4014 4015 CompileExp::CompileExp(Loc loc, Expression *e) 4016 : UnaExp(loc, TOKmixin, sizeof(CompileExp), e) 4017 { 4018 } 4019 4020 Expression *CompileExp::semantic(Scope *sc) 4021 { 4022 #if LOGSEMANTIC 4023 printf("CompileExp::semantic('%s')\n", toChars()); 4024 #endif 4025 UnaExp::semantic(sc); 4026 e1 = resolveProperties(sc, e1); 4027 e1 = e1->optimize(WANTvalue); 4028 if (e1->op != TOKstring) 4029 { error("argument to mixin must be a string, not (%s)", e1->toChars()); 4030 return this; 4031 } 4032 StringExp *se = (StringExp *)e1; 4033 se = se->toUTF8(sc); 4034 Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 4035 p.loc = loc; 4036 Expression *e = p.parseExpression(); 4037 if (p.token.value != TOKeof) 4038 error("incomplete mixin expression (%s)", se->toChars()); 4039 return e->semantic(sc); 4040 } 4041 4042 void CompileExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 4043 { 4044 buf->writestring("mixin("); 4045 expToCBuffer(buf, hgs, e1, PREC_assign); 4046 buf->writeByte(')'); 4047 } 4048 4049 /************************************************************/ 4050 4051 FileExp::FileExp(Loc loc, Expression *e) 4052 : UnaExp(loc, TOKmixin, sizeof(FileExp), e) 4053 { 4054 } 4055 4056 Expression *FileExp::semantic(Scope *sc) 4057 { 4058 #if LOGSEMANTIC 4059 printf("FileExp::semantic('%s')\n", toChars()); 4060 #endif 4061 UnaExp::semantic(sc); 4062 e1 = resolveProperties(sc, e1); 4063 e1 = e1->optimize(WANTvalue); 4064 if (e1->op != TOKstring) 4065 { error("file name argument must be a string, not (%s)", e1->toChars()); 4066 return this; 4067 } 4068 StringExp *se = (StringExp *)e1; 4069 se = se->toUTF8(sc); 4070 4071 if (global.params.verbose) 4072 printf("file %s\n", se->string); 4073 4074 File f((char *)se->string); 4075 if (f.read()) 4076 { error("cannot read file %s", f.toChars()); 4077 se = new StringExp(loc, ""); 4078 } 4079 else 4080 { 4081 f.ref = 1; 4082 se = new StringExp(loc, f.buffer, f.len); 4083 } 4084 return se->semantic(sc); 4085 } 4086 4087 void FileExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 4088 { 4089 buf->writestring("import("); 4090 expToCBuffer(buf, hgs, e1, PREC_assign); 4091 buf->writeByte(')'); 4092 } 4093 4094 /************************************************************/ 4095 3996 4096 AssertExp::AssertExp(Loc loc, Expression *e, Expression *msg) 3997 4097 : UnaExp(loc, TOKassert, sizeof(AssertExp), e) … … 4075 4175 4076 4176 //{ static int z; fflush(stdout); if (++z == 10) *(char*)0=0; } 4177 4178 #if 0 4179 /* Don't do semantic analysis if we'll be converting 4180 * it to a string. 4181 */ 4182 if (ident == Id::stringof) 4183 { char *s = e1->toChars(); 4184 e = new StringExp(loc, s, strlen(s), 'c'); 4185 e = e->semantic(sc); 4186 return e; 4187 } 4188 #endif 4077 4189 4078 4190 /* Special case: rewrite this.id and super.id … … 4272 4384 ident != Id::init && ident != Id::__sizeof && 4273 4385 ident != Id::alignof && ident != Id::offsetof && 4274 ident != Id::mangleof )4386 ident != Id::mangleof && ident != Id::stringof) 4275 4387 { 4276 4388 e = new PtrExp(loc, e1); … … 5646 5758 } 5647 5759 5760 void CastExp::checkEscape() 5761 { Type *tb = type->toBasetype(); 5762 if (tb->ty == Tarray && e1->op == TOKvar && 5763 e1->type->toBasetype()->ty == Tsarray) 5764 { VarExp *ve = (VarExp *)e1; 5765 VarDeclaration *v = ve->var->isVarDeclaration(); 5766 if (v) 5767 { 5768 if (!v->isDataseg()) 5769 error("escaping reference to local %s", v->toChars()); 5770 } 5771 } 5772 } 5773 5648 5774 void CastExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 5649 5775 { … … 7754 7880 Type *t2; 7755 7881 7882 //printf("EqualExp::semantic('%s')\n", toChars()); 7756 7883 if (type) 7757 7884 return this; branches/rebuild/rebuild/expression.h
r272 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 285 285 char *toChars(); 286 286 Expression *semantic(Scope *sc); 287 StringExp *toUTF8(Scope *sc); 287 288 int implicitConvTo(Type *t); 288 289 Expression *castTo(Scope *sc, Type *t); … … 453 454 void scanForNestedRef(Scope *sc); 454 455 455 //int inlineCost(InlineCostState *ics);456 int inlineCost(InlineCostState *ics); 456 457 Expression *doInline(InlineDoState *ids); 457 458 //Expression *inlineScan(InlineScanState *iss); … … 588 589 /****************************************************************/ 589 590 591 struct CompileExp : UnaExp 592 { 593 CompileExp(Loc loc, Expression *e); 594 Expression *semantic(Scope *sc); 595 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 596 }; 597 598 struct FileExp : UnaExp 599 { 600 FileExp(Loc loc, Expression *e); 601 Expression *semantic(Scope *sc); 602 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 603 }; 604 590 605 struct AssertExp : UnaExp 591 606 { … … 772 787 Expression *optimize(int result); 773 788 int checkSideEffect(int flag); 789 void checkEscape(); 774 790 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 775 791 Expression *constFold(); branches/rebuild/rebuild/func.c
r297 r311 930 930 931 931 // Verify that all the ctorinit fields got initialized 932 if (!(sc ->callSuper & CSXthis_ctor))932 if (!(sc2->callSuper & CSXthis_ctor)) 933 933 { 934 934 for (int i = 0; i < cd->fields.dim; i++) … … 1644 1644 int FuncDeclaration::isAbstract() 1645 1645 { 1646 return storage_class & STCabstract && !fbody;1646 return storage_class & STCabstract; 1647 1647 } 1648 1648 … … 1940 1940 { 1941 1941 ClassDeclaration *cd; 1942 Type *tret;1943 1944 sc = sc->push();1945 sc->stc &= ~STCstatic; // not a static destructor1946 1942 1947 1943 parent = sc->parent; … … 1955 1951 cd->dtors.push(this); 1956 1952 type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); 1953 1954 sc = sc->push(); 1955 sc->stc &= ~STCstatic; // not a static destructor 1956 sc->linkage = LINKd; 1957 1957 1958 1958 FuncDeclaration::semantic(sc); … … 2179 2179 type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); 2180 2180 2181 sc = sc->push(); 2182 sc->stc &= ~STCstatic; // not a static invariant 2181 2183 sc->incontract++; 2184 sc->linkage = LINKd; 2185 2182 2186 FuncDeclaration::semantic(sc); 2183 sc->incontract--; 2187 2188 sc->pop(); 2184 2189 } 2185 2190 branches/rebuild/rebuild/idgen.c
r272 r311 46 46 { "alignof" }, 47 47 { "mangleof" }, 48 { "stringof" }, 48 49 { "tupleof" }, 49 50 { "length" }, branches/rebuild/rebuild/inline.c
r272 r311 147 147 int Expression::inlineCost(InlineCostState *ics) 148 148 { 149 return 1; 150 } 151 152 int VarExp::inlineCost(InlineCostState *ics) 153 { 154 //printf("VarExp::inlineCost() %s\n", toChars()); 149 155 return 1; 150 156 } … … 471 477 Expression *ThisExp::doInline(InlineDoState *ids) 472 478 { 479 //if (!ids->vthis) 480 //error("no 'this' when inlining %s", ids->parent->toChars()); 473 481 assert(ids->vthis); 474 482 … … 1133 1141 1134 1142 #if CANINLINE_LOG 1135 printf("FuncDeclaration::canInline( '%s')\n", toChars());1143 printf("FuncDeclaration::canInline(hasthis = %d, '%s')\n", hasthis, toChars()); 1136 1144 #endif 1145 1146 if (needThis() && !hasthis) 1147 return 0; 1137 1148 1138 1149 if (inlineNest || (!semanticRun && !hdrscan)) branches/rebuild/rebuild/lexer.c
r301 r311 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2007 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 1001 1001 if (*p == '=') 1002 1002 { p++; 1003 if (*p == '=' )1003 if (*p == '=' && global.params.Dversion == 1) 1004 1004 { p++; 1005 1005 t->value = TOKnotidentity; // !== … … 1043 1043 if (*p == '=') 1044 1044 { p++; 1045 if (*p == '=' )1045 if (*p == '=' && global.params.Dversion == 1) 1046 1046 { p++; 1047 1047 t->value = TOKidentity; // === … … 2507 2507 { "typeof", TOKtypeof }, 2508 2508 { "typeid", TOKtypeid }, 2509 { "iftype", TOKiftype },2510 2509 2511 2510 { "template", TOKtemplate }, … … 2526 2525 { "real", TOKfloat80 }, 2527 2526 2528 /* { "bit", TOKbit }, */2529 2527 { "bool", TOKbool }, 2530 2528 { "char", TOKchar }, … … 2565 2563 { "foreach_reverse", TOKforeach_reverse }, 2566 2564 { "scope", TOKscope }, 2567 { "on_scope_exit", TOKon_scope_exit },2568 { "on_scope_failure", TOKon_scope_failure },2569 { "on_scope_success", TOKon_scope_success },2570 2565 2571 2566 { "struct", TOKstruct }, … … 2577 2572 { "mixin", TOKmixin }, 2578 2573 { "static", TOKstatic }, 2579 /*{ "virtual", TOKvirtual },*/2580 2574 { "final", TOKfinal }, 2581 2575 { "const", TOKconst }, branches/rebuild/rebuild/lexer.h
r272 r311 65 65 TOKpragma, TOKdsymbol, 66 66 TOKtypeid, TOKuadd, 67 TOK iftype, TOKremove,67 TOKremove, 68 68 TOKnewanonclass, TOKcomment, 69 69 TOKarrayliteral, branches/rebuild/rebuild/mars.c
r306 r311 57 57 doc_ext = "html"; 58 58 ddoc_ext = "ddoc"; 59 59 60 obj_ext = "o"; 60 61 61 62 copyright = "Copyright (c) 1999-2007 by Digital Mars and Gregor Richards,"; 62 63 written = "written by Walter Bright and Gregor Richards"; 63 version = "version 0.1 (based on DMD 1.00 4)";64 version = "version 0.1 (based on DMD 1.005)"; 64 65 global.structalign = 8; 65 66 cmodules = NULL; … … 251 252 global.params.useInline = 0; 252 253 global.params.obj = 1; 254 global.params.Dversion = 2; 253 255 254 256 global.params.linkswitches = new Array(); branches/rebuild/rebuild/module.c
r300 r311 289 289 result = sdi; 290 290 else if (FileName::exists(sd)) 291 result = sd;291 result = sd; 292 292 else if (FileName::absolute(filename)) 293 293 ; branches/rebuild/rebuild/mtype.c
r297 r311 540 540 e = e->semantic(&sc); 541 541 } 542 else if (ident == Id::stringof) 543 { char *s = toChars(); 544 e = new StringExp(loc, s, strlen(s), 'c'); 545 Scope sc; 546 e = e->semantic(&sc); 547 } 542 548 else 543 549 { … … 613 619 error(e->loc, ".typeinfo deprecated, use typeid(type)"); */ 614 620 e = getTypeInfo(sc); 621 return e; 622 } 623 if (ident == Id::stringof) 624 { char *s = e->toChars(); 625 e = new StringExp(e->loc, s, strlen(s), 'c'); 626 Scope sc; 627 e = e->semantic(&sc); 615 628 return e; 616 629 } … … 1653 1666 *pe = e; 1654 1667 } 1668 else if (*ps) 1669 { Dsymbol *s = *ps; 1670 TupleDeclaration *td = s->isTupleDeclaration(); 1671 if (td) 1672 { 1673 ScopeDsymbol *sym = new ArrayScopeSymbol(td); 1674 sym->parent = sc->scopesym; 1675 sc = sc->push(sym); 1676 1677 dim = dim->semantic(sc); 1678 dim = dim->constFold(); 1679 uinteger_t d = dim->toUInteger(); 1680 1681 sc = sc->pop(); 1682 1683 if (d >= td->objects->dim) 1684 { error(loc, "tuple index %ju exceeds %u", d, td->objects->dim); 1685 goto Ldefault; 1686 } 1687 1688 /* Create a new TupleDeclaration which 1689 * is a slice [d..d+1] out of the old one. 1690 * Do it this way because TemplateInstance::semanticTiargs() 1691 * can handle unresolved Objects this way. 1692 */ 1693 Objects *objects = new Objects; 1694 objects->setDim(1); 1695 objects->data[0] = td->objects->data[(size_t)d]; 1696 1697 TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); 1698 *ps = tds; 1699 } 1700 else 1701 goto Ldefault; 1702 } 1655 1703 else 1704 { 1705 Ldefault: 1656 1706 Type::resolve(loc, sc, pe, pt, ps); 1707 } 1657 1708 } 1658 1709 … … 2971 3022 VarDeclaration *v; 2972 3023 EnumMember *em; 3024 TupleDeclaration *td; 2973 3025 Type *t; 2974 3026 Expression *e; … … 3935 3987 return 0; // assume not 3936 3988 } 3937 return sym->basetype->isZeroInit(); 3989 if (sym->inuse) 3990 { 3991 sym->error("circular definition"); 3992 sym->basetype = Type::terror; 3993 } 3994 sym->inuse = 1; 3995 int result = sym->basetype->isZeroInit(); 3996 sym->inuse = 0; 3997 return result; 3938 3998 } 3939 3999 … … 4773 4833 *pe = e; 4774 4834 } 4835 else if (*ps) 4836 { Dsymbol *s = *ps; 4837 TupleDeclaration *td = s->isTupleDeclaration(); 4838 if (td) 4839 { 4840 /* It's a slice of a TupleDeclaration 4841 */ 4842 ScopeDsymbol *sym = new ArrayScopeSymbol(td); 4843 sym->parent = sc->scopesym; 4844 sc = sc->push(sym); 4845 4846 lwr = lwr->semantic(sc); 4847 lwr = lwr->constFold(); 4848 uinteger_t i1 = lwr->toUInteger(); 4849 4850 upr = upr->semantic(sc); 4851 upr = upr->constFold(); 4852 uinteger_t i2 = upr->toUInteger(); 4853 4854 sc = sc->pop(); 4855 4856 if (!(i1 <= i2 && i2 <= td->objects->dim)) 4857 { error(loc, "slice [%ju..%ju] is out of range of [0..%u]", i1, i2, td->objects->dim); 4858 goto Ldefault; 4859 } 4860 4861 if (i1 == 0 && i2 == td->objects->dim) 4862 { 4863 *ps = td; 4864 return; 4865 } 4866 4867 /* Create a new TupleDeclaration which 4868 * is a slice [i1..i2] out of the old one. 4869 */ 4870 Objects *objects = new Objects; 4871 objects->setDim(i2 - i1); 4872 for (size_t i = 0; i < objects->dim; i++) 4873 { 4874 objects->data[i] = td->objects->data[(size_t)i1 + i]; 4875 } 4876 4877 TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); 4878 *ps = tds; 4879 } 4880 else 4881 goto Ldefault; 4882 } 4775 4883 else 4884 { 4885 Ldefault: 4776 4886 Type::resolve(loc, sc, pe, pt, ps); 4887 } 4777 4888 } 4778 4889 … … 4980 5091 for (size_t i = 0; i < args->dim; i++) 4981 5092 { Argument *arg = (Argument *)args->data[i]; 4982 4983 if (arg->type->ty == Ttuple) 4984 { TypeTuple *t = (TypeTuple *)arg->type; 4985 n += dim(t->arguments); 5093 Type *t = arg->type->toBasetype(); 5094 5095 if (t->ty == Ttuple) 5096 { TypeTuple *tu = (TypeTuple *)t; 5097 n += dim(tu->arguments); 4986 5098 } 4987 5099 else … … 5008 5120 for (size_t i = 0; i < args->dim; i++) 5009 5121 { Argument *arg = (Argument *)args->data[i]; 5010 5011 if (arg->type->ty == Ttuple) 5012 { TypeTuple *t = (TypeTuple *)arg->type; 5013 arg = getNth(t->arguments, nth - n, &n); 5122 Type *t = arg->type->toBasetype(); 5123 5124 if (t->ty == Ttuple) 5125 { TypeTuple *tu = (TypeTuple *)t; 5126 arg = getNth(tu->arguments, nth - n, &n); 5014 5127 if (arg) 5015 5128 return arg; branches/rebuild/rebuild/mtype.h
r291 r311 232 232 virtual int isZeroInit(); // if initializer is 0 233 233 Identifier *getTypeInfoIdent(int internal); 234 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);234 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 235 235 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 236 236 Expression *getInternalTypeInfo(Scope *sc); … … 305 305 Expression *defaultInit(); 306 306 dt_t **toDtElem(dt_t **pdt, Expression *e); 307 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);307 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 308 308 Expression *toExpression(); 309 309 int hasPointers(); … … 343 343 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 344 344 Expression *defaultInit(); 345 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);345 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 346 346 int checkBoolean(); 347 347 int hasPointers(); … … 396 396 void toDecoBuffer(OutBuffer *buf); 397 397 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 398 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);398 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 399 399 Type *reliesOnTident(); 400 400 … … 442 442 Dsymbol *toDsymbol(Scope *sc); 443 443 Type *semantic(Loc loc, Scope *sc); 444 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);444 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 445 445 Type *reliesOnTident(); 446 446 Expression *toExpression(); … … 460 460 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 461 461 Type *semantic(Loc loc, Scope *sc); 462 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);462 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 463 463 }; 464 464 … … 494 494 int isZeroInit(); 495 495 int checkBoolean(); 496 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);496 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 497 497 int hasPointers(); 498 498 }; … … 521 521 Expression *defaultInit(); 522 522 int isZeroInit(); 523 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);523 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 524 524 int hasPointers(); 525 525 }; … … 553 553 Expression *defaultInit(); 554 554 int isZeroInit(); 555 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);555 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 556 556 int hasPointers(); 557 557 }; … … 575 575 Expression *defaultInit(); 576 576 int isZeroInit(); 577 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes);577 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 578 578 int isauto(); 579 579 int checkBoolean(); branches/rebuild/rebuild/optimize.c
r297 r311 355 355 Expression *v = eq.constFold(); 356 356 value = v->toInteger(); 357 if (value )357 if (value == 0) 358 358 break; 359 359 } branches/rebuild/rebuild/parse.c
r272 r311 <
