UNPKG

net.akehurst.language-agl-processor

Version:
502 lines (500 loc) 14.8 kB
import { KtList3hktaavzmj137 as KtList, initMetadataForInterface1egvbzx539z91 as initMetadataForInterface, VOID3gxj6tk5isa35 as VOID, AbstractList3ck35puwbp1e9 as AbstractList, ArrayList3it5z8td81qkl as ArrayList, checkIndexOverflow3frtmheghr0th as checkIndexOverflow, Unit_instance1fbcbse1fwigr as Unit_instance, THROW_CCE2g6jy02ryeudk as THROW_CCE, isInterface3d6p8outrmvmk as isInterface, initMetadataForClassbxx6q50dy2s7 as initMetadataForClass, toString30pk9tzaqopn as toString, joinToString1cxrrlmo0chqs as joinToString, hashCodeq5arwsb9dgti as hashCode, equals2au1ep9vhcato as equals, FunctionAdapter3lcrrz3moet5b as FunctionAdapter, Comparator2b3maoeh98xtg as Comparator, sortedWith2csnbbb21k0lg as sortedWith, Iteratorixy1j1asld45 as Iterator, toString1pkumu07cwy4m as toString_0, removeLastOrNull3odnlbetbttd4 as removeLastOrNull, last1vo29oleiqj36 as last, Iterable1y3qizuf89iou as Iterable, HashMap1a0ld5kgwhmhv as HashMap, Collection1k04j3hzsbod0 as Collection, KtMap140uvy3s5zad8 as KtMap, IllegalStateExceptionkoljg5n0nrlr as IllegalStateException, HashSet2dzve9y63nf0v as HashSet, KtSetjrjc7fhfd6b9 as KtSet, charSequenceLength3278n89t01tmv as charSequenceLength, charCodeAt1yspne1d8erbm as charCodeAt, toString3o7ifthqydp6e as toString_1, titlecase36e9fbud5gg4t as titlecase, isLowerCase16nv9n55l9laa as isLowerCase, substring3saq8ornu0luv as substring, LinkedHashMap1zhqxkxv3xnkl as LinkedHashMap, emptyMapr06gerzljqtm as emptyMap, } from './kotlin-kotlin-stdlib.mjs'; //region block: imports var imul = Math.imul; //endregion //region block: pre-declaration class ListSeparated {} class ListSeparatedArrayList extends AbstractList { static p16(elements) { var $this = this.vg(); $this.o16_1 = elements; return $this; } r11() { return this.o16_1; } h1() { return this.o16_1.h1(); } i1(index) { return this.o16_1.i1(index); } m16() { // Inline function 'kotlin.collections.filterIndexed' call var tmp0 = this.o16_1; // Inline function 'kotlin.collections.filterIndexedTo' call var destination = ArrayList.o1(); // Inline function 'kotlin.collections.forEachIndexed' call var index = 0; var _iterator__ex2g4s = tmp0.g1(); while (_iterator__ex2g4s.f()) { var item = _iterator__ex2g4s.e(); var _unary__edvuaz = index; index = _unary__edvuaz + 1 | 0; if ((checkIndexOverflow(_unary__edvuaz) % 2 | 0) === 0) { destination.v(item); } } var tmp = destination; return isInterface(tmp, KtList) ? tmp : THROW_CCE(); } n16() { // Inline function 'kotlin.collections.filterIndexed' call var tmp0 = this.o16_1; // Inline function 'kotlin.collections.filterIndexedTo' call var destination = ArrayList.o1(); // Inline function 'kotlin.collections.forEachIndexed' call var index = 0; var _iterator__ex2g4s = tmp0.g1(); while (_iterator__ex2g4s.f()) { var item = _iterator__ex2g4s.e(); var _unary__edvuaz = index; index = _unary__edvuaz + 1 | 0; if ((checkIndexOverflow(_unary__edvuaz) % 2 | 0) === 1) { destination.v(item); } } var tmp = destination; return isInterface(tmp, KtList) ? tmp : THROW_CCE(); } } class MutableQueue { constructor() { var tmp = this; // Inline function 'kotlin.collections.mutableListOf' call tmp.q16_1 = ArrayList.o1(); } q11() { return !(this.q16_1.h1() === 0); } r16(item) { this.q16_1.v(item); } s16() { return this.q16_1.o3(0); } toString() { return joinToString(this.q16_1, ',', VOID, VOID, VOID, VOID, MutableQueue$toString$lambda); } } class Entry {} class Entry_0 { constructor(key, value) { this.v16_1 = key; this.w16_1 = value; } a2() { return this.v16_1; } b2() { return this.w16_1; } hashCode() { // Inline function 'kotlin.hashCode' call var tmp0_safe_receiver = this.v16_1; var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : hashCode(tmp0_safe_receiver); var tmp$ret$0 = tmp1_elvis_lhs == null ? 0 : tmp1_elvis_lhs; var tmp = imul(tmp$ret$0, 31); // Inline function 'kotlin.hashCode' call var tmp0_safe_receiver_0 = this.w16_1; var tmp1_elvis_lhs_0 = tmp0_safe_receiver_0 == null ? null : hashCode(tmp0_safe_receiver_0); return tmp + (tmp1_elvis_lhs_0 == null ? 0 : tmp1_elvis_lhs_0) | 0; } equals(other) { var tmp; if (!(!(other == null) ? isInterface(other, Entry) : false)) { tmp = false; } else { tmp = (equals(this.v16_1, other.a2()) && equals(this.w16_1, other.b2())); } return tmp; } toString() { return toString(this.v16_1) + ' -> ' + toString(this.w16_1); } } class sam$kotlin_Comparator$0 { constructor(function_0) { this.y16_1 = function_0; } lg(a, b) { return this.y16_1(a, b); } compare(a, b) { return this.lg(a, b); } u3() { return this.y16_1; } equals(other) { var tmp; if (!(other == null) ? isInterface(other, Comparator) : false) { var tmp_0; if (!(other == null) ? isInterface(other, FunctionAdapter) : false) { tmp_0 = equals(this.u3(), other.u3()); } else { tmp_0 = false; } tmp = tmp_0; } else { tmp = false; } return tmp; } hashCode() { return hashCode(this.u3()); } } class BinaryHeapComparable$iterator$1 { constructor(this$0) { var tmp = this; var tmp_0 = BinaryHeapComparable$iterator$o$_sorted$lambda(this$0); tmp.z16_1 = sortedWith(this$0.u16_1, new sam$kotlin_Comparator$0(tmp_0)); this.a17_1 = 0; } f() { return this.a17_1 < this.z16_1.h1(); } e() { // Inline function 'kotlin.also' call var this_0 = this.z16_1.i1(this.a17_1).b2(); this.a17_1 = this.a17_1 + 1 | 0; return this_0; } } class BinaryHeapComparable { constructor(comparator) { this.t16_1 = comparator; var tmp = this; // Inline function 'kotlin.collections.mutableListOf' call tmp.u16_1 = ArrayList.o1(); } h1() { return this.u16_1.h1(); } b17() { return this.u16_1.h1() === 0 ? null : this.u16_1.i1(0).b2(); } c17(key, value) { return this.d17(key, value); } l1() { return 0 === this.h1(); } e17() { return !(0 === this.h1()); } d17(key, value) { var e = new Entry_0(key, value); this.u16_1.v(e); upHeap(this, this.u16_1.h1() - 1 | 0, key); } f17() { var tmp; if (0 === this.h1()) { tmp = null; } else { this.x16(0, this.u16_1.h1() - 1 | 0); var oldRoot = removeLastOrNull(this.u16_1); downHeap(this, 0); tmp = oldRoot == null ? null : oldRoot.b2(); } return tmp; } g3(key) { var tmp; if (0 === this.h1()) { tmp = null; } else if (equals(key, this.u16_1.i1(0).a2())) { tmp = this.f17(); } else if (equals(key, last(this.u16_1).a2())) { tmp = this.u16_1.o3(this.u16_1.h1() - 1 | 0).b2(); } else { var tmp0 = this.u16_1; var tmp$ret$1; $l$block: { // Inline function 'kotlin.collections.indexOfFirst' call var index = 0; var _iterator__ex2g4s = tmp0.g1(); while (_iterator__ex2g4s.f()) { var item = _iterator__ex2g4s.e(); if (equals(item.a2(), key)) { tmp$ret$1 = index; break $l$block; } index = index + 1 | 0; } tmp$ret$1 = -1; } var index_0 = tmp$ret$1; var tmp_0; if (index_0 >= 0) { this.x16(index_0, this.u16_1.h1() - 1 | 0); var old = this.u16_1.o3(this.u16_1.h1() - 1 | 0); downHeap(this, index_0); tmp_0 = old.b2(); } else { tmp_0 = null; } tmp = tmp_0; } return tmp; } i3() { this.u16_1.i3(); } x16(i1, i2) { var t = this.u16_1.i1(i1); this.u16_1.m3(i1, this.u16_1.i1(i2)); this.u16_1.m3(i2, t); } g1() { return new BinaryHeapComparable$iterator$1(this); } toString() { var tmp; if (this.h1() === 0) { tmp = '{}'; } else { tmp = joinToString(this.u16_1, '\n', VOID, VOID, VOID, VOID, BinaryHeapComparable$toString$lambda); } return tmp; } } //endregion function MutableQueue$toString$lambda(it) { return toString(it); } function mutableQueueOf(elements) { var stack = new MutableQueue(); // Inline function 'kotlin.collections.forEach' call var inductionVariable = 0; var last = elements.length; while (inductionVariable < last) { var element = elements[inductionVariable]; inductionVariable = inductionVariable + 1 | 0; stack.r16(element); } return stack; } function binaryHeap(comparator) { return new BinaryHeapComparable(comparator); } function BinaryHeapComparable$iterator$o$_sorted$lambda(this$0) { return (a, b) => this$0.t16_1.compare(b.a2(), a.a2()); } function parentIndexOf($this, childIndex) { return (childIndex - 1 | 0) / 2 | 0; } function leftChildIndexOf($this, parentIndex) { return imul(2, parentIndex) + 1 | 0; } function rightChildIndexOf($this, parentIndex) { return imul(2, parentIndex) + 2 | 0; } function upHeap($this, index, elementKey) { var tmp; if (1 === $this.h1()) { tmp = index; } else { var elementIndex = index; var parentIndex = parentIndexOf($this, elementIndex); var parentKey = $this.u16_1.i1(parentIndex).a2(); while (!equals(parentKey, elementKey) && 0 > $this.t16_1.compare(parentKey, elementKey)) { $this.x16(parentIndex, elementIndex); elementIndex = parentIndex; parentIndex = parentIndexOf($this, elementIndex); parentKey = $this.u16_1.i1(parentIndex).a2(); } tmp = elementIndex; } return tmp; } function downHeap($this, index) { var leftChildIndex = leftChildIndexOf($this, index); var rightChildIndex = rightChildIndexOf($this, index); var smallest = index; if (leftChildIndex < $this.u16_1.h1() && 0 < $this.t16_1.compare($this.u16_1.i1(leftChildIndex).a2(), $this.u16_1.i1(smallest).a2())) { smallest = leftChildIndex; } if (rightChildIndex < $this.u16_1.h1() && 0 < $this.t16_1.compare($this.u16_1.i1(rightChildIndex).a2(), $this.u16_1.i1(smallest).a2())) { smallest = rightChildIndex; } var tmp; if (!(smallest === index)) { $this.x16(index, smallest); tmp = downHeap($this, smallest); } else { tmp = index; } return tmp; } function BinaryHeapComparable$toString$lambda(it) { return toString_0(it); } function deepClone(_this__u8e3s4) { var result = HashMap.o7(); var _iterator__ex2g4s = _this__u8e3s4.z1().g1(); while (_iterator__ex2g4s.f()) { var me = _iterator__ex2g4s.e(); var ok = me.a2(); var ov = me.b2(); var tmp; if (!(ok == null) ? isInterface(ok, KtMap) : false) { var tmp_0 = deepClone(ok); tmp = !(tmp_0 == null) ? tmp_0 : THROW_CCE(); } else { if (!(ok == null) ? isInterface(ok, Collection) : false) { var tmp_1 = deepClone_0(ok); tmp = !(tmp_1 == null) ? tmp_1 : THROW_CCE(); } else { tmp = ok; } } var k = tmp; var tmp_2; if (!(ov == null) ? isInterface(ov, KtMap) : false) { var tmp_3 = deepClone(ov); tmp_2 = !(tmp_3 == null) ? tmp_3 : THROW_CCE(); } else { if (!(ov == null) ? isInterface(ov, Collection) : false) { var tmp_4 = deepClone_0(ov); tmp_2 = !(tmp_4 == null) ? tmp_4 : THROW_CCE(); } else { tmp_2 = ov; } } var v = tmp_2; // Inline function 'kotlin.collections.set' call result.f3(k, v); } return result; } function deepClone_0(_this__u8e3s4) { var tmp; if (isInterface(_this__u8e3s4, KtSet)) { tmp = HashSet.j9(); } else { if (isInterface(_this__u8e3s4, KtList)) { tmp = ArrayList.o1(); } else { var message = 'Cannot clone unknown type in deepClone'; throw IllegalStateException.t4(toString_0(message)); } } var result = tmp; var _iterator__ex2g4s = _this__u8e3s4.g1(); while (_iterator__ex2g4s.f()) { var oe = _iterator__ex2g4s.e(); var tmp_0; if (!(oe == null) ? isInterface(oe, Collection) : false) { var tmp_1 = deepClone_0(oe); tmp_0 = !(tmp_1 == null) ? tmp_1 : THROW_CCE(); } else { if (!(oe == null) ? isInterface(oe, KtMap) : false) { var tmp_2 = deepClone(oe); tmp_0 = !(tmp_2 == null) ? tmp_2 : THROW_CCE(); } else { tmp_0 = oe; } } var e = tmp_0; result.v(e); } return result; } function implies(_this__u8e3s4, other) { return !_this__u8e3s4 || other; } function get_capitalise(_this__u8e3s4) { // Inline function 'kotlin.text.replaceFirstChar' call var tmp; // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(_this__u8e3s4) > 0) { var it = charCodeAt(_this__u8e3s4, 0); var tmp$ret$1 = isLowerCase(it) ? titlecase(it) : toString_1(it); tmp = toString_0(tmp$ret$1) + substring(_this__u8e3s4, 1); } else { tmp = _this__u8e3s4; } return tmp; } function clone(_this__u8e3s4) { var tmp; if (_this__u8e3s4.l1()) { tmp = emptyMap(); } else { if (_this__u8e3s4 instanceof LinkedHashMap) { var tmp_0 = LinkedHashMap.hb(_this__u8e3s4); tmp = isInterface(tmp_0, KtMap) ? tmp_0 : THROW_CCE(); } else { if (_this__u8e3s4 instanceof HashMap) { var tmp_1 = HashMap.d8(_this__u8e3s4); tmp = isInterface(tmp_1, KtMap) ? tmp_1 : THROW_CCE(); } else { var message = 'Trying to clone unknown type'; throw IllegalStateException.t4(toString_0(message)); } } } return tmp; } //region block: post-declaration initMetadataForInterface(ListSeparated, 'ListSeparated', VOID, VOID, [KtList]); initMetadataForClass(ListSeparatedArrayList, 'ListSeparatedArrayList', VOID, VOID, [AbstractList, ListSeparated]); initMetadataForClass(MutableQueue, 'MutableQueue', MutableQueue); initMetadataForInterface(Entry, 'Entry'); initMetadataForClass(Entry_0, 'Entry', VOID, VOID, [Entry]); initMetadataForClass(sam$kotlin_Comparator$0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]); initMetadataForClass(BinaryHeapComparable$iterator$1, VOID, VOID, VOID, [Iterator]); initMetadataForClass(BinaryHeapComparable, 'BinaryHeapComparable', VOID, VOID, [Iterable]); //endregion //region block: exports export { ListSeparatedArrayList as ListSeparatedArrayListek9n2zsx3dqy, ListSeparated as ListSeparated97fiswuae3y9, binaryHeap as binaryHeaph0xdqa11rx2r, clone as clone3r99vnzybx8ak, deepClone as deepClone18s2gowzs8h7, mutableQueueOf as mutableQueueOf1rumet9be0696, get_capitalise as get_capitalise1fytkcnart99b, }; //endregion //# sourceMappingURL=net.akehurst.language-collections.mjs.map