xref: /aosp_15_r20/external/angle/src/compiler/preprocessor/Macro.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2012 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker 
7*8975f5c5SAndroid Build Coastguard Worker #ifndef COMPILER_PREPROCESSOR_MACRO_H_
8*8975f5c5SAndroid Build Coastguard Worker #define COMPILER_PREPROCESSOR_MACRO_H_
9*8975f5c5SAndroid Build Coastguard Worker 
10*8975f5c5SAndroid Build Coastguard Worker #include <map>
11*8975f5c5SAndroid Build Coastguard Worker #include <memory>
12*8975f5c5SAndroid Build Coastguard Worker #include <string>
13*8975f5c5SAndroid Build Coastguard Worker #include <vector>
14*8975f5c5SAndroid Build Coastguard Worker 
15*8975f5c5SAndroid Build Coastguard Worker namespace angle
16*8975f5c5SAndroid Build Coastguard Worker {
17*8975f5c5SAndroid Build Coastguard Worker 
18*8975f5c5SAndroid Build Coastguard Worker namespace pp
19*8975f5c5SAndroid Build Coastguard Worker {
20*8975f5c5SAndroid Build Coastguard Worker 
21*8975f5c5SAndroid Build Coastguard Worker struct Token;
22*8975f5c5SAndroid Build Coastguard Worker 
23*8975f5c5SAndroid Build Coastguard Worker struct Macro
24*8975f5c5SAndroid Build Coastguard Worker {
25*8975f5c5SAndroid Build Coastguard Worker     enum Type
26*8975f5c5SAndroid Build Coastguard Worker     {
27*8975f5c5SAndroid Build Coastguard Worker         kTypeObj,
28*8975f5c5SAndroid Build Coastguard Worker         kTypeFunc
29*8975f5c5SAndroid Build Coastguard Worker     };
30*8975f5c5SAndroid Build Coastguard Worker     typedef std::vector<std::string> Parameters;
31*8975f5c5SAndroid Build Coastguard Worker     typedef std::vector<Token> Replacements;
32*8975f5c5SAndroid Build Coastguard Worker 
33*8975f5c5SAndroid Build Coastguard Worker     Macro();
34*8975f5c5SAndroid Build Coastguard Worker     ~Macro();
35*8975f5c5SAndroid Build Coastguard Worker     bool equals(const Macro &other) const;
36*8975f5c5SAndroid Build Coastguard Worker 
37*8975f5c5SAndroid Build Coastguard Worker     bool predefined;
38*8975f5c5SAndroid Build Coastguard Worker     mutable bool disabled;
39*8975f5c5SAndroid Build Coastguard Worker     mutable int expansionCount;
40*8975f5c5SAndroid Build Coastguard Worker 
41*8975f5c5SAndroid Build Coastguard Worker     Type type;
42*8975f5c5SAndroid Build Coastguard Worker     std::string name;
43*8975f5c5SAndroid Build Coastguard Worker     Parameters parameters;
44*8975f5c5SAndroid Build Coastguard Worker     Replacements replacements;
45*8975f5c5SAndroid Build Coastguard Worker };
46*8975f5c5SAndroid Build Coastguard Worker 
47*8975f5c5SAndroid Build Coastguard Worker typedef std::map<std::string, std::shared_ptr<Macro>> MacroSet;
48*8975f5c5SAndroid Build Coastguard Worker 
49*8975f5c5SAndroid Build Coastguard Worker void PredefineMacro(MacroSet *macroSet, const char *name, int value);
50*8975f5c5SAndroid Build Coastguard Worker 
51*8975f5c5SAndroid Build Coastguard Worker }  // namespace pp
52*8975f5c5SAndroid Build Coastguard Worker 
53*8975f5c5SAndroid Build Coastguard Worker }  // namespace angle
54*8975f5c5SAndroid Build Coastguard Worker 
55*8975f5c5SAndroid Build Coastguard Worker #endif  // COMPILER_PREPROCESSOR_MACRO_H_
56