JS: fix bug in fallback long implementation

This commit is contained in:
Alexey Andreev 2021-03-10 16:22:19 +03:00
parent daef74e7f1
commit 35f025d7da

View File

@ -724,6 +724,15 @@ function $dbg_class(obj) {
} }
return clsName; return clsName;
} }
function Long(lo, hi) {
this.lo = lo | 0;
this.hi = hi | 0;
}
Long.prototype.__teavm_class__ = function() {
return "long";
};
var Long_MAX_NORMAL = 1 << 18; var Long_MAX_NORMAL = 1 << 18;
var Long_ZERO; var Long_ZERO;
var Long_create; var Long_create;
@ -733,14 +742,6 @@ var Long_toNumber;
var Long_hi; var Long_hi;
var Long_lo; var Long_lo;
if (typeof BigInt !== "function") { if (typeof BigInt !== "function") {
function Long(lo, hi) {
this.lo = lo | 0;
this.hi = hi | 0;
}
Long.prototype.__teavm_class__ = function() {
return "long";
};
function Long_isPositive(a) { function Long_isPositive(a) {
return (a.hi & 0x80000000) === 0; return (a.hi & 0x80000000) === 0;
} }
@ -781,7 +782,7 @@ if (typeof BigInt !== "function") {
} }
} }
Long_create = function(lo, hi) { Long_create = function(lo, hi) {
return new Long(hi, lo); return new Long(lo, hi);
} }
Long_toNumber = function(val) { Long_toNumber = function(val) {
return 0x100000000 * val.hi + (val.lo >>> 0); return 0x100000000 * val.hi + (val.lo >>> 0);