• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2017 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 // Declarator.h:
7 //   Declarator type for parsing structure field declarators.
8 
9 #ifndef COMPILER_TRANSLATOR_DECLARATOR_H_
10 #define COMPILER_TRANSLATOR_DECLARATOR_H_
11 
12 #include "compiler/translator/Common.h"
13 #include "compiler/translator/ImmutableString.h"
14 
15 namespace sh
16 {
17 
18 // Declarator like "a[2][4]". Only used for parsing structure field declarators.
19 class TDeclarator : angle::NonCopyable
20 {
21   public:
22     POOL_ALLOCATOR_NEW_DELETE
23     TDeclarator(const ImmutableString &name, const TSourceLoc &line);
24 
25     TDeclarator(const ImmutableString &name,
26                 const TVector<unsigned int> *arraySizes,
27                 const TSourceLoc &line);
28 
name()29     const ImmutableString &name() const { return mName; }
30 
31     bool isArray() const;
arraySizes()32     const TVector<unsigned int> *arraySizes() const { return mArraySizes; }
33 
line()34     const TSourceLoc &line() const { return mLine; }
35 
36   private:
37     const ImmutableString mName;
38 
39     // Outermost array size is stored at the end of the vector.
40     const TVector<unsigned int> *const mArraySizes;
41 
42     const TSourceLoc mLine;
43 };
44 
45 using TDeclaratorList = TVector<TDeclarator *>;
46 
47 }  // namespace sh
48 
49 #endif  // COMPILER_TRANSLATOR_DECLARATOR_H_
50