Mercurial > projects > ddmd
diff dmd/PostBlitDeclaration.d @ 98:5c859d5fbe27
and more
author | Trass3r |
---|---|
date | Tue, 31 Aug 2010 03:53:49 +0200 |
parents | 43073c7c7769 |
children | e28b18c23469 |
line wrap: on
line diff
--- a/dmd/PostBlitDeclaration.d Tue Aug 31 02:12:15 2010 +0200 +++ b/dmd/PostBlitDeclaration.d Tue Aug 31 03:53:49 2010 +0200 @@ -1,72 +1,103 @@ module dmd.PostBlitDeclaration; import dmd.FuncDeclaration; +import dmd.Global; +import dmd.LINK; +import dmd.LinkDeclaration; import dmd.Loc; import dmd.Identifier; import dmd.Dsymbol; import dmd.Scope; +import dmd.StructDeclaration; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.STC; +import dmd.Type; +import dmd.TypeFunction; import dmd.Id; +version(DMDV2) class PostBlitDeclaration : FuncDeclaration { - this(Loc loc, Loc endloc) + this(Loc loc, Loc endloc) { super(loc, endloc, Id._postblit, STCundefined, null); } - this(Loc loc, Loc endloc, Identifier id) + this(Loc loc, Loc endloc, Identifier id) { - assert(false); - super(loc, loc, null, STC.init, null); + super(loc, loc, id, STCundefined, null); } - override Dsymbol syntaxCopy(Dsymbol) + override Dsymbol syntaxCopy(Dsymbol s) { - assert(false); + assert(!s); + PostBlitDeclaration dd = new PostBlitDeclaration(loc, endloc, ident); + return super.syntaxCopy(dd); } - override void semantic(Scope sc) + override void semantic(Scope sc) { - assert(false); + //writef("PostBlitDeclaration.semantic() %s\n", toChars()); + //writef("ident: %s, %s, %p, %p\n", ident.toChars(), Id.dtor.toChars(), ident, Id.dtor); + //writef("stc = x%llx\n", sc.stc); + parent = sc.parent; + Dsymbol parent = toParent(); + StructDeclaration ad = parent.isStructDeclaration(); + if (!ad) + { + error("post blits are only for struct/union definitions, not %s %s", parent.kind(), parent.toChars()); + } + else if (ident == Id._postblit && semanticRun < PASSsemantic) + ad.postblits.push(this); + + if (!type) + type = new TypeFunction(null, Type.tvoid, false, LINKd); + + sc = sc.push(); + sc.stc &= ~STCstatic; // not static + sc.linkage = LINKd; + + FuncDeclaration.semantic(sc); + + sc.pop(); } - override void toCBuffer(OutBuffer buf, HdrGenState* hgs) + override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { - assert(false); + buf.writestring("this(this)"); + bodyToCBuffer(buf, hgs); } - version(DMDV2) override void toJsonBuffer(OutBuffer buf) { + // intentionally empty } - override bool isVirtual() + override bool isVirtual() { - assert(false); + return false; } - override bool addPreInvariant() + override bool addPreInvariant() { - assert(false); + return false; } - override bool addPostInvariant() + override bool addPostInvariant() { - assert(false); + return (isThis() && vthis && global.params.useInvariants); } - override bool overloadInsert(Dsymbol s) + override bool overloadInsert(Dsymbol s) { - assert(false); + return false; // cannot overload postblits } - override void emitComment(Scope sc) + override void emitComment(Scope sc) { - assert(false); + // intentionally empty } - override PostBlitDeclaration isPostBlitDeclaration() { return this; } -} + override PostBlitDeclaration isPostBlitDeclaration() { return this; } +} \ No newline at end of file