Adjust JS stdlib maps to changes in builtins

This commit is contained in:
Denis Zharkov
2015-10-12 19:54:31 +03:00
committed by Mikhail Glukhikh
parent d71b0144d5
commit a6dfa53d77
+40 -18
View File
@@ -52,7 +52,7 @@
}; };
function hashMapPutAll (fromMap) { function hashMapPutAll (fromMap) {
var entries = fromMap.entrySet(); var entries = fromMap.entries;
var it = entries.iterator(); var it = entries.iterator();
while (it.hasNext()) { while (it.hasNext()) {
var e = it.next(); var e = it.next();
@@ -367,7 +367,8 @@
this._values = createBucketAggregator("values"); this._values = createBucketAggregator("values");
this._entries = createBucketAggregator("getEntries"); this._entries = createBucketAggregator("getEntries");
this.values = function () { Object.defineProperty(this, "values", {
get: function () {
var values = this._values(); var values = this._values();
var i = values.length; var i = values.length;
var result = new Kotlin.ArrayList(); var result = new Kotlin.ArrayList();
@@ -375,7 +376,10 @@
result.add_za3rmp$(values[i]); result.add_za3rmp$(values[i]);
} }
return result; return result;
}; },
configurable: true
});
this.remove_za3rmp$ = function (key) { this.remove_za3rmp$ = function (key) {
var hash = hashingFunction(key), bucketIndex, oldValue = null, result = null; var hash = hashingFunction(key), bucketIndex, oldValue = null, result = null;
@@ -430,7 +434,8 @@
return clone; return clone;
}; };
this.keySet = function () { Object.defineProperty(this, "keys", {
get: function () {
var res = new Kotlin.ComplexHashSet(); var res = new Kotlin.ComplexHashSet();
var keys = this._keys(); var keys = this._keys();
var i = keys.length; var i = keys.length;
@@ -438,9 +443,12 @@
res.add_za3rmp$(keys[i]); res.add_za3rmp$(keys[i]);
} }
return res; return res;
}; },
configurable: true
});
this.entrySet = function () { Object.defineProperty(this, "entries", {
get: function () {
var result = new Kotlin.ComplexHashSet(); var result = new Kotlin.ComplexHashSet();
var entries = this._entries(); var entries = this._entries();
var i = entries.length; var i = entries.length;
@@ -450,7 +458,9 @@
} }
return result; return result;
}; },
configurable: true
});
this.hashCode = function() { this.hashCode = function() {
var h = 0; var h = 0;
@@ -642,7 +652,8 @@
this.map = {}; this.map = {};
}, },
putAll_48yl7j$: hashMapPutAll, putAll_48yl7j$: hashMapPutAll,
entrySet: function () { entries: {
get: function () {
var result = new Kotlin.ComplexHashSet(); var result = new Kotlin.ComplexHashSet();
var map = this.map; var map = this.map;
for (var key in map) { for (var key in map) {
@@ -651,6 +662,7 @@
} }
return result; return result;
}
}, },
getKeySetClass: function () { getKeySetClass: function () {
throw new Error("Kotlin.AbstractPrimitiveHashMap.getKetSetClass is abstract"); throw new Error("Kotlin.AbstractPrimitiveHashMap.getKetSetClass is abstract");
@@ -658,7 +670,8 @@
convertKeyToKeyType: function(key) { convertKeyToKeyType: function(key) {
throw new Error("Kotlin.AbstractPrimitiveHashMap.convertKeyToKeyType is abstract"); throw new Error("Kotlin.AbstractPrimitiveHashMap.convertKeyToKeyType is abstract");
}, },
keySet: function () { keys: {
get: function () {
var result = new (this.getKeySetClass())(); var result = new (this.getKeySetClass())();
var map = this.map; var map = this.map;
for (var key in map) { for (var key in map) {
@@ -667,9 +680,12 @@
} }
return result; return result;
}
}, },
values: function () { values: {
get: function () {
return new Kotlin.PrimitiveHashMapValues(this); return new Kotlin.PrimitiveHashMapValues(this);
}
}, },
toJSON: function () { toJSON: function () {
return this.map; return this.map;
@@ -785,14 +801,17 @@
this.orderedKeys = []; this.orderedKeys = [];
}; };
this.keySet = function() { Object.defineProperty(this, "keys", {
get: function () {
// TODO return special Set which unsupported adding // TODO return special Set which unsupported adding
var set = new Kotlin.LinkedHashSet(); var set = new Kotlin.LinkedHashSet();
set.map = this; set.map = this;
return set; return set;
}; }
});
this.values = function() { Object.defineProperty(this, "entries", {
get: function () {
var result = new Kotlin.ArrayList(); var result = new Kotlin.ArrayList();
for (var i = 0, c = this.orderedKeys, l = c.length; i < l; i++) { for (var i = 0, c = this.orderedKeys, l = c.length; i < l; i++) {
@@ -800,9 +819,11 @@
} }
return result; return result;
}; }
});
this.entrySet = function() { Object.defineProperty(this, "entries", {
get: function () {
var set = new Kotlin.LinkedHashSet(); var set = new Kotlin.LinkedHashSet();
for (var i = 0, c = this.orderedKeys, l = c.length; i < l; i++) { for (var i = 0, c = this.orderedKeys, l = c.length; i < l; i++) {
@@ -810,7 +831,8 @@
} }
return set; return set;
}; }
});
} }
lazyInitClasses.LinkedHashMap = Kotlin.createClass( lazyInitClasses.LinkedHashMap = Kotlin.createClass(
@@ -1076,7 +1098,7 @@
this.intersection = function (hashSet) { this.intersection = function (hashSet) {
var intersection = new HashSet(hashingFunction, equalityFunction); var intersection = new HashSet(hashingFunction, equalityFunction);
var values = hashSet.values(), i = values.length, val; var values = hashSet.values, i = values.length, val;
while (i--) { while (i--) {
val = values[i]; val = values[i];
if (hashTable.containsKey_za3rmp$(val)) { if (hashTable.containsKey_za3rmp$(val)) {
@@ -1088,7 +1110,7 @@
this.union = function (hashSet) { this.union = function (hashSet) {
var union = this.clone(); var union = this.clone();
var values = hashSet.values(), i = values.length, val; var values = hashSet.values, i = values.length, val;
while (i--) { while (i--) {
val = values[i]; val = values[i];
if (!hashTable.containsKey_za3rmp$(val)) { if (!hashTable.containsKey_za3rmp$(val)) {