glsl/parser: Track built-in types using the glsl_type directly

Without the lexer changes, tests/glslparsertest/glsl2/tex_rect-02.frag
fails.  Before this change, the parser would determine that
sampler2DRect is not a valid type because the call to
state->symbols->get_type() in ast_type_specifier::glsl_type() would
return NULL.  Since ast_type_specifier::glsl_type() is now going to
return the glsl_type pointer that it received from the lexer, it doesn't
have an opportunity to generate an error.

   text	   data	    bss	    dec	    hex	filename
8255243	 268856	 294072	8818171	 868dfb	32-bit i965_dri.so before
8255291	 268856	 294072	8818219	 868e2b	32-bit i965_dri.so after
7815195	 345592	 420592	8581379	 82f103	64-bit i965_dri.so before
7815339	 345592	 420592	8581523	 82f193	64-bit i965_dri.so after

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Ian Romanick
2017-09-20 16:19:15 -05:00
parent 747c057530
commit 34f7e761bc
4 changed files with 28 additions and 12 deletions

View File

@@ -27,6 +27,7 @@
#include "list.h"
#include "glsl_parser_extras.h"
#include "compiler/glsl_types.h"
struct _mesa_glsl_parse_state;
@@ -853,7 +854,7 @@ class ast_type_specifier : public ast_node {
public:
/** Construct a type specifier from a type name */
ast_type_specifier(const char *name)
: type_name(name), structure(NULL), array_specifier(NULL),
: type(NULL), type_name(name), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */
@@ -861,12 +862,19 @@ public:
/** Construct a type specifier from a structure definition */
ast_type_specifier(ast_struct_specifier *s)
: type_name(s->name), structure(s), array_specifier(NULL),
: type(NULL), type_name(s->name), structure(s), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */
}
ast_type_specifier(const glsl_type *t)
: type(t), type_name(t->name), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */
}
const struct glsl_type *glsl_type(const char **name,
struct _mesa_glsl_parse_state *state)
const;
@@ -875,6 +883,7 @@ public:
ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
const struct glsl_type *type;
const char *type_name;
ast_struct_specifier *structure;