jscript: Store is_global flag in call_frame_t.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Jacek Caban 2016-03-25 17:50:06 +01:00 committed by Alexandre Julliard
parent 932ffa0de9
commit 00ce4419b4
5 changed files with 16 additions and 16 deletions

View File

@ -295,7 +295,7 @@ void scope_release(scope_chain_t *scope)
heap_free(scope);
}
HRESULT create_exec_ctx(script_ctx_t *script_ctx, BOOL is_global, exec_ctx_t **ret)
HRESULT create_exec_ctx(script_ctx_t *script_ctx, exec_ctx_t **ret)
{
exec_ctx_t *ctx;
@ -304,7 +304,6 @@ HRESULT create_exec_ctx(script_ctx_t *script_ctx, BOOL is_global, exec_ctx_t **r
return E_OUTOFMEMORY;
ctx->ref = 1;
ctx->is_global = is_global;
script_addref(script_ctx);
ctx->script = script_ctx;
@ -2532,7 +2531,7 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
}
static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
IDispatch *this_obj, jsdisp_t *variable_obj)
IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj)
{
call_frame_t *frame;
@ -2569,6 +2568,7 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
frame->this_obj = to_disp(ctx->script->global);
IDispatch_AddRef(frame->this_obj);
frame->is_global = is_global;
frame->variable_obj = jsdisp_addref(variable_obj);
frame->exec_ctx = ctx;
@ -2579,7 +2579,7 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
}
HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, scope_chain_t *scope,
IDispatch *this_obj, jsdisp_t *variable_obj, jsval_t *ret)
IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj, jsval_t *ret)
{
jsval_t val;
unsigned i;
@ -2605,7 +2605,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, sc
}
for(i=0; i < func->var_cnt; i++) {
if(!ctx->is_global || !lookup_global_members(ctx->script, func->variables[i], NULL)) {
if(!is_global || !lookup_global_members(ctx->script, func->variables[i], NULL)) {
DISPID id = 0;
hres = jsdisp_get_id(variable_obj, func->variables[i], fdexNameEnsure, &id);
@ -2614,7 +2614,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, sc
}
}
hres = setup_call_frame(ctx, code, func, scope, this_obj, variable_obj);
hres = setup_call_frame(ctx, code, func, scope, this_obj, is_global, variable_obj);
if(FAILED(hres))
return hres;

View File

@ -202,6 +202,7 @@ typedef struct _call_frame_t {
IDispatch *this_obj;
jsdisp_t *variable_obj;
BOOL is_global;
bytecode_t *bytecode;
function_code_t *function;
@ -214,7 +215,6 @@ struct _exec_ctx_t {
LONG ref;
script_ctx_t *script;
BOOL is_global;
};
static inline void exec_addref(exec_ctx_t *ctx)
@ -223,6 +223,6 @@ static inline void exec_addref(exec_ctx_t *ctx)
}
void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN;
HRESULT create_exec_ctx(script_ctx_t*,BOOL,exec_ctx_t**) DECLSPEC_HIDDEN;
HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT create_exec_ctx(script_ctx_t*,exec_ctx_t**) DECLSPEC_HIDDEN;
HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,BOOL,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;

View File

@ -239,13 +239,13 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
hres = scope_push(function->scope_chain, var_disp, to_disp(var_disp), &scope);
if(SUCCEEDED(hres)) {
hres = create_exec_ctx(ctx, FALSE, &exec_ctx);
hres = create_exec_ctx(ctx, &exec_ctx);
if(SUCCEEDED(hres)) {
jsdisp_t *prev_args;
prev_args = function->arguments;
function->arguments = arg_disp;
hres = exec_source(exec_ctx, function->code, function->func_code, scope, this_obj, var_disp, r);
hres = exec_source(exec_ctx, function->code, function->func_code, scope, this_obj, FALSE, var_disp, r);
function->arguments = prev_args;
exec_release(exec_ctx);

View File

@ -224,7 +224,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
}
hres = exec_source(ctx->call_ctx->exec_ctx, code, &code->global_code, frame->scope,
frame->this_obj, frame->variable_obj, r);
frame->this_obj, frame->is_global, frame->variable_obj, r);
release_bytecode(code);
return hres;
}

View File

@ -105,14 +105,14 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code)
exec_ctx_t *exec_ctx;
HRESULT hres;
hres = create_exec_ctx(This->ctx, TRUE, &exec_ctx);
hres = create_exec_ctx(This->ctx, &exec_ctx);
if(FAILED(hres))
return hres;
IActiveScriptSite_OnEnterScript(This->site);
clear_ei(This->ctx);
hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, This->ctx->global, NULL);
hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, NULL);
exec_release(exec_ctx);
IActiveScriptSite_OnLeaveScript(This->site);
@ -776,14 +776,14 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
exec_ctx_t *exec_ctx;
hres = create_exec_ctx(This->ctx, TRUE, &exec_ctx);
hres = create_exec_ctx(This->ctx, &exec_ctx);
if(SUCCEEDED(hres)) {
jsval_t r;
IActiveScriptSite_OnEnterScript(This->site);
clear_ei(This->ctx);
hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, This->ctx->global, &r);
hres = exec_source(exec_ctx, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, &r);
if(SUCCEEDED(hres)) {
if(pvarResult)
hres = jsval_to_variant(r, pvarResult);