| Index: lib/compiler/implementation/lib/core_patch.dart
|
| diff --git a/lib/compiler/implementation/lib/core_patch.dart b/lib/compiler/implementation/lib/core_patch.dart
|
| index 0f6c7d1e82e012b31b3291bda2da06fa51a89b85..4e22ea13ab51d931a8a572ffcbaa52b8af3d9d9f 100644
|
| --- a/lib/compiler/implementation/lib/core_patch.dart
|
| +++ b/lib/compiler/implementation/lib/core_patch.dart
|
| @@ -14,3 +14,35 @@ patch class Object {
|
| throw new NoSuchMethodError(this, name, args);
|
| }
|
| }
|
| +
|
| +
|
| +// Patch for Expando implementation.
|
| +patch class Expando<T> {
|
| +
|
| + patch T operator[](Object object) {
|
| + var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
|
| + return (values === null) ? null : Primitives.getProperty(values, _getKey());
|
| + }
|
| +
|
| + patch void operator[]=(Object object, T value) {
|
| + var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
|
| + if (values === null) {
|
| + values = new Object();
|
| + Primitives.setProperty(object, _EXPANDO_PROPERTY_NAME, values);
|
| + }
|
| + Primitives.setProperty(values, _getKey(), value);
|
| + }
|
| +
|
| + String _getKey() {
|
| + String key = Primitives.getProperty(this, _KEY_PROPERTY_NAME);
|
| + if (key === null) {
|
| + key = "expando\$key\$${_keyCount++}";
|
| + Primitives.setProperty(this, _KEY_PROPERTY_NAME, key);
|
| + }
|
| + return key;
|
| + }
|
| +
|
| + static const String _KEY_PROPERTY_NAME = 'expando\$key';
|
| + static const String _EXPANDO_PROPERTY_NAME = 'expando\$values';
|
| + static int _keyCount = 0;
|
| +}
|
|
|