Remove js implementations of java.util maps and sets, disable intrinsic to select specialized implementations.

#KT-12386
This commit is contained in:
Ilya Gorbunov
2016-08-26 03:41:23 +03:00
parent 5cd3417d4c
commit ea82c20692
5 changed files with 4 additions and 1209 deletions
-1
View File
@@ -349,7 +349,6 @@
<sources dir="${stdlib.js.dir}">
<file name="kotlin_lib_ecma5.js"/>
<file name="kotlin_lib.js"/>
<file name="maps.js"/>
<file name="long.js"/>
</sources>
-53
View File
@@ -16,12 +16,6 @@
package java.util
@native
private val DEFAULT_INITIAL_CAPACITY = 16
@native
private val DEFAULT_LOAD_FACTOR = 0.75f
@library
public interface Comparator<T> {
public fun compare(obj1: T, obj2: T): Int
@@ -32,53 +26,6 @@ public inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Compara
}
// in lack of type aliases
/*
public abstract class AbstractCollection<E> : kotlin.collections.AbstractCollection<E>()
public abstract class AbstractList<E> : kotlin.collections.AbstractList<E>()
public open class ArrayList<E>(capacity: Int = 0) : kotlin.collections.ArrayList<E>(capacity)
*/
@library
public open class HashSet<E>(
initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR
) : AbstractCollection<E>(), MutableSet<E> {
override fun iterator(): MutableIterator<E> = noImpl
override val size: Int get() = noImpl
override fun equals(other: Any?): Boolean = noImpl
override fun hashCode(): Int = noImpl
}
@library
public open class LinkedHashSet<E>(
initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR
) : HashSet<E>(initialCapacity, loadFactor), MutableSet<E> {
override val size: Int get() = noImpl
}
@library
public open class HashMap<K, V>(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap<K, V> {
override val size: Int get() = noImpl
override fun isEmpty(): Boolean = noImpl
override fun get(key: K): V? = noImpl
override fun containsKey(key: K): Boolean = noImpl
override fun put(key: K, value: V): V? = noImpl
override fun putAll(m: Map<out K, V>): Unit = noImpl
override fun remove(key: K): V? = noImpl
override fun clear(): Unit = noImpl
override fun containsValue(value: V): Boolean = noImpl
override val keys: MutableSet<K> get() = noImpl
override val values: MutableCollection<V> get() = noImpl
override val entries: MutableSet<MutableMap.MutableEntry<K, V>> get() = noImpl
}
@library
public open class LinkedHashMap<K, V>(
initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR, accessOrder: Boolean = false
) : HashMap<K, V>(initialCapacity, loadFactor)
@native
public class Date() {
-30
View File
@@ -1,30 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package java.util
public fun <E> HashSet(c: Collection<E>): HashSet<E>
= HashSet<E>(c.size).apply { addAll(c) }
public fun <E> LinkedHashSet(c: Collection<E>): HashSet<E>
= LinkedHashSet<E>(c.size).apply { addAll(c) }
public fun <K, V> HashMap(m: Map<out K, V>): HashMap<K, V>
= HashMap<K, V>(m.size).apply { putAll(m) }
public fun <K, V> LinkedHashMap(m: Map<out K, V>): LinkedHashMap<K, V>
= LinkedHashMap<K, V>(m.size).apply { putAll(m) }
@@ -187,8 +187,8 @@ public final class TopLevelFIF extends CompositeFIF {
add(pattern("kotlin.collections", "Map", "get").checkOverridden(), NATIVE_MAP_GET);
add(pattern("kotlin.js", "set").isExtensionOf(FQ_NAMES.mutableMap.asString()), NATIVE_MAP_SET);
add(pattern("java.util", "HashMap", "<init>"), new MapSelectImplementationIntrinsic(false));
add(pattern("java.util", "HashSet", "<init>"), new MapSelectImplementationIntrinsic(true));
//add(pattern("java.util", "HashMap", "<init>"), new MapSelectImplementationIntrinsic(false));
//add(pattern("java.util", "HashSet", "<init>"), new MapSelectImplementationIntrinsic(true));
add(pattern("kotlin.js", "Json", "get"), ArrayFIF.GET_INTRINSIC);
add(pattern("kotlin.js", "Json", "set"), ArrayFIF.SET_INTRINSIC);
@@ -245,6 +245,7 @@ public final class TopLevelFIF extends CompositeFIF {
}
}
/*
private static class MapSelectImplementationIntrinsic extends CallParametersAwareFunctionIntrinsic {
private final boolean isSet;
@@ -281,4 +282,5 @@ public final class TopLevelFIF extends CompositeFIF {
return new JsNew(context.namer().kotlin(collectionClassName), arguments);
}
}
*/
}
-1123
View File
File diff suppressed because it is too large Load Diff