Mercurial > projects > ddmd
diff dmd/InExp.d @ 8:d42cd5917df4
wysiwyg strings, alias this, templates, TypeSlice implementation
author | dkoroskin <> |
---|---|
date | Mon, 14 Dec 2009 17:43:43 +0300 |
parents | 10317f0c89a5 |
children | 4ae0d790a452 |
line wrap: on
line diff
--- a/dmd/InExp.d Mon Dec 14 14:50:03 2009 +0300 +++ b/dmd/InExp.d Mon Dec 14 17:43:43 2009 +0300 @@ -6,7 +6,12 @@ import dmd.Scope; import dmd.IRState; import dmd.BinExp; -import dmd.TOK; +import dmd.TOK; +import dmd.Type; +import dmd.TY; +import dmd.TypeAArray; + +import dmd.expression.util.arrayTypeCompatible; import dmd.backend.elem; @@ -14,18 +19,47 @@ { this(Loc loc, Expression e1, Expression e2) { - assert(false); - super(loc, TOK.init, 0, e1, e2); + super(loc, TOKin, InExp.sizeof, e1, e2); } Expression semantic(Scope sc) { - assert(false); + 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() { - assert(false); + return 0; } Identifier opId()