Jacek Caban : jscript: Use bytecode for 'in' expression implementation.
Alexandre Julliard
julliard at winehq.org
Wed Nov 23 13:40:05 CST 2011
Module: wine
Branch: master
Commit: 1c824ea6065c15dd4bdbfc3eacb6e542fbbff336
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c824ea6065c15dd4bdbfc3eacb6e542fbbff336
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Nov 23 12:13:35 2011 +0100
jscript: Use bytecode for 'in' expression implementation.
---
dlls/jscript/compile.c | 2 ++
dlls/jscript/engine.c | 47 ++++++++++++++++++++++++-----------------------
dlls/jscript/engine.h | 2 +-
dlls/jscript/parser.y | 2 +-
4 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 1e496a8..e36dcbe 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -113,6 +113,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
case EXPR_EQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
+ case EXPR_IN:
+ return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_in);
case EXPR_LOGNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_NOTEQEQ:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index cbfde6d..c6b9eef 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -2111,42 +2111,43 @@ HRESULT instanceof_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD
}
/* ECMA-262 3rd Edition 11.8.7 */
-static HRESULT in_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *obj, jsexcept_t *ei, VARIANT *retv)
+HRESULT interp_in(exec_ctx_t *ctx)
{
- VARIANT_BOOL ret;
- DISPID id;
+ VARIANT *obj, *v;
+ DISPID id = 0;
+ BOOL ret;
BSTR str;
HRESULT hres;
- if(V_VT(obj) != VT_DISPATCH || !V_DISPATCH(obj))
- return throw_type_error(ctx, ei, JS_E_OBJECT_EXPECTED, NULL);
+ TRACE("\n");
- hres = to_string(ctx, lval, ei, &str);
- if(FAILED(hres))
+ obj = stack_pop(ctx);
+ v = stack_pop(ctx);
+
+ if(V_VT(obj) != VT_DISPATCH || !V_DISPATCH(obj)) {
+ VariantClear(obj);
+ VariantClear(v);
+ return throw_type_error(ctx->parser->script, &ctx->ei, JS_E_OBJECT_EXPECTED, NULL);
+ }
+
+ hres = to_string(ctx->parser->script, v, &ctx->ei, &str);
+ VariantClear(v);
+ if(FAILED(hres)) {
+ IDispatch_Release(V_DISPATCH(obj));
return hres;
+ }
- hres = disp_get_id(ctx, V_DISPATCH(obj), str, 0, &id);
+ hres = disp_get_id(ctx->parser->script, V_DISPATCH(obj), str, 0, &id);
+ IDispatch_Release(V_DISPATCH(obj));
SysFreeString(str);
if(SUCCEEDED(hres))
- ret = VARIANT_TRUE;
+ ret = TRUE;
else if(hres == DISP_E_UNKNOWNNAME)
- ret = VARIANT_FALSE;
+ ret = FALSE;
else
return hres;
- V_VT(retv) = VT_BOOL;
- V_BOOL(retv) = ret;
- return S_OK;
-}
-
-/* ECMA-262 3rd Edition 11.8.7 */
-HRESULT in_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
-{
- binary_expression_t *expr = (binary_expression_t*)_expr;
-
- TRACE("\n");
-
- return binary_expr_eval(ctx, expr, in_eval, ei, ret);
+ return stack_push_bool(ctx, ret);
}
/* ECMA-262 3rd Edition 11.6.1 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 829274d..e5e316f 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -45,6 +45,7 @@ typedef struct _func_stack {
X(add, 1, 0) \
X(bneg, 1, 0) \
X(eq2, 1, 0) \
+ X(in, 1, 0) \
X(neg, 1, 0) \
X(neq2, 1, 0) \
X(tonum, 1, 0) \
@@ -529,7 +530,6 @@ HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,
HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT in_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT mul_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT div_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 98813b4..0fcba92 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1312,7 +1312,7 @@ static const expression_eval_t expression_eval_table[] = {
binary_xor_expression_eval,
binary_and_expression_eval,
instanceof_expression_eval,
- in_expression_eval,
+ compiled_expression_eval,
compiled_expression_eval,
sub_expression_eval,
mul_expression_eval,
More information about the wine-cvs
mailing list