| Index: lib/compiler/implementation/scanner/token.dart
|
| diff --git a/lib/compiler/implementation/scanner/token.dart b/lib/compiler/implementation/scanner/token.dart
|
| index ddd921b074745f311777c71ec04380a0e8b2f4a4..4405d76878d5fbacea9fad2881816721bf437540 100644
|
| --- a/lib/compiler/implementation/scanner/token.dart
|
| +++ b/lib/compiler/implementation/scanner/token.dart
|
| @@ -126,7 +126,8 @@ class StringToken extends Token {
|
| String slowToString() => value.slowToString();
|
| }
|
|
|
| -interface SourceString extends Hashable, Iterable<int> default StringWrapper {
|
| +interface SourceString extends Comparable, Hashable, Iterable<int>
|
| + default StringWrapper {
|
| const SourceString(String string);
|
|
|
| void printOn(StringBuffer sb);
|
| @@ -146,6 +147,20 @@ interface SourceString extends Hashable, Iterable<int> default StringWrapper {
|
| bool isPrivate();
|
| }
|
|
|
| +int sourceStringCompare(SourceString string1, SourceString string2) {
|
| + Iterator<int> iterator1 = string1.iterator();
|
| + Iterator<int> iterator2 = string2.iterator();
|
| + while (iterator1.hasNext()) {
|
| + if (!iterator2.hasNext()) return 1;
|
| + int char1 = iterator1.next();
|
| + int char2 = iterator2.next();
|
| + int comparison = char1.compareTo(char2);
|
| + if (comparison != 0) return comparison;
|
| + }
|
| + if (iterator2.hasNext()) return -1;
|
| + return 0;
|
| +}
|
| +
|
| class StringWrapper implements SourceString {
|
| final String stringValue;
|
|
|
| @@ -153,6 +168,14 @@ class StringWrapper implements SourceString {
|
|
|
| int hashCode() => stringValue.hashCode();
|
|
|
| + int compareTo(SourceString other) {
|
| + if (other is StringWrapper) {
|
| + StringWrapper otherWrapper = other;
|
| + return stringValue.compareTo(otherWrapper.stringValue);
|
| + }
|
| + return sourceStringCompare(this, other);
|
| + }
|
| +
|
| bool operator ==(other) {
|
| return other is SourceString && toString() == other.slowToString();
|
| }
|
|
|