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
fe9cb0c2
Commit
fe9cb0c2
authored
Nov 18, 2011
by
Jacek Caban
Committed by
Alexandre Julliard
Nov 18, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use a helper function to allocate expression structs.
parent
2a9d63f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
36 deletions
+46
-36
engine.h
dlls/jscript/engine.h
+12
-1
parser.y
dlls/jscript/parser.y
+34
-35
No files found.
dlls/jscript/engine.h
View file @
fe9cb0c2
...
...
@@ -443,7 +443,18 @@ typedef enum {
EXPR_ASSIGNMOD
,
EXPR_ASSIGNAND
,
EXPR_ASSIGNOR
,
EXPR_ASSIGNXOR
EXPR_ASSIGNXOR
,
EXPR_COND
,
EXPR_ARRAY
,
EXPR_MEMBER
,
EXPR_NEW
,
EXPR_CALL
,
EXPR_THIS
,
EXPR_FUNC
,
EXPR_IDENT
,
EXPR_ARRAYLIT
,
EXPR_PROPVAL
,
EXPR_LITERAL
}
expression_type_t
;
HRESULT
function_expression_eval
(
script_ctx_t
*
,
expression_t
*
,
DWORD
,
jsexcept_t
*
,
exprval_t
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/parser.y
View file @
fe9cb0c2
...
...
@@ -123,6 +123,7 @@ static inline void pop_func(parser_ctx_t *ctx)
ctx->func_stack = ctx->func_stack->next;
}
static void *new_expression(parser_ctx_t *ctx,expression_type_t,size_t);
static expression_t *new_function_expression(parser_ctx_t*,const WCHAR*,parameter_list_t*,
source_elements_t*,const WCHAR*,DWORD);
static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*);
...
...
@@ -132,7 +133,6 @@ static expression_t *new_array_expression(parser_ctx_t*,expression_t*,expression
static expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
static expression_t *new_new_expression(parser_ctx_t*,expression_t*,argument_list_t*);
static expression_t *new_call_expression(parser_ctx_t*,expression_t*,argument_list_t*);
static expression_t *new_this_expression(parser_ctx_t*);
static expression_t *new_identifier_expression(parser_ctx_t*,const WCHAR*);
static expression_t *new_literal_expression(parser_ctx_t*,literal_t*);
static expression_t *new_array_literal_expression(parser_ctx_t*,element_list_t*,int);
...
...
@@ -740,7 +740,7 @@ ArgumentList
/* ECMA-262 3rd Edition 11.1 */
PrimaryExpression
: kTHIS { $$ = new_
this_expression(ctx
); }
: kTHIS { $$ = new_
expression(ctx, EXPR_THIS, 0
); }
| tIdentifier { $$ = new_identifier_expression(ctx, $1); }
| Literal { $$ = new_literal_expression(ctx, $1); }
| ArrayLiteral { $$ = $1; }
...
...
@@ -1281,9 +1281,8 @@ static parameter_list_t *parameter_list_add(parser_ctx_t *ctx, parameter_list_t
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier,
parameter_list_t *parameter_list, source_elements_t *source_elements, const WCHAR *src_str, DWORD src_len)
{
function_expression_t *ret =
parser_alloc(ctx, sizeof(function_expression_
t));
function_expression_t *ret =
new_expression(ctx, EXPR_FUNC, sizeof(*re
t));
ret->expr.eval = function_expression_eval;
ret->identifier = identifier;
ret->parameter_list = parameter_list ? parameter_list->head : NULL;
ret->source_elements = source_elements;
...
...
@@ -1353,14 +1352,33 @@ static const expression_eval_t expression_eval_table[] = {
assign_and_expression_eval,
assign_or_expression_eval,
assign_xor_expression_eval,
conditional_expression_eval,
array_expression_eval,
member_expression_eval,
new_expression_eval,
call_expression_eval,
this_expression_eval,
function_expression_eval,
identifier_expression_eval,
array_literal_expression_eval,
property_value_expression_eval,
literal_expression_eval
};
static void *new_expression(parser_ctx_t *ctx, expression_type_t type, size_t size)
{
expression_t *ret = parser_alloc(ctx, size ? size : sizeof(*ret));
ret->eval = expression_eval_table[type];
return ret;
}
static expression_t *new_binary_expression(parser_ctx_t *ctx, expression_type_t type,
expression_t *expression1, expression_t *expression2)
{
binary_expression_t *ret =
parser_alloc(ctx, sizeof(binary_expression_
t));
binary_expression_t *ret =
new_expression(ctx, type, sizeof(*re
t));
ret->expr.eval = expression_eval_table[type];
ret->expression1 = expression1;
ret->expression2 = expression2;
...
...
@@ -1369,9 +1387,8 @@ static expression_t *new_binary_expression(parser_ctx_t *ctx, expression_type_t
static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *expression)
{
unary_expression_t *ret =
parser_alloc(ctx, sizeof(unary_expression_
t));
unary_expression_t *ret =
new_expression(ctx, type, sizeof(*re
t));
ret->expr.eval = expression_eval_table[type];
ret->expression = expression;
return &ret->expr;
...
...
@@ -1380,9 +1397,8 @@ static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t t
static expression_t *new_conditional_expression(parser_ctx_t *ctx, expression_t *expression,
expression_t *true_expression, expression_t *false_expression)
{
conditional_expression_t *ret =
parser_alloc(ctx, sizeof(conditional_expression_
t));
conditional_expression_t *ret =
new_expression(ctx, EXPR_COND, sizeof(*re
t));
ret->expr.eval = conditional_expression_eval;
ret->expression = expression;
ret->true_expression = true_expression;
ret->false_expression = false_expression;
...
...
@@ -1392,9 +1408,8 @@ static expression_t *new_conditional_expression(parser_ctx_t *ctx, expression_t
static expression_t *new_array_expression(parser_ctx_t *ctx, expression_t *member_expr, expression_t *expression)
{
array_expression_t *ret =
parser_alloc(ctx, sizeof(array_expression_
t));
array_expression_t *ret =
new_expression(ctx, EXPR_ARRAY, sizeof(*re
t));
ret->expr.eval = array_expression_eval;
ret->member_expr = member_expr;
ret->expression = expression;
...
...
@@ -1403,9 +1418,8 @@ static expression_t *new_array_expression(parser_ctx_t *ctx, expression_t *membe
static expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *expression, const WCHAR *identifier)
{
member_expression_t *ret =
parser_alloc(ctx, sizeof(member_expression_
t));
member_expression_t *ret =
new_expression(ctx, EXPR_MEMBER, sizeof(*re
t));
ret->expr.eval = member_expression_eval;
ret->expression = expression;
ret->identifier = identifier;
...
...
@@ -1414,9 +1428,8 @@ static expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *expr
static expression_t *new_new_expression(parser_ctx_t *ctx, expression_t *expression, argument_list_t *argument_list)
{
call_expression_t *ret =
parser_alloc(ctx, sizeof(call_expression_
t));
call_expression_t *ret =
new_expression(ctx, EXPR_NEW, sizeof(*re
t));
ret->expr.eval = new_expression_eval;
ret->expression = expression;
ret->argument_list = argument_list ? argument_list->head : NULL;
...
...
@@ -1425,24 +1438,14 @@ static expression_t *new_new_expression(parser_ctx_t *ctx, expression_t *express
static expression_t *new_call_expression(parser_ctx_t *ctx, expression_t *expression, argument_list_t *argument_list)
{
call_expression_t *ret =
parser_alloc(ctx, sizeof(call_expression_
t));
call_expression_t *ret =
new_expression(ctx, EXPR_CALL, sizeof(*re
t));
ret->expr.eval = call_expression_eval;
ret->expression = expression;
ret->argument_list = argument_list ? argument_list->head : NULL;
return &ret->expr;
}
static expression_t *new_this_expression(parser_ctx_t *ctx)
{
expression_t *ret = parser_alloc(ctx, sizeof(expression_t));
ret->eval = this_expression_eval;
return ret;
}
static int parser_error(const char *str)
{
return 0;
...
...
@@ -1464,9 +1467,8 @@ static BOOL explicit_error(parser_ctx_t *ctx, void *obj, WCHAR next)
static expression_t *new_identifier_expression(parser_ctx_t *ctx, const WCHAR *identifier)
{
identifier_expression_t *ret =
parser_alloc(ctx, sizeof(identifier_expression_
t));
identifier_expression_t *ret =
new_expression(ctx, EXPR_IDENT, sizeof(*re
t));
ret->expr.eval = identifier_expression_eval;
ret->identifier = identifier;
return &ret->expr;
...
...
@@ -1474,9 +1476,8 @@ static expression_t *new_identifier_expression(parser_ctx_t *ctx, const WCHAR *i
static expression_t *new_array_literal_expression(parser_ctx_t *ctx, element_list_t *element_list, int length)
{
array_literal_expression_t *ret =
parser_alloc(ctx, sizeof(array_literal_expression_
t));
array_literal_expression_t *ret =
new_expression(ctx, EXPR_ARRAYLIT, sizeof(*re
t));
ret->expr.eval = array_literal_expression_eval;
ret->element_list = element_list ? element_list->head : NULL;
ret->length = length;
...
...
@@ -1485,9 +1486,8 @@ static expression_t *new_array_literal_expression(parser_ctx_t *ctx, element_lis
static expression_t *new_prop_and_value_expression(parser_ctx_t *ctx, property_list_t *property_list)
{
property_value_expression_t *ret =
parser_alloc(ctx, sizeof(property_value_expression_
t));
property_value_expression_t *ret =
new_expression(ctx, EXPR_PROPVAL, sizeof(*re
t));
ret->expr.eval = property_value_expression_eval;
ret->property_list = property_list ? property_list->head : NULL;
return &ret->expr;
...
...
@@ -1495,9 +1495,8 @@ static expression_t *new_prop_and_value_expression(parser_ctx_t *ctx, property_l
static expression_t *new_literal_expression(parser_ctx_t *ctx, literal_t *literal)
{
literal_expression_t *ret =
parser_alloc(ctx, sizeof(literal_expression_
t));
literal_expression_t *ret =
new_expression(ctx, EXPR_LITERAL, sizeof(*re
t));
ret->expr.eval = literal_expression_eval;
ret->literal = literal;
return &ret->expr;
...
...
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