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

Side by Side Diff: lib/compiler/implementation/lib/coreimpl_patch.dart

Issue 10870064: Use patching for Expando so the implementation-specific files are not needed in the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding missing file Created 8 years, 4 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) 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 // Patch file for dart:core classes. 5 // Patch file for dart:core classes.
6 6
7 // Patch for Date implementation. 7 // Patch for Date implementation.
8 // TODO(ager): Split out into date_patch.dart and allow #source 8 // TODO(ager): Split out into date_patch.dart and allow #source
9 // in patch files? 9 // in patch files?
10 patch class DateImplementation { 10 patch class DateImplementation {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // hidden global flag. 192 // hidden global flag.
193 _next = _re.firstMatch(_str); 193 _next = _re.firstMatch(_str);
194 if (_next == null) { 194 if (_next == null) {
195 _done = true; 195 _done = true;
196 return false; 196 return false;
197 } else { 197 } else {
198 return true; 198 return true;
199 } 199 }
200 } 200 }
201 } 201 }
202
203 // Patch for Expando implementation.
204 // TODO(ager): Split out into expando_patch.dart and allow #source in
205 // patch files?
206 patch class ExpandoImplementation<T> {
207
208 patch T operator[](Object object) {
209 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
210 return (values === null) ? null : Primitives.getProperty(values, _getKey());
211 }
212
213 patch void operator[]=(Object object, T value) {
214 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
215 if (values === null) {
216 values = new Object();
217 Primitives.setProperty(object, _EXPANDO_PROPERTY_NAME, values);
218 }
219 Primitives.setProperty(values, _getKey(), value);
220 }
221
222 String _getKey() {
223 String key = Primitives.getProperty(this, _KEY_PROPERTY_NAME);
224 if (key === null) {
225 key = "expando\$key\$${_keyCount++}";
226 Primitives.setProperty(this, _KEY_PROPERTY_NAME, key);
227 }
228 return key;
229 }
230
231 static final String _KEY_PROPERTY_NAME = 'expando\$key';
232 static final String _EXPANDO_PROPERTY_NAME = 'expando\$values';
233 static int _keyCount = 0;
234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698