@markw65/monkeyc-optimizer 1.1.57 → 1.1.58
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 +8 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-PUEG4GNZ.cjs → chunk-XC5IVRTO.cjs} +210 -136
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/worker-thread.cjs +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the "monkeyc-optimizer" package will be documented in this file.
|
|
4
4
|
|
|
5
|
+
### 1.1.58
|
|
6
|
+
|
|
7
|
+
- Update to [@markw65/prettier-plugin-monkeyc@1.0.57](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1057)
|
|
8
|
+
- Just updates exported types. No change in functionality
|
|
9
|
+
- Properly quote paths in the generated jungle
|
|
10
|
+
- Take account of all references from resource files
|
|
11
|
+
- Include Null in the types of uninitialized variables in their initialize method
|
|
12
|
+
|
|
5
13
|
### 1.1.57
|
|
6
14
|
|
|
7
15
|
- Include ConditionalExpression and LogicalExpression in evaluateFunction
|
package/build/api.cjs
CHANGED
|
@@ -18,47 +18,47 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var api_exports = {};
|
|
20
20
|
__export(api_exports, {
|
|
21
|
-
checkCompilerVersion: () =>
|
|
22
|
-
collectNamespaces: () =>
|
|
23
|
-
createDocumentationMap: () =>
|
|
24
|
-
diagnostic: () =>
|
|
25
|
-
diagnosticHelper: () =>
|
|
26
|
-
findNamesInScope: () =>
|
|
27
|
-
findUsingForNode: () =>
|
|
28
|
-
formatAst: () =>
|
|
29
|
-
formatAstLongLines: () =>
|
|
30
|
-
formatScopedName: () =>
|
|
31
|
-
getApiFunctionInfo: () =>
|
|
32
|
-
getApiMapping: () =>
|
|
33
|
-
getSuperClasses: () =>
|
|
21
|
+
checkCompilerVersion: () => import_chunk_XC5IVRTO.checkCompilerVersion,
|
|
22
|
+
collectNamespaces: () => import_chunk_XC5IVRTO.collectNamespaces,
|
|
23
|
+
createDocumentationMap: () => import_chunk_XC5IVRTO.createDocumentationMap,
|
|
24
|
+
diagnostic: () => import_chunk_XC5IVRTO.diagnostic,
|
|
25
|
+
diagnosticHelper: () => import_chunk_XC5IVRTO.diagnosticHelper,
|
|
26
|
+
findNamesInScope: () => import_chunk_XC5IVRTO.findNamesInScope,
|
|
27
|
+
findUsingForNode: () => import_chunk_XC5IVRTO.findUsingForNode,
|
|
28
|
+
formatAst: () => import_chunk_XC5IVRTO.formatAst,
|
|
29
|
+
formatAstLongLines: () => import_chunk_XC5IVRTO.formatAstLongLines,
|
|
30
|
+
formatScopedName: () => import_chunk_XC5IVRTO.formatScopedName,
|
|
31
|
+
getApiFunctionInfo: () => import_chunk_XC5IVRTO.getApiFunctionInfo,
|
|
32
|
+
getApiMapping: () => import_chunk_XC5IVRTO.getApiMapping,
|
|
33
|
+
getSuperClasses: () => import_chunk_XC5IVRTO.getSuperClasses,
|
|
34
34
|
hasProperty: () => import_chunk_MBTLUWXR.hasProperty,
|
|
35
|
-
isClassVariable: () =>
|
|
36
|
-
isLocal: () =>
|
|
37
|
-
isLookupCandidate: () =>
|
|
38
|
-
isStateNode: () =>
|
|
39
|
-
lookupByFullName: () =>
|
|
40
|
-
lookupNext: () =>
|
|
41
|
-
lookupResultContains: () =>
|
|
42
|
-
lookupWithType: () =>
|
|
43
|
-
makeToyboxLink: () =>
|
|
44
|
-
mapVarDeclsByType: () =>
|
|
45
|
-
markInvokeClassMethod: () =>
|
|
46
|
-
parseSdkVersion: () =>
|
|
47
|
-
resolveDiagnostics: () =>
|
|
48
|
-
resolveDiagnosticsMap: () =>
|
|
49
|
-
sameLookupResult: () =>
|
|
35
|
+
isClassVariable: () => import_chunk_XC5IVRTO.isClassVariable,
|
|
36
|
+
isLocal: () => import_chunk_XC5IVRTO.isLocal,
|
|
37
|
+
isLookupCandidate: () => import_chunk_XC5IVRTO.isLookupCandidate,
|
|
38
|
+
isStateNode: () => import_chunk_XC5IVRTO.isStateNode,
|
|
39
|
+
lookupByFullName: () => import_chunk_XC5IVRTO.lookupByFullName,
|
|
40
|
+
lookupNext: () => import_chunk_XC5IVRTO.lookupNext,
|
|
41
|
+
lookupResultContains: () => import_chunk_XC5IVRTO.lookupResultContains,
|
|
42
|
+
lookupWithType: () => import_chunk_XC5IVRTO.lookupWithType,
|
|
43
|
+
makeToyboxLink: () => import_chunk_XC5IVRTO.makeToyboxLink,
|
|
44
|
+
mapVarDeclsByType: () => import_chunk_XC5IVRTO.mapVarDeclsByType,
|
|
45
|
+
markInvokeClassMethod: () => import_chunk_XC5IVRTO.markInvokeClassMethod,
|
|
46
|
+
parseSdkVersion: () => import_chunk_XC5IVRTO.parseSdkVersion,
|
|
47
|
+
resolveDiagnostics: () => import_chunk_XC5IVRTO.resolveDiagnostics,
|
|
48
|
+
resolveDiagnosticsMap: () => import_chunk_XC5IVRTO.resolveDiagnosticsMap,
|
|
49
|
+
sameLookupResult: () => import_chunk_XC5IVRTO.sameLookupResult,
|
|
50
50
|
traverseAst: () => import_chunk_MBTLUWXR.traverseAst,
|
|
51
|
-
variableDeclarationName: () =>
|
|
52
|
-
visitReferences: () =>
|
|
53
|
-
visit_resources: () =>
|
|
54
|
-
visitorNode: () =>
|
|
51
|
+
variableDeclarationName: () => import_chunk_XC5IVRTO.variableDeclarationName,
|
|
52
|
+
visitReferences: () => import_chunk_XC5IVRTO.visitReferences,
|
|
53
|
+
visit_resources: () => import_chunk_XC5IVRTO.visit_resources,
|
|
54
|
+
visitorNode: () => import_chunk_XC5IVRTO.visitorNode
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(api_exports);
|
|
57
|
-
var
|
|
57
|
+
var import_chunk_XC5IVRTO = require("./chunk-XC5IVRTO.cjs");
|
|
58
58
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
59
59
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
60
60
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
61
|
-
(0,
|
|
61
|
+
(0, import_chunk_XC5IVRTO.init_api)();
|
|
62
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
63
|
0 && (module.exports = {
|
|
64
64
|
checkCompilerVersion,
|
|
@@ -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_XC5IVRTO_exports = {};
|
|
30
|
+
__export(chunk_XC5IVRTO_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -133,7 +133,7 @@ __export(chunk_PUEG4GNZ_exports, {
|
|
|
133
133
|
visitorNode: () => visitorNode,
|
|
134
134
|
xml_util_exports: () => xml_util_exports
|
|
135
135
|
});
|
|
136
|
-
module.exports = __toCommonJS(
|
|
136
|
+
module.exports = __toCommonJS(chunk_XC5IVRTO_exports);
|
|
137
137
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
138
138
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
139
139
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
@@ -12789,12 +12789,12 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
12789
12789
|
const order = getPostOrder(graph).reverse();
|
|
12790
12790
|
const queue = new DataflowQueue();
|
|
12791
12791
|
let selfClassDecl = null;
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
}
|
|
12792
|
+
const isStatic = !!(func.attributes & 8);
|
|
12793
|
+
const klass = func.stack?.[func.stack?.length - 1].sn;
|
|
12794
|
+
if (klass && klass.type === "ClassDeclaration") {
|
|
12795
|
+
selfClassDecl = klass;
|
|
12797
12796
|
}
|
|
12797
|
+
const isInitialize = selfClassDecl && func.name === "initialize";
|
|
12798
12798
|
order.forEach((block, i) => {
|
|
12799
12799
|
block.order = i;
|
|
12800
12800
|
});
|
|
@@ -12994,7 +12994,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
12994
12994
|
);
|
|
12995
12995
|
}
|
|
12996
12996
|
}
|
|
12997
|
-
if (selfClassDecl) {
|
|
12997
|
+
if (!isStatic && selfClassDecl) {
|
|
12998
12998
|
const baseObj = getObjectValue(baseElem.type);
|
|
12999
12999
|
if (baseObj && baseObj.klass.type === 16384 && (0, import_chunk_SG7ODKRM.some)(
|
|
13000
13000
|
baseObj.klass.value,
|
|
@@ -13055,6 +13055,9 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13055
13055
|
cur,
|
|
13056
13056
|
decl.type === "Literal" ? typeFromLiteral(decl) : typeFromTypeStateNode(state, decl, true)
|
|
13057
13057
|
);
|
|
13058
|
+
if (isInitialize && decl.type === "VariableDeclarator" && !decl.node.init && decl.node.kind === "var" && decl.stack[decl.stack.length - 1].sn === selfClassDecl) {
|
|
13059
|
+
cur.type |= 1;
|
|
13060
|
+
}
|
|
13058
13061
|
return cur;
|
|
13059
13062
|
},
|
|
13060
13063
|
{
|
|
@@ -17057,19 +17060,25 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17057
17060
|
Object.values(fnMap).forEach((f) => {
|
|
17058
17061
|
collectNamespaces(f.ast, state);
|
|
17059
17062
|
});
|
|
17060
|
-
const cleanupAll = () =>
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17063
|
+
const cleanupAll = () => {
|
|
17064
|
+
const usedDecls = findRezRefs(state);
|
|
17065
|
+
return Object.values(fnMap).reduce((changes, f) => {
|
|
17066
|
+
(0, import_chunk_MBTLUWXR.traverseAst)(f.ast, void 0, (node) => {
|
|
17067
|
+
if (usedDecls.has(node)) {
|
|
17068
|
+
return null;
|
|
17069
|
+
}
|
|
17070
|
+
const ret = cleanup(state, node, f.ast, usedDecls);
|
|
17071
|
+
if (ret === false) {
|
|
17072
|
+
changes = true;
|
|
17073
|
+
state.removeNodeComments(node, f.ast);
|
|
17074
|
+
} else if (ret) {
|
|
17075
|
+
changes = true;
|
|
17076
|
+
}
|
|
17077
|
+
return ret;
|
|
17078
|
+
});
|
|
17079
|
+
return changes;
|
|
17080
|
+
}, false);
|
|
17081
|
+
};
|
|
17073
17082
|
do {
|
|
17074
17083
|
state.usedByName = {};
|
|
17075
17084
|
state.calledFunctions = {};
|
|
@@ -17080,7 +17089,9 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17080
17089
|
});
|
|
17081
17090
|
state.exposed = state.nextExposed;
|
|
17082
17091
|
state.nextExposed = {};
|
|
17083
|
-
|
|
17092
|
+
if (!cleanupAll())
|
|
17093
|
+
break;
|
|
17094
|
+
} while (state.config?.iterateOptimizer);
|
|
17084
17095
|
delete state.pre;
|
|
17085
17096
|
delete state.post;
|
|
17086
17097
|
if (state.config?.minimizeModules ?? true) {
|
|
@@ -17129,6 +17140,53 @@ async function optimizeMonkeyCHelper(fnMap, resourcesMap, manifestXML, config) {
|
|
|
17129
17140
|
sdkVersion: state.sdkVersion
|
|
17130
17141
|
};
|
|
17131
17142
|
}
|
|
17143
|
+
function findRezRefs(state) {
|
|
17144
|
+
const usedDecls = /* @__PURE__ */ new Set();
|
|
17145
|
+
state.rezAst && visitReferences(
|
|
17146
|
+
state,
|
|
17147
|
+
state.rezAst,
|
|
17148
|
+
null,
|
|
17149
|
+
false,
|
|
17150
|
+
(node, results, error) => {
|
|
17151
|
+
if (error)
|
|
17152
|
+
return;
|
|
17153
|
+
results.forEach(
|
|
17154
|
+
(result) => result.results.forEach((sn) => {
|
|
17155
|
+
switch (sn.type) {
|
|
17156
|
+
case "ModuleDeclaration":
|
|
17157
|
+
case "Program":
|
|
17158
|
+
case "BlockStatement":
|
|
17159
|
+
return;
|
|
17160
|
+
case "Identifier":
|
|
17161
|
+
case "BinaryExpression":
|
|
17162
|
+
return;
|
|
17163
|
+
case "EnumStringMember":
|
|
17164
|
+
if (sn.system)
|
|
17165
|
+
return;
|
|
17166
|
+
usedDecls.add(sn);
|
|
17167
|
+
break;
|
|
17168
|
+
case "ClassDeclaration":
|
|
17169
|
+
case "FunctionDeclaration":
|
|
17170
|
+
case "EnumDeclaration":
|
|
17171
|
+
case "TypedefDeclaration":
|
|
17172
|
+
if (sn.node.attrs?.system)
|
|
17173
|
+
return;
|
|
17174
|
+
case "VariableDeclarator":
|
|
17175
|
+
if (sn.fullName.startsWith("$.Toybox") || sn.fullName.startsWith("$.Rez")) {
|
|
17176
|
+
return;
|
|
17177
|
+
}
|
|
17178
|
+
usedDecls.add(sn.node);
|
|
17179
|
+
break;
|
|
17180
|
+
default:
|
|
17181
|
+
unhandledType(sn);
|
|
17182
|
+
}
|
|
17183
|
+
})
|
|
17184
|
+
);
|
|
17185
|
+
return void 0;
|
|
17186
|
+
}
|
|
17187
|
+
);
|
|
17188
|
+
return usedDecls;
|
|
17189
|
+
}
|
|
17132
17190
|
function maybeCalled(state, func) {
|
|
17133
17191
|
if (!func.body) {
|
|
17134
17192
|
return true;
|
|
@@ -17149,13 +17207,15 @@ function maybeCalled(state, func) {
|
|
|
17149
17207
|
}
|
|
17150
17208
|
return false;
|
|
17151
17209
|
}
|
|
17152
|
-
function cleanup(state, node, ast) {
|
|
17210
|
+
function cleanup(state, node, ast, usedNodes) {
|
|
17153
17211
|
switch (node.type) {
|
|
17154
17212
|
case "ThisExpression":
|
|
17155
17213
|
node.text = "self";
|
|
17156
17214
|
break;
|
|
17157
17215
|
case "EnumStringBody":
|
|
17158
17216
|
if (node.members.every((m) => {
|
|
17217
|
+
if (usedNodes.has(m))
|
|
17218
|
+
return false;
|
|
17159
17219
|
const name = "name" in m ? m.name : m.id.name;
|
|
17160
17220
|
return (0, import_chunk_MBTLUWXR.hasProperty)(state.index, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.exposed, name) && !(0, import_chunk_MBTLUWXR.hasProperty)(state.usedByName, name);
|
|
17161
17221
|
})) {
|
|
@@ -17303,6 +17363,7 @@ var init_mc_rewrite = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17303
17363
|
init_unused_exprs();
|
|
17304
17364
|
(0, import_chunk_SG7ODKRM.init_util)();
|
|
17305
17365
|
init_variable_renamer();
|
|
17366
|
+
init_data_flow();
|
|
17306
17367
|
}
|
|
17307
17368
|
});
|
|
17308
17369
|
var negativeFixups;
|
|
@@ -17975,126 +18036,132 @@ function visitReferences(state, ast, name, defn, callback, includeDefs = false,
|
|
|
17975
18036
|
}
|
|
17976
18037
|
checkResults([id.name, [{ parent: parent.sn, results }]], id);
|
|
17977
18038
|
};
|
|
17978
|
-
|
|
17979
|
-
|
|
17980
|
-
|
|
17981
|
-
|
|
17982
|
-
case "AttributeList":
|
|
18039
|
+
const { pre, post } = state;
|
|
18040
|
+
try {
|
|
18041
|
+
state.pre = (node) => {
|
|
18042
|
+
if (filter && !filter(node))
|
|
17983
18043
|
return [];
|
|
17984
|
-
|
|
17985
|
-
|
|
18044
|
+
switch (node.type) {
|
|
18045
|
+
case "AttributeList":
|
|
17986
18046
|
return [];
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18047
|
+
case "UnaryExpression":
|
|
18048
|
+
if (node.operator === ":")
|
|
18049
|
+
return [];
|
|
18050
|
+
break;
|
|
18051
|
+
case "BinaryExpression":
|
|
18052
|
+
if (node.operator === "has") {
|
|
18053
|
+
if (node.right.type === "UnaryExpression" && node.right.operator === ":") {
|
|
18054
|
+
if (!name || node.right.argument.name === name) {
|
|
18055
|
+
return checkResults(
|
|
18056
|
+
lookup2({
|
|
18057
|
+
type: "MemberExpression",
|
|
18058
|
+
object: node.left,
|
|
18059
|
+
property: node.right.argument,
|
|
18060
|
+
computed: false
|
|
18061
|
+
}),
|
|
18062
|
+
node
|
|
18063
|
+
);
|
|
18064
|
+
}
|
|
18001
18065
|
}
|
|
18002
18066
|
}
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18067
|
+
break;
|
|
18068
|
+
case "CallExpression":
|
|
18069
|
+
if (node.callee.type === "Identifier") {
|
|
18070
|
+
if ((!name || node.callee.name === name) && (!filter || filter(node.callee))) {
|
|
18071
|
+
checkResults(lookup2(node.callee, true), node.callee);
|
|
18072
|
+
}
|
|
18073
|
+
return ["arguments"];
|
|
18009
18074
|
}
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
if (!name || node.name === name) {
|
|
18015
|
-
return checkResults(lookup2(node), node);
|
|
18016
|
-
}
|
|
18017
|
-
break;
|
|
18018
|
-
case "MemberExpression": {
|
|
18019
|
-
const property = isLookupCandidate(node);
|
|
18020
|
-
if (property) {
|
|
18021
|
-
if (!name || property.name === name) {
|
|
18022
|
-
return checkResults(lookup2(node), node) || ["object"];
|
|
18075
|
+
break;
|
|
18076
|
+
case "Identifier":
|
|
18077
|
+
if (!name || node.name === name) {
|
|
18078
|
+
return checkResults(lookup2(node), node);
|
|
18023
18079
|
}
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
throw new Error("Method definition outside of type!");
|
|
18031
|
-
}
|
|
18032
|
-
if (node.params) {
|
|
18033
|
-
node.params.forEach((param) => {
|
|
18034
|
-
if (param.type === "BinaryExpression") {
|
|
18035
|
-
state.traverse(param.right);
|
|
18080
|
+
break;
|
|
18081
|
+
case "MemberExpression": {
|
|
18082
|
+
const property = isLookupCandidate(node);
|
|
18083
|
+
if (property) {
|
|
18084
|
+
if (!name || property.name === name) {
|
|
18085
|
+
return checkResults(lookup2(node), node) || ["object"];
|
|
18036
18086
|
}
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
}
|
|
18041
|
-
case "ModuleDeclaration":
|
|
18042
|
-
if (includeDefs) {
|
|
18043
|
-
visitDef(node.id);
|
|
18044
|
-
}
|
|
18045
|
-
return ["body"];
|
|
18046
|
-
case "ClassDeclaration":
|
|
18047
|
-
if (includeDefs) {
|
|
18048
|
-
visitDef(node.id, node);
|
|
18049
|
-
}
|
|
18050
|
-
return ["body", "superClass"];
|
|
18051
|
-
case "FunctionDeclaration":
|
|
18052
|
-
if (includeDefs) {
|
|
18053
|
-
visitDef(node.id, node);
|
|
18054
|
-
}
|
|
18055
|
-
return ["params", "returnType", "body"];
|
|
18056
|
-
case "TypedefDeclaration":
|
|
18057
|
-
if (includeDefs) {
|
|
18058
|
-
visitDef(node.id, node, "type_decls");
|
|
18059
|
-
}
|
|
18060
|
-
return ["ts"];
|
|
18061
|
-
case "VariableDeclarator":
|
|
18062
|
-
if (includeDefs) {
|
|
18063
|
-
visitDef(node.id, node);
|
|
18087
|
+
return ["object"];
|
|
18088
|
+
}
|
|
18089
|
+
break;
|
|
18064
18090
|
}
|
|
18065
|
-
|
|
18066
|
-
state.
|
|
18091
|
+
case "MethodDefinition": {
|
|
18092
|
+
if (!state.inType) {
|
|
18093
|
+
throw new Error("Method definition outside of type!");
|
|
18094
|
+
}
|
|
18095
|
+
if (node.params) {
|
|
18096
|
+
node.params.forEach((param) => {
|
|
18097
|
+
if (param.type === "BinaryExpression") {
|
|
18098
|
+
state.traverse(param.right);
|
|
18099
|
+
}
|
|
18100
|
+
});
|
|
18101
|
+
}
|
|
18102
|
+
return ["returnType"];
|
|
18067
18103
|
}
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18104
|
+
case "ModuleDeclaration":
|
|
18105
|
+
if (includeDefs) {
|
|
18106
|
+
visitDef(node.id);
|
|
18107
|
+
}
|
|
18108
|
+
return ["body"];
|
|
18109
|
+
case "ClassDeclaration":
|
|
18110
|
+
if (includeDefs) {
|
|
18111
|
+
visitDef(node.id, node);
|
|
18112
|
+
}
|
|
18113
|
+
return ["body", "superClass"];
|
|
18114
|
+
case "FunctionDeclaration":
|
|
18115
|
+
if (includeDefs) {
|
|
18116
|
+
visitDef(node.id, node);
|
|
18117
|
+
}
|
|
18118
|
+
return ["params", "returnType", "body"];
|
|
18119
|
+
case "TypedefDeclaration":
|
|
18120
|
+
if (includeDefs) {
|
|
18072
18121
|
visitDef(node.id, node, "type_decls");
|
|
18073
18122
|
}
|
|
18123
|
+
return ["ts"];
|
|
18124
|
+
case "VariableDeclarator":
|
|
18125
|
+
if (includeDefs) {
|
|
18126
|
+
visitDef(node.id, node);
|
|
18127
|
+
}
|
|
18128
|
+
if (node.id.type === "BinaryExpression") {
|
|
18129
|
+
state.traverse(node.id.right);
|
|
18130
|
+
}
|
|
18131
|
+
return ["init"];
|
|
18132
|
+
case "EnumDeclaration":
|
|
18133
|
+
if (includeDefs) {
|
|
18134
|
+
if (node.id) {
|
|
18135
|
+
visitDef(node.id, node, "type_decls");
|
|
18136
|
+
}
|
|
18137
|
+
break;
|
|
18138
|
+
}
|
|
18139
|
+
return [];
|
|
18140
|
+
case "EnumStringMember": {
|
|
18141
|
+
if (!filter || filter(node.id)) {
|
|
18142
|
+
checkResults(
|
|
18143
|
+
[node.id.name, [{ parent: state.top().sn, results: [node] }]],
|
|
18144
|
+
node
|
|
18145
|
+
);
|
|
18146
|
+
}
|
|
18074
18147
|
break;
|
|
18075
18148
|
}
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
}
|
|
18084
|
-
break;
|
|
18149
|
+
case "CatchClause":
|
|
18150
|
+
if (includeDefs)
|
|
18151
|
+
break;
|
|
18152
|
+
if (node.param && node.param.type !== "Identifier") {
|
|
18153
|
+
state.traverse(node.param.right);
|
|
18154
|
+
}
|
|
18155
|
+
return ["body"];
|
|
18085
18156
|
}
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
return null;
|
|
18095
|
-
};
|
|
18096
|
-
collectNamespaces(ast, state);
|
|
18097
|
-
delete state.pre;
|
|
18157
|
+
return null;
|
|
18158
|
+
};
|
|
18159
|
+
delete state.post;
|
|
18160
|
+
collectNamespaces(ast, state);
|
|
18161
|
+
} finally {
|
|
18162
|
+
state.pre = pre;
|
|
18163
|
+
state.post = post;
|
|
18164
|
+
}
|
|
18098
18165
|
}
|
|
18099
18166
|
var init_visitor = (0, import_chunk_ABYVSU2C.__esm)({
|
|
18100
18167
|
"src/visitor.ts"() {
|
|
@@ -28729,7 +28796,14 @@ async function generateOptimizedProject(options) {
|
|
|
28729
28796
|
const jungle_dir = path4.resolve(workspace, config.outputPath);
|
|
28730
28797
|
await fs6.mkdir(jungle_dir, { recursive: true });
|
|
28731
28798
|
const relative_path = (s) => path4.relative(jungle_dir, s);
|
|
28732
|
-
|
|
28799
|
+
const quoted_relative_path = (s) => {
|
|
28800
|
+
const rel = relative_path(s);
|
|
28801
|
+
if (/[^-*._$/\\\w]/.test(rel)) {
|
|
28802
|
+
return `"${rel}"`;
|
|
28803
|
+
}
|
|
28804
|
+
return rel;
|
|
28805
|
+
};
|
|
28806
|
+
let relative_manifest = quoted_relative_path(manifest);
|
|
28733
28807
|
const manifestOk = (!config.checkManifest || await checkManifest(
|
|
28734
28808
|
xml,
|
|
28735
28809
|
targets.map((t) => t.product)
|
|
@@ -28875,8 +28949,8 @@ async function generateOptimizedProject(options) {
|
|
|
28875
28949
|
).join(";")}`
|
|
28876
28950
|
);
|
|
28877
28951
|
}
|
|
28878
|
-
process_field(prefix, qualifier, "resourcePath",
|
|
28879
|
-
process_field(prefix, qualifier, "personality",
|
|
28952
|
+
process_field(prefix, qualifier, "resourcePath", quoted_relative_path);
|
|
28953
|
+
process_field(prefix, qualifier, "personality", quoted_relative_path);
|
|
28880
28954
|
process_field(prefix, qualifier, "excludeAnnotations");
|
|
28881
28955
|
const qLang = qualifier.lang;
|
|
28882
28956
|
if (qLang) {
|
|
@@ -28885,7 +28959,7 @@ async function generateOptimizedProject(options) {
|
|
|
28885
28959
|
if ((0, import_chunk_MBTLUWXR.hasProperty)(devLang, key) || !(0, import_chunk_MBTLUWXR.hasProperty)(languagesToInclude, key)) {
|
|
28886
28960
|
return null;
|
|
28887
28961
|
}
|
|
28888
|
-
const mapped = map_field(qLang, key,
|
|
28962
|
+
const mapped = map_field(qLang, key, quoted_relative_path);
|
|
28889
28963
|
if (!mapped)
|
|
28890
28964
|
return null;
|
|
28891
28965
|
return [key, mapped];
|
|
@@ -29068,7 +29142,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29068
29142
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
29069
29143
|
Object.values(fnMap).map((v) => v.output)
|
|
29070
29144
|
);
|
|
29071
|
-
if (source_time < opt_time &&
|
|
29145
|
+
if (source_time < opt_time && 1713815963058 < opt_time) {
|
|
29072
29146
|
return {
|
|
29073
29147
|
hasTests,
|
|
29074
29148
|
diagnostics: prevDiagnostics,
|
|
@@ -29107,7 +29181,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29107
29181
|
hasTests: hasTests2,
|
|
29108
29182
|
diagnostics,
|
|
29109
29183
|
sdkVersion,
|
|
29110
|
-
optimizerVersion: "1.1.
|
|
29184
|
+
optimizerVersion: "1.1.58",
|
|
29111
29185
|
...Object.fromEntries(
|
|
29112
29186
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
29113
29187
|
)
|
package/build/optimizer.cjs
CHANGED
|
@@ -18,28 +18,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var optimizer_exports = {};
|
|
20
20
|
__export(optimizer_exports, {
|
|
21
|
-
StateNodeAttributes: () =>
|
|
22
|
-
buildOptimizedProject: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_XC5IVRTO.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_XC5IVRTO.buildOptimizedProject,
|
|
23
23
|
copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
generateOneConfig: () =>
|
|
27
|
-
generateOptimizedProject: () =>
|
|
28
|
-
getConfig: () =>
|
|
29
|
-
getProjectAnalysis: () =>
|
|
30
|
-
get_jungle: () =>
|
|
31
|
-
isErrorWithLocation: () =>
|
|
32
|
-
launchSimulator: () =>
|
|
33
|
-
manifestProducts: () =>
|
|
34
|
-
mctree: () =>
|
|
35
|
-
simulateProgram: () =>
|
|
24
|
+
defaultConfig: () => import_chunk_XC5IVRTO.defaultConfig,
|
|
25
|
+
display: () => import_chunk_XC5IVRTO.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_XC5IVRTO.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_XC5IVRTO.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_XC5IVRTO.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_XC5IVRTO.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_XC5IVRTO.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_XC5IVRTO.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_XC5IVRTO.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_XC5IVRTO.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_XC5IVRTO.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_XC5IVRTO.simulateProgram
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_chunk_XC5IVRTO = require("./chunk-XC5IVRTO.cjs");
|
|
39
39
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
40
40
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
41
41
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
42
|
-
(0,
|
|
42
|
+
(0, import_chunk_XC5IVRTO.init_optimizer)();
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
|
45
45
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,25 +18,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var sdk_util_exports = {};
|
|
20
20
|
__export(sdk_util_exports, {
|
|
21
|
-
SectionKinds: () =>
|
|
22
|
-
appSupport: () =>
|
|
23
|
-
connectiq: () =>
|
|
24
|
-
getDeviceInfo: () =>
|
|
25
|
-
getFunctionDocumentation: () =>
|
|
26
|
-
getLanguages: () =>
|
|
27
|
-
getSdkPath: () =>
|
|
28
|
-
isWin: () =>
|
|
29
|
-
optimizeProgram: () =>
|
|
30
|
-
readPrg: () =>
|
|
31
|
-
readPrgWithOffsets: () =>
|
|
32
|
-
xmlUtil: () =>
|
|
21
|
+
SectionKinds: () => import_chunk_XC5IVRTO.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_XC5IVRTO.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_XC5IVRTO.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_XC5IVRTO.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_XC5IVRTO.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_XC5IVRTO.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_XC5IVRTO.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_XC5IVRTO.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_XC5IVRTO.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_XC5IVRTO.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_XC5IVRTO.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_XC5IVRTO.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_XC5IVRTO = require("./chunk-XC5IVRTO.cjs");
|
|
36
36
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
37
37
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
38
38
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
-
(0,
|
|
39
|
+
(0, import_chunk_XC5IVRTO.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
package/build/worker-thread.cjs
CHANGED
|
@@ -21,17 +21,17 @@ __export(worker_thread_exports, {
|
|
|
21
21
|
default: () => worker_thread_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(worker_thread_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_chunk_XC5IVRTO = require("./chunk-XC5IVRTO.cjs");
|
|
25
25
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
26
26
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
27
27
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
28
28
|
var import_node_worker_threads = require("node:worker_threads");
|
|
29
29
|
var require_worker_thread = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
30
30
|
"src/worker-thread.ts"() {
|
|
31
|
-
(0,
|
|
31
|
+
(0, import_chunk_XC5IVRTO.init_worker_task)();
|
|
32
32
|
if (import_node_worker_threads.parentPort) {
|
|
33
33
|
import_node_worker_threads.parentPort.on("message", async (task) => {
|
|
34
|
-
return import_node_worker_threads.parentPort.postMessage(await (0,
|
|
34
|
+
return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_XC5IVRTO.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markw65/monkeyc-optimizer",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.58",
|
|
5
5
|
"description": "Source to source optimizer for Garmin Monkey C code",
|
|
6
6
|
"main": "build/optimizer.cjs",
|
|
7
7
|
"types": "build/src/optimizer.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"author": "markw65",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@markw65/prettier-plugin-monkeyc": "^1.0.
|
|
55
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.57"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@markw65/peggy-optimizer": "^1.0.1",
|