@markw65/monkeyc-optimizer 1.1.19 → 1.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_O5LFMOIG_exports = {};
30
- __export(chunk_O5LFMOIG_exports, {
29
+ var chunk_DCGJCC63_exports = {};
30
+ __export(chunk_DCGJCC63_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -125,8 +125,8 @@ __export(chunk_O5LFMOIG_exports, {
125
125
  visitorNode: () => visitorNode,
126
126
  xml_util_exports: () => xml_util_exports
127
127
  });
128
- module.exports = __toCommonJS(chunk_O5LFMOIG_exports);
129
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
128
+ module.exports = __toCommonJS(chunk_DCGJCC63_exports);
129
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
130
130
  var import_prettier_plugin_monkeyc = require("@markw65/prettier-plugin-monkeyc");
131
131
  var import_prettier_plugin_monkeyc2 = require("@markw65/prettier-plugin-monkeyc");
132
132
  var import_node_assert = __toESM(require("node:assert"));
@@ -142,9 +142,8 @@ var import_node_assert8 = __toESM(require("node:assert"));
142
142
  var import_node_assert9 = __toESM(require("node:assert"));
143
143
  var import_node_assert10 = __toESM(require("node:assert"));
144
144
  var import_node_assert11 = __toESM(require("node:assert"));
145
- var import_node_assert12 = __toESM(require("node:assert"));
146
145
  var fs2 = __toESM(require("fs/promises"));
147
- var import_node_assert13 = __toESM(require("node:assert"));
146
+ var import_node_assert12 = __toESM(require("node:assert"));
148
147
  var crypto = __toESM(require("node:crypto"));
149
148
  var fscb = __toESM(require("fs"));
150
149
  var fs3 = __toESM(require("fs/promises"));
@@ -417,7 +416,7 @@ function getLiteralNode(node) {
417
416
  return null;
418
417
  }
419
418
  var mctreeTypeInfo;
420
- var init_ast = (0, import_chunk_IAUHYWVN.__esm)({
419
+ var init_ast = (0, import_chunk_APACX34C.__esm)({
421
420
  "src/ast.ts"() {
422
421
  "use strict";
423
422
  mctreeTypeInfo = {
@@ -623,7 +622,7 @@ function findCalleesByNode(state, callee) {
623
622
  return null;
624
623
  return hasProperty(state.allFunctions, name) && state.allFunctions[name] || null;
625
624
  }
626
- var init_function_info = (0, import_chunk_IAUHYWVN.__esm)({
625
+ var init_function_info = (0, import_chunk_APACX34C.__esm)({
627
626
  "src/function-info.ts"() {
628
627
  "use strict";
629
628
  init_ast();
@@ -685,7 +684,7 @@ function renameVariable(state, locals, declName2) {
685
684
  map2[name] = true;
686
685
  return name;
687
686
  }
688
- var init_variable_renamer = (0, import_chunk_IAUHYWVN.__esm)({
687
+ var init_variable_renamer = (0, import_chunk_APACX34C.__esm)({
689
688
  "src/variable-renamer.ts"() {
690
689
  "use strict";
691
690
  init_api();
@@ -1518,7 +1517,7 @@ function fixNodeScope(state, lookupNode, nodeStack) {
1518
1517
  }
1519
1518
  return null;
1520
1519
  }
1521
- var init_inliner = (0, import_chunk_IAUHYWVN.__esm)({
1520
+ var init_inliner = (0, import_chunk_APACX34C.__esm)({
1522
1521
  "src/inliner.ts"() {
1523
1522
  "use strict";
1524
1523
  init_api();
@@ -1528,7 +1527,7 @@ var init_inliner = (0, import_chunk_IAUHYWVN.__esm)({
1528
1527
  }
1529
1528
  });
1530
1529
  var StateNodeAttributes;
1531
- var init_optimizer_types = (0, import_chunk_IAUHYWVN.__esm)({
1530
+ var init_optimizer_types = (0, import_chunk_APACX34C.__esm)({
1532
1531
  "src/optimizer-types.ts"() {
1533
1532
  "use strict";
1534
1533
  StateNodeAttributes = /* @__PURE__ */ ((StateNodeAttributes2) => {
@@ -1674,7 +1673,7 @@ function pragmaChecker(state, ast, diagnostics) {
1674
1673
  return null;
1675
1674
  });
1676
1675
  }
1677
- var init_pragma_checker = (0, import_chunk_IAUHYWVN.__esm)({
1676
+ var init_pragma_checker = (0, import_chunk_APACX34C.__esm)({
1678
1677
  "src/pragma-checker.ts"() {
1679
1678
  "use strict";
1680
1679
  init_api();
@@ -2035,9 +2034,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
2035
2034
  );
2036
2035
  }
2037
2036
  } else {
2038
- (0, import_chunk_IAUHYWVN.forEach)(events, (e) => e.mayThrow = false);
2037
+ (0, import_chunk_APACX34C.forEach)(events, (e) => e.mayThrow = false);
2039
2038
  }
2040
- (0, import_chunk_IAUHYWVN.forEach)(events, (event) => {
2039
+ (0, import_chunk_APACX34C.forEach)(events, (event) => {
2041
2040
  if (event.mayThrow) {
2042
2041
  for (let i = localState.stack.length; i--; ) {
2043
2042
  const target = localState.stack[i].throw;
@@ -2178,11 +2177,11 @@ function getPostOrder(head) {
2178
2177
  return blocks;
2179
2178
  }
2180
2179
  var Terminals, LocalState;
2181
- var init_control_flow = (0, import_chunk_IAUHYWVN.__esm)({
2180
+ var init_control_flow = (0, import_chunk_APACX34C.__esm)({
2182
2181
  "src/control-flow.ts"() {
2183
2182
  "use strict";
2184
2183
  init_ast();
2185
- (0, import_chunk_IAUHYWVN.init_util)();
2184
+ (0, import_chunk_APACX34C.init_util)();
2186
2185
  Terminals = {
2187
2186
  BreakStatement: "break",
2188
2187
  ContinueStatement: "continue",
@@ -2212,12 +2211,12 @@ var init_control_flow = (0, import_chunk_IAUHYWVN.__esm)({
2212
2211
  if (!from.succs) {
2213
2212
  from.succs = [to];
2214
2213
  } else {
2215
- (0, import_chunk_IAUHYWVN.pushUnique)(from.succs, to);
2214
+ (0, import_chunk_APACX34C.pushUnique)(from.succs, to);
2216
2215
  }
2217
2216
  if (!to.preds) {
2218
2217
  to.preds = [from];
2219
2218
  } else {
2220
- (0, import_chunk_IAUHYWVN.pushUnique)(to.preds, from);
2219
+ (0, import_chunk_APACX34C.pushUnique)(to.preds, from);
2221
2220
  }
2222
2221
  }
2223
2222
  newBlock(block) {
@@ -2257,85 +2256,6 @@ var init_control_flow = (0, import_chunk_IAUHYWVN.__esm)({
2257
2256
  };
2258
2257
  }
2259
2258
  });
2260
- var require_priorityqueuejs = (0, import_chunk_IAUHYWVN.__commonJS)({
2261
- "node_modules/priorityqueuejs/index.js"(exports, module2) {
2262
- module2.exports = PriorityQueue2;
2263
- function PriorityQueue2(comparator) {
2264
- this._comparator = comparator || PriorityQueue2.DEFAULT_COMPARATOR;
2265
- this._elements = [];
2266
- }
2267
- PriorityQueue2.DEFAULT_COMPARATOR = function(a, b) {
2268
- if (typeof a === "number" && typeof b === "number") {
2269
- return a - b;
2270
- } else {
2271
- a = a.toString();
2272
- b = b.toString();
2273
- if (a == b)
2274
- return 0;
2275
- return a > b ? 1 : -1;
2276
- }
2277
- };
2278
- PriorityQueue2.prototype.isEmpty = function() {
2279
- return this.size() === 0;
2280
- };
2281
- PriorityQueue2.prototype.peek = function() {
2282
- if (this.isEmpty())
2283
- throw new Error("PriorityQueue is empty");
2284
- return this._elements[0];
2285
- };
2286
- PriorityQueue2.prototype.deq = function() {
2287
- var first = this.peek();
2288
- var last = this._elements.pop();
2289
- var size = this.size();
2290
- if (size === 0)
2291
- return first;
2292
- this._elements[0] = last;
2293
- var current = 0;
2294
- while (current < size) {
2295
- var largest = current;
2296
- var left = 2 * current + 1;
2297
- var right = 2 * current + 2;
2298
- if (left < size && this._compare(left, largest) >= 0) {
2299
- largest = left;
2300
- }
2301
- if (right < size && this._compare(right, largest) >= 0) {
2302
- largest = right;
2303
- }
2304
- if (largest === current)
2305
- break;
2306
- this._swap(largest, current);
2307
- current = largest;
2308
- }
2309
- return first;
2310
- };
2311
- PriorityQueue2.prototype.enq = function(element) {
2312
- var size = this._elements.push(element);
2313
- var current = size - 1;
2314
- while (current > 0) {
2315
- var parent = Math.floor((current - 1) / 2);
2316
- if (this._compare(current, parent) <= 0)
2317
- break;
2318
- this._swap(parent, current);
2319
- current = parent;
2320
- }
2321
- return size;
2322
- };
2323
- PriorityQueue2.prototype.size = function() {
2324
- return this._elements.length;
2325
- };
2326
- PriorityQueue2.prototype.forEach = function(fn) {
2327
- return this._elements.forEach(fn);
2328
- };
2329
- PriorityQueue2.prototype._compare = function(a, b) {
2330
- return this._comparator(this._elements[a], this._elements[b]);
2331
- };
2332
- PriorityQueue2.prototype._swap = function(a, b) {
2333
- var aux = this._elements[a];
2334
- this._elements[a] = this._elements[b];
2335
- this._elements[b] = aux;
2336
- };
2337
- }
2338
- });
2339
2259
  function unionInto(to, from) {
2340
2260
  if (to == null || from == null) {
2341
2261
  throw new Error("Null");
@@ -2569,8 +2489,8 @@ function mergeObjectValues(to, from) {
2569
2489
  function mergeStateDecls(to, from) {
2570
2490
  let changed = false;
2571
2491
  let result = to;
2572
- (0, import_chunk_IAUHYWVN.forEach)(from, (v) => {
2573
- if ((0, import_chunk_IAUHYWVN.some)(to, (t) => t === v)) {
2492
+ (0, import_chunk_APACX34C.forEach)(from, (v) => {
2493
+ if ((0, import_chunk_APACX34C.some)(to, (t) => t === v)) {
2574
2494
  return;
2575
2495
  }
2576
2496
  if (Array.isArray(result)) {
@@ -2696,12 +2616,12 @@ function widenTypeHelper(t, depth) {
2696
2616
  function widenType(t) {
2697
2617
  return widenTypeHelper(t, 0);
2698
2618
  }
2699
- var init_union_type = (0, import_chunk_IAUHYWVN.__esm)({
2619
+ var init_union_type = (0, import_chunk_APACX34C.__esm)({
2700
2620
  "src/type-flow/union-type.ts"() {
2701
2621
  "use strict";
2702
2622
  init_ast();
2703
2623
  init_data_flow();
2704
- (0, import_chunk_IAUHYWVN.init_util)();
2624
+ (0, import_chunk_APACX34C.init_util)();
2705
2625
  init_intersection_type();
2706
2626
  init_sub_type();
2707
2627
  init_types();
@@ -2786,14 +2706,14 @@ function subtypeOfValue(pair) {
2786
2706
  case 8192: {
2787
2707
  const asd = pair.avalue;
2788
2708
  const bsd = pair.bvalue;
2789
- return (0, import_chunk_IAUHYWVN.some)(asd, (sna) => (0, import_chunk_IAUHYWVN.some)(bsd, (snb) => sna === snb));
2709
+ return (0, import_chunk_APACX34C.some)(asd, (sna) => (0, import_chunk_APACX34C.some)(bsd, (snb) => sna === snb));
2790
2710
  }
2791
2711
  case 16384: {
2792
2712
  const asd = pair.avalue;
2793
2713
  const bsd = pair.bvalue;
2794
- return (0, import_chunk_IAUHYWVN.every)(asd, (sna) => {
2714
+ return (0, import_chunk_APACX34C.every)(asd, (sna) => {
2795
2715
  const superA = getSuperClasses(sna);
2796
- return (0, import_chunk_IAUHYWVN.some)(bsd, (snb) => {
2716
+ return (0, import_chunk_APACX34C.some)(bsd, (snb) => {
2797
2717
  if (sna === snb || superA && superA.has(snb)) {
2798
2718
  return true;
2799
2719
  }
@@ -2824,12 +2744,12 @@ function subtypeOfObj(a, b) {
2824
2744
  return subtypeOf(a[key], value2);
2825
2745
  });
2826
2746
  }
2827
- var init_sub_type = (0, import_chunk_IAUHYWVN.__esm)({
2747
+ var init_sub_type = (0, import_chunk_APACX34C.__esm)({
2828
2748
  "src/type-flow/sub-type.ts"() {
2829
2749
  "use strict";
2830
2750
  init_api();
2831
2751
  init_data_flow();
2832
- (0, import_chunk_IAUHYWVN.init_util)();
2752
+ (0, import_chunk_APACX34C.init_util)();
2833
2753
  init_intersection_type();
2834
2754
  init_types();
2835
2755
  init_union_type();
@@ -3162,7 +3082,7 @@ function evaluateLogicalTypes(op, left, right) {
3162
3082
  }
3163
3083
  }
3164
3084
  var operators;
3165
- var init_interp_binary = (0, import_chunk_IAUHYWVN.__esm)({
3085
+ var init_interp_binary = (0, import_chunk_APACX34C.__esm)({
3166
3086
  "src/type-flow/interp-binary.ts"() {
3167
3087
  "use strict";
3168
3088
  init_could_be();
@@ -3218,7 +3138,7 @@ function calleeObjectType(istate, callee) {
3218
3138
  }
3219
3139
  function checkCallArgs(istate, node, callees, args) {
3220
3140
  const allDiags = [];
3221
- const resultType = (0, import_chunk_IAUHYWVN.reduce)(
3141
+ const resultType = (0, import_chunk_APACX34C.reduce)(
3222
3142
  callees,
3223
3143
  (result, cur) => {
3224
3144
  const curDiags = [];
@@ -3367,7 +3287,7 @@ function isOverride(cur, funcs) {
3367
3287
  const cls = cur.stack?.[cur.stack.length - 1]?.sn;
3368
3288
  if (cls?.type === "ClassDeclaration" && cls.superClasses) {
3369
3289
  const supers = getSuperClasses(cls);
3370
- if (supers && (0, import_chunk_IAUHYWVN.some)(funcs, (func) => {
3290
+ if (supers && (0, import_chunk_APACX34C.some)(funcs, (func) => {
3371
3291
  if (func === cur)
3372
3292
  return false;
3373
3293
  const fcls = func.stack?.[func.stack.length - 1].sn;
@@ -3753,12 +3673,12 @@ function expandKeys(state, table) {
3753
3673
  return result;
3754
3674
  }
3755
3675
  var systemCallInfo, systemCallVersion;
3756
- var init_interp_call = (0, import_chunk_IAUHYWVN.__esm)({
3676
+ var init_interp_call = (0, import_chunk_APACX34C.__esm)({
3757
3677
  "src/type-flow/interp-call.ts"() {
3758
3678
  "use strict";
3759
3679
  init_optimizer_types();
3760
3680
  init_api();
3761
- (0, import_chunk_IAUHYWVN.init_util)();
3681
+ (0, import_chunk_APACX34C.init_util)();
3762
3682
  init_interp();
3763
3683
  init_sub_type();
3764
3684
  init_types();
@@ -4661,7 +4581,7 @@ function mustBeIdentical(a, b) {
4661
4581
  }
4662
4582
  return false;
4663
4583
  }
4664
- var init_interp = (0, import_chunk_IAUHYWVN.__esm)({
4584
+ var init_interp = (0, import_chunk_APACX34C.__esm)({
4665
4585
  "src/type-flow/interp.ts"() {
4666
4586
  "use strict";
4667
4587
  init_api();
@@ -4880,7 +4800,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
4880
4800
  );
4881
4801
  if (value2) {
4882
4802
  const a = [];
4883
- (0, import_chunk_IAUHYWVN.forEach)(value2, (v) => {
4803
+ (0, import_chunk_APACX34C.forEach)(value2, (v) => {
4884
4804
  if (v !== sn)
4885
4805
  a.push(v);
4886
4806
  });
@@ -5255,7 +5175,7 @@ function mustBeFalse(arg) {
5255
5175
  return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
5256
5176
  }
5257
5177
  function display(type) {
5258
- const names = (v, fn) => (0, import_chunk_IAUHYWVN.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
5178
+ const names = (v, fn) => (0, import_chunk_APACX34C.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
5259
5179
  const parts = [];
5260
5180
  const displayOne = (tv) => {
5261
5181
  switch (tv.type) {
@@ -5446,13 +5366,13 @@ function getStateNodeDeclsFromType(state, object) {
5446
5366
  return decls;
5447
5367
  }
5448
5368
  var LastTypeTag, SingletonTypeTagsConst, UnionDataTypeTagsConst, ValueTypeTagsConst, ObjectLikeTagsConst, EnumTagsConst, TruthyTypes;
5449
- var init_types = (0, import_chunk_IAUHYWVN.__esm)({
5369
+ var init_types = (0, import_chunk_APACX34C.__esm)({
5450
5370
  "src/type-flow/types.ts"() {
5451
5371
  "use strict";
5452
5372
  init_data_flow();
5453
5373
  init_api();
5454
5374
  init_ast();
5455
- (0, import_chunk_IAUHYWVN.init_util)();
5375
+ (0, import_chunk_APACX34C.init_util)();
5456
5376
  init_interp();
5457
5377
  init_union_type();
5458
5378
  init_intersection_type();
@@ -5508,7 +5428,7 @@ function couldBeHelper(a, b, shallow) {
5508
5428
  262144
5509
5429
  /* Typedef */
5510
5430
  );
5511
- return typedef && (0, import_chunk_IAUHYWVN.some)(typedef, (td) => {
5431
+ return typedef && (0, import_chunk_APACX34C.some)(typedef, (td) => {
5512
5432
  if (!td.resolvedType) {
5513
5433
  throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
5514
5434
  }
@@ -5559,15 +5479,15 @@ function couldBeValue(pair, shallow) {
5559
5479
  }
5560
5480
  case 4096:
5561
5481
  case 8192: {
5562
- return (0, import_chunk_IAUHYWVN.some)(
5482
+ return (0, import_chunk_APACX34C.some)(
5563
5483
  pair.avalue,
5564
- (sna) => (0, import_chunk_IAUHYWVN.some)(pair.bvalue, (snb) => sna === snb)
5484
+ (sna) => (0, import_chunk_APACX34C.some)(pair.bvalue, (snb) => sna === snb)
5565
5485
  );
5566
5486
  }
5567
5487
  case 16384: {
5568
- return (0, import_chunk_IAUHYWVN.some)(pair.avalue, (sna) => {
5488
+ return (0, import_chunk_APACX34C.some)(pair.avalue, (sna) => {
5569
5489
  const superA = getSuperClasses(sna);
5570
- return (0, import_chunk_IAUHYWVN.some)(pair.bvalue, (snb) => {
5490
+ return (0, import_chunk_APACX34C.some)(pair.bvalue, (snb) => {
5571
5491
  if (sna === snb || superA && superA.has(snb)) {
5572
5492
  return true;
5573
5493
  }
@@ -5595,12 +5515,12 @@ function couldBeObj(a, b) {
5595
5515
  return couldBe(value2, b[key]);
5596
5516
  });
5597
5517
  }
5598
- var init_could_be = (0, import_chunk_IAUHYWVN.__esm)({
5518
+ var init_could_be = (0, import_chunk_APACX34C.__esm)({
5599
5519
  "src/type-flow/could-be.ts"() {
5600
5520
  "use strict";
5601
5521
  init_api();
5602
5522
  init_data_flow();
5603
- (0, import_chunk_IAUHYWVN.init_util)();
5523
+ (0, import_chunk_APACX34C.init_util)();
5604
5524
  init_types();
5605
5525
  }
5606
5526
  });
@@ -5612,7 +5532,7 @@ function expandTypedef(t) {
5612
5532
  );
5613
5533
  const tExpanded = cloneType(t);
5614
5534
  clearValuesUnder(tExpanded, 262144, true);
5615
- (0, import_chunk_IAUHYWVN.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
5535
+ (0, import_chunk_APACX34C.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
5616
5536
  return tExpanded;
5617
5537
  }
5618
5538
  function intersectEnum(t, e) {
@@ -5764,9 +5684,9 @@ function intersectionValue(pair) {
5764
5684
  case 4096:
5765
5685
  case 8192: {
5766
5686
  const common = [];
5767
- (0, import_chunk_IAUHYWVN.forEach)(
5687
+ (0, import_chunk_APACX34C.forEach)(
5768
5688
  pair.avalue,
5769
- (sna) => (0, import_chunk_IAUHYWVN.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
5689
+ (sna) => (0, import_chunk_APACX34C.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
5770
5690
  );
5771
5691
  if (!common.length)
5772
5692
  return null;
@@ -5774,9 +5694,9 @@ function intersectionValue(pair) {
5774
5694
  }
5775
5695
  case 16384: {
5776
5696
  const common = [];
5777
- (0, import_chunk_IAUHYWVN.forEach)(pair.avalue, (sna) => {
5697
+ (0, import_chunk_APACX34C.forEach)(pair.avalue, (sna) => {
5778
5698
  const superA = getSuperClasses(sna);
5779
- (0, import_chunk_IAUHYWVN.forEach)(pair.bvalue, (snb) => {
5699
+ (0, import_chunk_APACX34C.forEach)(pair.bvalue, (snb) => {
5780
5700
  if (sna === snb || superA && superA.has(snb)) {
5781
5701
  common.push(sna);
5782
5702
  }
@@ -5997,7 +5917,7 @@ function restrictExactTypesByEquality(a, b) {
5997
5917
  }
5998
5918
  case 262144:
5999
5919
  return restrictByEquality(
6000
- (0, import_chunk_IAUHYWVN.reduce)(
5920
+ (0, import_chunk_APACX34C.reduce)(
6001
5921
  a.value,
6002
5922
  (cur, decl) => {
6003
5923
  unionInto(cur, decl.resolvedType);
@@ -6059,12 +5979,12 @@ function restrictByEquality(a, b) {
6059
5979
  }
6060
5980
  return restrictByEqualityByComponent(a, b);
6061
5981
  }
6062
- var init_intersection_type = (0, import_chunk_IAUHYWVN.__esm)({
5982
+ var init_intersection_type = (0, import_chunk_APACX34C.__esm)({
6063
5983
  "src/type-flow/intersection-type.ts"() {
6064
5984
  "use strict";
6065
5985
  init_api();
6066
5986
  init_data_flow();
6067
- (0, import_chunk_IAUHYWVN.init_util)();
5987
+ (0, import_chunk_APACX34C.init_util)();
6068
5988
  init_could_be();
6069
5989
  init_interp();
6070
5990
  init_types();
@@ -6075,13 +5995,13 @@ function isTypeStateKey(decl) {
6075
5995
  return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
6076
5996
  }
6077
5997
  function declIsLocal(decl) {
6078
- return (0, import_chunk_IAUHYWVN.some)(
5998
+ return (0, import_chunk_APACX34C.some)(
6079
5999
  decl,
6080
6000
  (d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
6081
6001
  );
6082
6002
  }
6083
6003
  function declIsNonLocal(decl) {
6084
- return (0, import_chunk_IAUHYWVN.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
6004
+ return (0, import_chunk_APACX34C.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
6085
6005
  }
6086
6006
  function localDeclName(decl) {
6087
6007
  if (Array.isArray(decl))
@@ -6097,7 +6017,7 @@ function localDeclName(decl) {
6097
6017
  throw new Error(`Invalid local decl: ${declFullName(decl)}`);
6098
6018
  }
6099
6019
  function tsKey(key) {
6100
- return `${(0, import_chunk_IAUHYWVN.map)(key, (k) => {
6020
+ return `${(0, import_chunk_APACX34C.map)(key, (k) => {
6101
6021
  if (k.type === "Literal") {
6102
6022
  return k.raw;
6103
6023
  } else if (isStateNode(k)) {
@@ -6129,7 +6049,7 @@ function describeEvent(event) {
6129
6049
  }
6130
6050
  function printBlockEvents(block, extra) {
6131
6051
  console.log("Events:");
6132
- (0, import_chunk_IAUHYWVN.forEach)(
6052
+ (0, import_chunk_APACX34C.forEach)(
6133
6053
  block.events,
6134
6054
  (event) => console.log(` ${describeEvent(event)} ${extra ? extra(event) : ""}`)
6135
6055
  );
@@ -6246,12 +6166,12 @@ function resolveDottedMember(istate, object, next) {
6246
6166
  const mayThrow2 = !subtypeOf(object, type);
6247
6167
  return { mayThrow: mayThrow2, object: type, property };
6248
6168
  }
6249
- var init_type_flow_util = (0, import_chunk_IAUHYWVN.__esm)({
6169
+ var init_type_flow_util = (0, import_chunk_APACX34C.__esm)({
6250
6170
  "src/type-flow/type-flow-util.ts"() {
6251
6171
  "use strict";
6252
6172
  init_api();
6253
6173
  init_data_flow();
6254
- (0, import_chunk_IAUHYWVN.init_util)();
6174
+ (0, import_chunk_APACX34C.init_util)();
6255
6175
  init_intersection_type();
6256
6176
  init_sub_type();
6257
6177
  init_types();
@@ -6370,7 +6290,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
6370
6290
  }
6371
6291
  const decl = lookupDefToDecl(results);
6372
6292
  if (decl && path7.length) {
6373
- if (wantsAllRefs && (0, import_chunk_IAUHYWVN.every)(
6293
+ if (wantsAllRefs && (0, import_chunk_APACX34C.every)(
6374
6294
  decl,
6375
6295
  (d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
6376
6296
  )) {
@@ -6478,7 +6398,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
6478
6398
  const decls = findDecl(node);
6479
6399
  if (!decls)
6480
6400
  break;
6481
- if (trackInsertionPoints && (0, import_chunk_IAUHYWVN.some)(decls, (decl) => {
6401
+ if (trackInsertionPoints && (0, import_chunk_APACX34C.some)(decls, (decl) => {
6482
6402
  if (decl.type === "VariableDeclarator") {
6483
6403
  const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
6484
6404
  if (defStmts) {
@@ -6720,35 +6640,19 @@ function getFlowEvent(node, stmt, findDecl) {
6720
6640
  }
6721
6641
  return null;
6722
6642
  }
6723
- var import_priorityqueuejs, DataflowQueue;
6724
- var init_data_flow = (0, import_chunk_IAUHYWVN.__esm)({
6643
+ var DataflowQueue;
6644
+ var init_data_flow = (0, import_chunk_APACX34C.__esm)({
6725
6645
  "src/data-flow.ts"() {
6726
6646
  "use strict";
6727
- import_priorityqueuejs = (0, import_chunk_IAUHYWVN.__toESM)(require_priorityqueuejs());
6728
6647
  init_api();
6729
6648
  init_ast();
6730
6649
  init_control_flow();
6731
6650
  init_function_info();
6732
6651
  init_type_flow_util();
6733
- (0, import_chunk_IAUHYWVN.init_util)();
6734
- DataflowQueue = class {
6735
- enqueued = /* @__PURE__ */ new Set();
6736
- queue = new import_priorityqueuejs.default(
6737
- (b, a) => (a.order || 0) - (b.order || 0)
6738
- );
6739
- enqueue(block) {
6740
- if (!this.enqueued.has(block)) {
6741
- this.enqueued.add(block);
6742
- this.queue.enq(block);
6743
- }
6744
- }
6745
- dequeue() {
6746
- const block = this.queue.deq();
6747
- this.enqueued.delete(block);
6748
- return block;
6749
- }
6750
- empty() {
6751
- return this.queue.isEmpty();
6652
+ (0, import_chunk_APACX34C.init_util)();
6653
+ DataflowQueue = class extends import_chunk_APACX34C.GenericQueue {
6654
+ constructor() {
6655
+ super((b, a) => (a.order || 0) - (b.order || 0));
6752
6656
  }
6753
6657
  };
6754
6658
  }
@@ -7064,7 +6968,7 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
7064
6968
  });
7065
6969
  return { copyPropStores, changes };
7066
6970
  }
7067
- var init_dead_store = (0, import_chunk_IAUHYWVN.__esm)({
6971
+ var init_dead_store = (0, import_chunk_APACX34C.__esm)({
7068
6972
  "src/type-flow/dead-store.ts"() {
7069
6973
  "use strict";
7070
6974
  init_api();
@@ -7660,7 +7564,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
7660
7564
  }
7661
7565
  if (selfClassDecl) {
7662
7566
  const baseObj = getObjectValue(baseElem.type);
7663
- if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_IAUHYWVN.some)(
7567
+ if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_APACX34C.some)(
7664
7568
  baseObj.klass.value,
7665
7569
  (cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
7666
7570
  )) {
@@ -7705,7 +7609,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
7705
7609
  return [next, updateAny];
7706
7610
  }
7707
7611
  function typeConstraint(decls) {
7708
- return (0, import_chunk_IAUHYWVN.reduce)(
7612
+ return (0, import_chunk_APACX34C.reduce)(
7709
7613
  decls,
7710
7614
  (cur, decl) => {
7711
7615
  if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
@@ -7798,9 +7702,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
7798
7702
  stack: [],
7799
7703
  func
7800
7704
  };
7801
- const modifiableDecl = (decls, callees) => (0, import_chunk_IAUHYWVN.some)(
7705
+ const modifiableDecl = (decls, callees) => (0, import_chunk_APACX34C.some)(
7802
7706
  decls,
7803
- (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_IAUHYWVN.some)(callees, (callee) => functionMayModify(state, callee, decl)))
7707
+ (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_APACX34C.some)(callees, (callee) => functionMayModify(state, callee, decl)))
7804
7708
  );
7805
7709
  const mergeSuccState = (top, curState) => {
7806
7710
  top.succs?.forEach((succ) => {
@@ -7821,7 +7725,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
7821
7725
  type: 0
7822
7726
  /* Never */
7823
7727
  };
7824
- const result = (0, import_chunk_IAUHYWVN.every)(callees, (callee) => {
7728
+ const result = (0, import_chunk_APACX34C.every)(callees, (callee) => {
7825
7729
  const info = sysCallInfo(istate.state, callee);
7826
7730
  if (!info)
7827
7731
  return false;
@@ -8221,7 +8125,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8221
8125
  );
8222
8126
  }
8223
8127
  }
8224
- if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_IAUHYWVN.some)(callees, (callee) => inlineRequested(state, callee))) {
8128
+ if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_APACX34C.some)(callees, (callee) => inlineRequested(state, callee))) {
8225
8129
  event.node.arguments.forEach((arg) => {
8226
8130
  const def = nodeCopyProp.get(arg);
8227
8131
  if (def && nodeCopyProp.get(def) !== false) {
@@ -8233,7 +8137,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8233
8137
  let calleeEffects;
8234
8138
  curState.map.forEach((tsv, decl) => {
8235
8139
  let type = tsv.curType;
8236
- if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_IAUHYWVN.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
8140
+ if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_APACX34C.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
8237
8141
  return;
8238
8142
  }
8239
8143
  if (modifiableDecl(decl, callees)) {
@@ -8246,7 +8150,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8246
8150
  (0, import_node_assert2.default)(!tsv.copyPropItem);
8247
8151
  clearRelatedCopyPropEvents(curState, decl, nodeCopyProp);
8248
8152
  curState.map.set(decl, { curType: typeConstraint(decl) });
8249
- } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_IAUHYWVN.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
8153
+ } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_APACX34C.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
8250
8154
  if (type.value != null && type.type & 32768) {
8251
8155
  const odata = getObjectValue(tsv.curType);
8252
8156
  if (odata?.obj) {
@@ -8270,6 +8174,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8270
8174
  case "def": {
8271
8175
  const lval = event.node.type === "UpdateExpression" ? event.node.argument : event.node.type === "AssignmentExpression" ? event.node.left : null;
8272
8176
  if (lval) {
8177
+ if (nodeEquivs.has(lval)) {
8178
+ nodeEquivs.delete(lval);
8179
+ }
8273
8180
  const before = getStateEntry(curState, event.decl);
8274
8181
  if (before.curType) {
8275
8182
  typeMap.set(lval, before.curType);
@@ -8291,7 +8198,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8291
8198
  2
8292
8199
  /* Reassign */
8293
8200
  );
8294
- (0, import_chunk_IAUHYWVN.some)(event.decl, (decl) => {
8201
+ (0, import_chunk_APACX34C.some)(event.decl, (decl) => {
8295
8202
  if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
8296
8203
  return false;
8297
8204
  }
@@ -8299,7 +8206,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8299
8206
  if (affected) {
8300
8207
  const objType = typeFromTypeStateNodes(
8301
8208
  istate.state,
8302
- (0, import_chunk_IAUHYWVN.map)(
8209
+ (0, import_chunk_APACX34C.map)(
8303
8210
  event.decl,
8304
8211
  (decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
8305
8212
  ).filter(
@@ -8320,7 +8227,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8320
8227
  });
8321
8228
  if (wasComputedDecl) {
8322
8229
  curState.map.forEach((value2, decls) => {
8323
- if ((0, import_chunk_IAUHYWVN.some)(
8230
+ if ((0, import_chunk_APACX34C.some)(
8324
8231
  decls,
8325
8232
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
8326
8233
  )) {
@@ -8364,14 +8271,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8364
8271
  }
8365
8272
  if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
8366
8273
  // in case it has side effects.
8367
- (0, import_chunk_IAUHYWVN.some)(
8274
+ (0, import_chunk_APACX34C.some)(
8368
8275
  event2.calleeDecl,
8369
8276
  (callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
8370
8277
  )) {
8371
8278
  return false;
8372
8279
  }
8373
8280
  }
8374
- if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_IAUHYWVN.some)(
8281
+ if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_APACX34C.some)(
8375
8282
  event2.decl,
8376
8283
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
8377
8284
  )) {
@@ -8479,7 +8386,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8479
8386
  if (!successorsHandled) {
8480
8387
  if (logThisRun) {
8481
8388
  console.log(
8482
- ` merge to: ${(0, import_chunk_IAUHYWVN.map)(
8389
+ ` merge to: ${(0, import_chunk_APACX34C.map)(
8483
8390
  top.succs,
8484
8391
  (succ) => succ.order || -1
8485
8392
  ).join(", ")}`
@@ -8716,7 +8623,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
8716
8623
  }, curInfo);
8717
8624
  if (rep === curInfo)
8718
8625
  return null;
8719
- const name = (0, import_chunk_IAUHYWVN.reduce)(
8626
+ const name = (0, import_chunk_APACX34C.reduce)(
8720
8627
  rep.decl,
8721
8628
  (cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
8722
8629
  null
@@ -8817,7 +8724,7 @@ function updateByAssocPath(path7, property, union) {
8817
8724
  return property;
8818
8725
  }
8819
8726
  var logging, missingNullWorkaround;
8820
- var init_type_flow = (0, import_chunk_IAUHYWVN.__esm)({
8727
+ var init_type_flow = (0, import_chunk_APACX34C.__esm)({
8821
8728
  "src/type-flow.ts"() {
8822
8729
  "use strict";
8823
8730
  init_api();
@@ -8836,7 +8743,7 @@ var init_type_flow = (0, import_chunk_IAUHYWVN.__esm)({
8836
8743
  init_type_flow_util();
8837
8744
  init_types();
8838
8745
  init_union_type();
8839
- (0, import_chunk_IAUHYWVN.init_util)();
8746
+ (0, import_chunk_APACX34C.init_util)();
8840
8747
  logging = true;
8841
8748
  missingNullWorkaround = true;
8842
8749
  }
@@ -9153,7 +9060,7 @@ function variableCleanup(node) {
9153
9060
  }
9154
9061
  return null;
9155
9062
  }
9156
- var init_minimize_locals = (0, import_chunk_IAUHYWVN.__esm)({
9063
+ var init_minimize_locals = (0, import_chunk_APACX34C.__esm)({
9157
9064
  "src/type-flow/minimize-locals.ts"() {
9158
9065
  "use strict";
9159
9066
  init_api();
@@ -9281,7 +9188,7 @@ function buildPREGraph(state, func) {
9281
9188
  const event = block.events[i];
9282
9189
  switch (event.type) {
9283
9190
  case "ref":
9284
- if ((0, import_chunk_IAUHYWVN.some)(
9191
+ if ((0, import_chunk_APACX34C.some)(
9285
9192
  event.decl,
9286
9193
  (decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
9287
9194
  )) {
@@ -9299,7 +9206,7 @@ function buildPREGraph(state, func) {
9299
9206
  defs.add(event.decl);
9300
9207
  break;
9301
9208
  case "mod":
9302
- if (event.callees && (0, import_chunk_IAUHYWVN.every)(event.callees, (callee) => callee.info === false)) {
9209
+ if (event.callees && (0, import_chunk_APACX34C.every)(event.callees, (callee) => callee.info === false)) {
9303
9210
  block.events.splice(i, 1);
9304
9211
  break;
9305
9212
  }
@@ -9538,7 +9445,7 @@ function computeAttributes(state, head) {
9538
9445
  }
9539
9446
  case "mod": {
9540
9447
  curState.forEach((candidates, decls) => {
9541
- if ((0, import_chunk_IAUHYWVN.some)(
9448
+ if ((0, import_chunk_APACX34C.some)(
9542
9449
  decls,
9543
9450
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
9544
9451
  (callee) => functionMayModify(state, callee, decl)
@@ -9818,7 +9725,7 @@ function applyReplacements(func, nodeMap, declMap) {
9818
9725
  );
9819
9726
  }
9820
9727
  var logging2, LocalRefCost;
9821
- var init_pre = (0, import_chunk_IAUHYWVN.__esm)({
9728
+ var init_pre = (0, import_chunk_APACX34C.__esm)({
9822
9729
  "src/pre.ts"() {
9823
9730
  "use strict";
9824
9731
  init_api();
@@ -9827,7 +9734,7 @@ var init_pre = (0, import_chunk_IAUHYWVN.__esm)({
9827
9734
  init_data_flow();
9828
9735
  init_function_info();
9829
9736
  init_minimize_locals();
9830
- (0, import_chunk_IAUHYWVN.init_util)();
9737
+ (0, import_chunk_APACX34C.init_util)();
9831
9738
  logging2 = false;
9832
9739
  LocalRefCost = 2;
9833
9740
  }
@@ -10007,7 +9914,7 @@ function isImportCandidate(module2, stack) {
10007
9914
  );
10008
9915
  });
10009
9916
  }
10010
- var init_minimize_modules = (0, import_chunk_IAUHYWVN.__esm)({
9917
+ var init_minimize_modules = (0, import_chunk_APACX34C.__esm)({
10011
9918
  "src/type-flow/minimize-modules.ts"() {
10012
9919
  "use strict";
10013
9920
  init_api();
@@ -10137,7 +10044,7 @@ function beforeEvaluate(istate, node) {
10137
10044
  break;
10138
10045
  }
10139
10046
  const id = node.right.argument;
10140
- if ((0, import_chunk_IAUHYWVN.every)(left.value.value, (m) => {
10047
+ if ((0, import_chunk_APACX34C.every)(left.value.value, (m) => {
10141
10048
  if (hasProperty(m.decls, id.name))
10142
10049
  return false;
10143
10050
  return istate.state.lookup({
@@ -10507,13 +10414,13 @@ function tryDeEnumerate(istate, node, elem) {
10507
10414
  }
10508
10415
  return null;
10509
10416
  }
10510
- var init_optimize = (0, import_chunk_IAUHYWVN.__esm)({
10417
+ var init_optimize = (0, import_chunk_APACX34C.__esm)({
10511
10418
  "src/type-flow/optimize.ts"() {
10512
10419
  "use strict";
10513
10420
  init_inliner();
10514
10421
  init_ast();
10515
10422
  init_type_flow();
10516
- (0, import_chunk_IAUHYWVN.init_util)();
10423
+ (0, import_chunk_APACX34C.init_util)();
10517
10424
  init_interp();
10518
10425
  init_interp_binary();
10519
10426
  init_types();
@@ -10680,7 +10587,7 @@ function cleanupUnusedVars(state, node) {
10680
10587
  });
10681
10588
  return changes;
10682
10589
  }
10683
- var init_unused_exprs = (0, import_chunk_IAUHYWVN.__esm)({
10590
+ var init_unused_exprs = (0, import_chunk_APACX34C.__esm)({
10684
10591
  "src/unused-exprs.ts"() {
10685
10592
  "use strict";
10686
10593
  init_api();
@@ -11041,7 +10948,7 @@ function markFunctionCalled(state, func) {
11041
10948
  state.calledFunctions[func.id.name] = [func];
11042
10949
  return;
11043
10950
  }
11044
- (0, import_chunk_IAUHYWVN.pushUnique)(state.calledFunctions[func.id.name], func);
10951
+ (0, import_chunk_APACX34C.pushUnique)(state.calledFunctions[func.id.name], func);
11045
10952
  }
11046
10953
  async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
11047
10954
  const state = await analyze(
@@ -11671,7 +11578,7 @@ function optimizeCall(istate, node, context) {
11671
11578
  callees.forEach((c) => markFunctionCalled(state, c.node));
11672
11579
  return null;
11673
11580
  }
11674
- var init_mc_rewrite = (0, import_chunk_IAUHYWVN.__esm)({
11581
+ var init_mc_rewrite = (0, import_chunk_APACX34C.__esm)({
11675
11582
  "src/mc-rewrite.ts"() {
11676
11583
  "use strict";
11677
11584
  init_api();
@@ -11689,12 +11596,12 @@ var init_mc_rewrite = (0, import_chunk_IAUHYWVN.__esm)({
11689
11596
  init_sub_type();
11690
11597
  init_types();
11691
11598
  init_unused_exprs();
11692
- (0, import_chunk_IAUHYWVN.init_util)();
11599
+ (0, import_chunk_APACX34C.init_util)();
11693
11600
  init_variable_renamer();
11694
11601
  }
11695
11602
  });
11696
11603
  var negativeFixups;
11697
- var init_negative_fixups = (0, import_chunk_IAUHYWVN.__esm)({
11604
+ var init_negative_fixups = (0, import_chunk_APACX34C.__esm)({
11698
11605
  "src/negative-fixups.ts"() {
11699
11606
  "use strict";
11700
11607
  negativeFixups = [
@@ -16685,7 +16592,7 @@ function peg$parse(input, options) {
16685
16592
  );
16686
16593
  }
16687
16594
  }
16688
- var init_xml = (0, import_chunk_IAUHYWVN.__esm)({
16595
+ var init_xml = (0, import_chunk_APACX34C.__esm)({
16689
16596
  "src/xml.peggy"() {
16690
16597
  "use strict";
16691
16598
  peg$subclass(peg$SyntaxError, Error);
@@ -16786,7 +16693,7 @@ var init_xml = (0, import_chunk_IAUHYWVN.__esm)({
16786
16693
  }
16787
16694
  });
16788
16695
  var xml_util_exports = {};
16789
- (0, import_chunk_IAUHYWVN.__export)(xml_util_exports, {
16696
+ (0, import_chunk_APACX34C.__export)(xml_util_exports, {
16790
16697
  Document: () => Document,
16791
16698
  Nodes: () => Nodes,
16792
16699
  PeggyError: () => PeggyError,
@@ -16919,7 +16826,7 @@ function visit_xml(contents, visitor) {
16919
16826
  });
16920
16827
  }
16921
16828
  var PeggyError, entities, Document, Nodes;
16922
- var init_xml_util = (0, import_chunk_IAUHYWVN.__esm)({
16829
+ var init_xml_util = (0, import_chunk_APACX34C.__esm)({
16923
16830
  "src/xml-util.ts"() {
16924
16831
  "use strict";
16925
16832
  init_xml();
@@ -17089,7 +16996,7 @@ var init_xml_util = (0, import_chunk_IAUHYWVN.__esm)({
17089
16996
  };
17090
16997
  }
17091
16998
  });
17092
- var require_pend = (0, import_chunk_IAUHYWVN.__commonJS)({
16999
+ var require_pend = (0, import_chunk_APACX34C.__commonJS)({
17093
17000
  "node_modules/pend/index.js"(exports, module2) {
17094
17001
  module2.exports = Pend;
17095
17002
  function Pend() {
@@ -17143,16 +17050,16 @@ var require_pend = (0, import_chunk_IAUHYWVN.__commonJS)({
17143
17050
  }
17144
17051
  }
17145
17052
  });
17146
- var require_fd_slicer = (0, import_chunk_IAUHYWVN.__commonJS)({
17053
+ var require_fd_slicer = (0, import_chunk_APACX34C.__commonJS)({
17147
17054
  "node_modules/fd-slicer/index.js"(exports) {
17148
- var fs9 = (0, import_chunk_IAUHYWVN.__require)("fs");
17149
- var util = (0, import_chunk_IAUHYWVN.__require)("util");
17150
- var stream = (0, import_chunk_IAUHYWVN.__require)("stream");
17055
+ var fs9 = (0, import_chunk_APACX34C.__require)("fs");
17056
+ var util = (0, import_chunk_APACX34C.__require)("util");
17057
+ var stream = (0, import_chunk_APACX34C.__require)("stream");
17151
17058
  var Readable = stream.Readable;
17152
17059
  var Writable = stream.Writable;
17153
17060
  var PassThrough = stream.PassThrough;
17154
17061
  var Pend = require_pend();
17155
- var EventEmitter2 = (0, import_chunk_IAUHYWVN.__require)("events").EventEmitter;
17062
+ var EventEmitter2 = (0, import_chunk_APACX34C.__require)("events").EventEmitter;
17156
17063
  exports.createFromBuffer = createFromBuffer;
17157
17064
  exports.createFromFd = createFromFd;
17158
17065
  exports.BufferSlicer = BufferSlicer;
@@ -17409,9 +17316,9 @@ var require_fd_slicer = (0, import_chunk_IAUHYWVN.__commonJS)({
17409
17316
  }
17410
17317
  }
17411
17318
  });
17412
- var require_buffer_crc32 = (0, import_chunk_IAUHYWVN.__commonJS)({
17319
+ var require_buffer_crc32 = (0, import_chunk_APACX34C.__commonJS)({
17413
17320
  "node_modules/buffer-crc32/index.js"(exports, module2) {
17414
- var Buffer2 = (0, import_chunk_IAUHYWVN.__require)("buffer").Buffer;
17321
+ var Buffer2 = (0, import_chunk_APACX34C.__require)("buffer").Buffer;
17415
17322
  var CRC_TABLE = [
17416
17323
  0,
17417
17324
  1996959894,
@@ -17714,17 +17621,17 @@ var require_buffer_crc32 = (0, import_chunk_IAUHYWVN.__commonJS)({
17714
17621
  module2.exports = crc32;
17715
17622
  }
17716
17623
  });
17717
- var require_yauzl = (0, import_chunk_IAUHYWVN.__commonJS)({
17624
+ var require_yauzl = (0, import_chunk_APACX34C.__commonJS)({
17718
17625
  "node_modules/yauzl/index.js"(exports) {
17719
- var fs9 = (0, import_chunk_IAUHYWVN.__require)("fs");
17720
- var zlib = (0, import_chunk_IAUHYWVN.__require)("zlib");
17626
+ var fs9 = (0, import_chunk_APACX34C.__require)("fs");
17627
+ var zlib = (0, import_chunk_APACX34C.__require)("zlib");
17721
17628
  var fd_slicer = require_fd_slicer();
17722
17629
  var crc32 = require_buffer_crc32();
17723
- var util = (0, import_chunk_IAUHYWVN.__require)("util");
17724
- var EventEmitter2 = (0, import_chunk_IAUHYWVN.__require)("events").EventEmitter;
17725
- var Transform = (0, import_chunk_IAUHYWVN.__require)("stream").Transform;
17726
- var PassThrough = (0, import_chunk_IAUHYWVN.__require)("stream").PassThrough;
17727
- var Writable = (0, import_chunk_IAUHYWVN.__require)("stream").Writable;
17630
+ var util = (0, import_chunk_APACX34C.__require)("util");
17631
+ var EventEmitter2 = (0, import_chunk_APACX34C.__require)("events").EventEmitter;
17632
+ var Transform = (0, import_chunk_APACX34C.__require)("stream").Transform;
17633
+ var PassThrough = (0, import_chunk_APACX34C.__require)("stream").PassThrough;
17634
+ var Writable = (0, import_chunk_APACX34C.__require)("stream").Writable;
17728
17635
  exports.open = open2;
17729
17636
  exports.fromFd = fromFd;
17730
17637
  exports.fromBuffer = fromBuffer;
@@ -18413,14 +18320,14 @@ var require_yauzl = (0, import_chunk_IAUHYWVN.__commonJS)({
18413
18320
  }
18414
18321
  }
18415
18322
  });
18416
- var require_yazl = (0, import_chunk_IAUHYWVN.__commonJS)({
18323
+ var require_yazl = (0, import_chunk_APACX34C.__commonJS)({
18417
18324
  "node_modules/yazl/index.js"(exports) {
18418
- var fs9 = (0, import_chunk_IAUHYWVN.__require)("fs");
18419
- var Transform = (0, import_chunk_IAUHYWVN.__require)("stream").Transform;
18420
- var PassThrough = (0, import_chunk_IAUHYWVN.__require)("stream").PassThrough;
18421
- var zlib = (0, import_chunk_IAUHYWVN.__require)("zlib");
18422
- var util = (0, import_chunk_IAUHYWVN.__require)("util");
18423
- var EventEmitter2 = (0, import_chunk_IAUHYWVN.__require)("events").EventEmitter;
18325
+ var fs9 = (0, import_chunk_APACX34C.__require)("fs");
18326
+ var Transform = (0, import_chunk_APACX34C.__require)("stream").Transform;
18327
+ var PassThrough = (0, import_chunk_APACX34C.__require)("stream").PassThrough;
18328
+ var zlib = (0, import_chunk_APACX34C.__require)("zlib");
18329
+ var util = (0, import_chunk_APACX34C.__require)("util");
18330
+ var EventEmitter2 = (0, import_chunk_APACX34C.__require)("events").EventEmitter;
18424
18331
  var crc32 = require_buffer_crc32();
18425
18332
  exports.ZipFile = ZipFile2;
18426
18333
  exports.dateToDosDateTime = dateToDosDateTime;
@@ -19122,7 +19029,7 @@ function fixupClassDef(view, current, offsetMap) {
19122
19029
  }
19123
19030
  return current;
19124
19031
  }
19125
- var init_data = (0, import_chunk_IAUHYWVN.__esm)({
19032
+ var init_data = (0, import_chunk_APACX34C.__esm)({
19126
19033
  "src/readprg/data.ts"() {
19127
19034
  "use strict";
19128
19035
  init_bytecode();
@@ -19438,7 +19345,7 @@ function isCondBranch(op) {
19438
19345
  return false;
19439
19346
  }
19440
19347
  var Opcodes;
19441
- var init_opcodes = (0, import_chunk_IAUHYWVN.__esm)({
19348
+ var init_opcodes = (0, import_chunk_APACX34C.__esm)({
19442
19349
  "src/readprg/opcodes.ts"() {
19443
19350
  "use strict";
19444
19351
  init_data_flow();
@@ -19569,7 +19476,7 @@ function optimizeArrayInit(func, block, index, stackPreserving, context) {
19569
19476
  convertAputv(offset - 1);
19570
19477
  }
19571
19478
  }
19572
- (0, import_chunk_IAUHYWVN.logger)(
19479
+ (0, import_chunk_APACX34C.logger)(
19573
19480
  "array-init",
19574
19481
  1,
19575
19482
  `Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
@@ -19578,8 +19485,8 @@ function optimizeArrayInit(func, block, index, stackPreserving, context) {
19578
19485
  block.bytecodes[index].offset
19579
19486
  )}`
19580
19487
  );
19581
- if ((0, import_chunk_IAUHYWVN.wouldLog)("array-init", 5)) {
19582
- (0, import_chunk_IAUHYWVN.log)(blockToString(block, context));
19488
+ if ((0, import_chunk_APACX34C.wouldLog)("array-init", 5)) {
19489
+ (0, import_chunk_APACX34C.log)(blockToString(block, context));
19583
19490
  }
19584
19491
  return true;
19585
19492
  }
@@ -19592,7 +19499,7 @@ function optimizeArrayInit(func, block, index, stackPreserving, context) {
19592
19499
  if (initVal) {
19593
19500
  if (putvStarts.length < 3)
19594
19501
  return false;
19595
- (0, import_chunk_IAUHYWVN.logger)(
19502
+ (0, import_chunk_APACX34C.logger)(
19596
19503
  "array-init",
19597
19504
  1,
19598
19505
  `Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
@@ -19638,7 +19545,7 @@ function optimizeArrayInit(func, block, index, stackPreserving, context) {
19638
19545
  for (i = putvStarts.length; i-- > 1; ) {
19639
19546
  block.bytecodes.splice(putvStarts[i], 2);
19640
19547
  }
19641
- (0, import_chunk_IAUHYWVN.logger)(
19548
+ (0, import_chunk_APACX34C.logger)(
19642
19549
  "array-init",
19643
19550
  1,
19644
19551
  `Optimizing ${putvStarts.length} element array init at block ${offsetToString(
@@ -19666,52 +19573,49 @@ function optimizeArrayInit(func, block, index, stackPreserving, context) {
19666
19573
  loop.taken = loopOffset;
19667
19574
  return true;
19668
19575
  }
19669
- var init_array_init = (0, import_chunk_IAUHYWVN.__esm)({
19576
+ var init_array_init = (0, import_chunk_APACX34C.__esm)({
19670
19577
  "src/readprg/array-init.ts"() {
19671
19578
  "use strict";
19672
- (0, import_chunk_IAUHYWVN.init_util)();
19579
+ (0, import_chunk_APACX34C.init_util)();
19673
19580
  init_bytecode();
19674
19581
  init_opcodes();
19675
19582
  }
19676
19583
  });
19584
+ function postOrderTraverse2(func, visitor) {
19585
+ const visited = /* @__PURE__ */ new Set();
19586
+ const helper = (offset) => {
19587
+ if (visited.has(offset))
19588
+ return;
19589
+ visited.add(offset);
19590
+ const cur = func.blocks.get(offset);
19591
+ if (cur.next != null)
19592
+ helper(cur.next);
19593
+ if (cur.taken != null)
19594
+ helper(cur.taken);
19595
+ if (cur.exsucc != null)
19596
+ helper(cur.exsucc);
19597
+ visitor(cur);
19598
+ };
19599
+ helper(func.offset);
19600
+ }
19601
+ var init_cflow = (0, import_chunk_APACX34C.__esm)({
19602
+ "src/readprg/cflow.ts"() {
19603
+ "use strict";
19604
+ (0, import_chunk_APACX34C.init_util)();
19605
+ }
19606
+ });
19677
19607
  function localDCE(func, context) {
19678
- let numArgs = 0;
19679
- let numLocals = 0;
19680
- const locals = [];
19681
- func.blocks.forEach(
19682
- (block) => block.bytecodes.forEach((bytecode) => {
19683
- switch (bytecode.op) {
19684
- case 53:
19685
- numArgs = bytecode.arg;
19686
- (0, import_node_assert7.default)(numLocals === 0);
19687
- numLocals = numArgs;
19688
- break;
19689
- case 1:
19690
- numArgs = bytecode.arg;
19691
- break;
19692
- case 18: {
19693
- const local = locals[bytecode.arg];
19694
- if (!local) {
19695
- locals[bytecode.arg] = { read: true };
19696
- } else {
19697
- local.read = true;
19698
- }
19699
- break;
19700
- }
19701
- case 19: {
19702
- const local = locals[bytecode.arg];
19703
- if (!local) {
19704
- locals[bytecode.arg] = { write: true };
19705
- } else {
19706
- local.write = true;
19707
- }
19708
- }
19709
- }
19710
- })
19711
- );
19712
- if ((0, import_chunk_IAUHYWVN.wouldLog)("dce", 5)) {
19713
- (0, import_chunk_IAUHYWVN.setBanner)(functionBanner(func, context, "local-dce-start"));
19608
+ if ((0, import_chunk_APACX34C.wouldLog)("dce", 5)) {
19609
+ (0, import_chunk_APACX34C.setBanner)(
19610
+ functionBanner(func, context, "local-dce-start", (block) => {
19611
+ return `liveLocals: ${Array.from(
19612
+ liveLocals.get(block.offset) ?? []
19613
+ ).join(" ")}
19614
+ `;
19615
+ })
19616
+ );
19714
19617
  }
19618
+ const liveLocals = computeLiveLocals(func);
19715
19619
  let anyChanges = false;
19716
19620
  let changes = false;
19717
19621
  const makeNop = (bc) => {
@@ -19732,7 +19636,7 @@ function localDCE(func, context) {
19732
19636
  };
19733
19637
  func.blocks.forEach((block) => {
19734
19638
  const reportPopv = (i, item, kill) => {
19735
- (0, import_chunk_IAUHYWVN.logger)(
19639
+ (0, import_chunk_APACX34C.logger)(
19736
19640
  "dce",
19737
19641
  2,
19738
19642
  `${func.name}: Convert ${i}:${bytecodeToString(
@@ -19747,37 +19651,35 @@ function localDCE(func, context) {
19747
19651
  );
19748
19652
  };
19749
19653
  const reportNop = (item) => {
19750
- (0, import_chunk_IAUHYWVN.logger)(
19654
+ (0, import_chunk_APACX34C.logger)(
19751
19655
  "dce",
19752
19656
  2,
19753
19657
  `${func.name}: Kill ${item.deps.map((i) => bytecodeToString(block.bytecodes[i], context.symbolTable)).join(", ")}`
19754
19658
  );
19755
19659
  };
19756
19660
  changes = false;
19757
- const resetLocal = () => locals.map(
19758
- (l) => l && (block.next || block.taken || block.exsucc || block.bytecodes[block.bytecodes.length - 1]?.op === 23 ? { ...l } : {})
19759
- );
19661
+ const resetLocal = (offset) => new Set(liveLocals.get(offset));
19760
19662
  const dceInfo = {
19761
19663
  stack: [],
19762
- locals: resetLocal()
19664
+ locals: resetLocal(block.offset)
19763
19665
  };
19764
19666
  for (let i = block.bytecodes.length; i--; ) {
19765
19667
  const bytecode = block.bytecodes[i];
19766
19668
  switch (bytecode.op) {
19767
19669
  case 19: {
19768
- const local = dceInfo.locals[bytecode.arg];
19769
- if (!local.read) {
19770
- (0, import_chunk_IAUHYWVN.logger)(
19670
+ const liveLocal = dceInfo.locals.has(bytecode.arg);
19671
+ if (!liveLocal) {
19672
+ (0, import_chunk_APACX34C.logger)(
19771
19673
  "dce",
19772
19674
  2,
19773
- `${func.name}: Killing store to unused local ${bytecode.arg} at ${i}`
19675
+ `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
19774
19676
  );
19775
19677
  makePopv(bytecode);
19776
19678
  dceInfo.stack.push({ dead: true, deps: [i] });
19777
19679
  } else {
19778
19680
  dceInfo.stack.push({ dead: false });
19779
19681
  }
19780
- delete local.read;
19682
+ dceInfo.locals.delete(bytecode.arg);
19781
19683
  break;
19782
19684
  }
19783
19685
  case 2:
@@ -19812,7 +19714,7 @@ function localDCE(func, context) {
19812
19714
  reportNop(item);
19813
19715
  item.deps.forEach((index) => makeNop(block.bytecodes[index]));
19814
19716
  } else if (bytecode.op === 18) {
19815
- dceInfo.locals[bytecode.arg].read = true;
19717
+ dceInfo.locals.add(bytecode.arg);
19816
19718
  }
19817
19719
  break;
19818
19720
  }
@@ -19868,7 +19770,7 @@ function localDCE(func, context) {
19868
19770
  }
19869
19771
  case 15:
19870
19772
  if (block.exsucc) {
19871
- dceInfo.locals = resetLocal();
19773
+ dceInfo.locals = resetLocal(block.offset);
19872
19774
  }
19873
19775
  default: {
19874
19776
  let { push, pop } = getOpInfo(bytecode);
@@ -19887,19 +19789,100 @@ function localDCE(func, context) {
19887
19789
  (bc) => bc.op !== 0
19888
19790
  /* nop */
19889
19791
  );
19890
- if ((0, import_chunk_IAUHYWVN.wouldLog)("dce", 3)) {
19891
- (0, import_chunk_IAUHYWVN.log)(functionBanner(func, context, "local-dce-end")());
19792
+ if ((0, import_chunk_APACX34C.wouldLog)("dce", 3)) {
19793
+ (0, import_chunk_APACX34C.log)(functionBanner(func, context, "local-dce-end")());
19892
19794
  }
19893
19795
  }
19894
19796
  });
19895
- (0, import_chunk_IAUHYWVN.setBanner)(null);
19797
+ (0, import_chunk_APACX34C.setBanner)(null);
19896
19798
  return anyChanges;
19897
19799
  }
19898
- var init_dce = (0, import_chunk_IAUHYWVN.__esm)({
19800
+ function computeJsrMap(func) {
19801
+ const jsrMap = /* @__PURE__ */ new Map();
19802
+ const findRets = (offset, rets, visited) => {
19803
+ if (visited.has(offset))
19804
+ return;
19805
+ visited.add(offset);
19806
+ const block = func.blocks.get(offset);
19807
+ const last = block.bytecodes[block.bytecodes.length - 1];
19808
+ if (last?.op === 23) {
19809
+ rets.add(offset);
19810
+ return;
19811
+ }
19812
+ if (block.next != null) {
19813
+ findRets(block.next, rets, visited);
19814
+ }
19815
+ if (block.taken != null) {
19816
+ findRets(block.taken, rets, visited);
19817
+ }
19818
+ };
19819
+ func.blocks.forEach((block) => {
19820
+ const last = block.bytecodes[block.bytecodes.length - 1];
19821
+ if (last && last.op === 35) {
19822
+ const rets = /* @__PURE__ */ new Set();
19823
+ jsrMap.set(block.offset, rets);
19824
+ findRets(block.offset, rets, /* @__PURE__ */ new Set());
19825
+ }
19826
+ });
19827
+ return jsrMap;
19828
+ }
19829
+ function computeLiveLocals(func) {
19830
+ const order = /* @__PURE__ */ new Map();
19831
+ const queue = new import_chunk_APACX34C.GenericQueue(
19832
+ (b, a) => order.get(a) - order.get(b)
19833
+ );
19834
+ postOrderTraverse2(func, (block) => {
19835
+ order.set(block, order.size);
19836
+ queue.enqueue(block);
19837
+ });
19838
+ const jsrMap = computeJsrMap(func);
19839
+ const liveLocals = /* @__PURE__ */ new Map();
19840
+ const merge = (locals, pred) => {
19841
+ const predLocals = liveLocals.get(pred);
19842
+ if (!predLocals) {
19843
+ liveLocals.set(pred, new Set(locals));
19844
+ queue.enqueue(func.blocks.get(pred));
19845
+ return;
19846
+ }
19847
+ const size = predLocals.size;
19848
+ locals.forEach((local) => predLocals.add(local));
19849
+ if (size !== predLocals.size) {
19850
+ queue.enqueue(func.blocks.get(pred));
19851
+ }
19852
+ };
19853
+ while (!queue.empty()) {
19854
+ const top = queue.dequeue();
19855
+ const locals = new Set(liveLocals.get(top.offset));
19856
+ for (let i = top.bytecodes.length; i--; ) {
19857
+ const bc = top.bytecodes[i];
19858
+ switch (bc.op) {
19859
+ case 18:
19860
+ locals.add(bc.arg);
19861
+ break;
19862
+ case 19:
19863
+ locals.delete(bc.arg);
19864
+ break;
19865
+ }
19866
+ }
19867
+ top.preds?.forEach((pred) => {
19868
+ merge(locals, pred);
19869
+ const jsrPreds = jsrMap.get(pred);
19870
+ if (jsrPreds) {
19871
+ const predBlock = func.blocks.get(pred);
19872
+ if (predBlock.next === top.offset) {
19873
+ jsrPreds.forEach((jsrPred) => merge(locals, jsrPred));
19874
+ }
19875
+ }
19876
+ });
19877
+ }
19878
+ return liveLocals;
19879
+ }
19880
+ var init_dce = (0, import_chunk_APACX34C.__esm)({
19899
19881
  "src/readprg/dce.ts"() {
19900
19882
  "use strict";
19901
- (0, import_chunk_IAUHYWVN.init_util)();
19883
+ (0, import_chunk_APACX34C.init_util)();
19902
19884
  init_bytecode();
19885
+ init_cflow();
19903
19886
  init_opcodes();
19904
19887
  }
19905
19888
  });
@@ -19930,9 +19913,9 @@ function blockSharing(func, context) {
19930
19913
  if (!any)
19931
19914
  return false;
19932
19915
  any = false;
19933
- const logging3 = (0, import_chunk_IAUHYWVN.wouldLog)("sharing", 1);
19934
- if (logging3 && (0, import_chunk_IAUHYWVN.wouldLog)("sharing", 10)) {
19935
- (0, import_chunk_IAUHYWVN.setBanner)(functionBanner(func, context, "sharing"));
19916
+ const logging3 = (0, import_chunk_APACX34C.wouldLog)("sharing", 1);
19917
+ if (logging3 && (0, import_chunk_APACX34C.wouldLog)("sharing", 10)) {
19918
+ (0, import_chunk_APACX34C.setBanner)(functionBanner(func, context, "sharing"));
19936
19919
  }
19937
19920
  candidates.forEach((blocks) => {
19938
19921
  while (blocks.size > 1) {
@@ -20068,15 +20051,15 @@ function blockSharing(func, context) {
20068
20051
  block2.offset
20069
20052
  )})` : `block(${offsetToString(block2.offset)})`;
20070
20053
  };
20071
- (0, import_chunk_IAUHYWVN.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
20072
- if ((0, import_chunk_IAUHYWVN.wouldLog)("sharing", 5)) {
20073
- (0, import_chunk_IAUHYWVN.log)(blockToString(target, context));
20054
+ (0, import_chunk_APACX34C.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
20055
+ if ((0, import_chunk_APACX34C.wouldLog)("sharing", 5)) {
20056
+ (0, import_chunk_APACX34C.log)(blockToString(target, context));
20074
20057
  }
20075
20058
  }
20076
20059
  if (target.bytecodes.length > length2) {
20077
20060
  splitBlock(func, target, -length2);
20078
20061
  }
20079
- (0, import_node_assert8.default)(block.bytecodes.length >= length2);
20062
+ (0, import_node_assert7.default)(block.bytecodes.length >= length2);
20080
20063
  if (block.bytecodes.length > length2) {
20081
20064
  splitBlock(func, block, block.bytecodes.length - length2);
20082
20065
  const next = block.next;
@@ -20097,13 +20080,13 @@ function blockSharing(func, context) {
20097
20080
  });
20098
20081
  }
20099
20082
  });
20100
- (0, import_chunk_IAUHYWVN.setBanner)(null);
20083
+ (0, import_chunk_APACX34C.setBanner)(null);
20101
20084
  return any;
20102
20085
  }
20103
- var init_sharing = (0, import_chunk_IAUHYWVN.__esm)({
20086
+ var init_sharing = (0, import_chunk_APACX34C.__esm)({
20104
20087
  "src/readprg/sharing.ts"() {
20105
20088
  "use strict";
20106
- (0, import_chunk_IAUHYWVN.init_util)();
20089
+ (0, import_chunk_APACX34C.init_util)();
20107
20090
  init_bytecode();
20108
20091
  init_opcodes();
20109
20092
  }
@@ -20127,7 +20110,7 @@ function optimizeFunc(func, context) {
20127
20110
  }
20128
20111
  function simpleOpts(func, context) {
20129
20112
  const equalsSym = 8388787;
20130
- const logging3 = (0, import_chunk_IAUHYWVN.wouldLog)("optimize", 5);
20113
+ const logging3 = (0, import_chunk_APACX34C.wouldLog)("optimize", 5);
20131
20114
  return Array.from(func.blocks.values()).reduce((changes, block) => {
20132
20115
  for (let i = block.bytecodes.length; i--; ) {
20133
20116
  const cur = block.bytecodes[i];
@@ -20135,9 +20118,9 @@ function simpleOpts(func, context) {
20135
20118
  block.bytecodes.splice(i, 1);
20136
20119
  changes = true;
20137
20120
  if (logging3) {
20138
- (0, import_chunk_IAUHYWVN.log)(`${func.name}: deleting nop`);
20121
+ (0, import_chunk_APACX34C.log)(`${func.name}: deleting nop`);
20139
20122
  if (i > 0) {
20140
- (0, import_chunk_IAUHYWVN.log)(
20123
+ (0, import_chunk_APACX34C.log)(
20141
20124
  ` - previous bytecode was ${bytecodeToString(
20142
20125
  block.bytecodes[i - 1],
20143
20126
  null
@@ -20156,7 +20139,7 @@ function simpleOpts(func, context) {
20156
20139
  if (!shift && prev.op === 37) {
20157
20140
  block.bytecodes.splice(i - 1, 2);
20158
20141
  changes = true;
20159
- logging3 && (0, import_chunk_IAUHYWVN.log)(`${func.name}: deleting no-op shift (${shift})`);
20142
+ logging3 && (0, import_chunk_APACX34C.log)(`${func.name}: deleting no-op shift (${shift})`);
20160
20143
  continue;
20161
20144
  }
20162
20145
  if (shift < (prev.op === 49 ? 64n : 31n)) {
@@ -20166,7 +20149,7 @@ function simpleOpts(func, context) {
20166
20149
  } else {
20167
20150
  prev.arg = BigInt.asIntN(64, mul);
20168
20151
  }
20169
- logging3 && (0, import_chunk_IAUHYWVN.log)(
20152
+ logging3 && (0, import_chunk_APACX34C.log)(
20170
20153
  `${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
20171
20154
  );
20172
20155
  changes = true;
@@ -20181,14 +20164,14 @@ function simpleOpts(func, context) {
20181
20164
  func.blocks.get(block.taken).preds.delete(block.offset);
20182
20165
  delete block.taken;
20183
20166
  changes = true;
20184
- logging3 && (0, import_chunk_IAUHYWVN.log)(`${func.name}: deleting empty finally handler`);
20167
+ logging3 && (0, import_chunk_APACX34C.log)(`${func.name}: deleting empty finally handler`);
20185
20168
  } else if (isCondBranch(cur.op)) {
20186
20169
  const next = func.blocks.get(block.next);
20187
20170
  const taken = func.blocks.get(block.taken);
20188
20171
  if (next.preds.size > 1 && taken.preds.size === 1) {
20189
20172
  const newOp = cur.op === 40 ? 41 : 40;
20190
20173
  if (logging3) {
20191
- (0, import_chunk_IAUHYWVN.log)(
20174
+ (0, import_chunk_APACX34C.log)(
20192
20175
  `${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
20193
20176
  );
20194
20177
  }
@@ -20201,7 +20184,7 @@ function simpleOpts(func, context) {
20201
20184
  const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
20202
20185
  if (next.next === block.taken && next.taken == null && taken.bytecodes.length === 1 && isCondBranch(taken.bytecodes[0].op) && next.bytecodes.length > 1 && next.bytecodes[next.bytecodes.length - 1].op === (cur.op === 41 ? 7 : 8) && (isBool || next.bytecodes.length > 2 && isBoolOp(next.bytecodes[next.bytecodes.length - 2].op)) && next.preds?.size === 1 && taken.preds?.size === 2) {
20203
20186
  if (logging3) {
20204
- (0, import_chunk_IAUHYWVN.log)(
20187
+ (0, import_chunk_APACX34C.log)(
20205
20188
  `${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
20206
20189
  next.offset
20207
20190
  )}:${offsetToString(taken.offset)}:`
@@ -20218,7 +20201,7 @@ function simpleOpts(func, context) {
20218
20201
  changes = true;
20219
20202
  } else if (taken.next === block.next && taken.taken == null && next.bytecodes.length === 1 && isCondBranch(next.bytecodes[0].op) && taken.bytecodes.length > 1 && taken.bytecodes[taken.bytecodes.length - 1].op === (cur.op === 40 ? 7 : 8) && (isBool || taken.bytecodes.length > 2 && isBoolOp(taken.bytecodes[taken.bytecodes.length - 2].op)) && next.preds?.size === 2 && taken.preds?.size === 1) {
20220
20203
  if (logging3) {
20221
- (0, import_chunk_IAUHYWVN.log)(
20204
+ (0, import_chunk_APACX34C.log)(
20222
20205
  `${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
20223
20206
  taken.offset
20224
20207
  )}:${offsetToString(next.offset)}:`
@@ -20267,7 +20250,7 @@ function equalSymbolToEq(block, equalsIndex) {
20267
20250
  offset: invokem.offset,
20268
20251
  size: 1
20269
20252
  });
20270
- (0, import_chunk_IAUHYWVN.logger)(
20253
+ (0, import_chunk_APACX34C.logger)(
20271
20254
  "optimize",
20272
20255
  1,
20273
20256
  `Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
@@ -20280,8 +20263,8 @@ function isNopBlock(block) {
20280
20263
  return block.bytecodes.length === 0 || block.bytecodes.length === 1 && (block.bytecodes[0].op === 25 || block.bytecodes[0].op === 0);
20281
20264
  }
20282
20265
  function cleanCfg2(func, context) {
20283
- if ((0, import_chunk_IAUHYWVN.wouldLog)("cfg", 10)) {
20284
- (0, import_chunk_IAUHYWVN.setBanner)(functionBanner(func, context, "sharing"));
20266
+ if ((0, import_chunk_APACX34C.wouldLog)("cfg", 10)) {
20267
+ (0, import_chunk_APACX34C.setBanner)(functionBanner(func, context, "sharing"));
20285
20268
  }
20286
20269
  const deadBlocks = /* @__PURE__ */ new Map();
20287
20270
  func.blocks.forEach((block) => {
@@ -20328,7 +20311,7 @@ function cleanCfg2(func, context) {
20328
20311
  const next = func.blocks.get(block.next);
20329
20312
  if (block.try === next.try) {
20330
20313
  if (next.preds.size === 1) {
20331
- (0, import_chunk_IAUHYWVN.logger)(
20314
+ (0, import_chunk_APACX34C.logger)(
20332
20315
  "cfg",
20333
20316
  1,
20334
20317
  `${func.name}: ${offsetToString(
@@ -20342,7 +20325,7 @@ function cleanCfg2(func, context) {
20342
20325
  addPred(func, next.taken, block.offset);
20343
20326
  }
20344
20327
  if (next.exsucc) {
20345
- (0, import_node_assert9.default)(!block.exsucc || block.exsucc === next.exsucc);
20328
+ (0, import_node_assert8.default)(!block.exsucc || block.exsucc === next.exsucc);
20346
20329
  if (!block.exsucc) {
20347
20330
  block.exsucc = next.exsucc;
20348
20331
  addPred(func, next.exsucc, block.offset);
@@ -20351,7 +20334,7 @@ function cleanCfg2(func, context) {
20351
20334
  delete next.preds;
20352
20335
  removeBlock(func, next.offset);
20353
20336
  } else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + bc.size, 0) < 3 && countFallthroughPreds(func, next) > 1) {
20354
- (0, import_chunk_IAUHYWVN.logger)(
20337
+ (0, import_chunk_APACX34C.logger)(
20355
20338
  "cfg",
20356
20339
  1,
20357
20340
  `${func.name}: ${offsetToString(
@@ -20376,7 +20359,7 @@ function cleanCfg2(func, context) {
20376
20359
  switch (last.op) {
20377
20360
  case 41:
20378
20361
  case 40:
20379
- (0, import_chunk_IAUHYWVN.logger)(
20362
+ (0, import_chunk_APACX34C.logger)(
20380
20363
  "cfg",
20381
20364
  1,
20382
20365
  `${func.name}: killing no-op ${bytecodeToString(
@@ -20392,14 +20375,14 @@ function cleanCfg2(func, context) {
20392
20375
  delete block.taken;
20393
20376
  break;
20394
20377
  default:
20395
- (0, import_node_assert9.default)(false);
20378
+ (0, import_node_assert8.default)(false);
20396
20379
  }
20397
20380
  }
20398
20381
  if (block.try && !block.exsucc) {
20399
20382
  for (let i = block.try.length; i--; ) {
20400
20383
  const handler = block.try[i].handler;
20401
20384
  if (!func.blocks.get(handler).preds?.size) {
20402
- (0, import_chunk_IAUHYWVN.logger)(
20385
+ (0, import_chunk_APACX34C.logger)(
20403
20386
  "cfg",
20404
20387
  1,
20405
20388
  `${func.name}: killing unused try-catch at ${offsetToString(
@@ -20414,12 +20397,12 @@ function cleanCfg2(func, context) {
20414
20397
  }
20415
20398
  }
20416
20399
  });
20417
- (0, import_chunk_IAUHYWVN.setBanner)(null);
20400
+ (0, import_chunk_APACX34C.setBanner)(null);
20418
20401
  }
20419
- var init_optimize2 = (0, import_chunk_IAUHYWVN.__esm)({
20402
+ var init_optimize2 = (0, import_chunk_APACX34C.__esm)({
20420
20403
  "src/readprg/optimize.ts"() {
20421
20404
  "use strict";
20422
- (0, import_chunk_IAUHYWVN.init_util)();
20405
+ (0, import_chunk_APACX34C.init_util)();
20423
20406
  init_array_init();
20424
20407
  init_bytecode();
20425
20408
  init_dce();
@@ -20502,7 +20485,7 @@ function emitFunc(func, view, start, updateInfo, context) {
20502
20485
  offset = emitBytecode(bc, view, offset, linktable);
20503
20486
  }
20504
20487
  });
20505
- (0, import_node_assert10.default)(exceptionStack.length === 0);
20488
+ (0, import_node_assert9.default)(exceptionStack.length === 0);
20506
20489
  localsMap.forEach((item, slot) => {
20507
20490
  if (slot < numArgs) {
20508
20491
  item.startPc = start;
@@ -20512,7 +20495,7 @@ function emitFunc(func, view, start, updateInfo, context) {
20512
20495
  linktable.forEach((target, from) => {
20513
20496
  const newOffset = offsetMap.get(target);
20514
20497
  if (newOffset == null) {
20515
- (0, import_node_assert10.default)(newOffset != null);
20498
+ (0, import_node_assert9.default)(newOffset != null);
20516
20499
  }
20517
20500
  view.setInt16(from, newOffset - from - 2);
20518
20501
  });
@@ -20556,7 +20539,7 @@ function groupBlocks(func) {
20556
20539
  sortHelper(item).forEach((offset) => itemsFromOffset.set(offset, item));
20557
20540
  itemsToSort.add(item);
20558
20541
  item.items.forEach((block) => {
20559
- (0, import_node_assert10.default)(!isCfgNode(block));
20542
+ (0, import_node_assert9.default)(!isCfgNode(block));
20560
20543
  if (block.next && itemsFromOffset.get(block.next) !== item) {
20561
20544
  item.succs.add(block.next);
20562
20545
  }
@@ -20592,13 +20575,13 @@ function groupBlocks(func) {
20592
20575
  });
20593
20576
  }
20594
20577
  cur.items.forEach((item) => {
20595
- (0, import_node_assert10.default)(!isCfgNode(item));
20578
+ (0, import_node_assert9.default)(!isCfgNode(item));
20596
20579
  if (isCfgNode(item)) {
20597
20580
  item.items.forEach((block) => {
20598
- (0, import_node_assert10.default)(!isCfgNode(block));
20581
+ (0, import_node_assert9.default)(!isCfgNode(block));
20599
20582
  ordered.push(block.offset);
20600
20583
  });
20601
- (0, import_node_assert10.default)(false);
20584
+ (0, import_node_assert9.default)(false);
20602
20585
  } else {
20603
20586
  ordered.push(item.offset);
20604
20587
  }
@@ -20612,7 +20595,7 @@ function groupBlocks(func) {
20612
20595
  sortHelper(outer).reverse().map((offset) => [offset, func.blocks.get(offset)])
20613
20596
  );
20614
20597
  }
20615
- var init_emit = (0, import_chunk_IAUHYWVN.__esm)({
20598
+ var init_emit = (0, import_chunk_APACX34C.__esm)({
20616
20599
  "src/readprg/emit.ts"() {
20617
20600
  "use strict";
20618
20601
  init_ast();
@@ -20652,13 +20635,13 @@ function fixupExceptions(context, updateInfo) {
20652
20635
  ].view;
20653
20636
  const elems = updateInfo.exceptionsMap.size;
20654
20637
  const sectionLength = 2 + 9 * elems;
20655
- (0, import_node_assert11.default)(sectionLength <= view.byteLength);
20638
+ (0, import_node_assert10.default)(sectionLength <= view.byteLength);
20656
20639
  view.setUint16(0, elems);
20657
20640
  let writePos = 2;
20658
20641
  updateInfo.exceptionsMap.forEach(
20659
20642
  (entries) => entries.forEach((entry) => {
20660
20643
  const handler = updateInfo.offsetMap.get(entry.handler);
20661
- (0, import_node_assert11.default)(handler != null);
20644
+ (0, import_node_assert10.default)(handler != null);
20662
20645
  write24(view, (writePos += 3) - 3, entry.tryStart);
20663
20646
  write24(view, (writePos += 3) - 3, entry.tryEnd);
20664
20647
  write24(view, (writePos += 3) - 3, handler);
@@ -20671,7 +20654,7 @@ function write24(view, current, value2) {
20671
20654
  view.setUint8(current + 1, value2 >>> 8);
20672
20655
  view.setUint8(current + 2, value2);
20673
20656
  }
20674
- var init_exceptions = (0, import_chunk_IAUHYWVN.__esm)({
20657
+ var init_exceptions = (0, import_chunk_APACX34C.__esm)({
20675
20658
  "src/readprg/exceptions.ts"() {
20676
20659
  "use strict";
20677
20660
  init_bytecode();
@@ -20728,7 +20711,7 @@ function fixupHeader(context, updateInfo) {
20728
20711
  view.setUint32(25, offset);
20729
20712
  }
20730
20713
  }
20731
- var init_header = (0, import_chunk_IAUHYWVN.__esm)({
20714
+ var init_header = (0, import_chunk_APACX34C.__esm)({
20732
20715
  "src/readprg/header.ts"() {
20733
20716
  "use strict";
20734
20717
  init_bytecode();
@@ -20835,7 +20818,7 @@ function fixupLineNum(context, updateInfo) {
20835
20818
  });
20836
20819
  });
20837
20820
  }
20838
- var init_linenum = (0, import_chunk_IAUHYWVN.__esm)({
20821
+ var init_linenum = (0, import_chunk_APACX34C.__esm)({
20839
20822
  "src/readprg/linenum.ts"() {
20840
20823
  "use strict";
20841
20824
  init_sdk_util();
@@ -20847,7 +20830,7 @@ function offsetToString(offset) {
20847
20830
  }
20848
20831
  function fixSectionSize(section, sections, newSize) {
20849
20832
  const sectionInfo = sections[section];
20850
- (0, import_node_assert12.default)(sectionInfo);
20833
+ (0, import_node_assert11.default)(sectionInfo);
20851
20834
  const view = sectionInfo.view;
20852
20835
  sectionInfo.length = newSize;
20853
20836
  new DataView(view.buffer, view.byteOffset - 4, 4).setUint32(0, newSize);
@@ -20861,21 +20844,21 @@ function optimizeBytecode(context) {
20861
20844
  functions.forEach(callback);
20862
20845
  return;
20863
20846
  }
20864
- (0, import_chunk_IAUHYWVN.bumpLogging)(null, 10);
20847
+ (0, import_chunk_APACX34C.bumpLogging)(null, 10);
20865
20848
  functions.forEach((func2) => {
20866
20849
  if (loggerFunc.test(func2.name ?? "<null>")) {
20867
- (0, import_chunk_IAUHYWVN.bumpLogging)(null, -10);
20850
+ (0, import_chunk_APACX34C.bumpLogging)(null, -10);
20868
20851
  callback(func2);
20869
- (0, import_chunk_IAUHYWVN.bumpLogging)(null, 10);
20852
+ (0, import_chunk_APACX34C.bumpLogging)(null, 10);
20870
20853
  return;
20871
20854
  }
20872
20855
  callback(func2);
20873
20856
  });
20874
- (0, import_chunk_IAUHYWVN.bumpLogging)(null, -10);
20857
+ (0, import_chunk_APACX34C.bumpLogging)(null, -10);
20875
20858
  };
20876
- if ((0, import_chunk_IAUHYWVN.wouldLog)("list-input", 1)) {
20859
+ if ((0, import_chunk_APACX34C.wouldLog)("list-input", 1)) {
20877
20860
  forEachFunction(
20878
- (func2) => (0, import_chunk_IAUHYWVN.wouldLog)("list-input", 1) && printFunction(func2, context)
20861
+ (func2) => (0, import_chunk_APACX34C.wouldLog)("list-input", 1) && printFunction(func2, context)
20879
20862
  );
20880
20863
  }
20881
20864
  forEachFunction((func2) => optimizeFunc(func2, context));
@@ -20893,7 +20876,7 @@ function optimizeBytecode(context) {
20893
20876
  forEachFunction((func2) => {
20894
20877
  if (!func2.name)
20895
20878
  return;
20896
- (0, import_chunk_IAUHYWVN.logger)(
20879
+ (0, import_chunk_APACX34C.logger)(
20897
20880
  "bytecode",
20898
20881
  5,
20899
20882
  `${func2.name}: ${offset.toString(16)} ${offset - func2.offset}`
@@ -20902,7 +20885,7 @@ function optimizeBytecode(context) {
20902
20885
  });
20903
20886
  const { offsetMap } = updateInfo;
20904
20887
  offsetMap.set(code.byteLength, offset);
20905
- (0, import_chunk_IAUHYWVN.logger)(
20888
+ (0, import_chunk_APACX34C.logger)(
20906
20889
  "bytecode",
20907
20890
  1,
20908
20891
  `${context.filepath}: code size: ${context.sections[
@@ -20914,9 +20897,9 @@ function optimizeBytecode(context) {
20914
20897
  ].length - offset}`
20915
20898
  );
20916
20899
  fixSectionSize(-1059145026, context.sections, offset);
20917
- if ((0, import_chunk_IAUHYWVN.wouldLog)("list-output", 1)) {
20900
+ if ((0, import_chunk_APACX34C.wouldLog)("list-output", 1)) {
20918
20901
  forEachFunction(
20919
- (func2) => (0, import_chunk_IAUHYWVN.wouldLog)("list-output", 1) && printFunction(func2, context)
20902
+ (func2) => (0, import_chunk_APACX34C.wouldLog)("list-output", 1) && printFunction(func2, context)
20920
20903
  );
20921
20904
  }
20922
20905
  fixupHeader(context, updateInfo);
@@ -20945,13 +20928,13 @@ function optimizeBytecode(context) {
20945
20928
  };
20946
20929
  const funcRange = (pc) => {
20947
20930
  const index = funcIndex(pc);
20948
- (0, import_node_assert12.default)(
20931
+ (0, import_node_assert11.default)(
20949
20932
  funcArray[index].offset <= (pc & 16777215) && funcArray[index + 1].offset > (pc & 16777215)
20950
20933
  );
20951
20934
  const s = offsetMap.get(funcArray[index].offset);
20952
20935
  const e = offsetMap.get(funcArray[index + 1].offset);
20953
20936
  if (s == null || e == null) {
20954
- (0, import_node_assert12.default)(s != null && e != null);
20937
+ (0, import_node_assert11.default)(s != null && e != null);
20955
20938
  }
20956
20939
  return [s + 268435456, e + 268435456];
20957
20940
  };
@@ -20959,7 +20942,7 @@ function optimizeBytecode(context) {
20959
20942
  let fend = funcArray[1].offset;
20960
20943
  context.debugXml.body.children("localVars").children("entry").elements.forEach((entry) => {
20961
20944
  const { startPc, endPc, stackId } = entry.attr;
20962
- (0, import_node_assert12.default)(startPc && endPc && stackId);
20945
+ (0, import_node_assert11.default)(startPc && endPc && stackId);
20963
20946
  const spc = Number(startPc.value.value) & 16777215;
20964
20947
  const epc = Number(endPc.value.value) & 16777215;
20965
20948
  const sid = Number(stackId.value.value);
@@ -20969,7 +20952,7 @@ function optimizeBytecode(context) {
20969
20952
  fend = funcArray[index + 1].offset;
20970
20953
  }
20971
20954
  const info = updateInfo.localsMap.get(func);
20972
- (0, import_node_assert12.default)(info);
20955
+ (0, import_node_assert11.default)(info);
20973
20956
  const local = info.get(sid);
20974
20957
  if (!local) {
20975
20958
  entry.attr = {};
@@ -20984,23 +20967,31 @@ function optimizeBytecode(context) {
20984
20967
  if (!startPc || !endPc)
20985
20968
  return;
20986
20969
  const range = funcRange(Number(startPc.value.value));
20987
- (0, import_node_assert12.default)(funcRange(Number(endPc.value.value))[0] === range[0]);
20970
+ (0, import_node_assert11.default)(funcRange(Number(endPc.value.value))[0] === range[0]);
20988
20971
  startPc.value.value = range[0].toString();
20989
20972
  endPc.value.value = (range[1] - 1).toString();
20990
20973
  });
20991
20974
  }
20992
- function functionBanner(func, context, pass) {
20975
+ function functionBanner(func, context, pass, footer) {
20993
20976
  return () => `================ ${pass} : ${func.name} ================
20994
- ${functionToString(func, context)}
20977
+ ${functionToString(
20978
+ func,
20979
+ context,
20980
+ footer
20981
+ )}
20995
20982
  ---------------- ${func.name} ----------------`;
20996
20983
  }
20997
20984
  function printFunction(func, context) {
20998
- (0, import_chunk_IAUHYWVN.log)(functionToString(func, context));
20985
+ (0, import_chunk_APACX34C.log)(functionToString(func, context));
20999
20986
  }
21000
- function functionToString(func, context) {
20987
+ function functionToString(func, context, footer) {
21001
20988
  const parts = [];
21002
20989
  parts.push(`${func.name ?? "<unknown>"}:`);
21003
- func.blocks.forEach((block) => parts.push(blockToString(block, context)));
20990
+ func.blocks.forEach((block) => {
20991
+ parts.push(blockToString(block, context));
20992
+ if (footer)
20993
+ parts.push(footer(block));
20994
+ });
21004
20995
  parts.push(`${func.name ?? "<unknown>"}_end`);
21005
20996
  return parts.join("\n");
21006
20997
  }
@@ -21010,7 +21001,7 @@ function blockToString(block, context) {
21010
21001
  const log2 = (msg) => parts.push(msg + "\n");
21011
21002
  log2(`${offsetToString(block.offset)}:`);
21012
21003
  block.try?.forEach((exInfo) => {
21013
- (0, import_node_assert12.default)(exInfo);
21004
+ (0, import_node_assert11.default)(exInfo);
21014
21005
  log2(
21015
21006
  `tryCatch - start: ${offsetToString(
21016
21007
  exInfo.tryStart
@@ -21234,7 +21225,7 @@ function makeArgless(bc, op) {
21234
21225
  }
21235
21226
  function removeBlock(func, offset) {
21236
21227
  const block = func.blocks.get(offset);
21237
- (0, import_node_assert12.default)(block && !block.preds?.size);
21228
+ (0, import_node_assert11.default)(block && !block.preds?.size);
21238
21229
  block.next && removePred(func, block.next, block.offset);
21239
21230
  block.taken && removePred(func, block.taken, block.offset);
21240
21231
  block.exsucc && removePred(func, block.exsucc, block.offset);
@@ -21243,7 +21234,7 @@ function removeBlock(func, offset) {
21243
21234
  function removePred(func, target, pred) {
21244
21235
  const targetBlock = func.blocks.get(target);
21245
21236
  if (!targetBlock.preds?.has(pred)) {
21246
- (0, import_node_assert12.default)(targetBlock.preds?.has(pred));
21237
+ (0, import_node_assert11.default)(targetBlock.preds?.has(pred));
21247
21238
  }
21248
21239
  targetBlock.preds.delete(pred);
21249
21240
  }
@@ -21274,7 +21265,7 @@ function redirect(func, block, from, to) {
21274
21265
  last.arg = to;
21275
21266
  break;
21276
21267
  default:
21277
- (0, import_node_assert12.default)(false);
21268
+ (0, import_node_assert11.default)(false);
21278
21269
  }
21279
21270
  } else {
21280
21271
  delete block.taken;
@@ -21282,8 +21273,8 @@ function redirect(func, block, from, to) {
21282
21273
  changes = true;
21283
21274
  }
21284
21275
  if (block.exsucc === from) {
21285
- (0, import_node_assert12.default)(to);
21286
- (0, import_node_assert12.default)(block.try);
21276
+ (0, import_node_assert11.default)(to);
21277
+ (0, import_node_assert11.default)(block.try);
21287
21278
  block.try[block.try.length - 1].handler = to;
21288
21279
  block.exsucc = to;
21289
21280
  changes = true;
@@ -21313,7 +21304,7 @@ function splitBlock(func, block, offset) {
21313
21304
  }
21314
21305
  };
21315
21306
  if (offset > 0) {
21316
- (0, import_node_assert12.default)(offset < block.bytecodes.length);
21307
+ (0, import_node_assert11.default)(offset < block.bytecodes.length);
21317
21308
  const tail = block.bytecodes.splice(offset);
21318
21309
  const tailBlock = {
21319
21310
  ...block,
@@ -21337,7 +21328,7 @@ function splitBlock(func, block, offset) {
21337
21328
  delete block.taken;
21338
21329
  }
21339
21330
  } else {
21340
- (0, import_node_assert12.default)(offset < 0 && offset + block.bytecodes.length > 0);
21331
+ (0, import_node_assert11.default)(offset < 0 && offset + block.bytecodes.length > 0);
21341
21332
  const head = block.bytecodes.splice(0, block.bytecodes.length + offset);
21342
21333
  const headBlock = {
21343
21334
  ...block,
@@ -21380,11 +21371,11 @@ function countFallthroughPreds(func, block) {
21380
21371
  }, 0);
21381
21372
  }
21382
21373
  var SectionKinds;
21383
- var init_bytecode = (0, import_chunk_IAUHYWVN.__esm)({
21374
+ var init_bytecode = (0, import_chunk_APACX34C.__esm)({
21384
21375
  "src/readprg/bytecode.ts"() {
21385
21376
  "use strict";
21386
21377
  init_ast();
21387
- (0, import_chunk_IAUHYWVN.init_util)();
21378
+ (0, import_chunk_APACX34C.init_util)();
21388
21379
  init_data();
21389
21380
  init_emit();
21390
21381
  init_exceptions();
@@ -21420,7 +21411,7 @@ function getPrgSignature(context) {
21420
21411
  if (!signature)
21421
21412
  return;
21422
21413
  const keyInfo = context.key.export({ format: "jwk" });
21423
- (0, import_node_assert13.default)(keyInfo.n && keyInfo.e);
21414
+ (0, import_node_assert12.default)(keyInfo.n && keyInfo.e);
21424
21415
  const modulusBuf = Buffer.from(keyInfo.n, "base64");
21425
21416
  const publicExponent = Array.from(Buffer.from(keyInfo.e, "base64")).reduce(
21426
21417
  (value2, n) => (value2 << 8) + n,
@@ -21432,7 +21423,7 @@ function getPrgSignature(context) {
21432
21423
  modulusBuf.byteOffset + delta,
21433
21424
  modulusBuf.byteLength - delta
21434
21425
  );
21435
- (0, import_node_assert13.default)(modulus.byteLength === 512 && signature.length === 512);
21426
+ (0, import_node_assert12.default)(modulus.byteLength === 512 && signature.length === 512);
21436
21427
  const sectionLength = signature.length + modulus.byteLength + 4;
21437
21428
  const buffer = new DataView(new ArrayBuffer(sectionLength + 8));
21438
21429
  buffer.setInt32(
@@ -21495,7 +21486,7 @@ function signView(key, view) {
21495
21486
  signer.end();
21496
21487
  return signer.sign(key);
21497
21488
  }
21498
- var init_signer = (0, import_chunk_IAUHYWVN.__esm)({
21489
+ var init_signer = (0, import_chunk_APACX34C.__esm)({
21499
21490
  "src/readprg/signer.ts"() {
21500
21491
  "use strict";
21501
21492
  init_bytecode();
@@ -21509,7 +21500,7 @@ function hash(s) {
21509
21500
  return (h ^ h >>> 9) >>> 0;
21510
21501
  }
21511
21502
  var SymbolTable;
21512
- var init_symbols = (0, import_chunk_IAUHYWVN.__esm)({
21503
+ var init_symbols = (0, import_chunk_APACX34C.__esm)({
21513
21504
  "src/readprg/symbols.ts"() {
21514
21505
  "use strict";
21515
21506
  SymbolTable = class {
@@ -21642,7 +21633,7 @@ async function optimizeProgram(filepath, devKey, output) {
21642
21633
  }
21643
21634
  function optimizeProgramBuffer(filepath, view, debugXml, key) {
21644
21635
  const { sections } = readPrgWithOffsets(view);
21645
- (0, import_chunk_IAUHYWVN.logger)("readprg", 5, sections);
21636
+ (0, import_chunk_APACX34C.logger)("readprg", 5, sections);
21646
21637
  const symbolTable = new SymbolTable();
21647
21638
  if (hasProperty(sections, 1461170197 .toString())) {
21648
21639
  symbolTable.parse(sections[
@@ -21909,11 +21900,11 @@ function optimizePrgAndDebug(prgName, prgBuffer, prgOffset, prgLength, xmlName,
21909
21900
  });
21910
21901
  }
21911
21902
  var yauzl, yazl;
21912
- var init_readprg = (0, import_chunk_IAUHYWVN.__esm)({
21903
+ var init_readprg = (0, import_chunk_APACX34C.__esm)({
21913
21904
  "src/readprg.ts"() {
21914
21905
  "use strict";
21915
- yauzl = (0, import_chunk_IAUHYWVN.__toESM)(require_yauzl());
21916
- yazl = (0, import_chunk_IAUHYWVN.__toESM)(require_yazl());
21906
+ yauzl = (0, import_chunk_APACX34C.__toESM)(require_yauzl());
21907
+ yazl = (0, import_chunk_APACX34C.__toESM)(require_yazl());
21917
21908
  init_ast();
21918
21909
  init_bytecode();
21919
21910
  init_data();
@@ -21924,7 +21915,7 @@ var init_readprg = (0, import_chunk_IAUHYWVN.__esm)({
21924
21915
  init_signer();
21925
21916
  init_symbols();
21926
21917
  init_sdk_util();
21927
- (0, import_chunk_IAUHYWVN.init_util)();
21918
+ (0, import_chunk_APACX34C.init_util)();
21928
21919
  init_worker_pool();
21929
21920
  }
21930
21921
  });
@@ -21936,7 +21927,7 @@ function getSdkPath() {
21936
21927
  });
21937
21928
  }
21938
21929
  async function getDeviceInfo() {
21939
- const files = await (0, import_chunk_IAUHYWVN.globa)(`${connectiq}/Devices/*/compiler.json`);
21930
+ const files = await (0, import_chunk_APACX34C.globa)(`${connectiq}/Devices/*/compiler.json`);
21940
21931
  if (!files.length) {
21941
21932
  throw new Error(
21942
21933
  `No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
@@ -22001,9 +21992,9 @@ async function getFunctionDocumentation() {
22001
21992
  return entries;
22002
21993
  }
22003
21994
  var isWin, appSupport, connectiq;
22004
- var init_sdk_util = (0, import_chunk_IAUHYWVN.__esm)({
21995
+ var init_sdk_util = (0, import_chunk_APACX34C.__esm)({
22005
21996
  "src/sdk-util.ts"() {
22006
- (0, import_chunk_IAUHYWVN.init_util)();
21997
+ (0, import_chunk_APACX34C.init_util)();
22007
21998
  init_xml_util();
22008
21999
  init_readprg();
22009
22000
  init_bytecode();
@@ -22515,7 +22506,7 @@ function add_one_resource(state, doc, module2, e) {
22515
22506
  }
22516
22507
  }
22517
22508
  var drawableSkips;
22518
- var init_resources = (0, import_chunk_IAUHYWVN.__esm)({
22509
+ var init_resources = (0, import_chunk_APACX34C.__esm)({
22519
22510
  "src/resources.ts"() {
22520
22511
  "use strict";
22521
22512
  init_api();
@@ -22719,7 +22710,7 @@ function visitReferences(state, ast, name, defn, callback, includeDefs = false,
22719
22710
  collectNamespaces(ast, state);
22720
22711
  delete state.pre;
22721
22712
  }
22722
- var init_visitor = (0, import_chunk_IAUHYWVN.__esm)({
22713
+ var init_visitor = (0, import_chunk_APACX34C.__esm)({
22723
22714
  "src/visitor.ts"() {
22724
22715
  "use strict";
22725
22716
  init_api();
@@ -22891,11 +22882,11 @@ function sameStateNodeDecl(a, b) {
22891
22882
  function sameLookupDefinition(a, b) {
22892
22883
  return (
22893
22884
  // sameStateNodeDecl(a.parent, b.parent) &&
22894
- (0, import_chunk_IAUHYWVN.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
22885
+ (0, import_chunk_APACX34C.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
22895
22886
  );
22896
22887
  }
22897
22888
  function sameLookupResult(a, b) {
22898
- return (0, import_chunk_IAUHYWVN.sameArrays)(a, b, sameLookupDefinition);
22889
+ return (0, import_chunk_APACX34C.sameArrays)(a, b, sameLookupDefinition);
22899
22890
  }
22900
22891
  function declKey(decl) {
22901
22892
  return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
@@ -23362,7 +23353,7 @@ function stateFuncs() {
23362
23353
  if (!hasProperty(this.index, name)) {
23363
23354
  this.index[name] = [];
23364
23355
  }
23365
- (0, import_chunk_IAUHYWVN.pushUnique)(this.index[name], parent);
23356
+ (0, import_chunk_APACX34C.pushUnique)(this.index[name], parent);
23366
23357
  }
23367
23358
  });
23368
23359
  break;
@@ -23418,7 +23409,7 @@ function stateFuncs() {
23418
23409
  if (!hasProperty(values, name)) {
23419
23410
  values[name] = [];
23420
23411
  }
23421
- if ((0, import_chunk_IAUHYWVN.pushUnique)(values[name], m) && currentEnum) {
23412
+ if ((0, import_chunk_APACX34C.pushUnique)(values[name], m) && currentEnum) {
23422
23413
  if (!this.enumMap)
23423
23414
  this.enumMap = /* @__PURE__ */ new Map();
23424
23415
  this.enumMap.set(m, currentEnum);
@@ -23426,7 +23417,7 @@ function stateFuncs() {
23426
23417
  if (!hasProperty(this.index, name)) {
23427
23418
  this.index[name] = [];
23428
23419
  }
23429
- (0, import_chunk_IAUHYWVN.pushUnique)(this.index[name], parent);
23420
+ (0, import_chunk_APACX34C.pushUnique)(this.index[name], parent);
23430
23421
  });
23431
23422
  break;
23432
23423
  }
@@ -23865,7 +23856,7 @@ function getSuperClasses(klass) {
23865
23856
  });
23866
23857
  return superClasses;
23867
23858
  }
23868
- var init_api = (0, import_chunk_IAUHYWVN.__esm)({
23859
+ var init_api = (0, import_chunk_APACX34C.__esm)({
23869
23860
  "src/api.ts"() {
23870
23861
  init_ast();
23871
23862
  init_mc_rewrite();
@@ -23875,7 +23866,7 @@ var init_api = (0, import_chunk_IAUHYWVN.__esm)({
23875
23866
  init_sdk_util();
23876
23867
  init_type_flow_util();
23877
23868
  init_types();
23878
- (0, import_chunk_IAUHYWVN.init_util)();
23869
+ (0, import_chunk_APACX34C.init_util)();
23879
23870
  init_visitor();
23880
23871
  }
23881
23872
  });
@@ -23949,20 +23940,20 @@ async function build_project(product, options, lineCallback) {
23949
23940
  lineCallback || ((line) => console.log(line)),
23950
23941
  (line) => console.error(line)
23951
23942
  ];
23952
- await (0, import_chunk_IAUHYWVN.spawnByLine)(exe, args, handlers, {
23943
+ await (0, import_chunk_APACX34C.spawnByLine)(exe, args, handlers, {
23953
23944
  cwd: workspace
23954
23945
  });
23955
23946
  }
23956
23947
  return { exe, args, program: path3.resolve(workspace, program), product };
23957
23948
  }
23958
- var init_build = (0, import_chunk_IAUHYWVN.__esm)({
23949
+ var init_build = (0, import_chunk_APACX34C.__esm)({
23959
23950
  "src/build.ts"() {
23960
23951
  "use strict";
23961
23952
  init_sdk_util();
23962
- (0, import_chunk_IAUHYWVN.init_util)();
23953
+ (0, import_chunk_APACX34C.init_util)();
23963
23954
  }
23964
23955
  });
23965
- var require_ms = (0, import_chunk_IAUHYWVN.__commonJS)({
23956
+ var require_ms = (0, import_chunk_APACX34C.__commonJS)({
23966
23957
  "node_modules/ms/index.js"(exports, module2) {
23967
23958
  var s = 1e3;
23968
23959
  var m = s * 60;
@@ -24076,7 +24067,7 @@ var require_ms = (0, import_chunk_IAUHYWVN.__commonJS)({
24076
24067
  }
24077
24068
  }
24078
24069
  });
24079
- var require_common = (0, import_chunk_IAUHYWVN.__commonJS)({
24070
+ var require_common = (0, import_chunk_APACX34C.__commonJS)({
24080
24071
  "node_modules/debug/src/common.js"(exports, module2) {
24081
24072
  function setup(env) {
24082
24073
  createDebug.debug = createDebug;
@@ -24237,7 +24228,7 @@ var require_common = (0, import_chunk_IAUHYWVN.__commonJS)({
24237
24228
  module2.exports = setup;
24238
24229
  }
24239
24230
  });
24240
- var require_browser = (0, import_chunk_IAUHYWVN.__commonJS)({
24231
+ var require_browser = (0, import_chunk_APACX34C.__commonJS)({
24241
24232
  "node_modules/debug/src/browser.js"(exports, module2) {
24242
24233
  exports.formatArgs = formatArgs;
24243
24234
  exports.save = save;
@@ -24404,7 +24395,7 @@ var require_browser = (0, import_chunk_IAUHYWVN.__commonJS)({
24404
24395
  };
24405
24396
  }
24406
24397
  });
24407
- var require_has_flag = (0, import_chunk_IAUHYWVN.__commonJS)({
24398
+ var require_has_flag = (0, import_chunk_APACX34C.__commonJS)({
24408
24399
  "node_modules/has-flag/index.js"(exports, module2) {
24409
24400
  "use strict";
24410
24401
  module2.exports = (flag, argv = process.argv) => {
@@ -24415,11 +24406,11 @@ var require_has_flag = (0, import_chunk_IAUHYWVN.__commonJS)({
24415
24406
  };
24416
24407
  }
24417
24408
  });
24418
- var require_supports_color = (0, import_chunk_IAUHYWVN.__commonJS)({
24409
+ var require_supports_color = (0, import_chunk_APACX34C.__commonJS)({
24419
24410
  "node_modules/supports-color/index.js"(exports, module2) {
24420
24411
  "use strict";
24421
- var os2 = (0, import_chunk_IAUHYWVN.__require)("os");
24422
- var tty = (0, import_chunk_IAUHYWVN.__require)("tty");
24412
+ var os2 = (0, import_chunk_APACX34C.__require)("os");
24413
+ var tty = (0, import_chunk_APACX34C.__require)("tty");
24423
24414
  var hasFlag = require_has_flag();
24424
24415
  var { env } = process;
24425
24416
  var forceColor;
@@ -24515,10 +24506,10 @@ var require_supports_color = (0, import_chunk_IAUHYWVN.__commonJS)({
24515
24506
  };
24516
24507
  }
24517
24508
  });
24518
- var require_node = (0, import_chunk_IAUHYWVN.__commonJS)({
24509
+ var require_node = (0, import_chunk_APACX34C.__commonJS)({
24519
24510
  "node_modules/debug/src/node.js"(exports, module2) {
24520
- var tty = (0, import_chunk_IAUHYWVN.__require)("tty");
24521
- var util = (0, import_chunk_IAUHYWVN.__require)("util");
24511
+ var tty = (0, import_chunk_APACX34C.__require)("tty");
24512
+ var util = (0, import_chunk_APACX34C.__require)("util");
24522
24513
  exports.init = init;
24523
24514
  exports.log = log2;
24524
24515
  exports.formatArgs = formatArgs;
@@ -24687,7 +24678,7 @@ var require_node = (0, import_chunk_IAUHYWVN.__commonJS)({
24687
24678
  };
24688
24679
  }
24689
24680
  });
24690
- var require_src = (0, import_chunk_IAUHYWVN.__commonJS)({
24681
+ var require_src = (0, import_chunk_APACX34C.__commonJS)({
24691
24682
  "node_modules/debug/src/index.js"(exports, module2) {
24692
24683
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
24693
24684
  module2.exports = require_browser();
@@ -24696,7 +24687,7 @@ var require_src = (0, import_chunk_IAUHYWVN.__commonJS)({
24696
24687
  }
24697
24688
  }
24698
24689
  });
24699
- var require_wrappy = (0, import_chunk_IAUHYWVN.__commonJS)({
24690
+ var require_wrappy = (0, import_chunk_APACX34C.__commonJS)({
24700
24691
  "node_modules/wrappy/wrappy.js"(exports, module2) {
24701
24692
  module2.exports = wrappy;
24702
24693
  function wrappy(fn, cb) {
@@ -24725,7 +24716,7 @@ var require_wrappy = (0, import_chunk_IAUHYWVN.__commonJS)({
24725
24716
  }
24726
24717
  }
24727
24718
  });
24728
- var require_once = (0, import_chunk_IAUHYWVN.__commonJS)({
24719
+ var require_once = (0, import_chunk_APACX34C.__commonJS)({
24729
24720
  "node_modules/once/once.js"(exports, module2) {
24730
24721
  var wrappy = require_wrappy();
24731
24722
  module2.exports = wrappy(once);
@@ -24768,7 +24759,7 @@ var require_once = (0, import_chunk_IAUHYWVN.__commonJS)({
24768
24759
  }
24769
24760
  }
24770
24761
  });
24771
- var require_end_of_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
24762
+ var require_end_of_stream = (0, import_chunk_APACX34C.__commonJS)({
24772
24763
  "node_modules/end-of-stream/index.js"(exports, module2) {
24773
24764
  var once = require_once();
24774
24765
  var noop = function() {
@@ -24861,11 +24852,11 @@ var require_end_of_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
24861
24852
  module2.exports = eos;
24862
24853
  }
24863
24854
  });
24864
- var require_pump = (0, import_chunk_IAUHYWVN.__commonJS)({
24855
+ var require_pump = (0, import_chunk_APACX34C.__commonJS)({
24865
24856
  "node_modules/pump/index.js"(exports, module2) {
24866
24857
  var once = require_once();
24867
24858
  var eos = require_end_of_stream();
24868
- var fs9 = (0, import_chunk_IAUHYWVN.__require)("fs");
24859
+ var fs9 = (0, import_chunk_APACX34C.__require)("fs");
24869
24860
  var noop = function() {
24870
24861
  };
24871
24862
  var ancient = /^v?\.0/.test(process.version);
@@ -24943,10 +24934,10 @@ var require_pump = (0, import_chunk_IAUHYWVN.__commonJS)({
24943
24934
  module2.exports = pump;
24944
24935
  }
24945
24936
  });
24946
- var require_buffer_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
24937
+ var require_buffer_stream = (0, import_chunk_APACX34C.__commonJS)({
24947
24938
  "node_modules/get-stream/buffer-stream.js"(exports, module2) {
24948
24939
  "use strict";
24949
- var { PassThrough: PassThroughStream } = (0, import_chunk_IAUHYWVN.__require)("stream");
24940
+ var { PassThrough: PassThroughStream } = (0, import_chunk_APACX34C.__require)("stream");
24950
24941
  module2.exports = (options) => {
24951
24942
  options = { ...options };
24952
24943
  const { array } = options;
@@ -24986,10 +24977,10 @@ var require_buffer_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
24986
24977
  };
24987
24978
  }
24988
24979
  });
24989
- var require_get_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
24980
+ var require_get_stream = (0, import_chunk_APACX34C.__commonJS)({
24990
24981
  "node_modules/get-stream/index.js"(exports, module2) {
24991
24982
  "use strict";
24992
- var { constants: BufferConstants } = (0, import_chunk_IAUHYWVN.__require)("buffer");
24983
+ var { constants: BufferConstants } = (0, import_chunk_APACX34C.__require)("buffer");
24993
24984
  var pump = require_pump();
24994
24985
  var bufferStream = require_buffer_stream();
24995
24986
  var MaxBufferError = class extends Error {
@@ -25037,14 +25028,14 @@ var require_get_stream = (0, import_chunk_IAUHYWVN.__commonJS)({
25037
25028
  module2.exports.MaxBufferError = MaxBufferError;
25038
25029
  }
25039
25030
  });
25040
- var require_extract_zip = (0, import_chunk_IAUHYWVN.__commonJS)({
25031
+ var require_extract_zip = (0, import_chunk_APACX34C.__commonJS)({
25041
25032
  "node_modules/extract-zip/index.js"(exports, module2) {
25042
25033
  var debug = require_src()("extract-zip");
25043
- var { createWriteStream: createWriteStream2, promises: fs9 } = (0, import_chunk_IAUHYWVN.__require)("fs");
25034
+ var { createWriteStream: createWriteStream2, promises: fs9 } = (0, import_chunk_APACX34C.__require)("fs");
25044
25035
  var getStream = require_get_stream();
25045
- var path7 = (0, import_chunk_IAUHYWVN.__require)("path");
25046
- var { promisify } = (0, import_chunk_IAUHYWVN.__require)("util");
25047
- var stream = (0, import_chunk_IAUHYWVN.__require)("stream");
25036
+ var path7 = (0, import_chunk_APACX34C.__require)("path");
25037
+ var { promisify } = (0, import_chunk_APACX34C.__require)("util");
25038
+ var stream = (0, import_chunk_APACX34C.__require)("stream");
25048
25039
  var yauzl2 = require_yauzl();
25049
25040
  var openZip = promisify(yauzl2.open);
25050
25041
  var pipeline = promisify(stream.pipeline);
@@ -26665,7 +26656,7 @@ function peg$parse2(input, options) {
26665
26656
  );
26666
26657
  }
26667
26658
  }
26668
- var init_jungle = (0, import_chunk_IAUHYWVN.__esm)({
26659
+ var init_jungle = (0, import_chunk_APACX34C.__esm)({
26669
26660
  "src/jungle.peggy"() {
26670
26661
  "use strict";
26671
26662
  peg$subclass2(peg$SyntaxError2, Error);
@@ -26890,7 +26881,7 @@ async function checkManifest(manifest, products) {
26890
26881
  });
26891
26882
  return ok;
26892
26883
  }
26893
- var init_manifest = (0, import_chunk_IAUHYWVN.__esm)({
26884
+ var init_manifest = (0, import_chunk_APACX34C.__esm)({
26894
26885
  "src/manifest.ts"() {
26895
26886
  "use strict";
26896
26887
  init_sdk_util();
@@ -27146,7 +27137,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
27146
27137
  );
27147
27138
  if (!hasProperty(cache.resolvedPaths, resolved)) {
27148
27139
  if (/[*?[\]{}]/.test(resolved)) {
27149
- cache.resolvedPaths[resolved] = (0, import_chunk_IAUHYWVN.globSome)(resolved, () => true);
27140
+ cache.resolvedPaths[resolved] = (0, import_chunk_APACX34C.globSome)(resolved, () => true);
27150
27141
  } else {
27151
27142
  cache.resolvedPaths[resolved] = fs7.stat(resolved).then(() => true).catch(() => false);
27152
27143
  }
@@ -27215,12 +27206,12 @@ async function read_resource_files(targets, cache) {
27215
27206
  if (!hasProperty(resourceGroupPromises, key)) {
27216
27207
  resourceGroupPromises[key] = Promise.all(
27217
27208
  p.qualifier.resourcePath.map(
27218
- (pattern) => (0, import_chunk_IAUHYWVN.globa)(pattern, { mark: true })
27209
+ (pattern) => (0, import_chunk_APACX34C.globa)(pattern, { mark: true })
27219
27210
  )
27220
27211
  ).then(
27221
27212
  (patterns) => Promise.all(
27222
27213
  patterns.flat().map(
27223
- (path7) => path7.endsWith("/") ? (0, import_chunk_IAUHYWVN.globa)(`${path7}**/*.xml`, { mark: true }) : path7
27214
+ (path7) => path7.endsWith("/") ? (0, import_chunk_APACX34C.globa)(`${path7}**/*.xml`, { mark: true }) : path7
27224
27215
  )
27225
27216
  ).then(
27226
27217
  (paths) => Promise.all(
@@ -27284,7 +27275,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
27284
27275
  const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path4.resolve(dir, f).replace(/\\/g, "/"));
27285
27276
  const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path4.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
27286
27277
  if (filePatterns.length) {
27287
- const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_IAUHYWVN.globa)(p)))).flat();
27278
+ const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_APACX34C.globa)(p)))).flat();
27288
27279
  sourceExcludes.push(...files);
27289
27280
  }
27290
27281
  const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
@@ -27435,15 +27426,15 @@ function identify_optimizer_groups(targets, options) {
27435
27426
  function find_barrels(barrelPath) {
27436
27427
  if (Array.isArray(barrelPath)) {
27437
27428
  return Promise.all(
27438
- barrelPath.map((path7) => (0, import_chunk_IAUHYWVN.globa)(path7, { mark: true }))
27429
+ barrelPath.map((path7) => (0, import_chunk_APACX34C.globa)(path7, { mark: true }))
27439
27430
  ).then((paths) => [
27440
27431
  paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
27441
27432
  ]);
27442
27433
  }
27443
- return (0, import_chunk_IAUHYWVN.globa)(barrelPath, { mark: true }).then(
27434
+ return (0, import_chunk_APACX34C.globa)(barrelPath, { mark: true }).then(
27444
27435
  (paths) => Promise.all(
27445
27436
  paths.map(
27446
- (path7) => path7.endsWith("/") ? (0, import_chunk_IAUHYWVN.globa)(`${path7}**/*.barrel`) : path7
27437
+ (path7) => path7.endsWith("/") ? (0, import_chunk_APACX34C.globa)(`${path7}**/*.barrel`) : path7
27447
27438
  )
27448
27439
  )
27449
27440
  ).then(
@@ -27691,15 +27682,15 @@ async function get_jungle(jungles, options, resources) {
27691
27682
  return result;
27692
27683
  }
27693
27684
  var import_extract_zip;
27694
- var init_jungles = (0, import_chunk_IAUHYWVN.__esm)({
27685
+ var init_jungles = (0, import_chunk_APACX34C.__esm)({
27695
27686
  "src/jungles.ts"() {
27696
27687
  "use strict";
27697
- import_extract_zip = (0, import_chunk_IAUHYWVN.__toESM)(require_extract_zip());
27688
+ import_extract_zip = (0, import_chunk_APACX34C.__toESM)(require_extract_zip());
27698
27689
  init_jungle();
27699
27690
  init_api();
27700
27691
  init_manifest();
27701
27692
  init_sdk_util();
27702
- (0, import_chunk_IAUHYWVN.init_util)();
27693
+ (0, import_chunk_APACX34C.init_util)();
27703
27694
  }
27704
27695
  });
27705
27696
  async function launchSimulator(force = true) {
@@ -27757,7 +27748,7 @@ function simulateProgram(prg, device, test = false, logger2) {
27757
27748
  }
27758
27749
  }
27759
27750
  return getSdkPath().then(
27760
- (sdk) => (0, import_chunk_IAUHYWVN.spawnByLine)(
27751
+ (sdk) => (0, import_chunk_APACX34C.spawnByLine)(
27761
27752
  path5.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
27762
27753
  args,
27763
27754
  logger2 || ((line) => console.log(line))
@@ -27766,11 +27757,11 @@ function simulateProgram(prg, device, test = false, logger2) {
27766
27757
  })
27767
27758
  );
27768
27759
  }
27769
- var init_launch = (0, import_chunk_IAUHYWVN.__esm)({
27760
+ var init_launch = (0, import_chunk_APACX34C.__esm)({
27770
27761
  "src/launch.ts"() {
27771
27762
  "use strict";
27772
27763
  init_sdk_util();
27773
- (0, import_chunk_IAUHYWVN.init_util)();
27764
+ (0, import_chunk_APACX34C.init_util)();
27774
27765
  }
27775
27766
  });
27776
27767
  function relative_path_no_dotdot(relative2) {
@@ -27889,7 +27880,7 @@ async function createLocalBarrels(targets, options) {
27889
27880
  optBarrelDir
27890
27881
  };
27891
27882
  return promise2.then(
27892
- () => (0, import_chunk_IAUHYWVN.copyRecursiveAsNeeded)(
27883
+ () => (0, import_chunk_APACX34C.copyRecursiveAsNeeded)(
27893
27884
  rawBarrelDir,
27894
27885
  optBarrelDir,
27895
27886
  (src) => !src.endsWith(".mc")
@@ -28167,12 +28158,12 @@ async function generateOptimizedProject(options) {
28167
28158
  async function fileInfoFromConfig(workspace, output, buildConfig, extraExcludes) {
28168
28159
  const paths = (await Promise.all(
28169
28160
  buildConfig.sourcePath?.map(
28170
- (pattern) => (0, import_chunk_IAUHYWVN.globa)(pattern, { cwd: workspace, mark: true })
28161
+ (pattern) => (0, import_chunk_APACX34C.globa)(pattern, { cwd: workspace, mark: true })
28171
28162
  ) || []
28172
28163
  )).flat();
28173
28164
  const files = (await Promise.all(
28174
28165
  paths.map(
28175
- (path7) => path7.endsWith("/") ? (0, import_chunk_IAUHYWVN.globa)(`${path7}**/*.mc`, { cwd: workspace, mark: true }) : path7
28166
+ (path7) => path7.endsWith("/") ? (0, import_chunk_APACX34C.globa)(`${path7}**/*.mc`, { cwd: workspace, mark: true }) : path7
28176
28167
  )
28177
28168
  )).flat().filter(
28178
28169
  (file) => file.endsWith(".mc") && !path6.relative(workspace, file).startsWith("bin") && (!buildConfig.sourceExcludes || !buildConfig.sourceExcludes.includes(file))
@@ -28255,7 +28246,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28255
28246
  );
28256
28247
  barrelFnMaps.forEach((barrelFnMap) => Object.assign(fnMap, barrelFnMap));
28257
28248
  }
28258
- const actualOptimizedFiles = (await (0, import_chunk_IAUHYWVN.globa)(path6.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
28249
+ const actualOptimizedFiles = (await (0, import_chunk_APACX34C.globa)(path6.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
28259
28250
  const {
28260
28251
  hasTests,
28261
28252
  diagnostics: prevDiagnostics,
@@ -28266,13 +28257,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28266
28257
  if (hasTests != null && !config.checkBuildPragmas && configOptionsToCheck.every(
28267
28258
  (option) => prevOptions[option] === config[option]
28268
28259
  ) && actualOptimizedFiles.length === Object.values(fnMap).length && Object.values(fnMap).map((v) => v.output).sort().every((f, i) => f === actualOptimizedFiles[i])) {
28269
- const source_time = await (0, import_chunk_IAUHYWVN.last_modified)(
28260
+ const source_time = await (0, import_chunk_APACX34C.last_modified)(
28270
28261
  Object.keys(fnMap).concat(dependencyFiles)
28271
28262
  );
28272
- const opt_time = await (0, import_chunk_IAUHYWVN.first_modified)(
28263
+ const opt_time = await (0, import_chunk_APACX34C.first_modified)(
28273
28264
  Object.values(fnMap).map((v) => v.output)
28274
28265
  );
28275
- if (source_time < opt_time && 1679159320058 < opt_time) {
28266
+ if (source_time < opt_time && 1679270582760 < opt_time) {
28276
28267
  return { hasTests, diagnostics: prevDiagnostics };
28277
28268
  }
28278
28269
  }
@@ -28304,7 +28295,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28304
28295
  JSON.stringify({
28305
28296
  hasTests: hasTests2,
28306
28297
  diagnostics,
28307
- optimizerVersion: "1.1.19",
28298
+ optimizerVersion: "1.1.20",
28308
28299
  ...Object.fromEntries(
28309
28300
  configOptionsToCheck.map((option) => [option, config[option]])
28310
28301
  )
@@ -28449,7 +28440,7 @@ async function generateApiMirTests(options) {
28449
28440
  return fs8.writeFile(`${workspace}/source/apiTest.mc`, source);
28450
28441
  }
28451
28442
  var defaultConfig, configOptionsToCheck;
28452
- var init_optimizer = (0, import_chunk_IAUHYWVN.__esm)({
28443
+ var init_optimizer = (0, import_chunk_APACX34C.__esm)({
28453
28444
  "src/optimizer.ts"() {
28454
28445
  init_api();
28455
28446
  init_build();
@@ -28462,7 +28453,7 @@ var init_optimizer = (0, import_chunk_IAUHYWVN.__esm)({
28462
28453
  init_could_be();
28463
28454
  init_interp();
28464
28455
  init_sub_type();
28465
- (0, import_chunk_IAUHYWVN.init_util)();
28456
+ (0, import_chunk_APACX34C.init_util)();
28466
28457
  init_worker_pool();
28467
28458
  init_optimizer_types();
28468
28459
  init_types();
@@ -28503,7 +28494,7 @@ async function performTask(task) {
28503
28494
  return handler(task.data);
28504
28495
  }
28505
28496
  var workerTaskHandlers;
28506
- var init_worker_task = (0, import_chunk_IAUHYWVN.__esm)({
28497
+ var init_worker_task = (0, import_chunk_APACX34C.__esm)({
28507
28498
  "src/worker-task.ts"() {
28508
28499
  "use strict";
28509
28500
  init_optimizer();
@@ -28582,7 +28573,7 @@ function runTaskInPool(task) {
28582
28573
  return performTask(task);
28583
28574
  }
28584
28575
  var kTaskInfo, kWorkerFreedEvent, WorkerPoolTaskInfo, WorkerPool, pool;
28585
- var init_worker_pool = (0, import_chunk_IAUHYWVN.__esm)({
28576
+ var init_worker_pool = (0, import_chunk_APACX34C.__esm)({
28586
28577
  "src/worker-pool.ts"() {
28587
28578
  init_worker_task();
28588
28579
  kTaskInfo = Symbol("kTaskInfo");