Skip to content

Instantly share code, notes, and snippets.

@justinas
Created July 1, 2024 19:15
Show Gist options
  • Save justinas/9f3bb9cec262b08c8dfa2d52b269ab7c to your computer and use it in GitHub Desktop.
Save justinas/9f3bb9cec262b08c8dfa2d52b269ab7c to your computer and use it in GitHub Desktop.
// Generated by the V compiler
var $global = (new Function("return this"))();
function $ref(value) { if (value instanceof $ref) { return value; } this.val = value; }
$ref.prototype.valueOf = function() { return this.val; }
const $os = require("os");
const $process = process;
function checkDefine(key) {
if (globalThis.hasOwnProperty(key)) { return !!globalThis[key]; } return false;
}
function BreakException() {}
function ContinueException() {}
function ReturnException(val) { this.val = val; }
function Array_rune_arr_eq(a,b) {
if (a.arr.length != b.arr.length) {
return new bool(false);
}
for (let i = 0; i < a.len; ++i) {
if (!vEq(a.arr.get(new int(i)),b.arr.get(new int(i)))) {
return new bool(false);
}
}
return new bool(true);
}
function Array_int_contains(a,v) {
for (let i = 0; i < a.len; ++i) {
if (vEq(a.arr.get(new int(i)),v)) {
return new bool(true);
}
}
return new bool(false);
}
function compare_RepIndex_by_idx(a,b) {
if (a.val.idx.valueOf() < b.val.idx.valueOf()) return -1;
else return 1;
}
function Array_string_index(a, v) {
let pelem = a.arr;
for (let i = 0; i < pelem.arr.length; ++i) {
if (pelem.get(new int(i)).str == v.str) {
return new int(i);
}
}
return new int(-1);
}
function time__Duration_alias_eq(a,b) {
return new bool(vEq(a,b));
}
function Array_string_contains(a,v) {
for (let i = 0; i < a.len; ++i) {
if (a.arr.get(new int(i)).str == v.str) {
return new bool(true);
}
}
return new bool(false);
}
function time__FormatTime_str(it) { /* gen_str_for_enum */
switch(it) {
case time__FormatTime.hhmm12: return new string("hhmm12");
case time__FormatTime.hhmm24: return new string("hhmm24");
case time__FormatTime.hhmmss12: return new string("hhmmss12");
case time__FormatTime.hhmmss24: return new string("hhmmss24");
case time__FormatTime.hhmmss24_milli: return new string("hhmmss24_milli");
case time__FormatTime.hhmmss24_micro: return new string("hhmmss24_micro");
case time__FormatTime.hhmmss24_nano: return new string("hhmmss24_nano");
case time__FormatTime.no_time: return new string("no_time");
default: return new string("unknown enum value");
}
}
function time__FormatDate_str(it) { /* gen_str_for_enum */
switch(it) {
case time__FormatDate.ddmmyy: return new string("ddmmyy");
case time__FormatDate.ddmmyyyy: return new string("ddmmyyyy");
case time__FormatDate.mmddyy: return new string("mmddyy");
case time__FormatDate.mmddyyyy: return new string("mmddyyyy");
case time__FormatDate.mmmd: return new string("mmmd");
case time__FormatDate.mmmdd: return new string("mmmdd");
case time__FormatDate.mmmddyy: return new string("mmmddyy");
case time__FormatDate.mmmddyyyy: return new string("mmmddyyyy");
case time__FormatDate.no_date: return new string("no_date");
case time__FormatDate.yyyymmdd: return new string("yyyymmdd");
case time__FormatDate.yymmdd: return new string("yymmdd");
default: return new string("unknown enum value");
}
}
function Array_u8_str(a) { return indent_Array_u8_str(a, 0);}
function indent_Array_u8_str(a, indent_count) {
let sb = strings__new_builder(a.len * 10);
strings__Builder_write_string(sb, new string("["));
for (let i = 0; i < a.len; ++i) {
let it = a.arr.get(new int(i));
strings__Builder_write_string(sb, new string(""));
let x = u8_str_escaped( it);
strings__Builder_write_string(sb, x);
if (i < a.len-1) {
strings__Builder_write_string(sb, new string(", "));
}
}
strings__Builder_write_string(sb, new string("]"));
let res = strings__Builder_str(sb);
return res;
}
let wasmExportObject;
const loadRoutine = async () => {
}
// https://www.npmjs.com/package/fast-deep-equal - 3/3/2021
const envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
function vEq(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
// we want to convert all V types to JS for comparison.
if ('$toJS' in a)
a = a.$toJS();
if ('$toJS' in b)
b = b.$toJS();
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!vEq(a[i], b[i])) return false;
return true;
}
if (typeof Map != 'undefined') {
if ((a instanceof Map) && (b instanceof Map)) {
if (a.size !== b.size) return false;
for (i of a.entries())
if (!b.has(i[0])) return false;
for (i of a.entries())
if (!vEq(i[1], b.get(i[0]))) return false;
return true;
}
if ((a instanceof Set) && (b instanceof Set)) {
if (a.size !== b.size) return false;
for (i of a.entries())
if (!b.has(i[0])) return false;
return true;
}
}
if (typeof ArrayBuffer != 'undefined') {
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (a[i] !== b[i]) return false;
return true;
}
}
if (typeof RegExp != 'undefined') {
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (!vEq(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};
function $sortComparator(a, b)
{
a = a.$toJS();
b = b.$toJS();
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
/** @namespace strings */
function strings__Builder(val) { return val; }
/**
* @function
* @param {int} initial_size
* @returns {strings__Builder}
*/
function strings__new_builder(initial_size) {
try {
return new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} data
* @returns {void}
*/
function strings__Builder_write_byte(b, data) {
b = new $ref(b)
try {
array_push(b.valueOf(),data,false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function strings__Builder_clear(b) {
b = new $ref(b)
try {
/** @type {strings__Builder} */
b.val = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)})).val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} data
* @returns {void}
*/
function strings__Builder_write_u8(b, data) {
b = new $ref(b)
try {
array_push(b.valueOf(),data,false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} data
* @returns {int}
*/
function strings__Builder_write(b, data) {
b = new $ref(b)
try {
if ((new bool(data.len.valueOf() == new int(0).valueOf())).valueOf()) {
const _tmp1 = new _option({});
_tmp1.state = new u8(0);_tmp1.data = new int(0)
return _tmp1;}
array_push(b.valueOf(),data.arr.arr,true);
const _tmp2 = new _option({});
_tmp2.state = new u8(0);_tmp2.data = data.len
return _tmp2;} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {u8}
*/
function strings__Builder_byte_at(b, n) {
b = new $ref(b)
try {
{
return b.valueOf().arr.get(new int(n.valueOf()));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function strings__Builder_write_string(b, s) {
b = new $ref(b)
try {
if ((new bool(s.valueOf() == new string("").valueOf())).valueOf()) {
return;
}
for (const c of s.str.split('').map(c => new u8(c))) {
try {
array_push(b.valueOf(),c,false);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function strings__Builder_writeln(b, s) {
b = new $ref(b)
try {
if ((new bool(s.valueOf() != new string("").valueOf())).valueOf()) {
strings__Builder_write_string(b.valueOf(),s);
}
array_push(b.valueOf(),new int(10),false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function strings__Builder_str(b) {
b = new $ref(b)
try {
/** @type {string} */
const s = new string(new string(""));
for (const c of b.val.arr.arr)
s.str += String.fromCharCode(+c)
array_trim(b.valueOf(),new int(0));
return s;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_cut_last(b, n) {
b = new $ref(b)
try {
/** @type {int} */
const cut_pos = new int(new int( b.val.len.valueOf() - n.valueOf()));
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),cut_pos, b.valueOf().len);
/** @type {string} */
const res = new string(array_bytestr(x,));
array_trim(b.valueOf(),cut_pos);
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} pos
* @returns {void}
*/
function strings__Builder_go_back_to(b, pos) {
b = new $ref(b)
try {
array_trim(b.valueOf(),pos);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {void}
*/
function strings__Builder_go_back(b, n) {
b = new $ref(b)
try {
array_trim(b.valueOf(),new int( b.val.len.valueOf() - n.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} pos
* @returns {string}
*/
function strings__Builder_cut_to(b, pos) {
b = new $ref(b)
try {
if ((new bool(pos.valueOf() > b.val.len.valueOf())).valueOf()) {
return new string("");
}
return strings__Builder_cut_last(b.valueOf(),new int( b.val.len.valueOf() - pos.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_rune} runes
* @returns {void}
*/
function strings__Builder_write_runes(b, runes) {
b = new $ref(b)
try {
for (const r of runes) {
try {
/** @type {string} */
const res = new string(rune_str(r));
res.str = String.fromCharCode(r.val)
array_push(b.valueOf(),string_bytes(res,).arr.arr,true);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_after(b, n) {
b = new $ref(b)
try {
if ((new bool(n.valueOf() >= b.val.len.valueOf())).valueOf()) {
return new string("");
}
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),n, b.val.len);
return array_bytestr(x,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_last_n(b, n) {
b = new $ref(b)
try {
if ((new bool(n.valueOf() >= b.val.len.valueOf())).valueOf()) {
return new string("");
}
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),new int( b.val.len.valueOf() - n.valueOf()), b.val.len);
return array_bytestr(x,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/* [inline] */
/**
* @function
* @param {u16} a
* @param {u16} b
* @param {u16} c
* @returns {u16}
*/
function strings__min(a, b, c) {
try {
/** @type {u16} */
let m = new u16(a);
if ((new bool(b.valueOf() < m.valueOf())).valueOf()) {
/** @type {u16} */
m = new u16(b);
}
if ((new bool(c.valueOf() < m.valueOf())).valueOf()) {
/** @type {u16} */
m = new u16(c);
}
return m;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function strings__levenshtein_distance(a, b) {
try {
if ((new bool(a.len.valueOf() == new int(0).valueOf())).valueOf()) {
return b.len;
}
if ((new bool(b.len.valueOf() == new int(0).valueOf())).valueOf()) {
return a.len;
}
if ((new bool(a.valueOf() == b.valueOf())).valueOf()) {
return new int(0);
}
/** @type {Array_u16} */
let row = new array(new array_buffer({arr: (function(length) {
const _tmp3 = [];
for (let it = 0; it < length; it++) {
_tmp3.push(new u16(index));
};
return _tmp3;
})(new int( a.len.valueOf() + new int(1).valueOf())),len: new int(new int( a.len.valueOf() + new int(1).valueOf())), cap: new int(new int( a.len.valueOf() + new int(1).valueOf()))}));
for (let i = new int(new int(1)); +new bool(i.valueOf() < new int( b.len.valueOf() + new int(1).valueOf()).valueOf()); i.val ++) {
try {
let prev = new u16(new u16(i)); for (let j = new int(new int(1)); +new bool(j.valueOf() < new int( a.len.valueOf() + new int(1).valueOf()).valueOf()); j.val ++) {
try {
let current = new u16(row.arr.get(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf()))); if ((new bool(new u8(b.str.charCodeAt(new int( i.valueOf() - new int(1).valueOf()))).valueOf() != new u8(a.str.charCodeAt(new int( j.valueOf() - new int(1).valueOf()))).valueOf())).valueOf()) {
current = new u16(strings__min(new u16( row.arr.get(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf())).valueOf() + new int(1).valueOf()), new u16( prev.valueOf() + new int(1).valueOf()), new u16( row.arr.get(new int(j.valueOf())).valueOf() + new int(1).valueOf()))); }
row.arr.set(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf()),new u16(prev)); prev = new u16(current); } catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u16} */
row.arr.set(new int(a.len.valueOf()),new u16(prev));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return row.arr.get(new int(a.len.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {f32}
*/
function strings__levenshtein_distance_percentage(a, b) {
try {
/** @type {int} */
const d = new int(strings__levenshtein_distance(a, b));
/** @type {int} */
const l = new int(((new bool(a.len.valueOf() >= b.len.valueOf())).valueOf() ? a.len : b.len));
return new f32( (new f32( new f32(1.00).valueOf() - new f32( new f32(d).valueOf() / new f32(l).valueOf()).valueOf())).valueOf() * new f32(100.00).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s1
* @param {string} s2
* @returns {f32}
*/
function strings__dice_coefficient(s1, s2) {
try {
if ((new bool( new bool(s1.len.valueOf() == new int(0).valueOf()).valueOf() || new bool(s2.len.valueOf() == new int(0).valueOf()).valueOf())).valueOf()) {
return new f32(0.0);
}
if ((new bool(s1.valueOf() == s2.valueOf())).valueOf()) {
return new f32(1.0);
}
if ((new bool( new bool(s1.len.valueOf() < new int(2).valueOf()).valueOf() || new bool(s2.len.valueOf() < new int(2).valueOf()).valueOf())).valueOf()) {
return new f32(0.0);
}
/** @type {string} */
const a = new string(((new bool(s1.len.valueOf() > s2.len.valueOf())).valueOf() ? s1 : s2));
/** @type {string} */
const b = new string(((new bool(a.valueOf() == s1.valueOf())).valueOf() ? s2 : s1));
/** @type {Map_string_int} */
let first_bigrams = new map(
{});
for (let i = new int(0); i < new int( a.len.valueOf() - new int(1).valueOf()); i = new int(i + 1)) {
try {
/** @type {string} */
const bigram = new string(string_slice(a,i, new int_literal( i.valueOf() + new int(2).valueOf())));
/** @type {int} */
const q = new int(((first_bigrams.has(bigram.$toJS())).valueOf() ? new int( first_bigrams.get(bigram.$toJS()).valueOf() + new int(1).valueOf()) : new int(1)));
/** @type {int} */
first_bigrams.length++;
first_bigrams.map[bigram.$toJS()] = new int(q);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {int} */
let intersection_size = new int(new int(0));
for (let i = new int(0); i < new int( b.len.valueOf() - new int(1).valueOf()); i = new int(i + 1)) {
try {
/** @type {string} */
const bigram = new string(string_slice(b,i, new int_literal( i.valueOf() + new int(2).valueOf())));
/** @type {int} */
const count = new int(((first_bigrams.has(bigram.$toJS())).valueOf() ? first_bigrams.get(bigram.$toJS()) : new int(0)));
if ((new bool(count.valueOf() > new int(0).valueOf())).valueOf()) {
/** @type {int} */
first_bigrams.length++;
first_bigrams.map[bigram.$toJS()] = new int(new int( count.valueOf() - new int(1).valueOf()));
intersection_size.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new f32( (new f32( new f32(2.0).valueOf() * new f32(intersection_size).valueOf())).valueOf() / (new f32( new f32( new f32(a.len).valueOf() + new f32(b.len).valueOf()).valueOf() - new int(2).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/**
* @function
* @param {u8} c
* @param {int} n
* @returns {string}
*/
function strings__repeat(c, n) {
try {
if ((new bool(n.valueOf() <= new int(0).valueOf())).valueOf()) {
return new string("");
}
/** @type {Array_u8} */
const arr = array_repeat(new array(new array_buffer({arr: [new u8(c)], len: new int(1), cap: new int(1)})),n);
return array_bytestr(arr,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @param {int} n
* @returns {string}
*/
function strings__repeat_string(s, n) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = s.str.repeat(n.valueOf())
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/**
* @function
* @param {string} input
* @param {u8} start
* @param {u8} end
* @returns {string}
*/
function strings__find_between_pair_u8(input, start, end) {
try {
/** @type {int} */
let marks = new int(new int(0));
/** @type {int} */
let start_index = new int(new int(-1));
for (const [i, b] of Array.from(input.str.split('').entries(), ([i, b]) => [i, new u8(b)])) {
try {
if ((new bool(b.valueOf() == start.valueOf())).valueOf()) {
if ((new bool(start_index.valueOf() == new int(-1).valueOf())).valueOf()) {
/** @type {int} */
start_index = new int(new int( i.valueOf() + new int(1).valueOf()));
}
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(b.valueOf() == end.valueOf())).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return string_slice(input,start_index, i);
}
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} input
* @param {rune} start
* @param {rune} end
* @returns {string}
*/
function strings__find_between_pair_rune(input, start, end) {
try {
/** @type {int} */
let marks = new int(new int(0));
/** @type {int} */
let start_index = new int(new int(-1));
/** @type {Array_rune} */
const runes = string_runes(input,);
for (const [i, r] of runes.entries()) {
try {
if ((new bool(r.valueOf() == start.valueOf())).valueOf()) {
if ((new bool(start_index.valueOf() == new int(-1).valueOf())).valueOf()) {
/** @type {int} */
start_index = new int(new int( i.valueOf() + new int(1).valueOf()));
}
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(r.valueOf() == end.valueOf())).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return Array_rune_string(array_slice(runes,start_index, i),);
}
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} input
* @param {string} start
* @param {string} end
* @returns {string}
*/
function strings__find_between_pair_string(input, start, end) {
try {
/** @type {int} */
let start_index = new int(new int(-1));
/** @type {int} */
let marks = new int(new int(0));
/** @type {Array_rune} */
const start_runes = string_runes(start,);
/** @type {Array_rune} */
const end_runes = string_runes(end,);
/** @type {Array_rune} */
const runes = string_runes(input,);
/** @type {int} */
let i = new int(new int(0));
for (; +new bool(i.valueOf() < runes.len.valueOf()); i.val ++) {
try {
let start_slice = array_slice(runes,i, new int( i.valueOf() + start_runes.len.valueOf())); if ((new bool(Array_rune_arr_eq(start_slice, start_runes))).valueOf()) {
i = new int(new int( new int( i.valueOf() + start_runes.len.valueOf()).valueOf() - new int(1).valueOf())); if ((new bool(start_index.valueOf() < new int(0).valueOf())).valueOf()) {
start_index = new int(new int( i.valueOf() + new int(1).valueOf())); }
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
let end_slice = array_slice(runes,i, new int( i.valueOf() + end_runes.len.valueOf())); if ((new bool(Array_rune_arr_eq(end_slice, end_runes))).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return Array_rune_string(array_slice(runes,start_index, i),);
}
i = new int(new int( new int( i.valueOf() + end_runes.len.valueOf()).valueOf() - new int(1).valueOf())); continue;
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {Array_string}
*/
function strings__split_capital(s) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {int} */
let word_start = new int(new int(0));
for (const [idx, c] of Array.from(s.str.split('').entries(), ([idx, c]) => [idx, new u8(c)])) {
try {
if ((u8_is_capital(c,)).valueOf()) {
if ((new bool(word_start.valueOf() != idx.valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, idx),false);
}
/** @type {int} */
word_start = new int(idx);
continue;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(word_start.valueOf() != s.len.valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, s.len),false);
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/** @constant {u32} */
let math__bits__de_bruijn32 = undefined;
/** @constant {Array_fixed_u8_32} */
let math__bits__de_bruijn32tab = undefined;
/** @constant {u64} */
let math__bits__de_bruijn64 = undefined;
/** @constant {Array_fixed_u8_64} */
let math__bits__de_bruijn64tab = undefined;
/** @constant {u64} */
let math__bits__m0 = undefined;
/** @constant {u64} */
let math__bits__m1 = undefined;
/** @constant {u64} */
let math__bits__m2 = undefined;
/** @constant {u64} */
let math__bits__m3 = undefined;
/** @constant {u64} */
let math__bits__m4 = undefined;
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__leading_zeros_8(x) {
try {
return new int( new int(8).valueOf() - math__bits__len_8(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__leading_zeros_16(x) {
try {
return new int( new int(16).valueOf() - math__bits__len_16(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__leading_zeros_32(x) {
try {
return new int( new int(32).valueOf() - math__bits__len_32(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__leading_zeros_64(x) {
try {
return new int( new int(64).valueOf() - math__bits__len_64(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__trailing_zeros_8(x) {
try {
return new int(math__bits__ntz_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__trailing_zeros_16(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(16);
}
return new int(math__bits__de_bruijn32tab.arr.get(new int(new u32( new u32( new u32(new u16( x.valueOf() & -x.val .valueOf())).valueOf() * math__bits__de_bruijn32.valueOf()).valueOf() >> (new int(27)).valueOf()).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__trailing_zeros_32(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(32);
}
return new int(math__bits__de_bruijn32tab.arr.get(new int(new u32( new u32( (new u32( x.valueOf() & -x.val .valueOf())).valueOf() * math__bits__de_bruijn32.valueOf()).valueOf() >> (new int(27)).valueOf()).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__trailing_zeros_64(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(64);
}
return new int(math__bits__de_bruijn64tab.arr.get(new int(new u64( BigInt(new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt(-x.val .valueOf()))).valueOf()) * BigInt(math__bits__de_bruijn64.valueOf())).valueOf()) >> BigInt((new int(58)).valueOf())).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__ones_count_8(x) {
try {
return new int(math__bits__pop_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__ones_count_16(x) {
try {
return new int(new u8( math__bits__pop_8_tab.arr.get(new int(new u16( x.valueOf() >> new int(8).valueOf()).valueOf())).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u16( x.valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__ones_count_32(x) {
try {
return new int(new u8( new u8( new u8( math__bits__pop_8_tab.arr.get(new int(new u32( x.valueOf() >> new int(24).valueOf()).valueOf())).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( new u32( x.valueOf() >> new int(16).valueOf()).valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( new u32( x.valueOf() >> new int(8).valueOf()).valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( x.valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__ones_count_64(x) {
try {
/** @type {u64} */
let y = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(1n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) + BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
y = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(2n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) + BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
y = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(4).valueOf()))).valueOf()) + BigInt(y.valueOf()))).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(8).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(16).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
return new int( new int(y).valueOf() & (new int_literal( (new int(128)).valueOf() - new int(1).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {u8} */
let math__bits__n8 = undefined;
/** @constant {u16} */
let math__bits__n16 = undefined;
/** @constant {u32} */
let math__bits__n32 = undefined;
/** @constant {u64} */
let math__bits__n64 = undefined;
/* [inline] */
/**
* @function
* @param {u8} x
* @param {int} k
* @returns {u8}
*/
function math__bits__rotate_left_8(x, k) {
try {
/** @type {u8} */
const s = new u8(new u8( new u8(k).valueOf() & (new u8( math__bits__n8.valueOf() - new int(1).valueOf())).valueOf()));
return new u8( (new u8( x.valueOf() << s.valueOf())).valueOf() | (new u8( x.valueOf() >> (new u8( math__bits__n8.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @param {int} k
* @returns {u16}
*/
function math__bits__rotate_left_16(x, k) {
try {
/** @type {u16} */
const s = new u16(new u16( new u16(k).valueOf() & (new u16( math__bits__n16.valueOf() - new int(1).valueOf())).valueOf()));
return new u16( (new u16( x.valueOf() << s.valueOf())).valueOf() | (new u16( x.valueOf() >> (new u16( math__bits__n16.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @param {int} k
* @returns {u32}
*/
function math__bits__rotate_left_32(x, k) {
try {
/** @type {u32} */
const s = new u32(new u32( new u32(k).valueOf() & (new u32( math__bits__n32.valueOf() - new int(1).valueOf())).valueOf()));
return new u32( (new u32( x.valueOf() << s.valueOf())).valueOf() | (new u32( x.valueOf() >> (new u32( math__bits__n32.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @param {int} k
* @returns {u64}
*/
function math__bits__rotate_left_64(x, k) {
try {
/** @type {u64} */
const s = new u64(new u64( BigInt(new u64(k).valueOf()) & BigInt((new u64( BigInt(math__bits__n64.valueOf()) - BigInt(new u64(BigInt(1n)).valueOf()))).valueOf())));
return new u64( BigInt((new u64( BigInt(x.valueOf()) << BigInt(s.valueOf()))).valueOf()) | BigInt((new u64( BigInt(x.valueOf()) >> BigInt((new u64( BigInt(math__bits__n64.valueOf()) - BigInt(s.valueOf()))).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u8} x
* @returns {u8}
*/
function math__bits__reverse_8(x) {
try {
return math__bits__rev_8_tab.arr.get(new int(x.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @returns {u16}
*/
function math__bits__reverse_16(x) {
try {
return new u16( new u16(math__bits__rev_8_tab.arr.get(new int(new u16( x.valueOf() >> new int(8).valueOf()).valueOf()))).valueOf() | (new u16( new u16(math__bits__rev_8_tab.arr.get(new int(new u16( x.valueOf() & new int(0xff).valueOf()).valueOf()))).valueOf() << new int(8).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @returns {u32}
*/
function math__bits__reverse_32(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u32( x.valueOf() >> new int(1).valueOf()).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(1).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new int(2).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(2).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new int(4).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(4).valueOf()))).valueOf()))));
return math__bits__reverse_bytes_32(new u32(y));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @returns {u64}
*/
function math__bits__reverse_64(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(1n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(1).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(2n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(2).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(4n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(4).valueOf()))).valueOf()))));
return math__bits__reverse_bytes_64(y);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @returns {u16}
*/
function math__bits__reverse_bytes_16(x) {
try {
return new u16( (new u16( x.valueOf() >> new int(8).valueOf())).valueOf() | (new u16( x.valueOf() << new int(8).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @returns {u32}
*/
function math__bits__reverse_bytes_32(x) {
try {
/** @type {u64} */
const y = new u64((new u64( BigInt((new u64( BigInt(new u32( x.valueOf() >> new int(8).valueOf()).valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(8).valueOf()))).valueOf()))));
return new u32(new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(16).valueOf()))).valueOf()) | BigInt((new u64( BigInt(y.valueOf()) << BigInt(new int(16).valueOf()))).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @returns {u64}
*/
function math__bits__reverse_bytes_64(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(8n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new u64(BigInt(8n)).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(16n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m4.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m4.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new u64(BigInt(16n)).valueOf()))).valueOf()))));
return new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf()) | BigInt((new u64( BigInt(y.valueOf()) << BigInt(new int(32).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__len_8(x) {
try {
return new int(math__bits__len_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__len_16(x) {
try {
/** @type {u16} */
let y = new u16(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= new int(256).valueOf())).valueOf()) {
/** @type {u16} */
y.val = Math.floor(y >> new u16(new int(8)));
/** @type {int} */
n = new int(new int(8));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__len_32(x) {
try {
/** @type {u32} */
let y = new u32(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= (new int(65536)).valueOf())).valueOf()) {
/** @type {u32} */
y.val = Math.floor(y >> new u32(new int(16)));
/** @type {int} */
n = new int(new int(16));
}
if ((new bool(y.valueOf() >= (new int(256)).valueOf())).valueOf()) {
/** @type {u32} */
y.val = Math.floor(y >> new u32(new int(8)));
/** @type {int} */
n.val = Math.floor(n + new int(new int(8)));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__len_64(x) {
try {
/** @type {u64} */
let y = new u64(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(32n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(32));
/** @type {int} */
n = new int(new int(32));
}
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(16n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(16));
/** @type {int} */
n.val = Math.floor(n + new int(new int(16)));
}
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(8n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(8));
/** @type {int} */
n.val = Math.floor(n + new int(new int(8)));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @param {u32} y
* @param {u32} carry
* @returns {multi_return_u32_u32}
*/
function math__bits__add_32(x, y, carry) {
try {
/** @type {u64} */
const sum64 = new u64(new u64( BigInt(new u64( BigInt(new u64(x).valueOf()) + BigInt(new u64(y).valueOf())).valueOf()) + BigInt(new u64(carry).valueOf())));
/** @type {u32} */
const sum = new u32(new u32(sum64));
/** @type {u32} */
const carry_out = new u32(new u32(new u64( BigInt(sum64.valueOf()) >> BigInt(new int(32).valueOf()))));
return [sum, carry_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @param {u64} carry
* @returns {multi_return_u64_u64}
*/
function math__bits__add_64(x, y, carry) {
try {
/** @type {u64} */
const sum = new u64(new u64( BigInt(new u64( BigInt(x.valueOf()) + BigInt(y.valueOf())).valueOf()) + BigInt(carry.valueOf())));
/** @type {u64} */
const carry_out = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt(y.valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) | BigInt(y.valueOf()))).valueOf()) & BigInt(~sum.val .valueOf()))).valueOf()))).valueOf()) >> BigInt(new int(63).valueOf())));
return [sum, carry_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @param {u32} y
* @param {u32} borrow
* @returns {multi_return_u32_u32}
*/
function math__bits__sub_32(x, y, borrow) {
try {
/** @type {u32} */
const diff = new u32(new u32( new u32( x.valueOf() - y.valueOf()).valueOf() - borrow.valueOf()));
/** @type {u32} */
const borrow_out = new u32(new u32( (new u32( (new u32( ~x.val .valueOf() & y.valueOf())).valueOf() | (new u32( ~(new u32( x.valueOf() ^ y.valueOf())).val .valueOf() & diff.valueOf())).valueOf())).valueOf() >> new int(31).valueOf()));
return [diff, borrow_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @param {u64} borrow
* @returns {multi_return_u64_u64}
*/
function math__bits__sub_64(x, y, borrow) {
try {
/** @type {u64} */
const diff = new u64(new u64( BigInt(new u64( BigInt(x.valueOf()) - BigInt(y.valueOf())).valueOf()) - BigInt(borrow.valueOf())));
/** @type {u64} */
const borrow_out = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(~x.val .valueOf()) & BigInt(y.valueOf()))).valueOf()) | BigInt((new u64( BigInt(~(new u64( BigInt(x.valueOf()) ^ BigInt(y.valueOf()))).val .valueOf()) & BigInt(diff.valueOf()))).valueOf()))).valueOf()) >> BigInt(new int(63).valueOf())));
return [diff, borrow_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {u64} */
let math__bits__two32 = undefined;
/** @constant {u64} */
let math__bits__mask32 = undefined;
/** @constant {string} */
const math__bits__overflow_error = new string("Overflow Error");
/** @constant {string} */
const math__bits__divide_error = new string("Divide Error");
/**
* @function
* @param {u32} x
* @param {u32} y
* @returns {multi_return_u32_u32}
*/
function math__bits__mul_32(x, y) {
try {
/** @type {u64} */
const tmp = new u64(new u64( BigInt(new u64(x).valueOf()) * BigInt(new u64(y).valueOf())));
/** @type {u32} */
const hi = new u32(new u32(new u64( BigInt(tmp.valueOf()) >> BigInt(new int(32).valueOf()))));
/** @type {u32} */
const lo = new u32(new u32(tmp));
return [hi, lo];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @returns {multi_return_u64_u64}
*/
function math__bits__mul_64(x, y) {
try {
/** @type {u64} */
const x0 = new u64(new u64( BigInt(x.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const x1 = new u64(new u64( BigInt(x.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const y0 = new u64(new u64( BigInt(y.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const y1 = new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const w0 = new u64(new u64( BigInt(x0.valueOf()) * BigInt(y0.valueOf())));
/** @type {u64} */
const t = new u64(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y0.valueOf())).valueOf()) + BigInt((new u64( BigInt(w0.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
let w1 = new u64(new u64( BigInt(t.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const w2 = new u64(new u64( BigInt(t.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
w1.val = w1 + new u64(new u64( BigInt(x0.valueOf()) * BigInt(y1.valueOf())));
/** @type {u64} */
const hi = new u64(new u64( BigInt(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y1.valueOf())).valueOf()) + BigInt(w2.valueOf())).valueOf()) + BigInt((new u64( BigInt(w1.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
const lo = new u64(new u64( BigInt(x.valueOf()) * BigInt(y.valueOf())));
return [hi, lo];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} hi
* @param {u32} lo
* @param {u32} y
* @returns {multi_return_u32_u32}
*/
function math__bits__div_32(hi, lo, y) {
try {
if ((new bool( new bool(y.valueOf() != new int(0).valueOf()).valueOf() && new bool(y.valueOf() <= hi.valueOf()).valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
/** @type {u64} */
const z = new u64(new u64( BigInt((new u64( BigInt(new u64(hi).valueOf()) << BigInt(new int(32).valueOf()))).valueOf()) | BigInt(new u64(lo).valueOf())));
/** @type {u32} */
const quo = new u32(new u32(new u64( BigInt(z.valueOf()) / BigInt(new u64(y).valueOf()))));
/** @type {u32} */
const rem = new u32(new u32(new u64( BigInt(z.valueOf()) % BigInt(new u64(y).valueOf()))));
return [quo, rem];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} hi
* @param {u64} lo
* @param {u64} y1
* @returns {multi_return_u64_u64}
*/
function math__bits__div_64(hi, lo, y1) {
try {
/** @type {u64} */
let y = new u64(y1);
if ((new bool(y.valueOf() == new int(0).valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
if ((new bool(y.valueOf() <= hi.valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
/** @type {u32} */
const s = new u32(new u32(math__bits__leading_zeros_64(y)));
/** @type {u64} */
y.val = y << new u64(s);
/** @type {u64} */
const yn1 = new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const yn0 = new u64(new u64( BigInt(y.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const ss1 = new u64((new u64( BigInt(hi.valueOf()) << BigInt(s.valueOf()))));
/** @type {u32} */
const xxx = new u32(new u32( new int(64).valueOf() - s.valueOf()));
/** @type {u64} */
let ss2 = new u64(new u64( BigInt(lo.valueOf()) >> BigInt(xxx.valueOf())));
if ((new bool(xxx.valueOf() == new int(64).valueOf())).valueOf()) {
/** @type {u64} */
ss2 = new u64(new int(0));
}
/** @type {u64} */
const un32 = new u64(new u64( BigInt(ss1.valueOf()) | BigInt(ss2.valueOf())));
/** @type {u64} */
const un10 = new u64(new u64( BigInt(lo.valueOf()) << BigInt(s.valueOf())));
/** @type {u64} */
const un1 = new u64(new u64( BigInt(un10.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const un0 = new u64(new u64( BigInt(un10.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
let q1 = new u64(new u64( BigInt(un32.valueOf()) / BigInt(yn1.valueOf())));
/** @type {u64} */
let rhat = new u64(new u64( BigInt(un32.valueOf()) - BigInt((new u64( BigInt(q1.valueOf()) * BigInt(yn1.valueOf()))).valueOf())));
while (+new bool( new bool(q1.valueOf() >= math__bits__two32.valueOf()).valueOf() || new bool((new u64( BigInt(q1.valueOf()) * BigInt(yn0.valueOf()))).valueOf() > (new u64( BigInt((new u64( BigInt(math__bits__two32.valueOf()) * BigInt(rhat.valueOf()))).valueOf()) + BigInt(un1.valueOf()))).valueOf()).valueOf())) {
try {
q1.val --;
/** @type {u64} */
rhat.val = rhat + new u64(yn1);
if ((new bool(rhat.valueOf() >= math__bits__two32.valueOf())).valueOf()) {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
const un21 = new u64(new u64( BigInt((new u64( BigInt(un32.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt((new u64( BigInt(un1.valueOf()) - BigInt((new u64( BigInt(q1.valueOf()) * BigInt(y.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
let q0 = new u64(new u64( BigInt(un21.valueOf()) / BigInt(yn1.valueOf())));
/** @type {u64} */
rhat = new u64(new u64( BigInt(un21.valueOf()) - BigInt(new u64( BigInt(q0.valueOf()) * BigInt(yn1.valueOf())).valueOf())));
while (+new bool( new bool(q0.valueOf() >= math__bits__two32.valueOf()).valueOf() || new bool((new u64( BigInt(q0.valueOf()) * BigInt(yn0.valueOf()))).valueOf() > (new u64( BigInt((new u64( BigInt(math__bits__two32.valueOf()) * BigInt(rhat.valueOf()))).valueOf()) + BigInt(un0.valueOf()))).valueOf()).valueOf())) {
try {
q0.val --;
/** @type {u64} */
rhat.val = rhat + new u64(yn1);
if ((new bool(rhat.valueOf() >= math__bits__two32.valueOf())).valueOf()) {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
const qq = new u64((new u64( BigInt((new u64( BigInt(q1.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt(q0.valueOf()))));
/** @type {u64} */
const rr = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt((new u64( BigInt(un21.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt(un0.valueOf())).valueOf()) - BigInt((new u64( BigInt(q0.valueOf()) * BigInt(y.valueOf()))).valueOf()))).valueOf()) >> BigInt(s.valueOf())));
return [qq, rr];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} hi
* @param {u32} lo
* @param {u32} y
* @returns {u32}
*/
function math__bits__rem_32(hi, lo, y) {
try {
return new u32(new u64( BigInt((new u64( BigInt((new u64( BigInt(new u64(hi).valueOf()) << BigInt(new int(32).valueOf()))).valueOf()) | BigInt(new u64(lo).valueOf()))).valueOf()) % BigInt(new u64(y).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} hi
* @param {u64} lo
* @param {u64} y
* @returns {u64}
*/
function math__bits__rem_64(hi, lo, y) {
try {
let [, rem] = math__bits__div_64(new u64( BigInt(hi.valueOf()) % BigInt(y.valueOf())), lo, y);
return rem;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} x
* @returns {multi_return_f64_int}
*/
function math__bits__normalize(x) {
try {
/** @type {f64} */
const smallest_normal = new f64(new f32(2.2250738585072014e-308));
if ((new bool((((new bool(x.valueOf() > new f32(0.0).valueOf())).valueOf() ? x : -x.val )).valueOf() < smallest_normal.valueOf())).valueOf()) {
return [new f64( BigInt(x.valueOf()) * BigInt((new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(52n)).valueOf()))).valueOf())), new int(-52)];
}
return [x, new int(0)];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/** @constant {Array_fixed_u8_256} */
let math__bits__ntz_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__pop_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__rev_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__len_8_tab = undefined;
/** @namespace math.bits */
/**
* @function
* @param {f32} f
* @returns {u32}
*/
function math__bits__f32_bits(f) {
try {
/** @type {u32} */
const p = new u32(new int(0));
let buffer = new ArrayBuffer(4)
let floatArr = new Float32Array(buffer)
floatArr[0] = f.val
let uintArr = new Uint32Array(buffer)
p.val = uintArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} b
* @returns {f32}
*/
function math__bits__f32_from_bits(b) {
try {
/** @type {f32} */
const p = new f32(new f32(0.0));
let buffer = new ArrayBuffer(4)
let floatArr = new Float32Array(buffer)
let uintArr = new Uint32Array(buffer)
uintArr[0] = Number(b.val)
p.val = floatArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} f
* @returns {u64}
*/
function math__bits__f64_bits(f) {
try {
/** @type {u64} */
const p = new u64(new u64(BigInt(0n)));
let buffer = new ArrayBuffer(8)
let floatArr = new Float64Array(buffer)
floatArr[0] = f.val
let uintArr = new BigUint64Array(buffer)
p.val = uintArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} b
* @returns {f64}
*/
function math__bits__f64_from_bits(b) {
try {
/** @type {f64} */
const p = new f64(new f32(0.0));
let buffer = new ArrayBuffer(8)
let floatArr = new Float64Array(buffer)
let uintArr = new BigUint64Array(buffer)
uintArr[0] = b.val
p.val = floatArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/* [inline] */
/**
* @function
* @param {f32} f
* @returns {u32}
*/
function math__bits__pure_v_but_overridden_by_js_f32_bits(f) {
try {
/** @type {u32} */
const p = new u32((new $ref(new u32(new $ref(f)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} b
* @returns {f32}
*/
function math__bits__pure_v_but_overridden_by_js_f32_from_bits(b) {
try {
/** @type {f32} */
const p = new f32((new $ref(new f32(new $ref(b)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f64} f
* @returns {u64}
*/
function math__bits__pure_v_but_overridden_by_js_f64_bits(f) {
try {
/** @type {u64} */
const p = new u64((new $ref(new u64(new $ref(f)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} b
* @returns {f64}
*/
function math__bits__pure_v_but_overridden_by_js_f64_from_bits(b) {
try {
/** @type {f64} */
const p = new f64((new $ref(new f64(new $ref(b)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
function i8(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
i8.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function i8__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function i16(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
i16.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function i16__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function int(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
int.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function int__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function i64(val) { if (val === undefined) { val = BigInt(0); }this.val = BigInt.asIntN(64,BigInt(val)) }
i64.prototype = {
val: BigInt(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return this.val },
};
function i64__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u8(val) { if (val === undefined) { val = new Number(0); }if (typeof(val) == "string") { this.val = val.charCodeAt() } else if (val instanceof string) { this.val = val.str.charCodeAt(); } else { this.val = Math.round(Number(val)) } }
u8.prototype = {
val: new Number(0),
valueOf() { return this.val | 0 },
toString() { return new string(this.val + "") },
$toJS() { return +this },
};
function u8__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u16(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffff) >>> 0 }
u16.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function u16__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u32(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) >>> 0 }
u32.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function u32__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u64(val) { if (val === undefined) { val = BigInt(0); }this.val = BigInt.asUintN(64,BigInt(val)) }
u64.prototype = {
val: BigInt(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return this.val },
};
function u64__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function f32(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
f32.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function f32__eq(self,other) { return self.val === other.val; }
function f64(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
f64.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function f64__eq(self,other) { return self.val === other.val; }
function int_literal(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
int_literal.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function int_literal__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function float_literal(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
float_literal.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function float_literal__eq(self,other) { return self.val === other.val; }
function bool(val) { if (val === undefined) { val = new Boolean(false); }this.val = val instanceof bool ? val.val : +val !== 0 }
bool.prototype = {
val: new Boolean(false),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this != 0 },
};
function bool__eq(self,other) { return new bool(self.val === other.valueOf()); }
function string(str) { if (str === undefined) { str = new String(""); }this.str = str.toString(); this.len = this.str.length }
string.prototype = {
str: new String(""),
valueOf() { return this.str },
toString() { return this.str },
$toJS() { return this.str },
};
function string__eq(self,other) { return new bool(self.str === other.str); }
function map(map) { if (map === undefined) { map = new map({}); }this.map = map; this.length = 0; }
map.prototype = {
map: new map({}),
valueOf() { return this },
toString() { return this.map.toString() },
$toJS() { return this.map },
};
function map__eq(self,other) { return new bool(vEq(self, other)); }
function array(arr) { if (arr === undefined) { arr = new array_buffer({}); }this.arr = arr
if (arr.index_start.val != 0 || arr.has_slice.val) { v_makeSlice(this); } }
array.prototype = {
arr: new array_buffer({}),
valueOf() { return this },
toString() { return JSON.stringify(this.arr.map(it => it.valueOf())) },
$toJS() { return this.arr },
};
function array__eq(self,other) { return new bool(vEq(self, other)); }
function rune(val) { if (val === undefined) { val = new Number(0); }val = val.valueOf(); if (typeof val == "string") {this.val = val.charCodeAt();} else if (val instanceof string) { this.val = val.str.charCodeAt(); } else { this.val = val | 0 } }
rune.prototype = {
val: new Number(0),
valueOf() { return this.val | 0 },
toString() { return new string(this.val + "") },
$toJS() { return +this },
};
function rune__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function any(any) { if (any === undefined) { any = null; }this.val = any }
any.prototype = {
any: null,
valueOf() { return this.val },
toString() { return "&" + this.val },
$toJS() { return this.val.$toJS() },
};
function any__eq(self,other) { return new bool(self == other); }
function voidptr(val) { if (val === undefined) { val = null; }this.val = val; }
voidptr.prototype = {
val: null,
valueOf() { return this },
toString() { return "voidptr(" + this.val + ")" },
$toJS() { return this.val },
};
function voidptr__eq(self,other) { return this.val === other.val; }
Object.defineProperty(array.prototype,"len", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } });
Object.defineProperty(map.prototype,"len", { get: function() {return new int(this.length);}, set: function(l) { } });
Object.defineProperty(array.prototype,"length", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } });
/**
* @constructor
* @param {{arr?: Array, index_start?: int, len?: int, cap?: int, has_slice?: bool}} init
*/
function array_buffer({ arr = undefined, index_start = new int(0), len = new int(0), cap = new int(0), has_slice = new bool(false) }) {
this.arr = arr
this.index_start = index_start
this.len = len
this.cap = cap
this.has_slice = has_slice
};
array_buffer.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `array_buffer { arr: ${this["arr"].toString()} , index_start: ${this["index_start"].toString()} , len: ${this["len"].toString()} , cap: ${this["cap"].toString()} , has_slice: ${this["has_slice"].toString()} }`
},
/** @type {Array} */
arr: undefined,
/** @type {int} */
index_start: new int(0),
/** @type {int} */
len: new int(0),
/** @type {int} */
cap: new int(0),
/** @type {bool} */
has_slice: new bool(false),
$toJS() { return this; }
};
/**
* @function
* @returns {void}
*/
function array_buffer_make_copy(a) {
a = new $ref(a)
try {
if ((new bool( new bool(a.val.index_start.valueOf() != new int(0).valueOf()).valueOf() || a.val.has_slice.valueOf())).valueOf()) {
/** @type {Array} */
let new_arr = makeEmptyJSArray();
for (let i = new int(0); i < a.val.len; i = new int(i + 1)) {
try {
new_arr.push(a.val.get(i))
/** @type {int} */
let x = new int(i);
/** @type {int} */
x = new int(x);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Array} */
new_arr = new_arr;
a.val.arr = new_arr
a.val.index_start = new int(0)
a.val.has_slice = new bool(false)
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array_buffer.prototype.make_copy = function() { return array_buffer_make_copy(this) }
/**
* @function
* @param {int} ix
* @returns {voidptr}
*/
function array_buffer_get(a, ix) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr[a.index_start.val + ix.val];
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} ix
* @param {voidptr} val
* @returns {void}
*/
function array_buffer_set(a, ix, val) {
a = new $ref(a)
try {
a.val.arr[a.val.index_start.valueOf() + ix.valueOf()] = val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array_buffer.prototype.get = function(ix) { return array_buffer_get(this,ix);}
array_buffer.prototype.set = function(ix,val) { array_buffer_set(this,ix,val); }
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr_voidptr__int} comparator
* @returns {void}
*/
function v_sort(arr, comparator) {
arr = new $ref(arr)
try {
/** @type {bool} */
let need_iter = new bool(new bool(true));
while (+need_iter) {
try {
/** @type {bool} */
need_iter = new bool(new bool(false));
for (let i = new int(new int(1)); +new bool(i.valueOf() < arr.val.len.valueOf()); i.val ++) {
try {
if ((new bool(comparator(arr.valueOf().arr.get(new int(i.valueOf())), arr.valueOf().arr.get(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()))).valueOf() != new int(1).valueOf())).valueOf()) {
let tmp = arr.valueOf().arr.get(new int(i.valueOf())); arr.valueOf().arr.set(new int(i.valueOf()),arr.valueOf().arr.get(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()))); arr.valueOf().arr.set(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()),tmp); need_iter = new bool(new bool(true)); }
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} index
* @returns {void}
*/
function array_trim(a, index) {
a = new $ref(a)
try {
if ((new bool(index.valueOf() < a.val.len.valueOf())).valueOf()) {
/** @type {int} */
a.val.len = new int(index);
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
function flatIntoArray(target, source, sourceLength, targetIndex, depth) {
"use strict";
for (var sourceIndex = 0; sourceIndex < sourceLength; ++sourceIndex) {
if (sourceIndex in source) {
var element = source[sourceIndex];
if (depth > 0 && Array.isArray(element))
targetIndex = flatIntoArray(target, element, element.length, targetIndex, depth - 1);
else {
target[targetIndex] = element;
++targetIndex;
}
}
}
return targetIndex;
}
function flatArray(target,depth) {
var array = target
var length = array.length;
var depthNum = 1;
if (depth !== undefined)
depthNum = +depth
var result = []
flatIntoArray(result, array, length, 0, depthNum);
return result;
}
/* [unsafe] */
/**
* @function
* @param {int} count
* @param {int} depth
* @returns {array}
*/
function array_repeat_to_depth(a, count, depth) {
try {
if ((new bool(count.valueOf() < new int(0).valueOf())).valueOf()) {
builtin__panic (new string(`array.repeat: count is negative: ${int_str(count)}`));
}
/** @type {array} */
let arr = empty_array();
if ((new bool(a.len.valueOf() > new int(0).valueOf())).valueOf()) {
for (let _tmp4 = new int(0); _tmp4 < count; _tmp4 = new int(_tmp4 + 1)) {
try {
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
if ((new bool(depth.valueOf() > new int(0).valueOf())).valueOf()) {
} else {
array_push(arr,array_buffer_get(a.arr,i));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_last(a) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr.get(new int(a.len-1));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} ix
* @returns {voidptr}
*/
function array_get(a, ix) {
try {
/** @type {voidptr} */
let result = null;
result = a.arr.get(ix)
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {array}
*/
function array_repeat(a, count) {
try {
{
return array_repeat_to_depth(a,count, new int(0));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
function makeEmptyArray() { return new array(new array_buffer({ arr: [], len: new int(0), index_start: new int(0), cap: new int(0) })); }
function makeEmptyJSArray() { return new Array(); }
/**
* @function
* @returns {array}
*/
function empty_array() {
try {
return makeEmptyArray();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @returns {void}
*/
function array_set_len(a, i) {
a = new $ref(a)
try {
a.arr.arr.length=i
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} compare
* @returns {void}
*/
function array_sort_with_compare(a, compare) {
a = new $ref(a)
try {
v_sort(a, compare);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} compare
* @returns {void}
*/
function array_sort_with_compare_old(a, compare) {
a = new $ref(a)
try {
a.val.arr.arr.sort(compare)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_sort(a) {
a = new $ref(a)
try {
a.val.arr.arr.sort($sortComparator)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} v
* @returns {int}
*/
function array_index(a, v) {
try {
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
if (a.arr.get(i).toString() == v.toString())
{
return i;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} start
* @param {int} end
* @returns {array}
*/
function array_slice(a, start, end) {
try {
/** @type {array} */
let result = a;
let slice = a.arr.arr.slice(start,end)
result = new array(new array_buffer({arr: a.arr.arr, len: new int(slice.length),cap: new int(slice.length),index_start: new int(start),has_slice: new bool(true)}))
a.arr.has_slice = true
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {voidptr} val
* @returns {void}
*/
function array_insert(a, i, val) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.splice(i,0,val)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {voidptr} val
* @param {int} size
* @returns {void}
*/
function array_insert_many(a, i, val, size) {
a = new $ref(a)
try {
a.val.arr.arr.splice(i,0,...val.arr.slice(0,+size))
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} val
* @returns {void}
*/
function array_push(a, val) {
a = new $ref(a)
try {
a.val.arr.make_copy()
if (arguments[2] && arguments[2].valueOf()) {a.val.arr.arr.push(...val)} else {
a.val.arr.arr.push(val)
}
a.val.arr.len.val += 1
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr__bool} callback
* @returns {array}
*/
function v_filter(arr, callback) {
try {
/** @type {array} */
let filtered = empty_array();
for (let i = new int(new int(0)); +new bool(i.valueOf() < arr.arr.len.valueOf()); i.val ++) {
try {
if ((callback(array_buffer_get(arr.arr,i))).valueOf()) {
array_push(filtered,array_buffer_get(arr.arr,i));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return filtered;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr__voidptr} callback
* @returns {array}
*/
function v_map(arr, callback) {
try {
/** @type {array} */
let mapped = empty_array();
for (let i = new int(new int(0)); +new bool(i.valueOf() < arr.arr.len.valueOf()); i.val ++) {
try {
array_push(mapped,callback(array_buffer_get(arr.arr,i)));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return mapped;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{ix?: int, end?: int, arr?: Array}} init
*/
function array_iterator({ ix = new int(0), end = new int(0), arr = undefined }) {
this.ix = ix
this.end = end
this.arr = arr
};
array_iterator.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `array_iterator { ix: ${this["ix"].toString()} , end: ${this["end"].toString()} , arr: ${this["arr"].toString()} }`
},
/** @type {int} */
ix: new int(0),
/** @type {int} */
end: new int(0),
/** @type {Array} */
arr: undefined,
$toJS() { return this; }
};
array_iterator.prototype.next = function () {
if (this.ix.val < this.end.val) {
this.ix.val++;
return {done: false, value: this.arr.arr.get(new int(this.ix.val-1))}
} else {
return {done: true, value: undefined}
}
}
array_iterator.prototype[Symbol.iterator] = function () { return this; }
array.prototype[Symbol.iterator] = function () { return new array_iterator({ix: new int(0),end: new int(this.arr.len),arr: this}); }
array.prototype.entries = function () { let result = []; for (let key = this.arr.index_start.val;key < this.arr.len.val;key++) { result.push([new int(key), this.arr.get(new int(key))]); } return result[Symbol.iterator](); }
array.prototype.map = function(callback) { return v_map(this,callback); }
array.prototype.filter = function(callback) { return v_filter(this,callback); }
Object.defineProperty(array.prototype,'cap',{ get: function () { return this.len; } })
array.prototype.any = function (value) {
let val ;if (typeof value == 'function') { val = function (x) { return value(x); } } else { val = function (x) { return vEq(x,value); } }
for (let i = 0;i < this.arr.arr.length;i++)
if (val(this.arr.get(i)))
return true;
return false;
}
array.prototype.all = function (value) {
let val ;if (typeof value == 'function') { val = function (x) { return value(x); } } else { val = function (x) { return vEq(x,value); } }
for (let i = 0;i < this.arr.arr.length;i++)
if (!val(this.arr.get(i)))
return false;
return true;
}
function v_makeSlice(array) { Object.defineProperty(array,'len', {get: function() { return this.arr.len; }, set: function(l) { this.arr.len = l; }}) }
/**
* @function
* @param {int} i
* @returns {void}
*/
function array_delete(a, i) {
a = new $ref(a)
try {
array_delete_many(a.valueOf(),i, new int(1));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} dst
* @param {array} src
* @param {int} count
* @returns {void}
*/
function arr_copy(dst, src, count) {
dst = new $ref(dst)
try {
for (let i = new int(new int(0)); +new bool(i.valueOf() < count.valueOf()); i.val ++) {
try {
array_buffer_set(dst.val.arr,i, array_buffer_get(src.arr,i));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {int} size
* @returns {void}
*/
function array_delete_many(a, i, size) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.splice(i.valueOf(),size.valueOf())
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} val
* @returns {void}
*/
function array_prepend(a, val) {
a = new $ref(a)
try {
array_insert(a.valueOf(),new int(0), val);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @param {voidptr} val
* @param {int} size
* @returns {void}
*/
function array_prepend_many(a, val, size) {
a = new $ref(a)
try {
array_insert_many(a.valueOf(),new int(0), val, size);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {array}
*/
function array_reverse(a) {
try {
/** @type {array} */
let res = empty_array();
res.arr.arr = Array.from(a.arr).reverse()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_reverse_in_place(a) {
a = new $ref(a)
try {
a.val.arr.arr.reverse()
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array.prototype.$includes = function (elem) { return this.arr.arr.find(function(e) { return vEq(elem,e); }) !== undefined;}
/**
* @function
* @returns {void}
*/
function array_clear(a) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.clear()
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {anon_fn_int_int__int} iter
* @param {int} accum_start
* @returns {int}
*/
function array_reduce(a, iter, accum_start) {
try {
/** @type {int} */
let accum_ = new int(accum_start);
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {int} */
accum_ = new int(iter(accum_, array_get(a,i)));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return accum_;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_pop(a) {
a = new $ref(a)
try {
/** @type {voidptr} */
let res = null;
a.val.arr.make_copy()
res = a.val.arr.arr.pop()
a.val.arr.len.val -= 1
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_first(a) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr.get(new int(0))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array.prototype.toString = function () {
let res = "["
for (let i = 0; i < this.arr.arr.length;i++) {
res += this.arr.get(i).toString();
if (i != this.arr.arr.length-1)
res += ', '
}
res += ']'
return res;
}
/**
* @function
* @param {voidptr} key
* @returns {bool}
*/
function array_contains(a, key) {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_delete_last(a) {
a = new $ref(a)
try {
a.val.arr.arr.pop();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @returns {void}
*/
function array_free(a) {
a = new $ref(a)
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function array_bytestr(a) {
try {
/** @type {string} */
const res = new string(new string(""));
for (let i = 0;i < a.arr.len.valueOf();i++) res.str += String.fromCharCode(a.arr.get(new int(i)))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function Array_string_str(a) {
try {
/** @type {strings__Builder} */
let sb = strings__new_builder(new int( a.len.valueOf() * new int(3).valueOf()));
strings__Builder_write_string(sb,new string("["));
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {string} */
const val = new string(a.arr.get(new int(i.valueOf())));
strings__Builder_write_string(sb,new string("'"));
strings__Builder_write_string(sb,val);
strings__Builder_write_string(sb,new string("'"));
if ((new bool(i.valueOf() < new int( a.len.valueOf() - new int(1).valueOf()).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string(", "));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
strings__Builder_write_string(sb,new string("]"));
/** @type {string} */
const res = new string(strings__Builder_str(new $ref(sb)));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array}
*/
function array_to_js_array(a) {
try {
/** @type {Array} */
const tmp = Array.prototype.constructor();
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
tmp.push(array_buffer_get(a.arr,i));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return tmp;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array}
*/
function array_to_number_array(a) {
try {
/** @type {Array} */
const tmp = Array.prototype.constructor();
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {voidptr} */
const elem = array_buffer_get(a.arr,i);
const _tmp5 = elem;
tmp.push(Number(elem.valueOf()));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return tmp;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} arr
* @returns {Uint8Array}
*/
function uint8_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp6 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint8Array} */
let uint_arr = new Uint8Array();
uint_arr = new Uint8Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u16} arr
* @returns {Uint16Array}
*/
function uint16_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp7 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint16Array} */
let uint_arr = new Uint16Array();
uint_arr = new Uint16Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u32} arr
* @returns {Uint32Array}
*/
function uint32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp8 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint32Array} */
let uint_arr = new Uint32Array();
uint_arr = new Uint32Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i8} arr
* @returns {Int8Array}
*/
function int8_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp9 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int8Array} */
let int_arr = new Int8Array();
int_arr = new Int8Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i16} arr
* @returns {Int16Array}
*/
function int16_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp10 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int16Array} */
let int_arr = new Int16Array();
int_arr = new Int16Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_int} arr
* @returns {Int32Array}
*/
function int32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp11 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int32Array} */
let int_arr = new Int32Array();
int_arr = new Int32Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i64} arr
* @returns {BigInt64Array}
*/
function int64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp12 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {BigInt64Array} */
let int_arr = new BigInt64Array();
int_arr = new BigInt64Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u64} arr
* @returns {BigUint64Array}
*/
function uint64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp13 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {BigUint64Array} */
let int_arr = new BigUint64Array();
int_arr = new BigUint64Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_f32} arr
* @returns {Float32Array}
*/
function float32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp14 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Float32Array} */
let float_arr = new Float32Array();
float_arr = new Float32Array(tmp)
return float_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_f64} arr
* @returns {Float64Array}
*/
function float64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp15 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Float64Array} */
let float_arr = new Float64Array();
float_arr = new Float64Array(tmp)
return float_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/* [noreturn] */
/**
* @function
* @param {any} s
* @returns {void}
*/
function js_throw(s) {
try {
throw s
while (true) {
try {
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
let globalPrint, globalWrite;
if (false)
{
globalPrint = globalThis.print
globalWrite = (typeof globalThis.write === 'function')? write: globalThis.print
}
/**
* @function
* @returns {void}
*/
function flush_stdout() {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function flush_stderr() {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__println(s) {
try {
if (false)
{
globalPrint(s.str)
}
else
{
console.log(s.str)
}