JS: change how declarations are exported from modules. Change how parts of kotlin.js merged
This commit is contained in:
+2
-5
@@ -8,11 +8,8 @@
|
||||
}
|
||||
}(this, function () {
|
||||
var Kotlin = {};
|
||||
function require() {
|
||||
return Kotlin;
|
||||
}
|
||||
var module = {};
|
||||
|
||||
%output%
|
||||
Kotlin.modules.kotlin = Kotlin;
|
||||
|
||||
return Kotlin;
|
||||
}));
|
||||
+418
-422
@@ -14,90 +14,87 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
(function (Kotlin) {
|
||||
"use strict";
|
||||
// Shims for String
|
||||
if (typeof String.prototype.startsWith === "undefined") {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.lastIndexOf(searchString, position) === position;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith === "undefined") {
|
||||
String.prototype.endsWith = function(searchString, position) {
|
||||
var subjectString = this.toString();
|
||||
if (position === undefined || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
}
|
||||
|
||||
// Shims for String
|
||||
if (typeof String.prototype.startsWith === "undefined") {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
position = position || 0;
|
||||
return this.lastIndexOf(searchString, position) === position;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith === "undefined") {
|
||||
String.prototype.endsWith = function(searchString, position) {
|
||||
var subjectString = this.toString();
|
||||
if (position === undefined || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
String.prototype.contains = function (s) {
|
||||
return this.indexOf(s) !== -1;
|
||||
};
|
||||
|
||||
// Kotlin stdlib
|
||||
|
||||
Kotlin.equals = function (obj1, obj2) {
|
||||
if (obj1 == null) {
|
||||
return obj2 == null;
|
||||
}
|
||||
|
||||
String.prototype.contains = function (s) {
|
||||
return this.indexOf(s) !== -1;
|
||||
};
|
||||
if (obj2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Kotlin stdlib
|
||||
if (typeof obj1 == "object" && typeof obj1.equals_za3rmp$ === "function") {
|
||||
return obj1.equals_za3rmp$(obj2);
|
||||
}
|
||||
|
||||
Kotlin.equals = function (obj1, obj2) {
|
||||
if (obj1 == null) {
|
||||
return obj2 == null;
|
||||
}
|
||||
return obj1 === obj2;
|
||||
};
|
||||
|
||||
if (obj2 == null) {
|
||||
return false;
|
||||
}
|
||||
Kotlin.hashCode = function (obj) {
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
if ("function" == typeof obj.hashCode) {
|
||||
return obj.hashCode();
|
||||
}
|
||||
var objType = typeof obj;
|
||||
if ("object" == objType || "function" == objType) {
|
||||
return getObjectHashCode(obj);
|
||||
} else if ("number" == objType) {
|
||||
// TODO: a more elaborate code is needed for floating point values.
|
||||
return obj | 0;
|
||||
} if ("boolean" == objType) {
|
||||
return Number(obj)
|
||||
}
|
||||
|
||||
if (typeof obj1 == "object" && typeof obj1.equals_za3rmp$ === "function") {
|
||||
return obj1.equals_za3rmp$(obj2);
|
||||
}
|
||||
var str = String(obj);
|
||||
return getStringHashCode(str);
|
||||
};
|
||||
|
||||
return obj1 === obj2;
|
||||
};
|
||||
Kotlin.toString = function (o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
else if (Array.isArray(o)) {
|
||||
return "[...]";
|
||||
}
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.hashCode = function (obj) {
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
if ("function" == typeof obj.hashCode) {
|
||||
return obj.hashCode();
|
||||
}
|
||||
var objType = typeof obj;
|
||||
if ("object" == objType || "function" == objType) {
|
||||
return getObjectHashCode(obj);
|
||||
} else if ("number" == objType) {
|
||||
// TODO: a more elaborate code is needed for floating point values.
|
||||
return obj | 0;
|
||||
} if ("boolean" == objType) {
|
||||
return Number(obj)
|
||||
}
|
||||
Kotlin.arrayToString = function (a) {
|
||||
return "[" + a.map(Kotlin.toString).join(", ") + "]";
|
||||
};
|
||||
|
||||
var str = String(obj);
|
||||
return getStringHashCode(str);
|
||||
};
|
||||
|
||||
Kotlin.toString = function (o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
else if (Array.isArray(o)) {
|
||||
return "[...]";
|
||||
}
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.arrayToString = function (a) {
|
||||
return "[" + a.map(Kotlin.toString).join(", ") + "]";
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepToString = function (a, visited) {
|
||||
visited = visited || [a];
|
||||
return "[" + a.map(function(e) {
|
||||
Kotlin.arrayDeepToString = function (a, visited) {
|
||||
visited = visited || [a];
|
||||
return "[" + a.map(function(e) {
|
||||
if (Array.isArray(e) && visited.indexOf(e) < 0) {
|
||||
visited.push(e);
|
||||
var result = Kotlin.arrayDeepToString(e, visited);
|
||||
@@ -108,396 +105,395 @@
|
||||
return Kotlin.toString(e);
|
||||
}
|
||||
}).join(", ") + "]";
|
||||
};
|
||||
};
|
||||
|
||||
Kotlin.compareTo = function (a, b) {
|
||||
var typeA = typeof a;
|
||||
var typeB = typeof a;
|
||||
if (Kotlin.isChar(a) && typeB == "number") {
|
||||
return Kotlin.primitiveCompareTo(a.charCodeAt(0), b);
|
||||
}
|
||||
if (typeA == "number" && Kotlin.isChar(b)) {
|
||||
return Kotlin.primitiveCompareTo(a, b.charCodeAt(0));
|
||||
}
|
||||
if (typeA == "number" || typeA == "string") {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
return a.compareTo_za3rmp$(b);
|
||||
};
|
||||
|
||||
Kotlin.primitiveCompareTo = function (a, b) {
|
||||
Kotlin.compareTo = function (a, b) {
|
||||
var typeA = typeof a;
|
||||
var typeB = typeof a;
|
||||
if (Kotlin.isChar(a) && typeB == "number") {
|
||||
return Kotlin.primitiveCompareTo(a.charCodeAt(0), b);
|
||||
}
|
||||
if (typeA == "number" && Kotlin.isChar(b)) {
|
||||
return Kotlin.primitiveCompareTo(a, b.charCodeAt(0));
|
||||
}
|
||||
if (typeA == "number" || typeA == "string") {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
};
|
||||
}
|
||||
return a.compareTo_za3rmp$(b);
|
||||
};
|
||||
|
||||
Kotlin.isNumber = function (a) {
|
||||
return typeof a == "number" || a instanceof Kotlin.Long;
|
||||
};
|
||||
Kotlin.primitiveCompareTo = function (a, b) {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
};
|
||||
|
||||
Kotlin.isChar = function (value) {
|
||||
return (typeof value) == "string" && value.length == 1;
|
||||
};
|
||||
Kotlin.isNumber = function (a) {
|
||||
return typeof a == "number" || a instanceof Kotlin.Long;
|
||||
};
|
||||
|
||||
Kotlin.isComparable = function (value) {
|
||||
var type = typeof value;
|
||||
Kotlin.isChar = function (value) {
|
||||
return (typeof value) == "string" && value.length == 1;
|
||||
};
|
||||
|
||||
return type === "string" ||
|
||||
type === "boolean" ||
|
||||
Kotlin.isNumber(value) ||
|
||||
Kotlin.isType(value, Kotlin.kotlin.Comparable);
|
||||
};
|
||||
|
||||
Kotlin.isCharSequence = function (value) {
|
||||
return typeof value === "string" || Kotlin.isType(value, Kotlin.kotlin.CharSequence);
|
||||
};
|
||||
Kotlin.isComparable = function (value) {
|
||||
var type = typeof value;
|
||||
|
||||
Kotlin.charInc = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)+1);
|
||||
};
|
||||
return type === "string" ||
|
||||
type === "boolean" ||
|
||||
Kotlin.isNumber(value) ||
|
||||
Kotlin.isType(value, Kotlin.kotlin.Comparable);
|
||||
};
|
||||
|
||||
Kotlin.charDec = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)-1);
|
||||
};
|
||||
Kotlin.isCharSequence = function (value) {
|
||||
return typeof value === "string" || Kotlin.isType(value, Kotlin.kotlin.CharSequence);
|
||||
};
|
||||
|
||||
Kotlin.toShort = function (a) {
|
||||
return (a & 0xFFFF) << 16 >> 16;
|
||||
};
|
||||
Kotlin.charInc = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)+1);
|
||||
};
|
||||
|
||||
Kotlin.toByte = function (a) {
|
||||
return (a & 0xFF) << 24 >> 24;
|
||||
};
|
||||
Kotlin.charDec = function (value) {
|
||||
return String.fromCharCode(value.charCodeAt(0)-1);
|
||||
};
|
||||
|
||||
Kotlin.toChar = function (a) {
|
||||
return String.fromCharCode((((a | 0) % 65536) & 0xFFFF) << 16 >>> 16);
|
||||
};
|
||||
Kotlin.toShort = function (a) {
|
||||
return (a & 0xFFFF) << 16 >> 16;
|
||||
};
|
||||
|
||||
Kotlin.numberToLong = function (a) {
|
||||
return a instanceof Kotlin.Long ? a : Kotlin.Long.fromNumber(a);
|
||||
};
|
||||
Kotlin.toByte = function (a) {
|
||||
return (a & 0xFF) << 24 >> 24;
|
||||
};
|
||||
|
||||
Kotlin.numberToInt = function (a) {
|
||||
return a instanceof Kotlin.Long ? a.toInt() : (a | 0);
|
||||
};
|
||||
Kotlin.toChar = function (a) {
|
||||
return String.fromCharCode((((a | 0) % 65536) & 0xFFFF) << 16 >>> 16);
|
||||
};
|
||||
|
||||
Kotlin.numberToShort = function (a) {
|
||||
return Kotlin.toShort(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToLong = function (a) {
|
||||
return a instanceof Kotlin.Long ? a : Kotlin.Long.fromNumber(a);
|
||||
};
|
||||
|
||||
Kotlin.numberToByte = function (a) {
|
||||
return Kotlin.toByte(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToInt = function (a) {
|
||||
return a instanceof Kotlin.Long ? a.toInt() : (a | 0);
|
||||
};
|
||||
|
||||
Kotlin.numberToDouble = function (a) {
|
||||
return +a;
|
||||
};
|
||||
Kotlin.numberToShort = function (a) {
|
||||
return Kotlin.toShort(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.numberToChar = function (a) {
|
||||
return Kotlin.toChar(Kotlin.numberToInt(a));
|
||||
};
|
||||
Kotlin.numberToByte = function (a) {
|
||||
return Kotlin.toByte(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.intUpto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntRange(from, to);
|
||||
};
|
||||
Kotlin.numberToDouble = function (a) {
|
||||
return +a;
|
||||
};
|
||||
|
||||
Kotlin.intDownto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntProgression(from, to, -1);
|
||||
};
|
||||
Kotlin.numberToChar = function (a) {
|
||||
return Kotlin.toChar(Kotlin.numberToInt(a));
|
||||
};
|
||||
|
||||
Kotlin.Throwable = Error;
|
||||
Kotlin.intUpto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntRange(from, to);
|
||||
};
|
||||
|
||||
Kotlin.throwNPE = function (message) {
|
||||
throw new Kotlin.kotlin.NullPointerException(message);
|
||||
};
|
||||
Kotlin.intDownto = function (from, to) {
|
||||
return new Kotlin.kotlin.ranges.IntProgression(from, to, -1);
|
||||
};
|
||||
|
||||
Kotlin.throwCCE = function () {
|
||||
throw new Kotlin.kotlin.ClassCastException("Illegal cast");
|
||||
};
|
||||
Kotlin.Throwable = Error;
|
||||
|
||||
/** @const */
|
||||
var POW_2_32 = 4294967296;
|
||||
// TODO: consider switching to Symbol type once we are on ES6.
|
||||
/** @const */
|
||||
var OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$";
|
||||
Kotlin.throwNPE = function (message) {
|
||||
throw new Kotlin.kotlin.NullPointerException(message);
|
||||
};
|
||||
|
||||
function getObjectHashCode(obj) {
|
||||
if (!(OBJECT_HASH_CODE_PROPERTY_NAME in obj)) {
|
||||
var hash = (Math.random() * POW_2_32) | 0; // Make 32-bit singed integer.
|
||||
Object.defineProperty(obj, OBJECT_HASH_CODE_PROPERTY_NAME, { value: hash, enumerable: false });
|
||||
}
|
||||
return obj[OBJECT_HASH_CODE_PROPERTY_NAME];
|
||||
Kotlin.throwCCE = function () {
|
||||
throw new Kotlin.kotlin.ClassCastException("Illegal cast");
|
||||
};
|
||||
|
||||
/** @const */
|
||||
var POW_2_32 = 4294967296;
|
||||
// TODO: consider switching to Symbol type once we are on ES6.
|
||||
/** @const */
|
||||
var OBJECT_HASH_CODE_PROPERTY_NAME = "kotlinHashCodeValue$";
|
||||
|
||||
function getObjectHashCode(obj) {
|
||||
if (!(OBJECT_HASH_CODE_PROPERTY_NAME in obj)) {
|
||||
var hash = (Math.random() * POW_2_32) | 0; // Make 32-bit singed integer.
|
||||
Object.defineProperty(obj, OBJECT_HASH_CODE_PROPERTY_NAME, { value: hash, enumerable: false });
|
||||
}
|
||||
return obj[OBJECT_HASH_CODE_PROPERTY_NAME];
|
||||
}
|
||||
|
||||
function getStringHashCode(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var code = str.charCodeAt(i);
|
||||
hash = (hash * 31 + code) | 0; // Keep it 32-bit.
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
Kotlin.PropertyMetadata = Kotlin.createClassNow(null,
|
||||
function (name) {
|
||||
this.name = name;
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.safeParseInt = function (str) {
|
||||
var r = parseInt(str, 10);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.safeParseDouble = function (str) {
|
||||
var r = parseFloat(str);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.arrayEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getStringHashCode(str) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var code = str.charCodeAt(i);
|
||||
hash = (hash * 31 + code) | 0; // Keep it 32-bit.
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Kotlin.PropertyMetadata = Kotlin.createClassNow(null,
|
||||
function (name) {
|
||||
this.name = name;
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.safeParseInt = function (str) {
|
||||
var r = parseInt(str, 10);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.safeParseDouble = function (str) {
|
||||
var r = parseFloat(str);
|
||||
return isNaN(r) ? null : r;
|
||||
};
|
||||
|
||||
Kotlin.arrayEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (!Kotlin.equals(a[i], b[i])) {
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (Array.isArray(a[i])) {
|
||||
if (!Kotlin.arrayDeepEquals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepEquals = function (a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (!Array.isArray(b) || a.length !== b.length) {
|
||||
} else if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
if (Array.isArray(a[i])) {
|
||||
if (!Kotlin.arrayDeepEquals(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
} else if (!Kotlin.equals(a[i], b[i])) {
|
||||
return false;
|
||||
Kotlin.arrayHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
result = ((31 * result | 0) + Kotlin.hashCode(arr[i])) | 0;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
var e = arr[i];
|
||||
result = ((31 * result | 0) + (Array.isArray(e) ? Kotlin.arrayDeepHashCode(e) : Kotlin.hashCode(e))) | 0;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var BaseOutput = Kotlin.createClassNow(null, null, {
|
||||
println: function (a) {
|
||||
if (typeof a !== "undefined") this.print(a);
|
||||
this.print("\n");
|
||||
},
|
||||
flush: function () {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Kotlin.NodeJsOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function(outputStream) {
|
||||
this.outputStream = outputStream;
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.outputStream.write(a);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.OutputToConsoleLog = Kotlin.createClassNow(BaseOutput, null, {
|
||||
print: function (a) {
|
||||
console.log(a);
|
||||
},
|
||||
println: function (a) {
|
||||
this.print(typeof a !== "undefined" ? a : "");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function() {
|
||||
this.buffer = ""
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.buffer += String(a);
|
||||
},
|
||||
flush: function () {
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutputToConsoleLog = Kotlin.createClassNow(Kotlin.BufferedOutput,
|
||||
function() {
|
||||
Kotlin.BufferedOutput.call(this);
|
||||
}, {
|
||||
print: function (a) {
|
||||
var s = String(a);
|
||||
|
||||
var i = s.lastIndexOf("\n");
|
||||
if (i != -1) {
|
||||
this.buffer += s.substr(0, i);
|
||||
|
||||
this.flush();
|
||||
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
|
||||
this.buffer += s;
|
||||
},
|
||||
flush: function () {
|
||||
console.log(this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
);
|
||||
Kotlin.out = function() {
|
||||
var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;
|
||||
|
||||
Kotlin.arrayHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
result = ((31 * result | 0) + Kotlin.hashCode(arr[i])) | 0;
|
||||
if (isNode) return new Kotlin.NodeJsOutput(process.stdout);
|
||||
|
||||
return new Kotlin.BufferedOutputToConsoleLog();
|
||||
}();
|
||||
|
||||
Kotlin.println = function (s) {
|
||||
Kotlin.out.println(s);
|
||||
};
|
||||
|
||||
Kotlin.print = function (s) {
|
||||
Kotlin.out.print(s);
|
||||
};
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
var it = c.iterator();
|
||||
var max = it.next();
|
||||
while (it.hasNext()) {
|
||||
var el = it.next();
|
||||
if (comp.compare(max, el) < 0) {
|
||||
max = el;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.arrayDeepHashCode = function (arr) {
|
||||
var result = 1;
|
||||
for (var i = 0, n = arr.length; i < n; i++) {
|
||||
var e = arr[i];
|
||||
result = ((31 * result | 0) + (Array.isArray(e) ? Kotlin.arrayDeepHashCode(e) : Kotlin.hashCode(e))) | 0;
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = void 0;
|
||||
if (comparator !== void 0) {
|
||||
boundComparator = comparator.compare.bind(comparator);
|
||||
}
|
||||
|
||||
if (mutableList.size > 1) {
|
||||
var array = Kotlin.copyToArray(mutableList);
|
||||
|
||||
array.sort(boundComparator);
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
mutableList.set_vux3hl$(i, array[i]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.primitiveArraySort = function(array) {
|
||||
array.sort(Kotlin.primitiveCompareTo)
|
||||
};
|
||||
|
||||
var BaseOutput = Kotlin.createClassNow(null, null, {
|
||||
println: function (a) {
|
||||
if (typeof a !== "undefined") this.print(a);
|
||||
this.print("\n");
|
||||
},
|
||||
flush: function () {
|
||||
}
|
||||
Kotlin.copyToArray = function (collection) {
|
||||
if (typeof collection.toArray !== "undefined") return collection.toArray();
|
||||
return Kotlin.copyToArrayImpl(collection);
|
||||
};
|
||||
|
||||
Kotlin.copyToArrayImpl = function (collection) {
|
||||
var array = [];
|
||||
var it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
array.push(it.next());
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
|
||||
Kotlin.splitString = function (str, regex, limit) {
|
||||
return str.split(new RegExp(regex), limit);
|
||||
};
|
||||
|
||||
Kotlin.nullArray = function (size) {
|
||||
var res = [];
|
||||
var i = size;
|
||||
while (i > 0) {
|
||||
res[--i] = null;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
Kotlin.numberArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.charArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return '\0';
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.booleanArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.longArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return Kotlin.Long.ZERO;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.arrayFromFun = function (size, initFun) {
|
||||
var result = new Array(size);
|
||||
for (var i = 0; i < size; i++) {
|
||||
result[i] = initFun(i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.deleteProperty = function (object, property) {
|
||||
delete object[property];
|
||||
};
|
||||
|
||||
Kotlin.jsonAddProperties = function (obj1, obj2) {
|
||||
for (var p in obj2) {
|
||||
if (obj2.hasOwnProperty(p)) {
|
||||
obj1[p] = obj2[p];
|
||||
}
|
||||
);
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
|
||||
Kotlin.NodeJsOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function(outputStream) {
|
||||
this.outputStream = outputStream;
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.outputStream.write(a);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.OutputToConsoleLog = Kotlin.createClassNow(BaseOutput, null, {
|
||||
print: function (a) {
|
||||
console.log(a);
|
||||
},
|
||||
println: function (a) {
|
||||
this.print(typeof a !== "undefined" ? a : "");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutput = Kotlin.createClassNow(BaseOutput,
|
||||
function() {
|
||||
this.buffer = ""
|
||||
}, {
|
||||
print: function (a) {
|
||||
this.buffer += String(a);
|
||||
},
|
||||
flush: function () {
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Kotlin.BufferedOutputToConsoleLog = Kotlin.createClassNow(Kotlin.BufferedOutput,
|
||||
function() {
|
||||
Kotlin.BufferedOutput.call(this);
|
||||
}, {
|
||||
print: function (a) {
|
||||
var s = String(a);
|
||||
|
||||
var i = s.lastIndexOf("\n");
|
||||
if (i != -1) {
|
||||
this.buffer += s.substr(0, i);
|
||||
|
||||
this.flush();
|
||||
|
||||
s = s.substr(i + 1);
|
||||
}
|
||||
|
||||
this.buffer += s;
|
||||
},
|
||||
flush: function () {
|
||||
console.log(this.buffer);
|
||||
this.buffer = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
Kotlin.out = function() {
|
||||
var isNode = typeof process !== 'undefined' && process.versions && !!process.versions.node;
|
||||
|
||||
if (isNode) return new Kotlin.NodeJsOutput(process.stdout);
|
||||
|
||||
return new Kotlin.BufferedOutputToConsoleLog();
|
||||
}();
|
||||
|
||||
Kotlin.println = function (s) {
|
||||
Kotlin.out.println(s);
|
||||
};
|
||||
|
||||
Kotlin.print = function (s) {
|
||||
Kotlin.out.print(s);
|
||||
};
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
var it = c.iterator();
|
||||
var max = it.next();
|
||||
while (it.hasNext()) {
|
||||
var el = it.next();
|
||||
if (comp.compare(max, el) < 0) {
|
||||
max = el;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = void 0;
|
||||
if (comparator !== void 0) {
|
||||
boundComparator = comparator.compare.bind(comparator);
|
||||
}
|
||||
|
||||
if (mutableList.size > 1) {
|
||||
var array = Kotlin.copyToArray(mutableList);
|
||||
|
||||
array.sort(boundComparator);
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
mutableList.set_vux3hl$(i, array[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Kotlin.primitiveArraySort = function(array) {
|
||||
array.sort(Kotlin.primitiveCompareTo)
|
||||
};
|
||||
|
||||
Kotlin.copyToArray = function (collection) {
|
||||
if (typeof collection.toArray !== "undefined") return collection.toArray();
|
||||
return Kotlin.copyToArrayImpl(collection);
|
||||
};
|
||||
|
||||
Kotlin.copyToArrayImpl = function (collection) {
|
||||
var array = [];
|
||||
var it = collection.iterator();
|
||||
while (it.hasNext()) {
|
||||
array.push(it.next());
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
|
||||
Kotlin.splitString = function (str, regex, limit) {
|
||||
return str.split(new RegExp(regex), limit);
|
||||
};
|
||||
|
||||
Kotlin.nullArray = function (size) {
|
||||
var res = [];
|
||||
var i = size;
|
||||
while (i > 0) {
|
||||
res[--i] = null;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
Kotlin.numberArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.charArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return '\0';
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.booleanArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.longArrayOfSize = function (size) {
|
||||
return Kotlin.arrayFromFun(size, function () {
|
||||
return Kotlin.Long.ZERO;
|
||||
});
|
||||
};
|
||||
|
||||
Kotlin.arrayFromFun = function (size, initFun) {
|
||||
var result = new Array(size);
|
||||
for (var i = 0; i < size; i++) {
|
||||
result[i] = initFun(i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Kotlin.deleteProperty = function (object, property) {
|
||||
delete object[property];
|
||||
};
|
||||
|
||||
Kotlin.jsonAddProperties = function (obj1, obj2) {
|
||||
for (var p in obj2) {
|
||||
if (obj2.hasOwnProperty(p)) {
|
||||
obj1[p] = obj2[p];
|
||||
}
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
|
||||
Kotlin.identityHashCode = getObjectHashCode;
|
||||
})(Kotlin);
|
||||
Kotlin.identityHashCode = getObjectHashCode;
|
||||
|
||||
|
||||
Vendored
+798
-802
File diff suppressed because it is too large
Load Diff
-12
@@ -1,12 +0,0 @@
|
||||
var require = (function () {
|
||||
var builtins = module.exports.kotlin;
|
||||
var propertyNames = Object.getOwnPropertyNames(builtins);
|
||||
Kotlin.kotlin = Kotlin.kotlin || {};
|
||||
for (var i = 0; i < propertyNames.length; ++i) {
|
||||
var propertyName = propertyNames[i];
|
||||
Kotlin.kotlin[propertyName] = builtins[propertyName];
|
||||
}
|
||||
return function() {
|
||||
return Kotlin;
|
||||
}
|
||||
})();
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
(function () {
|
||||
var stdlib = module.exports;
|
||||
function copyProperties(from, to) {
|
||||
var propertyNames = Object.getOwnPropertyNames(from);
|
||||
for (var i = 0; i < propertyNames.length; ++i) {
|
||||
var propertyName = propertyNames[i];
|
||||
if (propertyName in to) {
|
||||
copyProperties(from[propertyName], to[propertyName]);
|
||||
}
|
||||
else {
|
||||
to[propertyName] = from[propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
copyProperties(stdlib, Kotlin);
|
||||
})();
|
||||
+25
-20
@@ -1,24 +1,29 @@
|
||||
|
||||
var emulatedModules = { kotlin: kotlin };
|
||||
var module = { exports: {} };
|
||||
var emulatedModules = { kotlin: kotlin };
|
||||
var module = { exports: {} };
|
||||
|
||||
function require(moduleId) {
|
||||
return emulatedModules[moduleId];
|
||||
function require(moduleId) {
|
||||
return emulatedModules[moduleId];
|
||||
}
|
||||
|
||||
function __beginModule__() {
|
||||
module.exports = {};
|
||||
}
|
||||
|
||||
function __endModule__(moduleId) {
|
||||
emulatedModules[moduleId] = module.exports;
|
||||
}
|
||||
|
||||
function define(moduleId, dependencies, body) {
|
||||
var resolvedDependencies = [];
|
||||
emulatedModules[moduleId] = {};
|
||||
for (var i = 0; i < dependencies.length; ++i) {
|
||||
var dependencyName = dependencies[i];
|
||||
resolvedDependencies.push(emulatedModules[dependencyName === 'exports' ? moduleId : dependencyName]);
|
||||
}
|
||||
|
||||
function __beginModule__() {
|
||||
module.exports = {};
|
||||
var result = body.apply(null, resolvedDependencies);
|
||||
if (result != null) {
|
||||
emulatedModules[moduleId] = result;
|
||||
}
|
||||
|
||||
function __endModule__(moduleId) {
|
||||
emulatedModules[moduleId] = module.exports;
|
||||
}
|
||||
|
||||
function define(moduleId, dependencies, body) {
|
||||
var resolvedDependencies = [];
|
||||
for (var i = 0; i < dependencies.length; ++i) {
|
||||
resolvedDependencies.push(emulatedModules[dependencies[i]]);
|
||||
}
|
||||
emulatedModules[moduleId] = body.apply(null, resolvedDependencies);
|
||||
}
|
||||
define.amd = {};
|
||||
}
|
||||
define.amd = {};
|
||||
|
||||
Reference in New Issue
Block a user