Module: wine Branch: master Commit: 403fb41cd136d02f304dc3fc570f23f7cf2a953e URL: http://source.winehq.org/git/wine.git/?a=commit;h=403fb41cd136d02f304dc3fc57...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Aug 5 17:15:06 2016 +0200
jscript: Create scope in setup_scope.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/engine.c | 33 ++++++++++++++++++++------------- dlls/jscript/function.c | 12 +++--------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index afa2b4b..871017c 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -2775,9 +2775,10 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis return hres; }
-static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc, jsval_t *argv) +static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, scope_chain_t *scope_chain, jsdisp_t *variable_object, unsigned argc, jsval_t *argv) { const unsigned orig_stack = ctx->stack_top; + scope_chain_t *scope; unsigned i; jsval_t v; HRESULT hres; @@ -2822,14 +2823,21 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc
frame->pop_variables = i;
+ hres = scope_push(scope_chain, variable_object, to_disp(variable_object), &scope); + if(FAILED(hres)) { + stack_popn(ctx, ctx->stack_top - orig_stack); + return hres; + } + for(i = 0; i < frame->function->func_cnt; i++) { if(frame->function->funcs[i].name && !frame->function->funcs[i].event_target) { jsdisp_t *func_obj; unsigned off;
- hres = create_source_function(ctx, frame->bytecode, frame->function->funcs+i, frame->base_scope, &func_obj); + hres = create_source_function(ctx, frame->bytecode, frame->function->funcs+i, scope, &func_obj); if(FAILED(hres)) { stack_popn(ctx, ctx->stack_top - orig_stack); + scope_release(scope); return hres; }
@@ -2839,7 +2847,8 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc } }
- frame->base_scope->frame = frame; + scope->frame = frame; + frame->base_scope = frame->scope = scope; return S_OK; }
@@ -2915,17 +2924,15 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi frame->argc = argc; frame->bytecode = bytecode_addref(bytecode);
- if(scope) { - frame->base_scope = frame->scope = scope_addref(scope); - - if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) { - hres = setup_scope(ctx, frame, argc, argv); - if(FAILED(hres)) { - release_bytecode(frame->bytecode); - heap_free(frame); - return hres; - } + if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) { + hres = setup_scope(ctx, frame, scope, variable_obj, argc, argv); + if(FAILED(hres)) { + release_bytecode(frame->bytecode); + heap_free(frame); + return hres; } + }else if(scope) { + frame->base_scope = frame->scope = scope_addref(scope); }
frame->ip = function->instr_off; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 704d2ef..03d5cad 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -233,7 +233,6 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis BOOL is_constructor, BOOL caller_execs_source, jsval_t *r) { jsdisp_t *var_disp; - scope_chain_t *scope; DWORD exec_flags = 0; HRESULT hres;
@@ -251,19 +250,14 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis if(FAILED(hres)) return hres;
- hres = scope_push(function->scope_chain, var_disp, to_disp(var_disp), &scope); - jsdisp_release(var_disp); - if(FAILED(hres)) - return hres; - if(caller_execs_source) exec_flags |= EXEC_RETURN_TO_INTERP; if(is_constructor) exec_flags |= EXEC_CONSTRUCTOR; - hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj, - &function->dispex, scope->jsobj, argc, argv, r); + hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj, + &function->dispex, var_disp, argc, argv, r);
- scope_release(scope); + jsdisp_release(var_disp); return hres; }