Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2016 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // ValidateMaxParameters checks if function definitions have more than a set number of parameters. |
| 7 | |
| 8 | #include "compiler/translator/ValidateMaxParameters.h" |
| 9 | |
Olli Etuaho | b427920 | 2017-05-18 15:08:24 +0300 | [diff] [blame^] | 10 | #include "compiler/translator/IntermNode.h" |
| 11 | |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 12 | namespace sh |
| 13 | { |
| 14 | |
Olli Etuaho | b427920 | 2017-05-18 15:08:24 +0300 | [diff] [blame^] | 15 | bool ValidateMaxParameters(TIntermBlock *root, unsigned int maxParameters) |
Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 16 | { |
Olli Etuaho | b427920 | 2017-05-18 15:08:24 +0300 | [diff] [blame^] | 17 | for (TIntermNode *node : *root->getSequence()) |
Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 18 | { |
Olli Etuaho | b427920 | 2017-05-18 15:08:24 +0300 | [diff] [blame^] | 19 | TIntermFunctionDefinition *definition = node->getAsFunctionDefinition(); |
| 20 | if (definition != nullptr && |
| 21 | definition->getFunctionPrototype()->getSequence()->size() > maxParameters) |
| 22 | { |
| 23 | return false; |
| 24 | } |
Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 25 | } |
Olli Etuaho | b427920 | 2017-05-18 15:08:24 +0300 | [diff] [blame^] | 26 | return true; |
Olli Etuaho | 19d1dc9 | 2016-03-08 17:18:46 +0200 | [diff] [blame] | 27 | } |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 28 | |
| 29 | } // namespace sh |