Mercurial > projects > ddmd
diff dmd/NotExp.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | cab4c37afb89 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmd/NotExp.d Sat Oct 24 08:42:06 2009 +0400 @@ -0,0 +1,63 @@ +module dmd.NotExp; + +import dmd.Expression; +import dmd.backend.elem; +import dmd.UnaExp; +import dmd.InterState; +import dmd.Loc; +import dmd.Scope; +import dmd.IRState; +import dmd.TOK; +import dmd.Type; + +import dmd.expression.Not; + +import dmd.backend.OPER; +import dmd.backend.Util; + +class NotExp : UnaExp +{ + this(Loc loc, Expression e) + { + super(loc, TOK.TOKnot, NotExp.sizeof, e); + } + + Expression semantic(Scope sc) + { + UnaExp.semantic(sc); + e1 = resolveProperties(sc, e1); + e1 = e1.checkToBoolean(); + type = Type.tboolean; + return this; + } + + Expression optimize(int result) + { + Expression e; + + e1 = e1.optimize(result); + if (e1.isConst() == 1) + e = Not(type, e1); + else + e = this; + + return e; + } + + Expression interpret(InterState* istate) + { + assert(false); + } + + int isBit() + { + assert(false); + } + + elem* toElem(IRState* irs) + { + elem* e = el_una(OPnot, type.totym(), e1.toElem(irs)); + el_setLoc(e,loc); + return e; + } +} \ No newline at end of file