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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/constant_map.dart

Issue 16538002: Move lib from sdk/lib/_internal/compiler/implementation to _internal root. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/lib/constant_map.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/lib/constant_map.dart (revision 23664)
+++ sdk/lib/_internal/compiler/implementation/lib/constant_map.dart (working copy)
@@ -1,77 +0,0 @@
-// Copyright (c) 2012, 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 _js_helper;
-
-// This class has no constructor. This is on purpose since the instantiation
-// is shortcut by the compiler.
-class ConstantMap<V> implements Map<String, V> {
- final int length;
- // A constant map is backed by a JavaScript object.
- final _jsObject;
- final List<String> _keys;
-
- bool containsValue(V needle) {
- return values.any((V value) => value == needle);
- }
-
- bool containsKey(String key) {
- if (key == '__proto__') return false;
- return jsHasOwnProperty(_jsObject, key);
- }
-
- V operator [](String key) {
- if (!containsKey(key)) return null;
- return jsPropertyAccess(_jsObject, key);
- }
-
- void forEach(void f(String key, V value)) {
- _keys.forEach((String key) => f(key, this[key]));
- }
-
- Iterable<String> get keys {
- return new _ConstantMapKeyIterable(this);
- }
-
- Iterable<V> get values {
- return _keys.map((String key) => this[key]);
- }
-
- bool get isEmpty => length == 0;
-
- bool get isNotEmpty => !isEmpty;
-
- String toString() => Maps.mapToString(this);
-
- _throwUnmodifiable() {
- throw new UnsupportedError("Cannot modify unmodifiable Map");
- }
- void operator []=(String key, V val) => _throwUnmodifiable();
- V putIfAbsent(String key, V ifAbsent()) => _throwUnmodifiable();
- V remove(String key) => _throwUnmodifiable();
- void clear() => _throwUnmodifiable();
-}
-
-// This class has no constructor. This is on purpose since the instantiation
-// is shortcut by the compiler.
-class ConstantProtoMap<V> extends ConstantMap<V> {
- final V _protoValue;
-
- bool containsKey(String key) {
- if (key == '__proto__') return true;
- return super.containsKey(key);
- }
-
- V operator [](String key) {
- if (key == '__proto__') return _protoValue;
- return super[key];
- }
-}
-
-class _ConstantMapKeyIterable extends IterableBase<String> {
- ConstantMap _map;
- _ConstantMapKeyIterable(this._map);
-
- Iterator<String> get iterator => _map._keys.iterator;
-}

Powered by Google App Engine
This is Rietveld 408576698