Commit 9de84a5d by Olli Etuaho Committed by Commit Bot

Clean up parsing function headers

Move function header parsing code to ParseContext instead of having it in the grammar file. This commit is pure refactoring. This code needs to be changed later to detect returning arrays containing structs. This commit also disables clang format for glslang.cpp generated by bison. TEST=angle_unittests BUG=angleproject:1015 Change-Id: If60848ca32da6b98ea8bcd95bba8c3f831634b51 Reviewed-on: https://chromium-review.googlesource.com/352480Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 9b08a3d5
......@@ -2178,6 +2178,31 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
return function;
}
TFunction *TParseContext::parseFunctionHeader(const TPublicType &type,
const TString *name,
const TSourceLoc &location)
{
if (type.qualifier != EvqGlobal && type.qualifier != EvqTemporary)
{
error(location, "no qualifiers allowed for function return",
getQualifierString(type.qualifier));
recover();
}
if (!type.layoutQualifier.isEmpty())
{
error(location, "no qualifiers allowed for function return", "layout");
recover();
}
// make sure a sampler is not involved as well...
if (samplerErrorCheck(location, type, "samplers can't be function return values"))
{
recover();
}
// Add the function as a prototype after parsing it (we do not support recursion)
return new TFunction(name, new TType(type));
}
TFunction *TParseContext::addConstructorFunc(const TPublicType &publicTypeIn)
{
TPublicType publicType = publicTypeIn;
......
......@@ -244,6 +244,9 @@ class TParseContext : angle::NonCopyable
TIntermAggregate **aggregateOut);
TFunction *parseFunctionDeclarator(const TSourceLoc &location,
TFunction *function);
TFunction *parseFunctionHeader(const TPublicType &type,
const TString *name,
const TSourceLoc &location);
TFunction *addConstructorFunc(const TPublicType &publicType);
TIntermTyped *addConstructor(TIntermNode *arguments,
TType *type,
......
......@@ -22,6 +22,8 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
// clang-format off
// Ignore errors in auto-generated code.
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function"
......@@ -665,26 +667,8 @@ function_header_with_parameters
function_header
: fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary)
{
context->error(@2, "no qualifiers allowed for function return", getQualifierString($1.qualifier));
context->recover();
}
if (!$1.layoutQualifier.isEmpty())
{
context->error(@2, "no qualifiers allowed for function return", "layout");
context->recover();
}
// make sure a sampler is not involved as well...
if (context->samplerErrorCheck(@2, $1, "samplers can't be function return values"))
context->recover();
$$ = context->parseFunctionHeader($1, $2.string, @2);
// Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function;
const TType *type = new TType($1);
function = new TFunction($2.string, type);
$$ = function;
context->symbolTable.push();
}
;
......
......@@ -72,6 +72,8 @@
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
// clang-format off
// Ignore errors in auto-generated code.
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wunused-function"
......@@ -694,34 +696,34 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 212, 212, 213, 216, 226, 229, 234, 239, 244,
249, 255, 258, 261, 264, 267, 270, 276, 284, 295,
299, 307, 310, 316, 320, 327, 333, 342, 350, 356,
363, 373, 376, 379, 382, 392, 393, 394, 395, 403,
404, 407, 410, 417, 418, 421, 427, 428, 432, 439,
440, 443, 446, 449, 455, 456, 459, 465, 466, 473,
474, 481, 482, 489, 490, 496, 497, 503, 504, 510,
511, 517, 518, 526, 527, 528, 529, 533, 534, 535,
539, 543, 547, 551, 558, 561, 567, 575, 583, 586,
592, 603, 607, 611, 615, 622, 628, 631, 638, 646,
667, 694, 704, 732, 737, 747, 752, 762, 765, 768,
771, 777, 784, 787, 791, 795, 800, 805, 812, 816,
820, 824, 829, 834, 838, 845, 855, 861, 864, 870,
876, 883, 892, 902, 910, 913, 920, 924, 928, 933,
941, 944, 948, 952, 961, 970, 978, 988, 1000, 1003,
1006, 1012, 1019, 1022, 1028, 1031, 1034, 1040, 1043, 1048,
1063, 1067, 1071, 1075, 1079, 1083, 1088, 1093, 1098, 1103,
1108, 1113, 1118, 1123, 1128, 1133, 1138, 1143, 1148, 1153,
1158, 1163, 1168, 1173, 1178, 1183, 1188, 1192, 1196, 1200,
1204, 1208, 1212, 1216, 1220, 1224, 1228, 1232, 1236, 1240,
1244, 1248, 1256, 1264, 1268, 1281, 1281, 1284, 1284, 1290,
1293, 1309, 1312, 1321, 1325, 1331, 1338, 1353, 1357, 1361,
1362, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1378, 1379,
1379, 1379, 1389, 1390, 1394, 1394, 1395, 1395, 1400, 1403,
1413, 1416, 1422, 1423, 1427, 1435, 1439, 1446, 1446, 1453,
1456, 1463, 1468, 1483, 1483, 1488, 1488, 1495, 1495, 1503,
1506, 1512, 1515, 1521, 1525, 1532, 1535, 1538, 1541, 1544,
1553, 1557, 1564, 1567, 1573, 1573
0, 214, 214, 215, 218, 228, 231, 236, 241, 246,
251, 257, 260, 263, 266, 269, 272, 278, 286, 297,
301, 309, 312, 318, 322, 329, 335, 344, 352, 358,
365, 375, 378, 381, 384, 394, 395, 396, 397, 405,
406, 409, 412, 419, 420, 423, 429, 430, 434, 441,
442, 445, 448, 451, 457, 458, 461, 467, 468, 475,
476, 483, 484, 491, 492, 498, 499, 505, 506, 512,
513, 519, 520, 528, 529, 530, 531, 535, 536, 537,
541, 545, 549, 553, 560, 563, 569, 577, 585, 588,
594, 605, 609, 613, 617, 624, 630, 633, 640, 648,
669, 678, 688, 716, 721, 731, 736, 746, 749, 752,
755, 761, 768, 771, 775, 779, 784, 789, 796, 800,
804, 808, 813, 818, 822, 829, 839, 845, 848, 854,
860, 867, 876, 886, 894, 897, 904, 908, 912, 917,
925, 928, 932, 936, 945, 954, 962, 972, 984, 987,
990, 996, 1003, 1006, 1012, 1015, 1018, 1024, 1027, 1032,
1047, 1051, 1055, 1059, 1063, 1067, 1072, 1077, 1082, 1087,
1092, 1097, 1102, 1107, 1112, 1117, 1122, 1127, 1132, 1137,
1142, 1147, 1152, 1157, 1162, 1167, 1172, 1176, 1180, 1184,
1188, 1192, 1196, 1200, 1204, 1208, 1212, 1216, 1220, 1224,
1228, 1232, 1241, 1249, 1253, 1266, 1266, 1269, 1269, 1275,
1278, 1294, 1297, 1306, 1310, 1316, 1323, 1338, 1342, 1346,
1347, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1363, 1364,
1364, 1364, 1374, 1375, 1379, 1379, 1380, 1380, 1385, 1388,
1398, 1401, 1407, 1408, 1412, 1420, 1424, 1431, 1431, 1438,
1441, 1448, 1453, 1468, 1468, 1473, 1473, 1480, 1480, 1488,
1491, 1497, 1500, 1506, 1510, 1517, 1520, 1523, 1526, 1529,
1538, 1542, 1549, 1552, 1558, 1558
};
#endif
......@@ -3179,26 +3181,8 @@ yyreduce:
case 100:
{
if ((yyvsp[-2].interm.type).qualifier != EvqGlobal && (yyvsp[-2].interm.type).qualifier != EvqTemporary)
{
context->error((yylsp[-1]), "no qualifiers allowed for function return", getQualifierString((yyvsp[-2].interm.type).qualifier));
context->recover();
}
if (!(yyvsp[-2].interm.type).layoutQualifier.isEmpty())
{
context->error((yylsp[-1]), "no qualifiers allowed for function return", "layout");
context->recover();
}
// make sure a sampler is not involved as well...
if (context->samplerErrorCheck((yylsp[-1]), (yyvsp[-2].interm.type), "samplers can't be function return values"))
context->recover();
(yyval.interm.function) = context->parseFunctionHeader((yyvsp[-2].interm.type), (yyvsp[-1].lex).string, (yylsp[-1]));
// Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function;
const TType *type = new TType((yyvsp[-2].interm.type));
function = new TFunction((yyvsp[-1].lex).string, type);
(yyval.interm.function) = function;
context->symbolTable.push();
}
......@@ -4200,8 +4184,7 @@ yyreduce:
{
if (!context->supportsExtension("GL_OES_EGL_image_external") &&
!context->supportsExtension("GL_NV_EGL_stream_consumer_external"))
{
!context->supportsExtension("GL_NV_EGL_stream_consumer_external")) {
context->error((yylsp[0]), "unsupported type", "samplerExternalOES");
context->recover();
}
......
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