Mercurial > projects > ddmd
view dmd/AliasThis.d @ 8:d42cd5917df4
wysiwyg strings, alias this, templates, TypeSlice implementation
author | dkoroskin <> |
---|---|
date | Mon, 14 Dec 2009 17:43:43 +0300 |
parents | 10317f0c89a5 |
children | 2e2a5c3f943a |
line wrap: on
line source
module dmd.AliasThis; import dmd.Dsymbol; import dmd.Identifier; import dmd.Loc; import dmd.Scope; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.AggregateDeclaration; class AliasThis : Dsymbol { // alias Identifier this; Identifier ident; this(Loc loc, Identifier ident) { super(null); // it's anonymous (no identifier) this.loc = loc; this.ident = ident; } Dsymbol syntaxCopy(Dsymbol s) { assert(!s); /* Since there is no semantic information stored here, * we don't need to copy it. */ return this; } void semantic(Scope sc) { Dsymbol parent = sc.parent; if (parent) parent = parent.pastMixin(); AggregateDeclaration ad = null; if (parent) ad = parent.isAggregateDeclaration(); if (ad) { if (ad.aliasthis) error("there can be only one alias this"); assert(ad.members); Dsymbol s = ad.search(loc, ident, 0); ad.aliasthis = s; } else error("alias this can only appear in struct or class declaration, not %s", parent ? parent.toChars() : "nowhere"); } string kind() { assert(false); } void toCBuffer(OutBuffer buf, HdrGenState* hgs) { assert(false); } AliasThis isAliasThis() { return this; } }