| OLD | NEW |
| 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:coreimpl classes. | 5 // Patch file for dart:coreimpl classes. |
| 6 | 6 |
| 7 // Patch for 'print' function. | 7 // Patch for 'print' function. |
| 8 patch class PrintImplementation { | 8 patch class PrintImplementation { |
| 9 patch static void print(var obj) { | 9 patch static void print(var obj) { |
| 10 if (obj is String) { | 10 if (obj is String) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // hidden global flag. | 269 // hidden global flag. |
| 270 _next = _re.firstMatch(_str); | 270 _next = _re.firstMatch(_str); |
| 271 if (_next == null) { | 271 if (_next == null) { |
| 272 _done = true; | 272 _done = true; |
| 273 return false; | 273 return false; |
| 274 } else { | 274 } else { |
| 275 return true; | 275 return true; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 |
| 280 // Patch for Expando implementation. |
| 281 // TODO(ager): Split out into expando_patch.dart and allow #source in |
| 282 // patch files? |
| 283 patch class ExpandoImplementation<T> { |
| 284 |
| 285 patch T operator[](Object object) { |
| 286 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); |
| 287 return (values === null) ? null : Primitives.getProperty(values, _getKey()); |
| 288 } |
| 289 |
| 290 patch void operator[]=(Object object, T value) { |
| 291 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); |
| 292 if (values === null) { |
| 293 values = new Object(); |
| 294 Primitives.setProperty(object, _EXPANDO_PROPERTY_NAME, values); |
| 295 } |
| 296 Primitives.setProperty(values, _getKey(), value); |
| 297 } |
| 298 |
| 299 String _getKey() { |
| 300 String key = Primitives.getProperty(this, _KEY_PROPERTY_NAME); |
| 301 if (key === null) { |
| 302 key = "expando\$key\$${_keyCount++}"; |
| 303 Primitives.setProperty(this, _KEY_PROPERTY_NAME, key); |
| 304 } |
| 305 return key; |
| 306 } |
| 307 |
| 308 static const String _KEY_PROPERTY_NAME = 'expando\$key'; |
| 309 static const String _EXPANDO_PROPERTY_NAME = 'expando\$values'; |
| 310 static int _keyCount = 0; |
| 311 } |
| OLD | NEW |