@markw65/monkeyc-optimizer 1.1.22 → 1.1.24

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_563GVBVT_exports = {};
30
- __export(chunk_563GVBVT_exports, {
29
+ var chunk_3HVXWNU4_exports = {};
30
+ __export(chunk_3HVXWNU4_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -125,8 +125,8 @@ __export(chunk_563GVBVT_exports, {
125
125
  visitorNode: () => visitorNode,
126
126
  xml_util_exports: () => xml_util_exports
127
127
  });
128
- module.exports = __toCommonJS(chunk_563GVBVT_exports);
129
- var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
128
+ module.exports = __toCommonJS(chunk_3HVXWNU4_exports);
129
+ var import_chunk_QFQPBQSO = require("./chunk-QFQPBQSO.cjs");
130
130
  var import_prettier_plugin_monkeyc = require("@markw65/prettier-plugin-monkeyc");
131
131
  var import_node_assert = __toESM(require("node:assert"));
132
132
  var import_prettier_plugin_monkeyc2 = require("@markw65/prettier-plugin-monkeyc");
@@ -148,8 +148,10 @@ var import_node_assert10 = __toESM(require("node:assert"));
148
148
  var import_node_assert11 = __toESM(require("node:assert"));
149
149
  var import_node_assert12 = __toESM(require("node:assert"));
150
150
  var import_node_assert13 = __toESM(require("node:assert"));
151
- var fs3 = __toESM(require("fs/promises"));
152
151
  var import_node_assert14 = __toESM(require("node:assert"));
152
+ var import_node_assert15 = __toESM(require("node:assert"));
153
+ var fs3 = __toESM(require("fs/promises"));
154
+ var import_node_assert16 = __toESM(require("node:assert"));
153
155
  var crypto = __toESM(require("node:crypto"));
154
156
  var path = __toESM(require("path"));
155
157
  var fs4 = __toESM(require("fs/promises"));
@@ -5121,7 +5123,7 @@ function peg$parse(input, options) {
5121
5123
  );
5122
5124
  }
5123
5125
  }
5124
- var init_xml = (0, import_chunk_HHQDDCTP.__esm)({
5126
+ var init_xml = (0, import_chunk_QFQPBQSO.__esm)({
5125
5127
  "src/xml.peggy"() {
5126
5128
  "use strict";
5127
5129
  peg$subclass(peg$SyntaxError, Error);
@@ -5466,7 +5468,7 @@ function getLiteralNode(node) {
5466
5468
  return null;
5467
5469
  }
5468
5470
  var mctreeTypeInfo;
5469
- var init_ast = (0, import_chunk_HHQDDCTP.__esm)({
5471
+ var init_ast = (0, import_chunk_QFQPBQSO.__esm)({
5470
5472
  "src/ast.ts"() {
5471
5473
  "use strict";
5472
5474
  mctreeTypeInfo = {
@@ -5536,7 +5538,7 @@ var init_ast = (0, import_chunk_HHQDDCTP.__esm)({
5536
5538
  }
5537
5539
  });
5538
5540
  var xml_util_exports = {};
5539
- (0, import_chunk_HHQDDCTP.__export)(xml_util_exports, {
5541
+ (0, import_chunk_QFQPBQSO.__export)(xml_util_exports, {
5540
5542
  Document: () => Document,
5541
5543
  Nodes: () => Nodes,
5542
5544
  PeggyError: () => PeggyError,
@@ -5669,7 +5671,7 @@ function visit_xml(contents, visitor) {
5669
5671
  });
5670
5672
  }
5671
5673
  var PeggyError, entities, Document, Nodes;
5672
- var init_xml_util = (0, import_chunk_HHQDDCTP.__esm)({
5674
+ var init_xml_util = (0, import_chunk_QFQPBQSO.__esm)({
5673
5675
  "src/xml-util.ts"() {
5674
5676
  "use strict";
5675
5677
  init_xml();
@@ -5839,7 +5841,7 @@ var init_xml_util = (0, import_chunk_HHQDDCTP.__esm)({
5839
5841
  };
5840
5842
  }
5841
5843
  });
5842
- var require_pend = (0, import_chunk_HHQDDCTP.__commonJS)({
5844
+ var require_pend = (0, import_chunk_QFQPBQSO.__commonJS)({
5843
5845
  "node_modules/pend/index.js"(exports, module2) {
5844
5846
  module2.exports = Pend;
5845
5847
  function Pend() {
@@ -5893,16 +5895,16 @@ var require_pend = (0, import_chunk_HHQDDCTP.__commonJS)({
5893
5895
  }
5894
5896
  }
5895
5897
  });
5896
- var require_fd_slicer = (0, import_chunk_HHQDDCTP.__commonJS)({
5898
+ var require_fd_slicer = (0, import_chunk_QFQPBQSO.__commonJS)({
5897
5899
  "node_modules/fd-slicer/index.js"(exports) {
5898
- var fs9 = (0, import_chunk_HHQDDCTP.__require)("fs");
5899
- var util = (0, import_chunk_HHQDDCTP.__require)("util");
5900
- var stream = (0, import_chunk_HHQDDCTP.__require)("stream");
5900
+ var fs9 = (0, import_chunk_QFQPBQSO.__require)("fs");
5901
+ var util = (0, import_chunk_QFQPBQSO.__require)("util");
5902
+ var stream = (0, import_chunk_QFQPBQSO.__require)("stream");
5901
5903
  var Readable = stream.Readable;
5902
5904
  var Writable = stream.Writable;
5903
5905
  var PassThrough = stream.PassThrough;
5904
5906
  var Pend = require_pend();
5905
- var EventEmitter2 = (0, import_chunk_HHQDDCTP.__require)("events").EventEmitter;
5907
+ var EventEmitter2 = (0, import_chunk_QFQPBQSO.__require)("events").EventEmitter;
5906
5908
  exports.createFromBuffer = createFromBuffer;
5907
5909
  exports.createFromFd = createFromFd;
5908
5910
  exports.BufferSlicer = BufferSlicer;
@@ -6159,9 +6161,9 @@ var require_fd_slicer = (0, import_chunk_HHQDDCTP.__commonJS)({
6159
6161
  }
6160
6162
  }
6161
6163
  });
6162
- var require_buffer_crc32 = (0, import_chunk_HHQDDCTP.__commonJS)({
6164
+ var require_buffer_crc32 = (0, import_chunk_QFQPBQSO.__commonJS)({
6163
6165
  "node_modules/buffer-crc32/index.js"(exports, module2) {
6164
- var Buffer2 = (0, import_chunk_HHQDDCTP.__require)("buffer").Buffer;
6166
+ var Buffer2 = (0, import_chunk_QFQPBQSO.__require)("buffer").Buffer;
6165
6167
  var CRC_TABLE = [
6166
6168
  0,
6167
6169
  1996959894,
@@ -6464,17 +6466,17 @@ var require_buffer_crc32 = (0, import_chunk_HHQDDCTP.__commonJS)({
6464
6466
  module2.exports = crc32;
6465
6467
  }
6466
6468
  });
6467
- var require_yauzl = (0, import_chunk_HHQDDCTP.__commonJS)({
6469
+ var require_yauzl = (0, import_chunk_QFQPBQSO.__commonJS)({
6468
6470
  "node_modules/yauzl/index.js"(exports) {
6469
- var fs9 = (0, import_chunk_HHQDDCTP.__require)("fs");
6470
- var zlib = (0, import_chunk_HHQDDCTP.__require)("zlib");
6471
+ var fs9 = (0, import_chunk_QFQPBQSO.__require)("fs");
6472
+ var zlib = (0, import_chunk_QFQPBQSO.__require)("zlib");
6471
6473
  var fd_slicer = require_fd_slicer();
6472
6474
  var crc32 = require_buffer_crc32();
6473
- var util = (0, import_chunk_HHQDDCTP.__require)("util");
6474
- var EventEmitter2 = (0, import_chunk_HHQDDCTP.__require)("events").EventEmitter;
6475
- var Transform = (0, import_chunk_HHQDDCTP.__require)("stream").Transform;
6476
- var PassThrough = (0, import_chunk_HHQDDCTP.__require)("stream").PassThrough;
6477
- var Writable = (0, import_chunk_HHQDDCTP.__require)("stream").Writable;
6475
+ var util = (0, import_chunk_QFQPBQSO.__require)("util");
6476
+ var EventEmitter2 = (0, import_chunk_QFQPBQSO.__require)("events").EventEmitter;
6477
+ var Transform = (0, import_chunk_QFQPBQSO.__require)("stream").Transform;
6478
+ var PassThrough = (0, import_chunk_QFQPBQSO.__require)("stream").PassThrough;
6479
+ var Writable = (0, import_chunk_QFQPBQSO.__require)("stream").Writable;
6478
6480
  exports.open = open2;
6479
6481
  exports.fromFd = fromFd;
6480
6482
  exports.fromBuffer = fromBuffer;
@@ -7163,14 +7165,14 @@ var require_yauzl = (0, import_chunk_HHQDDCTP.__commonJS)({
7163
7165
  }
7164
7166
  }
7165
7167
  });
7166
- var require_yazl = (0, import_chunk_HHQDDCTP.__commonJS)({
7168
+ var require_yazl = (0, import_chunk_QFQPBQSO.__commonJS)({
7167
7169
  "node_modules/yazl/index.js"(exports) {
7168
- var fs9 = (0, import_chunk_HHQDDCTP.__require)("fs");
7169
- var Transform = (0, import_chunk_HHQDDCTP.__require)("stream").Transform;
7170
- var PassThrough = (0, import_chunk_HHQDDCTP.__require)("stream").PassThrough;
7171
- var zlib = (0, import_chunk_HHQDDCTP.__require)("zlib");
7172
- var util = (0, import_chunk_HHQDDCTP.__require)("util");
7173
- var EventEmitter2 = (0, import_chunk_HHQDDCTP.__require)("events").EventEmitter;
7170
+ var fs9 = (0, import_chunk_QFQPBQSO.__require)("fs");
7171
+ var Transform = (0, import_chunk_QFQPBQSO.__require)("stream").Transform;
7172
+ var PassThrough = (0, import_chunk_QFQPBQSO.__require)("stream").PassThrough;
7173
+ var zlib = (0, import_chunk_QFQPBQSO.__require)("zlib");
7174
+ var util = (0, import_chunk_QFQPBQSO.__require)("util");
7175
+ var EventEmitter2 = (0, import_chunk_QFQPBQSO.__require)("events").EventEmitter;
7174
7176
  var crc32 = require_buffer_crc32();
7175
7177
  exports.ZipFile = ZipFile2;
7176
7178
  exports.dateToDosDateTime = dateToDosDateTime;
@@ -7827,7 +7829,7 @@ function skipClassDef(view, current, symbols) {
7827
7829
  const offset = symbols.symbolToLabelMap.get(f1 >>> 8);
7828
7830
  label = offset != null && symbols.symbols.get(offset)?.str || `method_${pc}`;
7829
7831
  }
7830
- symbols.methods.set(pc, { name: label, id: f1 >>> 8 });
7832
+ symbols.methods.set(pc, { name: label, id: f1 >>> 8, argc: null });
7831
7833
  }
7832
7834
  }
7833
7835
  return current;
@@ -7872,7 +7874,7 @@ function fixupClassDef(view, current, offsetMap) {
7872
7874
  }
7873
7875
  return current;
7874
7876
  }
7875
- var init_data = (0, import_chunk_HHQDDCTP.__esm)({
7877
+ var init_data = (0, import_chunk_QFQPBQSO.__esm)({
7876
7878
  "src/readprg/data.ts"() {
7877
7879
  "use strict";
7878
7880
  init_bytecode();
@@ -8015,7 +8017,7 @@ function findCalleesByNode(state, callee) {
8015
8017
  return null;
8016
8018
  return hasProperty(state.allFunctions, name) && state.allFunctions[name] || null;
8017
8019
  }
8018
- var init_function_info = (0, import_chunk_HHQDDCTP.__esm)({
8020
+ var init_function_info = (0, import_chunk_QFQPBQSO.__esm)({
8019
8021
  "src/function-info.ts"() {
8020
8022
  "use strict";
8021
8023
  init_ast();
@@ -8077,7 +8079,7 @@ function renameVariable(state, locals, declName2) {
8077
8079
  map2[name] = true;
8078
8080
  return name;
8079
8081
  }
8080
- var init_variable_renamer = (0, import_chunk_HHQDDCTP.__esm)({
8082
+ var init_variable_renamer = (0, import_chunk_QFQPBQSO.__esm)({
8081
8083
  "src/variable-renamer.ts"() {
8082
8084
  "use strict";
8083
8085
  init_api();
@@ -8910,7 +8912,7 @@ function fixNodeScope(state, lookupNode, nodeStack) {
8910
8912
  }
8911
8913
  return null;
8912
8914
  }
8913
- var init_inliner = (0, import_chunk_HHQDDCTP.__esm)({
8915
+ var init_inliner = (0, import_chunk_QFQPBQSO.__esm)({
8914
8916
  "src/inliner.ts"() {
8915
8917
  "use strict";
8916
8918
  init_api();
@@ -8920,7 +8922,7 @@ var init_inliner = (0, import_chunk_HHQDDCTP.__esm)({
8920
8922
  }
8921
8923
  });
8922
8924
  var StateNodeAttributes;
8923
- var init_optimizer_types = (0, import_chunk_HHQDDCTP.__esm)({
8925
+ var init_optimizer_types = (0, import_chunk_QFQPBQSO.__esm)({
8924
8926
  "src/optimizer-types.ts"() {
8925
8927
  "use strict";
8926
8928
  StateNodeAttributes = /* @__PURE__ */ ((StateNodeAttributes2) => {
@@ -9066,7 +9068,7 @@ function pragmaChecker(state, ast, diagnostics) {
9066
9068
  return null;
9067
9069
  });
9068
9070
  }
9069
- var init_pragma_checker = (0, import_chunk_HHQDDCTP.__esm)({
9071
+ var init_pragma_checker = (0, import_chunk_QFQPBQSO.__esm)({
9070
9072
  "src/pragma-checker.ts"() {
9071
9073
  "use strict";
9072
9074
  init_api();
@@ -9427,9 +9429,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
9427
9429
  );
9428
9430
  }
9429
9431
  } else {
9430
- (0, import_chunk_HHQDDCTP.forEach)(events, (e) => e.mayThrow = false);
9432
+ (0, import_chunk_QFQPBQSO.forEach)(events, (e) => e.mayThrow = false);
9431
9433
  }
9432
- (0, import_chunk_HHQDDCTP.forEach)(events, (event) => {
9434
+ (0, import_chunk_QFQPBQSO.forEach)(events, (event) => {
9433
9435
  if (event.mayThrow) {
9434
9436
  for (let i = localState.stack.length; i--; ) {
9435
9437
  const target = localState.stack[i].throw;
@@ -9570,11 +9572,11 @@ function getPostOrder(head) {
9570
9572
  return blocks;
9571
9573
  }
9572
9574
  var Terminals, LocalState;
9573
- var init_control_flow = (0, import_chunk_HHQDDCTP.__esm)({
9575
+ var init_control_flow = (0, import_chunk_QFQPBQSO.__esm)({
9574
9576
  "src/control-flow.ts"() {
9575
9577
  "use strict";
9576
9578
  init_ast();
9577
- (0, import_chunk_HHQDDCTP.init_util)();
9579
+ (0, import_chunk_QFQPBQSO.init_util)();
9578
9580
  Terminals = {
9579
9581
  BreakStatement: "break",
9580
9582
  ContinueStatement: "continue",
@@ -9604,12 +9606,12 @@ var init_control_flow = (0, import_chunk_HHQDDCTP.__esm)({
9604
9606
  if (!from.succs) {
9605
9607
  from.succs = [to];
9606
9608
  } else {
9607
- (0, import_chunk_HHQDDCTP.pushUnique)(from.succs, to);
9609
+ (0, import_chunk_QFQPBQSO.pushUnique)(from.succs, to);
9608
9610
  }
9609
9611
  if (!to.preds) {
9610
9612
  to.preds = [from];
9611
9613
  } else {
9612
- (0, import_chunk_HHQDDCTP.pushUnique)(to.preds, from);
9614
+ (0, import_chunk_QFQPBQSO.pushUnique)(to.preds, from);
9613
9615
  }
9614
9616
  }
9615
9617
  newBlock(block) {
@@ -9882,8 +9884,8 @@ function mergeObjectValues(to, from) {
9882
9884
  function mergeStateDecls(to, from) {
9883
9885
  let changed = false;
9884
9886
  let result = to;
9885
- (0, import_chunk_HHQDDCTP.forEach)(from, (v) => {
9886
- if ((0, import_chunk_HHQDDCTP.some)(to, (t) => t === v)) {
9887
+ (0, import_chunk_QFQPBQSO.forEach)(from, (v) => {
9888
+ if ((0, import_chunk_QFQPBQSO.some)(to, (t) => t === v)) {
9887
9889
  return;
9888
9890
  }
9889
9891
  if (Array.isArray(result)) {
@@ -10009,12 +10011,12 @@ function widenTypeHelper(t, depth) {
10009
10011
  function widenType(t) {
10010
10012
  return widenTypeHelper(t, 0);
10011
10013
  }
10012
- var init_union_type = (0, import_chunk_HHQDDCTP.__esm)({
10014
+ var init_union_type = (0, import_chunk_QFQPBQSO.__esm)({
10013
10015
  "src/type-flow/union-type.ts"() {
10014
10016
  "use strict";
10015
10017
  init_ast();
10016
10018
  init_data_flow();
10017
- (0, import_chunk_HHQDDCTP.init_util)();
10019
+ (0, import_chunk_QFQPBQSO.init_util)();
10018
10020
  init_intersection_type();
10019
10021
  init_sub_type();
10020
10022
  init_types();
@@ -10028,7 +10030,7 @@ function expandTypedef(t) {
10028
10030
  );
10029
10031
  const tExpanded = cloneType(t);
10030
10032
  clearValuesUnder(tExpanded, 262144, true);
10031
- (0, import_chunk_HHQDDCTP.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
10033
+ (0, import_chunk_QFQPBQSO.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
10032
10034
  return tExpanded;
10033
10035
  }
10034
10036
  function intersectEnum(t, e) {
@@ -10180,9 +10182,9 @@ function intersectionValue(pair) {
10180
10182
  case 4096:
10181
10183
  case 8192: {
10182
10184
  const common = [];
10183
- (0, import_chunk_HHQDDCTP.forEach)(
10185
+ (0, import_chunk_QFQPBQSO.forEach)(
10184
10186
  pair.avalue,
10185
- (sna) => (0, import_chunk_HHQDDCTP.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
10187
+ (sna) => (0, import_chunk_QFQPBQSO.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
10186
10188
  );
10187
10189
  if (!common.length)
10188
10190
  return null;
@@ -10190,9 +10192,9 @@ function intersectionValue(pair) {
10190
10192
  }
10191
10193
  case 16384: {
10192
10194
  const common = [];
10193
- (0, import_chunk_HHQDDCTP.forEach)(pair.avalue, (sna) => {
10195
+ (0, import_chunk_QFQPBQSO.forEach)(pair.avalue, (sna) => {
10194
10196
  const superA = getSuperClasses(sna);
10195
- (0, import_chunk_HHQDDCTP.forEach)(pair.bvalue, (snb) => {
10197
+ (0, import_chunk_QFQPBQSO.forEach)(pair.bvalue, (snb) => {
10196
10198
  if (sna === snb || superA && superA.has(snb)) {
10197
10199
  common.push(sna);
10198
10200
  }
@@ -10413,7 +10415,7 @@ function restrictExactTypesByEquality(a, b) {
10413
10415
  }
10414
10416
  case 262144:
10415
10417
  return restrictByEquality(
10416
- (0, import_chunk_HHQDDCTP.reduce)(
10418
+ (0, import_chunk_QFQPBQSO.reduce)(
10417
10419
  a.value,
10418
10420
  (cur, decl) => {
10419
10421
  unionInto(cur, decl.resolvedType);
@@ -10475,12 +10477,12 @@ function restrictByEquality(a, b) {
10475
10477
  }
10476
10478
  return restrictByEqualityByComponent(a, b);
10477
10479
  }
10478
- var init_intersection_type = (0, import_chunk_HHQDDCTP.__esm)({
10480
+ var init_intersection_type = (0, import_chunk_QFQPBQSO.__esm)({
10479
10481
  "src/type-flow/intersection-type.ts"() {
10480
10482
  "use strict";
10481
10483
  init_api();
10482
10484
  init_data_flow();
10483
- (0, import_chunk_HHQDDCTP.init_util)();
10485
+ (0, import_chunk_QFQPBQSO.init_util)();
10484
10486
  init_could_be();
10485
10487
  init_interp();
10486
10488
  init_types();
@@ -10566,14 +10568,14 @@ function subtypeOfValue(pair) {
10566
10568
  case 8192: {
10567
10569
  const asd = pair.avalue;
10568
10570
  const bsd = pair.bvalue;
10569
- return (0, import_chunk_HHQDDCTP.some)(asd, (sna) => (0, import_chunk_HHQDDCTP.some)(bsd, (snb) => sna === snb));
10571
+ return (0, import_chunk_QFQPBQSO.some)(asd, (sna) => (0, import_chunk_QFQPBQSO.some)(bsd, (snb) => sna === snb));
10570
10572
  }
10571
10573
  case 16384: {
10572
10574
  const asd = pair.avalue;
10573
10575
  const bsd = pair.bvalue;
10574
- return (0, import_chunk_HHQDDCTP.every)(asd, (sna) => {
10576
+ return (0, import_chunk_QFQPBQSO.every)(asd, (sna) => {
10575
10577
  const superA = getSuperClasses(sna);
10576
- return (0, import_chunk_HHQDDCTP.some)(bsd, (snb) => {
10578
+ return (0, import_chunk_QFQPBQSO.some)(bsd, (snb) => {
10577
10579
  if (sna === snb || superA && superA.has(snb)) {
10578
10580
  return true;
10579
10581
  }
@@ -10604,12 +10606,12 @@ function subtypeOfObj(a, b) {
10604
10606
  return subtypeOf(a[key], value2);
10605
10607
  });
10606
10608
  }
10607
- var init_sub_type = (0, import_chunk_HHQDDCTP.__esm)({
10609
+ var init_sub_type = (0, import_chunk_QFQPBQSO.__esm)({
10608
10610
  "src/type-flow/sub-type.ts"() {
10609
10611
  "use strict";
10610
10612
  init_api();
10611
10613
  init_data_flow();
10612
- (0, import_chunk_HHQDDCTP.init_util)();
10614
+ (0, import_chunk_QFQPBQSO.init_util)();
10613
10615
  init_intersection_type();
10614
10616
  init_types();
10615
10617
  init_union_type();
@@ -10942,7 +10944,7 @@ function evaluateLogicalTypes(op, left, right) {
10942
10944
  }
10943
10945
  }
10944
10946
  var operators;
10945
- var init_interp_binary = (0, import_chunk_HHQDDCTP.__esm)({
10947
+ var init_interp_binary = (0, import_chunk_QFQPBQSO.__esm)({
10946
10948
  "src/type-flow/interp-binary.ts"() {
10947
10949
  "use strict";
10948
10950
  init_could_be();
@@ -10957,13 +10959,13 @@ function isTypeStateKey(decl) {
10957
10959
  return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
10958
10960
  }
10959
10961
  function declIsLocal(decl) {
10960
- return (0, import_chunk_HHQDDCTP.some)(
10962
+ return (0, import_chunk_QFQPBQSO.some)(
10961
10963
  decl,
10962
10964
  (d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
10963
10965
  );
10964
10966
  }
10965
10967
  function declIsNonLocal(decl) {
10966
- return (0, import_chunk_HHQDDCTP.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
10968
+ return (0, import_chunk_QFQPBQSO.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
10967
10969
  }
10968
10970
  function localDeclName(decl) {
10969
10971
  if (Array.isArray(decl))
@@ -10979,7 +10981,7 @@ function localDeclName(decl) {
10979
10981
  throw new Error(`Invalid local decl: ${declFullName(decl)}`);
10980
10982
  }
10981
10983
  function tsKey(key) {
10982
- return `${(0, import_chunk_HHQDDCTP.map)(key, (k) => {
10984
+ return `${(0, import_chunk_QFQPBQSO.map)(key, (k) => {
10983
10985
  if (k.type === "Literal") {
10984
10986
  return k.raw;
10985
10987
  } else if (isStateNode(k)) {
@@ -11011,7 +11013,7 @@ function describeEvent(event) {
11011
11013
  }
11012
11014
  function printBlockEvents(block, extra) {
11013
11015
  console.log("Events:");
11014
- (0, import_chunk_HHQDDCTP.forEach)(
11016
+ (0, import_chunk_QFQPBQSO.forEach)(
11015
11017
  block.events,
11016
11018
  (event) => console.log(` ${describeEvent(event)} ${extra ? extra(event) : ""}`)
11017
11019
  );
@@ -11128,12 +11130,12 @@ function resolveDottedMember(istate, object, next) {
11128
11130
  const mayThrow2 = !subtypeOf(object, type);
11129
11131
  return { mayThrow: mayThrow2, object: type, property };
11130
11132
  }
11131
- var init_type_flow_util = (0, import_chunk_HHQDDCTP.__esm)({
11133
+ var init_type_flow_util = (0, import_chunk_QFQPBQSO.__esm)({
11132
11134
  "src/type-flow/type-flow-util.ts"() {
11133
11135
  "use strict";
11134
11136
  init_api();
11135
11137
  init_data_flow();
11136
- (0, import_chunk_HHQDDCTP.init_util)();
11138
+ (0, import_chunk_QFQPBQSO.init_util)();
11137
11139
  init_intersection_type();
11138
11140
  init_sub_type();
11139
11141
  init_types();
@@ -11185,7 +11187,7 @@ function calleeObjectType(istate, callee) {
11185
11187
  }
11186
11188
  function checkCallArgs(istate, node, callees, args) {
11187
11189
  const allDiags = [];
11188
- const resultType = (0, import_chunk_HHQDDCTP.reduce)(
11190
+ const resultType = (0, import_chunk_QFQPBQSO.reduce)(
11189
11191
  callees,
11190
11192
  (result, cur) => {
11191
11193
  const curDiags = [];
@@ -11334,7 +11336,7 @@ function isOverride(cur, funcs) {
11334
11336
  const cls = cur.stack?.[cur.stack.length - 1]?.sn;
11335
11337
  if (cls?.type === "ClassDeclaration" && cls.superClasses) {
11336
11338
  const supers = getSuperClasses(cls);
11337
- if (supers && (0, import_chunk_HHQDDCTP.some)(funcs, (func) => {
11339
+ if (supers && (0, import_chunk_QFQPBQSO.some)(funcs, (func) => {
11338
11340
  if (func === cur)
11339
11341
  return false;
11340
11342
  const fcls = func.stack?.[func.stack.length - 1].sn;
@@ -11720,12 +11722,12 @@ function expandKeys(state, table) {
11720
11722
  return result;
11721
11723
  }
11722
11724
  var systemCallInfo, systemCallVersion;
11723
- var init_interp_call = (0, import_chunk_HHQDDCTP.__esm)({
11725
+ var init_interp_call = (0, import_chunk_QFQPBQSO.__esm)({
11724
11726
  "src/type-flow/interp-call.ts"() {
11725
11727
  "use strict";
11726
11728
  init_optimizer_types();
11727
11729
  init_api();
11728
- (0, import_chunk_HHQDDCTP.init_util)();
11730
+ (0, import_chunk_QFQPBQSO.init_util)();
11729
11731
  init_interp();
11730
11732
  init_sub_type();
11731
11733
  init_types();
@@ -12628,7 +12630,7 @@ function mustBeIdentical(a, b) {
12628
12630
  }
12629
12631
  return false;
12630
12632
  }
12631
- var init_interp = (0, import_chunk_HHQDDCTP.__esm)({
12633
+ var init_interp = (0, import_chunk_QFQPBQSO.__esm)({
12632
12634
  "src/type-flow/interp.ts"() {
12633
12635
  "use strict";
12634
12636
  init_api();
@@ -12847,7 +12849,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
12847
12849
  );
12848
12850
  if (value2) {
12849
12851
  const a = [];
12850
- (0, import_chunk_HHQDDCTP.forEach)(value2, (v) => {
12852
+ (0, import_chunk_QFQPBQSO.forEach)(value2, (v) => {
12851
12853
  if (v !== sn)
12852
12854
  a.push(v);
12853
12855
  });
@@ -13222,7 +13224,7 @@ function mustBeFalse(arg) {
13222
13224
  return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
13223
13225
  }
13224
13226
  function display(type) {
13225
- const names = (v, fn) => (0, import_chunk_HHQDDCTP.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
13227
+ const names = (v, fn) => (0, import_chunk_QFQPBQSO.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
13226
13228
  const parts = [];
13227
13229
  const displayOne = (tv) => {
13228
13230
  switch (tv.type) {
@@ -13413,13 +13415,13 @@ function getStateNodeDeclsFromType(state, object) {
13413
13415
  return decls;
13414
13416
  }
13415
13417
  var LastTypeTag, SingletonTypeTagsConst, UnionDataTypeTagsConst, ValueTypeTagsConst, ObjectLikeTagsConst, EnumTagsConst, TruthyTypes;
13416
- var init_types = (0, import_chunk_HHQDDCTP.__esm)({
13418
+ var init_types = (0, import_chunk_QFQPBQSO.__esm)({
13417
13419
  "src/type-flow/types.ts"() {
13418
13420
  "use strict";
13419
13421
  init_data_flow();
13420
13422
  init_api();
13421
13423
  init_ast();
13422
- (0, import_chunk_HHQDDCTP.init_util)();
13424
+ (0, import_chunk_QFQPBQSO.init_util)();
13423
13425
  init_interp();
13424
13426
  init_union_type();
13425
13427
  init_intersection_type();
@@ -13475,7 +13477,7 @@ function couldBeHelper(a, b, shallow) {
13475
13477
  262144
13476
13478
  /* Typedef */
13477
13479
  );
13478
- return typedef && (0, import_chunk_HHQDDCTP.some)(typedef, (td) => {
13480
+ return typedef && (0, import_chunk_QFQPBQSO.some)(typedef, (td) => {
13479
13481
  if (!td.resolvedType) {
13480
13482
  throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
13481
13483
  }
@@ -13526,15 +13528,15 @@ function couldBeValue(pair, shallow) {
13526
13528
  }
13527
13529
  case 4096:
13528
13530
  case 8192: {
13529
- return (0, import_chunk_HHQDDCTP.some)(
13531
+ return (0, import_chunk_QFQPBQSO.some)(
13530
13532
  pair.avalue,
13531
- (sna) => (0, import_chunk_HHQDDCTP.some)(pair.bvalue, (snb) => sna === snb)
13533
+ (sna) => (0, import_chunk_QFQPBQSO.some)(pair.bvalue, (snb) => sna === snb)
13532
13534
  );
13533
13535
  }
13534
13536
  case 16384: {
13535
- return (0, import_chunk_HHQDDCTP.some)(pair.avalue, (sna) => {
13537
+ return (0, import_chunk_QFQPBQSO.some)(pair.avalue, (sna) => {
13536
13538
  const superA = getSuperClasses(sna);
13537
- return (0, import_chunk_HHQDDCTP.some)(pair.bvalue, (snb) => {
13539
+ return (0, import_chunk_QFQPBQSO.some)(pair.bvalue, (snb) => {
13538
13540
  if (sna === snb || superA && superA.has(snb)) {
13539
13541
  return true;
13540
13542
  }
@@ -13562,12 +13564,12 @@ function couldBeObj(a, b) {
13562
13564
  return couldBe(value2, b[key]);
13563
13565
  });
13564
13566
  }
13565
- var init_could_be = (0, import_chunk_HHQDDCTP.__esm)({
13567
+ var init_could_be = (0, import_chunk_QFQPBQSO.__esm)({
13566
13568
  "src/type-flow/could-be.ts"() {
13567
13569
  "use strict";
13568
13570
  init_api();
13569
13571
  init_data_flow();
13570
- (0, import_chunk_HHQDDCTP.init_util)();
13572
+ (0, import_chunk_QFQPBQSO.init_util)();
13571
13573
  init_types();
13572
13574
  }
13573
13575
  });
@@ -13888,7 +13890,7 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
13888
13890
  });
13889
13891
  return { copyPropStores, changes };
13890
13892
  }
13891
- var init_dead_store = (0, import_chunk_HHQDDCTP.__esm)({
13893
+ var init_dead_store = (0, import_chunk_QFQPBQSO.__esm)({
13892
13894
  "src/type-flow/dead-store.ts"() {
13893
13895
  "use strict";
13894
13896
  init_api();
@@ -14484,7 +14486,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14484
14486
  }
14485
14487
  if (selfClassDecl) {
14486
14488
  const baseObj = getObjectValue(baseElem.type);
14487
- if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_HHQDDCTP.some)(
14489
+ if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_QFQPBQSO.some)(
14488
14490
  baseObj.klass.value,
14489
14491
  (cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
14490
14492
  )) {
@@ -14529,7 +14531,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14529
14531
  return [next, updateAny];
14530
14532
  }
14531
14533
  function typeConstraint(decls) {
14532
- return (0, import_chunk_HHQDDCTP.reduce)(
14534
+ return (0, import_chunk_QFQPBQSO.reduce)(
14533
14535
  decls,
14534
14536
  (cur, decl) => {
14535
14537
  if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
@@ -14622,9 +14624,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14622
14624
  stack: [],
14623
14625
  func
14624
14626
  };
14625
- const modifiableDecl = (decls, callees) => (0, import_chunk_HHQDDCTP.some)(
14627
+ const modifiableDecl = (decls, callees) => (0, import_chunk_QFQPBQSO.some)(
14626
14628
  decls,
14627
- (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_HHQDDCTP.some)(callees, (callee) => functionMayModify(state, callee, decl)))
14629
+ (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_QFQPBQSO.some)(callees, (callee) => functionMayModify(state, callee, decl)))
14628
14630
  );
14629
14631
  const mergeSuccState = (top, curState) => {
14630
14632
  top.succs?.forEach((succ) => {
@@ -14645,7 +14647,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14645
14647
  type: 0
14646
14648
  /* Never */
14647
14649
  };
14648
- const result = (0, import_chunk_HHQDDCTP.every)(callees, (callee) => {
14650
+ const result = (0, import_chunk_QFQPBQSO.every)(callees, (callee) => {
14649
14651
  const info = sysCallInfo(istate.state, callee);
14650
14652
  if (!info)
14651
14653
  return false;
@@ -15045,7 +15047,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15045
15047
  );
15046
15048
  }
15047
15049
  }
15048
- if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_HHQDDCTP.some)(callees, (callee) => inlineRequested(state, callee))) {
15050
+ if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_QFQPBQSO.some)(callees, (callee) => inlineRequested(state, callee))) {
15049
15051
  event.node.arguments.forEach((arg) => {
15050
15052
  const def = nodeCopyProp.get(arg);
15051
15053
  if (def && nodeCopyProp.get(def) !== false) {
@@ -15057,7 +15059,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15057
15059
  let calleeEffects;
15058
15060
  curState.map.forEach((tsv, decl) => {
15059
15061
  let type = tsv.curType;
15060
- if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_HHQDDCTP.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
15062
+ if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_QFQPBQSO.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
15061
15063
  return;
15062
15064
  }
15063
15065
  if (modifiableDecl(decl, callees)) {
@@ -15070,7 +15072,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15070
15072
  (0, import_node_assert3.default)(!tsv.copyPropItem);
15071
15073
  clearRelatedCopyPropEvents(curState, decl, nodeCopyProp);
15072
15074
  curState.map.set(decl, { curType: typeConstraint(decl) });
15073
- } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_HHQDDCTP.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
15075
+ } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_QFQPBQSO.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
15074
15076
  if (type.value != null && type.type & 32768) {
15075
15077
  const odata = getObjectValue(tsv.curType);
15076
15078
  if (odata?.obj) {
@@ -15118,7 +15120,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15118
15120
  2
15119
15121
  /* Reassign */
15120
15122
  );
15121
- (0, import_chunk_HHQDDCTP.some)(event.decl, (decl) => {
15123
+ (0, import_chunk_QFQPBQSO.some)(event.decl, (decl) => {
15122
15124
  if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
15123
15125
  return false;
15124
15126
  }
@@ -15126,7 +15128,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15126
15128
  if (affected) {
15127
15129
  const objType = typeFromTypeStateNodes(
15128
15130
  istate.state,
15129
- (0, import_chunk_HHQDDCTP.map)(
15131
+ (0, import_chunk_QFQPBQSO.map)(
15130
15132
  event.decl,
15131
15133
  (decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
15132
15134
  ).filter(
@@ -15147,7 +15149,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15147
15149
  });
15148
15150
  if (wasComputedDecl) {
15149
15151
  curState.map.forEach((value2, decls) => {
15150
- if ((0, import_chunk_HHQDDCTP.some)(
15152
+ if ((0, import_chunk_QFQPBQSO.some)(
15151
15153
  decls,
15152
15154
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
15153
15155
  )) {
@@ -15191,14 +15193,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15191
15193
  }
15192
15194
  if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
15193
15195
  // in case it has side effects.
15194
- (0, import_chunk_HHQDDCTP.some)(
15196
+ (0, import_chunk_QFQPBQSO.some)(
15195
15197
  event2.calleeDecl,
15196
15198
  (callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
15197
15199
  )) {
15198
15200
  return false;
15199
15201
  }
15200
15202
  }
15201
- if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_HHQDDCTP.some)(
15203
+ if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_QFQPBQSO.some)(
15202
15204
  event2.decl,
15203
15205
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
15204
15206
  )) {
@@ -15306,7 +15308,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15306
15308
  if (!successorsHandled) {
15307
15309
  if (logThisRun) {
15308
15310
  console.log(
15309
- ` merge to: ${(0, import_chunk_HHQDDCTP.map)(
15311
+ ` merge to: ${(0, import_chunk_QFQPBQSO.map)(
15310
15312
  top.succs,
15311
15313
  (succ) => succ.order || -1
15312
15314
  ).join(", ")}`
@@ -15543,7 +15545,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
15543
15545
  }, curInfo);
15544
15546
  if (rep === curInfo)
15545
15547
  return null;
15546
- const name = (0, import_chunk_HHQDDCTP.reduce)(
15548
+ const name = (0, import_chunk_QFQPBQSO.reduce)(
15547
15549
  rep.decl,
15548
15550
  (cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
15549
15551
  null
@@ -15644,7 +15646,7 @@ function updateByAssocPath(path7, property, union) {
15644
15646
  return property;
15645
15647
  }
15646
15648
  var logging, missingNullWorkaround;
15647
- var init_type_flow = (0, import_chunk_HHQDDCTP.__esm)({
15649
+ var init_type_flow = (0, import_chunk_QFQPBQSO.__esm)({
15648
15650
  "src/type-flow.ts"() {
15649
15651
  "use strict";
15650
15652
  init_api();
@@ -15663,7 +15665,7 @@ var init_type_flow = (0, import_chunk_HHQDDCTP.__esm)({
15663
15665
  init_type_flow_util();
15664
15666
  init_types();
15665
15667
  init_union_type();
15666
- (0, import_chunk_HHQDDCTP.init_util)();
15668
+ (0, import_chunk_QFQPBQSO.init_util)();
15667
15669
  logging = true;
15668
15670
  missingNullWorkaround = true;
15669
15671
  }
@@ -15980,7 +15982,7 @@ function variableCleanup(node) {
15980
15982
  }
15981
15983
  return null;
15982
15984
  }
15983
- var init_minimize_locals = (0, import_chunk_HHQDDCTP.__esm)({
15985
+ var init_minimize_locals = (0, import_chunk_QFQPBQSO.__esm)({
15984
15986
  "src/type-flow/minimize-locals.ts"() {
15985
15987
  "use strict";
15986
15988
  init_api();
@@ -16108,7 +16110,7 @@ function buildPREGraph(state, func) {
16108
16110
  const event = block.events[i];
16109
16111
  switch (event.type) {
16110
16112
  case "ref":
16111
- if ((0, import_chunk_HHQDDCTP.some)(
16113
+ if ((0, import_chunk_QFQPBQSO.some)(
16112
16114
  event.decl,
16113
16115
  (decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
16114
16116
  )) {
@@ -16126,7 +16128,7 @@ function buildPREGraph(state, func) {
16126
16128
  defs.add(event.decl);
16127
16129
  break;
16128
16130
  case "mod":
16129
- if (event.callees && (0, import_chunk_HHQDDCTP.every)(event.callees, (callee) => callee.info === false)) {
16131
+ if (event.callees && (0, import_chunk_QFQPBQSO.every)(event.callees, (callee) => callee.info === false)) {
16130
16132
  block.events.splice(i, 1);
16131
16133
  break;
16132
16134
  }
@@ -16365,7 +16367,7 @@ function computeAttributes(state, head) {
16365
16367
  }
16366
16368
  case "mod": {
16367
16369
  curState.forEach((candidates, decls) => {
16368
- if ((0, import_chunk_HHQDDCTP.some)(
16370
+ if ((0, import_chunk_QFQPBQSO.some)(
16369
16371
  decls,
16370
16372
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
16371
16373
  (callee) => functionMayModify(state, callee, decl)
@@ -16645,7 +16647,7 @@ function applyReplacements(func, nodeMap, declMap) {
16645
16647
  );
16646
16648
  }
16647
16649
  var logging2, LocalRefCost;
16648
- var init_pre = (0, import_chunk_HHQDDCTP.__esm)({
16650
+ var init_pre = (0, import_chunk_QFQPBQSO.__esm)({
16649
16651
  "src/pre.ts"() {
16650
16652
  "use strict";
16651
16653
  init_api();
@@ -16654,7 +16656,7 @@ var init_pre = (0, import_chunk_HHQDDCTP.__esm)({
16654
16656
  init_data_flow();
16655
16657
  init_function_info();
16656
16658
  init_minimize_locals();
16657
- (0, import_chunk_HHQDDCTP.init_util)();
16659
+ (0, import_chunk_QFQPBQSO.init_util)();
16658
16660
  logging2 = false;
16659
16661
  LocalRefCost = 2;
16660
16662
  }
@@ -16834,7 +16836,7 @@ function isImportCandidate(module2, stack) {
16834
16836
  );
16835
16837
  });
16836
16838
  }
16837
- var init_minimize_modules = (0, import_chunk_HHQDDCTP.__esm)({
16839
+ var init_minimize_modules = (0, import_chunk_QFQPBQSO.__esm)({
16838
16840
  "src/type-flow/minimize-modules.ts"() {
16839
16841
  "use strict";
16840
16842
  init_api();
@@ -16960,7 +16962,7 @@ function beforeEvaluate(istate, node) {
16960
16962
  case "UnaryExpression":
16961
16963
  if (node.operator === "-") {
16962
16964
  const [arg] = istate.stack.slice(-1);
16963
- if ((arg.value.type & (8 | 16)) === arg.value.type && arg.value.value == null) {
16965
+ if ((arg.value.type & 120) === arg.value.type && arg.value.value == null) {
16964
16966
  const leftType = { type: 8, value: 0 };
16965
16967
  const rep = withLoc(
16966
16968
  {
@@ -16988,7 +16990,7 @@ function beforeEvaluate(istate, node) {
16988
16990
  break;
16989
16991
  }
16990
16992
  const id = node.right.argument;
16991
- if ((0, import_chunk_HHQDDCTP.every)(left.value.value, (m) => {
16993
+ if ((0, import_chunk_QFQPBQSO.every)(left.value.value, (m) => {
16992
16994
  if (hasProperty(m.decls, id.name))
16993
16995
  return false;
16994
16996
  return istate.state.lookup({
@@ -17428,13 +17430,13 @@ function tryDeEnumerate(istate, node, elem) {
17428
17430
  }
17429
17431
  return null;
17430
17432
  }
17431
- var init_optimize = (0, import_chunk_HHQDDCTP.__esm)({
17433
+ var init_optimize = (0, import_chunk_QFQPBQSO.__esm)({
17432
17434
  "src/type-flow/optimize.ts"() {
17433
17435
  "use strict";
17434
17436
  init_ast();
17435
17437
  init_inliner();
17436
17438
  init_type_flow();
17437
- (0, import_chunk_HHQDDCTP.init_util)();
17439
+ (0, import_chunk_QFQPBQSO.init_util)();
17438
17440
  init_interp();
17439
17441
  init_interp_binary();
17440
17442
  init_types();
@@ -17601,7 +17603,7 @@ function cleanupUnusedVars(state, node) {
17601
17603
  });
17602
17604
  return changes;
17603
17605
  }
17604
- var init_unused_exprs = (0, import_chunk_HHQDDCTP.__esm)({
17606
+ var init_unused_exprs = (0, import_chunk_QFQPBQSO.__esm)({
17605
17607
  "src/unused-exprs.ts"() {
17606
17608
  "use strict";
17607
17609
  init_api();
@@ -17966,7 +17968,7 @@ function markFunctionCalled(state, func) {
17966
17968
  state.calledFunctions[func.id.name] = [func];
17967
17969
  return;
17968
17970
  }
17969
- (0, import_chunk_HHQDDCTP.pushUnique)(state.calledFunctions[func.id.name], func);
17971
+ (0, import_chunk_QFQPBQSO.pushUnique)(state.calledFunctions[func.id.name], func);
17970
17972
  }
17971
17973
  async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
17972
17974
  const state = await analyze(
@@ -18606,7 +18608,7 @@ function optimizeCall(istate, node, context) {
18606
18608
  callees.forEach((c) => markFunctionCalled(state, c.node));
18607
18609
  return null;
18608
18610
  }
18609
- var init_mc_rewrite = (0, import_chunk_HHQDDCTP.__esm)({
18611
+ var init_mc_rewrite = (0, import_chunk_QFQPBQSO.__esm)({
18610
18612
  "src/mc-rewrite.ts"() {
18611
18613
  "use strict";
18612
18614
  init_api();
@@ -18624,12 +18626,12 @@ var init_mc_rewrite = (0, import_chunk_HHQDDCTP.__esm)({
18624
18626
  init_sub_type();
18625
18627
  init_types();
18626
18628
  init_unused_exprs();
18627
- (0, import_chunk_HHQDDCTP.init_util)();
18629
+ (0, import_chunk_QFQPBQSO.init_util)();
18628
18630
  init_variable_renamer();
18629
18631
  }
18630
18632
  });
18631
18633
  var negativeFixups;
18632
- var init_negative_fixups = (0, import_chunk_HHQDDCTP.__esm)({
18634
+ var init_negative_fixups = (0, import_chunk_QFQPBQSO.__esm)({
18633
18635
  "src/negative-fixups.ts"() {
18634
18636
  "use strict";
18635
18637
  negativeFixups = [
@@ -19174,7 +19176,7 @@ function add_one_resource(state, doc, module2, e) {
19174
19176
  }
19175
19177
  }
19176
19178
  var drawableSkips;
19177
- var init_resources = (0, import_chunk_HHQDDCTP.__esm)({
19179
+ var init_resources = (0, import_chunk_QFQPBQSO.__esm)({
19178
19180
  "src/resources.ts"() {
19179
19181
  "use strict";
19180
19182
  init_api();
@@ -19378,7 +19380,7 @@ function visitReferences(state, ast, name, defn, callback, includeDefs = false,
19378
19380
  collectNamespaces(ast, state);
19379
19381
  delete state.pre;
19380
19382
  }
19381
- var init_visitor = (0, import_chunk_HHQDDCTP.__esm)({
19383
+ var init_visitor = (0, import_chunk_QFQPBQSO.__esm)({
19382
19384
  "src/visitor.ts"() {
19383
19385
  "use strict";
19384
19386
  init_api();
@@ -19550,11 +19552,11 @@ function sameStateNodeDecl(a, b) {
19550
19552
  function sameLookupDefinition(a, b) {
19551
19553
  return (
19552
19554
  // sameStateNodeDecl(a.parent, b.parent) &&
19553
- (0, import_chunk_HHQDDCTP.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
19555
+ (0, import_chunk_QFQPBQSO.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
19554
19556
  );
19555
19557
  }
19556
19558
  function sameLookupResult(a, b) {
19557
- return (0, import_chunk_HHQDDCTP.sameArrays)(a, b, sameLookupDefinition);
19559
+ return (0, import_chunk_QFQPBQSO.sameArrays)(a, b, sameLookupDefinition);
19558
19560
  }
19559
19561
  function declKey(decl) {
19560
19562
  return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
@@ -20021,7 +20023,7 @@ function stateFuncs() {
20021
20023
  if (!hasProperty(this.index, name)) {
20022
20024
  this.index[name] = [];
20023
20025
  }
20024
- (0, import_chunk_HHQDDCTP.pushUnique)(this.index[name], parent);
20026
+ (0, import_chunk_QFQPBQSO.pushUnique)(this.index[name], parent);
20025
20027
  }
20026
20028
  });
20027
20029
  break;
@@ -20077,7 +20079,7 @@ function stateFuncs() {
20077
20079
  if (!hasProperty(values, name)) {
20078
20080
  values[name] = [];
20079
20081
  }
20080
- if ((0, import_chunk_HHQDDCTP.pushUnique)(values[name], m) && currentEnum) {
20082
+ if ((0, import_chunk_QFQPBQSO.pushUnique)(values[name], m) && currentEnum) {
20081
20083
  if (!this.enumMap)
20082
20084
  this.enumMap = /* @__PURE__ */ new Map();
20083
20085
  this.enumMap.set(m, currentEnum);
@@ -20085,7 +20087,7 @@ function stateFuncs() {
20085
20087
  if (!hasProperty(this.index, name)) {
20086
20088
  this.index[name] = [];
20087
20089
  }
20088
- (0, import_chunk_HHQDDCTP.pushUnique)(this.index[name], parent);
20090
+ (0, import_chunk_QFQPBQSO.pushUnique)(this.index[name], parent);
20089
20091
  });
20090
20092
  break;
20091
20093
  }
@@ -20524,7 +20526,7 @@ function getSuperClasses(klass) {
20524
20526
  });
20525
20527
  return superClasses;
20526
20528
  }
20527
- var init_api = (0, import_chunk_HHQDDCTP.__esm)({
20529
+ var init_api = (0, import_chunk_QFQPBQSO.__esm)({
20528
20530
  "src/api.ts"() {
20529
20531
  init_ast();
20530
20532
  init_mc_rewrite();
@@ -20534,7 +20536,7 @@ var init_api = (0, import_chunk_HHQDDCTP.__esm)({
20534
20536
  init_sdk_util();
20535
20537
  init_type_flow_util();
20536
20538
  init_types();
20537
- (0, import_chunk_HHQDDCTP.init_util)();
20539
+ (0, import_chunk_QFQPBQSO.init_util)();
20538
20540
  init_visitor();
20539
20541
  }
20540
20542
  });
@@ -20650,7 +20652,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
20650
20652
  }
20651
20653
  const decl = lookupDefToDecl(results);
20652
20654
  if (decl && path7.length) {
20653
- if (wantsAllRefs && (0, import_chunk_HHQDDCTP.every)(
20655
+ if (wantsAllRefs && (0, import_chunk_QFQPBQSO.every)(
20654
20656
  decl,
20655
20657
  (d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
20656
20658
  )) {
@@ -20758,7 +20760,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
20758
20760
  const decls = findDecl(node);
20759
20761
  if (!decls)
20760
20762
  break;
20761
- if (trackInsertionPoints && (0, import_chunk_HHQDDCTP.some)(decls, (decl) => {
20763
+ if (trackInsertionPoints && (0, import_chunk_QFQPBQSO.some)(decls, (decl) => {
20762
20764
  if (decl.type === "VariableDeclarator") {
20763
20765
  const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
20764
20766
  if (defStmts) {
@@ -21001,7 +21003,7 @@ function getFlowEvent(node, stmt, findDecl) {
21001
21003
  return null;
21002
21004
  }
21003
21005
  var DataflowQueue;
21004
- var init_data_flow = (0, import_chunk_HHQDDCTP.__esm)({
21006
+ var init_data_flow = (0, import_chunk_QFQPBQSO.__esm)({
21005
21007
  "src/data-flow.ts"() {
21006
21008
  "use strict";
21007
21009
  init_api();
@@ -21009,8 +21011,8 @@ var init_data_flow = (0, import_chunk_HHQDDCTP.__esm)({
21009
21011
  init_control_flow();
21010
21012
  init_function_info();
21011
21013
  init_type_flow_util();
21012
- (0, import_chunk_HHQDDCTP.init_util)();
21013
- DataflowQueue = class extends import_chunk_HHQDDCTP.GenericQueue {
21014
+ (0, import_chunk_QFQPBQSO.init_util)();
21015
+ DataflowQueue = class extends import_chunk_QFQPBQSO.GenericQueue {
21014
21016
  constructor() {
21015
21017
  super((b, a) => (a.order || 0) - (b.order || 0));
21016
21018
  }
@@ -21303,6 +21305,74 @@ function getOpInfo(bytecode) {
21303
21305
  unhandledType(bytecode);
21304
21306
  }
21305
21307
  }
21308
+ function getOpEffects(bytecode) {
21309
+ switch (bytecode.op) {
21310
+ case 19:
21311
+ return 1;
21312
+ case 14:
21313
+ return 2;
21314
+ case 17:
21315
+ return 4;
21316
+ case 21:
21317
+ return 2 | 4;
21318
+ case 15:
21319
+ return 8 | 2 | 4;
21320
+ case 0:
21321
+ case 23:
21322
+ case 1:
21323
+ case 53:
21324
+ case 25:
21325
+ case 35:
21326
+ case 2:
21327
+ case 22:
21328
+ case 51:
21329
+ case 40:
21330
+ case 41:
21331
+ case 3:
21332
+ case 4:
21333
+ case 5:
21334
+ case 6:
21335
+ case 7:
21336
+ case 8:
21337
+ case 9:
21338
+ case 10:
21339
+ case 11:
21340
+ case 12:
21341
+ case 26:
21342
+ case 27:
21343
+ case 28:
21344
+ case 29:
21345
+ case 30:
21346
+ case 31:
21347
+ case 34:
21348
+ case 33:
21349
+ case 13:
21350
+ case 16:
21351
+ case 32:
21352
+ case 45:
21353
+ case 48:
21354
+ case 20:
21355
+ case 54:
21356
+ case 47:
21357
+ case 42:
21358
+ case 44:
21359
+ case 43:
21360
+ case 18:
21361
+ case 46:
21362
+ case 24:
21363
+ case 37:
21364
+ case 38:
21365
+ case 39:
21366
+ case 52:
21367
+ case 49:
21368
+ case 50:
21369
+ return 0;
21370
+ case 36:
21371
+ throw new Error(`Unknown opcode ${bytecode.op}`);
21372
+ default:
21373
+ unhandledType(bytecode);
21374
+ }
21375
+ }
21306
21376
  function isBoolOp(op) {
21307
21377
  switch (op) {
21308
21378
  case 32:
@@ -21327,7 +21397,7 @@ function isCondBranch(op) {
21327
21397
  return false;
21328
21398
  }
21329
21399
  var Opcodes;
21330
- var init_opcodes = (0, import_chunk_HHQDDCTP.__esm)({
21400
+ var init_opcodes = (0, import_chunk_QFQPBQSO.__esm)({
21331
21401
  "src/readprg/opcodes.ts"() {
21332
21402
  "use strict";
21333
21403
  init_data_flow();
@@ -21408,6 +21478,45 @@ function postOrderTraverse2(func, visitor) {
21408
21478
  };
21409
21479
  helper(func.offset);
21410
21480
  }
21481
+ function intersect(a, b) {
21482
+ if (a.size > b.size)
21483
+ return intersect(b, a);
21484
+ const result = /* @__PURE__ */ new Set();
21485
+ a.forEach((x) => b.has(x) && result.add(x));
21486
+ return result;
21487
+ }
21488
+ function computeDominators(func) {
21489
+ const states = /* @__PURE__ */ new Map();
21490
+ rpoPropagate(
21491
+ func,
21492
+ (block) => {
21493
+ let state = states.get(block.offset);
21494
+ if (!state) {
21495
+ state = /* @__PURE__ */ new Set();
21496
+ states.set(block.offset, state);
21497
+ }
21498
+ return new Set(state).add(block.offset);
21499
+ },
21500
+ null,
21501
+ () => {
21502
+ },
21503
+ (from, state, succBlock) => {
21504
+ const succState = states.get(succBlock.offset);
21505
+ if (!succState) {
21506
+ states.set(succBlock.offset, new Set(state));
21507
+ return true;
21508
+ }
21509
+ const newState = intersect(state, succState);
21510
+ if (newState.size !== succState.size) {
21511
+ states.set(succBlock.offset, newState);
21512
+ return true;
21513
+ }
21514
+ return false;
21515
+ }
21516
+ );
21517
+ states.forEach((state, offset) => state.add(offset));
21518
+ return states;
21519
+ }
21411
21520
  function computeJsrMap(func) {
21412
21521
  const jsrMap = /* @__PURE__ */ new Map();
21413
21522
  const findRets = (offset, rets, visited) => {
@@ -21439,7 +21548,7 @@ function computeJsrMap(func) {
21439
21548
  }
21440
21549
  function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
21441
21550
  const order = /* @__PURE__ */ new Map();
21442
- const queue = new import_chunk_HHQDDCTP.GenericQueue(
21551
+ const queue = new import_chunk_QFQPBQSO.GenericQueue(
21443
21552
  (b, a) => order.get(a) - order.get(b)
21444
21553
  );
21445
21554
  postOrderTraverse2(func, (block) => {
@@ -21498,7 +21607,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21498
21607
  });
21499
21608
  blocks.reverse().forEach((block, i) => order.set(block, i));
21500
21609
  }
21501
- const queue = new import_chunk_HHQDDCTP.GenericQueue(
21610
+ const queue = new import_chunk_QFQPBQSO.GenericQueue(
21502
21611
  (b, a) => order.get(a) - order.get(b)
21503
21612
  );
21504
21613
  queue.enqueue(func.blocks.get(func.offset));
@@ -21511,15 +21620,17 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21511
21620
  merge(top, localState, toBlock, isExSucc) && queue.enqueue(toBlock);
21512
21621
  };
21513
21622
  let flags;
21514
- for (let i = 0; i < top.bytecodes.length; i++) {
21515
- const bc = top.bytecodes[i];
21516
- flags = processBc(top, bc, localState);
21517
- if (flags != null && flags & 16) {
21518
- i = -1;
21519
- continue;
21520
- }
21521
- if (top.exsucc && (bc.op === 15 || bc.op === 51)) {
21522
- doMerge(top.exsucc, true);
21623
+ if (processBc) {
21624
+ for (let i = 0; i < top.bytecodes.length; i++) {
21625
+ const bc = top.bytecodes[i];
21626
+ flags = processBc(top, bc, localState);
21627
+ if (flags != null && flags & 16) {
21628
+ i = -1;
21629
+ continue;
21630
+ }
21631
+ if (top.exsucc && (bc.op === 15 || bc.op === 51)) {
21632
+ doMerge(top.exsucc, true);
21633
+ }
21523
21634
  }
21524
21635
  }
21525
21636
  postBlock(top, localState);
@@ -21541,13 +21652,216 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21541
21652
  queue.enqueue(func.blocks.get(top.taken));
21542
21653
  }
21543
21654
  }
21655
+ if (!processBc && top.exsucc) {
21656
+ doMerge(top.exsucc, true);
21657
+ }
21544
21658
  retMap.get(top.offset)?.forEach((retSucc) => doMerge(retSucc, false));
21545
21659
  }
21546
21660
  }
21547
- var init_cflow = (0, import_chunk_HHQDDCTP.__esm)({
21661
+ var init_cflow = (0, import_chunk_QFQPBQSO.__esm)({
21548
21662
  "src/readprg/cflow.ts"() {
21549
21663
  "use strict";
21550
- (0, import_chunk_HHQDDCTP.init_util)();
21664
+ (0, import_chunk_QFQPBQSO.init_util)();
21665
+ init_opcodes();
21666
+ }
21667
+ });
21668
+ function sizeBasedPRE2(func, context) {
21669
+ if (func.argc == null) {
21670
+ return;
21671
+ }
21672
+ const canonicalMap = /* @__PURE__ */ new Map();
21673
+ let states = /* @__PURE__ */ new Map();
21674
+ let incSp = null;
21675
+ const getBigInt = (bc, index, bcs) => {
21676
+ switch (bc.op) {
21677
+ case 50: {
21678
+ const buffer = new ArrayBuffer(Float64Array.BYTES_PER_ELEMENT);
21679
+ const view = new DataView(buffer);
21680
+ view.setFloat64(0, bc.arg);
21681
+ return view.getBigInt64(0) << 8n | BigInt(bc.op);
21682
+ }
21683
+ case 38: {
21684
+ const buffer = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT);
21685
+ const view = new DataView(buffer);
21686
+ view.setFloat32(0, bc.arg);
21687
+ return BigInt(view.getInt32(0)) << 8n | BigInt(bc.op);
21688
+ }
21689
+ case 39:
21690
+ if (bcs[index + 1]?.op === 48) {
21691
+ break;
21692
+ }
21693
+ case 37:
21694
+ case 49:
21695
+ case 52:
21696
+ case 24:
21697
+ return BigInt(bc.arg) << 8n | BigInt(bc.op);
21698
+ case 1:
21699
+ if (incSp != null) {
21700
+ incSp = false;
21701
+ }
21702
+ incSp = bc;
21703
+ return null;
21704
+ case 48:
21705
+ if (index && bcs[index - 1].op === 39) {
21706
+ return BigInt(bcs[index - 1].arg) << 8n | BigInt(bc.op);
21707
+ }
21708
+ break;
21709
+ }
21710
+ return null;
21711
+ };
21712
+ const order = /* @__PURE__ */ new Map();
21713
+ postOrderTraverse2(func, (block) => {
21714
+ order.set(block.offset, order.size);
21715
+ });
21716
+ order.forEach((order2, offset) => {
21717
+ const block = func.blocks.get(offset);
21718
+ (0, import_node_assert7.default)(block);
21719
+ const state = /* @__PURE__ */ new Map();
21720
+ block.bytecodes.forEach((bc, i, bcs) => {
21721
+ const id = getBigInt(bc, i, bcs);
21722
+ if (id == null)
21723
+ return;
21724
+ let canon = canonicalMap.get(id);
21725
+ if (!canon) {
21726
+ canon = /* @__PURE__ */ new Set();
21727
+ canonicalMap.set(id, canon);
21728
+ }
21729
+ canon.add(bc);
21730
+ state.set(id, canon);
21731
+ });
21732
+ states.set(block.offset, state);
21733
+ });
21734
+ if (incSp === false) {
21735
+ return;
21736
+ }
21737
+ states = new Map(
21738
+ Array.from(states).map(
21739
+ ([offset, state]) => [
21740
+ offset,
21741
+ new Map(Array.from(state).filter(([, bcs]) => bcs.size >= 3))
21742
+ ]
21743
+ ).filter(([, state]) => state.size)
21744
+ );
21745
+ if (!states.size)
21746
+ return;
21747
+ const dominatorMap = computeDominators(func);
21748
+ const insertionBlocks = /* @__PURE__ */ new Map();
21749
+ states.forEach((state, offset) => {
21750
+ const dominators = dominatorMap.get(offset);
21751
+ (0, import_node_assert7.default)(dominators);
21752
+ state.forEach((bcs, key) => {
21753
+ const insertions = insertionBlocks.get(key);
21754
+ if (!insertions) {
21755
+ insertionBlocks.set(key, dominators);
21756
+ } else {
21757
+ insertionBlocks.set(key, intersect(insertions, dominators));
21758
+ }
21759
+ });
21760
+ });
21761
+ let nextSlot = func.argc + (incSp?.arg ?? 0);
21762
+ const bytecode = (op, arg) => {
21763
+ const bc = { op, arg, size: opcodeSize(op), offset: context.nextOffset++ };
21764
+ if (arg == null)
21765
+ delete bc.arg;
21766
+ return bc;
21767
+ };
21768
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("pre", 1)) {
21769
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("pre", 5)) {
21770
+ (0, import_chunk_QFQPBQSO.log)(functionBanner(func, context, "PRE")());
21771
+ } else {
21772
+ (0, import_chunk_QFQPBQSO.log)(`================ PRE : ${func.name} ================
21773
+ `);
21774
+ }
21775
+ insertionBlocks.forEach((o, key) => {
21776
+ const bcs = canonicalMap.get(key);
21777
+ (0, import_chunk_QFQPBQSO.log)(
21778
+ `Replacing ${bcs.size} instances of ${bytecodeToString(
21779
+ bcs.values().next().value,
21780
+ context.symbolTable
21781
+ )}`
21782
+ );
21783
+ });
21784
+ }
21785
+ insertionBlocks.forEach((blockOffsets, key) => {
21786
+ const blockOffset = Array.from(blockOffsets).sort(
21787
+ (a, b) => order.get(a) - order.get(b)
21788
+ )[0];
21789
+ (0, import_node_assert7.default)(blockOffset != null);
21790
+ const block = func.blocks.get(blockOffset);
21791
+ (0, import_node_assert7.default)(block);
21792
+ const bcs = canonicalMap.get(key);
21793
+ (0, import_node_assert7.default)(bcs);
21794
+ let index = block.bytecodes.findIndex((bc2) => bcs.has(bc2));
21795
+ if (index < 0) {
21796
+ if (block.next && !block.taken) {
21797
+ index = block.bytecodes.length;
21798
+ }
21799
+ }
21800
+ const bc = bcs.values().next().value;
21801
+ const slot = nextSlot++;
21802
+ if (bc.op === 48) {
21803
+ (0, import_node_assert7.default)(index !== 0);
21804
+ let spush = null;
21805
+ func.blocks.forEach(
21806
+ (b) => states.get(b.offset)?.get(key) && b.bytecodes.forEach((bc2, i) => {
21807
+ if (bcs.has(bc2)) {
21808
+ (0, import_node_assert7.default)(i > 0);
21809
+ const prev = b.bytecodes[i - 1];
21810
+ if (!spush) {
21811
+ spush = { ...prev };
21812
+ }
21813
+ bc2.op = 0;
21814
+ prev.op = 18;
21815
+ prev.arg = slot;
21816
+ prev.size = 2;
21817
+ }
21818
+ })
21819
+ );
21820
+ (0, import_node_assert7.default)(spush);
21821
+ if (index >= 0 && index < block.bytecodes.length) {
21822
+ index--;
21823
+ }
21824
+ block.bytecodes.splice(
21825
+ index,
21826
+ 0,
21827
+ bytecode(spush.op, spush.arg),
21828
+ bytecode(48, void 0),
21829
+ bytecode(19, slot)
21830
+ );
21831
+ } else {
21832
+ block.bytecodes.splice(
21833
+ index,
21834
+ 0,
21835
+ bytecode(bc.op, bc.arg),
21836
+ bytecode(19, slot)
21837
+ );
21838
+ bcs.forEach((bc2) => {
21839
+ bc2.op = 18;
21840
+ bc2.arg = slot;
21841
+ bc2.size = 2;
21842
+ });
21843
+ }
21844
+ });
21845
+ if (incSp) {
21846
+ incSp.arg += insertionBlocks.size;
21847
+ } else {
21848
+ const startBlock = func.blocks.get(func.offset);
21849
+ const index = startBlock.bytecodes.length === 0 || startBlock.bytecodes[0].op !== 53 ? 0 : 1;
21850
+ startBlock.bytecodes.splice(
21851
+ index,
21852
+ 0,
21853
+ bytecode(1, insertionBlocks.size)
21854
+ );
21855
+ }
21856
+ (0, import_chunk_QFQPBQSO.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
21857
+ return true;
21858
+ }
21859
+ var init_pre2 = (0, import_chunk_QFQPBQSO.__esm)({
21860
+ "src/readprg/pre.ts"() {
21861
+ "use strict";
21862
+ (0, import_chunk_QFQPBQSO.init_logger)();
21863
+ init_bytecode();
21864
+ init_cflow();
21551
21865
  init_opcodes();
21552
21866
  }
21553
21867
  });
@@ -21571,7 +21885,7 @@ function checkState(state) {
21571
21885
  const checkArray = (items) => items.forEach((item) => {
21572
21886
  item.equivs?.forEach((e) => {
21573
21887
  if (getEquivs(state, e) !== item.equivs) {
21574
- (0, import_node_assert7.default)(getEquivs(state, e) === item.equivs);
21888
+ (0, import_node_assert8.default)(getEquivs(state, e) === item.equivs);
21575
21889
  }
21576
21890
  });
21577
21891
  });
@@ -21947,6 +22261,16 @@ function interpBytecode(bc, localState, context) {
21947
22261
  case 30:
21948
22262
  binary(">=");
21949
22263
  break;
22264
+ case 45: {
22265
+ removeEquiv2(localState, -localState.stack.length);
22266
+ const arg = localState.stack.pop()?.type ?? {
22267
+ type: 524287
22268
+ /* Any */
22269
+ };
22270
+ const result = evaluateUnaryTypes("~", arg);
22271
+ localState.stack.push({ type: result });
22272
+ break;
22273
+ }
21950
22274
  default: {
21951
22275
  const { pop, push } = getOpInfo(bc);
21952
22276
  for (let i = 0; i < pop; i++) {
@@ -21965,31 +22289,57 @@ function interpBytecode(bc, localState, context) {
21965
22289
  }
21966
22290
  function interpFunc(func, context) {
21967
22291
  const { symbolTable } = context;
22292
+ const resolvedBranches = /* @__PURE__ */ new Map();
21968
22293
  const equivSets = /* @__PURE__ */ new Map();
21969
22294
  const selfStores = /* @__PURE__ */ new Set();
21970
22295
  const liveInState = /* @__PURE__ */ new Map();
21971
22296
  const replacements = /* @__PURE__ */ new Map();
21972
- const interpLogging = (0, import_chunk_HHQDDCTP.wouldLog)("interp", 1);
22297
+ const interpLogging = (0, import_chunk_QFQPBQSO.wouldLog)("interp", 1);
21973
22298
  if (interpLogging) {
21974
- if ((0, import_chunk_HHQDDCTP.wouldLog)("interp", 7)) {
21975
- (0, import_chunk_HHQDDCTP.setBanner)(functionBanner(func, context, "interp"));
21976
- } else if ((0, import_chunk_HHQDDCTP.wouldLog)("interp", 3)) {
21977
- (0, import_chunk_HHQDDCTP.setBanner)(
22299
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("interp", 7)) {
22300
+ (0, import_chunk_QFQPBQSO.setBanner)(functionBanner(func, context, "interp"));
22301
+ } else if ((0, import_chunk_QFQPBQSO.wouldLog)("interp", 3)) {
22302
+ (0, import_chunk_QFQPBQSO.setBanner)(
21978
22303
  () => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
21979
22304
  );
21980
22305
  }
21981
22306
  }
22307
+ const branchRedirects = /* @__PURE__ */ new Map();
22308
+ const safeBranchBlocks = /* @__PURE__ */ new Map();
22309
+ func.blocks.forEach((block) => {
22310
+ if (block.taken == null || block.next == null)
22311
+ return;
22312
+ if ((block.preds?.size ?? 0) <= 1)
22313
+ return;
22314
+ const maxpops = 1;
22315
+ let depth = maxpops;
22316
+ let mindepth = maxpops;
22317
+ if (block.bytecodes.every((bc) => {
22318
+ if (getOpEffects(bc))
22319
+ return false;
22320
+ const { push, pop } = getOpInfo(bc);
22321
+ depth -= pop;
22322
+ if (depth < 0)
22323
+ return false;
22324
+ if (depth < mindepth)
22325
+ mindepth = depth;
22326
+ depth += push;
22327
+ return true;
22328
+ }) && depth === mindepth) {
22329
+ safeBranchBlocks.set(block.offset, maxpops - depth);
22330
+ }
22331
+ });
21982
22332
  rpoPropagate(
21983
22333
  func,
21984
22334
  (block) => {
21985
22335
  if (interpLogging) {
21986
- (0, import_chunk_HHQDDCTP.logger)(
22336
+ (0, import_chunk_QFQPBQSO.logger)(
21987
22337
  "interp",
21988
22338
  3,
21989
22339
  `${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
21990
22340
  ${interpStateToString(liveInState.get(block.offset))}`
21991
22341
  );
21992
- (0, import_chunk_HHQDDCTP.logger)("interp", 9, blockToString(block, context));
22342
+ (0, import_chunk_QFQPBQSO.logger)("interp", 9, () => blockToString(block, context));
21993
22343
  }
21994
22344
  return cloneState2(liveInState.get(block.offset));
21995
22345
  },
@@ -22025,7 +22375,7 @@ function interpFunc(func, context) {
22025
22375
  case 39: {
22026
22376
  interpBytecode(bc, localState, context);
22027
22377
  const topType = localState.stack[localState.stack.length - 1].type;
22028
- (0, import_node_assert7.default)(isExact(topType));
22378
+ (0, import_node_assert8.default)(isExact(topType));
22029
22379
  const index = localState.loopBlock ? null : findEquivalent(localState, topType.type, topType.value);
22030
22380
  let blockReps = replacements.get(block);
22031
22381
  if (index != null) {
@@ -22061,15 +22411,15 @@ function interpFunc(func, context) {
22061
22411
  break;
22062
22412
  }
22063
22413
  case 40:
22064
- case 41:
22414
+ case 41: {
22065
22415
  if (block.taken === block.offset) {
22066
22416
  const inState = liveInState.get(block.offset);
22067
- (0, import_node_assert7.default)(inState);
22417
+ (0, import_node_assert8.default)(inState);
22068
22418
  if (inState.stack.length !== localState.stack.length - 1) {
22069
22419
  const condition = localState.stack[localState.stack.length - 1];
22070
22420
  const isTrue = mustBeTrue(condition.type);
22071
22421
  const isFalse = mustBeFalse(condition.type);
22072
- (0, import_node_assert7.default)(isTrue || isFalse);
22422
+ (0, import_node_assert8.default)(isTrue || isFalse);
22073
22423
  interpBytecode(bc, localState, context);
22074
22424
  if (isTrue === (bc.op === 40)) {
22075
22425
  localState.loopBlock = true;
@@ -22079,14 +22429,52 @@ function interpFunc(func, context) {
22079
22429
  return 4;
22080
22430
  }
22081
22431
  }
22432
+ resolvedBranches.delete(block);
22433
+ let flags = 0;
22434
+ const top = localState.stack[localState.stack.length - 1];
22435
+ if (top) {
22436
+ const isTrue = mustBeTrue(top.type);
22437
+ if (isTrue || mustBeFalse(top.type)) {
22438
+ const isTaken = isTrue === (bc.op === 40);
22439
+ flags = isTaken ? 8 : 4;
22440
+ resolvedBranches.set(block, isTaken);
22441
+ }
22442
+ }
22082
22443
  interpBytecode(bc, localState, context);
22083
- break;
22444
+ return flags;
22445
+ }
22084
22446
  default:
22085
22447
  interpBytecode(bc, localState, context);
22086
22448
  }
22087
22449
  return null;
22088
22450
  },
22089
- () => {
22451
+ (block, localState) => {
22452
+ const branchRedirect = (block2, localState2, next) => {
22453
+ if (next != null && !resolvedBranches.has(block2) && safeBranchBlocks.has(next) && (block2.taken == null || safeBranchBlocks.get(next) === 0)) {
22454
+ const state = cloneState2(localState2);
22455
+ const branchBlock = func.blocks.get(next);
22456
+ return branchBlock.bytecodes.every((bc) => {
22457
+ if (isCondBranch(bc.op)) {
22458
+ const top = state.stack[state.stack.length - 1];
22459
+ const isTrue = mustBeTrue(top.type);
22460
+ if (isTrue || mustBeFalse(top.type)) {
22461
+ branchRedirects.set(block2, {
22462
+ from: next,
22463
+ to: isTrue === (bc.op === 40) ? branchBlock.taken : branchBlock.next
22464
+ });
22465
+ return true;
22466
+ }
22467
+ return false;
22468
+ }
22469
+ interpBytecode(bc, state, context);
22470
+ return true;
22471
+ });
22472
+ }
22473
+ return false;
22474
+ };
22475
+ if (localState.loopBlock || !branchRedirect(block, localState, block.next) && !branchRedirect(block, localState, block.taken)) {
22476
+ branchRedirects.delete(block);
22477
+ }
22090
22478
  },
22091
22479
  (from, localState, succBlock, isExSucc) => {
22092
22480
  if (isExSucc) {
@@ -22112,14 +22500,14 @@ function interpFunc(func, context) {
22112
22500
  if (!mergeInto(localState, succState))
22113
22501
  return false;
22114
22502
  if (interpLogging) {
22115
- (0, import_chunk_HHQDDCTP.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
22503
+ (0, import_chunk_QFQPBQSO.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
22116
22504
  }
22117
22505
  return true;
22118
22506
  }
22119
22507
  );
22120
22508
  if (interpLogging) {
22121
- if ((0, import_chunk_HHQDDCTP.wouldLog)("interp", 5)) {
22122
- (0, import_chunk_HHQDDCTP.setBanner)(
22509
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("interp", 5)) {
22510
+ (0, import_chunk_QFQPBQSO.setBanner)(
22123
22511
  functionBanner(func, context, "interp", (block, footer) => {
22124
22512
  if (footer)
22125
22513
  return "";
@@ -22127,32 +22515,50 @@ function interpFunc(func, context) {
22127
22515
  })
22128
22516
  );
22129
22517
  } else {
22130
- (0, import_chunk_HHQDDCTP.setBanner)(() => `=============== interp ${func.name} ==============`);
22518
+ (0, import_chunk_QFQPBQSO.setBanner)(() => `=============== interp ${func.name} ==============`);
22131
22519
  }
22132
22520
  if (equivSets.size) {
22133
- (0, import_chunk_HHQDDCTP.log)(`====== equivSets =====`);
22521
+ (0, import_chunk_QFQPBQSO.log)(`====== equivSets =====`);
22134
22522
  equivSets.forEach(
22135
- (value2, key) => (0, import_chunk_HHQDDCTP.log)(
22523
+ (value2, key) => (0, import_chunk_QFQPBQSO.log)(
22136
22524
  `L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
22137
22525
  )
22138
22526
  );
22139
22527
  }
22140
22528
  if (selfStores.size) {
22141
- (0, import_chunk_HHQDDCTP.log)(`====== selfStores =====`);
22529
+ (0, import_chunk_QFQPBQSO.log)(`====== selfStores =====`);
22142
22530
  selfStores.forEach(
22143
- (value2) => (0, import_chunk_HHQDDCTP.log)(`${bytecodeToString(value2, symbolTable)}`)
22531
+ (value2) => (0, import_chunk_QFQPBQSO.log)(`${bytecodeToString(value2, symbolTable)}`)
22144
22532
  );
22145
22533
  }
22146
22534
  if (replacements.size) {
22147
- (0, import_chunk_HHQDDCTP.log)(`====== replacements =====`);
22535
+ (0, import_chunk_QFQPBQSO.log)(`====== replacements =====`);
22148
22536
  replacements.forEach(
22149
22537
  (blockRep) => blockRep.forEach(
22150
- (rep, bc) => (0, import_chunk_HHQDDCTP.log)(
22538
+ (rep, bc) => (0, import_chunk_QFQPBQSO.log)(
22151
22539
  `${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
22152
22540
  )
22153
22541
  )
22154
22542
  );
22155
22543
  }
22544
+ if (resolvedBranches.size) {
22545
+ (0, import_chunk_QFQPBQSO.log)(`====== resolved branches =====`);
22546
+ resolvedBranches.forEach(
22547
+ (isTaken, block) => (0, import_chunk_QFQPBQSO.log)(
22548
+ `block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
22549
+ )
22550
+ );
22551
+ }
22552
+ if (branchRedirects.size) {
22553
+ (0, import_chunk_QFQPBQSO.log)(`====== redirected branches =====`);
22554
+ branchRedirects.forEach(
22555
+ ({ to, from }, block) => (0, import_chunk_QFQPBQSO.log)(
22556
+ `block ${offsetToString(
22557
+ block.offset
22558
+ )} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
22559
+ )
22560
+ );
22561
+ }
22156
22562
  }
22157
22563
  selfStores.forEach((bc) => makeArgless(
22158
22564
  bc,
@@ -22176,15 +22582,48 @@ function interpFunc(func, context) {
22176
22582
  const invv = { ...orig };
22177
22583
  invv.op = 45;
22178
22584
  invv.size = 1;
22179
- invv.offset++;
22585
+ invv.offset = context.nextOffset++;
22180
22586
  delete invv.arg;
22181
22587
  block.bytecodes.splice(i + 1, 0, invv);
22182
22588
  }
22183
22589
  }
22184
22590
  });
22591
+ resolvedBranches.forEach((isTaken, block) => {
22592
+ const branch = block.bytecodes[block.bytecodes.length - 1];
22593
+ (0, import_node_assert8.default)(branch && isCondBranch(branch.op));
22594
+ if (isTaken) {
22595
+ redirect(func, block, block.next, block.taken);
22596
+ } else {
22597
+ redirect(func, block, block.taken, block.next);
22598
+ }
22599
+ delete block.taken;
22600
+ makeArgless(
22601
+ branch,
22602
+ 2
22603
+ /* popv */
22604
+ );
22605
+ });
22606
+ branchRedirects.forEach(({ from, to }, block) => {
22607
+ const pops = safeBranchBlocks.get(from);
22608
+ redirect(func, block, from, to);
22609
+ if (pops) {
22610
+ (0, import_node_assert8.default)(block.next && !block.taken);
22611
+ for (let i = 0; i < pops; i++) {
22612
+ block.bytecodes.push({
22613
+ op: 2,
22614
+ size: 1,
22615
+ offset: context.nextOffset++
22616
+ });
22617
+ }
22618
+ }
22619
+ });
22185
22620
  if (interpLogging)
22186
- (0, import_chunk_HHQDDCTP.setBanner)(null);
22187
- return { liveInState, equivSets };
22621
+ (0, import_chunk_QFQPBQSO.setBanner)(null);
22622
+ return {
22623
+ liveInState,
22624
+ equivSets,
22625
+ changes: selfStores.size || replacements.size || resolvedBranches.size || branchRedirects.size
22626
+ };
22188
22627
  }
22189
22628
  function instForType(type, offset) {
22190
22629
  if (!hasValue(type))
@@ -22217,7 +22656,7 @@ function instForType(type, offset) {
22217
22656
  };
22218
22657
  case 131072: {
22219
22658
  const match = type.value.match(/<(\d+)>$/);
22220
- (0, import_node_assert7.default)(match);
22659
+ (0, import_node_assert8.default)(match);
22221
22660
  return {
22222
22661
  op: 37,
22223
22662
  arg: parseInt(match[1], 10),
@@ -22228,11 +22667,11 @@ function instForType(type, offset) {
22228
22667
  }
22229
22668
  return null;
22230
22669
  }
22231
- var init_interp2 = (0, import_chunk_HHQDDCTP.__esm)({
22670
+ var init_interp2 = (0, import_chunk_QFQPBQSO.__esm)({
22232
22671
  "src/readprg/interp.ts"() {
22233
22672
  "use strict";
22234
22673
  init_interp_binary();
22235
- (0, import_chunk_HHQDDCTP.init_logger)();
22674
+ (0, import_chunk_QFQPBQSO.init_logger)();
22236
22675
  init_interp();
22237
22676
  init_types();
22238
22677
  init_union_type();
@@ -22242,7 +22681,7 @@ var init_interp2 = (0, import_chunk_HHQDDCTP.__esm)({
22242
22681
  }
22243
22682
  });
22244
22683
  function optimizeArrayInit(func, block, index, context, interpState) {
22245
- (0, import_node_assert8.default)(
22684
+ (0, import_node_assert9.default)(
22246
22685
  block.bytecodes[index].op === 20 || block.bytecodes[index].op === 54
22247
22686
  /* newba */
22248
22687
  );
@@ -22340,10 +22779,10 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22340
22779
  i = found;
22341
22780
  }
22342
22781
  if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
22343
- (0, import_chunk_HHQDDCTP.logger)(
22782
+ (0, import_chunk_QFQPBQSO.logger)(
22344
22783
  "array-init",
22345
22784
  1,
22346
- `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
22785
+ () => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
22347
22786
  block.offset
22348
22787
  )}, starting at index ${index}, at offset ${offsetToString(
22349
22788
  block.bytecodes[index].offset
@@ -22360,7 +22799,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22360
22799
  bc.op = 2;
22361
22800
  bc.size = 1;
22362
22801
  delete bc.arg;
22363
- (0, import_node_assert8.default)(
22802
+ (0, import_node_assert9.default)(
22364
22803
  op === 17
22365
22804
  /* aputv */
22366
22805
  );
@@ -22373,17 +22812,17 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22373
22812
  convertAputv(offset - 1);
22374
22813
  }
22375
22814
  }
22376
- (0, import_chunk_HHQDDCTP.logger)(
22815
+ (0, import_chunk_QFQPBQSO.logger)(
22377
22816
  "array-init",
22378
22817
  1,
22379
- `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
22818
+ () => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
22380
22819
  block.offset
22381
22820
  )}, starting at index ${index}, at offset ${offsetToString(
22382
22821
  block.bytecodes[index].offset
22383
22822
  )}`
22384
22823
  );
22385
- if ((0, import_chunk_HHQDDCTP.wouldLog)("array-init", 5)) {
22386
- (0, import_chunk_HHQDDCTP.log)(blockToString(block, context));
22824
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("array-init", 5)) {
22825
+ (0, import_chunk_QFQPBQSO.log)(blockToString(block, context));
22387
22826
  }
22388
22827
  return true;
22389
22828
  }
@@ -22401,7 +22840,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22401
22840
  for (let ix = putvStarts.length; ix--; ) {
22402
22841
  const dupIx = ++putvStarts[ix];
22403
22842
  const dup = block.bytecodes[dupIx];
22404
- (0, import_node_assert8.default)(dup.op === 46 && dup.arg === 0);
22843
+ (0, import_node_assert9.default)(dup.op === 46 && dup.arg === 0);
22405
22844
  block.bytecodes[dupIx].op = 18;
22406
22845
  block.bytecodes[dupIx].arg = local;
22407
22846
  }
@@ -22423,10 +22862,10 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22423
22862
  if (putvStarts.length < 3)
22424
22863
  return false;
22425
22864
  tryLocal(3);
22426
- (0, import_chunk_HHQDDCTP.logger)(
22865
+ (0, import_chunk_QFQPBQSO.logger)(
22427
22866
  "array-init",
22428
22867
  1,
22429
- `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
22868
+ () => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
22430
22869
  initInst,
22431
22870
  null
22432
22871
  )} at block ${offsetToString(
@@ -22449,10 +22888,10 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22449
22888
  block.bytecodes[index + 1].arg = putvStarts.length;
22450
22889
  }
22451
22890
  }
22452
- (0, import_chunk_HHQDDCTP.logger)(
22891
+ (0, import_chunk_QFQPBQSO.logger)(
22453
22892
  "array-init",
22454
22893
  5,
22455
- `index: ${index}, i: ${i}
22894
+ () => `index: ${index}, i: ${i}
22456
22895
  ${blockToString(block, context)}`
22457
22896
  );
22458
22897
  const loopOffset2 = context.nextOffset;
@@ -22487,10 +22926,10 @@ ${blockToString(block, context)}`
22487
22926
  for (let i2 = putvStarts.length; i2-- > 1; ) {
22488
22927
  block.bytecodes.splice(putvStarts[i2], 2);
22489
22928
  }
22490
- (0, import_chunk_HHQDDCTP.logger)(
22929
+ (0, import_chunk_QFQPBQSO.logger)(
22491
22930
  "array-init",
22492
22931
  1,
22493
- `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
22932
+ () => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
22494
22933
  block.offset
22495
22934
  )}, starting at index ${index}, at offset ${offsetToString(
22496
22935
  block.bytecodes[index].offset
@@ -22542,19 +22981,19 @@ ${blockToString(block, context)}`
22542
22981
  loop.taken = loopOffset;
22543
22982
  return true;
22544
22983
  }
22545
- var init_array_init = (0, import_chunk_HHQDDCTP.__esm)({
22984
+ var init_array_init = (0, import_chunk_QFQPBQSO.__esm)({
22546
22985
  "src/readprg/array-init.ts"() {
22547
22986
  "use strict";
22548
22987
  init_types();
22549
- (0, import_chunk_HHQDDCTP.init_util)();
22988
+ (0, import_chunk_QFQPBQSO.init_util)();
22550
22989
  init_bytecode();
22551
22990
  init_interp2();
22552
22991
  init_opcodes();
22553
22992
  }
22554
22993
  });
22555
22994
  function localDCE(func, context) {
22556
- if ((0, import_chunk_HHQDDCTP.wouldLog)("dce", 5)) {
22557
- (0, import_chunk_HHQDDCTP.setBanner)(
22995
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("dce", 5)) {
22996
+ (0, import_chunk_QFQPBQSO.setBanner)(
22558
22997
  functionBanner(
22559
22998
  func,
22560
22999
  context,
@@ -22587,10 +23026,10 @@ function localDCE(func, context) {
22587
23026
  };
22588
23027
  func.blocks.forEach((block) => {
22589
23028
  const reportPopv = (i, item, kill) => {
22590
- (0, import_chunk_HHQDDCTP.logger)(
23029
+ (0, import_chunk_QFQPBQSO.logger)(
22591
23030
  "dce",
22592
23031
  2,
22593
- `${func.name}: Convert ${i}:${bytecodeToString(
23032
+ () => `${func.name}: Convert ${i}:${bytecodeToString(
22594
23033
  block.bytecodes[i],
22595
23034
  context.symbolTable
22596
23035
  )} to popv for ${item.deps.map(
@@ -22602,10 +23041,12 @@ function localDCE(func, context) {
22602
23041
  );
22603
23042
  };
22604
23043
  const reportNop = (item) => {
22605
- (0, import_chunk_HHQDDCTP.logger)(
23044
+ (0, import_chunk_QFQPBQSO.logger)(
22606
23045
  "dce",
22607
23046
  2,
22608
- `${func.name}: Kill ${item.deps.map((i) => bytecodeToString(block.bytecodes[i], context.symbolTable)).join(", ")}`
23047
+ () => `${func.name}: Kill ${item.deps.map(
23048
+ (i) => bytecodeToString(block.bytecodes[i], context.symbolTable)
23049
+ ).join(", ")}`
22609
23050
  );
22610
23051
  };
22611
23052
  changes = false;
@@ -22619,10 +23060,10 @@ function localDCE(func, context) {
22619
23060
  case 19: {
22620
23061
  const liveLocal = dceInfo.locals.has(bytecode.arg);
22621
23062
  if (!liveLocal) {
22622
- (0, import_chunk_HHQDDCTP.logger)(
23063
+ (0, import_chunk_QFQPBQSO.logger)(
22623
23064
  "dce",
22624
23065
  2,
22625
- `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
23066
+ () => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
22626
23067
  );
22627
23068
  makePopv(bytecode);
22628
23069
  dceInfo.stack.push({ dead: true, deps: [i] });
@@ -22740,12 +23181,10 @@ function localDCE(func, context) {
22740
23181
  (bc) => bc.op !== 0
22741
23182
  /* nop */
22742
23183
  );
22743
- if ((0, import_chunk_HHQDDCTP.wouldLog)("dce", 3)) {
22744
- (0, import_chunk_HHQDDCTP.log)(functionBanner(func, context, "local-dce-end")());
22745
- }
23184
+ (0, import_chunk_QFQPBQSO.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
22746
23185
  }
22747
23186
  });
22748
- (0, import_chunk_HHQDDCTP.setBanner)(null);
23187
+ (0, import_chunk_QFQPBQSO.setBanner)(null);
22749
23188
  return anyChanges;
22750
23189
  }
22751
23190
  function computeLiveLocals(func) {
@@ -22788,10 +23227,354 @@ function computeLiveLocals(func) {
22788
23227
  );
22789
23228
  return { liveInLocals, liveOutLocals };
22790
23229
  }
22791
- var init_dce = (0, import_chunk_HHQDDCTP.__esm)({
23230
+ var init_dce = (0, import_chunk_QFQPBQSO.__esm)({
22792
23231
  "src/readprg/dce.ts"() {
22793
23232
  "use strict";
22794
- (0, import_chunk_HHQDDCTP.init_util)();
23233
+ (0, import_chunk_QFQPBQSO.init_util)();
23234
+ init_bytecode();
23235
+ init_cflow();
23236
+ init_opcodes();
23237
+ }
23238
+ });
23239
+ function cloneLive(locals) {
23240
+ const clone = /* @__PURE__ */ new Map();
23241
+ locals?.forEach((value2, key) => clone.set(key, new Set(value2)));
23242
+ return clone;
23243
+ }
23244
+ function mergeInto2(from, to) {
23245
+ let changed = false;
23246
+ from.forEach((local, key) => {
23247
+ const curr = to.get(key);
23248
+ if (!curr) {
23249
+ to.set(key, new Set(local));
23250
+ changed = true;
23251
+ return;
23252
+ }
23253
+ local.forEach((inst) => {
23254
+ if (!curr.has(inst)) {
23255
+ changed = true;
23256
+ curr.add(inst);
23257
+ }
23258
+ });
23259
+ });
23260
+ return changed;
23261
+ }
23262
+ function minimizeLocals2(func, equivSets, context) {
23263
+ const splitRanges = computeSplitRanges(func, equivSets);
23264
+ const locals = mergeSplitRanges(splitRanges);
23265
+ const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
23266
+ (0, import_chunk_QFQPBQSO.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
23267
+ const colors = /* @__PURE__ */ new Map();
23268
+ const merge = [];
23269
+ locals.forEach((local, key) => {
23270
+ if (key.op === 18 || key.arg === 0) {
23271
+ colors.set(key, key.arg);
23272
+ const merged = merge[key.arg];
23273
+ if (merged) {
23274
+ (0, import_node_assert10.default)(!key.arg);
23275
+ merged.push(key);
23276
+ } else {
23277
+ merge[key.arg] = [key];
23278
+ }
23279
+ }
23280
+ });
23281
+ locals.forEach((local, key) => {
23282
+ if (key.op === 18)
23283
+ return;
23284
+ let inUse = 0n;
23285
+ local.conflicts.forEach((conflict) => {
23286
+ const color = colors.get(conflict);
23287
+ if (color != null) {
23288
+ inUse |= 1n << BigInt(color);
23289
+ }
23290
+ });
23291
+ let lowest = 0;
23292
+ while (inUse & 1n) {
23293
+ lowest++;
23294
+ inUse >>= 1n;
23295
+ }
23296
+ colors.set(key, lowest);
23297
+ if (!merge[lowest]) {
23298
+ merge[lowest] = [key];
23299
+ } else {
23300
+ merge[lowest].push(key);
23301
+ }
23302
+ });
23303
+ if (merge.length >= numLocals)
23304
+ return false;
23305
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("locals", 1)) {
23306
+ if (!(0, import_chunk_QFQPBQSO.wouldLog)("locals", 10)) {
23307
+ (0, import_chunk_QFQPBQSO.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
23308
+ }
23309
+ (0, import_chunk_QFQPBQSO.log)(
23310
+ `>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
23311
+ );
23312
+ merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
23313
+ (merged) => (0, import_chunk_QFQPBQSO.log)(
23314
+ ` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
23315
+ )
23316
+ );
23317
+ }
23318
+ const fixupMap = /* @__PURE__ */ new Map();
23319
+ locals.forEach((value2, key) => {
23320
+ const color = colors.get(key);
23321
+ (0, import_node_assert10.default)(color != null);
23322
+ let name = null;
23323
+ Array.from(value2.live).some((bc) => {
23324
+ if ((bc.op === 18 || bc.op === 19) && bc.range) {
23325
+ if (!name) {
23326
+ name = bc.range.name;
23327
+ } else if (name !== bc.range.name) {
23328
+ if (typeof name === "string") {
23329
+ name = /* @__PURE__ */ new Set([name]);
23330
+ }
23331
+ name.add(bc.range.name);
23332
+ }
23333
+ }
23334
+ });
23335
+ let range = null;
23336
+ if (name) {
23337
+ if (typeof name !== "string") {
23338
+ name = Array.from(name).join("_");
23339
+ }
23340
+ range = { name, id: context.nextLocalId++ };
23341
+ if (key.op === 18) {
23342
+ range.isParam = true;
23343
+ }
23344
+ }
23345
+ value2.live.forEach((bc) => fixupMap.set(bc, { color, range }));
23346
+ });
23347
+ let argc = null;
23348
+ func.blocks.forEach((block) => {
23349
+ let filter = false;
23350
+ block.bytecodes.forEach((bc) => {
23351
+ switch (bc.op) {
23352
+ case 53:
23353
+ argc = bc.arg;
23354
+ break;
23355
+ case 1: {
23356
+ let newinc;
23357
+ if (argc != null) {
23358
+ newinc = merge.length - argc;
23359
+ } else {
23360
+ newinc = bc.arg + merge.length - numLocals;
23361
+ }
23362
+ if (newinc > 0) {
23363
+ bc.arg = newinc;
23364
+ } else {
23365
+ const nop = bc;
23366
+ nop.op = 0;
23367
+ delete nop.arg;
23368
+ nop.size = 1;
23369
+ filter = true;
23370
+ }
23371
+ break;
23372
+ }
23373
+ case 18:
23374
+ case 19: {
23375
+ const info = fixupMap.get(bc);
23376
+ (0, import_node_assert10.default)(info != null);
23377
+ bc.arg = info.color;
23378
+ if (info.range) {
23379
+ bc.range = info.range;
23380
+ } else {
23381
+ delete bc.range;
23382
+ }
23383
+ break;
23384
+ }
23385
+ }
23386
+ });
23387
+ if (filter) {
23388
+ block.bytecodes = block.bytecodes.filter(
23389
+ (bc) => bc.op !== 0
23390
+ /* nop */
23391
+ );
23392
+ }
23393
+ });
23394
+ return true;
23395
+ }
23396
+ function computeSplitRanges(func, equivSets) {
23397
+ const liveOutLocals = /* @__PURE__ */ new Map();
23398
+ const liveInLocals = /* @__PURE__ */ new Map();
23399
+ const splitRanges = /* @__PURE__ */ new Map();
23400
+ const recordLgetv = (locals, bc) => {
23401
+ const bcs = locals.get(bc.arg);
23402
+ if (!bcs) {
23403
+ locals.set(bc.arg, /* @__PURE__ */ new Set([bc]));
23404
+ } else {
23405
+ bcs.add(bc);
23406
+ }
23407
+ };
23408
+ const fakeLgetvs = /* @__PURE__ */ new Map();
23409
+ postOrderPropagate(
23410
+ func,
23411
+ (block) => cloneLive(liveOutLocals.get(block.offset)),
23412
+ (block, bc, locals) => {
23413
+ switch (bc.op) {
23414
+ case 42: {
23415
+ let fakeLgetv = fakeLgetvs.get(bc);
23416
+ if (!fakeLgetv) {
23417
+ fakeLgetv = {
23418
+ op: 18,
23419
+ arg: 0,
23420
+ size: 2,
23421
+ offset: bc.offset
23422
+ };
23423
+ fakeLgetvs.set(bc, fakeLgetv);
23424
+ }
23425
+ recordLgetv(locals, fakeLgetv);
23426
+ break;
23427
+ }
23428
+ case 18:
23429
+ recordLgetv(locals, bc);
23430
+ break;
23431
+ case 19: {
23432
+ let bcs = locals.get(bc.arg);
23433
+ if (!bcs) {
23434
+ bcs = /* @__PURE__ */ new Set();
23435
+ }
23436
+ let ranges = splitRanges.get(bc.arg);
23437
+ const equiv = equivSets.get(bc);
23438
+ const conflicts = /* @__PURE__ */ new Set();
23439
+ locals.forEach((liveBcs, local) => {
23440
+ if (local === bc.arg)
23441
+ return;
23442
+ if (equiv?.has(local))
23443
+ return;
23444
+ liveBcs.forEach((lbc) => conflicts.add(lbc));
23445
+ });
23446
+ if (!ranges) {
23447
+ splitRanges.set(
23448
+ bc.arg,
23449
+ ranges = /* @__PURE__ */ new Map([[bc, { live: bcs, conflicts }]])
23450
+ );
23451
+ } else {
23452
+ ranges.set(bc, { live: bcs, conflicts });
23453
+ }
23454
+ locals.delete(bc.arg);
23455
+ break;
23456
+ }
23457
+ case 51:
23458
+ case 15:
23459
+ if (block.exsucc) {
23460
+ const from = liveInLocals.get(block.exsucc);
23461
+ if (from) {
23462
+ mergeInto2(from, locals);
23463
+ }
23464
+ }
23465
+ break;
23466
+ }
23467
+ },
23468
+ (block, locals) => {
23469
+ liveInLocals.set(block.offset, locals);
23470
+ },
23471
+ (locals, predBlock, isExPred) => {
23472
+ if (isExPred)
23473
+ return false;
23474
+ const predLocals = liveOutLocals.get(predBlock.offset);
23475
+ if (!predLocals) {
23476
+ liveOutLocals.set(predBlock.offset, cloneLive(locals));
23477
+ return true;
23478
+ }
23479
+ return mergeInto2(locals, predLocals);
23480
+ }
23481
+ );
23482
+ const liveIn = liveInLocals.get(func.offset);
23483
+ liveIn?.forEach((bcs, num) => {
23484
+ const bc = bcs.values().next().value;
23485
+ let range = splitRanges.get(num);
23486
+ if (!range) {
23487
+ splitRanges.set(num, range = /* @__PURE__ */ new Map());
23488
+ }
23489
+ range.set(bc, { live: bcs, conflicts: /* @__PURE__ */ new Set() });
23490
+ });
23491
+ return splitRanges;
23492
+ }
23493
+ function mergeSplitRanges(splitRanges) {
23494
+ const bcToLiveRange = /* @__PURE__ */ new Map();
23495
+ splitRanges.forEach((range, localid) => {
23496
+ const reverseMap = /* @__PURE__ */ new Map();
23497
+ const pvMap = /* @__PURE__ */ new Map();
23498
+ range.forEach(({ live }, key) => {
23499
+ const putvSetRef = { ref: /* @__PURE__ */ new Set([key]) };
23500
+ pvMap.set(key, putvSetRef);
23501
+ live.forEach((bc) => {
23502
+ const m = reverseMap.get(bc);
23503
+ if (!m) {
23504
+ reverseMap.set(bc, putvSetRef);
23505
+ } else if (m.ref !== putvSetRef.ref) {
23506
+ putvSetRef.ref.forEach((pv) => {
23507
+ m.ref.add(pv);
23508
+ const other = pvMap.get(pv);
23509
+ other.ref = m.ref;
23510
+ });
23511
+ }
23512
+ });
23513
+ });
23514
+ const putvSets = /* @__PURE__ */ new Set();
23515
+ reverseMap.forEach(({ ref }) => putvSets.add(ref));
23516
+ range.forEach((x, key) => {
23517
+ const num = Array.from(putvSets).reduce(
23518
+ (count, set) => count + (set.has(key) ? 1 : 0),
23519
+ 0
23520
+ );
23521
+ (0, import_node_assert10.default)(num === 1);
23522
+ });
23523
+ const newRange = /* @__PURE__ */ new Map();
23524
+ putvSets.forEach((pvSet) => {
23525
+ let lputv = null;
23526
+ let singleRange = null;
23527
+ pvSet.forEach((pv) => {
23528
+ if (!lputv || pv.op === 18)
23529
+ lputv = pv;
23530
+ });
23531
+ pvSet.forEach((pv) => {
23532
+ const { live, conflicts } = range.get(pv);
23533
+ if (!singleRange) {
23534
+ singleRange = { live, conflicts };
23535
+ } else {
23536
+ live.forEach((l) => singleRange.live.add(l));
23537
+ conflicts.forEach((c) => singleRange.conflicts.add(c));
23538
+ }
23539
+ singleRange.live.add(pv);
23540
+ live.forEach((bc) => {
23541
+ const prev = bcToLiveRange.get(bc);
23542
+ (0, import_node_assert10.default)(!prev || prev === lputv);
23543
+ bcToLiveRange.set(bc, lputv);
23544
+ });
23545
+ });
23546
+ (0, import_node_assert10.default)(singleRange && lputv);
23547
+ newRange.set(lputv, singleRange);
23548
+ });
23549
+ splitRanges.set(localid, newRange);
23550
+ });
23551
+ const localInfo = /* @__PURE__ */ new Map();
23552
+ splitRanges.forEach((range) => {
23553
+ range.forEach((v, lputv) => {
23554
+ v.conflicts = new Set(
23555
+ Array.from(v.conflicts).flatMap((bc) => {
23556
+ const r = bcToLiveRange.get(bc);
23557
+ if (!r) {
23558
+ (0, import_node_assert10.default)(bc.arg === 0);
23559
+ return [];
23560
+ }
23561
+ return r;
23562
+ })
23563
+ );
23564
+ localInfo.set(lputv, v);
23565
+ });
23566
+ });
23567
+ localInfo.forEach((info, key) => {
23568
+ info.conflicts.forEach(
23569
+ (v) => localInfo.get(v).conflicts.add(key)
23570
+ );
23571
+ });
23572
+ return localInfo;
23573
+ }
23574
+ var init_locals = (0, import_chunk_QFQPBQSO.__esm)({
23575
+ "src/readprg/locals.ts"() {
23576
+ "use strict";
23577
+ (0, import_chunk_QFQPBQSO.init_logger)();
22795
23578
  init_bytecode();
22796
23579
  init_cflow();
22797
23580
  init_opcodes();
@@ -22824,9 +23607,9 @@ function blockSharing(func, context) {
22824
23607
  if (!any)
22825
23608
  return false;
22826
23609
  any = false;
22827
- const logging3 = (0, import_chunk_HHQDDCTP.wouldLog)("sharing", 1);
22828
- if (logging3 && (0, import_chunk_HHQDDCTP.wouldLog)("sharing", 10)) {
22829
- (0, import_chunk_HHQDDCTP.setBanner)(functionBanner(func, context, "sharing"));
23610
+ const logging3 = (0, import_chunk_QFQPBQSO.wouldLog)("sharing", 1);
23611
+ if (logging3 && (0, import_chunk_QFQPBQSO.wouldLog)("sharing", 10)) {
23612
+ (0, import_chunk_QFQPBQSO.setBanner)(functionBanner(func, context, "sharing"));
22830
23613
  }
22831
23614
  candidates.forEach((blocks) => {
22832
23615
  while (blocks.size > 1) {
@@ -22962,15 +23745,15 @@ function blockSharing(func, context) {
22962
23745
  block2.offset
22963
23746
  )})` : `block(${offsetToString(block2.offset)})`;
22964
23747
  };
22965
- (0, import_chunk_HHQDDCTP.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
22966
- if ((0, import_chunk_HHQDDCTP.wouldLog)("sharing", 5)) {
22967
- (0, import_chunk_HHQDDCTP.log)(blockToString(target, context));
23748
+ (0, import_chunk_QFQPBQSO.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23749
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("sharing", 5)) {
23750
+ (0, import_chunk_QFQPBQSO.log)(blockToString(target, context));
22968
23751
  }
22969
23752
  }
22970
23753
  if (target.bytecodes.length > length2) {
22971
23754
  splitBlock(func, target, -length2);
22972
23755
  }
22973
- (0, import_node_assert9.default)(block.bytecodes.length >= length2);
23756
+ (0, import_node_assert11.default)(block.bytecodes.length >= length2);
22974
23757
  if (block.bytecodes.length > length2) {
22975
23758
  splitBlock(func, block, block.bytecodes.length - length2);
22976
23759
  const next = block.next;
@@ -22991,28 +23774,43 @@ function blockSharing(func, context) {
22991
23774
  });
22992
23775
  }
22993
23776
  });
22994
- (0, import_chunk_HHQDDCTP.setBanner)(null);
23777
+ (0, import_chunk_QFQPBQSO.setBanner)(null);
22995
23778
  return any;
22996
23779
  }
22997
- var init_sharing = (0, import_chunk_HHQDDCTP.__esm)({
23780
+ var init_sharing = (0, import_chunk_QFQPBQSO.__esm)({
22998
23781
  "src/readprg/sharing.ts"() {
22999
23782
  "use strict";
23000
- (0, import_chunk_HHQDDCTP.init_util)();
23783
+ (0, import_chunk_QFQPBQSO.init_util)();
23001
23784
  init_bytecode();
23002
23785
  init_opcodes();
23003
23786
  }
23004
23787
  });
23005
23788
  function optimizeFunc(func, context) {
23006
- let changes;
23007
- let liveInState;
23008
- do {
23789
+ while (true) {
23790
+ let changes;
23009
23791
  cleanCfg2(func, context);
23010
23792
  changes = localDCE(func, context);
23011
- changes = blockSharing(func, context) || changes;
23012
23793
  changes = simpleOpts(func, context) || changes;
23013
- ({ liveInState } = interpFunc(func, context));
23794
+ const {
23795
+ liveInState,
23796
+ equivSets,
23797
+ changes: interpChanges
23798
+ } = interpFunc(func, context);
23799
+ changes = interpChanges || changes;
23014
23800
  changes = doArrayInits(func, liveInState, context) || changes;
23015
- } while (changes);
23801
+ if (changes)
23802
+ continue;
23803
+ changes = blockSharing(func, context) || changes;
23804
+ if (changes)
23805
+ continue;
23806
+ if (context.config.postBuildPRE !== false) {
23807
+ if (sizeBasedPRE2(func, context))
23808
+ continue;
23809
+ }
23810
+ if (!minimizeLocals2(func, equivSets, context) && !changes) {
23811
+ return;
23812
+ }
23813
+ }
23016
23814
  }
23017
23815
  function doArrayInits(func, liveInState, context) {
23018
23816
  const newAToProcess = /* @__PURE__ */ new Map();
@@ -23045,7 +23843,7 @@ function doArrayInits(func, liveInState, context) {
23045
23843
  }
23046
23844
  function simpleOpts(func, context) {
23047
23845
  const equalsSym = 8388787;
23048
- const logging3 = (0, import_chunk_HHQDDCTP.wouldLog)("optimize", 5);
23846
+ const logging3 = (0, import_chunk_QFQPBQSO.wouldLog)("optimize", 5);
23049
23847
  return Array.from(func.blocks.values()).reduce((changes, block) => {
23050
23848
  for (let i = block.bytecodes.length; i--; ) {
23051
23849
  const cur = block.bytecodes[i];
@@ -23053,7 +23851,7 @@ function simpleOpts(func, context) {
23053
23851
  block.bytecodes.splice(i, 1);
23054
23852
  changes = true;
23055
23853
  if (logging3) {
23056
- (0, import_chunk_HHQDDCTP.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23854
+ (0, import_chunk_QFQPBQSO.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23057
23855
  }
23058
23856
  } else if (i && cur.op === 39 && cur.arg === equalsSym) {
23059
23857
  changes = equalSymbolToEq(block, i) || changes;
@@ -23064,7 +23862,7 @@ function simpleOpts(func, context) {
23064
23862
  if (!shift && prev.op === 37) {
23065
23863
  block.bytecodes.splice(i - 1, 2);
23066
23864
  changes = true;
23067
- logging3 && (0, import_chunk_HHQDDCTP.log)(`${func.name}: deleting no-op shift (${shift})`);
23865
+ logging3 && (0, import_chunk_QFQPBQSO.log)(`${func.name}: deleting no-op shift (${shift})`);
23068
23866
  continue;
23069
23867
  }
23070
23868
  if (shift < (prev.op === 49 ? 64n : 31n)) {
@@ -23074,7 +23872,7 @@ function simpleOpts(func, context) {
23074
23872
  } else {
23075
23873
  prev.arg = BigInt.asIntN(64, mul);
23076
23874
  }
23077
- logging3 && (0, import_chunk_HHQDDCTP.log)(
23875
+ logging3 && (0, import_chunk_QFQPBQSO.log)(
23078
23876
  `${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
23079
23877
  );
23080
23878
  changes = true;
@@ -23089,14 +23887,14 @@ function simpleOpts(func, context) {
23089
23887
  func.blocks.get(block.taken).preds.delete(block.offset);
23090
23888
  delete block.taken;
23091
23889
  changes = true;
23092
- logging3 && (0, import_chunk_HHQDDCTP.log)(`${func.name}: deleting empty finally handler`);
23890
+ logging3 && (0, import_chunk_QFQPBQSO.log)(`${func.name}: deleting empty finally handler`);
23093
23891
  } else if (isCondBranch(cur.op)) {
23094
23892
  const next = func.blocks.get(block.next);
23095
23893
  const taken = func.blocks.get(block.taken);
23096
23894
  if (next.preds.size > 1 && taken.preds.size === 1) {
23097
23895
  const newOp = cur.op === 40 ? 41 : 40;
23098
23896
  if (logging3) {
23099
- (0, import_chunk_HHQDDCTP.log)(
23897
+ (0, import_chunk_QFQPBQSO.log)(
23100
23898
  `${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
23101
23899
  );
23102
23900
  }
@@ -23109,7 +23907,7 @@ function simpleOpts(func, context) {
23109
23907
  const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
23110
23908
  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) {
23111
23909
  if (logging3) {
23112
- (0, import_chunk_HHQDDCTP.log)(
23910
+ (0, import_chunk_QFQPBQSO.log)(
23113
23911
  `${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23114
23912
  next.offset
23115
23913
  )}:${offsetToString(taken.offset)}:`
@@ -23126,7 +23924,7 @@ function simpleOpts(func, context) {
23126
23924
  changes = true;
23127
23925
  } 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) {
23128
23926
  if (logging3) {
23129
- (0, import_chunk_HHQDDCTP.log)(
23927
+ (0, import_chunk_QFQPBQSO.log)(
23130
23928
  `${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23131
23929
  taken.offset
23132
23930
  )}:${offsetToString(next.offset)}:`
@@ -23175,7 +23973,7 @@ function equalSymbolToEq(block, equalsIndex) {
23175
23973
  offset: invokem.offset,
23176
23974
  size: 1
23177
23975
  });
23178
- (0, import_chunk_HHQDDCTP.logger)(
23976
+ (0, import_chunk_QFQPBQSO.logger)(
23179
23977
  "optimize",
23180
23978
  1,
23181
23979
  `Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
@@ -23187,60 +23985,58 @@ function equalSymbolToEq(block, equalsIndex) {
23187
23985
  function isNopBlock(block) {
23188
23986
  return block.bytecodes.length === 0 || block.bytecodes.length === 1 && (block.bytecodes[0].op === 25 || block.bytecodes[0].op === 0);
23189
23987
  }
23190
- function cleanCfg2(func, context) {
23191
- if ((0, import_chunk_HHQDDCTP.wouldLog)("cfg", 10)) {
23192
- (0, import_chunk_HHQDDCTP.setBanner)(functionBanner(func, context, "sharing"));
23193
- }
23194
- const deadBlocks = /* @__PURE__ */ new Map();
23988
+ function removeNoOpBlocks(func) {
23989
+ const noOpBlocks = /* @__PURE__ */ new Map();
23195
23990
  func.blocks.forEach((block) => {
23196
23991
  if (isNopBlock(block) && block.offset !== func.offset) {
23197
- deadBlocks.set(block.offset, block.next);
23992
+ noOpBlocks.set(block.offset, block.next);
23198
23993
  }
23199
23994
  });
23200
- if (deadBlocks.size) {
23201
- deadBlocks.forEach((target, key) => {
23202
- let next = deadBlocks.get(target);
23995
+ if (noOpBlocks.size) {
23996
+ noOpBlocks.forEach((target, key) => {
23997
+ let next = noOpBlocks.get(target);
23203
23998
  if (next != null) {
23204
23999
  do {
23205
- deadBlocks.set(key, next);
23206
- next = deadBlocks.get(next);
24000
+ noOpBlocks.set(key, next);
24001
+ next = noOpBlocks.get(next);
23207
24002
  } while (next);
23208
24003
  }
23209
24004
  });
23210
24005
  func.blocks.forEach((block) => {
23211
24006
  if (block.next) {
23212
- const fixed = deadBlocks.get(block.next);
24007
+ const fixed = noOpBlocks.get(block.next);
23213
24008
  if (fixed) {
23214
24009
  redirect(func, block, block.next, fixed);
23215
24010
  }
23216
24011
  }
23217
24012
  if (block.taken) {
23218
- const fixed = deadBlocks.get(block.taken);
24013
+ const fixed = noOpBlocks.get(block.taken);
23219
24014
  if (fixed) {
23220
24015
  redirect(func, block, block.taken, fixed);
23221
24016
  }
23222
24017
  }
23223
24018
  if (block.exsucc) {
23224
- const fixed = deadBlocks.get(block.exsucc);
24019
+ const fixed = noOpBlocks.get(block.exsucc);
23225
24020
  if (fixed) {
23226
24021
  redirect(func, block, block.exsucc, fixed);
23227
24022
  }
23228
24023
  }
23229
24024
  });
23230
- deadBlocks.forEach((target, offset) => {
24025
+ noOpBlocks.forEach((target, offset) => {
23231
24026
  removeBlock(func, offset);
23232
24027
  });
23233
24028
  }
23234
- const deadCatches = /* @__PURE__ */ new Set();
24029
+ }
24030
+ function removeUnreachableCatches(func, context) {
23235
24031
  func.blocks.forEach((block) => {
23236
24032
  if (block.next && !block.taken && block.next !== block.offset && block.next !== func.offset) {
23237
24033
  const next = func.blocks.get(block.next);
23238
24034
  if (block.try === next.try) {
23239
24035
  if (next.preds.size === 1) {
23240
- (0, import_chunk_HHQDDCTP.logger)(
24036
+ (0, import_chunk_QFQPBQSO.logger)(
23241
24037
  "cfg",
23242
24038
  1,
23243
- `${func.name}: ${offsetToString(
24039
+ () => `${func.name}: ${offsetToString(
23244
24040
  block.offset
23245
24041
  )}: Merging linear blocks: ${blockToString(next, context)}`
23246
24042
  );
@@ -23251,7 +24047,7 @@ function cleanCfg2(func, context) {
23251
24047
  addPred(func, next.taken, block.offset);
23252
24048
  }
23253
24049
  if (next.exsucc) {
23254
- (0, import_node_assert10.default)(!block.exsucc || block.exsucc === next.exsucc);
24050
+ (0, import_node_assert12.default)(!block.exsucc || block.exsucc === next.exsucc);
23255
24051
  if (!block.exsucc) {
23256
24052
  block.exsucc = next.exsucc;
23257
24053
  addPred(func, next.exsucc, block.offset);
@@ -23260,10 +24056,10 @@ function cleanCfg2(func, context) {
23260
24056
  delete next.preds;
23261
24057
  removeBlock(func, next.offset);
23262
24058
  } else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + bc.size, 0) < 3 && countFallthroughPreds(func, next) > 1) {
23263
- (0, import_chunk_HHQDDCTP.logger)(
24059
+ (0, import_chunk_QFQPBQSO.logger)(
23264
24060
  "cfg",
23265
24061
  1,
23266
- `${func.name}: ${offsetToString(
24062
+ () => `${func.name}: ${offsetToString(
23267
24063
  block.offset
23268
24064
  )}: Merging short fallthrough block: ${blockToString(
23269
24065
  next,
@@ -23285,10 +24081,10 @@ function cleanCfg2(func, context) {
23285
24081
  switch (last.op) {
23286
24082
  case 41:
23287
24083
  case 40:
23288
- (0, import_chunk_HHQDDCTP.logger)(
24084
+ (0, import_chunk_QFQPBQSO.logger)(
23289
24085
  "cfg",
23290
24086
  1,
23291
- `${func.name}: killing no-op ${bytecodeToString(
24087
+ () => `${func.name}: killing no-op ${bytecodeToString(
23292
24088
  last,
23293
24089
  context.symbolTable
23294
24090
  )}`
@@ -23301,14 +24097,14 @@ function cleanCfg2(func, context) {
23301
24097
  delete block.taken;
23302
24098
  break;
23303
24099
  default:
23304
- (0, import_node_assert10.default)(false);
24100
+ (0, import_node_assert12.default)(false);
23305
24101
  }
23306
24102
  }
23307
24103
  if (block.try && !block.exsucc) {
23308
24104
  for (let i = block.try.length; i--; ) {
23309
24105
  const handler = block.try[i].handler;
23310
- if (!func.blocks.get(handler).preds?.size) {
23311
- (0, import_chunk_HHQDDCTP.logger)(
24106
+ if (!func.blocks.get(handler)?.preds?.size) {
24107
+ (0, import_chunk_QFQPBQSO.logger)(
23312
24108
  "cfg",
23313
24109
  1,
23314
24110
  `${func.name}: killing unused try-catch at ${offsetToString(
@@ -23316,7 +24112,6 @@ function cleanCfg2(func, context) {
23316
24112
  )} with handler at ${handler}`
23317
24113
  );
23318
24114
  block.try.splice(i, 1);
23319
- deadCatches.add(handler);
23320
24115
  }
23321
24116
  }
23322
24117
  if (!block.try.length) {
@@ -23324,56 +24119,75 @@ function cleanCfg2(func, context) {
23324
24119
  }
23325
24120
  }
23326
24121
  });
23327
- deadCatches.forEach((cb) => {
23328
- const todo = [cb];
23329
- for (let i = 0; i < todo.length; i++) {
23330
- const offset = todo[i];
23331
- const block = func.blocks.get(offset);
23332
- if (!block) {
23333
- todo.splice(i--, 1);
23334
- continue;
23335
- }
23336
- if (block.preds?.size) {
23337
- continue;
23338
- }
23339
- if (block.next != null)
23340
- todo.push(block.next);
23341
- if (block.taken != null)
23342
- todo.push(block.taken);
23343
- if (block.exsucc != null)
23344
- todo.push(block.exsucc);
23345
- removeBlock(func, offset);
23346
- todo.splice(i, 1);
23347
- i = -1;
23348
- }
24122
+ }
24123
+ function cleanCfg2(func, context) {
24124
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("cfg", 10)) {
24125
+ (0, import_chunk_QFQPBQSO.setBanner)(functionBanner(func, context, "sharing"));
24126
+ }
24127
+ removeNoOpBlocks(func);
24128
+ removeUnreachableCatches(func, context);
24129
+ const deadBlocks = new Set(func.blocks.values());
24130
+ postOrderTraverse2(func, (block) => deadBlocks.delete(block));
24131
+ deadBlocks.forEach((block) => {
24132
+ block.next && removePred(func, block.next, block.offset);
24133
+ block.taken && removePred(func, block.taken, block.offset);
24134
+ block.exsucc && removePred(func, block.exsucc, block.offset);
24135
+ });
24136
+ deadBlocks.forEach((block) => {
24137
+ (0, import_node_assert12.default)(!block.preds?.size);
24138
+ func.blocks.delete(block.offset);
23349
24139
  });
23350
- (0, import_chunk_HHQDDCTP.setBanner)(null);
24140
+ (0, import_chunk_QFQPBQSO.setBanner)(null);
23351
24141
  }
23352
- var init_optimize2 = (0, import_chunk_HHQDDCTP.__esm)({
24142
+ var init_optimize2 = (0, import_chunk_QFQPBQSO.__esm)({
23353
24143
  "src/readprg/optimize.ts"() {
23354
24144
  "use strict";
23355
- (0, import_chunk_HHQDDCTP.init_util)();
24145
+ init_pre2();
24146
+ (0, import_chunk_QFQPBQSO.init_util)();
23356
24147
  init_array_init();
23357
24148
  init_bytecode();
23358
24149
  init_dce();
23359
24150
  init_interp2();
24151
+ init_locals();
23360
24152
  init_opcodes();
23361
24153
  init_sharing();
24154
+ init_cflow();
23362
24155
  }
23363
24156
  });
23364
24157
  function emitFunc(func, view, start, updateInfo, context) {
23365
24158
  cleanCfg2(func, context);
23366
24159
  groupBlocks(func);
23367
- const { offsetMap } = updateInfo;
23368
- const localsMap = /* @__PURE__ */ new Map();
23369
- let numArgs = 0;
23370
- updateInfo.localsMap.set(func, localsMap);
24160
+ const { liveInLocals } = getLocalsInfo(func);
24161
+ const liveLocalRanges = /* @__PURE__ */ new Map();
24162
+ const { localRanges, offsetMap } = updateInfo;
23371
24163
  const linktable = /* @__PURE__ */ new Map();
23372
24164
  let offset = start;
23373
24165
  let lineNum = null;
23374
24166
  const compareLineInfo = (a, b) => {
23375
24167
  return a.line === b.line && a.file === b.file && a.symbol === b.symbol && a.fileStr === b.fileStr && a.symbolStr === b.symbolStr;
23376
24168
  };
24169
+ const startLocalRange = (slot, id, name, isParam) => {
24170
+ const liveRange = liveLocalRanges.get(slot);
24171
+ if (liveRange) {
24172
+ if (liveRange.id === id) {
24173
+ return;
24174
+ }
24175
+ liveRange.endPc = offset - 1;
24176
+ liveLocalRanges.delete(slot);
24177
+ }
24178
+ if (id < 0)
24179
+ return;
24180
+ const newRange = {
24181
+ startPc: offset,
24182
+ endPc: offset,
24183
+ id,
24184
+ isParam,
24185
+ name,
24186
+ slot
24187
+ };
24188
+ liveLocalRanges.set(slot, newRange);
24189
+ localRanges.push(newRange);
24190
+ };
23377
24191
  const exceptionStack = [];
23378
24192
  Array.from(func.blocks.values()).forEach((block, i, blocks) => {
23379
24193
  offsetMap.set(block.offset, offset);
@@ -23402,6 +24216,10 @@ function emitFunc(func, view, start, updateInfo, context) {
23402
24216
  } else {
23403
24217
  exceptionStack.length = 0;
23404
24218
  }
24219
+ const liveInState = liveInLocals.get(block.offset);
24220
+ liveInState?.forEach(
24221
+ (local) => startLocalRange(local.slot, local.id, local.name, local.isParam)
24222
+ );
23405
24223
  block.bytecodes.forEach((bytecode) => {
23406
24224
  if (bytecode.op === 25) {
23407
24225
  return;
@@ -23413,17 +24231,26 @@ function emitFunc(func, view, start, updateInfo, context) {
23413
24231
  updateInfo.lineMap.push(lineNum);
23414
24232
  }
23415
24233
  }
23416
- offsetMap.set(bytecode.offset, offset);
23417
- if (bytecode.op === 53) {
23418
- numArgs = bytecode.arg;
23419
- } else if (bytecode.op === 19 || bytecode.op === 18) {
23420
- const li = localsMap.get(bytecode.arg);
23421
- if (!li) {
23422
- localsMap.set(bytecode.arg, { startPc: offset, endPc: offset });
24234
+ if (bytecode.op === 19) {
24235
+ const range = bytecode.range;
24236
+ if (range) {
24237
+ startLocalRange(
24238
+ bytecode.arg,
24239
+ range.id,
24240
+ range.name,
24241
+ range.isParam === true
24242
+ );
23423
24243
  } else {
23424
- li.endPc = offset + bytecode.size;
24244
+ startLocalRange(bytecode.arg, -1, "", false);
23425
24245
  }
23426
24246
  }
24247
+ if (isCondBranch(bytecode.op) && block.taken != null && block.taken === blocks[i + 1]?.offset) {
24248
+ const taken = block.next;
24249
+ block.next = block.taken;
24250
+ block.taken = taken;
24251
+ bytecode.arg = taken;
24252
+ bytecode.op = bytecode.op === 40 ? 41 : 40;
24253
+ }
23427
24254
  offset = emitBytecode(bytecode, view, offset, linktable);
23428
24255
  });
23429
24256
  if (block.next != null && block.next !== blocks[i + 1]?.offset) {
@@ -23436,17 +24263,14 @@ function emitFunc(func, view, start, updateInfo, context) {
23436
24263
  offset = emitBytecode(bc, view, offset, linktable);
23437
24264
  }
23438
24265
  });
23439
- (0, import_node_assert11.default)(exceptionStack.length === 0);
23440
- localsMap.forEach((item, slot) => {
23441
- if (slot < numArgs) {
23442
- item.startPc = start;
23443
- }
23444
- item.endPc = offset;
24266
+ (0, import_node_assert13.default)(exceptionStack.length === 0);
24267
+ liveLocalRanges.forEach((liveRange) => {
24268
+ liveRange.endPc = offset - 1;
23445
24269
  });
23446
24270
  linktable.forEach((target, from) => {
23447
24271
  const newOffset = offsetMap.get(target);
23448
24272
  if (newOffset == null) {
23449
- (0, import_node_assert11.default)(newOffset != null);
24273
+ (0, import_node_assert13.default)(newOffset != null);
23450
24274
  }
23451
24275
  view.setInt16(from, newOffset - from - 2);
23452
24276
  });
@@ -23490,7 +24314,7 @@ function groupBlocks(func) {
23490
24314
  sortHelper(item).forEach((offset) => itemsFromOffset.set(offset, item));
23491
24315
  itemsToSort.add(item);
23492
24316
  item.items.forEach((block) => {
23493
- (0, import_node_assert11.default)(!isCfgNode(block));
24317
+ (0, import_node_assert13.default)(!isCfgNode(block));
23494
24318
  if (block.next && itemsFromOffset.get(block.next) !== item) {
23495
24319
  item.succs.add(block.next);
23496
24320
  }
@@ -23526,13 +24350,13 @@ function groupBlocks(func) {
23526
24350
  });
23527
24351
  }
23528
24352
  cur.items.forEach((item) => {
23529
- (0, import_node_assert11.default)(!isCfgNode(item));
24353
+ (0, import_node_assert13.default)(!isCfgNode(item));
23530
24354
  if (isCfgNode(item)) {
23531
24355
  item.items.forEach((block) => {
23532
- (0, import_node_assert11.default)(!isCfgNode(block));
24356
+ (0, import_node_assert13.default)(!isCfgNode(block));
23533
24357
  ordered.push(block.offset);
23534
24358
  });
23535
- (0, import_node_assert11.default)(false);
24359
+ (0, import_node_assert13.default)(false);
23536
24360
  } else {
23537
24361
  ordered.push(item.offset);
23538
24362
  }
@@ -23546,10 +24370,73 @@ function groupBlocks(func) {
23546
24370
  sortHelper(outer).reverse().map((offset) => [offset, func.blocks.get(offset)])
23547
24371
  );
23548
24372
  }
23549
- var init_emit = (0, import_chunk_HHQDDCTP.__esm)({
24373
+ function getLocalsInfo(func) {
24374
+ const liveOutLocals = /* @__PURE__ */ new Map();
24375
+ const liveInLocals = /* @__PURE__ */ new Map();
24376
+ function mergeInto3(from, to) {
24377
+ let changed = false;
24378
+ from.forEach((local, key) => {
24379
+ const curr = to.get(key);
24380
+ if (!curr) {
24381
+ to.set(key, local);
24382
+ changed = true;
24383
+ return;
24384
+ }
24385
+ });
24386
+ return changed;
24387
+ }
24388
+ postOrderPropagate(
24389
+ func,
24390
+ (block) => new Map(liveOutLocals.get(block.offset)),
24391
+ (block, bc, locals) => {
24392
+ switch (bc.op) {
24393
+ case 18: {
24394
+ const range = bc.range;
24395
+ if (range) {
24396
+ locals.set(bc.arg, {
24397
+ name: range.name,
24398
+ id: range.id,
24399
+ isParam: range.isParam === true,
24400
+ slot: bc.arg
24401
+ });
24402
+ }
24403
+ break;
24404
+ }
24405
+ case 19:
24406
+ locals.delete(bc.arg);
24407
+ break;
24408
+ case 51:
24409
+ case 15:
24410
+ if (block.exsucc) {
24411
+ const from = liveInLocals.get(block.exsucc);
24412
+ if (from) {
24413
+ mergeInto3(from, locals);
24414
+ }
24415
+ }
24416
+ break;
24417
+ }
24418
+ },
24419
+ (block, locals) => {
24420
+ liveInLocals.set(block.offset, locals);
24421
+ },
24422
+ (locals, predBlock, isExPred) => {
24423
+ if (isExPred)
24424
+ return false;
24425
+ const predLocals = liveOutLocals.get(predBlock.offset);
24426
+ if (!predLocals) {
24427
+ liveOutLocals.set(predBlock.offset, new Map(locals));
24428
+ return true;
24429
+ }
24430
+ return mergeInto3(locals, predLocals);
24431
+ }
24432
+ );
24433
+ return { liveInLocals, liveOutLocals };
24434
+ }
24435
+ var init_emit = (0, import_chunk_QFQPBQSO.__esm)({
23550
24436
  "src/readprg/emit.ts"() {
23551
24437
  "use strict";
23552
24438
  init_ast();
24439
+ init_cflow();
23553
24440
  init_opcodes();
23554
24441
  init_optimize2();
23555
24442
  }
@@ -23586,13 +24473,13 @@ function fixupExceptions(context, updateInfo) {
23586
24473
  ].view;
23587
24474
  const elems = updateInfo.exceptionsMap.size;
23588
24475
  const sectionLength = 2 + 9 * elems;
23589
- (0, import_node_assert12.default)(sectionLength <= view.byteLength);
24476
+ (0, import_node_assert14.default)(sectionLength <= view.byteLength);
23590
24477
  view.setUint16(0, elems);
23591
24478
  let writePos = 2;
23592
24479
  updateInfo.exceptionsMap.forEach(
23593
24480
  (entries) => entries.forEach((entry) => {
23594
24481
  const handler = updateInfo.offsetMap.get(entry.handler);
23595
- (0, import_node_assert12.default)(handler != null);
24482
+ (0, import_node_assert14.default)(handler != null);
23596
24483
  write24(view, (writePos += 3) - 3, entry.tryStart);
23597
24484
  write24(view, (writePos += 3) - 3, entry.tryEnd);
23598
24485
  write24(view, (writePos += 3) - 3, handler);
@@ -23605,7 +24492,7 @@ function write24(view, current, value2) {
23605
24492
  view.setUint8(current + 1, value2 >>> 8);
23606
24493
  view.setUint8(current + 2, value2);
23607
24494
  }
23608
- var init_exceptions = (0, import_chunk_HHQDDCTP.__esm)({
24495
+ var init_exceptions = (0, import_chunk_QFQPBQSO.__esm)({
23609
24496
  "src/readprg/exceptions.ts"() {
23610
24497
  "use strict";
23611
24498
  init_bytecode();
@@ -23662,7 +24549,7 @@ function fixupHeader(context, updateInfo) {
23662
24549
  view.setUint32(25, offset);
23663
24550
  }
23664
24551
  }
23665
- var init_header = (0, import_chunk_HHQDDCTP.__esm)({
24552
+ var init_header = (0, import_chunk_QFQPBQSO.__esm)({
23666
24553
  "src/readprg/header.ts"() {
23667
24554
  "use strict";
23668
24555
  init_bytecode();
@@ -23769,7 +24656,7 @@ function fixupLineNum(context, updateInfo) {
23769
24656
  });
23770
24657
  });
23771
24658
  }
23772
- var init_linenum = (0, import_chunk_HHQDDCTP.__esm)({
24659
+ var init_linenum = (0, import_chunk_QFQPBQSO.__esm)({
23773
24660
  "src/readprg/linenum.ts"() {
23774
24661
  "use strict";
23775
24662
  init_sdk_util();
@@ -23781,13 +24668,77 @@ function offsetToString(offset) {
23781
24668
  }
23782
24669
  function fixSectionSize(section, sections, newSize) {
23783
24670
  const sectionInfo = sections[section];
23784
- (0, import_node_assert13.default)(sectionInfo);
24671
+ (0, import_node_assert15.default)(sectionInfo);
23785
24672
  const view = sectionInfo.view;
23786
24673
  sectionInfo.length = newSize;
23787
24674
  new DataView(view.buffer, view.byteOffset - 4, 4).setUint32(0, newSize);
23788
24675
  sectionInfo.view = new DataView(view.buffer, view.byteOffset, newSize);
23789
24676
  }
24677
+ function markLocals(context) {
24678
+ if (context.debugXml.body instanceof Error) {
24679
+ return;
24680
+ }
24681
+ const localMap = /* @__PURE__ */ new Map();
24682
+ let range = context.nextLocalId;
24683
+ context.debugXml.body.children("localVars").children("entry").elements.forEach((entry) => {
24684
+ const { startPc, endPc, stackId, name, arg } = entry.attr;
24685
+ (0, import_node_assert15.default)(startPc && endPc && stackId && name);
24686
+ const spc = Number(startPc.value.value) & 16777215;
24687
+ const epc = (Number(endPc.value.value) & 16777215) + 1;
24688
+ const sid = Number(stackId.value.value);
24689
+ let locals = localMap.get(spc);
24690
+ if (!locals) {
24691
+ locals = [];
24692
+ localMap.set(spc, locals);
24693
+ }
24694
+ range++;
24695
+ locals.push({
24696
+ name: name.value.value,
24697
+ arg: arg?.value.value === "true",
24698
+ epc,
24699
+ sid,
24700
+ range
24701
+ });
24702
+ });
24703
+ context.nextLocalId = range;
24704
+ const live = /* @__PURE__ */ new Map();
24705
+ const ends = /* @__PURE__ */ new Map();
24706
+ context.bytecodes.forEach((bc) => {
24707
+ const end = ends.get(bc.offset);
24708
+ if (end) {
24709
+ end.forEach((sid) => {
24710
+ (0, import_node_assert15.default)(live.has(sid));
24711
+ live.delete(sid);
24712
+ });
24713
+ ends.delete(bc.offset);
24714
+ }
24715
+ const locals = localMap.get(bc.offset);
24716
+ locals?.forEach((localInfo) => {
24717
+ if (live.has(localInfo.sid)) {
24718
+ (0, import_node_assert15.default)(!live.has(localInfo.sid));
24719
+ }
24720
+ live.set(localInfo.sid, localInfo);
24721
+ const e = ends.get(localInfo.epc);
24722
+ if (e == null) {
24723
+ ends.set(localInfo.epc, [localInfo.sid]);
24724
+ } else {
24725
+ e.push(localInfo.sid);
24726
+ }
24727
+ });
24728
+ if (bc.op === 18 || bc.op === 19) {
24729
+ const local = live.get(bc.arg);
24730
+ if (local) {
24731
+ const range2 = { name: local.name, id: local.range };
24732
+ if (local.arg) {
24733
+ range2.isParam = true;
24734
+ }
24735
+ bc.range = range2;
24736
+ }
24737
+ }
24738
+ });
24739
+ }
23790
24740
  function optimizeBytecode(context) {
24741
+ markLocals(context);
23791
24742
  const functions = findFunctions(context);
23792
24743
  const loggerFunc = process.env["MC_LOGGER_FUNC"] ? new RegExp(process.env["MC_LOGGER_FUNC"]) : null;
23793
24744
  const forEachFunction = (callback) => {
@@ -23795,24 +24746,24 @@ function optimizeBytecode(context) {
23795
24746
  functions.forEach(callback);
23796
24747
  return;
23797
24748
  }
23798
- (0, import_chunk_HHQDDCTP.bumpLogging)(null, 10);
23799
- functions.forEach((func2) => {
23800
- if (loggerFunc.test(func2.name ?? "<null>")) {
23801
- (0, import_chunk_HHQDDCTP.bumpLogging)(null, -10);
23802
- callback(func2);
23803
- (0, import_chunk_HHQDDCTP.bumpLogging)(null, 10);
24749
+ (0, import_chunk_QFQPBQSO.bumpLogging)(null, 10);
24750
+ functions.forEach((func) => {
24751
+ if (loggerFunc.test(func.name ?? "<null>")) {
24752
+ (0, import_chunk_QFQPBQSO.bumpLogging)(null, -10);
24753
+ callback(func);
24754
+ (0, import_chunk_QFQPBQSO.bumpLogging)(null, 10);
23804
24755
  return;
23805
24756
  }
23806
- callback(func2);
24757
+ callback(func);
23807
24758
  });
23808
- (0, import_chunk_HHQDDCTP.bumpLogging)(null, -10);
24759
+ (0, import_chunk_QFQPBQSO.bumpLogging)(null, -10);
23809
24760
  };
23810
- if ((0, import_chunk_HHQDDCTP.wouldLog)("list-input", 1)) {
24761
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("list-input", 1)) {
23811
24762
  forEachFunction(
23812
- (func2) => (0, import_chunk_HHQDDCTP.wouldLog)("list-input", 1) && printFunction(func2, context)
24763
+ (func) => (0, import_chunk_QFQPBQSO.wouldLog)("list-input", 1) && printFunction(func, context)
23813
24764
  );
23814
24765
  }
23815
- forEachFunction((func2) => optimizeFunc(func2, context));
24766
+ forEachFunction((func) => optimizeFunc(func, context));
23816
24767
  const code = context.sections[
23817
24768
  -1059145026
23818
24769
  /* TEXT */
@@ -23820,23 +24771,23 @@ function optimizeBytecode(context) {
23820
24771
  let offset = 0;
23821
24772
  const updateInfo = {
23822
24773
  offsetMap: /* @__PURE__ */ new Map(),
23823
- localsMap: /* @__PURE__ */ new Map(),
24774
+ localRanges: [],
23824
24775
  lineMap: [],
23825
24776
  exceptionsMap: /* @__PURE__ */ new Map()
23826
24777
  };
23827
- forEachFunction((func2) => {
23828
- if (!func2.name)
24778
+ forEachFunction((func) => {
24779
+ if (!func.name)
23829
24780
  return;
23830
- (0, import_chunk_HHQDDCTP.logger)(
24781
+ (0, import_chunk_QFQPBQSO.logger)(
23831
24782
  "bytecode",
23832
24783
  5,
23833
- `${func2.name}: ${offset.toString(16)} ${offset - func2.offset}`
24784
+ `${func.name}: ${offset.toString(16)} ${offset - func.offset}`
23834
24785
  );
23835
- offset = emitFunc(func2, code, offset, updateInfo, context);
24786
+ offset = emitFunc(func, code, offset, updateInfo, context);
23836
24787
  });
23837
24788
  const { offsetMap } = updateInfo;
23838
24789
  offsetMap.set(code.byteLength, offset);
23839
- (0, import_chunk_HHQDDCTP.logger)(
24790
+ (0, import_chunk_QFQPBQSO.logger)(
23840
24791
  "bytecode",
23841
24792
  1,
23842
24793
  `${context.filepath}: code size: ${context.sections[
@@ -23848,9 +24799,9 @@ function optimizeBytecode(context) {
23848
24799
  ].length - offset}`
23849
24800
  );
23850
24801
  fixSectionSize(-1059145026, context.sections, offset);
23851
- if ((0, import_chunk_HHQDDCTP.wouldLog)("list-output", 1)) {
24802
+ if ((0, import_chunk_QFQPBQSO.wouldLog)("list-output", 1)) {
23852
24803
  forEachFunction(
23853
- (func2) => (0, import_chunk_HHQDDCTP.wouldLog)("list-output", 1) && printFunction(func2, context)
24804
+ (func) => (0, import_chunk_QFQPBQSO.wouldLog)("list-output", 1) && printFunction(func, context)
23854
24805
  );
23855
24806
  }
23856
24807
  fixupHeader(context, updateInfo);
@@ -23861,7 +24812,7 @@ function optimizeBytecode(context) {
23861
24812
  return;
23862
24813
  }
23863
24814
  const funcArray = Array.from(functions.values()).filter(
23864
- (func2) => func2.name != null
24815
+ (func) => func.name != null
23865
24816
  );
23866
24817
  funcArray.push({ offset: code.byteLength, blocks: /* @__PURE__ */ new Map() });
23867
24818
  const funcIndex = (pc) => {
@@ -23879,46 +24830,53 @@ function optimizeBytecode(context) {
23879
24830
  };
23880
24831
  const funcRange = (pc) => {
23881
24832
  const index = funcIndex(pc);
23882
- (0, import_node_assert13.default)(
24833
+ (0, import_node_assert15.default)(
23883
24834
  funcArray[index].offset <= (pc & 16777215) && funcArray[index + 1].offset > (pc & 16777215)
23884
24835
  );
23885
24836
  const s = offsetMap.get(funcArray[index].offset);
23886
24837
  const e = offsetMap.get(funcArray[index + 1].offset);
23887
24838
  if (s == null || e == null) {
23888
- (0, import_node_assert13.default)(s != null && e != null);
24839
+ (0, import_node_assert15.default)(s != null && e != null);
23889
24840
  }
23890
24841
  return [s + 268435456, e + 268435456];
23891
24842
  };
23892
- let func = funcArray[0];
23893
- let fend = funcArray[1].offset;
23894
- context.debugXml.body.children("localVars").children("entry").elements.forEach((entry) => {
23895
- const { startPc, endPc, stackId } = entry.attr;
23896
- (0, import_node_assert13.default)(startPc && endPc && stackId);
23897
- const spc = Number(startPc.value.value) & 16777215;
23898
- const epc = Number(endPc.value.value) & 16777215;
23899
- const sid = Number(stackId.value.value);
23900
- if (spc < func.offset || epc > fend) {
23901
- const index = funcIndex(Number(startPc.value.value));
23902
- func = funcArray[index];
23903
- fend = funcArray[index + 1].offset;
23904
- }
23905
- const info = updateInfo.localsMap.get(func);
23906
- (0, import_node_assert13.default)(info);
23907
- const local = info.get(sid);
23908
- if (!local) {
23909
- entry.attr = {};
24843
+ const localVars = context.debugXml.body.children("localVars");
24844
+ const addAttr = (element, attrName, attrValue) => {
24845
+ element.attr[attrName] = xml_util_exports.makeAttribute(attrName, attrValue);
24846
+ };
24847
+ localVars.elements.forEach((element, i) => {
24848
+ delete element.children;
24849
+ if (i)
23910
24850
  return;
23911
- }
23912
- startPc.value.value = (local.startPc + 268435456).toString();
23913
- endPc.value.value = (local.endPc + 268435455).toString();
24851
+ element.children = [];
24852
+ const children = element.children;
24853
+ updateInfo.localRanges.forEach((localRange) => {
24854
+ if (localRange.endPc === localRange.startPc) {
24855
+ return;
24856
+ }
24857
+ children.push({ type: "chardata", value: "\n" });
24858
+ const element2 = {
24859
+ type: "element",
24860
+ name: "entry",
24861
+ attr: {}
24862
+ };
24863
+ addAttr(element2, "name", localRange.name);
24864
+ if (localRange.isParam) {
24865
+ addAttr(element2, "arg", "true");
24866
+ }
24867
+ addAttr(element2, "startPc", (localRange.startPc + 268435456).toString());
24868
+ addAttr(element2, "endPc", (localRange.endPc + 268435456).toString());
24869
+ addAttr(element2, "stackId", localRange.slot.toString());
24870
+ children.push(element2);
24871
+ });
24872
+ children.push({ type: "chardata", value: "\n" });
23914
24873
  });
23915
- context.debugXml.body.children("localVars").deleteChildren((entry) => !entry.attr.startPc);
23916
24874
  context.debugXml.body.children("functions").children("functionEntry").elements.forEach((entry) => {
23917
24875
  const { startPc, endPc } = entry.attr;
23918
24876
  if (!startPc || !endPc)
23919
24877
  return;
23920
24878
  const range = funcRange(Number(startPc.value.value));
23921
- (0, import_node_assert13.default)(funcRange(Number(endPc.value.value))[0] === range[0]);
24879
+ (0, import_node_assert15.default)(funcRange(Number(endPc.value.value))[0] === range[0]);
23922
24880
  startPc.value.value = range[0].toString();
23923
24881
  endPc.value.value = (range[1] - 1).toString();
23924
24882
  });
@@ -23933,7 +24891,7 @@ ${functionToString(
23933
24891
  ---------------- ${func.name} ----------------`;
23934
24892
  }
23935
24893
  function printFunction(func, context) {
23936
- (0, import_chunk_HHQDDCTP.log)(functionToString(func, context));
24894
+ (0, import_chunk_QFQPBQSO.log)(functionToString(func, context));
23937
24895
  }
23938
24896
  function functionToString(func, context, extra) {
23939
24897
  const parts = [];
@@ -23954,7 +24912,7 @@ function blockToString(block, context) {
23954
24912
  const log2 = (msg) => parts.push(msg + "\n");
23955
24913
  log2(`${offsetToString(block.offset)}:`);
23956
24914
  block.try?.forEach((exInfo) => {
23957
- (0, import_node_assert13.default)(exInfo);
24915
+ (0, import_node_assert15.default)(exInfo);
23958
24916
  log2(
23959
24917
  `tryCatch - start: ${offsetToString(
23960
24918
  exInfo.tryStart
@@ -23989,6 +24947,12 @@ function lineInfoToString(lineInfo, context) {
23989
24947
  function bytecodeToString(bytecode, symbolTable) {
23990
24948
  let arg = null;
23991
24949
  switch (bytecode.op) {
24950
+ case 18:
24951
+ case 19:
24952
+ if (bytecode.range) {
24953
+ arg = `${bytecode.range.name} ${bytecode.arg}${bytecode.range.isParam ? " (param)" : ""}`;
24954
+ }
24955
+ break;
23992
24956
  case 39: {
23993
24957
  const argSym = symbolTable?.symbolToLabelMap.get(bytecode.arg);
23994
24958
  if (argSym) {
@@ -24002,7 +24966,7 @@ function bytecodeToString(bytecode, symbolTable) {
24002
24966
  case 24: {
24003
24967
  const symbol = symbolTable?.symbols.get(bytecode.arg);
24004
24968
  if (symbol) {
24005
- arg = symbol.str;
24969
+ arg = `${JSON.stringify(symbol.str)} (${bytecode.arg})`;
24006
24970
  }
24007
24971
  break;
24008
24972
  }
@@ -24109,15 +25073,18 @@ function findFunctions({
24109
25073
  }
24110
25074
  start = i + 1;
24111
25075
  mayThrow2 = false;
24112
- const exnEntry = exceptionsMap.get(nextBcOffset);
24113
- if (exnEntry) {
24114
- exnStack = exnStack.concat(exnEntry);
25076
+ const exnEntries = exceptionsMap.get(nextBcOffset);
25077
+ if (exnEntries) {
25078
+ exnStack = exnStack.concat(
25079
+ exnEntries.filter((exnEntry) => exnEntry.tryEnd > nextBcOffset)
25080
+ );
24115
25081
  }
24116
25082
  }
24117
25083
  });
24118
25084
  const functions = /* @__PURE__ */ new Map();
24119
25085
  while (blocks.size) {
24120
25086
  const func = /* @__PURE__ */ new Map();
25087
+ let argc = null;
24121
25088
  const queue = [blocks.keys().next().value];
24122
25089
  while (queue.length) {
24123
25090
  const next2 = queue.pop();
@@ -24126,11 +25093,13 @@ function findFunctions({
24126
25093
  continue;
24127
25094
  }
24128
25095
  func.set(next2, block);
25096
+ if (func.size === 1 && block.bytecodes.length && block.bytecodes[0].op === 53) {
25097
+ argc = block.bytecodes[0].arg;
25098
+ }
24129
25099
  blocks.delete(next2);
24130
- exceptionsMap.get(block.offset)?.forEach((exInfo) => {
24131
- queue.push(exInfo.tryEnd);
24132
- queue.push(exInfo.handler);
24133
- });
25100
+ if (block.exsucc != null) {
25101
+ queue.push(block.exsucc);
25102
+ }
24134
25103
  if (block.next != null) {
24135
25104
  queue.push(block.next);
24136
25105
  }
@@ -24141,10 +25110,17 @@ function findFunctions({
24141
25110
  const funcSorted = Array.from(func.keys()).sort((a, b) => a - b).map((key) => [key, func.get(key)]);
24142
25111
  const offset = funcSorted[0][0];
24143
25112
  const f = { offset, blocks: new Map(funcSorted) };
24144
- const name = symbolTable.methods.get(offset)?.name;
25113
+ const method = symbolTable.methods.get(offset);
25114
+ const name = method?.name;
24145
25115
  if (!name)
24146
25116
  continue;
24147
25117
  f.name = name;
25118
+ if (argc == null && method.argc != null) {
25119
+ argc = method.argc;
25120
+ }
25121
+ if (argc != null) {
25122
+ f.argc = argc;
25123
+ }
24148
25124
  functions.set(offset, f);
24149
25125
  }
24150
25126
  const addPred2 = (func, block, succ) => {
@@ -24179,7 +25155,7 @@ function makeArgless(bc, op) {
24179
25155
  }
24180
25156
  function removeBlock(func, offset) {
24181
25157
  const block = func.blocks.get(offset);
24182
- (0, import_node_assert13.default)(block && !block.preds?.size);
25158
+ (0, import_node_assert15.default)(block && !block.preds?.size);
24183
25159
  block.next && removePred(func, block.next, block.offset);
24184
25160
  block.taken && removePred(func, block.taken, block.offset);
24185
25161
  block.exsucc && removePred(func, block.exsucc, block.offset);
@@ -24187,9 +25163,7 @@ function removeBlock(func, offset) {
24187
25163
  }
24188
25164
  function removePred(func, target, pred) {
24189
25165
  const targetBlock = func.blocks.get(target);
24190
- if (!targetBlock.preds?.has(pred)) {
24191
- (0, import_node_assert13.default)(targetBlock.preds?.has(pred));
24192
- }
25166
+ (0, import_node_assert15.default)(targetBlock.preds?.has(pred));
24193
25167
  targetBlock.preds.delete(pred);
24194
25168
  }
24195
25169
  function addPred(func, target, pred) {
@@ -24219,7 +25193,7 @@ function redirect(func, block, from, to) {
24219
25193
  last.arg = to;
24220
25194
  break;
24221
25195
  default:
24222
- (0, import_node_assert13.default)(false);
25196
+ (0, import_node_assert15.default)(false);
24223
25197
  }
24224
25198
  } else {
24225
25199
  delete block.taken;
@@ -24227,8 +25201,8 @@ function redirect(func, block, from, to) {
24227
25201
  changes = true;
24228
25202
  }
24229
25203
  if (block.exsucc === from) {
24230
- (0, import_node_assert13.default)(to);
24231
- (0, import_node_assert13.default)(block.try);
25204
+ (0, import_node_assert15.default)(to);
25205
+ (0, import_node_assert15.default)(block.try);
24232
25206
  block.try[block.try.length - 1].handler = to;
24233
25207
  block.exsucc = to;
24234
25208
  changes = true;
@@ -24258,7 +25232,7 @@ function splitBlock(func, block, offset) {
24258
25232
  }
24259
25233
  };
24260
25234
  if (offset > 0) {
24261
- (0, import_node_assert13.default)(offset < block.bytecodes.length);
25235
+ (0, import_node_assert15.default)(offset < block.bytecodes.length);
24262
25236
  const tail = block.bytecodes.splice(offset);
24263
25237
  const tailBlock = {
24264
25238
  ...block,
@@ -24282,7 +25256,7 @@ function splitBlock(func, block, offset) {
24282
25256
  delete block.taken;
24283
25257
  }
24284
25258
  } else {
24285
- (0, import_node_assert13.default)(offset < 0 && offset + block.bytecodes.length > 0);
25259
+ (0, import_node_assert15.default)(offset < 0 && offset + block.bytecodes.length > 0);
24286
25260
  const head = block.bytecodes.splice(0, block.bytecodes.length + offset);
24287
25261
  const headBlock = {
24288
25262
  ...block,
@@ -24325,11 +25299,12 @@ function countFallthroughPreds(func, block) {
24325
25299
  }, 0);
24326
25300
  }
24327
25301
  var SectionKinds;
24328
- var init_bytecode = (0, import_chunk_HHQDDCTP.__esm)({
25302
+ var init_bytecode = (0, import_chunk_QFQPBQSO.__esm)({
24329
25303
  "src/readprg/bytecode.ts"() {
24330
25304
  "use strict";
24331
25305
  init_ast();
24332
- (0, import_chunk_HHQDDCTP.init_util)();
25306
+ init_sdk_util();
25307
+ (0, import_chunk_QFQPBQSO.init_util)();
24333
25308
  init_data();
24334
25309
  init_emit();
24335
25310
  init_exceptions();
@@ -24365,7 +25340,7 @@ function getPrgSignature(context) {
24365
25340
  if (!signature)
24366
25341
  return;
24367
25342
  const keyInfo = context.key.export({ format: "jwk" });
24368
- (0, import_node_assert14.default)(keyInfo.n && keyInfo.e);
25343
+ (0, import_node_assert16.default)(keyInfo.n && keyInfo.e);
24369
25344
  const modulusBuf = Buffer.from(keyInfo.n, "base64");
24370
25345
  const publicExponent = Array.from(Buffer.from(keyInfo.e, "base64")).reduce(
24371
25346
  (value2, n) => (value2 << 8) + n,
@@ -24377,7 +25352,7 @@ function getPrgSignature(context) {
24377
25352
  modulusBuf.byteOffset + delta,
24378
25353
  modulusBuf.byteLength - delta
24379
25354
  );
24380
- (0, import_node_assert14.default)(modulus.byteLength === 512 && signature.length === 512);
25355
+ (0, import_node_assert16.default)(modulus.byteLength === 512 && signature.length === 512);
24381
25356
  const sectionLength = signature.length + modulus.byteLength + 4;
24382
25357
  const buffer = new DataView(new ArrayBuffer(sectionLength + 8));
24383
25358
  buffer.setInt32(
@@ -24440,7 +25415,7 @@ function signView(key, view) {
24440
25415
  signer.end();
24441
25416
  return signer.sign(key);
24442
25417
  }
24443
- var init_signer = (0, import_chunk_HHQDDCTP.__esm)({
25418
+ var init_signer = (0, import_chunk_QFQPBQSO.__esm)({
24444
25419
  "src/readprg/signer.ts"() {
24445
25420
  "use strict";
24446
25421
  init_bytecode();
@@ -24454,7 +25429,7 @@ function hash(s) {
24454
25429
  return (h ^ h >>> 9) >>> 0;
24455
25430
  }
24456
25431
  var SymbolTable;
24457
- var init_symbols = (0, import_chunk_HHQDDCTP.__esm)({
25432
+ var init_symbols = (0, import_chunk_QFQPBQSO.__esm)({
24458
25433
  "src/readprg/symbols.ts"() {
24459
25434
  "use strict";
24460
25435
  SymbolTable = class {
@@ -24488,9 +25463,16 @@ var init_symbols = (0, import_chunk_HHQDDCTP.__esm)({
24488
25463
  const { startPc, name, parent } = functionEntry.attr;
24489
25464
  if (!startPc || !name)
24490
25465
  return;
25466
+ const argc = functionEntry.children?.filter(
25467
+ (node) => node.type === "element" && node.name === "param"
25468
+ ).length || null;
24491
25469
  const fullName = (parent ? debugXml.processRefs(parent.value.value) + "." : "") + debugXml.processRefs(name.value.value);
24492
25470
  const pc = Number(startPc.value.value) & 16777215;
24493
- this.methods.set(pc, { name: fullName, id: null });
25471
+ this.methods.set(pc, {
25472
+ name: fullName,
25473
+ id: null,
25474
+ argc: argc == null ? null : argc + 1
25475
+ });
24494
25476
  });
24495
25477
  debugXml.body.children("symbolTable").children("entry").elements.forEach((entry) => {
24496
25478
  const { id, symbol } = entry.attr;
@@ -24591,20 +25573,20 @@ async function build_project(product, options, lineCallback) {
24591
25573
  lineCallback || ((line) => console.log(line)),
24592
25574
  (line) => console.error(line)
24593
25575
  ];
24594
- await (0, import_chunk_HHQDDCTP.spawnByLine)(exe, args, handlers, {
25576
+ await (0, import_chunk_QFQPBQSO.spawnByLine)(exe, args, handlers, {
24595
25577
  cwd: workspace
24596
25578
  });
24597
25579
  }
24598
25580
  return { exe, args, program: path.resolve(workspace, program), product };
24599
25581
  }
24600
- var init_build = (0, import_chunk_HHQDDCTP.__esm)({
25582
+ var init_build = (0, import_chunk_QFQPBQSO.__esm)({
24601
25583
  "src/build.ts"() {
24602
25584
  "use strict";
24603
25585
  init_sdk_util();
24604
- (0, import_chunk_HHQDDCTP.init_util)();
25586
+ (0, import_chunk_QFQPBQSO.init_util)();
24605
25587
  }
24606
25588
  });
24607
- var require_ms = (0, import_chunk_HHQDDCTP.__commonJS)({
25589
+ var require_ms = (0, import_chunk_QFQPBQSO.__commonJS)({
24608
25590
  "node_modules/ms/index.js"(exports, module2) {
24609
25591
  var s = 1e3;
24610
25592
  var m = s * 60;
@@ -24718,7 +25700,7 @@ var require_ms = (0, import_chunk_HHQDDCTP.__commonJS)({
24718
25700
  }
24719
25701
  }
24720
25702
  });
24721
- var require_common = (0, import_chunk_HHQDDCTP.__commonJS)({
25703
+ var require_common = (0, import_chunk_QFQPBQSO.__commonJS)({
24722
25704
  "node_modules/debug/src/common.js"(exports, module2) {
24723
25705
  function setup(env) {
24724
25706
  createDebug.debug = createDebug;
@@ -24879,7 +25861,7 @@ var require_common = (0, import_chunk_HHQDDCTP.__commonJS)({
24879
25861
  module2.exports = setup;
24880
25862
  }
24881
25863
  });
24882
- var require_browser = (0, import_chunk_HHQDDCTP.__commonJS)({
25864
+ var require_browser = (0, import_chunk_QFQPBQSO.__commonJS)({
24883
25865
  "node_modules/debug/src/browser.js"(exports, module2) {
24884
25866
  exports.formatArgs = formatArgs;
24885
25867
  exports.save = save;
@@ -25046,7 +26028,7 @@ var require_browser = (0, import_chunk_HHQDDCTP.__commonJS)({
25046
26028
  };
25047
26029
  }
25048
26030
  });
25049
- var require_has_flag = (0, import_chunk_HHQDDCTP.__commonJS)({
26031
+ var require_has_flag = (0, import_chunk_QFQPBQSO.__commonJS)({
25050
26032
  "node_modules/has-flag/index.js"(exports, module2) {
25051
26033
  "use strict";
25052
26034
  module2.exports = (flag, argv = process.argv) => {
@@ -25057,11 +26039,11 @@ var require_has_flag = (0, import_chunk_HHQDDCTP.__commonJS)({
25057
26039
  };
25058
26040
  }
25059
26041
  });
25060
- var require_supports_color = (0, import_chunk_HHQDDCTP.__commonJS)({
26042
+ var require_supports_color = (0, import_chunk_QFQPBQSO.__commonJS)({
25061
26043
  "node_modules/supports-color/index.js"(exports, module2) {
25062
26044
  "use strict";
25063
- var os2 = (0, import_chunk_HHQDDCTP.__require)("os");
25064
- var tty = (0, import_chunk_HHQDDCTP.__require)("tty");
26045
+ var os2 = (0, import_chunk_QFQPBQSO.__require)("os");
26046
+ var tty = (0, import_chunk_QFQPBQSO.__require)("tty");
25065
26047
  var hasFlag = require_has_flag();
25066
26048
  var { env } = process;
25067
26049
  var forceColor;
@@ -25157,10 +26139,10 @@ var require_supports_color = (0, import_chunk_HHQDDCTP.__commonJS)({
25157
26139
  };
25158
26140
  }
25159
26141
  });
25160
- var require_node = (0, import_chunk_HHQDDCTP.__commonJS)({
26142
+ var require_node = (0, import_chunk_QFQPBQSO.__commonJS)({
25161
26143
  "node_modules/debug/src/node.js"(exports, module2) {
25162
- var tty = (0, import_chunk_HHQDDCTP.__require)("tty");
25163
- var util = (0, import_chunk_HHQDDCTP.__require)("util");
26144
+ var tty = (0, import_chunk_QFQPBQSO.__require)("tty");
26145
+ var util = (0, import_chunk_QFQPBQSO.__require)("util");
25164
26146
  exports.init = init;
25165
26147
  exports.log = log2;
25166
26148
  exports.formatArgs = formatArgs;
@@ -25329,7 +26311,7 @@ var require_node = (0, import_chunk_HHQDDCTP.__commonJS)({
25329
26311
  };
25330
26312
  }
25331
26313
  });
25332
- var require_src = (0, import_chunk_HHQDDCTP.__commonJS)({
26314
+ var require_src = (0, import_chunk_QFQPBQSO.__commonJS)({
25333
26315
  "node_modules/debug/src/index.js"(exports, module2) {
25334
26316
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
25335
26317
  module2.exports = require_browser();
@@ -25338,7 +26320,7 @@ var require_src = (0, import_chunk_HHQDDCTP.__commonJS)({
25338
26320
  }
25339
26321
  }
25340
26322
  });
25341
- var require_wrappy = (0, import_chunk_HHQDDCTP.__commonJS)({
26323
+ var require_wrappy = (0, import_chunk_QFQPBQSO.__commonJS)({
25342
26324
  "node_modules/wrappy/wrappy.js"(exports, module2) {
25343
26325
  module2.exports = wrappy;
25344
26326
  function wrappy(fn, cb) {
@@ -25367,7 +26349,7 @@ var require_wrappy = (0, import_chunk_HHQDDCTP.__commonJS)({
25367
26349
  }
25368
26350
  }
25369
26351
  });
25370
- var require_once = (0, import_chunk_HHQDDCTP.__commonJS)({
26352
+ var require_once = (0, import_chunk_QFQPBQSO.__commonJS)({
25371
26353
  "node_modules/once/once.js"(exports, module2) {
25372
26354
  var wrappy = require_wrappy();
25373
26355
  module2.exports = wrappy(once);
@@ -25410,7 +26392,7 @@ var require_once = (0, import_chunk_HHQDDCTP.__commonJS)({
25410
26392
  }
25411
26393
  }
25412
26394
  });
25413
- var require_end_of_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
26395
+ var require_end_of_stream = (0, import_chunk_QFQPBQSO.__commonJS)({
25414
26396
  "node_modules/end-of-stream/index.js"(exports, module2) {
25415
26397
  var once = require_once();
25416
26398
  var noop = function() {
@@ -25503,11 +26485,11 @@ var require_end_of_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
25503
26485
  module2.exports = eos;
25504
26486
  }
25505
26487
  });
25506
- var require_pump = (0, import_chunk_HHQDDCTP.__commonJS)({
26488
+ var require_pump = (0, import_chunk_QFQPBQSO.__commonJS)({
25507
26489
  "node_modules/pump/index.js"(exports, module2) {
25508
26490
  var once = require_once();
25509
26491
  var eos = require_end_of_stream();
25510
- var fs9 = (0, import_chunk_HHQDDCTP.__require)("fs");
26492
+ var fs9 = (0, import_chunk_QFQPBQSO.__require)("fs");
25511
26493
  var noop = function() {
25512
26494
  };
25513
26495
  var ancient = /^v?\.0/.test(process.version);
@@ -25585,10 +26567,10 @@ var require_pump = (0, import_chunk_HHQDDCTP.__commonJS)({
25585
26567
  module2.exports = pump;
25586
26568
  }
25587
26569
  });
25588
- var require_buffer_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
26570
+ var require_buffer_stream = (0, import_chunk_QFQPBQSO.__commonJS)({
25589
26571
  "node_modules/get-stream/buffer-stream.js"(exports, module2) {
25590
26572
  "use strict";
25591
- var { PassThrough: PassThroughStream } = (0, import_chunk_HHQDDCTP.__require)("stream");
26573
+ var { PassThrough: PassThroughStream } = (0, import_chunk_QFQPBQSO.__require)("stream");
25592
26574
  module2.exports = (options) => {
25593
26575
  options = { ...options };
25594
26576
  const { array } = options;
@@ -25628,10 +26610,10 @@ var require_buffer_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
25628
26610
  };
25629
26611
  }
25630
26612
  });
25631
- var require_get_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
26613
+ var require_get_stream = (0, import_chunk_QFQPBQSO.__commonJS)({
25632
26614
  "node_modules/get-stream/index.js"(exports, module2) {
25633
26615
  "use strict";
25634
- var { constants: BufferConstants } = (0, import_chunk_HHQDDCTP.__require)("buffer");
26616
+ var { constants: BufferConstants } = (0, import_chunk_QFQPBQSO.__require)("buffer");
25635
26617
  var pump = require_pump();
25636
26618
  var bufferStream = require_buffer_stream();
25637
26619
  var MaxBufferError = class extends Error {
@@ -25679,14 +26661,14 @@ var require_get_stream = (0, import_chunk_HHQDDCTP.__commonJS)({
25679
26661
  module2.exports.MaxBufferError = MaxBufferError;
25680
26662
  }
25681
26663
  });
25682
- var require_extract_zip = (0, import_chunk_HHQDDCTP.__commonJS)({
26664
+ var require_extract_zip = (0, import_chunk_QFQPBQSO.__commonJS)({
25683
26665
  "node_modules/extract-zip/index.js"(exports, module2) {
25684
26666
  var debug = require_src()("extract-zip");
25685
- var { createWriteStream: createWriteStream2, promises: fs9 } = (0, import_chunk_HHQDDCTP.__require)("fs");
26667
+ var { createWriteStream: createWriteStream2, promises: fs9 } = (0, import_chunk_QFQPBQSO.__require)("fs");
25686
26668
  var getStream = require_get_stream();
25687
- var path7 = (0, import_chunk_HHQDDCTP.__require)("path");
25688
- var { promisify } = (0, import_chunk_HHQDDCTP.__require)("util");
25689
- var stream = (0, import_chunk_HHQDDCTP.__require)("stream");
26669
+ var path7 = (0, import_chunk_QFQPBQSO.__require)("path");
26670
+ var { promisify } = (0, import_chunk_QFQPBQSO.__require)("util");
26671
+ var stream = (0, import_chunk_QFQPBQSO.__require)("stream");
25690
26672
  var yauzl2 = require_yauzl();
25691
26673
  var openZip = promisify(yauzl2.open);
25692
26674
  var pipeline = promisify(stream.pipeline);
@@ -27307,7 +28289,7 @@ function peg$parse2(input, options) {
27307
28289
  );
27308
28290
  }
27309
28291
  }
27310
- var init_jungle = (0, import_chunk_HHQDDCTP.__esm)({
28292
+ var init_jungle = (0, import_chunk_QFQPBQSO.__esm)({
27311
28293
  "src/jungle.peggy"() {
27312
28294
  "use strict";
27313
28295
  peg$subclass2(peg$SyntaxError2, Error);
@@ -27532,7 +28514,7 @@ async function checkManifest(manifest, products) {
27532
28514
  });
27533
28515
  return ok;
27534
28516
  }
27535
- var init_manifest = (0, import_chunk_HHQDDCTP.__esm)({
28517
+ var init_manifest = (0, import_chunk_QFQPBQSO.__esm)({
27536
28518
  "src/manifest.ts"() {
27537
28519
  "use strict";
27538
28520
  init_sdk_util();
@@ -27788,7 +28770,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
27788
28770
  );
27789
28771
  if (!hasProperty(cache.resolvedPaths, resolved)) {
27790
28772
  if (/[*?[\]{}]/.test(resolved)) {
27791
- cache.resolvedPaths[resolved] = (0, import_chunk_HHQDDCTP.globSome)(resolved, () => true);
28773
+ cache.resolvedPaths[resolved] = (0, import_chunk_QFQPBQSO.globSome)(resolved, () => true);
27792
28774
  } else {
27793
28775
  cache.resolvedPaths[resolved] = fs5.stat(resolved).then(() => true).catch(() => false);
27794
28776
  }
@@ -27857,12 +28839,12 @@ async function read_resource_files(targets, cache) {
27857
28839
  if (!hasProperty(resourceGroupPromises, key)) {
27858
28840
  resourceGroupPromises[key] = Promise.all(
27859
28841
  p.qualifier.resourcePath.map(
27860
- (pattern) => (0, import_chunk_HHQDDCTP.globa)(pattern, { mark: true })
28842
+ (pattern) => (0, import_chunk_QFQPBQSO.globa)(pattern, { mark: true })
27861
28843
  )
27862
28844
  ).then(
27863
28845
  (patterns) => Promise.all(
27864
28846
  patterns.flat().map(
27865
- (path7) => path7.endsWith("/") ? (0, import_chunk_HHQDDCTP.globa)(`${path7}**/*.xml`, { mark: true }) : path7
28847
+ (path7) => path7.endsWith("/") ? (0, import_chunk_QFQPBQSO.globa)(`${path7}**/*.xml`, { mark: true }) : path7
27866
28848
  )
27867
28849
  ).then(
27868
28850
  (paths) => Promise.all(
@@ -27926,7 +28908,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
27926
28908
  const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
27927
28909
  const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
27928
28910
  if (filePatterns.length) {
27929
- const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_HHQDDCTP.globa)(p)))).flat();
28911
+ const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_QFQPBQSO.globa)(p)))).flat();
27930
28912
  sourceExcludes.push(...files);
27931
28913
  }
27932
28914
  const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
@@ -28077,15 +29059,15 @@ function identify_optimizer_groups(targets, options) {
28077
29059
  function find_barrels(barrelPath) {
28078
29060
  if (Array.isArray(barrelPath)) {
28079
29061
  return Promise.all(
28080
- barrelPath.map((path7) => (0, import_chunk_HHQDDCTP.globa)(path7, { mark: true }))
29062
+ barrelPath.map((path7) => (0, import_chunk_QFQPBQSO.globa)(path7, { mark: true }))
28081
29063
  ).then((paths) => [
28082
29064
  paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
28083
29065
  ]);
28084
29066
  }
28085
- return (0, import_chunk_HHQDDCTP.globa)(barrelPath, { mark: true }).then(
29067
+ return (0, import_chunk_QFQPBQSO.globa)(barrelPath, { mark: true }).then(
28086
29068
  (paths) => Promise.all(
28087
29069
  paths.map(
28088
- (path7) => path7.endsWith("/") ? (0, import_chunk_HHQDDCTP.globa)(`${path7}**/*.barrel`) : path7
29070
+ (path7) => path7.endsWith("/") ? (0, import_chunk_QFQPBQSO.globa)(`${path7}**/*.barrel`) : path7
28089
29071
  )
28090
29072
  )
28091
29073
  ).then(
@@ -28333,15 +29315,15 @@ async function get_jungle(jungles, options, resources) {
28333
29315
  return result;
28334
29316
  }
28335
29317
  var import_extract_zip;
28336
- var init_jungles = (0, import_chunk_HHQDDCTP.__esm)({
29318
+ var init_jungles = (0, import_chunk_QFQPBQSO.__esm)({
28337
29319
  "src/jungles.ts"() {
28338
29320
  "use strict";
28339
- import_extract_zip = (0, import_chunk_HHQDDCTP.__toESM)(require_extract_zip());
29321
+ import_extract_zip = (0, import_chunk_QFQPBQSO.__toESM)(require_extract_zip());
28340
29322
  init_jungle();
28341
29323
  init_api();
28342
29324
  init_manifest();
28343
29325
  init_sdk_util();
28344
- (0, import_chunk_HHQDDCTP.init_util)();
29326
+ (0, import_chunk_QFQPBQSO.init_util)();
28345
29327
  }
28346
29328
  });
28347
29329
  async function launchSimulator(force = true) {
@@ -28399,7 +29381,7 @@ function simulateProgram(prg, device, test = false, logger2) {
28399
29381
  }
28400
29382
  }
28401
29383
  return getSdkPath().then(
28402
- (sdk) => (0, import_chunk_HHQDDCTP.spawnByLine)(
29384
+ (sdk) => (0, import_chunk_QFQPBQSO.spawnByLine)(
28403
29385
  path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
28404
29386
  args,
28405
29387
  logger2 || ((line) => console.log(line))
@@ -28408,11 +29390,11 @@ function simulateProgram(prg, device, test = false, logger2) {
28408
29390
  })
28409
29391
  );
28410
29392
  }
28411
- var init_launch = (0, import_chunk_HHQDDCTP.__esm)({
29393
+ var init_launch = (0, import_chunk_QFQPBQSO.__esm)({
28412
29394
  "src/launch.ts"() {
28413
29395
  "use strict";
28414
29396
  init_sdk_util();
28415
- (0, import_chunk_HHQDDCTP.init_util)();
29397
+ (0, import_chunk_QFQPBQSO.init_util)();
28416
29398
  }
28417
29399
  });
28418
29400
  function relative_path_no_dotdot(relative2) {
@@ -28531,7 +29513,7 @@ async function createLocalBarrels(targets, options) {
28531
29513
  optBarrelDir
28532
29514
  };
28533
29515
  return promise2.then(
28534
- () => (0, import_chunk_HHQDDCTP.copyRecursiveAsNeeded)(
29516
+ () => (0, import_chunk_QFQPBQSO.copyRecursiveAsNeeded)(
28535
29517
  rawBarrelDir,
28536
29518
  optBarrelDir,
28537
29519
  (src) => !src.endsWith(".mc")
@@ -28809,12 +29791,12 @@ async function generateOptimizedProject(options) {
28809
29791
  async function fileInfoFromConfig(workspace, output, buildConfig, extraExcludes) {
28810
29792
  const paths = (await Promise.all(
28811
29793
  buildConfig.sourcePath?.map(
28812
- (pattern) => (0, import_chunk_HHQDDCTP.globa)(pattern, { cwd: workspace, mark: true })
29794
+ (pattern) => (0, import_chunk_QFQPBQSO.globa)(pattern, { cwd: workspace, mark: true })
28813
29795
  ) || []
28814
29796
  )).flat();
28815
29797
  const files = (await Promise.all(
28816
29798
  paths.map(
28817
- (path7) => path7.endsWith("/") ? (0, import_chunk_HHQDDCTP.globa)(`${path7}**/*.mc`, { cwd: workspace, mark: true }) : path7
29799
+ (path7) => path7.endsWith("/") ? (0, import_chunk_QFQPBQSO.globa)(`${path7}**/*.mc`, { cwd: workspace, mark: true }) : path7
28818
29800
  )
28819
29801
  )).flat().filter(
28820
29802
  (file) => file.endsWith(".mc") && !path4.relative(workspace, file).startsWith("bin") && (!buildConfig.sourceExcludes || !buildConfig.sourceExcludes.includes(file))
@@ -28897,7 +29879,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28897
29879
  );
28898
29880
  barrelFnMaps.forEach((barrelFnMap) => Object.assign(fnMap, barrelFnMap));
28899
29881
  }
28900
- const actualOptimizedFiles = (await (0, import_chunk_HHQDDCTP.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
29882
+ const actualOptimizedFiles = (await (0, import_chunk_QFQPBQSO.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
28901
29883
  const {
28902
29884
  hasTests,
28903
29885
  diagnostics: prevDiagnostics,
@@ -28908,13 +29890,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28908
29890
  if (hasTests != null && !config.checkBuildPragmas && configOptionsToCheck.every(
28909
29891
  (option) => prevOptions[option] === config[option]
28910
29892
  ) && actualOptimizedFiles.length === Object.values(fnMap).length && Object.values(fnMap).map((v) => v.output).sort().every((f, i) => f === actualOptimizedFiles[i])) {
28911
- const source_time = await (0, import_chunk_HHQDDCTP.last_modified)(
29893
+ const source_time = await (0, import_chunk_QFQPBQSO.last_modified)(
28912
29894
  Object.keys(fnMap).concat(dependencyFiles)
28913
29895
  );
28914
- const opt_time = await (0, import_chunk_HHQDDCTP.first_modified)(
29896
+ const opt_time = await (0, import_chunk_QFQPBQSO.first_modified)(
28915
29897
  Object.values(fnMap).map((v) => v.output)
28916
29898
  );
28917
- if (source_time < opt_time && 1680119325581 < opt_time) {
29899
+ if (source_time < opt_time && 1680389221493 < opt_time) {
28918
29900
  return { hasTests, diagnostics: prevDiagnostics };
28919
29901
  }
28920
29902
  }
@@ -28946,7 +29928,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28946
29928
  JSON.stringify({
28947
29929
  hasTests: hasTests2,
28948
29930
  diagnostics,
28949
- optimizerVersion: "1.1.22",
29931
+ optimizerVersion: "1.1.24",
28950
29932
  ...Object.fromEntries(
28951
29933
  configOptionsToCheck.map((option) => [option, config[option]])
28952
29934
  )
@@ -29091,7 +30073,7 @@ async function generateApiMirTests(options) {
29091
30073
  return fs6.writeFile(`${workspace}/source/apiTest.mc`, source);
29092
30074
  }
29093
30075
  var defaultConfig, configOptionsToCheck;
29094
- var init_optimizer = (0, import_chunk_HHQDDCTP.__esm)({
30076
+ var init_optimizer = (0, import_chunk_QFQPBQSO.__esm)({
29095
30077
  "src/optimizer.ts"() {
29096
30078
  init_api();
29097
30079
  init_build();
@@ -29104,7 +30086,7 @@ var init_optimizer = (0, import_chunk_HHQDDCTP.__esm)({
29104
30086
  init_could_be();
29105
30087
  init_interp();
29106
30088
  init_sub_type();
29107
- (0, import_chunk_HHQDDCTP.init_util)();
30089
+ (0, import_chunk_QFQPBQSO.init_util)();
29108
30090
  init_worker_pool();
29109
30091
  init_optimizer_types();
29110
30092
  init_types();
@@ -29145,7 +30127,7 @@ async function performTask(task) {
29145
30127
  return handler(task.data);
29146
30128
  }
29147
30129
  var workerTaskHandlers;
29148
- var init_worker_task = (0, import_chunk_HHQDDCTP.__esm)({
30130
+ var init_worker_task = (0, import_chunk_QFQPBQSO.__esm)({
29149
30131
  "src/worker-task.ts"() {
29150
30132
  "use strict";
29151
30133
  init_optimizer();
@@ -29225,7 +30207,7 @@ function runTaskInPool(task) {
29225
30207
  return performTask(task);
29226
30208
  }
29227
30209
  var kTaskInfo, kWorkerFreedEvent, WorkerPoolTaskInfo, WorkerPool, pool;
29228
- var init_worker_pool = (0, import_chunk_HHQDDCTP.__esm)({
30210
+ var init_worker_pool = (0, import_chunk_QFQPBQSO.__esm)({
29229
30211
  "src/worker-pool.ts"() {
29230
30212
  "use strict";
29231
30213
  init_worker_task();
@@ -29368,7 +30350,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
29368
30350
  }
29369
30351
  function optimizeProgramBuffer(filepath, view, debugXml, key, config) {
29370
30352
  const { sections } = readPrgWithOffsets(view);
29371
- (0, import_chunk_HHQDDCTP.logger)("readprg", 5, sections);
30353
+ (0, import_chunk_QFQPBQSO.logger)("readprg", 5, sections);
29372
30354
  const symbolTable = new SymbolTable();
29373
30355
  if (hasProperty(sections, 1461170197 .toString())) {
29374
30356
  symbolTable.parse(sections[
@@ -29410,7 +30392,8 @@ function optimizeProgramBuffer(filepath, view, debugXml, key, config) {
29410
30392
  exceptionsMap,
29411
30393
  key,
29412
30394
  debugXml,
29413
- nextOffset: (bytecodes[bytecodes.length - 1]?.offset ?? 0) + (bytecodes[bytecodes.length - 1]?.size ?? 0)
30395
+ nextOffset: (bytecodes[bytecodes.length - 1]?.offset ?? 0) + (bytecodes[bytecodes.length - 1]?.size ?? 0),
30396
+ nextLocalId: 0
29414
30397
  };
29415
30398
  optimizeBytecode(context);
29416
30399
  const signature = getPrgSignature(context);
@@ -29640,11 +30623,11 @@ function optimizePrgAndDebug(prgName, prgBuffer, prgOffset, prgLength, xmlName,
29640
30623
  });
29641
30624
  }
29642
30625
  var yauzl, yazl;
29643
- var init_readprg = (0, import_chunk_HHQDDCTP.__esm)({
30626
+ var init_readprg = (0, import_chunk_QFQPBQSO.__esm)({
29644
30627
  "src/readprg.ts"() {
29645
30628
  "use strict";
29646
- yauzl = (0, import_chunk_HHQDDCTP.__toESM)(require_yauzl());
29647
- yazl = (0, import_chunk_HHQDDCTP.__toESM)(require_yazl());
30629
+ yauzl = (0, import_chunk_QFQPBQSO.__toESM)(require_yauzl());
30630
+ yazl = (0, import_chunk_QFQPBQSO.__toESM)(require_yazl());
29648
30631
  init_ast();
29649
30632
  init_bytecode();
29650
30633
  init_data();
@@ -29655,7 +30638,7 @@ var init_readprg = (0, import_chunk_HHQDDCTP.__esm)({
29655
30638
  init_signer();
29656
30639
  init_symbols();
29657
30640
  init_sdk_util();
29658
- (0, import_chunk_HHQDDCTP.init_util)();
30641
+ (0, import_chunk_QFQPBQSO.init_util)();
29659
30642
  init_worker_pool();
29660
30643
  }
29661
30644
  });
@@ -29667,7 +30650,7 @@ function getSdkPath() {
29667
30650
  });
29668
30651
  }
29669
30652
  async function getDeviceInfo() {
29670
- const files = await (0, import_chunk_HHQDDCTP.globa)(`${connectiq}/Devices/*/compiler.json`);
30653
+ const files = await (0, import_chunk_QFQPBQSO.globa)(`${connectiq}/Devices/*/compiler.json`);
29671
30654
  if (!files.length) {
29672
30655
  throw new Error(
29673
30656
  `No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
@@ -29732,9 +30715,9 @@ async function getFunctionDocumentation() {
29732
30715
  return entries;
29733
30716
  }
29734
30717
  var isWin, appSupport, connectiq;
29735
- var init_sdk_util = (0, import_chunk_HHQDDCTP.__esm)({
30718
+ var init_sdk_util = (0, import_chunk_QFQPBQSO.__esm)({
29736
30719
  "src/sdk-util.ts"() {
29737
- (0, import_chunk_HHQDDCTP.init_util)();
30720
+ (0, import_chunk_QFQPBQSO.init_util)();
29738
30721
  init_xml_util();
29739
30722
  init_readprg();
29740
30723
  init_bytecode();