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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/scanner/token.dart

Issue 17569004: Implement hashCode on objects stored in a set or used as map keys. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with TOT Created 7 years, 5 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
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 part of scanner; 5 part of scanner;
6 6
7 const int EOF_TOKEN = 0; 7 const int EOF_TOKEN = 0;
8 8
9 const int KEYWORD_TOKEN = $k; 9 const int KEYWORD_TOKEN = $k;
10 const int IDENTIFIER_TOKEN = $a; 10 const int IDENTIFIER_TOKEN = $a;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 */ 143 */
144 int get slowCharCount { 144 int get slowCharCount {
145 if (info == BAD_INPUT_INFO) { 145 if (info == BAD_INPUT_INFO) {
146 // This is a token that wraps around an error message. Return 1 146 // This is a token that wraps around an error message. Return 1
147 // instead of the size of the length of the error message. 147 // instead of the size of the length of the error message.
148 return 1; 148 return 1;
149 } else { 149 } else {
150 return slowToString().length; 150 return slowToString().length;
151 } 151 }
152 } 152 }
153
154 int get hashCode => computeHashCode(charOffset, info, value);
153 } 155 }
154 156
155 /** 157 /**
156 * A keyword token. 158 * A keyword token.
157 */ 159 */
158 class KeywordToken extends Token { 160 class KeywordToken extends Token {
159 final Keyword value; 161 final Keyword value;
160 String get stringValue => value.syntax; 162 String get stringValue => value.syntax;
161 163
162 KeywordToken(Keyword value, int charOffset) 164 KeywordToken(Keyword value, int charOffset)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 bool isMinusOperator(String value) => identical(value, '-'); 307 bool isMinusOperator(String value) => identical(value, '-');
306 308
307 class PrecedenceInfo { 309 class PrecedenceInfo {
308 final SourceString value; 310 final SourceString value;
309 final int precedence; 311 final int precedence;
310 final int kind; 312 final int kind;
311 313
312 const PrecedenceInfo(this.value, this.precedence, this.kind); 314 const PrecedenceInfo(this.value, this.precedence, this.kind);
313 315
314 toString() => 'PrecedenceInfo($value, $precedence, $kind)'; 316 toString() => 'PrecedenceInfo($value, $precedence, $kind)';
317
318 int get hashCode => computeHashCode(value, precedence, kind);
315 } 319 }
316 320
317 // TODO(ahe): The following are not tokens in Dart. 321 // TODO(ahe): The following are not tokens in Dart.
318 const PrecedenceInfo BACKPING_INFO = 322 const PrecedenceInfo BACKPING_INFO =
319 const PrecedenceInfo(const SourceString('`'), 0, BACKPING_TOKEN); 323 const PrecedenceInfo(const SourceString('`'), 0, BACKPING_TOKEN);
320 const PrecedenceInfo BACKSLASH_INFO = 324 const PrecedenceInfo BACKSLASH_INFO =
321 const PrecedenceInfo(const SourceString('\\'), 0, BACKSLASH_TOKEN); 325 const PrecedenceInfo(const SourceString('\\'), 0, BACKSLASH_TOKEN);
322 const PrecedenceInfo PERIOD_PERIOD_PERIOD_INFO = 326 const PrecedenceInfo PERIOD_PERIOD_PERIOD_INFO =
323 const PrecedenceInfo(const SourceString('...'), 0, 327 const PrecedenceInfo(const SourceString('...'), 0,
324 PERIOD_PERIOD_PERIOD_TOKEN); 328 PERIOD_PERIOD_PERIOD_TOKEN);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 525
522 const PrecedenceInfo HEXADECIMAL_INFO = 526 const PrecedenceInfo HEXADECIMAL_INFO =
523 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 527 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
524 528
525 const PrecedenceInfo COMMENT_INFO = 529 const PrecedenceInfo COMMENT_INFO =
526 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); 530 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN);
527 531
528 // For reporting lexical errors. 532 // For reporting lexical errors.
529 const PrecedenceInfo ERROR_INFO = 533 const PrecedenceInfo ERROR_INFO =
530 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); 534 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698