Commit 375ab889 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Store source code range in function_code_t.

parent 8c533d10
...@@ -1804,6 +1804,11 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, ...@@ -1804,6 +1804,11 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if(func_expr) {
func->source = func_expr->src_str;
func->source_len = func_expr->src_len;
}
func->source_elements = source; func->source_elements = source;
func->expr = func_expr; func->expr = func_expr;
......
...@@ -814,7 +814,7 @@ static HRESULT interp_func(exec_ctx_t *ctx) ...@@ -814,7 +814,7 @@ static HRESULT interp_func(exec_ctx_t *ctx)
expr = ctx->func_code->funcs[func_idx].expr; expr = ctx->func_code->funcs[func_idx].expr;
hres = create_source_function(ctx->script, ctx->code, expr->parameter_list, ctx->func_code->funcs+func_idx, hres = create_source_function(ctx->script, ctx->code, expr->parameter_list, ctx->func_code->funcs+func_idx,
ctx->scope_chain, expr->src_str, expr->src_len, &dispex); ctx->scope_chain, &dispex);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
...@@ -2629,7 +2629,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO ...@@ -2629,7 +2629,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
expr = func->funcs[i].expr; expr = func->funcs[i].expr;
hres = create_source_function(ctx->script, code, expr->parameter_list, func->funcs+i, hres = create_source_function(ctx->script, code, expr->parameter_list, func->funcs+i,
ctx->scope_chain, expr->src_str, expr->src_len, &func_obj); ctx->scope_chain, &func_obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -173,6 +173,9 @@ typedef struct _function_code_t { ...@@ -173,6 +173,9 @@ typedef struct _function_code_t {
function_expression_t *expr; /* FIXME */ function_expression_t *expr; /* FIXME */
source_elements_t *source_elements; /* FIXME */ source_elements_t *source_elements; /* FIXME */
const WCHAR *source;
unsigned source_len;
unsigned func_cnt; unsigned func_cnt;
struct _function_code_t *funcs; struct _function_code_t *funcs;
} function_code_t; } function_code_t;
...@@ -268,7 +271,7 @@ HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,BOOL,jsexcept_t*,VA ...@@ -268,7 +271,7 @@ HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,BOOL,jsexcept_t*,VA
typedef struct _parameter_t parameter_t; typedef struct _parameter_t parameter_t;
HRESULT create_source_function(script_ctx_t*,bytecode_t*,parameter_t*,function_code_t*,scope_chain_t*, HRESULT create_source_function(script_ctx_t*,bytecode_t*,parameter_t*,function_code_t*,scope_chain_t*,
const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t**) DECLSPEC_HIDDEN;
typedef enum { typedef enum {
LT_INT, LT_INT,
......
...@@ -32,8 +32,6 @@ typedef struct { ...@@ -32,8 +32,6 @@ typedef struct {
scope_chain_t *scope_chain; scope_chain_t *scope_chain;
bytecode_t *code; bytecode_t *code;
function_code_t *func_code; function_code_t *func_code;
const WCHAR *src_str;
DWORD src_len;
DWORD length; DWORD length;
jsdisp_t *arguments; jsdisp_t *arguments;
} FunctionInstance; } FunctionInstance;
...@@ -303,7 +301,7 @@ static HRESULT function_to_string(FunctionInstance *function, BSTR *ret) ...@@ -303,7 +301,7 @@ static HRESULT function_to_string(FunctionInstance *function, BSTR *ret)
memcpy(str + sizeof(native_prefixW)/sizeof(WCHAR), function->name, name_len*sizeof(WCHAR)); memcpy(str + sizeof(native_prefixW)/sizeof(WCHAR), function->name, name_len*sizeof(WCHAR));
memcpy(str + sizeof(native_prefixW)/sizeof(WCHAR) + name_len, native_suffixW, sizeof(native_suffixW)); memcpy(str + sizeof(native_prefixW)/sizeof(WCHAR) + name_len, native_suffixW, sizeof(native_suffixW));
}else { }else {
str = SysAllocStringLen(function->src_str, function->src_len); str = SysAllocStringLen(function->func_code->source, function->func_code->source_len);
if(!str) if(!str)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -661,7 +659,7 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, ...@@ -661,7 +659,7 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
} }
HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, parameter_t *parameters, function_code_t *func_code, HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, parameter_t *parameters, function_code_t *func_code,
scope_chain_t *scope_chain, const WCHAR *src_str, DWORD src_len, jsdisp_t **ret) scope_chain_t *scope_chain, jsdisp_t **ret)
{ {
FunctionInstance *function; FunctionInstance *function;
jsdisp_t *prototype; jsdisp_t *prototype;
...@@ -698,9 +696,6 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, parameter_t ...@@ -698,9 +696,6 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, parameter_t
length++; length++;
function->length = length; function->length = length;
function->src_str = src_str;
function->src_len = src_len;
*ret = &function->dispex; *ret = &function->dispex;
return S_OK; return S_OK;
} }
...@@ -786,8 +781,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t ...@@ -786,8 +781,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t
} }
expr = code->global_code.funcs[0].expr; expr = code->global_code.funcs[0].expr;
hres = create_source_function(ctx, code, expr->parameter_list, code->global_code.funcs, NULL, expr->src_str, hres = create_source_function(ctx, code, expr->parameter_list, code->global_code.funcs, NULL, &function);
expr->src_len, &function);
release_bytecode(code); release_bytecode(code);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -836,7 +836,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars ...@@ -836,7 +836,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars
return hres; return hres;
} }
hres = create_source_function(This->ctx, code, NULL, &code->global_code, NULL, NULL, 0, &dispex); hres = create_source_function(This->ctx, code, NULL, &code->global_code, NULL, &dispex);
release_bytecode(code); release_bytecode(code);
if(FAILED(hres)) if(FAILED(hres))
return 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