[PATCH 1/5] d3dcompiler: Parse vector and matrix declarations.

Matteo Bruni mbruni at codeweavers.com
Mon Jun 11 12:18:31 CDT 2012


---
 dlls/d3dcompiler_43/hlsl.l |    2 --
 dlls/d3dcompiler_43/hlsl.y |   40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dcompiler_43/hlsl.l b/dlls/d3dcompiler_43/hlsl.l
index ef12ab9..84cf573 100644
--- a/dlls/d3dcompiler_43/hlsl.l
+++ b/dlls/d3dcompiler_43/hlsl.l
@@ -148,8 +148,6 @@ while                   {return KW_WHILE;               }
 \.\.\.                  {return OP_ELLIPSIS;            }
 \<=                     {return OP_LE;                  }
 \>=                     {return OP_GE;                  }
-\<                      {return OP_LT;                  }
-\>                      {return OP_GT;                  }
 !=                      {return OP_NE;                  }
 \+=                     {return OP_ADDASSIGN;           }
 \-=                     {return OP_SUBASSIGN;           }
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index ae1599f..cc13e25 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -213,8 +213,6 @@ static DWORD add_modifier(DWORD modifiers, DWORD mod)
 %token OP_ELLIPSIS
 %token OP_LE
 %token OP_GE
-%token OP_LT
-%token OP_GT
 %token OP_NE
 %token OP_ADDASSIGN
 %token OP_SUBASSIGN
@@ -302,6 +300,44 @@ type:                     base_type
                             {
                                 $$ = $1;
                             }
+                        | KW_VECTOR '<' base_type ',' C_INTEGER '>'
+                            {
+                                if ($3->type != HLSL_CLASS_SCALAR)
+                                {
+                                    hlsl_message("Line %u: vectors of non-scalar types are not allowed.\n",
+                                            hlsl_ctx.line_no);
+                                    set_parse_status(&hlsl_ctx.status, PARSE_ERR);
+                                    return 1;
+                                }
+                                if ($5 < 1 || $5 > 4)
+                                {
+                                    hlsl_message("Line %u: vector size must be between 1 and 4.\n",
+                                            hlsl_ctx.line_no);
+                                    set_parse_status(&hlsl_ctx.status, PARSE_ERR);
+                                    return 1;
+                                }
+
+                                $$ = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, $3->base_type, $5, 1);
+                            }
+                        | KW_MATRIX '<' base_type ',' C_INTEGER ',' C_INTEGER '>'
+                            {
+                                if ($3->type != HLSL_CLASS_SCALAR)
+                                {
+                                    hlsl_message("Line %u: matrices of non-scalar types are not allowed.\n",
+                                            hlsl_ctx.line_no);
+                                    set_parse_status(&hlsl_ctx.status, PARSE_ERR);
+                                    return 1;
+                                }
+                                if ($5 < 1 || $5 > 4 || $7 < 1 || $7 > 4)
+                                {
+                                    hlsl_message("Line %u: matrix dimensions must be between 1 and 4.\n",
+                                            hlsl_ctx.line_no);
+                                    set_parse_status(&hlsl_ctx.status, PARSE_ERR);
+                                    return 1;
+                                }
+
+                                $$ = new_hlsl_type(NULL, HLSL_CLASS_MATRIX, $3->base_type, $5, $7);
+                            }
 
 base_type:                KW_VOID
                             {
-- 
1.7.3.4




More information about the wine-patches mailing list