From 63366f8f1b4cec1350874fda6b2eb3b0ddf7ee36 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 15 Dec 2011 15:44:08 +0100 Subject: [PATCH] jscript: Always use compiler for member, array and identifier expressions. --- dlls/jscript/engine.c | 40 +++++++++++++++------------------------- dlls/jscript/engine.h | 3 --- dlls/jscript/parser.y | 6 +++--- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index cdfc4e346ed..31781ef432a 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -282,12 +282,6 @@ static HRESULT exprval_to_boolean(script_ctx_t *ctx, exprval_t *exprval, jsexcep return to_boolean(&exprval->u.var, b); } -static void exprval_init(exprval_t *val) -{ - val->type = EXPRVAL_VARIANT; - V_VT(&val->u.var) = VT_EMPTY; -} - static void exprval_set_idref(exprval_t *val, IDispatch *disp, DISPID id) { val->type = EXPRVAL_IDREF; @@ -1012,6 +1006,10 @@ HRESULT for_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t return S_OK; } +static HRESULT array_expression_eval(script_ctx_t*,expression_t*,jsexcept_t*,exprval_t*); +static HRESULT member_expression_eval(script_ctx_t*,expression_t*,jsexcept_t*,exprval_t*); +static HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,jsexcept_t*,exprval_t*); + /* ECMA-262 3rd Edition 12.6.4 */ HRESULT forin_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret) { @@ -1076,13 +1074,13 @@ HRESULT forin_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_ }else { switch(stat->expr->type) { case EXPR_ARRAY: - hres = array_expression_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval); + hres = array_expression_eval(ctx, stat->expr, &rt->ei, &exprval); break; case EXPR_IDENT: - hres = identifier_expression_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval); + hres = identifier_expression_eval(ctx, stat->expr, &rt->ei, &exprval); break; case EXPR_MEMBER: - hres = member_expression_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval); + hres = member_expression_eval(ctx, stat->expr, &rt->ei, &exprval); break; default: hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval); @@ -1452,7 +1450,7 @@ HRESULT function_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD f } /* ECMA-262 3rd Edition 11.2.1 */ -HRESULT array_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +static HRESULT array_expression_eval(script_ctx_t *ctx, expression_t *_expr, jsexcept_t *ei, exprval_t *ret) { binary_expression_t *expr = (binary_expression_t*)_expr; exprval_t exprval; @@ -1489,16 +1487,12 @@ HRESULT array_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flag hres = to_string(ctx, &val, ei, &str); VariantClear(&val); if(SUCCEEDED(hres)) { - hres = disp_get_id(ctx, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx, obj, str, fdexNameEnsure, &id); SysFreeString(str); } - if(SUCCEEDED(hres)) { + if(SUCCEEDED(hres)) exprval_set_idref(ret, obj, id); - }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) { - exprval_init(ret); - hres = S_OK; - } IDispatch_Release(obj); } @@ -1548,7 +1542,7 @@ static HRESULT interp_array(exec_ctx_t *ctx) } /* 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) +static HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, jsexcept_t *ei, exprval_t *ret) { member_expression_t *expr = (member_expression_t*)_expr; IDispatch *obj = NULL; @@ -1580,14 +1574,10 @@ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla return E_OUTOFMEMORY; } - hres = disp_get_id(ctx, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx, obj, str, fdexNameEnsure, &id); SysFreeString(str); - if(SUCCEEDED(hres)) { + if(SUCCEEDED(hres)) exprval_set_idref(ret, obj, id); - }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) { - exprval_init(ret); - hres = S_OK; - } IDispatch_Release(obj); return hres; @@ -1803,7 +1793,7 @@ static HRESULT interp_this(exec_ctx_t *ctx) } /* ECMA-262 3rd Edition 10.1.4 */ -HRESULT identifier_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +static HRESULT identifier_expression_eval(script_ctx_t *ctx, expression_t *_expr, jsexcept_t *ei, exprval_t *ret) { identifier_expression_t *expr = (identifier_expression_t*)_expr; BSTR identifier; @@ -1815,7 +1805,7 @@ HRESULT identifier_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD if(!identifier) return E_OUTOFMEMORY; - hres = identifier_eval(ctx, identifier, flags, ei, ret); + hres = identifier_eval(ctx, identifier, EXPR_NEWREF, ei, ret); SysFreeString(identifier); return hres; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index b2707cfb9b1..2cea63dfeec 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -566,9 +566,6 @@ typedef struct { } property_value_expression_t; HRESULT function_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; -HRESULT array_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; -HRESULT member_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; -HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; HRESULT compiled_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 013b7feb549..c791e9c7aca 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1352,13 +1352,13 @@ static const expression_eval_t expression_eval_table[] = { compiled_expression_eval, compiled_expression_eval, compiled_expression_eval, - array_expression_eval, - member_expression_eval, + compiled_expression_eval, + compiled_expression_eval, compiled_expression_eval, compiled_expression_eval, compiled_expression_eval, function_expression_eval, - identifier_expression_eval, + compiled_expression_eval, compiled_expression_eval, property_value_expression_eval, compiled_expression_eval