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

Side by Side Diff: runtime/lib/string.dart

Issue 8383029: Implement external strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fully displace external string metadata Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * [StringBase] contains common methods used by concrete String implementations, 6 * [StringBase] contains common methods used by concrete String implementations,
7 * e.g., OneByteString. 7 * e.g., OneByteString.
8 */ 8 */
9 class StringBase { 9 class StringBase {
10 10
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // Checks for one-byte whitespaces only. 407 // Checks for one-byte whitespaces only.
408 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid 408 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
409 // whitespaces. Add checking for multi-byte whitespace codepoints. 409 // whitespaces. Add checking for multi-byte whitespace codepoints.
410 bool _isWhitespace(int codePoint) { 410 bool _isWhitespace(int codePoint) {
411 return 411 return
412 (codePoint === 32) || // Space. 412 (codePoint === 32) || // Space.
413 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 413 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
414 } 414 }
415 } 415 }
416 416
417
418 class ExternalOneByteString extends StringBase implements String {
419 // Checks for one-byte whitespaces only.
420 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
421 // whitespaces for one byte strings.
422 bool _isWhitespace(int codePoint) {
Ivan Posva 2011/11/18 19:36:44 Shouldn't this be factored out into a private stat
cshapiro 2011/11/19 01:08:29 Yes. My intention was to replace all of these met
423 return
424 (codePoint === 32) || // Space.
425 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
426 }
427 }
428
429
430 class ExternalTwoByteString extends StringBase implements String {
431 // Checks for one-byte whitespaces only.
432 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
433 // whitespaces. Add checking for multi-byte whitespace codepoints.
434 bool _isWhitespace(int codePoint) {
435 return
436 (codePoint === 32) || // Space.
437 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
438 }
439 }
440
441
442 class ExternalFourByteString extends StringBase implements String {
443 // Checks for one-byte whitespaces only.
444 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
445 // whitespaces. Add checking for multi-byte whitespace codepoints.
446 bool _isWhitespace(int codePoint) {
447 return
448 (codePoint === 32) || // Space.
449 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
450 }
451 }
452
453
417 class _StringMatch implements Match { 454 class _StringMatch implements Match {
418 const _StringMatch(int this._start, 455 const _StringMatch(int this._start,
419 String this.str, 456 String this.str,
420 String this.pattern); 457 String this.pattern);
421 458
422 int start() => _start; 459 int start() => _start;
423 int end() => _start + pattern.length; 460 int end() => _start + pattern.length;
424 String operator[](int g) => group(g); 461 String operator[](int g) => group(g);
425 int groupCount() => 0; 462 int groupCount() => 0;
426 463
427 String group(int group) { 464 String group(int group) {
428 if (group != 0) { 465 if (group != 0) {
429 throw new IndexOutOfRangeException(group); 466 throw new IndexOutOfRangeException(group);
430 } 467 }
431 return pattern; 468 return pattern;
432 } 469 }
433 470
434 List<String> groups(List<int> groups) { 471 List<String> groups(List<int> groups) {
435 List<String> result = new List<String>(); 472 List<String> result = new List<String>();
436 for (int g in groups) { 473 for (int g in groups) {
437 result.add(group(g)); 474 result.add(group(g));
438 } 475 }
439 return result; 476 return result;
440 } 477 }
441 478
442 final int _start; 479 final int _start;
443 final String str; 480 final String str;
444 final String pattern; 481 final String pattern;
445 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698