Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: src/scanner-base.h

Issue 6759025: Version 3.2.6 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/scanner.cc ('k') | src/scanner-base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const uc16* buffer_cursor_; 116 const uc16* buffer_cursor_;
117 const uc16* buffer_end_; 117 const uc16* buffer_end_;
118 unsigned pos_; 118 unsigned pos_;
119 }; 119 };
120 120
121 121
122 class ScannerConstants { 122 class ScannerConstants {
123 // --------------------------------------------------------------------- 123 // ---------------------------------------------------------------------
124 // Constants used by scanners. 124 // Constants used by scanners.
125 public: 125 public:
126 ScannerConstants() {}
126 typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder; 127 typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder;
127 128
128 StaticResource<Utf8Decoder>* utf8_decoder() { 129 StaticResource<Utf8Decoder>* utf8_decoder() {
129 return &utf8_decoder_; 130 return &utf8_decoder_;
130 } 131 }
131 132
132 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); } 133 bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); }
133 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); } 134 bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); }
134 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); } 135 bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); }
135 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); } 136 bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); }
136 137
137 bool IsIdentifier(unibrow::CharacterStream* buffer); 138 bool IsIdentifier(unibrow::CharacterStream* buffer);
138 139
139 private: 140 private:
140 ScannerConstants() {}
141 141
142 unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart; 142 unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart;
143 unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart; 143 unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart;
144 unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator; 144 unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator;
145 unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace; 145 unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace;
146 StaticResource<Utf8Decoder> utf8_decoder_; 146 StaticResource<Utf8Decoder> utf8_decoder_;
147 147
148 friend class Isolate;
149 DISALLOW_COPY_AND_ASSIGN(ScannerConstants); 148 DISALLOW_COPY_AND_ASSIGN(ScannerConstants);
150 }; 149 };
151 150
152 // ---------------------------------------------------------------------------- 151 // ----------------------------------------------------------------------------
153 // LiteralBuffer - Collector of chars of literals. 152 // LiteralBuffer - Collector of chars of literals.
154 153
155 class LiteralBuffer { 154 class LiteralBuffer {
156 public: 155 public:
157 LiteralBuffer() : is_ascii_(true), position_(0), backing_store_() { } 156 LiteralBuffer() : is_ascii_(true), position_(0), backing_store_() { }
158 157
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 public: 265 public:
267 explicit LiteralScope(Scanner* self); 266 explicit LiteralScope(Scanner* self);
268 ~LiteralScope(); 267 ~LiteralScope();
269 void Complete(); 268 void Complete();
270 269
271 private: 270 private:
272 Scanner* scanner_; 271 Scanner* scanner_;
273 bool complete_; 272 bool complete_;
274 }; 273 };
275 274
276 explicit Scanner(Isolate* isolate); 275 explicit Scanner(ScannerConstants* scanner_contants);
277 276
278 // Returns the current token again. 277 // Returns the current token again.
279 Token::Value current_token() { return current_.token; } 278 Token::Value current_token() { return current_.token; }
280 279
281 // One token look-ahead (past the token returned by Next()). 280 // One token look-ahead (past the token returned by Next()).
282 Token::Value peek() const { return next_.token; } 281 Token::Value peek() const { return next_.token; }
283 282
284 struct Location { 283 struct Location {
285 Location(int b, int e) : beg_pos(b), end_pos(e) { } 284 Location(int b, int e) : beg_pos(b), end_pos(e) { }
286 Location() : beg_pos(0), end_pos(0) { } 285 Location() : beg_pos(0), end_pos(0) { }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 void Complete() { 466 void Complete() {
468 scanner_->TerminateLiteral(); 467 scanner_->TerminateLiteral();
469 complete_ = true; 468 complete_ = true;
470 } 469 }
471 470
472 private: 471 private:
473 JavaScriptScanner* scanner_; 472 JavaScriptScanner* scanner_;
474 bool complete_; 473 bool complete_;
475 }; 474 };
476 475
477 explicit JavaScriptScanner(Isolate* isolate); 476 explicit JavaScriptScanner(ScannerConstants* scanner_contants);
478 477
479 // Returns the next token. 478 // Returns the next token.
480 Token::Value Next(); 479 Token::Value Next();
481 480
482 // Returns true if there was a line terminator before the peek'ed token. 481 // Returns true if there was a line terminator before the peek'ed token.
483 bool has_line_terminator_before_next() const { 482 bool has_line_terminator_before_next() const {
484 return has_line_terminator_before_next_; 483 return has_line_terminator_before_next_;
485 } 484 }
486 485
487 // Scans the input as a regular expression pattern, previous 486 // Scans the input as a regular expression pattern, previous
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // keyword with the current prefix). 655 // keyword with the current prefix).
657 const char* keyword_; 656 const char* keyword_;
658 int counter_; 657 int counter_;
659 Token::Value keyword_token_; 658 Token::Value keyword_token_;
660 }; 659 };
661 660
662 661
663 } } // namespace v8::internal 662 } } // namespace v8::internal
664 663
665 #endif // V8_SCANNER_BASE_H_ 664 #endif // V8_SCANNER_BASE_H_
OLDNEW
« no previous file with comments | « src/scanner.cc ('k') | src/scanner-base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698