Revision: 17426
Author:   [email protected]
Date:     Tue Oct 29 12:11:21 2013 UTC
Log:      Experimental parser: don't hardcode 8-bit char type.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/50573003
http://code.google.com/p/v8/source/detail?r=17426

Modified:
 /branches/experimental/parser/src/lexer/lexer.h
 /branches/experimental/parser/src/lexer/lexer.re

=======================================
--- /branches/experimental/parser/src/lexer/lexer.h Fri Oct 25 11:59:14 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer.h Tue Oct 29 12:11:21 2013 UTC
@@ -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 @@
   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_;
=======================================
--- /branches/experimental/parser/src/lexer/lexer.re Mon Oct 28 11:25:37 2013 UTC +++ /branches/experimental/parser/src/lexer/lexer.re Tue Oct 29 12:11:21 2013 UTC
@@ -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 @@
   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 {
@@ -115,8 +94,6 @@
 #define PUSH_EOF_AND_RETURN() { send(Token::EOS); eof_ = true; return 1;}
#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),
@@ -170,7 +147,7 @@
   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 @@
   //  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 @@
     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