Commit 50c7c4b7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added '+=' expression implementation.

parent 7dddf097
...@@ -785,6 +785,47 @@ static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper ...@@ -785,6 +785,47 @@ static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper
return S_OK; return S_OK;
} }
/* ECMA-262 3rd Edition 11.13.2 */
static HRESULT assign_oper_eval(exec_ctx_t *ctx, expression_t *lexpr, expression_t *rexpr, oper_t oper,
jsexcept_t *ei, exprval_t *ret)
{
VARIANT retv, lval, rval;
exprval_t exprval, exprvalr;
HRESULT hres;
hres = expr_eval(ctx, lexpr, EXPR_NEWREF, ei, &exprval);
if(FAILED(hres))
return hres;
hres = exprval_value(ctx->parser->script, &exprval, ei, &lval);
if(SUCCEEDED(hres)) {
hres = expr_eval(ctx, rexpr, 0, ei, &exprvalr);
if(SUCCEEDED(hres)) {
hres = exprval_value(ctx->parser->script, &exprvalr, ei, &rval);
exprval_release(&exprvalr);
}
if(SUCCEEDED(hres)) {
hres = oper(ctx, &lval, &rval, ei, &retv);
VariantClear(&rval);
}
VariantClear(&lval);
}
if(SUCCEEDED(hres)) {
hres = put_value(ctx->parser->script, &exprval, &retv, ei);
if(FAILED(hres))
VariantClear(&retv);
}
exprval_release(&exprval);
if(FAILED(hres))
return hres;
ret->type = EXPRVAL_VARIANT;
ret->u.var = retv;
return S_OK;
}
/* ECMA-262 3rd Edition 13 */ /* ECMA-262 3rd Edition 13 */
HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{ {
...@@ -1624,10 +1665,14 @@ HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWOR ...@@ -1624,10 +1665,14 @@ HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWOR
return E_NOTIMPL; return E_NOTIMPL;
} }
HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) /* ECMA-262 3rd Edition 11.13.2 */
HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{ {
FIXME("\n"); binary_expression_t *expr = (binary_expression_t*)_expr;
return E_NOTIMPL;
TRACE("\n");
return assign_oper_eval(ctx, expr->expression1, expr->expression2, add_eval, ei, ret);
} }
HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
......
...@@ -176,4 +176,8 @@ ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4"); ...@@ -176,4 +176,8 @@ ok(getVT(tmp) === "VT_I4", "getVT(1.5+2.5) !== VT_I4");
tmp = "ab" + "cd"; tmp = "ab" + "cd";
ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\""); ok(tmp === "abcd", "\"ab\" + \"cd\" !== \"abcd\"");
tmp = 1;
ok((tmp += 1) === 2, "tmp += 1 !== 2");
ok(tmp === 2, "tmp !== 2");
reportSuccess(); reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment