Mercurial > projects > ddmd
diff dmd/TypeInstance.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 5c9b78899f5d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmd/TypeInstance.d Sat Oct 24 08:42:06 2009 +0400 @@ -0,0 +1,118 @@ +module dmd.TypeInstance; + +import dmd.TypeQualified; +import dmd.TemplateInstance; +import dmd.MOD; +import dmd.MATCH; +import dmd.Loc; +import dmd.Global; +import dmd.Type; +import dmd.OutBuffer; +import dmd.HdrGenState; +import dmd.Dsymbol; +import dmd.Expression; +import dmd.Scope; +import dmd.ArrayTypes; +import dmd.TY; + +/* Similar to TypeIdentifier, but with a TemplateInstance as the root + */ +class TypeInstance : TypeQualified +{ + TemplateInstance tempinst; + + this(Loc loc, TemplateInstance tempinst) + { + super(Tinstance, loc); + this.tempinst = tempinst; + } + +version (DumbClone) { +} else { + Type clone() + { + assert(false); + } +} + + Type syntaxCopy() + { + assert(false); + } + + //char *toChars(); + + //void toDecoBuffer(OutBuffer *buf, int flag); + + void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod) + { + assert(false); + } + + void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps) + { + // Note close similarity to TypeIdentifier::resolve() + Dsymbol s; + + *pe = null; + *pt = null; + *ps = null; + + static if (false) { + if (!idents.dim) + { + error(loc, "template instance '%s' has no identifier", toChars()); + return; + } + } + //id = (Identifier *)idents.data[0]; + //printf("TypeInstance::resolve(sc = %p, idents = '%s')\n", sc, id->toChars()); + s = tempinst; + if (s) + s.semantic(sc); + resolveHelper(loc, sc, s, null, pe, pt, ps); + if (*pt) + *pt = (*pt).addMod(mod); + //printf("pt = '%s'\n", (*pt)->toChars()); + } + + Type semantic(Loc loc, Scope sc) + { + assert(false); + } + + Dsymbol toDsymbol(Scope sc) + { + Type t; + Expression e; + Dsymbol s; + + //printf("TypeInstance::semantic(%s)\n", toChars()); + + if (sc.parameterSpecialization) + { + uint errors = global.errors; + global.gag++; + + resolve(loc, sc, &e, &t, &s); + + global.gag--; + if (errors != global.errors) + { + if (global.gag == 0) + global.errors = errors; + + return null; + } + } + else + resolve(loc, sc, &e, &t, &s); + + return s; + } + + MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes) + { + assert(false); + } +} \ No newline at end of file