Jacek Caban : jscript: Use bytecode for comma expression implementation.
Alexandre Julliard
julliard at winehq.org
Fri Nov 25 10:27:32 CST 2011
Module: wine
Branch: master
Commit: 47314a92d7c1d46739108ba21994ea3c2abba9af
URL: http://source.winehq.org/git/wine.git/?a=commit;h=47314a92d7c1d46739108ba21994ea3c2abba9af
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Nov 25 12:05:50 2011 +0100
jscript: Use bytecode for comma expression implementation.
---
dlls/jscript/compile.c | 17 +++++++++++++++++
dlls/jscript/engine.c | 28 ++++++++--------------------
dlls/jscript/engine.h | 2 +-
dlls/jscript/parser.y | 2 +-
4 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 4b5b91b..77391bd 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -156,6 +156,21 @@ static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
}
+/* ECMA-262 3rd Edition 11.14 */
+static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t *expr)
+{
+ HRESULT hres;
+
+ hres = compile_expression(ctx, expr->expression1);
+ if(FAILED(hres))
+ return hres;
+
+ if(push_instr(ctx, OP_pop) == -1)
+ return E_OUTOFMEMORY;
+
+ return compile_expression(ctx, expr->expression2);
+}
+
static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr)
{
unsigned instr;
@@ -211,6 +226,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
case EXPR_BITNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
+ case EXPR_COMMA:
+ return compile_comma_expression(ctx, (binary_expression_t*)expr);
case EXPR_EQEQ:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
case EXPR_IN:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index e706407..87f873c 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1910,26 +1910,6 @@ HRESULT property_value_expression_eval(script_ctx_t *ctx, expression_t *_expr, D
return S_OK;
}
-/* ECMA-262 3rd Edition 11.14 */
-HRESULT comma_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;
- VARIANT lval, rval;
- HRESULT hres;
-
- TRACE("\n");
-
- hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
- if(FAILED(hres))
- return hres;
-
- VariantClear(&lval);
-
- ret->type = EXPRVAL_VARIANT;
- ret->u.var = rval;
- return S_OK;
-}
-
/* ECMA-262 3rd Edition 11.11 */
HRESULT logical_or_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
@@ -3342,6 +3322,14 @@ HRESULT assign_xor_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD
return assign_oper_eval(ctx, expr->expression1, expr->expression2, xor_eval, ei, ret);
}
+static HRESULT interp_pop(exec_ctx_t *ctx)
+{
+ TRACE("\n");
+
+ stack_popn(ctx, 1);
+ return S_OK;
+}
+
static HRESULT interp_ret(exec_ctx_t *ctx)
{
TRACE("\n");
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index c42b2e8..a713e02 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -52,6 +52,7 @@ typedef struct _func_stack {
X(neg, 1, 0,0) \
X(neq2, 1, 0,0) \
X(null, 1, 0,0) \
+ X(pop, 1, 0,0) \
X(regexp, 1, ARG_STR, ARG_INT) \
X(str, 1, ARG_STR, 0) \
X(this, 1, 0,0) \
@@ -534,7 +535,6 @@ HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*
HRESULT array_literal_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 comma_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT logical_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT logical_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT binary_or_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 f051c0c..d8daa59 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1305,7 +1305,7 @@ static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *ide
}
static const expression_eval_t expression_eval_table[] = {
- comma_expression_eval,
+ compiled_expression_eval,
logical_or_expression_eval,
logical_and_expression_eval,
binary_or_expression_eval,
More information about the wine-cvs
mailing list