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

Unified Diff: pkg/kernel/lib/type_propagation/canonicalizer.dart

Issue 2780513004: [Kernel] Remove code from the old type propagation. (Closed)
Patch Set: Remove empty status file section Created 3 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
« no previous file with comments | « pkg/kernel/lib/type_propagation/builder.dart ('k') | pkg/kernel/lib/type_propagation/constraints.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/type_propagation/canonicalizer.dart
diff --git a/pkg/kernel/lib/type_propagation/canonicalizer.dart b/pkg/kernel/lib/type_propagation/canonicalizer.dart
deleted file mode 100644
index 60192b59f4a55aa94ffbcef182773459c7698b21..0000000000000000000000000000000000000000
--- a/pkg/kernel/lib/type_propagation/canonicalizer.dart
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2016, 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.
-library kernel.type_propagation.canonicalizer;
-
-import 'dart:collection';
-
-/// Generates unique consecutive integer IDs for tuples of variable length.
-class TupleCanonicalizer {
- final HashMap<List<Object>, int> _table = new HashMap<List<Object>, int>(
- equals: _contentEquals, hashCode: _contentHashCode);
- final List<List<Object>> _canonicalList = <List<Object>>[];
- List<Object> _buffer = [];
-
- void _push(Object value) {
- _buffer.add(value);
- }
-
- int _finish() {
- int index = _table[_buffer];
- if (index == null) {
- index = _canonicalList.length;
- _canonicalList.add(_buffer);
- _table[_buffer] = index;
- _buffer = [];
- } else {
- // The item already existed. Reuse the buffer object for the next query.
- _buffer.clear();
- }
- return index;
- }
-
- /// Generate or get the ID for a "unary tuple".
- int get1(Object first) {
- _push(first);
- return _finish();
- }
-
- /// Generate or get the ID for a pair.
- int get2(Object first, Object second) {
- _push(first);
- _push(second);
- return _finish();
- }
-
- /// Generate or get the ID for a triple.
- int get3(Object first, Object second, Object third) {
- _push(first);
- _push(second);
- _push(third);
- return _finish();
- }
-
- List<Object> getFromIndex(int index) {
- return _canonicalList[index];
- }
-
- int get length => _canonicalList.length;
-
- static bool _contentEquals(List<Object> first, List<Object> second) {
- if (first.length != second.length) return false;
- for (int i = 0; i < first.length; ++i) {
- if (first[i] != second[i]) return false;
- }
- return true;
- }
-
- static int _contentHashCode(List<Object> list) {
- int hash = 0;
- for (int i = 0; i < list.length; ++i) {
- hash = (hash * 31 + hash ^ list[i].hashCode) & 0x3fffffff;
- }
- return hash;
- }
-}
-
-/// Maps uint31 pairs to values of type [T].
-class Uint31PairMap<T> {
- final HashMap<int, T> _table = new HashMap<int, T>(hashCode: _bigintHash);
- int _key;
-
- /// Returns the value associated with the given pair, or `null` if no value
- /// is associated with the pair.
- ///
- /// This association can be changed using a subsequent call to [put].
- T lookup(int x, int y) {
- assert(x >= 0 && x >> 31 == 0);
- assert(y >= 0 && y >> 31 == 0);
- int key = (x << 31) + y;
- _key = key;
- return _table[key];
- }
-
- /// Associates [value] with the pair previously queried using [lookup].
- void put(T value) {
- _table[_key] = value;
- }
-
- Iterable<T> get values => _table.values;
-
- static int _bigintHash(int bigint) {
- int x = 0x3fffffff & (bigint >> 31);
- int y = 0x3fffffff & bigint;
- int hash = 0x3fffffff & (x * 1367);
- hash = 0x3fffffff & (y * 31 + hash ^ y);
- hash = 0x3fffffff & ((x ^ y) * 31 + hash ^ y);
- return hash;
- }
-}
« no previous file with comments | « pkg/kernel/lib/type_propagation/builder.dart ('k') | pkg/kernel/lib/type_propagation/constraints.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698