Jacek Caban : jscript: Use bytecode for assigning to array expression.

Alexandre Julliard julliard at winehq.org
Mon Dec 5 14:55:01 CST 2011


Module: wine
Branch: master
Commit: 9aafd0311086a22fde37119fe1a28e6c2b9b9bf5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9aafd0311086a22fde37119fe1a28e6c2b9b9bf5

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Dec  5 11:11:45 2011 +0100

jscript: Use bytecode for assigning to array expression.

---

 dlls/jscript/compile.c |   15 +++++++++++++++
 dlls/jscript/engine.c  |   35 +++++++++++++++++++++++++++++++++++
 dlls/jscript/engine.h  |    1 +
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 3679dfe..a237093 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -358,6 +358,21 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_
             return hres;
         break;
     }
+    case EXPR_ARRAY: {
+        array_expression_t *array_expr = (array_expression_t*)expr->expression1;
+
+        hres = compile_expression(ctx, array_expr->member_expr);
+        if(FAILED(hres))
+            return hres;
+
+        hres = compile_expression(ctx, array_expr->expression);
+        if(FAILED(hres))
+            return hres;
+
+        if(push_instr(ctx, OP_memberid) == -1)
+            return E_OUTOFMEMORY;
+        break;
+    }
     default:
         expr->expr.eval = assign_expression_eval;
         return compile_interp_fallback(ctx, &expr->expr);
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index c445eab..e4d918f 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1573,6 +1573,41 @@ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla
     return hres;
 }
 
+/* ECMA-262 3rd Edition    11.2.1 */
+static HRESULT interp_memberid(exec_ctx_t *ctx)
+{
+    VARIANT *objv, *namev;
+    IDispatch *obj;
+    BSTR name;
+    DISPID id;
+    HRESULT hres;
+
+    TRACE("\n");
+
+    namev = stack_pop(ctx);
+    objv = stack_pop(ctx);
+
+    hres = to_object(ctx->parser->script, objv, &obj);
+    VariantClear(objv);
+    if(SUCCEEDED(hres)) {
+        hres = to_string(ctx->parser->script, namev, &ctx->ei, &name);
+        if(FAILED(hres))
+            IDispatch_Release(obj);
+    }
+    VariantClear(namev);
+    if(FAILED(hres))
+        return hres;
+
+    hres = disp_get_id(ctx->parser->script, obj, name, fdexNameEnsure, &id);
+    SysFreeString(name);
+    if(FAILED(hres)) {
+        IDispatch_Release(obj);
+        return hres;
+    }
+
+    return stack_push_objid(ctx, obj, id);
+}
+
 static void free_dp(DISPPARAMS *dp)
 {
     DWORD i;
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 12329e8..a032f7b 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -62,6 +62,7 @@ typedef struct _func_stack {
     X(jmp_z,      0, ARG_ADDR,   0)        \
     X(lt,         1, 0,0)                  \
     X(lteq,       1, 0,0)                  \
+    X(memberid,   1, 0,0)                  \
     X(minus,      1, 0,0)                  \
     X(mod,        1, 0,0)                  \
     X(mul,        1, 0,0)                  \




More information about the wine-cvs mailing list