Refactor class to represent structure.
We had a TTypeLine to represent a structure field,
which simply encapsulated a TType and line number.
The line number was only used during parsing for error reporting.
There is no need to store a line number because it is already
available in the parser token.
TEST=WebGL conformance tests
R=kbr@chromium.org
Review URL: https://codereview.appspot.com/9223045
git-svn-id: http://angleproject.googlecode.com/svn/trunk@2198 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Intermediate.cpp b/src/compiler/Intermediate.cpp
index edf279e..11ca25e 100644
--- a/src/compiler/Intermediate.cpp
+++ b/src/compiler/Intermediate.cpp
@@ -1041,10 +1041,10 @@
int index = 0;
for (size_t j = 0; j < structSize; j++) {
- int size = (*fields)[j].type->getObjectSize();
+ int size = (*fields)[j]->getObjectSize();
for (int i = 0; i < size; i++) {
- if ((*fields)[j].type->getBasicType() == EbtStruct) {
- if (!CompareStructure(*(*fields)[j].type, &rightUnionArray[index], &leftUnionArray[index]))
+ if ((*fields)[j]->getBasicType() == EbtStruct) {
+ if (!CompareStructure(*(*fields)[j], &rightUnionArray[index], &leftUnionArray[index]))
return false;
} else {
if (leftUnionArray[index] != rightUnionArray[index])
diff --git a/src/compiler/OutputGLSLBase.cpp b/src/compiler/OutputGLSLBase.cpp
index 1b9a10d..169e79f 100644
--- a/src/compiler/OutputGLSLBase.cpp
+++ b/src/compiler/OutputGLSLBase.cpp
@@ -87,7 +87,7 @@
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
- const TType* fieldType = (*structure)[i].type;
+ const TType* fieldType = (*structure)[i];
ASSERT(fieldType != NULL);
if (writeVariablePrecision(fieldType->getPrecision()))
out << " ";
@@ -143,7 +143,7 @@
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
- const TType* fieldType = (*structure)[i].type;
+ const TType* fieldType = (*structure)[i];
ASSERT(fieldType != NULL);
pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
if (i != structure->size() - 1) out << ", ";
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index b5798dd..6fa3d05 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -1025,7 +1025,7 @@
for (size_t i = 0; i < fields->size(); i++)
{
- const TType *fieldType = (*fields)[i].type;
+ const TType *fieldType = (*fields)[i];
node->getLeft()->traverse(this);
out << "." + decorateField(fieldType->getFieldName(), node->getLeft()->getType()) + " == ";
@@ -2226,7 +2226,7 @@
for (unsigned int i = 0; i < fields.size(); i++)
{
- const TType &field = *fields[i].type;
+ const TType &field = *fields[i];
string += " " + typeString(field) + " " + decorate(field.getFieldName()) + arrayString(field) + ";\n";
}
@@ -2351,7 +2351,7 @@
for (unsigned int i = 0; i < fields.size(); i++)
{
- const TType &field = *fields[i].type;
+ const TType &field = *fields[i];
structure += " " + typeString(field) + " " + decorateField(field.getFieldName(), type) + arrayString(field) + ";\n";
}
@@ -2365,7 +2365,7 @@
for (unsigned int i = 0; i < fields.size(); i++)
{
- ctorParameters.push_back(*fields[i].type);
+ ctorParameters.push_back(*fields[i]);
}
}
else if (parameters)
@@ -2540,7 +2540,7 @@
for (size_t i = 0; i < structure->size(); i++)
{
- const TType *fieldType = (*structure)[i].type;
+ const TType *fieldType = (*structure)[i];
constUnion = writeConstantUnion(*fieldType, constUnion);
diff --git a/src/compiler/ParseHelper.cpp b/src/compiler/ParseHelper.cpp
index 441ff35..e9f1b63 100644
--- a/src/compiler/ParseHelper.cpp
+++ b/src/compiler/ParseHelper.cpp
@@ -659,7 +659,7 @@
if (type.getBasicType() == EbtStruct) {
TTypeList& structure = *type.getStruct();
for (unsigned int i = 0; i < structure.size(); ++i) {
- if (containsSampler(*structure[i].type))
+ if (containsSampler(*structure[i]))
return true;
}
}
@@ -1139,7 +1139,7 @@
if (type->isArray())
newNode = constructStruct(node, &elementType, 1, node->getLine(), false);
else if (op == EOpConstructStruct)
- newNode = constructStruct(node, (*memberTypes).type, 1, node->getLine(), false);
+ newNode = constructStruct(node, *memberTypes, 1, node->getLine(), false);
else
newNode = constructBuiltIn(type, op, node, node->getLine(), false);
@@ -1170,7 +1170,7 @@
if (type->isArray())
newNode = constructStruct(*p, &elementType, paramCount+1, node->getLine(), true);
else if (op == EOpConstructStruct)
- newNode = constructStruct(*p, (memberTypes[paramCount]).type, paramCount+1, node->getLine(), true);
+ newNode = constructStruct(*p, memberTypes[paramCount], paramCount+1, node->getLine(), true);
else
newNode = constructBuiltIn(type, op, *p, node->getLine(), true);
@@ -1430,10 +1430,10 @@
TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
for ( index = 0; index < fields->size(); ++index) {
- if ((*fields)[index].type->getFieldName() == identifier) {
+ if ((*fields)[index]->getFieldName() == identifier) {
break;
} else {
- instanceSize += (*fields)[index].type->getObjectSize();
+ instanceSize += (*fields)[index]->getObjectSize();
}
}
diff --git a/src/compiler/SymbolTable.cpp b/src/compiler/SymbolTable.cpp
index a63789d..cd625da 100644
--- a/src/compiler/SymbolTable.cpp
+++ b/src/compiler/SymbolTable.cpp
@@ -52,7 +52,7 @@
{// support MSVC++6.0
for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-';
- (*structure)[i].type->buildMangledName(mangledName);
+ (*structure)[i]->buildMangledName(mangledName);
}
}
default:
@@ -78,7 +78,7 @@
if (structureSize == 0)
for (TTypeList::const_iterator tl = getStruct()->begin(); tl != getStruct()->end(); tl++)
- structureSize += ((*tl).type)->getObjectSize();
+ structureSize += (*tl)->getObjectSize();
return structureSize;
}
@@ -91,7 +91,7 @@
int maxNesting = 0;
for (TTypeList::const_iterator tl = getStruct()->begin(); tl != getStruct()->end(); ++tl) {
- maxNesting = std::max(maxNesting, ((*tl).type)->getDeepestStructNesting());
+ maxNesting = std::max(maxNesting, (*tl)->getDeepestStructNesting());
}
deepestStructNesting = 1 + maxNesting;
@@ -106,8 +106,8 @@
for (TTypeList::const_iterator member = structure->begin(); member != structure->end(); member++)
{
- if (member->type->isArray() ||
- member->type->isStructureContainingArrays())
+ if ((*member)->isArray() ||
+ (*member)->isStructureContainingArrays())
{
return true;
}
diff --git a/src/compiler/Types.h b/src/compiler/Types.h
index ab9cd16..00bcbd8 100644
--- a/src/compiler/Types.h
+++ b/src/compiler/Types.h
@@ -14,14 +14,7 @@
class TType;
struct TPublicType;
-//
-// Need to have association of line numbers to types in a list for building structs.
-//
-struct TTypeLine {
- TType* type;
- int line;
-};
-typedef TVector<TTypeLine> TTypeList;
+typedef TVector<TType*> TTypeList;
inline TTypeList* NewPoolTTypeList()
{
diff --git a/src/compiler/VariableInfo.cpp b/src/compiler/VariableInfo.cpp
index eb6bea9..5a1402e 100644
--- a/src/compiler/VariableInfo.cpp
+++ b/src/compiler/VariableInfo.cpp
@@ -133,7 +133,7 @@
const TTypeList* structure = type.getStruct();
for (size_t i = 0; i < structure->size(); ++i) {
- const TType* fieldType = (*structure)[i].type;
+ const TType* fieldType = (*structure)[i];
getVariableInfo(*fieldType,
name + "." + fieldType->getFieldName(),
mappedName + "." + TIntermTraverser::hash(fieldType->getFieldName(), hashFunction),
diff --git a/src/compiler/glslang.y b/src/compiler/glslang.y
index 6c6782e..eed9fa8 100644
--- a/src/compiler/glslang.y
+++ b/src/compiler/glslang.y
@@ -74,8 +74,8 @@
TQualifier qualifier;
TFunction* function;
TParameter param;
- TTypeLine typeLine;
- TTypeList* typeList;
+ TType* field;
+ TTypeList* structure;
};
} interm;
}
@@ -154,8 +154,8 @@
%type <interm.type> type_qualifier fully_specified_type type_specifier
%type <interm.type> type_specifier_no_prec type_specifier_nonarray
%type <interm.type> struct_specifier
-%type <interm.typeLine> struct_declarator
-%type <interm.typeList> struct_declarator_list struct_declaration struct_declaration_list
+%type <interm.field> struct_declarator
+%type <interm> struct_declarator_list struct_declaration struct_declaration_list
%type <interm.function> function_header function_declarator function_identifier
%type <interm.function> function_header_with_parameters function_call_header
%type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype
@@ -384,7 +384,7 @@
} else {
unsigned int i;
for (i = 0; i < fields->size(); ++i) {
- if ((*fields)[i].type->getFieldName() == *$3.string) {
+ if ((*fields)[i]->getFieldName() == *$3.string) {
fieldFound = true;
break;
}
@@ -397,7 +397,7 @@
$$ = $1;
}
else {
- $$->setType(*(*fields)[i].type);
+ $$->setType(*(*fields)[i]);
// change the qualifier of the return type, not of the structure field
// as the structure definition is shared between various structures.
$$->getTypePointer()->setQualifier(EvqConst);
@@ -405,9 +405,9 @@
} else {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(i);
- TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
+ TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i], $3.line);
$$ = context->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
- $$->setType(*(*fields)[i].type);
+ $$->setType(*(*fields)[i]);
}
} else {
context->error($2.line, " no such field in structure", $3.string->c_str());
@@ -1698,7 +1698,7 @@
if (context->reservedErrorCheck($2.line, *$2.string))
context->recover();
- TType* structure = new TType($5, *$2.string);
+ TType* structure = new TType($5.structure, *$2.string);
TVariable* userTypeDef = new TVariable($2.string, *structure, true);
if (! context->symbolTable.insert(*userTypeDef)) {
context->error($2.line, "redefinition", $2.string->c_str(), "struct");
@@ -1709,7 +1709,7 @@
context->exitStructDeclaration();
}
| STRUCT LEFT_BRACE { if (context->enterStructDeclaration($2.line, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE {
- TType* structure = new TType($4, TString(""));
+ TType* structure = new TType($4.structure, TString(""));
$$.setBasic(EbtStruct, EvqTemporary, $1.line);
$$.userDef = structure;
context->exitStructDeclaration();
@@ -1722,14 +1722,15 @@
}
| struct_declaration_list struct_declaration {
$$ = $1;
- for (unsigned int i = 0; i < $2->size(); ++i) {
- for (unsigned int j = 0; j < $$->size(); ++j) {
- if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) {
- context->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());
+ for (size_t i = 0; i < $2.structure->size(); ++i) {
+ TType* field = (*$2.structure)[i];
+ for (size_t j = 0; j < $$.structure->size(); ++j) {
+ if ((*$$.structure)[j]->getFieldName() == field->getFieldName()) {
+ context->error($2.line, "duplicate field name in structure:", "struct", field->getFieldName().c_str());
context->recover();
}
}
- $$->push_back((*$2)[i]);
+ $$.structure->push_back(field);
}
}
;
@@ -1738,14 +1739,14 @@
: type_specifier struct_declarator_list SEMICOLON {
$$ = $2;
- if (context->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {
+ if (context->voidErrorCheck($1.line, (*$2.structure)[0]->getFieldName(), $1)) {
context->recover();
}
- for (unsigned int i = 0; i < $$->size(); ++i) {
+ for (unsigned int i = 0; i < $$.structure->size(); ++i) {
//
// Careful not to replace already known aspects of type, like array-ness
//
- TType* type = (*$$)[i].type;
+ TType* type = (*$$.structure)[i];
type->setBasicType($1.type);
type->setNominalSize($1.size);
type->setMatrix($1.matrix);
@@ -1772,11 +1773,11 @@
struct_declarator_list
: struct_declarator {
- $$ = NewPoolTTypeList();
- $$->push_back($1);
+ $$.structure = NewPoolTTypeList();
+ $$.structure->push_back($1);
}
| struct_declarator_list COMMA struct_declarator {
- $$->push_back($3);
+ $$.structure->push_back($3);
}
;
@@ -1785,22 +1786,20 @@
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
- $$.type = new TType(EbtVoid, EbpUndefined);
- $$.line = $1.line;
- $$.type->setFieldName(*$1.string);
+ $$ = new TType(EbtVoid, EbpUndefined);
+ $$->setFieldName(*$1.string);
}
| identifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
- $$.type = new TType(EbtVoid, EbpUndefined);
- $$.line = $1.line;
- $$.type->setFieldName(*$1.string);
+ $$ = new TType(EbtVoid, EbpUndefined);
+ $$->setFieldName(*$1.string);
int size;
if (context->arraySizeErrorCheck($2.line, $3, size))
context->recover();
- $$.type->setArraySize(size);
+ $$->setArraySize(size);
}
;
diff --git a/src/compiler/glslang_tab.cpp b/src/compiler/glslang_tab.cpp
index 20a840f..3158a69 100644
--- a/src/compiler/glslang_tab.cpp
+++ b/src/compiler/glslang_tab.cpp
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 2.5. */
+/* A Bison parser, made by GNU Bison 2.4.2. */
-/* Bison implementation for Yacc-like parsers in C
+/* Skeleton implementation for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
+ Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.5"
+#define YYBISON_VERSION "2.4.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -249,8 +250,8 @@
TQualifier qualifier;
TFunction* function;
TParameter param;
- TTypeLine typeLine;
- TTypeList* typeList;
+ TType* field;
+ TTypeList* structure;
};
} interm;
@@ -394,11 +395,11 @@
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
# endif
# endif
# endif
@@ -421,24 +422,24 @@
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+# if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
@@ -467,7 +468,23 @@
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
-# define YYCOPY_NEEDED 1
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -487,26 +504,6 @@
#endif
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 74
/* YYLAST -- Last index in YYTABLE. */
@@ -676,13 +673,13 @@
1520, 1530, 1537, 1540, 1543, 1549, 1552, 1567, 1571, 1575,
1579, 1588, 1593, 1598, 1603, 1608, 1613, 1618, 1623, 1628,
1633, 1639, 1645, 1651, 1656, 1661, 1670, 1679, 1684, 1697,
- 1697, 1711, 1711, 1720, 1723, 1738, 1774, 1778, 1784, 1792,
- 1808, 1812, 1816, 1817, 1823, 1824, 1825, 1826, 1827, 1831,
- 1832, 1832, 1832, 1842, 1843, 1847, 1847, 1848, 1848, 1853,
- 1856, 1866, 1869, 1875, 1876, 1880, 1888, 1892, 1902, 1907,
- 1924, 1924, 1929, 1929, 1936, 1936, 1944, 1947, 1953, 1956,
- 1962, 1966, 1973, 1980, 1987, 1994, 2005, 2014, 2018, 2025,
- 2028, 2034, 2034
+ 1697, 1711, 1711, 1720, 1723, 1739, 1775, 1779, 1785, 1792,
+ 1807, 1811, 1815, 1816, 1822, 1823, 1824, 1825, 1826, 1830,
+ 1831, 1831, 1831, 1841, 1842, 1846, 1846, 1847, 1847, 1852,
+ 1855, 1865, 1868, 1874, 1875, 1879, 1887, 1891, 1901, 1906,
+ 1923, 1923, 1928, 1928, 1935, 1935, 1943, 1946, 1952, 1955,
+ 1961, 1965, 1972, 1979, 1986, 1993, 2004, 2013, 2017, 2024,
+ 2027, 2033, 2033
};
#endif
@@ -809,8 +806,8 @@
1, 0, 3
};
-/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE doesn't specify something else to do. Zero
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
@@ -915,7 +912,8 @@
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
- number is the opposite. If YYTABLE_NINF, syntax error. */
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -166
static const yytype_int16 yytable[] =
{
@@ -1071,12 +1069,6 @@
31
};
-#define yypact_value_is_default(yystate) \
- ((yystate) == (-261))
-
-#define yytable_value_is_error(yytable_value) \
- YYID (0)
-
static const yytype_int16 yycheck[] =
{
0, 25, 89, 88, 96, 57, 162, 73, 153, 128,
@@ -1301,6 +1293,7 @@
{ \
yychar = (Token); \
yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \
goto yybackup; \
} \
@@ -1342,10 +1335,19 @@
#endif
-/* This macro is provided for backward compatibility. */
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
#endif
@@ -1541,6 +1543,7 @@
# define YYMAXDEPTH 10000
#endif
+
#if YYERROR_VERBOSE
@@ -1643,142 +1646,115 @@
}
# endif
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
+/* Copy into YYRESULT an error message about the unexpected token
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ including the terminating null byte. If YYRESULT is null, do not
+ copy anything; just return the number of bytes that would be
+ copied. As a special case, return 0 if an ordinary "syntax error"
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
+ size calculation. */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
{
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = 0;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
+ int yyn = yypact[yystate];
- /* There are many possibilities here to consider:
- - Assume YYFAIL is not used. It's too flawed to consider. See
- <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
- for details. YYERROR is fine as it does not invoke this
- function.
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
+ if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+ return 0;
+ else
{
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
+ int yytype = YYTRANSLATE (yychar);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ int yysize_overflow = 0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ int yyx;
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
+# if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+ char *yyfmt;
+ char const *yyf;
+ static char const yyunexpected[] = "syntax error, unexpected %s";
+ static char const yyexpecting[] = ", expecting %s";
+ static char const yyor[] = " or %s";
+ char yyformat[sizeof yyunexpected
+ + sizeof yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof yyor - 1))];
+ char const *yyprefix = yyexpecting;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 1;
+
+ yyarg[0] = yytname[yytype];
+ yyfmt = yystpcpy (yyformat, yyunexpected);
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ yyformat[sizeof yyunexpected - 1] = '\0';
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+ yyfmt = yystpcpy (yyfmt, yyprefix);
+ yyprefix = yyor;
+ }
+
+ yyf = YY_(yyformat);
+ yysize1 = yysize + yystrlen (yyf);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+
+ if (yysize_overflow)
+ return YYSIZE_MAXIMUM;
+
+ if (yyresult)
+ {
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *yyp = yyresult;
+ int yyi = 0;
+ while ((*yyp = *yyf) != '\0')
+ {
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyf += 2;
+ }
+ else
+ {
+ yyp++;
+ yyf++;
+ }
+ }
+ }
+ return yysize;
}
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
}
#endif /* YYERROR_VERBOSE */
+
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
@@ -1813,7 +1789,6 @@
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
@@ -1830,9 +1805,12 @@
#endif /* ! YYPARSE_PARAM */
-/*----------.
-| yyparse. |
-`----------*/
+
+
+
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -2019,7 +1997,7 @@
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
+ if (yyn == YYPACT_NINF)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
@@ -2050,8 +2028,8 @@
yyn = yytable[yyn];
if (yyn <= 0)
{
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
@@ -2351,7 +2329,7 @@
} else {
unsigned int i;
for (i = 0; i < fields->size(); ++i) {
- if ((*fields)[i].type->getFieldName() == *(yyvsp[(3) - (3)].lex).string) {
+ if ((*fields)[i]->getFieldName() == *(yyvsp[(3) - (3)].lex).string) {
fieldFound = true;
break;
}
@@ -2364,7 +2342,7 @@
(yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
}
else {
- (yyval.interm.intermTypedNode)->setType(*(*fields)[i].type);
+ (yyval.interm.intermTypedNode)->setType(*(*fields)[i]);
// change the qualifier of the return type, not of the structure field
// as the structure definition is shared between various structures.
(yyval.interm.intermTypedNode)->getTypePointer()->setQualifier(EvqConst);
@@ -2372,9 +2350,9 @@
} else {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(i);
- TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, (yyvsp[(3) - (3)].lex).line);
+ TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i], (yyvsp[(3) - (3)].lex).line);
(yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirectStruct, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line);
- (yyval.interm.intermTypedNode)->setType(*(*fields)[i].type);
+ (yyval.interm.intermTypedNode)->setType(*(*fields)[i]);
}
} else {
context->error((yyvsp[(2) - (3)].lex).line, " no such field in structure", (yyvsp[(3) - (3)].lex).string->c_str());
@@ -3952,7 +3930,7 @@
if (context->reservedErrorCheck((yyvsp[(2) - (6)].lex).line, *(yyvsp[(2) - (6)].lex).string))
context->recover();
- TType* structure = new TType((yyvsp[(5) - (6)].interm.typeList), *(yyvsp[(2) - (6)].lex).string);
+ TType* structure = new TType((yyvsp[(5) - (6)].interm).structure, *(yyvsp[(2) - (6)].lex).string);
TVariable* userTypeDef = new TVariable((yyvsp[(2) - (6)].lex).string, *structure, true);
if (! context->symbolTable.insert(*userTypeDef)) {
context->error((yyvsp[(2) - (6)].lex).line, "redefinition", (yyvsp[(2) - (6)].lex).string->c_str(), "struct");
@@ -3972,7 +3950,7 @@
case 142:
{
- TType* structure = new TType((yyvsp[(4) - (5)].interm.typeList), TString(""));
+ TType* structure = new TType((yyvsp[(4) - (5)].interm).structure, TString(""));
(yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yyvsp[(1) - (5)].lex).line);
(yyval.interm.type).userDef = structure;
context->exitStructDeclaration();
@@ -3982,22 +3960,23 @@
case 143:
{
- (yyval.interm.typeList) = (yyvsp[(1) - (1)].interm.typeList);
+ (yyval.interm) = (yyvsp[(1) - (1)].interm);
}
break;
case 144:
{
- (yyval.interm.typeList) = (yyvsp[(1) - (2)].interm.typeList);
- for (unsigned int i = 0; i < (yyvsp[(2) - (2)].interm.typeList)->size(); ++i) {
- for (unsigned int j = 0; j < (yyval.interm.typeList)->size(); ++j) {
- if ((*(yyval.interm.typeList))[j].type->getFieldName() == (*(yyvsp[(2) - (2)].interm.typeList))[i].type->getFieldName()) {
- context->error((*(yyvsp[(2) - (2)].interm.typeList))[i].line, "duplicate field name in structure:", "struct", (*(yyvsp[(2) - (2)].interm.typeList))[i].type->getFieldName().c_str());
+ (yyval.interm) = (yyvsp[(1) - (2)].interm);
+ for (size_t i = 0; i < (yyvsp[(2) - (2)].interm).structure->size(); ++i) {
+ TType* field = (*(yyvsp[(2) - (2)].interm).structure)[i];
+ for (size_t j = 0; j < (yyval.interm).structure->size(); ++j) {
+ if ((*(yyval.interm).structure)[j]->getFieldName() == field->getFieldName()) {
+ context->error((yyvsp[(2) - (2)].interm).line, "duplicate field name in structure:", "struct", field->getFieldName().c_str());
context->recover();
}
}
- (yyval.interm.typeList)->push_back((*(yyvsp[(2) - (2)].interm.typeList))[i]);
+ (yyval.interm).structure->push_back(field);
}
}
break;
@@ -4005,16 +3984,16 @@
case 145:
{
- (yyval.interm.typeList) = (yyvsp[(2) - (3)].interm.typeList);
+ (yyval.interm) = (yyvsp[(2) - (3)].interm);
- if (context->voidErrorCheck((yyvsp[(1) - (3)].interm.type).line, (*(yyvsp[(2) - (3)].interm.typeList))[0].type->getFieldName(), (yyvsp[(1) - (3)].interm.type))) {
+ if (context->voidErrorCheck((yyvsp[(1) - (3)].interm.type).line, (*(yyvsp[(2) - (3)].interm).structure)[0]->getFieldName(), (yyvsp[(1) - (3)].interm.type))) {
context->recover();
}
- for (unsigned int i = 0; i < (yyval.interm.typeList)->size(); ++i) {
+ for (unsigned int i = 0; i < (yyval.interm).structure->size(); ++i) {
//
// Careful not to replace already known aspects of type, like array-ness
//
- TType* type = (*(yyval.interm.typeList))[i].type;
+ TType* type = (*(yyval.interm).structure)[i];
type->setBasicType((yyvsp[(1) - (3)].interm.type).type);
type->setNominalSize((yyvsp[(1) - (3)].interm.type).size);
type->setMatrix((yyvsp[(1) - (3)].interm.type).matrix);
@@ -4042,15 +4021,15 @@
case 146:
{
- (yyval.interm.typeList) = NewPoolTTypeList();
- (yyval.interm.typeList)->push_back((yyvsp[(1) - (1)].interm.typeLine));
+ (yyval.interm).structure = NewPoolTTypeList();
+ (yyval.interm).structure->push_back((yyvsp[(1) - (1)].interm.field));
}
break;
case 147:
{
- (yyval.interm.typeList)->push_back((yyvsp[(3) - (3)].interm.typeLine));
+ (yyval.interm).structure->push_back((yyvsp[(3) - (3)].interm.field));
}
break;
@@ -4060,9 +4039,8 @@
if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string))
context->recover();
- (yyval.interm.typeLine).type = new TType(EbtVoid, EbpUndefined);
- (yyval.interm.typeLine).line = (yyvsp[(1) - (1)].lex).line;
- (yyval.interm.typeLine).type->setFieldName(*(yyvsp[(1) - (1)].lex).string);
+ (yyval.interm.field) = new TType(EbtVoid, EbpUndefined);
+ (yyval.interm.field)->setFieldName(*(yyvsp[(1) - (1)].lex).string);
}
break;
@@ -4072,14 +4050,13 @@
if (context->reservedErrorCheck((yyvsp[(1) - (4)].lex).line, *(yyvsp[(1) - (4)].lex).string))
context->recover();
- (yyval.interm.typeLine).type = new TType(EbtVoid, EbpUndefined);
- (yyval.interm.typeLine).line = (yyvsp[(1) - (4)].lex).line;
- (yyval.interm.typeLine).type->setFieldName(*(yyvsp[(1) - (4)].lex).string);
+ (yyval.interm.field) = new TType(EbtVoid, EbpUndefined);
+ (yyval.interm.field)->setFieldName(*(yyvsp[(1) - (4)].lex).string);
int size;
if (context->arraySizeErrorCheck((yyvsp[(2) - (4)].lex).line, (yyvsp[(3) - (4)].interm.intermTypedNode), size))
context->recover();
- (yyval.interm.typeLine).type->setArraySize(size);
+ (yyval.interm.field)->setArraySize(size);
}
break;
@@ -4572,17 +4549,6 @@
default: break;
}
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
@@ -4610,10 +4576,6 @@
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
@@ -4621,36 +4583,37 @@
#if ! YYERROR_VERBOSE
yyerror (context, YY_("syntax error"));
#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
{
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (context, yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+ {
+ YYSIZE_T yyalloc = 2 * yysize;
+ if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+ yyalloc = YYSTACK_ALLOC_MAXIMUM;
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+ if (yymsg)
+ yymsg_alloc = yyalloc;
+ else
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ }
+ }
+
+ if (0 < yysize && yysize <= yymsg_alloc)
+ {
+ (void) yysyntax_error (yymsg, yystate, yychar);
+ yyerror (context, yymsg);
+ }
+ else
+ {
+ yyerror (context, YY_("syntax error"));
+ if (yysize != 0)
+ goto yyexhaustedlab;
+ }
}
-# undef YYSYNTAX_ERROR
#endif
}
@@ -4709,7 +4672,7 @@
for (;;)
{
yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
+ if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
@@ -4768,13 +4731,8 @@
yyreturn:
if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval, context);
- }
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval, context);
/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
diff --git a/src/compiler/glslang_tab.h b/src/compiler/glslang_tab.h
index 3e95e3b..ba466e5 100644
--- a/src/compiler/glslang_tab.h
+++ b/src/compiler/glslang_tab.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 2.5. */
+/* A Bison parser, made by GNU Bison 2.4.2. */
-/* Bison interface for Yacc-like parsers in C
+/* Skeleton interface for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
+ Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -164,8 +165,8 @@
TQualifier qualifier;
TFunction* function;
TParameter param;
- TTypeLine typeLine;
- TTypeList* typeList;
+ TType* field;
+ TTypeList* structure;
};
} interm;