Mercurial > projects > ddmd
view dmd/TypeNext.d @ 84:be2ab491772e
Expressions -> Vector!Expression
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 16:12:19 +0100 |
parents | 2e2a5c3f943a |
children | acd69f84627e |
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)); } } override 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); } override 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); } override Type reliesOnTident() { return next.reliesOnTident(); } override Type nextOf() { return next; } override 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; } override 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; } override 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; } override Type makeSharedConst() { assert(false); } override MATCH constConv(Type to) { MATCH m = Type.constConv(to); if (m == MATCHconst && next.constConv((cast(TypeNext)to).next) == MATCHnomatch) m = MATCHnomatch; return m; } void transitive() { /* Invoke transitivity of type attributes */ next = next.addMod(mod); } }