Mercurial > projects > ddmd
view dmd/TypeReturn.d @ 77:ad4792a1cfd6
more D-ification container accessing
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Sun, 29 Aug 2010 14:36:55 +0100 |
parents | 2e2a5c3f943a |
children | e28b18c23469 |
line wrap: on
line source
module dmd.TypeReturn; import dmd.Loc; import dmd.MOD; import dmd.Type; import dmd.TypeQualified; import dmd.Scope; import dmd.Dsymbol; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.Identifier; import dmd.TY; class TypeReturn : TypeQualified { this(Loc loc) { super(TY.Treturn, loc); } version (DumbClone) { } else { Type clone() { assert(false); } } override Type syntaxCopy() { TypeReturn t = new TypeReturn(loc); t.syntaxCopyHelper(this); t.mod = mod; return t; } override Dsymbol toDsymbol(Scope sc) { Type t = semantic(Loc(0), sc); if (t is this) return null; return t.toDsymbol(sc); } override Type semantic(Loc loc, Scope sc) { Type t; if (!sc.func) { error(loc, "typeof(return) must be inside function"); goto Lerr; } t = sc.func.type.nextOf(); t = t.addMod(mod); if (idents.dim) { Dsymbol s = t.toDsymbol(sc); for (size_t i = 0; i < idents.dim; i++) { if (!s) break; Identifier id = cast(Identifier)idents.data[i]; s = s.searchX(loc, sc, id); } if (s) { t = s.getType(); if (!t) { error(loc, "%s is not a type", s.toChars()); goto Lerr; } } else { error(loc, "cannot resolve .property for %s", toChars()); goto Lerr; } } return t; Lerr: return terror; } override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod) { assert(false); } }