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