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
661241a3
Commit
661241a3
authored
Dec 28, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 28, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added bytecode version of for..in statement.
parent
20913272
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
1 deletion
+137
-1
compile.c
dlls/jscript/compile.c
+68
-0
engine.c
dlls/jscript/engine.c
+67
-0
engine.h
dlls/jscript/engine.h
+1
-0
parser.y
dlls/jscript/parser.y
+1
-1
No files found.
dlls/jscript/compile.c
View file @
661241a3
...
...
@@ -1097,6 +1097,72 @@ static HRESULT compile_for_statement(compiler_ctx_t *ctx, for_statement_t *stat)
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.6.4 */
static
HRESULT
compile_forin_statement
(
compiler_ctx_t
*
ctx
,
forin_statement_t
*
stat
)
{
unsigned
loop_addr
,
off_backup
=
ctx
->
code_off
;
BOOL
prev_no_fallback
;
HRESULT
hres
;
if
(
stat
->
variable
)
{
hres
=
compile_variable_list
(
ctx
,
stat
->
variable
);
if
(
FAILED
(
hres
))
return
hres
;
}
hres
=
compile_expression
(
ctx
,
stat
->
in_expr
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
stat
->
variable
)
{
hres
=
push_instr_bstr_uint
(
ctx
,
OP_identid
,
stat
->
variable
->
identifier
,
fdexNameEnsure
);
if
(
FAILED
(
hres
))
return
hres
;
}
else
if
(
is_memberid_expr
(
stat
->
expr
->
type
))
{
hres
=
compile_memberid_expression
(
ctx
,
stat
->
expr
,
fdexNameEnsure
);
if
(
FAILED
(
hres
))
return
hres
;
}
else
{
hres
=
push_instr_uint
(
ctx
,
OP_throw
,
JS_E_ILLEGAL_ASSIGN
);
if
(
FAILED
(
hres
))
return
hres
;
/* FIXME: compile statement anyways when we depend on compiler to check errors */
return
S_OK
;
}
hres
=
push_instr_int
(
ctx
,
OP_int
,
DISPID_STARTENUM
);
if
(
FAILED
(
hres
))
return
hres
;
/* FIXME: avoid */
if
(
push_instr
(
ctx
,
OP_undefined
)
==
-
1
)
return
E_OUTOFMEMORY
;
loop_addr
=
ctx
->
code_off
;
if
(
push_instr
(
ctx
,
OP_forin
)
==
-
1
)
return
E_OUTOFMEMORY
;
prev_no_fallback
=
ctx
->
no_fallback
;
ctx
->
no_fallback
=
TRUE
;
hres
=
compile_statement
(
ctx
,
stat
->
statement
);
ctx
->
no_fallback
=
prev_no_fallback
;
if
(
hres
==
E_NOTIMPL
)
{
ctx
->
code_off
=
off_backup
;
stat
->
stat
.
eval
=
forin_statement_eval
;
return
compile_interp_fallback
(
ctx
,
&
stat
->
stat
);
}
if
(
FAILED
(
hres
))
return
hres
;
hres
=
push_instr_uint
(
ctx
,
OP_jmp
,
loop_addr
);
if
(
FAILED
(
hres
))
return
hres
;
instr_ptr
(
ctx
,
loop_addr
)
->
arg1
.
uint
=
ctx
->
code_off
;
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.10 */
static
HRESULT
compile_with_statement
(
compiler_ctx_t
*
ctx
,
with_statement_t
*
stat
)
{
...
...
@@ -1244,6 +1310,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
return
compile_expression_statement
(
ctx
,
(
expression_statement_t
*
)
stat
);
case
STAT_FOR
:
return
compile_for_statement
(
ctx
,
(
for_statement_t
*
)
stat
);
case
STAT_FORIN
:
return
compile_forin_statement
(
ctx
,
(
forin_statement_t
*
)
stat
);
case
STAT_IF
:
return
compile_if_statement
(
ctx
,
(
if_statement_t
*
)
stat
);
case
STAT_LABEL
:
...
...
dlls/jscript/engine.c
View file @
661241a3
...
...
@@ -936,6 +936,73 @@ HRESULT forin_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.6.4 */
static
HRESULT
interp_forin
(
exec_ctx_t
*
ctx
)
{
const
HRESULT
arg
=
ctx
->
parser
->
code
->
instrs
[
ctx
->
ip
].
arg1
.
uint
;
IDispatch
*
var_obj
,
*
obj
=
NULL
;
IDispatchEx
*
dispex
;
DISPID
id
,
var_id
;
BSTR
name
=
NULL
;
VARIANT
*
val
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
val
=
stack_pop
(
ctx
);
assert
(
V_VT
(
stack_top
(
ctx
))
==
VT_I4
);
id
=
V_I4
(
stack_top
(
ctx
));
var_obj
=
stack_topn_objid
(
ctx
,
1
,
&
var_id
);
if
(
!
var_obj
)
{
FIXME
(
"invalid ref
\n
"
);
VariantClear
(
val
);
return
E_FAIL
;
}
if
(
V_VT
(
stack_topn
(
ctx
,
3
))
==
VT_DISPATCH
)
obj
=
V_DISPATCH
(
stack_topn
(
ctx
,
3
));
if
(
obj
)
{
hres
=
IDispatch_QueryInterface
(
obj
,
&
IID_IDispatchEx
,
(
void
**
)
&
dispex
);
if
(
SUCCEEDED
(
hres
))
{
hres
=
IDispatchEx_GetNextDispID
(
dispex
,
fdexEnumDefault
,
id
,
&
id
);
if
(
hres
==
S_OK
)
hres
=
IDispatchEx_GetMemberName
(
dispex
,
id
,
&
name
);
IDispatchEx_Release
(
dispex
);
if
(
FAILED
(
hres
))
{
VariantClear
(
val
);
return
hres
;
}
}
else
{
TRACE
(
"No IDispatchEx
\n
"
);
}
}
if
(
name
)
{
VARIANT
v
;
VariantClear
(
val
);
V_I4
(
stack_top
(
ctx
))
=
id
;
V_VT
(
&
v
)
=
VT_BSTR
;
V_BSTR
(
&
v
)
=
name
;
hres
=
disp_propput
(
ctx
->
parser
->
script
,
var_obj
,
var_id
,
&
v
,
ctx
->
ei
,
NULL
/*FIXME*/
);
SysFreeString
(
name
);
if
(
FAILED
(
hres
))
return
hres
;
ctx
->
ip
++
;
}
else
{
stack_popn
(
ctx
,
4
);
ctx
->
ip
=
arg
;
return
stack_push
(
ctx
,
val
);
}
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.7 */
HRESULT
continue_statement_eval
(
script_ctx_t
*
ctx
,
statement_t
*
_stat
,
return_type_t
*
rt
,
VARIANT
*
ret
)
{
...
...
dlls/jscript/engine.h
View file @
661241a3
...
...
@@ -61,6 +61,7 @@ typedef struct _func_stack {
X(double, 1, ARG_SBL, 0) \
X(eq, 1, 0,0) \
X(eq2, 1, 0,0) \
X(forin, 0, ARG_UINT, 0) \
X(func, 1, ARG_FUNC, 0) \
X(gt, 1, 0,0) \
X(gteq, 1, 0,0) \
...
...
dlls/jscript/parser.y
View file @
661241a3
...
...
@@ -842,7 +842,7 @@ static const statement_eval_t stat_eval_table[] = {
compiled_statement_eval,
compiled_statement_eval,
compiled_statement_eval,
forin
_statement_eval,
compiled
_statement_eval,
compiled_statement_eval,
compiled_statement_eval,
return_statement_eval,
...
...
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