Jacek Caban : jscript: Use bytecode for '<<' expression implementation.
Alexandre Julliard
julliard at winehq.org
Fri Dec 9 14:41:37 CST 2011
Module: wine
Branch: master
Commit: a80392e5eaa746590aaf46a8e046a0837fcfc54c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a80392e5eaa746590aaf46a8e046a0837fcfc54c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Dec 9 11:04:57 2011 +0100
jscript: Use bytecode for '<<' expression implementation.
---
dlls/jscript/compile.c | 2 ++
dlls/jscript/engine.c | 16 ++++++++++++----
dlls/jscript/engine.h | 2 +-
dlls/jscript/parser.y | 2 +-
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index 541e945..0f85471 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -667,6 +667,8 @@ static HRESULT compile_expression_noret(compiler_ctx_t *ctx, expression_t *expr,
return compile_literal(ctx, ((literal_expression_t*)expr)->literal);
case EXPR_LOGNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
+ case EXPR_LSHIFT:
+ return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_lshift);
case EXPR_MEMBER:
return compile_member_expression(ctx, (member_expression_t*)expr);
case EXPR_MINUS:
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 3ebdb83..0f74940 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -3113,13 +3113,21 @@ static HRESULT lshift_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsex
}
/* ECMA-262 3rd Edition 11.7.1 */
-HRESULT left_shift_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
+static HRESULT interp_lshift(exec_ctx_t *ctx)
{
- binary_expression_t *expr = (binary_expression_t*)_expr;
+ DWORD r;
+ INT l;
+ HRESULT hres;
- TRACE("\n");
+ hres = stack_pop_uint(ctx, &r);
+ if(FAILED(hres))
+ return hres;
+
+ hres = stack_pop_int(ctx, &l);
+ if(FAILED(hres))
+ return hres;
- return binary_expr_eval(ctx, expr, lshift_eval, ei, ret);
+ return stack_push_int(ctx, l << (r&0x1f));
}
/* ECMA-262 3rd Edition 11.7.2 */
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index ba2c3a8..d7714fe 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -65,6 +65,7 @@ typedef struct _func_stack {
X(jmp, 0, ARG_ADDR, 0) \
X(jmp_nz, 0, ARG_ADDR, 0) \
X(jmp_z, 0, ARG_ADDR, 0) \
+ X(lshift, 1, 0,0) \
X(lt, 1, 0,0) \
X(lteq, 1, 0,0) \
X(member, 1, ARG_BSTR, 0) \
@@ -567,7 +568,6 @@ HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcep
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT delete_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT typeof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
-HRESULT left_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
HRESULT assign_lshift_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 00fea0b..3019c60 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1336,7 +1336,7 @@ static const expression_eval_t expression_eval_table[] = {
compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
- left_shift_expression_eval,
+ compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
More information about the wine-cvs
mailing list