Commit 76079bcf by Alexis Hetu Committed by Alexis Hétu

Small named variable cleanup

- Replaced a few lines of codes in the parser by getNamedVariable - Deleted unused commented out code in the parser Change-Id: I34db0c971140a39cd91a32c05ebf866d5fca795b Reviewed-on: https://swiftshader-review.googlesource.com/3670Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent eee212e7
......@@ -201,23 +201,7 @@ extern void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason);
variable_identifier
: IDENTIFIER {
// The symbol table search was done in the lexical phase
const TSymbol* symbol = $1.symbol;
const TVariable* variable;
if (symbol == 0) {
context->error(@1, "undeclared identifier", $1.string->c_str());
context->recover();
TType type(EbtFloat, EbpUndefined);
TVariable* fakeVariable = new TVariable($1.string, type);
context->symbolTable.declare(*fakeVariable);
variable = fakeVariable;
} else {
// This identifier can only be a variable type symbol
if (! symbol->isVariable()) {
context->error(@1, "variable expected", $1.string->c_str());
context->recover();
}
variable = static_cast<const TVariable*>(symbol);
}
const TVariable *variable = context->getNamedVariable(@1, $1.string, $1.symbol);
// don't delete $1.string, it's used by error recovery, and the pool
// pop will reclaim the memory
......@@ -923,75 +907,6 @@ single_declaration
}
;
//
// Place holder for the pack/unpack languages.
//
// | buffer_specifier {
// $$.intermAggregate = 0;
// }
;
// Grammar Note: No 'enum', or 'typedef'.
//
// Place holder for the pack/unpack languages.
//
//%type <interm> buffer_declaration
//%type <interm.type> buffer_specifier input_or_output buffer_declaration_list
//buffer_specifier
// : input_or_output LEFT_BRACE buffer_declaration_list RIGHT_BRACE {
// }
// ;
//
//input_or_output
// : INPUT {
// if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "input"))
// context->recover();
// UNPACK_ONLY("input", @1);
// $$.qualifier = EvqInput;
// }
// | OUTPUT {
// if (context->globalErrorCheck(@1, context->symbolTable.atGlobalLevel(), "output"))
// context->recover();
// PACK_ONLY("output", @1);
// $$.qualifier = EvqOutput;
// }
// ;
//
// Place holder for the pack/unpack languages.
//
//buffer_declaration_list
// : buffer_declaration {
// }
// | buffer_declaration_list buffer_declaration {
// }
// ;
//
// Input/output semantics:
// float must be 16 or 32 bits
// float alignment restrictions?
// check for only one input and only one output
// sum of bitfields has to be multiple of 32
//
//
// Place holder for the pack/unpack languages.
//
//buffer_declaration
// : type_specifier IDENTIFIER COLON constant_expression SEMICOLON {
// if (context->reservedErrorCheck(@2, *$2.string, context))
// context->recover();
// $$.variable = new TVariable($2.string, $1);
// if (! context->symbolTable.declare(*$$.variable)) {
// context->error(@2, "redefinition", $$.variable->getName().c_str());
// context->recover();
// // don't have to delete $$.variable, the pool pop will take care of it
// }
// }
// ;
fully_specified_type
: type_specifier {
$$ = $1;
......
......@@ -765,34 +765,34 @@ static const yytype_int16 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 202, 202, 237, 240, 245, 250, 255, 260, 266,
269, 272, 275, 278, 281, 287, 295, 306, 309, 317,
321, 328, 332, 339, 345, 354, 362, 368, 375, 385,
388, 398, 408, 430, 431, 432, 433, 441, 442, 446,
450, 458, 459, 462, 468, 469, 473, 480, 481, 484,
487, 490, 496, 497, 500, 506, 507, 514, 515, 522,
523, 530, 531, 537, 538, 544, 545, 551, 552, 558,
559, 567, 568, 569, 570, 572, 573, 574, 576, 578,
580, 582, 587, 590, 601, 609, 617, 644, 650, 657,
661, 665, 669, 676, 714, 717, 724, 732, 753, 774,
785, 814, 819, 829, 834, 844, 847, 850, 853, 859,
866, 869, 873, 877, 882, 887, 894, 898, 902, 906,
911, 916, 920, 996, 1006, 1012, 1015, 1021, 1027, 1034,
1043, 1052, 1055, 1058, 1065, 1069, 1076, 1080, 1085, 1090,
1100, 1110, 1119, 1129, 1136, 1139, 1142, 1148, 1155, 1158,
1164, 1167, 1170, 1176, 1179, 1184, 1199, 1203, 1207, 1211,
1215, 1219, 1224, 1229, 1234, 1239, 1244, 1249, 1254, 1259,
1264, 1269, 1274, 1279, 1285, 1291, 1297, 1303, 1309, 1315,
1321, 1327, 1333, 1338, 1343, 1352, 1357, 1362, 1367, 1372,
1377, 1382, 1387, 1392, 1397, 1402, 1407, 1412, 1417, 1422,
1435, 1435, 1438, 1438, 1444, 1447, 1463, 1466, 1475, 1479,
1485, 1492, 1507, 1511, 1515, 1516, 1522, 1523, 1524, 1525,
1526, 1527, 1528, 1532, 1533, 1533, 1533, 1543, 1544, 1548,
1548, 1549, 1549, 1554, 1557, 1567, 1570, 1576, 1577, 1581,
1589, 1593, 1600, 1600, 1607, 1610, 1619, 1624, 1641, 1641,
1646, 1646, 1653, 1653, 1661, 1664, 1670, 1673, 1679, 1683,
1690, 1693, 1696, 1699, 1702, 1711, 1715, 1722, 1725, 1731,
1731
0, 202, 202, 221, 224, 229, 234, 239, 244, 250,
253, 256, 259, 262, 265, 271, 279, 290, 293, 301,
305, 312, 316, 323, 329, 338, 346, 352, 359, 369,
372, 382, 392, 414, 415, 416, 417, 425, 426, 430,
434, 442, 443, 446, 452, 453, 457, 464, 465, 468,
471, 474, 480, 481, 484, 490, 491, 498, 499, 506,
507, 514, 515, 521, 522, 528, 529, 535, 536, 542,
543, 551, 552, 553, 554, 556, 557, 558, 560, 562,
564, 566, 571, 574, 585, 593, 601, 628, 634, 641,
645, 649, 653, 660, 698, 701, 708, 716, 737, 758,
769, 798, 803, 813, 818, 828, 831, 834, 837, 843,
850, 853, 857, 861, 866, 871, 878, 882, 886, 890,
895, 900, 904, 911, 921, 927, 930, 936, 942, 949,
958, 967, 970, 973, 980, 984, 991, 995, 1000, 1005,
1015, 1025, 1034, 1044, 1051, 1054, 1057, 1063, 1070, 1073,
1079, 1082, 1085, 1091, 1094, 1099, 1114, 1118, 1122, 1126,
1130, 1134, 1139, 1144, 1149, 1154, 1159, 1164, 1169, 1174,
1179, 1184, 1189, 1194, 1200, 1206, 1212, 1218, 1224, 1230,
1236, 1242, 1248, 1253, 1258, 1267, 1272, 1277, 1282, 1287,
1292, 1297, 1302, 1307, 1312, 1317, 1322, 1327, 1332, 1337,
1350, 1350, 1353, 1353, 1359, 1362, 1378, 1381, 1390, 1394,
1400, 1407, 1422, 1426, 1430, 1431, 1437, 1438, 1439, 1440,
1441, 1442, 1443, 1447, 1448, 1448, 1448, 1458, 1459, 1463,
1463, 1464, 1464, 1469, 1472, 1482, 1485, 1491, 1492, 1496,
1504, 1508, 1515, 1515, 1522, 1525, 1534, 1539, 1556, 1556,
1561, 1561, 1568, 1568, 1576, 1579, 1585, 1588, 1594, 1598,
1605, 1608, 1611, 1614, 1617, 1626, 1630, 1637, 1640, 1646,
1646
};
#endif
......@@ -2489,23 +2489,7 @@ yyreduce:
{
// The symbol table search was done in the lexical phase
const TSymbol* symbol = (yyvsp[(1) - (1)].lex).symbol;
const TVariable* variable;
if (symbol == 0) {
context->error((yylsp[(1) - (1)]), "undeclared identifier", (yyvsp[(1) - (1)].lex).string->c_str());
context->recover();
TType type(EbtFloat, EbpUndefined);
TVariable* fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type);
context->symbolTable.declare(*fakeVariable);
variable = fakeVariable;
} else {
// This identifier can only be a variable type symbol
if (! symbol->isVariable()) {
context->error((yylsp[(1) - (1)]), "variable expected", (yyvsp[(1) - (1)].lex).string->c_str());
context->recover();
}
variable = static_cast<const TVariable*>(symbol);
}
const TVariable *variable = context->getNamedVariable((yylsp[(1) - (1)]), (yyvsp[(1) - (1)].lex).string, (yyvsp[(1) - (1)].lex).symbol);
// don't delete $1.string, it's used by error recovery, and the pool
// pop will reclaim the memory
......
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