comparison dmd/mtype.c @ 875:330f999ade44

Merged DMD 1.038
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 06 Jan 2009 16:33:51 +0100
parents aa953cc960b6
children 1c2faa8325d1
comparison
equal deleted inserted replaced
874:2ddee23bd70e 875:330f999ade44
3719 t = tvoid; 3719 t = tvoid;
3720 } 3720 }
3721 return t; 3721 return t;
3722 } 3722 }
3723 3723
3724 Dsymbol *TypeInstance::toDsymbol(Scope *sc)
3725 {
3726 Type *t;
3727 Expression *e;
3728 Dsymbol *s;
3729
3730 //printf("TypeInstance::semantic(%s)\n", toChars());
3731
3732 if (sc->parameterSpecialization)
3733 {
3734 unsigned errors = global.errors;
3735 global.gag++;
3736
3737 resolve(loc, sc, &e, &t, &s);
3738
3739 global.gag--;
3740 if (errors != global.errors)
3741 { if (global.gag == 0)
3742 global.errors = errors;
3743 return NULL;
3744 }
3745 }
3746 else
3747 resolve(loc, sc, &e, &t, &s);
3748
3749 return s;
3750 }
3751
3724 3752
3725 /***************************** TypeTypeof *****************************/ 3753 /***************************** TypeTypeof *****************************/
3726 3754
3727 TypeTypeof::TypeTypeof(Loc loc, Expression *exp) 3755 TypeTypeof::TypeTypeof(Loc loc, Expression *exp)
3728 : TypeQualified(Ttypeof, loc) 3756 : TypeQualified(Ttypeof, loc)
4378 { 4406 {
4379 error(e->loc, "struct %s is forward referenced", sym->toChars()); 4407 error(e->loc, "struct %s is forward referenced", sym->toChars());
4380 return new IntegerExp(e->loc, 0, Type::tint32); 4408 return new IntegerExp(e->loc, 0, Type::tint32);
4381 } 4409 }
4382 4410
4411 /* If e.tupleof
4412 */
4383 if (ident == Id::tupleof) 4413 if (ident == Id::tupleof)
4384 { 4414 {
4385 /* Create a TupleExp 4415 /* Create a TupleExp out of the fields of the struct e:
4416 * (e.field0, e.field1, e.field2, ...)
4386 */ 4417 */
4387 e = e->semantic(sc); // do this before turning on noaccesscheck 4418 e = e->semantic(sc); // do this before turning on noaccesscheck
4388 Expressions *exps = new Expressions; 4419 Expressions *exps = new Expressions;
4389 exps->reserve(sym->fields.dim); 4420 exps->reserve(sym->fields.dim);
4390 for (size_t i = 0; i < sym->fields.dim; i++) 4421 for (size_t i = 0; i < sym->fields.dim; i++)
4475 Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, ti)); 4506 Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, ti));
4476 de->type = e->type; 4507 de->type = e->type;
4477 return de; 4508 return de;
4478 } 4509 }
4479 4510
4511 Import *timp = s->isImport();
4512 if (timp)
4513 {
4514 e = new DsymbolExp(e->loc, s);
4515 e = e->semantic(sc);
4516 return e;
4517 }
4518
4480 d = s->isDeclaration(); 4519 d = s->isDeclaration();
4481 #ifdef DEBUG 4520 #ifdef DEBUG
4482 if (!d) 4521 if (!d)
4483 printf("d = %s '%s'\n", s->kind(), s->toChars()); 4522 printf("d = %s '%s'\n", s->kind(), s->toChars());
4484 #endif 4523 #endif
4519 if (v->toParent() != sym) 4558 if (v->toParent() != sym)
4520 sym->error(e->loc, "'%s' is not a member", v->toChars()); 4559 sym->error(e->loc, "'%s' is not a member", v->toChars());
4521 4560
4522 // *(&e + offset) 4561 // *(&e + offset)
4523 accessCheck(e->loc, sc, e, d); 4562 accessCheck(e->loc, sc, e, d);
4524 4563 #if 0
4525 // LDC we don't want dot exprs turned into pointer arithmetic. it complicates things for no apparent gain
4526 #ifndef IN_LLVM
4527 b = new AddrExp(e->loc, e); 4564 b = new AddrExp(e->loc, e);
4528 b->type = e->type->pointerTo(); 4565 b->type = e->type->pointerTo();
4529 b = new AddExp(e->loc, b, new IntegerExp(e->loc, v->offset, Type::tint32)); 4566 b = new AddExp(e->loc, b, new IntegerExp(e->loc, v->offset, Type::tint32));
4530 b->type = v->type->pointerTo(); 4567 b->type = v->type->pointerTo();
4531 e = new PtrExp(e->loc, b); 4568 e = new PtrExp(e->loc, b);