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

Unified Diff: sdk/lib/_internal/compiler/implementation/helpers/debug_collection.dart

Issue 208423012: Add helpers library to dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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: sdk/lib/_internal/compiler/implementation/helpers/debug_collection.dart
diff --git a/sdk/lib/_internal/compiler/implementation/helpers/debug_collection.dart b/sdk/lib/_internal/compiler/implementation/helpers/debug_collection.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8e585413696c17bd0858650798d936b239fe51e5
--- /dev/null
+++ b/sdk/lib/_internal/compiler/implementation/helpers/debug_collection.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart2js.helpers;
+
+typedef void DebugCallback(String methodName, var arg1, var arg2);
+
+class DebugMap<K, V> implements Map<K, V> {
+ final Map<K, V> map;
+ DebugCallback indexSetCallBack;
+ DebugCallback putIfAbsentCallBack;
+
+ DebugMap(this.map, {DebugCallback addCallback}) {
+ if (addCallback != null) {
+ this.addCallback = addCallback;
+ }
+ }
+
+ void set addCallback(DebugCallback value) {
+ indexSetCallBack = value;
+ putIfAbsentCallBack = value;
+ }
+
+ bool containsValue(Object value) {
+ return map.containsValue(value);
+ }
+
+ bool containsKey(Object key) => map.containsKey(key);
+
+ V operator [](Object key) => map[key];
+
+ void operator []=(K key, V value) {
+ if (indexSetCallBack != null) {
+ indexSetCallBack('[]=', key, value);
+ }
+ map[key] = value;
+ }
+
+ V putIfAbsent(K key, V ifAbsent()) {
+ return map.putIfAbsent(key, () {
+ V v = ifAbsent();
karlklose 2014/03/25 14:22:18 Indentation is off.
Johnni Winther 2014/03/26 07:35:05 Done.
+ if (putIfAbsentCallBack != null) {
+ putIfAbsentCallBack('putIfAbsent', key, v);
+ }
+ return v;
+ });
+ }
+
+ void addAll(Map<K, V> other) => map.addAll(other);
+
+ V remove(Object key) => map.remove(key);
+
+ void clear() => map.clear();
+
+ void forEach(void f(K key, V value)) => map.forEach(f);
+
+ Iterable<K> get keys => map.keys;
+
+ Iterable<V> get values => map.values;
+
+ int get length => map.length;
+
+ bool get isEmpty => map.isEmpty;
+
+ bool get isNotEmpty => map.isNotEmpty;
+}

Powered by Google App Engine
This is Rietveld 408576698