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

Method handleLoopAttributes

glslang/MachineIndependent/attribute.cpp:227–346  ·  view source on GitHub ↗

Loop attributes

Source from the content-addressed store, hash-verified

225// Loop attributes
226//
227void TParseContext::handleLoopAttributes(const TAttributes& attributes, TIntermNode* node)
228{
229 TIntermLoop* loop = node->getAsLoopNode();
230 if (loop == nullptr) {
231 // the actual loop might be part of a sequence
232 TIntermAggregate* agg = node->getAsAggregate();
233 if (agg == nullptr)
234 return;
235 for (auto it = agg->getSequence().begin(); it != agg->getSequence().end(); ++it) {
236 loop = (*it)->getAsLoopNode();
237 if (loop != nullptr)
238 break;
239 }
240 if (loop == nullptr)
241 return;
242 }
243
244 for (auto it = attributes.begin(); it != attributes.end(); ++it) {
245
246 const auto noArgument = [&](const char* feature) {
247 if (it->size() > 0) {
248 warn(node->getLoc(), "expected no arguments", feature, "");
249 return false;
250 }
251 return true;
252 };
253
254 const auto positiveSignedArgument = [&](const char* feature, int& value) {
255 if (it->size() == 1 && it->getInt(value)) {
256 if (value <= 0) {
257 error(node->getLoc(), "must be positive", feature, "");
258 return false;
259 }
260 } else {
261 warn(node->getLoc(), "expected a single integer argument", feature, "");
262 return false;
263 }
264 return true;
265 };
266
267 const auto unsignedArgument = [&](const char* feature, unsigned int& uiValue) {
268 int value;
269 if (!(it->size() == 1 && it->getInt(value))) {
270 warn(node->getLoc(), "expected a single integer argument", feature, "");
271 return false;
272 }
273 uiValue = (unsigned int)value;
274 return true;
275 };
276
277 const auto positiveUnsignedArgument = [&](const char* feature, unsigned int& uiValue) {
278 int value;
279 if (it->size() == 1 && it->getInt(value)) {
280 if (value == 0) {
281 error(node->getLoc(), "must be greater than or equal to 1", feature, "");
282 return false;
283 }
284 } else {

Callers 1

yyparseFunction · 0.45

Calls 15

errorFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
getIntMethod · 0.80
setUnrollMethod · 0.80
setDontUnrollMethod · 0.80
setLoopDependencyMethod · 0.80
setMinIterationsMethod · 0.80
setMaxIterationsMethod · 0.80
setIterationMultipleMethod · 0.80
setPeelCountMethod · 0.80
setPartialCountMethod · 0.80

Tested by

no test coverage detected