Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
661241a3
Commit
661241a3
authored
13 years ago
by
Jacek Caban
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
jscript: Added bytecode version of for..in statement.
parent
20913272
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dlls/jscript/compile.c
+68
-0
68 additions, 0 deletions
dlls/jscript/compile.c
dlls/jscript/engine.c
+67
-0
67 additions, 0 deletions
dlls/jscript/engine.c
dlls/jscript/engine.h
+1
-0
1 addition, 0 deletions
dlls/jscript/engine.h
dlls/jscript/parser.y
+1
-1
1 addition, 1 deletion
dlls/jscript/parser.y
with
137 additions
and
1 deletion
dlls/jscript/compile.c
+
68
−
0
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
:
...
...
This diff is collapsed.
Click to expand it.
dlls/jscript/engine.c
+
67
−
0
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
)
{
...
...
This diff is collapsed.
Click to expand it.
dlls/jscript/engine.h
+
1
−
0
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) \
...
...
This diff is collapsed.
Click to expand it.
dlls/jscript/parser.y
+
1
−
1
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,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment