Changeset 268
- Timestamp:
- 11/28/09 15:18:23 (2 years ago)
- Files:
-
- trunk/src/idgen.c (modified) (1 diff)
- trunk/src/mtype.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/idgen.c
r257 r268 192 192 { "orass", "opOrAssign" }, 193 193 { "xorass", "opXorAssign" }, 194 194 { "shlass", "opShlAssign" }, 195 195 { "shrass", "opShrAssign" }, 196 196 { "ushrass", "opUShrAssign" }, 197 197 { "catass", "opCatAssign" }, 198 198 { "postinc", "opPostInc" }, 199 199 { "postdec", "opPostDec" }, 200 200 { "index", "opIndex" }, 201 201 { "indexass", "opIndexAssign" }, 202 202 { "slice", "opSlice" }, 203 203 { "sliceass", "opSliceAssign" }, 204 204 { "call", "opCall" }, 205 205 { "cast", "opCast" }, 206 206 { "match", "opMatch" }, 207 207 { "next", "opNext" }, 208 208 { "opIn" }, 209 209 { "opIn_r" }, 210 210 { "opStar" }, 211 211 { "opDot" }, 212 { "opDispatch" }, 212 213 { "opImplicitCast" }, 213 214 214 215 { "classNew", "new" }, 215 216 { "classDelete", "delete" }, 216 217 217 218 // For foreach 218 219 { "apply", "opApply" }, 219 220 { "applyReverse", "opApplyReverse" }, 220 221 221 222 #if 1 222 223 { "Fempty", "empty" }, 223 224 { "Fhead", "front" }, 224 225 { "Ftoe", "back" }, 225 226 { "Fnext", "popFront" }, 226 227 { "Fretreat", "popBack" }, 227 228 #else 228 229 { "Fempty", "empty" }, 229 230 { "Fhead", "head" }, 230 231 { "Ftoe", "toe" }, 231 232 { "Fnext", "next" }, trunk/src/mtype.c
r264 r268 5964 5964 ident != Id::stringof && 5965 5965 ident != Id::offsetof) 5966 5966 { 5967 5967 /* See if we should forward to the alias this. 5968 5968 */ 5969 5969 if (sym->aliasthis) 5970 5970 { /* Rewrite e.ident as: 5971 5971 * e.aliasthis.ident 5972 5972 */ 5973 5973 e = new DotIdExp(e->loc, e, sym->aliasthis->ident); 5974 5974 e = new DotIdExp(e->loc, e, ident); 5975 5975 return e->semantic(sc); 5976 5976 } 5977 5977 5978 5978 /* Look for overloaded opDot() to see if we should forward request 5979 5979 * to it. 5980 5980 */ 5981 5981 Dsymbol *fd = search_function(sym, Id::opDot); 5982 5982 if (fd) 5983 5983 { /* Rewrite e.ident as: 5984 * e.op Id().ident5984 * e.opDot().ident 5985 5985 */ 5986 5986 e = build_overload(e->loc, sc, e, NULL, fd->ident); 5987 5987 e = new DotIdExp(e->loc, e, ident); 5988 return e->semantic(sc); 5989 } 5990 5991 /* Look for overloaded opDispatch to see if we should forward request 5992 * to it. 5993 */ 5994 fd = search_function(sym, Id::opDispatch); 5995 if (fd) 5996 { 5997 /* Rewrite e.ident as: 5998 * e.opDispatch!("ident") 5999 */ 6000 TemplateDeclaration *td = fd->isTemplateDeclaration(); 6001 if (!td) 6002 { 6003 fd->error("must be a template opDispatch(string s), not a %s", fd->kind()); 6004 return new ErrorExp(); 6005 } 6006 StringExp *se = new StringExp(e->loc, ident->toChars()); 6007 TemplateInstance *ti = new TemplateInstance(e->loc, td->ident); 6008 Objects *tiargs = new Objects(); 6009 tiargs->push(se); 6010 ti->tiargs = tiargs; 6011 e = new DotTemplateInstanceExp(e->loc, e, ti); 5988 6012 return e->semantic(sc); 5989 6013 } 5990 6014 } 5991 6015 return Type::dotExp(sc, e, ident); 5992 6016 } 5993 6017 if (!s->isFuncDeclaration()) // because of overloading 5994 6018 s->checkDeprecated(e->loc, sc); 5995 6019 s = s->toAlias(); 5996 6020 5997 6021 v = s->isVarDeclaration(); 5998 6022 if (v && !v->isDataseg()) 5999 6023 { 6000 6024 Expression *ei = v->getConstInitializer(); 6001 6025 if (ei) 6002 6026 { e = ei->copy(); // need to copy it if it's a StringExp 6003 6027 e = e->semantic(sc); 6004 6028 return e; 6005 6029 } 6006 6030 } 6007 6031 … … 6455 6479 ident != Id::stringof && 6456 6480 ident != Id::offsetof) 6457 6481 { 6458 6482 /* See if we should forward to the alias this. 6459 6483 */ 6460 6484 if (sym->aliasthis) 6461 6485 { /* Rewrite e.ident as: 6462 6486 * e.aliasthis.ident 6463 6487 */ 6464 6488 e = new DotIdExp(e->loc, e, sym->aliasthis->ident); 6465 6489 e = new DotIdExp(e->loc, e, ident); 6466 6490 return e->semantic(sc); 6467 6491 } 6468 6492 6469 6493 /* Look for overloaded opDot() to see if we should forward request 6470 6494 * to it. 6471 6495 */ 6472 6496 Dsymbol *fd = search_function(sym, Id::opDot); 6473 6497 if (fd) 6474 6498 { /* Rewrite e.ident as: 6475 * e.op Id().ident6499 * e.opDot().ident 6476 6500 */ 6477 6501 e = build_overload(e->loc, sc, e, NULL, fd->ident); 6478 6502 e = new DotIdExp(e->loc, e, ident); 6503 return e->semantic(sc); 6504 } 6505 6506 /* Look for overloaded opDispatch to see if we should forward request 6507 * to it. 6508 */ 6509 fd = search_function(sym, Id::opDispatch); 6510 if (fd) 6511 { 6512 /* Rewrite e.ident as: 6513 * e.opDispatch!("ident") 6514 */ 6515 TemplateDeclaration *td = fd->isTemplateDeclaration(); 6516 if (!td) 6517 { 6518 fd->error("must be a template opDispatch(string s), not a %s", fd->kind()); 6519 return new ErrorExp(); 6520 } 6521 StringExp *se = new StringExp(e->loc, ident->toChars()); 6522 TemplateInstance *ti = new TemplateInstance(e->loc, td->ident); 6523 Objects *tiargs = new Objects(); 6524 tiargs->push(se); 6525 ti->tiargs = tiargs; 6526 e = new DotTemplateInstanceExp(e->loc, e, ti); 6479 6527 return e->semantic(sc); 6480 6528 } 6481 6529 } 6482 6530 6483 6531 return Type::dotExp(sc, e, ident); 6484 6532 } 6485 6533 } 6486 6534 if (!s->isFuncDeclaration()) // because of overloading 6487 6535 s->checkDeprecated(e->loc, sc); 6488 6536 s = s->toAlias(); 6489 6537 v = s->isVarDeclaration(); 6490 6538 if (v && !v->isDataseg()) 6491 6539 { Expression *ei = v->getConstInitializer(); 6492 6540 6493 6541 if (ei) 6494 6542 { e = ei->copy(); // need to copy it if it's a StringExp 6495 6543 e = e->semantic(sc); 6496 6544 return e; 6497 6545 } 6498 6546 }
