Commit a289b8e0 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added bytecode version of member expression.

parent 822fdde4
...@@ -210,6 +210,18 @@ static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t ...@@ -210,6 +210,18 @@ static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK; return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
} }
/* ECMA-262 3rd Edition 11.2.1 */
static HRESULT compile_member_expression(compiler_ctx_t *ctx, member_expression_t *expr)
{
HRESULT hres;
hres = compile_expression(ctx, expr->expression);
if(FAILED(hres))
return hres;
return push_instr_bstr(ctx, OP_member, expr->identifier);
}
/* ECMA-262 3rd Edition 11.14 */ /* ECMA-262 3rd Edition 11.14 */
static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t *expr) static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t *expr)
{ {
...@@ -519,6 +531,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr) ...@@ -519,6 +531,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return compile_literal(ctx, ((literal_expression_t*)expr)->literal); return compile_literal(ctx, ((literal_expression_t*)expr)->literal);
case EXPR_LOGNEG: case EXPR_LOGNEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg); return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_MEMBER:
return compile_member_expression(ctx, (member_expression_t*)expr);
case EXPR_MINUS: case EXPR_MINUS:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_minus); return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_minus);
case EXPR_MOD: case EXPR_MOD:
......
...@@ -153,6 +153,22 @@ static HRESULT stack_pop_number(exec_ctx_t *ctx, VARIANT *r) ...@@ -153,6 +153,22 @@ static HRESULT stack_pop_number(exec_ctx_t *ctx, VARIANT *r)
return hres; return hres;
} }
static HRESULT stack_pop_object(exec_ctx_t *ctx, IDispatch **r)
{
VARIANT *v;
HRESULT hres;
v = stack_pop(ctx);
if(V_VT(v) == VT_DISPATCH) {
*r = V_DISPATCH(v);
return S_OK;
}
hres = to_object(ctx->parser->script, v, r);
VariantClear(v);
return hres;
}
static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r) static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r)
{ {
return to_int32(ctx->parser->script, stack_pop(ctx), &ctx->ei, r); return to_int32(ctx->parser->script, stack_pop(ctx), &ctx->ei, r);
...@@ -1591,6 +1607,35 @@ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla ...@@ -1591,6 +1607,35 @@ HRESULT member_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD fla
} }
/* ECMA-262 3rd Edition 11.2.1 */ /* ECMA-262 3rd Edition 11.2.1 */
static HRESULT interp_member(exec_ctx_t *ctx)
{
const BSTR arg = ctx->parser->code->instrs[ctx->ip].arg1.bstr;
IDispatch *obj;
VARIANT v;
DISPID id;
HRESULT hres;
TRACE("\n");
hres = stack_pop_object(ctx, &obj);
if(FAILED(hres))
return hres;
hres = disp_get_id(ctx->parser->script, obj, arg, 0, &id);
if(SUCCEEDED(hres)) {
hres = disp_propget(ctx->parser->script, obj, id, &v, &ctx->ei, NULL/*FIXME*/);
}else if(hres == DISP_E_UNKNOWNNAME) {
V_VT(&v) = VT_EMPTY;
hres = S_OK;
}
IDispatch_Release(obj);
if(FAILED(hres))
return hres;
return stack_push(ctx, &v);
}
/* ECMA-262 3rd Edition 11.2.1 */
static HRESULT interp_memberid(exec_ctx_t *ctx) static HRESULT interp_memberid(exec_ctx_t *ctx)
{ {
VARIANT *objv, *namev; VARIANT *objv, *namev;
......
...@@ -62,6 +62,7 @@ typedef struct _func_stack { ...@@ -62,6 +62,7 @@ typedef struct _func_stack {
X(jmp_z, 0, ARG_ADDR, 0) \ X(jmp_z, 0, ARG_ADDR, 0) \
X(lt, 1, 0,0) \ X(lt, 1, 0,0) \
X(lteq, 1, 0,0) \ X(lteq, 1, 0,0) \
X(member, 1, ARG_BSTR, 0) \
X(memberid, 1, 0,0) \ X(memberid, 1, 0,0) \
X(minus, 1, 0,0) \ X(minus, 1, 0,0) \
X(mod, 1, 0,0) \ X(mod, 1, 0,0) \
......
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