blob: 9dccbf413f61e9724eb254f374a654d0db456f3a [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
Olli Etuahob4279202017-05-18 15:08:24 +030010#include "compiler/translator/IntermNode.h"
11
Jamie Madill45bcc782016-11-07 13:58:48 -050012namespace sh
13{
14
Olli Etuahob4279202017-05-18 15:08:24 +030015bool ValidateMaxParameters(TIntermBlock *root, unsigned int maxParameters)
Olli Etuaho19d1dc92016-03-08 17:18:46 +020016{
Olli Etuahob4279202017-05-18 15:08:24 +030017 for (TIntermNode *node : *root->getSequence())
Olli Etuaho19d1dc92016-03-08 17:18:46 +020018 {
Olli Etuahob4279202017-05-18 15:08:24 +030019 TIntermFunctionDefinition *definition = node->getAsFunctionDefinition();
20 if (definition != nullptr &&
21 definition->getFunctionPrototype()->getSequence()->size() > maxParameters)
22 {
23 return false;
24 }
Olli Etuaho19d1dc92016-03-08 17:18:46 +020025 }
Olli Etuahob4279202017-05-18 15:08:24 +030026 return true;
Olli Etuaho19d1dc92016-03-08 17:18:46 +020027}
Jamie Madill45bcc782016-11-07 13:58:48 -050028
29} // namespace sh