Commit ba500a6a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Store source context and starting line in bytecode_t.

parent 614ea7e6
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment