Jacek Caban : jscript: Store function name in function_code_t.
Alexandre Julliard
julliard at winehq.org
Tue Apr 24 13:14:41 CDT 2012
Module: wine
Branch: master
Commit: 8c533d10d6aeafd1f1de06ea59ed9434f53b9e8c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8c533d10d6aeafd1f1de06ea59ed9434f53b9e8c
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Apr 24 17:39:25 2012 +0200
jscript: Store function name in function_code_t.
---
dlls/jscript/compile.c | 16 ++++++++++++----
dlls/jscript/engine.c | 4 ++--
dlls/jscript/engine.h | 1 +
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index e2d3390..3f6a2b6 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -1771,7 +1771,8 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
return S_OK;
}
-static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, BOOL from_eval, function_code_t *func)
+static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, function_expression_t *func_expr,
+ BOOL from_eval, function_code_t *func)
{
function_declaration_t *iter;
unsigned off, i;
@@ -1796,17 +1797,24 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
dump_code(ctx, off);
func->instr_off = off;
+
+ if(func_expr && func_expr->identifier) {
+ func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
+ if(!func->name)
+ return E_OUTOFMEMORY;
+ }
+
func->source_elements = source;
+ func->expr = func_expr;
func->funcs = heap_alloc_zero(func->func_cnt * sizeof(*func->funcs));
if(!func->funcs)
return E_OUTOFMEMORY;
for(iter = source->functions, i=0; iter; iter = iter->next, i++) {
- hres = compile_function(ctx, iter->expr->source_elements, FALSE, func->funcs+i);
+ hres = compile_function(ctx, iter->expr->source_elements, iter->expr, FALSE, func->funcs+i);
if(FAILED(hres))
return hres;
- func->funcs[i].expr = iter->expr;
}
assert(i == func->func_cnt);
@@ -1839,7 +1847,7 @@ HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimi
compiler.code->parser = compiler.parser;
- hres = compile_function(&compiler, compiler.parser->source, from_eval, &compiler.code->global_code);
+ hres = compile_function(&compiler, compiler.parser->source, NULL, from_eval, &compiler.code->global_code);
if(FAILED(hres)) {
release_bytecode(compiler.code);
return hres;
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 7baa8c6..929be80 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -2624,7 +2624,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
jsdisp_t *func_obj;
VARIANT var;
- if(!func->funcs[i].expr->identifier)
+ if(!func->funcs[i].name)
continue;
expr = func->funcs[i].expr;
@@ -2634,7 +2634,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
return hres;
var_set_jsdisp(&var, func_obj);
- hres = jsdisp_propput_name(ctx->var_disp, expr->identifier, &var, ei);
+ hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, &var, ei);
jsdisp_release(func_obj);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index 3234ed9..ce7ff8c 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -167,6 +167,7 @@ typedef struct {
} instr_t;
typedef struct _function_code_t {
+ BSTR name;
unsigned instr_off;
function_expression_t *expr; /* FIXME */
More information about the wine-cvs
mailing list