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

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

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 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-base.h ('k') | src/serialize.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 23 matching lines...) Expand all
34 some classes (NativeAllocationChecker) are moved into isolate.h 34 some classes (NativeAllocationChecker) are moved into isolate.h
35 #include "../include/v8stdint.h" 35 #include "../include/v8stdint.h"
36 */ 36 */
37 #include "scanner-base.h" 37 #include "scanner-base.h"
38 #include "char-predicates-inl.h" 38 #include "char-predicates-inl.h"
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 // ---------------------------------------------------------------------------- 43 // ----------------------------------------------------------------------------
44 // UTF16Buffer
45
46 UTF16Buffer::UTF16Buffer()
47 : pos_(0), end_(kNoEndPosition) { }
48
49 // ----------------------------------------------------------------------------
50 // LiteralCollector 44 // LiteralCollector
51 45
52 LiteralCollector::LiteralCollector() 46 LiteralCollector::LiteralCollector()
53 : buffer_(kInitialCapacity), recording_(false) { } 47 : buffer_(kInitialCapacity), recording_(false) { }
54 48
55 49
56 LiteralCollector::~LiteralCollector() {} 50 LiteralCollector::~LiteralCollector() {}
57 51
58 52
59 void LiteralCollector::AddCharSlow(uc32 c) { 53 void LiteralCollector::AddCharSlow(uc32 c) {
(...skipping 20 matching lines...) Expand all
80 if (!kIsIdentifierPart.get(buffer->GetNext())) { 74 if (!kIsIdentifierPart.get(buffer->GetNext())) {
81 return false; 75 return false;
82 } 76 }
83 } 77 }
84 return true; 78 return true;
85 } 79 }
86 80
87 // ---------------------------------------------------------------------------- 81 // ----------------------------------------------------------------------------
88 // Scanner 82 // Scanner
89 83
90 Scanner::Scanner() 84 Scanner::Scanner(Isolate* isolate)
91 : scanner_constants_(Isolate::Current()->scanner_constants()), 85 : scanner_constants_(isolate->scanner_constants()) {
92 source_(NULL) {
93 } 86 }
94 87
95 88
96 uc32 Scanner::ScanHexEscape(uc32 c, int length) { 89 uc32 Scanner::ScanHexEscape(uc32 c, int length) {
97 ASSERT(length <= 4); // prevent overflow 90 ASSERT(length <= 4); // prevent overflow
98 91
99 uc32 digits[4]; 92 uc32 digits[4];
100 uc32 x = 0; 93 uc32 x = 0;
101 for (int i = 0; i < length; i++) { 94 for (int i = 0; i < length; i++) {
102 digits[i] = c0_; 95 digits[i] = c0_;
(...skipping 30 matching lines...) Expand all
133 x = nx; 126 x = nx;
134 Advance(); 127 Advance();
135 } 128 }
136 return x; 129 return x;
137 } 130 }
138 131
139 132
140 // ---------------------------------------------------------------------------- 133 // ----------------------------------------------------------------------------
141 // JavaScriptScanner 134 // JavaScriptScanner
142 135
143 JavaScriptScanner::JavaScriptScanner(ScannerConstants* scanner_constants) 136 JavaScriptScanner::JavaScriptScanner(Isolate* isolate) : Scanner(isolate) {}
144 : scanner_constants_(scanner_constants),
145 has_line_terminator_before_next_(false) {}
146 137
147 138
148 Token::Value JavaScriptScanner::Next() { 139 Token::Value JavaScriptScanner::Next() {
149 current_ = next_; 140 current_ = next_;
150 has_line_terminator_before_next_ = false; 141 has_line_terminator_before_next_ = false;
151 Scan(); 142 Scan();
152 return current_.token; 143 return current_.token;
153 } 144 }
154 145
155 146
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Continue scanning for tokens as long as we're just skipping 486 // Continue scanning for tokens as long as we're just skipping
496 // whitespace. 487 // whitespace.
497 } while (token == Token::WHITESPACE); 488 } while (token == Token::WHITESPACE);
498 489
499 next_.location.end_pos = source_pos(); 490 next_.location.end_pos = source_pos();
500 next_.token = token; 491 next_.token = token;
501 } 492 }
502 493
503 494
504 void JavaScriptScanner::SeekForward(int pos) { 495 void JavaScriptScanner::SeekForward(int pos) {
505 source_->SeekForward(pos - 1); 496 // After this call, we will have the token at the given position as
506 Advance(); 497 // the "next" token. The "current" token will be invalid.
507 // This function is only called to seek to the location 498 if (pos == next_.location.beg_pos) return;
508 // of the end of a function (at the "}" token). It doesn't matter 499 int current_pos = source_pos();
509 // whether there was a line terminator in the part we skip. 500 ASSERT_EQ(next_.location.end_pos, current_pos);
510 has_line_terminator_before_next_ = false; 501 // Positions inside the lookahead token aren't supported.
502 ASSERT(pos >= current_pos);
503 if (pos != current_pos) {
504 source_->SeekForward(pos - source_->pos());
505 Advance();
506 // This function is only called to seek to the location
507 // of the end of a function (at the "}" token). It doesn't matter
508 // whether there was a line terminator in the part we skip.
509 has_line_terminator_before_next_ = false;
510 }
511 Scan(); 511 Scan();
512 } 512 }
513 513
514 514
515 void JavaScriptScanner::ScanEscape() { 515 void JavaScriptScanner::ScanEscape() {
516 uc32 c = c0_; 516 uc32 c = c0_;
517 Advance(); 517 Advance();
518 518
519 // Skip escaped newlines. 519 // Skip escaped newlines.
520 if (scanner_constants_->IsLineTerminator(c)) { 520 if (scanner_constants_->IsLineTerminator(c)) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; 913 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return;
914 break; 914 break;
915 case UNMATCHABLE: 915 case UNMATCHABLE:
916 break; 916 break;
917 } 917 }
918 // On fallthrough, it's a failure. 918 // On fallthrough, it's a failure.
919 state_ = UNMATCHABLE; 919 state_ = UNMATCHABLE;
920 } 920 }
921 921
922 } } // namespace v8::internal 922 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner-base.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698