jscript: Added var statement implementation.
This commit is contained in:
parent
11153d0e05
commit
326cf6e0cf
|
@ -838,6 +838,20 @@ HRESULT disp_call(IDispatch *disp, DISPID id, LCID lcid, WORD flags, DISPPARAMS
|
|||
return hres;
|
||||
}
|
||||
|
||||
HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, LCID lcid, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
DISPID named_arg = DISPID_PROPERTYPUT;
|
||||
DISPPARAMS dp = {val, &named_arg, 1, 1};
|
||||
dispex_prop_t *prop;
|
||||
HRESULT hres;
|
||||
|
||||
hres = find_prop_name_prot(obj, name, TRUE, &prop);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
return prop_put(obj, prop, lcid, &dp, ei, caller);
|
||||
}
|
||||
|
||||
HRESULT disp_propput(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
DISPID dispid = DISPID_PROPERTYPUT;
|
||||
|
|
|
@ -341,10 +341,53 @@ HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
|
||||
/* ECMA-262 3rd Edition 12.2 */
|
||||
static HRESULT variable_list_eval(exec_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
variable_declaration_t *iter;
|
||||
HRESULT hres;
|
||||
|
||||
for(iter = var_list; iter; iter = iter->next) {
|
||||
VARIANT val;
|
||||
|
||||
if(iter->expr) {
|
||||
exprval_t exprval;
|
||||
|
||||
hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
|
||||
hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
|
||||
exprval_release(&exprval);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
}else {
|
||||
V_VT(&val) = VT_EMPTY;
|
||||
}
|
||||
|
||||
hres = jsdisp_propput_name(ctx->var_disp, iter->identifier, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
|
||||
VariantClear(&val);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
}
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 12.2 */
|
||||
HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
|
||||
{
|
||||
var_statement_t *stat = (var_statement_t*)_stat;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
V_VT(ret) = VT_EMPTY;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 12.3 */
|
||||
|
|
|
@ -90,6 +90,7 @@ HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,DispatchEx*,DispatchEx
|
|||
HRESULT disp_call(IDispatch*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT disp_propget(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
|
||||
HRESULT to_boolean(VARIANT*,VARIANT_BOOL*);
|
||||
|
||||
|
|
|
@ -23,4 +23,7 @@ ok(!null, "!null is not true");
|
|||
ok(!0, "!0 is not true");
|
||||
ok(!0.0, "!0.0 is not true");
|
||||
|
||||
var trueVar = true;
|
||||
ok(trueVar, "trueVar is not true");
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue