jscript: Lookup global members after script_disp.
This commit is contained in:
parent
25e9e4f07b
commit
6afd53547e
|
@ -356,6 +356,26 @@ static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
|
||||
{
|
||||
named_item_t *item;
|
||||
DISPID id;
|
||||
HRESULT hres;
|
||||
|
||||
for(item = ctx->named_items; item; item = item->next) {
|
||||
if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
|
||||
hres = disp_get_id(item->disp, identifier, 0, &id);
|
||||
if(SUCCEEDED(hres)) {
|
||||
if(ret)
|
||||
exprval_set_idref(ret, item->disp, id);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
|
||||
{
|
||||
script_ctx_t *script = parser->script;
|
||||
|
@ -493,25 +513,15 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, js
|
|||
}
|
||||
}
|
||||
|
||||
for(item = ctx->parser->script->named_items; item; item = item->next) {
|
||||
if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
|
||||
hres = disp_get_id(item->disp, identifier, 0, &id);
|
||||
if(SUCCEEDED(hres))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(item) {
|
||||
exprval_set_idref(ret, item->disp, id);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
|
||||
if(SUCCEEDED(hres)) {
|
||||
exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if(lookup_global_members(ctx->parser->script, identifier, ret))
|
||||
return S_OK;
|
||||
|
||||
if(flags & EXPR_NEWREF) {
|
||||
hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
|
||||
if(FAILED(hres))
|
||||
|
|
|
@ -835,6 +835,8 @@ static void run_tests(void)
|
|||
|
||||
parse_script_a("ok(typeof(test) === 'object', \"typeof(test) != 'object'\");");
|
||||
|
||||
parse_script_a("function reportSuccess() {}; reportSuccess();");
|
||||
|
||||
run_from_res("lang.js");
|
||||
run_from_res("api.js");
|
||||
run_from_res("regexp.js");
|
||||
|
|
Loading…
Reference in New Issue