Move logic for parsing fully specified types out of the grammar file to TParseContext.

TRAC #23080 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2398 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8da034cc
...@@ -1104,6 +1104,34 @@ bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode) ...@@ -1104,6 +1104,34 @@ bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode)
return allConstant; return allConstant;
} }
TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier)
{
TPublicType returnType = typeSpecifier;
returnType.qualifier = qualifier;
if (typeSpecifier.array)
{
error(typeSpecifier.line, "not supported", "first-class array");
recover();
returnType.setArray(false);
}
if (qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
{
error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier));
recover();
}
if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) &&
(typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
{
error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier));
recover();
}
return returnType;
}
// This function is used to test for the correctness of the parameters passed to various constructor functions // This function is used to test for the correctness of the parameters passed to various constructor functions
// and also convert them to the right datatype if it is allowed and required. // and also convert them to the right datatype if it is allowed and required.
// //
......
...@@ -120,6 +120,7 @@ struct TParseContext { ...@@ -120,6 +120,7 @@ struct TParseContext {
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc); TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset); TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
......
...@@ -1330,24 +1330,7 @@ fully_specified_type ...@@ -1330,24 +1330,7 @@ fully_specified_type
} }
} }
| type_qualifier type_specifier { | type_qualifier type_specifier {
if ($2.array) { $$ = context->addFullySpecifiedType($1.qualifier, $2);
context->error($2.line, "not supported", "first-class array");
context->recover();
$2.setArray(false);
}
if ($1.qualifier == EvqAttribute &&
($2.type == EbtBool || $2.type == EbtInt)) {
context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier));
context->recover();
}
if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &&
($2.type == EbtBool || $2.type == EbtInt)) {
context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier));
context->recover();
}
$$ = $2;
$$.qualifier = $1.qualifier;
} }
; ;
......
...@@ -736,19 +736,19 @@ static const yytype_uint16 yyrline[] = ...@@ -736,19 +736,19 @@ static const yytype_uint16 yyrline[] =
798, 806, 814, 841, 846, 857, 861, 865, 872, 910, 798, 806, 814, 841, 846, 857, 861, 865, 872, 910,
913, 920, 928, 949, 970, 981, 1010, 1015, 1025, 1030, 913, 920, 928, 949, 970, 981, 1010, 1015, 1025, 1030,
1040, 1043, 1046, 1049, 1055, 1062, 1065, 1087, 1105, 1129, 1040, 1043, 1046, 1049, 1055, 1062, 1065, 1087, 1105, 1129,
1152, 1156, 1174, 1182, 1214, 1234, 1323, 1332, 1355, 1359, 1152, 1156, 1174, 1182, 1214, 1234, 1323, 1332, 1338, 1342,
1366, 1372, 1379, 1388, 1397, 1400, 1436, 1446, 1450, 1455, 1349, 1355, 1362, 1371, 1380, 1383, 1419, 1429, 1433, 1438,
1460, 1465, 1470, 1479, 1489, 1496, 1499, 1502, 1508, 1511, 1443, 1448, 1453, 1462, 1472, 1479, 1482, 1485, 1491, 1494,
1526, 1530, 1534, 1538, 1547, 1552, 1557, 1562, 1567, 1572, 1509, 1513, 1517, 1521, 1530, 1535, 1540, 1545, 1550, 1555,
1577, 1582, 1587, 1592, 1598, 1604, 1610, 1615, 1620, 1625, 1560, 1565, 1570, 1575, 1581, 1587, 1593, 1598, 1603, 1608,
1630, 1635, 1640, 1645, 1650, 1659, 1668, 1673, 1686, 1686, 1613, 1618, 1623, 1628, 1633, 1642, 1651, 1656, 1669, 1669,
1689, 1689, 1695, 1698, 1713, 1716, 1724, 1728, 1734, 1742, 1672, 1672, 1678, 1681, 1696, 1699, 1707, 1711, 1717, 1725,
1758, 1762, 1766, 1767, 1773, 1774, 1775, 1776, 1777, 1781, 1741, 1745, 1749, 1750, 1756, 1757, 1758, 1759, 1760, 1764,
1782, 1782, 1782, 1792, 1793, 1797, 1797, 1798, 1798, 1803, 1765, 1765, 1765, 1775, 1776, 1780, 1780, 1781, 1781, 1786,
1806, 1816, 1819, 1825, 1826, 1830, 1838, 1842, 1852, 1857, 1789, 1799, 1802, 1808, 1809, 1813, 1821, 1825, 1835, 1840,
1874, 1874, 1879, 1879, 1886, 1886, 1894, 1897, 1903, 1906, 1857, 1857, 1862, 1862, 1869, 1869, 1877, 1880, 1886, 1889,
1912, 1916, 1923, 1930, 1937, 1944, 1955, 1964, 1968, 1975, 1895, 1899, 1906, 1913, 1920, 1927, 1938, 1947, 1951, 1958,
1978, 1984, 1984 1961, 1967, 1967
}; };
#endif #endif
...@@ -3612,24 +3612,7 @@ yyreduce: ...@@ -3612,24 +3612,7 @@ yyreduce:
case 107: case 107:
{ {
if ((yyvsp[(2) - (2)].interm.type).array) { (yyval.interm.type) = context->addFullySpecifiedType((yyvsp[(1) - (2)].interm.type).qualifier, (yyvsp[(2) - (2)].interm.type));
context->error((yyvsp[(2) - (2)].interm.type).line, "not supported", "first-class array");
context->recover();
(yyvsp[(2) - (2)].interm.type).setArray(false);
}
if ((yyvsp[(1) - (2)].interm.type).qualifier == EvqAttribute &&
((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) {
context->error((yyvsp[(2) - (2)].interm.type).line, "cannot be bool or int", getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier));
context->recover();
}
if (((yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingIn || (yyvsp[(1) - (2)].interm.type).qualifier == EvqVaryingOut) &&
((yyvsp[(2) - (2)].interm.type).type == EbtBool || (yyvsp[(2) - (2)].interm.type).type == EbtInt)) {
context->error((yyvsp[(2) - (2)].interm.type).line, "cannot be bool or int", getQualifierString((yyvsp[(1) - (2)].interm.type).qualifier));
context->recover();
}
(yyval.interm.type) = (yyvsp[(2) - (2)].interm.type);
(yyval.interm.type).qualifier = (yyvsp[(1) - (2)].interm.type).qualifier;
} }
break; break;
......
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