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

Side by Side Diff: lib/compiler/implementation/scanner/string_scanner.dart

Issue 11191078: Make hashCode a getter and not a method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 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 * Scanner that reads from a String and creates tokens that points to 6 * Scanner that reads from a String and creates tokens that points to
7 * substrings. 7 * substrings.
8 */ 8 */
9 class StringScanner extends ArrayBasedScanner<SourceString> { 9 class StringScanner extends ArrayBasedScanner<SourceString> {
10 final String string; 10 final String string;
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 class SubstringWrapper implements SourceString { 37 class SubstringWrapper implements SourceString {
38 final String internalString; 38 final String internalString;
39 final int begin; 39 final int begin;
40 final int end; 40 final int end;
41 41
42 const SubstringWrapper(String this.internalString, 42 const SubstringWrapper(String this.internalString,
43 int this.begin, int this.end); 43 int this.begin, int this.end);
44 44
45 int hashCode() => slowToString().hashCode(); 45 int get hashCode => slowToString().hashCode;
46 46
47 bool operator ==(other) { 47 bool operator ==(other) {
48 return other is SourceString && slowToString() == other.slowToString(); 48 return other is SourceString && slowToString() == other.slowToString();
49 } 49 }
50 50
51 void printOn(StringBuffer sb) { 51 void printOn(StringBuffer sb) {
52 sb.add(internalString.substring(begin, end)); 52 sb.add(internalString.substring(begin, end));
53 } 53 }
54 54
55 String slowToString() => internalString.substring(begin, end); 55 String slowToString() => internalString.substring(begin, end);
(...skipping 10 matching lines...) Expand all
66 assert(0 <= terminal); 66 assert(0 <= terminal);
67 assert(initial + terminal <= internalString.length); 67 assert(initial + terminal <= internalString.length);
68 return new SubstringWrapper(internalString, 68 return new SubstringWrapper(internalString,
69 begin + initial, end - terminal); 69 begin + initial, end - terminal);
70 } 70 }
71 71
72 bool isEmpty() => begin == end; 72 bool isEmpty() => begin == end;
73 73
74 bool isPrivate() => !isEmpty() && identical(internalString.charCodeAt(begin), $_); 74 bool isPrivate() => !isEmpty() && identical(internalString.charCodeAt(begin), $_);
75 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698