Module: wine Branch: master Commit: aa809f1b7ee39c2b3879fb8998e92d96ad8d58f1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=aa809f1b7ee39c2b3879fb8998...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Dec 7 11:01:13 2011 +0100
jscript: Added bytecode version of array expression.
---
dlls/jscript/compile.c | 2 ++ dlls/jscript/engine.c | 40 ++++++++++++++++++++++++++++++++++++++++ dlls/jscript/engine.h | 1 + 3 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index c1073d8..3e5800e 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -558,6 +558,8 @@ static HRESULT compile_expression_noret(compiler_ctx_t *ctx, expression_t *expr, return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add); case EXPR_AND: return compile_logical_expression(ctx, (binary_expression_t*)expr, OP_jmp_z); + case EXPR_ARRAY: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_array); case EXPR_ASSIGN: return compile_assign_expression(ctx, (binary_expression_t*)expr, OP_LAST); case EXPR_ASSIGNADD: diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index b6eeaed..e98e98a 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1561,6 +1561,46 @@ HRESULT array_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flag }
/* ECMA-262 3rd Edition 11.2.1 */ +static HRESULT interp_array(exec_ctx_t *ctx) +{ + VARIANT v, *namev; + IDispatch *obj; + DISPID id; + BSTR name; + HRESULT hres; + + TRACE("\n"); + + namev = stack_pop(ctx); + + hres = stack_pop_object(ctx, &obj); + if(FAILED(hres)) { + VariantClear(namev); + return hres; + } + + hres = to_string(ctx->parser->script, namev, &ctx->ei, &name); + if(FAILED(hres)) { + IDispatch_Release(obj); + return hres; + } + + hres = disp_get_id(ctx->parser->script, obj, name, 0, &id); + SysFreeString(name); + if(SUCCEEDED(hres)) { + hres = disp_propget(ctx->parser->script, obj, id, &v, &ctx->ei, NULL/*FIXME*/); + }else if(hres == DISP_E_UNKNOWNNAME) { + V_VT(&v) = VT_EMPTY; + hres = S_OK; + } + IDispatch_Release(obj); + if(FAILED(hres)) + return hres; + + return stack_push(ctx, &v); +} + +/* ECMA-262 3rd Edition 11.2.1 */ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) { member_expression_t *expr = (member_expression_t*)_expr; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index fdc732d..8b2c0a7 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -43,6 +43,7 @@ typedef struct _func_stack {
#define OP_LIST \ X(add, 1, 0,0) \ + X(array, 1, 0,0) \ X(assign, 1, 0,0) \ X(bool, 1, ARG_INT, 0) \ X(bneg, 1, 0,0) \