Commit 403fb41c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Create scope in setup_scope.

parent 68f1df23
...@@ -2775,9 +2775,10 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis ...@@ -2775,9 +2775,10 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
return hres; 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; const unsigned orig_stack = ctx->stack_top;
scope_chain_t *scope;
unsigned i; unsigned i;
jsval_t v; jsval_t v;
HRESULT hres; HRESULT hres;
...@@ -2822,14 +2823,21 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc ...@@ -2822,14 +2823,21 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc
frame->pop_variables = i; 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++) { for(i = 0; i < frame->function->func_cnt; i++) {
if(frame->function->funcs[i].name && !frame->function->funcs[i].event_target) { if(frame->function->funcs[i].name && !frame->function->funcs[i].event_target) {
jsdisp_t *func_obj; jsdisp_t *func_obj;
unsigned off; 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)) { if(FAILED(hres)) {
stack_popn(ctx, ctx->stack_top - orig_stack); stack_popn(ctx, ctx->stack_top - orig_stack);
scope_release(scope);
return hres; return hres;
} }
...@@ -2839,7 +2847,8 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, unsigned argc ...@@ -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; return S_OK;
} }
...@@ -2915,17 +2924,15 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi ...@@ -2915,17 +2924,15 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
frame->argc = argc; frame->argc = argc;
frame->bytecode = bytecode_addref(bytecode); frame->bytecode = bytecode_addref(bytecode);
if(scope) {
frame->base_scope = frame->scope = scope_addref(scope);
if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) { if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) {
hres = setup_scope(ctx, frame, argc, argv); hres = setup_scope(ctx, frame, scope, variable_obj, argc, argv);
if(FAILED(hres)) { if(FAILED(hres)) {
release_bytecode(frame->bytecode); release_bytecode(frame->bytecode);
heap_free(frame); heap_free(frame);
return hres; return hres;
} }
} }else if(scope) {
frame->base_scope = frame->scope = scope_addref(scope);
} }
frame->ip = function->instr_off; frame->ip = function->instr_off;
......
...@@ -233,7 +233,6 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis ...@@ -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) BOOL is_constructor, BOOL caller_execs_source, jsval_t *r)
{ {
jsdisp_t *var_disp; jsdisp_t *var_disp;
scope_chain_t *scope;
DWORD exec_flags = 0; DWORD exec_flags = 0;
HRESULT hres; HRESULT hres;
...@@ -251,19 +250,14 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis ...@@ -251,19 +250,14 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
if(FAILED(hres)) if(FAILED(hres))
return 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) if(caller_execs_source)
exec_flags |= EXEC_RETURN_TO_INTERP; exec_flags |= EXEC_RETURN_TO_INTERP;
if(is_constructor) if(is_constructor)
exec_flags |= EXEC_CONSTRUCTOR; exec_flags |= EXEC_CONSTRUCTOR;
hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj, hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj,
&function->dispex, scope->jsobj, argc, argv, r); &function->dispex, var_disp, argc, argv, r);
scope_release(scope); jsdisp_release(var_disp);
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