vbscript: Call OnScriptError for compile errors.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
681cee4ed6
commit
34674eff5b
|
@ -375,6 +375,18 @@ static inline BOOL emit_catch(compile_ctx_t *ctx, unsigned off)
|
||||||
return emit_catch_jmp(ctx, off, ctx->instr_cnt);
|
return emit_catch_jmp(ctx, off, ctx->instr_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT compile_error(script_ctx_t *ctx, HRESULT error)
|
||||||
|
{
|
||||||
|
if(error == SCRIPT_E_REPORTED)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
clear_ei(&ctx->ei);
|
||||||
|
ctx->ei.scode = error = map_hres(error);
|
||||||
|
ctx->ei.bstrSource = get_vbscript_string(VBS_COMPILE_ERROR);
|
||||||
|
ctx->ei.bstrDescription = get_vbscript_error_string(error);
|
||||||
|
return report_script_error(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, BOOL lookup_global)
|
static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, BOOL lookup_global)
|
||||||
{
|
{
|
||||||
const_decl_t *decl;
|
const_decl_t *decl;
|
||||||
|
@ -1826,11 +1838,11 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
||||||
|
|
||||||
hres = parse_script(&ctx.parser, src, delimiter, flags);
|
hres = parse_script(&ctx.parser, src, delimiter, flags);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return compile_error(script, hres);
|
||||||
|
|
||||||
code = ctx.code = alloc_vbscode(&ctx, src);
|
code = ctx.code = alloc_vbscode(&ctx, src);
|
||||||
if(!ctx.code)
|
if(!ctx.code)
|
||||||
return E_OUTOFMEMORY;
|
return compile_error(script, E_OUTOFMEMORY);
|
||||||
|
|
||||||
ctx.funcs = NULL;
|
ctx.funcs = NULL;
|
||||||
ctx.func_decls = NULL;
|
ctx.func_decls = NULL;
|
||||||
|
@ -1844,7 +1856,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
||||||
hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code);
|
hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_compiler(&ctx);
|
release_compiler(&ctx);
|
||||||
return hres;
|
return compile_error(script, hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.global_consts = ctx.const_decls;
|
ctx.global_consts = ctx.const_decls;
|
||||||
|
@ -1853,7 +1865,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
||||||
hres = create_function(&ctx, func_decl, &new_func);
|
hres = create_function(&ctx, func_decl, &new_func);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_compiler(&ctx);
|
release_compiler(&ctx);
|
||||||
return hres;
|
return compile_error(script, hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_func->next = ctx.funcs;
|
new_func->next = ctx.funcs;
|
||||||
|
@ -1864,14 +1876,14 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli
|
||||||
hres = compile_class(&ctx, class_decl);
|
hres = compile_class(&ctx, class_decl);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_compiler(&ctx);
|
release_compiler(&ctx);
|
||||||
return hres;
|
return compile_error(script, hres);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = check_script_collisions(&ctx, script);
|
hres = check_script_collisions(&ctx, script);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_compiler(&ctx);
|
release_compiler(&ctx);
|
||||||
return hres;
|
return compile_error(script, hres);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx.global_vars) {
|
if(ctx.global_vars) {
|
||||||
|
|
|
@ -79,6 +79,12 @@ extern const CLSID CLSID_VBScriptRegExp;
|
||||||
expect_ ## func = called_ ## func = FALSE; \
|
expect_ ## func = called_ ## func = FALSE; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
#define CHECK_NOT_CALLED(func) \
|
||||||
|
do { \
|
||||||
|
ok(!called_ ## func, "unexpected " #func "\n"); \
|
||||||
|
expect_ ## func = called_ ## func = FALSE; \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
#define CLEAR_CALLED(func) \
|
#define CLEAR_CALLED(func) \
|
||||||
expect_ ## func = called_ ## func = FALSE
|
expect_ ## func = called_ ## func = FALSE
|
||||||
|
|
||||||
|
@ -2149,7 +2155,7 @@ static void test_parse_errors(void)
|
||||||
SET_EXPECT(OnScriptError);
|
SET_EXPECT(OnScriptError);
|
||||||
hres = parse_script_ar(invalid_scripts[i]);
|
hres = parse_script_ar(invalid_scripts[i]);
|
||||||
ok(FAILED(hres), "[%u] script did not fail\n", i);
|
ok(FAILED(hres), "[%u] script did not fail\n", i);
|
||||||
todo_wine CHECK_CALLED(OnScriptError);
|
CHECK_CALLED(OnScriptError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2309,7 +2315,7 @@ static void test_isexpression(void)
|
||||||
SET_EXPECT(OnScriptError);
|
SET_EXPECT(OnScriptError);
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
||||||
ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
|
ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
|
||||||
todo_wine CHECK_CALLED(OnScriptError);
|
CHECK_CALLED(OnScriptError);
|
||||||
VariantClear(&var);
|
VariantClear(&var);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
@ -2346,7 +2352,7 @@ static void test_isexpression(void)
|
||||||
SET_EXPECT(OnScriptError);
|
SET_EXPECT(OnScriptError);
|
||||||
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL);
|
||||||
ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
|
ok(FAILED(hres), "ParseScriptText did not fail: %08x\n", hres);
|
||||||
todo_wine CHECK_CALLED(OnScriptError);
|
CHECK_CALLED(OnScriptError);
|
||||||
VariantClear(&var);
|
VariantClear(&var);
|
||||||
SysFreeString(str);
|
SysFreeString(str);
|
||||||
|
|
||||||
|
@ -2545,9 +2551,12 @@ static void run_tests(void)
|
||||||
parse_script_a("Option Explicit\nset test.setobj = testObj");
|
parse_script_a("Option Explicit\nset test.setobj = testObj");
|
||||||
CHECK_CALLED(global_setobj_i);
|
CHECK_CALLED(global_setobj_i);
|
||||||
|
|
||||||
|
SET_EXPECT(OnScriptError);
|
||||||
hres = parse_script_ar("dim x\nx = testObj.rem");
|
hres = parse_script_ar("dim x\nx = testObj.rem");
|
||||||
todo_wine
|
todo_wine
|
||||||
ok(hres == S_OK, "use of 'rem' as dot identifier failed: %x08\n", hres);
|
ok(hres == S_OK, "use of 'rem' as dot identifier failed: %x08\n", hres);
|
||||||
|
todo_wine
|
||||||
|
CHECK_NOT_CALLED(OnScriptError);
|
||||||
|
|
||||||
SET_EXPECT(testobj_propget_d);
|
SET_EXPECT(testobj_propget_d);
|
||||||
SET_EXPECT(testobj_propget_i);
|
SET_EXPECT(testobj_propget_i);
|
||||||
|
@ -2593,7 +2602,7 @@ static void run_tests(void)
|
||||||
SET_EXPECT(OnScriptError);
|
SET_EXPECT(OnScriptError);
|
||||||
hres = parse_script_ar("<!--");
|
hres = parse_script_ar("<!--");
|
||||||
ok(FAILED(hres), "script didn't fail\n");
|
ok(FAILED(hres), "script didn't fail\n");
|
||||||
todo_wine CHECK_CALLED(OnScriptError);
|
CHECK_CALLED(OnScriptError);
|
||||||
|
|
||||||
SET_EXPECT(global_success_d);
|
SET_EXPECT(global_success_d);
|
||||||
SET_EXPECT(global_success_i);
|
SET_EXPECT(global_success_i);
|
||||||
|
|
Loading…
Reference in New Issue