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

Unified Diff: lib/compiler/implementation/lib/mockimpl.dart

Issue 10534089: Add experimental expando support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/mockimpl.dart
diff --git a/lib/compiler/implementation/lib/mockimpl.dart b/lib/compiler/implementation/lib/mockimpl.dart
index 08648b963210d8818313dab8ad876dd86f21a81e..d10ca5a15d489c3f1f3edf4dd590bab06c1e4b82 100644
--- a/lib/compiler/implementation/lib/mockimpl.dart
+++ b/lib/compiler/implementation/lib/mockimpl.dart
@@ -377,3 +377,27 @@ class ListFactory<E> {
return result;
}
}
+
+class ExpandoImplementation<T> implements Expando<T> {
+
+ final String name;
+ final String _key;
+
+ ExpandoImplementation([this.name]) : _key = _generateKey();
+
+ T operator[](Object object) {
+ return Primitives.getProperty(object, _key);
+ }
+
+ void operator[]=(Object object, T value) {
+ Primitives.setProperty(object, _key, value);
+ }
+
+ String toString() {
+ return (name === null) ? "Expando:${_key}" : "Expando:${name}@${_key}";
+ }
+
+ static int _keyCount = 0;
+ static String _generateKey() => "\$key\$${_keyCount++}";
+
+}

Powered by Google App Engine
This is Rietveld 408576698