From abb2d2872112e7e1242c4b94c388572885ce8440 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 22 Sep 2011 14:25:15 +0200 Subject: [PATCH] vbscript: Lookup global object before host-provided objects. --- dlls/vbscript/interp.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 08ea83e3f20..678b51ad830 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -126,12 +126,14 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ if(lookup_dynamic_vars(ctx->func->type == FUNC_GLOBAL ? ctx->script->global_vars : ctx->dynamic_vars, name, ref)) return S_OK; - hres = disp_get_id(ctx->this_obj, name, invoke_type, TRUE, &id); - if(SUCCEEDED(hres)) { - ref->type = REF_DISP; - ref->u.d.disp = ctx->this_obj; - ref->u.d.id = id; - return S_OK; + if(ctx->func->type != FUNC_GLOBAL) { + hres = disp_get_id(ctx->this_obj, name, invoke_type, TRUE, &id); + if(SUCCEEDED(hres)) { + ref->type = REF_DISP; + ref->u.d.disp = ctx->this_obj; + ref->u.d.id = id; + return S_OK; + } } if(ctx->func->type != FUNC_GLOBAL && lookup_dynamic_vars(ctx->script->global_vars, name, ref)) @@ -145,8 +147,22 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ } } + if(!strcmpiW(name, errW)) { + ref->type = REF_OBJ; + ref->u.obj = (IDispatch*)&ctx->script->err_obj->IDispatchEx_iface; + return S_OK; + } + + hres = vbdisp_get_id(ctx->script->global_obj, name, invoke_type, TRUE, &id); + if(SUCCEEDED(hres)) { + ref->type = REF_DISP; + ref->u.d.disp = (IDispatch*)&ctx->script->global_obj->IDispatchEx_iface; + ref->u.d.id = id; + return S_OK; + } + LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) { - if((item->flags & SCRIPTITEM_GLOBALMEMBERS) && item->disp != ctx->this_obj) { + if((item->flags & SCRIPTITEM_GLOBALMEMBERS)) { hres = disp_get_id(item->disp, name, invoke_type, FALSE, &id); if(SUCCEEDED(hres)) { ref->type = REF_DISP; @@ -180,20 +196,6 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ } } - if(!strcmpiW(name, errW)) { - ref->type = REF_OBJ; - ref->u.obj = (IDispatch*)&ctx->script->err_obj->IDispatchEx_iface; - return S_OK; - } - - hres = vbdisp_get_id(ctx->script->global_obj, name, invoke_type, TRUE, &id); - if(SUCCEEDED(hres)) { - ref->type = REF_DISP; - ref->u.d.disp = (IDispatch*)&ctx->script->global_obj->IDispatchEx_iface; - ref->u.d.id = id; - return S_OK; - } - ref->type = REF_NONE; return S_OK; } -- 2.11.4.GIT