Commit 5508f39d by Jamie Madill

Fix breaking the build with missing GetGlobalMaxTokenSize.

Because the preprocessor is used independently from the compiler, we need a way to track max token size when we don't have access to the parse context with the current spec. BUG=angle:550 Change-Id: Idf5035ec2c001ee75f264151ab3c4e92f3cd44d7 Reviewed-on: https://chromium-review.googlesource.com/187140Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 4fd5e4a3
......@@ -110,4 +110,9 @@ void Preprocessor::lex(Token* token)
}
}
void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
{
mImpl->tokenizer.setMaxTokenSize(maxTokenSize);
}
} // namespace pp
......@@ -40,6 +40,9 @@ class Preprocessor
void lex(Token* token);
// Set maximum preprocessor token size
void setMaxTokenSize(size_t maxTokenSize);
private:
PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
......
......@@ -540,7 +540,6 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
*/
#include "Tokenizer.h"
#include "length_limits.h"
#include "DiagnosticsBase.h"
#include "Token.h"
......@@ -2317,7 +2316,9 @@ void ppfree (void * ptr , yyscan_t yyscanner)
namespace pp {
Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
Tokenizer::Tokenizer(Diagnostics* diagnostics)
: mHandle(0),
mMaxTokenSize(256)
{
mContext.diagnostics = diagnostics;
}
......@@ -2347,14 +2348,19 @@ void Tokenizer::setLineNumber(int line)
ppset_lineno(line,mHandle);
}
void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
{
mMaxTokenSize = maxTokenSize;
}
void Tokenizer::lex(Token* token)
{
token->type = pplex(&token->text,&token->location,mHandle);
if (token->text.size() > GetGlobalMaxTokenSize())
if (token->text.size() > mMaxTokenSize)
{
mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
token->location, token->text);
token->text.erase(GetGlobalMaxTokenSize());
token->text.erase(mMaxTokenSize);
}
token->flags = 0;
......
......@@ -40,6 +40,7 @@ class Tokenizer : public Lexer
void setFileNumber(int file);
void setLineNumber(int line);
void setMaxTokenSize(size_t maxTokenSize);
virtual void lex(Token* token);
......@@ -50,6 +51,7 @@ class Tokenizer : public Lexer
void* mHandle; // Scanner handle.
Context mContext; // Scanner extra.
size_t mMaxTokenSize; // Maximum token size
};
} // namespace pp
......
......@@ -24,7 +24,6 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
%{
#include "Tokenizer.h"
#include "length_limits.h"
#include "DiagnosticsBase.h"
#include "Token.h"
......@@ -298,14 +297,19 @@ void Tokenizer::setLineNumber(int line)
yyset_lineno(line, mHandle);
}
void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
{
mMaxTokenSize = maxTokenSize;
}
void Tokenizer::lex(Token* token)
{
token->type = yylex(&token->text, &token->location, mHandle);
if (token->text.size() > GetGlobalMaxTokenSize())
if (token->text.size() > mMaxTokenSize)
{
mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
token->location, token->text);
token->text.erase(GetGlobalMaxTokenSize());
token->text.erase(mMaxTokenSize);
}
token->flags = 0;
......
......@@ -24,7 +24,7 @@
#include "compiler/translator/timing/RestrictVertexShaderTiming.h"
#include "third_party/compiler/ArrayBoundsClamper.h"
bool isWebGLBasedSpec(ShShaderSpec spec)
bool IsWebGLBasedSpec(ShShaderSpec spec)
{
return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
}
......@@ -34,7 +34,7 @@ size_t GetGlobalMaxTokenSize()
TParseContext *parseContext = GetGlobalParseContext();
// WebGL defines a max token legnth of 256, while ES2 leaves max token
// size undefined. ES3 defines a max size of 1024 characters.
if (isWebGLBasedSpec(parseContext->shaderSpec))
if (IsWebGLBasedSpec(parseContext->shaderSpec))
{
return 256;
}
......@@ -149,7 +149,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
return true;
// If compiling for WebGL, validate loop and indexing as well.
if (isWebGLBasedSpec(shaderSpec))
if (IsWebGLBasedSpec(shaderSpec))
compileOptions |= SH_VALIDATE_LOOP_INDEXING;
// First string is path of source file if flag is set. The actual source follows.
......@@ -392,14 +392,14 @@ bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
// Output any errors first.
bool success = enforceFragmentShaderTimingRestrictions(graph);
// Then, output the dependency graph.
if (outputGraph)
{
TDependencyGraphOutput output(infoSink.info);
output.outputAllSpanningTrees(graph);
}
return success;
}
else
......
......@@ -435,7 +435,7 @@ bool TParseContext::reservedErrorCheck(const TSourceLoc& line, const TString& id
error(line, reservedErrMsg, "gl_");
return true;
}
if (isWebGLBasedSpec(shaderSpec)) {
if (IsWebGLBasedSpec(shaderSpec)) {
if (identifier.compare(0, 6, "webgl_") == 0) {
error(line, reservedErrMsg, "webgl_");
return true;
......@@ -2029,7 +2029,7 @@ const int kWebGLMaxStructNesting = 4;
bool TParseContext::structNestingErrorCheck(const TSourceLoc& line, const TField& field)
{
if (!isWebGLBasedSpec(shaderSpec)) {
if (!IsWebGLBasedSpec(shaderSpec)) {
return false;
}
......
......@@ -33,7 +33,7 @@ class TranslatorHLSL;
// Helper function to identify specs that are based on the WebGL spec,
// like the CSS Shaders spec.
//
bool isWebGLBasedSpec(ShShaderSpec spec);
bool IsWebGLBasedSpec(ShShaderSpec spec);
//
// The base class used to back handles returned to the driver.
......
......@@ -12,7 +12,7 @@
#include "GLSLANG/ShaderLang.h"
#include "compiler/translator/InitializeDll.h"
#include "compiler/preprocessor/length_limits.h"
#include "compiler/translator/length_limits.h"
#include "compiler/translator/ShHandle.h"
#include "compiler/translator/TranslatorHLSL.h"
#include "compiler/translator/VariablePacker.h"
......
......@@ -40,6 +40,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
#include "compiler/translator/ParseContext.h"
#include "compiler/preprocessor/Token.h"
#include "compiler/translator/util.h"
#include "compiler/translator/length_limits.h"
#include "glslang_tab.h"
/* windows only pragma */
......@@ -550,6 +551,8 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
if (context->fragmentPrecisionHigh)
context->preprocessor.predefineMacro("GL_FRAGMENT_PRECISION_HIGH", 1);
context->preprocessor.setMaxTokenSize(GetGlobalMaxTokenSize());
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment