jscript: Throw an exception when evaluating invalid identifier instead of on lookup failure.
This commit is contained in:
parent
2c255287cd
commit
a4acd1b38f
|
@ -57,6 +57,9 @@ static void exprval_release(exprval_t *val)
|
||||||
if(val->u.nameref.disp)
|
if(val->u.nameref.disp)
|
||||||
IDispatch_Release(val->u.nameref.disp);
|
IDispatch_Release(val->u.nameref.disp);
|
||||||
SysFreeString(val->u.nameref.name);
|
SysFreeString(val->u.nameref.name);
|
||||||
|
return;
|
||||||
|
case EXPRVAL_INVALID:
|
||||||
|
SysFreeString(val->u.identifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +78,14 @@ static HRESULT exprval_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei,
|
||||||
}
|
}
|
||||||
|
|
||||||
return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/);
|
return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/);
|
||||||
default:
|
case EXPRVAL_NAMEREF:
|
||||||
ERR("type %d\n", val->type);
|
break;
|
||||||
return E_FAIL;
|
case EXPRVAL_INVALID:
|
||||||
|
return throw_type_error(ctx, ei, IDS_UNDEFINED, val->u.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ERR("type %d\n", val->type);
|
||||||
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
|
static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
|
||||||
|
@ -538,7 +545,12 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, js
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return throw_type_error(ctx->var_disp->ctx, ei, IDS_UNDEFINED, identifier);
|
ret->type = EXPRVAL_INVALID;
|
||||||
|
ret->u.identifier = SysAllocString(identifier);
|
||||||
|
if(!ret->u.identifier)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECMA-262 3rd Edition 12.1 */
|
/* ECMA-262 3rd Edition 12.1 */
|
||||||
|
|
|
@ -272,7 +272,8 @@ typedef struct {
|
||||||
enum {
|
enum {
|
||||||
EXPRVAL_VARIANT,
|
EXPRVAL_VARIANT,
|
||||||
EXPRVAL_IDREF,
|
EXPRVAL_IDREF,
|
||||||
EXPRVAL_NAMEREF
|
EXPRVAL_NAMEREF,
|
||||||
|
EXPRVAL_INVALID
|
||||||
} type;
|
} type;
|
||||||
union {
|
union {
|
||||||
VARIANT var;
|
VARIANT var;
|
||||||
|
@ -284,6 +285,7 @@ typedef struct {
|
||||||
IDispatch *disp;
|
IDispatch *disp;
|
||||||
BSTR name;
|
BSTR name;
|
||||||
} nameref;
|
} nameref;
|
||||||
|
BSTR identifier;
|
||||||
} u;
|
} u;
|
||||||
} exprval_t;
|
} exprval_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue