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 | |
| 10 | ValidateMaxParameters::ValidateMaxParameters(unsigned int maxParameters) |
| 11 | : TIntermTraverser(true, false, false), mMaxParameters(maxParameters), mValid(true) |
| 12 | { |
| 13 | } |
| 14 | |
| 15 | bool ValidateMaxParameters::visitAggregate(Visit visit, TIntermAggregate *node) |
| 16 | { |
| 17 | if (!mValid) |
| 18 | { |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | if (node->getOp() == EOpParameters && node->getSequence()->size() > mMaxParameters) |
| 23 | { |
| 24 | mValid = false; |
| 25 | } |
| 26 | |
| 27 | return mValid; |
| 28 | } |
| 29 | |
| 30 | bool ValidateMaxParameters::validate(TIntermNode *root, unsigned int maxParameters) |
| 31 | { |
| 32 | ValidateMaxParameters argsTraverser(maxParameters); |
| 33 | root->traverse(&argsTraverser); |
| 34 | return argsTraverser.mValid; |
| 35 | } |