blob: f5c94399db77d90b5ead042160c51015b72fce53 [file] [log] [blame]
alokp@chromium.org3a01d1b2011-08-30 05:10:53 +00001//
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 Wallez054f7ed2016-09-20 17:15:59 -04007#include "compiler/preprocessor/Macro.h"
alokp@chromium.org3a01d1b2011-08-30 05:10:53 +00008
Corentin Wallez054f7ed2016-09-20 17:15:59 -04009#include "common/angleutils.h"
10#include "compiler/preprocessor/Token.h"
alokp@chromium.org3a01d1b2011-08-30 05:10:53 +000011
12namespace pp
13{
14
Zhenyao Mod526f982014-05-13 14:51:19 -070015bool Macro::equals(const Macro &other) const
alokp@chromium.org3a01d1b2011-08-30 05:10:53 +000016{
alokp@chromium.org98d04ec2012-05-21 22:47:20 +000017 return (type == other.type) &&
18 (name == other.name) &&
19 (parameters == other.parameters) &&
20 (replacements == other.replacements);
alokp@chromium.org3a01d1b2011-08-30 05:10:53 +000021}
22
Olli Etuaho6cb4c7f2015-08-13 11:27:17 +030023void PredefineMacro(MacroSet *macroSet, const char *name, int value)
24{
Olli Etuaho6cb4c7f2015-08-13 11:27:17 +030025 Token token;
26 token.type = Token::CONST_INT;
Corentin Wallez054f7ed2016-09-20 17:15:59 -040027 token.text = ToString(value);
Olli Etuaho6cb4c7f2015-08-13 11:27:17 +030028
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.org3a01d1b2011-08-30 05:10:53 +000038} // namespace pp
39