@markw65/monkeyc-optimizer 1.1.66 → 1.1.67

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_UDJNFXSX_exports = {};
30
- __export(chunk_UDJNFXSX_exports, {
29
+ var chunk_2OEXWI65_exports = {};
30
+ __export(chunk_2OEXWI65_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -64,6 +64,7 @@ __export(chunk_UDJNFXSX_exports, {
64
64
  getConfig: () => getConfig,
65
65
  getDeviceInfo: () => getDeviceInfo,
66
66
  getFileASTs: () => getFileASTs,
67
+ getFnMapAnalysis: () => getFnMapAnalysis,
67
68
  getFunctionDocumentation: () => getFunctionDocumentation,
68
69
  getLanguages: () => getLanguages,
69
70
  getProjectAnalysis: () => getProjectAnalysis,
@@ -134,8 +135,8 @@ __export(chunk_UDJNFXSX_exports, {
134
135
  visitorNode: () => visitorNode,
135
136
  xml_util_exports: () => xml_util_exports
136
137
  });
137
- module.exports = __toCommonJS(chunk_UDJNFXSX_exports);
138
- var import_chunk_67LU4GPQ = require("./chunk-67LU4GPQ.cjs");
138
+ module.exports = __toCommonJS(chunk_2OEXWI65_exports);
139
+ var import_chunk_OASVKTK5 = require("./chunk-OASVKTK5.cjs");
139
140
  var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
140
141
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
141
142
  var import_node_assert = __toESM(require("node:assert"));
@@ -5642,6 +5643,18 @@ var init_build_config = (0, import_chunk_ABYVSU2C.__esm)({
5642
5643
  default: "WARNING",
5643
5644
  scope: "resource"
5644
5645
  },
5646
+ strictTypeCheck: {
5647
+ type: "string",
5648
+ description: "Whether to do strict or relaxed type checking - Default deduces it from typeCheckLevel",
5649
+ enum: ["On", "Off", "Default"],
5650
+ enumDescriptions: [
5651
+ "Do Strict type checking",
5652
+ "Do Relaxed type checking",
5653
+ "Do Strict type checking iff typeCheckLevel is Strict"
5654
+ ],
5655
+ default: "Default",
5656
+ scope: "resource"
5657
+ },
5645
5658
  trustDeclaredTypes: {
5646
5659
  order: 100,
5647
5660
  type: "boolean",
@@ -7326,9 +7339,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
7326
7339
  );
7327
7340
  }
7328
7341
  } else {
7329
- (0, import_chunk_67LU4GPQ.forEach)(events, (e) => e.mayThrow = false);
7342
+ (0, import_chunk_OASVKTK5.forEach)(events, (e) => e.mayThrow = false);
7330
7343
  }
7331
- (0, import_chunk_67LU4GPQ.forEach)(events, (event) => {
7344
+ (0, import_chunk_OASVKTK5.forEach)(events, (event) => {
7332
7345
  if (event.mayThrow) {
7333
7346
  for (let i = localState.stack.length; i--; ) {
7334
7347
  const target = localState.stack[i].throw;
@@ -7473,7 +7486,7 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7473
7486
  "src/control-flow.ts"() {
7474
7487
  "use strict";
7475
7488
  (0, import_chunk_MBTLUWXR.init_ast)();
7476
- (0, import_chunk_67LU4GPQ.init_util)();
7489
+ (0, import_chunk_OASVKTK5.init_util)();
7477
7490
  Terminals = {
7478
7491
  BreakStatement: "break",
7479
7492
  ContinueStatement: "continue",
@@ -7503,12 +7516,12 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
7503
7516
  if (!from.succs) {
7504
7517
  from.succs = [to];
7505
7518
  } else {
7506
- (0, import_chunk_67LU4GPQ.pushUnique)(from.succs, to);
7519
+ (0, import_chunk_OASVKTK5.pushUnique)(from.succs, to);
7507
7520
  }
7508
7521
  if (!to.preds) {
7509
7522
  to.preds = [from];
7510
7523
  } else {
7511
- (0, import_chunk_67LU4GPQ.pushUnique)(to.preds, from);
7524
+ (0, import_chunk_OASVKTK5.pushUnique)(to.preds, from);
7512
7525
  }
7513
7526
  }
7514
7527
  newBlock(block) {
@@ -7862,8 +7875,8 @@ function mergeObjectValues(to, from) {
7862
7875
  function mergeStateDecls(to, from) {
7863
7876
  let changed = false;
7864
7877
  let result = to;
7865
- (0, import_chunk_67LU4GPQ.forEach)(from, (v) => {
7866
- if ((0, import_chunk_67LU4GPQ.some)(to, (t) => t === v)) {
7878
+ (0, import_chunk_OASVKTK5.forEach)(from, (v) => {
7879
+ if ((0, import_chunk_OASVKTK5.some)(to, (t) => t === v)) {
7867
7880
  return;
7868
7881
  }
7869
7882
  if (Array.isArray(result)) {
@@ -8030,7 +8043,7 @@ var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
8030
8043
  "use strict";
8031
8044
  (0, import_chunk_MBTLUWXR.init_ast)();
8032
8045
  init_data_flow();
8033
- (0, import_chunk_67LU4GPQ.init_util)();
8046
+ (0, import_chunk_OASVKTK5.init_util)();
8034
8047
  init_could_be();
8035
8048
  init_intersection_type();
8036
8049
  init_sub_type();
@@ -8045,7 +8058,7 @@ function expandTypedef(t) {
8045
8058
  );
8046
8059
  const tExpanded = cloneType(t);
8047
8060
  clearValuesUnder(tExpanded, 262144, true);
8048
- (0, import_chunk_67LU4GPQ.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
8061
+ (0, import_chunk_OASVKTK5.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
8049
8062
  return tExpanded;
8050
8063
  }
8051
8064
  function intersectEnum(t, e) {
@@ -8239,9 +8252,9 @@ function intersectionValue(pair) {
8239
8252
  case 4096:
8240
8253
  case 8192: {
8241
8254
  const common = [];
8242
- (0, import_chunk_67LU4GPQ.forEach)(
8255
+ (0, import_chunk_OASVKTK5.forEach)(
8243
8256
  pair.avalue,
8244
- (sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
8257
+ (sna) => (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
8245
8258
  );
8246
8259
  if (!common.length)
8247
8260
  return null;
@@ -8249,9 +8262,9 @@ function intersectionValue(pair) {
8249
8262
  }
8250
8263
  case 16384: {
8251
8264
  const common = [];
8252
- (0, import_chunk_67LU4GPQ.forEach)(pair.avalue, (sna) => {
8265
+ (0, import_chunk_OASVKTK5.forEach)(pair.avalue, (sna) => {
8253
8266
  const superA = getSuperClasses(sna);
8254
- (0, import_chunk_67LU4GPQ.forEach)(pair.bvalue, (snb) => {
8267
+ (0, import_chunk_OASVKTK5.forEach)(pair.bvalue, (snb) => {
8255
8268
  if (sna === snb || superA && superA.has(snb)) {
8256
8269
  common.push(sna);
8257
8270
  }
@@ -8497,7 +8510,7 @@ function restrictExactTypesByEquality(a, b) {
8497
8510
  }
8498
8511
  case 262144:
8499
8512
  return restrictByEquality(
8500
- (0, import_chunk_67LU4GPQ.reduce)(
8513
+ (0, import_chunk_OASVKTK5.reduce)(
8501
8514
  a.value,
8502
8515
  (cur, decl) => {
8503
8516
  unionInto(cur, decl.resolvedType);
@@ -8564,7 +8577,7 @@ var init_intersection_type = (0, import_chunk_ABYVSU2C.__esm)({
8564
8577
  "use strict";
8565
8578
  init_api();
8566
8579
  init_data_flow();
8567
- (0, import_chunk_67LU4GPQ.init_util)();
8580
+ (0, import_chunk_OASVKTK5.init_util)();
8568
8581
  init_could_be();
8569
8582
  init_interp();
8570
8583
  init_types();
@@ -8678,14 +8691,14 @@ function subtypeOfValue(pair) {
8678
8691
  case 8192: {
8679
8692
  const asd = pair.avalue;
8680
8693
  const bsd = pair.bvalue;
8681
- return (0, import_chunk_67LU4GPQ.some)(asd, (sna) => (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => sna === snb));
8694
+ return (0, import_chunk_OASVKTK5.some)(asd, (sna) => (0, import_chunk_OASVKTK5.some)(bsd, (snb) => sna === snb));
8682
8695
  }
8683
8696
  case 16384: {
8684
8697
  const asd = pair.avalue;
8685
8698
  const bsd = pair.bvalue;
8686
- return (0, import_chunk_67LU4GPQ.every)(asd, (sna) => {
8699
+ return (0, import_chunk_OASVKTK5.every)(asd, (sna) => {
8687
8700
  const superA = getSuperClasses(sna);
8688
- return (0, import_chunk_67LU4GPQ.some)(bsd, (snb) => {
8701
+ return (0, import_chunk_OASVKTK5.some)(bsd, (snb) => {
8689
8702
  if (sna === snb || superA && superA.has(snb)) {
8690
8703
  return true;
8691
8704
  }
@@ -8721,7 +8734,7 @@ var init_sub_type = (0, import_chunk_ABYVSU2C.__esm)({
8721
8734
  "use strict";
8722
8735
  init_api();
8723
8736
  init_data_flow();
8724
- (0, import_chunk_67LU4GPQ.init_util)();
8737
+ (0, import_chunk_OASVKTK5.init_util)();
8725
8738
  init_could_be();
8726
8739
  init_intersection_type();
8727
8740
  init_types();
@@ -9142,13 +9155,13 @@ function isTypeStateKey(decl) {
9142
9155
  return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
9143
9156
  }
9144
9157
  function declIsLocal(decl) {
9145
- return (0, import_chunk_67LU4GPQ.some)(
9158
+ return (0, import_chunk_OASVKTK5.some)(
9146
9159
  decl,
9147
9160
  (d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
9148
9161
  );
9149
9162
  }
9150
9163
  function declIsNonLocal(decl) {
9151
- return (0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
9164
+ return (0, import_chunk_OASVKTK5.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
9152
9165
  }
9153
9166
  function localDeclName(decl) {
9154
9167
  if (Array.isArray(decl))
@@ -9161,12 +9174,12 @@ function localDeclName(decl) {
9161
9174
  case "VariableDeclarator":
9162
9175
  return variableDeclarationName(decl.node.id);
9163
9176
  }
9164
- throw new import_chunk_67LU4GPQ.AwaitedError(
9177
+ throw new import_chunk_OASVKTK5.AwaitedError(
9165
9178
  declFullName(decl).then((declStr) => `Invalid local decl: ${declStr}`)
9166
9179
  );
9167
9180
  }
9168
9181
  function tsKey(key) {
9169
- return `${(0, import_chunk_67LU4GPQ.map)(key, (k) => {
9182
+ return `${(0, import_chunk_OASVKTK5.map)(key, (k) => {
9170
9183
  if (k.type === "Literal") {
9171
9184
  return k.raw;
9172
9185
  } else if (isStateNode(k)) {
@@ -9185,7 +9198,7 @@ function sourceLocation(loc) {
9185
9198
  return loc ? `${loc.source || "??"}:${loc.start.line}:${loc.start.column}` : "??";
9186
9199
  }
9187
9200
  function printBlockHeader(block) {
9188
- (0, import_chunk_67LU4GPQ.log)(
9201
+ (0, import_chunk_OASVKTK5.log)(
9189
9202
  block.order,
9190
9203
  `(${block.node?.loc?.source || "??"}:${block.node?.loc?.start.line || "??"})`,
9191
9204
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
@@ -9199,10 +9212,10 @@ function describeEvent(event) {
9199
9212
  ).then((desc) => `${event.type}: ${desc}`);
9200
9213
  }
9201
9214
  function printBlockEvents(block, extra) {
9202
- (0, import_chunk_67LU4GPQ.log)("Events:");
9203
- (0, import_chunk_67LU4GPQ.forEach)(
9215
+ (0, import_chunk_OASVKTK5.log)("Events:");
9216
+ (0, import_chunk_OASVKTK5.forEach)(
9204
9217
  block.events,
9205
- (event) => (0, import_chunk_67LU4GPQ.log)(
9218
+ (event) => (0, import_chunk_OASVKTK5.log)(
9206
9219
  describeEvent(event).then(
9207
9220
  (eventStr) => ` ${eventStr} ${extra ? extra(event) : ""}`
9208
9221
  )
@@ -9210,7 +9223,7 @@ function printBlockEvents(block, extra) {
9210
9223
  );
9211
9224
  }
9212
9225
  function printBlockTrailer(block) {
9213
- (0, import_chunk_67LU4GPQ.log)(
9226
+ (0, import_chunk_OASVKTK5.log)(
9214
9227
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
9215
9228
  );
9216
9229
  }
@@ -9295,8 +9308,8 @@ function findObjectDeclsByProperty(state, object, next) {
9295
9308
  const decls = getStateNodeDeclsFromType(state, object);
9296
9309
  if (!decls)
9297
9310
  return [null, null];
9298
- const possibleDecls = (0, import_chunk_MBTLUWXR.hasProperty)(state.allDeclarations, next.property.name) && state.allDeclarations[next.property.name];
9299
- return filterDecls(decls, possibleDecls, next.property.name);
9311
+ const possibleDecls = (0, import_chunk_MBTLUWXR.hasProperty)(state.allDeclarations, next.name) && state.allDeclarations[next.name];
9312
+ return filterDecls(decls, possibleDecls, next.name);
9300
9313
  }
9301
9314
  function refineObjectTypeByDecls(istate, object, trueDecls) {
9302
9315
  const refinedType = typeFromTypeStateNodes(istate.state, trueDecls);
@@ -9326,7 +9339,7 @@ function resolveDottedMember(istate, object, next) {
9326
9339
  const [objDecls, trueDecls] = findObjectDeclsByProperty(
9327
9340
  istate.state,
9328
9341
  object,
9329
- next
9342
+ next.property
9330
9343
  );
9331
9344
  if (!objDecls)
9332
9345
  return null;
@@ -9342,7 +9355,7 @@ var init_type_flow_util = (0, import_chunk_ABYVSU2C.__esm)({
9342
9355
  "use strict";
9343
9356
  init_api();
9344
9357
  init_data_flow();
9345
- (0, import_chunk_67LU4GPQ.init_util)();
9358
+ (0, import_chunk_OASVKTK5.init_util)();
9346
9359
  init_intersection_type();
9347
9360
  init_sub_type();
9348
9361
  init_types();
@@ -9396,7 +9409,7 @@ function calleeObjectType(istate, callee) {
9396
9409
  }
9397
9410
  function checkCallArgs(istate, node, callees, args) {
9398
9411
  const allDiags = [];
9399
- const resultType = (0, import_chunk_67LU4GPQ.reduce)(
9412
+ const resultType = (0, import_chunk_OASVKTK5.reduce)(
9400
9413
  callees,
9401
9414
  (result, cur) => {
9402
9415
  const curDiags = [];
@@ -9555,7 +9568,7 @@ function isOverride(cur, funcs) {
9555
9568
  const cls = cur.stack?.[cur.stack.length - 1]?.sn;
9556
9569
  if (cls?.type === "ClassDeclaration" && cls.superClasses) {
9557
9570
  const supers = getSuperClasses(cls);
9558
- if (supers && (0, import_chunk_67LU4GPQ.some)(funcs, (func) => {
9571
+ if (supers && (0, import_chunk_OASVKTK5.some)(funcs, (func) => {
9559
9572
  if (func === cur)
9560
9573
  return false;
9561
9574
  const fcls = func.stack?.[func.stack.length - 1].sn;
@@ -9841,7 +9854,11 @@ function getSystemCallTable(state) {
9841
9854
  property: symbol,
9842
9855
  computed: false
9843
9856
  };
9844
- const [, trueDecls] = findObjectDeclsByProperty(state2, calleeObj, next);
9857
+ const [, trueDecls] = findObjectDeclsByProperty(
9858
+ state2,
9859
+ calleeObj,
9860
+ next.property
9861
+ );
9845
9862
  if (!trueDecls)
9846
9863
  return ret;
9847
9864
  const callees = trueDecls.flatMap((decl) => decl.decls?.[symbol.name]).filter(
@@ -10049,7 +10066,7 @@ var init_interp_call = (0, import_chunk_ABYVSU2C.__esm)({
10049
10066
  "use strict";
10050
10067
  init_optimizer_types();
10051
10068
  init_api();
10052
- (0, import_chunk_67LU4GPQ.init_util)();
10069
+ (0, import_chunk_OASVKTK5.init_util)();
10053
10070
  init_interp();
10054
10071
  init_sub_type();
10055
10072
  init_types();
@@ -10410,7 +10427,7 @@ function getLhsConstraint(istate, node) {
10410
10427
  const [, trueDecls2] = findObjectDeclsByProperty(
10411
10428
  istate.state,
10412
10429
  object,
10413
- node
10430
+ node.property
10414
10431
  );
10415
10432
  if (trueDecls2) {
10416
10433
  lookupDefs = lookupNext(
@@ -11174,7 +11191,7 @@ function mustBeIdentical(a, b) {
11174
11191
  return false;
11175
11192
  }
11176
11193
  function isByteArrayData(objectData) {
11177
- return objectData.klass.value && (0, import_chunk_67LU4GPQ.every)(
11194
+ return objectData.klass.value && (0, import_chunk_OASVKTK5.every)(
11178
11195
  objectData.klass.value,
11179
11196
  (klass) => klass.fullName === "$.Toybox.Lang.ByteArray"
11180
11197
  );
@@ -11186,7 +11203,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
11186
11203
  (0, import_chunk_MBTLUWXR.init_ast)();
11187
11204
  init_data_flow();
11188
11205
  init_optimizer_types();
11189
- (0, import_chunk_67LU4GPQ.init_util)();
11206
+ (0, import_chunk_OASVKTK5.init_util)();
11190
11207
  init_could_be();
11191
11208
  init_interp_binary();
11192
11209
  init_interp_call();
@@ -11417,7 +11434,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
11417
11434
  );
11418
11435
  if (value2) {
11419
11436
  const a = [];
11420
- (0, import_chunk_67LU4GPQ.forEach)(value2, (v) => {
11437
+ (0, import_chunk_OASVKTK5.forEach)(value2, (v) => {
11421
11438
  if (v !== sn)
11422
11439
  a.push(v);
11423
11440
  });
@@ -11909,7 +11926,7 @@ function mustBeFalse(arg) {
11909
11926
  return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
11910
11927
  }
11911
11928
  function display(type) {
11912
- const names = (v, fn) => (0, import_chunk_67LU4GPQ.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
11929
+ const names = (v, fn) => (0, import_chunk_OASVKTK5.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
11913
11930
  const parts = [];
11914
11931
  const displayOne = (tv) => {
11915
11932
  switch (tv.type) {
@@ -12110,7 +12127,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
12110
12127
  init_data_flow();
12111
12128
  init_api();
12112
12129
  (0, import_chunk_MBTLUWXR.init_ast)();
12113
- (0, import_chunk_67LU4GPQ.init_util)();
12130
+ (0, import_chunk_OASVKTK5.init_util)();
12114
12131
  init_interp();
12115
12132
  init_union_type();
12116
12133
  init_intersection_type();
@@ -12170,7 +12187,7 @@ function couldBeHelper(a, b, shallow) {
12170
12187
  262144
12171
12188
  /* Typedef */
12172
12189
  );
12173
- return typedef && (0, import_chunk_67LU4GPQ.some)(typedef, (td) => {
12190
+ return typedef && (0, import_chunk_OASVKTK5.some)(typedef, (td) => {
12174
12191
  if (!td.resolvedType) {
12175
12192
  throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
12176
12193
  }
@@ -12242,15 +12259,15 @@ function couldBeValue(pair, shallow) {
12242
12259
  }
12243
12260
  case 4096:
12244
12261
  case 8192: {
12245
- return (0, import_chunk_67LU4GPQ.some)(
12262
+ return (0, import_chunk_OASVKTK5.some)(
12246
12263
  pair.avalue,
12247
- (sna) => (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => sna === snb)
12264
+ (sna) => (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => sna === snb)
12248
12265
  );
12249
12266
  }
12250
12267
  case 16384: {
12251
- return (0, import_chunk_67LU4GPQ.some)(pair.avalue, (sna) => {
12268
+ return (0, import_chunk_OASVKTK5.some)(pair.avalue, (sna) => {
12252
12269
  const superA = getSuperClasses(sna);
12253
- return (0, import_chunk_67LU4GPQ.some)(pair.bvalue, (snb) => {
12270
+ return (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => {
12254
12271
  if (sna === snb || superA && superA.has(snb)) {
12255
12272
  return true;
12256
12273
  }
@@ -12283,7 +12300,7 @@ var init_could_be = (0, import_chunk_ABYVSU2C.__esm)({
12283
12300
  "use strict";
12284
12301
  init_api();
12285
12302
  init_data_flow();
12286
- (0, import_chunk_67LU4GPQ.init_util)();
12303
+ (0, import_chunk_OASVKTK5.init_util)();
12287
12304
  init_types();
12288
12305
  }
12289
12306
  });
@@ -12390,7 +12407,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12390
12407
  }
12391
12408
  addAnt(curState.partiallyAnticipated, key, node);
12392
12409
  if (logThisRun) {
12393
- (0, import_chunk_67LU4GPQ.log)(
12410
+ (0, import_chunk_OASVKTK5.log)(
12394
12411
  ` antrefs: ${curState.partiallyAnticipated.get(key) !== false} ${curState.anticipated.get(key) !== false}`
12395
12412
  );
12396
12413
  }
@@ -12413,7 +12430,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12413
12430
  const curState = cloneState(blockStates[top.order]);
12414
12431
  if (logThisRun) {
12415
12432
  printBlockHeader(top);
12416
- curState.dead.forEach((decl) => (0, import_chunk_67LU4GPQ.log)(` - anticipated: ${tsKey(decl)}`));
12433
+ curState.dead.forEach((decl) => (0, import_chunk_OASVKTK5.log)(` - anticipated: ${tsKey(decl)}`));
12417
12434
  }
12418
12435
  if (top.events) {
12419
12436
  for (let i = top.events.length; i--; ) {
@@ -12425,12 +12442,12 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12425
12442
  case "ref":
12426
12443
  if (isTypeStateKey(event.decl)) {
12427
12444
  if (logThisRun) {
12428
- (0, import_chunk_67LU4GPQ.log)(
12445
+ (0, import_chunk_OASVKTK5.log)(
12429
12446
  describeEvent(event).then(
12430
12447
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12431
12448
  )
12432
12449
  );
12433
- (0, import_chunk_67LU4GPQ.log)(` kill => ${tsKey(event.decl)}`);
12450
+ (0, import_chunk_OASVKTK5.log)(` kill => ${tsKey(event.decl)}`);
12434
12451
  }
12435
12452
  copyPropRef(curState, event.decl, event.node);
12436
12453
  curState.dead.delete(event.decl);
@@ -12439,7 +12456,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12439
12456
  case "def":
12440
12457
  if (isTypeStateKey(event.decl) && (event.node.type !== "VariableDeclarator" || event.node.init)) {
12441
12458
  if (logThisRun) {
12442
- (0, import_chunk_67LU4GPQ.log)(
12459
+ (0, import_chunk_OASVKTK5.log)(
12443
12460
  describeEvent(event).then(
12444
12461
  (eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
12445
12462
  )
@@ -12455,7 +12472,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12455
12472
  const pant = curState.partiallyAnticipated.get(event.decl);
12456
12473
  if (pant) {
12457
12474
  if (logThisRun) {
12458
- (0, import_chunk_67LU4GPQ.log)(
12475
+ (0, import_chunk_OASVKTK5.log)(
12459
12476
  ` is copy-prop-candidate ${curState.anticipated?.get(event.decl) === pant}`
12460
12477
  );
12461
12478
  }
@@ -12487,7 +12504,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12487
12504
  if (assignNode) {
12488
12505
  curState.dead.add(event.decl);
12489
12506
  if (logThisRun) {
12490
- (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12507
+ (0, import_chunk_OASVKTK5.log)(` anticipated => ${tsKey(event.decl)}`);
12491
12508
  }
12492
12509
  } else if (event.node.type === "UpdateExpression") {
12493
12510
  copyPropRef(curState, event.decl, event.node.argument);
@@ -12498,7 +12515,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
12498
12515
  if (isTypeStateKey(event.decl)) {
12499
12516
  curState.dead.add(event.decl);
12500
12517
  if (logThisRun) {
12501
- (0, import_chunk_67LU4GPQ.log)(` anticipated => ${tsKey(event.decl)}`);
12518
+ (0, import_chunk_OASVKTK5.log)(` anticipated => ${tsKey(event.decl)}`);
12502
12519
  }
12503
12520
  }
12504
12521
  break;
@@ -12561,9 +12578,9 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
12561
12578
  if (!deadStores.size)
12562
12579
  return { changes: false, copyPropStores };
12563
12580
  if (logThisRun) {
12564
- (0, import_chunk_67LU4GPQ.log)("====== Dead Stores =====");
12581
+ (0, import_chunk_OASVKTK5.log)("====== Dead Stores =====");
12565
12582
  deadStores.forEach(
12566
- (dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_67LU4GPQ.log)(
12583
+ (dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_OASVKTK5.log)(
12567
12584
  formatAst(dead).then(
12568
12585
  (deadStr) => `${deadStr} (${sourceLocation(dead.loc)})`
12569
12586
  )
@@ -12618,7 +12635,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
12618
12635
  init_control_flow();
12619
12636
  init_data_flow();
12620
12637
  init_inliner();
12621
- (0, import_chunk_67LU4GPQ.init_util)();
12638
+ (0, import_chunk_OASVKTK5.init_util)();
12622
12639
  init_minimize_locals();
12623
12640
  init_type_flow_util();
12624
12641
  }
@@ -12983,13 +13000,13 @@ function typeStateEntry(value2, key) {
12983
13000
  return `${tsKey(key)} = ${display(value2.curType)}`;
12984
13001
  }
12985
13002
  function printBlockState(block, state, indent = "") {
12986
- (0, import_chunk_67LU4GPQ.log)(indent + "State:");
13003
+ (0, import_chunk_OASVKTK5.log)(indent + "State:");
12987
13004
  if (!state) {
12988
- (0, import_chunk_67LU4GPQ.log)(indent + "Not visited!");
13005
+ (0, import_chunk_OASVKTK5.log)(indent + "Not visited!");
12989
13006
  return;
12990
13007
  }
12991
13008
  state.map.forEach((value2, key) => {
12992
- (0, import_chunk_67LU4GPQ.log)(
13009
+ (0, import_chunk_OASVKTK5.log)(
12993
13010
  `${indent} - ${typeStateEntry(value2, key)}${value2.equivSet ? ` [(${Array.from(value2.equivSet).map(tsKey).join(", ")})]` : ""}`
12994
13011
  );
12995
13012
  });
@@ -13139,7 +13156,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13139
13156
  const [objDecls, trueDecls] = findObjectDeclsByProperty(
13140
13157
  istate.state,
13141
13158
  cur,
13142
- me
13159
+ me.property
13143
13160
  );
13144
13161
  if (!objDecls) {
13145
13162
  return null;
@@ -13196,7 +13213,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13196
13213
  type: 0
13197
13214
  /* Never */
13198
13215
  };
13199
- (0, import_chunk_67LU4GPQ.forEach)(avalue, (v) => unionInto(n, v));
13216
+ (0, import_chunk_OASVKTK5.forEach)(avalue, (v) => unionInto(n, v));
13200
13217
  next = n;
13201
13218
  }
13202
13219
  } else {
@@ -13301,7 +13318,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13301
13318
  }
13302
13319
  if (!isStatic && selfClassDecl) {
13303
13320
  const baseObj = getObjectValue(baseElem.type);
13304
- if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_67LU4GPQ.some)(
13321
+ if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_OASVKTK5.some)(
13305
13322
  baseObj.klass.value,
13306
13323
  (cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
13307
13324
  )) {
@@ -13346,7 +13363,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13346
13363
  return [cur, updateAny];
13347
13364
  }
13348
13365
  function typeConstraint(decls, blockState) {
13349
- return (0, import_chunk_67LU4GPQ.reduce)(
13366
+ return (0, import_chunk_OASVKTK5.reduce)(
13350
13367
  decls,
13351
13368
  (cur, decl) => {
13352
13369
  if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
@@ -13442,9 +13459,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13442
13459
  stack: [],
13443
13460
  func
13444
13461
  };
13445
- const modifiableDecl = (decls, callees) => (0, import_chunk_67LU4GPQ.some)(
13462
+ const modifiableDecl = (decls, callees) => (0, import_chunk_OASVKTK5.some)(
13446
13463
  decls,
13447
- (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_67LU4GPQ.some)(callees, (callee) => functionMayModify(state, callee, decl)))
13464
+ (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_OASVKTK5.some)(callees, (callee) => functionMayModify(state, callee, decl)))
13448
13465
  );
13449
13466
  const mergeSuccState = (top, curState) => {
13450
13467
  top.succs?.forEach((succ) => {
@@ -13453,7 +13470,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13453
13470
  }
13454
13471
  if (mergeTypeState(blockStates, succ.order, curState, nodeCopyProp)) {
13455
13472
  if (logThisRun) {
13456
- (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${succ.order}`);
13473
+ (0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${succ.order}`);
13457
13474
  }
13458
13475
  queue.enqueue(succ);
13459
13476
  }
@@ -13463,7 +13480,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13463
13480
  const calleeObj = getStateType(curState, calleeObjDecl);
13464
13481
  let calleeResult = null;
13465
13482
  let effectFree = true;
13466
- (0, import_chunk_67LU4GPQ.forEach)(callees, (callee) => {
13483
+ (0, import_chunk_OASVKTK5.forEach)(callees, (callee) => {
13467
13484
  const info = sysCallInfo(istate.state, callee);
13468
13485
  if (!info) {
13469
13486
  effectFree = false;
@@ -13740,7 +13757,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13740
13757
  });
13741
13758
  } else {
13742
13759
  if (logThisRun) {
13743
- (0, import_chunk_67LU4GPQ.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
13760
+ (0, import_chunk_OASVKTK5.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
13744
13761
  printBlockState(top, sTrue || curState, " >true ");
13745
13762
  }
13746
13763
  if (mergeTypeState(
@@ -13750,7 +13767,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13750
13767
  nodeCopyProp
13751
13768
  )) {
13752
13769
  if (logThisRun) {
13753
- (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13770
+ (0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
13754
13771
  }
13755
13772
  queue.enqueue(trueSucc);
13756
13773
  }
@@ -13762,7 +13779,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13762
13779
  });
13763
13780
  } else {
13764
13781
  if (logThisRun) {
13765
- (0, import_chunk_67LU4GPQ.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
13782
+ (0, import_chunk_OASVKTK5.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
13766
13783
  printBlockState(top, sFalse || curState, " >false ");
13767
13784
  }
13768
13785
  if (mergeTypeState(
@@ -13772,7 +13789,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13772
13789
  nodeCopyProp
13773
13790
  )) {
13774
13791
  if (logThisRun) {
13775
- (0, import_chunk_67LU4GPQ.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13792
+ (0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
13776
13793
  }
13777
13794
  queue.enqueue(falseSucc);
13778
13795
  }
@@ -13847,7 +13864,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13847
13864
  }
13848
13865
  }
13849
13866
  if (logThisRun) {
13850
- (0, import_chunk_67LU4GPQ.log)(
13867
+ (0, import_chunk_OASVKTK5.log)(
13851
13868
  describeEvent(event).then(
13852
13869
  (eventStr) => ` ${eventStr} == ${display(curEntry.curType)}`
13853
13870
  )
@@ -13857,7 +13874,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13857
13874
  }
13858
13875
  case "mod": {
13859
13876
  if (logThisRun) {
13860
- (0, import_chunk_67LU4GPQ.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13877
+ (0, import_chunk_OASVKTK5.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
13861
13878
  }
13862
13879
  modInterference(curState, event, true, (callees, calleeObj) => {
13863
13880
  clearRelatedCopyPropEvents(curState, null, nodeCopyProp);
@@ -13873,7 +13890,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13873
13890
  );
13874
13891
  }
13875
13892
  }
13876
- if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_67LU4GPQ.some)(callees, (callee) => inlineRequested(state, callee))) {
13893
+ if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_OASVKTK5.some)(callees, (callee) => inlineRequested(state, callee))) {
13877
13894
  event.node.arguments.forEach((arg) => {
13878
13895
  const def = nodeCopyProp.get(arg);
13879
13896
  if (def && nodeCopyProp.get(def) !== false) {
@@ -13885,7 +13902,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13885
13902
  let calleeEffects;
13886
13903
  curState.map.forEach((tsv, decl) => {
13887
13904
  let type = tsv.curType;
13888
- if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_67LU4GPQ.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
13905
+ if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_OASVKTK5.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
13889
13906
  return;
13890
13907
  }
13891
13908
  if (modifiableDecl(decl, callees)) {
@@ -13900,7 +13917,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13900
13917
  curState.map.set(decl, {
13901
13918
  curType: typeConstraint(decl, curState)
13902
13919
  });
13903
- } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_67LU4GPQ.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
13920
+ } else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_OASVKTK5.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
13904
13921
  if (type.value != null && type.type & 32768) {
13905
13922
  const odata = getObjectValue(tsv.curType);
13906
13923
  if (odata?.obj) {
@@ -13968,7 +13985,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13968
13985
  2
13969
13986
  /* Reassign */
13970
13987
  );
13971
- (0, import_chunk_67LU4GPQ.some)(event.decl, (decl) => {
13988
+ (0, import_chunk_OASVKTK5.some)(event.decl, (decl) => {
13972
13989
  if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
13973
13990
  return false;
13974
13991
  }
@@ -13976,7 +13993,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13976
13993
  if (affected) {
13977
13994
  const objType = typeFromTypeStateNodes(
13978
13995
  istate.state,
13979
- (0, import_chunk_67LU4GPQ.map)(
13996
+ (0, import_chunk_OASVKTK5.map)(
13980
13997
  event.decl,
13981
13998
  (decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
13982
13999
  ).filter(
@@ -13997,7 +14014,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
13997
14014
  });
13998
14015
  if (wasComputedDecl) {
13999
14016
  curState.map.forEach((value2, decls) => {
14000
- if ((0, import_chunk_67LU4GPQ.some)(
14017
+ if ((0, import_chunk_OASVKTK5.some)(
14001
14018
  decls,
14002
14019
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
14003
14020
  )) {
@@ -14043,14 +14060,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14043
14060
  }
14044
14061
  if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
14045
14062
  // in case it has side effects.
14046
- (0, import_chunk_67LU4GPQ.some)(
14063
+ (0, import_chunk_OASVKTK5.some)(
14047
14064
  event2.calleeDecl,
14048
14065
  (callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
14049
14066
  )) {
14050
14067
  return false;
14051
14068
  }
14052
14069
  }
14053
- if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_67LU4GPQ.some)(
14070
+ if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_OASVKTK5.some)(
14054
14071
  event2.decl,
14055
14072
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
14056
14073
  )) {
@@ -14089,13 +14106,13 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14089
14106
  }
14090
14107
  }
14091
14108
  if (uninitClassDecls?.size) {
14092
- (0, import_chunk_67LU4GPQ.forEach)(
14109
+ (0, import_chunk_OASVKTK5.forEach)(
14093
14110
  event.decl,
14094
14111
  (decl) => uninitClassDecls.has(decl) && curState.inited?.add(decl)
14095
14112
  );
14096
14113
  }
14097
14114
  if (logThisRun) {
14098
- (0, import_chunk_67LU4GPQ.log)(
14115
+ (0, import_chunk_OASVKTK5.log)(
14099
14116
  describeEvent(event).then(
14100
14117
  (eventStr) => ` ${eventStr} := ${display(type)}`
14101
14118
  )
@@ -14113,7 +14130,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14113
14130
  );
14114
14131
  }
14115
14132
  if (logThisRun) {
14116
- (0, import_chunk_67LU4GPQ.log)(
14133
+ (0, import_chunk_OASVKTK5.log)(
14117
14134
  describeEvent(event).then(
14118
14135
  (eventStr) => ` ${eventStr} : ${!Array.isArray(event.left) && event.left.type === "MemberDecl" ? `${display(
14119
14136
  curState.map.get(event.left.base)?.curType || {
@@ -14171,8 +14188,8 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14171
14188
  }
14172
14189
  if (!successorsHandled) {
14173
14190
  if (logThisRun) {
14174
- (0, import_chunk_67LU4GPQ.log)(
14175
- ` merge to: ${(0, import_chunk_67LU4GPQ.map)(
14191
+ (0, import_chunk_OASVKTK5.log)(
14192
+ ` merge to: ${(0, import_chunk_OASVKTK5.map)(
14176
14193
  top.succs,
14177
14194
  (succ) => succ.order || -1
14178
14195
  ).join(", ")}`
@@ -14203,17 +14220,17 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14203
14220
  );
14204
14221
  printBlockTrailer(block);
14205
14222
  });
14206
- (0, import_chunk_67LU4GPQ.log)("====== TypeMap =====");
14223
+ (0, import_chunk_OASVKTK5.log)("====== TypeMap =====");
14207
14224
  typeMap.forEach((value2, key) => {
14208
- (0, import_chunk_67LU4GPQ.log)(
14225
+ (0, import_chunk_OASVKTK5.log)(
14209
14226
  formatAst(key).then(
14210
14227
  (keyStr) => `${keyStr} = ${display(value2)} ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
14211
14228
  )
14212
14229
  );
14213
14230
  });
14214
- (0, import_chunk_67LU4GPQ.log)("====== EquivMap =====");
14231
+ (0, import_chunk_OASVKTK5.log)("====== EquivMap =====");
14215
14232
  nodeEquivs.forEach((value2, key) => {
14216
- (0, import_chunk_67LU4GPQ.log)(
14233
+ (0, import_chunk_OASVKTK5.log)(
14217
14234
  formatAst(key).then(
14218
14235
  (keyStr) => `${keyStr} = [${value2.equiv.map(
14219
14236
  (equiv) => tsKey(equiv)
@@ -14221,7 +14238,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14221
14238
  )
14222
14239
  );
14223
14240
  });
14224
- (0, import_chunk_67LU4GPQ.log)("====== Copy Prop =====");
14241
+ (0, import_chunk_OASVKTK5.log)("====== Copy Prop =====");
14225
14242
  nodeCopyProp.forEach((value2, key) => {
14226
14243
  (0, import_node_assert3.default)(value2 !== false);
14227
14244
  if (key.type === "VariableDeclarator" || key.type === "AssignmentExpression") {
@@ -14231,7 +14248,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14231
14248
  value2.type === "VariableDeclarator" && value2.init || value2.type === "AssignmentExpression"
14232
14249
  );
14233
14250
  const node = value2.type === "VariableDeclarator" ? value2.init : value2.right;
14234
- (0, import_chunk_67LU4GPQ.log)(
14251
+ (0, import_chunk_OASVKTK5.log)(
14235
14252
  formatAst(key).then(
14236
14253
  (keyStr) => formatAstLongLines(node).then(
14237
14254
  (nodeStr) => `${keyStr} = [${nodeStr}] ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
@@ -14241,10 +14258,10 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14241
14258
  });
14242
14259
  }
14243
14260
  if (logThisRun) {
14244
- (0, import_chunk_67LU4GPQ.log)(formatAstLongLines(func.node));
14261
+ (0, import_chunk_OASVKTK5.log)(formatAstLongLines(func.node));
14245
14262
  if (copyPropStores) {
14246
14263
  copyPropStores.forEach(({ ref, ant }, node) => {
14247
- (0, import_chunk_67LU4GPQ.log)(
14264
+ (0, import_chunk_OASVKTK5.log)(
14248
14265
  formatAstLongLines(node).then(
14249
14266
  (nodeStr) => `copy-prop-store: ${nodeStr}${ant ? "!" : ""} => ${nodeCopyProp.get(node) !== ref ? "Failed" : "Success"}`
14250
14267
  )
@@ -14258,9 +14275,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14258
14275
  }
14259
14276
  if (logThisRun) {
14260
14277
  if (selfAssignments.size) {
14261
- (0, import_chunk_67LU4GPQ.log)("====== Self Assignments =====");
14278
+ (0, import_chunk_OASVKTK5.log)("====== Self Assignments =====");
14262
14279
  selfAssignments.forEach(
14263
- (self) => (0, import_chunk_67LU4GPQ.log)(
14280
+ (self) => (0, import_chunk_OASVKTK5.log)(
14264
14281
  formatAst(self).then(
14265
14282
  (selfStr) => `${selfStr} (${sourceLocation(self.loc)})`
14266
14283
  )
@@ -14325,7 +14342,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14325
14342
  if (copyNode) {
14326
14343
  if (node.type === "AssignmentExpression") {
14327
14344
  if (logThisRun) {
14328
- (0, import_chunk_67LU4GPQ.log)(
14345
+ (0, import_chunk_OASVKTK5.log)(
14329
14346
  formatAstLongLines(node).then(
14330
14347
  (nodeStr) => `Killing copy-prop assignment ${nodeStr}`
14331
14348
  )
@@ -14340,7 +14357,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14340
14357
  if (node.type === "VariableDeclarator") {
14341
14358
  (0, import_node_assert3.default)(node.init);
14342
14359
  if (logThisRun) {
14343
- (0, import_chunk_67LU4GPQ.log)(
14360
+ (0, import_chunk_OASVKTK5.log)(
14344
14361
  formatAstLongLines(node).then(
14345
14362
  (nodeStr) => `Killing copy-prop variable initialization ${nodeStr}`
14346
14363
  )
@@ -14361,7 +14378,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14361
14378
  right: copyNode.right
14362
14379
  };
14363
14380
  if (logThisRun) {
14364
- (0, import_chunk_67LU4GPQ.log)(
14381
+ (0, import_chunk_OASVKTK5.log)(
14365
14382
  formatAstLongLines(node).then(
14366
14383
  (nodeStr) => formatAstLongLines(replacement2).then(
14367
14384
  (repStr) => `copy-prop ${nodeStr} => ${repStr}`
@@ -14374,7 +14391,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14374
14391
  const init = copyNode.init;
14375
14392
  (0, import_node_assert3.default)(init);
14376
14393
  if (logThisRun) {
14377
- (0, import_chunk_67LU4GPQ.log)(
14394
+ (0, import_chunk_OASVKTK5.log)(
14378
14395
  formatAstLongLines(node).then(
14379
14396
  (nodeStr) => formatAstLongLines(init).then(
14380
14397
  (initStr) => `copy-prop ${nodeStr} => ${initStr}`
@@ -14388,7 +14405,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14388
14405
  }
14389
14406
  if (selfAssignments.has(node)) {
14390
14407
  if (logThisRun) {
14391
- (0, import_chunk_67LU4GPQ.log)(
14408
+ (0, import_chunk_OASVKTK5.log)(
14392
14409
  formatAst(node).then(
14393
14410
  (nodeStr) => `Deleting self assignment: ${nodeStr} (${sourceLocation(
14394
14411
  node.loc
@@ -14432,7 +14449,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14432
14449
  }, curInfo);
14433
14450
  if (rep === curInfo)
14434
14451
  return null;
14435
- const name = (0, import_chunk_67LU4GPQ.reduce)(
14452
+ const name = (0, import_chunk_OASVKTK5.reduce)(
14436
14453
  rep.decl,
14437
14454
  (cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
14438
14455
  null
@@ -14440,7 +14457,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
14440
14457
  if (!name)
14441
14458
  return null;
14442
14459
  if (logThisRun) {
14443
- (0, import_chunk_67LU4GPQ.log)(
14460
+ (0, import_chunk_OASVKTK5.log)(
14444
14461
  formatAst(node).then(
14445
14462
  (nodeStr) => `Replacing ${nodeStr} with ${name} at ${sourceLocation(
14446
14463
  node.loc
@@ -14571,7 +14588,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
14571
14588
  init_type_flow_util();
14572
14589
  init_types();
14573
14590
  init_union_type();
14574
- (0, import_chunk_67LU4GPQ.init_util)();
14591
+ (0, import_chunk_OASVKTK5.init_util)();
14575
14592
  logging = true;
14576
14593
  missingNullWorkaround = true;
14577
14594
  }
@@ -14623,9 +14640,9 @@ function minimizeLocals(state, func) {
14623
14640
  if (!didMerge)
14624
14641
  return;
14625
14642
  if (logThisRun) {
14626
- (0, import_chunk_67LU4GPQ.log)(`>>> Merging locals in ${func.fullName}`);
14643
+ (0, import_chunk_OASVKTK5.log)(`>>> Merging locals in ${func.fullName}`);
14627
14644
  merge.forEach(
14628
- (merged) => merged.length > 1 && (0, import_chunk_67LU4GPQ.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
14645
+ (merged) => merged.length > 1 && (0, import_chunk_OASVKTK5.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
14629
14646
  );
14630
14647
  }
14631
14648
  const remap = /* @__PURE__ */ new Map();
@@ -14895,7 +14912,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
14895
14912
  (0, import_chunk_MBTLUWXR.init_ast)();
14896
14913
  init_control_flow();
14897
14914
  init_type_flow();
14898
- (0, import_chunk_67LU4GPQ.init_util)();
14915
+ (0, import_chunk_OASVKTK5.init_util)();
14899
14916
  init_variable_renamer();
14900
14917
  init_type_flow_util();
14901
14918
  }
@@ -14906,12 +14923,12 @@ function logAntState(s, decl) {
14906
14923
  defs2++;
14907
14924
  return defs2;
14908
14925
  }, 0);
14909
- (0, import_chunk_67LU4GPQ.log)(
14926
+ (0, import_chunk_OASVKTK5.log)(
14910
14927
  declFullName(decl).then(
14911
14928
  (declStr) => ` - ${declStr}: ${candidateCost(s)} bytes, ${s.ant.size - defs} refs, ${defs} defs, ${s.live ? "" : "!"}live, ${s.isIsolated ? "" : "!"}isolated`
14912
14929
  )
14913
14930
  );
14914
- (0, import_chunk_67LU4GPQ.log)(
14931
+ (0, import_chunk_OASVKTK5.log)(
14915
14932
  ` - members: ${Array.from(s.members).map(([block, live]) => block.order + (live ? "t" : "f")).join(", ")}`
14916
14933
  );
14917
14934
  }
@@ -14928,7 +14945,7 @@ async function sizeBasedPRE(state, func) {
14928
14945
  const candidates = computeAttributes(state, head);
14929
14946
  if (candidates) {
14930
14947
  if (logging2) {
14931
- (0, import_chunk_67LU4GPQ.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
14948
+ (0, import_chunk_OASVKTK5.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
14932
14949
  logAntDecls(candidates);
14933
14950
  }
14934
14951
  const nodeMap = /* @__PURE__ */ new Map();
@@ -15021,7 +15038,7 @@ function buildPREGraph(state, func) {
15021
15038
  const event = block.events[i];
15022
15039
  switch (event.type) {
15023
15040
  case "ref":
15024
- if ((0, import_chunk_67LU4GPQ.some)(
15041
+ if ((0, import_chunk_OASVKTK5.some)(
15025
15042
  event.decl,
15026
15043
  (decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
15027
15044
  )) {
@@ -15039,7 +15056,7 @@ function buildPREGraph(state, func) {
15039
15056
  defs.add(event.decl);
15040
15057
  break;
15041
15058
  case "mod":
15042
- if (event.callees && (0, import_chunk_67LU4GPQ.every)(event.callees, (callee) => callee.info === false)) {
15059
+ if (event.callees && (0, import_chunk_OASVKTK5.every)(event.callees, (callee) => callee.info === false)) {
15043
15060
  block.events.splice(i, 1);
15044
15061
  break;
15045
15062
  }
@@ -15198,21 +15215,21 @@ function computeAttributes(state, head) {
15198
15215
  });
15199
15216
  if (logging2) {
15200
15217
  order.forEach((block) => {
15201
- (0, import_chunk_67LU4GPQ.log)(
15218
+ (0, import_chunk_OASVKTK5.log)(
15202
15219
  block.order,
15203
15220
  `(${block.node ? block.node.loc?.start.line : "??"})`,
15204
15221
  `Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
15205
15222
  );
15206
15223
  if (block.events) {
15207
15224
  block.events.forEach(
15208
- (event) => event.type !== "exn" && (0, import_chunk_67LU4GPQ.log)(
15225
+ (event) => event.type !== "exn" && (0, import_chunk_OASVKTK5.log)(
15209
15226
  Promise.resolve(
15210
15227
  event.decl ? declFullName(event.decl) : event.node ? formatAst(event.node) : "??"
15211
15228
  ).then((eventDetails) => ` ${event.type}: ${eventDetails}`)
15212
15229
  )
15213
15230
  );
15214
15231
  }
15215
- (0, import_chunk_67LU4GPQ.log)(
15232
+ (0, import_chunk_OASVKTK5.log)(
15216
15233
  `Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
15217
15234
  );
15218
15235
  });
@@ -15280,7 +15297,7 @@ function computeAttributes(state, head) {
15280
15297
  }
15281
15298
  case "mod": {
15282
15299
  curState.forEach((candidates, decls) => {
15283
- if ((0, import_chunk_67LU4GPQ.some)(
15300
+ if ((0, import_chunk_OASVKTK5.some)(
15284
15301
  decls,
15285
15302
  (decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
15286
15303
  (callee) => functionMayModify(state, callee, decl)
@@ -15322,7 +15339,7 @@ function computeAttributes(state, head) {
15322
15339
  }
15323
15340
  blockStates[top.order] = curState;
15324
15341
  if (logging2) {
15325
- (0, import_chunk_67LU4GPQ.log)(`Updated block ${top.order}`);
15342
+ (0, import_chunk_OASVKTK5.log)(`Updated block ${top.order}`);
15326
15343
  logAntDecls(curState);
15327
15344
  }
15328
15345
  if (top.preds) {
@@ -15424,7 +15441,7 @@ function applyReplacements(func, nodeMap, declMap) {
15424
15441
  }
15425
15442
  const name = declMap.get(event.decl);
15426
15443
  if (!name) {
15427
- throw new import_chunk_67LU4GPQ.AwaitedError(
15444
+ throw new import_chunk_OASVKTK5.AwaitedError(
15428
15445
  formatAst(node).then(
15429
15446
  (targetStr) => `No replacement found for "${targetStr}"`
15430
15447
  )
@@ -15446,7 +15463,7 @@ function applyReplacements(func, nodeMap, declMap) {
15446
15463
  const target = node.type === "AssignmentExpression" ? node.left : node.argument;
15447
15464
  const name = declMap.get(event.decl);
15448
15465
  if (!name) {
15449
- throw new import_chunk_67LU4GPQ.AwaitedError(
15466
+ throw new import_chunk_OASVKTK5.AwaitedError(
15450
15467
  formatAst(target).then(
15451
15468
  (targetStr) => `No replacement found for "${targetStr}"`
15452
15469
  )
@@ -15509,14 +15526,14 @@ function applyReplacements(func, nodeMap, declMap) {
15509
15526
  const decl = event.decl;
15510
15527
  const name = declMap.get(decl);
15511
15528
  if (!name) {
15512
- throw new import_chunk_67LU4GPQ.AwaitedError(
15529
+ throw new import_chunk_OASVKTK5.AwaitedError(
15513
15530
  declFullName(decl).then(
15514
15531
  (declStr) => `No replacement found for "${declStr}"`
15515
15532
  )
15516
15533
  );
15517
15534
  }
15518
15535
  if (!event.id) {
15519
- throw new import_chunk_67LU4GPQ.AwaitedError(
15536
+ throw new import_chunk_OASVKTK5.AwaitedError(
15520
15537
  declFullName(decl).then(
15521
15538
  (declStr) => `Missing id for mod event for "${declStr}"`
15522
15539
  )
@@ -15581,7 +15598,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
15581
15598
  init_data_flow();
15582
15599
  init_function_info();
15583
15600
  init_minimize_locals();
15584
- (0, import_chunk_67LU4GPQ.init_util)();
15601
+ (0, import_chunk_OASVKTK5.init_util)();
15585
15602
  logging2 = false;
15586
15603
  LocalRefCost = 2;
15587
15604
  }
@@ -15952,7 +15969,7 @@ function beforeEvaluate(istate, node) {
15952
15969
  break;
15953
15970
  }
15954
15971
  const id = node.right.argument;
15955
- if ((0, import_chunk_67LU4GPQ.every)(left.value.value, (m) => {
15972
+ if ((0, import_chunk_OASVKTK5.every)(left.value.value, (m) => {
15956
15973
  if ((0, import_chunk_MBTLUWXR.hasProperty)(m.decls, id.name))
15957
15974
  return false;
15958
15975
  return istate.state.lookup({
@@ -16398,7 +16415,7 @@ var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
16398
16415
  (0, import_chunk_MBTLUWXR.init_ast)();
16399
16416
  init_inliner();
16400
16417
  init_type_flow();
16401
- (0, import_chunk_67LU4GPQ.init_util)();
16418
+ (0, import_chunk_OASVKTK5.init_util)();
16402
16419
  init_interp();
16403
16420
  init_interp_binary();
16404
16421
  init_types();
@@ -16675,7 +16692,7 @@ function getFileSources(fnMap) {
16675
16692
  function getFileASTs(fnMap) {
16676
16693
  return getFileSources(fnMap).then(
16677
16694
  () => Object.entries(fnMap).reduce((ok, [name, value2]) => {
16678
- if (!value2.ast) {
16695
+ if (!value2.ast && !value2.parserError) {
16679
16696
  const options = {
16680
16697
  filepath: name
16681
16698
  };
@@ -16689,7 +16706,6 @@ function getFileASTs(fnMap) {
16689
16706
  options
16690
16707
  );
16691
16708
  } catch (e) {
16692
- ok = false;
16693
16709
  if (e instanceof Error) {
16694
16710
  value2.parserError = e;
16695
16711
  } else {
@@ -16697,11 +16713,11 @@ function getFileASTs(fnMap) {
16697
16713
  }
16698
16714
  }
16699
16715
  }
16700
- return ok;
16716
+ return value2.parserError ? false : ok;
16701
16717
  }, true)
16702
16718
  );
16703
16719
  }
16704
- async function analyze(fnMap, resourcesMap, manifestXML, config) {
16720
+ async function analyze(fnMap, resourcesMap, manifestXML, config, allowParseErrors) {
16705
16721
  let hasTests = false;
16706
16722
  let markApi = true;
16707
16723
  const preState = {
@@ -16767,6 +16783,8 @@ async function analyze(fnMap, resourcesMap, manifestXML, config) {
16767
16783
  Object.entries(fnMap).forEach(([name, value2]) => {
16768
16784
  const { ast, parserError } = value2;
16769
16785
  if (!ast) {
16786
+ if (allowParseErrors)
16787
+ return;
16770
16788
  throw parserError || new Error(`Failed to parse ${name}`);
16771
16789
  }
16772
16790
  hasTests = false;
@@ -16785,7 +16803,7 @@ function reportMissingSymbols(state, config) {
16785
16803
  const diagnosticType = config?.checkInvalidSymbols !== "OFF" ? config?.checkInvalidSymbols || "WARNING" : null;
16786
16804
  const compiler2DiagnosticType = config?.checkCompilerLookupRules !== "OFF" ? config?.checkCompilerLookupRules || "WARNING" : null;
16787
16805
  if (diagnosticType && !config?.compilerOptions?.includes("--Eno-invalid-symbol")) {
16788
- const checkTypes = config?.typeCheckLevel && config.typeCheckLevel !== "Off";
16806
+ const checkTypes = config?.checkTypes?.toLowerCase() !== "off";
16789
16807
  const report = (ast) => {
16790
16808
  visitReferences(state, ast, null, false, (node, results, error) => {
16791
16809
  if (node.type === "BinaryExpression" && node.operator === "has") {
@@ -16935,17 +16953,12 @@ function markFunctionCalled(state, func) {
16935
16953
  state.calledFunctions[func.id.name] = [func];
16936
16954
  return;
16937
16955
  }
16938
- (0, import_chunk_67LU4GPQ.pushUnique)(state.calledFunctions[func.id.name], func);
16956
+ (0, import_chunk_OASVKTK5.pushUnique)(state.calledFunctions[func.id.name], func);
16939
16957
  }
16940
- async function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
16941
- try {
16942
- return optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config);
16943
- } catch (ex) {
16944
- if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
16945
- await ex.resolve();
16946
- }
16947
- throw ex;
16948
- }
16958
+ function optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config) {
16959
+ return optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config).catch(
16960
+ (ex) => Promise.reject(ex instanceof import_chunk_OASVKTK5.AwaitedError ? ex.resolve() : ex)
16961
+ );
16949
16962
  }
16950
16963
  async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
16951
16964
  const state = await analyze(
@@ -17040,7 +17053,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
17040
17053
  };
17041
17054
  const gistate = { state, stack: [] };
17042
17055
  if (state.config?.checkTypes !== "OFF" && state.config?.trustDeclaredTypes && state.config.propagateTypes) {
17043
- gistate.typeChecker = state.config.typeCheckLevel?.toLowerCase() === "strict" ? subtypeOf : couldBeWeak;
17056
+ gistate.typeChecker = state.config.strictTypeCheck?.toLowerCase() === "on" ? subtypeOf : couldBeWeak;
17044
17057
  gistate.checkTypes = state.config?.checkTypes || "WARNING";
17045
17058
  }
17046
17059
  let istate = gistate;
@@ -17469,15 +17482,12 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
17469
17482
  }
17470
17483
  delete state.inlineDiagnostics;
17471
17484
  }
17485
+ const diagnostics = state.diagnostics && await resolveDiagnosticsMap(state.diagnostics);
17472
17486
  if (state.config?.checkBuildPragmas) {
17473
- await Object.entries(fnMap).reduce((promise, [name, f]) => {
17474
- return Promise.all([
17475
- resolveDiagnostics(state.diagnostics?.[name]),
17476
- promise
17477
- ]).then(([diagnostics2]) => pragmaChecker(state, f.ast, diagnostics2));
17478
- }, Promise.resolve());
17479
- }
17480
- const diagnostics = state.diagnostics ? await resolveDiagnosticsMap(state.diagnostics) : state.diagnostics;
17487
+ Object.entries(fnMap).forEach(([name, f]) => {
17488
+ pragmaChecker(state, f.ast, diagnostics?.[name]);
17489
+ });
17490
+ }
17481
17491
  return {
17482
17492
  diagnostics,
17483
17493
  sdkVersion: state.sdkVersion
@@ -17699,6 +17709,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
17699
17709
  "use strict";
17700
17710
  init_api();
17701
17711
  (0, import_chunk_MBTLUWXR.init_ast)();
17712
+ init_data_flow();
17702
17713
  init_function_info();
17703
17714
  init_inliner();
17704
17715
  init_optimizer_types();
@@ -17712,9 +17723,8 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
17712
17723
  init_sub_type();
17713
17724
  init_types();
17714
17725
  init_unused_exprs();
17715
- (0, import_chunk_67LU4GPQ.init_util)();
17726
+ (0, import_chunk_OASVKTK5.init_util)();
17716
17727
  init_variable_renamer();
17717
- init_data_flow();
17718
17728
  }
17719
17729
  });
17720
17730
  var negativeFixups;
@@ -18607,7 +18617,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
18607
18617
  throw `Negative constant ${fixup} was not a Literal`;
18608
18618
  }
18609
18619
  if (typeof init.value !== "number") {
18610
- (0, import_chunk_67LU4GPQ.log)(`Negative fixup ${fixup} was not a number!`);
18620
+ (0, import_chunk_OASVKTK5.log)(`Negative fixup ${fixup} was not a number!`);
18611
18621
  } else if (init.value > 0) {
18612
18622
  init.value = -init.value;
18613
18623
  init.raw = "-" + init.raw;
@@ -18697,11 +18707,11 @@ function sameStateNodeDecl(a, b) {
18697
18707
  function sameLookupDefinition(a, b) {
18698
18708
  return (
18699
18709
  // sameStateNodeDecl(a.parent, b.parent) &&
18700
- (0, import_chunk_67LU4GPQ.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
18710
+ (0, import_chunk_OASVKTK5.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
18701
18711
  );
18702
18712
  }
18703
18713
  function sameLookupResult(a, b) {
18704
- return (0, import_chunk_67LU4GPQ.sameArrays)(a, b, sameLookupDefinition);
18714
+ return (0, import_chunk_OASVKTK5.sameArrays)(a, b, sameLookupDefinition);
18705
18715
  }
18706
18716
  function declKey(decl) {
18707
18717
  return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
@@ -18758,6 +18768,17 @@ function lookupNext(state, results, decls, property) {
18758
18768
  );
18759
18769
  return;
18760
18770
  }
18771
+ if (module2.type === "VariableDeclarator" && module2.resolvedType) {
18772
+ const [, decls2] = findObjectDeclsByProperty(
18773
+ state,
18774
+ module2.resolvedType,
18775
+ property
18776
+ );
18777
+ if (decls2) {
18778
+ addToItems(decls2);
18779
+ return;
18780
+ }
18781
+ }
18761
18782
  const res = checkOne(state, module2, decls, property);
18762
18783
  if (res) {
18763
18784
  items.push({ parent: module2, results: res });
@@ -18952,7 +18973,11 @@ function lookupWithType(state, node, typeMap, nonLocal = false, stack = null) {
18952
18973
  const objectType = typeMap.get(node.object);
18953
18974
  if (!objectType)
18954
18975
  return results;
18955
- const [, decls] = findObjectDeclsByProperty(state, objectType, node);
18976
+ const [, decls] = findObjectDeclsByProperty(
18977
+ state,
18978
+ objectType,
18979
+ node.property
18980
+ );
18956
18981
  if (decls) {
18957
18982
  const next = lookupNext(
18958
18983
  state,
@@ -19239,7 +19264,7 @@ function stateFuncs() {
19239
19264
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
19240
19265
  this.index[name] = [];
19241
19266
  }
19242
- (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
19267
+ (0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
19243
19268
  }
19244
19269
  });
19245
19270
  break;
@@ -19294,7 +19319,7 @@ function stateFuncs() {
19294
19319
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
19295
19320
  values[name] = [];
19296
19321
  }
19297
- if ((0, import_chunk_67LU4GPQ.pushUnique)(values[name], m) && currentEnum) {
19322
+ if ((0, import_chunk_OASVKTK5.pushUnique)(values[name], m) && currentEnum) {
19298
19323
  if (!this.enumMap)
19299
19324
  this.enumMap = /* @__PURE__ */ new Map();
19300
19325
  this.enumMap.set(m, currentEnum);
@@ -19302,7 +19327,7 @@ function stateFuncs() {
19302
19327
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
19303
19328
  this.index[name] = [];
19304
19329
  }
19305
- (0, import_chunk_67LU4GPQ.pushUnique)(this.index[name], parent);
19330
+ (0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
19306
19331
  });
19307
19332
  break;
19308
19333
  }
@@ -19803,7 +19828,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
19803
19828
  init_sdk_util();
19804
19829
  init_type_flow_util();
19805
19830
  init_types();
19806
- (0, import_chunk_67LU4GPQ.init_util)();
19831
+ (0, import_chunk_OASVKTK5.init_util)();
19807
19832
  init_visitor();
19808
19833
  }
19809
19834
  });
@@ -19887,7 +19912,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19887
19912
  return decls;
19888
19913
  }
19889
19914
  if (canon.length !== decls.length || !canon.every((v, i) => v === decls[i])) {
19890
- throw new import_chunk_67LU4GPQ.AwaitedError(
19915
+ throw new import_chunk_OASVKTK5.AwaitedError(
19891
19916
  declFullName(canon).then(
19892
19917
  (canonStr) => `Canonical representation of ${canonStr} did not match`
19893
19918
  )
@@ -19921,7 +19946,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19921
19946
  }
19922
19947
  const decl = lookupDefToDecl(results);
19923
19948
  if (decl && path7.length) {
19924
- if (wantsAllRefs && (0, import_chunk_67LU4GPQ.every)(
19949
+ if (wantsAllRefs && (0, import_chunk_OASVKTK5.every)(
19925
19950
  decl,
19926
19951
  (d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
19927
19952
  )) {
@@ -19973,7 +19998,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
19973
19998
  }
19974
19999
  const v = liveDefs.get(def);
19975
20000
  if (!v || !v.has(node)) {
19976
- throw new import_chunk_67LU4GPQ.AwaitedError(
20001
+ throw new import_chunk_OASVKTK5.AwaitedError(
19977
20002
  Promise.resolve(def ? declFullName(def) : "null").then(
19978
20003
  (defStr) => `No stmt in liveDef for ${defStr}`
19979
20004
  )
@@ -20031,7 +20056,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
20031
20056
  const decls = findDecl(node);
20032
20057
  if (!decls)
20033
20058
  break;
20034
- if (trackInsertionPoints && (0, import_chunk_67LU4GPQ.some)(decls, (decl) => {
20059
+ if (trackInsertionPoints && (0, import_chunk_OASVKTK5.some)(decls, (decl) => {
20035
20060
  if (decl.type === "VariableDeclarator") {
20036
20061
  const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
20037
20062
  if (defStmts) {
@@ -20282,8 +20307,8 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
20282
20307
  init_control_flow();
20283
20308
  init_function_info();
20284
20309
  init_type_flow_util();
20285
- (0, import_chunk_67LU4GPQ.init_util)();
20286
- DataflowQueue = class extends import_chunk_67LU4GPQ.GenericQueue {
20310
+ (0, import_chunk_OASVKTK5.init_util)();
20311
+ DataflowQueue = class extends import_chunk_OASVKTK5.GenericQueue {
20287
20312
  constructor() {
20288
20313
  super((b, a) => (a.order || 0) - (b.order || 0));
20289
20314
  }
@@ -21078,7 +21103,7 @@ function computeJsrMap(func) {
21078
21103
  }
21079
21104
  function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
21080
21105
  const order = /* @__PURE__ */ new Map();
21081
- const queue = new import_chunk_67LU4GPQ.GenericQueue(
21106
+ const queue = new import_chunk_OASVKTK5.GenericQueue(
21082
21107
  (b, a) => order.get(a) - order.get(b)
21083
21108
  );
21084
21109
  postOrderTraverse2(func, (block) => {
@@ -21137,7 +21162,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21137
21162
  });
21138
21163
  blocks.reverse().forEach((block, i) => order.set(block, i));
21139
21164
  }
21140
- const queue = new import_chunk_67LU4GPQ.GenericQueue(
21165
+ const queue = new import_chunk_OASVKTK5.GenericQueue(
21141
21166
  (b, a) => order.get(a) - order.get(b)
21142
21167
  );
21143
21168
  queue.enqueue(func.blocks.get(func.offset));
@@ -21191,7 +21216,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
21191
21216
  var init_cflow = (0, import_chunk_ABYVSU2C.__esm)({
21192
21217
  "src/readprg/cflow.ts"() {
21193
21218
  "use strict";
21194
- (0, import_chunk_67LU4GPQ.init_util)();
21219
+ (0, import_chunk_OASVKTK5.init_util)();
21195
21220
  init_opcodes();
21196
21221
  }
21197
21222
  });
@@ -21654,12 +21679,12 @@ function interpFunc(func, context) {
21654
21679
  const selfStores = /* @__PURE__ */ new Set();
21655
21680
  const liveInState = /* @__PURE__ */ new Map();
21656
21681
  const replacements = /* @__PURE__ */ new Map();
21657
- const interpLogging = (0, import_chunk_67LU4GPQ.wouldLog)("interp", 1);
21682
+ const interpLogging = (0, import_chunk_OASVKTK5.wouldLog)("interp", 1);
21658
21683
  if (interpLogging) {
21659
- if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 7)) {
21660
- (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "interp"));
21661
- } else if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 3)) {
21662
- (0, import_chunk_67LU4GPQ.setBanner)(
21684
+ if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 7)) {
21685
+ (0, import_chunk_OASVKTK5.setBanner)(functionBanner(func, context, "interp"));
21686
+ } else if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 3)) {
21687
+ (0, import_chunk_OASVKTK5.setBanner)(
21663
21688
  () => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
21664
21689
  );
21665
21690
  }
@@ -21693,20 +21718,20 @@ function interpFunc(func, context) {
21693
21718
  func,
21694
21719
  (block) => {
21695
21720
  if (interpLogging) {
21696
- (0, import_chunk_67LU4GPQ.logger)(
21721
+ (0, import_chunk_OASVKTK5.logger)(
21697
21722
  "interp",
21698
21723
  3,
21699
21724
  `${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
21700
21725
  ${interpStateToString(liveInState.get(block.offset))}`
21701
21726
  );
21702
- (0, import_chunk_67LU4GPQ.logger)("interp", 9, () => blockToString(block, context));
21727
+ (0, import_chunk_OASVKTK5.logger)("interp", 9, () => blockToString(block, context));
21703
21728
  }
21704
21729
  return cloneState2(liveInState.get(block.offset));
21705
21730
  },
21706
21731
  (block, bc, localState) => {
21707
21732
  if (interpLogging) {
21708
- if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 8)) {
21709
- (0, import_chunk_67LU4GPQ.log)(
21733
+ if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 8)) {
21734
+ (0, import_chunk_OASVKTK5.log)(
21710
21735
  `${interpStateToString(localState)}
21711
21736
  ${bytecodeToString(
21712
21737
  bc,
@@ -21871,14 +21896,14 @@ function interpFunc(func, context) {
21871
21896
  if (!mergeInto(localState, succState))
21872
21897
  return false;
21873
21898
  if (interpLogging) {
21874
- (0, import_chunk_67LU4GPQ.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
21899
+ (0, import_chunk_OASVKTK5.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
21875
21900
  }
21876
21901
  return true;
21877
21902
  }
21878
21903
  );
21879
21904
  if (interpLogging) {
21880
- if ((0, import_chunk_67LU4GPQ.wouldLog)("interp", 5)) {
21881
- (0, import_chunk_67LU4GPQ.setBanner)(
21905
+ if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 5)) {
21906
+ (0, import_chunk_OASVKTK5.setBanner)(
21882
21907
  functionBanner(func, context, "interp", (block, footer) => {
21883
21908
  if (footer)
21884
21909
  return "";
@@ -21886,44 +21911,44 @@ function interpFunc(func, context) {
21886
21911
  })
21887
21912
  );
21888
21913
  } else {
21889
- (0, import_chunk_67LU4GPQ.setBanner)(() => `=============== interp ${func.name} ==============`);
21914
+ (0, import_chunk_OASVKTK5.setBanner)(() => `=============== interp ${func.name} ==============`);
21890
21915
  }
21891
21916
  if (equivSets.size) {
21892
- (0, import_chunk_67LU4GPQ.log)(`====== equivSets =====`);
21917
+ (0, import_chunk_OASVKTK5.log)(`====== equivSets =====`);
21893
21918
  equivSets.forEach(
21894
- (value2, key) => (0, import_chunk_67LU4GPQ.log)(
21919
+ (value2, key) => (0, import_chunk_OASVKTK5.log)(
21895
21920
  `L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
21896
21921
  )
21897
21922
  );
21898
21923
  }
21899
21924
  if (selfStores.size) {
21900
- (0, import_chunk_67LU4GPQ.log)(`====== selfStores =====`);
21925
+ (0, import_chunk_OASVKTK5.log)(`====== selfStores =====`);
21901
21926
  selfStores.forEach(
21902
- (value2) => (0, import_chunk_67LU4GPQ.log)(`${bytecodeToString(value2, symbolTable)}`)
21927
+ (value2) => (0, import_chunk_OASVKTK5.log)(`${bytecodeToString(value2, symbolTable)}`)
21903
21928
  );
21904
21929
  }
21905
21930
  if (replacements.size) {
21906
- (0, import_chunk_67LU4GPQ.log)(`====== replacements =====`);
21931
+ (0, import_chunk_OASVKTK5.log)(`====== replacements =====`);
21907
21932
  replacements.forEach(
21908
21933
  (blockRep) => blockRep.forEach(
21909
- (rep, bc) => (0, import_chunk_67LU4GPQ.log)(
21934
+ (rep, bc) => (0, import_chunk_OASVKTK5.log)(
21910
21935
  `${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
21911
21936
  )
21912
21937
  )
21913
21938
  );
21914
21939
  }
21915
21940
  if (resolvedBranches.size) {
21916
- (0, import_chunk_67LU4GPQ.log)(`====== resolved branches =====`);
21941
+ (0, import_chunk_OASVKTK5.log)(`====== resolved branches =====`);
21917
21942
  resolvedBranches.forEach(
21918
- (isTaken, block) => (0, import_chunk_67LU4GPQ.log)(
21943
+ (isTaken, block) => (0, import_chunk_OASVKTK5.log)(
21919
21944
  `block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
21920
21945
  )
21921
21946
  );
21922
21947
  }
21923
21948
  if (branchRedirects.size) {
21924
- (0, import_chunk_67LU4GPQ.log)(`====== redirected branches =====`);
21949
+ (0, import_chunk_OASVKTK5.log)(`====== redirected branches =====`);
21925
21950
  branchRedirects.forEach(
21926
- ({ to, from }, block) => (0, import_chunk_67LU4GPQ.log)(
21951
+ ({ to, from }, block) => (0, import_chunk_OASVKTK5.log)(
21927
21952
  `block ${offsetToString(
21928
21953
  block.offset
21929
21954
  )} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
@@ -21986,7 +22011,7 @@ function interpFunc(func, context) {
21986
22011
  }
21987
22012
  });
21988
22013
  if (interpLogging)
21989
- (0, import_chunk_67LU4GPQ.setBanner)(null);
22014
+ (0, import_chunk_OASVKTK5.setBanner)(null);
21990
22015
  return {
21991
22016
  liveInState,
21992
22017
  equivSets,
@@ -22036,7 +22061,7 @@ var init_interp2 = (0, import_chunk_ABYVSU2C.__esm)({
22036
22061
  "src/readprg/interp.ts"() {
22037
22062
  "use strict";
22038
22063
  init_interp_binary();
22039
- (0, import_chunk_67LU4GPQ.init_logger)();
22064
+ (0, import_chunk_OASVKTK5.init_logger)();
22040
22065
  init_interp();
22041
22066
  init_types();
22042
22067
  init_union_type();
@@ -22148,7 +22173,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22148
22173
  i = found;
22149
22174
  }
22150
22175
  if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
22151
- (0, import_chunk_67LU4GPQ.logger)(
22176
+ (0, import_chunk_OASVKTK5.logger)(
22152
22177
  "array-init",
22153
22178
  1,
22154
22179
  () => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
@@ -22185,7 +22210,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22185
22210
  convertAputv(offset - 1);
22186
22211
  }
22187
22212
  }
22188
- (0, import_chunk_67LU4GPQ.logger)(
22213
+ (0, import_chunk_OASVKTK5.logger)(
22189
22214
  "array-init",
22190
22215
  1,
22191
22216
  () => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
@@ -22194,8 +22219,8 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22194
22219
  block.bytecodes[index].offset
22195
22220
  )}`
22196
22221
  );
22197
- if ((0, import_chunk_67LU4GPQ.wouldLog)("array-init", 5)) {
22198
- (0, import_chunk_67LU4GPQ.log)(blockToString(block, context));
22222
+ if ((0, import_chunk_OASVKTK5.wouldLog)("array-init", 5)) {
22223
+ (0, import_chunk_OASVKTK5.log)(blockToString(block, context));
22199
22224
  }
22200
22225
  return true;
22201
22226
  }
@@ -22235,7 +22260,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22235
22260
  if (putvStarts.length < 3)
22236
22261
  return false;
22237
22262
  tryLocal(3);
22238
- (0, import_chunk_67LU4GPQ.logger)(
22263
+ (0, import_chunk_OASVKTK5.logger)(
22239
22264
  "array-init",
22240
22265
  1,
22241
22266
  () => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
@@ -22261,7 +22286,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
22261
22286
  block.bytecodes[index + 1].arg = putvStarts.length;
22262
22287
  }
22263
22288
  }
22264
- (0, import_chunk_67LU4GPQ.logger)(
22289
+ (0, import_chunk_OASVKTK5.logger)(
22265
22290
  "array-init",
22266
22291
  5,
22267
22292
  () => `index: ${index}, i: ${i}
@@ -22314,7 +22339,7 @@ ${blockToString(block, context)}`
22314
22339
  for (let i2 = putvStarts.length; i2-- > 1; ) {
22315
22340
  block.bytecodes.splice(putvStarts[i2], 2);
22316
22341
  }
22317
- (0, import_chunk_67LU4GPQ.logger)(
22342
+ (0, import_chunk_OASVKTK5.logger)(
22318
22343
  "array-init",
22319
22344
  1,
22320
22345
  () => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
@@ -22373,15 +22398,15 @@ var init_array_init = (0, import_chunk_ABYVSU2C.__esm)({
22373
22398
  "src/readprg/array-init.ts"() {
22374
22399
  "use strict";
22375
22400
  init_types();
22376
- (0, import_chunk_67LU4GPQ.init_util)();
22401
+ (0, import_chunk_OASVKTK5.init_util)();
22377
22402
  init_bytecode();
22378
22403
  init_interp2();
22379
22404
  init_opcodes();
22380
22405
  }
22381
22406
  });
22382
22407
  function localDCE(func, context) {
22383
- if ((0, import_chunk_67LU4GPQ.wouldLog)("dce", 5)) {
22384
- (0, import_chunk_67LU4GPQ.setBanner)(
22408
+ if ((0, import_chunk_OASVKTK5.wouldLog)("dce", 5)) {
22409
+ (0, import_chunk_OASVKTK5.setBanner)(
22385
22410
  functionBanner(
22386
22411
  func,
22387
22412
  context,
@@ -22414,7 +22439,7 @@ function localDCE(func, context) {
22414
22439
  };
22415
22440
  func.blocks.forEach((block) => {
22416
22441
  const reportPopv = (i, item, kill) => {
22417
- (0, import_chunk_67LU4GPQ.logger)(
22442
+ (0, import_chunk_OASVKTK5.logger)(
22418
22443
  "dce",
22419
22444
  2,
22420
22445
  () => `${func.name}: Convert ${i}:${bytecodeToString(
@@ -22429,7 +22454,7 @@ function localDCE(func, context) {
22429
22454
  );
22430
22455
  };
22431
22456
  const reportNop = (item) => {
22432
- (0, import_chunk_67LU4GPQ.logger)(
22457
+ (0, import_chunk_OASVKTK5.logger)(
22433
22458
  "dce",
22434
22459
  2,
22435
22460
  () => `${func.name}: Kill ${item.deps.map(
@@ -22448,7 +22473,7 @@ function localDCE(func, context) {
22448
22473
  case 19: {
22449
22474
  const liveLocal = dceInfo.locals.has(bytecode.arg);
22450
22475
  if (!liveLocal && (bytecode.arg || context.config.allowForbiddenOpts)) {
22451
- (0, import_chunk_67LU4GPQ.logger)(
22476
+ (0, import_chunk_OASVKTK5.logger)(
22452
22477
  "dce",
22453
22478
  2,
22454
22479
  () => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
@@ -22608,10 +22633,10 @@ function localDCE(func, context) {
22608
22633
  (bc) => bc.op !== 0
22609
22634
  /* nop */
22610
22635
  );
22611
- (0, import_chunk_67LU4GPQ.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
22636
+ (0, import_chunk_OASVKTK5.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
22612
22637
  }
22613
22638
  });
22614
- (0, import_chunk_67LU4GPQ.setBanner)(null);
22639
+ (0, import_chunk_OASVKTK5.setBanner)(null);
22615
22640
  return anyChanges;
22616
22641
  }
22617
22642
  function computeLiveLocals(func) {
@@ -22662,7 +22687,7 @@ var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
22662
22687
  "src/readprg/dce.ts"() {
22663
22688
  "use strict";
22664
22689
  init_data_flow();
22665
- (0, import_chunk_67LU4GPQ.init_util)();
22690
+ (0, import_chunk_OASVKTK5.init_util)();
22666
22691
  init_bytecode();
22667
22692
  init_cflow();
22668
22693
  init_opcodes();
@@ -22702,7 +22727,7 @@ function minimizeLocals2(func, equivSets, context) {
22702
22727
  const splitRanges = computeSplitRanges(func, equivSets);
22703
22728
  const locals = mergeSplitRanges(splitRanges);
22704
22729
  const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
22705
- (0, import_chunk_67LU4GPQ.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
22730
+ (0, import_chunk_OASVKTK5.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
22706
22731
  let argc = func.argc ?? null;
22707
22732
  const colors = /* @__PURE__ */ new Map();
22708
22733
  const merge = [];
@@ -22769,15 +22794,15 @@ function minimizeLocals2(func, equivSets, context) {
22769
22794
  }
22770
22795
  }
22771
22796
  }
22772
- if ((0, import_chunk_67LU4GPQ.wouldLog)("locals", 1)) {
22773
- if (!(0, import_chunk_67LU4GPQ.wouldLog)("locals", 10)) {
22774
- (0, import_chunk_67LU4GPQ.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
22797
+ if ((0, import_chunk_OASVKTK5.wouldLog)("locals", 1)) {
22798
+ if (!(0, import_chunk_OASVKTK5.wouldLog)("locals", 10)) {
22799
+ (0, import_chunk_OASVKTK5.logger)("locals", 5, functionBanner(func, context, "Minimize Locals"));
22775
22800
  }
22776
- (0, import_chunk_67LU4GPQ.log)(
22801
+ (0, import_chunk_OASVKTK5.log)(
22777
22802
  `>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
22778
22803
  );
22779
22804
  merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
22780
- (merged) => (0, import_chunk_67LU4GPQ.log)(
22805
+ (merged) => (0, import_chunk_OASVKTK5.log)(
22781
22806
  ` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
22782
22807
  )
22783
22808
  );
@@ -23076,7 +23101,7 @@ function mergeSplitRanges(splitRanges) {
23076
23101
  var init_locals = (0, import_chunk_ABYVSU2C.__esm)({
23077
23102
  "src/readprg/locals.ts"() {
23078
23103
  "use strict";
23079
- (0, import_chunk_67LU4GPQ.init_logger)();
23104
+ (0, import_chunk_OASVKTK5.init_logger)();
23080
23105
  init_bytecode();
23081
23106
  init_cflow();
23082
23107
  init_opcodes();
@@ -23189,16 +23214,16 @@ function sizeBasedPRE2(func, context) {
23189
23214
  delete bc.arg;
23190
23215
  return bc;
23191
23216
  };
23192
- if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 1)) {
23193
- if ((0, import_chunk_67LU4GPQ.wouldLog)("pre", 5)) {
23194
- (0, import_chunk_67LU4GPQ.log)(functionBanner(func, context, "PRE")());
23217
+ if ((0, import_chunk_OASVKTK5.wouldLog)("pre", 1)) {
23218
+ if ((0, import_chunk_OASVKTK5.wouldLog)("pre", 5)) {
23219
+ (0, import_chunk_OASVKTK5.log)(functionBanner(func, context, "PRE")());
23195
23220
  } else {
23196
- (0, import_chunk_67LU4GPQ.log)(`================ PRE : ${func.name} ================
23221
+ (0, import_chunk_OASVKTK5.log)(`================ PRE : ${func.name} ================
23197
23222
  `);
23198
23223
  }
23199
23224
  insertionBlocks.forEach((o, key) => {
23200
23225
  const bcs = canonicalMap.get(key);
23201
- (0, import_chunk_67LU4GPQ.log)(
23226
+ (0, import_chunk_OASVKTK5.log)(
23202
23227
  `Replacing ${bcs.size} instances of ${bytecodeToString(
23203
23228
  bcs.values().next().value,
23204
23229
  context.symbolTable
@@ -23281,13 +23306,13 @@ function sizeBasedPRE2(func, context) {
23281
23306
  bytecode(1, insertionBlocks.size)
23282
23307
  );
23283
23308
  }
23284
- (0, import_chunk_67LU4GPQ.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
23309
+ (0, import_chunk_OASVKTK5.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
23285
23310
  return true;
23286
23311
  }
23287
23312
  var init_pre2 = (0, import_chunk_ABYVSU2C.__esm)({
23288
23313
  "src/readprg/pre.ts"() {
23289
23314
  "use strict";
23290
- (0, import_chunk_67LU4GPQ.init_logger)();
23315
+ (0, import_chunk_OASVKTK5.init_logger)();
23291
23316
  init_bytecode();
23292
23317
  init_cflow();
23293
23318
  init_opcodes();
@@ -23320,9 +23345,9 @@ function blockSharing(func, context) {
23320
23345
  if (!any)
23321
23346
  return false;
23322
23347
  any = false;
23323
- const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 1);
23324
- if (logging3 && (0, import_chunk_67LU4GPQ.wouldLog)("sharing", 10)) {
23325
- (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
23348
+ const logging3 = (0, import_chunk_OASVKTK5.wouldLog)("sharing", 1);
23349
+ if (logging3 && (0, import_chunk_OASVKTK5.wouldLog)("sharing", 10)) {
23350
+ (0, import_chunk_OASVKTK5.setBanner)(functionBanner(func, context, "sharing"));
23326
23351
  }
23327
23352
  candidates.forEach((blocks) => {
23328
23353
  while (blocks.size > 1) {
@@ -23458,9 +23483,9 @@ function blockSharing(func, context) {
23458
23483
  block2.offset
23459
23484
  )})` : `block(${offsetToString(block2.offset)})`;
23460
23485
  };
23461
- (0, import_chunk_67LU4GPQ.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23462
- if ((0, import_chunk_67LU4GPQ.wouldLog)("sharing", 5)) {
23463
- (0, import_chunk_67LU4GPQ.log)(blockToString(target, context));
23486
+ (0, import_chunk_OASVKTK5.log)(`Sharing ${showBlock(block)} with ${showBlock(target)}`);
23487
+ if ((0, import_chunk_OASVKTK5.wouldLog)("sharing", 5)) {
23488
+ (0, import_chunk_OASVKTK5.log)(blockToString(target, context));
23464
23489
  }
23465
23490
  }
23466
23491
  if (target.bytecodes.length > length2) {
@@ -23487,13 +23512,13 @@ function blockSharing(func, context) {
23487
23512
  });
23488
23513
  }
23489
23514
  });
23490
- (0, import_chunk_67LU4GPQ.setBanner)(null);
23515
+ (0, import_chunk_OASVKTK5.setBanner)(null);
23491
23516
  return any;
23492
23517
  }
23493
23518
  var init_sharing = (0, import_chunk_ABYVSU2C.__esm)({
23494
23519
  "src/readprg/sharing.ts"() {
23495
23520
  "use strict";
23496
- (0, import_chunk_67LU4GPQ.init_util)();
23521
+ (0, import_chunk_OASVKTK5.init_util)();
23497
23522
  init_bytecode();
23498
23523
  init_opcodes();
23499
23524
  }
@@ -23557,7 +23582,7 @@ function doArrayInits(func, liveInState, context) {
23557
23582
  }
23558
23583
  function simpleOpts(func, context) {
23559
23584
  const equalsSym = 8388787;
23560
- const logging3 = (0, import_chunk_67LU4GPQ.wouldLog)("optimize", 5);
23585
+ const logging3 = (0, import_chunk_OASVKTK5.wouldLog)("optimize", 5);
23561
23586
  return Array.from(func.blocks.values()).reduce((changes, block) => {
23562
23587
  for (let i = block.bytecodes.length; i--; ) {
23563
23588
  const cur = block.bytecodes[i];
@@ -23565,7 +23590,7 @@ function simpleOpts(func, context) {
23565
23590
  block.bytecodes.splice(i, 1);
23566
23591
  changes = true;
23567
23592
  if (logging3) {
23568
- (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23593
+ (0, import_chunk_OASVKTK5.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
23569
23594
  }
23570
23595
  } else if (cur.op === 74 && context.config.removeArgc && context.config.allowForbiddenOpts) {
23571
23596
  const arg = cur.arg.incsp;
@@ -23574,7 +23599,7 @@ function simpleOpts(func, context) {
23574
23599
  incsp.arg = arg;
23575
23600
  changes = true;
23576
23601
  if (logging3) {
23577
- (0, import_chunk_67LU4GPQ.log)(`${func.name}: argcincsp => incsp`);
23602
+ (0, import_chunk_OASVKTK5.log)(`${func.name}: argcincsp => incsp`);
23578
23603
  }
23579
23604
  } else if (i && cur.op === 39 && cur.arg === equalsSym) {
23580
23605
  changes = equalSymbolToEq(block, i) || changes;
@@ -23585,7 +23610,7 @@ function simpleOpts(func, context) {
23585
23610
  if (!shift && prev.op === 37) {
23586
23611
  block.bytecodes.splice(i - 1, 2);
23587
23612
  changes = true;
23588
- logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting no-op shift (${shift})`);
23613
+ logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: deleting no-op shift (${shift})`);
23589
23614
  continue;
23590
23615
  }
23591
23616
  if (shift === 1n && prev.op === 37) {
@@ -23595,7 +23620,7 @@ function simpleOpts(func, context) {
23595
23620
  const add = cur;
23596
23621
  add.op = 3;
23597
23622
  delete add.arg;
23598
- logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
23623
+ logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
23599
23624
  continue;
23600
23625
  }
23601
23626
  if (shift < (prev.op === 49 ? 64n : 31n)) {
@@ -23605,7 +23630,7 @@ function simpleOpts(func, context) {
23605
23630
  } else {
23606
23631
  prev.arg = BigInt.asIntN(64, mul);
23607
23632
  }
23608
- logging3 && (0, import_chunk_67LU4GPQ.log)(
23633
+ logging3 && (0, import_chunk_OASVKTK5.log)(
23609
23634
  `${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
23610
23635
  );
23611
23636
  changes = true;
@@ -23619,14 +23644,14 @@ function simpleOpts(func, context) {
23619
23644
  func.blocks.get(block.taken).preds.delete(block.offset);
23620
23645
  delete block.taken;
23621
23646
  changes = true;
23622
- logging3 && (0, import_chunk_67LU4GPQ.log)(`${func.name}: deleting empty finally handler`);
23647
+ logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: deleting empty finally handler`);
23623
23648
  } else if (isCondBranch(cur.op)) {
23624
23649
  const next = func.blocks.get(block.next);
23625
23650
  const taken = func.blocks.get(block.taken);
23626
23651
  if (next.preds.size > 1 && taken.preds.size === 1) {
23627
23652
  const newOp = cur.op === 40 ? 41 : 40;
23628
23653
  if (logging3) {
23629
- (0, import_chunk_67LU4GPQ.log)(
23654
+ (0, import_chunk_OASVKTK5.log)(
23630
23655
  `${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
23631
23656
  );
23632
23657
  }
@@ -23639,7 +23664,7 @@ function simpleOpts(func, context) {
23639
23664
  const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
23640
23665
  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) {
23641
23666
  if (logging3) {
23642
- (0, import_chunk_67LU4GPQ.log)(
23667
+ (0, import_chunk_OASVKTK5.log)(
23643
23668
  `${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23644
23669
  next.offset
23645
23670
  )}:${offsetToString(taken.offset)}:`
@@ -23656,7 +23681,7 @@ function simpleOpts(func, context) {
23656
23681
  changes = true;
23657
23682
  } 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) {
23658
23683
  if (logging3) {
23659
- (0, import_chunk_67LU4GPQ.log)(
23684
+ (0, import_chunk_OASVKTK5.log)(
23660
23685
  `${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
23661
23686
  taken.offset
23662
23687
  )}:${offsetToString(next.offset)}:`
@@ -23704,7 +23729,7 @@ function equalSymbolToEq(block, equalsIndex) {
23704
23729
  op: 26,
23705
23730
  offset: invokem.offset
23706
23731
  });
23707
- (0, import_chunk_67LU4GPQ.logger)(
23732
+ (0, import_chunk_OASVKTK5.logger)(
23708
23733
  "optimize",
23709
23734
  1,
23710
23735
  `Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
@@ -23764,7 +23789,7 @@ function removeUnreachableCatches(func, context) {
23764
23789
  const next = func.blocks.get(block.next);
23765
23790
  if (block.try === next.try) {
23766
23791
  if (next.preds.size === 1) {
23767
- (0, import_chunk_67LU4GPQ.logger)(
23792
+ (0, import_chunk_OASVKTK5.logger)(
23768
23793
  "cfg",
23769
23794
  1,
23770
23795
  () => `${func.name}: ${offsetToString(
@@ -23787,7 +23812,7 @@ function removeUnreachableCatches(func, context) {
23787
23812
  delete next.preds;
23788
23813
  removeBlock(func, next.offset);
23789
23814
  } else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + opcodeSize(bc.op), 0) < 3 && countFallthroughPreds(func, next) > 1) {
23790
- (0, import_chunk_67LU4GPQ.logger)(
23815
+ (0, import_chunk_OASVKTK5.logger)(
23791
23816
  "cfg",
23792
23817
  1,
23793
23818
  () => `${func.name}: ${offsetToString(
@@ -23812,7 +23837,7 @@ function removeUnreachableCatches(func, context) {
23812
23837
  switch (last.op) {
23813
23838
  case 41:
23814
23839
  case 40:
23815
- (0, import_chunk_67LU4GPQ.logger)(
23840
+ (0, import_chunk_OASVKTK5.logger)(
23816
23841
  "cfg",
23817
23842
  1,
23818
23843
  () => `${func.name}: killing no-op ${bytecodeToString(
@@ -23835,7 +23860,7 @@ function removeUnreachableCatches(func, context) {
23835
23860
  for (let i = block.try.length; i--; ) {
23836
23861
  const handler = block.try[i].handler;
23837
23862
  if (!func.blocks.get(handler)?.preds?.size) {
23838
- (0, import_chunk_67LU4GPQ.logger)(
23863
+ (0, import_chunk_OASVKTK5.logger)(
23839
23864
  "cfg",
23840
23865
  1,
23841
23866
  `${func.name}: killing unused try-catch at ${offsetToString(
@@ -23852,8 +23877,8 @@ function removeUnreachableCatches(func, context) {
23852
23877
  });
23853
23878
  }
23854
23879
  function cleanCfg2(func, context) {
23855
- if ((0, import_chunk_67LU4GPQ.wouldLog)("cfg", 10)) {
23856
- (0, import_chunk_67LU4GPQ.setBanner)(functionBanner(func, context, "sharing"));
23880
+ if ((0, import_chunk_OASVKTK5.wouldLog)("cfg", 10)) {
23881
+ (0, import_chunk_OASVKTK5.setBanner)(functionBanner(func, context, "sharing"));
23857
23882
  }
23858
23883
  removeNoOpBlocks(func);
23859
23884
  removeUnreachableCatches(func, context);
@@ -23868,12 +23893,12 @@ function cleanCfg2(func, context) {
23868
23893
  (0, import_node_assert12.default)(!block.preds?.size);
23869
23894
  func.blocks.delete(block.offset);
23870
23895
  });
23871
- (0, import_chunk_67LU4GPQ.setBanner)(null);
23896
+ (0, import_chunk_OASVKTK5.setBanner)(null);
23872
23897
  }
23873
23898
  var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
23874
23899
  "src/readprg/optimize.ts"() {
23875
23900
  "use strict";
23876
- (0, import_chunk_67LU4GPQ.init_util)();
23901
+ (0, import_chunk_OASVKTK5.init_util)();
23877
23902
  init_array_init();
23878
23903
  init_bytecode();
23879
23904
  init_cflow();
@@ -24488,21 +24513,21 @@ function optimizeBytecode(context) {
24488
24513
  functions.forEach(callback);
24489
24514
  return;
24490
24515
  }
24491
- (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24516
+ (0, import_chunk_OASVKTK5.bumpLogging)(null, 10);
24492
24517
  functions.forEach((func) => {
24493
24518
  if (loggerFunc.test(func.name ?? "<null>")) {
24494
- (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24519
+ (0, import_chunk_OASVKTK5.bumpLogging)(null, -10);
24495
24520
  callback(func);
24496
- (0, import_chunk_67LU4GPQ.bumpLogging)(null, 10);
24521
+ (0, import_chunk_OASVKTK5.bumpLogging)(null, 10);
24497
24522
  return;
24498
24523
  }
24499
24524
  callback(func);
24500
24525
  });
24501
- (0, import_chunk_67LU4GPQ.bumpLogging)(null, -10);
24526
+ (0, import_chunk_OASVKTK5.bumpLogging)(null, -10);
24502
24527
  };
24503
- if ((0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1)) {
24528
+ if ((0, import_chunk_OASVKTK5.wouldLog)("list-input", 1)) {
24504
24529
  forEachFunction(
24505
- (func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-input", 1) && printFunction(func, context)
24530
+ (func) => (0, import_chunk_OASVKTK5.wouldLog)("list-input", 1) && printFunction(func, context)
24506
24531
  );
24507
24532
  }
24508
24533
  forEachFunction((func) => optimizeFunc(func, context));
@@ -24520,7 +24545,7 @@ function optimizeBytecode(context) {
24520
24545
  forEachFunction((func) => {
24521
24546
  if (!func.name)
24522
24547
  return;
24523
- (0, import_chunk_67LU4GPQ.logger)(
24548
+ (0, import_chunk_OASVKTK5.logger)(
24524
24549
  "bytecode",
24525
24550
  5,
24526
24551
  `${func.name}: ${offset.toString(16)} ${offset - func.offset}`
@@ -24529,7 +24554,7 @@ function optimizeBytecode(context) {
24529
24554
  });
24530
24555
  const { offsetMap } = updateInfo;
24531
24556
  offsetMap.set(code.byteLength, offset);
24532
- (0, import_chunk_67LU4GPQ.logger)(
24557
+ (0, import_chunk_OASVKTK5.logger)(
24533
24558
  "bytecode",
24534
24559
  1,
24535
24560
  `${context.filepath}: code size: ${context.sections[
@@ -24541,9 +24566,9 @@ function optimizeBytecode(context) {
24541
24566
  ].length - offset}`
24542
24567
  );
24543
24568
  fixSectionSize(-1059145026, context.sections, offset);
24544
- if ((0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1)) {
24569
+ if ((0, import_chunk_OASVKTK5.wouldLog)("list-output", 1)) {
24545
24570
  forEachFunction(
24546
- (func) => (0, import_chunk_67LU4GPQ.wouldLog)("list-output", 1) && printFunction(func, context)
24571
+ (func) => (0, import_chunk_OASVKTK5.wouldLog)("list-output", 1) && printFunction(func, context)
24547
24572
  );
24548
24573
  }
24549
24574
  fixupHeader(context, updateInfo);
@@ -24633,7 +24658,7 @@ ${functionToString(
24633
24658
  ---------------- ${func.name} ----------------`;
24634
24659
  }
24635
24660
  function printFunction(func, context) {
24636
- (0, import_chunk_67LU4GPQ.log)(functionToString(func, context));
24661
+ (0, import_chunk_OASVKTK5.log)(functionToString(func, context));
24637
24662
  }
24638
24663
  function functionToString(func, context, extra) {
24639
24664
  const parts = [];
@@ -25064,7 +25089,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
25064
25089
  "use strict";
25065
25090
  (0, import_chunk_MBTLUWXR.init_ast)();
25066
25091
  init_sdk_util();
25067
- (0, import_chunk_67LU4GPQ.init_util)();
25092
+ (0, import_chunk_OASVKTK5.init_util)();
25068
25093
  init_data();
25069
25094
  init_emit();
25070
25095
  init_exceptions();
@@ -25350,10 +25375,10 @@ async function build_project(product, options, lineCallback) {
25350
25375
  ].flat();
25351
25376
  if (!returnCommand) {
25352
25377
  const handlers = [
25353
- lineCallback || ((line) => (0, import_chunk_67LU4GPQ.log)(line)),
25378
+ lineCallback || ((line) => (0, import_chunk_OASVKTK5.log)(line)),
25354
25379
  (line) => console.error(line)
25355
25380
  ];
25356
- await (0, import_chunk_67LU4GPQ.spawnByLine)(exe, args, handlers, {
25381
+ await (0, import_chunk_OASVKTK5.spawnByLine)(exe, args, handlers, {
25357
25382
  cwd: workspace
25358
25383
  });
25359
25384
  }
@@ -25363,7 +25388,7 @@ var init_build = (0, import_chunk_ABYVSU2C.__esm)({
25363
25388
  "src/build.ts"() {
25364
25389
  "use strict";
25365
25390
  init_sdk_util();
25366
- (0, import_chunk_67LU4GPQ.init_util)();
25391
+ (0, import_chunk_OASVKTK5.init_util)();
25367
25392
  }
25368
25393
  });
25369
25394
  var require_ms = (0, import_chunk_ABYVSU2C.__commonJS)({
@@ -28330,7 +28355,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
28330
28355
  );
28331
28356
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(cache.resolvedPaths, resolved)) {
28332
28357
  if (/[*?[\]{}]/.test(resolved)) {
28333
- cache.resolvedPaths[resolved] = (0, import_chunk_67LU4GPQ.globSome)(resolved, () => true);
28358
+ cache.resolvedPaths[resolved] = (0, import_chunk_OASVKTK5.globSome)(resolved, () => true);
28334
28359
  } else {
28335
28360
  cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
28336
28361
  () => true,
@@ -28408,12 +28433,12 @@ async function read_resource_files(targets, cache) {
28408
28433
  if (!(0, import_chunk_MBTLUWXR.hasProperty)(resourceGroupPromises, key)) {
28409
28434
  resourceGroupPromises[key] = Promise.all(
28410
28435
  p.qualifier.resourcePath.map(
28411
- (pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { mark: true })
28436
+ (pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { mark: true })
28412
28437
  )
28413
28438
  ).then(
28414
28439
  (patterns) => Promise.all(
28415
28440
  patterns.flat().map(
28416
- (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.xml`, { mark: true }) : path7
28441
+ (path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*.xml`, { mark: true }) : path7
28417
28442
  )
28418
28443
  )
28419
28444
  ).then(
@@ -28473,7 +28498,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
28473
28498
  const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
28474
28499
  const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
28475
28500
  if (filePatterns.length) {
28476
- const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_67LU4GPQ.globa)(p)))).flat();
28501
+ const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_OASVKTK5.globa)(p)))).flat();
28477
28502
  sourceExcludes.push(...files);
28478
28503
  }
28479
28504
  const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
@@ -28650,15 +28675,15 @@ function identify_optimizer_groups(targets, options) {
28650
28675
  function find_barrels(barrelPath) {
28651
28676
  if (Array.isArray(barrelPath)) {
28652
28677
  return Promise.all(
28653
- barrelPath.map((path7) => (0, import_chunk_67LU4GPQ.globa)(path7, { mark: true }))
28678
+ barrelPath.map((path7) => (0, import_chunk_OASVKTK5.globa)(path7, { mark: true }))
28654
28679
  ).then((paths) => [
28655
28680
  paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
28656
28681
  ]);
28657
28682
  }
28658
- return (0, import_chunk_67LU4GPQ.globa)(barrelPath, { mark: true }).then(
28683
+ return (0, import_chunk_OASVKTK5.globa)(barrelPath, { mark: true }).then(
28659
28684
  (paths) => Promise.all(
28660
28685
  paths.map(
28661
- (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*.barrel`) : path7
28686
+ (path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*.barrel`) : path7
28662
28687
  )
28663
28688
  )
28664
28689
  ).then(
@@ -28931,7 +28956,7 @@ var init_jungles = (0, import_chunk_ABYVSU2C.__esm)({
28931
28956
  init_api();
28932
28957
  init_manifest();
28933
28958
  init_sdk_util();
28934
- (0, import_chunk_67LU4GPQ.init_util)();
28959
+ (0, import_chunk_OASVKTK5.init_util)();
28935
28960
  depth = 0;
28936
28961
  }
28937
28962
  });
@@ -28959,7 +28984,7 @@ async function launchSimulator(force = true) {
28959
28984
  await new Promise((r) => setTimeout(r, 200));
28960
28985
  }
28961
28986
  } catch (e) {
28962
- (0, import_chunk_67LU4GPQ.log)(e);
28987
+ (0, import_chunk_OASVKTK5.log)(e);
28963
28988
  }
28964
28989
  }
28965
28990
  function checkIfSimulatorRunning() {
@@ -28990,10 +29015,10 @@ function simulateProgram(prg, device, test = false, logger2) {
28990
29015
  }
28991
29016
  }
28992
29017
  return getSdkPath().then(
28993
- (sdk) => (0, import_chunk_67LU4GPQ.spawnByLine)(
29018
+ (sdk) => (0, import_chunk_OASVKTK5.spawnByLine)(
28994
29019
  path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
28995
29020
  args,
28996
- logger2 || ((line) => (0, import_chunk_67LU4GPQ.log)(line))
29021
+ logger2 || ((line) => (0, import_chunk_OASVKTK5.log)(line))
28997
29022
  ).then(() => {
28998
29023
  return;
28999
29024
  })
@@ -29003,7 +29028,7 @@ var init_launch = (0, import_chunk_ABYVSU2C.__esm)({
29003
29028
  "src/launch.ts"() {
29004
29029
  "use strict";
29005
29030
  init_sdk_util();
29006
- (0, import_chunk_67LU4GPQ.init_util)();
29031
+ (0, import_chunk_OASVKTK5.init_util)();
29007
29032
  }
29008
29033
  });
29009
29034
  function relative_path_no_dotdot(relative2) {
@@ -29024,7 +29049,7 @@ async function getCodeWorkspaceSettings(folder) {
29024
29049
  let curDir = folder;
29025
29050
  try {
29026
29051
  while (curDir) {
29027
- const code_workspaces = await (0, import_chunk_67LU4GPQ.globa)(
29052
+ const code_workspaces = await (0, import_chunk_OASVKTK5.globa)(
29028
29053
  path4.resolve(curDir, "*.code-workspace"),
29029
29054
  { onlyFiles: true }
29030
29055
  );
@@ -29075,7 +29100,12 @@ function getConfig(options) {
29075
29100
  }
29076
29101
  return settings;
29077
29102
  });
29078
- }, Promise.resolve(null)).then(() => config);
29103
+ }, Promise.resolve(options.ignore_settings_files ? {} : null)).then((settings) => {
29104
+ if (settings && (!config.strictTypeCheck || config.strictTypeCheck === "Default") && (settings["monkeyC.typeCheckLevel"]?.toString().toLowerCase() === "strict" || settings["prettierMonkeyC.typeCheckLevel"]?.toString().toLowerCase() === "strict")) {
29105
+ config.strictTypeCheck = "On";
29106
+ }
29107
+ return config;
29108
+ });
29079
29109
  }
29080
29110
  async function buildOptimizedProject(product, options) {
29081
29111
  const config = await getConfig(options);
@@ -29147,7 +29177,7 @@ async function createLocalBarrels(targets, options) {
29147
29177
  optBarrelDir
29148
29178
  };
29149
29179
  return promise2.then(
29150
- () => (0, import_chunk_67LU4GPQ.copyRecursiveAsNeeded)(
29180
+ () => (0, import_chunk_OASVKTK5.copyRecursiveAsNeeded)(
29151
29181
  rawBarrelDir,
29152
29182
  optBarrelDir,
29153
29183
  (src) => !src.endsWith(".mc")
@@ -29449,11 +29479,11 @@ async function generateOptimizedProject(options) {
29449
29479
  }
29450
29480
  async function filesFromPaths(workspace, paths, extension) {
29451
29481
  paths = (await Promise.all(
29452
- paths?.map((pattern) => (0, import_chunk_67LU4GPQ.globa)(pattern, { cwd: workspace, mark: true })) || []
29482
+ paths?.map((pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { cwd: workspace, mark: true })) || []
29453
29483
  )).flat();
29454
29484
  const files = await Promise.all(
29455
29485
  paths.map(
29456
- (path7) => path7.endsWith("/") ? (0, import_chunk_67LU4GPQ.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
29486
+ (path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
29457
29487
  )
29458
29488
  );
29459
29489
  return {
@@ -29563,7 +29593,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29563
29593
  })
29564
29594
  );
29565
29595
  }
29566
- const actualOptimizedFiles = (await (0, import_chunk_67LU4GPQ.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
29596
+ const actualOptimizedFiles = (await (0, import_chunk_OASVKTK5.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
29567
29597
  const {
29568
29598
  hasTests,
29569
29599
  diagnostics: prevDiagnostics,
@@ -29579,13 +29609,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29579
29609
  const sdk = await getSdkPath();
29580
29610
  const match = sdk.match(/-(\d+\.\d+\.\d+)/);
29581
29611
  if ((match && parseSdkVersion(match[1])) === prevSdkVersion) {
29582
- const source_time = await (0, import_chunk_67LU4GPQ.last_modified)(
29612
+ const source_time = await (0, import_chunk_OASVKTK5.last_modified)(
29583
29613
  Object.keys(fnMap).concat(dependencyFiles)
29584
29614
  );
29585
- const opt_time = await (0, import_chunk_67LU4GPQ.first_modified)(
29615
+ const opt_time = await (0, import_chunk_OASVKTK5.first_modified)(
29586
29616
  Object.values(fnMap).map((v) => v.output)
29587
29617
  );
29588
- if (source_time < opt_time && 1719699536477 < opt_time) {
29618
+ if (source_time < opt_time && 1720052616198 < opt_time) {
29589
29619
  return {
29590
29620
  hasTests,
29591
29621
  diagnostics: prevDiagnostics,
@@ -29624,7 +29654,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29624
29654
  hasTests: hasTests2,
29625
29655
  diagnostics,
29626
29656
  sdkVersion,
29627
- optimizerVersion: "1.1.66",
29657
+ optimizerVersion: "1.1.67",
29628
29658
  ...Object.fromEntries(
29629
29659
  configOptionsToCheck.map((option) => [option, config[option]])
29630
29660
  )
@@ -29634,15 +29664,12 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29634
29664
  }
29635
29665
  );
29636
29666
  }
29637
- async function getProjectAnalysis(targets, analysis, manifestXML, options) {
29638
- try {
29639
- return getProjectAnalysisHelper(targets, analysis, manifestXML, options);
29640
- } catch (ex) {
29641
- if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
29642
- await ex.resolve();
29643
- }
29644
- throw ex;
29645
- }
29667
+ function getProjectAnalysis(targets, analysis, manifestXML, options) {
29668
+ return getConfig(options).then(
29669
+ (options2) => getProjectAnalysisHelper(targets, analysis, manifestXML, options2)
29670
+ ).catch(
29671
+ (ex) => Promise.reject(ex instanceof import_chunk_OASVKTK5.AwaitedError ? ex.resolve() : ex)
29672
+ );
29646
29673
  }
29647
29674
  async function getProjectAnalysisHelper(targets, analysis, manifestXML, options) {
29648
29675
  const qualifiers = /* @__PURE__ */ new Map();
@@ -29708,9 +29735,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29708
29735
  }
29709
29736
  });
29710
29737
  }
29711
- if (!await getFileASTs(fnMap)) {
29712
- return { fnMap, paths };
29713
- }
29738
+ await getFileASTs(fnMap);
29714
29739
  const resourcesMap = {};
29715
29740
  const addResources = (name, resources) => {
29716
29741
  if (!resources)
@@ -29729,14 +29754,22 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29729
29754
  );
29730
29755
  }
29731
29756
  });
29732
- const state = await analyze(fnMap, resourcesMap, manifestXML, options);
29733
- reportMissingSymbols(state, options);
29757
+ return {
29758
+ ...await getFnMapAnalysis(fnMap, resourcesMap, manifestXML, options),
29759
+ paths
29760
+ };
29761
+ }
29762
+ async function getFnMapAnalysis(fnMap, resourcesMap, manifestXML, options) {
29763
+ const state = await analyze(fnMap, resourcesMap, manifestXML, options, true);
29764
+ if (Object.values(fnMap).every(({ ast }) => ast != null)) {
29765
+ reportMissingSymbols(state, options);
29766
+ }
29734
29767
  let typeMap = null;
29735
- if (state.config?.propagateTypes && state.config.trustDeclaredTypes && state.config.checkTypes !== "OFF" && Object.values(state.fnMap).every((ast) => ast != null)) {
29768
+ if (state.config?.propagateTypes && state.config.trustDeclaredTypes && state.config.checkTypes !== "OFF") {
29736
29769
  const gistate = {
29737
29770
  state,
29738
29771
  stack: [],
29739
- typeChecker: state.config.typeCheckLevel?.toLowerCase() === "strict" ? subtypeOf : couldBeWeak,
29772
+ typeChecker: state.config.strictTypeCheck?.toLowerCase() === "on" ? subtypeOf : couldBeWeak,
29740
29773
  checkTypes: state.config?.checkTypes || "WARNING"
29741
29774
  };
29742
29775
  state.pre = (node) => {
@@ -29765,14 +29798,17 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
29765
29798
  return null;
29766
29799
  };
29767
29800
  Object.values(state.fnMap).forEach((f) => {
29768
- collectNamespaces(f.ast, state);
29801
+ f.ast && collectNamespaces(f.ast, state);
29769
29802
  });
29770
29803
  delete state.pre;
29771
29804
  }
29772
- if (state.diagnostics) {
29773
- await resolveDiagnosticsMap(state.diagnostics);
29805
+ const diagnostics = state.diagnostics && await resolveDiagnosticsMap(state.diagnostics);
29806
+ if (state.config?.checkBuildPragmas) {
29807
+ Object.entries(fnMap).forEach(([name, f]) => {
29808
+ pragmaChecker(state, f.ast, diagnostics?.[name]);
29809
+ });
29774
29810
  }
29775
- return { fnMap, paths, state, typeMap };
29811
+ return { fnMap, state, typeMap };
29776
29812
  }
29777
29813
  var defaultConfig, configOptionsToCheck;
29778
29814
  var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
@@ -29789,8 +29825,9 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
29789
29825
  init_could_be();
29790
29826
  init_interp();
29791
29827
  init_sub_type();
29792
- (0, import_chunk_67LU4GPQ.init_util)();
29828
+ (0, import_chunk_OASVKTK5.init_util)();
29793
29829
  init_worker_pool();
29830
+ init_pragma_checker();
29794
29831
  init_optimizer_types();
29795
29832
  init_types();
29796
29833
  defaultConfig = {
@@ -29849,7 +29886,7 @@ async function performTask(task) {
29849
29886
  throw new Error(`Invalid task type ${type}`);
29850
29887
  }
29851
29888
  return Promise.resolve(handler(task.data)).then(
29852
- (result) => import_chunk_67LU4GPQ.logPromise.then(() => result)
29889
+ (result) => import_chunk_OASVKTK5.logPromise.then(() => result)
29853
29890
  );
29854
29891
  }
29855
29892
  var workerTaskHandlers;
@@ -29859,7 +29896,7 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
29859
29896
  init_optimizer();
29860
29897
  init_readprg();
29861
29898
  init_sdk_util();
29862
- (0, import_chunk_67LU4GPQ.init_logger)();
29899
+ (0, import_chunk_OASVKTK5.init_logger)();
29863
29900
  workerTaskHandlers = {
29864
29901
  buildOptimizedProject(data) {
29865
29902
  return buildOptimizedProject(data.product, data.options);
@@ -30076,7 +30113,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
30076
30113
  }
30077
30114
  function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, config) {
30078
30115
  const { sections } = readPrgWithOffsets(view);
30079
- (0, import_chunk_67LU4GPQ.logger)("readprg", 5, sections);
30116
+ (0, import_chunk_OASVKTK5.logger)("readprg", 5, sections);
30080
30117
  const symbolTable = new SymbolTable();
30081
30118
  if ((0, import_chunk_MBTLUWXR.hasProperty)(sections, 1461170197 .toString())) {
30082
30119
  symbolTable.parse(sections[
@@ -30376,7 +30413,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
30376
30413
  init_signer();
30377
30414
  init_symbols();
30378
30415
  init_sdk_util();
30379
- (0, import_chunk_67LU4GPQ.init_util)();
30416
+ (0, import_chunk_OASVKTK5.init_util)();
30380
30417
  init_worker_pool();
30381
30418
  }
30382
30419
  });
@@ -30388,7 +30425,7 @@ function getSdkPath() {
30388
30425
  });
30389
30426
  }
30390
30427
  async function getDeviceInfo() {
30391
- const files = await (0, import_chunk_67LU4GPQ.globa)(`${connectiq}/Devices/*/compiler.json`);
30428
+ const files = await (0, import_chunk_OASVKTK5.globa)(`${connectiq}/Devices/*/compiler.json`);
30392
30429
  if (!files.length) {
30393
30430
  throw new Error(
30394
30431
  `No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
@@ -30456,7 +30493,7 @@ async function getFunctionDocumentation() {
30456
30493
  var isWin, appSupport, connectiq;
30457
30494
  var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
30458
30495
  "src/sdk-util.ts"() {
30459
- (0, import_chunk_67LU4GPQ.init_util)();
30496
+ (0, import_chunk_OASVKTK5.init_util)();
30460
30497
  init_xml_util();
30461
30498
  init_readprg();
30462
30499
  init_bytecode();
@@ -30504,6 +30541,7 @@ var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
30504
30541
  getConfig,
30505
30542
  getDeviceInfo,
30506
30543
  getFileASTs,
30544
+ getFnMapAnalysis,
30507
30545
  getFunctionDocumentation,
30508
30546
  getLanguages,
30509
30547
  getProjectAnalysis,