Commit dc4b4f85 by zmo@google.com

Always emit precision in shader variable declarations.

After the shader compile (and before code output), the precision scopes are already lost. In order to correctly output precisions, we need to emit precision in each variable declaration, therefore, each variable should have its precision set. This CL fixes the bugs that the precisions are lost for variables using default precsions and struct fields. Also, this CL fixes a bug in the grammar: constructors are not type_specifier and they shouldn't have precisions. BUG=168 TEST=webgl conformance tests, gles2 conformance tests. Review URL: http://codereview.appspot.com/4617041 git-svn-id: https://angleproject.googlecode.com/svn/trunk@695 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 189be2f1
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 694
#define BUILD_REVISION 695
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -18,7 +18,9 @@ bool InitializeSymbolTable(
{
TIntermediate intermediate(infoSink);
TExtensionBehavior extBehavior;
TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, NULL, infoSink);
// The builtins deliberately don't specify precisions for the function
// arguments and return types. For that reason we don't try to check them.
TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink);
GlobalParseContext = &parseContext;
......@@ -127,7 +129,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
TIntermediate intermediate(infoSink);
TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
shaderType, shaderSpec, compileOptions,
shaderType, shaderSpec, compileOptions, true,
sourcePath, infoSink);
GlobalParseContext = &parseContext;
......
......@@ -261,6 +261,8 @@ void TParseContext::binaryOpError(int line, const char* op, TString left, TStrin
}
bool TParseContext::precisionErrorCheck(int line, TPrecision precision, TBasicType type){
if (!checksPrecisionErrors)
return false;
switch( type ){
case EbtFloat:
if( precision == EbpUndefined ){
......
......@@ -30,8 +30,8 @@ struct TPragma {
// they can be passed to the parser without needing a global.
//
struct TParseContext {
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, const char* sourcePath, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), sourcePath(sourcePath), treeRoot(0),
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), checksPrecisionErrors(checksPrecErrors), sourcePath(sourcePath), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), scanner(NULL), contextPragma(true, false) { }
TIntermediate& intermediate; // to hold and build a parse tree
......@@ -50,6 +50,7 @@ struct TParseContext {
bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
void error(TSourceLoc loc, const char *reason, const char* token,
const char* extraInfoFormat, ...);
......
......@@ -18,18 +18,6 @@ void TranslatorESSL::translate(TIntermNode* root) {
// Write built-in extension behaviors.
writeExtensionBehavior();
// FIXME(zmo): no need to emit default precision if all variables emit
// their own precision.
// http://code.google.com/p/angleproject/issues/detail?id=168
if (this->getShaderType() == SH_FRAGMENT_SHADER) {
// Write default float precision.
sink << "#if defined(GL_FRAGMENT_PRECISION_HIGH)\n"
<< "precision highp float;\n"
<< "#else\n"
<< "precision mediump float;\n"
<< "#endif\n";
}
// Write translated shader.
TOutputESSL outputESSL(sink);
root->traverse(&outputESSL);
......
......@@ -591,17 +591,10 @@ function_call_header
// Grammar Note: Constructors look like functions, but are recognized as types.
function_identifier
: type_specifier {
: type_specifier_nonarray {
//
// Constructor
//
if ($1.array) {
// Constructors for arrays are not allowed.
context->error($1.line, "cannot construct this type", "array", "");
context->recover();
$1.setArray(false);
}
TOperator op = EOpNull;
if ($1.userDef) {
op = EOpConstructStruct;
......@@ -1176,13 +1169,6 @@ parameter_type_specifier
init_declarator_list
: single_declaration {
$$ = $1;
if ($$.type.precision == EbpUndefined) {
$$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type);
if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
context->recover();
}
}
}
| init_declarator_list COMMA IDENTIFIER {
TIntermSymbol* symbol = context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line);
......@@ -1490,6 +1476,13 @@ type_qualifier
type_specifier
: type_specifier_no_prec {
$$ = $1;
if ($$.precision == EbpUndefined) {
$$.precision = context->symbolTable.getDefaultPrecision($1.type);
if (context->precisionErrorCheck($1.line, $$.precision, $1.type)) {
context->recover();
}
}
}
| precision_qualifier type_specifier_no_prec {
$$ = $2;
......@@ -1693,6 +1686,7 @@ struct_declaration
type->setBasicType($1.type);
type->setNominalSize($1.size);
type->setMatrix($1.matrix);
type->setPrecision($1.precision);
// don't allow arrays of arrays
if (type->isArray()) {
......
......@@ -580,7 +580,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 69
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 1334
#define YYLAST 1362
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 94
......@@ -674,7 +674,7 @@ static const yytype_int16 yyrhs[] =
97, 51, -1, 97, 52, -1, 122, -1, 100, -1,
101, -1, 97, 76, 101, -1, 103, 71, -1, 102,
71, -1, 104, 39, -1, 104, -1, 104, 120, -1,
103, 77, 120, -1, 105, 70, -1, 137, -1, 43,
103, 77, 120, -1, 105, 70, -1, 140, -1, 43,
-1, 48, -1, 97, -1, 51, 106, -1, 52, 106,
-1, 107, 106, -1, 84, -1, 82, -1, 81, -1,
106, -1, 108, 85, 106, -1, 108, 86, 106, -1,
......@@ -731,24 +731,24 @@ static const yytype_uint16 yyrline[] =
{
0, 153, 153, 188, 191, 204, 209, 214, 220, 223,
296, 299, 408, 418, 431, 439, 538, 541, 549, 553,
560, 564, 571, 577, 586, 594, 656, 663, 673, 676,
686, 696, 717, 718, 719, 724, 725, 734, 746, 747,
755, 766, 770, 771, 781, 791, 801, 814, 815, 825,
838, 842, 846, 850, 851, 864, 865, 878, 879, 892,
893, 910, 911, 924, 925, 926, 927, 928, 932, 935,
946, 954, 979, 984, 991, 1027, 1030, 1037, 1045, 1066,
1085, 1096, 1125, 1130, 1140, 1145, 1155, 1158, 1161, 1164,
1170, 1177, 1187, 1203, 1221, 1245, 1268, 1272, 1290, 1298,
1330, 1350, 1426, 1435, 1458, 1461, 1467, 1475, 1483, 1491,
1494, 1501, 1504, 1507, 1513, 1516, 1531, 1535, 1539, 1543,
1552, 1557, 1562, 1567, 1572, 1577, 1582, 1587, 1592, 1597,
1603, 1609, 1615, 1620, 1625, 1630, 1643, 1656, 1664, 1667,
1682, 1713, 1717, 1723, 1731, 1747, 1751, 1755, 1756, 1762,
1763, 1764, 1765, 1766, 1770, 1771, 1771, 1771, 1781, 1782,
1787, 1790, 1800, 1803, 1809, 1810, 1814, 1822, 1826, 1836,
1841, 1858, 1858, 1863, 1863, 1870, 1870, 1878, 1881, 1887,
1890, 1896, 1900, 1907, 1914, 1921, 1928, 1939, 1948, 1952,
1959, 1962, 1968, 1968
560, 564, 571, 577, 586, 594, 649, 656, 666, 669,
679, 689, 710, 711, 712, 717, 718, 727, 739, 740,
748, 759, 763, 764, 774, 784, 794, 807, 808, 818,
831, 835, 839, 843, 844, 857, 858, 871, 872, 885,
886, 903, 904, 917, 918, 919, 920, 921, 925, 928,
939, 947, 972, 977, 984, 1020, 1023, 1030, 1038, 1059,
1078, 1089, 1118, 1123, 1133, 1138, 1148, 1151, 1154, 1157,
1163, 1170, 1173, 1189, 1207, 1231, 1254, 1258, 1276, 1284,
1316, 1336, 1412, 1421, 1444, 1447, 1453, 1461, 1469, 1477,
1487, 1494, 1497, 1500, 1506, 1509, 1524, 1528, 1532, 1536,
1545, 1550, 1555, 1560, 1565, 1570, 1575, 1580, 1585, 1590,
1596, 1602, 1608, 1613, 1618, 1623, 1636, 1649, 1657, 1660,
1675, 1707, 1711, 1717, 1725, 1741, 1745, 1749, 1750, 1756,
1757, 1758, 1759, 1760, 1764, 1765, 1765, 1765, 1775, 1776,
1781, 1784, 1794, 1797, 1803, 1804, 1808, 1816, 1820, 1830,
1835, 1852, 1852, 1857, 1857, 1864, 1864, 1872, 1875, 1881,
1884, 1890, 1894, 1901, 1908, 1915, 1922, 1933, 1942, 1946,
1953, 1956, 1962, 1962
};
#endif
......@@ -892,10 +892,10 @@ static const yytype_uint8 yydefact[] =
38, 41, 42, 47, 50, 51, 52, 53, 55, 57,
59, 70, 0, 25, 73, 0, 143, 0, 141, 137,
139, 0, 0, 173, 0, 0, 0, 0, 0, 155,
160, 164, 35, 61, 68, 0, 146, 0, 102, 149,
160, 164, 35, 61, 68, 0, 146, 0, 114, 149,
162, 148, 147, 0, 150, 151, 152, 153, 80, 82,
84, 0, 0, 98, 0, 145, 100, 29, 30, 0,
12, 13, 0, 0, 19, 18, 0, 116, 22, 24,
12, 13, 0, 0, 19, 18, 0, 20, 22, 24,
31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 115, 136, 0, 0, 140,
184, 183, 0, 175, 0, 187, 185, 0, 171, 154,
......@@ -917,7 +917,7 @@ static const yytype_int16 yydefgoto[] =
106, 107, 142, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, 120, 143, 144, 216, 145, 122,
146, 147, 32, 33, 34, 79, 60, 61, 80, 35,
36, 37, 38, 123, 40, 41, 42, 43, 74, 75,
36, 37, 38, 39, 40, 41, 123, 43, 74, 75,
127, 128, 166, 149, 150, 151, 152, 210, 270, 288,
289, 153, 154, 155, 278, 269, 156, 253, 202, 250,
265, 275, 276, 157, 44, 45, 46, 53
......@@ -928,86 +928,86 @@ static const yytype_int16 yydefgoto[] =
#define YYPACT_NINF -250
static const yytype_int16 yypact[] =
{
1225, 36, -250, -250, -250, 150, -250, -250, -250, -250,
1218, -13, -250, -250, -250, 137, -250, -250, -250, -250,
-250, -250, -250, -250, -250, -250, -250, -250, -250, -250,
-250, -250, -250, -250, -250, -33, -250, -250, -250, -250,
-250, -60, -22, -17, 21, -62, -250, 22, 1266, -250,
1290, -250, 11, -250, 1138, -250, -250, -250, -250, 1290,
14, 1266, -250, 27, -250, 34, 41, -250, -250, -250,
-250, 1266, 129, 61, -250, 17, -250, -250, 908, -250,
-250, 31, 1266, 72, 1042, -250, 283, -250, -250, -250,
-250, 90, 1266, -46, -250, 194, 908, 65, -250, -250,
-250, -250, 908, 908, 908, -250, -250, -250, -250, -250,
-40, -250, -250, -250, 80, -25, 975, 87, -250, 908,
35, 13, -250, -26, 68, -250, -250, -250, 110, 109,
-54, -250, 96, -250, -250, 1083, 98, 33, -250, -250,
-250, 91, 92, -250, 104, 107, 99, 760, 108, 105,
-250, -250, 24, -250, -250, 37, -250, -60, 112, -250,
-250, -250, -250, 365, -250, -250, -250, -250, 111, -250,
-250, 827, 908, -250, 113, -250, -250, -250, -250, 4,
-250, -250, 908, 1179, -250, -250, 908, 114, -250, -250,
-250, 908, 908, 908, 908, 908, 908, 908, 908, 908,
908, 908, 908, 908, 908, -250, -250, 908, 72, -250,
-250, -250, 447, -250, 908, -250, -250, 42, -250, -250,
447, -250, -250, -250, -250, -250, 908, 908, -250, -250,
-250, 908, -250, 115, -250, -250, -250, 116, 117, -250,
120, -250, -250, -250, -250, 35, 35, -250, -250, -250,
-250, -26, -26, -250, 110, 109, 51, 119, -250, 144,
611, 23, -250, 693, 447, -250, -250, 122, -250, -250,
908, -250, 123, -250, -250, 693, 447, 117, 153, 126,
128, -250, -250, 908, -250, 127, 137, 171, -250, 130,
529, -250, 28, 908, 529, 447, 908, -250, -250, -250,
131, 117, -250, -250, -250, -250
-250, -250, -250, -250, -250, -28, -250, -250, -250, -250,
-250, -55, -38, -4, 33, -20, -250, 44, 1259, -250,
1318, -250, 18, -250, 1176, -250, -250, -250, -250, 1318,
-22, 1259, -250, 29, -250, 85, 73, -250, -250, -250,
-250, 1259, 113, 70, -250, 13, -250, -250, 949, -250,
-250, 49, 1259, 90, 1080, -250, 283, -250, -250, -250,
-250, 101, 1259, -56, -250, 757, 949, 80, -250, -250,
-250, -250, 949, 949, 949, -250, -250, -250, -250, -250,
-33, -250, -250, -250, 81, -15, 1013, 92, -250, 949,
52, -75, -250, -25, 40, -250, -250, -250, 106, 105,
-46, -250, 93, -250, -250, 1121, 95, 9, -250, -250,
-250, 88, 89, -250, 100, 102, 91, 821, 104, 103,
-250, -250, 66, -250, -250, 20, -250, -55, 79, -250,
-250, -250, -250, 365, -250, -250, -250, -250, 107, -250,
-250, 885, 949, -250, 109, -250, -250, -250, -250, -6,
-250, -250, 949, 1283, -250, -250, 949, 110, -250, -250,
-250, 949, 949, 949, 949, 949, 949, 949, 949, 949,
949, 949, 949, 949, 949, -250, -250, 949, 90, -250,
-250, -250, 447, -250, 949, -250, -250, 34, -250, -250,
447, -250, -250, -250, -250, -250, 949, 949, -250, -250,
-250, 949, -250, 111, -250, -250, -250, 112, 99, -250,
116, -250, -250, -250, -250, 52, 52, -250, -250, -250,
-250, -25, -25, -250, 106, 105, 77, 114, -250, 125,
611, 4, -250, 693, 447, -250, -250, 115, -250, -250,
949, -250, 119, -250, -250, 693, 447, 99, 134, 122,
108, -250, -250, 949, -250, 117, 123, 174, -250, 120,
529, -250, 7, 949, 529, 447, 949, -250, -250, -250,
118, 99, -250, -250, -250, -250
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-250, -250, -250, -250, -250, -250, -250, 39, -250, -250,
-250, -250, -45, -250, -18, -250, -79, -30, -250, -250,
-250, 38, 52, 20, -250, -63, -85, -250, -92, -71,
6, 9, -250, -250, -250, 132, 172, 166, 148, -250,
-250, -246, -21, 0, 226, -24, -250, -250, 162, -66,
-250, 45, -159, -3, -136, -249, -250, -250, -250, -36,
196, 46, 1, -250, -250, -13, -250, -250, -250, -250,
-250, -250, -250, -250, -250, 211, -250, -250
-250, -250, -250, -250, -250, -250, -250, 22, -250, -250,
-250, -250, 31, -250, -27, -250, -79, -30, -250, -250,
-250, 5, 8, 12, -250, -63, -85, -250, -92, -82,
10, 11, -250, -250, -250, 121, 149, 144, 126, -250,
-250, -233, -21, -24, 202, -23, 0, -250, 139, -66,
-250, 27, -156, -41, -149, -249, -250, -250, -250, -58,
176, 17, -19, -250, -250, -35, -250, -250, -250, -250,
-250, -250, -250, -250, -250, 188, -250, -250
};
/* 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 zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -76
#define YYTABLE_NINF -117
static const yytype_int16 yytable[] =
{
39, 165, 169, 224, 193, 121, 30, 268, 130, 31,
50, 170, 171, 62, 164, 63, 67, 220, 64, 268,
52, 178, 121, 108, 56, 71, 161, 185, 186, 6,
7, 287, 172, 162, 62, 287, 173, 56, 66, 194,
108, 51, 6, 7, 39, 207, 175, 167, 168, 54,
30, 73, 176, 31, 57, 58, 59, 23, 24, 130,
55, 81, 187, 188, 180, 65, 249, 57, 58, 59,
23, 24, 73, 47, 73, 226, 148, 165, 47, 48,
228, 217, 81, 68, 211, 212, 213, 84, 72, 85,
223, 232, -75, 214, 266, 183, 86, 184, 121, 290,
217, 76, 246, 215, 83, 217, 237, 238, 239, 240,
198, 124, 251, 199, 217, 126, 108, 218, 220, 217,
181, 182, 252, 189, 190, 73, 247, 294, 217, 260,
277, 255, 256, 158, 121, -26, 233, 234, 108, 108,
108, 108, 108, 108, 108, 108, 108, 108, 108, 293,
257, 174, 108, 148, 2, 3, 4, 179, 121, 241,
242, 267, 57, 58, 59, 235, 236, 191, 192, 195,
197, 200, 201, 267, 203, 272, 108, 204, 208, 205,
209, 282, -25, 221, 262, -20, 225, 285, 258, 259,
-27, 291, 261, 273, 217, 271, 279, 280, 2, 3,
4, 165, 148, 281, 8, 9, 10, 283, 284, 286,
148, 295, 231, 245, 159, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 78, 82, 243,
160, 49, 25, 26, 125, 27, 28, 87, 29, 88,
89, 90, 91, 248, 244, 92, 93, 263, 292, 77,
148, 264, 274, 148, 148, 70, 254, 0, 0, 0,
0, 0, 0, 0, 94, 148, 148, 163, 0, 0,
0, 0, 0, 0, 0, 95, 96, 0, 97, 0,
42, 165, 169, 164, 220, 121, 224, 183, 130, 184,
30, 31, 193, 62, 66, 50, 161, 67, 170, 171,
268, 178, 121, 162, 47, 52, 71, 73, 185, 186,
48, 287, 268, 54, 62, 287, 56, 81, 42, 172,
42, 6, 7, 173, 42, 207, 51, 194, 73, 42,
73, 42, 72, 249, 30, 31, 175, 63, 81, 130,
64, 42, 176, 187, 188, 226, 57, 58, 59, 23,
24, 217, 42, 55, 42, 266, 148, 165, 290, 223,
228, 217, 42, 84, 217, 85, 198, 65, 56, 199,
68, 232, 86, 6, 7, 189, 190, 217, 121, 108,
218, 73, 246, 76, -75, 220, 237, 238, 239, 240,
47, 217, 251, 83, 252, 247, 108, 277, 57, 58,
59, 23, 24, 167, 168, 42, 211, 212, 213, 124,
294, 255, 256, 126, 121, 214, 293, 181, 182, 257,
180, 2, 3, 4, 158, 215, 57, 58, 59, -25,
-26, 68, 174, 148, 217, 260, 235, 236, 121, 241,
242, 267, 179, 191, 192, 262, 195, 197, 200, 201,
203, 205, 204, 267, 208, 272, 217, 279, 209, 221,
-116, 282, 225, 281, 258, 259, -27, 261, 271, 273,
285, 291, 108, 280, 284, 231, 243, 283, 295, 286,
244, 165, 148, 159, 78, 245, 82, 49, 160, 263,
148, 125, 233, 234, 108, 108, 108, 108, 108, 108,
108, 108, 108, 108, 108, 248, 292, 254, 108, 77,
274, 264, 70, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148, 0, 108, 148, 148, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 148, 148, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148, 0, 0, 0, 148, 148, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 131, 132, 133, 0,
134, 135, 136, 137, 11, 12, 13, 14, 15, 16,
......@@ -1056,96 +1056,99 @@ static const yytype_int16 yytable[] =
24, 25, 26, 0, 27, 28, 87, 29, 88, 89,
90, 91, 0, 0, 92, 93, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 94, 2, 3, 4, 0, 0, 0,
8, 9, 10, 0, 95, 96, 0, 97, 0, 0,
0, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 0, 0, 0, 0, 0, 25, 26,
0, 27, 28, 87, 29, 88, 89, 90, 91, 0,
0, 92, 93, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94, 2, 3, 4, 0, 0, 0, 8, 9, 10,
206, 95, 96, 0, 97, 0, 0, 0, 11, 12,
0, 0, 0, 94, 0, 0, 0, 8, 9, 10,
0, 0, 0, 0, 95, 96, 0, 97, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
0, 0, 0, 0, 0, 25, 26, 0, 27, 28,
87, 29, 88, 89, 90, 91, 0, 0, 92, 93,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 94, 0, 0,
222, 0, 0, 0, 0, 0, 0, 0, 95, 96,
0, 97, 2, 3, 4, 0, 0, 0, 8, 9,
10, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 0, 0, 0, 0, 0, 25, 26, 0, 27,
28, 87, 29, 88, 89, 90, 91, 0, 0, 92,
93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 94, 2,
3, 4, 0, 0, 0, 8, 9, 10, 0, 95,
96, 0, 97, 0, 0, 0, 11, 12, 13, 14,
163, 8, 9, 10, 0, 0, 0, 0, 95, 96,
0, 97, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 0, 0, 0, 0, 0, 25,
26, 0, 27, 28, 87, 29, 88, 89, 90, 91,
0, 0, 92, 93, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 94, 0, 0, 0, 8, 9, 10, 0, 0,
0, 206, 95, 96, 0, 97, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 0, 0,
0, 0, 0, 25, 177, 0, 27, 28, 87, 29,
0, 0, 0, 25, 26, 0, 27, 28, 87, 29,
88, 89, 90, 91, 0, 0, 92, 93, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 94, 2, 3, 4, 0,
0, 0, 8, 9, 10, 0, 95, 96, 0, 97,
0, 0, 0, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 0, 0, 0, 0, 0,
25, 26, 0, 27, 28, 0, 29, 2, 3, 4,
0, 0, 0, 0, 0, 94, 0, 0, 222, 8,
9, 10, 0, 0, 0, 0, 95, 96, 0, 97,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 0, 0, 0, 0, 0, 25, 26, 0,
27, 28, 87, 29, 88, 89, 90, 91, 0, 0,
92, 93, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 94,
0, 0, 0, 8, 9, 10, 0, 0, 0, 0,
0, 0, 0, 0, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 0, 129, 0, 0,
0, 25, 26, 0, 27, 28, 0, 29, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 69, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 0, 0, 0, 0, 0, 0, 0, 196, 11,
95, 96, 0, 97, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 0, 0, 0, 0,
0, 25, 177, 0, 27, 28, 87, 29, 88, 89,
90, 91, 0, 0, 92, 93, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 94, 2, 3, 4, 0, 0, 0,
8, 9, 10, 0, 95, 96, 0, 97, 0, 0,
0, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 0, 0, 0, 0, 0, 25, 26,
0, 27, 28, 0, 29, 2, 3, 4, 0, 0,
0, 8, 9, 10, 0, 0, 0, 0, 0, 0,
0, 0, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 0, 129, 0, 0, 0, 25,
26, 0, 27, 28, 0, 29, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 69, 0, 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 0,
0, 0, 0, 0, 0, 0, 196, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
0, 0, 23, 24, 25, 26, 0, 27, 28, 0,
29, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 0, 0, 0, 0, 0, 0, 0, 0, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 0, 0, 0, 23, 24, 25, 26, 0, 27,
28, 0, 29, 2, 3, 4, 0, 0, 0, 8,
9, 10, 0, 0, 0, 0, 0, 0, 0, 0,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 0, 0, 0, 0, 0, 25, 26, 0,
27, 28, 229, 29, 0, 0, 0, 230, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 0, 0,
0, 0, 0, 0, 0, 0, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 0, 0,
0, 23, 24, 25, 26, 0, 27, 28, 0, 29,
2, 3, 4, 0, 0, 0, 8, 9, 10, 0,
0, 0, 0, 0, 0, 0, 0, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
8, 9, 10, 0, 25, 26, 0, 27, 28, 0,
29, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 0, 0, 0, 0, 0, 25, 26,
0, 27, 28, 0, 29
21, 22, 0, 8, 9, 10, 0, 25, 26, 0,
27, 28, 0, 29, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 0, 0, 0, 0,
0, 25, 26, 0, 27, 28, 229, 29, 8, 9,
10, 230, 0, 0, 0, 0, 0, 0, 0, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 0, 0, 0, 0, 0, 25, 26, 0, 27,
28, 0, 29
};
static const yytype_int16 yycheck[] =
{
0, 86, 94, 162, 58, 68, 0, 253, 74, 0,
43, 51, 52, 34, 85, 77, 40, 153, 80, 265,
80, 106, 85, 68, 3, 49, 72, 53, 54, 8,
9, 280, 72, 79, 55, 284, 76, 3, 38, 93,
85, 74, 8, 9, 44, 137, 71, 92, 93, 71,
44, 51, 77, 44, 33, 34, 35, 36, 37, 125,
77, 61, 88, 89, 109, 43, 202, 33, 34, 35,
36, 37, 72, 37, 74, 71, 76, 162, 37, 43,
172, 77, 82, 72, 60, 61, 62, 70, 74, 72,
161, 176, 71, 69, 71, 82, 79, 84, 161, 71,
77, 74, 194, 79, 43, 77, 185, 186, 187, 188,
77, 80, 204, 80, 77, 43, 161, 80, 254, 77,
85, 86, 80, 55, 56, 125, 197, 286, 77, 78,
266, 216, 217, 43, 197, 70, 181, 182, 183, 184,
185, 186, 187, 188, 189, 190, 191, 192, 193, 285,
221, 71, 197, 153, 4, 5, 6, 70, 221, 189,
190, 253, 33, 34, 35, 183, 184, 57, 59, 73,
72, 80, 80, 265, 70, 260, 221, 70, 70, 80,
75, 273, 70, 72, 40, 71, 73, 16, 73, 73,
70, 283, 73, 70, 77, 73, 43, 71, 4, 5,
6, 286, 202, 75, 10, 11, 12, 80, 71, 79,
210, 80, 173, 193, 82, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 55, 62, 191,
82, 5, 38, 39, 72, 41, 42, 43, 44, 45,
46, 47, 48, 198, 192, 51, 52, 250, 284, 53,
250, 250, 265, 253, 254, 44, 210, -1, -1, -1,
-1, -1, -1, -1, 70, 265, 266, 73, -1, -1,
-1, -1, -1, -1, -1, 81, 82, -1, 84, -1,
0, 86, 94, 85, 153, 68, 162, 82, 74, 84,
0, 0, 58, 34, 38, 43, 72, 40, 51, 52,
253, 106, 85, 79, 37, 80, 49, 51, 53, 54,
43, 280, 265, 71, 55, 284, 3, 61, 38, 72,
40, 8, 9, 76, 44, 137, 74, 93, 72, 49,
74, 51, 74, 202, 44, 44, 71, 77, 82, 125,
80, 61, 77, 88, 89, 71, 33, 34, 35, 36,
37, 77, 72, 77, 74, 71, 76, 162, 71, 161,
172, 77, 82, 70, 77, 72, 77, 43, 3, 80,
72, 176, 79, 8, 9, 55, 56, 77, 161, 68,
80, 125, 194, 74, 71, 254, 185, 186, 187, 188,
37, 77, 204, 43, 80, 197, 85, 266, 33, 34,
35, 36, 37, 92, 93, 125, 60, 61, 62, 80,
286, 216, 217, 43, 197, 69, 285, 85, 86, 221,
109, 4, 5, 6, 43, 79, 33, 34, 35, 70,
70, 72, 71, 153, 77, 78, 183, 184, 221, 189,
190, 253, 70, 57, 59, 40, 73, 72, 80, 80,
70, 80, 70, 265, 70, 260, 77, 43, 75, 72,
70, 273, 73, 75, 73, 73, 70, 73, 73, 70,
16, 283, 161, 71, 71, 173, 191, 80, 80, 79,
192, 286, 202, 82, 55, 193, 62, 5, 82, 250,
210, 72, 181, 182, 183, 184, 185, 186, 187, 188,
189, 190, 191, 192, 193, 198, 284, 210, 197, 53,
265, 250, 44, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
250, -1, 221, 253, 254, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 265, 266, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
280, -1, -1, -1, 284, 285, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, -1,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
......@@ -1194,64 +1197,67 @@ static const yytype_int16 yycheck[] =
37, 38, 39, -1, 41, 42, 43, 44, 45, 46,
47, 48, -1, -1, 51, 52, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 70, 4, 5, 6, -1, -1, -1,
10, 11, 12, -1, 81, 82, -1, 84, -1, -1,
-1, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, -1, -1, -1, -1, -1, 38, 39,
-1, 41, 42, 43, 44, 45, 46, 47, 48, -1,
-1, 51, 52, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
70, 4, 5, 6, -1, -1, -1, 10, 11, 12,
80, 81, 82, -1, 84, -1, -1, -1, 21, 22,
-1, -1, -1, 70, -1, -1, -1, 10, 11, 12,
-1, -1, -1, -1, 81, 82, -1, 84, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
-1, -1, -1, -1, -1, 38, 39, -1, 41, 42,
43, 44, 45, 46, 47, 48, -1, -1, 51, 52,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 70, -1, -1,
73, -1, -1, -1, -1, -1, -1, -1, 81, 82,
-1, 84, 4, 5, 6, -1, -1, -1, 10, 11,
12, -1, -1, -1, -1, -1, -1, -1, -1, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, -1, -1, -1, -1, -1, 38, 39, -1, 41,
42, 43, 44, 45, 46, 47, 48, -1, -1, 51,
52, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 70, 4,
5, 6, -1, -1, -1, 10, 11, 12, -1, 81,
82, -1, 84, -1, -1, -1, 21, 22, 23, 24,
73, 10, 11, 12, -1, -1, -1, -1, 81, 82,
-1, 84, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, -1, -1, -1, -1, -1, 38,
39, -1, 41, 42, 43, 44, 45, 46, 47, 48,
-1, -1, 51, 52, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 70, -1, -1, -1, 10, 11, 12, -1, -1,
-1, 80, 81, 82, -1, 84, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, -1, -1,
-1, -1, -1, 38, 39, -1, 41, 42, 43, 44,
45, 46, 47, 48, -1, -1, 51, 52, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 70, 4, 5, 6, -1,
-1, -1, 10, 11, 12, -1, 81, 82, -1, 84,
-1, -1, -1, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, -1, -1, -1, -1, -1,
38, 39, -1, 41, 42, -1, 44, 4, 5, 6,
-1, -1, -1, -1, -1, 70, -1, -1, 73, 10,
11, 12, -1, -1, -1, -1, 81, 82, -1, 84,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, -1, -1, -1, -1, -1, 38, 39, -1,
41, 42, 43, 44, 45, 46, 47, 48, -1, -1,
51, 52, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 70,
-1, -1, -1, 10, 11, 12, -1, -1, -1, -1,
-1, -1, -1, -1, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, -1, 75, -1, -1,
-1, 38, 39, -1, 41, 42, -1, 44, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 0, -1,
-1, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, -1, -1, -1, -1, -1, -1, -1, 75, 21,
81, 82, -1, 84, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, -1, -1, -1, -1,
-1, 38, 39, -1, 41, 42, 43, 44, 45, 46,
47, 48, -1, -1, 51, 52, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 70, 4, 5, 6, -1, -1, -1,
10, 11, 12, -1, 81, 82, -1, 84, -1, -1,
-1, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, -1, -1, -1, -1, -1, 38, 39,
-1, 41, 42, -1, 44, 4, 5, 6, -1, -1,
-1, 10, 11, 12, -1, -1, -1, -1, -1, -1,
-1, -1, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, -1, 75, -1, -1, -1, 38,
39, -1, 41, 42, -1, 44, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 0, -1, -1, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, -1,
-1, -1, -1, -1, -1, -1, 75, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, -1,
-1, -1, 36, 37, 38, 39, -1, 41, 42, -1,
44, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, -1, -1, -1, -1, -1, -1, -1, -1, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, -1, -1, -1, 36, 37, 38, 39, -1, 41,
42, -1, 44, 4, 5, 6, -1, -1, -1, 10,
11, 12, -1, -1, -1, -1, -1, -1, -1, -1,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, -1, -1, -1, -1, -1, 38, 39, -1,
41, 42, 43, 44, -1, -1, -1, 48, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, -1, -1,
-1, -1, -1, -1, -1, -1, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, -1, -1,
-1, 36, 37, 38, 39, -1, 41, 42, -1, 44,
4, 5, 6, -1, -1, -1, 10, 11, 12, -1,
-1, -1, -1, -1, -1, -1, -1, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, -1,
10, 11, 12, -1, 38, 39, -1, 41, 42, -1,
44, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, -1, -1, -1, -1, -1, 38, 39,
-1, 41, 42, -1, 44
31, 32, -1, 10, 11, 12, -1, 38, 39, -1,
41, 42, -1, 44, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, -1, -1, -1, -1,
-1, 38, 39, -1, 41, 42, 43, 44, 10, 11,
12, 48, -1, -1, -1, -1, -1, -1, -1, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, -1, -1, -1, -1, -1, 38, 39, -1, 41,
42, -1, 44
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
......@@ -1270,9 +1276,9 @@ static const yytype_uint8 yystos[] =
47, 48, 51, 52, 70, 81, 82, 84, 95, 96,
97, 99, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
118, 119, 123, 137, 80, 142, 43, 144, 145, 75,
118, 119, 123, 140, 80, 142, 43, 144, 145, 75,
143, 13, 14, 15, 17, 18, 19, 20, 40, 74,
75, 80, 106, 119, 120, 122, 124, 125, 137, 147,
75, 80, 106, 119, 120, 122, 124, 125, 140, 147,
148, 149, 150, 155, 156, 157, 160, 167, 43, 129,
132, 72, 79, 73, 123, 120, 146, 106, 106, 122,
51, 52, 72, 76, 71, 71, 77, 39, 120, 70,
......@@ -2614,13 +2620,6 @@ yyreduce:
//
// Constructor
//
if ((yyvsp[(1) - (1)].interm.type).array) {
// Constructors for arrays are not allowed.
context->error((yyvsp[(1) - (1)].interm.type).line, "cannot construct this type", "array", "");
context->recover();
(yyvsp[(1) - (1)].interm.type).setArray(false);
}
TOperator op = EOpNull;
if ((yyvsp[(1) - (1)].interm.type).userDef) {
op = EOpConstructStruct;
......@@ -3360,13 +3359,6 @@ yyreduce:
{
(yyval.interm) = (yyvsp[(1) - (1)].interm);
if ((yyval.interm).type.precision == EbpUndefined) {
(yyval.interm).type.precision = context->symbolTable.getDefaultPrecision((yyvsp[(1) - (1)].interm).type.type);
if (context->precisionErrorCheck((yyvsp[(1) - (1)].interm).line, (yyval.interm).type.precision, (yyvsp[(1) - (1)].interm).type.type)) {
context->recover();
}
}
;}
break;
......@@ -3666,6 +3658,13 @@ yyreduce:
{
(yyval.interm.type) = (yyvsp[(1) - (1)].interm.type);
if ((yyval.interm.type).precision == EbpUndefined) {
(yyval.interm.type).precision = context->symbolTable.getDefaultPrecision((yyvsp[(1) - (1)].interm.type).type);
if (context->precisionErrorCheck((yyvsp[(1) - (1)].interm.type).line, (yyval.interm.type).precision, (yyvsp[(1) - (1)].interm.type).type)) {
context->recover();
}
}
;}
break;
......@@ -3970,6 +3969,7 @@ yyreduce:
type->setBasicType((yyvsp[(1) - (3)].interm.type).type);
type->setNominalSize((yyvsp[(1) - (3)].interm.type).size);
type->setMatrix((yyvsp[(1) - (3)].interm.type).matrix);
type->setPrecision((yyvsp[(1) - (3)].interm.type).precision);
// don't allow arrays of arrays
if (type->isArray()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment