Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f5425aee
Commit
f5425aee
authored
Dec 27, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 27, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added bytecode version of while statement.
parent
a1a1cbcf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
1 deletion
+69
-1
compile.c
dlls/jscript/compile.c
+68
-0
parser.y
dlls/jscript/parser.y
+1
-1
No files found.
dlls/jscript/compile.c
View file @
f5425aee
...
@@ -32,6 +32,8 @@ struct _compiler_ctx_t {
...
@@ -32,6 +32,8 @@ struct _compiler_ctx_t {
unsigned
code_off
;
unsigned
code_off
;
unsigned
code_size
;
unsigned
code_size
;
BOOL
no_fallback
;
};
};
static
HRESULT
compile_expression
(
compiler_ctx_t
*
,
expression_t
*
);
static
HRESULT
compile_expression
(
compiler_ctx_t
*
,
expression_t
*
);
...
@@ -425,6 +427,9 @@ static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, statement_t *stat)
...
@@ -425,6 +427,9 @@ static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, statement_t *stat)
{
{
unsigned
instr
;
unsigned
instr
;
if
(
ctx
->
no_fallback
)
return
E_NOTIMPL
;
instr
=
push_instr
(
ctx
,
OP_tree
);
instr
=
push_instr
(
ctx
,
OP_tree
);
if
(
instr
==
-
1
)
if
(
instr
==
-
1
)
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
...
@@ -943,6 +948,67 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
...
@@ -943,6 +948,67 @@ static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
return
S_OK
;
return
S_OK
;
}
}
/* ECMA-262 3rd Edition 12.6.2 */
static
HRESULT
compile_while_statement
(
compiler_ctx_t
*
ctx
,
while_statement_t
*
stat
)
{
unsigned
off_backup
,
jmp_off
,
jmp
=
-
1
;
BOOL
prev_no_fallback
;
HRESULT
hres
;
off_backup
=
ctx
->
code_off
;
if
(
!
stat
->
do_while
)
{
/* FIXME: avoid */
if
(
push_instr
(
ctx
,
OP_undefined
)
==
-
1
)
return
E_OUTOFMEMORY
;
jmp_off
=
ctx
->
code_off
;
hres
=
compile_expression
(
ctx
,
stat
->
expr
);
if
(
FAILED
(
hres
))
return
hres
;
jmp
=
push_instr
(
ctx
,
OP_jmp_z
);
if
(
jmp
==
-
1
)
return
E_OUTOFMEMORY
;
if
(
push_instr
(
ctx
,
OP_pop
)
==
-
1
)
return
E_OUTOFMEMORY
;
}
else
{
jmp_off
=
ctx
->
code_off
;
}
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
=
while_statement_eval
;
return
compile_interp_fallback
(
ctx
,
&
stat
->
stat
);
}
if
(
FAILED
(
hres
))
return
hres
;
if
(
stat
->
do_while
)
{
hres
=
compile_expression
(
ctx
,
stat
->
expr
);
if
(
FAILED
(
hres
))
return
hres
;
jmp
=
push_instr
(
ctx
,
OP_jmp_z
);
if
(
jmp
==
-
1
)
return
E_OUTOFMEMORY
;
if
(
push_instr
(
ctx
,
OP_pop
)
==
-
1
)
return
E_OUTOFMEMORY
;
}
hres
=
push_instr_uint
(
ctx
,
OP_jmp
,
jmp_off
);
if
(
FAILED
(
hres
))
return
hres
;
instr_ptr
(
ctx
,
jmp
)
->
arg1
.
uint
=
ctx
->
code_off
;
return
S_OK
;
}
static
HRESULT
compile_statement
(
compiler_ctx_t
*
ctx
,
statement_t
*
stat
)
static
HRESULT
compile_statement
(
compiler_ctx_t
*
ctx
,
statement_t
*
stat
)
{
{
switch
(
stat
->
type
)
{
switch
(
stat
->
type
)
{
...
@@ -956,6 +1022,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
...
@@ -956,6 +1022,8 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_t *stat)
return
compile_if_statement
(
ctx
,
(
if_statement_t
*
)
stat
);
return
compile_if_statement
(
ctx
,
(
if_statement_t
*
)
stat
);
case
STAT_VAR
:
case
STAT_VAR
:
return
compile_var_statement
(
ctx
,
(
var_statement_t
*
)
stat
);
return
compile_var_statement
(
ctx
,
(
var_statement_t
*
)
stat
);
case
STAT_WHILE
:
return
compile_while_statement
(
ctx
,
(
while_statement_t
*
)
stat
);
default:
default:
return
compile_interp_fallback
(
ctx
,
stat
);
return
compile_interp_fallback
(
ctx
,
stat
);
}
}
...
...
dlls/jscript/parser.y
View file @
f5425aee
...
@@ -850,7 +850,7 @@ static const statement_eval_t stat_eval_table[] = {
...
@@ -850,7 +850,7 @@ static const statement_eval_t stat_eval_table[] = {
throw_statement_eval,
throw_statement_eval,
try_statement_eval,
try_statement_eval,
compiled_statement_eval,
compiled_statement_eval,
while
_statement_eval,
compiled
_statement_eval,
with_statement_eval
with_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