Mercurial > projects > ddmd
diff dmd/NegExp.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/NegExp.d Sat Oct 24 08:42:06 2009 +0400 @@ -0,0 +1,93 @@ +module dmd.NegExp; + +import dmd.Expression; +import dmd.Identifier; +import dmd.backend.elem; +import dmd.UnaExp; +import dmd.InterState; +import dmd.OutBuffer; +import dmd.Loc; +import dmd.Scope; +import dmd.IRState; +import dmd.ArrayTypes; +import dmd.TOK; + +import dmd.expression.Neg; + +import dmd.backend.Util; +import dmd.backend.OPER; + +class NegExp : UnaExp +{ + this(Loc loc, Expression e) + { + super(loc, TOKneg, NegExp.sizeof, e); + } + + Expression semantic(Scope sc) + { + Expression e; + + version (LOGSEMANTIC) { + printf("NegExp::semantic('%s')\n", toChars()); + } + if (!type) + { + UnaExp.semantic(sc); + e1 = resolveProperties(sc, e1); + e = op_overload(sc); + if (e) + return e; + + e1.checkNoBool(); + if (e1.op != TOKslice) + e1.checkArithmetic(); + + type = e1.type; + } + return this; + } + + Expression optimize(int result) + { + Expression e; + + e1 = e1.optimize(result); + if (e1.isConst() == 1) + { + e = Neg(type, e1); + } + else + e = this; + + return e; + } + + Expression interpret(InterState* istate) + { + assert(false); + } + + void buildArrayIdent(OutBuffer buf, Expressions arguments) + { + assert(false); + } + + Expression buildArrayLoop(Arguments fparams) + { + assert(false); + } + + Identifier opId() + { + assert(false); + } + + elem* toElem(IRState* irs) + { + elem *e = el_una(OPneg, type.totym(), e1.toElem(irs)); + el_setLoc(e,loc); + return e; + } +} +