Module: wine Branch: master Commit: 152b3e48c119f2bfe8325471ecca8ca52ca1d8ea URL: http://source.winehq.org/git/wine.git/?a=commit;h=152b3e48c119f2bfe8325471ec...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Sep 10 21:07:35 2008 +0200
jscript: Added 'new' expression implementation.
---
dlls/jscript/engine.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 831dcba..d1dc0a7 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -869,10 +869,43 @@ static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei, return S_OK; }
-HRESULT member_new_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) +/* ECMA-262 3rd Edition 11.2.2 */ +HRESULT member_new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret) { - FIXME("\n"); - return E_NOTIMPL; + call_expression_t *expr = (call_expression_t*)_expr; + exprval_t exprval; + VARIANT constr, var; + DISPPARAMS dp; + HRESULT hres; + + TRACE("\n"); + + hres = expr_eval(ctx, expr->expression, 0, ei, &exprval); + if(FAILED(hres)) + return hres; + + hres = args_to_param(ctx, expr->argument_list, ei, &dp); + if(SUCCEEDED(hres)) + hres = exprval_to_value(ctx->parser->script, &exprval, ei, &constr); + exprval_release(&exprval); + if(FAILED(hres)) + return hres; + + if(V_VT(&constr) != VT_DISPATCH) { + FIXME("throw TypeError\n"); + VariantClear(&constr); + return E_FAIL; + } + + hres = disp_call(V_DISPATCH(&constr), DISPID_VALUE, ctx->parser->script->lcid, + DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/); + IDispatch_Release(V_DISPATCH(&constr)); + if(FAILED(hres)) + return hres; + + ret->type = EXPRVAL_VARIANT; + ret->u.var = var; + return S_OK; }
HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)