Mercurial > projects > ddmd
view dmd/TypeNext.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 51605de93870 |
line wrap: on
line source
module dmd.TypeNext; import dmd.Type; import dmd.TY; import dmd.OutBuffer; import dmd.Loc; import dmd.Scope; import dmd.MATCH; import dmd.MOD; class TypeNext : Type { Type next; this(TY ty, Type next) { super(ty); this.next = next; } version (DumbClone) { } else { final TypeNext cloneTo(TypeNext t) { super.cloneTo(t); return t; } TypeNext clone() { assert(this.classinfo == TypeNext.classinfo); return cloneTo(new TypeNext(ty, next)); } } void toDecoBuffer(OutBuffer buf, int flag) { super.toDecoBuffer(buf, flag); assert(next !is this); //printf("this = %p, ty = %d, next = %p, ty = %d\n", this, this.ty, next, next.ty); next.toDecoBuffer(buf, (flag & 0x100) ? 0 : mod); } void checkDeprecated(Loc loc, Scope sc) { Type.checkDeprecated(loc, sc); if (next) // next can be null if TypeFunction and auto return type next.checkDeprecated(loc, sc); } Type reliesOnTident() { return next.reliesOnTident(); } Type nextOf() { return next; } Type makeConst() { //printf("TypeNext::makeConst() %p, %s\n", this, toChars()); if (cto) { assert(cto.mod == MOD.MODconst); return cto; } TypeNext t = cast(TypeNext)super.makeConst(); if (ty != TY.Tfunction && ty != TY.Tdelegate && (next.deco || next.ty == TY.Tfunction) && !next.isInvariant() && !next.isConst()) { if (next.isShared()) t.next = next.sharedConstOf(); else t.next = next.constOf(); } //printf("TypeNext::makeConst() returns %p, %s\n", t, t.toChars()); return t; } Type makeInvariant() { //printf("TypeNext::makeInvariant() %s\n", toChars()); if (ito) { assert(ito.isInvariant()); return ito; } TypeNext t = cast(TypeNext)Type.makeInvariant(); if (ty != TY.Tfunction && ty != TY.Tdelegate && (next.deco || next.ty == TY.Tfunction) && !next.isInvariant()) { t.next = next.invariantOf(); } return t; } Type makeShared() { //printf("TypeNext::makeShared() %s\n", toChars()); if (sto) { assert(sto.mod == MODshared); return sto; } TypeNext t = cast(TypeNext)Type.makeShared(); if (ty != Tfunction && ty != Tdelegate && (next.deco || next.ty == Tfunction) && !next.isInvariant() && !next.isShared()) { if (next.isConst()) t.next = next.sharedConstOf(); else t.next = next.sharedOf(); } //printf("TypeNext::makeShared() returns %p, %s\n", t, t.toChars()); return t; } Type makeSharedConst() { assert(false); } MATCH constConv(Type to) { assert(false); } void transitive() { /* Invoke transitivity of type attributes */ next = next.addMod(mod); } }