From d10fe19495191072d39689337700b69e62252bf1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 10 Mar 2010 13:25:56 -0800 Subject: [PATCH] Simplified constructor for identifier expressions --- ast.h | 9 +++++++++ glsl_parser.ypp | 12 ++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ast.h b/ast.h index 36316920926..3eb8e5f20fd 100644 --- a/ast.h +++ b/ast.h @@ -150,6 +150,15 @@ public: ast_expression(int oper, ast_expression *, ast_expression *, ast_expression *); + ast_expression(const char *identifier) : + oper(ast_identifier) + { + subexpressions[0] = NULL; + subexpressions[1] = NULL; + subexpressions[2] = NULL; + primary_expression.identifier = (char *) identifier; + } + static const char *operator_string(enum ast_operators op); virtual ir_instruction *hir(exec_list *instructions, diff --git a/glsl_parser.ypp b/glsl_parser.ypp index c7557254581..debbcea9366 100644 --- a/glsl_parser.ypp +++ b/glsl_parser.ypp @@ -351,19 +351,11 @@ function_identifier: } | IDENTIFIER { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; + $$ = new ast_expression($1); } | FIELD_SELECTION { - ast_expression *expr = - new ast_expression(ast_identifier, NULL, NULL, NULL); - expr->primary_expression.identifier = $1; - - $$ = (struct ast_node *) expr; + $$ = new ast_expression($1); } ; -- 2.30.2