blob: 00b3c9b451ba1c37689256509bb76e6f88d50106 [file] [log] [blame]
Olli Etuaho19d1dc92016-03-08 17:18:46 +02001//
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
10ValidateMaxParameters::ValidateMaxParameters(unsigned int maxParameters)
11 : TIntermTraverser(true, false, false), mMaxParameters(maxParameters), mValid(true)
12{
13}
14
15bool 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
30bool ValidateMaxParameters::validate(TIntermNode *root, unsigned int maxParameters)
31{
32 ValidateMaxParameters argsTraverser(maxParameters);
33 root->traverse(&argsTraverser);
34 return argsTraverser.mValid;
35}