@markw65/monkeyc-optimizer 1.1.64 → 1.1.65

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_VZBYW6QS_exports = {};
30
- __export(chunk_VZBYW6QS_exports, {
29
+ var chunk_MDTDXRQB_exports = {};
30
+ __export(chunk_MDTDXRQB_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -134,8 +134,8 @@ __export(chunk_VZBYW6QS_exports, {
134
134
  visitorNode: () => visitorNode,
135
135
  xml_util_exports: () => xml_util_exports
136
136
  });
137
- module.exports = __toCommonJS(chunk_VZBYW6QS_exports);
138
- var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
137
+ module.exports = __toCommonJS(chunk_MDTDXRQB_exports);
138
+ var import_chunk_67LU4GPQ = require("./chunk-67LU4GPQ.cjs");
139
139
  var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
140
140
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
141
141
  var import_node_assert = __toESM(require("node:assert"));
@@ -7319,9 +7319,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
7319
7319
  );
7320
7320
  }
7321
7321
  } else {
7322
- (0, import_chunk_SG7ODKRM.forEach)(events, (e) => e.mayThrow = false);
7322
+ (0, import_chunk_67LU4GPQ.forEach)(events, (e) => e.mayThrow = false);
7323
7323
  }
7324
- (0, import_chunk_SG7ODKRM.forEach)(events, (event) => {
7324
+ (0, import_chunk_67LU4GPQ.forEach)(events, (event) => {
7325
7325
  if (event.mayThrow) {
7326
7326
  for (let i = localState.stack.length; i--; ) {
7327
7327
  const target = localState.stack[i].throw;
@@ -7466,7 +7466,7 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7466
7466
  "src/control-flow.ts"() {
7467
7467
  "use strict";
7468
7468
  (0, import_chunk_MBTLUWXR.init_ast)();
7469
- (0, import_chunk_SG7ODKRM.init_util)();
7469
+ (0, import_chunk_67LU4GPQ.init_util)();
7470
7470
  Terminals = {
7471
7471
  BreakStatement: "break",
7472
7472
  ContinueStatement: "continue",
@@ -7496,12 +7496,12 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7496
7496
  if (!from.succs) {
7497
7497
  from.succs = [to];
7498
7498
  } else {
7499
- (0, import_chunk_SG7ODKRM.pushUnique)(from.succs, to);
7499
+ (0, import_chunk_67LU4GPQ.pushUnique)(from.succs, to);
7500
7500
  }
7501
7501
  if (!to.preds) {
7502
7502
  to.preds = [from];
7503
7503
  } else {
7504
- (0, import_chunk_SG7ODKRM.pushUnique)(to.preds, from);
7504
+ (0, import_chunk_67LU4GPQ.pushUnique)(to.preds, from);
7505
7505
  }
7506
7506
  }
7507
7507
  newBlock(block) {
@@ -7855,8 +7855,8 @@ function mergeObjectValues(to, from) {
7855
7855
  function mergeStateDecls(to, from) {
7856
7856
  let changed = false;
7857
7857
  let result = to;
7858
- (0, import_chunk_SG7ODKRM.forEach)(from, (v) => {
7859
- if ((0, import_chunk_SG7ODKRM.some)(to, (t) => t === v)) {
7858
+ (0, import_chunk_67LU4GPQ.forEach)(from, (v) => {
7859
+ if ((0, import_chunk_67LU4GPQ.some)(to, (t) => t === v)) {
7860
7860
  return;
7861
7861
  }
7862
7862
  if (Array.isArray(result)) {
@@ -8023,7 +8023,7 @@ var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
8023
8023
  "use strict";
8024
8024
  (0, import_chunk_MBTLUWXR.init_ast)();
8025
8025
  init_data_flow();
8026
- (0, import_chunk_SG7ODKRM.init_util)();
8026
+ (0, import_chunk_67LU4GPQ.init_util)();
8027
8027
  init_could_be();
8028
8028
  init_intersection_type();
8029
8029
  init_sub_type();
@@ -8038,7 +8038,7 @@ function expandTypedef(t) {
8038
8038
  );
8039
8039
  const tExpanded = cloneType(t);
8040
8040
  clearValuesUnder(tExpanded, 262144, true);
8041
- (0, import_chunk_SG7ODKRM.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
8041
+ (0, import_chunk_67LU4GPQ.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
8042
8042
  return tExpanded;
8043
8043
  }
8044
8044
  function intersectEnum(t, e) {
@@ -8232,9 +8232,9 @@ function intersectionValue(pair) {
8232
8232
  case 4096:
8233
8233
  case 8192: {
8234
8234
  const common = [];
8235
- (0, import_chunk_SG7ODKRM.forEach)(
8235
+ (0, import_chunk_67LU4GPQ.forEach)(
8236
8236
  pair.avalue,
8237
- (sna) => (0, import_chunk_SG7ODKRM.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
8237
+ (sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
8238
8238
  );
8239
8239
  if (!common.length)
8240
8240
  return null;
@@ -8242,9 +8242,9 @@ function intersectionValue(pair) {
8242
8242
  }
8243
8243
  case 16384: {
8244
8244
  const common = [];
8245
- (0, import_chunk_SG7ODKRM.forEach)(pair.avalue, (sna) => {
8245
+ (0, import_chunk_67LU4GPQ.forEach)(pair.avalue, (sna) => {
8246
8246
  const superA = getSuperClasses(sna);
8247
- (0, import_chunk_SG7ODKRM.forEach)(pair.bvalue, (snb) => {
8247
+ (0, import_chunk_67LU4GPQ.forEach)(pair.bvalue, (snb) => {
8248
8248
  if (sna === snb || superA && superA.has(snb)) {
8249
8249
  common.push(sna);
8250
8250
  }
@@ -8490,7 +8490,7 @@ function restrictExactTypesByEquality(a, b) {
8490
8490
  }
8491
8491
  case 262144:
8492
8492
  return restrictByEquality(
8493
- (0, import_chunk_SG7ODKRM.reduce)(
8493
+ (0, import_chunk_67LU4GPQ.reduce)(
8494
8494
  a.value,
8495
8495
  (cur, decl) => {
8496
8496
  unionInto(cur, decl.resolvedType);
@@ -8557,7 +8557,7 @@ var init_intersection_type = (0, import_chunk_ABYVSU2C.__esm)({
8557
8557
  "use strict";
8558
8558
  init_api();
8559
8559
  init_data_flow();
8560
- (0, import_chunk_SG7ODKRM.init_util)();
8560
+ (0, import_chunk_67LU4GPQ.init_util)();
8561
8561
  init_could_be();
8562
8562
  init_interp();
8563
8563
  init_types();
@@ -8671,14 +8671,14 @@ function subtypeOfValue(pair) {
8671
8671
  case 8192: {
8672
8672
  const asd = pair.avalue;
8673
8673
  const bsd = pair.bvalue;
8674
- return (0, import_chunk_SG7ODKRM.some)(asd, (sna) => (0, import_chunk_SG7ODKRM.some)(bsd, (snb) => sna === snb));
8674
+ return (0, import_chunk_67LU4GPQ.some)(asd, (sna) => (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => sna === snb));
8675
8675
  }
8676
8676
  case 16384: {
8677
8677
  const asd = pair.avalue;
8678
8678
  const bsd = pair.bvalue;
8679
- return (0, import_chunk_SG7ODKRM.every)(asd, (sna) => {
8679
+ return (0, import_chunk_67LU4GPQ.every)(asd, (sna) => {
8680
8680
  const superA = getSuperClasses(sna);
8681
- return (0, import_chunk_SG7ODKRM.some)(bsd, (snb) => {
8681
+ return (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => {
8682
8682
  if (sna === snb || superA && superA.has(snb)) {
8683
8683
  return true;
8684
8684
  }
@@ -8714,7 +8714,7 @@ var init_sub_type = (0, import_chunk_ABYVSU2C.__esm)({
8714
8714
  "use strict";
8715
8715
  init_api();
8716
8716
  init_data_flow();
8717
- (0, import_chunk_SG7ODKRM.init_util)();
8717
+ (0, import_chunk_67LU4GPQ.init_util)();
8718
8718
  init_could_be();
8719
8719
  init_intersection_type();
8720
8720
  init_types();
@@ -9135,13 +9135,13 @@ function isTypeStateKey(decl) {
9135
9135
  return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
9136
9136
  }
9137
9137
  function declIsLocal(decl) {
9138
- return (0, import_chunk_SG7ODKRM.some)(
9138
+ return (0, import_chunk_67LU4GPQ.some)(
9139
9139
  decl,
9140
9140
  (d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
9141
9141
  );
9142
9142
  }
9143
9143
  function declIsNonLocal(decl) {
9144
- return (0, import_chunk_SG7ODKRM.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
9144
+ return (0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
9145
9145
  }
9146
9146
  function localDeclName(decl) {
9147
9147
  if (Array.isArray(decl))
@@ -9154,12 +9154,12 @@ function localDeclName(decl) {
9154
9154
  case "VariableDeclarator":
9155
9155
  return variableDeclarationName(decl.node.id);
9156
9156
  }
9157
- throw new import_chunk_SG7ODKRM.AwaitedError(
9157
+ throw new import_chunk_67LU4GPQ.AwaitedError(
9158
9158
  declFullName(decl).then((declStr) => `Invalid local decl: ${declStr}`)
9159
9159
  );
9160
9160
  }
9161
9161
  function tsKey(key) {
9162
- return `${(0, import_chunk_SG7ODKRM.map)(key, (k) => {
9162
+ return `${(0, import_chunk_67LU4GPQ.map)(key, (k) => {
9163
9163
  if (k.type === "Literal") {
9164
9164
  return k.raw;
9165
9165
  } else if (isStateNode(k)) {
@@ -9178,7 +9178,7 @@ function sourceLocation(loc) {
9178
9178
  return loc ? `${loc.source || "??"}:${loc.start.line}:${loc.start.column}` : "??";
9179
9179
  }
9180
9180
  function printBlockHeader(block) {
9181
- (0, import_chunk_SG7ODKRM.log)(
9181
+ (0, import_chunk_67LU4GPQ.log)(
9182
9182
  block.order,
9183
9183
  `(${block.node?.loc?.source || "??"}:${block.node?.loc?.start.line || "??"})`,
9184
9184
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
@@ -9192,10 +9192,10 @@ function describeEvent(event) {
9192
9192
  ).then((desc) => `${event.type}: ${desc}`);
9193
9193
  }
9194
9194
  function printBlockEvents(block, extra) {
9195
- (0, import_chunk_SG7ODKRM.log)("Events:");
9196
- (0, import_chunk_SG7ODKRM.forEach)(
9195
+ (0, import_chunk_67LU4GPQ.log)("Events:");
9196
+ (0, import_chunk_67LU4GPQ.forEach)(
9197
9197
  block.events,
9198
- (event) => (0, import_chunk_SG7ODKRM.log)(
9198
+ (event) => (0, import_chunk_67LU4GPQ.log)(
9199
9199
  describeEvent(event).then(
9200
9200
  (eventStr) => ` ${eventStr} ${extra ? extra(event) : ""}`
9201
9201
  )
@@ -9203,7 +9203,7 @@ function printBlockEvents(block, extra) {
9203
9203
  );
9204
9204
  }
9205
9205
  function printBlockTrailer(block) {
9206
- (0, import_chunk_SG7ODKRM.log)(
9206
+ (0, import_chunk_67LU4GPQ.log)(
9207
9207
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
9208
9208
  );
9209
9209
  }
@@ -9335,7 +9335,7 @@ var init_type_flow_util = (0, import_chunk_ABYVSU2C.__esm)({
9335
9335
  "use strict";
9336
9336
  init_api();
9337
9337
  init_data_flow();
9338
- (0, import_chunk_SG7ODKRM.init_util)();
9338
+ (0, import_chunk_67LU4GPQ.init_util)();
9339
9339
  init_intersection_type();
9340
9340
  init_sub_type();
9341
9341
  init_types();
@@ -9389,7 +9389,7 @@ function calleeObjectType(istate, callee) {
9389
9389
  }
9390
9390
  function checkCallArgs(istate, node, callees, args) {
9391
9391
  const allDiags = [];
9392
- const resultType = (0, import_chunk_SG7ODKRM.reduce)(
9392
+ const resultType = (0, import_chunk_67LU4GPQ.reduce)(
9393
9393
  callees,
9394
9394
  (result, cur) => {
9395
9395
  const curDiags = [];
@@ -9548,7 +9548,7 @@ function isOverride(cur, funcs) {
9548
9548
  const cls = cur.stack?.[cur.stack.length - 1]?.sn;
9549
9549
  if (cls?.type === "ClassDeclaration" && cls.superClasses) {
9550
9550
  const supers = getSuperClasses(cls);
9551
- if (supers && (0, import_chunk_SG7ODKRM.some)(funcs, (func) => {
9551
+ if (supers && (0, import_chunk_67LU4GPQ.some)(funcs, (func) => {
9552
9552
  if (func === cur)
9553
9553
  return false;
9554
9554
  const fcls = func.stack?.[func.stack.length - 1].sn;
@@ -10034,7 +10034,7 @@ var init_interp_call = (0, import_chunk_ABYVSU2C.__esm)({
10034
10034
  "use strict";
10035
10035
  init_optimizer_types();
10036
10036
  init_api();
10037
- (0, import_chunk_SG7ODKRM.init_util)();
10037
+ (0, import_chunk_67LU4GPQ.init_util)();
10038
10038
  init_interp();
10039
10039
  init_sub_type();
10040
10040
  init_types();
@@ -11159,7 +11159,7 @@ function mustBeIdentical(a, b) {
11159
11159
  return false;
11160
11160
  }
11161
11161
  function isByteArrayData(objectData) {
11162
- return objectData.klass.value && (0, import_chunk_SG7ODKRM.every)(
11162
+ return objectData.klass.value && (0, import_chunk_67LU4GPQ.every)(
11163
11163
  objectData.klass.value,
11164
11164
  (klass) => klass.fullName === "$.Toybox.Lang.ByteArray"
11165
11165
  );
@@ -11171,7 +11171,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
11171
11171
  (0, import_chunk_MBTLUWXR.init_ast)();
11172
11172
  init_data_flow();
11173
11173
  init_optimizer_types();
11174
- (0, import_chunk_SG7ODKRM.init_util)();
11174
+ (0, import_chunk_67LU4GPQ.init_util)();
11175
11175
  init_could_be();
11176
11176
  init_interp_binary();
11177
11177
  init_interp_call();
@@ -11402,7 +11402,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
11402
11402
  );
11403
11403
  if (value2) {
11404
11404
  const a = [];
11405
- (0, import_chunk_SG7ODKRM.forEach)(value2, (v) => {
11405
+ (0, import_chunk_67LU4GPQ.forEach)(value2, (v) => {
11406
11406
  if (v !== sn)
11407
11407
  a.push(v);
11408
11408
  });
@@ -11569,7 +11569,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
11569
11569
  return {
11570
11570
  type: 512,
11571
11571
  value: type.elements.map(
11572
- (cur) => typeFromTypespec(state, cur)
11572
+ (cur) => typeFromTypespec(state, cur, stack)
11573
11573
  )
11574
11574
  };
11575
11575
  }
@@ -11579,7 +11579,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
11579
11579
  const prop = property;
11580
11580
  fields.set(
11581
11581
  objectLiteralKeyFromKeyExpr(prop.left),
11582
- typeFromTypespec(state, prop.right)
11582
+ typeFromTypespec(state, prop.right, stack)
11583
11583
  );
11584
11584
  });
11585
11585
  return { type: 1024, value: fields };
@@ -11894,7 +11894,7 @@ function mustBeFalse(arg) {
11894
11894
  return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
11895
11895
  }
11896
11896
  function display(type) {
11897
- const names = (v, fn) => (0, import_chunk_SG7ODKRM.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
11897
+ const names = (v, fn) => (0, import_chunk_67LU4GPQ.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
11898
11898
  const parts = [];
11899
11899
  const displayOne = (tv) => {
11900
11900
  switch (tv.type) {
@@ -12095,7 +12095,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
12095
12095
  init_data_flow();
12096
12096
  init_api();
12097
12097
  (0, import_chunk_MBTLUWXR.init_ast)();
12098
- (0, import_chunk_SG7ODKRM.init_util)();
12098
+ (0, import_chunk_67LU4GPQ.init_util)();
12099
12099
  init_interp();
12100
12100
  init_union_type();
12101
12101
  init_intersection_type();
@@ -12155,7 +12155,7 @@ function couldBeHelper(a, b, shallow) {
12155
12155
  262144
12156
12156
  /* Typedef */
12157
12157
  );
12158
- return typedef && (0, import_chunk_SG7ODKRM.some)(typedef, (td) => {
12158
+ return typedef && (0, import_chunk_67LU4GPQ.some)(typedef, (td) => {
12159
12159
  if (!td.resolvedType) {
12160
12160
  throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
12161
12161
  }
@@ -12227,15 +12227,15 @@ function couldBeValue(pair, shallow) {
12227
12227
  }
12228
12228
  case 4096:
12229
12229
  case 8192: {
12230
- return (0, import_chunk_SG7ODKRM.some)(
12230
+ return (0, import_chunk_67LU4GPQ.some)(
12231
12231
  pair.avalue,
12232
- (sna) => (0, import_chunk_SG7ODKRM.some)(pair.bvalue, (snb) => sna === snb)
12232
+ (sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb)
12233
12233
  );
12234
12234
  }
12235
12235
  case 16384: {
12236
- return (0, import_chunk_SG7ODKRM.some)(pair.avalue, (sna) => {
12236
+ return (0, import_chunk_67LU4GPQ.some)(pair.avalue, (sna) => {
12237
12237
  const superA = getSuperClasses(sna);
12238
- return (0, import_chunk_SG7ODKRM.some)(pair.bvalue, (snb) => {
12238
+ return (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => {
12239
12239
  if (sna === snb || superA && superA.has(snb)) {
12240
12240
  return true;
12241
12241
  }
@@ -12268,7 +12268,7 @@ var init_could_be = (0, import_chunk_ABYVSU2C.__esm)({
12268
12268
  "use strict";
12269
12269
  init_api();
12270
12270
  init_data_flow();
12271
- (0, import_chunk_SG7ODKRM.init_util)();
12271
+ (0, import_chunk_67LU4GPQ.init_util)();
12272
12272
  init_types();
12273
12273
  }
12274
12274
  });
@@ -12375,7 +12375,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12375
12375
  }
12376
12376
  addAnt(curState.partiallyAnticipated, key, node);
12377
12377
  if (logThisRun) {
12378
- (0, import_chunk_SG7ODKRM.log)(
12378
+ (0, import_chunk_67LU4GPQ.log)(
12379
12379
  ` antrefs: ${curState.partiallyAnticipated.get(key) !== false} ${curState.anticipated.get(key) !== false}`
12380
12380
  );
12381
12381
  }
@@ -12398,7 +12398,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12398
12398
  const curState = cloneState(blockStates[top.order]);
12399
12399
  if (logThisRun) {
12400
12400
  printBlockHeader(top);
12401
- curState.dead.forEach((decl) => (0, import_chunk_SG7ODKRM.log)(` - anticipated: ${tsKey(decl)}`));
12401
+ curState.dead.forEach((decl) => (0, import_chunk_67LU4GPQ.log)(` - anticipated: ${tsKey(decl)}`));
12402
12402
  }
12403
12403
  if (top.events) {
12404
12404
  for (let i = top.events.length; i--; ) {
@@ -12410,12 +12410,12 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12410
12410
  case "ref":
12411
12411
  if (isTypeStateKey(event.decl)) {
12412
12412
  if (logThisRun) {
12413
- (0, import_chunk_SG7ODKRM.log)(
12413
+ (0, import_chunk_67LU4GPQ.log)(
12414
12414
  describeEvent(event).then(
12415
12415
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12416
12416
  )
12417
12417
  );
12418
- (0, import_chunk_SG7ODKRM.log)(` kill => ${tsKey(event.decl)}`);
12418
+ (0, import_chunk_67LU4GPQ.log)(` kill => ${tsKey(event.decl)}`);
12419
12419
  }
12420
12420
  copyPropRef(curState, event.decl, event.node);
12421
12421
  curState.dead.delete(event.decl);
@@ -12424,7 +12424,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12424
12424
  case "def":
12425
12425
  if (isTypeStateKey(event.decl) && (event.node.type !== "VariableDeclarator" || event.node.init)) {
12426
12426
  if (logThisRun) {
12427
- (0, import_chunk_SG7ODKRM.log)(
12427
+ (0, import_chunk_67LU4GPQ.log)(
12428
12428
  describeEvent(event).then(
12429
12429
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12430
12430
  )
@@ -12440,7 +12440,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12440
12440
  const pant = curState.partiallyAnticipated.get(event.decl);
12441
12441
  if (pant) {
12442
12442
  if (logThisRun) {
12443
- (0, import_chunk_SG7ODKRM.log)(
12443
+ (0, import_chunk_67LU4GPQ.log)(
12444
12444
  ` is copy-prop-candidate ${curState.anticipated?.get(event.decl) === pant}`
12445
12445
  );
12446
12446
  }
@@ -12472,7 +12472,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12472
12472
  if (assignNode) {
12473
12473
  curState.dead.add(event.decl);
12474
12474
  if (logThisRun) {
12475
- (0, import_chunk_SG7ODKRM.log)(` anticipated => ${tsKey(event.decl)}`);
12475
+ (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12476
12476
  }
12477
12477
  } else if (event.node.type === "UpdateExpression") {
12478
12478
  copyPropRef(curState, event.decl, event.node.argument);
@@ -12483,7 +12483,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12483
12483
  if (isTypeStateKey(event.decl)) {
12484
12484
  curState.dead.add(event.decl);
12485
12485
  if (logThisRun) {
12486
- (0, import_chunk_SG7ODKRM.log)(` anticipated => ${tsKey(event.decl)}`);
12486
+ (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12487
12487
  }
12488
12488
  }
12489
12489
  break;
@@ -12546,9 +12546,9 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
12546
12546
  if (!deadStores.size)
12547
12547
  return { changes: false, copyPropStores };
12548
12548
  if (logThisRun) {
12549
- (0, import_chunk_SG7ODKRM.log)("====== Dead Stores =====");
12549
+ (0, import_chunk_67LU4GPQ.log)("====== Dead Stores =====");
12550
12550
  deadStores.forEach(
12551
- (dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_SG7ODKRM.log)(
12551
+ (dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_67LU4GPQ.log)(
12552
12552
  formatAst(dead).then(
12553
12553
  (deadStr) => `${deadStr} (${sourceLocation(dead.loc)})`
12554
12554
  )
@@ -12603,7 +12603,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
12603
12603
  init_control_flow();
12604
12604
  init_data_flow();
12605
12605
  init_inliner();
12606
- (0, import_chunk_SG7ODKRM.init_util)();
12606
+ (0, import_chunk_67LU4GPQ.init_util)();
12607
12607
  init_minimize_locals();
12608
12608
  init_type_flow_util();
12609
12609
  }
@@ -12968,13 +12968,13 @@ function typeStateEntry(value2, key) {
12968
12968
  return `${tsKey(key)} = ${display(value2.curType)}`;
12969
12969
  }
12970
12970
  function printBlockState(block, state, indent = "") {
12971
- (0, import_chunk_SG7ODKRM.log)(indent + "State:");
12971
+ (0, import_chunk_67LU4GPQ.log)(indent + "State:");
12972
12972
  if (!state) {
12973
- (0, import_chunk_SG7ODKRM.log)(indent + "Not visited!");
12973
+ (0, import_chunk_67LU4GPQ.log)(indent + "Not visited!");
12974
12974
  return;
12975
12975
  }
12976
12976
  state.map.forEach((value2, key) => {
12977
- (0, import_chunk_SG7ODKRM.log)(
12977
+ (0, import_chunk_67LU4GPQ.log)(
12978
12978
  `${indent} - ${typeStateEntry(value2, key)}${value2.equivSet ? ` [(${Array.from(value2.equivSet).map(tsKey).join(", ")})]` : ""}`
12979
12979
  );
12980
12980
  });
@@ -13181,7 +13181,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13181
13181
  type: 0
13182
13182
  /* Never */
13183
13183
  };
13184
- (0, import_chunk_SG7ODKRM.forEach)(avalue, (v) => unionInto(n, v));
13184
+ (0, import_chunk_67LU4GPQ.forEach)(avalue, (v) => unionInto(n, v));
13185
13185
  next = n;
13186
13186
  }
13187
13187
  } else {
@@ -13286,7 +13286,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13286
13286
  }
13287
13287
  if (!isStatic && selfClassDecl) {
13288
13288
  const baseObj = getObjectValue(baseElem.type);
13289
- if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_SG7ODKRM.some)(
13289
+ if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_67LU4GPQ.some)(
13290
13290
  baseObj.klass.value,
13291
13291
  (cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
13292
13292
  )) {
@@ -13331,7 +13331,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13331
13331
  return [cur, updateAny];
13332
13332
  }
13333
13333
  function typeConstraint(decls, blockState) {
13334
- return (0, import_chunk_SG7ODKRM.reduce)(
13334
+ return (0, import_chunk_67LU4GPQ.reduce)(
13335
13335
  decls,
13336
13336
  (cur, decl) => {
13337
13337
  if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
@@ -13427,9 +13427,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13427
13427
  stack: [],
13428
13428
  func
13429
13429
  };
13430
- const modifiableDecl = (decls, callees) => (0, import_chunk_SG7ODKRM.some)(
13430
+ const modifiableDecl = (decls, callees) => (0, import_chunk_67LU4GPQ.some)(
13431
13431
  decls,
13432
- (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_SG7ODKRM.some)(callees, (callee) => functionMayModify(state, callee, decl)))
13432
+ (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_67LU4GPQ.some)(callees, (callee) => functionMayModify(state, callee, decl)))
13433
13433
  );
13434
13434
  const mergeSuccState = (top, curState) => {
13435
13435
  top.succs?.forEach((succ) => {
@@ -13438,7 +13438,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13438
13438
  }
13439
13439
  if (mergeTypeState(blockStates, succ.order, curState, nodeCopyProp)) {
13440
13440
  if (logThisRun) {
13441
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${succ.order}`);
13441
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${succ.order}`);
13442
13442
  }
13443
13443
  queue.enqueue(succ);
13444
13444
  }
@@ -13448,7 +13448,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13448
13448
  const calleeObj = getStateType(curState, calleeObjDecl);
13449
13449
  let calleeResult = null;
13450
13450
  let effectFree = true;
13451
- (0, import_chunk_SG7ODKRM.forEach)(callees, (callee) => {
13451
+ (0, import_chunk_67LU4GPQ.forEach)(callees, (callee) => {
13452
13452
  const info = sysCallInfo(istate.state, callee);
13453
13453
  if (!info) {
13454
13454
  effectFree = false;
@@ -13725,7 +13725,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13725
13725
  });
13726
13726
  } else {
13727
13727
  if (logThisRun) {
13728
- (0, import_chunk_SG7ODKRM.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
13728
+ (0, import_chunk_67LU4GPQ.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
13729
13729
  printBlockState(top, sTrue || curState, " >true ");
13730
13730
  }
13731
13731
  if (mergeTypeState(
@@ -13735,7 +13735,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13735
13735
  nodeCopyProp
13736
13736
  )) {
13737
13737
  if (logThisRun) {
13738
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13738
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13739
13739
  }
13740
13740
  queue.enqueue(trueSucc);
13741
13741
  }
@@ -13747,7 +13747,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13747
13747
  });
13748
13748
  } else {
13749
13749
  if (logThisRun) {
13750
- (0, import_chunk_SG7ODKRM.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
13750
+ (0, import_chunk_67LU4GPQ.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
13751
13751
  printBlockState(top, sFalse || curState, " >false ");
13752
13752
  }
13753
13753
  if (mergeTypeState(
@@ -13757,7 +13757,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13757
13757
  nodeCopyProp
13758
13758
  )) {
13759
13759
  if (logThisRun) {
13760
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13760
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13761
13761
  }
13762
13762
  queue.enqueue(falseSucc);
13763
13763
  }
@@ -13832,7 +13832,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13832
13832
  }
13833
13833
  }
13834
13834
  if (logThisRun) {
13835
- (0, import_chunk_SG7ODKRM.log)(
13835
+ (0, import_chunk_67LU4GPQ.log)(
13836
13836
  describeEvent(event).then(
13837
13837
  (eventStr) => ` ${eventStr} == ${display(curEntry.curType)}`
13838
13838
  )
@@ -13842,7 +13842,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13842
13842
  }
13843
13843
  case "mod": {
13844
13844
  if (logThisRun) {
13845
- (0, import_chunk_SG7ODKRM.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13845
+ (0, import_chunk_67LU4GPQ.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13846
13846
  }
13847
13847
  modInterference(curState, event, true, (callees, calleeObj) => {
13848
13848
  clearRelatedCopyPropEvents(curState, null, nodeCopyProp);
@@ -13858,7 +13858,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13858
13858
  );
13859
13859
  }
13860
13860
  }
13861
- if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_SG7ODKRM.some)(callees, (callee) => inlineRequested(state, callee))) {
13861
+ if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_67LU4GPQ.some)(callees, (callee) => inlineRequested(state, callee))) {
13862
13862
  event.node.arguments.forEach((arg) => {
13863
13863
  const def = nodeCopyProp.get(arg);
13864
13864
  if (def && nodeCopyProp.get(def) !== false) {
@@ -13870,7 +13870,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13870
13870
  let calleeEffects;
13871
13871
  curState.map.forEach((tsv, decl) => {
13872
13872
  let type = tsv.curType;
13873
- if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_SG7ODKRM.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
13873
+ if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
13874
13874
  return;
13875
13875
  }
13876
13876
  if (modifiableDecl(decl, callees)) {
@@ -13885,7 +13885,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13885
13885
  curState.map.set(decl, {
13886
13886
  curType: typeConstraint(decl, curState)
13887
13887
  });
13888
- } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_SG7ODKRM.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
13888
+ } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_67LU4GPQ.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
13889
13889
  if (type.value != null && type.type & 32768) {
13890
13890
  const odata = getObjectValue(tsv.curType);
13891
13891
  if (odata?.obj) {
@@ -13953,7 +13953,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13953
13953
  2
13954
13954
  /* Reassign */
13955
13955
  );
13956
- (0, import_chunk_SG7ODKRM.some)(event.decl, (decl) => {
13956
+ (0, import_chunk_67LU4GPQ.some)(event.decl, (decl) => {
13957
13957
  if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
13958
13958
  return false;
13959
13959
  }
@@ -13961,7 +13961,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13961
13961
  if (affected) {
13962
13962
  const objType = typeFromTypeStateNodes(
13963
13963
  istate.state,
13964
- (0, import_chunk_SG7ODKRM.map)(
13964
+ (0, import_chunk_67LU4GPQ.map)(
13965
13965
  event.decl,
13966
13966
  (decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
13967
13967
  ).filter(
@@ -13982,7 +13982,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13982
13982
  });
13983
13983
  if (wasComputedDecl) {
13984
13984
  curState.map.forEach((value2, decls) => {
13985
- if ((0, import_chunk_SG7ODKRM.some)(
13985
+ if ((0, import_chunk_67LU4GPQ.some)(
13986
13986
  decls,
13987
13987
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
13988
13988
  )) {
@@ -14028,14 +14028,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14028
14028
  }
14029
14029
  if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
14030
14030
  // in case it has side effects.
14031
- (0, import_chunk_SG7ODKRM.some)(
14031
+ (0, import_chunk_67LU4GPQ.some)(
14032
14032
  event2.calleeDecl,
14033
14033
  (callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
14034
14034
  )) {
14035
14035
  return false;
14036
14036
  }
14037
14037
  }
14038
- if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_SG7ODKRM.some)(
14038
+ if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_67LU4GPQ.some)(
14039
14039
  event2.decl,
14040
14040
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
14041
14041
  )) {
@@ -14074,13 +14074,13 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14074
14074
  }
14075
14075
  }
14076
14076
  if (uninitClassDecls?.size) {
14077
- (0, import_chunk_SG7ODKRM.forEach)(
14077
+ (0, import_chunk_67LU4GPQ.forEach)(
14078
14078
  event.decl,
14079
14079
  (decl) => uninitClassDecls.has(decl) && curState.inited?.add(decl)
14080
14080
  );
14081
14081
  }
14082
14082
  if (logThisRun) {
14083
- (0, import_chunk_SG7ODKRM.log)(
14083
+ (0, import_chunk_67LU4GPQ.log)(
14084
14084
  describeEvent(event).then(
14085
14085
  (eventStr) => ` ${eventStr} := ${display(type)}`
14086
14086
  )
@@ -14098,7 +14098,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14098
14098
  );
14099
14099
  }
14100
14100
  if (logThisRun) {
14101
- (0, import_chunk_SG7ODKRM.log)(
14101
+ (0, import_chunk_67LU4GPQ.log)(
14102
14102
  describeEvent(event).then(
14103
14103
  (eventStr) => ` ${eventStr} : ${!Array.isArray(event.left) && event.left.type === "MemberDecl" ? `${display(
14104
14104
  curState.map.get(event.left.base)?.curType || {
@@ -14156,8 +14156,8 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14156
14156
  }
14157
14157
  if (!successorsHandled) {
14158
14158
  if (logThisRun) {
14159
- (0, import_chunk_SG7ODKRM.log)(
14160
- ` merge to: ${(0, import_chunk_SG7ODKRM.map)(
14159
+ (0, import_chunk_67LU4GPQ.log)(
14160
+ ` merge to: ${(0, import_chunk_67LU4GPQ.map)(
14161
14161
  top.succs,
14162
14162
  (succ) => succ.order || -1
14163
14163
  ).join(", ")}`
@@ -14188,17 +14188,17 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14188
14188
  );
14189
14189
  printBlockTrailer(block);
14190
14190
  });
14191
- (0, import_chunk_SG7ODKRM.log)("====== TypeMap =====");
14191
+ (0, import_chunk_67LU4GPQ.log)("====== TypeMap =====");
14192
14192
  typeMap.forEach((value2, key) => {
14193
- (0, import_chunk_SG7ODKRM.log)(
14193
+ (0, import_chunk_67LU4GPQ.log)(
14194
14194
  formatAst(key).then(
14195
14195
  (keyStr) => `${keyStr} = ${display(value2)} ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
14196
14196
  )
14197
14197
  );
14198
14198
  });
14199
- (0, import_chunk_SG7ODKRM.log)("====== EquivMap =====");
14199
+ (0, import_chunk_67LU4GPQ.log)("====== EquivMap =====");
14200
14200
  nodeEquivs.forEach((value2, key) => {
14201
- (0, import_chunk_SG7ODKRM.log)(
14201
+ (0, import_chunk_67LU4GPQ.log)(
14202
14202
  formatAst(key).then(
14203
14203
  (keyStr) => `${keyStr} = [${value2.equiv.map(
14204
14204
  (equiv) => tsKey(equiv)
@@ -14206,7 +14206,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14206
14206
  )
14207
14207
  );
14208
14208
  });
14209
- (0, import_chunk_SG7ODKRM.log)("====== Copy Prop =====");
14209
+ (0, import_chunk_67LU4GPQ.log)("====== Copy Prop =====");
14210
14210
  nodeCopyProp.forEach((value2, key) => {
14211
14211
  (0, import_node_assert3.default)(value2 !== false);
14212
14212
  if (key.type === "VariableDeclarator" || key.type === "AssignmentExpression") {
@@ -14216,7 +14216,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14216
14216
  value2.type === "VariableDeclarator" && value2.init || value2.type === "AssignmentExpression"
14217
14217
  );
14218
14218
  const node = value2.type === "VariableDeclarator" ? value2.init : value2.right;
14219
- (0, import_chunk_SG7ODKRM.log)(
14219
+ (0, import_chunk_67LU4GPQ.log)(
14220
14220
  formatAst(key).then(
14221
14221
  (keyStr) => formatAstLongLines(node).then(
14222
14222
  (nodeStr) => `${keyStr} = [${nodeStr}] ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
@@ -14226,10 +14226,10 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14226
14226
  });
14227
14227
  }
14228
14228
  if (logThisRun) {
14229
- (0, import_chunk_SG7ODKRM.log)(formatAstLongLines(func.node));
14229
+ (0, import_chunk_67LU4GPQ.log)(formatAstLongLines(func.node));
14230
14230
  if (copyPropStores) {
14231
14231
  copyPropStores.forEach(({ ref, ant }, node) => {
14232
- (0, import_chunk_SG7ODKRM.log)(
14232
+ (0, import_chunk_67LU4GPQ.log)(
14233
14233
  formatAstLongLines(node).then(
14234
14234
  (nodeStr) => `copy-prop-store: ${nodeStr}${ant ? "!" : ""} => ${nodeCopyProp.get(node) !== ref ? "Failed" : "Success"}`
14235
14235
  )
@@ -14243,9 +14243,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14243
14243
  }
14244
14244
  if (logThisRun) {
14245
14245
  if (selfAssignments.size) {
14246
- (0, import_chunk_SG7ODKRM.log)("====== Self Assignments =====");
14246
+ (0, import_chunk_67LU4GPQ.log)("====== Self Assignments =====");
14247
14247
  selfAssignments.forEach(
14248
- (self) => (0, import_chunk_SG7ODKRM.log)(
14248
+ (self) => (0, import_chunk_67LU4GPQ.log)(
14249
14249
  formatAst(self).then(
14250
14250
  (selfStr) => `${selfStr} (${sourceLocation(self.loc)})`
14251
14251
  )
@@ -14310,7 +14310,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14310
14310
  if (copyNode) {
14311
14311
  if (node.type === "AssignmentExpression") {
14312
14312
  if (logThisRun) {
14313
- (0, import_chunk_SG7ODKRM.log)(
14313
+ (0, import_chunk_67LU4GPQ.log)(
14314
14314
  formatAstLongLines(node).then(
14315
14315
  (nodeStr) => `Killing copy-prop assignment ${nodeStr}`
14316
14316
  )
@@ -14325,7 +14325,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14325
14325
  if (node.type === "VariableDeclarator") {
14326
14326
  (0, import_node_assert3.default)(node.init);
14327
14327
  if (logThisRun) {
14328
- (0, import_chunk_SG7ODKRM.log)(
14328
+ (0, import_chunk_67LU4GPQ.log)(
14329
14329
  formatAstLongLines(node).then(
14330
14330
  (nodeStr) => `Killing copy-prop variable initialization ${nodeStr}`
14331
14331
  )
@@ -14346,7 +14346,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14346
14346
  right: copyNode.right
14347
14347
  };
14348
14348
  if (logThisRun) {
14349
- (0, import_chunk_SG7ODKRM.log)(
14349
+ (0, import_chunk_67LU4GPQ.log)(
14350
14350
  formatAstLongLines(node).then(
14351
14351
  (nodeStr) => formatAstLongLines(replacement2).then(
14352
14352
  (repStr) => `copy-prop ${nodeStr} => ${repStr}`
@@ -14359,7 +14359,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14359
14359
  const init = copyNode.init;
14360
14360
  (0, import_node_assert3.default)(init);
14361
14361
  if (logThisRun) {
14362
- (0, import_chunk_SG7ODKRM.log)(
14362
+ (0, import_chunk_67LU4GPQ.log)(
14363
14363
  formatAstLongLines(node).then(
14364
14364
  (nodeStr) => formatAstLongLines(init).then(
14365
14365
  (initStr) => `copy-prop ${nodeStr} => ${initStr}`
@@ -14373,7 +14373,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14373
14373
  }
14374
14374
  if (selfAssignments.has(node)) {
14375
14375
  if (logThisRun) {
14376
- (0, import_chunk_SG7ODKRM.log)(
14376
+ (0, import_chunk_67LU4GPQ.log)(
14377
14377
  formatAst(node).then(
14378
14378
  (nodeStr) => `Deleting self assignment: ${nodeStr} (${sourceLocation(
14379
14379
  node.loc
@@ -14417,7 +14417,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14417
14417
  }, curInfo);
14418
14418
  if (rep === curInfo)
14419
14419
  return null;
14420
- const name = (0, import_chunk_SG7ODKRM.reduce)(
14420
+ const name = (0, import_chunk_67LU4GPQ.reduce)(
14421
14421
  rep.decl,
14422
14422
  (cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
14423
14423
  null
@@ -14425,7 +14425,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14425
14425
  if (!name)
14426
14426
  return null;
14427
14427
  if (logThisRun) {
14428
- (0, import_chunk_SG7ODKRM.log)(
14428
+ (0, import_chunk_67LU4GPQ.log)(
14429
14429
  formatAst(node).then(
14430
14430
  (nodeStr) => `Replacing ${nodeStr} with ${name} at ${sourceLocation(
14431
14431
  node.loc
@@ -14556,7 +14556,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
14556
14556
  init_type_flow_util();
14557
14557
  init_types();
14558
14558
  init_union_type();
14559
- (0, import_chunk_SG7ODKRM.init_util)();
14559
+ (0, import_chunk_67LU4GPQ.init_util)();
14560
14560
  logging = true;
14561
14561
  missingNullWorkaround = true;
14562
14562
  }
@@ -14608,9 +14608,9 @@ function minimizeLocals(state, func) {
14608
14608
  if (!didMerge)
14609
14609
  return;
14610
14610
  if (logThisRun) {
14611
- (0, import_chunk_SG7ODKRM.log)(`>>> Merging locals in ${func.fullName}`);
14611
+ (0, import_chunk_67LU4GPQ.log)(`>>> Merging locals in ${func.fullName}`);
14612
14612
  merge.forEach(
14613
- (merged) => merged.length > 1 && (0, import_chunk_SG7ODKRM.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
14613
+ (merged) => merged.length > 1 && (0, import_chunk_67LU4GPQ.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
14614
14614
  );
14615
14615
  }
14616
14616
  const remap = /* @__PURE__ */ new Map();
@@ -14880,7 +14880,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
14880
14880
  (0, import_chunk_MBTLUWXR.init_ast)();
14881
14881
  init_control_flow();
14882
14882
  init_type_flow();
14883
- (0, import_chunk_SG7ODKRM.init_util)();
14883
+ (0, import_chunk_67LU4GPQ.init_util)();
14884
14884
  init_variable_renamer();
14885
14885
  init_type_flow_util();
14886
14886
  }
@@ -14891,12 +14891,12 @@ function logAntState(s, decl) {
14891
14891
  defs2++;
14892
14892
  return defs2;
14893
14893
  }, 0);
14894
- (0, import_chunk_SG7ODKRM.log)(
14894
+ (0, import_chunk_67LU4GPQ.log)(
14895
14895
  declFullName(decl).then(
14896
14896
  (declStr) => ` - ${declStr}: ${candidateCost(s)} bytes, ${s.ant.size - defs} refs, ${defs} defs, ${s.live ? "" : "!"}live, ${s.isIsolated ? "" : "!"}isolated`
14897
14897
  )
14898
14898
  );
14899
- (0, import_chunk_SG7ODKRM.log)(
14899
+ (0, import_chunk_67LU4GPQ.log)(
14900
14900
  ` - members: ${Array.from(s.members).map(([block, live]) => block.order + (live ? "t" : "f")).join(", ")}`
14901
14901
  );
14902
14902
  }
@@ -14913,7 +14913,7 @@ async function sizeBasedPRE(state, func) {
14913
14913
  const candidates = computeAttributes(state, head);
14914
14914
  if (candidates) {
14915
14915
  if (logging2) {
14916
- (0, import_chunk_SG7ODKRM.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
14916
+ (0, import_chunk_67LU4GPQ.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
14917
14917
  logAntDecls(candidates);
14918
14918
  }
14919
14919
  const nodeMap = /* @__PURE__ */ new Map();
@@ -15006,7 +15006,7 @@ function buildPREGraph(state, func) {
15006
15006
  const event = block.events[i];
15007
15007
  switch (event.type) {
15008
15008
  case "ref":
15009
- if ((0, import_chunk_SG7ODKRM.some)(
15009
+ if ((0, import_chunk_67LU4GPQ.some)(
15010
15010
  event.decl,
15011
15011
  (decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
15012
15012
  )) {
@@ -15024,7 +15024,7 @@ function buildPREGraph(state, func) {
15024
15024
  defs.add(event.decl);
15025
15025
  break;
15026
15026
  case "mod":
15027
- if (event.callees && (0, import_chunk_SG7ODKRM.every)(event.callees, (callee) => callee.info === false)) {
15027
+ if (event.callees && (0, import_chunk_67LU4GPQ.every)(event.callees, (callee) => callee.info === false)) {
15028
15028
  block.events.splice(i, 1);
15029
15029
  break;
15030
15030
  }
@@ -15183,21 +15183,21 @@ function computeAttributes(state, head) {
15183
15183
  });
15184
15184
  if (logging2) {
15185
15185
  order.forEach((block) => {
15186
- (0, import_chunk_SG7ODKRM.log)(
15186
+ (0, import_chunk_67LU4GPQ.log)(
15187
15187
  block.order,
15188
15188
  `(${block.node ? block.node.loc?.start.line : "??"})`,
15189
15189
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
15190
15190
  );
15191
15191
  if (block.events) {
15192
15192
  block.events.forEach(
15193
- (event) => event.type !== "exn" && (0, import_chunk_SG7ODKRM.log)(
15193
+ (event) => event.type !== "exn" && (0, import_chunk_67LU4GPQ.log)(
15194
15194
  Promise.resolve(
15195
15195
  event.decl ? declFullName(event.decl) : event.node ? formatAst(event.node) : "??"
15196
15196
  ).then((eventDetails) => ` ${event.type}: ${eventDetails}`)
15197
15197
  )
15198
15198
  );
15199
15199
  }
15200
- (0, import_chunk_SG7ODKRM.log)(
15200
+ (0, import_chunk_67LU4GPQ.log)(
15201
15201
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
15202
15202
  );
15203
15203
  });
@@ -15265,7 +15265,7 @@ function computeAttributes(state, head) {
15265
15265
  }
15266
15266
  case "mod": {
15267
15267
  curState.forEach((candidates, decls) => {
15268
- if ((0, import_chunk_SG7ODKRM.some)(
15268
+ if ((0, import_chunk_67LU4GPQ.some)(
15269
15269
  decls,
15270
15270
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
15271
15271
  (callee) => functionMayModify(state, callee, decl)
@@ -15307,7 +15307,7 @@ function computeAttributes(state, head) {
15307
15307
  }
15308
15308
  blockStates[top.order] = curState;
15309
15309
  if (logging2) {
15310
- (0, import_chunk_SG7ODKRM.log)(`Updated block ${top.order}`);
15310
+ (0, import_chunk_67LU4GPQ.log)(`Updated block ${top.order}`);
15311
15311
  logAntDecls(curState);
15312
15312
  }
15313
15313
  if (top.preds) {
@@ -15409,7 +15409,7 @@ function applyReplacements(func, nodeMap, declMap) {
15409
15409
  }
15410
15410
  const name = declMap.get(event.decl);
15411
15411
  if (!name) {
15412
- throw new import_chunk_SG7ODKRM.AwaitedError(
15412
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15413
15413
  formatAst(node).then(
15414
15414
  (targetStr) => `No replacement found for "${targetStr}"`
15415
15415
  )
@@ -15431,7 +15431,7 @@ function applyReplacements(func, nodeMap, declMap) {
15431
15431
  const target = node.type === "AssignmentExpression" ? node.left : node.argument;
15432
15432
  const name = declMap.get(event.decl);
15433
15433
  if (!name) {
15434
- throw new import_chunk_SG7ODKRM.AwaitedError(
15434
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15435
15435
  formatAst(target).then(
15436
15436
  (targetStr) => `No replacement found for "${targetStr}"`
15437
15437
  )
@@ -15494,14 +15494,14 @@ function applyReplacements(func, nodeMap, declMap) {
15494
15494
  const decl = event.decl;
15495
15495
  const name = declMap.get(decl);
15496
15496
  if (!name) {
15497
- throw new import_chunk_SG7ODKRM.AwaitedError(
15497
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15498
15498
  declFullName(decl).then(
15499
15499
  (declStr) => `No replacement found for "${declStr}"`
15500
15500
  )
15501
15501
  );
15502
15502
  }
15503
15503
  if (!event.id) {
15504
- throw new import_chunk_SG7ODKRM.AwaitedError(
15504
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15505
15505
  declFullName(decl).then(
15506
15506
  (declStr) => `Missing id for mod event for "${declStr}"`
15507
15507
  )
@@ -15566,7 +15566,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
15566
15566
  init_data_flow();
15567
15567
  init_function_info();
15568
15568
  init_minimize_locals();
15569
- (0, import_chunk_SG7ODKRM.init_util)();
15569
+ (0, import_chunk_67LU4GPQ.init_util)();
15570
15570
  logging2 = false;
15571
15571
  LocalRefCost = 2;
15572
15572
  }
@@ -15937,7 +15937,7 @@ function beforeEvaluate(istate, node) {
15937
15937
  break;
15938
15938
  }
15939
15939
  const id = node.right.argument;
15940
- if ((0, import_chunk_SG7ODKRM.every)(left.value.value, (m) => {
15940
+ if ((0, import_chunk_67LU4GPQ.every)(left.value.value, (m) => {
15941
15941
  if ((0, import_chunk_MBTLUWXR.hasProperty)(m.decls, id.name))
15942
15942
  return false;
15943
15943
  return istate.state.lookup({
@@ -16383,7 +16383,7 @@ var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
16383
16383
  (0, import_chunk_MBTLUWXR.init_ast)();
16384
16384
  init_inliner();
16385
16385
  init_type_flow();
16386
- (0, import_chunk_SG7ODKRM.init_util)();
16386
+ (0, import_chunk_67LU4GPQ.init_util)();
16387
16387
  init_interp();
16388
16388
  init_interp_binary();
16389
16389
  init_types();
@@ -16920,13 +16920,13 @@ function markFunctionCalled(state, func) {
16920
16920
  state.calledFunctions[func.id.name] = [func];
16921
16921
  return;
16922
16922
  }
16923
- (0, import_chunk_SG7ODKRM.pushUnique)(state.calledFunctions[func.id.name], func);
16923
+ (0, import_chunk_67LU4GPQ.pushUnique)(state.calledFunctions[func.id.name], func);
16924
16924
  }
16925
16925
  async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
16926
16926
  try {
16927
16927
  return optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config);
16928
16928
  } catch (ex) {
16929
- if (ex instanceof import_chunk_SG7ODKRM.AwaitedError) {
16929
+ if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
16930
16930
  await ex.resolve();
16931
16931
  }
16932
16932
  throw ex;
@@ -17663,7 +17663,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
17663
17663
  init_sub_type();
17664
17664
  init_types();
17665
17665
  init_unused_exprs();
17666
- (0, import_chunk_SG7ODKRM.init_util)();
17666
+ (0, import_chunk_67LU4GPQ.init_util)();
17667
17667
  init_variable_renamer();
17668
17668
  init_data_flow();
17669
17669
  }
@@ -17892,7 +17892,9 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
17892
17892
  const hiddenRez = makeModule("*Rez*");
17893
17893
  rez.body.body.push(hiddenRez);
17894
17894
  if (barrel === "" && manifestXML && manifestXML.body instanceof xml_util_exports.Nodes) {
17895
- manifestXML.body.children("iq:application").elements.forEach((e) => add_one_resource(state, manifestXML, rez, e));
17895
+ manifestXML.body.children("iq:application").elements.forEach(
17896
+ (e) => add_one_resource(state, manifestXML, rez, e, "")
17897
+ );
17896
17898
  }
17897
17899
  const rezModules = Object.fromEntries(
17898
17900
  Object.entries(modules).map(([moduleName, isPublic]) => {
@@ -17910,7 +17912,7 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
17910
17912
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(rezModules, s))
17911
17913
  return;
17912
17914
  const module2 = rezModules[s];
17913
- add_one_resource(state, rez2, module2, e);
17915
+ add_one_resource(state, rez2, module2, e, barrel);
17914
17916
  });
17915
17917
  });
17916
17918
  });
@@ -17926,11 +17928,14 @@ function addPositions(base, pos) {
17926
17928
  result.offset += pos.offset;
17927
17929
  return result;
17928
17930
  }
17929
- function visit_resource_refs(state, doc, e) {
17931
+ function visit_resource_refs(state, doc, e, barrel) {
17930
17932
  const result = [];
17931
17933
  const parseArg = (name, loc, skip) => {
17932
17934
  if (name.startsWith("@")) {
17933
17935
  name = name.substring(1);
17936
+ if (barrel && name.startsWith(barrel) && name[barrel.length] === ".") {
17937
+ name = name.slice(barrel.length + 1);
17938
+ }
17934
17939
  loc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 1, 0);
17935
17940
  }
17936
17941
  if ((0, import_chunk_MBTLUWXR.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
@@ -17987,18 +17992,27 @@ function visit_resource_refs(state, doc, e) {
17987
17992
  }
17988
17993
  if (id === "personality") {
17989
17994
  const elems = dotted.match(/\s+|\S+/g);
17990
- elems?.reduce((offset, name) => {
17991
- const end = offset + name.length;
17992
- if (!/\s/.test(name)) {
17995
+ elems?.reduce((loc, name) => {
17996
+ if (/\s/.test(name)) {
17997
+ const newLines = name.match(/\r\n|[\r\n]/g);
17998
+ if (newLines?.length) {
17999
+ loc.start.line += newLines.length;
18000
+ loc.start.column = 1;
18001
+ loc.start.offset += name.length;
18002
+ name = name.replace(/^.*(\r\n|[\r\n])(.*)$/, "$2");
18003
+ loc.start.offset -= name.length;
18004
+ }
18005
+ } else {
17993
18006
  const base = (0, import_chunk_MBTLUWXR.makeScopedName)(`Rez.Styles`);
17994
- const id2 = (0, import_chunk_MBTLUWXR.makeIdentifier)(
17995
- name,
17996
- (0, import_chunk_MBTLUWXR.adjustLoc)(l, offset, end - dotted.length)
17997
- );
18007
+ const idLoc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 0, 0);
18008
+ idLoc.end = { ...idLoc.start };
18009
+ idLoc.end.column += name.length;
18010
+ idLoc.end.offset += name.length;
18011
+ const id2 = (0, import_chunk_MBTLUWXR.makeIdentifier)(name, idLoc);
17998
18012
  result.push((0, import_chunk_MBTLUWXR.makeMemberExpression)((0, import_chunk_MBTLUWXR.withLoc)(base, id2, false), id2));
17999
18013
  }
18000
- return end;
18001
- }, 0);
18014
+ return (0, import_chunk_MBTLUWXR.adjustLoc)(loc, name.length, 0);
18015
+ }, (0, import_chunk_MBTLUWXR.adjustLoc)(l, 0, 0));
18002
18016
  return;
18003
18017
  }
18004
18018
  if (/^\s*(true|false|null|NaN|(0x|#)[0-9a-f]+|[-+]?\d+%?)\s*$/i.test(dotted)) {
@@ -18072,7 +18086,7 @@ function visit_resource_refs(state, doc, e) {
18072
18086
  });
18073
18087
  return result;
18074
18088
  }
18075
- function add_one_resource(state, doc, module2, e) {
18089
+ function add_one_resource(state, doc, module2, e, barrel) {
18076
18090
  let id;
18077
18091
  let func;
18078
18092
  const makeVarDecl = (id2, outer) => {
@@ -18236,7 +18250,7 @@ function add_one_resource(state, doc, module2, e) {
18236
18250
  }
18237
18251
  if (!func)
18238
18252
  return;
18239
- const elements = visit_resource_refs(state, doc, e);
18253
+ const elements = visit_resource_refs(state, doc, e, barrel);
18240
18254
  const startLoc = elements[0]?.loc;
18241
18255
  const endLoc = elements[elements.length - 1]?.loc;
18242
18256
  const init = elements.length ? (0, import_chunk_MBTLUWXR.wrap)(
@@ -18544,7 +18558,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
18544
18558
  throw `Negative constant ${fixup} was not a Literal`;
18545
18559
  }
18546
18560
  if (typeof init.value !== "number") {
18547
- (0, import_chunk_SG7ODKRM.log)(`Negative fixup ${fixup} was not a number!`);
18561
+ (0, import_chunk_67LU4GPQ.log)(`Negative fixup ${fixup} was not a number!`);
18548
18562
  } else if (init.value > 0) {
18549
18563
  init.value = -init.value;
18550
18564
  init.raw = "-" + init.raw;
@@ -18634,11 +18648,11 @@ function sameStateNodeDecl(a, b) {
18634
18648
  function sameLookupDefinition(a, b) {
18635
18649
  return (
18636
18650
  // sameStateNodeDecl(a.parent, b.parent) &&
18637
- (0, import_chunk_SG7ODKRM.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
18651
+ (0, import_chunk_67LU4GPQ.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
18638
18652
  );
18639
18653
  }
18640
18654
  function sameLookupResult(a, b) {
18641
- return (0, import_chunk_SG7ODKRM.sameArrays)(a, b, sameLookupDefinition);
18655
+ return (0, import_chunk_67LU4GPQ.sameArrays)(a, b, sameLookupDefinition);
18642
18656
  }
18643
18657
  function declKey(decl) {
18644
18658
  return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
@@ -19176,7 +19190,7 @@ function stateFuncs() {
19176
19190
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
19177
19191
  this.index[name] = [];
19178
19192
  }
19179
- (0, import_chunk_SG7ODKRM.pushUnique)(this.index[name], parent);
19193
+ (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
19180
19194
  }
19181
19195
  });
19182
19196
  break;
@@ -19231,7 +19245,7 @@ function stateFuncs() {
19231
19245
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
19232
19246
  values[name] = [];
19233
19247
  }
19234
- if ((0, import_chunk_SG7ODKRM.pushUnique)(values[name], m) && currentEnum) {
19248
+ if ((0, import_chunk_67LU4GPQ.pushUnique)(values[name], m) && currentEnum) {
19235
19249
  if (!this.enumMap)
19236
19250
  this.enumMap = /* @__PURE__ */ new Map();
19237
19251
  this.enumMap.set(m, currentEnum);
@@ -19239,7 +19253,7 @@ function stateFuncs() {
19239
19253
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
19240
19254
  this.index[name] = [];
19241
19255
  }
19242
- (0, import_chunk_SG7ODKRM.pushUnique)(this.index[name], parent);
19256
+ (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
19243
19257
  });
19244
19258
  break;
19245
19259
  }
@@ -19740,7 +19754,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
19740
19754
  init_sdk_util();
19741
19755
  init_type_flow_util();
19742
19756
  init_types();
19743
- (0, import_chunk_SG7ODKRM.init_util)();
19757
+ (0, import_chunk_67LU4GPQ.init_util)();
19744
19758
  init_visitor();
19745
19759
  }
19746
19760
  });
@@ -19824,7 +19838,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19824
19838
  return decls;
19825
19839
  }
19826
19840
  if (canon.length !== decls.length || !canon.every((v, i) => v === decls[i])) {
19827
- throw new import_chunk_SG7ODKRM.AwaitedError(
19841
+ throw new import_chunk_67LU4GPQ.AwaitedError(
19828
19842
  declFullName(canon).then(
19829
19843
  (canonStr) => `Canonical representation of ${canonStr} did not match`
19830
19844
  )
@@ -19858,7 +19872,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19858
19872
  }
19859
19873
  const decl = lookupDefToDecl(results);
19860
19874
  if (decl && path7.length) {
19861
- if (wantsAllRefs && (0, import_chunk_SG7ODKRM.every)(
19875
+ if (wantsAllRefs && (0, import_chunk_67LU4GPQ.every)(
19862
19876
  decl,
19863
19877
  (d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
19864
19878
  )) {
@@ -19910,7 +19924,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19910
19924
  }
19911
19925
  const v = liveDefs.get(def);
19912
19926
  if (!v || !v.has(node)) {
19913
- throw new import_chunk_SG7ODKRM.AwaitedError(
19927
+ throw new import_chunk_67LU4GPQ.AwaitedError(
19914
19928
  Promise.resolve(def ? declFullName(def) : "null").then(
19915
19929
  (defStr) => `No stmt in liveDef for ${defStr}`
19916
19930
  )
@@ -19968,7 +19982,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19968
19982
  const decls = findDecl(node);
19969
19983
  if (!decls)
19970
19984
  break;
19971
- if (trackInsertionPoints && (0, import_chunk_SG7ODKRM.some)(decls, (decl) => {
19985
+ if (trackInsertionPoints && (0, import_chunk_67LU4GPQ.some)(decls, (decl) => {
19972
19986
  if (decl.type === "VariableDeclarator") {
19973
19987
  const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
19974
19988
  if (defStmts) {
@@ -20219,8 +20233,8 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
20219
20233
  init_control_flow();
20220
20234
  init_function_info();
20221
20235
  init_type_flow_util();
20222
- (0, import_chunk_SG7ODKRM.init_util)();
20223
- DataflowQueue = class extends import_chunk_SG7ODKRM.GenericQueue {
20236
+ (0, import_chunk_67LU4GPQ.init_util)();
20237
+ DataflowQueue = class extends import_chunk_67LU4GPQ.GenericQueue {
20224
20238
  constructor() {
20225
20239
  super((b, a) => (a.order || 0) - (b.order || 0));
20226
20240
  }
@@ -21015,7 +21029,7 @@ function computeJsrMap(func) {
21015
21029
  }
21016
21030
  function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
21017
21031
  const order = /* @__PURE__ */ new Map();
21018
- const queue = new import_chunk_SG7ODKRM.GenericQueue(
21032
+ const queue = new import_chunk_67LU4GPQ.GenericQueue(
21019
21033
  (b, a) => order.get(a) - order.get(b)
21020
21034
  );
21021
21035
  postOrderTraverse2(func, (block) => {
@@ -21074,7 +21088,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21074
21088
  });
21075
21089
  blocks.reverse().forEach((block, i) => order.set(block, i));
21076
21090
  }
21077
- const queue = new import_chunk_SG7ODKRM.GenericQueue(
21091
+ const queue = new import_chunk_67LU4GPQ.GenericQueue(
21078
21092
  (b, a) => order.get(a) - order.get(b)
21079
21093
  );
21080
21094
  queue.enqueue(func.blocks.get(func.offset));
@@ -21128,7 +21142,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21128
21142
  var init_cflow = (0, import_chunk_ABYVSU2C.__esm)({
21129
21143
  "src/readprg/cflow.ts"() {
21130
21144
  "use strict";
21131
- (0, import_chunk_SG7ODKRM.init_util)();
21145
+ (0, import_chunk_67LU4GPQ.init_util)();
21132
21146
  init_opcodes();
21133
21147
  }
21134
21148
  });
@@ -21591,12 +21605,12 @@ function interpFunc(func, context) {
21591
21605
  const selfStores = /* @__PURE__ */ new Set();
21592
21606
  const liveInState = /* @__PURE__ */ new Map();
21593
21607
  const replacements = /* @__PURE__ */ new Map();
21594
- const interpLogging = (0, import_chunk_SG7ODKRM.wouldLog)("interp", 1);
21608
+ const interpLogging = (0, import_chunk_67LU4GPQ.wouldLog)("interp", 1);
21595
21609
  if (interpLogging) {
21596
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 7)) {
21597
- (0, import_chunk_SG7ODKRM.setBanner)(functionBanner(func, context, "interp"));
21598
- } else if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 3)) {
21599
- (0, import_chunk_SG7ODKRM.setBanner)(
21610
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 7)) {
21611
+ (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "interp"));
21612
+ } else if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 3)) {
21613
+ (0, import_chunk_67LU4GPQ.setBanner)(
21600
21614
  () => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
21601
21615
  );
21602
21616
  }
@@ -21630,20 +21644,20 @@ function interpFunc(func, context) {
21630
21644
  func,
21631
21645
  (block) => {
21632
21646
  if (interpLogging) {
21633
- (0, import_chunk_SG7ODKRM.logger)(
21647
+ (0, import_chunk_67LU4GPQ.logger)(
21634
21648
  "interp",
21635
21649
  3,
21636
21650
  `${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
21637
21651
  ${interpStateToString(liveInState.get(block.offset))}`
21638
21652
  );
21639
- (0, import_chunk_SG7ODKRM.logger)("interp", 9, () => blockToString(block, context));
21653
+ (0, import_chunk_67LU4GPQ.logger)("interp", 9, () => blockToString(block, context));
21640
21654
  }
21641
21655
  return cloneState2(liveInState.get(block.offset));
21642
21656
  },
21643
21657
  (block, bc, localState) => {
21644
21658
  if (interpLogging) {
21645
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 8)) {
21646
- (0, import_chunk_SG7ODKRM.log)(
21659
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 8)) {
21660
+ (0, import_chunk_67LU4GPQ.log)(
21647
21661
  `${interpStateToString(localState)}
21648
21662
  ${bytecodeToString(
21649
21663
  bc,
@@ -21808,14 +21822,14 @@ function interpFunc(func, context) {
21808
21822
  if (!mergeInto(localState, succState))
21809
21823
  return false;
21810
21824
  if (interpLogging) {
21811
- (0, import_chunk_SG7ODKRM.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
21825
+ (0, import_chunk_67LU4GPQ.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
21812
21826
  }
21813
21827
  return true;
21814
21828
  }
21815
21829
  );
21816
21830
  if (interpLogging) {
21817
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 5)) {
21818
- (0, import_chunk_SG7ODKRM.setBanner)(
21831
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 5)) {
21832
+ (0, import_chunk_67LU4GPQ.setBanner)(
21819
21833
  functionBanner(func, context, "interp", (block, footer) => {
21820
21834
  if (footer)
21821
21835
  return "";
@@ -21823,44 +21837,44 @@ function interpFunc(func, context) {
21823
21837
  })
21824
21838
  );
21825
21839
  } else {
21826
- (0, import_chunk_SG7ODKRM.setBanner)(() => `=============== interp ${func.name} ==============`);
21840
+ (0, import_chunk_67LU4GPQ.setBanner)(() => `=============== interp ${func.name} ==============`);
21827
21841
  }
21828
21842
  if (equivSets.size) {
21829
- (0, import_chunk_SG7ODKRM.log)(`====== equivSets =====`);
21843
+ (0, import_chunk_67LU4GPQ.log)(`====== equivSets =====`);
21830
21844
  equivSets.forEach(
21831
- (value2, key) => (0, import_chunk_SG7ODKRM.log)(
21845
+ (value2, key) => (0, import_chunk_67LU4GPQ.log)(
21832
21846
  `L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
21833
21847
  )
21834
21848
  );
21835
21849
  }
21836
21850
  if (selfStores.size) {
21837
- (0, import_chunk_SG7ODKRM.log)(`====== selfStores =====`);
21851
+ (0, import_chunk_67LU4GPQ.log)(`====== selfStores =====`);
21838
21852
  selfStores.forEach(
21839
- (value2) => (0, import_chunk_SG7ODKRM.log)(`${bytecodeToString(value2, symbolTable)}`)
21853
+ (value2) => (0, import_chunk_67LU4GPQ.log)(`${bytecodeToString(value2, symbolTable)}`)
21840
21854
  );
21841
21855
  }
21842
21856
  if (replacements.size) {
21843
- (0, import_chunk_SG7ODKRM.log)(`====== replacements =====`);
21857
+ (0, import_chunk_67LU4GPQ.log)(`====== replacements =====`);
21844
21858
  replacements.forEach(
21845
21859
  (blockRep) => blockRep.forEach(
21846
- (rep, bc) => (0, import_chunk_SG7ODKRM.log)(
21860
+ (rep, bc) => (0, import_chunk_67LU4GPQ.log)(
21847
21861
  `${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
21848
21862
  )
21849
21863
  )
21850
21864
  );
21851
21865
  }
21852
21866
  if (resolvedBranches.size) {
21853
- (0, import_chunk_SG7ODKRM.log)(`====== resolved branches =====`);
21867
+ (0, import_chunk_67LU4GPQ.log)(`====== resolved branches =====`);
21854
21868
  resolvedBranches.forEach(
21855
- (isTaken, block) => (0, import_chunk_SG7ODKRM.log)(
21869
+ (isTaken, block) => (0, import_chunk_67LU4GPQ.log)(
21856
21870
  `block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
21857
21871
  )
21858
21872
  );
21859
21873
  }
21860
21874
  if (branchRedirects.size) {
21861
- (0, import_chunk_SG7ODKRM.log)(`====== redirected branches =====`);
21875
+ (0, import_chunk_67LU4GPQ.log)(`====== redirected branches =====`);
21862
21876
  branchRedirects.forEach(
21863
- ({ to, from }, block) => (0, import_chunk_SG7ODKRM.log)(
21877
+ ({ to, from }, block) => (0, import_chunk_67LU4GPQ.log)(
21864
21878
  `block ${offsetToString(
21865
21879
  block.offset
21866
21880
  )} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
@@ -21923,7 +21937,7 @@ function interpFunc(func, context) {
21923
21937
  }
21924
21938
  });
21925
21939
  if (interpLogging)
21926
- (0, import_chunk_SG7ODKRM.setBanner)(null);
21940
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
21927
21941
  return {
21928
21942
  liveInState,
21929
21943
  equivSets,
@@ -21973,7 +21987,7 @@ var init_interp2 = (0, import_chunk_ABYVSU2C.__esm)({
21973
21987
  "src/readprg/interp.ts"() {
21974
21988
  "use strict";
21975
21989
  init_interp_binary();
21976
- (0, import_chunk_SG7ODKRM.init_logger)();
21990
+ (0, import_chunk_67LU4GPQ.init_logger)();
21977
21991
  init_interp();
21978
21992
  init_types();
21979
21993
  init_union_type();
@@ -22085,7 +22099,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22085
22099
  i = found;
22086
22100
  }
22087
22101
  if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
22088
- (0, import_chunk_SG7ODKRM.logger)(
22102
+ (0, import_chunk_67LU4GPQ.logger)(
22089
22103
  "array-init",
22090
22104
  1,
22091
22105
  () => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
@@ -22122,7 +22136,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22122
22136
  convertAputv(offset - 1);
22123
22137
  }
22124
22138
  }
22125
- (0, import_chunk_SG7ODKRM.logger)(
22139
+ (0, import_chunk_67LU4GPQ.logger)(
22126
22140
  "array-init",
22127
22141
  1,
22128
22142
  () => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
@@ -22131,8 +22145,8 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22131
22145
  block.bytecodes[index].offset
22132
22146
  )}`
22133
22147
  );
22134
- if ((0, import_chunk_SG7ODKRM.wouldLog)("array-init", 5)) {
22135
- (0, import_chunk_SG7ODKRM.log)(blockToString(block, context));
22148
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("array-init", 5)) {
22149
+ (0, import_chunk_67LU4GPQ.log)(blockToString(block, context));
22136
22150
  }
22137
22151
  return true;
22138
22152
  }
@@ -22172,7 +22186,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22172
22186
  if (putvStarts.length < 3)
22173
22187
  return false;
22174
22188
  tryLocal(3);
22175
- (0, import_chunk_SG7ODKRM.logger)(
22189
+ (0, import_chunk_67LU4GPQ.logger)(
22176
22190
  "array-init",
22177
22191
  1,
22178
22192
  () => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
@@ -22198,7 +22212,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22198
22212
  block.bytecodes[index + 1].arg = putvStarts.length;
22199
22213
  }
22200
22214
  }
22201
- (0, import_chunk_SG7ODKRM.logger)(
22215
+ (0, import_chunk_67LU4GPQ.logger)(
22202
22216
  "array-init",
22203
22217
  5,
22204
22218
  () => `index: ${index}, i: ${i}
@@ -22251,7 +22265,7 @@ ${blockToString(block, context)}`
22251
22265
  for (let i2 = putvStarts.length; i2-- > 1; ) {
22252
22266
  block.bytecodes.splice(putvStarts[i2], 2);
22253
22267
  }
22254
- (0, import_chunk_SG7ODKRM.logger)(
22268
+ (0, import_chunk_67LU4GPQ.logger)(
22255
22269
  "array-init",
22256
22270
  1,
22257
22271
  () => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
@@ -22310,15 +22324,15 @@ var init_array_init = (0, import_chunk_ABYVSU2C.__esm)({
22310
22324
  "src/readprg/array-init.ts"() {
22311
22325
  "use strict";
22312
22326
  init_types();
22313
- (0, import_chunk_SG7ODKRM.init_util)();
22327
+ (0, import_chunk_67LU4GPQ.init_util)();
22314
22328
  init_bytecode();
22315
22329
  init_interp2();
22316
22330
  init_opcodes();
22317
22331
  }
22318
22332
  });
22319
22333
  function localDCE(func, context) {
22320
- if ((0, import_chunk_SG7ODKRM.wouldLog)("dce", 5)) {
22321
- (0, import_chunk_SG7ODKRM.setBanner)(
22334
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("dce", 5)) {
22335
+ (0, import_chunk_67LU4GPQ.setBanner)(
22322
22336
  functionBanner(
22323
22337
  func,
22324
22338
  context,
@@ -22351,7 +22365,7 @@ function localDCE(func, context) {
22351
22365
  };
22352
22366
  func.blocks.forEach((block) => {
22353
22367
  const reportPopv = (i, item, kill) => {
22354
- (0, import_chunk_SG7ODKRM.logger)(
22368
+ (0, import_chunk_67LU4GPQ.logger)(
22355
22369
  "dce",
22356
22370
  2,
22357
22371
  () => `${func.name}: Convert ${i}:${bytecodeToString(
@@ -22366,7 +22380,7 @@ function localDCE(func, context) {
22366
22380
  );
22367
22381
  };
22368
22382
  const reportNop = (item) => {
22369
- (0, import_chunk_SG7ODKRM.logger)(
22383
+ (0, import_chunk_67LU4GPQ.logger)(
22370
22384
  "dce",
22371
22385
  2,
22372
22386
  () => `${func.name}: Kill ${item.deps.map(
@@ -22385,7 +22399,7 @@ function localDCE(func, context) {
22385
22399
  case 19: {
22386
22400
  const liveLocal = dceInfo.locals.has(bytecode.arg);
22387
22401
  if (!liveLocal && (bytecode.arg || context.config.allowForbiddenOpts)) {
22388
- (0, import_chunk_SG7ODKRM.logger)(
22402
+ (0, import_chunk_67LU4GPQ.logger)(
22389
22403
  "dce",
22390
22404
  2,
22391
22405
  () => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
@@ -22545,10 +22559,10 @@ function localDCE(func, context) {
22545
22559
  (bc) => bc.op !== 0
22546
22560
  /* nop */
22547
22561
  );
22548
- (0, import_chunk_SG7ODKRM.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
22562
+ (0, import_chunk_67LU4GPQ.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
22549
22563
  }
22550
22564
  });
22551
- (0, import_chunk_SG7ODKRM.setBanner)(null);
22565
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
22552
22566
  return anyChanges;
22553
22567
  }
22554
22568
  function computeLiveLocals(func) {
@@ -22599,7 +22613,7 @@ var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
22599
22613
  "src/readprg/dce.ts"() {
22600
22614
  "use strict";
22601
22615
  init_data_flow();
22602
- (0, import_chunk_SG7ODKRM.init_util)();
22616
+ (0, import_chunk_67LU4GPQ.init_util)();
22603
22617
  init_bytecode();
22604
22618
  init_cflow();
22605
22619
  init_opcodes();
@@ -22639,7 +22653,7 @@ function minimizeLocals2(func, equivSets, context) {
22639
22653
  const splitRanges = computeSplitRanges(func, equivSets);
22640
22654
  const locals = mergeSplitRanges(splitRanges);
22641
22655
  const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
22642
- (0, import_chunk_SG7ODKRM.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
22656
+ (0, import_chunk_67LU4GPQ.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
22643
22657
  let argc = func.argc ?? null;
22644
22658
  const colors = /* @__PURE__ */ new Map();
22645
22659
  const merge = [];
@@ -22706,15 +22720,15 @@ function minimizeLocals2(func, equivSets, context) {
22706
22720
  }
22707
22721
  }
22708
22722
  }
22709
- if ((0, import_chunk_SG7ODKRM.wouldLog)("locals", 1)) {
22710
- if (!(0, import_chunk_SG7ODKRM.wouldLog)("locals", 10)) {
22711
- (0, import_chunk_SG7ODKRM.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
22723
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("locals", 1)) {
22724
+ if (!(0, import_chunk_67LU4GPQ.wouldLog)("locals", 10)) {
22725
+ (0, import_chunk_67LU4GPQ.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
22712
22726
  }
22713
- (0, import_chunk_SG7ODKRM.log)(
22727
+ (0, import_chunk_67LU4GPQ.log)(
22714
22728
  `>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
22715
22729
  );
22716
22730
  merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
22717
- (merged) => (0, import_chunk_SG7ODKRM.log)(
22731
+ (merged) => (0, import_chunk_67LU4GPQ.log)(
22718
22732
  ` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
22719
22733
  )
22720
22734
  );
@@ -23013,7 +23027,7 @@ function mergeSplitRanges(splitRanges) {
23013
23027
  var init_locals = (0, import_chunk_ABYVSU2C.__esm)({
23014
23028
  "src/readprg/locals.ts"() {
23015
23029
  "use strict";
23016
- (0, import_chunk_SG7ODKRM.init_logger)();
23030
+ (0, import_chunk_67LU4GPQ.init_logger)();
23017
23031
  init_bytecode();
23018
23032
  init_cflow();
23019
23033
  init_opcodes();
@@ -23126,16 +23140,16 @@ function sizeBasedPRE2(func, context) {
23126
23140
  delete bc.arg;
23127
23141
  return bc;
23128
23142
  };
23129
- if ((0, import_chunk_SG7ODKRM.wouldLog)("pre", 1)) {
23130
- if ((0, import_chunk_SG7ODKRM.wouldLog)("pre", 5)) {
23131
- (0, import_chunk_SG7ODKRM.log)(functionBanner(func, context, "PRE")());
23143
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 1)) {
23144
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 5)) {
23145
+ (0, import_chunk_67LU4GPQ.log)(functionBanner(func, context, "PRE")());
23132
23146
  } else {
23133
- (0, import_chunk_SG7ODKRM.log)(`================ PRE : ${func.name} ================
23147
+ (0, import_chunk_67LU4GPQ.log)(`================ PRE : ${func.name} ================
23134
23148
  `);
23135
23149
  }
23136
23150
  insertionBlocks.forEach((o, key) => {
23137
23151
  const bcs = canonicalMap.get(key);
23138
- (0, import_chunk_SG7ODKRM.log)(
23152
+ (0, import_chunk_67LU4GPQ.log)(
23139
23153
  `Replacing ${bcs.size} instances of ${bytecodeToString(
23140
23154
  bcs.values().next().value,
23141
23155
  context.symbolTable
@@ -23218,13 +23232,13 @@ function sizeBasedPRE2(func, context) {
23218
23232
  bytecode(1, insertionBlocks.size)
23219
23233
  );
23220
23234
  }
23221
- (0, import_chunk_SG7ODKRM.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
23235
+ (0, import_chunk_67LU4GPQ.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
23222
23236
  return true;
23223
23237
  }
23224
23238
  var init_pre2 = (0, import_chunk_ABYVSU2C.__esm)({
23225
23239
  "src/readprg/pre.ts"() {
23226
23240
  "use strict";
23227
- (0, import_chunk_SG7ODKRM.init_logger)();
23241
+ (0, import_chunk_67LU4GPQ.init_logger)();
23228
23242
  init_bytecode();
23229
23243
  init_cflow();
23230
23244
  init_opcodes();
@@ -23257,9 +23271,9 @@ function blockSharing(func, context) {
23257
23271
  if (!any)
23258
23272
  return false;
23259
23273
  any = false;
23260
- const logging3 = (0, import_chunk_SG7ODKRM.wouldLog)("sharing", 1);
23261
- if (logging3 && (0, import_chunk_SG7ODKRM.wouldLog)("sharing", 10)) {
23262
- (0, import_chunk_SG7ODKRM.setBanner)(functionBanner(func, context, "sharing"));
23274
+ const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 1);
23275
+ if (logging3 && (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 10)) {
23276
+ (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
23263
23277
  }
23264
23278
  candidates.forEach((blocks) => {
23265
23279
  while (blocks.size > 1) {
@@ -23395,9 +23409,9 @@ function blockSharing(func, context) {
23395
23409
  block2.offset
23396
23410
  )})` : `block(${offsetToString(block2.offset)})`;
23397
23411
  };
23398
- (0, import_chunk_SG7ODKRM.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23399
- if ((0, import_chunk_SG7ODKRM.wouldLog)("sharing", 5)) {
23400
- (0, import_chunk_SG7ODKRM.log)(blockToString(target, context));
23412
+ (0, import_chunk_67LU4GPQ.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23413
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("sharing", 5)) {
23414
+ (0, import_chunk_67LU4GPQ.log)(blockToString(target, context));
23401
23415
  }
23402
23416
  }
23403
23417
  if (target.bytecodes.length > length2) {
@@ -23424,13 +23438,13 @@ function blockSharing(func, context) {
23424
23438
  });
23425
23439
  }
23426
23440
  });
23427
- (0, import_chunk_SG7ODKRM.setBanner)(null);
23441
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
23428
23442
  return any;
23429
23443
  }
23430
23444
  var init_sharing = (0, import_chunk_ABYVSU2C.__esm)({
23431
23445
  "src/readprg/sharing.ts"() {
23432
23446
  "use strict";
23433
- (0, import_chunk_SG7ODKRM.init_util)();
23447
+ (0, import_chunk_67LU4GPQ.init_util)();
23434
23448
  init_bytecode();
23435
23449
  init_opcodes();
23436
23450
  }
@@ -23494,7 +23508,7 @@ function doArrayInits(func, liveInState, context) {
23494
23508
  }
23495
23509
  function simpleOpts(func, context) {
23496
23510
  const equalsSym = 8388787;
23497
- const logging3 = (0, import_chunk_SG7ODKRM.wouldLog)("optimize", 5);
23511
+ const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("optimize", 5);
23498
23512
  return Array.from(func.blocks.values()).reduce((changes, block) => {
23499
23513
  for (let i = block.bytecodes.length; i--; ) {
23500
23514
  const cur = block.bytecodes[i];
@@ -23502,7 +23516,7 @@ function simpleOpts(func, context) {
23502
23516
  block.bytecodes.splice(i, 1);
23503
23517
  changes = true;
23504
23518
  if (logging3) {
23505
- (0, import_chunk_SG7ODKRM.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23519
+ (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23506
23520
  }
23507
23521
  } else if (cur.op === 74 && context.config.removeArgc && context.config.allowForbiddenOpts) {
23508
23522
  const arg = cur.arg.incsp;
@@ -23511,7 +23525,7 @@ function simpleOpts(func, context) {
23511
23525
  incsp.arg = arg;
23512
23526
  changes = true;
23513
23527
  if (logging3) {
23514
- (0, import_chunk_SG7ODKRM.log)(`${func.name}: argcincsp => incsp`);
23528
+ (0, import_chunk_67LU4GPQ.log)(`${func.name}: argcincsp => incsp`);
23515
23529
  }
23516
23530
  } else if (i && cur.op === 39 && cur.arg === equalsSym) {
23517
23531
  changes = equalSymbolToEq(block, i) || changes;
@@ -23522,7 +23536,7 @@ function simpleOpts(func, context) {
23522
23536
  if (!shift && prev.op === 37) {
23523
23537
  block.bytecodes.splice(i - 1, 2);
23524
23538
  changes = true;
23525
- logging3 && (0, import_chunk_SG7ODKRM.log)(`${func.name}: deleting no-op shift (${shift})`);
23539
+ logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting no-op shift (${shift})`);
23526
23540
  continue;
23527
23541
  }
23528
23542
  if (shift === 1n && prev.op === 37) {
@@ -23532,7 +23546,7 @@ function simpleOpts(func, context) {
23532
23546
  const add = cur;
23533
23547
  add.op = 3;
23534
23548
  delete add.arg;
23535
- logging3 && (0, import_chunk_SG7ODKRM.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
23549
+ logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
23536
23550
  continue;
23537
23551
  }
23538
23552
  if (shift < (prev.op === 49 ? 64n : 31n)) {
@@ -23542,7 +23556,7 @@ function simpleOpts(func, context) {
23542
23556
  } else {
23543
23557
  prev.arg = BigInt.asIntN(64, mul);
23544
23558
  }
23545
- logging3 && (0, import_chunk_SG7ODKRM.log)(
23559
+ logging3 && (0, import_chunk_67LU4GPQ.log)(
23546
23560
  `${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
23547
23561
  );
23548
23562
  changes = true;
@@ -23556,14 +23570,14 @@ function simpleOpts(func, context) {
23556
23570
  func.blocks.get(block.taken).preds.delete(block.offset);
23557
23571
  delete block.taken;
23558
23572
  changes = true;
23559
- logging3 && (0, import_chunk_SG7ODKRM.log)(`${func.name}: deleting empty finally handler`);
23573
+ logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting empty finally handler`);
23560
23574
  } else if (isCondBranch(cur.op)) {
23561
23575
  const next = func.blocks.get(block.next);
23562
23576
  const taken = func.blocks.get(block.taken);
23563
23577
  if (next.preds.size > 1 && taken.preds.size === 1) {
23564
23578
  const newOp = cur.op === 40 ? 41 : 40;
23565
23579
  if (logging3) {
23566
- (0, import_chunk_SG7ODKRM.log)(
23580
+ (0, import_chunk_67LU4GPQ.log)(
23567
23581
  `${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
23568
23582
  );
23569
23583
  }
@@ -23576,7 +23590,7 @@ function simpleOpts(func, context) {
23576
23590
  const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
23577
23591
  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) {
23578
23592
  if (logging3) {
23579
- (0, import_chunk_SG7ODKRM.log)(
23593
+ (0, import_chunk_67LU4GPQ.log)(
23580
23594
  `${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23581
23595
  next.offset
23582
23596
  )}:${offsetToString(taken.offset)}:`
@@ -23593,7 +23607,7 @@ function simpleOpts(func, context) {
23593
23607
  changes = true;
23594
23608
  } 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) {
23595
23609
  if (logging3) {
23596
- (0, import_chunk_SG7ODKRM.log)(
23610
+ (0, import_chunk_67LU4GPQ.log)(
23597
23611
  `${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23598
23612
  taken.offset
23599
23613
  )}:${offsetToString(next.offset)}:`
@@ -23641,7 +23655,7 @@ function equalSymbolToEq(block, equalsIndex) {
23641
23655
  op: 26,
23642
23656
  offset: invokem.offset
23643
23657
  });
23644
- (0, import_chunk_SG7ODKRM.logger)(
23658
+ (0, import_chunk_67LU4GPQ.logger)(
23645
23659
  "optimize",
23646
23660
  1,
23647
23661
  `Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
@@ -23701,7 +23715,7 @@ function removeUnreachableCatches(func, context) {
23701
23715
  const next = func.blocks.get(block.next);
23702
23716
  if (block.try === next.try) {
23703
23717
  if (next.preds.size === 1) {
23704
- (0, import_chunk_SG7ODKRM.logger)(
23718
+ (0, import_chunk_67LU4GPQ.logger)(
23705
23719
  "cfg",
23706
23720
  1,
23707
23721
  () => `${func.name}: ${offsetToString(
@@ -23724,7 +23738,7 @@ function removeUnreachableCatches(func, context) {
23724
23738
  delete next.preds;
23725
23739
  removeBlock(func, next.offset);
23726
23740
  } else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + opcodeSize(bc.op), 0) < 3 && countFallthroughPreds(func, next) > 1) {
23727
- (0, import_chunk_SG7ODKRM.logger)(
23741
+ (0, import_chunk_67LU4GPQ.logger)(
23728
23742
  "cfg",
23729
23743
  1,
23730
23744
  () => `${func.name}: ${offsetToString(
@@ -23749,7 +23763,7 @@ function removeUnreachableCatches(func, context) {
23749
23763
  switch (last.op) {
23750
23764
  case 41:
23751
23765
  case 40:
23752
- (0, import_chunk_SG7ODKRM.logger)(
23766
+ (0, import_chunk_67LU4GPQ.logger)(
23753
23767
  "cfg",
23754
23768
  1,
23755
23769
  () => `${func.name}: killing no-op ${bytecodeToString(
@@ -23772,7 +23786,7 @@ function removeUnreachableCatches(func, context) {
23772
23786
  for (let i = block.try.length; i--; ) {
23773
23787
  const handler = block.try[i].handler;
23774
23788
  if (!func.blocks.get(handler)?.preds?.size) {
23775
- (0, import_chunk_SG7ODKRM.logger)(
23789
+ (0, import_chunk_67LU4GPQ.logger)(
23776
23790
  "cfg",
23777
23791
  1,
23778
23792
  `${func.name}: killing unused try-catch at ${offsetToString(
@@ -23789,8 +23803,8 @@ function removeUnreachableCatches(func, context) {
23789
23803
  });
23790
23804
  }
23791
23805
  function cleanCfg2(func, context) {
23792
- if ((0, import_chunk_SG7ODKRM.wouldLog)("cfg", 10)) {
23793
- (0, import_chunk_SG7ODKRM.setBanner)(functionBanner(func, context, "sharing"));
23806
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("cfg", 10)) {
23807
+ (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
23794
23808
  }
23795
23809
  removeNoOpBlocks(func);
23796
23810
  removeUnreachableCatches(func, context);
@@ -23805,12 +23819,12 @@ function cleanCfg2(func, context) {
23805
23819
  (0, import_node_assert12.default)(!block.preds?.size);
23806
23820
  func.blocks.delete(block.offset);
23807
23821
  });
23808
- (0, import_chunk_SG7ODKRM.setBanner)(null);
23822
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
23809
23823
  }
23810
23824
  var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
23811
23825
  "src/readprg/optimize.ts"() {
23812
23826
  "use strict";
23813
- (0, import_chunk_SG7ODKRM.init_util)();
23827
+ (0, import_chunk_67LU4GPQ.init_util)();
23814
23828
  init_array_init();
23815
23829
  init_bytecode();
23816
23830
  init_cflow();
@@ -24425,21 +24439,21 @@ function optimizeBytecode(context) {
24425
24439
  functions.forEach(callback);
24426
24440
  return;
24427
24441
  }
24428
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, 10);
24442
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24429
24443
  functions.forEach((func) => {
24430
24444
  if (loggerFunc.test(func.name ?? "<null>")) {
24431
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, -10);
24445
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24432
24446
  callback(func);
24433
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, 10);
24447
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24434
24448
  return;
24435
24449
  }
24436
24450
  callback(func);
24437
24451
  });
24438
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, -10);
24452
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24439
24453
  };
24440
- if ((0, import_chunk_SG7ODKRM.wouldLog)("list-input", 1)) {
24454
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1)) {
24441
24455
  forEachFunction(
24442
- (func) => (0, import_chunk_SG7ODKRM.wouldLog)("list-input", 1) && printFunction(func, context)
24456
+ (func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1) && printFunction(func, context)
24443
24457
  );
24444
24458
  }
24445
24459
  forEachFunction((func) => optimizeFunc(func, context));
@@ -24457,7 +24471,7 @@ function optimizeBytecode(context) {
24457
24471
  forEachFunction((func) => {
24458
24472
  if (!func.name)
24459
24473
  return;
24460
- (0, import_chunk_SG7ODKRM.logger)(
24474
+ (0, import_chunk_67LU4GPQ.logger)(
24461
24475
  "bytecode",
24462
24476
  5,
24463
24477
  `${func.name}: ${offset.toString(16)} ${offset - func.offset}`
@@ -24466,7 +24480,7 @@ function optimizeBytecode(context) {
24466
24480
  });
24467
24481
  const { offsetMap } = updateInfo;
24468
24482
  offsetMap.set(code.byteLength, offset);
24469
- (0, import_chunk_SG7ODKRM.logger)(
24483
+ (0, import_chunk_67LU4GPQ.logger)(
24470
24484
  "bytecode",
24471
24485
  1,
24472
24486
  `${context.filepath}: code size: ${context.sections[
@@ -24478,9 +24492,9 @@ function optimizeBytecode(context) {
24478
24492
  ].length - offset}`
24479
24493
  );
24480
24494
  fixSectionSize(-1059145026, context.sections, offset);
24481
- if ((0, import_chunk_SG7ODKRM.wouldLog)("list-output", 1)) {
24495
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1)) {
24482
24496
  forEachFunction(
24483
- (func) => (0, import_chunk_SG7ODKRM.wouldLog)("list-output", 1) && printFunction(func, context)
24497
+ (func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1) && printFunction(func, context)
24484
24498
  );
24485
24499
  }
24486
24500
  fixupHeader(context, updateInfo);
@@ -24570,7 +24584,7 @@ ${functionToString(
24570
24584
  ---------------- ${func.name} ----------------`;
24571
24585
  }
24572
24586
  function printFunction(func, context) {
24573
- (0, import_chunk_SG7ODKRM.log)(functionToString(func, context));
24587
+ (0, import_chunk_67LU4GPQ.log)(functionToString(func, context));
24574
24588
  }
24575
24589
  function functionToString(func, context, extra) {
24576
24590
  const parts = [];
@@ -25001,7 +25015,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
25001
25015
  "use strict";
25002
25016
  (0, import_chunk_MBTLUWXR.init_ast)();
25003
25017
  init_sdk_util();
25004
- (0, import_chunk_SG7ODKRM.init_util)();
25018
+ (0, import_chunk_67LU4GPQ.init_util)();
25005
25019
  init_data();
25006
25020
  init_emit();
25007
25021
  init_exceptions();
@@ -25287,10 +25301,10 @@ async function build_project(product, options, lineCallback) {
25287
25301
  ].flat();
25288
25302
  if (!returnCommand) {
25289
25303
  const handlers = [
25290
- lineCallback || ((line) => (0, import_chunk_SG7ODKRM.log)(line)),
25304
+ lineCallback || ((line) => (0, import_chunk_67LU4GPQ.log)(line)),
25291
25305
  (line) => console.error(line)
25292
25306
  ];
25293
- await (0, import_chunk_SG7ODKRM.spawnByLine)(exe, args, handlers, {
25307
+ await (0, import_chunk_67LU4GPQ.spawnByLine)(exe, args, handlers, {
25294
25308
  cwd: workspace
25295
25309
  });
25296
25310
  }
@@ -25300,7 +25314,7 @@ var init_build = (0, import_chunk_ABYVSU2C.__esm)({
25300
25314
  "src/build.ts"() {
25301
25315
  "use strict";
25302
25316
  init_sdk_util();
25303
- (0, import_chunk_SG7ODKRM.init_util)();
25317
+ (0, import_chunk_67LU4GPQ.init_util)();
25304
25318
  }
25305
25319
  });
25306
25320
  var require_ms = (0, import_chunk_ABYVSU2C.__commonJS)({
@@ -28267,7 +28281,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
28267
28281
  );
28268
28282
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(cache.resolvedPaths, resolved)) {
28269
28283
  if (/[*?[\]{}]/.test(resolved)) {
28270
- cache.resolvedPaths[resolved] = (0, import_chunk_SG7ODKRM.globSome)(resolved, () => true);
28284
+ cache.resolvedPaths[resolved] = (0, import_chunk_67LU4GPQ.globSome)(resolved, () => true);
28271
28285
  } else {
28272
28286
  cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
28273
28287
  () => true,
@@ -28345,12 +28359,12 @@ async function read_resource_files(targets, cache) {
28345
28359
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(resourceGroupPromises, key)) {
28346
28360
  resourceGroupPromises[key] = Promise.all(
28347
28361
  p.qualifier.resourcePath.map(
28348
- (pattern) => (0, import_chunk_SG7ODKRM.globa)(pattern, { mark: true })
28362
+ (pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { mark: true })
28349
28363
  )
28350
28364
  ).then(
28351
28365
  (patterns) => Promise.all(
28352
28366
  patterns.flat().map(
28353
- (path7) => path7.endsWith("/") ? (0, import_chunk_SG7ODKRM.globa)(`${path7}**/*.xml`, { mark: true }) : path7
28367
+ (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.xml`, { mark: true }) : path7
28354
28368
  )
28355
28369
  )
28356
28370
  ).then(
@@ -28410,7 +28424,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
28410
28424
  const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
28411
28425
  const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
28412
28426
  if (filePatterns.length) {
28413
- const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_SG7ODKRM.globa)(p)))).flat();
28427
+ const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_67LU4GPQ.globa)(p)))).flat();
28414
28428
  sourceExcludes.push(...files);
28415
28429
  }
28416
28430
  const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
@@ -28587,15 +28601,15 @@ function identify_optimizer_groups(targets, options) {
28587
28601
  function find_barrels(barrelPath) {
28588
28602
  if (Array.isArray(barrelPath)) {
28589
28603
  return Promise.all(
28590
- barrelPath.map((path7) => (0, import_chunk_SG7ODKRM.globa)(path7, { mark: true }))
28604
+ barrelPath.map((path7) => (0, import_chunk_67LU4GPQ.globa)(path7, { mark: true }))
28591
28605
  ).then((paths) => [
28592
28606
  paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
28593
28607
  ]);
28594
28608
  }
28595
- return (0, import_chunk_SG7ODKRM.globa)(barrelPath, { mark: true }).then(
28609
+ return (0, import_chunk_67LU4GPQ.globa)(barrelPath, { mark: true }).then(
28596
28610
  (paths) => Promise.all(
28597
28611
  paths.map(
28598
- (path7) => path7.endsWith("/") ? (0, import_chunk_SG7ODKRM.globa)(`${path7}**/*.barrel`) : path7
28612
+ (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.barrel`) : path7
28599
28613
  )
28600
28614
  )
28601
28615
  ).then(
@@ -28606,7 +28620,7 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
28606
28620
  if ((0, import_chunk_MBTLUWXR.hasProperty)(cache.barrels, barrel)) {
28607
28621
  return cache.barrels[barrel];
28608
28622
  }
28609
- let promise = Promise.resolve();
28623
+ let promise = Promise.resolve(null);
28610
28624
  let rawBarrel = barrel;
28611
28625
  if (barrel.endsWith(".barrel")) {
28612
28626
  const sha1 = crypto2.createHash("sha1").update(barrel, "binary").digest("base64").replace(/[/=+]/g, "");
@@ -28619,9 +28633,9 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
28619
28633
  () => fs5.stat(localPath).then(
28620
28634
  (localStat) => !localStat.isDirectory() || fs5.stat(barrel).then((barrelStat) => localStat.mtimeMs < barrelStat.mtimeMs),
28621
28635
  () => true
28622
- ).then((needsUpdate) => {
28623
- needsUpdate && fs5.rm(localPath, { recursive: true, force: true }).then(() => (0, import_extract_zip.default)(barrel, { dir: localPath }));
28624
- })
28636
+ ).then(
28637
+ (needsUpdate) => needsUpdate ? fs5.rm(localPath, { recursive: true, force: true }).catch(() => null).then(() => (0, import_extract_zip.default)(barrel, { dir: localPath })) : null
28638
+ )
28625
28639
  );
28626
28640
  }
28627
28641
  return promise.then(() => get_jungle_and_barrels(rawBarrel, products, options, cache)).then((result) => {
@@ -28868,7 +28882,7 @@ var init_jungles = (0, import_chunk_ABYVSU2C.__esm)({
28868
28882
  init_api();
28869
28883
  init_manifest();
28870
28884
  init_sdk_util();
28871
- (0, import_chunk_SG7ODKRM.init_util)();
28885
+ (0, import_chunk_67LU4GPQ.init_util)();
28872
28886
  depth = 0;
28873
28887
  }
28874
28888
  });
@@ -28896,7 +28910,7 @@ async function launchSimulator(force = true) {
28896
28910
  await new Promise((r) => setTimeout(r, 200));
28897
28911
  }
28898
28912
  } catch (e) {
28899
- (0, import_chunk_SG7ODKRM.log)(e);
28913
+ (0, import_chunk_67LU4GPQ.log)(e);
28900
28914
  }
28901
28915
  }
28902
28916
  function checkIfSimulatorRunning() {
@@ -28927,10 +28941,10 @@ function simulateProgram(prg, device, test = false, logger2) {
28927
28941
  }
28928
28942
  }
28929
28943
  return getSdkPath().then(
28930
- (sdk) => (0, import_chunk_SG7ODKRM.spawnByLine)(
28944
+ (sdk) => (0, import_chunk_67LU4GPQ.spawnByLine)(
28931
28945
  path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
28932
28946
  args,
28933
- logger2 || ((line) => (0, import_chunk_SG7ODKRM.log)(line))
28947
+ logger2 || ((line) => (0, import_chunk_67LU4GPQ.log)(line))
28934
28948
  ).then(() => {
28935
28949
  return;
28936
28950
  })
@@ -28940,7 +28954,7 @@ var init_launch = (0, import_chunk_ABYVSU2C.__esm)({
28940
28954
  "src/launch.ts"() {
28941
28955
  "use strict";
28942
28956
  init_sdk_util();
28943
- (0, import_chunk_SG7ODKRM.init_util)();
28957
+ (0, import_chunk_67LU4GPQ.init_util)();
28944
28958
  }
28945
28959
  });
28946
28960
  function relative_path_no_dotdot(relative2) {
@@ -28961,7 +28975,7 @@ async function getCodeWorkspaceSettings(folder) {
28961
28975
  let curDir = folder;
28962
28976
  try {
28963
28977
  while (curDir) {
28964
- const code_workspaces = await (0, import_chunk_SG7ODKRM.globa)(
28978
+ const code_workspaces = await (0, import_chunk_67LU4GPQ.globa)(
28965
28979
  path4.resolve(curDir, "*.code-workspace"),
28966
28980
  { onlyFiles: true }
28967
28981
  );
@@ -29084,7 +29098,7 @@ async function createLocalBarrels(targets, options) {
29084
29098
  optBarrelDir
29085
29099
  };
29086
29100
  return promise2.then(
29087
- () => (0, import_chunk_SG7ODKRM.copyRecursiveAsNeeded)(
29101
+ () => (0, import_chunk_67LU4GPQ.copyRecursiveAsNeeded)(
29088
29102
  rawBarrelDir,
29089
29103
  optBarrelDir,
29090
29104
  (src) => !src.endsWith(".mc")
@@ -29386,11 +29400,11 @@ async function generateOptimizedProject(options) {
29386
29400
  }
29387
29401
  async function filesFromPaths(workspace, paths, extension) {
29388
29402
  paths = (await Promise.all(
29389
- paths?.map((pattern) => (0, import_chunk_SG7ODKRM.globa)(pattern, { cwd: workspace, mark: true })) || []
29403
+ paths?.map((pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { cwd: workspace, mark: true })) || []
29390
29404
  )).flat();
29391
29405
  const files = await Promise.all(
29392
29406
  paths.map(
29393
- (path7) => path7.endsWith("/") ? (0, import_chunk_SG7ODKRM.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
29407
+ (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
29394
29408
  )
29395
29409
  );
29396
29410
  return {
@@ -29500,7 +29514,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29500
29514
  })
29501
29515
  );
29502
29516
  }
29503
- const actualOptimizedFiles = (await (0, import_chunk_SG7ODKRM.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
29517
+ const actualOptimizedFiles = (await (0, import_chunk_67LU4GPQ.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
29504
29518
  const {
29505
29519
  hasTests,
29506
29520
  diagnostics: prevDiagnostics,
@@ -29516,13 +29530,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29516
29530
  const sdk = await getSdkPath();
29517
29531
  const match = sdk.match(/-(\d+\.\d+\.\d+)/);
29518
29532
  if ((match && parseSdkVersion(match[1])) === prevSdkVersion) {
29519
- const source_time = await (0, import_chunk_SG7ODKRM.last_modified)(
29533
+ const source_time = await (0, import_chunk_67LU4GPQ.last_modified)(
29520
29534
  Object.keys(fnMap).concat(dependencyFiles)
29521
29535
  );
29522
- const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
29536
+ const opt_time = await (0, import_chunk_67LU4GPQ.first_modified)(
29523
29537
  Object.values(fnMap).map((v) => v.output)
29524
29538
  );
29525
- if (source_time < opt_time && 1717017718374 < opt_time) {
29539
+ if (source_time < opt_time && 1719447701318 < opt_time) {
29526
29540
  return {
29527
29541
  hasTests,
29528
29542
  diagnostics: prevDiagnostics,
@@ -29561,7 +29575,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29561
29575
  hasTests: hasTests2,
29562
29576
  diagnostics,
29563
29577
  sdkVersion,
29564
- optimizerVersion: "1.1.64",
29578
+ optimizerVersion: "1.1.65",
29565
29579
  ...Object.fromEntries(
29566
29580
  configOptionsToCheck.map((option) => [option, config[option]])
29567
29581
  )
@@ -29575,7 +29589,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
29575
29589
  try {
29576
29590
  return getProjectAnalysisHelper(targets, analysis, manifestXML, options);
29577
29591
  } catch (ex) {
29578
- if (ex instanceof import_chunk_SG7ODKRM.AwaitedError) {
29592
+ if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
29579
29593
  await ex.resolve();
29580
29594
  }
29581
29595
  throw ex;
@@ -29583,13 +29597,17 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
29583
29597
  }
29584
29598
  async function getProjectAnalysisHelper(targets, analysis, manifestXML, options) {
29585
29599
  const qualifiers = /* @__PURE__ */ new Map();
29586
- const addQualifier = (name, qualifier) => {
29600
+ const addQualifier = (name, qualifier, root) => {
29587
29601
  const sp = qualifier.sourcePath;
29588
29602
  const pp = qualifier.personality;
29589
29603
  if (sp || pp) {
29590
29604
  let q = qualifiers.get(name);
29591
29605
  if (!q) {
29592
- q = { sourcePath: /* @__PURE__ */ new Set(), personality: /* @__PURE__ */ new Set() };
29606
+ q = {
29607
+ sourcePath: /* @__PURE__ */ new Set(),
29608
+ personality: /* @__PURE__ */ new Set(),
29609
+ root
29610
+ };
29593
29611
  qualifiers.set(name, q);
29594
29612
  }
29595
29613
  sp?.forEach((s) => q.sourcePath.add(s));
@@ -29597,10 +29615,10 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29597
29615
  }
29598
29616
  };
29599
29617
  const products = targets.map(({ qualifier, product }) => {
29600
- addQualifier("", qualifier);
29618
+ addQualifier("", qualifier, options.workspace);
29601
29619
  if (qualifier.barrelMap) {
29602
29620
  Object.entries(qualifier.barrelMap).forEach(([name, bm]) => {
29603
- addQualifier(name, bm.qualifier);
29621
+ addQualifier(name, bm.qualifier, path4.dirname(bm.jungles[0]));
29604
29622
  });
29605
29623
  }
29606
29624
  return product;
@@ -29608,7 +29626,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29608
29626
  const { fnMap, paths } = await Promise.all(
29609
29627
  Array.from(qualifiers).map(
29610
29628
  ([name, qualifier]) => fileInfoFromConfig(
29611
- options.workspace,
29629
+ qualifier.root,
29612
29630
  options.workspace,
29613
29631
  {
29614
29632
  sourcePath: Array.from(qualifier.sourcePath),
@@ -29624,7 +29642,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29624
29642
  if (!cur)
29625
29643
  return result;
29626
29644
  Object.entries(result.fnMap).forEach(
29627
- ([key, value2]) => cur.fnMap[key] = value2
29645
+ ([key, value2]) => cur.fnMap[key] || (cur.fnMap[key] = value2)
29628
29646
  );
29629
29647
  cur.paths.push(...result.paths);
29630
29648
  return cur;
@@ -29722,7 +29740,7 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
29722
29740
  init_could_be();
29723
29741
  init_interp();
29724
29742
  init_sub_type();
29725
- (0, import_chunk_SG7ODKRM.init_util)();
29743
+ (0, import_chunk_67LU4GPQ.init_util)();
29726
29744
  init_worker_pool();
29727
29745
  init_optimizer_types();
29728
29746
  init_types();
@@ -29782,7 +29800,7 @@ async function performTask(task) {
29782
29800
  throw new Error(`Invalid task type ${type}`);
29783
29801
  }
29784
29802
  return Promise.resolve(handler(task.data)).then(
29785
- (result) => import_chunk_SG7ODKRM.logPromise.then(() => result)
29803
+ (result) => import_chunk_67LU4GPQ.logPromise.then(() => result)
29786
29804
  );
29787
29805
  }
29788
29806
  var workerTaskHandlers;
@@ -29792,7 +29810,7 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
29792
29810
  init_optimizer();
29793
29811
  init_readprg();
29794
29812
  init_sdk_util();
29795
- (0, import_chunk_SG7ODKRM.init_logger)();
29813
+ (0, import_chunk_67LU4GPQ.init_logger)();
29796
29814
  workerTaskHandlers = {
29797
29815
  buildOptimizedProject(data) {
29798
29816
  return buildOptimizedProject(data.product, data.options);
@@ -30009,7 +30027,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
30009
30027
  }
30010
30028
  function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, config) {
30011
30029
  const { sections } = readPrgWithOffsets(view);
30012
- (0, import_chunk_SG7ODKRM.logger)("readprg", 5, sections);
30030
+ (0, import_chunk_67LU4GPQ.logger)("readprg", 5, sections);
30013
30031
  const symbolTable = new SymbolTable();
30014
30032
  if ((0, import_chunk_MBTLUWXR.hasProperty)(sections, 1461170197 .toString())) {
30015
30033
  symbolTable.parse(sections[
@@ -30309,7 +30327,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
30309
30327
  init_signer();
30310
30328
  init_symbols();
30311
30329
  init_sdk_util();
30312
- (0, import_chunk_SG7ODKRM.init_util)();
30330
+ (0, import_chunk_67LU4GPQ.init_util)();
30313
30331
  init_worker_pool();
30314
30332
  }
30315
30333
  });
@@ -30321,7 +30339,7 @@ function getSdkPath() {
30321
30339
  });
30322
30340
  }
30323
30341
  async function getDeviceInfo() {
30324
- const files = await (0, import_chunk_SG7ODKRM.globa)(`${connectiq}/Devices/*/compiler.json`);
30342
+ const files = await (0, import_chunk_67LU4GPQ.globa)(`${connectiq}/Devices/*/compiler.json`);
30325
30343
  if (!files.length) {
30326
30344
  throw new Error(
30327
30345
  `No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
@@ -30389,7 +30407,7 @@ async function getFunctionDocumentation() {
30389
30407
  var isWin, appSupport, connectiq;
30390
30408
  var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
30391
30409
  "src/sdk-util.ts"() {
30392
- (0, import_chunk_SG7ODKRM.init_util)();
30410
+ (0, import_chunk_67LU4GPQ.init_util)();
30393
30411
  init_xml_util();
30394
30412
  init_readprg();
30395
30413
  init_bytecode();