@markw65/monkeyc-optimizer 1.1.53 → 1.1.55
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 +14 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-32NRMXAJ.cjs → chunk-GWRGLJLB.cjs} +147 -94
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/src/inliner.d.ts +2 -2
- package/build/src/readprg/bytecode.d.ts +1 -0
- package/build/src/readprg/opcodes.d.ts +0 -1
- package/build/worker-thread.cjs +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the "monkeyc-optimizer" package will be documented in this file.
|
|
4
4
|
|
|
5
|
+
### 1.1.55
|
|
6
|
+
|
|
7
|
+
- Allow class typedef lookups from static methods
|
|
8
|
+
- Fix method lookups on enum values
|
|
9
|
+
|
|
10
|
+
### 1.1.54
|
|
11
|
+
|
|
12
|
+
- Fix return types of Dictionary.values() and Dictionary.keys()
|
|
13
|
+
- Fix issue with single-copy-prop creating stores that the Garmin compiler can't parse
|
|
14
|
+
- Handle percentage strings in resources
|
|
15
|
+
- Handle special strings in <param> nodes
|
|
16
|
+
- Don't treat '@Dotted.Name' as special in strings and jsonData
|
|
17
|
+
- Include ipush2 and ipush3 in pre
|
|
18
|
+
|
|
5
19
|
### 1.1.53
|
|
6
20
|
|
|
7
21
|
- Update to [@markw65/prettier-plugin-monkeyc@1.0.56](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1056)
|
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_GWRGLJLB.checkCompilerVersion,
|
|
22
|
+
collectNamespaces: () => import_chunk_GWRGLJLB.collectNamespaces,
|
|
23
|
+
createDocumentationMap: () => import_chunk_GWRGLJLB.createDocumentationMap,
|
|
24
|
+
diagnostic: () => import_chunk_GWRGLJLB.diagnostic,
|
|
25
|
+
diagnosticHelper: () => import_chunk_GWRGLJLB.diagnosticHelper,
|
|
26
|
+
findNamesInScope: () => import_chunk_GWRGLJLB.findNamesInScope,
|
|
27
|
+
findUsingForNode: () => import_chunk_GWRGLJLB.findUsingForNode,
|
|
28
|
+
formatAst: () => import_chunk_GWRGLJLB.formatAst,
|
|
29
|
+
formatAstLongLines: () => import_chunk_GWRGLJLB.formatAstLongLines,
|
|
30
|
+
formatScopedName: () => import_chunk_GWRGLJLB.formatScopedName,
|
|
31
|
+
getApiFunctionInfo: () => import_chunk_GWRGLJLB.getApiFunctionInfo,
|
|
32
|
+
getApiMapping: () => import_chunk_GWRGLJLB.getApiMapping,
|
|
33
|
+
getSuperClasses: () => import_chunk_GWRGLJLB.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_GWRGLJLB.isClassVariable,
|
|
36
|
+
isLocal: () => import_chunk_GWRGLJLB.isLocal,
|
|
37
|
+
isLookupCandidate: () => import_chunk_GWRGLJLB.isLookupCandidate,
|
|
38
|
+
isStateNode: () => import_chunk_GWRGLJLB.isStateNode,
|
|
39
|
+
lookupByFullName: () => import_chunk_GWRGLJLB.lookupByFullName,
|
|
40
|
+
lookupNext: () => import_chunk_GWRGLJLB.lookupNext,
|
|
41
|
+
lookupResultContains: () => import_chunk_GWRGLJLB.lookupResultContains,
|
|
42
|
+
lookupWithType: () => import_chunk_GWRGLJLB.lookupWithType,
|
|
43
|
+
makeToyboxLink: () => import_chunk_GWRGLJLB.makeToyboxLink,
|
|
44
|
+
mapVarDeclsByType: () => import_chunk_GWRGLJLB.mapVarDeclsByType,
|
|
45
|
+
markInvokeClassMethod: () => import_chunk_GWRGLJLB.markInvokeClassMethod,
|
|
46
|
+
parseSdkVersion: () => import_chunk_GWRGLJLB.parseSdkVersion,
|
|
47
|
+
resolveDiagnostics: () => import_chunk_GWRGLJLB.resolveDiagnostics,
|
|
48
|
+
resolveDiagnosticsMap: () => import_chunk_GWRGLJLB.resolveDiagnosticsMap,
|
|
49
|
+
sameLookupResult: () => import_chunk_GWRGLJLB.sameLookupResult,
|
|
50
50
|
traverseAst: () => import_chunk_MBTLUWXR.traverseAst,
|
|
51
|
-
variableDeclarationName: () =>
|
|
52
|
-
visitReferences: () =>
|
|
53
|
-
visit_resources: () =>
|
|
54
|
-
visitorNode: () =>
|
|
51
|
+
variableDeclarationName: () => import_chunk_GWRGLJLB.variableDeclarationName,
|
|
52
|
+
visitReferences: () => import_chunk_GWRGLJLB.visitReferences,
|
|
53
|
+
visit_resources: () => import_chunk_GWRGLJLB.visit_resources,
|
|
54
|
+
visitorNode: () => import_chunk_GWRGLJLB.visitorNode
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(api_exports);
|
|
57
|
-
var
|
|
57
|
+
var import_chunk_GWRGLJLB = require("./chunk-GWRGLJLB.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_GWRGLJLB.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_GWRGLJLB_exports = {};
|
|
30
|
+
__export(chunk_GWRGLJLB_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -133,7 +133,7 @@ __export(chunk_32NRMXAJ_exports, {
|
|
|
133
133
|
visitorNode: () => visitorNode,
|
|
134
134
|
xml_util_exports: () => xml_util_exports
|
|
135
135
|
});
|
|
136
|
-
module.exports = __toCommonJS(
|
|
136
|
+
module.exports = __toCommonJS(chunk_GWRGLJLB_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");
|
|
@@ -5896,7 +5896,11 @@ function shouldInline(state, func, call, context) {
|
|
|
5896
5896
|
state,
|
|
5897
5897
|
func,
|
|
5898
5898
|
call,
|
|
5899
|
-
"This function can only be inlined in statement, assignment, if or return contexts"
|
|
5899
|
+
"This function can only be inlined in statement, assignment, if or return contexts",
|
|
5900
|
+
{
|
|
5901
|
+
uri: "https://github.com/markw65/monkeyc-optimizer/wiki/Inlining#so-inlining-is-restricted-to-a-few-fairly-common-places-or-contexts",
|
|
5902
|
+
message: "contexts"
|
|
5903
|
+
}
|
|
5900
5904
|
);
|
|
5901
5905
|
}
|
|
5902
5906
|
return context != null;
|
|
@@ -6128,7 +6132,7 @@ function unused(state, expression, top) {
|
|
|
6128
6132
|
}
|
|
6129
6133
|
return top ? null : [estmt(expression)];
|
|
6130
6134
|
}
|
|
6131
|
-
function inlineDiagnostic(state, func, call, message) {
|
|
6135
|
+
function inlineDiagnostic(state, func, call, message, extra) {
|
|
6132
6136
|
if (inlineRequested(state, func)) {
|
|
6133
6137
|
if (!state.inlineDiagnostics) {
|
|
6134
6138
|
state.inlineDiagnostics = {};
|
|
@@ -6138,7 +6142,7 @@ function inlineDiagnostic(state, func, call, message) {
|
|
|
6138
6142
|
call,
|
|
6139
6143
|
message && `While inlining ${func.node.id.name}: ${message}`,
|
|
6140
6144
|
"INFO",
|
|
6141
|
-
|
|
6145
|
+
extra
|
|
6142
6146
|
);
|
|
6143
6147
|
}
|
|
6144
6148
|
}
|
|
@@ -9382,7 +9386,7 @@ function getSystemCallTable(state) {
|
|
|
9382
9386
|
returnType.value = value2;
|
|
9383
9387
|
}
|
|
9384
9388
|
}
|
|
9385
|
-
ret.returnType =
|
|
9389
|
+
ret.returnType = returnType;
|
|
9386
9390
|
}
|
|
9387
9391
|
}
|
|
9388
9392
|
return ret;
|
|
@@ -9414,7 +9418,7 @@ function getSystemCallTable(state) {
|
|
|
9414
9418
|
returnType.value = value2;
|
|
9415
9419
|
}
|
|
9416
9420
|
}
|
|
9417
|
-
ret.returnType =
|
|
9421
|
+
ret.returnType = returnType;
|
|
9418
9422
|
}
|
|
9419
9423
|
}
|
|
9420
9424
|
return ret;
|
|
@@ -13576,6 +13580,20 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
13576
13580
|
case "def": {
|
|
13577
13581
|
const lval = event.node.type === "UpdateExpression" ? event.node.argument : event.node.type === "AssignmentExpression" ? event.node.left : null;
|
|
13578
13582
|
if (lval) {
|
|
13583
|
+
if (nodeCopyProp.size && lval.type === "MemberExpression") {
|
|
13584
|
+
let t = lval;
|
|
13585
|
+
while (t.type === "MemberExpression") {
|
|
13586
|
+
t = t.object;
|
|
13587
|
+
}
|
|
13588
|
+
const target = nodeCopyProp.get(t);
|
|
13589
|
+
if (target) {
|
|
13590
|
+
const copyExpr = target.type === "AssignmentExpression" ? target.right : target.type === "VariableDeclarator" ? target.init : null;
|
|
13591
|
+
if (copyExpr?.type === "BinaryExpression") {
|
|
13592
|
+
nodeCopyProp.set(target, false);
|
|
13593
|
+
nodeCopyProp.delete(t);
|
|
13594
|
+
}
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13579
13597
|
if (declIsLocal(event.decl)) {
|
|
13580
13598
|
if (!istate.localLvals) {
|
|
13581
13599
|
istate.localLvals = /* @__PURE__ */ new Set();
|
|
@@ -17516,7 +17534,7 @@ function visit_resource_refs(state, doc, e) {
|
|
|
17516
17534
|
name = name.substring(1);
|
|
17517
17535
|
loc = (0, import_chunk_MBTLUWXR.adjustLoc)(loc, 1, 0);
|
|
17518
17536
|
}
|
|
17519
|
-
if ((0, import_chunk_MBTLUWXR.hasProperty)(skip, name)) {
|
|
17537
|
+
if ((0, import_chunk_MBTLUWXR.hasProperty)(skip, name) || /^\d+(\.\d+)?%?$/.test(name)) {
|
|
17520
17538
|
return;
|
|
17521
17539
|
}
|
|
17522
17540
|
if (/^([-\w_$]+\s*\.\s*)*[-\w_$]+$/.test(name)) {
|
|
@@ -17590,7 +17608,12 @@ function visit_resource_refs(state, doc, e) {
|
|
|
17590
17608
|
switch (element.name) {
|
|
17591
17609
|
case "param":
|
|
17592
17610
|
if (id === null) {
|
|
17593
|
-
|
|
17611
|
+
const name = element.attr.name?.value.value;
|
|
17612
|
+
parseArg(
|
|
17613
|
+
dotted,
|
|
17614
|
+
l,
|
|
17615
|
+
name && (0, import_chunk_MBTLUWXR.hasProperty)(drawableSkips, name) ? drawableSkips[name] : null
|
|
17616
|
+
);
|
|
17594
17617
|
}
|
|
17595
17618
|
return;
|
|
17596
17619
|
case "drawable":
|
|
@@ -17628,16 +17651,22 @@ function visit_resource_refs(state, doc, e) {
|
|
|
17628
17651
|
});
|
|
17629
17652
|
const content = doc.textContent(node);
|
|
17630
17653
|
if (content) {
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17654
|
+
switch (node.name) {
|
|
17655
|
+
case "string":
|
|
17656
|
+
case "jsonData":
|
|
17657
|
+
return false;
|
|
17658
|
+
default:
|
|
17659
|
+
stringToScopedName(
|
|
17660
|
+
node,
|
|
17661
|
+
null,
|
|
17662
|
+
content,
|
|
17663
|
+
(0, import_chunk_MBTLUWXR.locRange)(
|
|
17664
|
+
node.children[0].loc,
|
|
17665
|
+
node.children[node.children.length - 1].loc
|
|
17666
|
+
)
|
|
17667
|
+
);
|
|
17668
|
+
return false;
|
|
17669
|
+
}
|
|
17641
17670
|
}
|
|
17642
17671
|
return;
|
|
17643
17672
|
}
|
|
@@ -17833,7 +17862,9 @@ var init_resources = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
17833
17862
|
init_sdk_util();
|
|
17834
17863
|
drawableSkips = {
|
|
17835
17864
|
x: { center: true, left: true, right: true, start: true },
|
|
17865
|
+
locX: { center: true, left: true, right: true, start: true },
|
|
17836
17866
|
y: { center: true, top: true, bottom: true, start: true },
|
|
17867
|
+
locY: { center: true, top: true, bottom: true, start: true },
|
|
17837
17868
|
width: { fill: true },
|
|
17838
17869
|
height: { fill: true },
|
|
17839
17870
|
a: { fill: true },
|
|
@@ -18216,13 +18247,51 @@ function isLookupCandidate(node) {
|
|
|
18216
18247
|
}
|
|
18217
18248
|
function lookupNext(state, results, decls, property) {
|
|
18218
18249
|
return results.reduce((current, lookupDef) => {
|
|
18219
|
-
const items =
|
|
18250
|
+
const items = [];
|
|
18251
|
+
const addToItems = (sns) => sns.forEach((module2) => {
|
|
18220
18252
|
if (!isStateNode(module2)) {
|
|
18221
|
-
|
|
18253
|
+
if (module2.type === "EnumStringMember") {
|
|
18254
|
+
if (!module2.init) {
|
|
18255
|
+
addToItems(lookupByFullName(state, "Toybox.Lang.Number"));
|
|
18256
|
+
} else if (module2.init.type === "Literal") {
|
|
18257
|
+
const [, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(module2.init);
|
|
18258
|
+
switch (type) {
|
|
18259
|
+
case "Null":
|
|
18260
|
+
return;
|
|
18261
|
+
case "Boolean":
|
|
18262
|
+
case "Char":
|
|
18263
|
+
case "Double":
|
|
18264
|
+
case "Float":
|
|
18265
|
+
case "Long":
|
|
18266
|
+
case "Number":
|
|
18267
|
+
case "String":
|
|
18268
|
+
addToItems(lookupByFullName(state, `Toybox.Lang.${type}`));
|
|
18269
|
+
return;
|
|
18270
|
+
}
|
|
18271
|
+
} else {
|
|
18272
|
+
[
|
|
18273
|
+
"Boolean",
|
|
18274
|
+
"Char",
|
|
18275
|
+
"Double",
|
|
18276
|
+
"Float",
|
|
18277
|
+
"Long",
|
|
18278
|
+
"Number",
|
|
18279
|
+
"String"
|
|
18280
|
+
].forEach(
|
|
18281
|
+
(type) => addToItems(lookupByFullName(state, `Toybox.Lang.${type}`))
|
|
18282
|
+
);
|
|
18283
|
+
return;
|
|
18284
|
+
}
|
|
18285
|
+
}
|
|
18286
|
+
addToItems(lookupByFullName(state, "Toybox.Lang.Object"));
|
|
18287
|
+
return;
|
|
18222
18288
|
}
|
|
18223
18289
|
const res = checkOne(state, module2, decls, property);
|
|
18224
|
-
|
|
18225
|
-
|
|
18290
|
+
if (res) {
|
|
18291
|
+
items.push({ parent: module2, results: res });
|
|
18292
|
+
}
|
|
18293
|
+
});
|
|
18294
|
+
addToItems(lookupDef.results);
|
|
18226
18295
|
if (!items.length)
|
|
18227
18296
|
return current;
|
|
18228
18297
|
return current ? current.concat(items) : items;
|
|
@@ -18296,8 +18365,8 @@ function lookup(state, decls, node, name, maybeStack, nonlocal, ignoreImports) {
|
|
|
18296
18365
|
case "ClassDeclaration":
|
|
18297
18366
|
if (inStatic && state.config?.enforceStatic !== "NO") {
|
|
18298
18367
|
inStatic = false;
|
|
18299
|
-
if ((0, import_chunk_MBTLUWXR.hasProperty)(si
|
|
18300
|
-
const r = si
|
|
18368
|
+
if ((0, import_chunk_MBTLUWXR.hasProperty)(si[decls], node.name)) {
|
|
18369
|
+
const r = si[decls][node.name].filter((s) => {
|
|
18301
18370
|
switch (s.type) {
|
|
18302
18371
|
case "FunctionDeclaration":
|
|
18303
18372
|
case "VariableDeclarator":
|
|
@@ -19248,6 +19317,7 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
19248
19317
|
init_type_flow_util();
|
|
19249
19318
|
init_types();
|
|
19250
19319
|
(0, import_chunk_SG7ODKRM.init_util)();
|
|
19320
|
+
(0, import_chunk_MBTLUWXR.init_ast)();
|
|
19251
19321
|
init_visitor();
|
|
19252
19322
|
}
|
|
19253
19323
|
});
|
|
@@ -19763,7 +19833,7 @@ function parseCode(view, lineTable) {
|
|
|
19763
19833
|
case 29:
|
|
19764
19834
|
case 30:
|
|
19765
19835
|
case 31:
|
|
19766
|
-
return { op, offset
|
|
19836
|
+
return { op, offset };
|
|
19767
19837
|
case 42:
|
|
19768
19838
|
case 34:
|
|
19769
19839
|
case 33:
|
|
@@ -19787,7 +19857,7 @@ function parseCode(view, lineTable) {
|
|
|
19787
19857
|
case 68:
|
|
19788
19858
|
case 73:
|
|
19789
19859
|
case 75:
|
|
19790
|
-
return { op, offset
|
|
19860
|
+
return { op, offset };
|
|
19791
19861
|
case 1:
|
|
19792
19862
|
case 15:
|
|
19793
19863
|
case 18:
|
|
@@ -19796,7 +19866,7 @@ function parseCode(view, lineTable) {
|
|
|
19796
19866
|
case 46:
|
|
19797
19867
|
case 53:
|
|
19798
19868
|
case 56:
|
|
19799
|
-
return { op, arg: view.getUint8(current++), offset
|
|
19869
|
+
return { op, arg: view.getUint8(current++), offset };
|
|
19800
19870
|
case 25:
|
|
19801
19871
|
case 35:
|
|
19802
19872
|
case 40:
|
|
@@ -19804,22 +19874,19 @@ function parseCode(view, lineTable) {
|
|
|
19804
19874
|
return {
|
|
19805
19875
|
op,
|
|
19806
19876
|
arg: offset + view.getInt16((current += 2) - 2) + 3,
|
|
19807
|
-
offset
|
|
19808
|
-
size: 3
|
|
19877
|
+
offset
|
|
19809
19878
|
};
|
|
19810
19879
|
case 57:
|
|
19811
19880
|
return {
|
|
19812
19881
|
op,
|
|
19813
19882
|
arg: view.getInt16((current += 2) - 2),
|
|
19814
|
-
offset
|
|
19815
|
-
size: 3
|
|
19883
|
+
offset
|
|
19816
19884
|
};
|
|
19817
19885
|
case 58:
|
|
19818
19886
|
return {
|
|
19819
19887
|
op,
|
|
19820
19888
|
arg: view.getInt32((current += 3) - 3) >> 8,
|
|
19821
|
-
offset
|
|
19822
|
-
size: 4
|
|
19889
|
+
offset
|
|
19823
19890
|
};
|
|
19824
19891
|
case 24:
|
|
19825
19892
|
case 64:
|
|
@@ -19830,7 +19897,7 @@ function parseCode(view, lineTable) {
|
|
|
19830
19897
|
case 52:
|
|
19831
19898
|
case 71:
|
|
19832
19899
|
case 67:
|
|
19833
|
-
return { op, arg: view.getInt32((current += 4) - 4), offset
|
|
19900
|
+
return { op, arg: view.getInt32((current += 4) - 4), offset };
|
|
19834
19901
|
case 69:
|
|
19835
19902
|
return {
|
|
19836
19903
|
op,
|
|
@@ -19838,8 +19905,7 @@ function parseCode(view, lineTable) {
|
|
|
19838
19905
|
module: view.getInt32((current += 4) - 4),
|
|
19839
19906
|
var: view.getInt32((current += 4) - 4)
|
|
19840
19907
|
},
|
|
19841
|
-
offset
|
|
19842
|
-
size: 9
|
|
19908
|
+
offset
|
|
19843
19909
|
};
|
|
19844
19910
|
case 70:
|
|
19845
19911
|
return {
|
|
@@ -19848,8 +19914,7 @@ function parseCode(view, lineTable) {
|
|
|
19848
19914
|
local: view.getUint8(current++),
|
|
19849
19915
|
var: view.getInt32((current += 4) - 4)
|
|
19850
19916
|
},
|
|
19851
|
-
offset
|
|
19852
|
-
size: 6
|
|
19917
|
+
offset
|
|
19853
19918
|
};
|
|
19854
19919
|
case 74:
|
|
19855
19920
|
return {
|
|
@@ -19858,29 +19923,25 @@ function parseCode(view, lineTable) {
|
|
|
19858
19923
|
argc: view.getUint8(current++),
|
|
19859
19924
|
incsp: view.getUint8(current++)
|
|
19860
19925
|
},
|
|
19861
|
-
offset
|
|
19862
|
-
size: 3
|
|
19926
|
+
offset
|
|
19863
19927
|
};
|
|
19864
19928
|
case 49:
|
|
19865
19929
|
return {
|
|
19866
19930
|
op,
|
|
19867
19931
|
arg: view.getBigInt64((current += 8) - 8),
|
|
19868
|
-
offset
|
|
19869
|
-
size: 9
|
|
19932
|
+
offset
|
|
19870
19933
|
};
|
|
19871
19934
|
case 38:
|
|
19872
19935
|
return {
|
|
19873
19936
|
op,
|
|
19874
19937
|
arg: view.getFloat32((current += 4) - 4),
|
|
19875
|
-
offset
|
|
19876
|
-
size: 5
|
|
19938
|
+
offset
|
|
19877
19939
|
};
|
|
19878
19940
|
case 50:
|
|
19879
19941
|
return {
|
|
19880
19942
|
op,
|
|
19881
19943
|
arg: view.getFloat64((current += 8) - 8),
|
|
19882
|
-
offset
|
|
19883
|
-
size: 9
|
|
19944
|
+
offset
|
|
19884
19945
|
};
|
|
19885
19946
|
case 36:
|
|
19886
19947
|
throw new Error(`Unknown opcode ${op}`);
|
|
@@ -19897,7 +19958,7 @@ function parseCode(view, lineTable) {
|
|
|
19897
19958
|
}
|
|
19898
19959
|
results.push(nextOp);
|
|
19899
19960
|
}
|
|
19900
|
-
results.push({ op: 0,
|
|
19961
|
+
results.push({ op: 0, offset: current });
|
|
19901
19962
|
return results;
|
|
19902
19963
|
}
|
|
19903
19964
|
function opcodeSize(op) {
|
|
@@ -19946,6 +20007,8 @@ function opcodeSize(op) {
|
|
|
19946
20007
|
case 68:
|
|
19947
20008
|
case 73:
|
|
19948
20009
|
case 75:
|
|
20010
|
+
case 10:
|
|
20011
|
+
case 11:
|
|
19949
20012
|
return 1;
|
|
19950
20013
|
case 1:
|
|
19951
20014
|
case 15:
|
|
@@ -19954,8 +20017,6 @@ function opcodeSize(op) {
|
|
|
19954
20017
|
case 43:
|
|
19955
20018
|
case 46:
|
|
19956
20019
|
case 53:
|
|
19957
|
-
case 10:
|
|
19958
|
-
case 11:
|
|
19959
20020
|
case 56:
|
|
19960
20021
|
return 2;
|
|
19961
20022
|
case 25:
|
|
@@ -21192,6 +21253,8 @@ function interpFunc(func, context) {
|
|
|
21192
21253
|
break;
|
|
21193
21254
|
}
|
|
21194
21255
|
case 37:
|
|
21256
|
+
case 57:
|
|
21257
|
+
case 58:
|
|
21195
21258
|
case 49:
|
|
21196
21259
|
case 38:
|
|
21197
21260
|
case 50:
|
|
@@ -21213,7 +21276,6 @@ function interpFunc(func, context) {
|
|
|
21213
21276
|
op: 46,
|
|
21214
21277
|
arg,
|
|
21215
21278
|
offset: bc.offset,
|
|
21216
|
-
size: 2,
|
|
21217
21279
|
invert: localState.stack.length <= ~index
|
|
21218
21280
|
});
|
|
21219
21281
|
} else {
|
|
@@ -21222,7 +21284,6 @@ function interpFunc(func, context) {
|
|
|
21222
21284
|
op: 18,
|
|
21223
21285
|
arg,
|
|
21224
21286
|
offset: bc.offset,
|
|
21225
|
-
size: 2,
|
|
21226
21287
|
invert: localState.locals.length <= index
|
|
21227
21288
|
});
|
|
21228
21289
|
}
|
|
@@ -21401,11 +21462,9 @@ function interpFunc(func, context) {
|
|
|
21401
21462
|
} else {
|
|
21402
21463
|
delete orig.arg;
|
|
21403
21464
|
}
|
|
21404
|
-
orig.size = rep.size;
|
|
21405
21465
|
if (rep.invert) {
|
|
21406
21466
|
const invv = { ...orig };
|
|
21407
21467
|
invv.op = 45;
|
|
21408
|
-
invv.size = 1;
|
|
21409
21468
|
invv.offset = context.nextOffset++;
|
|
21410
21469
|
delete invv.arg;
|
|
21411
21470
|
block.bytecodes.splice(i + 1, 0, invv);
|
|
@@ -21435,7 +21494,6 @@ function interpFunc(func, context) {
|
|
|
21435
21494
|
for (let i = 0; i < pops; i++) {
|
|
21436
21495
|
block.bytecodes.push({
|
|
21437
21496
|
op: 2,
|
|
21438
|
-
size: 1,
|
|
21439
21497
|
offset: context.nextOffset++
|
|
21440
21498
|
});
|
|
21441
21499
|
}
|
|
@@ -21454,29 +21512,27 @@ function instForType(type, offset) {
|
|
|
21454
21512
|
return null;
|
|
21455
21513
|
switch (type.type) {
|
|
21456
21514
|
case 1:
|
|
21457
|
-
return { op: 44, offset
|
|
21515
|
+
return { op: 44, offset };
|
|
21458
21516
|
case 2:
|
|
21459
21517
|
case 4:
|
|
21460
21518
|
return {
|
|
21461
21519
|
op: 43,
|
|
21462
21520
|
arg: type.type === 2 ? 0 : 1,
|
|
21463
|
-
offset
|
|
21464
|
-
size: 2
|
|
21521
|
+
offset
|
|
21465
21522
|
};
|
|
21466
21523
|
case 8:
|
|
21467
|
-
return { op: 37, arg: type.value, offset
|
|
21524
|
+
return { op: 37, arg: type.value, offset };
|
|
21468
21525
|
case 16:
|
|
21469
|
-
return { op: 49, arg: type.value, offset
|
|
21526
|
+
return { op: 49, arg: type.value, offset };
|
|
21470
21527
|
case 32:
|
|
21471
|
-
return { op: 38, arg: type.value, offset
|
|
21528
|
+
return { op: 38, arg: type.value, offset };
|
|
21472
21529
|
case 64:
|
|
21473
|
-
return { op: 50, arg: type.value, offset
|
|
21530
|
+
return { op: 50, arg: type.value, offset };
|
|
21474
21531
|
case 128:
|
|
21475
21532
|
return {
|
|
21476
21533
|
op: 52,
|
|
21477
21534
|
arg: type.value.charCodeAt(0),
|
|
21478
|
-
offset
|
|
21479
|
-
size: 5
|
|
21535
|
+
offset
|
|
21480
21536
|
};
|
|
21481
21537
|
case 131072: {
|
|
21482
21538
|
const match = type.value.match(/<(\d+)>$/);
|
|
@@ -21484,8 +21540,7 @@ function instForType(type, offset) {
|
|
|
21484
21540
|
return {
|
|
21485
21541
|
op: 39,
|
|
21486
21542
|
arg: parseInt(match[1], 10),
|
|
21487
|
-
offset
|
|
21488
|
-
size: 5
|
|
21543
|
+
offset
|
|
21489
21544
|
};
|
|
21490
21545
|
}
|
|
21491
21546
|
}
|
|
@@ -21591,7 +21646,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
21591
21646
|
}
|
|
21592
21647
|
if (initType) {
|
|
21593
21648
|
const bc = block.bytecodes[found - 1];
|
|
21594
|
-
if (bc.op !== 46 && (!initInst || initInst.
|
|
21649
|
+
if (bc.op !== 46 && (!initInst || opcodeSize(initInst.op) > opcodeSize(bc.op))) {
|
|
21595
21650
|
const { push, pop } = getOpInfo(bc);
|
|
21596
21651
|
if (push === 1 && pop === 0) {
|
|
21597
21652
|
initInst = bc;
|
|
@@ -21625,7 +21680,6 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
21625
21680
|
const bc = block.bytecodes[i2];
|
|
21626
21681
|
const op = bc.op;
|
|
21627
21682
|
bc.op = 2;
|
|
21628
|
-
bc.size = 1;
|
|
21629
21683
|
delete bc.arg;
|
|
21630
21684
|
(0, import_node_assert8.default)(
|
|
21631
21685
|
op === 17
|
|
@@ -21688,7 +21742,7 @@ function optimizeArrayInit(func, block, index, context, interpState) {
|
|
|
21688
21742
|
} else {
|
|
21689
21743
|
initInst = null;
|
|
21690
21744
|
}
|
|
21691
|
-
if (initLocal && (!initInst || initInst.
|
|
21745
|
+
if (initLocal && (!initInst || opcodeSize(initInst.op) > opcodeSize(initLocal.op))) {
|
|
21692
21746
|
initInst = initLocal;
|
|
21693
21747
|
}
|
|
21694
21748
|
if (initInst) {
|
|
@@ -22279,7 +22333,6 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22279
22333
|
const argCount = bc;
|
|
22280
22334
|
argCount.op = 53;
|
|
22281
22335
|
argCount.arg = argc;
|
|
22282
|
-
argCount.size = 2;
|
|
22283
22336
|
filter = true;
|
|
22284
22337
|
}
|
|
22285
22338
|
break;
|
|
@@ -22300,7 +22353,6 @@ function minimizeLocals2(func, equivSets, context) {
|
|
|
22300
22353
|
const nop = bc;
|
|
22301
22354
|
nop.op = 0;
|
|
22302
22355
|
delete nop.arg;
|
|
22303
|
-
nop.size = 1;
|
|
22304
22356
|
filter = true;
|
|
22305
22357
|
}
|
|
22306
22358
|
break;
|
|
@@ -22544,11 +22596,17 @@ function sizeBasedPRE2(func, context) {
|
|
|
22544
22596
|
view.setFloat32(0, bc.arg);
|
|
22545
22597
|
return BigInt(view.getInt32(0)) << 8n | BigInt(bc.op);
|
|
22546
22598
|
}
|
|
22599
|
+
case 37:
|
|
22600
|
+
case 57:
|
|
22601
|
+
case 58:
|
|
22602
|
+
return BigInt(bc.arg) << 8n | BigInt(
|
|
22603
|
+
37
|
|
22604
|
+
/* ipush */
|
|
22605
|
+
);
|
|
22547
22606
|
case 39:
|
|
22548
22607
|
if (bcs[index + 1]?.op === 48) {
|
|
22549
22608
|
break;
|
|
22550
22609
|
}
|
|
22551
|
-
case 37:
|
|
22552
22610
|
case 49:
|
|
22553
22611
|
case 52:
|
|
22554
22612
|
case 24:
|
|
@@ -22673,7 +22731,6 @@ function sizeBasedPRE2(func, context) {
|
|
|
22673
22731
|
bc2.op = 0;
|
|
22674
22732
|
prev.op = 18;
|
|
22675
22733
|
prev.arg = slot;
|
|
22676
|
-
prev.size = 2;
|
|
22677
22734
|
}
|
|
22678
22735
|
})
|
|
22679
22736
|
);
|
|
@@ -22698,7 +22755,6 @@ function sizeBasedPRE2(func, context) {
|
|
|
22698
22755
|
bcs.forEach((bc2) => {
|
|
22699
22756
|
bc2.op = 18;
|
|
22700
22757
|
bc2.arg = slot;
|
|
22701
|
-
bc2.size = 2;
|
|
22702
22758
|
});
|
|
22703
22759
|
}
|
|
22704
22760
|
});
|
|
@@ -22763,7 +22819,7 @@ function blockSharing(func, context) {
|
|
|
22763
22819
|
blocks.forEach((block) => {
|
|
22764
22820
|
const blockEnd = block.bytecodes[block.bytecodes.length - 1];
|
|
22765
22821
|
if (!group.length) {
|
|
22766
|
-
size = blockEnd.
|
|
22822
|
+
size = opcodeSize(blockEnd.op);
|
|
22767
22823
|
} else {
|
|
22768
22824
|
const key = group[0];
|
|
22769
22825
|
const keyEnd = key.bytecodes[key.bytecodes.length - 1];
|
|
@@ -22832,7 +22888,7 @@ function blockSharing(func, context) {
|
|
|
22832
22888
|
}
|
|
22833
22889
|
entry.group.delete(block);
|
|
22834
22890
|
} else {
|
|
22835
|
-
const sz = size2 + (bc
|
|
22891
|
+
const sz = size2 + (bc ? opcodeSize(bc.op) : 0);
|
|
22836
22892
|
nextState.push({ group: blocks2.map((b) => group2[b]), size: sz });
|
|
22837
22893
|
}
|
|
22838
22894
|
});
|
|
@@ -23014,11 +23070,9 @@ function simpleOpts(func, context) {
|
|
|
23014
23070
|
const dup = prev;
|
|
23015
23071
|
dup.op = 46;
|
|
23016
23072
|
dup.arg = 0;
|
|
23017
|
-
dup.size = 2;
|
|
23018
23073
|
const add = cur;
|
|
23019
23074
|
add.op = 3;
|
|
23020
23075
|
delete add.arg;
|
|
23021
|
-
add.size = 1;
|
|
23022
23076
|
logging3 && (0, import_chunk_SG7ODKRM.log)(`${func.name}: converting "ipush 1; shlv" to "dup 0; addv"`);
|
|
23023
23077
|
continue;
|
|
23024
23078
|
}
|
|
@@ -23035,7 +23089,6 @@ function simpleOpts(func, context) {
|
|
|
23035
23089
|
changes = true;
|
|
23036
23090
|
const mulv = cur;
|
|
23037
23091
|
mulv.op = 5;
|
|
23038
|
-
mulv.size = 1;
|
|
23039
23092
|
delete mulv.arg;
|
|
23040
23093
|
}
|
|
23041
23094
|
}
|
|
@@ -23127,8 +23180,7 @@ function equalSymbolToEq(block, equalsIndex) {
|
|
|
23127
23180
|
}
|
|
23128
23181
|
block.bytecodes.splice(equalsIndex, 5, spush, {
|
|
23129
23182
|
op: 26,
|
|
23130
|
-
offset: invokem.offset
|
|
23131
|
-
size: 1
|
|
23183
|
+
offset: invokem.offset
|
|
23132
23184
|
});
|
|
23133
23185
|
(0, import_chunk_SG7ODKRM.logger)(
|
|
23134
23186
|
"optimize",
|
|
@@ -23212,7 +23264,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23212
23264
|
}
|
|
23213
23265
|
delete next.preds;
|
|
23214
23266
|
removeBlock(func, next.offset);
|
|
23215
|
-
} else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + bc.
|
|
23267
|
+
} else if (next.next == null && next.bytecodes.length < 3 && next.bytecodes.reduce((size, bc) => size + opcodeSize(bc.op), 0) < 3 && countFallthroughPreds(func, next) > 1) {
|
|
23216
23268
|
(0, import_chunk_SG7ODKRM.logger)(
|
|
23217
23269
|
"cfg",
|
|
23218
23270
|
1,
|
|
@@ -23226,7 +23278,7 @@ function removeUnreachableCatches(func, context) {
|
|
|
23226
23278
|
let offset = context.nextOffset;
|
|
23227
23279
|
next.bytecodes.forEach((bc) => {
|
|
23228
23280
|
block.bytecodes.push({ ...bc, offset });
|
|
23229
|
-
offset += bc.
|
|
23281
|
+
offset += opcodeSize(bc.op);
|
|
23230
23282
|
});
|
|
23231
23283
|
context.nextOffset = offset;
|
|
23232
23284
|
redirect(func, block, next.offset, null);
|
|
@@ -23415,8 +23467,7 @@ function emitFunc(func, view, start, updateInfo, context) {
|
|
|
23415
23467
|
const bc = {
|
|
23416
23468
|
op: 25,
|
|
23417
23469
|
arg: block.next,
|
|
23418
|
-
offset: block.offset
|
|
23419
|
-
size: 3
|
|
23470
|
+
offset: block.offset
|
|
23420
23471
|
};
|
|
23421
23472
|
offset = emitBytecode(bc, view, offset, linktable, shift_hack);
|
|
23422
23473
|
}
|
|
@@ -24162,6 +24213,9 @@ function bytecodeToString(bytecode, symbolTable) {
|
|
|
24162
24213
|
}
|
|
24163
24214
|
return `${Opcodes[bytecode.op]}${arg ?? ""}`;
|
|
24164
24215
|
}
|
|
24216
|
+
function offsetAfter(bc) {
|
|
24217
|
+
return bc.offset + opcodeSize(bc.op);
|
|
24218
|
+
}
|
|
24165
24219
|
function findFunctions({
|
|
24166
24220
|
bytecodes,
|
|
24167
24221
|
symbolTable,
|
|
@@ -24181,13 +24235,13 @@ function findFunctions({
|
|
|
24181
24235
|
case 41:
|
|
24182
24236
|
case 25:
|
|
24183
24237
|
case 35:
|
|
24184
|
-
blockStarts.add(bytecode
|
|
24238
|
+
blockStarts.add(offsetAfter(bytecode));
|
|
24185
24239
|
blockStarts.add(bytecode.arg);
|
|
24186
24240
|
return;
|
|
24187
24241
|
case 22:
|
|
24188
24242
|
case 23:
|
|
24189
24243
|
case 51:
|
|
24190
|
-
blockStarts.add(bytecode
|
|
24244
|
+
blockStarts.add(offsetAfter(bytecode));
|
|
24191
24245
|
return;
|
|
24192
24246
|
}
|
|
24193
24247
|
});
|
|
@@ -24198,7 +24252,7 @@ function findFunctions({
|
|
|
24198
24252
|
let next;
|
|
24199
24253
|
let taken;
|
|
24200
24254
|
bytecodes.forEach((bytecode, i) => {
|
|
24201
|
-
const nextBcOffset = bytecode
|
|
24255
|
+
const nextBcOffset = offsetAfter(bytecode);
|
|
24202
24256
|
next = nextBcOffset;
|
|
24203
24257
|
taken = void 0;
|
|
24204
24258
|
switch (bytecode.op) {
|
|
@@ -24328,7 +24382,6 @@ function findFunctions({
|
|
|
24328
24382
|
function makeArgless(bc, op) {
|
|
24329
24383
|
bc.op = op;
|
|
24330
24384
|
delete bc.arg;
|
|
24331
|
-
bc.size = 1;
|
|
24332
24385
|
}
|
|
24333
24386
|
function removeBlock(func, offset) {
|
|
24334
24387
|
const block = func.blocks.get(offset);
|
|
@@ -28367,7 +28420,7 @@ async function launchSimulator(force = true) {
|
|
|
28367
28420
|
for (let i = 0; ; i++) {
|
|
28368
28421
|
if (await checkIfSimulatorRunning())
|
|
28369
28422
|
return;
|
|
28370
|
-
if (i ===
|
|
28423
|
+
if (i === 25)
|
|
28371
28424
|
return;
|
|
28372
28425
|
await new Promise((r) => setTimeout(r, 200));
|
|
28373
28426
|
}
|
|
@@ -28969,7 +29022,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28969
29022
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28970
29023
|
Object.values(fnMap).map((v) => v.output)
|
|
28971
29024
|
);
|
|
28972
|
-
if (source_time < opt_time &&
|
|
29025
|
+
if (source_time < opt_time && 1713229195228 < opt_time) {
|
|
28973
29026
|
return {
|
|
28974
29027
|
hasTests,
|
|
28975
29028
|
diagnostics: prevDiagnostics,
|
|
@@ -29008,7 +29061,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
29008
29061
|
hasTests: hasTests2,
|
|
29009
29062
|
diagnostics,
|
|
29010
29063
|
sdkVersion,
|
|
29011
|
-
optimizerVersion: "1.1.
|
|
29064
|
+
optimizerVersion: "1.1.55",
|
|
29012
29065
|
...Object.fromEntries(
|
|
29013
29066
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
29014
29067
|
)
|
|
@@ -29505,7 +29558,7 @@ function optimizeProgramBuffer(filepath, view, debugXml, apiDebugXml, key, confi
|
|
|
29505
29558
|
exceptionsMap,
|
|
29506
29559
|
key,
|
|
29507
29560
|
debugXml,
|
|
29508
|
-
nextOffset:
|
|
29561
|
+
nextOffset: bytecodes[bytecodes.length - 1] ? offsetAfter(bytecodes[bytecodes.length - 1]) : 0,
|
|
29509
29562
|
nextLocalId: 0
|
|
29510
29563
|
};
|
|
29511
29564
|
optimizeBytecode(context);
|
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_GWRGLJLB.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_GWRGLJLB.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_GWRGLJLB.defaultConfig,
|
|
25
|
+
display: () => import_chunk_GWRGLJLB.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_GWRGLJLB.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_GWRGLJLB.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_GWRGLJLB.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_GWRGLJLB.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_GWRGLJLB.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_GWRGLJLB.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_GWRGLJLB.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_GWRGLJLB.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_GWRGLJLB.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_GWRGLJLB.simulateProgram
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_chunk_GWRGLJLB = require("./chunk-GWRGLJLB.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_GWRGLJLB.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_GWRGLJLB.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_GWRGLJLB.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_GWRGLJLB.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_GWRGLJLB.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_GWRGLJLB.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_GWRGLJLB.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_GWRGLJLB.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_GWRGLJLB.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_GWRGLJLB.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_GWRGLJLB.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_GWRGLJLB.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_GWRGLJLB.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_GWRGLJLB = require("./chunk-GWRGLJLB.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_GWRGLJLB.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/src/inliner.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
|
|
2
|
+
import { Diagnostic, FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
|
|
3
3
|
export declare function inlinableSubExpression(expr: mctree.Expression): mctree.SimpleCallExpression | null;
|
|
4
4
|
export declare function inlineRequested(state: ProgramStateAnalysis, func: FunctionStateNode): boolean;
|
|
5
5
|
export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): boolean;
|
|
6
6
|
type InlineBody = mctree.BlockStatement | mctree.ExpressionStatement["expression"];
|
|
7
7
|
export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"]): mctree.Statement[];
|
|
8
8
|
export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"], top: true): mctree.Statement[] | null;
|
|
9
|
-
export declare function inlineDiagnostic(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, message: string | null): void;
|
|
9
|
+
export declare function inlineDiagnostic(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, message: string | null, extra?: Diagnostic["extra"]): void;
|
|
10
10
|
export type InlineContext = mctree.ReturnStatement | mctree.IfStatement | mctree.AssignmentExpression | mctree.ExpressionStatement | mctree.VariableDeclarator;
|
|
11
11
|
export declare function inlineFunction(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): InlineBody | null;
|
|
12
12
|
export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
|
|
@@ -62,6 +62,7 @@ export declare function functionToString(func: FuncEntry, context: Context | nul
|
|
|
62
62
|
export declare function blockToString(block: Block, context: Context | null): string;
|
|
63
63
|
export declare function lineInfoToString(lineInfo: LineNumber, context: Context | null): string;
|
|
64
64
|
export declare function bytecodeToString(bytecode: Bytecode, symbolTable: SymbolTable | null | undefined): string;
|
|
65
|
+
export declare function offsetAfter(bc: Bytecode): number;
|
|
65
66
|
export declare function findFunctions({ bytecodes, symbolTable, exceptionsMap, }: Context): Map<number, FuncEntry>;
|
|
66
67
|
export declare function makeArgless(bc: Bytecode, op: Opcodes): void;
|
|
67
68
|
export declare function equalBlocks(b1: Block, b2: Block): boolean;
|
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_GWRGLJLB = require("./chunk-GWRGLJLB.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_GWRGLJLB.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_GWRGLJLB.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED