| 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: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 Loading... |
| 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 } |
| OLD | NEW |