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

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

Issue 11316354: Re-apply "Move the handling of operator[] into the new interceptors." (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [String]. The compiler recognizes this 8 * The interceptor class for [String]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 hash = JS('int', '# ^ (# >> 6)', hash, hash); 156 hash = JS('int', '# ^ (# >> 6)', hash, hash);
157 } 157 }
158 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); 158 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
159 hash = JS('int', '# ^ (# >> 11)', hash, hash); 159 hash = JS('int', '# ^ (# >> 11)', hash, hash);
160 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); 160 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
161 } 161 }
162 162
163 Type get runtimeType => String; 163 Type get runtimeType => String;
164 164
165 int get length => JS('int', r'#.length', this); 165 int get length => JS('int', r'#.length', this);
166
167 String operator [](int index) {
168 if (index is !int) throw new ArgumentError(index);
169 if (index >= length || index < 0) throw new RangeError.value(index);
170 return JS('String', '#[#]', this, index);
171 }
166 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698