Jacek Caban : jscript: Store source context and starting line in bytecode_t.
Alexandre Julliard
julliard at winehq.org
Thu Jan 30 16:10:23 CST 2020
Module: wine
Branch: master
Commit: ba500a6a9ef59d1410ad8d1c01147a3022e8ddd6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ba500a6a9ef59d1410ad8d1c01147a3022e8ddd6
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Jan 30 15:49:58 2020 +0100
jscript: Store source context and starting line in bytecode_t.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/compile.c | 10 ++++++----
dlls/jscript/engine.h | 4 +++-
dlls/jscript/function.c | 2 +-
dlls/jscript/global.c | 2 +-
dlls/jscript/jscript.c | 7 ++++---
5 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index a96adb235c..f1e005a6d3 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -2258,7 +2258,7 @@ void release_bytecode(bytecode_t *code)
heap_free(code);
}
-static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
+static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source, UINT64 source_context, unsigned start_line)
{
size_t len = source ? lstrlenW(source) : 0;
@@ -2270,6 +2270,8 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
return E_OUTOFMEMORY;
compiler->code->ref = 1;
+ compiler->code->source_context = source_context;
+ compiler->code->start_line = start_line;
heap_pool_init(&compiler->code->heap);
compiler->code->source = heap_alloc((len + 1) * sizeof(WCHAR));
@@ -2482,13 +2484,13 @@ static HRESULT compile_arguments(compiler_ctx_t *ctx, const WCHAR *args)
return parse_arguments(ctx, args, ctx->code->global_code.params, NULL);
}
-HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, const WCHAR *delimiter,
- BOOL from_eval, BOOL use_decode, bytecode_t **ret)
+HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, UINT64 source_context, unsigned start_line,
+ const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, bytecode_t **ret)
{
compiler_ctx_t compiler = {0};
HRESULT hres;
- hres = init_code(&compiler, code);
+ hres = init_code(&compiler, code, source_context, start_line);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index d158a8b51a..c5ed3c7690 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -182,6 +182,8 @@ struct _bytecode_t {
function_code_t global_code;
WCHAR *source;
+ UINT64 source_context;
+ unsigned start_line;
BSTR *bstr_pool;
unsigned bstr_pool_size;
@@ -194,7 +196,7 @@ struct _bytecode_t {
struct list entry;
};
-HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,BOOL,BOOL,bytecode_t**) DECLSPEC_HIDDEN;
+HRESULT compile_script(script_ctx_t*,const WCHAR*,UINT64,unsigned,const WCHAR*,const WCHAR*,BOOL,BOOL,bytecode_t**) DECLSPEC_HIDDEN;
void release_bytecode(bytecode_t*) DECLSPEC_HIDDEN;
static inline bytecode_t *bytecode_addref(bytecode_t *code)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 52c12676dc..e5701835b0 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -984,7 +984,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
if(FAILED(hres))
return hres;
- hres = compile_script(ctx, str, NULL, NULL, FALSE, FALSE, &code);
+ hres = compile_script(ctx, str, 0, 0, NULL, NULL, FALSE, FALSE, &code);
heap_free(str);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 2f7dbcd53f..bd1f45b940 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -204,7 +204,7 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a
return E_OUTOFMEMORY;
TRACE("parsing %s\n", debugstr_jsval(argv[0]));
- hres = compile_script(ctx, src, NULL, NULL, TRUE, FALSE, &code);
+ hres = compile_script(ctx, src, 0, 0, NULL, NULL, TRUE, FALSE, &code);
if(FAILED(hres)) {
WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres);
return throw_syntax_error(ctx, hres, NULL);
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 5b6fe3ecca..f9c2430a2b 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -774,8 +774,8 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
- hres = compile_script(This->ctx, pstrCode, NULL, pstrDelimiter, (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0,
- This->is_encode, &code);
+ hres = compile_script(This->ctx, pstrCode, dwSourceContextCookie, ulStartingLine, NULL, pstrDelimiter,
+ (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0, This->is_encode, &code);
if(FAILED(hres))
return hres;
@@ -871,7 +871,8 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
return E_UNEXPECTED;
- hres = compile_script(This->ctx, pstrCode, pstrFormalParams, pstrDelimiter, FALSE, This->is_encode, &code);
+ hres = compile_script(This->ctx, pstrCode, dwSourceContextCookie, ulStartingLineNumber, pstrFormalParams,
+ pstrDelimiter, FALSE, This->is_encode, &code);
if(FAILED(hres)) {
WARN("Parse failed %08x\n", hres);
return hres;
More information about the wine-cvs
mailing list