Mercurial > projects > ddmd
diff dmd/MinAssignExp.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 832f71e6f96c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmd/MinAssignExp.d Sat Oct 24 08:42:06 2009 +0400 @@ -0,0 +1,93 @@ +module dmd.MinAssignExp; + +import dmd.BinExp; +import dmd.Loc; +import dmd.Expression; +import dmd.Scope; +import dmd.InterState; +import dmd.OutBuffer; +import dmd.ArrayTypes; +import dmd.Identifier; +import dmd.IRState; +import dmd.TY; +import dmd.TOK; +import dmd.Id; + +import dmd.backend.elem; +import dmd.backend.Util; +import dmd.backend.OPER; + +class MinAssignExp : BinExp +{ + this(Loc loc, Expression e1, Expression e2) + { + super(loc, TOK.TOKminass, MinAssignExp.sizeof, e1, e2); + } + + Expression semantic(Scope sc) + { + Expression e; + + if (type) + return this; + + BinExp.semantic(sc); + e2 = resolveProperties(sc, e2); + + e = op_overload(sc); + if (e) + return e; + + if (e1.op == TOKslice) + { // T[] -= ... + typeCombine(sc); + type = e1.type; + return arrayOp(sc); + } + + e1 = e1.modifiableLvalue(sc, e1); + e1.checkScalar(); + e1.checkNoBool(); + if (e1.type.ty == Tpointer && e2.type.isintegral()) + e = scaleFactor(sc); + else + { + e1 = e1.checkArithmetic(); + e2 = e2.checkArithmetic(); + type = e1.type; + typeCombine(sc); + if (type.isreal() || type.isimaginary()) + { + assert(e2.type.isfloating()); + e2 = e2.castTo(sc, e1.type); + } + 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() /* For operator overloading */ + { + return Id.subass; + } + + elem* toElem(IRState* irs) + { + return toElemBin(irs,OPminass); + } +} \ No newline at end of file