diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 3f6a2b67aa8..f8aaa41dbdc 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1804,6 +1804,11 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, return E_OUTOFMEMORY; } + if(func_expr) { + func->source = func_expr->src_str; + func->source_len = func_expr->src_len; + } + func->source_elements = source; func->expr = func_expr; diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 929be802662..ec906a1d72f 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -814,7 +814,7 @@ static HRESULT interp_func(exec_ctx_t *ctx) 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, - ctx->scope_chain, expr->src_str, expr->src_len, &dispex); + ctx->scope_chain, &dispex); if(FAILED(hres)) return hres; @@ -2629,7 +2629,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO expr = func->funcs[i].expr; 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)) return hres; diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h index ce7ff8cd4c6..a2be6ee62ce 100644 --- a/dlls/jscript/engine.h +++ b/dlls/jscript/engine.h @@ -173,6 +173,9 @@ typedef struct _function_code_t { function_expression_t *expr; /* FIXME */ source_elements_t *source_elements; /* FIXME */ + const WCHAR *source; + unsigned source_len; + unsigned func_cnt; struct _function_code_t *funcs; } function_code_t; @@ -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; 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 { LT_INT, diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index f79ac04520c..dc4c5e831a9 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -32,8 +32,6 @@ typedef struct { scope_chain_t *scope_chain; bytecode_t *code; function_code_t *func_code; - const WCHAR *src_str; - DWORD src_len; DWORD length; jsdisp_t *arguments; } FunctionInstance; @@ -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) + name_len, native_suffixW, sizeof(native_suffixW)); }else { - str = SysAllocStringLen(function->src_str, function->src_len); + str = SysAllocStringLen(function->func_code->source, function->func_code->source_len); if(!str) return E_OUTOFMEMORY; } @@ -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, - 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; jsdisp_t *prototype; @@ -698,9 +696,6 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, parameter_t length++; function->length = length; - function->src_str = src_str; - function->src_len = src_len; - *ret = &function->dispex; return S_OK; } @@ -786,8 +781,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t } expr = code->global_code.funcs[0].expr; - hres = create_source_function(ctx, code, expr->parameter_list, code->global_code.funcs, NULL, expr->src_str, - expr->src_len, &function); + hres = create_source_function(ctx, code, expr->parameter_list, code->global_code.funcs, NULL, &function); release_bytecode(code); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index dfd7d6c86b0..da34c1155b4 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -836,7 +836,7 @@ static HRESULT WINAPI JScriptParseProcedure_ParseProcedureText(IActiveScriptPars 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); if(FAILED(hres)) return hres;