jscript: Use bytecode for comma expression implementation.

This commit is contained in:
Jacek Caban 2011-11-25 12:05:50 +01:00 committed by Alexandre Julliard
parent 172fa4fa99
commit 47314a92d7
4 changed files with 27 additions and 22 deletions

View file

@ -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:

View file

@ -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");

View file

@ -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;

View file

@ -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,