JS backend: switched to use native Function.bind(from ES5) instead library function b0-b4.
Removed unnecessary functions from jslib. (cherry picked from commit f6550e9)
This commit is contained in:
@@ -569,52 +569,9 @@ var kotlin = {set:function (receiver, key, value) {
|
||||
Kotlin.sure = function (obj) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
// native concat doesn't work for arguments
|
||||
Kotlin.concat = function (a, b) {
|
||||
var r = new Array(a.length + b.length);
|
||||
var i = 0;
|
||||
var n = a.length;
|
||||
for (; i < n; i++) {
|
||||
r[i] = a[i];
|
||||
}
|
||||
n = b.length;
|
||||
for (var j = 0; j < n;) {
|
||||
r[i++] = b[j++];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
})();
|
||||
|
||||
Kotlin.assignOwner = function(f, o) {
|
||||
f.o = o;
|
||||
return f;
|
||||
};
|
||||
|
||||
// we cannot use Function.bind, because if we bind with null self, but call with not null — fun must receive passed not null self
|
||||
// test case: WebDemoExamples2Test.testBuilder
|
||||
Kotlin.b0 = function (f, self, value) {
|
||||
return function () {
|
||||
return f.call(self !== null ? self : this, value);
|
||||
}
|
||||
};
|
||||
Kotlin.b1 = function (f, self, values) {
|
||||
return function () {
|
||||
return f.apply(self !== null ? self : this, values);
|
||||
}
|
||||
};
|
||||
Kotlin.b2 = function (f, self, values) {
|
||||
return function () {
|
||||
return f.apply(self !== null ? self : this, Kotlin.concat(values, arguments));
|
||||
}
|
||||
};
|
||||
Kotlin.b3 = function (f, self) {
|
||||
return function () {
|
||||
return f.call(self)
|
||||
}
|
||||
};
|
||||
Kotlin.b4 = function (f, self) {
|
||||
return function () {
|
||||
return f.apply(self, Kotlin.argumentsToArrayLike(arguments));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,15 +48,6 @@ var Kotlin = {};
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.argumentsToArrayLike = function (args) {
|
||||
var n = args.length;
|
||||
var result = new Array(n);
|
||||
while (n--) {
|
||||
result[n] = args[n];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function copyProperties(to, from) {
|
||||
for (var p in from) {
|
||||
if (from.hasOwnProperty(p)) {
|
||||
|
||||
@@ -5,11 +5,6 @@ var Kotlin = Object.create(null);
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// ecma5 is still sucks — concat doesn't accept arguments, but apply does, so, we just return arguments
|
||||
Kotlin.argumentsToArrayLike = function (args) {
|
||||
return args;
|
||||
};
|
||||
|
||||
Kotlin.keys = Object.keys;
|
||||
|
||||
Kotlin.isType = function (object, type) {
|
||||
|
||||
Reference in New Issue
Block a user