@markw65/monkeyc-optimizer 1.1.67 → 1.1.69
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 +13 -0
- package/build/api.cjs +37 -37
- package/build/cftinfo.cjs +4 -4
- package/build/{chunk-MBTLUWXR.cjs → chunk-JDC43A3I.cjs} +5 -5
- package/build/{chunk-2OEXWI65.cjs → chunk-YERUPFGW.cjs} +406 -320
- package/build/optimizer.cjs +19 -19
- package/build/sdk-util.cjs +15 -15
- package/build/src/ast.d.ts +1 -1
- package/build/src/optimizer.d.ts +1 -1
- package/build/src/worker-task.d.ts +1 -0
- package/build/worker-thread.cjs +4 -4
- package/package.json +1 -1
|
@@ -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_YERUPFGW_exports = {};
|
|
30
|
+
__export(chunk_YERUPFGW_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -135,9 +135,9 @@ __export(chunk_2OEXWI65_exports, {
|
|
|
135
135
|
visitorNode: () => visitorNode,
|
|
136
136
|
xml_util_exports: () => xml_util_exports
|
|
137
137
|
});
|
|
138
|
-
module.exports = __toCommonJS(
|
|
138
|
+
module.exports = __toCommonJS(chunk_YERUPFGW_exports);
|
|
139
139
|
var import_chunk_OASVKTK5 = require("./chunk-OASVKTK5.cjs");
|
|
140
|
-
var
|
|
140
|
+
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
141
141
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
142
142
|
var import_node_assert = __toESM(require("node:assert"));
|
|
143
143
|
var import_prettier_plugin_monkeyc = require("@markw65/prettier-plugin-monkeyc");
|
|
@@ -3196,7 +3196,7 @@ var init_xml_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
3196
3196
|
"src/xml-util.ts"() {
|
|
3197
3197
|
"use strict";
|
|
3198
3198
|
init_xml();
|
|
3199
|
-
(0,
|
|
3199
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
3200
3200
|
PeggyError = class extends Error {
|
|
3201
3201
|
constructor(message, location) {
|
|
3202
3202
|
super(message);
|
|
@@ -3244,11 +3244,11 @@ var init_xml_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
3244
3244
|
result.push(String.fromCharCode(child.value));
|
|
3245
3245
|
return true;
|
|
3246
3246
|
case "entityref":
|
|
3247
|
-
if ((0,
|
|
3247
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(entities, child.name)) {
|
|
3248
3248
|
result.push(entities[child.name]);
|
|
3249
3249
|
return true;
|
|
3250
3250
|
}
|
|
3251
|
-
if ((0,
|
|
3251
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(this.entities, child.name)) {
|
|
3252
3252
|
result.push(
|
|
3253
3253
|
this.processRefs(referenceList(this.entities[child.name].value))
|
|
3254
3254
|
);
|
|
@@ -3273,13 +3273,13 @@ var init_xml_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
3273
3273
|
} else if (hexref) {
|
|
3274
3274
|
return String.fromCharCode(parseInt(decref, 16));
|
|
3275
3275
|
} else if (entref) {
|
|
3276
|
-
if ((0,
|
|
3276
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(entities, entref)) {
|
|
3277
3277
|
return entities[entref];
|
|
3278
3278
|
}
|
|
3279
|
-
if ((0,
|
|
3279
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(this.entities, entref)) {
|
|
3280
3280
|
return referenceList(this.entities[entref].value);
|
|
3281
3281
|
}
|
|
3282
|
-
} else if ((0,
|
|
3282
|
+
} else if ((0, import_chunk_JDC43A3I.hasProperty)(this.pentities, peref)) {
|
|
3283
3283
|
return referenceList(this.pentities[peref].value);
|
|
3284
3284
|
}
|
|
3285
3285
|
return "";
|
|
@@ -5526,7 +5526,7 @@ function findCallees(lookupDefs) {
|
|
|
5526
5526
|
}
|
|
5527
5527
|
function findCalleesForNew(lookupDefs) {
|
|
5528
5528
|
const initializer = (decl) => {
|
|
5529
|
-
if ((0,
|
|
5529
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(decl.decls, "initialize")) {
|
|
5530
5530
|
return decl.decls["initialize"];
|
|
5531
5531
|
}
|
|
5532
5532
|
if (decl.superClass && decl.superClass !== true) {
|
|
@@ -5554,12 +5554,12 @@ function findCalleesByNode(state, callee) {
|
|
|
5554
5554
|
const name = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && !callee.computed ? callee.property.name : null;
|
|
5555
5555
|
if (!name)
|
|
5556
5556
|
return null;
|
|
5557
|
-
return (0,
|
|
5557
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(state.allFunctions, name) && state.allFunctions[name] || null;
|
|
5558
5558
|
}
|
|
5559
5559
|
var init_function_info = (0, import_chunk_ABYVSU2C.__esm)({
|
|
5560
5560
|
"src/function-info.ts"() {
|
|
5561
5561
|
"use strict";
|
|
5562
|
-
(0,
|
|
5562
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
5563
5563
|
}
|
|
5564
5564
|
});
|
|
5565
5565
|
var buildConfigDescription;
|
|
@@ -5883,7 +5883,7 @@ function renameIdentifier(ident, newName) {
|
|
|
5883
5883
|
function renameVariable(state, locals, declName2) {
|
|
5884
5884
|
const map2 = locals.map;
|
|
5885
5885
|
if (declName2) {
|
|
5886
|
-
if (!(0,
|
|
5886
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(map2, declName2))
|
|
5887
5887
|
return null;
|
|
5888
5888
|
} else {
|
|
5889
5889
|
declName2 = "tmp";
|
|
@@ -5898,7 +5898,7 @@ function renameVariable(state, locals, declName2) {
|
|
|
5898
5898
|
if (!locals.inners) {
|
|
5899
5899
|
locals.inners = {};
|
|
5900
5900
|
const inners = locals.inners;
|
|
5901
|
-
(0,
|
|
5901
|
+
(0, import_chunk_JDC43A3I.traverseAst)(locals.node, (node) => {
|
|
5902
5902
|
if (node.type === "VariableDeclarator") {
|
|
5903
5903
|
inners[variableDeclarationName(node.id)] = true;
|
|
5904
5904
|
}
|
|
@@ -5907,13 +5907,13 @@ function renameVariable(state, locals, declName2) {
|
|
|
5907
5907
|
let name;
|
|
5908
5908
|
while (true) {
|
|
5909
5909
|
name = `pmcr_${node_name}_${suffix}`;
|
|
5910
|
-
if (!(0,
|
|
5910
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(map2, name) && !(0, import_chunk_JDC43A3I.hasProperty)(locals.inners, name)) {
|
|
5911
5911
|
let ok = false;
|
|
5912
5912
|
let i;
|
|
5913
5913
|
for (i = state.stack.length; i--; ) {
|
|
5914
5914
|
const elm = state.stack[i].sn;
|
|
5915
5915
|
if (ok) {
|
|
5916
|
-
if ((0,
|
|
5916
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(elm.decls, name)) {
|
|
5917
5917
|
break;
|
|
5918
5918
|
}
|
|
5919
5919
|
} else if (elm.node && elm.node.type === "FunctionDeclaration") {
|
|
@@ -5934,7 +5934,7 @@ var init_variable_renamer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
5934
5934
|
"src/variable-renamer.ts"() {
|
|
5935
5935
|
"use strict";
|
|
5936
5936
|
init_api();
|
|
5937
|
-
(0,
|
|
5937
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
5938
5938
|
}
|
|
5939
5939
|
});
|
|
5940
5940
|
function inlinableSubExpression(expr) {
|
|
@@ -6070,7 +6070,7 @@ function getArgSafety(state, func, args, requireAll) {
|
|
|
6070
6070
|
case "AssignmentExpression":
|
|
6071
6071
|
case "UpdateExpression": {
|
|
6072
6072
|
const v = node.type === "UpdateExpression" ? node.argument : node.left;
|
|
6073
|
-
if (v.type === "Identifier" && (0,
|
|
6073
|
+
if (v.type === "Identifier" && (0, import_chunk_JDC43A3I.hasProperty)(params, v.name)) {
|
|
6074
6074
|
safeArgs[params[v.name]] = null;
|
|
6075
6075
|
break;
|
|
6076
6076
|
}
|
|
@@ -6116,7 +6116,7 @@ function getArgSafety(state, func, args, requireAll) {
|
|
|
6116
6116
|
}
|
|
6117
6117
|
break;
|
|
6118
6118
|
case "Identifier":
|
|
6119
|
-
if ((0,
|
|
6119
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(params, node.name) && !safeArgs[params[node.name]] && (modifiedUnknown || !argDecls[params[node.name]] || modifiedDecls.has(argDecls[params[node.name]]) || Array.from(callsSeen).some(
|
|
6120
6120
|
(callee) => functionMayModify(state, callee, argDecls[params[node.name]])
|
|
6121
6121
|
))) {
|
|
6122
6122
|
safeArgs[params[node.name]] = null;
|
|
@@ -6195,7 +6195,7 @@ function inliningLooksUseful(state, func, node) {
|
|
|
6195
6195
|
function inlineRequestedNode(state, func) {
|
|
6196
6196
|
const excludeAnnotations = func.loc?.source && state.fnMap[func.loc?.source]?.excludeAnnotations || {};
|
|
6197
6197
|
if (func.attrs && func.attrs.attributes && func.attrs.attributes.elements.some(
|
|
6198
|
-
(attr) => attr.type === "UnaryExpression" && (attr.argument.name === "inline" || attr.argument.name.startsWith("inline_") && !(0,
|
|
6198
|
+
(attr) => attr.type === "UnaryExpression" && (attr.argument.name === "inline" || attr.argument.name.startsWith("inline_") && !(0, import_chunk_JDC43A3I.hasProperty)(excludeAnnotations, attr.argument.name.substring(7)))
|
|
6199
6199
|
)) {
|
|
6200
6200
|
return true;
|
|
6201
6201
|
}
|
|
@@ -6309,7 +6309,7 @@ function processInlineBody(state, func, call, root, params) {
|
|
|
6309
6309
|
const fixId = (node) => {
|
|
6310
6310
|
if (state.inType)
|
|
6311
6311
|
return null;
|
|
6312
|
-
if ((0,
|
|
6312
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(params, node.name)) {
|
|
6313
6313
|
const ix = params[node.name];
|
|
6314
6314
|
if (ix >= 0) {
|
|
6315
6315
|
const replacement2 = { ...call.arguments[ix] };
|
|
@@ -6379,7 +6379,7 @@ function processInlineBody(state, func, call, root, params) {
|
|
|
6379
6379
|
}
|
|
6380
6380
|
}
|
|
6381
6381
|
function unused(state, expression, top) {
|
|
6382
|
-
const estmt = (expression2) => (0,
|
|
6382
|
+
const estmt = (expression2) => (0, import_chunk_JDC43A3I.withLoc)(
|
|
6383
6383
|
{
|
|
6384
6384
|
type: "ExpressionStatement",
|
|
6385
6385
|
expression: expression2
|
|
@@ -6404,7 +6404,7 @@ function unused(state, expression, top) {
|
|
|
6404
6404
|
const right = unused(state, expression.right);
|
|
6405
6405
|
if (!right.length)
|
|
6406
6406
|
return unused(state, expression.left);
|
|
6407
|
-
const consequent = (0,
|
|
6407
|
+
const consequent = (0, import_chunk_JDC43A3I.withLoc)(
|
|
6408
6408
|
{
|
|
6409
6409
|
type: "BlockStatement",
|
|
6410
6410
|
body: [estmt(expression.right)]
|
|
@@ -6417,7 +6417,7 @@ function unused(state, expression, top) {
|
|
|
6417
6417
|
consequent.body = [];
|
|
6418
6418
|
}
|
|
6419
6419
|
return [
|
|
6420
|
-
(0,
|
|
6420
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
6421
6421
|
{
|
|
6422
6422
|
type: "IfStatement",
|
|
6423
6423
|
test: expression.left,
|
|
@@ -6435,18 +6435,18 @@ function unused(state, expression, top) {
|
|
|
6435
6435
|
return unused(state, expression.test);
|
|
6436
6436
|
}
|
|
6437
6437
|
return [
|
|
6438
|
-
(0,
|
|
6438
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
6439
6439
|
{
|
|
6440
6440
|
type: "IfStatement",
|
|
6441
6441
|
test: expression.test,
|
|
6442
|
-
consequent: (0,
|
|
6442
|
+
consequent: (0, import_chunk_JDC43A3I.withLoc)(
|
|
6443
6443
|
{
|
|
6444
6444
|
type: "BlockStatement",
|
|
6445
6445
|
body: consequentExprs
|
|
6446
6446
|
},
|
|
6447
6447
|
expression.consequent
|
|
6448
6448
|
),
|
|
6449
|
-
alternate: (0,
|
|
6449
|
+
alternate: (0, import_chunk_JDC43A3I.withLoc)(
|
|
6450
6450
|
{
|
|
6451
6451
|
type: "BlockStatement",
|
|
6452
6452
|
body: alternateExprs
|
|
@@ -6514,7 +6514,7 @@ function inlineWithArgs(state, func, call, context) {
|
|
|
6514
6514
|
return null;
|
|
6515
6515
|
}
|
|
6516
6516
|
} else {
|
|
6517
|
-
(0,
|
|
6517
|
+
(0, import_chunk_JDC43A3I.traverseAst)(func.node.body, (node) => {
|
|
6518
6518
|
node.type === "ReturnStatement" && retStmtCount++;
|
|
6519
6519
|
});
|
|
6520
6520
|
if (retStmtCount > 1) {
|
|
@@ -6548,7 +6548,7 @@ function inlineWithArgs(state, func, call, context) {
|
|
|
6548
6548
|
}
|
|
6549
6549
|
}
|
|
6550
6550
|
}
|
|
6551
|
-
const body = (0,
|
|
6551
|
+
const body = (0, import_chunk_JDC43A3I.cloneDeep)(func.node.body);
|
|
6552
6552
|
const safeArgs = getArgSafety(state, func, call.arguments, false);
|
|
6553
6553
|
const params = Object.fromEntries(
|
|
6554
6554
|
func.node.params.map((param, i) => {
|
|
@@ -6636,7 +6636,7 @@ function updateLocationForInline(node, original, context, func) {
|
|
|
6636
6636
|
if (!loc) {
|
|
6637
6637
|
throw new Error("Internal error: Inlined call had no location info");
|
|
6638
6638
|
}
|
|
6639
|
-
(0,
|
|
6639
|
+
(0, import_chunk_JDC43A3I.traverseAst)(node, (node2) => {
|
|
6640
6640
|
if (!node2.loc || node2.loc.source !== loc.source || node2.loc.start.offset > loc.end.offset || node2.loc.end.offset <= loc.start.offset) {
|
|
6641
6641
|
if (node2.loc) {
|
|
6642
6642
|
if (!node2.origins) {
|
|
@@ -6644,7 +6644,7 @@ function updateLocationForInline(node, original, context, func) {
|
|
|
6644
6644
|
}
|
|
6645
6645
|
node2.origins.unshift({ loc: node2.loc, func: func.fullName });
|
|
6646
6646
|
}
|
|
6647
|
-
(0,
|
|
6647
|
+
(0, import_chunk_JDC43A3I.withLoc)(node2, context, context === original ? context : false);
|
|
6648
6648
|
}
|
|
6649
6649
|
});
|
|
6650
6650
|
return node;
|
|
@@ -6656,7 +6656,7 @@ function inlineFunctionHelper(state, func, call, context) {
|
|
|
6656
6656
|
if (context) {
|
|
6657
6657
|
return inlineWithArgs(state, func, call, context);
|
|
6658
6658
|
}
|
|
6659
|
-
const retArg = (0,
|
|
6659
|
+
const retArg = (0, import_chunk_JDC43A3I.cloneDeep)(
|
|
6660
6660
|
func.node.body.body[0].argument
|
|
6661
6661
|
);
|
|
6662
6662
|
const params = Object.fromEntries(
|
|
@@ -6693,7 +6693,7 @@ function inlineFunction(state, func, call, context) {
|
|
|
6693
6693
|
return ret;
|
|
6694
6694
|
}
|
|
6695
6695
|
if (!caller.attrs) {
|
|
6696
|
-
caller.attrs = (0,
|
|
6696
|
+
caller.attrs = (0, import_chunk_JDC43A3I.withLoc)(
|
|
6697
6697
|
{
|
|
6698
6698
|
type: "AttributeList"
|
|
6699
6699
|
},
|
|
@@ -6702,7 +6702,7 @@ function inlineFunction(state, func, call, context) {
|
|
|
6702
6702
|
);
|
|
6703
6703
|
}
|
|
6704
6704
|
if (!caller.attrs.attributes) {
|
|
6705
|
-
caller.attrs.attributes = (0,
|
|
6705
|
+
caller.attrs.attributes = (0, import_chunk_JDC43A3I.withLoc)(
|
|
6706
6706
|
{ type: "Attributes", elements: [] },
|
|
6707
6707
|
caller.attrs,
|
|
6708
6708
|
false
|
|
@@ -6710,7 +6710,7 @@ function inlineFunction(state, func, call, context) {
|
|
|
6710
6710
|
}
|
|
6711
6711
|
caller.attrs.attributes.elements.unshift(
|
|
6712
6712
|
...typecheckAttrs.map(
|
|
6713
|
-
(typecheck) => (0,
|
|
6713
|
+
(typecheck) => (0, import_chunk_JDC43A3I.withLocDeep)({ ...typecheck }, caller.attrs, false)
|
|
6714
6714
|
)
|
|
6715
6715
|
);
|
|
6716
6716
|
return ret;
|
|
@@ -6732,7 +6732,7 @@ function fixNodeScope(state, lookupNode, nodeStack) {
|
|
|
6732
6732
|
const { map: map2 } = locals;
|
|
6733
6733
|
if (!map2)
|
|
6734
6734
|
throw new Error("No local variable map!");
|
|
6735
|
-
if ((0,
|
|
6735
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(map2, lookupNode.name) && map2[lookupNode.name] !== false) {
|
|
6736
6736
|
return lookupNode;
|
|
6737
6737
|
}
|
|
6738
6738
|
}
|
|
@@ -6812,7 +6812,7 @@ function fixNodeScope(state, lookupNode, nodeStack) {
|
|
|
6812
6812
|
return null;
|
|
6813
6813
|
}
|
|
6814
6814
|
function reportFailedInlining(state, ast) {
|
|
6815
|
-
(0,
|
|
6815
|
+
(0, import_chunk_JDC43A3I.traverseAst)(ast, (node) => {
|
|
6816
6816
|
switch (node.type) {
|
|
6817
6817
|
case "FunctionDeclaration":
|
|
6818
6818
|
if (inlineRequestedNode(state, node)) {
|
|
@@ -6837,7 +6837,7 @@ var init_inliner = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
6837
6837
|
"src/inliner.ts"() {
|
|
6838
6838
|
"use strict";
|
|
6839
6839
|
init_api();
|
|
6840
|
-
(0,
|
|
6840
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
6841
6841
|
init_function_info();
|
|
6842
6842
|
init_optimizer_types();
|
|
6843
6843
|
init_variable_renamer();
|
|
@@ -6907,7 +6907,7 @@ function pragmaChecker(state, ast, diagnostics) {
|
|
|
6907
6907
|
};
|
|
6908
6908
|
next();
|
|
6909
6909
|
let promise = Promise.resolve();
|
|
6910
|
-
(0,
|
|
6910
|
+
(0, import_chunk_JDC43A3I.traverseAst)(ast, (node) => {
|
|
6911
6911
|
if (index >= comments.length || node.type === "Line" || node.type === "Block" || node.type === "MultiLine") {
|
|
6912
6912
|
return false;
|
|
6913
6913
|
}
|
|
@@ -6987,7 +6987,7 @@ var init_pragma_checker = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
6987
6987
|
"src/pragma-checker.ts"() {
|
|
6988
6988
|
"use strict";
|
|
6989
6989
|
init_api();
|
|
6990
|
-
(0,
|
|
6990
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
6991
6991
|
}
|
|
6992
6992
|
});
|
|
6993
6993
|
function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
@@ -7006,14 +7006,14 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
|
7006
7006
|
if (state.inType || localState.unreachable) {
|
|
7007
7007
|
return [];
|
|
7008
7008
|
}
|
|
7009
|
-
if (!localState.curBlock.node && ((0,
|
|
7009
|
+
if (!localState.curBlock.node && ((0, import_chunk_JDC43A3I.isStatement)(node) || (0, import_chunk_JDC43A3I.isExpression)(node))) {
|
|
7010
7010
|
localState.curBlock.node = node;
|
|
7011
7011
|
}
|
|
7012
7012
|
let topTest = testStack[testStack.length - 1];
|
|
7013
7013
|
if (topTest.node !== node && topTest.true) {
|
|
7014
7014
|
testStack.push(topTest = { node });
|
|
7015
7015
|
}
|
|
7016
|
-
if ((0,
|
|
7016
|
+
if ((0, import_chunk_JDC43A3I.isStatement)(node)) {
|
|
7017
7017
|
stmtStack.push(node);
|
|
7018
7018
|
}
|
|
7019
7019
|
switch (node.type) {
|
|
@@ -7330,7 +7330,7 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
|
7330
7330
|
const curStmt = stmtStack[stmtStack.length - 1];
|
|
7331
7331
|
const topTest = testStack[testStack.length - 1];
|
|
7332
7332
|
if (!state.inType) {
|
|
7333
|
-
const throws = tryActive > 0 && (0,
|
|
7333
|
+
const throws = tryActive > 0 && (0, import_chunk_JDC43A3I.mayThrow)(node);
|
|
7334
7334
|
const events = notice(node, curStmt, throws, getContainedEvents);
|
|
7335
7335
|
if (throws) {
|
|
7336
7336
|
if (!events) {
|
|
@@ -7391,7 +7391,7 @@ function buildReducedGraph(state, func, refsForUpdate, notice) {
|
|
|
7391
7391
|
}
|
|
7392
7392
|
if (curStmt === node) {
|
|
7393
7393
|
stmtStack.pop();
|
|
7394
|
-
} else if (localState.unreachable && curStmt.type === "BlockStatement" && (0,
|
|
7394
|
+
} else if (localState.unreachable && curStmt.type === "BlockStatement" && (0, import_chunk_JDC43A3I.isStatement)(node)) {
|
|
7395
7395
|
return false;
|
|
7396
7396
|
}
|
|
7397
7397
|
return null;
|
|
@@ -7485,7 +7485,7 @@ var Terminals, LocalState;
|
|
|
7485
7485
|
var init_control_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
7486
7486
|
"src/control-flow.ts"() {
|
|
7487
7487
|
"use strict";
|
|
7488
|
-
(0,
|
|
7488
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
7489
7489
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
7490
7490
|
Terminals = {
|
|
7491
7491
|
BreakStatement: "break",
|
|
@@ -7853,7 +7853,7 @@ function mergeObjectValues(to, from) {
|
|
|
7853
7853
|
let empty = true;
|
|
7854
7854
|
let result = to;
|
|
7855
7855
|
Object.entries(to).forEach(([key, value2]) => {
|
|
7856
|
-
if (!(0,
|
|
7856
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(from, key)) {
|
|
7857
7857
|
if (result === to)
|
|
7858
7858
|
result = { ...result };
|
|
7859
7859
|
delete result[key];
|
|
@@ -8041,7 +8041,7 @@ function widenType(t) {
|
|
|
8041
8041
|
var init_union_type = (0, import_chunk_ABYVSU2C.__esm)({
|
|
8042
8042
|
"src/type-flow/union-type.ts"() {
|
|
8043
8043
|
"use strict";
|
|
8044
|
-
(0,
|
|
8044
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
8045
8045
|
init_data_flow();
|
|
8046
8046
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
8047
8047
|
init_could_be();
|
|
@@ -8309,7 +8309,7 @@ function intersectObj(to, from) {
|
|
|
8309
8309
|
return to;
|
|
8310
8310
|
let result = to;
|
|
8311
8311
|
Object.entries(from).forEach(([key, value2]) => {
|
|
8312
|
-
if (!(0,
|
|
8312
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(to, key)) {
|
|
8313
8313
|
if (result === to)
|
|
8314
8314
|
result = { ...result };
|
|
8315
8315
|
result[key] = value2;
|
|
@@ -8724,7 +8724,7 @@ function subtypeOfObj(a, b) {
|
|
|
8724
8724
|
if (!a || !b)
|
|
8725
8725
|
return true;
|
|
8726
8726
|
return Object.entries(b).every(([key, value2]) => {
|
|
8727
|
-
if (!(0,
|
|
8727
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(a, key))
|
|
8728
8728
|
return false;
|
|
8729
8729
|
return subtypeOf(a[key], value2);
|
|
8730
8730
|
});
|
|
@@ -9282,7 +9282,7 @@ function filterDecls(decls, possible, name) {
|
|
|
9282
9282
|
cur[1].add(poss);
|
|
9283
9283
|
break;
|
|
9284
9284
|
}
|
|
9285
|
-
if ((0,
|
|
9285
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(sn.decls, name)) {
|
|
9286
9286
|
break;
|
|
9287
9287
|
}
|
|
9288
9288
|
}
|
|
@@ -9308,7 +9308,7 @@ function findObjectDeclsByProperty(state, object, next) {
|
|
|
9308
9308
|
const decls = getStateNodeDeclsFromType(state, object);
|
|
9309
9309
|
if (!decls)
|
|
9310
9310
|
return [null, null];
|
|
9311
|
-
const possibleDecls = (0,
|
|
9311
|
+
const possibleDecls = (0, import_chunk_JDC43A3I.hasProperty)(state.allDeclarations, next.name) && state.allDeclarations[next.name];
|
|
9312
9312
|
return filterDecls(decls, possibleDecls, next.name);
|
|
9313
9313
|
}
|
|
9314
9314
|
function refineObjectTypeByDecls(istate, object, trueDecls) {
|
|
@@ -9581,7 +9581,7 @@ function isOverride(cur, funcs) {
|
|
|
9581
9581
|
}
|
|
9582
9582
|
function sysCallInfo(state, func) {
|
|
9583
9583
|
const info = getSystemCallTable(state);
|
|
9584
|
-
if ((0,
|
|
9584
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(info, func.fullName)) {
|
|
9585
9585
|
return info[func.fullName];
|
|
9586
9586
|
}
|
|
9587
9587
|
return null;
|
|
@@ -9922,7 +9922,7 @@ function getSystemCallTable(state) {
|
|
|
9922
9922
|
};
|
|
9923
9923
|
const mathHelper = (state2, callee, calleeObj, getArgs, helper) => {
|
|
9924
9924
|
const results = {};
|
|
9925
|
-
const fn = helper && typeof helper === "function" ? helper : (0,
|
|
9925
|
+
const fn = helper && typeof helper === "function" ? helper : (0, import_chunk_JDC43A3I.hasProperty)(Math, helper || callee.name) && Math[helper || callee.name];
|
|
9926
9926
|
if (fn && typeof fn === "function") {
|
|
9927
9927
|
results.effectFree = true;
|
|
9928
9928
|
const args = getArgs();
|
|
@@ -10051,7 +10051,7 @@ function expandKeys(state, table) {
|
|
|
10051
10051
|
);
|
|
10052
10052
|
decls.forEach((decl) => {
|
|
10053
10053
|
if (decl.type === "FunctionDeclaration") {
|
|
10054
|
-
if (!(0,
|
|
10054
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(result, decl.fullName)) {
|
|
10055
10055
|
result[decl.fullName] = value2;
|
|
10056
10056
|
}
|
|
10057
10057
|
}
|
|
@@ -10256,9 +10256,9 @@ function evaluate(istate, node) {
|
|
|
10256
10256
|
}
|
|
10257
10257
|
return null;
|
|
10258
10258
|
};
|
|
10259
|
-
(0,
|
|
10259
|
+
(0, import_chunk_JDC43A3I.traverseAst)(node, pre, post);
|
|
10260
10260
|
const ret = istate.stack.pop();
|
|
10261
|
-
if ((0,
|
|
10261
|
+
if ((0, import_chunk_JDC43A3I.isExpression)(node)) {
|
|
10262
10262
|
if (!ret || node !== ret.node) {
|
|
10263
10263
|
throw new Error("evaluate failed to produce a value for an expression");
|
|
10264
10264
|
}
|
|
@@ -11200,7 +11200,7 @@ var init_interp = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
11200
11200
|
"src/type-flow/interp.ts"() {
|
|
11201
11201
|
"use strict";
|
|
11202
11202
|
init_api();
|
|
11203
|
-
(0,
|
|
11203
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
11204
11204
|
init_data_flow();
|
|
11205
11205
|
init_optimizer_types();
|
|
11206
11206
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
@@ -11459,7 +11459,7 @@ function typeFromTypeStateNode(state, sn, classVsObj) {
|
|
|
11459
11459
|
declared = typeFromTypespec(state, sn.node.id.right, sn.stack);
|
|
11460
11460
|
}
|
|
11461
11461
|
if (sn.node.kind === "const" && sn.node.init) {
|
|
11462
|
-
if ((0,
|
|
11462
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(sn, "resolvedType")) {
|
|
11463
11463
|
return declared ?? {
|
|
11464
11464
|
type: 524287
|
|
11465
11465
|
/* Any */
|
|
@@ -11640,7 +11640,7 @@ function typeFromSingleTypeSpec(state, type, stack) {
|
|
|
11640
11640
|
value: { result, args }
|
|
11641
11641
|
};
|
|
11642
11642
|
}
|
|
11643
|
-
const id = typeof type.name === "string" ? (0,
|
|
11643
|
+
const id = typeof type.name === "string" ? (0, import_chunk_JDC43A3I.makeScopedName)(type.name) : type.name;
|
|
11644
11644
|
const [, results] = state.lookupType(id, null, stack);
|
|
11645
11645
|
if (!results) {
|
|
11646
11646
|
if (id.type === "Identifier") {
|
|
@@ -11719,7 +11719,7 @@ function typeFromTypespec(state, ts, stack) {
|
|
|
11719
11719
|
);
|
|
11720
11720
|
}
|
|
11721
11721
|
function typeFromLiteral(literal) {
|
|
11722
|
-
const [value2, type] = (0,
|
|
11722
|
+
const [value2, type] = (0, import_chunk_JDC43A3I.getNodeValue)(literal);
|
|
11723
11723
|
switch (type) {
|
|
11724
11724
|
case "Null":
|
|
11725
11725
|
return {
|
|
@@ -12126,7 +12126,7 @@ var init_types = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12126
12126
|
"use strict";
|
|
12127
12127
|
init_data_flow();
|
|
12128
12128
|
init_api();
|
|
12129
|
-
(0,
|
|
12129
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
12130
12130
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
12131
12131
|
init_interp();
|
|
12132
12132
|
init_union_type();
|
|
@@ -12290,7 +12290,7 @@ function couldBeObj(a, b) {
|
|
|
12290
12290
|
if (!a || !b)
|
|
12291
12291
|
return true;
|
|
12292
12292
|
return Object.entries(a).every(([key, value2]) => {
|
|
12293
|
-
if (!(0,
|
|
12293
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(b, key))
|
|
12294
12294
|
return true;
|
|
12295
12295
|
return couldBe(value2, b[key]);
|
|
12296
12296
|
});
|
|
@@ -12588,7 +12588,7 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
|
|
|
12588
12588
|
);
|
|
12589
12589
|
}
|
|
12590
12590
|
let changes = false;
|
|
12591
|
-
(0,
|
|
12591
|
+
(0, import_chunk_JDC43A3I.traverseAst)(func.node.body, null, (node) => {
|
|
12592
12592
|
const cleaned = variableCleanup(node);
|
|
12593
12593
|
if (cleaned !== null)
|
|
12594
12594
|
return cleaned;
|
|
@@ -12598,7 +12598,7 @@ function eliminateDeadStores(state, func, graph, logThisRun) {
|
|
|
12598
12598
|
);
|
|
12599
12599
|
changes = true;
|
|
12600
12600
|
if (body.length) {
|
|
12601
|
-
return (0,
|
|
12601
|
+
return (0, import_chunk_JDC43A3I.withLoc)({ type: "BlockStatement", body }, node, node);
|
|
12602
12602
|
}
|
|
12603
12603
|
return false;
|
|
12604
12604
|
}
|
|
@@ -12631,7 +12631,7 @@ var init_dead_store = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
12631
12631
|
"src/type-flow/dead-store.ts"() {
|
|
12632
12632
|
"use strict";
|
|
12633
12633
|
init_api();
|
|
12634
|
-
(0,
|
|
12634
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
12635
12635
|
init_control_flow();
|
|
12636
12636
|
init_data_flow();
|
|
12637
12637
|
init_inliner();
|
|
@@ -13087,7 +13087,7 @@ function updateAffected(blockState, objectType, baseDecl, assignedPath, affected
|
|
|
13087
13087
|
type = newType;
|
|
13088
13088
|
} else {
|
|
13089
13089
|
const objValue = getObjectValue(type);
|
|
13090
|
-
if (!objValue || !(0,
|
|
13090
|
+
if (!objValue || !(0, import_chunk_JDC43A3I.hasProperty)(objValue.obj, pathItem)) {
|
|
13091
13091
|
break;
|
|
13092
13092
|
}
|
|
13093
13093
|
type = objValue.obj[pathItem];
|
|
@@ -13150,7 +13150,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13150
13150
|
const value2 = getObjectValue(cur);
|
|
13151
13151
|
if (i === l && newValue) {
|
|
13152
13152
|
next = newValue;
|
|
13153
|
-
} else if (value2 && (0,
|
|
13153
|
+
} else if (value2 && (0, import_chunk_JDC43A3I.hasProperty)(value2.obj, me.property.name)) {
|
|
13154
13154
|
next = value2.obj[me.property.name];
|
|
13155
13155
|
} else {
|
|
13156
13156
|
const [objDecls, trueDecls] = findObjectDeclsByProperty(
|
|
@@ -14317,16 +14317,16 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14317
14317
|
}
|
|
14318
14318
|
})
|
|
14319
14319
|
);
|
|
14320
|
-
(0,
|
|
14320
|
+
(0, import_chunk_JDC43A3I.traverseAst)(
|
|
14321
14321
|
func.node.body,
|
|
14322
14322
|
(node) => {
|
|
14323
14323
|
if (node.type === "AssignmentExpression" && node.operator !== "=" && nodeCopyProp.has(node.left)) {
|
|
14324
|
-
const left = (0,
|
|
14325
|
-
const right = (0,
|
|
14324
|
+
const left = (0, import_chunk_JDC43A3I.cloneDeep)(node.left);
|
|
14325
|
+
const right = (0, import_chunk_JDC43A3I.withLoc)(
|
|
14326
14326
|
{
|
|
14327
14327
|
type: "BinaryExpression",
|
|
14328
14328
|
operator: node.operator.slice(0, -1),
|
|
14329
|
-
left: (0,
|
|
14329
|
+
left: (0, import_chunk_JDC43A3I.withLocDeep)(node.left, node.right, false, true),
|
|
14330
14330
|
right: node.right
|
|
14331
14331
|
},
|
|
14332
14332
|
node.left,
|
|
@@ -14348,7 +14348,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14348
14348
|
)
|
|
14349
14349
|
);
|
|
14350
14350
|
}
|
|
14351
|
-
return (0,
|
|
14351
|
+
return (0, import_chunk_JDC43A3I.withLoc)(
|
|
14352
14352
|
{ type: "Literal", value: null, raw: "null" },
|
|
14353
14353
|
node,
|
|
14354
14354
|
node
|
|
@@ -14386,7 +14386,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14386
14386
|
)
|
|
14387
14387
|
);
|
|
14388
14388
|
}
|
|
14389
|
-
return (0,
|
|
14389
|
+
return (0, import_chunk_JDC43A3I.withLocDeep)(replacement2, node, node, false);
|
|
14390
14390
|
} else if (copyNode.type === "VariableDeclarator") {
|
|
14391
14391
|
const init = copyNode.init;
|
|
14392
14392
|
(0, import_node_assert3.default)(init);
|
|
@@ -14399,7 +14399,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14399
14399
|
)
|
|
14400
14400
|
);
|
|
14401
14401
|
}
|
|
14402
|
-
return (0,
|
|
14402
|
+
return (0, import_chunk_JDC43A3I.withLocDeep)(init, node, node, false);
|
|
14403
14403
|
}
|
|
14404
14404
|
(0, import_node_assert3.default)(false);
|
|
14405
14405
|
}
|
|
@@ -14413,7 +14413,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14413
14413
|
)
|
|
14414
14414
|
);
|
|
14415
14415
|
}
|
|
14416
|
-
return (0,
|
|
14416
|
+
return (0, import_chunk_JDC43A3I.withLoc)(
|
|
14417
14417
|
{ type: "Literal", value: null, raw: "null" },
|
|
14418
14418
|
node,
|
|
14419
14419
|
node
|
|
@@ -14465,7 +14465,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
14465
14465
|
)
|
|
14466
14466
|
);
|
|
14467
14467
|
}
|
|
14468
|
-
const replacement = (0,
|
|
14468
|
+
const replacement = (0, import_chunk_JDC43A3I.withLoc)({ type: "Identifier", name }, node, node);
|
|
14469
14469
|
const tm = typeMap.get(node);
|
|
14470
14470
|
if (tm)
|
|
14471
14471
|
typeMap.set(replacement, tm);
|
|
@@ -14573,7 +14573,7 @@ var init_type_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14573
14573
|
"src/type-flow.ts"() {
|
|
14574
14574
|
"use strict";
|
|
14575
14575
|
init_api();
|
|
14576
|
-
(0,
|
|
14576
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
14577
14577
|
init_control_flow();
|
|
14578
14578
|
init_data_flow();
|
|
14579
14579
|
init_function_info();
|
|
@@ -14712,11 +14712,11 @@ function minimizeLocals(state, func) {
|
|
|
14712
14712
|
};
|
|
14713
14713
|
if (sn.node.body.length && sn.node.body[0].type === "VariableDeclaration") {
|
|
14714
14714
|
sn.node.body[0].declarations.unshift(
|
|
14715
|
-
(0,
|
|
14715
|
+
(0, import_chunk_JDC43A3I.withLocDeep)(varDecl, sn.node.body[0], false, true)
|
|
14716
14716
|
);
|
|
14717
14717
|
} else {
|
|
14718
14718
|
sn.node.body.unshift(
|
|
14719
|
-
(0,
|
|
14719
|
+
(0, import_chunk_JDC43A3I.withLocDeep)(
|
|
14720
14720
|
{
|
|
14721
14721
|
type: "VariableDeclaration",
|
|
14722
14722
|
declarations: [varDecl],
|
|
@@ -14743,7 +14743,7 @@ function minimizeLocals(state, func) {
|
|
|
14743
14743
|
nodeMap.set(event.node, rep);
|
|
14744
14744
|
})
|
|
14745
14745
|
);
|
|
14746
|
-
(0,
|
|
14746
|
+
(0, import_chunk_JDC43A3I.traverseAst)(func.node.body, null, (node) => {
|
|
14747
14747
|
const info = nodeMap.get(node);
|
|
14748
14748
|
switch (node.type) {
|
|
14749
14749
|
case "Identifier":
|
|
@@ -14755,7 +14755,7 @@ function minimizeLocals(state, func) {
|
|
|
14755
14755
|
if (info) {
|
|
14756
14756
|
(0, import_node_assert4.default)(node.left.type === "Identifier");
|
|
14757
14757
|
if (node.right.type === "Identifier" && node.right.name === info.name && node.operator === "=") {
|
|
14758
|
-
return (0,
|
|
14758
|
+
return (0, import_chunk_JDC43A3I.withLoc)(
|
|
14759
14759
|
{ type: "Literal", value: null, raw: "null" },
|
|
14760
14760
|
node,
|
|
14761
14761
|
node
|
|
@@ -14784,11 +14784,11 @@ function minimizeLocals(state, func) {
|
|
|
14784
14784
|
if (node.init.type === "Identifier" && node.init.name === info.name) {
|
|
14785
14785
|
return false;
|
|
14786
14786
|
}
|
|
14787
|
-
return (0,
|
|
14787
|
+
return (0, import_chunk_JDC43A3I.withLoc)(
|
|
14788
14788
|
{
|
|
14789
14789
|
type: "AssignmentExpression",
|
|
14790
14790
|
operator: "=",
|
|
14791
|
-
left: (0,
|
|
14791
|
+
left: (0, import_chunk_JDC43A3I.withLoc)(
|
|
14792
14792
|
{
|
|
14793
14793
|
type: "Identifier",
|
|
14794
14794
|
name: info.name,
|
|
@@ -14824,11 +14824,11 @@ function variableCleanup(node) {
|
|
|
14824
14824
|
const results = [];
|
|
14825
14825
|
node.declarations.forEach(
|
|
14826
14826
|
(decl) => {
|
|
14827
|
-
if ((0,
|
|
14827
|
+
if ((0, import_chunk_JDC43A3I.isStatement)(decl)) {
|
|
14828
14828
|
results.push(decl);
|
|
14829
|
-
} else if ((0,
|
|
14829
|
+
} else if ((0, import_chunk_JDC43A3I.isExpression)(decl)) {
|
|
14830
14830
|
results.push(
|
|
14831
|
-
(0,
|
|
14831
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
14832
14832
|
{ type: "ExpressionStatement", expression: decl },
|
|
14833
14833
|
decl,
|
|
14834
14834
|
decl
|
|
@@ -14836,14 +14836,14 @@ function variableCleanup(node) {
|
|
|
14836
14836
|
);
|
|
14837
14837
|
} else if (decl.init) {
|
|
14838
14838
|
results.push(
|
|
14839
|
-
(0,
|
|
14839
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
14840
14840
|
{
|
|
14841
14841
|
type: "ExpressionStatement",
|
|
14842
|
-
expression: (0,
|
|
14842
|
+
expression: (0, import_chunk_JDC43A3I.withLoc)(
|
|
14843
14843
|
{
|
|
14844
14844
|
type: "AssignmentExpression",
|
|
14845
14845
|
operator: "=",
|
|
14846
|
-
left: (0,
|
|
14846
|
+
left: (0, import_chunk_JDC43A3I.withLoc)(
|
|
14847
14847
|
{
|
|
14848
14848
|
type: "Identifier",
|
|
14849
14849
|
name: variableDeclarationName(decl.id)
|
|
@@ -14872,7 +14872,7 @@ function variableCleanup(node) {
|
|
|
14872
14872
|
return false;
|
|
14873
14873
|
});
|
|
14874
14874
|
if (node.declarations.length) {
|
|
14875
|
-
(0,
|
|
14875
|
+
(0, import_chunk_JDC43A3I.withLocDeep)(node, node, false);
|
|
14876
14876
|
results.unshift(node);
|
|
14877
14877
|
}
|
|
14878
14878
|
return results;
|
|
@@ -14909,7 +14909,7 @@ var init_minimize_locals = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
14909
14909
|
"src/type-flow/minimize-locals.ts"() {
|
|
14910
14910
|
"use strict";
|
|
14911
14911
|
init_api();
|
|
14912
|
-
(0,
|
|
14912
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
14913
14913
|
init_control_flow();
|
|
14914
14914
|
init_type_flow();
|
|
14915
14915
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
@@ -14950,7 +14950,7 @@ async function sizeBasedPRE(state, func) {
|
|
|
14950
14950
|
}
|
|
14951
14951
|
const nodeMap = /* @__PURE__ */ new Map();
|
|
14952
14952
|
const declMap = /* @__PURE__ */ new Map();
|
|
14953
|
-
const variableDecl = (0,
|
|
14953
|
+
const variableDecl = (0, import_chunk_JDC43A3I.withLoc)(
|
|
14954
14954
|
{
|
|
14955
14955
|
type: "VariableDeclaration",
|
|
14956
14956
|
declarations: [],
|
|
@@ -14976,10 +14976,10 @@ async function sizeBasedPRE(state, func) {
|
|
|
14976
14976
|
declMap.set(decl, name);
|
|
14977
14977
|
const s = candidates.get(decl);
|
|
14978
14978
|
variableDecl.declarations.push(
|
|
14979
|
-
(0,
|
|
14979
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
14980
14980
|
{
|
|
14981
14981
|
type: "VariableDeclarator",
|
|
14982
|
-
id: (0,
|
|
14982
|
+
id: (0, import_chunk_JDC43A3I.withLoc)({ type: "Identifier", name }, variableDecl),
|
|
14983
14983
|
kind: "var"
|
|
14984
14984
|
},
|
|
14985
14985
|
variableDecl
|
|
@@ -15410,14 +15410,14 @@ function computeAttributes(state, head) {
|
|
|
15410
15410
|
}
|
|
15411
15411
|
function applyReplacements(func, nodeMap, declMap) {
|
|
15412
15412
|
const ident = (name, node) => {
|
|
15413
|
-
return (0,
|
|
15413
|
+
return (0, import_chunk_JDC43A3I.withLoc)({ type: "Identifier", name }, node);
|
|
15414
15414
|
};
|
|
15415
15415
|
const pendingMap = /* @__PURE__ */ new Map();
|
|
15416
15416
|
const stmtStack = [func];
|
|
15417
|
-
(0,
|
|
15417
|
+
(0, import_chunk_JDC43A3I.traverseAst)(
|
|
15418
15418
|
func,
|
|
15419
15419
|
(node) => {
|
|
15420
|
-
if ((0,
|
|
15420
|
+
if ((0, import_chunk_JDC43A3I.isStatement)(node)) {
|
|
15421
15421
|
stmtStack.push(node);
|
|
15422
15422
|
}
|
|
15423
15423
|
},
|
|
@@ -15470,7 +15470,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15470
15470
|
);
|
|
15471
15471
|
}
|
|
15472
15472
|
const id = ident(name, target);
|
|
15473
|
-
const assign = (0,
|
|
15473
|
+
const assign = (0, import_chunk_JDC43A3I.withLoc)(
|
|
15474
15474
|
{
|
|
15475
15475
|
type: "AssignmentExpression",
|
|
15476
15476
|
left: target,
|
|
@@ -15484,7 +15484,7 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15484
15484
|
} else {
|
|
15485
15485
|
node.argument = id;
|
|
15486
15486
|
}
|
|
15487
|
-
return (0,
|
|
15487
|
+
return (0, import_chunk_JDC43A3I.withLoc)(
|
|
15488
15488
|
{ type: "SequenceExpression", expressions: [node, assign] },
|
|
15489
15489
|
node
|
|
15490
15490
|
);
|
|
@@ -15539,15 +15539,15 @@ function applyReplacements(func, nodeMap, declMap) {
|
|
|
15539
15539
|
)
|
|
15540
15540
|
);
|
|
15541
15541
|
}
|
|
15542
|
-
const rhs = (0,
|
|
15542
|
+
const rhs = (0, import_chunk_JDC43A3I.withLocDeep)(event.id, locNode, locNode);
|
|
15543
15543
|
rhs.end = rhs.start;
|
|
15544
15544
|
if (rhs.loc) {
|
|
15545
15545
|
rhs.loc.end = rhs.loc.start;
|
|
15546
15546
|
}
|
|
15547
|
-
const insertion = (0,
|
|
15547
|
+
const insertion = (0, import_chunk_JDC43A3I.withLoc)(
|
|
15548
15548
|
{
|
|
15549
15549
|
type: "ExpressionStatement",
|
|
15550
|
-
expression: (0,
|
|
15550
|
+
expression: (0, import_chunk_JDC43A3I.withLoc)(
|
|
15551
15551
|
{
|
|
15552
15552
|
type: "AssignmentExpression",
|
|
15553
15553
|
left: ident(name, rhs),
|
|
@@ -15593,7 +15593,7 @@ var init_pre = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
15593
15593
|
"src/pre.ts"() {
|
|
15594
15594
|
"use strict";
|
|
15595
15595
|
init_api();
|
|
15596
|
-
(0,
|
|
15596
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
15597
15597
|
init_control_flow();
|
|
15598
15598
|
init_data_flow();
|
|
15599
15599
|
init_function_info();
|
|
@@ -15712,9 +15712,9 @@ function minimizeModules(ast, state) {
|
|
|
15712
15712
|
delete repl.computed;
|
|
15713
15713
|
});
|
|
15714
15714
|
mappedNames.forEach((name, module2) => {
|
|
15715
|
-
const id = (0,
|
|
15716
|
-
const as = name !== (id.type === "Identifier" ? id : id.property).name && (0,
|
|
15717
|
-
const using = (0,
|
|
15715
|
+
const id = (0, import_chunk_JDC43A3I.makeScopedName)(module2.fullName.slice(2));
|
|
15716
|
+
const as = name !== (id.type === "Identifier" ? id : id.property).name && (0, import_chunk_JDC43A3I.makeIdentifier)(name);
|
|
15717
|
+
const using = (0, import_chunk_JDC43A3I.withLocDeep)(
|
|
15718
15718
|
as ? { type: "Using", id, as } : { type: "Using", id },
|
|
15719
15719
|
ast,
|
|
15720
15720
|
false,
|
|
@@ -15782,7 +15782,7 @@ var init_minimize_modules = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
15782
15782
|
"src/type-flow/minimize-modules.ts"() {
|
|
15783
15783
|
"use strict";
|
|
15784
15784
|
init_api();
|
|
15785
|
-
(0,
|
|
15785
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
15786
15786
|
}
|
|
15787
15787
|
});
|
|
15788
15788
|
function beforeEvaluate(istate, node) {
|
|
@@ -15793,7 +15793,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15793
15793
|
if (expression.embeddedEffects) {
|
|
15794
15794
|
istate.stack.push(expression);
|
|
15795
15795
|
} else {
|
|
15796
|
-
const rep = (0,
|
|
15796
|
+
const rep = (0, import_chunk_JDC43A3I.withLoc)(
|
|
15797
15797
|
{ type: "Literal", value: null, raw: "null" },
|
|
15798
15798
|
node,
|
|
15799
15799
|
node
|
|
@@ -15834,7 +15834,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15834
15834
|
}
|
|
15835
15835
|
if (test.value.type === 6 && (consequent.value.type === 4 && alternate.value.type === 2 || consequent.value.type === 2 && alternate.value.type === 4) && !consequent.embeddedEffects && !alternate.embeddedEffects) {
|
|
15836
15836
|
if (consequent.value.type === 2) {
|
|
15837
|
-
test.node = (0,
|
|
15837
|
+
test.node = (0, import_chunk_JDC43A3I.wrap)(
|
|
15838
15838
|
{
|
|
15839
15839
|
type: "UnaryExpression",
|
|
15840
15840
|
operator: "!",
|
|
@@ -15856,7 +15856,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15856
15856
|
}
|
|
15857
15857
|
const test = popIstate(istate, node.test);
|
|
15858
15858
|
if (!node.alternate && node.consequent.type === "BlockStatement" && !node.consequent.body.length) {
|
|
15859
|
-
const ret = (0,
|
|
15859
|
+
const ret = (0, import_chunk_JDC43A3I.withLoc)(node.consequent, node.test, node.test);
|
|
15860
15860
|
const u = test.embeddedEffects && unused(istate.state, node.test);
|
|
15861
15861
|
if (u) {
|
|
15862
15862
|
node.consequent.body = u;
|
|
@@ -15869,7 +15869,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15869
15869
|
if (!test.embeddedEffects) {
|
|
15870
15870
|
return rep;
|
|
15871
15871
|
}
|
|
15872
|
-
const estmt = (0,
|
|
15872
|
+
const estmt = (0, import_chunk_JDC43A3I.wrap)(
|
|
15873
15873
|
{ type: "ExpressionStatement", expression: node.test },
|
|
15874
15874
|
node.loc
|
|
15875
15875
|
);
|
|
@@ -15899,7 +15899,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15899
15899
|
}
|
|
15900
15900
|
let ok = true;
|
|
15901
15901
|
let switchDepth = 0;
|
|
15902
|
-
(0,
|
|
15902
|
+
(0, import_chunk_JDC43A3I.traverseAst)(
|
|
15903
15903
|
node.body,
|
|
15904
15904
|
(n) => {
|
|
15905
15905
|
if (!ok)
|
|
@@ -15943,11 +15943,11 @@ function beforeEvaluate(istate, node) {
|
|
|
15943
15943
|
const [arg] = istate.stack.slice(-1);
|
|
15944
15944
|
if ((arg.value.type & 120) === arg.value.type && arg.value.value == null) {
|
|
15945
15945
|
const leftType = { type: 8, value: 0 };
|
|
15946
|
-
const rep = (0,
|
|
15946
|
+
const rep = (0, import_chunk_JDC43A3I.withLoc)(
|
|
15947
15947
|
{
|
|
15948
15948
|
type: "BinaryExpression",
|
|
15949
15949
|
operator: "-",
|
|
15950
|
-
left: (0,
|
|
15950
|
+
left: (0, import_chunk_JDC43A3I.withLoc)(mcExprFromType(leftType), node.argument, false),
|
|
15951
15951
|
right: node.argument
|
|
15952
15952
|
},
|
|
15953
15953
|
node
|
|
@@ -15970,7 +15970,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15970
15970
|
}
|
|
15971
15971
|
const id = node.right.argument;
|
|
15972
15972
|
if ((0, import_chunk_OASVKTK5.every)(left.value.value, (m) => {
|
|
15973
|
-
if ((0,
|
|
15973
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(m.decls, id.name))
|
|
15974
15974
|
return false;
|
|
15975
15975
|
return istate.state.lookup({
|
|
15976
15976
|
type: "MemberExpression",
|
|
@@ -15981,7 +15981,7 @@ function beforeEvaluate(istate, node) {
|
|
|
15981
15981
|
})) {
|
|
15982
15982
|
popIstate(istate, node.right);
|
|
15983
15983
|
popIstate(istate, node.left);
|
|
15984
|
-
const rep = (0,
|
|
15984
|
+
const rep = (0, import_chunk_JDC43A3I.wrap)(
|
|
15985
15985
|
{ type: "Literal", value: false, raw: "false" },
|
|
15986
15986
|
node.loc
|
|
15987
15987
|
);
|
|
@@ -16098,7 +16098,7 @@ function beforeEvaluate(istate, node) {
|
|
|
16098
16098
|
if (selfAssign) {
|
|
16099
16099
|
popIstate(istate, node.right);
|
|
16100
16100
|
popIstate(istate, node.left);
|
|
16101
|
-
const rep = (0,
|
|
16101
|
+
const rep = (0, import_chunk_JDC43A3I.withLoc)(
|
|
16102
16102
|
{ type: "Literal", value: null, raw: "null" },
|
|
16103
16103
|
node,
|
|
16104
16104
|
node
|
|
@@ -16120,13 +16120,13 @@ function beforeEvaluate(istate, node) {
|
|
|
16120
16120
|
return null;
|
|
16121
16121
|
}
|
|
16122
16122
|
function afterEvaluate(istate, node) {
|
|
16123
|
-
if ((0,
|
|
16123
|
+
if ((0, import_chunk_JDC43A3I.isExpression)(node) && node.type !== "Literal") {
|
|
16124
16124
|
const top = istate.stack[istate.stack.length - 1];
|
|
16125
16125
|
if (!top.embeddedEffects && hasValue(top.value)) {
|
|
16126
16126
|
const rep = mcExprFromType(top.value);
|
|
16127
16127
|
if (rep) {
|
|
16128
16128
|
top.node = rep;
|
|
16129
|
-
return (0,
|
|
16129
|
+
return (0, import_chunk_JDC43A3I.withLoc)(rep, node, node);
|
|
16130
16130
|
}
|
|
16131
16131
|
}
|
|
16132
16132
|
}
|
|
@@ -16238,7 +16238,7 @@ function tryCommuteAndAssociate(istate, node) {
|
|
|
16238
16238
|
switch (node.operator) {
|
|
16239
16239
|
case "-":
|
|
16240
16240
|
if (left.value.type === 8 && left.value.value === -1 && (right.value.type & (8 | 16)) === right.value.type || left.value.type === 16 && left.value.value === -1n && right.value.type === 16) {
|
|
16241
|
-
const rep = (0,
|
|
16241
|
+
const rep = (0, import_chunk_JDC43A3I.withLoc)(
|
|
16242
16242
|
{
|
|
16243
16243
|
type: "UnaryExpression",
|
|
16244
16244
|
operator: "~",
|
|
@@ -16285,11 +16285,11 @@ function tryReAssociate(istate, node, left, right) {
|
|
|
16285
16285
|
if (node.left.type !== "BinaryExpression" || node.left.operator !== node.operator && !(node.operator === "+" && node.left.operator === "-") && !(node.operator === "-" && node.left.operator === "+")) {
|
|
16286
16286
|
return false;
|
|
16287
16287
|
}
|
|
16288
|
-
let leftLit = (0,
|
|
16288
|
+
let leftLit = (0, import_chunk_JDC43A3I.getLiteralNode)(node.left.right);
|
|
16289
16289
|
if (!leftLit) {
|
|
16290
16290
|
if (node.left.operator !== "-")
|
|
16291
16291
|
return false;
|
|
16292
|
-
leftLit = (0,
|
|
16292
|
+
leftLit = (0, import_chunk_JDC43A3I.getLiteralNode)(node.left.left);
|
|
16293
16293
|
if (!leftLit)
|
|
16294
16294
|
return false;
|
|
16295
16295
|
const leftLeft = evaluate(istate, leftLit);
|
|
@@ -16357,7 +16357,7 @@ function tryReAssociate(istate, node, left, right) {
|
|
|
16357
16357
|
return false;
|
|
16358
16358
|
}
|
|
16359
16359
|
if (node.right.type === "BinaryExpression" && (node.right.operator === node.operator || (node.operator === "+" || node.operator === "-") && (node.right.operator === "+" || node.right.operator === "-"))) {
|
|
16360
|
-
const rr = (0,
|
|
16360
|
+
const rr = (0, import_chunk_JDC43A3I.getLiteralNode)(node.right.right);
|
|
16361
16361
|
if (!rr)
|
|
16362
16362
|
return false;
|
|
16363
16363
|
const rightRight = evaluate(istate, rr);
|
|
@@ -16412,7 +16412,7 @@ function tryDeEnumerate(istate, node, elem) {
|
|
|
16412
16412
|
var init_optimize = (0, import_chunk_ABYVSU2C.__esm)({
|
|
16413
16413
|
"src/type-flow/optimize.ts"() {
|
|
16414
16414
|
"use strict";
|
|
16415
|
-
(0,
|
|
16415
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
16416
16416
|
init_inliner();
|
|
16417
16417
|
init_type_flow();
|
|
16418
16418
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
@@ -16447,7 +16447,7 @@ function cleanupUnusedVars(state, node) {
|
|
|
16447
16447
|
const stack = [];
|
|
16448
16448
|
const activeRemove = {};
|
|
16449
16449
|
let changes = false;
|
|
16450
|
-
(0,
|
|
16450
|
+
(0, import_chunk_JDC43A3I.traverseAst)(
|
|
16451
16451
|
node,
|
|
16452
16452
|
(node2) => {
|
|
16453
16453
|
switch (node2.type) {
|
|
@@ -16468,7 +16468,7 @@ function cleanupUnusedVars(state, node) {
|
|
|
16468
16468
|
case "VariableDeclaration": {
|
|
16469
16469
|
node2.declarations.forEach((decl, i) => {
|
|
16470
16470
|
const name = variableDeclarationName(decl.id);
|
|
16471
|
-
if ((0,
|
|
16471
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(toRemove, name) && toRemove[name].node === decl) {
|
|
16472
16472
|
activeRemove[name] = toRemove[name];
|
|
16473
16473
|
const info = varDeclarations.get(node2);
|
|
16474
16474
|
if (info) {
|
|
@@ -16485,11 +16485,11 @@ function cleanupUnusedVars(state, node) {
|
|
|
16485
16485
|
}
|
|
16486
16486
|
case "ExpressionStatement":
|
|
16487
16487
|
if (node2.expression.type === "AssignmentExpression") {
|
|
16488
|
-
if (node2.expression.left.type === "Identifier" && (0,
|
|
16488
|
+
if (node2.expression.left.type === "Identifier" && (0, import_chunk_JDC43A3I.hasProperty)(activeRemove, node2.expression.left.name)) {
|
|
16489
16489
|
changes = true;
|
|
16490
16490
|
return unused(state, node2.expression.right);
|
|
16491
16491
|
}
|
|
16492
|
-
} else if (node2.expression.type === "UpdateExpression" && node2.expression.argument.type === "Identifier" && (0,
|
|
16492
|
+
} else if (node2.expression.type === "UpdateExpression" && node2.expression.argument.type === "Identifier" && (0, import_chunk_JDC43A3I.hasProperty)(activeRemove, node2.expression.argument.name)) {
|
|
16493
16493
|
return false;
|
|
16494
16494
|
}
|
|
16495
16495
|
break;
|
|
@@ -16497,7 +16497,7 @@ function cleanupUnusedVars(state, node) {
|
|
|
16497
16497
|
for (let i = node2.expressions.length; i--; ) {
|
|
16498
16498
|
const expr = node2.expressions[i];
|
|
16499
16499
|
if (expr.type === "AssignmentExpression") {
|
|
16500
|
-
if (expr.left.type === "Identifier" && (0,
|
|
16500
|
+
if (expr.left.type === "Identifier" && (0, import_chunk_JDC43A3I.hasProperty)(activeRemove, expr.left.name)) {
|
|
16501
16501
|
const rep = unused(state, expr.right);
|
|
16502
16502
|
if (!rep.length) {
|
|
16503
16503
|
changes = true;
|
|
@@ -16507,7 +16507,7 @@ function cleanupUnusedVars(state, node) {
|
|
|
16507
16507
|
expr.operator = "=";
|
|
16508
16508
|
}
|
|
16509
16509
|
}
|
|
16510
|
-
} else if (expr.type === "UpdateExpression" && expr.argument.type === "Identifier" && (0,
|
|
16510
|
+
} else if (expr.type === "UpdateExpression" && expr.argument.type === "Identifier" && (0, import_chunk_JDC43A3I.hasProperty)(activeRemove, expr.argument.name)) {
|
|
16511
16511
|
changes = true;
|
|
16512
16512
|
node2.expressions.splice(i, 1);
|
|
16513
16513
|
}
|
|
@@ -16524,7 +16524,7 @@ function cleanupUnusedVars(state, node) {
|
|
|
16524
16524
|
const i = info.indices[ii];
|
|
16525
16525
|
const vdecl = decl.declarations[i];
|
|
16526
16526
|
const name = variableDeclarationName(vdecl.id);
|
|
16527
|
-
if ((0,
|
|
16527
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(activeRemove, name)) {
|
|
16528
16528
|
const rep = vdecl.init ? unused(state, vdecl.init) : [];
|
|
16529
16529
|
if (rep.length) {
|
|
16530
16530
|
if ((state.sdkVersion || 0) < 4001007 && rep.find(
|
|
@@ -16586,7 +16586,7 @@ var init_unused_exprs = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
16586
16586
|
"src/unused-exprs.ts"() {
|
|
16587
16587
|
"use strict";
|
|
16588
16588
|
init_api();
|
|
16589
|
-
(0,
|
|
16589
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
16590
16590
|
init_inliner();
|
|
16591
16591
|
}
|
|
16592
16592
|
});
|
|
@@ -16610,7 +16610,7 @@ function collectDeclarationsByName(state) {
|
|
|
16610
16610
|
}
|
|
16611
16611
|
});
|
|
16612
16612
|
if (keyed.length) {
|
|
16613
|
-
if (!(0,
|
|
16613
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(allDecls, key)) {
|
|
16614
16614
|
allDecls[key] = keyed;
|
|
16615
16615
|
} else {
|
|
16616
16616
|
allDecls[key].push(...keyed);
|
|
@@ -16626,6 +16626,7 @@ function collectClassInfo(state) {
|
|
|
16626
16626
|
const toybox = state.stack[0].sn.decls["Toybox"][0];
|
|
16627
16627
|
const lang = toybox.decls["Lang"][0];
|
|
16628
16628
|
const object = lang.decls["Object"];
|
|
16629
|
+
const invalidSymbols = state.config?.checkInvalidSymbols ?? "WARNING";
|
|
16629
16630
|
state.allClasses.forEach((elm) => {
|
|
16630
16631
|
if (elm.stack[elm.stack.length - 1].sn.type === "ClassDeclaration") {
|
|
16631
16632
|
elm.stack = elm.stack.slice(0, 1);
|
|
@@ -16640,7 +16641,18 @@ function collectClassInfo(state) {
|
|
|
16640
16641
|
(c) => isStateNode(c) && c.type === "ClassDeclaration"
|
|
16641
16642
|
);
|
|
16642
16643
|
elm.superClass = superClass && superClass.length ? superClass : true;
|
|
16643
|
-
if (
|
|
16644
|
+
if (elm.superClass === true) {
|
|
16645
|
+
if (invalidSymbols !== "OFF") {
|
|
16646
|
+
diagnostic(
|
|
16647
|
+
state,
|
|
16648
|
+
elm.node,
|
|
16649
|
+
formatAstLongLines(elm.node.superClass).then(
|
|
16650
|
+
(superClass2) => `Unable to find super class ${superClass2} for ${elm.fullName}`
|
|
16651
|
+
),
|
|
16652
|
+
invalidSymbols
|
|
16653
|
+
);
|
|
16654
|
+
}
|
|
16655
|
+
} else if (name) {
|
|
16644
16656
|
if (!elm.decls)
|
|
16645
16657
|
elm.decls = {};
|
|
16646
16658
|
elm.decls[name] = elm.superClass;
|
|
@@ -16649,24 +16661,44 @@ function collectClassInfo(state) {
|
|
|
16649
16661
|
elm.superClass = object;
|
|
16650
16662
|
}
|
|
16651
16663
|
});
|
|
16652
|
-
const markOverrides = (cls, scls) => {
|
|
16664
|
+
const markOverrides = (cls, scls, seen) => {
|
|
16653
16665
|
if (scls === true)
|
|
16654
16666
|
return;
|
|
16655
|
-
scls.
|
|
16656
|
-
|
|
16667
|
+
for (let i = scls.length; i--; ) {
|
|
16668
|
+
const c = scls[i];
|
|
16669
|
+
if (!c.decls)
|
|
16670
|
+
continue;
|
|
16671
|
+
if (seen.has(c)) {
|
|
16672
|
+
if (invalidSymbols !== "OFF") {
|
|
16673
|
+
diagnostic(
|
|
16674
|
+
state,
|
|
16675
|
+
cls.node,
|
|
16676
|
+
`Class ${cls.fullName}'s inheritance graph contains a cycle including ${c.fullName}`,
|
|
16677
|
+
invalidSymbols
|
|
16678
|
+
);
|
|
16679
|
+
}
|
|
16680
|
+
scls.splice(i, 1);
|
|
16681
|
+
continue;
|
|
16682
|
+
}
|
|
16683
|
+
Object.values(c.decls).forEach((funcs) => {
|
|
16657
16684
|
funcs.forEach((f) => {
|
|
16658
|
-
if (f.type === "FunctionDeclaration" && (0,
|
|
16685
|
+
if (f.type === "FunctionDeclaration" && (0, import_chunk_JDC43A3I.hasProperty)(cls.decls, f.name)) {
|
|
16659
16686
|
f.node.hasOverride = true;
|
|
16660
16687
|
}
|
|
16661
16688
|
});
|
|
16662
16689
|
});
|
|
16663
|
-
if (c.superClass)
|
|
16664
|
-
|
|
16665
|
-
|
|
16690
|
+
if (c.superClass) {
|
|
16691
|
+
seen.add(c);
|
|
16692
|
+
markOverrides(cls, c.superClass, seen);
|
|
16693
|
+
seen.delete(c);
|
|
16694
|
+
}
|
|
16695
|
+
}
|
|
16666
16696
|
};
|
|
16667
16697
|
state.allClasses.forEach((elm) => {
|
|
16668
|
-
if (elm.superClass)
|
|
16669
|
-
|
|
16698
|
+
if (elm.superClass) {
|
|
16699
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16700
|
+
markOverrides(elm, elm.superClass, seen);
|
|
16701
|
+
}
|
|
16670
16702
|
if (elm.hasInvoke && elm.decls) {
|
|
16671
16703
|
Object.values(elm.decls).forEach((funcs) => {
|
|
16672
16704
|
funcs.forEach((f) => {
|
|
@@ -16677,6 +16709,11 @@ function collectClassInfo(state) {
|
|
|
16677
16709
|
});
|
|
16678
16710
|
}
|
|
16679
16711
|
});
|
|
16712
|
+
state.allClasses.forEach((elm) => {
|
|
16713
|
+
if (elm.superClass && elm.superClass !== true && elm.superClass.length === 0) {
|
|
16714
|
+
elm.superClass = true;
|
|
16715
|
+
}
|
|
16716
|
+
});
|
|
16680
16717
|
}
|
|
16681
16718
|
function getFileSources(fnMap) {
|
|
16682
16719
|
return Promise.all(
|
|
@@ -16735,7 +16772,7 @@ async function analyze(fnMap, resourcesMap, manifestXML, config, allowParseError
|
|
|
16735
16772
|
return drop;
|
|
16736
16773
|
if (attr.argument.type !== "Identifier")
|
|
16737
16774
|
return drop;
|
|
16738
|
-
if ((0,
|
|
16775
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(excludeAnnotations, attr.argument.name)) {
|
|
16739
16776
|
return true;
|
|
16740
16777
|
}
|
|
16741
16778
|
if (attr.argument.name === "test") {
|
|
@@ -16762,7 +16799,7 @@ async function analyze(fnMap, resourcesMap, manifestXML, config, allowParseError
|
|
|
16762
16799
|
scope.info = getApiFunctionInfo(state2, scope);
|
|
16763
16800
|
}
|
|
16764
16801
|
const allFuncs = state2.allFunctions;
|
|
16765
|
-
if (!(0,
|
|
16802
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(allFuncs, scope.name)) {
|
|
16766
16803
|
allFuncs[scope.name] = [scope];
|
|
16767
16804
|
} else {
|
|
16768
16805
|
allFuncs[scope.name].push(scope);
|
|
@@ -16896,10 +16933,10 @@ function evaluateFunction(istate, func, args) {
|
|
|
16896
16933
|
])
|
|
16897
16934
|
);
|
|
16898
16935
|
let ret = null;
|
|
16899
|
-
const body = args ? (0,
|
|
16936
|
+
const body = args ? (0, import_chunk_JDC43A3I.cloneDeep)(func.body) : func.body;
|
|
16900
16937
|
const depth2 = istate.stack.length;
|
|
16901
16938
|
try {
|
|
16902
|
-
(0,
|
|
16939
|
+
(0, import_chunk_JDC43A3I.traverseAst)(
|
|
16903
16940
|
body,
|
|
16904
16941
|
(node) => {
|
|
16905
16942
|
switch (node.type) {
|
|
@@ -16924,7 +16961,7 @@ function evaluateFunction(istate, func, args) {
|
|
|
16924
16961
|
case "BlockStatement":
|
|
16925
16962
|
return null;
|
|
16926
16963
|
case "Identifier":
|
|
16927
|
-
if ((0,
|
|
16964
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(paramValues, node.name)) {
|
|
16928
16965
|
istate.stack.push(
|
|
16929
16966
|
evaluate(istate, node = paramValues[node.name])
|
|
16930
16967
|
);
|
|
@@ -16949,7 +16986,7 @@ function evaluateFunction(istate, func, args) {
|
|
|
16949
16986
|
}
|
|
16950
16987
|
}
|
|
16951
16988
|
function markFunctionCalled(state, func) {
|
|
16952
|
-
if (!(0,
|
|
16989
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(state.calledFunctions, func.id.name)) {
|
|
16953
16990
|
state.calledFunctions[func.id.name] = [func];
|
|
16954
16991
|
return;
|
|
16955
16992
|
}
|
|
@@ -16976,7 +17013,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
16976
17013
|
const optimizeCallHelper = (istate2, call, node) => {
|
|
16977
17014
|
const result = optimizeCall(istate2, call, node);
|
|
16978
17015
|
if (result) {
|
|
16979
|
-
if ((0,
|
|
17016
|
+
if ((0, import_chunk_JDC43A3I.isExpression)(result)) {
|
|
16980
17017
|
const elem = istate2.stack[istate2.stack.length - 1];
|
|
16981
17018
|
elem.node = result;
|
|
16982
17019
|
if (result.type === "Literal") {
|
|
@@ -16990,7 +17027,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
16990
17027
|
};
|
|
16991
17028
|
const topLocals = () => state.localsStack[state.localsStack.length - 1];
|
|
16992
17029
|
const checkInherited = (elm, name) => elm.superClass === true || elm.superClass != null && elm.superClass.some(
|
|
16993
|
-
(sc) => (0,
|
|
17030
|
+
(sc) => (0, import_chunk_JDC43A3I.hasProperty)(sc.decls, name) && sc.decls[name].some(
|
|
16994
17031
|
(f) => isStateNode(f) && f.type === "FunctionDeclaration" && maybeCalled(state, f.node)
|
|
16995
17032
|
) || sc.superClass && checkInherited(sc, name)
|
|
16996
17033
|
);
|
|
@@ -17018,10 +17055,10 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17018
17055
|
throw new Error(`No parent in lookup of local ${declName2}`);
|
|
17019
17056
|
}
|
|
17020
17057
|
const decls = parent.decls;
|
|
17021
|
-
if (!decls || !(0,
|
|
17058
|
+
if (!decls || !(0, import_chunk_JDC43A3I.hasProperty)(decls, declName2)) {
|
|
17022
17059
|
throw new Error(`Missing decls in lookup of local ${declName2}`);
|
|
17023
17060
|
}
|
|
17024
|
-
if ((0,
|
|
17061
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(decls, name)) {
|
|
17025
17062
|
throw new Error(
|
|
17026
17063
|
`While renaming ${declName2} to ${name}, there was already a variable ${name}`
|
|
17027
17064
|
);
|
|
@@ -17090,7 +17127,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17090
17127
|
break;
|
|
17091
17128
|
case "Identifier": {
|
|
17092
17129
|
const map2 = topLocals().map;
|
|
17093
|
-
if ((0,
|
|
17130
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(map2, node.name)) {
|
|
17094
17131
|
const name = map2[node.name];
|
|
17095
17132
|
if (typeof name === "string") {
|
|
17096
17133
|
renameIdentifier(node, name);
|
|
@@ -17124,7 +17161,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17124
17161
|
if (lhs.type === "Identifier") {
|
|
17125
17162
|
const map2 = topLocals().map;
|
|
17126
17163
|
if (map2) {
|
|
17127
|
-
if ((0,
|
|
17164
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(map2, lhs.name)) {
|
|
17128
17165
|
const name = map2[lhs.name];
|
|
17129
17166
|
if (typeof name === "string") {
|
|
17130
17167
|
renameIdentifier(lhs, name);
|
|
@@ -17248,14 +17285,14 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17248
17285
|
}
|
|
17249
17286
|
break;
|
|
17250
17287
|
case "Identifier":
|
|
17251
|
-
if ((0,
|
|
17288
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state.index, node.name)) {
|
|
17252
17289
|
state.usedByName[node.name] = true;
|
|
17253
17290
|
}
|
|
17254
17291
|
break;
|
|
17255
17292
|
case "MemberExpression": {
|
|
17256
17293
|
const property = isLookupCandidate(node);
|
|
17257
17294
|
if (property) {
|
|
17258
|
-
if ((0,
|
|
17295
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state.index, property.name)) {
|
|
17259
17296
|
state.usedByName[property.name] = true;
|
|
17260
17297
|
}
|
|
17261
17298
|
}
|
|
@@ -17308,7 +17345,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17308
17345
|
}
|
|
17309
17346
|
delete decl.init;
|
|
17310
17347
|
results.push(
|
|
17311
|
-
(0,
|
|
17348
|
+
(0, import_chunk_JDC43A3I.withLoc)(
|
|
17312
17349
|
{
|
|
17313
17350
|
...node,
|
|
17314
17351
|
declarations: declarations.slice(j, i)
|
|
@@ -17341,7 +17378,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17341
17378
|
if (call) {
|
|
17342
17379
|
let ok = false;
|
|
17343
17380
|
if (node.expression.left.type === "Identifier") {
|
|
17344
|
-
if ((0,
|
|
17381
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(topLocals().map, node.expression.left.type)) {
|
|
17345
17382
|
ok = true;
|
|
17346
17383
|
}
|
|
17347
17384
|
}
|
|
@@ -17361,7 +17398,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17361
17398
|
const n = node;
|
|
17362
17399
|
n.type = "AssignmentExpression";
|
|
17363
17400
|
n.left = node.argument;
|
|
17364
|
-
n.right = (0,
|
|
17401
|
+
n.right = (0, import_chunk_JDC43A3I.withLoc)(
|
|
17365
17402
|
mcExprFromType({ type: 8, value: 1 }),
|
|
17366
17403
|
n.left
|
|
17367
17404
|
);
|
|
@@ -17473,7 +17510,7 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17473
17510
|
state.diagnostics = state.inlineDiagnostics;
|
|
17474
17511
|
} else {
|
|
17475
17512
|
Object.entries(state.inlineDiagnostics).forEach(([key, diags]) => {
|
|
17476
|
-
if (!(0,
|
|
17513
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(state.diagnostics, key)) {
|
|
17477
17514
|
state.diagnostics[key] = diags;
|
|
17478
17515
|
} else {
|
|
17479
17516
|
state.diagnostics[key].push(...diags);
|
|
@@ -17544,7 +17581,7 @@ function maybeCalled(state, func) {
|
|
|
17544
17581
|
if (!func.body) {
|
|
17545
17582
|
return true;
|
|
17546
17583
|
}
|
|
17547
|
-
if ((0,
|
|
17584
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state.exposed, func.id.name))
|
|
17548
17585
|
return true;
|
|
17549
17586
|
if (func.attrs && func.attrs.attributes && func.attrs.attributes.elements.some((attr) => {
|
|
17550
17587
|
if (attr.type !== "UnaryExpression")
|
|
@@ -17555,7 +17592,7 @@ function maybeCalled(state, func) {
|
|
|
17555
17592
|
})) {
|
|
17556
17593
|
return true;
|
|
17557
17594
|
}
|
|
17558
|
-
if ((0,
|
|
17595
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state.calledFunctions, func.id.name)) {
|
|
17559
17596
|
return state.calledFunctions[func.id.name].find((f) => f === func) !== null;
|
|
17560
17597
|
}
|
|
17561
17598
|
return false;
|
|
@@ -17570,7 +17607,7 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17570
17607
|
if (usedNodes.has(m))
|
|
17571
17608
|
return false;
|
|
17572
17609
|
const name = "name" in m ? m.name : m.id.name;
|
|
17573
|
-
return (0,
|
|
17610
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(state.index, name) && !(0, import_chunk_JDC43A3I.hasProperty)(state.exposed, name) && !(0, import_chunk_JDC43A3I.hasProperty)(state.usedByName, name);
|
|
17574
17611
|
})) {
|
|
17575
17612
|
break;
|
|
17576
17613
|
}
|
|
@@ -17578,7 +17615,7 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17578
17615
|
node.body.members.map((m) => {
|
|
17579
17616
|
if (!("init" in m))
|
|
17580
17617
|
return "Number";
|
|
17581
|
-
const [node2, type] = (0,
|
|
17618
|
+
const [node2, type] = (0, import_chunk_JDC43A3I.getNodeValue)(m.init);
|
|
17582
17619
|
return node2 ? type : null;
|
|
17583
17620
|
})
|
|
17584
17621
|
);
|
|
@@ -17587,7 +17624,7 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17587
17624
|
if (!node.id)
|
|
17588
17625
|
return false;
|
|
17589
17626
|
state.removeNodeComments(node, ast);
|
|
17590
|
-
const typedefDecl = (0,
|
|
17627
|
+
const typedefDecl = (0, import_chunk_JDC43A3I.withLocDeep)(
|
|
17591
17628
|
{
|
|
17592
17629
|
type: "TypedefDeclaration",
|
|
17593
17630
|
id: node.id,
|
|
@@ -17597,7 +17634,7 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17597
17634
|
type: "TypeSpecList",
|
|
17598
17635
|
ts: Array.from(enumType).map((t) => ({
|
|
17599
17636
|
type: "TypeSpecPart",
|
|
17600
|
-
name: t === "Null" ? t : (0,
|
|
17637
|
+
name: t === "Null" ? t : (0, import_chunk_JDC43A3I.makeScopedName)(`Toybox.Lang.${t}`)
|
|
17601
17638
|
}))
|
|
17602
17639
|
},
|
|
17603
17640
|
prefix: true,
|
|
@@ -17625,7 +17662,7 @@ function cleanup(state, node, ast, usedNodes) {
|
|
|
17625
17662
|
}
|
|
17626
17663
|
case "VariableDeclarator": {
|
|
17627
17664
|
const name = variableDeclarationName(node.id);
|
|
17628
|
-
return !(0,
|
|
17665
|
+
return !(0, import_chunk_JDC43A3I.hasProperty)(state.index, name) || (0, import_chunk_JDC43A3I.hasProperty)(state.exposed, name) || (0, import_chunk_JDC43A3I.hasProperty)(state.usedByName, name) ? null : false;
|
|
17629
17666
|
}
|
|
17630
17667
|
case "VariableDeclaration": {
|
|
17631
17668
|
if (!node.declarations.length) {
|
|
@@ -17667,7 +17704,7 @@ function optimizeCall(istate, node, context) {
|
|
|
17667
17704
|
if (!callees || !callees.length) {
|
|
17668
17705
|
const n = name || "name" in node.callee && node.callee.name || "property" in node.callee && node.callee.property && "name" in node.callee.property && node.callee.property.name;
|
|
17669
17706
|
if (n) {
|
|
17670
|
-
if ((0,
|
|
17707
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state.allFunctions, n)) {
|
|
17671
17708
|
if (state.currentFunction) {
|
|
17672
17709
|
recordCalledFuncs(state.currentFunction, state.allFunctions[n]);
|
|
17673
17710
|
}
|
|
@@ -17686,11 +17723,11 @@ function optimizeCall(istate, node, context) {
|
|
|
17686
17723
|
if (callees.length === 1) {
|
|
17687
17724
|
const callee = callees[0].node;
|
|
17688
17725
|
if (callees[0].type === "FunctionDeclaration" && !callee.hasOverride) {
|
|
17689
|
-
if (!context && callee.optimizable && node.arguments.every((n) => (0,
|
|
17726
|
+
if (!context && callee.optimizable && node.arguments.every((n) => (0, import_chunk_JDC43A3I.getNodeValue)(n)[0] !== null)) {
|
|
17690
17727
|
const ret = evaluateFunction(istate, callee, node.arguments);
|
|
17691
17728
|
if (ret) {
|
|
17692
17729
|
inlineDiagnostic(state, callees[0], node, null);
|
|
17693
|
-
return (0,
|
|
17730
|
+
return (0, import_chunk_JDC43A3I.withLoc)(ret, node, node);
|
|
17694
17731
|
}
|
|
17695
17732
|
}
|
|
17696
17733
|
if (shouldInline(state, callees[0], node, context)) {
|
|
@@ -17708,7 +17745,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17708
17745
|
"src/mc-rewrite.ts"() {
|
|
17709
17746
|
"use strict";
|
|
17710
17747
|
init_api();
|
|
17711
|
-
(0,
|
|
17748
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
17712
17749
|
init_data_flow();
|
|
17713
17750
|
init_function_info();
|
|
17714
17751
|
init_inliner();
|
|
@@ -17929,8 +17966,8 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17929
17966
|
loc: outerLoc
|
|
17930
17967
|
});
|
|
17931
17968
|
const makeImport = (type, module2, as) => {
|
|
17932
|
-
const id = (0,
|
|
17933
|
-
return type === "Using" && as ? { type, id, as: (0,
|
|
17969
|
+
const id = (0, import_chunk_JDC43A3I.makeScopedName)(module2);
|
|
17970
|
+
return type === "Using" && as ? { type, id, as: (0, import_chunk_JDC43A3I.makeIdentifier)(as) } : { type, id };
|
|
17934
17971
|
};
|
|
17935
17972
|
ast.body.push(
|
|
17936
17973
|
makeImport("ImportModule", "Toybox.Lang"),
|
|
@@ -17939,8 +17976,15 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17939
17976
|
makeImport("Using", "Toybox.Graphics"),
|
|
17940
17977
|
makeImport("Using", "Toybox.Graphics", "Gfx")
|
|
17941
17978
|
);
|
|
17979
|
+
const barrelName = manifestXML && manifestXML.body instanceof xml_util_exports.Nodes && manifestXML?.body.children("iq:barrel").attrs()[0]?.module?.value.value;
|
|
17980
|
+
const barrelNames = new Set(
|
|
17981
|
+
Object.keys(resources).map((k) => k || barrelName).filter((e) => !!e)
|
|
17982
|
+
);
|
|
17942
17983
|
Object.entries(resources).forEach(([barrel, resourceMap]) => {
|
|
17943
17984
|
let body = ast.body;
|
|
17985
|
+
if (barrel === "" && barrelName) {
|
|
17986
|
+
barrel = barrelName;
|
|
17987
|
+
}
|
|
17944
17988
|
if (barrel !== "") {
|
|
17945
17989
|
const module2 = makeModule(barrel);
|
|
17946
17990
|
body.push(module2);
|
|
@@ -17952,7 +17996,7 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17952
17996
|
rez.body.body.push(hiddenRez);
|
|
17953
17997
|
if (barrel === "" && manifestXML && manifestXML.body instanceof xml_util_exports.Nodes) {
|
|
17954
17998
|
manifestXML.body.children("iq:application").elements.forEach(
|
|
17955
|
-
(e) => add_one_resource(state, manifestXML, rez, e,
|
|
17999
|
+
(e) => add_one_resource(state, manifestXML, rez, e, barrelNames)
|
|
17956
18000
|
);
|
|
17957
18001
|
}
|
|
17958
18002
|
const rezModules = Object.fromEntries(
|
|
@@ -17968,10 +18012,10 @@ function add_resources_to_ast(state, ast, resources, manifestXML) {
|
|
|
17968
18012
|
visit_resources(rez2.body.elements, null, (e, s) => {
|
|
17969
18013
|
if (!s)
|
|
17970
18014
|
return;
|
|
17971
|
-
if (!(0,
|
|
18015
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(rezModules, s))
|
|
17972
18016
|
return;
|
|
17973
18017
|
const module2 = rezModules[s];
|
|
17974
|
-
add_one_resource(state, rez2, module2, e,
|
|
18018
|
+
add_one_resource(state, rez2, module2, e, barrelNames);
|
|
17975
18019
|
});
|
|
17976
18020
|
});
|
|
17977
18021
|
});
|
|
@@ -17987,30 +18031,39 @@ function addPositions(base, pos) {
|
|
|
17987
18031
|
result.offset += pos.offset;
|
|
17988
18032
|
return result;
|
|
17989
18033
|
}
|
|
17990
|
-
function visit_resource_refs(state, doc, e,
|
|
18034
|
+
function visit_resource_refs(state, doc, e, barrelNames) {
|
|
17991
18035
|
const result = [];
|
|
17992
18036
|
const parseArg = (name, loc, skip) => {
|
|
18037
|
+
let base;
|
|
17993
18038
|
if (name.startsWith("@")) {
|
|
17994
18039
|
name = name.substring(1);
|
|
17995
|
-
|
|
17996
|
-
|
|
18040
|
+
loc = (0, import_chunk_JDC43A3I.adjustLoc)(loc, 1, 0);
|
|
18041
|
+
if (barrelNames.size) {
|
|
18042
|
+
const dot = name.indexOf(".");
|
|
18043
|
+
if (dot > 0 && dot < name.length - 1) {
|
|
18044
|
+
const start = name.substring(0, dot);
|
|
18045
|
+
if (barrelNames.has(start)) {
|
|
18046
|
+
base = (0, import_chunk_JDC43A3I.makeScopedName)(`${start}.Rez`, loc);
|
|
18047
|
+
loc = (0, import_chunk_JDC43A3I.adjustLoc)(loc, dot + 1, 0);
|
|
18048
|
+
name = name.substring(dot + 1);
|
|
18049
|
+
}
|
|
18050
|
+
}
|
|
17997
18051
|
}
|
|
17998
|
-
loc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 1, 0);
|
|
17999
18052
|
}
|
|
18000
|
-
if ((0,
|
|
18053
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
|
|
18001
18054
|
return;
|
|
18002
18055
|
}
|
|
18003
18056
|
if (/^([-\w_$]+\s*\.\s*)*[-\w_$]+$/.test(name)) {
|
|
18004
|
-
result.push((0,
|
|
18057
|
+
result.push((0, import_chunk_JDC43A3I.makeScopedName)(name, loc, base));
|
|
18005
18058
|
return;
|
|
18006
18059
|
}
|
|
18007
|
-
const startPos = (0,
|
|
18060
|
+
const startPos = (0, import_chunk_JDC43A3I.adjustLoc)(loc, -1, 0).start;
|
|
18008
18061
|
try {
|
|
18009
18062
|
const expr = import_prettier_plugin_monkeyc3.default.parsers.monkeyc.parse(`(${name})`, null, {
|
|
18010
18063
|
filepath: loc.source || void 0,
|
|
18011
18064
|
singleExpression: true
|
|
18012
18065
|
});
|
|
18013
|
-
(0,
|
|
18066
|
+
(0, import_chunk_JDC43A3I.traverseAst)(expr, (node) => {
|
|
18014
18067
|
if (node.loc) {
|
|
18015
18068
|
node.loc = {
|
|
18016
18069
|
source: node.loc.source,
|
|
@@ -18062,16 +18115,16 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18062
18115
|
loc.start.offset -= name.length;
|
|
18063
18116
|
}
|
|
18064
18117
|
} else {
|
|
18065
|
-
const base = (0,
|
|
18066
|
-
const idLoc = (0,
|
|
18118
|
+
const base = (0, import_chunk_JDC43A3I.makeScopedName)(`Rez.Styles`);
|
|
18119
|
+
const idLoc = (0, import_chunk_JDC43A3I.adjustLoc)(loc, 0, 0);
|
|
18067
18120
|
idLoc.end = { ...idLoc.start };
|
|
18068
18121
|
idLoc.end.column += name.length;
|
|
18069
18122
|
idLoc.end.offset += name.length;
|
|
18070
|
-
const id2 = (0,
|
|
18071
|
-
result.push((0,
|
|
18123
|
+
const id2 = (0, import_chunk_JDC43A3I.makeIdentifier)(name, idLoc);
|
|
18124
|
+
result.push((0, import_chunk_JDC43A3I.makeMemberExpression)((0, import_chunk_JDC43A3I.withLoc)(base, id2, false), id2));
|
|
18072
18125
|
}
|
|
18073
|
-
return (0,
|
|
18074
|
-
}, (0,
|
|
18126
|
+
return (0, import_chunk_JDC43A3I.adjustLoc)(loc, name.length, 0);
|
|
18127
|
+
}, (0, import_chunk_JDC43A3I.adjustLoc)(l, 0, 0));
|
|
18075
18128
|
return;
|
|
18076
18129
|
}
|
|
18077
18130
|
if (/^\s*(true|false|null|NaN|(0x|#)[0-9a-f]+|[-+]?\d+%?)\s*$/i.test(dotted)) {
|
|
@@ -18084,7 +18137,7 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18084
18137
|
parseArg(
|
|
18085
18138
|
dotted,
|
|
18086
18139
|
l,
|
|
18087
|
-
name && (0,
|
|
18140
|
+
name && (0, import_chunk_JDC43A3I.hasProperty)(drawableSkips, name) ? drawableSkips[name] : null
|
|
18088
18141
|
);
|
|
18089
18142
|
}
|
|
18090
18143
|
return;
|
|
@@ -18098,7 +18151,7 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18098
18151
|
case "drawable-list":
|
|
18099
18152
|
case "text-area":
|
|
18100
18153
|
case "label":
|
|
18101
|
-
if (id && (0,
|
|
18154
|
+
if (id && (0, import_chunk_JDC43A3I.hasProperty)(drawableSkips, id)) {
|
|
18102
18155
|
parseArg(dotted, l, drawableSkips[id]);
|
|
18103
18156
|
}
|
|
18104
18157
|
return;
|
|
@@ -18118,7 +18171,7 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18118
18171
|
Object.values(node.attr).forEach((attr) => {
|
|
18119
18172
|
if (!attr || !attr.value.loc)
|
|
18120
18173
|
return;
|
|
18121
|
-
const loc = (0,
|
|
18174
|
+
const loc = (0, import_chunk_JDC43A3I.adjustLoc)(attr.value.loc);
|
|
18122
18175
|
stringToScopedName(node, attr.name.value, attr.value.value, loc);
|
|
18123
18176
|
});
|
|
18124
18177
|
const content = doc.textContent(node);
|
|
@@ -18132,7 +18185,7 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18132
18185
|
node,
|
|
18133
18186
|
null,
|
|
18134
18187
|
content,
|
|
18135
|
-
(0,
|
|
18188
|
+
(0, import_chunk_JDC43A3I.locRange)(
|
|
18136
18189
|
node.children[0].loc,
|
|
18137
18190
|
node.children[node.children.length - 1].loc
|
|
18138
18191
|
)
|
|
@@ -18145,29 +18198,29 @@ function visit_resource_refs(state, doc, e, barrel) {
|
|
|
18145
18198
|
});
|
|
18146
18199
|
return result;
|
|
18147
18200
|
}
|
|
18148
|
-
function add_one_resource(state, doc, module2, e,
|
|
18201
|
+
function add_one_resource(state, doc, module2, e, barrelNames) {
|
|
18149
18202
|
let id;
|
|
18150
18203
|
let func;
|
|
18151
18204
|
const makeVarDecl = (id2, outer) => {
|
|
18152
|
-
const loc = id2 && (0,
|
|
18153
|
-
return (0,
|
|
18205
|
+
const loc = id2 && (0, import_chunk_JDC43A3I.adjustLoc)(id2.value.loc);
|
|
18206
|
+
return (0, import_chunk_JDC43A3I.wrap)(
|
|
18154
18207
|
{
|
|
18155
18208
|
type: "VariableDeclaration",
|
|
18156
18209
|
declarations: [
|
|
18157
|
-
(0,
|
|
18210
|
+
(0, import_chunk_JDC43A3I.wrap)(
|
|
18158
18211
|
{
|
|
18159
18212
|
type: "VariableDeclarator",
|
|
18160
18213
|
kind: "var",
|
|
18161
18214
|
id: {
|
|
18162
18215
|
type: "BinaryExpression",
|
|
18163
18216
|
operator: "as",
|
|
18164
|
-
left: (0,
|
|
18217
|
+
left: (0, import_chunk_JDC43A3I.makeIdentifier)(id2 ? id2.value.value : "*invalid*", loc),
|
|
18165
18218
|
right: {
|
|
18166
18219
|
type: "TypeSpecList",
|
|
18167
18220
|
ts: [
|
|
18168
18221
|
{
|
|
18169
18222
|
type: "TypeSpecPart",
|
|
18170
|
-
name: (0,
|
|
18223
|
+
name: (0, import_chunk_JDC43A3I.makeScopedName)(
|
|
18171
18224
|
(state?.sdkVersion ?? 0) >= 7e6 ? "Toybox.Lang.ResourceId" : "Toybox.Lang.Symbol"
|
|
18172
18225
|
)
|
|
18173
18226
|
}
|
|
@@ -18200,7 +18253,7 @@ function add_one_resource(state, doc, module2, e, barrel) {
|
|
|
18200
18253
|
type: "ClassElement",
|
|
18201
18254
|
item: {
|
|
18202
18255
|
type: "FunctionDeclaration",
|
|
18203
|
-
id: (0,
|
|
18256
|
+
id: (0, import_chunk_JDC43A3I.makeIdentifier)("initialize", loc),
|
|
18204
18257
|
body: null,
|
|
18205
18258
|
params: [],
|
|
18206
18259
|
loc: e.loc
|
|
@@ -18209,8 +18262,8 @@ function add_one_resource(state, doc, module2, e, barrel) {
|
|
|
18209
18262
|
return {
|
|
18210
18263
|
type: "ClassDeclaration",
|
|
18211
18264
|
body: { type: "ClassBody", body: items, loc: e.loc },
|
|
18212
|
-
id: (0,
|
|
18213
|
-
superClass: (0,
|
|
18265
|
+
id: (0, import_chunk_JDC43A3I.makeIdentifier)(id.value.value, loc),
|
|
18266
|
+
superClass: (0, import_chunk_JDC43A3I.makeScopedName)(parent),
|
|
18214
18267
|
loc: e.loc
|
|
18215
18268
|
};
|
|
18216
18269
|
};
|
|
@@ -18222,18 +18275,18 @@ function add_one_resource(state, doc, module2, e, barrel) {
|
|
|
18222
18275
|
return {
|
|
18223
18276
|
type: "FunctionDeclaration",
|
|
18224
18277
|
body: { type: "BlockStatement", body: items, loc: e.loc },
|
|
18225
|
-
id: (0,
|
|
18278
|
+
id: (0, import_chunk_JDC43A3I.makeIdentifier)(id.value.value, loc),
|
|
18226
18279
|
params: [
|
|
18227
18280
|
{
|
|
18228
18281
|
type: "BinaryExpression",
|
|
18229
18282
|
operator: "as",
|
|
18230
|
-
left: (0,
|
|
18283
|
+
left: (0, import_chunk_JDC43A3I.makeIdentifier)("dc"),
|
|
18231
18284
|
right: {
|
|
18232
18285
|
type: "TypeSpecList",
|
|
18233
18286
|
ts: [
|
|
18234
18287
|
{
|
|
18235
18288
|
type: "TypeSpecPart",
|
|
18236
|
-
name: (0,
|
|
18289
|
+
name: (0, import_chunk_JDC43A3I.makeScopedName)("Graphics.Dc")
|
|
18237
18290
|
}
|
|
18238
18291
|
]
|
|
18239
18292
|
}
|
|
@@ -18248,14 +18301,14 @@ function add_one_resource(state, doc, module2, e, barrel) {
|
|
|
18248
18301
|
ts: [
|
|
18249
18302
|
{
|
|
18250
18303
|
type: "TypeSpecPart",
|
|
18251
|
-
name: (0,
|
|
18304
|
+
name: (0, import_chunk_JDC43A3I.makeScopedName)("$.Toybox.Lang.Array"),
|
|
18252
18305
|
generics: [
|
|
18253
18306
|
{
|
|
18254
18307
|
type: "TypeSpecList",
|
|
18255
18308
|
ts: [
|
|
18256
18309
|
{
|
|
18257
18310
|
type: "TypeSpecPart",
|
|
18258
|
-
name: (0,
|
|
18311
|
+
name: (0, import_chunk_JDC43A3I.makeScopedName)("$.Toybox.WatchUi.Drawable")
|
|
18259
18312
|
}
|
|
18260
18313
|
]
|
|
18261
18314
|
}
|
|
@@ -18309,12 +18362,12 @@ function add_one_resource(state, doc, module2, e, barrel) {
|
|
|
18309
18362
|
}
|
|
18310
18363
|
if (!func)
|
|
18311
18364
|
return;
|
|
18312
|
-
const elements = visit_resource_refs(state, doc, e,
|
|
18365
|
+
const elements = visit_resource_refs(state, doc, e, barrelNames);
|
|
18313
18366
|
const startLoc = elements[0]?.loc;
|
|
18314
18367
|
const endLoc = elements[elements.length - 1]?.loc;
|
|
18315
|
-
const init = elements.length ? (0,
|
|
18368
|
+
const init = elements.length ? (0, import_chunk_JDC43A3I.wrap)(
|
|
18316
18369
|
{ type: "ArrayExpression", elements },
|
|
18317
|
-
startLoc && endLoc && (0,
|
|
18370
|
+
startLoc && endLoc && (0, import_chunk_JDC43A3I.locRange)(startLoc, endLoc)
|
|
18318
18371
|
) : void 0;
|
|
18319
18372
|
if (!id) {
|
|
18320
18373
|
if (!init)
|
|
@@ -18330,7 +18383,7 @@ var init_resources = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
18330
18383
|
"src/resources.ts"() {
|
|
18331
18384
|
"use strict";
|
|
18332
18385
|
init_api();
|
|
18333
|
-
(0,
|
|
18386
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
18334
18387
|
init_sdk_util();
|
|
18335
18388
|
drawableSkips = {
|
|
18336
18389
|
x: { center: true, left: true, right: true, start: true },
|
|
@@ -18612,7 +18665,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
|
|
|
18612
18665
|
if (!value2 || value2.type !== "EnumStringMember" && (value2.type !== "VariableDeclarator" || value2.kind !== "const")) {
|
|
18613
18666
|
throw `Negative constant ${fixup} did not refer to a constant`;
|
|
18614
18667
|
}
|
|
18615
|
-
const init = (0,
|
|
18668
|
+
const init = (0, import_chunk_JDC43A3I.getLiteralNode)(value2.init);
|
|
18616
18669
|
if (!init || init.type !== "Literal") {
|
|
18617
18670
|
throw `Negative constant ${fixup} was not a Literal`;
|
|
18618
18671
|
}
|
|
@@ -18627,7 +18680,7 @@ async function getApiMapping(state, resourcesMap, manifestXML) {
|
|
|
18627
18680
|
return result;
|
|
18628
18681
|
}
|
|
18629
18682
|
function isStateNode(node) {
|
|
18630
|
-
return (0,
|
|
18683
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(node, "node");
|
|
18631
18684
|
}
|
|
18632
18685
|
function variableDeclarationName(node) {
|
|
18633
18686
|
return ("left" in node ? node.left : node).name;
|
|
@@ -18663,7 +18716,7 @@ function checkOne(state, ns, decls, node) {
|
|
|
18663
18716
|
}
|
|
18664
18717
|
return cls.superClass.reduce((result, sup) => {
|
|
18665
18718
|
const sdecls = sup[decls];
|
|
18666
|
-
const next = (0,
|
|
18719
|
+
const next = (0, import_chunk_JDC43A3I.hasProperty)(sdecls, node.name) ? sdecls[node.name] : superChain(sup);
|
|
18667
18720
|
return next ? result ? result.concat(next) : next : result;
|
|
18668
18721
|
}, null);
|
|
18669
18722
|
};
|
|
@@ -18684,7 +18737,7 @@ function checkOne(state, ns, decls, node) {
|
|
|
18684
18737
|
}, null);
|
|
18685
18738
|
};
|
|
18686
18739
|
const ndecls = ns[decls];
|
|
18687
|
-
if ((0,
|
|
18740
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(ndecls, node.name)) {
|
|
18688
18741
|
return ndecls[node.name];
|
|
18689
18742
|
}
|
|
18690
18743
|
switch (ns.type) {
|
|
@@ -18737,7 +18790,7 @@ function lookupNext(state, results, decls, property) {
|
|
|
18737
18790
|
return;
|
|
18738
18791
|
}
|
|
18739
18792
|
if (module2.init.type === "Literal") {
|
|
18740
|
-
const [, type] = (0,
|
|
18793
|
+
const [, type] = (0, import_chunk_JDC43A3I.getNodeValue)(module2.init);
|
|
18741
18794
|
switch (type) {
|
|
18742
18795
|
case "Null":
|
|
18743
18796
|
break;
|
|
@@ -18858,7 +18911,7 @@ function lookup(state, decls, node, name, maybeStack, nonlocal, ignoreImports) {
|
|
|
18858
18911
|
case "ClassDeclaration":
|
|
18859
18912
|
if (inStatic && state.config?.enforceStatic !== "NO") {
|
|
18860
18913
|
inStatic = false;
|
|
18861
|
-
if ((0,
|
|
18914
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(si[decls], node.name)) {
|
|
18862
18915
|
const r = si[decls][node.name].filter((s) => {
|
|
18863
18916
|
switch (s.type) {
|
|
18864
18917
|
case "FunctionDeclaration":
|
|
@@ -18949,7 +19002,7 @@ function lookup(state, decls, node, name, maybeStack, nonlocal, ignoreImports) {
|
|
|
18949
19002
|
return [null, null];
|
|
18950
19003
|
}
|
|
18951
19004
|
case "Literal": {
|
|
18952
|
-
const [, type] = (0,
|
|
19005
|
+
const [, type] = (0, import_chunk_JDC43A3I.getNodeValue)(node);
|
|
18953
19006
|
if (type === "Null")
|
|
18954
19007
|
break;
|
|
18955
19008
|
return [
|
|
@@ -19053,7 +19106,7 @@ function stateFuncs() {
|
|
|
19053
19106
|
return this.stack[this.stack.length - 1];
|
|
19054
19107
|
},
|
|
19055
19108
|
traverse(root) {
|
|
19056
|
-
return (0,
|
|
19109
|
+
return (0, import_chunk_JDC43A3I.traverseAst)(
|
|
19057
19110
|
root,
|
|
19058
19111
|
(node) => {
|
|
19059
19112
|
try {
|
|
@@ -19163,7 +19216,7 @@ function stateFuncs() {
|
|
|
19163
19216
|
if (name) {
|
|
19164
19217
|
if (!parent.decls)
|
|
19165
19218
|
parent.decls = {};
|
|
19166
|
-
if ((0,
|
|
19219
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(parent.decls, name)) {
|
|
19167
19220
|
const what = node.type === "ModuleDeclaration" ? "type" : "node";
|
|
19168
19221
|
const e = parent.decls[name].find(
|
|
19169
19222
|
(d) => isStateNode(d) && d[what] === elm[what]
|
|
@@ -19186,7 +19239,7 @@ function stateFuncs() {
|
|
|
19186
19239
|
if (node.type === "ModuleDeclaration" || node.type === "ClassDeclaration") {
|
|
19187
19240
|
if (!parent.type_decls)
|
|
19188
19241
|
parent.type_decls = {};
|
|
19189
|
-
if (!(0,
|
|
19242
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(parent.type_decls, name)) {
|
|
19190
19243
|
parent.type_decls[name] = [];
|
|
19191
19244
|
}
|
|
19192
19245
|
parent.type_decls[name].push(elm);
|
|
@@ -19215,7 +19268,7 @@ function stateFuncs() {
|
|
|
19215
19268
|
const parent = this.top().sn;
|
|
19216
19269
|
if (!parent.type_decls)
|
|
19217
19270
|
parent.type_decls = {};
|
|
19218
|
-
if (!(0,
|
|
19271
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(parent.type_decls, name)) {
|
|
19219
19272
|
parent.type_decls[name] = [];
|
|
19220
19273
|
} else if (parent.type_decls[name].find(
|
|
19221
19274
|
(n) => (isStateNode(n) ? n.node : n) === node
|
|
@@ -19244,7 +19297,7 @@ function stateFuncs() {
|
|
|
19244
19297
|
const stack = this.stackClone();
|
|
19245
19298
|
node.declarations.forEach((decl) => {
|
|
19246
19299
|
const name = variableDeclarationName(decl.id);
|
|
19247
|
-
if (!(0,
|
|
19300
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(decls, name)) {
|
|
19248
19301
|
decls[name] = [];
|
|
19249
19302
|
} else if (decls[name].find(
|
|
19250
19303
|
(n) => (isStateNode(n) ? n.node : n) === decl
|
|
@@ -19261,7 +19314,7 @@ function stateFuncs() {
|
|
|
19261
19314
|
attributes: stateNodeAttrs(node.attrs)
|
|
19262
19315
|
});
|
|
19263
19316
|
if (node.kind === "const") {
|
|
19264
|
-
if (!(0,
|
|
19317
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(this.index, name)) {
|
|
19265
19318
|
this.index[name] = [];
|
|
19266
19319
|
}
|
|
19267
19320
|
(0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
|
|
@@ -19304,7 +19357,7 @@ function stateFuncs() {
|
|
|
19304
19357
|
};
|
|
19305
19358
|
}
|
|
19306
19359
|
const name = m.id.name;
|
|
19307
|
-
const init = (0,
|
|
19360
|
+
const init = (0, import_chunk_JDC43A3I.getLiteralNode)(m.init);
|
|
19308
19361
|
if (init) {
|
|
19309
19362
|
if (init !== m.init) {
|
|
19310
19363
|
if (m.init.enumType) {
|
|
@@ -19316,7 +19369,7 @@ function stateFuncs() {
|
|
|
19316
19369
|
prev = init.value;
|
|
19317
19370
|
}
|
|
19318
19371
|
}
|
|
19319
|
-
if (!(0,
|
|
19372
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(values, name)) {
|
|
19320
19373
|
values[name] = [];
|
|
19321
19374
|
}
|
|
19322
19375
|
if ((0, import_chunk_OASVKTK5.pushUnique)(values[name], m) && currentEnum) {
|
|
@@ -19324,7 +19377,7 @@ function stateFuncs() {
|
|
|
19324
19377
|
this.enumMap = /* @__PURE__ */ new Map();
|
|
19325
19378
|
this.enumMap.set(m, currentEnum);
|
|
19326
19379
|
}
|
|
19327
|
-
if (!(0,
|
|
19380
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(this.index, name)) {
|
|
19328
19381
|
this.index[name] = [];
|
|
19329
19382
|
}
|
|
19330
19383
|
(0, import_chunk_OASVKTK5.pushUnique)(this.index[name], parent);
|
|
@@ -19642,7 +19695,7 @@ function findUsing(state, stack, using) {
|
|
|
19642
19695
|
find(node.object);
|
|
19643
19696
|
name = node.property.name;
|
|
19644
19697
|
}
|
|
19645
|
-
if ((0,
|
|
19698
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(module2.decls, name)) {
|
|
19646
19699
|
const decls = module2.decls[name];
|
|
19647
19700
|
if (decls && decls.length === 1 && decls[0].type === "ModuleDeclaration") {
|
|
19648
19701
|
module2 = decls[0];
|
|
@@ -19671,7 +19724,7 @@ function findUsingForNode(state, stack, i, node) {
|
|
|
19671
19724
|
let imports = null;
|
|
19672
19725
|
while (i >= 0) {
|
|
19673
19726
|
const si = stack[i--];
|
|
19674
|
-
if ((0,
|
|
19727
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(si.usings, node.name)) {
|
|
19675
19728
|
const using = si.usings[node.name];
|
|
19676
19729
|
return findUsing(state, stack, using);
|
|
19677
19730
|
}
|
|
@@ -19680,7 +19733,7 @@ function findUsingForNode(state, stack, i, node) {
|
|
|
19680
19733
|
const using = si.imports[j];
|
|
19681
19734
|
const module2 = findUsing(state, stack, using);
|
|
19682
19735
|
if (module2) {
|
|
19683
|
-
if ((0,
|
|
19736
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(module2.type_decls, node.name)) {
|
|
19684
19737
|
if (!imports)
|
|
19685
19738
|
imports = [];
|
|
19686
19739
|
imports.push({
|
|
@@ -19774,7 +19827,7 @@ function diagnosticHelper(diagnostics, node, message, type = "INFO", extra) {
|
|
|
19774
19827
|
if (!loc || !loc.source)
|
|
19775
19828
|
return;
|
|
19776
19829
|
const source = loc.source;
|
|
19777
|
-
if (!(0,
|
|
19830
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(diagnostics, source)) {
|
|
19778
19831
|
if (!message)
|
|
19779
19832
|
return;
|
|
19780
19833
|
diagnostics[source] = [];
|
|
@@ -19819,7 +19872,7 @@ function getSuperClasses(klass) {
|
|
|
19819
19872
|
}
|
|
19820
19873
|
var init_api = (0, import_chunk_ABYVSU2C.__esm)({
|
|
19821
19874
|
"src/api.ts"() {
|
|
19822
|
-
(0,
|
|
19875
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
19823
19876
|
init_data_flow();
|
|
19824
19877
|
init_mc_rewrite();
|
|
19825
19878
|
init_negative_fixups();
|
|
@@ -20035,7 +20088,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
20035
20088
|
break;
|
|
20036
20089
|
case "Literal":
|
|
20037
20090
|
if (wantsLiteral(node)) {
|
|
20038
|
-
const result = (0,
|
|
20091
|
+
const result = (0, import_chunk_JDC43A3I.getNodeValue)(node);
|
|
20039
20092
|
const key = result[1] + (result[0].value === null ? "" : "-" + result[0].value.toString());
|
|
20040
20093
|
let decl = literals.get(key);
|
|
20041
20094
|
if (!decl) {
|
|
@@ -20188,7 +20241,7 @@ function buildDataFlowGraph(state, func, wantsLiteral, trackInsertionPoints, wan
|
|
|
20188
20241
|
return { type: "mod", node, mayThrow: mayThrow2, callees };
|
|
20189
20242
|
}
|
|
20190
20243
|
default:
|
|
20191
|
-
if (!(0,
|
|
20244
|
+
if (!(0, import_chunk_JDC43A3I.isExpression)(node))
|
|
20192
20245
|
break;
|
|
20193
20246
|
unhandledType(node);
|
|
20194
20247
|
}
|
|
@@ -20303,7 +20356,7 @@ var init_data_flow = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
20303
20356
|
"src/data-flow.ts"() {
|
|
20304
20357
|
"use strict";
|
|
20305
20358
|
init_api();
|
|
20306
|
-
(0,
|
|
20359
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
20307
20360
|
init_control_flow();
|
|
20308
20361
|
init_function_info();
|
|
20309
20362
|
init_type_flow_util();
|
|
@@ -24060,7 +24113,7 @@ function groupBlocks(func) {
|
|
|
24060
24113
|
}
|
|
24061
24114
|
});
|
|
24062
24115
|
const isCfgNode = (node) => {
|
|
24063
|
-
return (0,
|
|
24116
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(node, "items");
|
|
24064
24117
|
};
|
|
24065
24118
|
const sortHelper = (node) => {
|
|
24066
24119
|
const itemsToSort = /* @__PURE__ */ new Set();
|
|
@@ -24195,7 +24248,7 @@ function getLocalsInfo(func) {
|
|
|
24195
24248
|
var init_emit = (0, import_chunk_ABYVSU2C.__esm)({
|
|
24196
24249
|
"src/readprg/emit.ts"() {
|
|
24197
24250
|
"use strict";
|
|
24198
|
-
(0,
|
|
24251
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
24199
24252
|
init_cflow();
|
|
24200
24253
|
init_opcodes();
|
|
24201
24254
|
init_optimize2();
|
|
@@ -24756,7 +24809,7 @@ function bytecodeToString(bytecode, symbolTable) {
|
|
|
24756
24809
|
arg = `${bytecode.arg.argc} ${bytecode.arg.incsp}`;
|
|
24757
24810
|
break;
|
|
24758
24811
|
}
|
|
24759
|
-
if (arg == null && (0,
|
|
24812
|
+
if (arg == null && (0, import_chunk_JDC43A3I.hasProperty)(bytecode, "arg")) {
|
|
24760
24813
|
arg = `${bytecode.arg}`;
|
|
24761
24814
|
}
|
|
24762
24815
|
if (arg != null) {
|
|
@@ -25087,7 +25140,7 @@ var SectionKinds;
|
|
|
25087
25140
|
var init_bytecode = (0, import_chunk_ABYVSU2C.__esm)({
|
|
25088
25141
|
"src/readprg/bytecode.ts"() {
|
|
25089
25142
|
"use strict";
|
|
25090
|
-
(0,
|
|
25143
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
25091
25144
|
init_sdk_util();
|
|
25092
25145
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
25093
25146
|
init_data();
|
|
@@ -28055,7 +28108,7 @@ var init_manifest = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
28055
28108
|
}
|
|
28056
28109
|
});
|
|
28057
28110
|
function isJNode(obj) {
|
|
28058
|
-
return (0,
|
|
28111
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(obj, "type");
|
|
28059
28112
|
}
|
|
28060
28113
|
async function default_jungle() {
|
|
28061
28114
|
const assignments = [];
|
|
@@ -28097,11 +28150,11 @@ async function default_jungle() {
|
|
|
28097
28150
|
);
|
|
28098
28151
|
}
|
|
28099
28152
|
const shape = match[1];
|
|
28100
|
-
if (!(0,
|
|
28153
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(done, shape)) {
|
|
28101
28154
|
rezAndLang(shape, `resources-${shape}`, "base");
|
|
28102
28155
|
done[shape] = true;
|
|
28103
28156
|
}
|
|
28104
|
-
if (!(0,
|
|
28157
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(done, deviceFamily)) {
|
|
28105
28158
|
rezAndLang(deviceFamily, `resources-${deviceFamily}`, shape);
|
|
28106
28159
|
done[deviceFamily] = true;
|
|
28107
28160
|
}
|
|
@@ -28114,7 +28167,7 @@ function process_assignments(assignments, current) {
|
|
|
28114
28167
|
return assignments.reduce((state, a) => {
|
|
28115
28168
|
const { node, dot, dotnames } = a.names.reduce(
|
|
28116
28169
|
(r, name) => {
|
|
28117
|
-
if (!(0,
|
|
28170
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(r.node, name))
|
|
28118
28171
|
r.node[name] = {};
|
|
28119
28172
|
r.dotnames.push(name);
|
|
28120
28173
|
r.node = r.node[name];
|
|
@@ -28185,7 +28238,7 @@ function evaluate_locals(assignments) {
|
|
|
28185
28238
|
value: v.values.map((s) => s.type === "Literal" ? s.value : "").join("")
|
|
28186
28239
|
};
|
|
28187
28240
|
}
|
|
28188
|
-
} else if (v.type === "QualifiedName" && v.names.length === 1 && (0,
|
|
28241
|
+
} else if (v.type === "QualifiedName" && v.names.length === 1 && (0, import_chunk_JDC43A3I.hasProperty)(locals, v.names[0])) {
|
|
28189
28242
|
values.splice(i, 1, ...locals[v.names[0]]);
|
|
28190
28243
|
} else if (v.type === "SubList") {
|
|
28191
28244
|
process_list(v.values);
|
|
@@ -28335,7 +28388,7 @@ function resolve_filename(literal, default_source = null) {
|
|
|
28335
28388
|
return path2.resolve(root, literal.value);
|
|
28336
28389
|
}
|
|
28337
28390
|
async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
28338
|
-
const resolve_file_list = (literals) => Promise.all(
|
|
28391
|
+
const resolve_file_list = (literals, checkExists = true) => Promise.all(
|
|
28339
28392
|
literals.map((v) => {
|
|
28340
28393
|
if (!isJNode(v)) {
|
|
28341
28394
|
return v;
|
|
@@ -28353,13 +28406,13 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28353
28406
|
/[\\/]\*\*([^\\/])/g,
|
|
28354
28407
|
"/**/*$1"
|
|
28355
28408
|
);
|
|
28356
|
-
if (!(0,
|
|
28409
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(cache.resolvedPaths, resolved)) {
|
|
28357
28410
|
if (/[*?[\]{}]/.test(resolved)) {
|
|
28358
28411
|
cache.resolvedPaths[resolved] = (0, import_chunk_OASVKTK5.globSome)(resolved, () => true);
|
|
28359
28412
|
} else {
|
|
28360
28413
|
cache.resolvedPaths[resolved] = fs5.stat(resolved).then(
|
|
28361
28414
|
() => true,
|
|
28362
|
-
() =>
|
|
28415
|
+
() => !checkExists
|
|
28363
28416
|
);
|
|
28364
28417
|
}
|
|
28365
28418
|
}
|
|
@@ -28370,12 +28423,13 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28370
28423
|
).then(
|
|
28371
28424
|
(results) => results.filter((name) => name != null)
|
|
28372
28425
|
);
|
|
28373
|
-
const resolve_one_file_list = async (base, name) => {
|
|
28426
|
+
const resolve_one_file_list = async (base, name, checkExists = true) => {
|
|
28374
28427
|
const bname = base[name];
|
|
28375
28428
|
if (!bname)
|
|
28376
28429
|
return;
|
|
28377
28430
|
const result = await resolve_file_list(
|
|
28378
|
-
bname
|
|
28431
|
+
bname,
|
|
28432
|
+
checkExists
|
|
28379
28433
|
);
|
|
28380
28434
|
if (!result || !result.length) {
|
|
28381
28435
|
delete base[name];
|
|
@@ -28387,7 +28441,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28387
28441
|
resolve_one_file_list(qualifier, "sourcePath"),
|
|
28388
28442
|
resolve_one_file_list(qualifier, "resourcePath"),
|
|
28389
28443
|
resolve_one_file_list(qualifier, "personality"),
|
|
28390
|
-
resolve_one_file_list(qualifier, "barrelPath")
|
|
28444
|
+
resolve_one_file_list(qualifier, "barrelPath", false)
|
|
28391
28445
|
];
|
|
28392
28446
|
const lang = qualifier["lang"];
|
|
28393
28447
|
if (lang) {
|
|
@@ -28409,7 +28463,7 @@ async function resolve_literals(qualifier, default_source, deviceInfo, cache) {
|
|
|
28409
28463
|
resolve_literal_list(qualifier, "excludeAnnotations");
|
|
28410
28464
|
const annotations = {};
|
|
28411
28465
|
Object.entries(qualifier).forEach(([k, v]) => {
|
|
28412
|
-
if ((0,
|
|
28466
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(v, "annotations")) {
|
|
28413
28467
|
annotations[k] = v["annotations"];
|
|
28414
28468
|
resolve_literal_list(annotations, k);
|
|
28415
28469
|
delete qualifier[k];
|
|
@@ -28430,7 +28484,7 @@ async function read_resource_files(targets, cache) {
|
|
|
28430
28484
|
if (!p.qualifier.resourcePath)
|
|
28431
28485
|
return null;
|
|
28432
28486
|
const key = p.qualifier.resourcePath.join(";");
|
|
28433
|
-
if (!(0,
|
|
28487
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(resourceGroupPromises, key)) {
|
|
28434
28488
|
resourceGroupPromises[key] = Promise.all(
|
|
28435
28489
|
p.qualifier.resourcePath.map(
|
|
28436
28490
|
(pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { mark: true })
|
|
@@ -28444,7 +28498,7 @@ async function read_resource_files(targets, cache) {
|
|
|
28444
28498
|
).then(
|
|
28445
28499
|
(paths) => Promise.all(
|
|
28446
28500
|
paths.flat().filter((file) => file.endsWith(".xml")).map((file) => {
|
|
28447
|
-
if (!(0,
|
|
28501
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(cache.resources, file)) {
|
|
28448
28502
|
cache.resources[file] = fs5.readFile(file).then((data) => xml_util_exports.parseXml(data.toString(), file));
|
|
28449
28503
|
}
|
|
28450
28504
|
return Promise.resolve(cache.resources[file]).then((rez) => {
|
|
@@ -28510,9 +28564,9 @@ async function find_build_instructions(targets, resourceGroups, buildDependencie
|
|
|
28510
28564
|
if (!p.qualifier.resourcePath)
|
|
28511
28565
|
return;
|
|
28512
28566
|
const key = p.qualifier.resourcePath.join(";");
|
|
28513
|
-
if (!(0,
|
|
28567
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(resourceGroups, key))
|
|
28514
28568
|
return;
|
|
28515
|
-
if (!(0,
|
|
28569
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(resourceGroups[key], "buildInstructions")) {
|
|
28516
28570
|
resourceGroups[key].buildInstructions = (await Promise.all(
|
|
28517
28571
|
resourceGroups[key].resourceFiles.map(
|
|
28518
28572
|
({ path: path7, resources }) => find_build_instructions_in_resource(
|
|
@@ -28549,7 +28603,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28549
28603
|
if (option === "*") {
|
|
28550
28604
|
return [];
|
|
28551
28605
|
} else {
|
|
28552
|
-
return strs.filter((a) => !(0,
|
|
28606
|
+
return strs.filter((a) => !(0, import_chunk_JDC43A3I.hasProperty)(option, a));
|
|
28553
28607
|
}
|
|
28554
28608
|
};
|
|
28555
28609
|
const ignoreRegExpOption = (str) => {
|
|
@@ -28592,7 +28646,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28592
28646
|
target.qualifier.sourcePath.forEach((path7) => {
|
|
28593
28647
|
const m = path7.match(ignoredSourcePathsRe);
|
|
28594
28648
|
const key2 = m ? "key-" + m.slice(1).join("") : path7;
|
|
28595
|
-
if (!(0,
|
|
28649
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(state.keys, key2)) {
|
|
28596
28650
|
state.keys[key2] = {};
|
|
28597
28651
|
}
|
|
28598
28652
|
state.keys[key2][path7] = true;
|
|
@@ -28658,7 +28712,7 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28658
28712
|
}
|
|
28659
28713
|
return toSortedEntries(value2);
|
|
28660
28714
|
});
|
|
28661
|
-
if (!(0,
|
|
28715
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(groups, serialized)) {
|
|
28662
28716
|
groups[serialized] = {
|
|
28663
28717
|
key: "group" + key.toString().padStart(3, "0"),
|
|
28664
28718
|
optimizerConfig
|
|
@@ -28672,26 +28726,35 @@ function identify_optimizer_groups(targets, options) {
|
|
|
28672
28726
|
target.group.optimizerConfig.products.push(target.product);
|
|
28673
28727
|
});
|
|
28674
28728
|
}
|
|
28675
|
-
function find_barrels(barrelPath) {
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28682
|
-
|
|
28683
|
-
|
|
28729
|
+
function find_barrels(barrelPath, buildDependencies) {
|
|
28730
|
+
return (Array.isArray(barrelPath) ? (
|
|
28731
|
+
// This is a sublist. The barrel has more than one jungle file.
|
|
28732
|
+
Promise.all(barrelPath.map((path7) => (0, import_chunk_OASVKTK5.globa)(path7, { mark: true }))).then(
|
|
28733
|
+
(paths) => [
|
|
28734
|
+
paths.flat().filter((path7) => path7.endsWith(".jungle")).join(";")
|
|
28735
|
+
]
|
|
28736
|
+
)
|
|
28737
|
+
) : (0, import_chunk_OASVKTK5.globa)(barrelPath, { mark: true }).then(
|
|
28684
28738
|
(paths) => Promise.all(
|
|
28685
28739
|
paths.map(
|
|
28686
28740
|
(path7) => path7.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${path7}**/*.barrel`) : path7
|
|
28687
28741
|
)
|
|
28688
28742
|
)
|
|
28689
28743
|
).then(
|
|
28690
|
-
(barrelPaths) => barrelPaths.flat().filter(
|
|
28691
|
-
|
|
28744
|
+
(barrelPaths) => barrelPaths.flat().filter(
|
|
28745
|
+
(path7) => path7.endsWith(".jungle") || path7.endsWith(".barrel")
|
|
28746
|
+
)
|
|
28747
|
+
)).then((paths) => {
|
|
28748
|
+
(0, import_chunk_OASVKTK5.forEach)(
|
|
28749
|
+
barrelPath,
|
|
28750
|
+
(path7) => /[*?[\]{}]/.test(path7) || (buildDependencies[path7] = true)
|
|
28751
|
+
);
|
|
28752
|
+
paths.forEach((path7) => buildDependencies[path7] = true);
|
|
28753
|
+
return paths;
|
|
28754
|
+
});
|
|
28692
28755
|
}
|
|
28693
28756
|
function resolve_barrel(barrel, barrelDir, products, options, cache, buildDependencies) {
|
|
28694
|
-
if ((0,
|
|
28757
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(cache.barrels, barrel)) {
|
|
28695
28758
|
return cache.barrels[barrel];
|
|
28696
28759
|
}
|
|
28697
28760
|
let promise = Promise.resolve(null);
|
|
@@ -28734,7 +28797,7 @@ function resolve_barrel(barrel, barrelDir, products, options, cache, buildDepend
|
|
|
28734
28797
|
throw e;
|
|
28735
28798
|
});
|
|
28736
28799
|
}
|
|
28737
|
-
function resolve_barrels(product, qualifier, barrels, products, options, cache, buildDependencies) {
|
|
28800
|
+
function resolve_barrels(jungle, product, qualifier, barrels, products, options, cache, buildDependencies) {
|
|
28738
28801
|
if (qualifier.annotations) {
|
|
28739
28802
|
Object.keys(qualifier.annotations).forEach((key) => {
|
|
28740
28803
|
if (!barrels.includes(key)) {
|
|
@@ -28759,7 +28822,7 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
28759
28822
|
return result;
|
|
28760
28823
|
}, {});
|
|
28761
28824
|
};
|
|
28762
|
-
if ((0,
|
|
28825
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(cache.barrelMap, barrelMapKey)) {
|
|
28763
28826
|
setBarrelMap(cache.barrelMap[barrelMapKey]);
|
|
28764
28827
|
return null;
|
|
28765
28828
|
}
|
|
@@ -28772,7 +28835,7 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
28772
28835
|
barrels.map((b) => [b, null])
|
|
28773
28836
|
);
|
|
28774
28837
|
return (qualifier.barrelPath || []).reduce(
|
|
28775
|
-
(promise, barrelPath) => promise.then(() => find_barrels(barrelPath)).then((barrelPaths) => {
|
|
28838
|
+
(promise, barrelPath) => promise.then(() => find_barrels(barrelPath, buildDependencies)).then((barrelPaths) => {
|
|
28776
28839
|
return Promise.all(
|
|
28777
28840
|
barrelPaths.map(
|
|
28778
28841
|
(barrel) => resolve_barrel(
|
|
@@ -28791,7 +28854,7 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
28791
28854
|
resolvedBarrel.manifest,
|
|
28792
28855
|
resolvedBarrel.xml
|
|
28793
28856
|
);
|
|
28794
|
-
if (!(0,
|
|
28857
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(barrelMap, name))
|
|
28795
28858
|
return;
|
|
28796
28859
|
const bmapName = barrelMap[name];
|
|
28797
28860
|
if (bmapName) {
|
|
@@ -28809,9 +28872,11 @@ function resolve_barrels(product, qualifier, barrels, products, options, cache,
|
|
|
28809
28872
|
).then(() => {
|
|
28810
28873
|
const unresolved = Object.entries(barrelMap).filter((v) => v[1] === null);
|
|
28811
28874
|
if (unresolved.length) {
|
|
28812
|
-
|
|
28875
|
+
const e = new Error(
|
|
28813
28876
|
`Failed to resolve some barrels: ${unresolved.map(([name]) => name).join(",")}`
|
|
28814
28877
|
);
|
|
28878
|
+
e.source = jungle;
|
|
28879
|
+
throw e;
|
|
28815
28880
|
}
|
|
28816
28881
|
const finalMap = barrelMap;
|
|
28817
28882
|
if (!cache.barrelMap)
|
|
@@ -28847,7 +28912,7 @@ async function get_jungle_and_barrels(jungleFiles, defaultProducts, options, cac
|
|
|
28847
28912
|
if (!options.workspace) {
|
|
28848
28913
|
options.workspace = path2.dirname(manifest);
|
|
28849
28914
|
}
|
|
28850
|
-
if (!(0,
|
|
28915
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(cache.resources, manifest)) {
|
|
28851
28916
|
cache.resources[manifest] = readManifest(manifest);
|
|
28852
28917
|
}
|
|
28853
28918
|
const xml = await Promise.resolve(cache.resources[manifest]);
|
|
@@ -28876,6 +28941,7 @@ async function get_jungle_and_barrels(jungleFiles, defaultProducts, options, cac
|
|
|
28876
28941
|
).then((qualifier) => {
|
|
28877
28942
|
targets.push({ product, qualifier, shape });
|
|
28878
28943
|
return resolve_barrels(
|
|
28944
|
+
jungles[0],
|
|
28879
28945
|
product,
|
|
28880
28946
|
qualifier,
|
|
28881
28947
|
barrels,
|
|
@@ -28889,7 +28955,7 @@ async function get_jungle_and_barrels(jungleFiles, defaultProducts, options, cac
|
|
|
28889
28955
|
});
|
|
28890
28956
|
};
|
|
28891
28957
|
products.forEach((product) => {
|
|
28892
|
-
if ((0,
|
|
28958
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(state, product)) {
|
|
28893
28959
|
const sp = state[product];
|
|
28894
28960
|
if (sp && !Array.isArray(sp) && sp.products) {
|
|
28895
28961
|
sp.products.forEach((p) => add_one(p, product));
|
|
@@ -29075,7 +29141,7 @@ async function getCodeWorkspaceSettings(folder) {
|
|
|
29075
29141
|
return {};
|
|
29076
29142
|
}
|
|
29077
29143
|
function isErrorWithLocation(e) {
|
|
29078
|
-
return (0,
|
|
29144
|
+
return (0, import_chunk_JDC43A3I.hasProperty)(e, "location");
|
|
29079
29145
|
}
|
|
29080
29146
|
function getConfig(options) {
|
|
29081
29147
|
const config = { ...defaultConfig, ...options || {} };
|
|
@@ -29113,7 +29179,7 @@ async function buildOptimizedProject(product, options) {
|
|
|
29113
29179
|
config.products = [product];
|
|
29114
29180
|
} else {
|
|
29115
29181
|
delete config.testBuild;
|
|
29116
|
-
if (!(0,
|
|
29182
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(config, "releaseBuild")) {
|
|
29117
29183
|
config.releaseBuild = true;
|
|
29118
29184
|
}
|
|
29119
29185
|
}
|
|
@@ -29169,7 +29235,7 @@ async function createLocalBarrels(targets, options) {
|
|
|
29169
29235
|
);
|
|
29170
29236
|
const sha1 = crypto3.createHash("sha1").update(rawBarrelDir, "binary").digest("base64").replace(/[/=+]/g, "");
|
|
29171
29237
|
const optBarrelDir = path4.resolve(barrelDir, `${barrel}-${sha1}`);
|
|
29172
|
-
if (!(0,
|
|
29238
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(optBarrels, barrel)) {
|
|
29173
29239
|
optBarrels[barrel] = {
|
|
29174
29240
|
rawBarrelDir,
|
|
29175
29241
|
manifest,
|
|
@@ -29252,7 +29318,7 @@ async function generateOptimizedProject(options) {
|
|
|
29252
29318
|
throw new Error(`Missing group in build target ${p.product}`);
|
|
29253
29319
|
}
|
|
29254
29320
|
const key = configKey(p);
|
|
29255
|
-
if (!(0,
|
|
29321
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(buildConfigs, key)) {
|
|
29256
29322
|
p.group.dir = key;
|
|
29257
29323
|
if (p.group.optimizerConfig.barrelMap && !p.group.optimizerConfig.optBarrels) {
|
|
29258
29324
|
dropBarrels = true;
|
|
@@ -29295,17 +29361,14 @@ async function generateOptimizedProject(options) {
|
|
|
29295
29361
|
let hasPersonality = false;
|
|
29296
29362
|
const promises = Object.keys(buildConfigs).sort().map((key) => {
|
|
29297
29363
|
const buildConfig = buildConfigs[key];
|
|
29298
|
-
const outputPath = path4.join(config.outputPath, key);
|
|
29299
29364
|
return buildConfig ? runTaskInPool({
|
|
29300
29365
|
type: "generateOneConfig",
|
|
29301
29366
|
data: {
|
|
29302
29367
|
buildConfig,
|
|
29303
29368
|
manifestXML: xml,
|
|
29304
29369
|
dependencyFiles,
|
|
29305
|
-
config
|
|
29306
|
-
|
|
29307
|
-
outputPath
|
|
29308
|
-
}
|
|
29370
|
+
config,
|
|
29371
|
+
key
|
|
29309
29372
|
}
|
|
29310
29373
|
}).catch((e) => {
|
|
29311
29374
|
if (!e.stack) {
|
|
@@ -29324,7 +29387,7 @@ async function generateOptimizedProject(options) {
|
|
|
29324
29387
|
if (t.sdkVersion != null && t.sdkVersion >= 4002001) {
|
|
29325
29388
|
hasPersonality = true;
|
|
29326
29389
|
}
|
|
29327
|
-
}) : fs6.rm(path4.resolve(workspace, outputPath), {
|
|
29390
|
+
}) : fs6.rm(path4.resolve(workspace, config.outputPath, key), {
|
|
29328
29391
|
recursive: true,
|
|
29329
29392
|
force: true
|
|
29330
29393
|
});
|
|
@@ -29429,7 +29492,7 @@ async function generateOptimizedProject(options) {
|
|
|
29429
29492
|
if (qLang) {
|
|
29430
29493
|
const devLang = devices[product].languages;
|
|
29431
29494
|
const unsupportedLangs = Object.keys(qLang).sort().map((key) => {
|
|
29432
|
-
if ((0,
|
|
29495
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(devLang, key) || !(0, import_chunk_JDC43A3I.hasProperty)(languagesToInclude, key)) {
|
|
29433
29496
|
return null;
|
|
29434
29497
|
}
|
|
29435
29498
|
const mapped = map_field(qLang, key, quoted_relative_path);
|
|
@@ -29440,7 +29503,7 @@ async function generateOptimizedProject(options) {
|
|
|
29440
29503
|
let keysToSkip = null;
|
|
29441
29504
|
if (unsupportedLangs.length) {
|
|
29442
29505
|
const key = JSON.stringify(unsupportedLangs);
|
|
29443
|
-
if (!(0,
|
|
29506
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(unsupportedLangsCache, key)) {
|
|
29444
29507
|
const base = nextAvailableDefault();
|
|
29445
29508
|
if (base) {
|
|
29446
29509
|
unsupportedLangs.forEach(
|
|
@@ -29449,13 +29512,13 @@ async function generateOptimizedProject(options) {
|
|
|
29449
29512
|
unsupportedLangsCache[key] = `${base}.lang`;
|
|
29450
29513
|
}
|
|
29451
29514
|
}
|
|
29452
|
-
if ((0,
|
|
29515
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(unsupportedLangsCache, key)) {
|
|
29453
29516
|
keysToSkip = Object.fromEntries(unsupportedLangs);
|
|
29454
29517
|
parts.push(`${prefix}lang = $(${unsupportedLangsCache[key]})`);
|
|
29455
29518
|
}
|
|
29456
29519
|
}
|
|
29457
29520
|
Object.keys(qLang).forEach((key) => {
|
|
29458
|
-
(0,
|
|
29521
|
+
(0, import_chunk_JDC43A3I.hasProperty)(keysToSkip, key) || !(0, import_chunk_JDC43A3I.hasProperty)(languagesToInclude, key) || process_field(`${prefix}lang.`, qLang, key, relative_path);
|
|
29459
29522
|
});
|
|
29460
29523
|
}
|
|
29461
29524
|
});
|
|
@@ -29477,30 +29540,48 @@ async function generateOptimizedProject(options) {
|
|
|
29477
29540
|
diagnostics
|
|
29478
29541
|
};
|
|
29479
29542
|
}
|
|
29480
|
-
async function filesFromPaths(workspace,
|
|
29481
|
-
|
|
29482
|
-
|
|
29543
|
+
async function filesFromPaths(workspace, buildDir, inPaths, extension) {
|
|
29544
|
+
const filter = buildDir.startsWith(workspace);
|
|
29545
|
+
const paths = (await Promise.all(
|
|
29546
|
+
inPaths?.map(
|
|
29547
|
+
(pattern) => (0, import_chunk_OASVKTK5.globa)(pattern, { cwd: workspace, mark: true }).then(
|
|
29548
|
+
(paths2) => paths2.map((p) => ({
|
|
29549
|
+
path: p,
|
|
29550
|
+
filter: filter && /^\*\*[\\/]\*.mc$/i.test(path4.relative(workspace, pattern))
|
|
29551
|
+
}))
|
|
29552
|
+
)
|
|
29553
|
+
) || []
|
|
29483
29554
|
)).flat();
|
|
29484
29555
|
const files = await Promise.all(
|
|
29485
29556
|
paths.map(
|
|
29486
|
-
(
|
|
29557
|
+
(result) => result.path.endsWith("/") ? (0, import_chunk_OASVKTK5.globa)(`${result.path}**/*${extension}`, {
|
|
29558
|
+
cwd: workspace,
|
|
29559
|
+
mark: true
|
|
29560
|
+
}).then(
|
|
29561
|
+
(paths2) => paths2.map((path7) => ({
|
|
29562
|
+
path: path7,
|
|
29563
|
+
filter: result.filter
|
|
29564
|
+
}))
|
|
29565
|
+
) : result
|
|
29487
29566
|
)
|
|
29488
29567
|
);
|
|
29489
29568
|
return {
|
|
29490
29569
|
files: files.flat().filter(
|
|
29491
|
-
(file) => file.endsWith(extension) && !
|
|
29492
|
-
),
|
|
29493
|
-
paths
|
|
29570
|
+
(file) => file.path.endsWith(extension) && (!file.filter || !file.path.startsWith(buildDir))
|
|
29571
|
+
).map(({ path: path7 }) => path7),
|
|
29572
|
+
paths: paths.map(({ path: path7 }) => path7)
|
|
29494
29573
|
};
|
|
29495
29574
|
}
|
|
29496
|
-
async function fileInfoFromConfig(workspace, output, buildConfig, extraExcludes, barrel) {
|
|
29575
|
+
async function fileInfoFromConfig(workspace, buildDir, output, buildConfig, extraExcludes, barrel) {
|
|
29497
29576
|
const { files, paths } = await filesFromPaths(
|
|
29498
29577
|
workspace,
|
|
29578
|
+
buildDir,
|
|
29499
29579
|
buildConfig.sourcePath,
|
|
29500
29580
|
".mc"
|
|
29501
29581
|
);
|
|
29502
29582
|
const { files: personalityFiles } = await filesFromPaths(
|
|
29503
29583
|
workspace,
|
|
29584
|
+
buildDir,
|
|
29504
29585
|
buildConfig.personality,
|
|
29505
29586
|
".mss"
|
|
29506
29587
|
);
|
|
@@ -29538,9 +29619,10 @@ function excludesFromAnnotations(barrel, annotations, resolvedBarrel) {
|
|
|
29538
29619
|
}
|
|
29539
29620
|
return excludes;
|
|
29540
29621
|
}
|
|
29541
|
-
async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, config) {
|
|
29622
|
+
async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, config, key) {
|
|
29542
29623
|
const { workspace } = config;
|
|
29543
|
-
const
|
|
29624
|
+
const outputRoot = path4.resolve(workspace, config.outputPath);
|
|
29625
|
+
const output = path4.join(outputRoot, key);
|
|
29544
29626
|
const buildModeExcludes = {
|
|
29545
29627
|
// note: exclude debug in release builds, and release in debug builds
|
|
29546
29628
|
[config.releaseBuild ? "debug" : "release"]: true
|
|
@@ -29554,6 +29636,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29554
29636
|
}
|
|
29555
29637
|
const { fnMap } = await fileInfoFromConfig(
|
|
29556
29638
|
workspace,
|
|
29639
|
+
outputRoot,
|
|
29557
29640
|
path4.join(output, "source"),
|
|
29558
29641
|
buildConfig,
|
|
29559
29642
|
buildModeExcludes,
|
|
@@ -29571,6 +29654,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29571
29654
|
);
|
|
29572
29655
|
return fileInfoFromConfig(
|
|
29573
29656
|
path4.dirname(resolvedBarrel.jungles[0]),
|
|
29657
|
+
outputRoot,
|
|
29574
29658
|
path4.join(output, "barrels", barrel),
|
|
29575
29659
|
resolvedBarrel.qualifier,
|
|
29576
29660
|
{
|
|
@@ -29586,9 +29670,9 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29586
29670
|
}).flat()
|
|
29587
29671
|
);
|
|
29588
29672
|
barrelFnMaps.forEach(
|
|
29589
|
-
(barrelFnMap) => Object.entries(barrelFnMap).forEach(([
|
|
29590
|
-
if (!(0,
|
|
29591
|
-
fnMap[
|
|
29673
|
+
(barrelFnMap) => Object.entries(barrelFnMap).forEach(([key2, value2]) => {
|
|
29674
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(fnMap, key2)) {
|
|
29675
|
+
fnMap[key2] = value2;
|
|
29592
29676
|
}
|
|
29593
29677
|
})
|
|
29594
29678
|
);
|
|
@@ -29615,7 +29699,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29615
29699
|
const opt_time = await (0, import_chunk_OASVKTK5.first_modified)(
|
|
29616
29700
|
Object.values(fnMap).map((v) => v.output)
|
|
29617
29701
|
);
|
|
29618
|
-
if (source_time < opt_time &&
|
|
29702
|
+
if (source_time < opt_time && 1721003959168 < opt_time) {
|
|
29619
29703
|
return {
|
|
29620
29704
|
hasTests,
|
|
29621
29705
|
diagnostics: prevDiagnostics,
|
|
@@ -29624,13 +29708,12 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29624
29708
|
}
|
|
29625
29709
|
}
|
|
29626
29710
|
}
|
|
29627
|
-
const [
|
|
29628
|
-
fs6.rm(output, { recursive: true, force: true }),
|
|
29629
|
-
fs6.mkdir(output, { recursive: true }),
|
|
29711
|
+
const [prettierConfig] = await Promise.all([
|
|
29630
29712
|
Prettier2.resolveConfig(config.workspace, {
|
|
29631
29713
|
useCache: false,
|
|
29632
29714
|
editorconfig: true
|
|
29633
|
-
})
|
|
29715
|
+
}),
|
|
29716
|
+
fs6.rm(output, { recursive: true, force: true }).then(() => fs6.mkdir(output, { recursive: true }))
|
|
29634
29717
|
]);
|
|
29635
29718
|
return optimizeMonkeyC(fnMap, resourcesMap, manifestXML, config).then(
|
|
29636
29719
|
({ diagnostics, sdkVersion }) => {
|
|
@@ -29654,7 +29737,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29654
29737
|
hasTests: hasTests2,
|
|
29655
29738
|
diagnostics,
|
|
29656
29739
|
sdkVersion,
|
|
29657
|
-
optimizerVersion: "1.1.
|
|
29740
|
+
optimizerVersion: "1.1.69",
|
|
29658
29741
|
...Object.fromEntries(
|
|
29659
29742
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
29660
29743
|
)
|
|
@@ -29699,11 +29782,13 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29699
29782
|
}
|
|
29700
29783
|
return product;
|
|
29701
29784
|
});
|
|
29785
|
+
const { workspace, outputPath } = options;
|
|
29702
29786
|
const { fnMap, paths } = await Promise.all(
|
|
29703
29787
|
Array.from(qualifiers).map(
|
|
29704
29788
|
([name, qualifier]) => fileInfoFromConfig(
|
|
29705
29789
|
qualifier.root,
|
|
29706
|
-
|
|
29790
|
+
path4.resolve(workspace, outputPath ?? "bin/optimized"),
|
|
29791
|
+
workspace,
|
|
29707
29792
|
{
|
|
29708
29793
|
sourcePath: Array.from(qualifier.sourcePath),
|
|
29709
29794
|
personality: Array.from(qualifier.personality),
|
|
@@ -29726,7 +29811,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29726
29811
|
);
|
|
29727
29812
|
if (analysis) {
|
|
29728
29813
|
Object.entries(fnMap).forEach(([k, v]) => {
|
|
29729
|
-
if ((0,
|
|
29814
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(analysis.fnMap, k)) {
|
|
29730
29815
|
const old = analysis.fnMap[k];
|
|
29731
29816
|
if (old.monkeyCSource)
|
|
29732
29817
|
v.monkeyCSource = old.monkeyCSource;
|
|
@@ -29740,7 +29825,7 @@ async function getProjectAnalysisHelper(targets, analysis, manifestXML, options)
|
|
|
29740
29825
|
const addResources = (name, resources) => {
|
|
29741
29826
|
if (!resources)
|
|
29742
29827
|
return;
|
|
29743
|
-
if (!(0,
|
|
29828
|
+
if (!(0, import_chunk_JDC43A3I.hasProperty)(resourcesMap, name)) {
|
|
29744
29829
|
resourcesMap[name] = { ...resources };
|
|
29745
29830
|
} else {
|
|
29746
29831
|
Object.assign(resourcesMap[name], resources);
|
|
@@ -29820,6 +29905,7 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29820
29905
|
init_launch();
|
|
29821
29906
|
init_manifest();
|
|
29822
29907
|
init_mc_rewrite();
|
|
29908
|
+
init_pragma_checker();
|
|
29823
29909
|
init_sdk_util();
|
|
29824
29910
|
init_type_flow();
|
|
29825
29911
|
init_could_be();
|
|
@@ -29827,7 +29913,6 @@ var init_optimizer = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29827
29913
|
init_sub_type();
|
|
29828
29914
|
(0, import_chunk_OASVKTK5.init_util)();
|
|
29829
29915
|
init_worker_pool();
|
|
29830
|
-
init_pragma_checker();
|
|
29831
29916
|
init_optimizer_types();
|
|
29832
29917
|
init_types();
|
|
29833
29918
|
defaultConfig = {
|
|
@@ -29913,7 +29998,8 @@ var init_worker_task = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29913
29998
|
data.buildConfig,
|
|
29914
29999
|
data.manifestXML,
|
|
29915
30000
|
data.dependencyFiles,
|
|
29916
|
-
data.config
|
|
30001
|
+
data.config,
|
|
30002
|
+
data.key
|
|
29917
30003
|
);
|
|
29918
30004
|
},
|
|
29919
30005
|
optimizePrgAndDebug(data) {
|
|
@@ -30115,7 +30201,7 @@ function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, confi
|
|
|
30115
30201
|
const { sections } = readPrgWithOffsets(view);
|
|
30116
30202
|
(0, import_chunk_OASVKTK5.logger)("readprg", 5, sections);
|
|
30117
30203
|
const symbolTable = new SymbolTable();
|
|
30118
|
-
if ((0,
|
|
30204
|
+
if ((0, import_chunk_JDC43A3I.hasProperty)(sections, 1461170197 .toString())) {
|
|
30119
30205
|
symbolTable.parse(sections[
|
|
30120
30206
|
1461170197
|
|
30121
30207
|
/* SYMBOLS */
|
|
@@ -30403,7 +30489,7 @@ var init_readprg = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
30403
30489
|
"use strict";
|
|
30404
30490
|
yauzl = (0, import_chunk_ABYVSU2C.__toESM)(require_yauzl());
|
|
30405
30491
|
yazl = (0, import_chunk_ABYVSU2C.__toESM)(require_yazl());
|
|
30406
|
-
(0,
|
|
30492
|
+
(0, import_chunk_JDC43A3I.init_ast)();
|
|
30407
30493
|
init_bytecode();
|
|
30408
30494
|
init_data();
|
|
30409
30495
|
init_exceptions();
|