Mercurial > projects > ddmd
view dmd/InExp.d @ 62:6557375aff35
InExp.opId_r
WhileStatement.syntaxCopy
author | korDen |
---|---|
date | Mon, 23 Aug 2010 03:21:32 +0400 |
parents | 4ae0d790a452 |
children | f708f0452e81 |
line wrap: on
line source
module dmd.InExp; import dmd.Expression; import dmd.Identifier; import dmd.Loc; import dmd.Scope; import dmd.IRState; import dmd.BinExp; import dmd.TOK; import dmd.Type; import dmd.Id; import dmd.TY; import dmd.TypeAArray; import dmd.expression.util.arrayTypeCompatible; import dmd.backend.elem; class InExp : BinExp { this(Loc loc, Expression e1, Expression e2) { super(loc, TOKin, InExp.sizeof, e1, e2); } Expression semantic(Scope sc) { if (type) return this; super.semanticp(sc); Expression e = op_overload(sc); if (e) return e; //type = Type.tboolean; Type t2b = e2.type.toBasetype(); if (t2b.ty != TY.Taarray) { error("rvalue of in expression must be an associative array, not %s", e2.type.toChars()); type = Type.terror; } else { TypeAArray ta = cast(TypeAArray)t2b; // Special handling for array keys if (!arrayTypeCompatible(e1.loc, e1.type, ta.index)) { // Convert key to type of key e1 = e1.implicitCastTo(sc, ta.index); } // Return type is pointer to value type = ta.nextOf().pointerTo(); } return this; } int isBit() { return 0; } Identifier opId() { return Id.opIn; } Identifier opId_r() { return Id.opIn_r; } elem* toElem(IRState* irs) { assert(false); } }