Mercurial > projects > ldc
comparison dmd/mtype.c @ 35:3cfcb944304e trunk
[svn r39] * Updated to DMD 1.022 with the exception of:
Bugzilla 278: dmd.conf search path doesn't work
This fix was causing crashes for me :/ So for it's the old behaviour
author | lindquist |
---|---|
date | Tue, 09 Oct 2007 06:21:30 +0200 |
parents | d3ee9efe20e2 |
children | 70d6113eeb8c |
comparison
equal
deleted
inserted
replaced
34:4648206ca213 | 35:3cfcb944304e |
---|---|
552 error(loc, ".typeinfo deprecated, use typeid(type)"); | 552 error(loc, ".typeinfo deprecated, use typeid(type)"); |
553 e = getTypeInfo(NULL); | 553 e = getTypeInfo(NULL); |
554 } | 554 } |
555 else if (ident == Id::init) | 555 else if (ident == Id::init) |
556 { | 556 { |
557 if (ty == Tvoid) | |
558 error(loc, "void does not have an initializer"); | |
557 e = defaultInit(); | 559 e = defaultInit(); |
558 e->loc = loc; | 560 e->loc = loc; |
559 } | 561 } |
560 else if (ident == Id::mangleof) | 562 else if (ident == Id::mangleof) |
561 { | 563 { |
640 // error(loc, ".init cannot be evaluated at compile time"); | 642 // error(loc, ".init cannot be evaluated at compile time"); |
641 } | 643 } |
642 return e; | 644 return e; |
643 } | 645 } |
644 #endif | 646 #endif |
645 return defaultInit(); | 647 Expression *ex = defaultInit(); |
648 ex->loc = e->loc; | |
649 return ex; | |
646 } | 650 } |
647 } | 651 } |
648 if (ident == Id::typeinfo) | 652 if (ident == Id::typeinfo) |
649 { | 653 { |
650 if (!global.params.useDeprecated) | 654 if (!global.params.useDeprecated) |
3758 Expression *em; | 3762 Expression *em; |
3759 | 3763 |
3760 #if LOGDOTEXP | 3764 #if LOGDOTEXP |
3761 printf("TypeEnum::dotExp(e = '%s', ident = '%s') '%s'\n", e->toChars(), ident->toChars(), toChars()); | 3765 printf("TypeEnum::dotExp(e = '%s', ident = '%s') '%s'\n", e->toChars(), ident->toChars(), toChars()); |
3762 #endif | 3766 #endif |
3767 if (!sym->symtab) | |
3768 goto Lfwd; | |
3763 s = sym->symtab->lookup(ident); | 3769 s = sym->symtab->lookup(ident); |
3764 if (!s) | 3770 if (!s) |
3765 { | 3771 { |
3766 return getProperty(e->loc, ident); | 3772 return getProperty(e->loc, ident); |
3767 } | 3773 } |
3768 m = s->isEnumMember(); | 3774 m = s->isEnumMember(); |
3769 em = m->value->copy(); | 3775 em = m->value->copy(); |
3770 em->loc = e->loc; | 3776 em->loc = e->loc; |
3771 return em; | 3777 return em; |
3778 | |
3779 Lfwd: | |
3780 error(e->loc, "forward reference of %s.%s", toChars(), ident->toChars()); | |
3781 return new IntegerExp(0, 0, this); | |
3772 } | 3782 } |
3773 | 3783 |
3774 Expression *TypeEnum::getProperty(Loc loc, Identifier *ident) | 3784 Expression *TypeEnum::getProperty(Loc loc, Identifier *ident) |
3775 { Expression *e; | 3785 { Expression *e; |
3776 | 3786 |
4470 | 4480 |
4471 assert(ClassDeclaration::classinfo); | 4481 assert(ClassDeclaration::classinfo); |
4472 t = ClassDeclaration::classinfo->type; | 4482 t = ClassDeclaration::classinfo->type; |
4473 if (e->op == TOKtype || e->op == TOKdottype) | 4483 if (e->op == TOKtype || e->op == TOKdottype) |
4474 { | 4484 { |
4485 /* For type.classinfo, we know the classinfo | |
4486 * at compile time. | |
4487 */ | |
4475 if (!sym->vclassinfo) | 4488 if (!sym->vclassinfo) |
4476 sym->vclassinfo = new ClassInfoDeclaration(sym); | 4489 sym->vclassinfo = new ClassInfoDeclaration(sym); |
4477 e = new VarExp(e->loc, sym->vclassinfo); | 4490 e = new VarExp(e->loc, sym->vclassinfo); |
4478 e = e->addressOf(sc); | 4491 e = e->addressOf(sc); |
4479 e->type = t; // do this so we don't get redundant dereference | 4492 e->type = t; // do this so we don't get redundant dereference |
4480 } | 4493 } |
4481 else | 4494 else |
4482 { | 4495 { /* For class objects, the classinfo reference is the first |
4496 * entry in the vtbl[] | |
4497 */ | |
4483 e = new PtrExp(e->loc, e); | 4498 e = new PtrExp(e->loc, e); |
4484 e->type = t->pointerTo(); | 4499 e->type = t->pointerTo(); |
4485 if (sym->isInterfaceDeclaration()) | 4500 if (sym->isInterfaceDeclaration()) |
4486 { | 4501 { |
4487 if (sym->isCOMclass()) | 4502 if (sym->isCOMinterface()) |
4503 { /* COM interface vtbl[]s are different in that the | |
4504 * first entry is always pointer to QueryInterface(). | |
4505 * We can't get a .classinfo for it. | |
4506 */ | |
4488 error(e->loc, "no .classinfo for COM interface objects"); | 4507 error(e->loc, "no .classinfo for COM interface objects"); |
4508 } | |
4509 /* For an interface, the first entry in the vtbl[] | |
4510 * is actually a pointer to an instance of struct Interface. | |
4511 * The first member of Interface is the .classinfo, | |
4512 * so add an extra pointer indirection. | |
4513 */ | |
4489 e->type = e->type->pointerTo(); | 4514 e->type = e->type->pointerTo(); |
4490 e = new PtrExp(e->loc, e); | 4515 e = new PtrExp(e->loc, e); |
4491 e->type = t->pointerTo(); | 4516 e->type = t->pointerTo(); |
4492 } | 4517 } |
4493 e = new PtrExp(e->loc, e, t); | 4518 e = new PtrExp(e->loc, e, t); |