diff dmd/MulAssignExp.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/MulAssignExp.d	Sat Oct 24 08:42:06 2009 +0400
@@ -0,0 +1,110 @@
+module dmd.MulAssignExp;
+
+import dmd.BinExp;
+import dmd.Loc;
+import dmd.Expression;
+import dmd.Scope;
+import dmd.InterState;
+import dmd.OutBuffer;
+import dmd.Id;
+import dmd.ArrayTypes;
+import dmd.Identifier;
+import dmd.IRState;
+import dmd.TOK;
+import dmd.Type;
+import dmd.TY;
+
+import dmd.backend.elem;
+import dmd.backend.OPER;
+import dmd.expression.Util;
+
+class MulAssignExp : BinExp
+{
+    this(Loc loc, Expression e1, Expression e2)
+	{
+		super(loc, TOK.TOKmulass, MulAssignExp.sizeof, e1, e2);
+	}
+	
+    Expression semantic(Scope sc)
+	{
+		Expression e;
+
+		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();
+		type = e1.type;
+		typeCombine(sc);
+		e1.checkArithmetic();
+		e2.checkArithmetic();
+		if (e2.type.isfloating())
+		{	
+			Type t1;
+			Type t2;
+
+			t1 = e1.type;
+			t2 = e2.type;
+			if (t1.isreal())
+			{
+				if (t2.isimaginary() || t2.iscomplex())
+				{
+					e2 = e2.castTo(sc, t1);
+				}
+			}
+			else if (t1.isimaginary())
+			{
+				if (t2.isimaginary() || t2.iscomplex())
+				{
+					switch (t1.ty)
+					{
+						case Timaginary32: t2 = Type.tfloat32; break;
+						case Timaginary64: t2 = Type.tfloat64; break;
+						case Timaginary80: t2 = Type.tfloat80; break;
+						default:
+							assert(0);
+					}
+					e2 = e2.castTo(sc, t2);
+				}
+			}
+		}
+		return this;
+	}
+	
+    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.mulass;
+	}
+
+    elem* toElem(IRState* irs)
+	{
+		return toElemBin(irs,OPmulass);
+	}
+}
\ No newline at end of file