Changeset 881
- Timestamp:
- 03/08/08 17:08:58 (6 months ago)
- Files:
-
- branches/dmdfe-2.0/cast.c (modified) (2 diffs)
- branches/dmdfe-2.0/declaration.c (modified) (5 diffs)
- branches/dmdfe-2.0/dsymbol.c (modified) (1 diff)
- branches/dmdfe-2.0/expression.c (modified) (15 diffs)
- branches/dmdfe-2.0/func.c (modified) (2 diffs)
- branches/dmdfe-2.0/idgen.c (modified) (1 diff)
- branches/dmdfe-2.0/lexer.c (modified) (2 diffs)
- branches/dmdfe-2.0/lexer.h (modified) (1 diff)
- branches/dmdfe-2.0/mangle.c (modified) (1 diff)
- branches/dmdfe-2.0/mars.c (modified) (3 diffs)
- branches/dmdfe-2.0/mtype.c (modified) (8 diffs)
- branches/dmdfe-2.0/mtype.h (modified) (1 diff)
- branches/dmdfe-2.0/parse.c (modified) (7 diffs)
- branches/dmdfe-2.0/statement.c (modified) (2 diffs)
- branches/dmdfe-2.0/template.c (modified) (6 diffs)
- branches/dmdfe-2.0/toir.c (modified) (6 diffs)
- branches/dmdfe-2.0/toobj.c (modified) (1 diff)
- branches/dmdfe-2.0/traits.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmdfe-2.0/cast.c
r880 r881 35 35 //printf("%s\n", toChars()); 36 36 37 if (implicitConvTo(t)) 37 MATCH match = implicitConvTo(t); 38 if (match) 38 39 { 39 40 if (global.params.warnings && … … 49 50 error("implicit conversion of expression (%s) of type %s to %s can cause loss of data", 50 51 toChars(), type->toChars(), t->toChars()); 52 } 53 if (match == MATCHconst && t == type->constOf()) 54 { 55 Expression *e = copy(); 56 e->type = t; 57 return e; 51 58 } 52 59 return castTo(sc, t); branches/dmdfe-2.0/declaration.c
r880 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 386 386 Dsymbol *AliasDeclaration::syntaxCopy(Dsymbol *s) 387 387 { 388 //printf("AliasDeclaration::syntaxCopy()\n"); 388 389 assert(!s); 389 390 AliasDeclaration *sa; … … 660 661 //printf(" type = %s\n", type ? type->toChars() : "null"); 661 662 //printf(" stc = x%x\n", sc->stc); 663 //printf(" storage_class = x%x\n", storage_class); 662 664 //printf("linkage = %d\n", sc->linkage); 663 665 //if (strcmp(toChars(), "mul") == 0) halt(); … … 1280 1282 { Expression *e = NULL; 1281 1283 1284 //printf("VarDeclaration::callAutoDtor() %s\n", toChars()); 1282 1285 if (storage_class & (STCauto | STCscope) && !noauto) 1283 1286 { … … 1290 1293 * could be set. 1291 1294 */ 1295 if (cd->isInterfaceDeclaration()) 1296 error("interface %s cannot be scope", cd->toChars()); 1292 1297 if (1 || onstack || cd->dtors.dim) // if any destructors 1293 1298 { branches/dmdfe-2.0/dsymbol.c
r880 r881 395 395 AggregateDeclaration *Dsymbol::isMember() // is this a member of an AggregateDeclaration? 396 396 { 397 //printf("Dsymbol::isMember() %s\n", toChars()); 397 398 Dsymbol *parent = toParent(); 399 //printf("parent is %s %s\n", parent->kind(), parent->toChars()); 398 400 return parent ? parent->isAggregateDeclaration() : NULL; 399 401 } branches/dmdfe-2.0/expression.c
r880 r881 521 521 L1: 522 522 if (!(p->storageClass & STClazy && p->type->ty == Tvoid)) 523 arg = arg->implicitCastTo(sc, p->type);524 if (p->storageClass & (STCout | STCref))525 523 { 526 // BUG: should check that argument to ref is type 'invariant' 527 // BUG: assignments to ref should also be type 'invariant' 528 arg = arg->modifiableLvalue(sc, NULL); 529 530 //if (arg->op == TOKslice) 531 //arg->error("cannot modify slice %s", arg->toChars()); 524 if (p->type != arg->type) 525 { 526 //printf("arg->type = %s, p->type = %s\n", arg->type->toChars(), p->type->toChars()); 527 arg = arg->implicitCastTo(sc, p->type); 528 arg = arg->optimize(WANTvalue); 529 } 530 } 531 if (p->storageClass & STCref) 532 { 533 arg = arg->toLvalue(sc, arg); 534 } 535 else if (p->storageClass & STCout) 536 { 537 arg = arg->modifiableLvalue(sc, arg); 532 538 } 533 539 … … 3225 3231 3226 3232 tf = (TypeFunction *)f->type; 3227 type = tf->next;3233 // type = tf->next; 3228 3234 3229 3235 if (!arguments) … … 4434 4440 return e; 4435 4441 4436 e1 = e1->modifiableLvalue(sc, NULL);4442 e1 = e1->modifiableLvalue(sc, e1); 4437 4443 e1->checkScalar(); 4438 4444 type = e1->type; … … 4465 4471 return e; 4466 4472 4467 e1 = e1->modifiableLvalue(sc, NULL);4473 e1 = e1->modifiableLvalue(sc, e1); 4468 4474 e1->checkScalar(); 4469 4475 type = e1->type; … … 7075 7081 7076 7082 e = this; 7077 e1 = e1->modifiableLvalue(sc, NULL);7083 e1 = e1->modifiableLvalue(sc, e1); 7078 7084 e1->checkScalar(); 7079 7085 e1->checkNoBool(); … … 7244 7250 /* If it is an assignment from a 'foreign' type, 7245 7251 * check for operator overloading. 7252 * Changed in V2 to be for structs only. 7246 7253 */ 7247 if (t1->ty == T class || t1->ty == Tstruct)7254 if (t1->ty == Tstruct) 7248 7255 { 7249 7256 if (!e2->type->implicitConvTo(e1->type)) … … 7262 7269 ArrayLengthExp *ale = (ArrayLengthExp *)e1; 7263 7270 7264 ale->e1 = ale->e1->modifiableLvalue(sc, NULL);7271 ale->e1 = ale->e1->modifiableLvalue(sc, e1); 7265 7272 } 7266 7273 else if (e1->op == TOKslice) … … 7334 7341 return e; 7335 7342 7336 e1 = e1->modifiableLvalue(sc, NULL);7343 e1 = e1->modifiableLvalue(sc, e1); 7337 7344 7338 7345 Type *tb1 = e1->type->toBasetype(); … … 7434 7441 return e; 7435 7442 7436 e1 = e1->modifiableLvalue(sc, NULL);7443 e1 = e1->modifiableLvalue(sc, e1); 7437 7444 e1->checkScalar(); 7438 7445 e1->checkNoBool(); … … 7479 7486 } 7480 7487 7481 e1 = e1->modifiableLvalue(sc, NULL);7488 e1 = e1->modifiableLvalue(sc, e1); 7482 7489 7483 7490 Type *tb1 = e1->type->toBasetype(); … … 7528 7535 return e; 7529 7536 7530 e1 = e1->modifiableLvalue(sc, NULL);7537 e1 = e1->modifiableLvalue(sc, e1); 7531 7538 e1->checkScalar(); 7532 7539 e1->checkNoBool(); … … 7584 7591 return e; 7585 7592 7586 e1 = e1->modifiableLvalue(sc, NULL);7593 e1 = e1->modifiableLvalue(sc, e1); 7587 7594 e1->checkScalar(); 7588 7595 e1->checkNoBool(); … … 7655 7662 return e; 7656 7663 7657 e1 = e1->modifiableLvalue(sc, NULL);7664 e1 = e1->modifiableLvalue(sc, e1); 7658 7665 e1->checkScalar(); 7659 7666 e1->checkNoBool(); … … 7683 7690 return e; 7684 7691 7685 e1 = e1->modifiableLvalue(sc, NULL);7692 e1 = e1->modifiableLvalue(sc, e1); 7686 7693 e1->checkScalar(); 7687 7694 e1->checkNoBool(); … … 7711 7718 return e; 7712 7719 7713 e1 = e1->modifiableLvalue(sc, NULL);7720 e1 = e1->modifiableLvalue(sc, e1); 7714 7721 e1->checkScalar(); 7715 7722 e1->checkNoBool(); branches/dmdfe-2.0/func.c
r880 r881 1782 1782 int FuncDeclaration::isWinMain() 1783 1783 { 1784 //printf("FuncDeclaration::isWinMain() %s\n", toChars()); 1785 #if 0 1786 int x = ident == Id::WinMain && 1787 linkage != LINKc && !isMember(); 1788 printf("%s\n", x ? "yes" : "no"); 1789 return x; 1790 #else 1784 1791 return ident == Id::WinMain && 1785 1792 linkage != LINKc && !isMember(); 1793 #endif 1786 1794 } 1787 1795 … … 1859 1867 //if (!toParent()) 1860 1868 //printf("FuncDeclaration::isNested('%s') parent=%p\n", toChars(), parent); 1861 //printf("\ttoParent () = '%s'\n", toParent()->toChars());1869 //printf("\ttoParent2() = '%s'\n", toParent2()->toChars()); 1862 1870 return ((storage_class & STCstatic) == 0) && 1863 1871 (toParent2()->isFuncDeclaration() != NULL); branches/dmdfe-2.0/idgen.c
r838 r881 192 192 { "opIn_r" }, 193 193 { "opStar" }, 194 { "opClone" }, 194 195 195 196 { "classNew", "new" }, branches/dmdfe-2.0/lexer.c
r880 r881 2168 2168 if (d >= r) 2169 2169 break; 2170 if (n * r + d <n)2170 if (n && n * r + d <= n) 2171 2171 { 2172 2172 error ("integer overflow"); … … 2887 2887 { "macro", TOKmacro }, 2888 2888 #if V2 2889 { "pure", TOKpure }, 2889 2890 { "__traits", TOKtraits }, 2890 2891 { "__overloadset", TOKoverloadset }, branches/dmdfe-2.0/lexer.h
r880 r881 154 154 TOKtraits, 155 155 TOKoverloadset, 156 TOKpure, 156 157 #endif 157 158 branches/dmdfe-2.0/mangle.c
r880 r881 153 153 return "_Dmain"; 154 154 155 if (isWinMain() || isDllMain()) 156 return ident->toChars(); 157 155 158 assert(this); 156 159 return Declaration::mangle(); branches/dmdfe-2.0/mars.c
r880 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 54 54 obj_ext = "o"; 55 55 56 copyright = "Copyright (c) 1999-200 7by Digital Mars";56 copyright = "Copyright (c) 1999-2008 by Digital Mars"; 57 57 written = "written by Walter Bright"; 58 version = "v2.0 09";58 version = "v2.010"; 59 59 global.structalign = 8; 60 60 … … 110 110 fprintf(stdmsg, "\n"); 111 111 fflush(stdmsg); 112 //halt();112 halt(); 113 113 } 114 114 global.errors++; branches/dmdfe-2.0/mtype.c
r880 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 2350 2350 MATCH TypeDArray::implicitConvTo(Type *to) 2351 2351 { 2352 //printf("TypeDArray::implicitConvTo( )\n");2352 //printf("TypeDArray::implicitConvTo(to = %s) this = %s\n", to->toChars(), toChars()); 2353 2353 if (equals(to)) 2354 2354 return MATCHexact; … … 3696 3696 s = sc->search(loc, ident, &scopesym); 3697 3697 resolveHelper(loc, sc, s, scopesym, pe, pt, ps); 3698 if (*pt && mod) 3699 { 3700 if (mod & MODconst) 3701 *pt = (*pt)->constOf(); 3702 else if (mod & MODinvariant) 3703 *pt = (*pt)->invariantOf(); 3704 } 3698 3705 } 3699 3706 … … 3839 3846 s->semantic(sc); 3840 3847 resolveHelper(loc, sc, s, NULL, pe, pt, ps); 3848 if (*pt && mod) 3849 { 3850 if (mod & MODconst) 3851 *pt = (*pt)->constOf(); 3852 else if (mod & MODinvariant) 3853 *pt = (*pt)->invariantOf(); 3854 } 3841 3855 //printf("pt = '%s'\n", (*pt)->toChars()); 3842 3856 } … … 4388 4402 } 4389 4403 4404 Expression *TypeTypedef::getProperty(Loc loc, Identifier *ident) 4405 { 4406 #if LOGDOTEXP 4407 printf("TypeTypedef::getProperty(ident = '%s') '%s'\n", ident->toChars(), toChars()); 4408 #endif 4409 if (ident == Id::init) 4410 { 4411 return Type::getProperty(loc, ident); 4412 } 4413 return sym->basetype->getProperty(loc, ident); 4414 } 4415 4390 4416 int TypeTypedef::isintegral() 4391 4417 { … … 4695 4721 TemplateMixin *tm = s->isTemplateMixin(); 4696 4722 if (tm) 4697 { Expression *de; 4698 4699 de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm)); 4723 { 4724 Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm)); 4700 4725 de->type = e->type; 4701 4726 return de; … … 4708 4733 e->semantic(sc); 4709 4734 return e; 4735 } 4736 4737 TemplateInstance *ti = s->isTemplateInstance(); 4738 if (ti) 4739 { if (!ti->semanticdone) 4740 ti->semantic(sc); 4741 s = ti->inst->toAlias(); 4742 if (!s->isTemplateInstance()) 4743 goto L1; 4744 Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, ti)); 4745 de->type = e->type; 4746 return de; 4710 4747 } 4711 4748 … … 5089 5126 } 5090 5127 5128 TemplateInstance *ti = s->isTemplateInstance(); 5129 if (ti) 5130 { if (!ti->semanticdone) 5131 ti->semantic(sc); 5132 s = ti->inst->toAlias(); 5133 if (!s->isTemplateInstance()) 5134 goto L1; 5135 Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, ti)); 5136 de->type = e->type; 5137 return de; 5138 } 5139 5091 5140 d = s->isDeclaration(); 5092 5141 if (!d) branches/dmdfe-2.0/mtype.h
r880 r881 613 613 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 614 614 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 615 Expression *getProperty(Loc loc, Identifier *ident); 615 616 int isbit(); 616 617 int isintegral(); branches/dmdfe-2.0/parse.c
r880 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 387 387 Lprot: 388 388 nextToken(); 389 switch (token.value) 390 { 391 case TOKprivate: 392 case TOKpackage: 393 case TOKprotected: 394 case TOKpublic: 395 case TOKexport: 396 error("redundant protection attribute"); 397 break; 398 } 389 399 a = parseBlock(); 390 400 s = new ProtDeclaration(prot, a); … … 1254 1264 BaseClasses *Parser::parseBaseClasses() 1255 1265 { 1256 enum PROT protection = PROTpublic;1257 1266 BaseClasses *baseclasses = new BaseClasses(); 1258 1267 1259 1268 for (; 1; nextToken()) 1260 1269 { 1270 enum PROT protection = PROTpublic; 1261 1271 switch (token.value) 1262 1272 { 1263 case TOKidentifier:1264 break;1265 1273 case TOKprivate: 1266 1274 protection = PROTprivate; 1267 continue; 1275 nextToken(); 1276 break; 1268 1277 case TOKpackage: 1269 1278 protection = PROTpackage; 1270 continue; 1279 nextToken(); 1280 break; 1271 1281 case TOKprotected: 1272 1282 protection = PROTprotected; 1273 continue; 1283 nextToken(); 1284 break; 1274 1285 case TOKpublic: 1275 1286 protection = PROTpublic; 1276 continue; 1277 default: 1278 error("base classes expected instead of %s", token.toChars()); 1279 return NULL; 1280 } 1281 BaseClass *b = new BaseClass(parseBasicType(), protection); 1282 baseclasses->push(b); 1283 if (token.value != TOKcomma) 1284 break; 1285 protection = PROTpublic; 1287 nextToken(); 1288 break; 1289 } 1290 if (token.value == TOKidentifier) 1291 { 1292 BaseClass *b = new BaseClass(parseBasicType(), protection); 1293 baseclasses->push(b); 1294 if (token.value != TOKcomma) 1295 break; 1296 } 1297 else 1298 { 1299 error("base classes expected instead of %s", token.toChars()); 1300 return NULL; 1301 } 1286 1302 } 1287 1303 return baseclasses; … … 1342 1358 TemplateParameters *Parser::parseTemplateParameterList(int flag) 1343 1359 { 1344 TemplateParameters *tpl ;1360 TemplateParameters *tpl = new TemplateParameters(); 1345 1361 1346 1362 if (!flag && token.value != TOKlparen) … … 1348 1364 goto Lerr; 1349 1365 } 1350 tpl = new TemplateParameters();1351 1366 nextToken(); 1352 1367 … … 1448 1463 { 1449 1464 error("no identifier for template value parameter"); 1450 goto Lerr;1465 tp_ident = new Identifier("error", TOKidentifier); 1451 1466 } 1452 1467 if (token.value == TOKcolon) // : CondExpression … … 1469 1484 } 1470 1485 check(TOKrparen); 1486 Lerr: 1471 1487 return tpl; 1472 1473 Lerr:1474 return NULL;1475 1488 } 1476 1489 branches/dmdfe-2.0/statement.c
r880 r881 1175 1175 Initializer *ie = new ExpInitializer(0, new IntegerExp(k)); 1176 1176 VarDeclaration *var = new VarDeclaration(loc, arg->type, arg->ident, ie); 1177 var->storage_class |= STC const;1177 var->storage_class |= STCmanifest; 1178 1178 DeclarationExp *de = new DeclarationExp(loc, var); 1179 1179 st->push(new ExpStatement(loc, de)); … … 2128 2128 condition->checkIntegral(); 2129 2129 } 2130 condition = condition->optimize(WANTvalue); 2130 2131 2131 2132 sc = sc->push(); branches/dmdfe-2.0/template.c
r880 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 1590 1590 goto Lnomatch; 1591 1591 1592 if (tempinst->tiargs->dim != tp->tempinst->tiargs->dim) 1593 goto Lnomatch; 1594 1592 1595 for (int i = 0; i < tempinst->tiargs->dim; i++) 1593 1596 { 1594 //printf(" test:[%d]\n", i);1597 //printf("\ttest: tempinst->tiargs[%d]\n", i); 1595 1598 Object *o1 = (Object *)tempinst->tiargs->data[i]; 1596 1599 Object *o2 = (Object *)tp->tempinst->tiargs->data[i]; … … 1937 1940 if (!ta) 1938 1941 { 1942 //printf("test1 %s %p %p %p\n", oarg->toChars(), isExpression(oarg), isDsymbol(oarg), isTuple(oarg)); 1939 1943 goto Lnomatch; 1940 1944 } … … 2876 2880 int dosemantic3 = 0; 2877 2881 { Array *a; 2878 int i; 2879 2880 if (sc->scopesym && sc->scopesym->members && !sc->scopesym->isTemplateMixin()) 2881 { 2882 //printf("\t1: adding to %s %s\n", sc->scopesym->kind(), sc->scopesym->toChars()); 2883 a = sc->scopesym->members; 2882 2883 Scope *scx = sc; 2884 #if 0 2885 for (scx = sc; scx; scx = scx->enclosing) 2886 if (scx->scopesym) 2887 break; 2888 #endif 2889 2890 //if (scx && scx->scopesym) printf("3: scx is %s %s\n", scx->scopesym->kind(), scx->scopesym->toChars()); 2891 if (scx && scx->scopesym && scx->scopesym->members && !scx->scopesym->isTemplateMixin()) 2892 { 2893 //printf("\t1: adding to %s %s\n", scx->scopesym->kind(), scx->scopesym->toChars()); 2894 a = scx->scopesym->members; 2884 2895 } 2885 2896 else 2886 2897 { Module *m = sc->module->importedFrom; 2887 //printf("\t2: adding to module %s \n", m->toChars());2898 //printf("\t2: adding to module %s instead of module %s\n", m->toChars(), sc->module->toChars()); 2888 2899 a = m->members; 2889 2900 if (m->semanticdone >= 3) 2890 2901 dosemantic3 = 1; 2891 2902 } 2892 for (i = 0; 1; i++)2903 for (int i = 0; 1; i++) 2893 2904 { 2894 2905 if (i == a->dim) … … 3133 3144 ea = ea->optimize(WANTvalue | WANTinterpret); 3134 3145 tiargs->data[j] = ea; 3146 if (ea->op == TOKtype) 3147 tiargs->data[j] = ea->type; 3135 3148 } 3136 3149 else if (sa) … … 3417 3430 Declaration *d = sa->isDeclaration(); 3418 3431 if (d && !d->isDataseg() && 3432 !(d->storage_class & STCmanifest) && 3419 3433 (!d->isFuncDeclaration() || d->isFuncDeclaration()->isNested()) && 3420 3434 !isTemplateMixin()) branches/dmdfe-2.0/toir.c
r838 r881 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 103 103 * a nested function from its enclosing function. 104 104 */ 105 #if V2 105 106 if (irs->sclosure) 106 107 ethis = el_var(irs->sclosure); 107 else if (irs->sthis) 108 else 109 #endif 110 if (irs->sthis) 108 111 { // We have a 'this' pointer for the current function 109 112 ethis = el_var(irs->sthis); … … 189 192 */ 190 193 ClassDeclaration *cd = s->isClassDeclaration(); 191 assert(cd); 194 if (!cd) 195 goto Lnoframe; 192 196 if (//cd->baseClass == fd || 193 197 fd->isClassDeclaration() && … … 196 200 if (!cd->isNested() || !cd->vthis) 197 201 { 202 Lnoframe: 198 203 irs->getFunc()->error(loc, "cannot get frame pointer to %s", fd->toChars()); 199 204 return el_long(TYnptr, 0); // error recovery … … 394 399 */ 395 400 401 #if V2 402 396 403 void FuncDeclaration::buildClosure(IRState *irs) 397 404 { … … 477 484 } 478 485 479 486 #endif 487 branches/dmdfe-2.0/toobj.c
r880 r881 967 967 if (/*protection == PROTprivate ||*/ 968 968 !parent || parent->ident == NULL || parent->isFuncDeclaration()) 969 { 969 970 s->Sclass = SCstatic; 971 } 970 972 else 971 973 #endif branches/dmdfe-2.0/traits.c
r836 r881 232 232 else if (ident == Id::getVirtualFunctions) 233 233 { 234 printf("test1\n"); 235 e->dump(0); 234 236 e = e->semantic(sc); 237 printf("test2\n"); 235 238 236 239 /* Create tuple of virtual function overloads of e
