From 7c6b6c8ca840dc591d05bd3395163fb82eea7c3e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 17 Sep 2008 23:33:15 +0200 Subject: [PATCH] jscript: Added plus expression implementation. --- dlls/jscript/engine.c | 28 +++++++++++++++++++++++++--- dlls/jscript/tests/lang.js | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index ff201518c1d..09b1efe7d42 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1871,10 +1871,32 @@ HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return S_OK; } -HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +/* ECMA-262 3rd Edition 11.4.6 */ +HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) { - FIXME("\n"); - return E_NOTIMPL; + unary_expression_t *expr = (unary_expression_t*)_expr; + exprval_t exprval; + VARIANT val, num; + HRESULT hres; + + TRACE("\n"); + + hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval); + if(FAILED(hres)) + return hres; + + hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val); + exprval_release(&exprval); + if(FAILED(hres)) + return hres; + + hres = to_number(ctx->parser->script, &val, ei, &num); + if(FAILED(hres)) + return hres; + + ret->type = EXPRVAL_VARIANT; + ret->u.var = num; + return S_OK; } /* ECMA-262 3rd Edition 11.3.1 */ diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 03c208a251f..b4ab2b73a3f 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -307,6 +307,8 @@ ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp)); ok((3,4) === 4, "(3,4) !== 4"); +ok(+3 === 3, "+3 !== 3"); + ok(1 < 3.4, "1 < 3.4 failed"); ok(!(3.4 < 1), "3.4 < 1"); ok("abc" < "abcd", "abc < abcd failed");