alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2011 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 | |
Corentin Wallez | 054f7ed | 2016-09-20 17:15:59 -0400 | [diff] [blame] | 7 | #include "compiler/preprocessor/Macro.h" |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 8 | |
Corentin Wallez | 054f7ed | 2016-09-20 17:15:59 -0400 | [diff] [blame] | 9 | #include "common/angleutils.h" |
| 10 | #include "compiler/preprocessor/Token.h" |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 11 | |
Geoff Lang | 197d529 | 2018-04-25 14:29:00 -0400 | [diff] [blame^] | 12 | namespace angle |
| 13 | { |
| 14 | |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 15 | namespace pp |
| 16 | { |
| 17 | |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 18 | Macro::Macro() : predefined(false), disabled(false), expansionCount(0), type(kTypeObj) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | Macro::~Macro() |
| 23 | { |
| 24 | } |
| 25 | |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 26 | bool Macro::equals(const Macro &other) const |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 27 | { |
Jamie Madill | f832c9d | 2016-12-12 17:38:48 -0500 | [diff] [blame] | 28 | return (type == other.type) && (name == other.name) && (parameters == other.parameters) && |
alokp@chromium.org | 98d04ec | 2012-05-21 22:47:20 +0000 | [diff] [blame] | 29 | (replacements == other.replacements); |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 32 | void PredefineMacro(MacroSet *macroSet, const char *name, int value) |
| 33 | { |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 34 | Token token; |
| 35 | token.type = Token::CONST_INT; |
Corentin Wallez | 054f7ed | 2016-09-20 17:15:59 -0400 | [diff] [blame] | 36 | token.text = ToString(value); |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 37 | |
Olli Etuaho | 47c27e8 | 2017-01-17 15:29:35 +0000 | [diff] [blame] | 38 | std::shared_ptr<Macro> macro = std::make_shared<Macro>(); |
| 39 | macro->predefined = true; |
| 40 | macro->type = Macro::kTypeObj; |
| 41 | macro->name = name; |
| 42 | macro->replacements.push_back(token); |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 43 | |
| 44 | (*macroSet)[name] = macro; |
| 45 | } |
| 46 | |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 47 | } // namespace pp |
Geoff Lang | 197d529 | 2018-04-25 14:29:00 -0400 | [diff] [blame^] | 48 | |
| 49 | } // namespace angle |