Reviewers: ulan,

Message:
Committed patchset #1 manually as r17426.

Description:
Experimental parser: don't hardcode 8-bit char type.

BUG=
[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=17426

Please review this at https://codereview.chromium.org/50573003/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/parser

Affected files (+32, -36 lines):
  M src/lexer/lexer.h
  M src/lexer/lexer.re


Index: src/lexer/lexer.h
diff --git a/src/lexer/lexer.h b/src/lexer/lexer.h
index 087b46c3ec884c791d9095c068f587dab8623eb5..c9b762302e162d6e1f2f9699db544960a61d9668 100644
--- a/src/lexer/lexer.h
+++ b/src/lexer/lexer.h
@@ -30,9 +30,28 @@
 #ifndef V8_LEXER_LEXER_H
 #define V8_LEXER_LEXER_H

+#if defined(WIN32)  // FIXME: does this work?
+
+typedef signed char   int8_t;
+typedef signed short  int16_t;
+typedef signed int   int32_t;
+
+typedef unsigned char  uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int  uint32_t;
+
+#else
+
+#include <stdint.h>
+#include <unistd.h>
+
+#endif  // defined(WIN32)
+
 #include "token.h"
 #include "flags.h"

+#define YYCTYPE uint8_t
+
 namespace v8 {
 namespace internal {

@@ -59,16 +78,16 @@ class PushScanner {
   int32_t state_;
   int32_t condition_;

-  uint8_t* limit_;
-  uint8_t* start_;
-  uint8_t* cursor_;
-  uint8_t* marker_;
+  YYCTYPE* limit_;
+  YYCTYPE* start_;
+  YYCTYPE* cursor_;
+  YYCTYPE* marker_;
   int real_start_;

-  uint8_t* buffer_;
-  uint8_t* buffer_end_;
+  YYCTYPE* buffer_;
+  YYCTYPE* buffer_end_;

-  uint8_t yych;
+  YYCTYPE yych;
   uint32_t yyaccept;

   bool just_seen_line_terminator_;
Index: src/lexer/lexer.re
diff --git a/src/lexer/lexer.re b/src/lexer/lexer.re
index 28f1dfc1f1f209f7b0f623290918cb4a0e339ad5..c7ab5763a03edc67c96506e2afae34e19ee09597 100644
--- a/src/lexer/lexer.re
+++ b/src/lexer/lexer.re
@@ -27,6 +27,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+#include "lexer.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -54,6 +56,7 @@
 #include "scopeinfo.h"
 #include "string-stream.h"

+#include "experimental-scanner.h"

 // TODO:
// - Run-time lexing modifications: harmony number literals, keywords depending
@@ -72,30 +75,6 @@ enum Condition {
   kConditionHtmlComment
 };

-#if defined(WIN32)
-
-  typedef signed char   int8_t;
-  typedef signed short  int16_t;
-  typedef signed int   int32_t;
-
-  typedef unsigned char  uint8_t;
-  typedef unsigned short uint16_t;
-  typedef unsigned int  uint32_t;
-
-#else
-
-#include <stdint.h>
-#include <unistd.h>
-
-#ifndef O_BINARY
-  #define O_BINARY 0
-#endif
-
-#endif //  defined(WIN32)
-
-#include "experimental-scanner.h"
-#include "lexer.h"
-
 using namespace v8::internal;

 namespace {
@@ -116,8 +95,6 @@ inline int HexValue(uc32 c) {
#define PUSH_LINE_TERMINATOR() { just_seen_line_terminator_ = true; SKIP(); } #define TERMINATE_ILLEGAL() { send(Token::ILLEGAL); send(Token::EOS); return 1; }

-#define YYCTYPE uint8_t
-
PushScanner::PushScanner(ExperimentalScanner* sink, UnicodeCache* unicode_cache)
 : unicode_cache_(unicode_cache),
   eof_(false),
@@ -170,7 +147,7 @@ void PushScanner::send(Token::Value token) {
   int end = (cursor_ - buffer_) + real_start_;
   if (FLAG_trace_lexer) {
     printf("got %s at (%d, %d): ", Token::Name(token), beg, end);
-    for (uint8_t* s = start_; s != cursor_; s++) printf("%c", (char)*s);
+    for (YYCTYPE* s = start_; s != cursor_; s++) printf("%c", (char)*s);
     printf(".\n");
   }
   just_seen_line_terminator_ = false;
@@ -192,7 +169,7 @@ uint32_t PushScanner::push(const void *input, int input_size) {
   //  its thing. Practically though, max_fill is never bigger than
   //  the longest keyword, so given our grammar, 32 is a safe bet.

-  uint8_t null[64];
+  YYCTYPE null[64];
   const int max_fill = 32;
   if (input_size < max_fill) { // FIXME: do something about this!!!
     eof_ = true;
@@ -221,7 +198,7 @@ uint32_t PushScanner::push(const void *input, int input_size) {
     size_t marker__offset = marker_ - buffer_;
     size_t cursor__offset = cursor_ - buffer_;

-    buffer_ = (uint8_t*)realloc(buffer_, needed);
+    buffer_ = (YYCTYPE*)realloc(buffer_, needed);
     buffer_end_ = needed + buffer_;

     marker_ = marker__offset + buffer_;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to