vbscript: Lookup the named item in compile_script.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
07f902b080
commit
729c9eab58
|
@ -1921,16 +1921,25 @@ static void release_compiler(compile_ctx_t *ctx)
|
|||
release_vbscode(ctx->code);
|
||||
}
|
||||
|
||||
HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD_PTR cookie,
|
||||
unsigned start_line, DWORD flags, vbscode_t **ret)
|
||||
HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *item_name, const WCHAR *delimiter,
|
||||
DWORD_PTR cookie, unsigned start_line, DWORD flags, vbscode_t **ret)
|
||||
{
|
||||
function_decl_t *func_decl;
|
||||
named_item_t *item = NULL;
|
||||
class_decl_t *class_decl;
|
||||
function_t *new_func;
|
||||
compile_ctx_t ctx;
|
||||
vbscode_t *code;
|
||||
HRESULT hres;
|
||||
|
||||
if(item_name) {
|
||||
item = lookup_named_item(script, item_name, 0);
|
||||
if(!item) {
|
||||
WARN("Unknown context %s\n", debugstr_w(item_name));
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
code = ctx.code = alloc_vbscode(&ctx, src, cookie, start_line);
|
||||
if(!ctx.code)
|
||||
|
@ -1993,19 +2002,23 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
|||
ctx.code = NULL;
|
||||
release_compiler(&ctx);
|
||||
|
||||
if(item && item->disp)
|
||||
IDispatch_AddRef(code->context = item->disp);
|
||||
|
||||
list_add_tail(&script->code_list, &code->entry);
|
||||
*ret = code;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD_PTR cookie,
|
||||
unsigned start_line, DWORD flags, class_desc_t **ret)
|
||||
HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *item_name, const WCHAR *delimiter,
|
||||
DWORD_PTR cookie, unsigned start_line, DWORD flags, class_desc_t **ret)
|
||||
{
|
||||
class_desc_t *desc;
|
||||
vbscode_t *code;
|
||||
HRESULT hres;
|
||||
|
||||
hres = compile_script(script, src, delimiter, cookie, start_line, flags & ~SCRIPTTEXT_ISPERSISTENT, &code);
|
||||
hres = compile_script(script, src, item_name, delimiter, cookie, start_line,
|
||||
flags & ~SCRIPTTEXT_ISPERSISTENT, &code);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
|
|
@ -870,7 +870,6 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||
DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
|
||||
{
|
||||
VBScript *This = impl_from_IActiveScriptParse(iface);
|
||||
named_item_t *item = NULL;
|
||||
vbscode_t *code;
|
||||
HRESULT hres;
|
||||
|
||||
|
@ -881,21 +880,11 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
if(pstrItemName) {
|
||||
item = lookup_named_item(This->ctx, pstrItemName, 0);
|
||||
if(!item) {
|
||||
WARN("Unknown context %s\n", debugstr_w(pstrItemName));
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
}
|
||||
|
||||
hres = compile_script(This->ctx, pstrCode, pstrDelimiter, dwSourceContextCookie, ulStartingLine, dwFlags, &code);
|
||||
hres = compile_script(This->ctx, pstrCode, pstrItemName, pstrDelimiter, dwSourceContextCookie,
|
||||
ulStartingLine, dwFlags, &code);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(item && item->disp)
|
||||
IDispatch_AddRef(code->context = item->disp);
|
||||
|
||||
if(!(dwFlags & SCRIPTTEXT_ISEXPRESSION) && !is_started(This)) {
|
||||
code->pending_exec = TRUE;
|
||||
return S_OK;
|
||||
|
@ -953,8 +942,8 @@ static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptPar
|
|||
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
hres = compile_procedure(This->ctx, pstrCode, pstrDelimiter, dwSourceContextCookie, ulStartingLineNumber,
|
||||
dwFlags, &desc);
|
||||
hres = compile_procedure(This->ctx, pstrCode, pstrItemName, pstrDelimiter, dwSourceContextCookie,
|
||||
ulStartingLineNumber, dwFlags, &desc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
|
|
@ -368,8 +368,8 @@ static inline void grab_vbscode(vbscode_t *code)
|
|||
}
|
||||
|
||||
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,vbscode_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,class_desc_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,vbscode_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,class_desc_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
||||
void release_dynamic_var(dynamic_var_t*) DECLSPEC_HIDDEN;
|
||||
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue