Add support for arrays of arrays to VariableLocation
Array indices are sorted so that the outermost index is in the back.
This is because we want to be consistent with future arrays of arrays
parsing code. In parsing we'll have a utility function to make a
TType object into an array, and there it's most natural to push the
new outermost sizes to the back of the vector.
Further patches will still be needed to parse arrays of arrays and
add support to arrays of arrays into the API.
BUG=angleproject:2125
TEST=angle_unittests, angle_end2end_tests
Change-Id: I6c88edabf68ae9dbd803ec6d20543016c408b702
Reviewed-on: https://chromium-review.googlesource.com/686414
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp
index efa175a..efb5323 100644
--- a/src/common/utilities.cpp
+++ b/src/common/utilities.cpp
@@ -735,35 +735,39 @@
}
}
-std::string ParseResourceName(const std::string &name, size_t *outSubscript)
+std::string ParseResourceName(const std::string &name, std::vector<unsigned int> *outSubscripts)
{
- // Strip any trailing array operator and retrieve the subscript
- size_t open = name.find_last_of('[');
- size_t close = name.find_last_of(']');
- bool hasIndex = (open != std::string::npos) && (close == name.length() - 1);
- if (!hasIndex)
+ if (outSubscripts)
{
- if (outSubscript)
- {
- *outSubscript = GL_INVALID_INDEX;
- }
- return name;
+ outSubscripts->clear();
}
-
- if (outSubscript)
+ // Strip any trailing array indexing operators and retrieve the subscripts.
+ size_t baseNameLength = name.length();
+ bool hasIndex = true;
+ while (hasIndex)
{
- int index = atoi(name.substr(open + 1).c_str());
- if (index >= 0)
+ size_t open = name.find_last_of('[', baseNameLength - 1);
+ size_t close = name.find_last_of(']', baseNameLength - 1);
+ hasIndex = (open != std::string::npos) && (close == baseNameLength - 1);
+ if (hasIndex)
{
- *outSubscript = index;
- }
- else
- {
- *outSubscript = GL_INVALID_INDEX;
+ baseNameLength = open;
+ if (outSubscripts)
+ {
+ int index = atoi(name.substr(open + 1).c_str());
+ if (index >= 0)
+ {
+ outSubscripts->push_back(index);
+ }
+ else
+ {
+ outSubscripts->push_back(GL_INVALID_INDEX);
+ }
+ }
}
}
- return name.substr(0, open);
+ return name.substr(0, baseNameLength);
}
unsigned int ParseAndStripArrayIndex(std::string *name)