jscript: Use bytecode for 'in' expression implementation.
This commit is contained in:
parent
517d9333d4
commit
1c824ea606
|
@ -113,6 +113,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
|
||||||
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
|
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_bneg);
|
||||||
case EXPR_EQEQ:
|
case EXPR_EQEQ:
|
||||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
|
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eq2);
|
||||||
|
case EXPR_IN:
|
||||||
|
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_in);
|
||||||
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_NOTEQEQ:
|
case EXPR_NOTEQEQ:
|
||||||
|
|
|
@ -2111,42 +2111,43 @@ HRESULT instanceof_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 11.8.7 */
|
/* ECMA-262 3rd Edition 11.8.7 */
|
||||||
static HRESULT in_eval(script_ctx_t *ctx, VARIANT *lval, VARIANT *obj, jsexcept_t *ei, VARIANT *retv)
|
HRESULT interp_in(exec_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
VARIANT_BOOL ret;
|
VARIANT *obj, *v;
|
||||||
DISPID id;
|
DISPID id = 0;
|
||||||
|
BOOL ret;
|
||||||
BSTR str;
|
BSTR str;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
if(V_VT(obj) != VT_DISPATCH || !V_DISPATCH(obj))
|
TRACE("\n");
|
||||||
return throw_type_error(ctx, ei, JS_E_OBJECT_EXPECTED, NULL);
|
|
||||||
|
|
||||||
hres = to_string(ctx, lval, ei, &str);
|
obj = stack_pop(ctx);
|
||||||
if(FAILED(hres))
|
v = stack_pop(ctx);
|
||||||
|
|
||||||
|
if(V_VT(obj) != VT_DISPATCH || !V_DISPATCH(obj)) {
|
||||||
|
VariantClear(obj);
|
||||||
|
VariantClear(v);
|
||||||
|
return throw_type_error(ctx->parser->script, &ctx->ei, JS_E_OBJECT_EXPECTED, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = to_string(ctx->parser->script, v, &ctx->ei, &str);
|
||||||
|
VariantClear(v);
|
||||||
|
if(FAILED(hres)) {
|
||||||
|
IDispatch_Release(V_DISPATCH(obj));
|
||||||
return hres;
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
hres = disp_get_id(ctx, V_DISPATCH(obj), str, 0, &id);
|
hres = disp_get_id(ctx->parser->script, V_DISPATCH(obj), str, 0, &id);
|
||||||
|
IDispatch_Release(V_DISPATCH(obj));
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
if(SUCCEEDED(hres))
|
if(SUCCEEDED(hres))
|
||||||
ret = VARIANT_TRUE;
|
ret = TRUE;
|
||||||
else if(hres == DISP_E_UNKNOWNNAME)
|
else if(hres == DISP_E_UNKNOWNNAME)
|
||||||
ret = VARIANT_FALSE;
|
ret = FALSE;
|
||||||
else
|
else
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
V_VT(retv) = VT_BOOL;
|
return stack_push_bool(ctx, ret);
|
||||||
V_BOOL(retv) = ret;
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 11.8.7 */
|
|
||||||
HRESULT in_expression_eval(script_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
|
|
||||||
{
|
|
||||||
binary_expression_t *expr = (binary_expression_t*)_expr;
|
|
||||||
|
|
||||||
TRACE("\n");
|
|
||||||
|
|
||||||
return binary_expr_eval(ctx, expr, in_eval, ei, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 11.6.1 */
|
/* ECMA-262 3rd Edition 11.6.1 */
|
||||||
|
|
|
@ -45,6 +45,7 @@ typedef struct _func_stack {
|
||||||
X(add, 1, 0) \
|
X(add, 1, 0) \
|
||||||
X(bneg, 1, 0) \
|
X(bneg, 1, 0) \
|
||||||
X(eq2, 1, 0) \
|
X(eq2, 1, 0) \
|
||||||
|
X(in, 1, 0) \
|
||||||
X(neg, 1, 0) \
|
X(neg, 1, 0) \
|
||||||
X(neq2, 1, 0) \
|
X(neq2, 1, 0) \
|
||||||
X(tonum, 1, 0) \
|
X(tonum, 1, 0) \
|
||||||
|
@ -529,7 +530,6 @@ HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,
|
||||||
HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT in_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
||||||
HRESULT sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT mul_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT mul_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT div_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
HRESULT div_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -1312,7 +1312,7 @@ static const expression_eval_t expression_eval_table[] = {
|
||||||
binary_xor_expression_eval,
|
binary_xor_expression_eval,
|
||||||
binary_and_expression_eval,
|
binary_and_expression_eval,
|
||||||
instanceof_expression_eval,
|
instanceof_expression_eval,
|
||||||
in_expression_eval,
|
compiled_expression_eval,
|
||||||
compiled_expression_eval,
|
compiled_expression_eval,
|
||||||
sub_expression_eval,
|
sub_expression_eval,
|
||||||
mul_expression_eval,
|
mul_expression_eval,
|
||||||
|
|
Loading…
Reference in New Issue