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
474f1152
Commit
474f1152
authored
Apr 25, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 25, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Moved collecting variable declarations from parser to compiler.
parent
b866c7f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
35 deletions
+32
-35
compile.c
dlls/jscript/compile.c
+30
-14
engine.h
dlls/jscript/engine.h
+1
-9
parser.y
dlls/jscript/parser.y
+1
-12
No files found.
dlls/jscript/compile.c
View file @
474f1152
...
...
@@ -53,6 +53,9 @@ typedef struct {
statement_ctx_t
*
stat_ctx
;
function_code_t
*
func
;
variable_declaration_t
*
var_head
;
variable_declaration_t
*
var_tail
;
}
compiler_ctx_t
;
static
const
struct
{
...
...
@@ -988,7 +991,19 @@ static HRESULT compile_variable_list(compiler_ctx_t *ctx, variable_declaration_t
variable_declaration_t
*
iter
;
HRESULT
hres
;
assert
(
list
!=
NULL
);
if
(
ctx
->
var_tail
)
ctx
->
var_tail
->
global_next
=
list
;
else
ctx
->
var_head
=
list
;
for
(
iter
=
list
;
iter
;
iter
=
iter
->
next
)
{
ctx
->
func
->
var_cnt
++
;
iter
->
global_next
=
iter
->
next
;
if
(
!
iter
->
next
)
ctx
->
var_tail
=
iter
;
if
(
!
iter
->
expr
)
continue
;
...
...
@@ -1771,13 +1786,15 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
static
HRESULT
compile_function
(
compiler_ctx_t
*
ctx
,
source_elements_t
*
source
,
function_expression_t
*
func_expr
,
BOOL
from_eval
,
function_code_t
*
func
)
{
variable_declaration_t
*
var_iter
;
function_declaration_t
*
iter
;
var_list_t
*
var_iter
;
unsigned
off
,
i
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
ctx
->
var_head
=
ctx
->
var_tail
=
NULL
;
off
=
ctx
->
code_off
;
ctx
->
func
=
func
;
hres
=
compile_block_statement
(
ctx
,
source
->
statement
);
...
...
@@ -1822,6 +1839,18 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
}
}
func
->
variables
=
compiler_alloc
(
ctx
->
code
,
func
->
var_cnt
*
sizeof
(
*
func
->
variables
));
if
(
!
func
->
variables
)
return
E_OUTOFMEMORY
;
for
(
var_iter
=
ctx
->
var_head
,
i
=
0
;
var_iter
;
var_iter
=
var_iter
->
global_next
,
i
++
)
{
func
->
variables
[
i
]
=
compiler_alloc_bstr
(
ctx
,
var_iter
->
identifier
);
if
(
!
func
->
variables
[
i
])
return
E_OUTOFMEMORY
;
}
assert
(
i
==
func
->
var_cnt
);
func
->
funcs
=
compiler_alloc
(
ctx
->
code
,
func
->
func_cnt
*
sizeof
(
*
func
->
funcs
));
if
(
!
func
->
funcs
)
return
E_OUTOFMEMORY
;
...
...
@@ -1835,19 +1864,6 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
assert
(
i
==
func
->
func_cnt
);
for
(
var_iter
=
source
->
variables
;
var_iter
;
var_iter
=
var_iter
->
next
)
func
->
var_cnt
++
;
func
->
variables
=
compiler_alloc
(
ctx
->
code
,
func
->
var_cnt
*
sizeof
(
*
func
->
variables
));
if
(
!
func
->
variables
)
return
E_OUTOFMEMORY
;
for
(
var_iter
=
source
->
variables
,
i
=
0
;
var_iter
;
var_iter
=
var_iter
->
next
,
i
++
)
{
func
->
variables
[
i
]
=
compiler_alloc_bstr
(
ctx
,
var_iter
->
identifier
);
if
(
!
func
->
variables
[
i
])
return
E_OUTOFMEMORY
;
}
return
S_OK
;
}
...
...
dlls/jscript/engine.h
View file @
474f1152
...
...
@@ -27,17 +27,9 @@ typedef struct _function_declaration_t {
struct
_function_declaration_t
*
next
;
}
function_declaration_t
;
typedef
struct
_var_list_t
{
const
WCHAR
*
identifier
;
struct
_var_list_t
*
next
;
}
var_list_t
;
typedef
struct
_func_stack
{
function_declaration_t
*
func_head
;
function_declaration_t
*
func_tail
;
var_list_t
*
var_head
;
var_list_t
*
var_tail
;
struct
_func_stack
*
next
;
}
func_stack_t
;
...
...
@@ -302,6 +294,7 @@ typedef struct _variable_declaration_t {
expression_t
*
expr
;
struct
_variable_declaration_t
*
next
;
struct
_variable_declaration_t
*
global_next
;
/* for compiler */
}
variable_declaration_t
;
typedef
enum
{
...
...
@@ -505,7 +498,6 @@ struct _source_elements_t {
statement_t
*
statement
;
statement_t
*
statement_tail
;
function_declaration_t
*
functions
;
var_list_t
*
variables
;
};
struct
_function_expression_t
{
...
...
dlls/jscript/parser.y
View file @
474f1152
...
...
@@ -1051,19 +1051,11 @@ static statement_t *new_block_statement(parser_ctx_t *ctx, statement_list_t *lis
static variable_declaration_t *new_variable_declaration(parser_ctx_t *ctx, const WCHAR *identifier, expression_t *expr)
{
variable_declaration_t *ret = parser_alloc(ctx, sizeof(variable_declaration_t));
var_list_t *var_list = parser_alloc(ctx, sizeof(var_list_t));
ret->identifier = identifier;
ret->expr = expr;
ret->next = NULL;
var_list->identifier = identifier;
var_list->next = NULL;
if(ctx->func_stack->var_tail)
ctx->func_stack->var_tail = ctx->func_stack->var_tail->next = var_list;
else
ctx->func_stack->var_head = ctx->func_stack->var_tail = var_list;
ret->global_next = NULL;
return ret;
}
...
...
@@ -1503,7 +1495,6 @@ static void push_func(parser_ctx_t *ctx)
func_stack_t *new_func = parser_alloc_tmp(ctx, sizeof(func_stack_t));
new_func->func_head = new_func->func_tail = NULL;
new_func->var_head = new_func->var_tail = NULL;
new_func->next = ctx->func_stack;
ctx->func_stack = new_func;
...
...
@@ -1512,7 +1503,6 @@ static void push_func(parser_ctx_t *ctx)
static source_elements_t *function_body_parsed(parser_ctx_t *ctx, source_elements_t *source)
{
source->functions = ctx->func_stack->func_head;
source->variables = ctx->func_stack->var_head;
pop_func(ctx);
return source;
...
...
@@ -1521,7 +1511,6 @@ static source_elements_t *function_body_parsed(parser_ctx_t *ctx, source_element
static void program_parsed(parser_ctx_t *ctx, source_elements_t *source)
{
source->functions = ctx->func_stack->func_head;
source->variables = ctx->func_stack->var_head;
pop_func(ctx);
ctx->source = source;
...
...
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