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 | |
| 12 | namespace pp |
| 13 | { |
| 14 | |
Zhenyao Mo | d526f98 | 2014-05-13 14:51:19 -0700 | [diff] [blame] | 15 | bool Macro::equals(const Macro &other) const |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 16 | { |
alokp@chromium.org | 98d04ec | 2012-05-21 22:47:20 +0000 | [diff] [blame] | 17 | return (type == other.type) && |
| 18 | (name == other.name) && |
| 19 | (parameters == other.parameters) && |
| 20 | (replacements == other.replacements); |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 23 | void PredefineMacro(MacroSet *macroSet, const char *name, int value) |
| 24 | { |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 25 | Token token; |
| 26 | token.type = Token::CONST_INT; |
Corentin Wallez | 054f7ed | 2016-09-20 17:15:59 -0400 | [diff] [blame^] | 27 | token.text = ToString(value); |
Olli Etuaho | 6cb4c7f | 2015-08-13 11:27:17 +0300 | [diff] [blame] | 28 | |
| 29 | Macro macro; |
| 30 | macro.predefined = true; |
| 31 | macro.type = Macro::kTypeObj; |
| 32 | macro.name = name; |
| 33 | macro.replacements.push_back(token); |
| 34 | |
| 35 | (*macroSet)[name] = macro; |
| 36 | } |
| 37 | |
alokp@chromium.org | 3a01d1b | 2011-08-30 05:10:53 +0000 | [diff] [blame] | 38 | } // namespace pp |
| 39 | |