jscript: Use bytecode for assigning to array expression.

This commit is contained in:
Jacek Caban 2011-12-05 11:11:45 +01:00 committed by Alexandre Julliard
parent d3d2f063b6
commit 9aafd03110
3 changed files with 51 additions and 0 deletions

View File

@ -358,6 +358,21 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_
return hres;
break;
}
case EXPR_ARRAY: {
array_expression_t *array_expr = (array_expression_t*)expr->expression1;
hres = compile_expression(ctx, array_expr->member_expr);
if(FAILED(hres))
return hres;
hres = compile_expression(ctx, array_expr->expression);
if(FAILED(hres))
return hres;
if(push_instr(ctx, OP_memberid) == -1)
return E_OUTOFMEMORY;
break;
}
default:
expr->expr.eval = assign_expression_eval;
return compile_interp_fallback(ctx, &expr->expr);

View File

@ -1573,6 +1573,41 @@ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla
return hres;
}
/* ECMA-262 3rd Edition 11.2.1 */
static HRESULT interp_memberid(exec_ctx_t *ctx)
{
VARIANT *objv, *namev;
IDispatch *obj;
BSTR name;
DISPID id;
HRESULT hres;
TRACE("\n");
namev = stack_pop(ctx);
objv = stack_pop(ctx);
hres = to_object(ctx->parser->script, objv, &obj);
VariantClear(objv);
if(SUCCEEDED(hres)) {
hres = to_string(ctx->parser->script, namev, &ctx->ei, &name);
if(FAILED(hres))
IDispatch_Release(obj);
}
VariantClear(namev);
if(FAILED(hres))
return hres;
hres = disp_get_id(ctx->parser->script, obj, name, fdexNameEnsure, &id);
SysFreeString(name);
if(FAILED(hres)) {
IDispatch_Release(obj);
return hres;
}
return stack_push_objid(ctx, obj, id);
}
static void free_dp(DISPPARAMS *dp)
{
DWORD i;

View File

@ -62,6 +62,7 @@ typedef struct _func_stack {
X(jmp_z, 0, ARG_ADDR, 0) \
X(lt, 1, 0,0) \
X(lteq, 1, 0,0) \
X(memberid, 1, 0,0) \
X(minus, 1, 0,0) \
X(mod, 1, 0,0) \
X(mul, 1, 0,0) \