Commit 0b5ea35a authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

vbscript: Use a helper function to lookup the global functions.

parent b6240570
...@@ -110,6 +110,22 @@ static BOOL lookup_global_vars(ScriptDisp *script, const WCHAR *name, ref_t *ref ...@@ -110,6 +110,22 @@ static BOOL lookup_global_vars(ScriptDisp *script, const WCHAR *name, ref_t *ref
return FALSE; return FALSE;
} }
static BOOL lookup_global_funcs(ScriptDisp *script, const WCHAR *name, ref_t *ref)
{
function_t **funcs = script->global_funcs;
size_t i, cnt = script->global_funcs_cnt;
for(i = 0; i < cnt; i++) {
if(!wcsicmp(funcs[i]->name, name)) {
ref->type = REF_FUNC;
ref->u.f = funcs[i];
return TRUE;
}
}
return FALSE;
}
static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_t invoke_type, ref_t *ref) static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_t invoke_type, ref_t *ref)
{ {
ScriptDisp *script_obj = ctx->script->script_obj; ScriptDisp *script_obj = ctx->script->script_obj;
...@@ -177,15 +193,8 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ ...@@ -177,15 +193,8 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
if(lookup_global_vars(script_obj, name, ref)) if(lookup_global_vars(script_obj, name, ref))
return S_OK; return S_OK;
if(lookup_global_funcs(script_obj, name, ref))
for(i = 0; i < script_obj->global_funcs_cnt; i++) { return S_OK;
function_t *func = script_obj->global_funcs[i];
if(!wcsicmp(func->name, name)) {
ref->type = REF_FUNC;
ref->u.f = func;
return S_OK;
}
}
hres = get_builtin_id(ctx->script->global_obj, name, &id); hres = get_builtin_id(ctx->script->global_obj, name, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
......
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