Mercurial > projects > ddmd
view dmd/InvariantDeclaration.d @ 160:ff61fb0e06ae
RTLSYM update
author | korDen |
---|---|
date | Mon, 20 Sep 2010 01:18:05 +0400 |
parents | e28b18c23469 |
children | e3afd1303184 |
line wrap: on
line source
module dmd.InvariantDeclaration; import dmd.common; import dmd.FuncDeclaration; import dmd.Loc; import dmd.Dsymbol; import dmd.Id; import dmd.Scope; import dmd.OutBuffer; import dmd.HdrGenState; import dmd.LINK; import dmd.STC; import dmd.TypeFunction; import dmd.Type; import dmd.AggregateDeclaration; class InvariantDeclaration : FuncDeclaration { this(Loc loc, Loc endloc) { super(loc, endloc, Id.classInvariant, STCundefined, null); } override Dsymbol syntaxCopy(Dsymbol s) { assert(!s); InvariantDeclaration id = new InvariantDeclaration(loc, endloc); FuncDeclaration.syntaxCopy(id); return id; } override void semantic(Scope sc) { AggregateDeclaration ad; Type tret; parent = sc.parent; Dsymbol parent = toParent(); ad = parent.isAggregateDeclaration(); if (!ad) { error("invariants are only for struct/union/class definitions"); return; } else if (ad.inv && ad.inv != this) { error("more than one invariant for %s", ad.toChars()); } ad.inv = this; type = new TypeFunction(null, Type.tvoid, false, LINKd); sc = sc.push(); sc.stc &= ~STCstatic; // not a static invariant sc.incontract++; sc.linkage = LINK.LINKd; FuncDeclaration.semantic(sc); sc.pop(); } override bool isVirtual() { return false; } override bool addPreInvariant() { return false; } override bool addPostInvariant() { return false; } override void emitComment(Scope sc) { assert(false); } override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { if (hgs.hdrgen) return; buf.writestring("invariant"); bodyToCBuffer(buf, hgs); } override void toJsonBuffer(OutBuffer buf) { } override InvariantDeclaration isInvariantDeclaration() { return this; } }