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/187140
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/preprocessor/Preprocessor.cpp b/src/compiler/preprocessor/Preprocessor.cpp
index 8536ed1..47e6000 100644
--- a/src/compiler/preprocessor/Preprocessor.cpp
+++ b/src/compiler/preprocessor/Preprocessor.cpp
@@ -110,4 +110,9 @@
     }
 }
 
+void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
+{
+    mImpl->tokenizer.setMaxTokenSize(maxTokenSize);
+}
+
 }  // namespace pp
diff --git a/src/compiler/preprocessor/Preprocessor.h b/src/compiler/preprocessor/Preprocessor.h
index 7b70180..76694a5 100644
--- a/src/compiler/preprocessor/Preprocessor.h
+++ b/src/compiler/preprocessor/Preprocessor.h
@@ -40,6 +40,9 @@
 
     void lex(Token* token);
 
+    // Set maximum preprocessor token size
+    void setMaxTokenSize(size_t maxTokenSize);
+
   private:
     PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
 
diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp
index 45130b3..25aefa9 100644
--- a/src/compiler/preprocessor/Tokenizer.cpp
+++ b/src/compiler/preprocessor/Tokenizer.cpp
@@ -540,7 +540,6 @@
 */
 
 #include "Tokenizer.h"
-#include "length_limits.h"
 
 #include "DiagnosticsBase.h"
 #include "Token.h"
@@ -2317,7 +2316,9 @@
 
 namespace pp {
 
-Tokenizer::Tokenizer(Diagnostics* diagnostics) : mHandle(0)
+Tokenizer::Tokenizer(Diagnostics* diagnostics)
+    : mHandle(0),
+      mMaxTokenSize(256)
 {
     mContext.diagnostics = diagnostics;
 }
@@ -2347,14 +2348,19 @@
     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;
diff --git a/src/compiler/preprocessor/Tokenizer.h b/src/compiler/preprocessor/Tokenizer.h
index 35a57a0..535dd12 100644
--- a/src/compiler/preprocessor/Tokenizer.h
+++ b/src/compiler/preprocessor/Tokenizer.h
@@ -40,6 +40,7 @@
 
     void setFileNumber(int file);
     void setLineNumber(int line);
+    void setMaxTokenSize(size_t maxTokenSize);
 
     virtual void lex(Token* token);
 
@@ -50,6 +51,7 @@
 
     void* mHandle;  // Scanner handle.
     Context mContext;  // Scanner extra.
+    size_t mMaxTokenSize; // Maximum token size
 };
 
 }  // namespace pp
diff --git a/src/compiler/preprocessor/Tokenizer.l b/src/compiler/preprocessor/Tokenizer.l
index 95120e7..ab9d99a 100644
--- a/src/compiler/preprocessor/Tokenizer.l
+++ b/src/compiler/preprocessor/Tokenizer.l
@@ -24,7 +24,6 @@
 
 %{
 #include "Tokenizer.h"
-#include "length_limits.h"
 
 #include "DiagnosticsBase.h"
 #include "Token.h"
@@ -298,14 +297,19 @@
     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;
diff --git a/src/compiler/preprocessor/length_limits.h b/src/compiler/preprocessor/length_limits.h
deleted file mode 100644
index fd90584..0000000
--- a/src/compiler/preprocessor/length_limits.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-//
-// length_limits.h
-//
-
-#if !defined(__LENGTH_LIMITS_H)
-#define __LENGTH_LIMITS_H 1
-
-// These constants are factored out from the rest of the headers to
-// make it easier to reference them from the compiler sources.
-
-size_t GetGlobalMaxTokenSize();
-
-#endif // !(defined(__LENGTH_LIMITS_H)