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

Unified Diff: src/scanner.cc

Issue 316173002: Handle "//# sourceURL" comments in the Parser instead of the JS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: oops Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« src/parser.cc ('K') | « src/scanner.h ('k') | src/vector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index 0265a8fa7810a797361e202f05dfd5ff045d11d1..e345e8353adc4e5a07db7b2c6c97465383715837 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -209,6 +209,7 @@ Token::Value Scanner::Next() {
current_ = next_;
has_line_terminator_before_next_ = false;
has_multiline_comment_before_next_ = false;
+ has_source_map_comment_ = false;
if (static_cast<unsigned>(c0_) <= 0x7f) {
Token::Value token = static_cast<Token::Value>(one_char_tokens[c0_]);
if (token != Token::ILLEGAL) {
@@ -294,6 +295,18 @@ Token::Value Scanner::SkipSingleLineComment() {
}
+Token::Value Scanner::SkipSourceMapComment() {
+ Advance();
+ source_map_comment_.Reset();
+ while (c0_ >= 0 && !unicode_cache_->IsLineTerminator(c0_)) {
+ source_map_comment_.AddChar(c0_);
+ Advance();
+ }
+ has_source_map_comment_ = true;
+ return Token::WHITESPACE;
+}
+
+
Token::Value Scanner::SkipMultiLineComment() {
ASSERT(c0_ == '*');
Advance();
@@ -458,7 +471,14 @@ void Scanner::Scan() {
// / // /* /=
Advance();
if (c0_ == '/') {
- token = SkipSingleLineComment();
+ Advance();
+ if (c0_ == '@' || c0_ == '#') {
+ Advance();
+ token = SkipSourceMapComment();
yurys 2014/06/05 13:55:21 I believe we should consider only sourceURL that a
+ } else {
+ PushBack(c0_);
+ token = SkipSingleLineComment();
+ }
} else if (c0_ == '*') {
token = SkipMultiLineComment();
} else if (c0_ == '=') {
@@ -1093,6 +1113,17 @@ bool Scanner::ScanRegExpFlags() {
}
+Handle<String> Scanner::AllocateInternalizedSourceMapComment(Isolate* isolate) {
+ if (source_map_comment_.is_one_byte()) {
+ return isolate->factory()->InternalizeOneByteString(
+ source_map_comment_.one_byte_literal());
+ } else {
+ return isolate->factory()->InternalizeTwoByteString(
+ source_map_comment_.two_byte_literal());
+ }
+}
+
+
Handle<String> Scanner::AllocateNextLiteralString(Isolate* isolate,
PretenureFlag tenured) {
if (is_next_literal_one_byte()) {
« src/parser.cc ('K') | « src/scanner.h ('k') | src/vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698