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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/lib/coreimpl_patch.dart
diff --git a/lib/compiler/implementation/lib/coreimpl_patch.dart b/lib/compiler/implementation/lib/coreimpl_patch.dart
index d48cafe2a2e68d31c025f486d57a4788a957aaa8..ee13f7c44ce8b8c1e383f529b85552a67c824373 100644
--- a/lib/compiler/implementation/lib/coreimpl_patch.dart
+++ b/lib/compiler/implementation/lib/coreimpl_patch.dart
@@ -199,3 +199,36 @@ class _AllMatchesIterator implements Iterator<Match> {
}
}
}
+
+// Patch for Expando implementation.
+// TODO(ager): Split out into expando_patch.dart and allow #source in
+// patch files?
+patch class ExpandoImplementation<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 final String _KEY_PROPERTY_NAME = 'expando\$key';
+ static final String _EXPANDO_PROPERTY_NAME = 'expando\$values';
+ static int _keyCount = 0;
+}

Powered by Google App Engine
This is Rietveld 408576698