Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
49ecfa95
Commit
49ecfa95
authored
Mar 25, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Store current scope chain in call_frame_t.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0e32c099
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
39 deletions
+38
-39
engine.c
dlls/jscript/engine.c
+22
-25
engine.h
dlls/jscript/engine.h
+5
-4
function.c
dlls/jscript/function.c
+4
-4
global.c
dlls/jscript/global.c
+3
-2
jscript.c
dlls/jscript/jscript.c
+4
-4
No files found.
dlls/jscript/engine.c
View file @
49ecfa95
...
...
@@ -296,7 +296,7 @@ void scope_release(scope_chain_t *scope)
}
HRESULT
create_exec_ctx
(
script_ctx_t
*
script_ctx
,
IDispatch
*
this_obj
,
jsdisp_t
*
var_disp
,
scope_chain_t
*
scope
,
BOOL
is_global
,
exec_ctx_t
**
ret
)
BOOL
is_global
,
exec_ctx_t
**
ret
)
{
exec_ctx_t
*
ctx
;
...
...
@@ -334,11 +334,6 @@ HRESULT create_exec_ctx(script_ctx_t *script_ctx, IDispatch *this_obj, jsdisp_t
script_addref
(
script_ctx
);
ctx
->
script
=
script_ctx
;
if
(
scope
)
{
scope_addref
(
scope
);
ctx
->
scope_chain
=
scope
;
}
*
ret
=
ctx
;
return
S_OK
;
}
...
...
@@ -348,8 +343,6 @@ void exec_release(exec_ctx_t *ctx)
if
(
--
ctx
->
ref
)
return
;
if
(
ctx
->
scope_chain
)
scope_release
(
ctx
->
scope_chain
);
if
(
ctx
->
var_disp
)
jsdisp_release
(
ctx
->
var_disp
);
if
(
ctx
->
this_obj
)
...
...
@@ -512,7 +505,7 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
TRACE
(
"%s
\n
"
,
debugstr_w
(
identifier
));
if
(
ctx
->
call_ctx
)
{
for
(
scope
=
ctx
->
call_ctx
->
exec_ctx
->
scope_chain
;
scope
;
scope
=
scope
->
next
)
{
for
(
scope
=
ctx
->
call_ctx
->
scope
;
scope
;
scope
=
scope
->
next
)
{
if
(
scope
->
jsobj
)
hres
=
jsdisp_get_id
(
scope
->
jsobj
,
identifier
,
fdexNameImplicit
,
&
id
);
else
...
...
@@ -694,7 +687,7 @@ static HRESULT interp_push_scope(exec_ctx_t *ctx)
if
(
FAILED
(
hres
))
return
hres
;
hres
=
scope_push
(
ctx
->
sc
ope_chain
,
to_jsdisp
(
disp
),
disp
,
&
ctx
->
scope_chain
);
hres
=
scope_push
(
ctx
->
sc
ript
->
call_ctx
->
scope
,
to_jsdisp
(
disp
),
disp
,
&
ctx
->
script
->
call_ctx
->
scope
);
IDispatch_Release
(
disp
);
return
hres
;
}
...
...
@@ -704,7 +697,7 @@ static HRESULT interp_pop_scope(exec_ctx_t *ctx)
{
TRACE
(
"
\n
"
);
scope_pop
(
&
ctx
->
sc
ope_chain
);
scope_pop
(
&
ctx
->
sc
ript
->
call_ctx
->
scope
);
return
S_OK
;
}
...
...
@@ -793,7 +786,7 @@ static HRESULT interp_push_except(exec_ctx_t *ctx)
return
E_OUTOFMEMORY
;
except
->
stack_top
=
stack_top
;
except
->
scope
=
ctx
->
scope_chain
;
except
->
scope
=
frame
->
scope
;
except
->
catch_off
=
arg1
;
except
->
ident
=
arg2
;
except
->
next
=
frame
->
except_frame
;
...
...
@@ -849,7 +842,7 @@ static HRESULT interp_func(exec_ctx_t *ctx)
TRACE
(
"%d
\n
"
,
func_idx
);
hres
=
create_source_function
(
ctx
->
script
,
frame
->
bytecode
,
frame
->
function
->
funcs
+
func_idx
,
ctx
->
scope_chain
,
&
dispex
);
frame
->
scope
,
&
dispex
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -2413,6 +2406,8 @@ OP_LIST
static
void
release_call_frame
(
call_frame_t
*
frame
)
{
if
(
frame
->
scope
)
scope_release
(
frame
->
scope
);
heap_free
(
frame
);
}
...
...
@@ -2430,8 +2425,8 @@ static HRESULT unwind_exception(exec_ctx_t *ctx)
assert
(
except_frame
->
stack_top
<=
ctx
->
top
);
stack_popn
(
ctx
,
ctx
->
top
-
except_frame
->
stack_top
);
while
(
except_frame
->
scope
!=
ctx
->
scope_chain
)
scope_pop
(
&
ctx
->
scope_chain
);
while
(
except_frame
->
scope
!=
frame
->
scope
)
scope_pop
(
&
frame
->
scope
);
frame
->
ip
=
except_frame
->
catch_off
;
...
...
@@ -2455,7 +2450,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx)
if
(
FAILED
(
hres
))
return
hres
;
hres
=
scope_push
(
ctx
->
scope_chain
,
scope_obj
,
to_disp
(
scope_obj
),
&
ctx
->
scope_chain
);
hres
=
scope_push
(
frame
->
scope
,
scope_obj
,
to_disp
(
scope_obj
),
&
frame
->
scope
);
jsdisp_release
(
scope_obj
);
}
else
{
hres
=
stack_push
(
ctx
,
except_val
);
...
...
@@ -2479,7 +2474,7 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t
TRACE
(
"
\n
"
);
frame
=
ctx
->
call_ctx
;
prev_scope
=
exec_ctx
->
scope_chain
;
prev_scope
=
frame
->
scope
;
while
(
frame
->
ip
!=
-
1
)
{
op
=
frame
->
bytecode
->
instrs
[
frame
->
ip
].
op
;
...
...
@@ -2501,20 +2496,19 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, function_code_t *func, jsval_t
assert
(
ctx
->
call_ctx
==
frame
);
if
(
FAILED
(
hres
))
{
while
(
exec_ctx
->
scope_chain
!=
prev_scope
)
scope_pop
(
&
exec_ctx
->
scope_chain
);
while
(
frame
->
scope
!=
prev_scope
)
scope_pop
(
&
frame
->
scope
);
stack_popn
(
exec_ctx
,
exec_ctx
->
top
-
frame
->
stack_base
);
}
assert
(
exec_ctx
->
top
==
frame
->
stack_base
);
assert
(
frame
->
scope
==
prev_scope
);
ctx
->
call_ctx
=
frame
->
prev_frame
;
release_call_frame
(
frame
);
if
(
FAILED
(
hres
))
return
hres
;
assert
(
exec_ctx
->
scope_chain
==
prev_scope
);
*
ret
=
exec_ctx
->
ret
;
exec_ctx
->
ret
=
jsval_undefined
();
return
S_OK
;
...
...
@@ -2557,7 +2551,7 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
return
hres
;
}
static
HRESULT
setup_call_frame
(
exec_ctx_t
*
ctx
,
bytecode_t
*
bytecode
,
function_code_t
*
function
)
static
HRESULT
setup_call_frame
(
exec_ctx_t
*
ctx
,
bytecode_t
*
bytecode
,
function_code_t
*
function
,
scope_chain_t
*
scope
)
{
call_frame_t
*
frame
;
...
...
@@ -2570,6 +2564,9 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
frame
->
ip
=
function
->
instr_off
;
frame
->
stack_base
=
ctx
->
top
;
if
(
scope
)
frame
->
scope
=
scope_addref
(
scope
);
frame
->
exec_ctx
=
ctx
;
frame
->
prev_frame
=
ctx
->
script
->
call_ctx
;
...
...
@@ -2577,7 +2574,7 @@ static HRESULT setup_call_frame(exec_ctx_t *ctx, bytecode_t *bytecode, function_
return
S_OK
;
}
HRESULT
exec_source
(
exec_ctx_t
*
ctx
,
bytecode_t
*
code
,
function_code_t
*
func
,
jsval_t
*
ret
)
HRESULT
exec_source
(
exec_ctx_t
*
ctx
,
bytecode_t
*
code
,
function_code_t
*
func
,
scope_chain_t
*
scope
,
jsval_t
*
ret
)
{
jsval_t
val
;
unsigned
i
;
...
...
@@ -2589,7 +2586,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, js
if
(
!
func
->
funcs
[
i
].
name
)
continue
;
hres
=
create_source_function
(
ctx
->
script
,
code
,
func
->
funcs
+
i
,
ctx
->
scope_chain
,
&
func_obj
);
hres
=
create_source_function
(
ctx
->
script
,
code
,
func
->
funcs
+
i
,
scope
,
&
func_obj
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -2612,7 +2609,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, js
}
}
hres
=
setup_call_frame
(
ctx
,
code
,
func
);
hres
=
setup_call_frame
(
ctx
,
code
,
func
,
scope
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
dlls/jscript/engine.h
View file @
49ecfa95
...
...
@@ -182,9 +182,10 @@ typedef struct _scope_chain_t {
HRESULT
scope_push
(
scope_chain_t
*
,
jsdisp_t
*
,
IDispatch
*
,
scope_chain_t
**
)
DECLSPEC_HIDDEN
;
void
scope_release
(
scope_chain_t
*
)
DECLSPEC_HIDDEN
;
static
inline
void
scope_addref
(
scope_chain_t
*
scope
)
static
inline
scope_chain_t
*
scope_addref
(
scope_chain_t
*
scope
)
{
scope
->
ref
++
;
return
scope
;
}
typedef
struct
_except_frame_t
except_frame_t
;
...
...
@@ -194,6 +195,7 @@ typedef struct _call_frame_t {
unsigned
ip
;
except_frame_t
*
except_frame
;
unsigned
stack_base
;
scope_chain_t
*
scope
;
bytecode_t
*
bytecode
;
function_code_t
*
function
;
...
...
@@ -206,7 +208,6 @@ struct _exec_ctx_t {
LONG
ref
;
script_ctx_t
*
script
;
scope_chain_t
*
scope_chain
;
jsdisp_t
*
var_disp
;
IDispatch
*
this_obj
;
BOOL
is_global
;
...
...
@@ -223,6 +224,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
*
,
IDispatch
*
,
jsdisp_t
*
,
scope_chain_t
*
,
BOOL
,
exec_ctx_t
**
)
DECLSPEC_HIDDEN
;
HRESULT
exec_source
(
exec_ctx_t
*
,
bytecode_t
*
,
function_code_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
create_exec_ctx
(
script_ctx_t
*
,
IDispatch
*
,
jsdisp_t
*
,
BOOL
,
exec_ctx_t
**
)
DECLSPEC_HIDDEN
;
HRESULT
exec_source
(
exec_ctx_t
*
,
bytecode_t
*
,
function_code_t
*
,
scope_chain_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
create_source_function
(
script_ctx_t
*
,
bytecode_t
*
,
function_code_t
*
,
scope_chain_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
dlls/jscript/function.c
View file @
49ecfa95
...
...
@@ -239,19 +239,19 @@ 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
,
this_obj
,
var_disp
,
scope
,
FALSE
,
&
exec_ctx
);
scope_release
(
scope
);
hres
=
create_exec_ctx
(
ctx
,
this_obj
,
var_disp
,
FALSE
,
&
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
,
r
);
hres
=
exec_source
(
exec_ctx
,
function
->
code
,
function
->
func_code
,
scope
,
r
);
function
->
arguments
=
prev_args
;
exec_release
(
exec_ctx
);
}
scope_release
(
scope
);
}
/* Reset arguments value to cut the reference cycle. Note that since all activation contexts have
...
...
dlls/jscript/global.c
View file @
49ecfa95
...
...
@@ -188,6 +188,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
static
HRESULT
JSGlobal_eval
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
call_frame_t
*
frame
;
bytecode_t
*
code
;
const
WCHAR
*
src
;
HRESULT
hres
;
...
...
@@ -206,7 +207,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
return
S_OK
;
}
if
(
!
ctx
->
call_ctx
)
{
if
(
!
(
frame
=
ctx
->
call_ctx
)
)
{
FIXME
(
"No active exec_ctx
\n
"
);
return
E_UNEXPECTED
;
}
...
...
@@ -222,7 +223,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
return
throw_syntax_error
(
ctx
,
hres
,
NULL
);
}
hres
=
exec_source
(
ctx
->
call_ctx
->
exec_ctx
,
code
,
&
code
->
global_code
,
r
);
hres
=
exec_source
(
ctx
->
call_ctx
->
exec_ctx
,
code
,
&
code
->
global_code
,
frame
->
scope
,
r
);
release_bytecode
(
code
);
return
hres
;
}
...
...
dlls/jscript/jscript.c
View file @
49ecfa95
...
...
@@ -103,14 +103,14 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code)
exec_ctx_t
*
exec_ctx
;
HRESULT
hres
;
hres
=
create_exec_ctx
(
This
->
ctx
,
NULL
,
This
->
ctx
->
global
,
NULL
,
TRUE
,
&
exec_ctx
);
hres
=
create_exec_ctx
(
This
->
ctx
,
NULL
,
This
->
ctx
->
global
,
TRUE
,
&
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
);
hres
=
exec_source
(
exec_ctx
,
code
,
&
code
->
global_code
,
NULL
,
NULL
);
exec_release
(
exec_ctx
);
IActiveScriptSite_OnLeaveScript
(
This
->
site
);
...
...
@@ -774,14 +774,14 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if
(
dwFlags
&
SCRIPTTEXT_ISEXPRESSION
)
{
exec_ctx_t
*
exec_ctx
;
hres
=
create_exec_ctx
(
This
->
ctx
,
NULL
,
This
->
ctx
->
global
,
NULL
,
TRUE
,
&
exec_ctx
);
hres
=
create_exec_ctx
(
This
->
ctx
,
NULL
,
This
->
ctx
->
global
,
TRUE
,
&
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
,
&
r
);
hres
=
exec_source
(
exec_ctx
,
code
,
&
code
->
global_code
,
NULL
,
&
r
);
if
(
SUCCEEDED
(
hres
))
{
if
(
pvarResult
)
hres
=
jsval_to_variant
(
r
,
pvarResult
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment