Changeset 634
- Timestamp:
- 08/27/10 23:02:45 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/expression.c (modified) (2 diffs)
- trunk/src/expression.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/expression.c
r629 r634 3929 3929 return 0; 3930 3930 } 3931 3931 3932 3932 Expression *VarExp::semantic(Scope *sc) 3933 3933 { FuncLiteralDeclaration *fd; 3934 3934 3935 3935 #if LOGSEMANTIC 3936 3936 printf("VarExp::semantic(%s)\n", toChars()); 3937 3937 #endif 3938 3938 if (!type) 3939 3939 { type = var->type; 3940 3940 #if 0 3941 3941 if (var->storage_class & STClazy) 3942 3942 { 3943 3943 TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 3944 3944 type = new TypeDelegate(tf); 3945 3945 type = type->semantic(loc, sc); 3946 3946 } 3947 3947 #endif 3948 3948 } 3949 3950 if (type && !type->deco) 3951 type = type->semantic(loc, sc); 3949 3952 3950 3953 /* Fix for 1161 doesn't work because it causes protection 3951 3954 * problems when instantiating imported templates passing private 3952 3955 * variables as alias template parameters. 3953 3956 */ 3954 3957 //accessCheck(loc, sc, NULL, var); 3955 3958 3956 3959 VarDeclaration *v = var->isVarDeclaration(); 3957 3960 if (v) 3958 3961 { 3959 3962 if (v->isConst() && v->type && type->toBasetype()->ty != Tsarray && v->init) 3960 3963 { 3961 3964 ExpInitializer *ei = v->init->isExpInitializer(); 3962 3965 if (ei) 3963 3966 { 3964 3967 //ei->exp->implicitCastTo(sc, type)->print(); 3965 3968 return ei->exp->implicitCastTo(sc, type); 3966 3969 } 3967 3970 } 3968 3971 v->checkNestedReference(sc, loc); … … 5462 5465 e = type->defaultInit(); 5463 5466 e->loc = loc; 5464 5467 return e; 5465 5468 } 5466 5469 } 5467 5470 if (v->needThis()) 5468 5471 { 5469 5472 if (!eleft) 5470 5473 eleft = new ThisExp(loc); 5471 5474 e = new DotVarExp(loc, eleft, v); 5472 5475 e = e->semantic(sc); 5473 5476 } 5474 5477 else 5475 5478 { 5476 5479 e = new VarExp(loc, v); 5477 5480 if (eleft) 5478 5481 { e = new CommaExp(loc, eleft, e); 5479 5482 e->type = v->type; 5480 5483 } 5481 5484 } 5482 return e->deref(); 5485 //return e->deref(); 5486 e = e->deref(); 5487 return e->semantic(sc); 5483 5488 } 5484 5489 5485 5490 FuncDeclaration *f = s->isFuncDeclaration(); 5486 5491 if (f) 5487 5492 { 5488 5493 //printf("it's a function\n"); 5489 5494 if (f->needThis()) 5490 5495 { 5491 5496 if (!eleft) 5492 5497 eleft = new ThisExp(loc); 5493 5498 e = new DotVarExp(loc, eleft, f); 5494 5499 e = e->semantic(sc); 5495 5500 } 5496 5501 else 5497 5502 { 5498 5503 e = new VarExp(loc, f); 5499 5504 if (eleft) 5500 5505 { e = new CommaExp(loc, eleft, e); 5501 5506 e->type = f->type; 5502 5507 } trunk/src/expression.c
r629 r634 4198 4198 Expression *VarExp::semantic(Scope *sc) 4199 4199 { FuncLiteralDeclaration *fd; 4200 4200 4201 4201 #if LOGSEMANTIC 4202 4202 printf("VarExp::semantic(%s)\n", toChars()); 4203 4203 #endif 4204 4204 // if (var->sem == SemanticStart && var->scope) // if forward referenced 4205 4205 // var->semantic(sc); 4206 4206 if (!type) 4207 4207 { type = var->type; 4208 4208 #if 0 4209 4209 if (var->storage_class & STClazy) 4210 4210 { 4211 4211 TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 4212 4212 type = new TypeDelegate(tf); 4213 4213 type = type->semantic(loc, sc); 4214 4214 } 4215 4215 #endif 4216 4216 } 4217 4217 4218 if (type && !type->deco) 4219 type = type->semantic(loc, sc); 4220 4218 4221 /* Fix for 1161 doesn't work because it causes protection 4219 4222 * problems when instantiating imported templates passing private 4220 4223 * variables as alias template parameters. 4221 4224 */ 4222 4225 //accessCheck(loc, sc, NULL, var); 4223 4226 4224 4227 VarDeclaration *v = var->isVarDeclaration(); 4225 4228 if (v) 4226 4229 { 4227 4230 #if 0 4228 4231 if ((v->isConst() || v->isImmutable()) && 4229 4232 type->toBasetype()->ty != Tsarray && v->init) 4230 4233 { 4231 4234 ExpInitializer *ei = v->init->isExpInitializer(); 4232 4235 if (ei) 4233 4236 { 4234 4237 //ei->exp->implicitCastTo(sc, type)->print(); 4235 4238 return ei->exp->implicitCastTo(sc, type); 4236 4239 } 4237 4240 } … … 5893 5896 { 5894 5897 error("circular reference to '%s'", v->toChars()); 5895 5898 return new ErrorExp(); 5896 5899 } 5897 5900 type = v->type; 5898 5901 if (v->needThis()) 5899 5902 { 5900 5903 if (!eleft) 5901 5904 eleft = new ThisExp(loc); 5902 5905 e = new DotVarExp(loc, eleft, v); 5903 5906 e = e->semantic(sc); 5904 5907 } 5905 5908 else 5906 5909 { 5907 5910 e = new VarExp(loc, v); 5908 5911 if (eleft) 5909 5912 { e = new CommaExp(loc, eleft, e); 5910 5913 e->type = v->type; 5911 5914 } 5912 5915 } 5913 return e->deref(); 5916 //return e->deref(); 5917 e = e->deref(); 5918 return e->semantic(sc); 5914 5919 } 5915 5920 5916 5921 FuncDeclaration *f = s->isFuncDeclaration(); 5917 5922 if (f) 5918 5923 { 5919 5924 //printf("it's a function\n"); 5920 5925 if (f->needThis()) 5921 5926 { 5922 5927 if (!eleft) 5923 5928 eleft = new ThisExp(loc); 5924 5929 e = new DotVarExp(loc, eleft, f); 5925 5930 e = e->semantic(sc); 5926 5931 } 5927 5932 else 5928 5933 { 5929 5934 e = new VarExp(loc, f, 1); 5930 5935 if (eleft) 5931 5936 { e = new CommaExp(loc, eleft, e); 5932 5937 e->type = f->type; 5933 5938 }
