MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / acceptArraySpecifier

Method acceptArraySpecifier

glslang/HLSL/hlslGrammar.cpp:4277–4309  ·  view source on GitHub ↗

array_specifier : LEFT_BRACKET integer_expression RGHT_BRACKET ... // optional : LEFT_BRACKET RGHT_BRACKET // optional

Source from the content-addressed store, hash-verified

4275// : LEFT_BRACKET RGHT_BRACKET // optional
4276//
4277void HlslGrammar::acceptArraySpecifier(TArraySizes*& arraySizes)
4278{
4279 arraySizes = nullptr;
4280
4281 // Early-out if there aren't any array dimensions
4282 if (!peekTokenClass(EHTokLeftBracket))
4283 return;
4284
4285 // If we get here, we have at least one array dimension. This will track the sizes we find.
4286 arraySizes = new TArraySizes;
4287
4288 // Collect each array dimension.
4289 while (acceptTokenClass(EHTokLeftBracket)) {
4290 TSourceLoc loc = token.loc;
4291 TIntermTyped* sizeExpr = nullptr;
4292
4293 // Array sizing expression is optional. If omitted, array will be later sized by initializer list.
4294 const bool hasArraySize = acceptAssignmentExpression(sizeExpr);
4295
4296 if (! acceptTokenClass(EHTokRightBracket)) {
4297 expected("]");
4298 return;
4299 }
4300
4301 if (hasArraySize) {
4302 TArraySize arraySize;
4303 parseContext.arraySizeCheck(loc, sizeExpr, arraySize);
4304 arraySizes->addInnerSize(arraySize);
4305 } else {
4306 arraySizes->addInnerSize(0); // sized by initializers.
4307 }
4308 }
4309}
4310
4311// post_decls
4312// : COLON semantic // optional

Callers

nothing calls this directly

Calls 2

addInnerSizeMethod · 0.80
arraySizeCheckMethod · 0.45

Tested by

no test coverage detected