@markw65/monkeyc-optimizer 1.1.63 → 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_Y2ZRISYL_exports = {};
30
- __export(chunk_Y2ZRISYL_exports, {
29
+ var chunk_MDTDXRQB_exports = {};
30
+ __export(chunk_MDTDXRQB_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -37,6 +37,7 @@ __export(chunk_Y2ZRISYL_exports, {
37
37
  TruthyTypes: () => TruthyTypes,
38
38
  analyze: () => analyze,
39
39
  appSupport: () => appSupport,
40
+ buildConfigDescription: () => buildConfigDescription,
40
41
  buildOptimizedProject: () => buildOptimizedProject,
41
42
  checkCompilerVersion: () => checkCompilerVersion,
42
43
  collectNamespaces: () => collectNamespaces,
@@ -133,8 +134,8 @@ __export(chunk_Y2ZRISYL_exports, {
133
134
  visitorNode: () => visitorNode,
134
135
  xml_util_exports: () => xml_util_exports
135
136
  });
136
- module.exports = __toCommonJS(chunk_Y2ZRISYL_exports);
137
- var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
137
+ module.exports = __toCommonJS(chunk_MDTDXRQB_exports);
138
+ var import_chunk_67LU4GPQ = require("./chunk-67LU4GPQ.cjs");
138
139
  var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
139
140
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
140
141
  var import_node_assert = __toESM(require("node:assert"));
@@ -5560,10 +5561,289 @@ var init_function_info = (0, import_chunk_ABYVSU2C.__esm)({
5560
5561
  (0, import_chunk_MBTLUWXR.init_ast)();
5561
5562
  }
5562
5563
  });
5564
+ var buildConfigDescription;
5565
+ var init_build_config = (0, import_chunk_ABYVSU2C.__esm)({
5566
+ "src/build-config.ts"() {
5567
+ "use strict";
5568
+ buildConfigDescription = [
5569
+ {
5570
+ title: "Optimizer",
5571
+ type: "object",
5572
+ properties: {
5573
+ outputPath: {
5574
+ type: "string",
5575
+ description: "Path to where the optimized project should be generated.",
5576
+ default: "bin/optimized",
5577
+ scope: "resource"
5578
+ },
5579
+ extraExcludes: {
5580
+ type: "string",
5581
+ markdownDescription: "[Semicolon separated list of excludeAnnotations to add or remove](https://github.com/markw65/monkeyc-optimizer/wiki/The-extraExcludes-Option)",
5582
+ default: "",
5583
+ scope: "resource"
5584
+ },
5585
+ ignoredExcludeAnnotations: {
5586
+ type: "string",
5587
+ description: "Semicolon separated list of excludeAnnotations to ignore, or `*' to ignore all",
5588
+ default: "",
5589
+ scope: "resource"
5590
+ },
5591
+ ignoredAnnotations: {
5592
+ type: "string",
5593
+ description: "Semicolon separated list of annotations to ignore, or `*' to ignore all",
5594
+ default: "",
5595
+ scope: "resource"
5596
+ },
5597
+ ignoredSourcePaths: {
5598
+ type: "string",
5599
+ description: "Regex of source paths to ignore.",
5600
+ default: "",
5601
+ scope: "resource"
5602
+ },
5603
+ typeCheckLevel: {
5604
+ type: "string",
5605
+ description: "Unless set to 'Default', overrides the corresponding `monkeyC' setting.",
5606
+ taskDescription: "If present, overrides the corresponding `monkeyC' setting.",
5607
+ launchDescription: "If present, overrides the corresponding `monkeyC' setting.",
5608
+ default: "Off",
5609
+ enum: ["Off", "Default", "Gradual", "Informative", "Strict"],
5610
+ enumDescriptions: [
5611
+ "Disable type checking",
5612
+ "Inherit the Garmin Extension's typeCheckLevel",
5613
+ "Type match failures are marked as errors, but ambiguity is ignored",
5614
+ "Type match failures are marked as errors, and ambiguity is marked as a warning",
5615
+ "Type match failures and ambiguity are marked as errors"
5616
+ ],
5617
+ scope: "resource"
5618
+ },
5619
+ checkInvalidSymbols: {
5620
+ type: "string",
5621
+ description: "Whether to check for invalid symbols, and how to report them",
5622
+ enum: ["OFF", "INFO", "WARNING", "ERROR"],
5623
+ enumDescriptions: [
5624
+ "Disable checking",
5625
+ "Generate INFO level diagnostics",
5626
+ "Generate WARNING level diagnostics",
5627
+ "Generate ERROR level diagnostics"
5628
+ ],
5629
+ default: "WARNING",
5630
+ scope: "resource"
5631
+ },
5632
+ checkTypes: {
5633
+ type: "string",
5634
+ description: "Whether to check for type related issues, and how to report them",
5635
+ enum: ["OFF", "INFO", "WARNING", "ERROR"],
5636
+ enumDescriptions: [
5637
+ "Disable checking",
5638
+ "Generate INFO level diagnostics",
5639
+ "Generate WARNING level diagnostics",
5640
+ "Generate ERROR level diagnostics"
5641
+ ],
5642
+ default: "WARNING",
5643
+ scope: "resource"
5644
+ },
5645
+ trustDeclaredTypes: {
5646
+ order: 10,
5647
+ type: "boolean",
5648
+ markdownDescription: "[Whether to rely on type declarations when optimizing](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#trust-declared-types)",
5649
+ default: true,
5650
+ scope: "resource"
5651
+ },
5652
+ propagateTypes: {
5653
+ order: 11,
5654
+ type: "boolean",
5655
+ markdownDescription: "[Whether to propagate type information, or process it locally](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#propagate-types)",
5656
+ default: true,
5657
+ scope: "resource"
5658
+ },
5659
+ sizeBasedPRE: {
5660
+ order: 11,
5661
+ type: "boolean",
5662
+ markdownDescription: "[Whether to enable the size based partial redundancy pass](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre)",
5663
+ default: true,
5664
+ scope: "resource"
5665
+ },
5666
+ minimizeLocals: {
5667
+ order: 12,
5668
+ type: "boolean",
5669
+ markdownDescription: "[Whether to enable the minimize locals pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#minimize-locals)",
5670
+ default: true,
5671
+ scope: "resource"
5672
+ },
5673
+ singleUseCopyProp: {
5674
+ order: 12,
5675
+ type: "boolean",
5676
+ markdownDescription: "[Whether to enable the single use copy propagation pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#single-use-copy-propagation)",
5677
+ default: true,
5678
+ scope: "resource"
5679
+ },
5680
+ minimizeModules: {
5681
+ order: 12,
5682
+ type: "boolean",
5683
+ markdownDescription: "[Whether to enable the minimize modules pass](https://github.com/markw65/monkeyc-optimizer/wiki/Optimizing-module-imports#minimize-modules)",
5684
+ default: true,
5685
+ scope: "resource"
5686
+ },
5687
+ iterateOptimizer: {
5688
+ order: 12,
5689
+ type: "boolean",
5690
+ description: "Whether to keep running the optimizer pass until it makes no further changes (may be slow)",
5691
+ default: false,
5692
+ scope: "resource"
5693
+ },
5694
+ enforceStatic: {
5695
+ type: "string",
5696
+ description: "Whether to perform lookups in static methods as if they were invoked statically",
5697
+ enum: ["NO", "YES"],
5698
+ enumDescriptions: [
5699
+ "Assume static functions may be invoked non-statically",
5700
+ "Assume static functions will always be invoked statically"
5701
+ ],
5702
+ default: "YES",
5703
+ scope: "resource"
5704
+ },
5705
+ compilerLookupRules: {
5706
+ type: "string",
5707
+ description: "Whether to perform lookups as compiler1, compiler2, or based on the currently selected sdk",
5708
+ enum: ["COMPILER1", "COMPILER2", "DEFAULT"],
5709
+ enumDescriptions: [
5710
+ "Match compiler1's behavior when performing lookups",
5711
+ "Match compiler2's behavior when performing lookups",
5712
+ "Match the currently selected compiler's behavior"
5713
+ ],
5714
+ default: "DEFAULT",
5715
+ scope: "resource"
5716
+ },
5717
+ checkCompilerLookupRules: {
5718
+ type: "string",
5719
+ description: "Whether to report differences in your code's behavior between compiler1 and compiler2",
5720
+ enum: ["OFF", "INFO", "WARNING", "ERROR"],
5721
+ enumDescriptions: [
5722
+ "Disable checking",
5723
+ "Generate INFO level diagnostics",
5724
+ "Generate WARNING level diagnostics",
5725
+ "Generate ERROR level diagnostics"
5726
+ ],
5727
+ default: "WARNING",
5728
+ scope: "resource"
5729
+ },
5730
+ useLocalOptimizer: {
5731
+ type: "boolean",
5732
+ description: "Whether to use a locally installed @markw65/monkeyc-optimizer for builds",
5733
+ default: true,
5734
+ scope: "resource"
5735
+ }
5736
+ }
5737
+ },
5738
+ {
5739
+ title: "Post Build Optimizer",
5740
+ type: "object",
5741
+ properties: {
5742
+ postBuildOptimizer: {
5743
+ title: "Enable",
5744
+ order: 0,
5745
+ type: "boolean",
5746
+ description: "Whether to enable the post build optimizer",
5747
+ default: false,
5748
+ scope: "resource"
5749
+ },
5750
+ removeArgc: {
5751
+ order: 1,
5752
+ type: "boolean",
5753
+ markdownDescription: "[Whether to remove argc bytecodes](https://github.com/markw65/monkeyc-optimizer/wiki/Post-Build-Optimizer#remove-argc). Does not apply to exports",
5754
+ default: false,
5755
+ scope: "resource"
5756
+ },
5757
+ allowForbiddenOpts: {
5758
+ order: 2,
5759
+ type: "boolean",
5760
+ markdownDescription: "[Whether to perform optimizations no longer allowed on the app store](https://github.com/markw65/monkeyc-optimizer/wiki/Post-Build-Optimizer#allow-forbidden-optimizations). Always false for exports",
5761
+ default: false,
5762
+ scope: "resource"
5763
+ },
5764
+ postBuildPRE: {
5765
+ order: 3,
5766
+ type: "boolean",
5767
+ markdownDescription: "Post Build Size based PRE [similar to the source-to-source pass](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre)",
5768
+ default: true,
5769
+ scope: "resource"
5770
+ }
5771
+ }
5772
+ },
5773
+ {
5774
+ title: "OnlyTasks",
5775
+ type: "object",
5776
+ properties: {
5777
+ device: {
5778
+ type: "string",
5779
+ taskDescription: "The device to build for. The special value `export' will do an iq build into bin/export, and the value `choose' will let you pick the device from a list",
5780
+ launchDescription: "Device to run or 'choose' or '${command:GetTargetDevice}' to choose a new device each run.",
5781
+ scope: "tasks_launch"
5782
+ },
5783
+ releaseBuild: {
5784
+ type: "boolean",
5785
+ taskDescription: "Is this a release build.",
5786
+ launchDescription: "Run a release build.",
5787
+ scope: "tasks_launch"
5788
+ },
5789
+ runTests: {
5790
+ type: "boolean",
5791
+ description: "run test cases.",
5792
+ default: false,
5793
+ scope: "launch"
5794
+ },
5795
+ jungleFiles: {
5796
+ type: "string",
5797
+ description: "If present, overrides the corresponding `monkeyC' setting.",
5798
+ scope: "tasks_launch"
5799
+ },
5800
+ developerKeyPath: {
5801
+ type: "string",
5802
+ description: "If present, overrides the corresponding `monkeyC' setting.",
5803
+ scope: "tasks_launch"
5804
+ },
5805
+ optimizationLevel: {
5806
+ type: "string",
5807
+ description: "If present, overrides the corresponding `monkeyC' setting.",
5808
+ enum: ["None", "Basic", "Fast", "Slow"],
5809
+ enumDescriptions: [
5810
+ "No optimization",
5811
+ "Basic optimizations for building in debug",
5812
+ "Fast optimizations for building in release",
5813
+ "Slow optimizations that need more time"
5814
+ ],
5815
+ scope: "tasks_launch"
5816
+ },
5817
+ compilerOptions: {
5818
+ type: "string",
5819
+ description: "If present, overrides the corresponding `monkeyC' setting.",
5820
+ scope: "tasks_launch"
5821
+ },
5822
+ compilerWarnings: {
5823
+ type: "boolean",
5824
+ description: "If present, overrides the corresponding `monkeyC' setting.",
5825
+ scope: "tasks_launch"
5826
+ },
5827
+ simulatorBuild: {
5828
+ type: "boolean",
5829
+ description: "Is this build for the simulator.",
5830
+ scope: "tasks"
5831
+ },
5832
+ testBuild: {
5833
+ type: "boolean",
5834
+ description: "Is this a test build.",
5835
+ scope: "tasks"
5836
+ }
5837
+ }
5838
+ }
5839
+ ];
5840
+ }
5841
+ });
5563
5842
  var StateNodeAttributes;
5564
5843
  var init_optimizer_types = (0, import_chunk_ABYVSU2C.__esm)({
5565
5844
  "src/optimizer-types.ts"() {
5566
5845
  "use strict";
5846
+ init_build_config();
5567
5847
  StateNodeAttributes = /* @__PURE__ */ ((StateNodeAttributes2) => {
5568
5848
  StateNodeAttributes2[StateNodeAttributes2["NONE"] = 0] = "NONE";
5569
5849
  StateNodeAttributes2[StateNodeAttributes2["PUBLIC"] = 1] = "PUBLIC";
@@ -7039,9 +7319,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
7039
7319
  );
7040
7320
  }
7041
7321
  } else {
7042
- (0, import_chunk_SG7ODKRM.forEach)(events, (e) => e.mayThrow = false);
7322
+ (0, import_chunk_67LU4GPQ.forEach)(events, (e) => e.mayThrow = false);
7043
7323
  }
7044
- (0, import_chunk_SG7ODKRM.forEach)(events, (event) => {
7324
+ (0, import_chunk_67LU4GPQ.forEach)(events, (event) => {
7045
7325
  if (event.mayThrow) {
7046
7326
  for (let i = localState.stack.length; i--; ) {
7047
7327
  const target = localState.stack[i].throw;
@@ -7186,7 +7466,7 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7186
7466
  "src/control-flow.ts"() {
7187
7467
  "use strict";
7188
7468
  (0, import_chunk_MBTLUWXR.init_ast)();
7189
- (0, import_chunk_SG7ODKRM.init_util)();
7469
+ (0, import_chunk_67LU4GPQ.init_util)();
7190
7470
  Terminals = {
7191
7471
  BreakStatement: "break",
7192
7472
  ContinueStatement: "continue",
@@ -7216,12 +7496,12 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7216
7496
  if (!from.succs) {
7217
7497
  from.succs = [to];
7218
7498
  } else {
7219
- (0, import_chunk_SG7ODKRM.pushUnique)(from.succs, to);
7499
+ (0, import_chunk_67LU4GPQ.pushUnique)(from.succs, to);
7220
7500
  }
7221
7501
  if (!to.preds) {
7222
7502
  to.preds = [from];
7223
7503
  } else {
7224
- (0, import_chunk_SG7ODKRM.pushUnique)(to.preds, from);
7504
+ (0, import_chunk_67LU4GPQ.pushUnique)(to.preds, from);
7225
7505
  }
7226
7506
  }
7227
7507
  newBlock(block) {
@@ -7575,8 +7855,8 @@ function mergeObjectValues(to, from) {
7575
7855
  function mergeStateDecls(to, from) {
7576
7856
  let changed = false;
7577
7857
  let result = to;
7578
- (0, import_chunk_SG7ODKRM.forEach)(from, (v) => {
7579
- 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)) {
7580
7860
  return;
7581
7861
  }
7582
7862
  if (Array.isArray(result)) {
@@ -7743,7 +8023,7 @@ var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
7743
8023
  "use strict";
7744
8024
  (0, import_chunk_MBTLUWXR.init_ast)();
7745
8025
  init_data_flow();
7746
- (0, import_chunk_SG7ODKRM.init_util)();
8026
+ (0, import_chunk_67LU4GPQ.init_util)();
7747
8027
  init_could_be();
7748
8028
  init_intersection_type();
7749
8029
  init_sub_type();
@@ -7758,7 +8038,7 @@ function expandTypedef(t) {
7758
8038
  );
7759
8039
  const tExpanded = cloneType(t);
7760
8040
  clearValuesUnder(tExpanded, 262144, true);
7761
- (0, import_chunk_SG7ODKRM.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
8041
+ (0, import_chunk_67LU4GPQ.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
7762
8042
  return tExpanded;
7763
8043
  }
7764
8044
  function intersectEnum(t, e) {
@@ -7952,9 +8232,9 @@ function intersectionValue(pair) {
7952
8232
  case 4096:
7953
8233
  case 8192: {
7954
8234
  const common = [];
7955
- (0, import_chunk_SG7ODKRM.forEach)(
8235
+ (0, import_chunk_67LU4GPQ.forEach)(
7956
8236
  pair.avalue,
7957
- (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)
7958
8238
  );
7959
8239
  if (!common.length)
7960
8240
  return null;
@@ -7962,9 +8242,9 @@ function intersectionValue(pair) {
7962
8242
  }
7963
8243
  case 16384: {
7964
8244
  const common = [];
7965
- (0, import_chunk_SG7ODKRM.forEach)(pair.avalue, (sna) => {
8245
+ (0, import_chunk_67LU4GPQ.forEach)(pair.avalue, (sna) => {
7966
8246
  const superA = getSuperClasses(sna);
7967
- (0, import_chunk_SG7ODKRM.forEach)(pair.bvalue, (snb) => {
8247
+ (0, import_chunk_67LU4GPQ.forEach)(pair.bvalue, (snb) => {
7968
8248
  if (sna === snb || superA && superA.has(snb)) {
7969
8249
  common.push(sna);
7970
8250
  }
@@ -8210,7 +8490,7 @@ function restrictExactTypesByEquality(a, b) {
8210
8490
  }
8211
8491
  case 262144:
8212
8492
  return restrictByEquality(
8213
- (0, import_chunk_SG7ODKRM.reduce)(
8493
+ (0, import_chunk_67LU4GPQ.reduce)(
8214
8494
  a.value,
8215
8495
  (cur, decl) => {
8216
8496
  unionInto(cur, decl.resolvedType);
@@ -8277,7 +8557,7 @@ var init_intersection_type = (0, import_chunk_ABYVSU2C.__esm)({
8277
8557
  "use strict";
8278
8558
  init_api();
8279
8559
  init_data_flow();
8280
- (0, import_chunk_SG7ODKRM.init_util)();
8560
+ (0, import_chunk_67LU4GPQ.init_util)();
8281
8561
  init_could_be();
8282
8562
  init_interp();
8283
8563
  init_types();
@@ -8391,14 +8671,14 @@ function subtypeOfValue(pair) {
8391
8671
  case 8192: {
8392
8672
  const asd = pair.avalue;
8393
8673
  const bsd = pair.bvalue;
8394
- 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));
8395
8675
  }
8396
8676
  case 16384: {
8397
8677
  const asd = pair.avalue;
8398
8678
  const bsd = pair.bvalue;
8399
- return (0, import_chunk_SG7ODKRM.every)(asd, (sna) => {
8679
+ return (0, import_chunk_67LU4GPQ.every)(asd, (sna) => {
8400
8680
  const superA = getSuperClasses(sna);
8401
- return (0, import_chunk_SG7ODKRM.some)(bsd, (snb) => {
8681
+ return (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => {
8402
8682
  if (sna === snb || superA && superA.has(snb)) {
8403
8683
  return true;
8404
8684
  }
@@ -8434,7 +8714,7 @@ var init_sub_type = (0, import_chunk_ABYVSU2C.__esm)({
8434
8714
  "use strict";
8435
8715
  init_api();
8436
8716
  init_data_flow();
8437
- (0, import_chunk_SG7ODKRM.init_util)();
8717
+ (0, import_chunk_67LU4GPQ.init_util)();
8438
8718
  init_could_be();
8439
8719
  init_intersection_type();
8440
8720
  init_types();
@@ -8855,13 +9135,13 @@ function isTypeStateKey(decl) {
8855
9135
  return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
8856
9136
  }
8857
9137
  function declIsLocal(decl) {
8858
- return (0, import_chunk_SG7ODKRM.some)(
9138
+ return (0, import_chunk_67LU4GPQ.some)(
8859
9139
  decl,
8860
9140
  (d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
8861
9141
  );
8862
9142
  }
8863
9143
  function declIsNonLocal(decl) {
8864
- 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));
8865
9145
  }
8866
9146
  function localDeclName(decl) {
8867
9147
  if (Array.isArray(decl))
@@ -8874,12 +9154,12 @@ function localDeclName(decl) {
8874
9154
  case "VariableDeclarator":
8875
9155
  return variableDeclarationName(decl.node.id);
8876
9156
  }
8877
- throw new import_chunk_SG7ODKRM.AwaitedError(
9157
+ throw new import_chunk_67LU4GPQ.AwaitedError(
8878
9158
  declFullName(decl).then((declStr) => `Invalid local decl: ${declStr}`)
8879
9159
  );
8880
9160
  }
8881
9161
  function tsKey(key) {
8882
- return `${(0, import_chunk_SG7ODKRM.map)(key, (k) => {
9162
+ return `${(0, import_chunk_67LU4GPQ.map)(key, (k) => {
8883
9163
  if (k.type === "Literal") {
8884
9164
  return k.raw;
8885
9165
  } else if (isStateNode(k)) {
@@ -8898,7 +9178,7 @@ function sourceLocation(loc) {
8898
9178
  return loc ? `${loc.source || "??"}:${loc.start.line}:${loc.start.column}` : "??";
8899
9179
  }
8900
9180
  function printBlockHeader(block) {
8901
- (0, import_chunk_SG7ODKRM.log)(
9181
+ (0, import_chunk_67LU4GPQ.log)(
8902
9182
  block.order,
8903
9183
  `(${block.node?.loc?.source || "??"}:${block.node?.loc?.start.line || "??"})`,
8904
9184
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
@@ -8912,10 +9192,10 @@ function describeEvent(event) {
8912
9192
  ).then((desc) => `${event.type}: ${desc}`);
8913
9193
  }
8914
9194
  function printBlockEvents(block, extra) {
8915
- (0, import_chunk_SG7ODKRM.log)("Events:");
8916
- (0, import_chunk_SG7ODKRM.forEach)(
9195
+ (0, import_chunk_67LU4GPQ.log)("Events:");
9196
+ (0, import_chunk_67LU4GPQ.forEach)(
8917
9197
  block.events,
8918
- (event) => (0, import_chunk_SG7ODKRM.log)(
9198
+ (event) => (0, import_chunk_67LU4GPQ.log)(
8919
9199
  describeEvent(event).then(
8920
9200
  (eventStr) => ` ${eventStr} ${extra ? extra(event) : ""}`
8921
9201
  )
@@ -8923,7 +9203,7 @@ function printBlockEvents(block, extra) {
8923
9203
  );
8924
9204
  }
8925
9205
  function printBlockTrailer(block) {
8926
- (0, import_chunk_SG7ODKRM.log)(
9206
+ (0, import_chunk_67LU4GPQ.log)(
8927
9207
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
8928
9208
  );
8929
9209
  }
@@ -9055,7 +9335,7 @@ var init_type_flow_util = (0, import_chunk_ABYVSU2C.__esm)({
9055
9335
  "use strict";
9056
9336
  init_api();
9057
9337
  init_data_flow();
9058
- (0, import_chunk_SG7ODKRM.init_util)();
9338
+ (0, import_chunk_67LU4GPQ.init_util)();
9059
9339
  init_intersection_type();
9060
9340
  init_sub_type();
9061
9341
  init_types();
@@ -9109,7 +9389,7 @@ function calleeObjectType(istate, callee) {
9109
9389
  }
9110
9390
  function checkCallArgs(istate, node, callees, args) {
9111
9391
  const allDiags = [];
9112
- const resultType = (0, import_chunk_SG7ODKRM.reduce)(
9392
+ const resultType = (0, import_chunk_67LU4GPQ.reduce)(
9113
9393
  callees,
9114
9394
  (result, cur) => {
9115
9395
  const curDiags = [];
@@ -9268,7 +9548,7 @@ function isOverride(cur, funcs) {
9268
9548
  const cls = cur.stack?.[cur.stack.length - 1]?.sn;
9269
9549
  if (cls?.type === "ClassDeclaration" && cls.superClasses) {
9270
9550
  const supers = getSuperClasses(cls);
9271
- if (supers && (0, import_chunk_SG7ODKRM.some)(funcs, (func) => {
9551
+ if (supers && (0, import_chunk_67LU4GPQ.some)(funcs, (func) => {
9272
9552
  if (func === cur)
9273
9553
  return false;
9274
9554
  const fcls = func.stack?.[func.stack.length - 1].sn;
@@ -9754,7 +10034,7 @@ var init_interp_call = (0, import_chunk_ABYVSU2C.__esm)({
9754
10034
  "use strict";
9755
10035
  init_optimizer_types();
9756
10036
  init_api();
9757
- (0, import_chunk_SG7ODKRM.init_util)();
10037
+ (0, import_chunk_67LU4GPQ.init_util)();
9758
10038
  init_interp();
9759
10039
  init_sub_type();
9760
10040
  init_types();
@@ -10879,7 +11159,7 @@ function mustBeIdentical(a, b) {
10879
11159
  return false;
10880
11160
  }
10881
11161
  function isByteArrayData(objectData) {
10882
- return objectData.klass.value && (0, import_chunk_SG7ODKRM.every)(
11162
+ return objectData.klass.value && (0, import_chunk_67LU4GPQ.every)(
10883
11163
  objectData.klass.value,
10884
11164
  (klass) => klass.fullName === "$.Toybox.Lang.ByteArray"
10885
11165
  );
@@ -10891,7 +11171,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
10891
11171
  (0, import_chunk_MBTLUWXR.init_ast)();
10892
11172
  init_data_flow();
10893
11173
  init_optimizer_types();
10894
- (0, import_chunk_SG7ODKRM.init_util)();
11174
+ (0, import_chunk_67LU4GPQ.init_util)();
10895
11175
  init_could_be();
10896
11176
  init_interp_binary();
10897
11177
  init_interp_call();
@@ -11122,7 +11402,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
11122
11402
  );
11123
11403
  if (value2) {
11124
11404
  const a = [];
11125
- (0, import_chunk_SG7ODKRM.forEach)(value2, (v) => {
11405
+ (0, import_chunk_67LU4GPQ.forEach)(value2, (v) => {
11126
11406
  if (v !== sn)
11127
11407
  a.push(v);
11128
11408
  });
@@ -11289,7 +11569,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
11289
11569
  return {
11290
11570
  type: 512,
11291
11571
  value: type.elements.map(
11292
- (cur) => typeFromTypespec(state, cur)
11572
+ (cur) => typeFromTypespec(state, cur, stack)
11293
11573
  )
11294
11574
  };
11295
11575
  }
@@ -11299,7 +11579,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
11299
11579
  const prop = property;
11300
11580
  fields.set(
11301
11581
  objectLiteralKeyFromKeyExpr(prop.left),
11302
- typeFromTypespec(state, prop.right)
11582
+ typeFromTypespec(state, prop.right, stack)
11303
11583
  );
11304
11584
  });
11305
11585
  return { type: 1024, value: fields };
@@ -11614,7 +11894,7 @@ function mustBeFalse(arg) {
11614
11894
  return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
11615
11895
  }
11616
11896
  function display(type) {
11617
- 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 ");
11618
11898
  const parts = [];
11619
11899
  const displayOne = (tv) => {
11620
11900
  switch (tv.type) {
@@ -11815,7 +12095,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
11815
12095
  init_data_flow();
11816
12096
  init_api();
11817
12097
  (0, import_chunk_MBTLUWXR.init_ast)();
11818
- (0, import_chunk_SG7ODKRM.init_util)();
12098
+ (0, import_chunk_67LU4GPQ.init_util)();
11819
12099
  init_interp();
11820
12100
  init_union_type();
11821
12101
  init_intersection_type();
@@ -11875,7 +12155,7 @@ function couldBeHelper(a, b, shallow) {
11875
12155
  262144
11876
12156
  /* Typedef */
11877
12157
  );
11878
- return typedef && (0, import_chunk_SG7ODKRM.some)(typedef, (td) => {
12158
+ return typedef && (0, import_chunk_67LU4GPQ.some)(typedef, (td) => {
11879
12159
  if (!td.resolvedType) {
11880
12160
  throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
11881
12161
  }
@@ -11947,15 +12227,15 @@ function couldBeValue(pair, shallow) {
11947
12227
  }
11948
12228
  case 4096:
11949
12229
  case 8192: {
11950
- return (0, import_chunk_SG7ODKRM.some)(
12230
+ return (0, import_chunk_67LU4GPQ.some)(
11951
12231
  pair.avalue,
11952
- (sna) => (0, import_chunk_SG7ODKRM.some)(pair.bvalue, (snb) => sna === snb)
12232
+ (sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb)
11953
12233
  );
11954
12234
  }
11955
12235
  case 16384: {
11956
- return (0, import_chunk_SG7ODKRM.some)(pair.avalue, (sna) => {
12236
+ return (0, import_chunk_67LU4GPQ.some)(pair.avalue, (sna) => {
11957
12237
  const superA = getSuperClasses(sna);
11958
- return (0, import_chunk_SG7ODKRM.some)(pair.bvalue, (snb) => {
12238
+ return (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => {
11959
12239
  if (sna === snb || superA && superA.has(snb)) {
11960
12240
  return true;
11961
12241
  }
@@ -11988,7 +12268,7 @@ var init_could_be = (0, import_chunk_ABYVSU2C.__esm)({
11988
12268
  "use strict";
11989
12269
  init_api();
11990
12270
  init_data_flow();
11991
- (0, import_chunk_SG7ODKRM.init_util)();
12271
+ (0, import_chunk_67LU4GPQ.init_util)();
11992
12272
  init_types();
11993
12273
  }
11994
12274
  });
@@ -12095,7 +12375,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12095
12375
  }
12096
12376
  addAnt(curState.partiallyAnticipated, key, node);
12097
12377
  if (logThisRun) {
12098
- (0, import_chunk_SG7ODKRM.log)(
12378
+ (0, import_chunk_67LU4GPQ.log)(
12099
12379
  ` antrefs: ${curState.partiallyAnticipated.get(key) !== false} ${curState.anticipated.get(key) !== false}`
12100
12380
  );
12101
12381
  }
@@ -12118,7 +12398,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12118
12398
  const curState = cloneState(blockStates[top.order]);
12119
12399
  if (logThisRun) {
12120
12400
  printBlockHeader(top);
12121
- 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)}`));
12122
12402
  }
12123
12403
  if (top.events) {
12124
12404
  for (let i = top.events.length; i--; ) {
@@ -12130,12 +12410,12 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12130
12410
  case "ref":
12131
12411
  if (isTypeStateKey(event.decl)) {
12132
12412
  if (logThisRun) {
12133
- (0, import_chunk_SG7ODKRM.log)(
12413
+ (0, import_chunk_67LU4GPQ.log)(
12134
12414
  describeEvent(event).then(
12135
12415
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12136
12416
  )
12137
12417
  );
12138
- (0, import_chunk_SG7ODKRM.log)(` kill => ${tsKey(event.decl)}`);
12418
+ (0, import_chunk_67LU4GPQ.log)(` kill => ${tsKey(event.decl)}`);
12139
12419
  }
12140
12420
  copyPropRef(curState, event.decl, event.node);
12141
12421
  curState.dead.delete(event.decl);
@@ -12144,7 +12424,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12144
12424
  case "def":
12145
12425
  if (isTypeStateKey(event.decl) && (event.node.type !== "VariableDeclarator" || event.node.init)) {
12146
12426
  if (logThisRun) {
12147
- (0, import_chunk_SG7ODKRM.log)(
12427
+ (0, import_chunk_67LU4GPQ.log)(
12148
12428
  describeEvent(event).then(
12149
12429
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12150
12430
  )
@@ -12160,7 +12440,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12160
12440
  const pant = curState.partiallyAnticipated.get(event.decl);
12161
12441
  if (pant) {
12162
12442
  if (logThisRun) {
12163
- (0, import_chunk_SG7ODKRM.log)(
12443
+ (0, import_chunk_67LU4GPQ.log)(
12164
12444
  ` is copy-prop-candidate ${curState.anticipated?.get(event.decl) === pant}`
12165
12445
  );
12166
12446
  }
@@ -12192,7 +12472,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12192
12472
  if (assignNode) {
12193
12473
  curState.dead.add(event.decl);
12194
12474
  if (logThisRun) {
12195
- (0, import_chunk_SG7ODKRM.log)(` anticipated => ${tsKey(event.decl)}`);
12475
+ (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12196
12476
  }
12197
12477
  } else if (event.node.type === "UpdateExpression") {
12198
12478
  copyPropRef(curState, event.decl, event.node.argument);
@@ -12203,7 +12483,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12203
12483
  if (isTypeStateKey(event.decl)) {
12204
12484
  curState.dead.add(event.decl);
12205
12485
  if (logThisRun) {
12206
- (0, import_chunk_SG7ODKRM.log)(` anticipated => ${tsKey(event.decl)}`);
12486
+ (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12207
12487
  }
12208
12488
  }
12209
12489
  break;
@@ -12266,9 +12546,9 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
12266
12546
  if (!deadStores.size)
12267
12547
  return { changes: false, copyPropStores };
12268
12548
  if (logThisRun) {
12269
- (0, import_chunk_SG7ODKRM.log)("====== Dead Stores =====");
12549
+ (0, import_chunk_67LU4GPQ.log)("====== Dead Stores =====");
12270
12550
  deadStores.forEach(
12271
- (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)(
12272
12552
  formatAst(dead).then(
12273
12553
  (deadStr) => `${deadStr} (${sourceLocation(dead.loc)})`
12274
12554
  )
@@ -12323,7 +12603,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
12323
12603
  init_control_flow();
12324
12604
  init_data_flow();
12325
12605
  init_inliner();
12326
- (0, import_chunk_SG7ODKRM.init_util)();
12606
+ (0, import_chunk_67LU4GPQ.init_util)();
12327
12607
  init_minimize_locals();
12328
12608
  init_type_flow_util();
12329
12609
  }
@@ -12688,13 +12968,13 @@ function typeStateEntry(value2, key) {
12688
12968
  return `${tsKey(key)} = ${display(value2.curType)}`;
12689
12969
  }
12690
12970
  function printBlockState(block, state, indent = "") {
12691
- (0, import_chunk_SG7ODKRM.log)(indent + "State:");
12971
+ (0, import_chunk_67LU4GPQ.log)(indent + "State:");
12692
12972
  if (!state) {
12693
- (0, import_chunk_SG7ODKRM.log)(indent + "Not visited!");
12973
+ (0, import_chunk_67LU4GPQ.log)(indent + "Not visited!");
12694
12974
  return;
12695
12975
  }
12696
12976
  state.map.forEach((value2, key) => {
12697
- (0, import_chunk_SG7ODKRM.log)(
12977
+ (0, import_chunk_67LU4GPQ.log)(
12698
12978
  `${indent} - ${typeStateEntry(value2, key)}${value2.equivSet ? ` [(${Array.from(value2.equivSet).map(tsKey).join(", ")})]` : ""}`
12699
12979
  );
12700
12980
  });
@@ -12901,7 +13181,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
12901
13181
  type: 0
12902
13182
  /* Never */
12903
13183
  };
12904
- (0, import_chunk_SG7ODKRM.forEach)(avalue, (v) => unionInto(n, v));
13184
+ (0, import_chunk_67LU4GPQ.forEach)(avalue, (v) => unionInto(n, v));
12905
13185
  next = n;
12906
13186
  }
12907
13187
  } else {
@@ -13006,7 +13286,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13006
13286
  }
13007
13287
  if (!isStatic && selfClassDecl) {
13008
13288
  const baseObj = getObjectValue(baseElem.type);
13009
- if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_SG7ODKRM.some)(
13289
+ if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_67LU4GPQ.some)(
13010
13290
  baseObj.klass.value,
13011
13291
  (cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
13012
13292
  )) {
@@ -13051,7 +13331,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13051
13331
  return [cur, updateAny];
13052
13332
  }
13053
13333
  function typeConstraint(decls, blockState) {
13054
- return (0, import_chunk_SG7ODKRM.reduce)(
13334
+ return (0, import_chunk_67LU4GPQ.reduce)(
13055
13335
  decls,
13056
13336
  (cur, decl) => {
13057
13337
  if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
@@ -13147,9 +13427,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13147
13427
  stack: [],
13148
13428
  func
13149
13429
  };
13150
- const modifiableDecl = (decls, callees) => (0, import_chunk_SG7ODKRM.some)(
13430
+ const modifiableDecl = (decls, callees) => (0, import_chunk_67LU4GPQ.some)(
13151
13431
  decls,
13152
- (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)))
13153
13433
  );
13154
13434
  const mergeSuccState = (top, curState) => {
13155
13435
  top.succs?.forEach((succ) => {
@@ -13158,7 +13438,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13158
13438
  }
13159
13439
  if (mergeTypeState(blockStates, succ.order, curState, nodeCopyProp)) {
13160
13440
  if (logThisRun) {
13161
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${succ.order}`);
13441
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${succ.order}`);
13162
13442
  }
13163
13443
  queue.enqueue(succ);
13164
13444
  }
@@ -13168,7 +13448,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13168
13448
  const calleeObj = getStateType(curState, calleeObjDecl);
13169
13449
  let calleeResult = null;
13170
13450
  let effectFree = true;
13171
- (0, import_chunk_SG7ODKRM.forEach)(callees, (callee) => {
13451
+ (0, import_chunk_67LU4GPQ.forEach)(callees, (callee) => {
13172
13452
  const info = sysCallInfo(istate.state, callee);
13173
13453
  if (!info) {
13174
13454
  effectFree = false;
@@ -13445,7 +13725,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13445
13725
  });
13446
13726
  } else {
13447
13727
  if (logThisRun) {
13448
- (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}`);
13449
13729
  printBlockState(top, sTrue || curState, " >true ");
13450
13730
  }
13451
13731
  if (mergeTypeState(
@@ -13455,7 +13735,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13455
13735
  nodeCopyProp
13456
13736
  )) {
13457
13737
  if (logThisRun) {
13458
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13738
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13459
13739
  }
13460
13740
  queue.enqueue(trueSucc);
13461
13741
  }
@@ -13467,7 +13747,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13467
13747
  });
13468
13748
  } else {
13469
13749
  if (logThisRun) {
13470
- (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}`);
13471
13751
  printBlockState(top, sFalse || curState, " >false ");
13472
13752
  }
13473
13753
  if (mergeTypeState(
@@ -13477,7 +13757,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13477
13757
  nodeCopyProp
13478
13758
  )) {
13479
13759
  if (logThisRun) {
13480
- (0, import_chunk_SG7ODKRM.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13760
+ (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13481
13761
  }
13482
13762
  queue.enqueue(falseSucc);
13483
13763
  }
@@ -13552,7 +13832,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13552
13832
  }
13553
13833
  }
13554
13834
  if (logThisRun) {
13555
- (0, import_chunk_SG7ODKRM.log)(
13835
+ (0, import_chunk_67LU4GPQ.log)(
13556
13836
  describeEvent(event).then(
13557
13837
  (eventStr) => ` ${eventStr} == ${display(curEntry.curType)}`
13558
13838
  )
@@ -13562,7 +13842,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13562
13842
  }
13563
13843
  case "mod": {
13564
13844
  if (logThisRun) {
13565
- (0, import_chunk_SG7ODKRM.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13845
+ (0, import_chunk_67LU4GPQ.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13566
13846
  }
13567
13847
  modInterference(curState, event, true, (callees, calleeObj) => {
13568
13848
  clearRelatedCopyPropEvents(curState, null, nodeCopyProp);
@@ -13578,7 +13858,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13578
13858
  );
13579
13859
  }
13580
13860
  }
13581
- 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))) {
13582
13862
  event.node.arguments.forEach((arg) => {
13583
13863
  const def = nodeCopyProp.get(arg);
13584
13864
  if (def && nodeCopyProp.get(def) !== false) {
@@ -13590,7 +13870,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13590
13870
  let calleeEffects;
13591
13871
  curState.map.forEach((tsv, decl) => {
13592
13872
  let type = tsv.curType;
13593
- 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))) {
13594
13874
  return;
13595
13875
  }
13596
13876
  if (modifiableDecl(decl, callees)) {
@@ -13605,7 +13885,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13605
13885
  curState.map.set(decl, {
13606
13886
  curType: typeConstraint(decl, curState)
13607
13887
  });
13608
- } 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)) {
13609
13889
  if (type.value != null && type.type & 32768) {
13610
13890
  const odata = getObjectValue(tsv.curType);
13611
13891
  if (odata?.obj) {
@@ -13673,7 +13953,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13673
13953
  2
13674
13954
  /* Reassign */
13675
13955
  );
13676
- (0, import_chunk_SG7ODKRM.some)(event.decl, (decl) => {
13956
+ (0, import_chunk_67LU4GPQ.some)(event.decl, (decl) => {
13677
13957
  if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
13678
13958
  return false;
13679
13959
  }
@@ -13681,7 +13961,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13681
13961
  if (affected) {
13682
13962
  const objType = typeFromTypeStateNodes(
13683
13963
  istate.state,
13684
- (0, import_chunk_SG7ODKRM.map)(
13964
+ (0, import_chunk_67LU4GPQ.map)(
13685
13965
  event.decl,
13686
13966
  (decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
13687
13967
  ).filter(
@@ -13702,7 +13982,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13702
13982
  });
13703
13983
  if (wasComputedDecl) {
13704
13984
  curState.map.forEach((value2, decls) => {
13705
- if ((0, import_chunk_SG7ODKRM.some)(
13985
+ if ((0, import_chunk_67LU4GPQ.some)(
13706
13986
  decls,
13707
13987
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
13708
13988
  )) {
@@ -13748,14 +14028,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13748
14028
  }
13749
14029
  if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
13750
14030
  // in case it has side effects.
13751
- (0, import_chunk_SG7ODKRM.some)(
14031
+ (0, import_chunk_67LU4GPQ.some)(
13752
14032
  event2.calleeDecl,
13753
14033
  (callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
13754
14034
  )) {
13755
14035
  return false;
13756
14036
  }
13757
14037
  }
13758
- if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_SG7ODKRM.some)(
14038
+ if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_67LU4GPQ.some)(
13759
14039
  event2.decl,
13760
14040
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
13761
14041
  )) {
@@ -13794,13 +14074,13 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13794
14074
  }
13795
14075
  }
13796
14076
  if (uninitClassDecls?.size) {
13797
- (0, import_chunk_SG7ODKRM.forEach)(
14077
+ (0, import_chunk_67LU4GPQ.forEach)(
13798
14078
  event.decl,
13799
14079
  (decl) => uninitClassDecls.has(decl) && curState.inited?.add(decl)
13800
14080
  );
13801
14081
  }
13802
14082
  if (logThisRun) {
13803
- (0, import_chunk_SG7ODKRM.log)(
14083
+ (0, import_chunk_67LU4GPQ.log)(
13804
14084
  describeEvent(event).then(
13805
14085
  (eventStr) => ` ${eventStr} := ${display(type)}`
13806
14086
  )
@@ -13818,7 +14098,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13818
14098
  );
13819
14099
  }
13820
14100
  if (logThisRun) {
13821
- (0, import_chunk_SG7ODKRM.log)(
14101
+ (0, import_chunk_67LU4GPQ.log)(
13822
14102
  describeEvent(event).then(
13823
14103
  (eventStr) => ` ${eventStr} : ${!Array.isArray(event.left) && event.left.type === "MemberDecl" ? `${display(
13824
14104
  curState.map.get(event.left.base)?.curType || {
@@ -13876,8 +14156,8 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13876
14156
  }
13877
14157
  if (!successorsHandled) {
13878
14158
  if (logThisRun) {
13879
- (0, import_chunk_SG7ODKRM.log)(
13880
- ` merge to: ${(0, import_chunk_SG7ODKRM.map)(
14159
+ (0, import_chunk_67LU4GPQ.log)(
14160
+ ` merge to: ${(0, import_chunk_67LU4GPQ.map)(
13881
14161
  top.succs,
13882
14162
  (succ) => succ.order || -1
13883
14163
  ).join(", ")}`
@@ -13908,17 +14188,17 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13908
14188
  );
13909
14189
  printBlockTrailer(block);
13910
14190
  });
13911
- (0, import_chunk_SG7ODKRM.log)("====== TypeMap =====");
14191
+ (0, import_chunk_67LU4GPQ.log)("====== TypeMap =====");
13912
14192
  typeMap.forEach((value2, key) => {
13913
- (0, import_chunk_SG7ODKRM.log)(
14193
+ (0, import_chunk_67LU4GPQ.log)(
13914
14194
  formatAst(key).then(
13915
14195
  (keyStr) => `${keyStr} = ${display(value2)} ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
13916
14196
  )
13917
14197
  );
13918
14198
  });
13919
- (0, import_chunk_SG7ODKRM.log)("====== EquivMap =====");
14199
+ (0, import_chunk_67LU4GPQ.log)("====== EquivMap =====");
13920
14200
  nodeEquivs.forEach((value2, key) => {
13921
- (0, import_chunk_SG7ODKRM.log)(
14201
+ (0, import_chunk_67LU4GPQ.log)(
13922
14202
  formatAst(key).then(
13923
14203
  (keyStr) => `${keyStr} = [${value2.equiv.map(
13924
14204
  (equiv) => tsKey(equiv)
@@ -13926,7 +14206,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13926
14206
  )
13927
14207
  );
13928
14208
  });
13929
- (0, import_chunk_SG7ODKRM.log)("====== Copy Prop =====");
14209
+ (0, import_chunk_67LU4GPQ.log)("====== Copy Prop =====");
13930
14210
  nodeCopyProp.forEach((value2, key) => {
13931
14211
  (0, import_node_assert3.default)(value2 !== false);
13932
14212
  if (key.type === "VariableDeclarator" || key.type === "AssignmentExpression") {
@@ -13936,7 +14216,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13936
14216
  value2.type === "VariableDeclarator" && value2.init || value2.type === "AssignmentExpression"
13937
14217
  );
13938
14218
  const node = value2.type === "VariableDeclarator" ? value2.init : value2.right;
13939
- (0, import_chunk_SG7ODKRM.log)(
14219
+ (0, import_chunk_67LU4GPQ.log)(
13940
14220
  formatAst(key).then(
13941
14221
  (keyStr) => formatAstLongLines(node).then(
13942
14222
  (nodeStr) => `${keyStr} = [${nodeStr}] ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
@@ -13946,10 +14226,10 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13946
14226
  });
13947
14227
  }
13948
14228
  if (logThisRun) {
13949
- (0, import_chunk_SG7ODKRM.log)(formatAstLongLines(func.node));
14229
+ (0, import_chunk_67LU4GPQ.log)(formatAstLongLines(func.node));
13950
14230
  if (copyPropStores) {
13951
14231
  copyPropStores.forEach(({ ref, ant }, node) => {
13952
- (0, import_chunk_SG7ODKRM.log)(
14232
+ (0, import_chunk_67LU4GPQ.log)(
13953
14233
  formatAstLongLines(node).then(
13954
14234
  (nodeStr) => `copy-prop-store: ${nodeStr}${ant ? "!" : ""} => ${nodeCopyProp.get(node) !== ref ? "Failed" : "Success"}`
13955
14235
  )
@@ -13963,9 +14243,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13963
14243
  }
13964
14244
  if (logThisRun) {
13965
14245
  if (selfAssignments.size) {
13966
- (0, import_chunk_SG7ODKRM.log)("====== Self Assignments =====");
14246
+ (0, import_chunk_67LU4GPQ.log)("====== Self Assignments =====");
13967
14247
  selfAssignments.forEach(
13968
- (self) => (0, import_chunk_SG7ODKRM.log)(
14248
+ (self) => (0, import_chunk_67LU4GPQ.log)(
13969
14249
  formatAst(self).then(
13970
14250
  (selfStr) => `${selfStr} (${sourceLocation(self.loc)})`
13971
14251
  )
@@ -14030,7 +14310,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14030
14310
  if (copyNode) {
14031
14311
  if (node.type === "AssignmentExpression") {
14032
14312
  if (logThisRun) {
14033
- (0, import_chunk_SG7ODKRM.log)(
14313
+ (0, import_chunk_67LU4GPQ.log)(
14034
14314
  formatAstLongLines(node).then(
14035
14315
  (nodeStr) => `Killing copy-prop assignment ${nodeStr}`
14036
14316
  )
@@ -14045,7 +14325,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14045
14325
  if (node.type === "VariableDeclarator") {
14046
14326
  (0, import_node_assert3.default)(node.init);
14047
14327
  if (logThisRun) {
14048
- (0, import_chunk_SG7ODKRM.log)(
14328
+ (0, import_chunk_67LU4GPQ.log)(
14049
14329
  formatAstLongLines(node).then(
14050
14330
  (nodeStr) => `Killing copy-prop variable initialization ${nodeStr}`
14051
14331
  )
@@ -14066,7 +14346,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14066
14346
  right: copyNode.right
14067
14347
  };
14068
14348
  if (logThisRun) {
14069
- (0, import_chunk_SG7ODKRM.log)(
14349
+ (0, import_chunk_67LU4GPQ.log)(
14070
14350
  formatAstLongLines(node).then(
14071
14351
  (nodeStr) => formatAstLongLines(replacement2).then(
14072
14352
  (repStr) => `copy-prop ${nodeStr} => ${repStr}`
@@ -14079,7 +14359,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14079
14359
  const init = copyNode.init;
14080
14360
  (0, import_node_assert3.default)(init);
14081
14361
  if (logThisRun) {
14082
- (0, import_chunk_SG7ODKRM.log)(
14362
+ (0, import_chunk_67LU4GPQ.log)(
14083
14363
  formatAstLongLines(node).then(
14084
14364
  (nodeStr) => formatAstLongLines(init).then(
14085
14365
  (initStr) => `copy-prop ${nodeStr} => ${initStr}`
@@ -14093,7 +14373,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14093
14373
  }
14094
14374
  if (selfAssignments.has(node)) {
14095
14375
  if (logThisRun) {
14096
- (0, import_chunk_SG7ODKRM.log)(
14376
+ (0, import_chunk_67LU4GPQ.log)(
14097
14377
  formatAst(node).then(
14098
14378
  (nodeStr) => `Deleting self assignment: ${nodeStr} (${sourceLocation(
14099
14379
  node.loc
@@ -14137,7 +14417,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14137
14417
  }, curInfo);
14138
14418
  if (rep === curInfo)
14139
14419
  return null;
14140
- const name = (0, import_chunk_SG7ODKRM.reduce)(
14420
+ const name = (0, import_chunk_67LU4GPQ.reduce)(
14141
14421
  rep.decl,
14142
14422
  (cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
14143
14423
  null
@@ -14145,7 +14425,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14145
14425
  if (!name)
14146
14426
  return null;
14147
14427
  if (logThisRun) {
14148
- (0, import_chunk_SG7ODKRM.log)(
14428
+ (0, import_chunk_67LU4GPQ.log)(
14149
14429
  formatAst(node).then(
14150
14430
  (nodeStr) => `Replacing ${nodeStr} with ${name} at ${sourceLocation(
14151
14431
  node.loc
@@ -14276,7 +14556,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
14276
14556
  init_type_flow_util();
14277
14557
  init_types();
14278
14558
  init_union_type();
14279
- (0, import_chunk_SG7ODKRM.init_util)();
14559
+ (0, import_chunk_67LU4GPQ.init_util)();
14280
14560
  logging = true;
14281
14561
  missingNullWorkaround = true;
14282
14562
  }
@@ -14328,9 +14608,9 @@ function minimizeLocals(state, func) {
14328
14608
  if (!didMerge)
14329
14609
  return;
14330
14610
  if (logThisRun) {
14331
- (0, import_chunk_SG7ODKRM.log)(`>>> Merging locals in ${func.fullName}`);
14611
+ (0, import_chunk_67LU4GPQ.log)(`>>> Merging locals in ${func.fullName}`);
14332
14612
  merge.forEach(
14333
- (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(" | ")}`)
14334
14614
  );
14335
14615
  }
14336
14616
  const remap = /* @__PURE__ */ new Map();
@@ -14600,7 +14880,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
14600
14880
  (0, import_chunk_MBTLUWXR.init_ast)();
14601
14881
  init_control_flow();
14602
14882
  init_type_flow();
14603
- (0, import_chunk_SG7ODKRM.init_util)();
14883
+ (0, import_chunk_67LU4GPQ.init_util)();
14604
14884
  init_variable_renamer();
14605
14885
  init_type_flow_util();
14606
14886
  }
@@ -14611,12 +14891,12 @@ function logAntState(s, decl) {
14611
14891
  defs2++;
14612
14892
  return defs2;
14613
14893
  }, 0);
14614
- (0, import_chunk_SG7ODKRM.log)(
14894
+ (0, import_chunk_67LU4GPQ.log)(
14615
14895
  declFullName(decl).then(
14616
14896
  (declStr) => ` - ${declStr}: ${candidateCost(s)} bytes, ${s.ant.size - defs} refs, ${defs} defs, ${s.live ? "" : "!"}live, ${s.isIsolated ? "" : "!"}isolated`
14617
14897
  )
14618
14898
  );
14619
- (0, import_chunk_SG7ODKRM.log)(
14899
+ (0, import_chunk_67LU4GPQ.log)(
14620
14900
  ` - members: ${Array.from(s.members).map(([block, live]) => block.order + (live ? "t" : "f")).join(", ")}`
14621
14901
  );
14622
14902
  }
@@ -14633,7 +14913,7 @@ async function sizeBasedPRE(state, func) {
14633
14913
  const candidates = computeAttributes(state, head);
14634
14914
  if (candidates) {
14635
14915
  if (logging2) {
14636
- (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}`);
14637
14917
  logAntDecls(candidates);
14638
14918
  }
14639
14919
  const nodeMap = /* @__PURE__ */ new Map();
@@ -14726,7 +15006,7 @@ function buildPREGraph(state, func) {
14726
15006
  const event = block.events[i];
14727
15007
  switch (event.type) {
14728
15008
  case "ref":
14729
- if ((0, import_chunk_SG7ODKRM.some)(
15009
+ if ((0, import_chunk_67LU4GPQ.some)(
14730
15010
  event.decl,
14731
15011
  (decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
14732
15012
  )) {
@@ -14744,7 +15024,7 @@ function buildPREGraph(state, func) {
14744
15024
  defs.add(event.decl);
14745
15025
  break;
14746
15026
  case "mod":
14747
- 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)) {
14748
15028
  block.events.splice(i, 1);
14749
15029
  break;
14750
15030
  }
@@ -14903,21 +15183,21 @@ function computeAttributes(state, head) {
14903
15183
  });
14904
15184
  if (logging2) {
14905
15185
  order.forEach((block) => {
14906
- (0, import_chunk_SG7ODKRM.log)(
15186
+ (0, import_chunk_67LU4GPQ.log)(
14907
15187
  block.order,
14908
15188
  `(${block.node ? block.node.loc?.start.line : "??"})`,
14909
15189
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
14910
15190
  );
14911
15191
  if (block.events) {
14912
15192
  block.events.forEach(
14913
- (event) => event.type !== "exn" && (0, import_chunk_SG7ODKRM.log)(
15193
+ (event) => event.type !== "exn" && (0, import_chunk_67LU4GPQ.log)(
14914
15194
  Promise.resolve(
14915
15195
  event.decl ? declFullName(event.decl) : event.node ? formatAst(event.node) : "??"
14916
15196
  ).then((eventDetails) => ` ${event.type}: ${eventDetails}`)
14917
15197
  )
14918
15198
  );
14919
15199
  }
14920
- (0, import_chunk_SG7ODKRM.log)(
15200
+ (0, import_chunk_67LU4GPQ.log)(
14921
15201
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
14922
15202
  );
14923
15203
  });
@@ -14985,7 +15265,7 @@ function computeAttributes(state, head) {
14985
15265
  }
14986
15266
  case "mod": {
14987
15267
  curState.forEach((candidates, decls) => {
14988
- if ((0, import_chunk_SG7ODKRM.some)(
15268
+ if ((0, import_chunk_67LU4GPQ.some)(
14989
15269
  decls,
14990
15270
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
14991
15271
  (callee) => functionMayModify(state, callee, decl)
@@ -15027,7 +15307,7 @@ function computeAttributes(state, head) {
15027
15307
  }
15028
15308
  blockStates[top.order] = curState;
15029
15309
  if (logging2) {
15030
- (0, import_chunk_SG7ODKRM.log)(`Updated block ${top.order}`);
15310
+ (0, import_chunk_67LU4GPQ.log)(`Updated block ${top.order}`);
15031
15311
  logAntDecls(curState);
15032
15312
  }
15033
15313
  if (top.preds) {
@@ -15129,7 +15409,7 @@ function applyReplacements(func, nodeMap, declMap) {
15129
15409
  }
15130
15410
  const name = declMap.get(event.decl);
15131
15411
  if (!name) {
15132
- throw new import_chunk_SG7ODKRM.AwaitedError(
15412
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15133
15413
  formatAst(node).then(
15134
15414
  (targetStr) => `No replacement found for "${targetStr}"`
15135
15415
  )
@@ -15151,7 +15431,7 @@ function applyReplacements(func, nodeMap, declMap) {
15151
15431
  const target = node.type === "AssignmentExpression" ? node.left : node.argument;
15152
15432
  const name = declMap.get(event.decl);
15153
15433
  if (!name) {
15154
- throw new import_chunk_SG7ODKRM.AwaitedError(
15434
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15155
15435
  formatAst(target).then(
15156
15436
  (targetStr) => `No replacement found for "${targetStr}"`
15157
15437
  )
@@ -15214,14 +15494,14 @@ function applyReplacements(func, nodeMap, declMap) {
15214
15494
  const decl = event.decl;
15215
15495
  const name = declMap.get(decl);
15216
15496
  if (!name) {
15217
- throw new import_chunk_SG7ODKRM.AwaitedError(
15497
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15218
15498
  declFullName(decl).then(
15219
15499
  (declStr) => `No replacement found for "${declStr}"`
15220
15500
  )
15221
15501
  );
15222
15502
  }
15223
15503
  if (!event.id) {
15224
- throw new import_chunk_SG7ODKRM.AwaitedError(
15504
+ throw new import_chunk_67LU4GPQ.AwaitedError(
15225
15505
  declFullName(decl).then(
15226
15506
  (declStr) => `Missing id for mod event for "${declStr}"`
15227
15507
  )
@@ -15286,7 +15566,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
15286
15566
  init_data_flow();
15287
15567
  init_function_info();
15288
15568
  init_minimize_locals();
15289
- (0, import_chunk_SG7ODKRM.init_util)();
15569
+ (0, import_chunk_67LU4GPQ.init_util)();
15290
15570
  logging2 = false;
15291
15571
  LocalRefCost = 2;
15292
15572
  }
@@ -15657,7 +15937,7 @@ function beforeEvaluate(istate, node) {
15657
15937
  break;
15658
15938
  }
15659
15939
  const id = node.right.argument;
15660
- if ((0, import_chunk_SG7ODKRM.every)(left.value.value, (m) => {
15940
+ if ((0, import_chunk_67LU4GPQ.every)(left.value.value, (m) => {
15661
15941
  if ((0, import_chunk_MBTLUWXR.hasProperty)(m.decls, id.name))
15662
15942
  return false;
15663
15943
  return istate.state.lookup({
@@ -16103,7 +16383,7 @@ var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
16103
16383
  (0, import_chunk_MBTLUWXR.init_ast)();
16104
16384
  init_inliner();
16105
16385
  init_type_flow();
16106
- (0, import_chunk_SG7ODKRM.init_util)();
16386
+ (0, import_chunk_67LU4GPQ.init_util)();
16107
16387
  init_interp();
16108
16388
  init_interp_binary();
16109
16389
  init_types();
@@ -16640,13 +16920,13 @@ function markFunctionCalled(state, func) {
16640
16920
  state.calledFunctions[func.id.name] = [func];
16641
16921
  return;
16642
16922
  }
16643
- (0, import_chunk_SG7ODKRM.pushUnique)(state.calledFunctions[func.id.name], func);
16923
+ (0, import_chunk_67LU4GPQ.pushUnique)(state.calledFunctions[func.id.name], func);
16644
16924
  }
16645
16925
  async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
16646
16926
  try {
16647
16927
  return optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config);
16648
16928
  } catch (ex) {
16649
- if (ex instanceof import_chunk_SG7ODKRM.AwaitedError) {
16929
+ if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
16650
16930
  await ex.resolve();
16651
16931
  }
16652
16932
  throw ex;
@@ -17383,7 +17663,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
17383
17663
  init_sub_type();
17384
17664
  init_types();
17385
17665
  init_unused_exprs();
17386
- (0, import_chunk_SG7ODKRM.init_util)();
17666
+ (0, import_chunk_67LU4GPQ.init_util)();
17387
17667
  init_variable_renamer();
17388
17668
  init_data_flow();
17389
17669
  }
@@ -17612,7 +17892,9 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
17612
17892
  const hiddenRez = makeModule("*Rez*");
17613
17893
  rez.body.body.push(hiddenRez);
17614
17894
  if (barrel === "" && manifestXML && manifestXML.body instanceof xml_util_exports.Nodes) {
17615
- 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
+ );
17616
17898
  }
17617
17899
  const rezModules = Object.fromEntries(
17618
17900
  Object.entries(modules).map(([moduleName, isPublic]) => {
@@ -17630,7 +17912,7 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
17630
17912
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(rezModules, s))
17631
17913
  return;
17632
17914
  const module2 = rezModules[s];
17633
- add_one_resource(state, rez2, module2, e);
17915
+ add_one_resource(state, rez2, module2, e, barrel);
17634
17916
  });
17635
17917
  });
17636
17918
  });
@@ -17646,11 +17928,14 @@ function addPositions(base, pos) {
17646
17928
  result.offset += pos.offset;
17647
17929
  return result;
17648
17930
  }
17649
- function visit_resource_refs(state, doc, e) {
17931
+ function visit_resource_refs(state, doc, e, barrel) {
17650
17932
  const result = [];
17651
17933
  const parseArg = (name, loc, skip) => {
17652
17934
  if (name.startsWith("@")) {
17653
17935
  name = name.substring(1);
17936
+ if (barrel && name.startsWith(barrel) && name[barrel.length] === ".") {
17937
+ name = name.slice(barrel.length + 1);
17938
+ }
17654
17939
  loc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 1, 0);
17655
17940
  }
17656
17941
  if ((0, import_chunk_MBTLUWXR.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
@@ -17707,18 +17992,27 @@ function visit_resource_refs(state, doc, e) {
17707
17992
  }
17708
17993
  if (id === "personality") {
17709
17994
  const elems = dotted.match(/\s+|\S+/g);
17710
- elems?.reduce((offset, name) => {
17711
- const end = offset + name.length;
17712
- 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 {
17713
18006
  const base = (0, import_chunk_MBTLUWXR.makeScopedName)(`Rez.Styles`);
17714
- const id2 = (0, import_chunk_MBTLUWXR.makeIdentifier)(
17715
- name,
17716
- (0, import_chunk_MBTLUWXR.adjustLoc)(l, offset, end - dotted.length)
17717
- );
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);
17718
18012
  result.push((0, import_chunk_MBTLUWXR.makeMemberExpression)((0, import_chunk_MBTLUWXR.withLoc)(base, id2, false), id2));
17719
18013
  }
17720
- return end;
17721
- }, 0);
18014
+ return (0, import_chunk_MBTLUWXR.adjustLoc)(loc, name.length, 0);
18015
+ }, (0, import_chunk_MBTLUWXR.adjustLoc)(l, 0, 0));
17722
18016
  return;
17723
18017
  }
17724
18018
  if (/^\s*(true|false|null|NaN|(0x|#)[0-9a-f]+|[-+]?\d+%?)\s*$/i.test(dotted)) {
@@ -17792,7 +18086,7 @@ function visit_resource_refs(state, doc, e) {
17792
18086
  });
17793
18087
  return result;
17794
18088
  }
17795
- function add_one_resource(state, doc, module2, e) {
18089
+ function add_one_resource(state, doc, module2, e, barrel) {
17796
18090
  let id;
17797
18091
  let func;
17798
18092
  const makeVarDecl = (id2, outer) => {
@@ -17956,7 +18250,7 @@ function add_one_resource(state, doc, module2, e) {
17956
18250
  }
17957
18251
  if (!func)
17958
18252
  return;
17959
- const elements = visit_resource_refs(state, doc, e);
18253
+ const elements = visit_resource_refs(state, doc, e, barrel);
17960
18254
  const startLoc = elements[0]?.loc;
17961
18255
  const endLoc = elements[elements.length - 1]?.loc;
17962
18256
  const init = elements.length ? (0, import_chunk_MBTLUWXR.wrap)(
@@ -18264,7 +18558,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
18264
18558
  throw `Negative constant ${fixup} was not a Literal`;
18265
18559
  }
18266
18560
  if (typeof init.value !== "number") {
18267
- (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!`);
18268
18562
  } else if (init.value > 0) {
18269
18563
  init.value = -init.value;
18270
18564
  init.raw = "-" + init.raw;
@@ -18354,11 +18648,11 @@ function sameStateNodeDecl(a, b) {
18354
18648
  function sameLookupDefinition(a, b) {
18355
18649
  return (
18356
18650
  // sameStateNodeDecl(a.parent, b.parent) &&
18357
- (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))
18358
18652
  );
18359
18653
  }
18360
18654
  function sameLookupResult(a, b) {
18361
- return (0, import_chunk_SG7ODKRM.sameArrays)(a, b, sameLookupDefinition);
18655
+ return (0, import_chunk_67LU4GPQ.sameArrays)(a, b, sameLookupDefinition);
18362
18656
  }
18363
18657
  function declKey(decl) {
18364
18658
  return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
@@ -18896,7 +19190,7 @@ function stateFuncs() {
18896
19190
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
18897
19191
  this.index[name] = [];
18898
19192
  }
18899
- (0, import_chunk_SG7ODKRM.pushUnique)(this.index[name], parent);
19193
+ (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
18900
19194
  }
18901
19195
  });
18902
19196
  break;
@@ -18951,7 +19245,7 @@ function stateFuncs() {
18951
19245
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
18952
19246
  values[name] = [];
18953
19247
  }
18954
- if ((0, import_chunk_SG7ODKRM.pushUnique)(values[name], m) && currentEnum) {
19248
+ if ((0, import_chunk_67LU4GPQ.pushUnique)(values[name], m) && currentEnum) {
18955
19249
  if (!this.enumMap)
18956
19250
  this.enumMap = /* @__PURE__ */ new Map();
18957
19251
  this.enumMap.set(m, currentEnum);
@@ -18959,7 +19253,7 @@ function stateFuncs() {
18959
19253
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
18960
19254
  this.index[name] = [];
18961
19255
  }
18962
- (0, import_chunk_SG7ODKRM.pushUnique)(this.index[name], parent);
19256
+ (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
18963
19257
  });
18964
19258
  break;
18965
19259
  }
@@ -19460,7 +19754,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
19460
19754
  init_sdk_util();
19461
19755
  init_type_flow_util();
19462
19756
  init_types();
19463
- (0, import_chunk_SG7ODKRM.init_util)();
19757
+ (0, import_chunk_67LU4GPQ.init_util)();
19464
19758
  init_visitor();
19465
19759
  }
19466
19760
  });
@@ -19544,7 +19838,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19544
19838
  return decls;
19545
19839
  }
19546
19840
  if (canon.length !== decls.length || !canon.every((v, i) => v === decls[i])) {
19547
- throw new import_chunk_SG7ODKRM.AwaitedError(
19841
+ throw new import_chunk_67LU4GPQ.AwaitedError(
19548
19842
  declFullName(canon).then(
19549
19843
  (canonStr) => `Canonical representation of ${canonStr} did not match`
19550
19844
  )
@@ -19578,7 +19872,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19578
19872
  }
19579
19873
  const decl = lookupDefToDecl(results);
19580
19874
  if (decl && path7.length) {
19581
- if (wantsAllRefs && (0, import_chunk_SG7ODKRM.every)(
19875
+ if (wantsAllRefs && (0, import_chunk_67LU4GPQ.every)(
19582
19876
  decl,
19583
19877
  (d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
19584
19878
  )) {
@@ -19630,7 +19924,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19630
19924
  }
19631
19925
  const v = liveDefs.get(def);
19632
19926
  if (!v || !v.has(node)) {
19633
- throw new import_chunk_SG7ODKRM.AwaitedError(
19927
+ throw new import_chunk_67LU4GPQ.AwaitedError(
19634
19928
  Promise.resolve(def ? declFullName(def) : "null").then(
19635
19929
  (defStr) => `No stmt in liveDef for ${defStr}`
19636
19930
  )
@@ -19688,7 +19982,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19688
19982
  const decls = findDecl(node);
19689
19983
  if (!decls)
19690
19984
  break;
19691
- if (trackInsertionPoints && (0, import_chunk_SG7ODKRM.some)(decls, (decl) => {
19985
+ if (trackInsertionPoints && (0, import_chunk_67LU4GPQ.some)(decls, (decl) => {
19692
19986
  if (decl.type === "VariableDeclarator") {
19693
19987
  const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
19694
19988
  if (defStmts) {
@@ -19939,8 +20233,8 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
19939
20233
  init_control_flow();
19940
20234
  init_function_info();
19941
20235
  init_type_flow_util();
19942
- (0, import_chunk_SG7ODKRM.init_util)();
19943
- DataflowQueue = class extends import_chunk_SG7ODKRM.GenericQueue {
20236
+ (0, import_chunk_67LU4GPQ.init_util)();
20237
+ DataflowQueue = class extends import_chunk_67LU4GPQ.GenericQueue {
19944
20238
  constructor() {
19945
20239
  super((b, a) => (a.order || 0) - (b.order || 0));
19946
20240
  }
@@ -20735,7 +21029,7 @@ function computeJsrMap(func) {
20735
21029
  }
20736
21030
  function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
20737
21031
  const order = /* @__PURE__ */ new Map();
20738
- const queue = new import_chunk_SG7ODKRM.GenericQueue(
21032
+ const queue = new import_chunk_67LU4GPQ.GenericQueue(
20739
21033
  (b, a) => order.get(a) - order.get(b)
20740
21034
  );
20741
21035
  postOrderTraverse2(func, (block) => {
@@ -20794,7 +21088,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
20794
21088
  });
20795
21089
  blocks.reverse().forEach((block, i) => order.set(block, i));
20796
21090
  }
20797
- const queue = new import_chunk_SG7ODKRM.GenericQueue(
21091
+ const queue = new import_chunk_67LU4GPQ.GenericQueue(
20798
21092
  (b, a) => order.get(a) - order.get(b)
20799
21093
  );
20800
21094
  queue.enqueue(func.blocks.get(func.offset));
@@ -20848,7 +21142,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
20848
21142
  var init_cflow = (0, import_chunk_ABYVSU2C.__esm)({
20849
21143
  "src/readprg/cflow.ts"() {
20850
21144
  "use strict";
20851
- (0, import_chunk_SG7ODKRM.init_util)();
21145
+ (0, import_chunk_67LU4GPQ.init_util)();
20852
21146
  init_opcodes();
20853
21147
  }
20854
21148
  });
@@ -21311,12 +21605,12 @@ function interpFunc(func, context) {
21311
21605
  const selfStores = /* @__PURE__ */ new Set();
21312
21606
  const liveInState = /* @__PURE__ */ new Map();
21313
21607
  const replacements = /* @__PURE__ */ new Map();
21314
- const interpLogging = (0, import_chunk_SG7ODKRM.wouldLog)("interp", 1);
21608
+ const interpLogging = (0, import_chunk_67LU4GPQ.wouldLog)("interp", 1);
21315
21609
  if (interpLogging) {
21316
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 7)) {
21317
- (0, import_chunk_SG7ODKRM.setBanner)(functionBanner(func, context, "interp"));
21318
- } else if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 3)) {
21319
- (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)(
21320
21614
  () => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
21321
21615
  );
21322
21616
  }
@@ -21350,20 +21644,20 @@ function interpFunc(func, context) {
21350
21644
  func,
21351
21645
  (block) => {
21352
21646
  if (interpLogging) {
21353
- (0, import_chunk_SG7ODKRM.logger)(
21647
+ (0, import_chunk_67LU4GPQ.logger)(
21354
21648
  "interp",
21355
21649
  3,
21356
21650
  `${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
21357
21651
  ${interpStateToString(liveInState.get(block.offset))}`
21358
21652
  );
21359
- (0, import_chunk_SG7ODKRM.logger)("interp", 9, () => blockToString(block, context));
21653
+ (0, import_chunk_67LU4GPQ.logger)("interp", 9, () => blockToString(block, context));
21360
21654
  }
21361
21655
  return cloneState2(liveInState.get(block.offset));
21362
21656
  },
21363
21657
  (block, bc, localState) => {
21364
21658
  if (interpLogging) {
21365
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 8)) {
21366
- (0, import_chunk_SG7ODKRM.log)(
21659
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 8)) {
21660
+ (0, import_chunk_67LU4GPQ.log)(
21367
21661
  `${interpStateToString(localState)}
21368
21662
  ${bytecodeToString(
21369
21663
  bc,
@@ -21528,14 +21822,14 @@ function interpFunc(func, context) {
21528
21822
  if (!mergeInto(localState, succState))
21529
21823
  return false;
21530
21824
  if (interpLogging) {
21531
- (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)}`);
21532
21826
  }
21533
21827
  return true;
21534
21828
  }
21535
21829
  );
21536
21830
  if (interpLogging) {
21537
- if ((0, import_chunk_SG7ODKRM.wouldLog)("interp", 5)) {
21538
- (0, import_chunk_SG7ODKRM.setBanner)(
21831
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 5)) {
21832
+ (0, import_chunk_67LU4GPQ.setBanner)(
21539
21833
  functionBanner(func, context, "interp", (block, footer) => {
21540
21834
  if (footer)
21541
21835
  return "";
@@ -21543,44 +21837,44 @@ function interpFunc(func, context) {
21543
21837
  })
21544
21838
  );
21545
21839
  } else {
21546
- (0, import_chunk_SG7ODKRM.setBanner)(() => `=============== interp ${func.name} ==============`);
21840
+ (0, import_chunk_67LU4GPQ.setBanner)(() => `=============== interp ${func.name} ==============`);
21547
21841
  }
21548
21842
  if (equivSets.size) {
21549
- (0, import_chunk_SG7ODKRM.log)(`====== equivSets =====`);
21843
+ (0, import_chunk_67LU4GPQ.log)(`====== equivSets =====`);
21550
21844
  equivSets.forEach(
21551
- (value2, key) => (0, import_chunk_SG7ODKRM.log)(
21845
+ (value2, key) => (0, import_chunk_67LU4GPQ.log)(
21552
21846
  `L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
21553
21847
  )
21554
21848
  );
21555
21849
  }
21556
21850
  if (selfStores.size) {
21557
- (0, import_chunk_SG7ODKRM.log)(`====== selfStores =====`);
21851
+ (0, import_chunk_67LU4GPQ.log)(`====== selfStores =====`);
21558
21852
  selfStores.forEach(
21559
- (value2) => (0, import_chunk_SG7ODKRM.log)(`${bytecodeToString(value2, symbolTable)}`)
21853
+ (value2) => (0, import_chunk_67LU4GPQ.log)(`${bytecodeToString(value2, symbolTable)}`)
21560
21854
  );
21561
21855
  }
21562
21856
  if (replacements.size) {
21563
- (0, import_chunk_SG7ODKRM.log)(`====== replacements =====`);
21857
+ (0, import_chunk_67LU4GPQ.log)(`====== replacements =====`);
21564
21858
  replacements.forEach(
21565
21859
  (blockRep) => blockRep.forEach(
21566
- (rep, bc) => (0, import_chunk_SG7ODKRM.log)(
21860
+ (rep, bc) => (0, import_chunk_67LU4GPQ.log)(
21567
21861
  `${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
21568
21862
  )
21569
21863
  )
21570
21864
  );
21571
21865
  }
21572
21866
  if (resolvedBranches.size) {
21573
- (0, import_chunk_SG7ODKRM.log)(`====== resolved branches =====`);
21867
+ (0, import_chunk_67LU4GPQ.log)(`====== resolved branches =====`);
21574
21868
  resolvedBranches.forEach(
21575
- (isTaken, block) => (0, import_chunk_SG7ODKRM.log)(
21869
+ (isTaken, block) => (0, import_chunk_67LU4GPQ.log)(
21576
21870
  `block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
21577
21871
  )
21578
21872
  );
21579
21873
  }
21580
21874
  if (branchRedirects.size) {
21581
- (0, import_chunk_SG7ODKRM.log)(`====== redirected branches =====`);
21875
+ (0, import_chunk_67LU4GPQ.log)(`====== redirected branches =====`);
21582
21876
  branchRedirects.forEach(
21583
- ({ to, from }, block) => (0, import_chunk_SG7ODKRM.log)(
21877
+ ({ to, from }, block) => (0, import_chunk_67LU4GPQ.log)(
21584
21878
  `block ${offsetToString(
21585
21879
  block.offset
21586
21880
  )} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
@@ -21643,7 +21937,7 @@ function interpFunc(func, context) {
21643
21937
  }
21644
21938
  });
21645
21939
  if (interpLogging)
21646
- (0, import_chunk_SG7ODKRM.setBanner)(null);
21940
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
21647
21941
  return {
21648
21942
  liveInState,
21649
21943
  equivSets,
@@ -21693,7 +21987,7 @@ var init_interp2 = (0, import_chunk_ABYVSU2C.__esm)({
21693
21987
  "src/readprg/interp.ts"() {
21694
21988
  "use strict";
21695
21989
  init_interp_binary();
21696
- (0, import_chunk_SG7ODKRM.init_logger)();
21990
+ (0, import_chunk_67LU4GPQ.init_logger)();
21697
21991
  init_interp();
21698
21992
  init_types();
21699
21993
  init_union_type();
@@ -21805,7 +22099,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
21805
22099
  i = found;
21806
22100
  }
21807
22101
  if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
21808
- (0, import_chunk_SG7ODKRM.logger)(
22102
+ (0, import_chunk_67LU4GPQ.logger)(
21809
22103
  "array-init",
21810
22104
  1,
21811
22105
  () => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
@@ -21842,7 +22136,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
21842
22136
  convertAputv(offset - 1);
21843
22137
  }
21844
22138
  }
21845
- (0, import_chunk_SG7ODKRM.logger)(
22139
+ (0, import_chunk_67LU4GPQ.logger)(
21846
22140
  "array-init",
21847
22141
  1,
21848
22142
  () => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
@@ -21851,8 +22145,8 @@ function optimizeArrayInit(func, block, index, context, interpState) {
21851
22145
  block.bytecodes[index].offset
21852
22146
  )}`
21853
22147
  );
21854
- if ((0, import_chunk_SG7ODKRM.wouldLog)("array-init", 5)) {
21855
- (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));
21856
22150
  }
21857
22151
  return true;
21858
22152
  }
@@ -21892,7 +22186,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
21892
22186
  if (putvStarts.length < 3)
21893
22187
  return false;
21894
22188
  tryLocal(3);
21895
- (0, import_chunk_SG7ODKRM.logger)(
22189
+ (0, import_chunk_67LU4GPQ.logger)(
21896
22190
  "array-init",
21897
22191
  1,
21898
22192
  () => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
@@ -21918,7 +22212,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
21918
22212
  block.bytecodes[index + 1].arg = putvStarts.length;
21919
22213
  }
21920
22214
  }
21921
- (0, import_chunk_SG7ODKRM.logger)(
22215
+ (0, import_chunk_67LU4GPQ.logger)(
21922
22216
  "array-init",
21923
22217
  5,
21924
22218
  () => `index: ${index}, i: ${i}
@@ -21971,7 +22265,7 @@ ${blockToString(block, context)}`
21971
22265
  for (let i2 = putvStarts.length; i2-- > 1; ) {
21972
22266
  block.bytecodes.splice(putvStarts[i2], 2);
21973
22267
  }
21974
- (0, import_chunk_SG7ODKRM.logger)(
22268
+ (0, import_chunk_67LU4GPQ.logger)(
21975
22269
  "array-init",
21976
22270
  1,
21977
22271
  () => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
@@ -22030,15 +22324,15 @@ var init_array_init = (0, import_chunk_ABYVSU2C.__esm)({
22030
22324
  "src/readprg/array-init.ts"() {
22031
22325
  "use strict";
22032
22326
  init_types();
22033
- (0, import_chunk_SG7ODKRM.init_util)();
22327
+ (0, import_chunk_67LU4GPQ.init_util)();
22034
22328
  init_bytecode();
22035
22329
  init_interp2();
22036
22330
  init_opcodes();
22037
22331
  }
22038
22332
  });
22039
22333
  function localDCE(func, context) {
22040
- if ((0, import_chunk_SG7ODKRM.wouldLog)("dce", 5)) {
22041
- (0, import_chunk_SG7ODKRM.setBanner)(
22334
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("dce", 5)) {
22335
+ (0, import_chunk_67LU4GPQ.setBanner)(
22042
22336
  functionBanner(
22043
22337
  func,
22044
22338
  context,
@@ -22071,7 +22365,7 @@ function localDCE(func, context) {
22071
22365
  };
22072
22366
  func.blocks.forEach((block) => {
22073
22367
  const reportPopv = (i, item, kill) => {
22074
- (0, import_chunk_SG7ODKRM.logger)(
22368
+ (0, import_chunk_67LU4GPQ.logger)(
22075
22369
  "dce",
22076
22370
  2,
22077
22371
  () => `${func.name}: Convert ${i}:${bytecodeToString(
@@ -22086,7 +22380,7 @@ function localDCE(func, context) {
22086
22380
  );
22087
22381
  };
22088
22382
  const reportNop = (item) => {
22089
- (0, import_chunk_SG7ODKRM.logger)(
22383
+ (0, import_chunk_67LU4GPQ.logger)(
22090
22384
  "dce",
22091
22385
  2,
22092
22386
  () => `${func.name}: Kill ${item.deps.map(
@@ -22105,7 +22399,7 @@ function localDCE(func, context) {
22105
22399
  case 19: {
22106
22400
  const liveLocal = dceInfo.locals.has(bytecode.arg);
22107
22401
  if (!liveLocal && (bytecode.arg || context.config.allowForbiddenOpts)) {
22108
- (0, import_chunk_SG7ODKRM.logger)(
22402
+ (0, import_chunk_67LU4GPQ.logger)(
22109
22403
  "dce",
22110
22404
  2,
22111
22405
  () => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
@@ -22265,10 +22559,10 @@ function localDCE(func, context) {
22265
22559
  (bc) => bc.op !== 0
22266
22560
  /* nop */
22267
22561
  );
22268
- (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"));
22269
22563
  }
22270
22564
  });
22271
- (0, import_chunk_SG7ODKRM.setBanner)(null);
22565
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
22272
22566
  return anyChanges;
22273
22567
  }
22274
22568
  function computeLiveLocals(func) {
@@ -22319,7 +22613,7 @@ var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
22319
22613
  "src/readprg/dce.ts"() {
22320
22614
  "use strict";
22321
22615
  init_data_flow();
22322
- (0, import_chunk_SG7ODKRM.init_util)();
22616
+ (0, import_chunk_67LU4GPQ.init_util)();
22323
22617
  init_bytecode();
22324
22618
  init_cflow();
22325
22619
  init_opcodes();
@@ -22359,7 +22653,7 @@ function minimizeLocals2(func, equivSets, context) {
22359
22653
  const splitRanges = computeSplitRanges(func, equivSets);
22360
22654
  const locals = mergeSplitRanges(splitRanges);
22361
22655
  const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
22362
- (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"));
22363
22657
  let argc = func.argc ?? null;
22364
22658
  const colors = /* @__PURE__ */ new Map();
22365
22659
  const merge = [];
@@ -22426,15 +22720,15 @@ function minimizeLocals2(func, equivSets, context) {
22426
22720
  }
22427
22721
  }
22428
22722
  }
22429
- if ((0, import_chunk_SG7ODKRM.wouldLog)("locals", 1)) {
22430
- if (!(0, import_chunk_SG7ODKRM.wouldLog)("locals", 10)) {
22431
- (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"));
22432
22726
  }
22433
- (0, import_chunk_SG7ODKRM.log)(
22727
+ (0, import_chunk_67LU4GPQ.log)(
22434
22728
  `>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
22435
22729
  );
22436
22730
  merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
22437
- (merged) => (0, import_chunk_SG7ODKRM.log)(
22731
+ (merged) => (0, import_chunk_67LU4GPQ.log)(
22438
22732
  ` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
22439
22733
  )
22440
22734
  );
@@ -22733,7 +23027,7 @@ function mergeSplitRanges(splitRanges) {
22733
23027
  var init_locals = (0, import_chunk_ABYVSU2C.__esm)({
22734
23028
  "src/readprg/locals.ts"() {
22735
23029
  "use strict";
22736
- (0, import_chunk_SG7ODKRM.init_logger)();
23030
+ (0, import_chunk_67LU4GPQ.init_logger)();
22737
23031
  init_bytecode();
22738
23032
  init_cflow();
22739
23033
  init_opcodes();
@@ -22846,16 +23140,16 @@ function sizeBasedPRE2(func, context) {
22846
23140
  delete bc.arg;
22847
23141
  return bc;
22848
23142
  };
22849
- if ((0, import_chunk_SG7ODKRM.wouldLog)("pre", 1)) {
22850
- if ((0, import_chunk_SG7ODKRM.wouldLog)("pre", 5)) {
22851
- (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")());
22852
23146
  } else {
22853
- (0, import_chunk_SG7ODKRM.log)(`================ PRE : ${func.name} ================
23147
+ (0, import_chunk_67LU4GPQ.log)(`================ PRE : ${func.name} ================
22854
23148
  `);
22855
23149
  }
22856
23150
  insertionBlocks.forEach((o, key) => {
22857
23151
  const bcs = canonicalMap.get(key);
22858
- (0, import_chunk_SG7ODKRM.log)(
23152
+ (0, import_chunk_67LU4GPQ.log)(
22859
23153
  `Replacing ${bcs.size} instances of ${bytecodeToString(
22860
23154
  bcs.values().next().value,
22861
23155
  context.symbolTable
@@ -22938,13 +23232,13 @@ function sizeBasedPRE2(func, context) {
22938
23232
  bytecode(1, insertionBlocks.size)
22939
23233
  );
22940
23234
  }
22941
- (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"));
22942
23236
  return true;
22943
23237
  }
22944
23238
  var init_pre2 = (0, import_chunk_ABYVSU2C.__esm)({
22945
23239
  "src/readprg/pre.ts"() {
22946
23240
  "use strict";
22947
- (0, import_chunk_SG7ODKRM.init_logger)();
23241
+ (0, import_chunk_67LU4GPQ.init_logger)();
22948
23242
  init_bytecode();
22949
23243
  init_cflow();
22950
23244
  init_opcodes();
@@ -22977,9 +23271,9 @@ function blockSharing(func, context) {
22977
23271
  if (!any)
22978
23272
  return false;
22979
23273
  any = false;
22980
- const logging3 = (0, import_chunk_SG7ODKRM.wouldLog)("sharing", 1);
22981
- if (logging3 && (0, import_chunk_SG7ODKRM.wouldLog)("sharing", 10)) {
22982
- (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"));
22983
23277
  }
22984
23278
  candidates.forEach((blocks) => {
22985
23279
  while (blocks.size > 1) {
@@ -23115,9 +23409,9 @@ function blockSharing(func, context) {
23115
23409
  block2.offset
23116
23410
  )})` : `block(${offsetToString(block2.offset)})`;
23117
23411
  };
23118
- (0, import_chunk_SG7ODKRM.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23119
- if ((0, import_chunk_SG7ODKRM.wouldLog)("sharing", 5)) {
23120
- (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));
23121
23415
  }
23122
23416
  }
23123
23417
  if (target.bytecodes.length > length2) {
@@ -23144,13 +23438,13 @@ function blockSharing(func, context) {
23144
23438
  });
23145
23439
  }
23146
23440
  });
23147
- (0, import_chunk_SG7ODKRM.setBanner)(null);
23441
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
23148
23442
  return any;
23149
23443
  }
23150
23444
  var init_sharing = (0, import_chunk_ABYVSU2C.__esm)({
23151
23445
  "src/readprg/sharing.ts"() {
23152
23446
  "use strict";
23153
- (0, import_chunk_SG7ODKRM.init_util)();
23447
+ (0, import_chunk_67LU4GPQ.init_util)();
23154
23448
  init_bytecode();
23155
23449
  init_opcodes();
23156
23450
  }
@@ -23214,7 +23508,7 @@ function doArrayInits(func, liveInState, context) {
23214
23508
  }
23215
23509
  function simpleOpts(func, context) {
23216
23510
  const equalsSym = 8388787;
23217
- const logging3 = (0, import_chunk_SG7ODKRM.wouldLog)("optimize", 5);
23511
+ const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("optimize", 5);
23218
23512
  return Array.from(func.blocks.values()).reduce((changes, block) => {
23219
23513
  for (let i = block.bytecodes.length; i--; ) {
23220
23514
  const cur = block.bytecodes[i];
@@ -23222,7 +23516,7 @@ function simpleOpts(func, context) {
23222
23516
  block.bytecodes.splice(i, 1);
23223
23517
  changes = true;
23224
23518
  if (logging3) {
23225
- (0, import_chunk_SG7ODKRM.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23519
+ (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23226
23520
  }
23227
23521
  } else if (cur.op === 74 && context.config.removeArgc && context.config.allowForbiddenOpts) {
23228
23522
  const arg = cur.arg.incsp;
@@ -23231,7 +23525,7 @@ function simpleOpts(func, context) {
23231
23525
  incsp.arg = arg;
23232
23526
  changes = true;
23233
23527
  if (logging3) {
23234
- (0, import_chunk_SG7ODKRM.log)(`${func.name}: argcincsp => incsp`);
23528
+ (0, import_chunk_67LU4GPQ.log)(`${func.name}: argcincsp => incsp`);
23235
23529
  }
23236
23530
  } else if (i && cur.op === 39 && cur.arg === equalsSym) {
23237
23531
  changes = equalSymbolToEq(block, i) || changes;
@@ -23242,7 +23536,7 @@ function simpleOpts(func, context) {
23242
23536
  if (!shift && prev.op === 37) {
23243
23537
  block.bytecodes.splice(i - 1, 2);
23244
23538
  changes = true;
23245
- 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})`);
23246
23540
  continue;
23247
23541
  }
23248
23542
  if (shift === 1n && prev.op === 37) {
@@ -23252,7 +23546,7 @@ function simpleOpts(func, context) {
23252
23546
  const add = cur;
23253
23547
  add.op = 3;
23254
23548
  delete add.arg;
23255
- 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"`);
23256
23550
  continue;
23257
23551
  }
23258
23552
  if (shift < (prev.op === 49 ? 64n : 31n)) {
@@ -23262,7 +23556,7 @@ function simpleOpts(func, context) {
23262
23556
  } else {
23263
23557
  prev.arg = BigInt.asIntN(64, mul);
23264
23558
  }
23265
- logging3 && (0, import_chunk_SG7ODKRM.log)(
23559
+ logging3 && (0, import_chunk_67LU4GPQ.log)(
23266
23560
  `${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
23267
23561
  );
23268
23562
  changes = true;
@@ -23276,14 +23570,14 @@ function simpleOpts(func, context) {
23276
23570
  func.blocks.get(block.taken).preds.delete(block.offset);
23277
23571
  delete block.taken;
23278
23572
  changes = true;
23279
- 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`);
23280
23574
  } else if (isCondBranch(cur.op)) {
23281
23575
  const next = func.blocks.get(block.next);
23282
23576
  const taken = func.blocks.get(block.taken);
23283
23577
  if (next.preds.size > 1 && taken.preds.size === 1) {
23284
23578
  const newOp = cur.op === 40 ? 41 : 40;
23285
23579
  if (logging3) {
23286
- (0, import_chunk_SG7ODKRM.log)(
23580
+ (0, import_chunk_67LU4GPQ.log)(
23287
23581
  `${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
23288
23582
  );
23289
23583
  }
@@ -23296,7 +23590,7 @@ function simpleOpts(func, context) {
23296
23590
  const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
23297
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) {
23298
23592
  if (logging3) {
23299
- (0, import_chunk_SG7ODKRM.log)(
23593
+ (0, import_chunk_67LU4GPQ.log)(
23300
23594
  `${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23301
23595
  next.offset
23302
23596
  )}:${offsetToString(taken.offset)}:`
@@ -23313,7 +23607,7 @@ function simpleOpts(func, context) {
23313
23607
  changes = true;
23314
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) {
23315
23609
  if (logging3) {
23316
- (0, import_chunk_SG7ODKRM.log)(
23610
+ (0, import_chunk_67LU4GPQ.log)(
23317
23611
  `${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23318
23612
  taken.offset
23319
23613
  )}:${offsetToString(next.offset)}:`
@@ -23361,7 +23655,7 @@ function equalSymbolToEq(block, equalsIndex) {
23361
23655
  op: 26,
23362
23656
  offset: invokem.offset
23363
23657
  });
23364
- (0, import_chunk_SG7ODKRM.logger)(
23658
+ (0, import_chunk_67LU4GPQ.logger)(
23365
23659
  "optimize",
23366
23660
  1,
23367
23661
  `Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
@@ -23421,7 +23715,7 @@ function removeUnreachableCatches(func, context) {
23421
23715
  const next = func.blocks.get(block.next);
23422
23716
  if (block.try === next.try) {
23423
23717
  if (next.preds.size === 1) {
23424
- (0, import_chunk_SG7ODKRM.logger)(
23718
+ (0, import_chunk_67LU4GPQ.logger)(
23425
23719
  "cfg",
23426
23720
  1,
23427
23721
  () => `${func.name}: ${offsetToString(
@@ -23444,7 +23738,7 @@ function removeUnreachableCatches(func, context) {
23444
23738
  delete next.preds;
23445
23739
  removeBlock(func, next.offset);
23446
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) {
23447
- (0, import_chunk_SG7ODKRM.logger)(
23741
+ (0, import_chunk_67LU4GPQ.logger)(
23448
23742
  "cfg",
23449
23743
  1,
23450
23744
  () => `${func.name}: ${offsetToString(
@@ -23469,7 +23763,7 @@ function removeUnreachableCatches(func, context) {
23469
23763
  switch (last.op) {
23470
23764
  case 41:
23471
23765
  case 40:
23472
- (0, import_chunk_SG7ODKRM.logger)(
23766
+ (0, import_chunk_67LU4GPQ.logger)(
23473
23767
  "cfg",
23474
23768
  1,
23475
23769
  () => `${func.name}: killing no-op ${bytecodeToString(
@@ -23492,7 +23786,7 @@ function removeUnreachableCatches(func, context) {
23492
23786
  for (let i = block.try.length; i--; ) {
23493
23787
  const handler = block.try[i].handler;
23494
23788
  if (!func.blocks.get(handler)?.preds?.size) {
23495
- (0, import_chunk_SG7ODKRM.logger)(
23789
+ (0, import_chunk_67LU4GPQ.logger)(
23496
23790
  "cfg",
23497
23791
  1,
23498
23792
  `${func.name}: killing unused try-catch at ${offsetToString(
@@ -23509,8 +23803,8 @@ function removeUnreachableCatches(func, context) {
23509
23803
  });
23510
23804
  }
23511
23805
  function cleanCfg2(func, context) {
23512
- if ((0, import_chunk_SG7ODKRM.wouldLog)("cfg", 10)) {
23513
- (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"));
23514
23808
  }
23515
23809
  removeNoOpBlocks(func);
23516
23810
  removeUnreachableCatches(func, context);
@@ -23525,12 +23819,12 @@ function cleanCfg2(func, context) {
23525
23819
  (0, import_node_assert12.default)(!block.preds?.size);
23526
23820
  func.blocks.delete(block.offset);
23527
23821
  });
23528
- (0, import_chunk_SG7ODKRM.setBanner)(null);
23822
+ (0, import_chunk_67LU4GPQ.setBanner)(null);
23529
23823
  }
23530
23824
  var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
23531
23825
  "src/readprg/optimize.ts"() {
23532
23826
  "use strict";
23533
- (0, import_chunk_SG7ODKRM.init_util)();
23827
+ (0, import_chunk_67LU4GPQ.init_util)();
23534
23828
  init_array_init();
23535
23829
  init_bytecode();
23536
23830
  init_cflow();
@@ -24145,21 +24439,21 @@ function optimizeBytecode(context) {
24145
24439
  functions.forEach(callback);
24146
24440
  return;
24147
24441
  }
24148
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, 10);
24442
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24149
24443
  functions.forEach((func) => {
24150
24444
  if (loggerFunc.test(func.name ?? "<null>")) {
24151
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, -10);
24445
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24152
24446
  callback(func);
24153
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, 10);
24447
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24154
24448
  return;
24155
24449
  }
24156
24450
  callback(func);
24157
24451
  });
24158
- (0, import_chunk_SG7ODKRM.bumpLogging)(null, -10);
24452
+ (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24159
24453
  };
24160
- if ((0, import_chunk_SG7ODKRM.wouldLog)("list-input", 1)) {
24454
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1)) {
24161
24455
  forEachFunction(
24162
- (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)
24163
24457
  );
24164
24458
  }
24165
24459
  forEachFunction((func) => optimizeFunc(func, context));
@@ -24177,7 +24471,7 @@ function optimizeBytecode(context) {
24177
24471
  forEachFunction((func) => {
24178
24472
  if (!func.name)
24179
24473
  return;
24180
- (0, import_chunk_SG7ODKRM.logger)(
24474
+ (0, import_chunk_67LU4GPQ.logger)(
24181
24475
  "bytecode",
24182
24476
  5,
24183
24477
  `${func.name}: ${offset.toString(16)} ${offset - func.offset}`
@@ -24186,7 +24480,7 @@ function optimizeBytecode(context) {
24186
24480
  });
24187
24481
  const { offsetMap } = updateInfo;
24188
24482
  offsetMap.set(code.byteLength, offset);
24189
- (0, import_chunk_SG7ODKRM.logger)(
24483
+ (0, import_chunk_67LU4GPQ.logger)(
24190
24484
  "bytecode",
24191
24485
  1,
24192
24486
  `${context.filepath}: code size: ${context.sections[
@@ -24198,9 +24492,9 @@ function optimizeBytecode(context) {
24198
24492
  ].length - offset}`
24199
24493
  );
24200
24494
  fixSectionSize(-1059145026, context.sections, offset);
24201
- if ((0, import_chunk_SG7ODKRM.wouldLog)("list-output", 1)) {
24495
+ if ((0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1)) {
24202
24496
  forEachFunction(
24203
- (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)
24204
24498
  );
24205
24499
  }
24206
24500
  fixupHeader(context, updateInfo);
@@ -24290,7 +24584,7 @@ ${functionToString(
24290
24584
  ---------------- ${func.name} ----------------`;
24291
24585
  }
24292
24586
  function printFunction(func, context) {
24293
- (0, import_chunk_SG7ODKRM.log)(functionToString(func, context));
24587
+ (0, import_chunk_67LU4GPQ.log)(functionToString(func, context));
24294
24588
  }
24295
24589
  function functionToString(func, context, extra) {
24296
24590
  const parts = [];
@@ -24721,7 +25015,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
24721
25015
  "use strict";
24722
25016
  (0, import_chunk_MBTLUWXR.init_ast)();
24723
25017
  init_sdk_util();
24724
- (0, import_chunk_SG7ODKRM.init_util)();
25018
+ (0, import_chunk_67LU4GPQ.init_util)();
24725
25019
  init_data();
24726
25020
  init_emit();
24727
25021
  init_exceptions();
@@ -25007,10 +25301,10 @@ async function build_project(product, options, lineCallback) {
25007
25301
  ].flat();
25008
25302
  if (!returnCommand) {
25009
25303
  const handlers = [
25010
- lineCallback || ((line) => (0, import_chunk_SG7ODKRM.log)(line)),
25304
+ lineCallback || ((line) => (0, import_chunk_67LU4GPQ.log)(line)),
25011
25305
  (line) => console.error(line)
25012
25306
  ];
25013
- await (0, import_chunk_SG7ODKRM.spawnByLine)(exe, args, handlers, {
25307
+ await (0, import_chunk_67LU4GPQ.spawnByLine)(exe, args, handlers, {
25014
25308
  cwd: workspace
25015
25309
  });
25016
25310
  }
@@ -25020,7 +25314,7 @@ var init_build = (0, import_chunk_ABYVSU2C.__esm)({
25020
25314
  "src/build.ts"() {
25021
25315
  "use strict";
25022
25316
  init_sdk_util();
25023
- (0, import_chunk_SG7ODKRM.init_util)();
25317
+ (0, import_chunk_67LU4GPQ.init_util)();
25024
25318
  }
25025
25319
  });
25026
25320
  var require_ms = (0, import_chunk_ABYVSU2C.__commonJS)({
@@ -27987,7 +28281,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
27987
28281
  );
27988
28282
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(cache.resolvedPaths, resolved)) {
27989
28283
  if (/[*?[\]{}]/.test(resolved)) {
27990
- cache.resolvedPaths[resolved] = (0, import_chunk_SG7ODKRM.globSome)(resolved, () => true);
28284
+ cache.resolvedPaths[resolved] = (0, import_chunk_67LU4GPQ.globSome)(resolved, () => true);
27991
28285
  } else {
27992
28286
  cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
27993
28287
  () => true,
@@ -28065,12 +28359,12 @@ async function read_resource_files(targets, cache) {
28065
28359
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(resourceGroupPromises, key)) {
28066
28360
  resourceGroupPromises[key] = Promise.all(
28067
28361
  p.qualifier.resourcePath.map(
28068
- (pattern) => (0, import_chunk_SG7ODKRM.globa)(pattern, { mark: true })
28362
+ (pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { mark: true })
28069
28363
  )
28070
28364
  ).then(
28071
28365
  (patterns) => Promise.all(
28072
28366
  patterns.flat().map(
28073
- (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
28074
28368
  )
28075
28369
  )
28076
28370
  ).then(
@@ -28130,7 +28424,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
28130
28424
  const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
28131
28425
  const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
28132
28426
  if (filePatterns.length) {
28133
- 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();
28134
28428
  sourceExcludes.push(...files);
28135
28429
  }
28136
28430
  const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
@@ -28307,15 +28601,15 @@ function identify_optimizer_groups(targets, options) {
28307
28601
  function find_barrels(barrelPath) {
28308
28602
  if (Array.isArray(barrelPath)) {
28309
28603
  return Promise.all(
28310
- barrelPath.map((path7) => (0, import_chunk_SG7ODKRM.globa)(path7, { mark: true }))
28604
+ barrelPath.map((path7) => (0, import_chunk_67LU4GPQ.globa)(path7, { mark: true }))
28311
28605
  ).then((paths) => [
28312
28606
  paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
28313
28607
  ]);
28314
28608
  }
28315
- return (0, import_chunk_SG7ODKRM.globa)(barrelPath, { mark: true }).then(
28609
+ return (0, import_chunk_67LU4GPQ.globa)(barrelPath, { mark: true }).then(
28316
28610
  (paths) => Promise.all(
28317
28611
  paths.map(
28318
- (path7) => path7.endsWith("/") ? (0, import_chunk_SG7ODKRM.globa)(`${path7}**/*.barrel`) : path7
28612
+ (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.barrel`) : path7
28319
28613
  )
28320
28614
  )
28321
28615
  ).then(
@@ -28326,7 +28620,7 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
28326
28620
  if ((0, import_chunk_MBTLUWXR.hasProperty)(cache.barrels, barrel)) {
28327
28621
  return cache.barrels[barrel];
28328
28622
  }
28329
- let promise = Promise.resolve();
28623
+ let promise = Promise.resolve(null);
28330
28624
  let rawBarrel = barrel;
28331
28625
  if (barrel.endsWith(".barrel")) {
28332
28626
  const sha1 = crypto2.createHash("sha1").update(barrel, "binary").digest("base64").replace(/[/=+]/g, "");
@@ -28339,9 +28633,9 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
28339
28633
  () => fs5.stat(localPath).then(
28340
28634
  (localStat) => !localStat.isDirectory() || fs5.stat(barrel).then((barrelStat) => localStat.mtimeMs < barrelStat.mtimeMs),
28341
28635
  () => true
28342
- ).then((needsUpdate) => {
28343
- needsUpdate && fs5.rm(localPath, { recursive: true, force: true }).then(() => (0, import_extract_zip.default)(barrel, { dir: localPath }));
28344
- })
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
+ )
28345
28639
  );
28346
28640
  }
28347
28641
  return promise.then(() => get_jungle_and_barrels(rawBarrel, products, options, cache)).then((result) => {
@@ -28588,7 +28882,7 @@ var init_jungles = (0, import_chunk_ABYVSU2C.__esm)({
28588
28882
  init_api();
28589
28883
  init_manifest();
28590
28884
  init_sdk_util();
28591
- (0, import_chunk_SG7ODKRM.init_util)();
28885
+ (0, import_chunk_67LU4GPQ.init_util)();
28592
28886
  depth = 0;
28593
28887
  }
28594
28888
  });
@@ -28616,7 +28910,7 @@ async function launchSimulator(force = true) {
28616
28910
  await new Promise((r) => setTimeout(r, 200));
28617
28911
  }
28618
28912
  } catch (e) {
28619
- (0, import_chunk_SG7ODKRM.log)(e);
28913
+ (0, import_chunk_67LU4GPQ.log)(e);
28620
28914
  }
28621
28915
  }
28622
28916
  function checkIfSimulatorRunning() {
@@ -28647,10 +28941,10 @@ function simulateProgram(prg, device, test = false, logger2) {
28647
28941
  }
28648
28942
  }
28649
28943
  return getSdkPath().then(
28650
- (sdk) => (0, import_chunk_SG7ODKRM.spawnByLine)(
28944
+ (sdk) => (0, import_chunk_67LU4GPQ.spawnByLine)(
28651
28945
  path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
28652
28946
  args,
28653
- logger2 || ((line) => (0, import_chunk_SG7ODKRM.log)(line))
28947
+ logger2 || ((line) => (0, import_chunk_67LU4GPQ.log)(line))
28654
28948
  ).then(() => {
28655
28949
  return;
28656
28950
  })
@@ -28660,7 +28954,7 @@ var init_launch = (0, import_chunk_ABYVSU2C.__esm)({
28660
28954
  "src/launch.ts"() {
28661
28955
  "use strict";
28662
28956
  init_sdk_util();
28663
- (0, import_chunk_SG7ODKRM.init_util)();
28957
+ (0, import_chunk_67LU4GPQ.init_util)();
28664
28958
  }
28665
28959
  });
28666
28960
  function relative_path_no_dotdot(relative2) {
@@ -28677,32 +28971,56 @@ async function getVSCodeSettings(path7) {
28677
28971
  return {};
28678
28972
  }
28679
28973
  }
28974
+ async function getCodeWorkspaceSettings(folder) {
28975
+ let curDir = folder;
28976
+ try {
28977
+ while (curDir) {
28978
+ const code_workspaces = await (0, import_chunk_67LU4GPQ.globa)(
28979
+ path4.resolve(curDir, "*.code-workspace"),
28980
+ { onlyFiles: true }
28981
+ );
28982
+ if (code_workspaces.length === 1) {
28983
+ const contents = await fs6.readFile(code_workspaces[0], "utf-8");
28984
+ const code_workspace = JSON.parse(contents);
28985
+ if (Array.isArray(code_workspace.folders) && code_workspace.settings && code_workspace.folders.some(
28986
+ (workspace) => path4.resolve(curDir, workspace.path) === folder
28987
+ )) {
28988
+ return code_workspace.settings;
28989
+ }
28990
+ break;
28991
+ }
28992
+ if (code_workspaces.length > 1)
28993
+ break;
28994
+ const next = path4.dirname(curDir);
28995
+ if (next === curDir)
28996
+ break;
28997
+ curDir = next;
28998
+ }
28999
+ } catch (ex) {
29000
+ }
29001
+ return {};
29002
+ }
28680
29003
  function isErrorWithLocation(e) {
28681
29004
  return (0, import_chunk_MBTLUWXR.hasProperty)(e, "location");
28682
29005
  }
28683
29006
  function getConfig(options) {
28684
29007
  const config = { ...defaultConfig, ...options || {} };
28685
- return [
28686
- "jungleFiles",
28687
- "developerKeyPath",
28688
- "typeCheckLevel",
28689
- "optimizationLevel",
28690
- "compilerOptions",
28691
- "compilerWarnings",
28692
- "ignoredExcludeAnnotations",
28693
- "ignoredAnnotations",
28694
- "ignoredSourcePaths"
28695
- ].reduce((promise, key) => {
29008
+ const defaults = buildConfigDescription.flatMap(
29009
+ (desc) => Object.entries(desc.properties)
29010
+ );
29011
+ return defaults.reduce((promise, [key, info]) => {
28696
29012
  if (key in config)
28697
29013
  return promise;
28698
29014
  return promise.then(
28699
29015
  (v) => v || getVSCodeSettings(`${appSupport}/Code/User/settings.json`).then(
28700
- (globals) => getVSCodeSettings(
28701
- `${config.workspace}/.vscode/settings.json`
28702
- ).then((locals) => ({ ...globals, ...locals }))
29016
+ (globals) => getCodeWorkspaceSettings(config.workspace).then(
29017
+ (workspace) => getVSCodeSettings(
29018
+ `${config.workspace ?? "."}/.vscode/settings.json`
29019
+ ).then((locals) => ({ ...globals, ...workspace, ...locals }))
29020
+ )
28703
29021
  )
28704
29022
  ).then((settings) => {
28705
- const value2 = settings[`monkeyC.${key}`] || settings[`prettierMonkeyC.${key}`];
29023
+ const value2 = settings[`prettierMonkeyC.${key}`] ?? settings[`monkeyC.${key}`] ?? info.default;
28706
29024
  if (value2 !== void 0) {
28707
29025
  config[key] = value2;
28708
29026
  }
@@ -28780,7 +29098,7 @@ async function createLocalBarrels(targets, options) {
28780
29098
  optBarrelDir
28781
29099
  };
28782
29100
  return promise2.then(
28783
- () => (0, import_chunk_SG7ODKRM.copyRecursiveAsNeeded)(
29101
+ () => (0, import_chunk_67LU4GPQ.copyRecursiveAsNeeded)(
28784
29102
  rawBarrelDir,
28785
29103
  optBarrelDir,
28786
29104
  (src) => !src.endsWith(".mc")
@@ -29082,11 +29400,11 @@ async function generateOptimizedProject(options) {
29082
29400
  }
29083
29401
  async function filesFromPaths(workspace, paths, extension) {
29084
29402
  paths = (await Promise.all(
29085
- 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 })) || []
29086
29404
  )).flat();
29087
29405
  const files = await Promise.all(
29088
29406
  paths.map(
29089
- (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
29090
29408
  )
29091
29409
  );
29092
29410
  return {
@@ -29196,7 +29514,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29196
29514
  })
29197
29515
  );
29198
29516
  }
29199
- 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();
29200
29518
  const {
29201
29519
  hasTests,
29202
29520
  diagnostics: prevDiagnostics,
@@ -29212,13 +29530,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29212
29530
  const sdk = await getSdkPath();
29213
29531
  const match = sdk.match(/-(\d+\.\d+\.\d+)/);
29214
29532
  if ((match && parseSdkVersion(match[1])) === prevSdkVersion) {
29215
- const source_time = await (0, import_chunk_SG7ODKRM.last_modified)(
29533
+ const source_time = await (0, import_chunk_67LU4GPQ.last_modified)(
29216
29534
  Object.keys(fnMap).concat(dependencyFiles)
29217
29535
  );
29218
- const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
29536
+ const opt_time = await (0, import_chunk_67LU4GPQ.first_modified)(
29219
29537
  Object.values(fnMap).map((v) => v.output)
29220
29538
  );
29221
- if (source_time < opt_time && 1716827034287 < opt_time) {
29539
+ if (source_time < opt_time && 1719447701318 < opt_time) {
29222
29540
  return {
29223
29541
  hasTests,
29224
29542
  diagnostics: prevDiagnostics,
@@ -29257,7 +29575,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29257
29575
  hasTests: hasTests2,
29258
29576
  diagnostics,
29259
29577
  sdkVersion,
29260
- optimizerVersion: "1.1.63",
29578
+ optimizerVersion: "1.1.65",
29261
29579
  ...Object.fromEntries(
29262
29580
  configOptionsToCheck.map((option) => [option, config[option]])
29263
29581
  )
@@ -29271,7 +29589,7 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
29271
29589
  try {
29272
29590
  return getProjectAnalysisHelper(targets, analysis, manifestXML, options);
29273
29591
  } catch (ex) {
29274
- if (ex instanceof import_chunk_SG7ODKRM.AwaitedError) {
29592
+ if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
29275
29593
  await ex.resolve();
29276
29594
  }
29277
29595
  throw ex;
@@ -29279,13 +29597,17 @@ async function getProjectAnalysis(targets, analysis, manifestXML, options) {
29279
29597
  }
29280
29598
  async function getProjectAnalysisHelper(targets, analysis, manifestXML, options) {
29281
29599
  const qualifiers = /* @__PURE__ */ new Map();
29282
- const addQualifier = (name, qualifier) => {
29600
+ const addQualifier = (name, qualifier, root) => {
29283
29601
  const sp = qualifier.sourcePath;
29284
29602
  const pp = qualifier.personality;
29285
29603
  if (sp || pp) {
29286
29604
  let q = qualifiers.get(name);
29287
29605
  if (!q) {
29288
- q = { sourcePath: /* @__PURE__ */ new Set(), personality: /* @__PURE__ */ new Set() };
29606
+ q = {
29607
+ sourcePath: /* @__PURE__ */ new Set(),
29608
+ personality: /* @__PURE__ */ new Set(),
29609
+ root
29610
+ };
29289
29611
  qualifiers.set(name, q);
29290
29612
  }
29291
29613
  sp?.forEach((s) => q.sourcePath.add(s));
@@ -29293,10 +29615,10 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29293
29615
  }
29294
29616
  };
29295
29617
  const products = targets.map(({ qualifier, product }) => {
29296
- addQualifier("", qualifier);
29618
+ addQualifier("", qualifier, options.workspace);
29297
29619
  if (qualifier.barrelMap) {
29298
29620
  Object.entries(qualifier.barrelMap).forEach(([name, bm]) => {
29299
- addQualifier(name, bm.qualifier);
29621
+ addQualifier(name, bm.qualifier, path4.dirname(bm.jungles[0]));
29300
29622
  });
29301
29623
  }
29302
29624
  return product;
@@ -29304,7 +29626,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29304
29626
  const { fnMap, paths } = await Promise.all(
29305
29627
  Array.from(qualifiers).map(
29306
29628
  ([name, qualifier]) => fileInfoFromConfig(
29307
- options.workspace,
29629
+ qualifier.root,
29308
29630
  options.workspace,
29309
29631
  {
29310
29632
  sourcePath: Array.from(qualifier.sourcePath),
@@ -29320,7 +29642,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29320
29642
  if (!cur)
29321
29643
  return result;
29322
29644
  Object.entries(result.fnMap).forEach(
29323
- ([key, value2]) => cur.fnMap[key] = value2
29645
+ ([key, value2]) => cur.fnMap[key] || (cur.fnMap[key] = value2)
29324
29646
  );
29325
29647
  cur.paths.push(...result.paths);
29326
29648
  return cur;
@@ -29408,6 +29730,7 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
29408
29730
  "src/optimizer.ts"() {
29409
29731
  init_api();
29410
29732
  init_build();
29733
+ init_build_config();
29411
29734
  init_jungles();
29412
29735
  init_launch();
29413
29736
  init_manifest();
@@ -29417,7 +29740,7 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
29417
29740
  init_could_be();
29418
29741
  init_interp();
29419
29742
  init_sub_type();
29420
- (0, import_chunk_SG7ODKRM.init_util)();
29743
+ (0, import_chunk_67LU4GPQ.init_util)();
29421
29744
  init_worker_pool();
29422
29745
  init_optimizer_types();
29423
29746
  init_types();
@@ -29477,7 +29800,7 @@ async function performTask(task) {
29477
29800
  throw new Error(`Invalid task type ${type}`);
29478
29801
  }
29479
29802
  return Promise.resolve(handler(task.data)).then(
29480
- (result) => import_chunk_SG7ODKRM.logPromise.then(() => result)
29803
+ (result) => import_chunk_67LU4GPQ.logPromise.then(() => result)
29481
29804
  );
29482
29805
  }
29483
29806
  var workerTaskHandlers;
@@ -29487,7 +29810,7 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
29487
29810
  init_optimizer();
29488
29811
  init_readprg();
29489
29812
  init_sdk_util();
29490
- (0, import_chunk_SG7ODKRM.init_logger)();
29813
+ (0, import_chunk_67LU4GPQ.init_logger)();
29491
29814
  workerTaskHandlers = {
29492
29815
  buildOptimizedProject(data) {
29493
29816
  return buildOptimizedProject(data.product, data.options);
@@ -29704,7 +30027,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
29704
30027
  }
29705
30028
  function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, config) {
29706
30029
  const { sections } = readPrgWithOffsets(view);
29707
- (0, import_chunk_SG7ODKRM.logger)("readprg", 5, sections);
30030
+ (0, import_chunk_67LU4GPQ.logger)("readprg", 5, sections);
29708
30031
  const symbolTable = new SymbolTable();
29709
30032
  if ((0, import_chunk_MBTLUWXR.hasProperty)(sections, 1461170197 .toString())) {
29710
30033
  symbolTable.parse(sections[
@@ -30004,7 +30327,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
30004
30327
  init_signer();
30005
30328
  init_symbols();
30006
30329
  init_sdk_util();
30007
- (0, import_chunk_SG7ODKRM.init_util)();
30330
+ (0, import_chunk_67LU4GPQ.init_util)();
30008
30331
  init_worker_pool();
30009
30332
  }
30010
30333
  });
@@ -30016,7 +30339,7 @@ function getSdkPath() {
30016
30339
  });
30017
30340
  }
30018
30341
  async function getDeviceInfo() {
30019
- 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`);
30020
30343
  if (!files.length) {
30021
30344
  throw new Error(
30022
30345
  `No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
@@ -30084,7 +30407,7 @@ async function getFunctionDocumentation() {
30084
30407
  var isWin, appSupport, connectiq;
30085
30408
  var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
30086
30409
  "src/sdk-util.ts"() {
30087
- (0, import_chunk_SG7ODKRM.init_util)();
30410
+ (0, import_chunk_67LU4GPQ.init_util)();
30088
30411
  init_xml_util();
30089
30412
  init_readprg();
30090
30413
  init_bytecode();
@@ -30105,6 +30428,7 @@ var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
30105
30428
  TruthyTypes,
30106
30429
  analyze,
30107
30430
  appSupport,
30431
+ buildConfigDescription,
30108
30432
  buildOptimizedProject,
30109
30433
  checkCompilerVersion,
30110
30434
  collectNamespaces,