Matteo Bruni : d3dcompiler: Parse unary and prefix operators.
Alexandre Julliard
julliard at winehq.org
Fri Jul 20 15:29:59 CDT 2012
Module: wine
Branch: master
Commit: f2b5f71218e40e9afe87c33a3db47c65bfd10678
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f2b5f71218e40e9afe87c33a3db47c65bfd10678
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri Jul 20 16:37:38 2012 +0200
d3dcompiler: Parse unary and prefix operators.
---
dlls/d3dcompiler_43/d3dcompiler_private.h | 8 ++++
dlls/d3dcompiler_43/hlsl.y | 58 +++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 32d378a..769bf74 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -904,6 +904,14 @@ struct parse_variable_def
struct list *initializer;
};
+enum parse_unary_op
+{
+ UNARY_OP_PLUS,
+ UNARY_OP_MINUS,
+ UNARY_OP_LOGICNOT,
+ UNARY_OP_BITNOT,
+};
+
struct hlsl_parse_ctx
{
const char **source_files;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index c84736b..6cc2150 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -206,6 +206,7 @@ static unsigned int components_count_expr_list(struct list *list)
struct hlsl_ir_function_decl *function;
struct parse_parameter parameter;
struct parse_variable_def *variable_def;
+ enum parse_unary_op unary_op;
}
%token KW_BLENDSTATE
@@ -350,6 +351,7 @@ static unsigned int components_count_expr_list(struct list *list)
%type <instr> conditional_expr
%type <instr> assignment_expr
%type <list> expr_statement
+%type <unary_op> unary_op
%type <modifiers> input_mod
%%
@@ -982,6 +984,62 @@ unary_expr: postfix_expr
{
$$ = $1;
}
+ | OP_INC unary_expr
+ {
+ struct hlsl_ir_node *operands[3];
+ struct source_location loc;
+
+ operands[0] = $2;
+ operands[1] = operands[2] = NULL;
+ set_location(&loc, &@1);
+ $$ = &new_expr(HLSL_IR_BINOP_PREINC, operands, &loc)->node;
+ }
+ | OP_DEC unary_expr
+ {
+ struct hlsl_ir_node *operands[3];
+ struct source_location loc;
+
+ operands[0] = $2;
+ operands[1] = operands[2] = NULL;
+ set_location(&loc, &@1);
+ $$ = &new_expr(HLSL_IR_BINOP_PREDEC, operands, &loc)->node;
+ }
+ | unary_op unary_expr
+ {
+ enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG,
+ HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT};
+ struct hlsl_ir_node *operands[3];
+ struct source_location loc;
+
+ if ($1 == UNARY_OP_PLUS)
+ {
+ $$ = $2;
+ }
+ else
+ {
+ operands[0] = $2;
+ operands[1] = operands[2] = NULL;
+ set_location(&loc, &@1);
+ $$ = &new_expr(ops[$1], operands, &loc)->node;
+ }
+ }
+
+unary_op: '+'
+ {
+ $$ = UNARY_OP_PLUS;
+ }
+ | '-'
+ {
+ $$ = UNARY_OP_MINUS;
+ }
+ | '!'
+ {
+ $$ = UNARY_OP_LOGICNOT;
+ }
+ | '~'
+ {
+ $$ = UNARY_OP_BITNOT;
+ }
mul_expr: unary_expr
{
More information about the wine-cvs
mailing list