vbscript: Store global functions in script_ctx_t.

This commit is contained in:
Jacek Caban 2011-09-14 12:55:32 +02:00 committed by Alexandre Julliard
parent 413bc99044
commit 190ea00010
2 changed files with 22 additions and 0 deletions

View File

@ -674,18 +674,25 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi
static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifier)
{
dynamic_var_t *var;
function_t *func;
for(var = script->global_vars; var; var = var->next) {
if(!strcmpiW(var->name, identifier))
return TRUE;
}
for(func = script->global_funcs; func; func = func->next) {
if(!strcmpiW(func->name, identifier))
return TRUE;
}
return FALSE;
}
static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script)
{
dynamic_var_t *var;
function_t *func;
for(var = ctx->global_vars; var; var = var->next) {
if(lookup_script_identifier(script, var->name)) {
@ -694,6 +701,13 @@ static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script)
}
}
for(func = ctx->funcs; func; func = func->next) {
if(lookup_script_identifier(script, func->name)) {
FIXME("%s: redefined\n", debugstr_w(func->name));
return E_FAIL;
}
}
return S_OK;
}
@ -815,6 +829,13 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
script->global_vars = ctx.global_vars;
}
if(ctx.funcs) {
for(new_func = ctx.funcs; new_func->next; new_func = new_func->next);
new_func->next = script->global_funcs;
script->global_funcs = ctx.funcs;
}
if(TRACE_ON(vbscript_disas))
dump_code(&ctx);

View File

@ -80,6 +80,7 @@ struct _script_ctx_t {
vbdisp_t *script_obj;
dynamic_var_t *global_vars;
function_t *global_funcs;
struct list code_list;
struct list named_items;