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

Side by Side Diff: src/scanner.cc

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 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.h ('k') | src/scopes.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 next_.location.end_pos = pos + 1; 239 next_.location.end_pos = pos + 1;
240 Advance(); 240 Advance();
241 return current_.token; 241 return current_.token;
242 } 242 }
243 } 243 }
244 Scan(); 244 Scan();
245 return current_.token; 245 return current_.token;
246 } 246 }
247 247
248 248
249 // TODO(yangguo): check whether this is actually necessary. 249 static inline bool IsByteOrderMark(uc32 c) {
250 static inline bool IsLittleEndianByteOrderMark(uc32 c) {
251 // The Unicode value U+FFFE is guaranteed never to be assigned as a 250 // The Unicode value U+FFFE is guaranteed never to be assigned as a
252 // Unicode character; this implies that in a Unicode context the 251 // Unicode character; this implies that in a Unicode context the
253 // 0xFF, 0xFE byte pattern can only be interpreted as the U+FEFF 252 // 0xFF, 0xFE byte pattern can only be interpreted as the U+FEFF
254 // character expressed in little-endian byte order (since it could 253 // character expressed in little-endian byte order (since it could
255 // not be a U+FFFE character expressed in big-endian byte 254 // not be a U+FFFE character expressed in big-endian byte
256 // order). Nevertheless, we check for it to be compatible with 255 // order). Nevertheless, we check for it to be compatible with
257 // Spidermonkey. 256 // Spidermonkey.
258 return c == 0xFFFE; 257 return c == 0xFEFF || c == 0xFFFE;
259 } 258 }
260 259
261 260
262 bool Scanner::SkipWhiteSpace() { 261 bool Scanner::SkipWhiteSpace() {
263 int start_position = source_pos(); 262 int start_position = source_pos();
264 263
265 while (true) { 264 while (true) {
266 while (true) { 265 // We treat byte-order marks (BOMs) as whitespace for better
267 // Advance as long as character is a WhiteSpace or LineTerminator. 266 // compatibility with Spidermonkey and other JavaScript engines.
268 // Remember if the latter is the case. 267 while (unicode_cache_->IsWhiteSpace(c0_) || IsByteOrderMark(c0_)) {
268 // IsWhiteSpace() includes line terminators!
269 if (unicode_cache_->IsLineTerminator(c0_)) { 269 if (unicode_cache_->IsLineTerminator(c0_)) {
270 // Ignore line terminators, but remember them. This is necessary
271 // for automatic semicolon insertion.
270 has_line_terminator_before_next_ = true; 272 has_line_terminator_before_next_ = true;
271 } else if (!unicode_cache_->IsWhiteSpace(c0_) &&
272 !IsLittleEndianByteOrderMark(c0_)) {
273 break;
274 } 273 }
275 Advance(); 274 Advance();
276 } 275 }
277 276
278 // If there is an HTML comment end '-->' at the beginning of a 277 // If there is an HTML comment end '-->' at the beginning of a
279 // line (with only whitespace in front of it), we treat the rest 278 // line (with only whitespace in front of it), we treat the rest
280 // of the line as a comment. This is in line with the way 279 // of the line as a comment. This is in line with the way
281 // SpiderMonkey handles it. 280 // SpiderMonkey handles it.
282 if (c0_ == '-' && has_line_terminator_before_next_) { 281 if (c0_ == '-' && has_line_terminator_before_next_) {
283 Advance(); 282 Advance();
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 } 1242 }
1244 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); 1243 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u));
1245 } 1244 }
1246 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); 1245 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f));
1247 1246
1248 backing_store_.AddBlock(bytes); 1247 backing_store_.AddBlock(bytes);
1249 return backing_store_.EndSequence().start(); 1248 return backing_store_.EndSequence().start();
1250 } 1249 }
1251 1250
1252 } } // namespace v8::internal 1251 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698