aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/glsl_parser.yy
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-01-26 20:19:23 +0100
committermarha <marha@users.sourceforge.net>2014-01-26 20:19:23 +0100
commit5f455179ae4b279a82d99a7a3dabe61f58c42ad6 (patch)
treefdecec022cf1b8b782b90a64c14e374fa6d400cb /mesalib/src/glsl/glsl_parser.yy
parent78d84bd03c744b0ed420c450dd2807904ccaef21 (diff)
parent30af30b78075159fce477ae99cc72540133714d0 (diff)
downloadvcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.tar.gz
vcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.tar.bz2
vcxsrv-5f455179ae4b279a82d99a7a3dabe61f58c42ad6.zip
Merge remote-tracking branch 'origin/released'
* origin/released: xserver randrproto libxtrans fontconfig libxcb xcb-proto mesa git update 26 Jan 2014 Conflicts: X11/xtrans/Xtrans.c xorg-server/dix/dispatch.c xorg-server/os/xdmcp.c
Diffstat (limited to 'mesalib/src/glsl/glsl_parser.yy')
-rw-r--r--mesalib/src/glsl/glsl_parser.yy173
1 files changed, 65 insertions, 108 deletions
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 52f674b63..5d8dfac02 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -98,6 +98,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
ast_node *node;
ast_type_specifier *type_specifier;
+ ast_array_specifier *array_specifier;
ast_fully_specified_type *fully_specified_type;
ast_function *function;
ast_parameter_declarator *parameter_declarator;
@@ -203,6 +204,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
%type <type_qualifier> interface_qualifier
%type <type_specifier> type_specifier
%type <type_specifier> type_specifier_nonarray
+%type <array_specifier> array_specifier
%type <identifier> basic_type_specifier_nonarray
%type <fully_specified_type> fully_specified_type
%type <function> function_prototype
@@ -881,7 +883,7 @@ parameter_declarator:
$$->type->specifier = $1;
$$->identifier = $2;
}
- | type_specifier any_identifier '[' constant_expression ']'
+ | type_specifier any_identifier array_specifier
{
void *ctx = state;
$$ = new(ctx) ast_parameter_declarator();
@@ -890,8 +892,7 @@ parameter_declarator:
$$->type->set_location(yylloc);
$$->type->specifier = $1;
$$->identifier = $2;
- $$->is_array = true;
- $$->array_size = $4;
+ $$->array_specifier = $3;
}
;
@@ -977,76 +978,42 @@ init_declarator_list:
| init_declarator_list ',' any_identifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' ']'
+ | init_declarator_list ',' any_identifier array_specifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' constant_expression ']'
+ | init_declarator_list ',' any_identifier array_specifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
- decl->set_location(yylloc);
-
- $$ = $1;
- $$->declarations.push_tail(&decl->link);
- state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($7->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->type->specifier, true, NULL);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
- | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
- decl->set_location(yylloc);
-
- $$ = $1;
- $$->declarations.push_tail(&decl->link);
- state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($8->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$8;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->type->specifier, true, $5);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
| init_declarator_list ',' any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
+ ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($5->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$5;
- _mesa_ast_set_aggregate_type($1->type->specifier, ai, state);
- }
}
;
@@ -1062,74 +1029,43 @@ single_declaration:
| fully_specified_type any_identifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' ']'
+ | fully_specified_type any_identifier array_specifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' constant_expression ']'
+ | fully_specified_type any_identifier array_specifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
-
- $$ = new(ctx) ast_declarator_list($1);
- $$->set_location(yylloc);
- $$->declarations.push_tail(&decl->link);
- if ($6->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$6;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, true, NULL);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
- | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
-
- $$ = new(ctx) ast_declarator_list($1);
- $$->set_location(yylloc);
- $$->declarations.push_tail(&decl->link);
- if ($7->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, true, $4);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
| fully_specified_type any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
- if ($4->oper == ast_aggregate) {
- _mesa_ast_set_aggregate_type($1->specifier, $4, state);
- }
}
| INVARIANT variable_identifier // Vertex only.
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
$$ = new(ctx) ast_declarator_list(NULL);
$$->set_location(yylloc);
@@ -1612,19 +1548,51 @@ storage_qualifier:
}
;
-type_specifier:
- type_specifier_nonarray
- | type_specifier_nonarray '[' ']'
+array_specifier:
+ '[' ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_array_specifier(yylloc);
+ }
+ | '[' constant_expression ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_array_specifier(yylloc, $2);
+ }
+ | array_specifier '[' ']'
{
$$ = $1;
- $$->is_array = true;
- $$->array_size = NULL;
+
+ if (!state->ARB_arrays_of_arrays_enable) {
+ _mesa_glsl_error(& @1, state,
+ "GL_ARB_arrays_of_arrays "
+ "required for defining arrays of arrays");
+ } else {
+ _mesa_glsl_error(& @1, state,
+ "only the outermost array dimension can "
+ "be unsized");
+ }
}
- | type_specifier_nonarray '[' constant_expression ']'
+ | array_specifier '[' constant_expression ']'
{
$$ = $1;
- $$->is_array = true;
- $$->array_size = $3;
+
+ if (!state->ARB_arrays_of_arrays_enable) {
+ _mesa_glsl_error(& @1, state,
+ "GL_ARB_arrays_of_arrays "
+ "required for defining arrays of arrays");
+ }
+
+ $$->add_dimension($3);
+ }
+ ;
+
+type_specifier:
+ type_specifier_nonarray
+ | type_specifier_nonarray array_specifier
+ {
+ $$ = $1;
+ $$->array_specifier = $2;
}
;
@@ -1804,19 +1772,13 @@ struct_declarator:
any_identifier
{
void *ctx = state;
- $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
- $$->set_location(yylloc);
- }
- | any_identifier '[' ']'
- {
- void *ctx = state;
- $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
+ $$ = new(ctx) ast_declaration($1, NULL, NULL);
$$->set_location(yylloc);
}
- | any_identifier '[' constant_expression ']'
+ | any_identifier array_specifier
{
void *ctx = state;
- $$ = new(ctx) ast_declaration($1, true, $3, NULL);
+ $$ = new(ctx) ast_declaration($1, $2, NULL);
$$->set_location(yylloc);
}
;
@@ -1974,7 +1936,7 @@ condition:
| fully_specified_type any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
decl->set_location(yylloc);
declarator->set_location(yylloc);
@@ -2309,22 +2271,17 @@ instance_name_opt:
/* empty */
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- NULL, false, NULL);
+ NULL, NULL);
}
| NEW_IDENTIFIER
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, false, NULL);
- }
- | NEW_IDENTIFIER '[' constant_expression ']'
- {
- $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, true, $3);
+ $1, NULL);
}
- | NEW_IDENTIFIER '[' ']'
+ | NEW_IDENTIFIER array_specifier
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, true, NULL);
+ $1, $2);
}
;