diff options
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp')
-rw-r--r-- | Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp index b615c85dc..1709d6673 100644 --- a/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp +++ b/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Preprocessor.cpp @@ -4,41 +4,38 @@ // found in the LICENSE file. // -#include "Preprocessor.h" +#include "compiler/preprocessor/Preprocessor.h" -#include <cassert> -#include <sstream> - -#include "DiagnosticsBase.h" -#include "DirectiveParser.h" -#include "Macro.h" -#include "MacroExpander.h" -#include "Token.h" -#include "Tokenizer.h" +#include "common/debug.h" +#include "compiler/preprocessor/DiagnosticsBase.h" +#include "compiler/preprocessor/DirectiveParser.h" +#include "compiler/preprocessor/Macro.h" +#include "compiler/preprocessor/MacroExpander.h" +#include "compiler/preprocessor/Token.h" +#include "compiler/preprocessor/Tokenizer.h" namespace pp { struct PreprocessorImpl { - Diagnostics* diagnostics; + Diagnostics *diagnostics; MacroSet macroSet; Tokenizer tokenizer; DirectiveParser directiveParser; MacroExpander macroExpander; - PreprocessorImpl(Diagnostics* diag, - DirectiveHandler* directiveHandler) : - diagnostics(diag), - tokenizer(diag), - directiveParser(&tokenizer, ¯oSet, diag, directiveHandler), - macroExpander(&directiveParser, ¯oSet, diag) + PreprocessorImpl(Diagnostics *diag, DirectiveHandler *directiveHandler) + : diagnostics(diag), + tokenizer(diag), + directiveParser(&tokenizer, ¯oSet, diag, directiveHandler), + macroExpander(&directiveParser, ¯oSet, diag) { } }; -Preprocessor::Preprocessor(Diagnostics* diagnostics, - DirectiveHandler* directiveHandler) +Preprocessor::Preprocessor(Diagnostics *diagnostics, + DirectiveHandler *directiveHandler) { mImpl = new PreprocessorImpl(diagnostics, directiveHandler); } @@ -49,44 +46,26 @@ Preprocessor::~Preprocessor() } bool Preprocessor::init(size_t count, - const char* const string[], + const char * const string[], const int length[]) { - static const int kGLSLVersion = 100; + static const int kDefaultGLSLVersion = 100; // Add standard pre-defined macros. predefineMacro("__LINE__", 0); predefineMacro("__FILE__", 0); - predefineMacro("__VERSION__", kGLSLVersion); + predefineMacro("__VERSION__", kDefaultGLSLVersion); predefineMacro("GL_ES", 1); return mImpl->tokenizer.init(count, string, length); } -void Preprocessor::predefineMacro(const char* name, int value) -{ - std::ostringstream stream; - stream << value; - - Token token; - token.type = Token::CONST_INT; - token.text = stream.str(); - - Macro macro; - macro.predefined = true; - macro.type = Macro::kTypeObj; - macro.name = name; - macro.replacements.push_back(token); - - mImpl->macroSet[name] = macro; -} - -void Preprocessor::setMaxTokenLength(size_t maxLength) +void Preprocessor::predefineMacro(const char *name, int value) { - mImpl->tokenizer.setMaxTokenLength(maxLength); + PredefineMacro(&mImpl->macroSet, name, value); } -void Preprocessor::lex(Token* token) +void Preprocessor::lex(Token *token) { bool validToken = false; while (!validToken) @@ -98,14 +77,14 @@ void Preprocessor::lex(Token* token) // Convert preprocessing tokens to compiler tokens or report // diagnostics. case Token::PP_HASH: - assert(false); - break; + UNREACHABLE(); + break; case Token::PP_NUMBER: - mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER, + mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, token->location, token->text); break; case Token::PP_OTHER: - mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER, + mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, token->location, token->text); break; default: @@ -115,5 +94,9 @@ void Preprocessor::lex(Token* token) } } -} // namespace pp +void Preprocessor::setMaxTokenSize(size_t maxTokenSize) +{ + mImpl->tokenizer.setMaxTokenSize(maxTokenSize); +} +} // namespace pp |