@markw65/monkeyc-optimizer 1.1.65 → 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.
- package/CHANGELOG.md +12 -0
- package/build/api.cjs +35 -35
- package/build/{chunk-MDTDXRQB.cjs → chunk-2OEXWI65.cjs} +479 -392
- package/build/{chunk-67LU4GPQ.cjs → chunk-OASVKTK5.cjs} +7 -4
- package/build/optimizer.cjs +21 -19
- package/build/sdk-util.cjs +15 -15
- package/build/src/build-config.d.ts +3 -0
- package/build/src/mc-rewrite.d.ts +1 -1
- package/build/src/optimizer.d.ts +6 -6
- package/build/src/pragma-checker.d.ts +2 -2
- package/build/src/type-flow/type-flow-util.d.ts +1 -1
- package/build/src/util.d.ts +1 -1
- package/build/util.cjs +26 -26
- package/build/worker-thread.cjs +4 -4
- package/package.json +4 -4
|
@@ -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
|
|
30
|
-
__export(
|
|
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_MDTDXRQB_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_MDTDXRQB_exports, {
|
|
|
134
135
|
visitorNode: () => visitorNode,
|
|
135
136
|
xml_util_exports: () => xml_util_exports
|
|
136
137
|
});
|
|
137
|
-
module.exports = __toCommonJS(
|
|
138
|
-
var
|
|
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,50 +5643,69 @@ 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
|
-
order:
|
|
5659
|
+
order: 100,
|
|
5647
5660
|
type: "boolean",
|
|
5648
5661
|
markdownDescription: "[Whether to rely on type declarations when optimizing](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#trust-declared-types)",
|
|
5649
5662
|
default: true,
|
|
5650
5663
|
scope: "resource"
|
|
5651
5664
|
},
|
|
5652
5665
|
propagateTypes: {
|
|
5653
|
-
order:
|
|
5666
|
+
order: 110,
|
|
5654
5667
|
type: "boolean",
|
|
5655
5668
|
markdownDescription: "[Whether to propagate type information, or process it locally](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#propagate-types)",
|
|
5656
5669
|
default: true,
|
|
5657
5670
|
scope: "resource"
|
|
5658
5671
|
},
|
|
5659
5672
|
sizeBasedPRE: {
|
|
5660
|
-
order:
|
|
5673
|
+
order: 111,
|
|
5661
5674
|
type: "boolean",
|
|
5662
5675
|
markdownDescription: "[Whether to enable the size based partial redundancy pass](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre)",
|
|
5663
5676
|
default: true,
|
|
5664
5677
|
scope: "resource"
|
|
5665
5678
|
},
|
|
5679
|
+
preSkipLiterals: {
|
|
5680
|
+
order: 112,
|
|
5681
|
+
type: "boolean",
|
|
5682
|
+
markdownDescription: "[Whether to skip the size based partial redundancy pass for literal values](https://github.com/markw65/monkeyc-optimizer/wiki/Type-and-Dataflow-analysis#size-based-pre-skip-literals)",
|
|
5683
|
+
default: false,
|
|
5684
|
+
scope: "resource"
|
|
5685
|
+
},
|
|
5666
5686
|
minimizeLocals: {
|
|
5667
|
-
order:
|
|
5687
|
+
order: 120,
|
|
5668
5688
|
type: "boolean",
|
|
5669
5689
|
markdownDescription: "[Whether to enable the minimize locals pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#minimize-locals)",
|
|
5670
5690
|
default: true,
|
|
5671
5691
|
scope: "resource"
|
|
5672
5692
|
},
|
|
5673
5693
|
singleUseCopyProp: {
|
|
5674
|
-
order:
|
|
5694
|
+
order: 120,
|
|
5675
5695
|
type: "boolean",
|
|
5676
5696
|
markdownDescription: "[Whether to enable the single use copy propagation pass](https://github.com/markw65/monkeyc-optimizer/wiki/Local-variable-elimination#single-use-copy-propagation)",
|
|
5677
5697
|
default: true,
|
|
5678
5698
|
scope: "resource"
|
|
5679
5699
|
},
|
|
5680
5700
|
minimizeModules: {
|
|
5681
|
-
order:
|
|
5701
|
+
order: 120,
|
|
5682
5702
|
type: "boolean",
|
|
5683
5703
|
markdownDescription: "[Whether to enable the minimize modules pass](https://github.com/markw65/monkeyc-optimizer/wiki/Optimizing-module-imports#minimize-modules)",
|
|
5684
5704
|
default: true,
|
|
5685
5705
|
scope: "resource"
|
|
5686
5706
|
},
|
|
5687
5707
|
iterateOptimizer: {
|
|
5688
|
-
order:
|
|
5708
|
+
order: 120,
|
|
5689
5709
|
type: "boolean",
|
|
5690
5710
|
description: "Whether to keep running the optimizer pass until it makes no further changes (may be slow)",
|
|
5691
5711
|
default: false,
|
|
@@ -7319,9 +7339,9 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
|
7319
7339
|
);
|
|
7320
7340
|
}
|
|
7321
7341
|
} else {
|
|
7322
|
-
(0,
|
|
7342
|
+
(0, import_chunk_OASVKTK5.forEach)(events, (e) => e.mayThrow = false);
|
|
7323
7343
|
}
|
|
7324
|
-
(0,
|
|
7344
|
+
(0, import_chunk_OASVKTK5.forEach)(events, (event) => {
|
|
7325
7345
|
if (event.mayThrow) {
|
|
7326
7346
|
for (let i = localState.stack.length; i--; ) {
|
|
7327
7347
|
const target = localState.stack[i].throw;
|
|
@@ -7466,7 +7486,7 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
7466
7486
|
"src/control-flow.ts"() {
|
|
7467
7487
|
"use strict";
|
|
7468
7488
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
7469
|
-
(0,
|
|
7489
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
7470
7490
|
Terminals = {
|
|
7471
7491
|
BreakStatement: "break",
|
|
7472
7492
|
ContinueStatement: "continue",
|
|
@@ -7496,12 +7516,12 @@ var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
7496
7516
|
if (!from.succs) {
|
|
7497
7517
|
from.succs = [to];
|
|
7498
7518
|
} else {
|
|
7499
|
-
(0,
|
|
7519
|
+
(0, import_chunk_OASVKTK5.pushUnique)(from.succs, to);
|
|
7500
7520
|
}
|
|
7501
7521
|
if (!to.preds) {
|
|
7502
7522
|
to.preds = [from];
|
|
7503
7523
|
} else {
|
|
7504
|
-
(0,
|
|
7524
|
+
(0, import_chunk_OASVKTK5.pushUnique)(to.preds, from);
|
|
7505
7525
|
}
|
|
7506
7526
|
}
|
|
7507
7527
|
newBlock(block) {
|
|
@@ -7855,8 +7875,8 @@ function mergeObjectValues(to, from) {
|
|
|
7855
7875
|
function mergeStateDecls(to, from) {
|
|
7856
7876
|
let changed = false;
|
|
7857
7877
|
let result = to;
|
|
7858
|
-
(0,
|
|
7859
|
-
if ((0,
|
|
7878
|
+
(0, import_chunk_OASVKTK5.forEach)(from, (v) => {
|
|
7879
|
+
if ((0, import_chunk_OASVKTK5.some)(to, (t) => t === v)) {
|
|
7860
7880
|
return;
|
|
7861
7881
|
}
|
|
7862
7882
|
if (Array.isArray(result)) {
|
|
@@ -8023,7 +8043,7 @@ var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8023
8043
|
"use strict";
|
|
8024
8044
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
8025
8045
|
init_data_flow();
|
|
8026
|
-
(0,
|
|
8046
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
8027
8047
|
init_could_be();
|
|
8028
8048
|
init_intersection_type();
|
|
8029
8049
|
init_sub_type();
|
|
@@ -8038,7 +8058,7 @@ function expandTypedef(t) {
|
|
|
8038
8058
|
);
|
|
8039
8059
|
const tExpanded = cloneType(t);
|
|
8040
8060
|
clearValuesUnder(tExpanded, 262144, true);
|
|
8041
|
-
(0,
|
|
8061
|
+
(0, import_chunk_OASVKTK5.forEach)(decls, (decl) => unionInto(tExpanded, decl.resolvedType));
|
|
8042
8062
|
return tExpanded;
|
|
8043
8063
|
}
|
|
8044
8064
|
function intersectEnum(t, e) {
|
|
@@ -8232,9 +8252,9 @@ function intersectionValue(pair) {
|
|
|
8232
8252
|
case 4096:
|
|
8233
8253
|
case 8192: {
|
|
8234
8254
|
const common = [];
|
|
8235
|
-
(0,
|
|
8255
|
+
(0, import_chunk_OASVKTK5.forEach)(
|
|
8236
8256
|
pair.avalue,
|
|
8237
|
-
(sna) => (0,
|
|
8257
|
+
(sna) => (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => sna === snb) && common.push(sna)
|
|
8238
8258
|
);
|
|
8239
8259
|
if (!common.length)
|
|
8240
8260
|
return null;
|
|
@@ -8242,9 +8262,9 @@ function intersectionValue(pair) {
|
|
|
8242
8262
|
}
|
|
8243
8263
|
case 16384: {
|
|
8244
8264
|
const common = [];
|
|
8245
|
-
(0,
|
|
8265
|
+
(0, import_chunk_OASVKTK5.forEach)(pair.avalue, (sna) => {
|
|
8246
8266
|
const superA = getSuperClasses(sna);
|
|
8247
|
-
(0,
|
|
8267
|
+
(0, import_chunk_OASVKTK5.forEach)(pair.bvalue, (snb) => {
|
|
8248
8268
|
if (sna === snb || superA && superA.has(snb)) {
|
|
8249
8269
|
common.push(sna);
|
|
8250
8270
|
}
|
|
@@ -8490,7 +8510,7 @@ function restrictExactTypesByEquality(a, b) {
|
|
|
8490
8510
|
}
|
|
8491
8511
|
case 262144:
|
|
8492
8512
|
return restrictByEquality(
|
|
8493
|
-
(0,
|
|
8513
|
+
(0, import_chunk_OASVKTK5.reduce)(
|
|
8494
8514
|
a.value,
|
|
8495
8515
|
(cur, decl) => {
|
|
8496
8516
|
unionInto(cur, decl.resolvedType);
|
|
@@ -8557,7 +8577,7 @@ var init_intersection_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8557
8577
|
"use strict";
|
|
8558
8578
|
init_api();
|
|
8559
8579
|
init_data_flow();
|
|
8560
|
-
(0,
|
|
8580
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
8561
8581
|
init_could_be();
|
|
8562
8582
|
init_interp();
|
|
8563
8583
|
init_types();
|
|
@@ -8671,14 +8691,14 @@ function subtypeOfValue(pair) {
|
|
|
8671
8691
|
case 8192: {
|
|
8672
8692
|
const asd = pair.avalue;
|
|
8673
8693
|
const bsd = pair.bvalue;
|
|
8674
|
-
return (0,
|
|
8694
|
+
return (0, import_chunk_OASVKTK5.some)(asd, (sna) => (0, import_chunk_OASVKTK5.some)(bsd, (snb) => sna === snb));
|
|
8675
8695
|
}
|
|
8676
8696
|
case 16384: {
|
|
8677
8697
|
const asd = pair.avalue;
|
|
8678
8698
|
const bsd = pair.bvalue;
|
|
8679
|
-
return (0,
|
|
8699
|
+
return (0, import_chunk_OASVKTK5.every)(asd, (sna) => {
|
|
8680
8700
|
const superA = getSuperClasses(sna);
|
|
8681
|
-
return (0,
|
|
8701
|
+
return (0, import_chunk_OASVKTK5.some)(bsd, (snb) => {
|
|
8682
8702
|
if (sna === snb || superA && superA.has(snb)) {
|
|
8683
8703
|
return true;
|
|
8684
8704
|
}
|
|
@@ -8714,7 +8734,7 @@ var init_sub_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
8714
8734
|
"use strict";
|
|
8715
8735
|
init_api();
|
|
8716
8736
|
init_data_flow();
|
|
8717
|
-
(0,
|
|
8737
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
8718
8738
|
init_could_be();
|
|
8719
8739
|
init_intersection_type();
|
|
8720
8740
|
init_types();
|
|
@@ -9135,13 +9155,13 @@ function isTypeStateKey(decl) {
|
|
|
9135
9155
|
return Array.isArray(decl) || decl.type !== "MemberDecl" && decl.type !== "Unknown";
|
|
9136
9156
|
}
|
|
9137
9157
|
function declIsLocal(decl) {
|
|
9138
|
-
return (0,
|
|
9158
|
+
return (0, import_chunk_OASVKTK5.some)(
|
|
9139
9159
|
decl,
|
|
9140
9160
|
(d) => d.type === "BinaryExpression" || d.type === "Identifier" || d.type === "VariableDeclarator" && isLocal(d)
|
|
9141
9161
|
);
|
|
9142
9162
|
}
|
|
9143
9163
|
function declIsNonLocal(decl) {
|
|
9144
|
-
return (0,
|
|
9164
|
+
return (0, import_chunk_OASVKTK5.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d));
|
|
9145
9165
|
}
|
|
9146
9166
|
function localDeclName(decl) {
|
|
9147
9167
|
if (Array.isArray(decl))
|
|
@@ -9154,12 +9174,12 @@ function localDeclName(decl) {
|
|
|
9154
9174
|
case "VariableDeclarator":
|
|
9155
9175
|
return variableDeclarationName(decl.node.id);
|
|
9156
9176
|
}
|
|
9157
|
-
throw new
|
|
9177
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
9158
9178
|
declFullName(decl).then((declStr) => `Invalid local decl: ${declStr}`)
|
|
9159
9179
|
);
|
|
9160
9180
|
}
|
|
9161
9181
|
function tsKey(key) {
|
|
9162
|
-
return `${(0,
|
|
9182
|
+
return `${(0, import_chunk_OASVKTK5.map)(key, (k) => {
|
|
9163
9183
|
if (k.type === "Literal") {
|
|
9164
9184
|
return k.raw;
|
|
9165
9185
|
} else if (isStateNode(k)) {
|
|
@@ -9178,7 +9198,7 @@ function sourceLocation(loc) {
|
|
|
9178
9198
|
return loc ? `${loc.source || "??"}:${loc.start.line}:${loc.start.column}` : "??";
|
|
9179
9199
|
}
|
|
9180
9200
|
function printBlockHeader(block) {
|
|
9181
|
-
(0,
|
|
9201
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
9182
9202
|
block.order,
|
|
9183
9203
|
`(${block.node?.loc?.source || "??"}:${block.node?.loc?.start.line || "??"})`,
|
|
9184
9204
|
`Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
|
|
@@ -9192,10 +9212,10 @@ function describeEvent(event) {
|
|
|
9192
9212
|
).then((desc) => `${event.type}: ${desc}`);
|
|
9193
9213
|
}
|
|
9194
9214
|
function printBlockEvents(block, extra) {
|
|
9195
|
-
(0,
|
|
9196
|
-
(0,
|
|
9215
|
+
(0, import_chunk_OASVKTK5.log)("Events:");
|
|
9216
|
+
(0, import_chunk_OASVKTK5.forEach)(
|
|
9197
9217
|
block.events,
|
|
9198
|
-
(event) => (0,
|
|
9218
|
+
(event) => (0, import_chunk_OASVKTK5.log)(
|
|
9199
9219
|
describeEvent(event).then(
|
|
9200
9220
|
(eventStr) => ` ${eventStr} ${extra ? extra(event) : ""}`
|
|
9201
9221
|
)
|
|
@@ -9203,7 +9223,7 @@ function printBlockEvents(block, extra) {
|
|
|
9203
9223
|
);
|
|
9204
9224
|
}
|
|
9205
9225
|
function printBlockTrailer(block) {
|
|
9206
|
-
(0,
|
|
9226
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
9207
9227
|
`Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
|
|
9208
9228
|
);
|
|
9209
9229
|
}
|
|
@@ -9288,8 +9308,8 @@ function findObjectDeclsByProperty(state, object, next) {
|
|
|
9288
9308
|
const decls = getStateNodeDeclsFromType(state, object);
|
|
9289
9309
|
if (!decls)
|
|
9290
9310
|
return [null, null];
|
|
9291
|
-
const possibleDecls = (0, import_chunk_MBTLUWXR.hasProperty)(state.allDeclarations, next.
|
|
9292
|
-
return filterDecls(decls, possibleDecls, next.
|
|
9311
|
+
const possibleDecls = (0, import_chunk_MBTLUWXR.hasProperty)(state.allDeclarations, next.name) && state.allDeclarations[next.name];
|
|
9312
|
+
return filterDecls(decls, possibleDecls, next.name);
|
|
9293
9313
|
}
|
|
9294
9314
|
function refineObjectTypeByDecls(istate, object, trueDecls) {
|
|
9295
9315
|
const refinedType = typeFromTypeStateNodes(istate.state, trueDecls);
|
|
@@ -9319,7 +9339,7 @@ function resolveDottedMember(istate, object, next) {
|
|
|
9319
9339
|
const [objDecls, trueDecls] = findObjectDeclsByProperty(
|
|
9320
9340
|
istate.state,
|
|
9321
9341
|
object,
|
|
9322
|
-
next
|
|
9342
|
+
next.property
|
|
9323
9343
|
);
|
|
9324
9344
|
if (!objDecls)
|
|
9325
9345
|
return null;
|
|
@@ -9335,7 +9355,7 @@ var init_type_flow_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
9335
9355
|
"use strict";
|
|
9336
9356
|
init_api();
|
|
9337
9357
|
init_data_flow();
|
|
9338
|
-
(0,
|
|
9358
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
9339
9359
|
init_intersection_type();
|
|
9340
9360
|
init_sub_type();
|
|
9341
9361
|
init_types();
|
|
@@ -9389,7 +9409,7 @@ function calleeObjectType(istate, callee) {
|
|
|
9389
9409
|
}
|
|
9390
9410
|
function checkCallArgs(istate, node, callees, args) {
|
|
9391
9411
|
const allDiags = [];
|
|
9392
|
-
const resultType = (0,
|
|
9412
|
+
const resultType = (0, import_chunk_OASVKTK5.reduce)(
|
|
9393
9413
|
callees,
|
|
9394
9414
|
(result, cur) => {
|
|
9395
9415
|
const curDiags = [];
|
|
@@ -9548,7 +9568,7 @@ function isOverride(cur, funcs) {
|
|
|
9548
9568
|
const cls = cur.stack?.[cur.stack.length - 1]?.sn;
|
|
9549
9569
|
if (cls?.type === "ClassDeclaration" && cls.superClasses) {
|
|
9550
9570
|
const supers = getSuperClasses(cls);
|
|
9551
|
-
if (supers && (0,
|
|
9571
|
+
if (supers && (0, import_chunk_OASVKTK5.some)(funcs, (func) => {
|
|
9552
9572
|
if (func === cur)
|
|
9553
9573
|
return false;
|
|
9554
9574
|
const fcls = func.stack?.[func.stack.length - 1].sn;
|
|
@@ -9606,8 +9626,16 @@ function getSystemCallTable(state) {
|
|
|
9606
9626
|
512
|
|
9607
9627
|
/* Array */
|
|
9608
9628
|
);
|
|
9609
|
-
if (argSubtypes
|
|
9610
|
-
|
|
9629
|
+
if (argSubtypes) {
|
|
9630
|
+
if (Array.isArray(argSubtypes)) {
|
|
9631
|
+
const newAData2 = [...adata, ...argSubtypes];
|
|
9632
|
+
ret.returnType.value = newAData2;
|
|
9633
|
+
ret.argTypes = [arg];
|
|
9634
|
+
ret.calleeObj = ret.returnType;
|
|
9635
|
+
return ret;
|
|
9636
|
+
}
|
|
9637
|
+
const newAData = reducedType(adata);
|
|
9638
|
+
unionInto(newAData, argSubtypes);
|
|
9611
9639
|
ret.returnType.value = newAData;
|
|
9612
9640
|
ret.argTypes = [arg];
|
|
9613
9641
|
ret.calleeObj = ret.returnType;
|
|
@@ -9826,7 +9854,11 @@ function getSystemCallTable(state) {
|
|
|
9826
9854
|
property: symbol,
|
|
9827
9855
|
computed: false
|
|
9828
9856
|
};
|
|
9829
|
-
const [, trueDecls] = findObjectDeclsByProperty(
|
|
9857
|
+
const [, trueDecls] = findObjectDeclsByProperty(
|
|
9858
|
+
state2,
|
|
9859
|
+
calleeObj,
|
|
9860
|
+
next.property
|
|
9861
|
+
);
|
|
9830
9862
|
if (!trueDecls)
|
|
9831
9863
|
return ret;
|
|
9832
9864
|
const callees = trueDecls.flatMap((decl) => decl.decls?.[symbol.name]).filter(
|
|
@@ -10034,7 +10066,7 @@ var init_interp_call = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
10034
10066
|
"use strict";
|
|
10035
10067
|
init_optimizer_types();
|
|
10036
10068
|
init_api();
|
|
10037
|
-
(0,
|
|
10069
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
10038
10070
|
init_interp();
|
|
10039
10071
|
init_sub_type();
|
|
10040
10072
|
init_types();
|
|
@@ -10395,7 +10427,7 @@ function getLhsConstraint(istate, node) {
|
|
|
10395
10427
|
const [, trueDecls2] = findObjectDeclsByProperty(
|
|
10396
10428
|
istate.state,
|
|
10397
10429
|
object,
|
|
10398
|
-
node
|
|
10430
|
+
node.property
|
|
10399
10431
|
);
|
|
10400
10432
|
if (trueDecls2) {
|
|
10401
10433
|
lookupDefs = lookupNext(
|
|
@@ -11159,7 +11191,7 @@ function mustBeIdentical(a, b) {
|
|
|
11159
11191
|
return false;
|
|
11160
11192
|
}
|
|
11161
11193
|
function isByteArrayData(objectData) {
|
|
11162
|
-
return objectData.klass.value && (0,
|
|
11194
|
+
return objectData.klass.value && (0, import_chunk_OASVKTK5.every)(
|
|
11163
11195
|
objectData.klass.value,
|
|
11164
11196
|
(klass) => klass.fullName === "$.Toybox.Lang.ByteArray"
|
|
11165
11197
|
);
|
|
@@ -11171,7 +11203,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
11171
11203
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
11172
11204
|
init_data_flow();
|
|
11173
11205
|
init_optimizer_types();
|
|
11174
|
-
(0,
|
|
11206
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
11175
11207
|
init_could_be();
|
|
11176
11208
|
init_interp_binary();
|
|
11177
11209
|
init_interp_call();
|
|
@@ -11402,7 +11434,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
|
|
|
11402
11434
|
);
|
|
11403
11435
|
if (value2) {
|
|
11404
11436
|
const a = [];
|
|
11405
|
-
(0,
|
|
11437
|
+
(0, import_chunk_OASVKTK5.forEach)(value2, (v) => {
|
|
11406
11438
|
if (v !== sn)
|
|
11407
11439
|
a.push(v);
|
|
11408
11440
|
});
|
|
@@ -11894,7 +11926,7 @@ function mustBeFalse(arg) {
|
|
|
11894
11926
|
return arg.type === 1 || arg.type === 2 || (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) === 0;
|
|
11895
11927
|
}
|
|
11896
11928
|
function display(type) {
|
|
11897
|
-
const names = (v, fn) => (0,
|
|
11929
|
+
const names = (v, fn) => (0, import_chunk_OASVKTK5.map)(v, fn).sort().filter((s, i, arr) => !i || s !== arr[i - 1]).join(" or ");
|
|
11898
11930
|
const parts = [];
|
|
11899
11931
|
const displayOne = (tv) => {
|
|
11900
11932
|
switch (tv.type) {
|
|
@@ -12095,7 +12127,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12095
12127
|
init_data_flow();
|
|
12096
12128
|
init_api();
|
|
12097
12129
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
12098
|
-
(0,
|
|
12130
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
12099
12131
|
init_interp();
|
|
12100
12132
|
init_union_type();
|
|
12101
12133
|
init_intersection_type();
|
|
@@ -12155,7 +12187,7 @@ function couldBeHelper(a, b, shallow) {
|
|
|
12155
12187
|
262144
|
|
12156
12188
|
/* Typedef */
|
|
12157
12189
|
);
|
|
12158
|
-
return typedef && (0,
|
|
12190
|
+
return typedef && (0, import_chunk_OASVKTK5.some)(typedef, (td) => {
|
|
12159
12191
|
if (!td.resolvedType) {
|
|
12160
12192
|
throw new Error(`No resolved type for ${td.fullName} in 'couldBe'`);
|
|
12161
12193
|
}
|
|
@@ -12227,15 +12259,15 @@ function couldBeValue(pair, shallow) {
|
|
|
12227
12259
|
}
|
|
12228
12260
|
case 4096:
|
|
12229
12261
|
case 8192: {
|
|
12230
|
-
return (0,
|
|
12262
|
+
return (0, import_chunk_OASVKTK5.some)(
|
|
12231
12263
|
pair.avalue,
|
|
12232
|
-
(sna) => (0,
|
|
12264
|
+
(sna) => (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => sna === snb)
|
|
12233
12265
|
);
|
|
12234
12266
|
}
|
|
12235
12267
|
case 16384: {
|
|
12236
|
-
return (0,
|
|
12268
|
+
return (0, import_chunk_OASVKTK5.some)(pair.avalue, (sna) => {
|
|
12237
12269
|
const superA = getSuperClasses(sna);
|
|
12238
|
-
return (0,
|
|
12270
|
+
return (0, import_chunk_OASVKTK5.some)(pair.bvalue, (snb) => {
|
|
12239
12271
|
if (sna === snb || superA && superA.has(snb)) {
|
|
12240
12272
|
return true;
|
|
12241
12273
|
}
|
|
@@ -12268,7 +12300,7 @@ var init_could_be = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12268
12300
|
"use strict";
|
|
12269
12301
|
init_api();
|
|
12270
12302
|
init_data_flow();
|
|
12271
|
-
(0,
|
|
12303
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
12272
12304
|
init_types();
|
|
12273
12305
|
}
|
|
12274
12306
|
});
|
|
@@ -12375,7 +12407,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12375
12407
|
}
|
|
12376
12408
|
addAnt(curState.partiallyAnticipated, key, node);
|
|
12377
12409
|
if (logThisRun) {
|
|
12378
|
-
(0,
|
|
12410
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
12379
12411
|
` antrefs: ${curState.partiallyAnticipated.get(key) !== false} ${curState.anticipated.get(key) !== false}`
|
|
12380
12412
|
);
|
|
12381
12413
|
}
|
|
@@ -12398,7 +12430,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12398
12430
|
const curState = cloneState(blockStates[top.order]);
|
|
12399
12431
|
if (logThisRun) {
|
|
12400
12432
|
printBlockHeader(top);
|
|
12401
|
-
curState.dead.forEach((decl) => (0,
|
|
12433
|
+
curState.dead.forEach((decl) => (0, import_chunk_OASVKTK5.log)(` - anticipated: ${tsKey(decl)}`));
|
|
12402
12434
|
}
|
|
12403
12435
|
if (top.events) {
|
|
12404
12436
|
for (let i = top.events.length; i--; ) {
|
|
@@ -12410,12 +12442,12 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12410
12442
|
case "ref":
|
|
12411
12443
|
if (isTypeStateKey(event.decl)) {
|
|
12412
12444
|
if (logThisRun) {
|
|
12413
|
-
(0,
|
|
12445
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
12414
12446
|
describeEvent(event).then(
|
|
12415
12447
|
(eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
|
|
12416
12448
|
)
|
|
12417
12449
|
);
|
|
12418
|
-
(0,
|
|
12450
|
+
(0, import_chunk_OASVKTK5.log)(` kill => ${tsKey(event.decl)}`);
|
|
12419
12451
|
}
|
|
12420
12452
|
copyPropRef(curState, event.decl, event.node);
|
|
12421
12453
|
curState.dead.delete(event.decl);
|
|
@@ -12424,7 +12456,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12424
12456
|
case "def":
|
|
12425
12457
|
if (isTypeStateKey(event.decl) && (event.node.type !== "VariableDeclarator" || event.node.init)) {
|
|
12426
12458
|
if (logThisRun) {
|
|
12427
|
-
(0,
|
|
12459
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
12428
12460
|
describeEvent(event).then(
|
|
12429
12461
|
(eventStr) => `${eventStr} (${sourceLocation(event.node.loc)})`
|
|
12430
12462
|
)
|
|
@@ -12440,7 +12472,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12440
12472
|
const pant = curState.partiallyAnticipated.get(event.decl);
|
|
12441
12473
|
if (pant) {
|
|
12442
12474
|
if (logThisRun) {
|
|
12443
|
-
(0,
|
|
12475
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
12444
12476
|
` is copy-prop-candidate ${curState.anticipated?.get(event.decl) === pant}`
|
|
12445
12477
|
);
|
|
12446
12478
|
}
|
|
@@ -12472,7 +12504,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12472
12504
|
if (assignNode) {
|
|
12473
12505
|
curState.dead.add(event.decl);
|
|
12474
12506
|
if (logThisRun) {
|
|
12475
|
-
(0,
|
|
12507
|
+
(0, import_chunk_OASVKTK5.log)(` anticipated => ${tsKey(event.decl)}`);
|
|
12476
12508
|
}
|
|
12477
12509
|
} else if (event.node.type === "UpdateExpression") {
|
|
12478
12510
|
copyPropRef(curState, event.decl, event.node.argument);
|
|
@@ -12483,7 +12515,7 @@ function findDeadStores(func, graph, nodeEquivs, findCopyPropCandidates, logThis
|
|
|
12483
12515
|
if (isTypeStateKey(event.decl)) {
|
|
12484
12516
|
curState.dead.add(event.decl);
|
|
12485
12517
|
if (logThisRun) {
|
|
12486
|
-
(0,
|
|
12518
|
+
(0, import_chunk_OASVKTK5.log)(` anticipated => ${tsKey(event.decl)}`);
|
|
12487
12519
|
}
|
|
12488
12520
|
}
|
|
12489
12521
|
break;
|
|
@@ -12546,9 +12578,9 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
|
|
|
12546
12578
|
if (!deadStores.size)
|
|
12547
12579
|
return { changes: false, copyPropStores };
|
|
12548
12580
|
if (logThisRun) {
|
|
12549
|
-
(0,
|
|
12581
|
+
(0, import_chunk_OASVKTK5.log)("====== Dead Stores =====");
|
|
12550
12582
|
deadStores.forEach(
|
|
12551
|
-
(dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0,
|
|
12583
|
+
(dead) => (dead.type === "AssignmentExpression" || dead.type === "UpdateExpression" || dead.type === "VariableDeclarator") && (0, import_chunk_OASVKTK5.log)(
|
|
12552
12584
|
formatAst(dead).then(
|
|
12553
12585
|
(deadStr) => `${deadStr} (${sourceLocation(dead.loc)})`
|
|
12554
12586
|
)
|
|
@@ -12603,7 +12635,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12603
12635
|
init_control_flow();
|
|
12604
12636
|
init_data_flow();
|
|
12605
12637
|
init_inliner();
|
|
12606
|
-
(0,
|
|
12638
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
12607
12639
|
init_minimize_locals();
|
|
12608
12640
|
init_type_flow_util();
|
|
12609
12641
|
}
|
|
@@ -12968,13 +13000,13 @@ function typeStateEntry(value2, key) {
|
|
|
12968
13000
|
return `${tsKey(key)} = ${display(value2.curType)}`;
|
|
12969
13001
|
}
|
|
12970
13002
|
function printBlockState(block, state, indent = "") {
|
|
12971
|
-
(0,
|
|
13003
|
+
(0, import_chunk_OASVKTK5.log)(indent + "State:");
|
|
12972
13004
|
if (!state) {
|
|
12973
|
-
(0,
|
|
13005
|
+
(0, import_chunk_OASVKTK5.log)(indent + "Not visited!");
|
|
12974
13006
|
return;
|
|
12975
13007
|
}
|
|
12976
13008
|
state.map.forEach((value2, key) => {
|
|
12977
|
-
(0,
|
|
13009
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
12978
13010
|
`${indent} - ${typeStateEntry(value2, key)}${value2.equivSet ? ` [(${Array.from(value2.equivSet).map(tsKey).join(", ")})]` : ""}`
|
|
12979
13011
|
);
|
|
12980
13012
|
});
|
|
@@ -13124,7 +13156,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13124
13156
|
const [objDecls, trueDecls] = findObjectDeclsByProperty(
|
|
13125
13157
|
istate.state,
|
|
13126
13158
|
cur,
|
|
13127
|
-
me
|
|
13159
|
+
me.property
|
|
13128
13160
|
);
|
|
13129
13161
|
if (!objDecls) {
|
|
13130
13162
|
return null;
|
|
@@ -13181,7 +13213,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13181
13213
|
type: 0
|
|
13182
13214
|
/* Never */
|
|
13183
13215
|
};
|
|
13184
|
-
(0,
|
|
13216
|
+
(0, import_chunk_OASVKTK5.forEach)(avalue, (v) => unionInto(n, v));
|
|
13185
13217
|
next = n;
|
|
13186
13218
|
}
|
|
13187
13219
|
} else {
|
|
@@ -13286,7 +13318,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13286
13318
|
}
|
|
13287
13319
|
if (!isStatic && selfClassDecl) {
|
|
13288
13320
|
const baseObj = getObjectValue(baseElem.type);
|
|
13289
|
-
if (baseObj && baseObj.klass.type === 16384 && (0,
|
|
13321
|
+
if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_OASVKTK5.some)(
|
|
13290
13322
|
baseObj.klass.value,
|
|
13291
13323
|
(cls) => cls === selfClassDecl || getSuperClasses(cls)?.has(selfClassDecl) || getSuperClasses(selfClassDecl)?.has(cls) || false
|
|
13292
13324
|
)) {
|
|
@@ -13331,7 +13363,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13331
13363
|
return [cur, updateAny];
|
|
13332
13364
|
}
|
|
13333
13365
|
function typeConstraint(decls, blockState) {
|
|
13334
|
-
return (0,
|
|
13366
|
+
return (0, import_chunk_OASVKTK5.reduce)(
|
|
13335
13367
|
decls,
|
|
13336
13368
|
(cur, decl) => {
|
|
13337
13369
|
if (decl.type === "Identifier" || decl.type === "BinaryExpression") {
|
|
@@ -13427,9 +13459,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13427
13459
|
stack: [],
|
|
13428
13460
|
func
|
|
13429
13461
|
};
|
|
13430
|
-
const modifiableDecl = (decls, callees) => (0,
|
|
13462
|
+
const modifiableDecl = (decls, callees) => (0, import_chunk_OASVKTK5.some)(
|
|
13431
13463
|
decls,
|
|
13432
|
-
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0,
|
|
13464
|
+
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl) && (!callees || (0, import_chunk_OASVKTK5.some)(callees, (callee) => functionMayModify(state, callee, decl)))
|
|
13433
13465
|
);
|
|
13434
13466
|
const mergeSuccState = (top, curState) => {
|
|
13435
13467
|
top.succs?.forEach((succ) => {
|
|
@@ -13438,7 +13470,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13438
13470
|
}
|
|
13439
13471
|
if (mergeTypeState(blockStates, succ.order, curState, nodeCopyProp)) {
|
|
13440
13472
|
if (logThisRun) {
|
|
13441
|
-
(0,
|
|
13473
|
+
(0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${succ.order}`);
|
|
13442
13474
|
}
|
|
13443
13475
|
queue.enqueue(succ);
|
|
13444
13476
|
}
|
|
@@ -13448,7 +13480,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13448
13480
|
const calleeObj = getStateType(curState, calleeObjDecl);
|
|
13449
13481
|
let calleeResult = null;
|
|
13450
13482
|
let effectFree = true;
|
|
13451
|
-
(0,
|
|
13483
|
+
(0, import_chunk_OASVKTK5.forEach)(callees, (callee) => {
|
|
13452
13484
|
const info = sysCallInfo(istate.state, callee);
|
|
13453
13485
|
if (!info) {
|
|
13454
13486
|
effectFree = false;
|
|
@@ -13725,7 +13757,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13725
13757
|
});
|
|
13726
13758
|
} else {
|
|
13727
13759
|
if (logThisRun) {
|
|
13728
|
-
(0,
|
|
13760
|
+
(0, import_chunk_OASVKTK5.log)(` Flow (true): merge to ${trueSucc.order || -1}`);
|
|
13729
13761
|
printBlockState(top, sTrue || curState, " >true ");
|
|
13730
13762
|
}
|
|
13731
13763
|
if (mergeTypeState(
|
|
@@ -13735,7 +13767,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13735
13767
|
nodeCopyProp
|
|
13736
13768
|
)) {
|
|
13737
13769
|
if (logThisRun) {
|
|
13738
|
-
(0,
|
|
13770
|
+
(0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${trueSucc.order}`);
|
|
13739
13771
|
}
|
|
13740
13772
|
queue.enqueue(trueSucc);
|
|
13741
13773
|
}
|
|
@@ -13747,7 +13779,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13747
13779
|
});
|
|
13748
13780
|
} else {
|
|
13749
13781
|
if (logThisRun) {
|
|
13750
|
-
(0,
|
|
13782
|
+
(0, import_chunk_OASVKTK5.log)(` Flow (false): merge to: ${falseSucc.order || -1}`);
|
|
13751
13783
|
printBlockState(top, sFalse || curState, " >false ");
|
|
13752
13784
|
}
|
|
13753
13785
|
if (mergeTypeState(
|
|
@@ -13757,7 +13789,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13757
13789
|
nodeCopyProp
|
|
13758
13790
|
)) {
|
|
13759
13791
|
if (logThisRun) {
|
|
13760
|
-
(0,
|
|
13792
|
+
(0, import_chunk_OASVKTK5.log)(`re-merge: ${top.order} -> ${falseSucc.order}`);
|
|
13761
13793
|
}
|
|
13762
13794
|
queue.enqueue(falseSucc);
|
|
13763
13795
|
}
|
|
@@ -13832,7 +13864,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13832
13864
|
}
|
|
13833
13865
|
}
|
|
13834
13866
|
if (logThisRun) {
|
|
13835
|
-
(0,
|
|
13867
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
13836
13868
|
describeEvent(event).then(
|
|
13837
13869
|
(eventStr) => ` ${eventStr} == ${display(curEntry.curType)}`
|
|
13838
13870
|
)
|
|
@@ -13842,7 +13874,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13842
13874
|
}
|
|
13843
13875
|
case "mod": {
|
|
13844
13876
|
if (logThisRun) {
|
|
13845
|
-
(0,
|
|
13877
|
+
(0, import_chunk_OASVKTK5.log)(describeEvent(event).then((eventStr) => ` ${eventStr}`));
|
|
13846
13878
|
}
|
|
13847
13879
|
modInterference(curState, event, true, (callees, calleeObj) => {
|
|
13848
13880
|
clearRelatedCopyPropEvents(curState, null, nodeCopyProp);
|
|
@@ -13858,7 +13890,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13858
13890
|
);
|
|
13859
13891
|
}
|
|
13860
13892
|
}
|
|
13861
|
-
if (nodeCopyProp.size && event.node.type === "CallExpression" && (0,
|
|
13893
|
+
if (nodeCopyProp.size && event.node.type === "CallExpression" && (0, import_chunk_OASVKTK5.some)(callees, (callee) => inlineRequested(state, callee))) {
|
|
13862
13894
|
event.node.arguments.forEach((arg) => {
|
|
13863
13895
|
const def = nodeCopyProp.get(arg);
|
|
13864
13896
|
if (def && nodeCopyProp.get(def) !== false) {
|
|
@@ -13870,7 +13902,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13870
13902
|
let calleeEffects;
|
|
13871
13903
|
curState.map.forEach((tsv, decl) => {
|
|
13872
13904
|
let type = tsv.curType;
|
|
13873
|
-
if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0,
|
|
13905
|
+
if ((type.value == null || !(type.type & (32768 | 512 | 1024))) && !(0, import_chunk_OASVKTK5.some)(decl, (d) => d.type === "VariableDeclarator" && !isLocal(d))) {
|
|
13874
13906
|
return;
|
|
13875
13907
|
}
|
|
13876
13908
|
if (modifiableDecl(decl, callees)) {
|
|
@@ -13885,7 +13917,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13885
13917
|
curState.map.set(decl, {
|
|
13886
13918
|
curType: typeConstraint(decl, curState)
|
|
13887
13919
|
});
|
|
13888
|
-
} else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0,
|
|
13920
|
+
} else if (type.type & (32768 | 512 | 1024) && (calleeEffects == null ? calleeEffects = !callees || !(0, import_chunk_OASVKTK5.every)(callees, (callee) => callee.info === false) : calleeEffects)) {
|
|
13889
13921
|
if (type.value != null && type.type & 32768) {
|
|
13890
13922
|
const odata = getObjectValue(tsv.curType);
|
|
13891
13923
|
if (odata?.obj) {
|
|
@@ -13953,7 +13985,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13953
13985
|
2
|
|
13954
13986
|
/* Reassign */
|
|
13955
13987
|
);
|
|
13956
|
-
(0,
|
|
13988
|
+
(0, import_chunk_OASVKTK5.some)(event.decl, (decl) => {
|
|
13957
13989
|
if (decl.type !== "VariableDeclarator" || decl.node.kind !== "var" || !isClassVariable(decl)) {
|
|
13958
13990
|
return false;
|
|
13959
13991
|
}
|
|
@@ -13961,7 +13993,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13961
13993
|
if (affected) {
|
|
13962
13994
|
const objType = typeFromTypeStateNodes(
|
|
13963
13995
|
istate.state,
|
|
13964
|
-
(0,
|
|
13996
|
+
(0, import_chunk_OASVKTK5.map)(
|
|
13965
13997
|
event.decl,
|
|
13966
13998
|
(decl2) => decl2.type === "VariableDeclarator" && decl2.stack[decl2.stack.length - 1].sn
|
|
13967
13999
|
).filter(
|
|
@@ -13982,7 +14014,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13982
14014
|
});
|
|
13983
14015
|
if (wasComputedDecl) {
|
|
13984
14016
|
curState.map.forEach((value2, decls) => {
|
|
13985
|
-
if ((0,
|
|
14017
|
+
if ((0, import_chunk_OASVKTK5.some)(
|
|
13986
14018
|
decls,
|
|
13987
14019
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && !isLocal(decl)
|
|
13988
14020
|
)) {
|
|
@@ -14028,14 +14060,14 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14028
14060
|
}
|
|
14029
14061
|
if (!copyPropCandidate.ant || // If the ref isn't anticipated, we can't propagate it
|
|
14030
14062
|
// in case it has side effects.
|
|
14031
|
-
(0,
|
|
14063
|
+
(0, import_chunk_OASVKTK5.some)(
|
|
14032
14064
|
event2.calleeDecl,
|
|
14033
14065
|
(callee) => callee.type === "FunctionDeclaration" && inlineRequested(state, callee)
|
|
14034
14066
|
)) {
|
|
14035
14067
|
return false;
|
|
14036
14068
|
}
|
|
14037
14069
|
}
|
|
14038
|
-
if (!event2.decl || isTypeStateKey(event2.decl) && (0,
|
|
14070
|
+
if (!event2.decl || isTypeStateKey(event2.decl) && (0, import_chunk_OASVKTK5.some)(
|
|
14039
14071
|
event2.decl,
|
|
14040
14072
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" || decl.type === "BinaryExpression" || decl.type === "Identifier"
|
|
14041
14073
|
)) {
|
|
@@ -14074,13 +14106,13 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14074
14106
|
}
|
|
14075
14107
|
}
|
|
14076
14108
|
if (uninitClassDecls?.size) {
|
|
14077
|
-
(0,
|
|
14109
|
+
(0, import_chunk_OASVKTK5.forEach)(
|
|
14078
14110
|
event.decl,
|
|
14079
14111
|
(decl) => uninitClassDecls.has(decl) && curState.inited?.add(decl)
|
|
14080
14112
|
);
|
|
14081
14113
|
}
|
|
14082
14114
|
if (logThisRun) {
|
|
14083
|
-
(0,
|
|
14115
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14084
14116
|
describeEvent(event).then(
|
|
14085
14117
|
(eventStr) => ` ${eventStr} := ${display(type)}`
|
|
14086
14118
|
)
|
|
@@ -14098,7 +14130,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14098
14130
|
);
|
|
14099
14131
|
}
|
|
14100
14132
|
if (logThisRun) {
|
|
14101
|
-
(0,
|
|
14133
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14102
14134
|
describeEvent(event).then(
|
|
14103
14135
|
(eventStr) => ` ${eventStr} : ${!Array.isArray(event.left) && event.left.type === "MemberDecl" ? `${display(
|
|
14104
14136
|
curState.map.get(event.left.base)?.curType || {
|
|
@@ -14156,8 +14188,8 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14156
14188
|
}
|
|
14157
14189
|
if (!successorsHandled) {
|
|
14158
14190
|
if (logThisRun) {
|
|
14159
|
-
(0,
|
|
14160
|
-
` merge to: ${(0,
|
|
14191
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14192
|
+
` merge to: ${(0, import_chunk_OASVKTK5.map)(
|
|
14161
14193
|
top.succs,
|
|
14162
14194
|
(succ) => succ.order || -1
|
|
14163
14195
|
).join(", ")}`
|
|
@@ -14188,17 +14220,17 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14188
14220
|
);
|
|
14189
14221
|
printBlockTrailer(block);
|
|
14190
14222
|
});
|
|
14191
|
-
(0,
|
|
14223
|
+
(0, import_chunk_OASVKTK5.log)("====== TypeMap =====");
|
|
14192
14224
|
typeMap.forEach((value2, key) => {
|
|
14193
|
-
(0,
|
|
14225
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14194
14226
|
formatAst(key).then(
|
|
14195
14227
|
(keyStr) => `${keyStr} = ${display(value2)} ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
|
|
14196
14228
|
)
|
|
14197
14229
|
);
|
|
14198
14230
|
});
|
|
14199
|
-
(0,
|
|
14231
|
+
(0, import_chunk_OASVKTK5.log)("====== EquivMap =====");
|
|
14200
14232
|
nodeEquivs.forEach((value2, key) => {
|
|
14201
|
-
(0,
|
|
14233
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14202
14234
|
formatAst(key).then(
|
|
14203
14235
|
(keyStr) => `${keyStr} = [${value2.equiv.map(
|
|
14204
14236
|
(equiv) => tsKey(equiv)
|
|
@@ -14206,7 +14238,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14206
14238
|
)
|
|
14207
14239
|
);
|
|
14208
14240
|
});
|
|
14209
|
-
(0,
|
|
14241
|
+
(0, import_chunk_OASVKTK5.log)("====== Copy Prop =====");
|
|
14210
14242
|
nodeCopyProp.forEach((value2, key) => {
|
|
14211
14243
|
(0, import_node_assert3.default)(value2 !== false);
|
|
14212
14244
|
if (key.type === "VariableDeclarator" || key.type === "AssignmentExpression") {
|
|
@@ -14216,7 +14248,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14216
14248
|
value2.type === "VariableDeclarator" && value2.init || value2.type === "AssignmentExpression"
|
|
14217
14249
|
);
|
|
14218
14250
|
const node = value2.type === "VariableDeclarator" ? value2.init : value2.right;
|
|
14219
|
-
(0,
|
|
14251
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14220
14252
|
formatAst(key).then(
|
|
14221
14253
|
(keyStr) => formatAstLongLines(node).then(
|
|
14222
14254
|
(nodeStr) => `${keyStr} = [${nodeStr}] ${key.loc && key.loc.source ? ` (${sourceLocation(key.loc)})` : ""}`
|
|
@@ -14226,10 +14258,10 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14226
14258
|
});
|
|
14227
14259
|
}
|
|
14228
14260
|
if (logThisRun) {
|
|
14229
|
-
(0,
|
|
14261
|
+
(0, import_chunk_OASVKTK5.log)(formatAstLongLines(func.node));
|
|
14230
14262
|
if (copyPropStores) {
|
|
14231
14263
|
copyPropStores.forEach(({ ref, ant }, node) => {
|
|
14232
|
-
(0,
|
|
14264
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14233
14265
|
formatAstLongLines(node).then(
|
|
14234
14266
|
(nodeStr) => `copy-prop-store: ${nodeStr}${ant ? "!" : ""} => ${nodeCopyProp.get(node) !== ref ? "Failed" : "Success"}`
|
|
14235
14267
|
)
|
|
@@ -14243,9 +14275,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14243
14275
|
}
|
|
14244
14276
|
if (logThisRun) {
|
|
14245
14277
|
if (selfAssignments.size) {
|
|
14246
|
-
(0,
|
|
14278
|
+
(0, import_chunk_OASVKTK5.log)("====== Self Assignments =====");
|
|
14247
14279
|
selfAssignments.forEach(
|
|
14248
|
-
(self) => (0,
|
|
14280
|
+
(self) => (0, import_chunk_OASVKTK5.log)(
|
|
14249
14281
|
formatAst(self).then(
|
|
14250
14282
|
(selfStr) => `${selfStr} (${sourceLocation(self.loc)})`
|
|
14251
14283
|
)
|
|
@@ -14310,7 +14342,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14310
14342
|
if (copyNode) {
|
|
14311
14343
|
if (node.type === "AssignmentExpression") {
|
|
14312
14344
|
if (logThisRun) {
|
|
14313
|
-
(0,
|
|
14345
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14314
14346
|
formatAstLongLines(node).then(
|
|
14315
14347
|
(nodeStr) => `Killing copy-prop assignment ${nodeStr}`
|
|
14316
14348
|
)
|
|
@@ -14325,7 +14357,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14325
14357
|
if (node.type === "VariableDeclarator") {
|
|
14326
14358
|
(0, import_node_assert3.default)(node.init);
|
|
14327
14359
|
if (logThisRun) {
|
|
14328
|
-
(0,
|
|
14360
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14329
14361
|
formatAstLongLines(node).then(
|
|
14330
14362
|
(nodeStr) => `Killing copy-prop variable initialization ${nodeStr}`
|
|
14331
14363
|
)
|
|
@@ -14346,7 +14378,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14346
14378
|
right: copyNode.right
|
|
14347
14379
|
};
|
|
14348
14380
|
if (logThisRun) {
|
|
14349
|
-
(0,
|
|
14381
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14350
14382
|
formatAstLongLines(node).then(
|
|
14351
14383
|
(nodeStr) => formatAstLongLines(replacement2).then(
|
|
14352
14384
|
(repStr) => `copy-prop ${nodeStr} => ${repStr}`
|
|
@@ -14359,7 +14391,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14359
14391
|
const init = copyNode.init;
|
|
14360
14392
|
(0, import_node_assert3.default)(init);
|
|
14361
14393
|
if (logThisRun) {
|
|
14362
|
-
(0,
|
|
14394
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14363
14395
|
formatAstLongLines(node).then(
|
|
14364
14396
|
(nodeStr) => formatAstLongLines(init).then(
|
|
14365
14397
|
(initStr) => `copy-prop ${nodeStr} => ${initStr}`
|
|
@@ -14373,7 +14405,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14373
14405
|
}
|
|
14374
14406
|
if (selfAssignments.has(node)) {
|
|
14375
14407
|
if (logThisRun) {
|
|
14376
|
-
(0,
|
|
14408
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14377
14409
|
formatAst(node).then(
|
|
14378
14410
|
(nodeStr) => `Deleting self assignment: ${nodeStr} (${sourceLocation(
|
|
14379
14411
|
node.loc
|
|
@@ -14417,7 +14449,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14417
14449
|
}, curInfo);
|
|
14418
14450
|
if (rep === curInfo)
|
|
14419
14451
|
return null;
|
|
14420
|
-
const name = (0,
|
|
14452
|
+
const name = (0, import_chunk_OASVKTK5.reduce)(
|
|
14421
14453
|
rep.decl,
|
|
14422
14454
|
(cur, decl) => decl.type === "VariableDeclarator" ? decl.name : cur,
|
|
14423
14455
|
null
|
|
@@ -14425,7 +14457,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14425
14457
|
if (!name)
|
|
14426
14458
|
return null;
|
|
14427
14459
|
if (logThisRun) {
|
|
14428
|
-
(0,
|
|
14460
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14429
14461
|
formatAst(node).then(
|
|
14430
14462
|
(nodeStr) => `Replacing ${nodeStr} with ${name} at ${sourceLocation(
|
|
14431
14463
|
node.loc
|
|
@@ -14556,7 +14588,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14556
14588
|
init_type_flow_util();
|
|
14557
14589
|
init_types();
|
|
14558
14590
|
init_union_type();
|
|
14559
|
-
(0,
|
|
14591
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
14560
14592
|
logging = true;
|
|
14561
14593
|
missingNullWorkaround = true;
|
|
14562
14594
|
}
|
|
@@ -14608,9 +14640,9 @@ function minimizeLocals(state, func) {
|
|
|
14608
14640
|
if (!didMerge)
|
|
14609
14641
|
return;
|
|
14610
14642
|
if (logThisRun) {
|
|
14611
|
-
(0,
|
|
14643
|
+
(0, import_chunk_OASVKTK5.log)(`>>> Merging locals in ${func.fullName}`);
|
|
14612
14644
|
merge.forEach(
|
|
14613
|
-
(merged) => merged.length > 1 && (0,
|
|
14645
|
+
(merged) => merged.length > 1 && (0, import_chunk_OASVKTK5.log)(` - merging ${merged.map((k) => tsKey(k)).join(" | ")}`)
|
|
14614
14646
|
);
|
|
14615
14647
|
}
|
|
14616
14648
|
const remap = /* @__PURE__ */ new Map();
|
|
@@ -14880,7 +14912,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14880
14912
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
14881
14913
|
init_control_flow();
|
|
14882
14914
|
init_type_flow();
|
|
14883
|
-
(0,
|
|
14915
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
14884
14916
|
init_variable_renamer();
|
|
14885
14917
|
init_type_flow_util();
|
|
14886
14918
|
}
|
|
@@ -14891,12 +14923,12 @@ function logAntState(s, decl) {
|
|
|
14891
14923
|
defs2++;
|
|
14892
14924
|
return defs2;
|
|
14893
14925
|
}, 0);
|
|
14894
|
-
(0,
|
|
14926
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14895
14927
|
declFullName(decl).then(
|
|
14896
14928
|
(declStr) => ` - ${declStr}: ${candidateCost(s)} bytes, ${s.ant.size - defs} refs, ${defs} defs, ${s.live ? "" : "!"}live, ${s.isIsolated ? "" : "!"}isolated`
|
|
14897
14929
|
)
|
|
14898
14930
|
);
|
|
14899
|
-
(0,
|
|
14931
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
14900
14932
|
` - members: ${Array.from(s.members).map(([block, live]) => block.order + (live ? "t" : "f")).join(", ")}`
|
|
14901
14933
|
);
|
|
14902
14934
|
}
|
|
@@ -14913,7 +14945,7 @@ async function sizeBasedPRE(state, func) {
|
|
|
14913
14945
|
const candidates = computeAttributes(state, head);
|
|
14914
14946
|
if (candidates) {
|
|
14915
14947
|
if (logging2) {
|
|
14916
|
-
(0,
|
|
14948
|
+
(0, import_chunk_OASVKTK5.log)(`Found ${candidates.size} candidates in ${func.fullName}`);
|
|
14917
14949
|
logAntDecls(candidates);
|
|
14918
14950
|
}
|
|
14919
14951
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
@@ -14973,7 +15005,7 @@ function buildPREGraph(state, func) {
|
|
|
14973
15005
|
const result = buildDataFlowGraph(
|
|
14974
15006
|
state,
|
|
14975
15007
|
func,
|
|
14976
|
-
(literal) => refCost(literal) > LocalRefCost,
|
|
15008
|
+
(literal) => !state.config?.preSkipLiterals && refCost(literal) > LocalRefCost,
|
|
14977
15009
|
true,
|
|
14978
15010
|
false
|
|
14979
15011
|
);
|
|
@@ -15006,7 +15038,7 @@ function buildPREGraph(state, func) {
|
|
|
15006
15038
|
const event = block.events[i];
|
|
15007
15039
|
switch (event.type) {
|
|
15008
15040
|
case "ref":
|
|
15009
|
-
if ((0,
|
|
15041
|
+
if ((0, import_chunk_OASVKTK5.some)(
|
|
15010
15042
|
event.decl,
|
|
15011
15043
|
(decl) => decl.type === "Literal" || decl.type === "VariableDeclarator" && decl.node.kind === "const"
|
|
15012
15044
|
)) {
|
|
@@ -15024,7 +15056,7 @@ function buildPREGraph(state, func) {
|
|
|
15024
15056
|
defs.add(event.decl);
|
|
15025
15057
|
break;
|
|
15026
15058
|
case "mod":
|
|
15027
|
-
if (event.callees && (0,
|
|
15059
|
+
if (event.callees && (0, import_chunk_OASVKTK5.every)(event.callees, (callee) => callee.info === false)) {
|
|
15028
15060
|
block.events.splice(i, 1);
|
|
15029
15061
|
break;
|
|
15030
15062
|
}
|
|
@@ -15183,21 +15215,21 @@ function computeAttributes(state, head) {
|
|
|
15183
15215
|
});
|
|
15184
15216
|
if (logging2) {
|
|
15185
15217
|
order.forEach((block) => {
|
|
15186
|
-
(0,
|
|
15218
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
15187
15219
|
block.order,
|
|
15188
15220
|
`(${block.node ? block.node.loc?.start.line : "??"})`,
|
|
15189
15221
|
`Preds: ${(block.preds || []).map((block2) => block2.order).join(", ")}`
|
|
15190
15222
|
);
|
|
15191
15223
|
if (block.events) {
|
|
15192
15224
|
block.events.forEach(
|
|
15193
|
-
(event) => event.type !== "exn" && (0,
|
|
15225
|
+
(event) => event.type !== "exn" && (0, import_chunk_OASVKTK5.log)(
|
|
15194
15226
|
Promise.resolve(
|
|
15195
15227
|
event.decl ? declFullName(event.decl) : event.node ? formatAst(event.node) : "??"
|
|
15196
15228
|
).then((eventDetails) => ` ${event.type}: ${eventDetails}`)
|
|
15197
15229
|
)
|
|
15198
15230
|
);
|
|
15199
15231
|
}
|
|
15200
|
-
(0,
|
|
15232
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
15201
15233
|
`Succs: ${(block.succs || []).map((block2) => block2.order).join(", ")} ExSucc: ${block.exsucc ? block.exsucc.order : ""}`
|
|
15202
15234
|
);
|
|
15203
15235
|
});
|
|
@@ -15265,7 +15297,7 @@ function computeAttributes(state, head) {
|
|
|
15265
15297
|
}
|
|
15266
15298
|
case "mod": {
|
|
15267
15299
|
curState.forEach((candidates, decls) => {
|
|
15268
|
-
if ((0,
|
|
15300
|
+
if ((0, import_chunk_OASVKTK5.some)(
|
|
15269
15301
|
decls,
|
|
15270
15302
|
(decl) => decl.type === "VariableDeclarator" && decl.node.kind === "var" && candidates.live && (!event.callees || event.callees.some(
|
|
15271
15303
|
(callee) => functionMayModify(state, callee, decl)
|
|
@@ -15307,7 +15339,7 @@ function computeAttributes(state, head) {
|
|
|
15307
15339
|
}
|
|
15308
15340
|
blockStates[top.order] = curState;
|
|
15309
15341
|
if (logging2) {
|
|
15310
|
-
(0,
|
|
15342
|
+
(0, import_chunk_OASVKTK5.log)(`Updated block ${top.order}`);
|
|
15311
15343
|
logAntDecls(curState);
|
|
15312
15344
|
}
|
|
15313
15345
|
if (top.preds) {
|
|
@@ -15409,7 +15441,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15409
15441
|
}
|
|
15410
15442
|
const name = declMap.get(event.decl);
|
|
15411
15443
|
if (!name) {
|
|
15412
|
-
throw new
|
|
15444
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
15413
15445
|
formatAst(node).then(
|
|
15414
15446
|
(targetStr) => `No replacement found for "${targetStr}"`
|
|
15415
15447
|
)
|
|
@@ -15431,7 +15463,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15431
15463
|
const target = node.type === "AssignmentExpression" ? node.left : node.argument;
|
|
15432
15464
|
const name = declMap.get(event.decl);
|
|
15433
15465
|
if (!name) {
|
|
15434
|
-
throw new
|
|
15466
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
15435
15467
|
formatAst(target).then(
|
|
15436
15468
|
(targetStr) => `No replacement found for "${targetStr}"`
|
|
15437
15469
|
)
|
|
@@ -15494,14 +15526,14 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15494
15526
|
const decl = event.decl;
|
|
15495
15527
|
const name = declMap.get(decl);
|
|
15496
15528
|
if (!name) {
|
|
15497
|
-
throw new
|
|
15529
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
15498
15530
|
declFullName(decl).then(
|
|
15499
15531
|
(declStr) => `No replacement found for "${declStr}"`
|
|
15500
15532
|
)
|
|
15501
15533
|
);
|
|
15502
15534
|
}
|
|
15503
15535
|
if (!event.id) {
|
|
15504
|
-
throw new
|
|
15536
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
15505
15537
|
declFullName(decl).then(
|
|
15506
15538
|
(declStr) => `Missing id for mod event for "${declStr}"`
|
|
15507
15539
|
)
|
|
@@ -15566,7 +15598,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
15566
15598
|
init_data_flow();
|
|
15567
15599
|
init_function_info();
|
|
15568
15600
|
init_minimize_locals();
|
|
15569
|
-
(0,
|
|
15601
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
15570
15602
|
logging2 = false;
|
|
15571
15603
|
LocalRefCost = 2;
|
|
15572
15604
|
}
|
|
@@ -15937,7 +15969,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15937
15969
|
break;
|
|
15938
15970
|
}
|
|
15939
15971
|
const id = node.right.argument;
|
|
15940
|
-
if ((0,
|
|
15972
|
+
if ((0, import_chunk_OASVKTK5.every)(left.value.value, (m) => {
|
|
15941
15973
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(m.decls, id.name))
|
|
15942
15974
|
return false;
|
|
15943
15975
|
return istate.state.lookup({
|
|
@@ -16383,7 +16415,7 @@ var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
16383
16415
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
16384
16416
|
init_inliner();
|
|
16385
16417
|
init_type_flow();
|
|
16386
|
-
(0,
|
|
16418
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
16387
16419
|
init_interp();
|
|
16388
16420
|
init_interp_binary();
|
|
16389
16421
|
init_types();
|
|
@@ -16660,7 +16692,7 @@ function getFileSources(fnMap) {
|
|
|
16660
16692
|
function getFileASTs(fnMap) {
|
|
16661
16693
|
return getFileSources(fnMap).then(
|
|
16662
16694
|
() => Object.entries(fnMap).reduce((ok, [name, value2]) => {
|
|
16663
|
-
if (!value2.ast) {
|
|
16695
|
+
if (!value2.ast && !value2.parserError) {
|
|
16664
16696
|
const options = {
|
|
16665
16697
|
filepath: name
|
|
16666
16698
|
};
|
|
@@ -16674,7 +16706,6 @@ function getFileASTs(fnMap) {
|
|
|
16674
16706
|
options
|
|
16675
16707
|
);
|
|
16676
16708
|
} catch (e) {
|
|
16677
|
-
ok = false;
|
|
16678
16709
|
if (e instanceof Error) {
|
|
16679
16710
|
value2.parserError = e;
|
|
16680
16711
|
} else {
|
|
@@ -16682,11 +16713,11 @@ function getFileASTs(fnMap) {
|
|
|
16682
16713
|
}
|
|
16683
16714
|
}
|
|
16684
16715
|
}
|
|
16685
|
-
return ok;
|
|
16716
|
+
return value2.parserError ? false : ok;
|
|
16686
16717
|
}, true)
|
|
16687
16718
|
);
|
|
16688
16719
|
}
|
|
16689
|
-
async function analyze(fnMap, resourcesMap, manifestXML, config) {
|
|
16720
|
+
async function analyze(fnMap, resourcesMap, manifestXML, config, allowParseErrors) {
|
|
16690
16721
|
let hasTests = false;
|
|
16691
16722
|
let markApi = true;
|
|
16692
16723
|
const preState = {
|
|
@@ -16752,6 +16783,8 @@ async function analyze(fnMap, resourcesMap, manifestXML, config) {
|
|
|
16752
16783
|
Object.entries(fnMap).forEach(([name, value2]) => {
|
|
16753
16784
|
const { ast, parserError } = value2;
|
|
16754
16785
|
if (!ast) {
|
|
16786
|
+
if (allowParseErrors)
|
|
16787
|
+
return;
|
|
16755
16788
|
throw parserError || new Error(`Failed to parse ${name}`);
|
|
16756
16789
|
}
|
|
16757
16790
|
hasTests = false;
|
|
@@ -16770,7 +16803,7 @@ function reportMissingSymbols(state, config) {
|
|
|
16770
16803
|
const diagnosticType = config?.checkInvalidSymbols !== "OFF" ? config?.checkInvalidSymbols || "WARNING" : null;
|
|
16771
16804
|
const compiler2DiagnosticType = config?.checkCompilerLookupRules !== "OFF" ? config?.checkCompilerLookupRules || "WARNING" : null;
|
|
16772
16805
|
if (diagnosticType && !config?.compilerOptions?.includes("--Eno-invalid-symbol")) {
|
|
16773
|
-
const checkTypes = config?.
|
|
16806
|
+
const checkTypes = config?.checkTypes?.toLowerCase() !== "off";
|
|
16774
16807
|
const report = (ast) => {
|
|
16775
16808
|
visitReferences(state, ast, null, false, (node, results, error) => {
|
|
16776
16809
|
if (node.type === "BinaryExpression" && node.operator === "has") {
|
|
@@ -16920,17 +16953,12 @@ function markFunctionCalled(state, func) {
|
|
|
16920
16953
|
state.calledFunctions[func.id.name] = [func];
|
|
16921
16954
|
return;
|
|
16922
16955
|
}
|
|
16923
|
-
(0,
|
|
16956
|
+
(0, import_chunk_OASVKTK5.pushUnique)(state.calledFunctions[func.id.name], func);
|
|
16924
16957
|
}
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
|
|
16928
|
-
|
|
16929
|
-
if (ex instanceof import_chunk_67LU4GPQ.AwaitedError) {
|
|
16930
|
-
await ex.resolve();
|
|
16931
|
-
}
|
|
16932
|
-
throw ex;
|
|
16933
|
-
}
|
|
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
|
+
);
|
|
16934
16962
|
}
|
|
16935
16963
|
async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
16936
16964
|
const state = await analyze(
|
|
@@ -17025,7 +17053,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17025
17053
|
};
|
|
17026
17054
|
const gistate = { state, stack: [] };
|
|
17027
17055
|
if (state.config?.checkTypes !== "OFF" && state.config?.trustDeclaredTypes && state.config.propagateTypes) {
|
|
17028
|
-
gistate.typeChecker = state.config.
|
|
17056
|
+
gistate.typeChecker = state.config.strictTypeCheck?.toLowerCase() === "on" ? subtypeOf : couldBeWeak;
|
|
17029
17057
|
gistate.checkTypes = state.config?.checkTypes || "WARNING";
|
|
17030
17058
|
}
|
|
17031
17059
|
let istate = gistate;
|
|
@@ -17362,26 +17390,49 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17362
17390
|
Object.values(fnMap).forEach((f) => {
|
|
17363
17391
|
collectNamespaces(f.ast, state);
|
|
17364
17392
|
});
|
|
17393
|
+
let Changes;
|
|
17394
|
+
((Changes2) => {
|
|
17395
|
+
Changes2[Changes2["None"] = 0] = "None";
|
|
17396
|
+
Changes2[Changes2["Some"] = 1] = "Some";
|
|
17397
|
+
Changes2[Changes2["Force"] = 2] = "Force";
|
|
17398
|
+
})(Changes || (Changes = {}));
|
|
17365
17399
|
const cleanupAll = () => {
|
|
17366
17400
|
const usedDecls = findRezRefs(state);
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17401
|
+
const pre = state.pre;
|
|
17402
|
+
const post = state.post;
|
|
17403
|
+
try {
|
|
17404
|
+
delete state.pre;
|
|
17405
|
+
return Object.values(fnMap).reduce(
|
|
17406
|
+
(changes, f) => {
|
|
17407
|
+
state.post = (node) => {
|
|
17408
|
+
if (usedDecls.has(node)) {
|
|
17409
|
+
return null;
|
|
17410
|
+
}
|
|
17411
|
+
const ret = cleanup(state, node, f.ast, usedDecls);
|
|
17412
|
+
if (ret === false) {
|
|
17413
|
+
changes |= 1;
|
|
17414
|
+
state.removeNodeComments(node, f.ast);
|
|
17415
|
+
} else if (ret) {
|
|
17416
|
+
if (node.type === "EnumDeclaration" && ret.type === "TypedefDeclaration" && ret.ts.argument.ts.length > 1) {
|
|
17417
|
+
changes |= 2;
|
|
17418
|
+
} else {
|
|
17419
|
+
changes |= 1;
|
|
17420
|
+
}
|
|
17421
|
+
}
|
|
17422
|
+
return ret;
|
|
17423
|
+
};
|
|
17424
|
+
collectNamespaces(f.ast, state);
|
|
17425
|
+
return changes;
|
|
17426
|
+
},
|
|
17427
|
+
0
|
|
17428
|
+
/* None */
|
|
17429
|
+
);
|
|
17430
|
+
} finally {
|
|
17431
|
+
state.pre = pre;
|
|
17432
|
+
state.post = post;
|
|
17433
|
+
}
|
|
17383
17434
|
};
|
|
17384
|
-
|
|
17435
|
+
while (true) {
|
|
17385
17436
|
state.usedByName = {};
|
|
17386
17437
|
state.calledFunctions = {};
|
|
17387
17438
|
state.exposed = state.nextExposed;
|
|
@@ -17391,9 +17442,12 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17391
17442
|
});
|
|
17392
17443
|
state.exposed = state.nextExposed;
|
|
17393
17444
|
state.nextExposed = {};
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17445
|
+
const changes = cleanupAll();
|
|
17446
|
+
if (changes & 2 || changes & 1 && state.config?.iterateOptimizer) {
|
|
17447
|
+
continue;
|
|
17448
|
+
}
|
|
17449
|
+
break;
|
|
17450
|
+
}
|
|
17397
17451
|
delete state.pre;
|
|
17398
17452
|
delete state.post;
|
|
17399
17453
|
if (state.config?.minimizeModules ?? true) {
|
|
@@ -17428,15 +17482,12 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17428
17482
|
}
|
|
17429
17483
|
delete state.inlineDiagnostics;
|
|
17430
17484
|
}
|
|
17485
|
+
const diagnostics = state.diagnostics && await resolveDiagnosticsMap(state.diagnostics);
|
|
17431
17486
|
if (state.config?.checkBuildPragmas) {
|
|
17432
|
-
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17436
|
-
]).then(([diagnostics2]) => pragmaChecker(state, f.ast, diagnostics2));
|
|
17437
|
-
}, Promise.resolve());
|
|
17438
|
-
}
|
|
17439
|
-
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
|
+
}
|
|
17440
17491
|
return {
|
|
17441
17492
|
diagnostics,
|
|
17442
17493
|
sdkVersion: state.sdkVersion
|
|
@@ -17514,56 +17565,64 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17514
17565
|
case "ThisExpression":
|
|
17515
17566
|
node.text = "self";
|
|
17516
17567
|
break;
|
|
17517
|
-
case "
|
|
17518
|
-
if (node.members.every((m) => {
|
|
17568
|
+
case "EnumDeclaration": {
|
|
17569
|
+
if (!node.body.members.every((m) => {
|
|
17519
17570
|
if (usedNodes.has(m))
|
|
17520
17571
|
return false;
|
|
17521
17572
|
const name = "name" in m ? m.name : m.id.name;
|
|
17522
17573
|
return (0, import_chunk_MBTLUWXR.hasProperty)(state.index, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.exposed, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.usedByName, name);
|
|
17523
17574
|
})) {
|
|
17524
|
-
|
|
17525
|
-
node.members.map((m) => {
|
|
17526
|
-
if (!("init" in m))
|
|
17527
|
-
return "Number";
|
|
17528
|
-
const [node2, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(m.init);
|
|
17529
|
-
return node2 ? type : null;
|
|
17530
|
-
})
|
|
17531
|
-
);
|
|
17532
|
-
if (!enumType.has(null)) {
|
|
17533
|
-
node.enumType = [...enumType].map((t) => t === "Null" ? t : `Toybox.Lang.${t}`).join(" or ");
|
|
17534
|
-
node.members.splice(0);
|
|
17535
|
-
}
|
|
17575
|
+
break;
|
|
17536
17576
|
}
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17577
|
+
const enumType = new Set(
|
|
17578
|
+
node.body.members.map((m) => {
|
|
17579
|
+
if (!("init" in m))
|
|
17580
|
+
return "Number";
|
|
17581
|
+
const [node2, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(m.init);
|
|
17582
|
+
return node2 ? type : null;
|
|
17583
|
+
})
|
|
17584
|
+
);
|
|
17585
|
+
if (enumType.has(null))
|
|
17586
|
+
break;
|
|
17587
|
+
if (!node.id)
|
|
17588
|
+
return false;
|
|
17589
|
+
state.removeNodeComments(node, ast);
|
|
17590
|
+
const typedefDecl = (0, import_chunk_MBTLUWXR.withLocDeep)(
|
|
17591
|
+
{
|
|
17592
|
+
type: "TypedefDeclaration",
|
|
17593
|
+
id: node.id,
|
|
17594
|
+
ts: {
|
|
17595
|
+
type: "UnaryExpression",
|
|
17596
|
+
argument: {
|
|
17597
|
+
type: "TypeSpecList",
|
|
17598
|
+
ts: Array.from(enumType).map((t) => ({
|
|
17599
|
+
type: "TypeSpecPart",
|
|
17600
|
+
name: t === "Null" ? t : (0, import_chunk_MBTLUWXR.makeScopedName)(`Toybox.Lang.${t}`)
|
|
17601
|
+
}))
|
|
17602
|
+
},
|
|
17603
|
+
prefix: true,
|
|
17604
|
+
operator: " as"
|
|
17605
|
+
}
|
|
17606
|
+
},
|
|
17607
|
+
node,
|
|
17608
|
+
node
|
|
17609
|
+
);
|
|
17610
|
+
const decls = state.stack[state.stack.length - 1].sn?.type_decls?.[node.id.name];
|
|
17611
|
+
if (decls) {
|
|
17612
|
+
const i = decls.findIndex(
|
|
17613
|
+
(d) => d.type === "EnumDeclaration" && d.node === node
|
|
17564
17614
|
);
|
|
17615
|
+
if (i >= 0) {
|
|
17616
|
+
const old = decls[i];
|
|
17617
|
+
decls.splice(i, 1, {
|
|
17618
|
+
...old,
|
|
17619
|
+
type: "TypedefDeclaration",
|
|
17620
|
+
node: typedefDecl
|
|
17621
|
+
});
|
|
17622
|
+
}
|
|
17565
17623
|
}
|
|
17566
|
-
|
|
17624
|
+
return typedefDecl;
|
|
17625
|
+
}
|
|
17567
17626
|
case "VariableDeclarator": {
|
|
17568
17627
|
const name = variableDeclarationName(node.id);
|
|
17569
17628
|
return !(0, import_chunk_MBTLUWXR.hasProperty)(state.index, name) || (0, import_chunk_MBTLUWXR.hasProperty)(state.exposed, name) || (0, import_chunk_MBTLUWXR.hasProperty)(state.usedByName, name) ? null : false;
|
|
@@ -17650,6 +17709,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17650
17709
|
"use strict";
|
|
17651
17710
|
init_api();
|
|
17652
17711
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
17712
|
+
init_data_flow();
|
|
17653
17713
|
init_function_info();
|
|
17654
17714
|
init_inliner();
|
|
17655
17715
|
init_optimizer_types();
|
|
@@ -17663,9 +17723,8 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17663
17723
|
init_sub_type();
|
|
17664
17724
|
init_types();
|
|
17665
17725
|
init_unused_exprs();
|
|
17666
|
-
(0,
|
|
17726
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
17667
17727
|
init_variable_renamer();
|
|
17668
|
-
init_data_flow();
|
|
17669
17728
|
}
|
|
17670
17729
|
});
|
|
17671
17730
|
var negativeFixups;
|
|
@@ -18558,7 +18617,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
|
|
|
18558
18617
|
throw `Negative constant ${fixup} was not a Literal`;
|
|
18559
18618
|
}
|
|
18560
18619
|
if (typeof init.value !== "number") {
|
|
18561
|
-
(0,
|
|
18620
|
+
(0, import_chunk_OASVKTK5.log)(`Negative fixup ${fixup} was not a number!`);
|
|
18562
18621
|
} else if (init.value > 0) {
|
|
18563
18622
|
init.value = -init.value;
|
|
18564
18623
|
init.raw = "-" + init.raw;
|
|
@@ -18648,11 +18707,11 @@ function sameStateNodeDecl(a, b) {
|
|
|
18648
18707
|
function sameLookupDefinition(a, b) {
|
|
18649
18708
|
return (
|
|
18650
18709
|
// sameStateNodeDecl(a.parent, b.parent) &&
|
|
18651
|
-
(0,
|
|
18710
|
+
(0, import_chunk_OASVKTK5.sameArrays)(a.results, b.results, (ar, br) => sameStateNodeDecl(ar, br))
|
|
18652
18711
|
);
|
|
18653
18712
|
}
|
|
18654
18713
|
function sameLookupResult(a, b) {
|
|
18655
|
-
return (0,
|
|
18714
|
+
return (0, import_chunk_OASVKTK5.sameArrays)(a, b, sameLookupDefinition);
|
|
18656
18715
|
}
|
|
18657
18716
|
function declKey(decl) {
|
|
18658
18717
|
return isStateNode(decl) ? decl.type === "ModuleDeclaration" ? decl.fullName : decl.node : decl;
|
|
@@ -18709,6 +18768,17 @@ function lookupNext(state, results, decls, property) {
|
|
|
18709
18768
|
);
|
|
18710
18769
|
return;
|
|
18711
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
|
+
}
|
|
18712
18782
|
const res = checkOne(state, module2, decls, property);
|
|
18713
18783
|
if (res) {
|
|
18714
18784
|
items.push({ parent: module2, results: res });
|
|
@@ -18903,7 +18973,11 @@ function lookupWithType(state, node, typeMap, nonLocal = false, stack = null) {
|
|
|
18903
18973
|
const objectType = typeMap.get(node.object);
|
|
18904
18974
|
if (!objectType)
|
|
18905
18975
|
return results;
|
|
18906
|
-
const [, decls] = findObjectDeclsByProperty(
|
|
18976
|
+
const [, decls] = findObjectDeclsByProperty(
|
|
18977
|
+
state,
|
|
18978
|
+
objectType,
|
|
18979
|
+
node.property
|
|
18980
|
+
);
|
|
18907
18981
|
if (decls) {
|
|
18908
18982
|
const next = lookupNext(
|
|
18909
18983
|
state,
|
|
@@ -19190,7 +19264,7 @@ function stateFuncs() {
|
|
|
19190
19264
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
|
|
19191
19265
|
this.index[name] = [];
|
|
19192
19266
|
}
|
|
19193
|
-
(0,
|
|
19267
|
+
(0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
|
|
19194
19268
|
}
|
|
19195
19269
|
});
|
|
19196
19270
|
break;
|
|
@@ -19245,7 +19319,7 @@ function stateFuncs() {
|
|
|
19245
19319
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(values, name)) {
|
|
19246
19320
|
values[name] = [];
|
|
19247
19321
|
}
|
|
19248
|
-
if ((0,
|
|
19322
|
+
if ((0, import_chunk_OASVKTK5.pushUnique)(values[name], m) && currentEnum) {
|
|
19249
19323
|
if (!this.enumMap)
|
|
19250
19324
|
this.enumMap = /* @__PURE__ */ new Map();
|
|
19251
19325
|
this.enumMap.set(m, currentEnum);
|
|
@@ -19253,7 +19327,7 @@ function stateFuncs() {
|
|
|
19253
19327
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(this.index, name)) {
|
|
19254
19328
|
this.index[name] = [];
|
|
19255
19329
|
}
|
|
19256
|
-
(0,
|
|
19330
|
+
(0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
|
|
19257
19331
|
});
|
|
19258
19332
|
break;
|
|
19259
19333
|
}
|
|
@@ -19754,7 +19828,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
19754
19828
|
init_sdk_util();
|
|
19755
19829
|
init_type_flow_util();
|
|
19756
19830
|
init_types();
|
|
19757
|
-
(0,
|
|
19831
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
19758
19832
|
init_visitor();
|
|
19759
19833
|
}
|
|
19760
19834
|
});
|
|
@@ -19838,7 +19912,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19838
19912
|
return decls;
|
|
19839
19913
|
}
|
|
19840
19914
|
if (canon.length !== decls.length || !canon.every((v, i) => v === decls[i])) {
|
|
19841
|
-
throw new
|
|
19915
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
19842
19916
|
declFullName(canon).then(
|
|
19843
19917
|
(canonStr) => `Canonical representation of ${canonStr} did not match`
|
|
19844
19918
|
)
|
|
@@ -19872,7 +19946,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19872
19946
|
}
|
|
19873
19947
|
const decl = lookupDefToDecl(results);
|
|
19874
19948
|
if (decl && path7.length) {
|
|
19875
|
-
if (wantsAllRefs && (0,
|
|
19949
|
+
if (wantsAllRefs && (0, import_chunk_OASVKTK5.every)(
|
|
19876
19950
|
decl,
|
|
19877
19951
|
(d) => d.type === "VariableDeclarator" || d.type === "BinaryExpression" || d.type === "Identifier"
|
|
19878
19952
|
)) {
|
|
@@ -19924,7 +19998,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19924
19998
|
}
|
|
19925
19999
|
const v = liveDefs.get(def);
|
|
19926
20000
|
if (!v || !v.has(node)) {
|
|
19927
|
-
throw new
|
|
20001
|
+
throw new import_chunk_OASVKTK5.AwaitedError(
|
|
19928
20002
|
Promise.resolve(def ? declFullName(def) : "null").then(
|
|
19929
20003
|
(defStr) => `No stmt in liveDef for ${defStr}`
|
|
19930
20004
|
)
|
|
@@ -19982,7 +20056,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
19982
20056
|
const decls = findDecl(node);
|
|
19983
20057
|
if (!decls)
|
|
19984
20058
|
break;
|
|
19985
|
-
if (trackInsertionPoints && (0,
|
|
20059
|
+
if (trackInsertionPoints && (0, import_chunk_OASVKTK5.some)(decls, (decl) => {
|
|
19986
20060
|
if (decl.type === "VariableDeclarator") {
|
|
19987
20061
|
const defStmts = decl.node.kind === "var" && liveDefs.get(null) || liveDefs.get(decl);
|
|
19988
20062
|
if (defStmts) {
|
|
@@ -20233,8 +20307,8 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20233
20307
|
init_control_flow();
|
|
20234
20308
|
init_function_info();
|
|
20235
20309
|
init_type_flow_util();
|
|
20236
|
-
(0,
|
|
20237
|
-
DataflowQueue = class extends
|
|
20310
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
20311
|
+
DataflowQueue = class extends import_chunk_OASVKTK5.GenericQueue {
|
|
20238
20312
|
constructor() {
|
|
20239
20313
|
super((b, a) => (a.order || 0) - (b.order || 0));
|
|
20240
20314
|
}
|
|
@@ -21029,7 +21103,7 @@ function computeJsrMap(func) {
|
|
|
21029
21103
|
}
|
|
21030
21104
|
function postOrderPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
21031
21105
|
const order = /* @__PURE__ */ new Map();
|
|
21032
|
-
const queue = new
|
|
21106
|
+
const queue = new import_chunk_OASVKTK5.GenericQueue(
|
|
21033
21107
|
(b, a) => order.get(a) - order.get(b)
|
|
21034
21108
|
);
|
|
21035
21109
|
postOrderTraverse2(func, (block) => {
|
|
@@ -21088,7 +21162,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
21088
21162
|
});
|
|
21089
21163
|
blocks.reverse().forEach((block, i) => order.set(block, i));
|
|
21090
21164
|
}
|
|
21091
|
-
const queue = new
|
|
21165
|
+
const queue = new import_chunk_OASVKTK5.GenericQueue(
|
|
21092
21166
|
(b, a) => order.get(a) - order.get(b)
|
|
21093
21167
|
);
|
|
21094
21168
|
queue.enqueue(func.blocks.get(func.offset));
|
|
@@ -21142,7 +21216,7 @@ function rpoPropagate(func, preBlock, processBc, postBlock, merge) {
|
|
|
21142
21216
|
var init_cflow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
21143
21217
|
"src/readprg/cflow.ts"() {
|
|
21144
21218
|
"use strict";
|
|
21145
|
-
(0,
|
|
21219
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
21146
21220
|
init_opcodes();
|
|
21147
21221
|
}
|
|
21148
21222
|
});
|
|
@@ -21605,12 +21679,12 @@ function interpFunc(func, context) {
|
|
|
21605
21679
|
const selfStores = /* @__PURE__ */ new Set();
|
|
21606
21680
|
const liveInState = /* @__PURE__ */ new Map();
|
|
21607
21681
|
const replacements = /* @__PURE__ */ new Map();
|
|
21608
|
-
const interpLogging = (0,
|
|
21682
|
+
const interpLogging = (0, import_chunk_OASVKTK5.wouldLog)("interp", 1);
|
|
21609
21683
|
if (interpLogging) {
|
|
21610
|
-
if ((0,
|
|
21611
|
-
(0,
|
|
21612
|
-
} else if ((0,
|
|
21613
|
-
(0,
|
|
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)(
|
|
21614
21688
|
() => `+++++++++++++ interp-prepare ${func.name} ++++++++++++++`
|
|
21615
21689
|
);
|
|
21616
21690
|
}
|
|
@@ -21644,20 +21718,20 @@ function interpFunc(func, context) {
|
|
|
21644
21718
|
func,
|
|
21645
21719
|
(block) => {
|
|
21646
21720
|
if (interpLogging) {
|
|
21647
|
-
(0,
|
|
21721
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
21648
21722
|
"interp",
|
|
21649
21723
|
3,
|
|
21650
21724
|
`${offsetToString(block.offset)}: ${block.bytecodes[0]?.lineNum ? lineInfoToString(block.bytecodes[0]?.lineNum, context) : ""}
|
|
21651
21725
|
${interpStateToString(liveInState.get(block.offset))}`
|
|
21652
21726
|
);
|
|
21653
|
-
(0,
|
|
21727
|
+
(0, import_chunk_OASVKTK5.logger)("interp", 9, () => blockToString(block, context));
|
|
21654
21728
|
}
|
|
21655
21729
|
return cloneState2(liveInState.get(block.offset));
|
|
21656
21730
|
},
|
|
21657
21731
|
(block, bc, localState) => {
|
|
21658
21732
|
if (interpLogging) {
|
|
21659
|
-
if ((0,
|
|
21660
|
-
(0,
|
|
21733
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 8)) {
|
|
21734
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
21661
21735
|
`${interpStateToString(localState)}
|
|
21662
21736
|
${bytecodeToString(
|
|
21663
21737
|
bc,
|
|
@@ -21822,14 +21896,14 @@ function interpFunc(func, context) {
|
|
|
21822
21896
|
if (!mergeInto(localState, succState))
|
|
21823
21897
|
return false;
|
|
21824
21898
|
if (interpLogging) {
|
|
21825
|
-
(0,
|
|
21899
|
+
(0, import_chunk_OASVKTK5.logger)("interp", 3, `Re-Merge to ${offsetToString(succBlock.offset)}`);
|
|
21826
21900
|
}
|
|
21827
21901
|
return true;
|
|
21828
21902
|
}
|
|
21829
21903
|
);
|
|
21830
21904
|
if (interpLogging) {
|
|
21831
|
-
if ((0,
|
|
21832
|
-
(0,
|
|
21905
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("interp", 5)) {
|
|
21906
|
+
(0, import_chunk_OASVKTK5.setBanner)(
|
|
21833
21907
|
functionBanner(func, context, "interp", (block, footer) => {
|
|
21834
21908
|
if (footer)
|
|
21835
21909
|
return "";
|
|
@@ -21837,44 +21911,44 @@ function interpFunc(func, context) {
|
|
|
21837
21911
|
})
|
|
21838
21912
|
);
|
|
21839
21913
|
} else {
|
|
21840
|
-
(0,
|
|
21914
|
+
(0, import_chunk_OASVKTK5.setBanner)(() => `=============== interp ${func.name} ==============`);
|
|
21841
21915
|
}
|
|
21842
21916
|
if (equivSets.size) {
|
|
21843
|
-
(0,
|
|
21917
|
+
(0, import_chunk_OASVKTK5.log)(`====== equivSets =====`);
|
|
21844
21918
|
equivSets.forEach(
|
|
21845
|
-
(value2, key) => (0,
|
|
21919
|
+
(value2, key) => (0, import_chunk_OASVKTK5.log)(
|
|
21846
21920
|
`L${key.arg} === ${Array.from(value2).sort().join(" ")} ${key.lineNum ? lineInfoToString(key.lineNum, context) : ""}`
|
|
21847
21921
|
)
|
|
21848
21922
|
);
|
|
21849
21923
|
}
|
|
21850
21924
|
if (selfStores.size) {
|
|
21851
|
-
(0,
|
|
21925
|
+
(0, import_chunk_OASVKTK5.log)(`====== selfStores =====`);
|
|
21852
21926
|
selfStores.forEach(
|
|
21853
|
-
(value2) => (0,
|
|
21927
|
+
(value2) => (0, import_chunk_OASVKTK5.log)(`${bytecodeToString(value2, symbolTable)}`)
|
|
21854
21928
|
);
|
|
21855
21929
|
}
|
|
21856
21930
|
if (replacements.size) {
|
|
21857
|
-
(0,
|
|
21931
|
+
(0, import_chunk_OASVKTK5.log)(`====== replacements =====`);
|
|
21858
21932
|
replacements.forEach(
|
|
21859
21933
|
(blockRep) => blockRep.forEach(
|
|
21860
|
-
(rep, bc) => (0,
|
|
21934
|
+
(rep, bc) => (0, import_chunk_OASVKTK5.log)(
|
|
21861
21935
|
`${bytecodeToString(bc, symbolTable)} => ${rep.invert ? "~" : ""}${bytecodeToString(rep, symbolTable)} ${bc.lineNum ? lineInfoToString(bc.lineNum, context) : ""}`
|
|
21862
21936
|
)
|
|
21863
21937
|
)
|
|
21864
21938
|
);
|
|
21865
21939
|
}
|
|
21866
21940
|
if (resolvedBranches.size) {
|
|
21867
|
-
(0,
|
|
21941
|
+
(0, import_chunk_OASVKTK5.log)(`====== resolved branches =====`);
|
|
21868
21942
|
resolvedBranches.forEach(
|
|
21869
|
-
(isTaken, block) => (0,
|
|
21943
|
+
(isTaken, block) => (0, import_chunk_OASVKTK5.log)(
|
|
21870
21944
|
`block ${offsetToString(block.offset)} is ${isTaken ? "always" : "never"} taken`
|
|
21871
21945
|
)
|
|
21872
21946
|
);
|
|
21873
21947
|
}
|
|
21874
21948
|
if (branchRedirects.size) {
|
|
21875
|
-
(0,
|
|
21949
|
+
(0, import_chunk_OASVKTK5.log)(`====== redirected branches =====`);
|
|
21876
21950
|
branchRedirects.forEach(
|
|
21877
|
-
({ to, from }, block) => (0,
|
|
21951
|
+
({ to, from }, block) => (0, import_chunk_OASVKTK5.log)(
|
|
21878
21952
|
`block ${offsetToString(
|
|
21879
21953
|
block.offset
|
|
21880
21954
|
)} redirects from ${offsetToString(from)} to ${offsetToString(to)}${safeBranchBlocks.get(from) ? ` popping ${safeBranchBlocks.get(from)}` : ""}`
|
|
@@ -21937,7 +22011,7 @@ function interpFunc(func, context) {
|
|
|
21937
22011
|
}
|
|
21938
22012
|
});
|
|
21939
22013
|
if (interpLogging)
|
|
21940
|
-
(0,
|
|
22014
|
+
(0, import_chunk_OASVKTK5.setBanner)(null);
|
|
21941
22015
|
return {
|
|
21942
22016
|
liveInState,
|
|
21943
22017
|
equivSets,
|
|
@@ -21987,7 +22061,7 @@ var init_interp2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
21987
22061
|
"src/readprg/interp.ts"() {
|
|
21988
22062
|
"use strict";
|
|
21989
22063
|
init_interp_binary();
|
|
21990
|
-
(0,
|
|
22064
|
+
(0, import_chunk_OASVKTK5.init_logger)();
|
|
21991
22065
|
init_interp();
|
|
21992
22066
|
init_types();
|
|
21993
22067
|
init_union_type();
|
|
@@ -22099,7 +22173,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22099
22173
|
i = found;
|
|
22100
22174
|
}
|
|
22101
22175
|
if (initType && (block.bytecodes[index].op === 20 ? initType.type === 1 : initType.type === 8 && initType.value === 0)) {
|
|
22102
|
-
(0,
|
|
22176
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22103
22177
|
"array-init",
|
|
22104
22178
|
1,
|
|
22105
22179
|
() => `${func.name}: Removing initialization of default initialized ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22136,7 +22210,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22136
22210
|
convertAputv(offset - 1);
|
|
22137
22211
|
}
|
|
22138
22212
|
}
|
|
22139
|
-
(0,
|
|
22213
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22140
22214
|
"array-init",
|
|
22141
22215
|
1,
|
|
22142
22216
|
() => `${func.name}: Optimizing unused ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22145,8 +22219,8 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22145
22219
|
block.bytecodes[index].offset
|
|
22146
22220
|
)}`
|
|
22147
22221
|
);
|
|
22148
|
-
if ((0,
|
|
22149
|
-
(0,
|
|
22222
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("array-init", 5)) {
|
|
22223
|
+
(0, import_chunk_OASVKTK5.log)(blockToString(block, context));
|
|
22150
22224
|
}
|
|
22151
22225
|
return true;
|
|
22152
22226
|
}
|
|
@@ -22186,7 +22260,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22186
22260
|
if (putvStarts.length < 3)
|
|
22187
22261
|
return false;
|
|
22188
22262
|
tryLocal(3);
|
|
22189
|
-
(0,
|
|
22263
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22190
22264
|
"array-init",
|
|
22191
22265
|
1,
|
|
22192
22266
|
() => `${func.name}: Optimizing ${putvStarts.length} element array init with constant initializer ${bytecodeToString(
|
|
@@ -22212,7 +22286,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
22212
22286
|
block.bytecodes[index + 1].arg = putvStarts.length;
|
|
22213
22287
|
}
|
|
22214
22288
|
}
|
|
22215
|
-
(0,
|
|
22289
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22216
22290
|
"array-init",
|
|
22217
22291
|
5,
|
|
22218
22292
|
() => `index: ${index}, i: ${i}
|
|
@@ -22265,7 +22339,7 @@ ${blockToString(block, context)}`
|
|
|
22265
22339
|
for (let i2 = putvStarts.length; i2-- > 1; ) {
|
|
22266
22340
|
block.bytecodes.splice(putvStarts[i2], 2);
|
|
22267
22341
|
}
|
|
22268
|
-
(0,
|
|
22342
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22269
22343
|
"array-init",
|
|
22270
22344
|
1,
|
|
22271
22345
|
() => `${func.name}: Optimizing ${putvStarts.length} element array init at block ${offsetToString(
|
|
@@ -22324,15 +22398,15 @@ var init_array_init = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
22324
22398
|
"src/readprg/array-init.ts"() {
|
|
22325
22399
|
"use strict";
|
|
22326
22400
|
init_types();
|
|
22327
|
-
(0,
|
|
22401
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
22328
22402
|
init_bytecode();
|
|
22329
22403
|
init_interp2();
|
|
22330
22404
|
init_opcodes();
|
|
22331
22405
|
}
|
|
22332
22406
|
});
|
|
22333
22407
|
function localDCE(func, context) {
|
|
22334
|
-
if ((0,
|
|
22335
|
-
(0,
|
|
22408
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("dce", 5)) {
|
|
22409
|
+
(0, import_chunk_OASVKTK5.setBanner)(
|
|
22336
22410
|
functionBanner(
|
|
22337
22411
|
func,
|
|
22338
22412
|
context,
|
|
@@ -22365,7 +22439,7 @@ function localDCE(func, context) {
|
|
|
22365
22439
|
};
|
|
22366
22440
|
func.blocks.forEach((block) => {
|
|
22367
22441
|
const reportPopv = (i, item, kill) => {
|
|
22368
|
-
(0,
|
|
22442
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22369
22443
|
"dce",
|
|
22370
22444
|
2,
|
|
22371
22445
|
() => `${func.name}: Convert ${i}:${bytecodeToString(
|
|
@@ -22380,7 +22454,7 @@ function localDCE(func, context) {
|
|
|
22380
22454
|
);
|
|
22381
22455
|
};
|
|
22382
22456
|
const reportNop = (item) => {
|
|
22383
|
-
(0,
|
|
22457
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22384
22458
|
"dce",
|
|
22385
22459
|
2,
|
|
22386
22460
|
() => `${func.name}: Kill ${item.deps.map(
|
|
@@ -22399,7 +22473,7 @@ function localDCE(func, context) {
|
|
|
22399
22473
|
case 19: {
|
|
22400
22474
|
const liveLocal = dceInfo.locals.has(bytecode.arg);
|
|
22401
22475
|
if (!liveLocal && (bytecode.arg || context.config.allowForbiddenOpts)) {
|
|
22402
|
-
(0,
|
|
22476
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
22403
22477
|
"dce",
|
|
22404
22478
|
2,
|
|
22405
22479
|
() => `${func.name}: Killing store to unused local ${bytecode.arg} at ${offsetToString(block.offset)}:${i}`
|
|
@@ -22559,10 +22633,10 @@ function localDCE(func, context) {
|
|
|
22559
22633
|
(bc) => bc.op !== 0
|
|
22560
22634
|
/* nop */
|
|
22561
22635
|
);
|
|
22562
|
-
(0,
|
|
22636
|
+
(0, import_chunk_OASVKTK5.logger)("dce", 3, functionBanner(func, context, "local-dce-end"));
|
|
22563
22637
|
}
|
|
22564
22638
|
});
|
|
22565
|
-
(0,
|
|
22639
|
+
(0, import_chunk_OASVKTK5.setBanner)(null);
|
|
22566
22640
|
return anyChanges;
|
|
22567
22641
|
}
|
|
22568
22642
|
function computeLiveLocals(func) {
|
|
@@ -22613,7 +22687,7 @@ var init_dce = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
22613
22687
|
"src/readprg/dce.ts"() {
|
|
22614
22688
|
"use strict";
|
|
22615
22689
|
init_data_flow();
|
|
22616
|
-
(0,
|
|
22690
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
22617
22691
|
init_bytecode();
|
|
22618
22692
|
init_cflow();
|
|
22619
22693
|
init_opcodes();
|
|
@@ -22653,7 +22727,7 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22653
22727
|
const splitRanges = computeSplitRanges(func, equivSets);
|
|
22654
22728
|
const locals = mergeSplitRanges(splitRanges);
|
|
22655
22729
|
const numLocals = Math.max(...Array.from(splitRanges.keys())) + 1;
|
|
22656
|
-
(0,
|
|
22730
|
+
(0, import_chunk_OASVKTK5.logger)("locals", 10, functionBanner(func, context, "Minimize Locals"));
|
|
22657
22731
|
let argc = func.argc ?? null;
|
|
22658
22732
|
const colors = /* @__PURE__ */ new Map();
|
|
22659
22733
|
const merge = [];
|
|
@@ -22720,15 +22794,15 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22720
22794
|
}
|
|
22721
22795
|
}
|
|
22722
22796
|
}
|
|
22723
|
-
if ((0,
|
|
22724
|
-
if (!(0,
|
|
22725
|
-
(0,
|
|
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"));
|
|
22726
22800
|
}
|
|
22727
|
-
(0,
|
|
22801
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
22728
22802
|
`>>> Merging locals in ${func.name} (in: ${numLocals} => out: ${merge.length})`
|
|
22729
22803
|
);
|
|
22730
22804
|
merge.slice().sort((a, b) => (colors.get(a[0]) ?? 0) - (colors.get(b[0]) ?? 0)).forEach(
|
|
22731
|
-
(merged) => (0,
|
|
22805
|
+
(merged) => (0, import_chunk_OASVKTK5.log)(
|
|
22732
22806
|
` ${colors.get(merged[0])} - ${merged.map((k) => bytecodeToString(k, context.symbolTable)).join(" | ")}`
|
|
22733
22807
|
)
|
|
22734
22808
|
);
|
|
@@ -23027,7 +23101,7 @@ function mergeSplitRanges(splitRanges) {
|
|
|
23027
23101
|
var init_locals = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23028
23102
|
"src/readprg/locals.ts"() {
|
|
23029
23103
|
"use strict";
|
|
23030
|
-
(0,
|
|
23104
|
+
(0, import_chunk_OASVKTK5.init_logger)();
|
|
23031
23105
|
init_bytecode();
|
|
23032
23106
|
init_cflow();
|
|
23033
23107
|
init_opcodes();
|
|
@@ -23140,16 +23214,16 @@ function sizeBasedPRE2(func, context) {
|
|
|
23140
23214
|
delete bc.arg;
|
|
23141
23215
|
return bc;
|
|
23142
23216
|
};
|
|
23143
|
-
if ((0,
|
|
23144
|
-
if ((0,
|
|
23145
|
-
(0,
|
|
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")());
|
|
23146
23220
|
} else {
|
|
23147
|
-
(0,
|
|
23221
|
+
(0, import_chunk_OASVKTK5.log)(`================ PRE : ${func.name} ================
|
|
23148
23222
|
`);
|
|
23149
23223
|
}
|
|
23150
23224
|
insertionBlocks.forEach((o, key) => {
|
|
23151
23225
|
const bcs = canonicalMap.get(key);
|
|
23152
|
-
(0,
|
|
23226
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
23153
23227
|
`Replacing ${bcs.size} instances of ${bytecodeToString(
|
|
23154
23228
|
bcs.values().next().value,
|
|
23155
23229
|
context.symbolTable
|
|
@@ -23232,13 +23306,13 @@ function sizeBasedPRE2(func, context) {
|
|
|
23232
23306
|
bytecode(1, insertionBlocks.size)
|
|
23233
23307
|
);
|
|
23234
23308
|
}
|
|
23235
|
-
(0,
|
|
23309
|
+
(0, import_chunk_OASVKTK5.logger)("pre", 5, functionBanner(func, context, "post-PRE"));
|
|
23236
23310
|
return true;
|
|
23237
23311
|
}
|
|
23238
23312
|
var init_pre2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23239
23313
|
"src/readprg/pre.ts"() {
|
|
23240
23314
|
"use strict";
|
|
23241
|
-
(0,
|
|
23315
|
+
(0, import_chunk_OASVKTK5.init_logger)();
|
|
23242
23316
|
init_bytecode();
|
|
23243
23317
|
init_cflow();
|
|
23244
23318
|
init_opcodes();
|
|
@@ -23271,9 +23345,9 @@ function blockSharing(func, context) {
|
|
|
23271
23345
|
if (!any)
|
|
23272
23346
|
return false;
|
|
23273
23347
|
any = false;
|
|
23274
|
-
const logging3 = (0,
|
|
23275
|
-
if (logging3 && (0,
|
|
23276
|
-
(0,
|
|
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"));
|
|
23277
23351
|
}
|
|
23278
23352
|
candidates.forEach((blocks) => {
|
|
23279
23353
|
while (blocks.size > 1) {
|
|
@@ -23409,9 +23483,9 @@ function blockSharing(func, context) {
|
|
|
23409
23483
|
block2.offset
|
|
23410
23484
|
)})` : `block(${offsetToString(block2.offset)})`;
|
|
23411
23485
|
};
|
|
23412
|
-
(0,
|
|
23413
|
-
if ((0,
|
|
23414
|
-
(0,
|
|
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));
|
|
23415
23489
|
}
|
|
23416
23490
|
}
|
|
23417
23491
|
if (target.bytecodes.length > length2) {
|
|
@@ -23438,13 +23512,13 @@ function blockSharing(func, context) {
|
|
|
23438
23512
|
});
|
|
23439
23513
|
}
|
|
23440
23514
|
});
|
|
23441
|
-
(0,
|
|
23515
|
+
(0, import_chunk_OASVKTK5.setBanner)(null);
|
|
23442
23516
|
return any;
|
|
23443
23517
|
}
|
|
23444
23518
|
var init_sharing = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23445
23519
|
"src/readprg/sharing.ts"() {
|
|
23446
23520
|
"use strict";
|
|
23447
|
-
(0,
|
|
23521
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
23448
23522
|
init_bytecode();
|
|
23449
23523
|
init_opcodes();
|
|
23450
23524
|
}
|
|
@@ -23508,7 +23582,7 @@ function doArrayInits(func, liveInState, context) {
|
|
|
23508
23582
|
}
|
|
23509
23583
|
function simpleOpts(func, context) {
|
|
23510
23584
|
const equalsSym = 8388787;
|
|
23511
|
-
const logging3 = (0,
|
|
23585
|
+
const logging3 = (0, import_chunk_OASVKTK5.wouldLog)("optimize", 5);
|
|
23512
23586
|
return Array.from(func.blocks.values()).reduce((changes, block) => {
|
|
23513
23587
|
for (let i = block.bytecodes.length; i--; ) {
|
|
23514
23588
|
const cur = block.bytecodes[i];
|
|
@@ -23516,7 +23590,7 @@ function simpleOpts(func, context) {
|
|
|
23516
23590
|
block.bytecodes.splice(i, 1);
|
|
23517
23591
|
changes = true;
|
|
23518
23592
|
if (logging3) {
|
|
23519
|
-
(0,
|
|
23593
|
+
(0, import_chunk_OASVKTK5.log)(`${func.name}: deleting ${bytecodeToString(cur, null)}`);
|
|
23520
23594
|
}
|
|
23521
23595
|
} else if (cur.op === 74 && context.config.removeArgc && context.config.allowForbiddenOpts) {
|
|
23522
23596
|
const arg = cur.arg.incsp;
|
|
@@ -23525,7 +23599,7 @@ function simpleOpts(func, context) {
|
|
|
23525
23599
|
incsp.arg = arg;
|
|
23526
23600
|
changes = true;
|
|
23527
23601
|
if (logging3) {
|
|
23528
|
-
(0,
|
|
23602
|
+
(0, import_chunk_OASVKTK5.log)(`${func.name}: argcincsp => incsp`);
|
|
23529
23603
|
}
|
|
23530
23604
|
} else if (i && cur.op === 39 && cur.arg === equalsSym) {
|
|
23531
23605
|
changes = equalSymbolToEq(block, i) || changes;
|
|
@@ -23536,7 +23610,7 @@ function simpleOpts(func, context) {
|
|
|
23536
23610
|
if (!shift && prev.op === 37) {
|
|
23537
23611
|
block.bytecodes.splice(i - 1, 2);
|
|
23538
23612
|
changes = true;
|
|
23539
|
-
logging3 && (0,
|
|
23613
|
+
logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: deleting no-op shift (${shift})`);
|
|
23540
23614
|
continue;
|
|
23541
23615
|
}
|
|
23542
23616
|
if (shift === 1n && prev.op === 37) {
|
|
@@ -23546,7 +23620,7 @@ function simpleOpts(func, context) {
|
|
|
23546
23620
|
const add = cur;
|
|
23547
23621
|
add.op = 3;
|
|
23548
23622
|
delete add.arg;
|
|
23549
|
-
logging3 && (0,
|
|
23623
|
+
logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
|
|
23550
23624
|
continue;
|
|
23551
23625
|
}
|
|
23552
23626
|
if (shift < (prev.op === 49 ? 64n : 31n)) {
|
|
@@ -23556,7 +23630,7 @@ function simpleOpts(func, context) {
|
|
|
23556
23630
|
} else {
|
|
23557
23631
|
prev.arg = BigInt.asIntN(64, mul);
|
|
23558
23632
|
}
|
|
23559
|
-
logging3 && (0,
|
|
23633
|
+
logging3 && (0, import_chunk_OASVKTK5.log)(
|
|
23560
23634
|
`${func.name}: converting shlv(${shift}) to mulv(${prev.arg})`
|
|
23561
23635
|
);
|
|
23562
23636
|
changes = true;
|
|
@@ -23570,14 +23644,14 @@ function simpleOpts(func, context) {
|
|
|
23570
23644
|
func.blocks.get(block.taken).preds.delete(block.offset);
|
|
23571
23645
|
delete block.taken;
|
|
23572
23646
|
changes = true;
|
|
23573
|
-
logging3 && (0,
|
|
23647
|
+
logging3 && (0, import_chunk_OASVKTK5.log)(`${func.name}: deleting empty finally handler`);
|
|
23574
23648
|
} else if (isCondBranch(cur.op)) {
|
|
23575
23649
|
const next = func.blocks.get(block.next);
|
|
23576
23650
|
const taken = func.blocks.get(block.taken);
|
|
23577
23651
|
if (next.preds.size > 1 && taken.preds.size === 1) {
|
|
23578
23652
|
const newOp = cur.op === 40 ? 41 : 40;
|
|
23579
23653
|
if (logging3) {
|
|
23580
|
-
(0,
|
|
23654
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
23581
23655
|
`${func.name}: converting ${Opcodes[cur.op]} to ${Opcodes[newOp]}`
|
|
23582
23656
|
);
|
|
23583
23657
|
}
|
|
@@ -23590,7 +23664,7 @@ function simpleOpts(func, context) {
|
|
|
23590
23664
|
const isBool = i >= 2 && isBoolOp(block.bytecodes[i - 2].op);
|
|
23591
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) {
|
|
23592
23666
|
if (logging3) {
|
|
23593
|
-
(0,
|
|
23667
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
23594
23668
|
`${func.name}: simplifying ${next.bytecodes[next.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
|
|
23595
23669
|
next.offset
|
|
23596
23670
|
)}:${offsetToString(taken.offset)}:`
|
|
@@ -23607,7 +23681,7 @@ function simpleOpts(func, context) {
|
|
|
23607
23681
|
changes = true;
|
|
23608
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) {
|
|
23609
23683
|
if (logging3) {
|
|
23610
|
-
(0,
|
|
23684
|
+
(0, import_chunk_OASVKTK5.log)(
|
|
23611
23685
|
`${func.name}: simplifying ${taken.bytecodes[taken.bytecodes.length - 1].op === 7 ? "'&&'" : "'||'"} at ${offsetToString(block.offset)}:${offsetToString(
|
|
23612
23686
|
taken.offset
|
|
23613
23687
|
)}:${offsetToString(next.offset)}:`
|
|
@@ -23655,7 +23729,7 @@ function equalSymbolToEq(block, equalsIndex) {
|
|
|
23655
23729
|
op: 26,
|
|
23656
23730
|
offset: invokem.offset
|
|
23657
23731
|
});
|
|
23658
|
-
(0,
|
|
23732
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
23659
23733
|
"optimize",
|
|
23660
23734
|
1,
|
|
23661
23735
|
`Replacing <thing>.equals(:symbol) with <thing> eq :symbol at ${offsetToString(
|
|
@@ -23715,7 +23789,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23715
23789
|
const next = func.blocks.get(block.next);
|
|
23716
23790
|
if (block.try === next.try) {
|
|
23717
23791
|
if (next.preds.size === 1) {
|
|
23718
|
-
(0,
|
|
23792
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
23719
23793
|
"cfg",
|
|
23720
23794
|
1,
|
|
23721
23795
|
() => `${func.name}: ${offsetToString(
|
|
@@ -23738,7 +23812,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23738
23812
|
delete next.preds;
|
|
23739
23813
|
removeBlock(func, next.offset);
|
|
23740
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) {
|
|
23741
|
-
(0,
|
|
23815
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
23742
23816
|
"cfg",
|
|
23743
23817
|
1,
|
|
23744
23818
|
() => `${func.name}: ${offsetToString(
|
|
@@ -23763,7 +23837,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23763
23837
|
switch (last.op) {
|
|
23764
23838
|
case 41:
|
|
23765
23839
|
case 40:
|
|
23766
|
-
(0,
|
|
23840
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
23767
23841
|
"cfg",
|
|
23768
23842
|
1,
|
|
23769
23843
|
() => `${func.name}: killing no-op ${bytecodeToString(
|
|
@@ -23786,7 +23860,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23786
23860
|
for (let i = block.try.length; i--; ) {
|
|
23787
23861
|
const handler = block.try[i].handler;
|
|
23788
23862
|
if (!func.blocks.get(handler)?.preds?.size) {
|
|
23789
|
-
(0,
|
|
23863
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
23790
23864
|
"cfg",
|
|
23791
23865
|
1,
|
|
23792
23866
|
`${func.name}: killing unused try-catch at ${offsetToString(
|
|
@@ -23803,8 +23877,8 @@ function removeUnreachableCatches(func, context) {
|
|
|
23803
23877
|
});
|
|
23804
23878
|
}
|
|
23805
23879
|
function cleanCfg2(func, context) {
|
|
23806
|
-
if ((0,
|
|
23807
|
-
(0,
|
|
23880
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("cfg", 10)) {
|
|
23881
|
+
(0, import_chunk_OASVKTK5.setBanner)(functionBanner(func, context, "sharing"));
|
|
23808
23882
|
}
|
|
23809
23883
|
removeNoOpBlocks(func);
|
|
23810
23884
|
removeUnreachableCatches(func, context);
|
|
@@ -23819,12 +23893,12 @@ function cleanCfg2(func, context) {
|
|
|
23819
23893
|
(0, import_node_assert12.default)(!block.preds?.size);
|
|
23820
23894
|
func.blocks.delete(block.offset);
|
|
23821
23895
|
});
|
|
23822
|
-
(0,
|
|
23896
|
+
(0, import_chunk_OASVKTK5.setBanner)(null);
|
|
23823
23897
|
}
|
|
23824
23898
|
var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
23825
23899
|
"src/readprg/optimize.ts"() {
|
|
23826
23900
|
"use strict";
|
|
23827
|
-
(0,
|
|
23901
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
23828
23902
|
init_array_init();
|
|
23829
23903
|
init_bytecode();
|
|
23830
23904
|
init_cflow();
|
|
@@ -24439,21 +24513,21 @@ function optimizeBytecode(context) {
|
|
|
24439
24513
|
functions.forEach(callback);
|
|
24440
24514
|
return;
|
|
24441
24515
|
}
|
|
24442
|
-
(0,
|
|
24516
|
+
(0, import_chunk_OASVKTK5.bumpLogging)(null, 10);
|
|
24443
24517
|
functions.forEach((func) => {
|
|
24444
24518
|
if (loggerFunc.test(func.name ?? "<null>")) {
|
|
24445
|
-
(0,
|
|
24519
|
+
(0, import_chunk_OASVKTK5.bumpLogging)(null, -10);
|
|
24446
24520
|
callback(func);
|
|
24447
|
-
(0,
|
|
24521
|
+
(0, import_chunk_OASVKTK5.bumpLogging)(null, 10);
|
|
24448
24522
|
return;
|
|
24449
24523
|
}
|
|
24450
24524
|
callback(func);
|
|
24451
24525
|
});
|
|
24452
|
-
(0,
|
|
24526
|
+
(0, import_chunk_OASVKTK5.bumpLogging)(null, -10);
|
|
24453
24527
|
};
|
|
24454
|
-
if ((0,
|
|
24528
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("list-input", 1)) {
|
|
24455
24529
|
forEachFunction(
|
|
24456
|
-
(func) => (0,
|
|
24530
|
+
(func) => (0, import_chunk_OASVKTK5.wouldLog)("list-input", 1) && printFunction(func, context)
|
|
24457
24531
|
);
|
|
24458
24532
|
}
|
|
24459
24533
|
forEachFunction((func) => optimizeFunc(func, context));
|
|
@@ -24471,7 +24545,7 @@ function optimizeBytecode(context) {
|
|
|
24471
24545
|
forEachFunction((func) => {
|
|
24472
24546
|
if (!func.name)
|
|
24473
24547
|
return;
|
|
24474
|
-
(0,
|
|
24548
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
24475
24549
|
"bytecode",
|
|
24476
24550
|
5,
|
|
24477
24551
|
`${func.name}: ${offset.toString(16)} ${offset - func.offset}`
|
|
@@ -24480,7 +24554,7 @@ function optimizeBytecode(context) {
|
|
|
24480
24554
|
});
|
|
24481
24555
|
const { offsetMap } = updateInfo;
|
|
24482
24556
|
offsetMap.set(code.byteLength, offset);
|
|
24483
|
-
(0,
|
|
24557
|
+
(0, import_chunk_OASVKTK5.logger)(
|
|
24484
24558
|
"bytecode",
|
|
24485
24559
|
1,
|
|
24486
24560
|
`${context.filepath}: code size: ${context.sections[
|
|
@@ -24492,9 +24566,9 @@ function optimizeBytecode(context) {
|
|
|
24492
24566
|
].length - offset}`
|
|
24493
24567
|
);
|
|
24494
24568
|
fixSectionSize(-1059145026, context.sections, offset);
|
|
24495
|
-
if ((0,
|
|
24569
|
+
if ((0, import_chunk_OASVKTK5.wouldLog)("list-output", 1)) {
|
|
24496
24570
|
forEachFunction(
|
|
24497
|
-
(func) => (0,
|
|
24571
|
+
(func) => (0, import_chunk_OASVKTK5.wouldLog)("list-output", 1) && printFunction(func, context)
|
|
24498
24572
|
);
|
|
24499
24573
|
}
|
|
24500
24574
|
fixupHeader(context, updateInfo);
|
|
@@ -24584,7 +24658,7 @@ ${functionToString(
|
|
|
24584
24658
|
---------------- ${func.name} ----------------`;
|
|
24585
24659
|
}
|
|
24586
24660
|
function printFunction(func, context) {
|
|
24587
|
-
(0,
|
|
24661
|
+
(0, import_chunk_OASVKTK5.log)(functionToString(func, context));
|
|
24588
24662
|
}
|
|
24589
24663
|
function functionToString(func, context, extra) {
|
|
24590
24664
|
const parts = [];
|
|
@@ -25015,7 +25089,7 @@ var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
25015
25089
|
"use strict";
|
|
25016
25090
|
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
25017
25091
|
init_sdk_util();
|
|
25018
|
-
(0,
|
|
25092
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
25019
25093
|
init_data();
|
|
25020
25094
|
init_emit();
|
|
25021
25095
|
init_exceptions();
|
|
@@ -25301,10 +25375,10 @@ async function build_project(product, options, lineCallback) {
|
|
|
25301
25375
|
].flat();
|
|
25302
25376
|
if (!returnCommand) {
|
|
25303
25377
|
const handlers = [
|
|
25304
|
-
lineCallback || ((line) => (0,
|
|
25378
|
+
lineCallback || ((line) => (0, import_chunk_OASVKTK5.log)(line)),
|
|
25305
25379
|
(line) => console.error(line)
|
|
25306
25380
|
];
|
|
25307
|
-
await (0,
|
|
25381
|
+
await (0, import_chunk_OASVKTK5.spawnByLine)(exe, args, handlers, {
|
|
25308
25382
|
cwd: workspace
|
|
25309
25383
|
});
|
|
25310
25384
|
}
|
|
@@ -25314,7 +25388,7 @@ var init_build = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
25314
25388
|
"src/build.ts"() {
|
|
25315
25389
|
"use strict";
|
|
25316
25390
|
init_sdk_util();
|
|
25317
|
-
(0,
|
|
25391
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
25318
25392
|
}
|
|
25319
25393
|
});
|
|
25320
25394
|
var require_ms = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
@@ -28281,7 +28355,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28281
28355
|
);
|
|
28282
28356
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(cache.resolvedPaths, resolved)) {
|
|
28283
28357
|
if (/[*?[\]{}]/.test(resolved)) {
|
|
28284
|
-
cache.resolvedPaths[resolved] = (0,
|
|
28358
|
+
cache.resolvedPaths[resolved] = (0, import_chunk_OASVKTK5.globSome)(resolved, () => true);
|
|
28285
28359
|
} else {
|
|
28286
28360
|
cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
|
|
28287
28361
|
() => true,
|
|
@@ -28359,12 +28433,12 @@ async function read_resource_files(targets, cache) {
|
|
|
28359
28433
|
if (!(0, import_chunk_MBTLUWXR.hasProperty)(resourceGroupPromises, key)) {
|
|
28360
28434
|
resourceGroupPromises[key] = Promise.all(
|
|
28361
28435
|
p.qualifier.resourcePath.map(
|
|
28362
|
-
(pattern) => (0,
|
|
28436
|
+
(pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { mark: true })
|
|
28363
28437
|
)
|
|
28364
28438
|
).then(
|
|
28365
28439
|
(patterns) => Promise.all(
|
|
28366
28440
|
patterns.flat().map(
|
|
28367
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
28441
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*.xml`, { mark: true }) : path7
|
|
28368
28442
|
)
|
|
28369
28443
|
)
|
|
28370
28444
|
).then(
|
|
@@ -28424,7 +28498,7 @@ async function find_build_instructions_in_resource(file, rez, buildDependencies)
|
|
|
28424
28498
|
const sourceExcludes = excludes.map((e) => e.file?.value.value).filter((f) => f != null).map((f) => path2.resolve(dir, f).replace(/\\/g, "/"));
|
|
28425
28499
|
const filePatterns = excludes.map((e) => e.dir?.value.value).filter((f) => f != null).map((f) => path2.join(dir, f, "**", "*.mc").replace(/\\/g, "/"));
|
|
28426
28500
|
if (filePatterns.length) {
|
|
28427
|
-
const files = (await Promise.all(filePatterns.map((p) => (0,
|
|
28501
|
+
const files = (await Promise.all(filePatterns.map((p) => (0, import_chunk_OASVKTK5.globa)(p)))).flat();
|
|
28428
28502
|
sourceExcludes.push(...files);
|
|
28429
28503
|
}
|
|
28430
28504
|
const excludeAnnotations = excludes.map((e) => e.annotation?.value.value).filter((f) => f != null);
|
|
@@ -28601,15 +28675,15 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28601
28675
|
function find_barrels(barrelPath) {
|
|
28602
28676
|
if (Array.isArray(barrelPath)) {
|
|
28603
28677
|
return Promise.all(
|
|
28604
|
-
barrelPath.map((path7) => (0,
|
|
28678
|
+
barrelPath.map((path7) => (0, import_chunk_OASVKTK5.globa)(path7, { mark: true }))
|
|
28605
28679
|
).then((paths) => [
|
|
28606
28680
|
paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
|
|
28607
28681
|
]);
|
|
28608
28682
|
}
|
|
28609
|
-
return (0,
|
|
28683
|
+
return (0, import_chunk_OASVKTK5.globa)(barrelPath, { mark: true }).then(
|
|
28610
28684
|
(paths) => Promise.all(
|
|
28611
28685
|
paths.map(
|
|
28612
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
28686
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*.barrel`) : path7
|
|
28613
28687
|
)
|
|
28614
28688
|
)
|
|
28615
28689
|
).then(
|
|
@@ -28882,7 +28956,7 @@ var init_jungles = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
28882
28956
|
init_api();
|
|
28883
28957
|
init_manifest();
|
|
28884
28958
|
init_sdk_util();
|
|
28885
|
-
(0,
|
|
28959
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
28886
28960
|
depth = 0;
|
|
28887
28961
|
}
|
|
28888
28962
|
});
|
|
@@ -28910,7 +28984,7 @@ async function launchSimulator(force = true) {
|
|
|
28910
28984
|
await new Promise((r) => setTimeout(r, 200));
|
|
28911
28985
|
}
|
|
28912
28986
|
} catch (e) {
|
|
28913
|
-
(0,
|
|
28987
|
+
(0, import_chunk_OASVKTK5.log)(e);
|
|
28914
28988
|
}
|
|
28915
28989
|
}
|
|
28916
28990
|
function checkIfSimulatorRunning() {
|
|
@@ -28941,10 +29015,10 @@ function simulateProgram(prg, device, test = false, logger2) {
|
|
|
28941
29015
|
}
|
|
28942
29016
|
}
|
|
28943
29017
|
return getSdkPath().then(
|
|
28944
|
-
(sdk) => (0,
|
|
29018
|
+
(sdk) => (0, import_chunk_OASVKTK5.spawnByLine)(
|
|
28945
29019
|
path3.resolve(sdk, "bin", isWin ? "monkeydo.bat" : "monkeydo"),
|
|
28946
29020
|
args,
|
|
28947
|
-
logger2 || ((line) => (0,
|
|
29021
|
+
logger2 || ((line) => (0, import_chunk_OASVKTK5.log)(line))
|
|
28948
29022
|
).then(() => {
|
|
28949
29023
|
return;
|
|
28950
29024
|
})
|
|
@@ -28954,7 +29028,7 @@ var init_launch = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
28954
29028
|
"src/launch.ts"() {
|
|
28955
29029
|
"use strict";
|
|
28956
29030
|
init_sdk_util();
|
|
28957
|
-
(0,
|
|
29031
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
28958
29032
|
}
|
|
28959
29033
|
});
|
|
28960
29034
|
function relative_path_no_dotdot(relative2) {
|
|
@@ -28975,7 +29049,7 @@ async function getCodeWorkspaceSettings(folder) {
|
|
|
28975
29049
|
let curDir = folder;
|
|
28976
29050
|
try {
|
|
28977
29051
|
while (curDir) {
|
|
28978
|
-
const code_workspaces = await (0,
|
|
29052
|
+
const code_workspaces = await (0, import_chunk_OASVKTK5.globa)(
|
|
28979
29053
|
path4.resolve(curDir, "*.code-workspace"),
|
|
28980
29054
|
{ onlyFiles: true }
|
|
28981
29055
|
);
|
|
@@ -29026,7 +29100,12 @@ function getConfig(options) {
|
|
|
29026
29100
|
}
|
|
29027
29101
|
return settings;
|
|
29028
29102
|
});
|
|
29029
|
-
}, Promise.resolve(null)).then(() =>
|
|
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
|
+
});
|
|
29030
29109
|
}
|
|
29031
29110
|
async function buildOptimizedProject(product, options) {
|
|
29032
29111
|
const config = await getConfig(options);
|
|
@@ -29098,7 +29177,7 @@ async function createLocalBarrels(targets, options) {
|
|
|
29098
29177
|
optBarrelDir
|
|
29099
29178
|
};
|
|
29100
29179
|
return promise2.then(
|
|
29101
|
-
() => (0,
|
|
29180
|
+
() => (0, import_chunk_OASVKTK5.copyRecursiveAsNeeded)(
|
|
29102
29181
|
rawBarrelDir,
|
|
29103
29182
|
optBarrelDir,
|
|
29104
29183
|
(src) => !src.endsWith(".mc")
|
|
@@ -29400,11 +29479,11 @@ async function generateOptimizedProject(options) {
|
|
|
29400
29479
|
}
|
|
29401
29480
|
async function filesFromPaths(workspace, paths, extension) {
|
|
29402
29481
|
paths = (await Promise.all(
|
|
29403
|
-
paths?.map((pattern) => (0,
|
|
29482
|
+
paths?.map((pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { cwd: workspace, mark: true })) || []
|
|
29404
29483
|
)).flat();
|
|
29405
29484
|
const files = await Promise.all(
|
|
29406
29485
|
paths.map(
|
|
29407
|
-
(path7) => path7.endsWith("/") ? (0,
|
|
29486
|
+
(path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*${extension}`, { cwd: workspace, mark: true }) : path7
|
|
29408
29487
|
)
|
|
29409
29488
|
);
|
|
29410
29489
|
return {
|
|
@@ -29514,7 +29593,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29514
29593
|
})
|
|
29515
29594
|
);
|
|
29516
29595
|
}
|
|
29517
|
-
const actualOptimizedFiles = (await (0,
|
|
29596
|
+
const actualOptimizedFiles = (await (0, import_chunk_OASVKTK5.globa)(path4.join(output, "**", "*.mc"), { mark: true })).filter((file) => !file.endsWith("/")).sort();
|
|
29518
29597
|
const {
|
|
29519
29598
|
hasTests,
|
|
29520
29599
|
diagnostics: prevDiagnostics,
|
|
@@ -29530,13 +29609,13 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29530
29609
|
const sdk = await getSdkPath();
|
|
29531
29610
|
const match = sdk.match(/-(\d+\.\d+\.\d+)/);
|
|
29532
29611
|
if ((match && parseSdkVersion(match[1])) === prevSdkVersion) {
|
|
29533
|
-
const source_time = await (0,
|
|
29612
|
+
const source_time = await (0, import_chunk_OASVKTK5.last_modified)(
|
|
29534
29613
|
Object.keys(fnMap).concat(dependencyFiles)
|
|
29535
29614
|
);
|
|
29536
|
-
const opt_time = await (0,
|
|
29615
|
+
const opt_time = await (0, import_chunk_OASVKTK5.first_modified)(
|
|
29537
29616
|
Object.values(fnMap).map((v) => v.output)
|
|
29538
29617
|
);
|
|
29539
|
-
if (source_time < opt_time &&
|
|
29618
|
+
if (source_time < opt_time && 1720052616198 < opt_time) {
|
|
29540
29619
|
return {
|
|
29541
29620
|
hasTests,
|
|
29542
29621
|
diagnostics: prevDiagnostics,
|
|
@@ -29575,7 +29654,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29575
29654
|
hasTests: hasTests2,
|
|
29576
29655
|
diagnostics,
|
|
29577
29656
|
sdkVersion,
|
|
29578
|
-
optimizerVersion: "1.1.
|
|
29657
|
+
optimizerVersion: "1.1.67",
|
|
29579
29658
|
...Object.fromEntries(
|
|
29580
29659
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
29581
29660
|
)
|
|
@@ -29585,15 +29664,12 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29585
29664
|
}
|
|
29586
29665
|
);
|
|
29587
29666
|
}
|
|
29588
|
-
|
|
29589
|
-
|
|
29590
|
-
|
|
29591
|
-
|
|
29592
|
-
|
|
29593
|
-
|
|
29594
|
-
}
|
|
29595
|
-
throw ex;
|
|
29596
|
-
}
|
|
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
|
+
);
|
|
29597
29673
|
}
|
|
29598
29674
|
async function getProjectAnalysisHelper(targets, analysis, manifestXML, options) {
|
|
29599
29675
|
const qualifiers = /* @__PURE__ */ new Map();
|
|
@@ -29659,9 +29735,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29659
29735
|
}
|
|
29660
29736
|
});
|
|
29661
29737
|
}
|
|
29662
|
-
|
|
29663
|
-
return { fnMap, paths };
|
|
29664
|
-
}
|
|
29738
|
+
await getFileASTs(fnMap);
|
|
29665
29739
|
const resourcesMap = {};
|
|
29666
29740
|
const addResources = (name, resources) => {
|
|
29667
29741
|
if (!resources)
|
|
@@ -29680,14 +29754,22 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29680
29754
|
);
|
|
29681
29755
|
}
|
|
29682
29756
|
});
|
|
29683
|
-
|
|
29684
|
-
|
|
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
|
+
}
|
|
29685
29767
|
let typeMap = null;
|
|
29686
|
-
if (state.config?.propagateTypes && state.config.trustDeclaredTypes && state.config.checkTypes !== "OFF"
|
|
29768
|
+
if (state.config?.propagateTypes && state.config.trustDeclaredTypes && state.config.checkTypes !== "OFF") {
|
|
29687
29769
|
const gistate = {
|
|
29688
29770
|
state,
|
|
29689
29771
|
stack: [],
|
|
29690
|
-
typeChecker: state.config.
|
|
29772
|
+
typeChecker: state.config.strictTypeCheck?.toLowerCase() === "on" ? subtypeOf : couldBeWeak,
|
|
29691
29773
|
checkTypes: state.config?.checkTypes || "WARNING"
|
|
29692
29774
|
};
|
|
29693
29775
|
state.pre = (node) => {
|
|
@@ -29716,14 +29798,17 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29716
29798
|
return null;
|
|
29717
29799
|
};
|
|
29718
29800
|
Object.values(state.fnMap).forEach((f) => {
|
|
29719
|
-
collectNamespaces(f.ast, state);
|
|
29801
|
+
f.ast && collectNamespaces(f.ast, state);
|
|
29720
29802
|
});
|
|
29721
29803
|
delete state.pre;
|
|
29722
29804
|
}
|
|
29723
|
-
|
|
29724
|
-
|
|
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
|
+
});
|
|
29725
29810
|
}
|
|
29726
|
-
return { fnMap,
|
|
29811
|
+
return { fnMap, state, typeMap };
|
|
29727
29812
|
}
|
|
29728
29813
|
var defaultConfig, configOptionsToCheck;
|
|
29729
29814
|
var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
@@ -29740,8 +29825,9 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29740
29825
|
init_could_be();
|
|
29741
29826
|
init_interp();
|
|
29742
29827
|
init_sub_type();
|
|
29743
|
-
(0,
|
|
29828
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
29744
29829
|
init_worker_pool();
|
|
29830
|
+
init_pragma_checker();
|
|
29745
29831
|
init_optimizer_types();
|
|
29746
29832
|
init_types();
|
|
29747
29833
|
defaultConfig = {
|
|
@@ -29800,7 +29886,7 @@ async function performTask(task) {
|
|
|
29800
29886
|
throw new Error(`Invalid task type ${type}`);
|
|
29801
29887
|
}
|
|
29802
29888
|
return Promise.resolve(handler(task.data)).then(
|
|
29803
|
-
(result) =>
|
|
29889
|
+
(result) => import_chunk_OASVKTK5.logPromise.then(() => result)
|
|
29804
29890
|
);
|
|
29805
29891
|
}
|
|
29806
29892
|
var workerTaskHandlers;
|
|
@@ -29810,7 +29896,7 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29810
29896
|
init_optimizer();
|
|
29811
29897
|
init_readprg();
|
|
29812
29898
|
init_sdk_util();
|
|
29813
|
-
(0,
|
|
29899
|
+
(0, import_chunk_OASVKTK5.init_logger)();
|
|
29814
29900
|
workerTaskHandlers = {
|
|
29815
29901
|
buildOptimizedProject(data) {
|
|
29816
29902
|
return buildOptimizedProject(data.product, data.options);
|
|
@@ -30027,7 +30113,7 @@ async function optimizeProgram(filepath, devKey, output, config) {
|
|
|
30027
30113
|
}
|
|
30028
30114
|
function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, config) {
|
|
30029
30115
|
const { sections } = readPrgWithOffsets(view);
|
|
30030
|
-
(0,
|
|
30116
|
+
(0, import_chunk_OASVKTK5.logger)("readprg", 5, sections);
|
|
30031
30117
|
const symbolTable = new SymbolTable();
|
|
30032
30118
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(sections, 1461170197 .toString())) {
|
|
30033
30119
|
symbolTable.parse(sections[
|
|
@@ -30327,7 +30413,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
30327
30413
|
init_signer();
|
|
30328
30414
|
init_symbols();
|
|
30329
30415
|
init_sdk_util();
|
|
30330
|
-
(0,
|
|
30416
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
30331
30417
|
init_worker_pool();
|
|
30332
30418
|
}
|
|
30333
30419
|
});
|
|
@@ -30339,7 +30425,7 @@ function getSdkPath() {
|
|
|
30339
30425
|
});
|
|
30340
30426
|
}
|
|
30341
30427
|
async function getDeviceInfo() {
|
|
30342
|
-
const files = await (0,
|
|
30428
|
+
const files = await (0, import_chunk_OASVKTK5.globa)(`${connectiq}/Devices/*/compiler.json`);
|
|
30343
30429
|
if (!files.length) {
|
|
30344
30430
|
throw new Error(
|
|
30345
30431
|
`No devices found at '${connectiq}/Devices'. Check your sdk is correctly installed`
|
|
@@ -30407,7 +30493,7 @@ async function getFunctionDocumentation() {
|
|
|
30407
30493
|
var isWin, appSupport, connectiq;
|
|
30408
30494
|
var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
30409
30495
|
"src/sdk-util.ts"() {
|
|
30410
|
-
(0,
|
|
30496
|
+
(0, import_chunk_OASVKTK5.init_util)();
|
|
30411
30497
|
init_xml_util();
|
|
30412
30498
|
init_readprg();
|
|
30413
30499
|
init_bytecode();
|
|
@@ -30455,6 +30541,7 @@ var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
30455
30541
|
getConfig,
|
|
30456
30542
|
getDeviceInfo,
|
|
30457
30543
|
getFileASTs,
|
|
30544
|
+
getFnMapAnalysis,
|
|
30458
30545
|
getFunctionDocumentation,
|
|
30459
30546
|
getLanguages,
|
|
30460
30547
|
getProjectAnalysis,
|