diff dmd/RemoveExp.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 2e2a5c3f943a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmd/RemoveExp.d	Sat Oct 24 08:42:06 2009 +0400
@@ -0,0 +1,57 @@
+module dmd.RemoveExp;
+
+import dmd.Expression;
+import dmd.backend.elem;
+import dmd.Loc;
+import dmd.IRState;
+import dmd.BinExp;
+import dmd.TOK;
+import dmd.Type;
+import dmd.TypeAArray;
+import dmd.TY;
+
+import dmd.backend.Util;
+import dmd.backend.OPER;
+import dmd.backend.Symbol;
+import dmd.backend.TYM;
+import dmd.backend.mTY;
+
+/* This deletes the key e1 from the associative array e2
+ */
+
+class RemoveExp : BinExp
+{
+	this(Loc loc, Expression e1, Expression e2)
+	{
+		super(loc, TOKremove, RemoveExp.sizeof, e1, e2);
+		type = Type.tvoid;
+	}
+
+	elem* toElem(IRState* irs)
+	{
+		elem* e;
+		Type tb = e1.type.toBasetype();
+		assert(tb.ty == Taarray);
+		TypeAArray taa = cast(TypeAArray)tb;
+		elem* ea = e1.toElem(irs);
+		elem* ekey = e2.toElem(irs);
+		elem* ep;
+		elem* keyti;
+
+		if (tybasic(ekey.Ety) == TYstruct)
+		{
+			ekey = el_una(OPstrpar, TYstruct, ekey);
+			ekey.Enumbytes = ekey.E1.Enumbytes;
+			assert(ekey.Enumbytes);
+		}
+
+		Symbol* s = taa.aaGetSymbol("Del", 0);
+		keyti = taa.index.getInternalTypeInfo(null).toElem(irs);
+		ep = el_params(ekey, keyti, ea, null);
+		e = el_bin(OPcall, TYnptr, el_var(s), ep);
+
+		el_setLoc(e,loc);
+		return e;
+	}
+}
+