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
b268e41d
Commit
b268e41d
authored
Dec 16, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Dec 16, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use bytecode for function expression implementation.
parent
f999f4ae
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
22 deletions
+39
-22
compile.c
dlls/jscript/compile.c
+17
-0
engine.c
dlls/jscript/engine.c
+10
-20
engine.h
dlls/jscript/engine.h
+3
-1
parser.y
dlls/jscript/parser.y
+1
-1
lang.js
dlls/jscript/tests/lang.js
+6
-0
run.c
dlls/jscript/tests/run.c
+2
-0
No files found.
dlls/jscript/compile.c
View file @
b268e41d
...
...
@@ -646,6 +646,21 @@ static HRESULT compile_array_literal(compiler_ctx_t *ctx, array_literal_expressi
return
push_instr_uint
(
ctx
,
OP_carray
,
elem_cnt
);
}
static
HRESULT
compile_function_expression
(
compiler_ctx_t
*
ctx
,
function_expression_t
*
expr
)
{
unsigned
instr
;
/* FIXME: not exactly right */
if
(
expr
->
identifier
)
return
push_instr_bstr
(
ctx
,
OP_ident
,
expr
->
identifier
);
instr
=
push_instr
(
ctx
,
OP_func
);
if
(
instr
==
-
1
)
return
E_OUTOFMEMORY
;
instr_ptr
(
ctx
,
instr
)
->
arg1
.
func
=
expr
;
return
S_OK
;
}
static
HRESULT
compile_expression_noret
(
compiler_ctx_t
*
ctx
,
expression_t
*
expr
,
BOOL
*
no_ret
)
{
...
...
@@ -702,6 +717,8 @@ static HRESULT compile_expression_noret(compiler_ctx_t *ctx, expression_t *expr,
return
compile_binary_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_eq
);
case
EXPR_EQEQ
:
return
compile_binary_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_eq2
);
case
EXPR_FUNC
:
return
compile_function_expression
(
ctx
,
(
function_expression_t
*
)
expr
);
case
EXPR_GREATER
:
return
compile_binary_expression
(
ctx
,
(
binary_expression_t
*
)
expr
,
OP_gt
);
case
EXPR_GREATEREQ
:
...
...
dlls/jscript/engine.c
View file @
b268e41d
...
...
@@ -1420,32 +1420,22 @@ HRESULT try_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_t
}
/* ECMA-262 3rd Edition 13 */
HRESULT
function_expression_eval
(
script_ctx_t
*
ctx
,
expression_t
*
_expr
,
DWORD
flags
,
jsexcept_t
*
ei
,
exprval_t
*
ret
)
static
HRESULT
interp_func
(
exec_ctx_t
*
ctx
)
{
function_expression_t
*
expr
=
(
function_expression_t
*
)
_expr
;
VARIANT
var
;
function_expression_t
*
expr
=
ctx
->
parser
->
code
->
instrs
[
ctx
->
ip
].
arg1
.
func
;
jsdisp_t
*
dispex
;
VARIANT
v
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
if
(
expr
->
identifier
)
{
hres
=
jsdisp_propget_name
(
ctx
->
exec_ctx
->
var_disp
,
expr
->
identifier
,
&
var
,
ei
,
NULL
/*FIXME*/
);
if
(
FAILED
(
hres
))
return
hres
;
}
else
{
jsdisp_t
*
dispex
;
hres
=
create_source_function
(
ctx
->
exec_ctx
->
parser
,
expr
->
parameter_list
,
expr
->
source_elements
,
ctx
->
exec_ctx
->
scope_chain
,
expr
->
src_str
,
expr
->
src_len
,
&
dispex
);
if
(
FAILED
(
hres
))
return
hres
;
var_set_jsdisp
(
&
var
,
dispex
);
}
hres
=
create_source_function
(
ctx
->
parser
,
expr
->
parameter_list
,
expr
->
source_elements
,
ctx
->
scope_chain
,
expr
->
src_str
,
expr
->
src_len
,
&
dispex
);
if
(
FAILED
(
hres
))
return
hres
;
ret
->
type
=
EXPRVAL_VARIANT
;
ret
->
u
.
var
=
var
;
return
S_OK
;
var_set_jsdisp
(
&
v
,
dispex
);
return
stack_push
(
ctx
,
&
v
);
}
/* ECMA-262 3rd Edition 11.2.1 */
...
...
dlls/jscript/engine.h
View file @
b268e41d
...
...
@@ -57,6 +57,7 @@ typedef struct _func_stack {
X(double, 1, ARG_SBL, 0) \
X(eq, 1, 0,0) \
X(eq2, 1, 0,0) \
X(func, 1, ARG_FUNC, 0) \
X(gt, 1, 0,0) \
X(gteq, 1, 0,0) \
X(ident, 1, ARG_BSTR, 0) \
...
...
@@ -117,6 +118,7 @@ typedef union {
LONG
lng
;
WCHAR
*
str
;
unsigned
uint
;
function_expression_t
*
func
;
/* FIXME */
}
instr_arg_t
;
typedef
enum
{
...
...
@@ -124,6 +126,7 @@ typedef enum {
ARG_ADDR
,
ARG_BSTR
,
ARG_EXPR
,
ARG_FUNC
,
ARG_INT
,
ARG_STR
}
instr_arg_type_t
;
...
...
@@ -565,7 +568,6 @@ typedef struct {
prop_val_t
*
property_list
;
}
property_value_expression_t
;
HRESULT
function_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
compiled_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/parser.y
View file @
b268e41d
...
...
@@ -1357,7 +1357,7 @@ static const expression_eval_t expression_eval_table[] = {
compiled_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
function
_expression_eval,
compiled
_expression_eval,
compiled_expression_eval,
compiled_expression_eval,
property_value_expression_eval,
...
...
dlls/jscript/tests/lang.js
View file @
b268e41d
...
...
@@ -1110,6 +1110,12 @@ ok(newValue === 1, "newValue = " + newValue);
obj = {undefined: 3};
ok(typeof(name_override_func) === "
function
", "
typeof
(
name_override_func
)
=
" + typeof(name_override_func));
name_override_func = 3;
ok(name_override_func === 3, "
name_override_func
=
" + name_override_func);
function name_override_func() {};
ok(name_override_func === 3, "
name_override_func
=
" + name_override_func);
/* Keep this test in the end of file */
undefined = 6;
ok(undefined === 6, "
undefined
=
" + undefined);
...
...
dlls/jscript/tests/run.c
View file @
b268e41d
...
...
@@ -1487,6 +1487,8 @@ static void run_tests(void)
CHECK_CALLED
(
global_propdelete_d
);
CHECK_CALLED
(
DeleteMemberByDispID
);
parse_script_a
(
"(function reportSuccess() {})()"
);
parse_script_a
(
"ok(typeof(test) === 'object',
\"
typeof(test) != 'object'
\"
);"
);
parse_script_a
(
"function reportSuccess() {}; reportSuccess();"
);
...
...
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