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
28375af3
Commit
28375af3
authored
Nov 28, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Nov 28, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use bytecode for logical or expression.
parent
7d5861f6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
34 deletions
+43
-34
compile.c
dlls/jscript/compile.c
+24
-0
engine.c
dlls/jscript/engine.c
+13
-31
engine.h
dlls/jscript/engine.h
+5
-2
parser.y
dlls/jscript/parser.y
+1
-1
No files found.
dlls/jscript/compile.c
View file @
28375af3
...
...
@@ -171,6 +171,28 @@ static HRESULT compile_comma_expression(compiler_ctx_t *ctx, binary_expression_t
return
compile_expression
(
ctx
,
expr
->
expression2
);
}
/* ECMA-262 3rd Edition 11.11 */
static
HRESULT
compile_logical_expression
(
compiler_ctx_t
*
ctx
,
binary_expression_t
*
expr
,
jsop_t
op
)
{
unsigned
instr
;
HRESULT
hres
;
hres
=
compile_expression
(
ctx
,
expr
->
expression1
);
if
(
FAILED
(
hres
))
return
hres
;
instr
=
push_instr
(
ctx
,
op
);
if
(
instr
==
-
1
)
return
E_OUTOFMEMORY
;
hres
=
compile_expression
(
ctx
,
expr
->
expression2
);
if
(
FAILED
(
hres
))
return
hres
;
instr_ptr
(
ctx
,
instr
)
->
arg1
.
uint
=
ctx
->
code_off
;
return
S_OK
;
}
static
HRESULT
compile_interp_fallback
(
compiler_ctx_t
*
ctx
,
expression_t
*
expr
)
{
unsigned
instr
;
...
...
@@ -244,6 +266,8 @@ static HRESULT compile_expression(compiler_ctx_t *ctx, expression_t *expr)
return
compile_binary_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_neq
);
case
EXPR_NOTEQEQ
:
return
compile_binary_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_neq2
);
case
EXPR_OR
:
return
compile_logical_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_jmp_nz
);
case
EXPR_PLUS
:
return
compile_unary_expression
(
ctx
,
(
unary_expression_t
*
)
expr
,
OP_tonum
);
case
EXPR_SUB
:
...
...
dlls/jscript/engine.c
View file @
28375af3
...
...
@@ -94,6 +94,11 @@ static inline HRESULT stack_push_number(exec_ctx_t *ctx, double number)
return
stack_push
(
ctx
,
&
v
);
}
static
inline
VARIANT
*
stack_top
(
exec_ctx_t
*
ctx
)
{
return
ctx
->
stack
+
ctx
->
top
-
1
;
}
static
inline
VARIANT
*
stack_pop
(
exec_ctx_t
*
ctx
)
{
assert
(
ctx
->
top
);
...
...
@@ -1930,47 +1935,24 @@ HRESULT property_value_expression_eval(script_ctx_t *ctx, expression_t *_expr, D
}
/* ECMA-262 3rd Edition 11.11 */
HRESULT
logical_or_expression_eval
(
script_ctx_t
*
ctx
,
expression_t
*
_expr
,
DWORD
flags
,
jsexcept_t
*
ei
,
exprval_t
*
ret
)
HRESULT
interp_jmp_nz
(
exec_ctx_t
*
ctx
)
{
binary_expression_t
*
expr
=
(
binary_expression_t
*
)
_expr
;
exprval_t
exprval
;
const
unsigned
arg
=
ctx
->
parser
->
code
->
instrs
[
ctx
->
ip
].
arg1
.
uint
;
VARIANT_BOOL
b
;
VARIANT
val
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
hres
=
expr_eval
(
ctx
,
expr
->
expression1
,
0
,
ei
,
&
exprval
);
hres
=
to_boolean
(
stack_top
(
ctx
),
&
b
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
exprval_to_value
(
ctx
,
&
exprval
,
ei
,
&
val
);
exprval_release
(
&
exprval
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
to_boolean
(
&
val
,
&
b
);
if
(
SUCCEEDED
(
hres
)
&&
b
)
{
ret
->
type
=
EXPRVAL_VARIANT
;
ret
->
u
.
var
=
val
;
return
S_OK
;
if
(
b
)
{
ctx
->
ip
=
arg
;
}
else
{
stack_popn
(
ctx
,
1
);
ctx
->
ip
++
;
}
VariantClear
(
&
val
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
expr_eval
(
ctx
,
expr
->
expression2
,
0
,
ei
,
&
exprval
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
exprval_to_value
(
ctx
,
&
exprval
,
ei
,
&
val
);
exprval_release
(
&
exprval
);
if
(
FAILED
(
hres
))
return
hres
;
ret
->
type
=
EXPRVAL_VARIANT
;
ret
->
u
.
var
=
val
;
return
S_OK
;
}
...
...
dlls/jscript/engine.h
View file @
28375af3
...
...
@@ -50,6 +50,7 @@ typedef struct _func_stack {
X(eq2, 1, 0,0) \
X(in, 1, 0,0) \
X(int, 1, ARG_INT, 0) \
X(jmp_nz, 0, ARG_ADDR, 0) \
X(minus, 1, 0,0) \
X(neg, 1, 0,0) \
X(neq, 1, 0,0) \
...
...
@@ -77,12 +78,15 @@ typedef union {
double
*
dbl
;
LONG
lng
;
WCHAR
*
str
;
unsigned
uint
;
}
instr_arg_t
;
typedef
enum
{
ARG_NONE
=
0
,
ARG_ADDR
,
ARG_EXPR
,
ARG_INT
ARG_INT
,
ARG_STR
}
instr_arg_type_t
;
typedef
struct
{
...
...
@@ -539,7 +543,6 @@ HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*
HRESULT
array_literal_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
property_value_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
logical_or_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
logical_and_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
binary_or_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
binary_xor_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/parser.y
View file @
28375af3
...
...
@@ -1306,7 +1306,7 @@ static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *ide
static const expression_eval_t expression_eval_table[] = {
compiled_expression_eval,
logical_or
_expression_eval,
compiled
_expression_eval,
logical_and_expression_eval,
binary_or_expression_eval,
binary_xor_expression_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