Changeset 791
- Timestamp:
- 12/07/10 23:19:16 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/interpret.c (modified) (1 diff)
- trunk/src/interpret.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/interpret.c
r790 r791 1316 1316 return getVarExp(loc, istate, var); 1317 1317 } 1318 1318 1319 1319 Expression *DeclarationExp::interpret(InterState *istate) 1320 1320 { 1321 1321 #if LOG 1322 1322 printf("DeclarationExp::interpret() %s\n", toChars()); 1323 1323 #endif 1324 1324 Expression *e; 1325 1325 VarDeclaration *v = declaration->isVarDeclaration(); 1326 1326 if (v) 1327 1327 { 1328 1328 Dsymbol *s = v->toAlias(); 1329 1329 if (s == v && !v->isStatic() && v->init) 1330 1330 { 1331 1331 ExpInitializer *ie = v->init->isExpInitializer(); 1332 1332 if (ie) 1333 1333 e = ie->exp->interpret(istate); 1334 1334 else if (v->init->isVoidInitializer()) 1335 1335 e = NULL; 1336 else 1337 { 1338 error("Declaration %s is not yet implemented in CTFE", toChars()); 1339 e = EXP_CANT_INTERPRET; 1340 } 1336 1341 } 1337 1342 #if DMDV2 1338 1343 else if (s == v && (v->isConst() || v->isImmutable()) && v->init) 1339 1344 #else 1340 1345 else if (s == v && v->isConst() && v->init) 1341 1346 #endif 1342 1347 { e = v->init->toExpression(); 1343 1348 if (!e) 1344 1349 e = EXP_CANT_INTERPRET; 1345 1350 else if (!e->type) 1346 1351 e->type = v->type; 1347 1352 } 1348 #if 0 // currently fails test interpret3.d 1353 else if (s->isTupleDeclaration() && !v->init) 1354 e = NULL; 1349 1355 else 1350 1356 { 1351 error(" %s cannot be interpreted at compile time");1357 error("Declaration %s is not yet implemented in CTFE", toChars()); 1352 1358 e = EXP_CANT_INTERPRET; 1353 1359 } 1354 #endif1355 1360 } 1356 1361 else if (declaration->isAttribDeclaration() || 1357 1362 declaration->isTemplateMixin() || 1358 1363 declaration->isTupleDeclaration()) 1359 1364 { // These can be made to work, too lazy now 1360 error("Declaration %s is not yet implemented in CTFE", toChars()); 1361 1365 error("Declaration %s is not yet implemented in CTFE", toChars()); 1362 1366 e = EXP_CANT_INTERPRET; 1363 1367 } 1364 1368 else 1365 1369 { // Others should not contain executable code, so are trivial to evaluate 1366 1370 e = NULL; 1367 1371 } 1368 1372 #if LOG 1369 1373 printf("-DeclarationExp::interpret(%s): %p\n", toChars(), e); 1370 1374 #endif 1371 1375 return e; 1372 1376 } 1373 1377 1374 1378 Expression *TupleExp::interpret(InterState *istate) 1375 1379 { 1376 1380 #if LOG 1377 1381 printf("TupleExp::interpret() %s\n", toChars()); 1378 1382 #endif 1379 1383 Expressions *expsx = NULL; 1380 1384 1381 1385 for (size_t i = 0; i < exps->dim; i++) trunk/src/interpret.c
r790 r791 1316 1316 return getVarExp(loc, istate, var); 1317 1317 } 1318 1318 1319 1319 Expression *DeclarationExp::interpret(InterState *istate) 1320 1320 { 1321 1321 #if LOG 1322 1322 printf("DeclarationExp::interpret() %s\n", toChars()); 1323 1323 #endif 1324 1324 Expression *e; 1325 1325 VarDeclaration *v = declaration->isVarDeclaration(); 1326 1326 if (v) 1327 1327 { 1328 1328 Dsymbol *s = v->toAlias(); 1329 1329 if (s == v && !v->isStatic() && v->init) 1330 1330 { 1331 1331 ExpInitializer *ie = v->init->isExpInitializer(); 1332 1332 if (ie) 1333 1333 e = ie->exp->interpret(istate); 1334 1334 else if (v->init->isVoidInitializer()) 1335 1335 e = NULL; 1336 else 1337 { 1338 error("Declaration %s is not yet implemented in CTFE", toChars()); 1339 e = EXP_CANT_INTERPRET; 1340 } 1336 1341 } 1337 1342 #if DMDV2 1338 1343 else if (s == v && (v->isConst() || v->isImmutable()) && v->init) 1339 1344 #else 1340 1345 else if (s == v && v->isConst() && v->init) 1341 1346 #endif 1342 1347 { e = v->init->toExpression(); 1343 1348 if (!e) 1344 1349 e = EXP_CANT_INTERPRET; 1345 1350 else if (!e->type) 1346 1351 e->type = v->type; 1347 1352 } 1348 #if 0 // currently fails test interpret3.d 1353 else if (s->isTupleDeclaration() && !v->init) 1354 e = NULL; 1349 1355 else 1350 1356 { 1351 error(" %s cannot be interpreted at compile time");1357 error("Declaration %s is not yet implemented in CTFE", toChars()); 1352 1358 e = EXP_CANT_INTERPRET; 1353 1359 } 1354 #endif1355 1360 } 1356 1361 else if (declaration->isAttribDeclaration() || 1357 1362 declaration->isTemplateMixin() || 1358 1363 declaration->isTupleDeclaration()) 1359 1364 { // These can be made to work, too lazy now 1360 error("Declaration %s is not yet implemented in CTFE", toChars()); 1361 1365 error("Declaration %s is not yet implemented in CTFE", toChars()); 1362 1366 e = EXP_CANT_INTERPRET; 1363 1367 } 1364 1368 else 1365 1369 { // Others should not contain executable code, so are trivial to evaluate 1366 1370 e = NULL; 1367 1371 } 1368 1372 #if LOG 1369 1373 printf("-DeclarationExp::interpret(%s): %p\n", toChars(), e); 1370 1374 #endif 1371 1375 return e; 1372 1376 } 1373 1377 1374 1378 Expression *TupleExp::interpret(InterState *istate) 1375 1379 { 1376 1380 #if LOG 1377 1381 printf("TupleExp::interpret() %s\n", toChars()); 1378 1382 #endif 1379 1383 Expressions *expsx = NULL; 1380 1384 1381 1385 for (size_t i = 0; i < exps->dim; i++)
