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
cf2fc11e
Commit
cf2fc11e
authored
Dec 19, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 19, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use compiler for handling if statement.
parent
ccba279b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
31 deletions
+44
-31
compile.c
dlls/jscript/compile.c
+43
-0
engine.c
dlls/jscript/engine.c
+0
-29
engine.h
dlls/jscript/engine.h
+0
-1
parser.y
dlls/jscript/parser.y
+1
-1
No files found.
dlls/jscript/compile.c
View file @
cf2fc11e
...
...
@@ -882,6 +882,47 @@ static HRESULT compile_expression_statement(compiler_ctx_t *ctx, expression_stat
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.5 */
static
HRESULT
compile_if_statement
(
compiler_ctx_t
*
ctx
,
if_statement_t
*
stat
)
{
unsigned
jmp_else
,
jmp_end
;
HRESULT
hres
;
hres
=
compile_expression
(
ctx
,
stat
->
expr
);
if
(
FAILED
(
hres
))
return
hres
;
jmp_else
=
push_instr
(
ctx
,
OP_jmp_z
);
if
(
jmp_else
==
-
1
)
return
E_OUTOFMEMORY
;
hres
=
compile_statement
(
ctx
,
stat
->
if_stat
);
if
(
FAILED
(
hres
))
return
hres
;
jmp_end
=
push_instr
(
ctx
,
OP_jmp
);
if
(
jmp_end
==
-
1
)
return
E_OUTOFMEMORY
;
instr_ptr
(
ctx
,
jmp_else
)
->
arg1
.
uint
=
ctx
->
code_off
;
if
(
push_instr
(
ctx
,
OP_pop
)
==
-
1
)
return
E_OUTOFMEMORY
;
if
(
stat
->
else_stat
)
{
hres
=
compile_statement
(
ctx
,
stat
->
else_stat
);
if
(
FAILED
(
hres
))
return
hres
;
}
else
{
/* FIXME: We could sometimes avoid it */
if
(
push_instr
(
ctx
,
OP_undefined
)
==
-
1
)
return
E_OUTOFMEMORY
;
}
instr_ptr
(
ctx
,
jmp_end
)
->
arg1
.
uint
=
ctx
->
code_off
;
return
S_OK
;
}
static
HRESULT
compile_statement
(
compiler_ctx_t
*
ctx
,
statement_t
*
stat
)
{
switch
(
stat
->
type
)
{
...
...
@@ -889,6 +930,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
return
compile_block_statement
(
ctx
,
((
block_statement_t
*
)
stat
)
->
stat_list
);
case
STAT_EXPR
:
return
compile_expression_statement
(
ctx
,
(
expression_statement_t
*
)
stat
);
case
STAT_IF
:
return
compile_if_statement
(
ctx
,
(
if_statement_t
*
)
stat
);
default:
return
compile_interp_fallback
(
ctx
,
stat
);
}
...
...
dlls/jscript/engine.c
View file @
cf2fc11e
...
...
@@ -712,35 +712,6 @@ HRESULT empty_statement_eval(script_ctx_t *ctx, statement_t *stat, return_type_t
return
S_OK
;
}
/* ECMA-262 3rd Edition 12.5 */
HRESULT
if_statement_eval
(
script_ctx_t
*
ctx
,
statement_t
*
_stat
,
return_type_t
*
rt
,
VARIANT
*
ret
)
{
if_statement_t
*
stat
=
(
if_statement_t
*
)
_stat
;
VARIANT_BOOL
b
;
VARIANT
v
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
hres
=
expr_eval
(
ctx
,
stat
->
expr
,
0
,
&
rt
->
ei
,
&
v
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
to_boolean
(
&
v
,
&
b
);
VariantClear
(
&
v
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
b
)
hres
=
stat_eval
(
ctx
,
stat
->
if_stat
,
rt
,
ret
);
else
if
(
stat
->
else_stat
)
hres
=
stat_eval
(
ctx
,
stat
->
else_stat
,
rt
,
ret
);
else
V_VT
(
ret
)
=
VT_EMPTY
;
return
hres
;
}
/* ECMA-262 3rd Edition 12.6.2 */
HRESULT
while_statement_eval
(
script_ctx_t
*
ctx
,
statement_t
*
_stat
,
return_type_t
*
rt
,
VARIANT
*
ret
)
{
...
...
dlls/jscript/engine.h
View file @
cf2fc11e
...
...
@@ -400,7 +400,6 @@ typedef struct {
HRESULT
compiled_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
var_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
empty_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
if_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
while_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
for_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
HRESULT
forin_statement_eval
(
script_ctx_t
*
,
statement_t
*
,
return_type_t
*
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/parser.y
View file @
cf2fc11e
...
...
@@ -843,7 +843,7 @@ static const statement_eval_t stat_eval_table[] = {
compiled_statement_eval,
for_statement_eval,
forin_statement_eval,
if
_statement_eval,
compiled
_statement_eval,
labelled_statement_eval,
return_statement_eval,
switch_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