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
7#include "compiler/preprocessor/Macro.h"
8
9#include "common/angleutils.h"
10#include "compiler/preprocessor/Token.h"
11
12namespace angle
13{
14
15namespace pp
16{
17
18Macro::Macro() : predefined(false), disabled(false), expansionCount(0), type(kTypeObj) {}
19
20Macro::~Macro() {}
21
22bool Macro::equals(const Macro &other) const
23{
24 return (type == other.type) && (name == other.name) && (parameters == other.parameters) &&
25 (replacements == other.replacements);
26}
27
28void PredefineMacro(MacroSet *macroSet, const char *name, int value)
29{
30 Token token;
31 token.type = Token::CONST_INT;
32 token.text = ToString(value);
33
34 std::shared_ptr<Macro> macro = std::make_shared<Macro>();
35 macro->predefined = true;
36 macro->type = Macro::kTypeObj;
37 macro->name = name;
38 macro->replacements.push_back(token);
39
40 (*macroSet)[name] = macro;
41}
42
43} // namespace pp
44
45} // namespace angle
46