summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/preprocessor/MacroExpander.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/compiler/preprocessor/MacroExpander.h')
-rwxr-xr-xgfx/angle/src/compiler/preprocessor/MacroExpander.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/gfx/angle/src/compiler/preprocessor/MacroExpander.h b/gfx/angle/src/compiler/preprocessor/MacroExpander.h
index 3a8450f5e..dbf980308 100755
--- a/gfx/angle/src/compiler/preprocessor/MacroExpander.h
+++ b/gfx/angle/src/compiler/preprocessor/MacroExpander.h
@@ -7,11 +7,13 @@
#ifndef COMPILER_PREPROCESSOR_MACROEXPANDER_H_
#define COMPILER_PREPROCESSOR_MACROEXPANDER_H_
+#include <cassert>
#include <memory>
#include <vector>
-#include "compiler/preprocessor/Lexer.h"
-#include "compiler/preprocessor/Macro.h"
+#include "Lexer.h"
+#include "Macro.h"
+#include "pp_utils.h"
namespace pp
{
@@ -28,6 +30,8 @@ class MacroExpander : public Lexer
void lex(Token *token) override;
private:
+ PP_DISALLOW_COPY_AND_ASSIGN(MacroExpander);
+
void getToken(Token *token);
void ungetToken(const Token &token);
bool isNextTokenLeftParen();
@@ -50,14 +54,28 @@ class MacroExpander : public Lexer
struct MacroContext
{
- MacroContext();
- bool empty() const;
- const Token &get();
- void unget();
-
const Macro *macro;
std::size_t index;
std::vector<Token> replacements;
+
+ MacroContext()
+ : macro(0),
+ index(0)
+ {
+ }
+ bool empty() const
+ {
+ return index == replacements.size();
+ }
+ const Token &get()
+ {
+ return replacements[index++];
+ }
+ void unget()
+ {
+ assert(index > 0);
+ --index;
+ }
};
Lexer *mLexer;
@@ -66,12 +84,6 @@ class MacroExpander : public Lexer
std::unique_ptr<Token> mReserveToken;
std::vector<MacroContext *> mContextStack;
- size_t mTotalTokensInContexts;
-
- bool mDeferReenablingMacros;
- std::vector<const Macro *> mMacrosToReenable;
-
- class ScopedMacroReenabler;
};
} // namespace pp