Module: wine Branch: master Commit: eb73571fe987344c0caca9ada621a129d1883c2b URL: https://source.winehq.org/git/wine.git/?a=commit;h=eb73571fe987344c0caca9ada...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Jan 22 23:27:54 2020 +0100
vbscript: Pass parser error location to compiler.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/vbscript/compile.c | 15 +++++++-------- dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 769bbf15ba..1f9462aee8 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1917,27 +1917,25 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli vbscode_t *code; HRESULT hres;
+ memset(&ctx, 0, sizeof(ctx)); code = ctx.code = alloc_vbscode(&ctx, src, cookie, start_line); if(!ctx.code) return E_OUTOFMEMORY;
hres = parse_script(&ctx.parser, code->source, delimiter, flags); if(FAILED(hres)) { + if(ctx.parser.error_loc != -1) + ctx.loc = ctx.parser.error_loc; hres = compile_error(script, hres); release_vbscode(code); return hres; }
- ctx.func_decls = NULL; - ctx.labels = NULL; - ctx.global_consts = NULL; - ctx.stat_ctx = NULL; - ctx.labels_cnt = ctx.labels_size = 0; - hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code); if(FAILED(hres)) { + hres = compile_error(script, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; }
ctx.global_consts = ctx.const_decls; @@ -1947,8 +1945,9 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) { hres = create_function(&ctx, func_decl, &new_func); if(FAILED(hres)) { + hres = compile_error(script, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; }
new_func->next = ctx.code->funcs; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 8d68e781fb..568d8b9a42 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -286,6 +286,7 @@ typedef struct { BOOL option_explicit; BOOL is_html; HRESULT hres; + int error_loc;
int last_token; unsigned last_nl; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 16a673fac7..8ebfc82f00 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -505,6 +505,8 @@ StSep
static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str) { + if(ctx->error_loc == -1) + ctx->error_loc = *loc; if(ctx->hres == S_OK) { FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str)); ctx->hres = E_FAIL; @@ -1142,6 +1144,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite heap_pool_init(&ctx->heap);
ctx->hres = S_OK; + ctx->error_loc = -1; ctx->last_token = tNL; ctx->last_nl = 0; ctx->stats = ctx->stats_tail = NULL;