Changeset 657
- Timestamp:
- 07/02/07 18:12:57 (1 year ago)
- Files:
-
- branches/dmdfe/cast.c (modified) (2 diffs)
- branches/dmdfe/declaration.c (modified) (1 diff)
- branches/dmdfe/expression.c (modified) (2 diffs)
- branches/dmdfe/init.c (modified) (1 diff)
- branches/dmdfe/init.h (modified) (3 diffs)
- branches/dmdfe/interpret.c (modified) (4 diffs)
- branches/dmdfe/mars.c (modified) (1 diff)
- branches/dmdfe/parse.c (modified) (1 diff)
- branches/dmdfe/statement.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmdfe/cast.c
r523 r657 333 333 { MATCH m; 334 334 335 //printf("StringExp::implicitConvTo(t = %s), '%s' committed = %d\n", t->toChars(), toChars(), committed); 335 #if 0 336 printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", 337 toChars(), committed, type->toChars(), t->toChars()); 338 #endif 336 339 if (!committed) 337 340 { … … 351 354 ((TypeSArray *)t)->dim->toInteger()) 352 355 return MATCHnomatch; 356 goto L1; 353 357 case Tarray: 358 goto L1; 354 359 case Tpointer: 360 L1: 355 361 if (t->next->ty == Tchar) 356 362 return MATCHexact; branches/dmdfe/declaration.c
r523 r657 802 802 if (init) 803 803 { 804 ArrayInitializer *ai = init->isArrayInitializer(); 805 if (ai && type->toBasetype()->ty == Taarray) 806 { 807 init = ai->toAssocArrayInitializer(); 808 } 809 804 810 ExpInitializer *ei = init->isExpInitializer(); 805 811 branches/dmdfe/expression.c
r656 r657 2460 2460 error("%s has no value", e->toChars()); 2461 2461 e = resolveProperties(sc, e); 2462 2463 unsigned char committed = 1; 2464 if (e->op == TOKstring) 2465 committed = ((StringExp *)e)->committed; 2466 2462 2467 if (!t0) 2463 2468 { t0 = e->type; … … 2471 2476 else 2472 2477 e = e->implicitCastTo(sc, t0); 2478 if (!committed && e->op == TOKstring) 2479 { StringExp *se = (StringExp *)e; 2480 se->committed = 0; 2481 } 2473 2482 elements->data[i] = (void *)e; 2474 2483 } branches/dmdfe/init.c
r460 r657 387 387 388 388 389 /******************************** 390 * If possible, convert array initializer to associative array initializer. 391 */ 392 393 Initializer *ArrayInitializer::toAssocArrayInitializer() 394 { Expressions *keys; 395 Expressions *values; 396 Expression *e; 397 398 //printf("ArrayInitializer::toAssocArrayInitializer()\n"); 399 //static int i; if (++i == 2) halt(); 400 keys = new Expressions(); 401 keys->setDim(value.dim); 402 values = new Expressions(); 403 values->setDim(value.dim); 404 405 for (size_t i = 0; i < value.dim; i++) 406 { 407 e = (Expression *)index.data[i]; 408 if (!e) 409 goto Lno; 410 keys->data[i] = (void *)e; 411 412 Initializer *iz = (Initializer *)value.data[i]; 413 if (!iz) 414 goto Lno; 415 e = iz->toExpression(); 416 if (!e) 417 goto Lno; 418 values->data[i] = (void *)e; 419 } 420 e = new AssocArrayLiteralExp(loc, keys, values); 421 return new ExpInitializer(loc, e); 422 423 Lno: 424 delete keys; 425 delete values; 426 error(loc, "not an associative array initializer"); 427 return this; 428 } 429 430 389 431 Type *ArrayInitializer::inferType(Scope *sc) 390 432 { branches/dmdfe/init.h
r460 r657 24 24 struct AggregateDeclaration; 25 25 struct VoidInitializer; 26 struct ArrayInitializer; 26 27 struct ExpInitializer; 27 28 #ifdef _DH … … 44 45 45 46 virtual VoidInitializer *isVoidInitializer() { return NULL; } 47 virtual ArrayInitializer *isArrayInitializer() { return NULL; } 46 48 virtual ExpInitializer *isExpInitializer() { return NULL; } 47 49 }; … … 90 92 Type *inferType(Scope *sc); 91 93 Expression *toExpression(); 94 Initializer *toAssocArrayInitializer(); 92 95 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 93 96 94 97 dt_t *toDtBit(); // for bit arrays 98 99 ArrayInitializer *isArrayInitializer() { return this; } 95 100 }; 96 101 branches/dmdfe/interpret.c
r656 r657 859 859 } 860 860 861 Expression *getVarExp(InterState *istate, VarDeclaration *v)861 Expression *getVarExp(InterState *istate, Declaration *d) 862 862 { 863 863 Expression *e = EXP_CANT_INTERPRET; 864 VarDeclaration *v = d->isVarDeclaration(); 865 SymbolDeclaration *s = d->isSymbolDeclaration(); 864 866 if (v) 865 867 { … … 879 881 e = EXP_CANT_INTERPRET; 880 882 } 883 else if (s) 884 { 885 /* if (s->dsym->toInitializer() == s->sym) 886 { Expressions *exps = new Expressions(); 887 e = new StructLiteralExp(0, s->dsym, exps); 888 e = e->semantic(NULL); 889 } */ 890 } 881 891 return e; 882 892 } … … 887 897 printf("VarExp::interpret() %s\n", toChars()); 888 898 #endif 889 return getVarExp(istate, var ->isVarDeclaration());899 return getVarExp(istate, var); 890 900 } 891 901 … … 1931 1941 } 1932 1942 } 1943 #if LOG 1944 if (e == EXP_CANT_INTERPRET) 1945 printf("PtrExp::interpret() %s = EXP_CANT_INTERPRET\n", toChars()); 1946 #endif 1933 1947 return e; 1934 1948 } branches/dmdfe/mars.c
r656 r657 56 56 copyright = "Copyright (c) 1999-2007 by Digital Mars"; 57 57 written = "written by Walter Bright"; 58 version = "v1.01 4";58 version = "v1.015"; 59 59 global.structalign = 8; 60 60 branches/dmdfe/parse.c
r523 r657 767 767 768 768 nextToken(); 769 //check(TOKlparen); // don't require () 770 //check(TOKrparen); 769 if (token.value == TOKlparen) // optional () 770 { 771 nextToken(); 772 check(TOKrparen); 773 } 771 774 772 775 f = new InvariantDeclaration(loc, 0); branches/dmdfe/statement.c
r523 r657 814 814 condition = condition->semantic(sc); 815 815 condition = resolveProperties(sc, condition); 816 condition = condition->optimize(WANTvalue); 816 817 condition = condition->checkToBoolean(); 817 818
