1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef COMPILER_PREPROCESSOR_MACRO_H_ 16 #define COMPILER_PREPROCESSOR_MACRO_H_ 17 18 #include <map> 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace pp 24 { 25 26 struct Token; 27 28 struct Macro 29 { 30 enum Type 31 { 32 kTypeObj, 33 kTypeFunc 34 }; 35 typedef std::vector<std::string> Parameters; 36 typedef std::vector<Token> Replacements; 37 38 Macro(); 39 ~Macro(); 40 bool equals(const Macro &other) const; 41 42 bool predefined; 43 mutable bool disabled; 44 mutable int expansionCount; 45 46 Type type; 47 std::string name; 48 Parameters parameters; 49 Replacements replacements; 50 }; 51 52 typedef std::map<std::string, std::shared_ptr<Macro>> MacroSet; 53 54 void PredefineMacro(MacroSet *macroSet, const char *name, int value); 55 56 } // namespace pp 57 #endif // COMPILER_PREPROCESSOR_MACRO_H_ 58