@markw65/monkeyc-optimizer 1.1.39 → 1.1.41
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 +9 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-3H4GE7RU.cjs → chunk-BJHWDTEM.cjs} +275 -74
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/src/readprg/opcodes.d.ts +3 -3
- package/build/src/type-flow/types.d.ts +4 -1
- package/build/worker-thread.cjs +3 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the "monkeyc-optimizer" package will be documented in this file.
|
|
4
4
|
|
|
5
|
+
### 1.1.41
|
|
6
|
+
|
|
7
|
+
- Add proper support for tuple types (Sdk-7.x)
|
|
8
|
+
- Fix a bug with the signature of the initialize method of resource-generated menus
|
|
9
|
+
|
|
10
|
+
### 1.1.40
|
|
11
|
+
|
|
12
|
+
- Update the bytecode optimizer to be compatible with Sdk-7.x
|
|
13
|
+
|
|
5
14
|
### 1.1.39
|
|
6
15
|
|
|
7
16
|
- Update to [@markw65/prettier-plugin-monkeyc@1.0.54](https://github.com/markw65/prettier-plugin-monkeyc/blob/main/CHANGELOG.md#1054)
|
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_BJHWDTEM.checkCompilerVersion,
|
|
22
|
+
collectNamespaces: () => import_chunk_BJHWDTEM.collectNamespaces,
|
|
23
|
+
createDocumentationMap: () => import_chunk_BJHWDTEM.createDocumentationMap,
|
|
24
|
+
diagnostic: () => import_chunk_BJHWDTEM.diagnostic,
|
|
25
|
+
diagnosticHelper: () => import_chunk_BJHWDTEM.diagnosticHelper,
|
|
26
|
+
findNamesInScope: () => import_chunk_BJHWDTEM.findNamesInScope,
|
|
27
|
+
findUsingForNode: () => import_chunk_BJHWDTEM.findUsingForNode,
|
|
28
|
+
formatAst: () => import_chunk_BJHWDTEM.formatAst,
|
|
29
|
+
formatAstLongLines: () => import_chunk_BJHWDTEM.formatAstLongLines,
|
|
30
|
+
formatScopedName: () => import_chunk_BJHWDTEM.formatScopedName,
|
|
31
|
+
getApiFunctionInfo: () => import_chunk_BJHWDTEM.getApiFunctionInfo,
|
|
32
|
+
getApiMapping: () => import_chunk_BJHWDTEM.getApiMapping,
|
|
33
|
+
getSuperClasses: () => import_chunk_BJHWDTEM.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_BJHWDTEM.isClassVariable,
|
|
36
|
+
isLocal: () => import_chunk_BJHWDTEM.isLocal,
|
|
37
|
+
isLookupCandidate: () => import_chunk_BJHWDTEM.isLookupCandidate,
|
|
38
|
+
isStateNode: () => import_chunk_BJHWDTEM.isStateNode,
|
|
39
|
+
lookupByFullName: () => import_chunk_BJHWDTEM.lookupByFullName,
|
|
40
|
+
lookupNext: () => import_chunk_BJHWDTEM.lookupNext,
|
|
41
|
+
lookupResultContains: () => import_chunk_BJHWDTEM.lookupResultContains,
|
|
42
|
+
lookupWithType: () => import_chunk_BJHWDTEM.lookupWithType,
|
|
43
|
+
makeToyboxLink: () => import_chunk_BJHWDTEM.makeToyboxLink,
|
|
44
|
+
mapVarDeclsByType: () => import_chunk_BJHWDTEM.mapVarDeclsByType,
|
|
45
|
+
markInvokeClassMethod: () => import_chunk_BJHWDTEM.markInvokeClassMethod,
|
|
46
|
+
parseSdkVersion: () => import_chunk_BJHWDTEM.parseSdkVersion,
|
|
47
|
+
resolveDiagnostics: () => import_chunk_BJHWDTEM.resolveDiagnostics,
|
|
48
|
+
resolveDiagnosticsMap: () => import_chunk_BJHWDTEM.resolveDiagnosticsMap,
|
|
49
|
+
sameLookupResult: () => import_chunk_BJHWDTEM.sameLookupResult,
|
|
50
50
|
traverseAst: () => import_chunk_MBTLUWXR.traverseAst,
|
|
51
|
-
variableDeclarationName: () =>
|
|
52
|
-
visitReferences: () =>
|
|
53
|
-
visit_resources: () =>
|
|
54
|
-
visitorNode: () =>
|
|
51
|
+
variableDeclarationName: () => import_chunk_BJHWDTEM.variableDeclarationName,
|
|
52
|
+
visitReferences: () => import_chunk_BJHWDTEM.visitReferences,
|
|
53
|
+
visit_resources: () => import_chunk_BJHWDTEM.visit_resources,
|
|
54
|
+
visitorNode: () => import_chunk_BJHWDTEM.visitorNode
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(api_exports);
|
|
57
|
-
var
|
|
57
|
+
var import_chunk_BJHWDTEM = require("./chunk-BJHWDTEM.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_BJHWDTEM.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_BJHWDTEM_exports = {};
|
|
30
|
+
__export(chunk_BJHWDTEM_exports, {
|
|
31
31
|
EnumTagsConst: () => EnumTagsConst,
|
|
32
32
|
LastTypeTag: () => LastTypeTag,
|
|
33
33
|
ObjectLikeTagsConst: () => ObjectLikeTagsConst,
|
|
@@ -86,6 +86,7 @@ __export(chunk_3H4GE7RU_exports, {
|
|
|
86
86
|
init_union_type: () => init_union_type,
|
|
87
87
|
init_worker_pool: () => init_worker_pool,
|
|
88
88
|
init_worker_task: () => init_worker_task,
|
|
89
|
+
init_xml_util: () => init_xml_util,
|
|
89
90
|
intersection: () => intersection,
|
|
90
91
|
isClassVariable: () => isClassVariable,
|
|
91
92
|
isCondBranch: () => isCondBranch,
|
|
@@ -108,8 +109,10 @@ __export(chunk_3H4GE7RU_exports, {
|
|
|
108
109
|
mustBeTrue: () => mustBeTrue,
|
|
109
110
|
opcodeSize: () => opcodeSize,
|
|
110
111
|
optimizeFunc: () => optimizeFunc,
|
|
112
|
+
optimizeMonkeyC: () => optimizeMonkeyC,
|
|
111
113
|
optimizeProgram: () => optimizeProgram,
|
|
112
114
|
parseSdkVersion: () => parseSdkVersion,
|
|
115
|
+
parseXml: () => parseXml,
|
|
113
116
|
performTask: () => performTask,
|
|
114
117
|
readPrg: () => readPrg,
|
|
115
118
|
readPrgWithOffsets: () => readPrgWithOffsets,
|
|
@@ -130,7 +133,7 @@ __export(chunk_3H4GE7RU_exports, {
|
|
|
130
133
|
visitorNode: () => visitorNode,
|
|
131
134
|
xml_util_exports: () => xml_util_exports
|
|
132
135
|
});
|
|
133
|
-
module.exports = __toCommonJS(
|
|
136
|
+
module.exports = __toCommonJS(chunk_BJHWDTEM_exports);
|
|
134
137
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
135
138
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
136
139
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
@@ -7291,7 +7294,7 @@ function mergeSingle(pair) {
|
|
|
7291
7294
|
case 1:
|
|
7292
7295
|
case 2:
|
|
7293
7296
|
case 4:
|
|
7294
|
-
throw new Error("Unexpected
|
|
7297
|
+
throw new Error("Unexpected TypeTag in mergeSingle");
|
|
7295
7298
|
case 8:
|
|
7296
7299
|
case 16:
|
|
7297
7300
|
case 32:
|
|
@@ -7304,8 +7307,24 @@ function mergeSingle(pair) {
|
|
|
7304
7307
|
}
|
|
7305
7308
|
return [null, true];
|
|
7306
7309
|
case 512: {
|
|
7307
|
-
|
|
7308
|
-
|
|
7310
|
+
if (Array.isArray(pair.avalue)) {
|
|
7311
|
+
const bv = pair.bvalue;
|
|
7312
|
+
if (Array.isArray(bv)) {
|
|
7313
|
+
if (pair.avalue.length === bv.length) {
|
|
7314
|
+
let changed = false;
|
|
7315
|
+
const u = pair.avalue.map((a, i) => {
|
|
7316
|
+
const merged2 = tryUnion(a, bv[i]);
|
|
7317
|
+
if (merged2)
|
|
7318
|
+
changed = true;
|
|
7319
|
+
return merged2 || a;
|
|
7320
|
+
});
|
|
7321
|
+
return [u, changed];
|
|
7322
|
+
}
|
|
7323
|
+
}
|
|
7324
|
+
}
|
|
7325
|
+
const av = reducedType(pair.avalue);
|
|
7326
|
+
const merged = tryUnion(av, reducedType(pair.bvalue));
|
|
7327
|
+
return [merged || av, merged != null];
|
|
7309
7328
|
}
|
|
7310
7329
|
case 1024: {
|
|
7311
7330
|
const avalue = pair.avalue;
|
|
@@ -7556,11 +7575,29 @@ function widenTypeHelper(t, depth) {
|
|
|
7556
7575
|
result = cloneType(t);
|
|
7557
7576
|
clearValuesUnder(result, ac.type);
|
|
7558
7577
|
} else {
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7578
|
+
if (Array.isArray(ac.value)) {
|
|
7579
|
+
let newAData = ac.value;
|
|
7580
|
+
ac.value.forEach((avalue, index) => {
|
|
7581
|
+
const data = widenTypeHelper(avalue, depth + 1);
|
|
7582
|
+
if (data) {
|
|
7583
|
+
if (newAData === ac.value) {
|
|
7584
|
+
newAData = newAData.slice();
|
|
7585
|
+
}
|
|
7586
|
+
newAData[index] = data;
|
|
7587
|
+
}
|
|
7588
|
+
});
|
|
7589
|
+
if (newAData !== ac.value) {
|
|
7590
|
+
if (!result)
|
|
7591
|
+
result = cloneType(t);
|
|
7592
|
+
setUnionComponent(result, ac.type, newAData);
|
|
7593
|
+
}
|
|
7594
|
+
} else {
|
|
7595
|
+
const v = widenTypeHelper(ac.value, depth + 1);
|
|
7596
|
+
if (v) {
|
|
7597
|
+
if (!result)
|
|
7598
|
+
result = cloneType(t);
|
|
7599
|
+
setUnionComponent(result, ac.type, v);
|
|
7600
|
+
}
|
|
7564
7601
|
}
|
|
7565
7602
|
}
|
|
7566
7603
|
return;
|
|
@@ -7754,6 +7791,31 @@ function intersectionValue(pair) {
|
|
|
7754
7791
|
case 131072:
|
|
7755
7792
|
return pair.avalue === pair.bvalue ? pair.avalue : null;
|
|
7756
7793
|
case 512: {
|
|
7794
|
+
if (Array.isArray(pair.avalue)) {
|
|
7795
|
+
const bv = pair.bvalue;
|
|
7796
|
+
if (Array.isArray(bv)) {
|
|
7797
|
+
if (pair.avalue.length !== bv.length) {
|
|
7798
|
+
return null;
|
|
7799
|
+
}
|
|
7800
|
+
const isect2 = pair.avalue.map((t, i) => intersection(t, bv[i]));
|
|
7801
|
+
return isect2.some(
|
|
7802
|
+
(t) => t.type === 0
|
|
7803
|
+
/* Never */
|
|
7804
|
+
) ? null : isect2;
|
|
7805
|
+
}
|
|
7806
|
+
const isect = pair.avalue.map((t) => intersection(t, bv));
|
|
7807
|
+
return isect.some(
|
|
7808
|
+
(t) => t.type === 0
|
|
7809
|
+
/* Never */
|
|
7810
|
+
) ? null : isect;
|
|
7811
|
+
} else if (Array.isArray(pair.bvalue)) {
|
|
7812
|
+
const av = pair.avalue;
|
|
7813
|
+
const isect = pair.bvalue.map((t) => intersection(av, t));
|
|
7814
|
+
return isect.some(
|
|
7815
|
+
(t) => t.type === 0
|
|
7816
|
+
/* Never */
|
|
7817
|
+
) ? null : isect;
|
|
7818
|
+
}
|
|
7757
7819
|
const atype = intersection(pair.avalue, pair.bvalue);
|
|
7758
7820
|
return atype.type === 0 ? null : atype;
|
|
7759
7821
|
}
|
|
@@ -8197,8 +8259,21 @@ function subtypeOfValue(pair) {
|
|
|
8197
8259
|
case 128:
|
|
8198
8260
|
case 131072:
|
|
8199
8261
|
return pair.avalue === pair.bvalue;
|
|
8200
|
-
case 512:
|
|
8262
|
+
case 512: {
|
|
8263
|
+
if (Array.isArray(pair.avalue)) {
|
|
8264
|
+
const bv = pair.bvalue;
|
|
8265
|
+
if (Array.isArray(bv)) {
|
|
8266
|
+
if (pair.avalue.length !== bv.length) {
|
|
8267
|
+
return false;
|
|
8268
|
+
}
|
|
8269
|
+
return pair.avalue.every((t, i) => subtypeOf(t, bv[i]));
|
|
8270
|
+
}
|
|
8271
|
+
return pair.avalue.every((t) => subtypeOf(t, bv));
|
|
8272
|
+
} else if (Array.isArray(pair.bvalue)) {
|
|
8273
|
+
return false;
|
|
8274
|
+
}
|
|
8201
8275
|
return subtypeOf(pair.avalue, pair.bvalue);
|
|
8276
|
+
}
|
|
8202
8277
|
case 1024: {
|
|
8203
8278
|
const adict = pair.avalue;
|
|
8204
8279
|
const bdict = pair.bvalue;
|
|
@@ -9012,10 +9087,12 @@ function checkCallArgs(istate, node, callees, args) {
|
|
|
9012
9087
|
512
|
|
9013
9088
|
/* Array */
|
|
9014
9089
|
);
|
|
9015
|
-
if (!ptype || !subtypeOf(ptype, atype)) {
|
|
9090
|
+
if (!ptype || Array.isArray(ptype) || Array.isArray(atype) || !subtypeOf(ptype, atype)) {
|
|
9016
9091
|
curDiags.push([
|
|
9017
9092
|
node.arguments[i],
|
|
9018
|
-
`Argument ${i + 1} to ${cur.fullName}: passing
|
|
9093
|
+
`Argument ${i + 1} to ${cur.fullName}: passing ${display(
|
|
9094
|
+
arg
|
|
9095
|
+
)} to parameter ${display(paramType)} is not type safe`
|
|
9019
9096
|
]);
|
|
9020
9097
|
}
|
|
9021
9098
|
}
|
|
@@ -9139,7 +9216,13 @@ function getSystemCallTable(state) {
|
|
|
9139
9216
|
if (args.length === 1) {
|
|
9140
9217
|
const arg = args[0];
|
|
9141
9218
|
if (callee.name === "add") {
|
|
9142
|
-
if (
|
|
9219
|
+
if (Array.isArray(adata)) {
|
|
9220
|
+
const relaxed = relaxType(arg);
|
|
9221
|
+
const newAData = [...adata, relaxed];
|
|
9222
|
+
ret.returnType.value = newAData;
|
|
9223
|
+
ret.argTypes = [relaxed];
|
|
9224
|
+
ret.calleeObj = ret.returnType;
|
|
9225
|
+
} else if (!subtypeOf(arg, adata)) {
|
|
9143
9226
|
const newAData = cloneType(adata);
|
|
9144
9227
|
unionInto(newAData, arg);
|
|
9145
9228
|
const newObj = cloneType(calleeObj);
|
|
@@ -9148,6 +9231,23 @@ function getSystemCallTable(state) {
|
|
|
9148
9231
|
ret.argTypes = [adata];
|
|
9149
9232
|
}
|
|
9150
9233
|
} else {
|
|
9234
|
+
if (Array.isArray(adata)) {
|
|
9235
|
+
if (arg.type & 512) {
|
|
9236
|
+
const argSubtypes = getUnionComponent(
|
|
9237
|
+
arg,
|
|
9238
|
+
512
|
|
9239
|
+
/* Array */
|
|
9240
|
+
);
|
|
9241
|
+
if (argSubtypes && Array.isArray(argSubtypes)) {
|
|
9242
|
+
const newAData = [...adata, ...argSubtypes];
|
|
9243
|
+
ret.returnType.value = newAData;
|
|
9244
|
+
ret.argTypes = [arg];
|
|
9245
|
+
ret.calleeObj = ret.returnType;
|
|
9246
|
+
return ret;
|
|
9247
|
+
}
|
|
9248
|
+
}
|
|
9249
|
+
ret.returnType.value = reducedType(adata);
|
|
9250
|
+
}
|
|
9151
9251
|
if (!subtypeOf(arg, ret.returnType)) {
|
|
9152
9252
|
ret.argTypes = [ret.returnType];
|
|
9153
9253
|
const newObj = cloneType(calleeObj);
|
|
@@ -9823,6 +9923,24 @@ function deEnumerate(t) {
|
|
|
9823
9923
|
}
|
|
9824
9924
|
return t;
|
|
9825
9925
|
}
|
|
9926
|
+
function arrayTypeAtIndex(arr, elemType) {
|
|
9927
|
+
if (Array.isArray(arr)) {
|
|
9928
|
+
if (elemType && isExact(elemType) && elemType.type === 8 && elemType.value != null && arr[elemType.value] != null) {
|
|
9929
|
+
return arr[elemType.value];
|
|
9930
|
+
}
|
|
9931
|
+
return arr.reduce(
|
|
9932
|
+
(p, v) => {
|
|
9933
|
+
unionInto(p, v);
|
|
9934
|
+
return p;
|
|
9935
|
+
},
|
|
9936
|
+
{
|
|
9937
|
+
type: 0
|
|
9938
|
+
/* Never */
|
|
9939
|
+
}
|
|
9940
|
+
);
|
|
9941
|
+
}
|
|
9942
|
+
return arr;
|
|
9943
|
+
}
|
|
9826
9944
|
function getLhsConstraint(istate, node) {
|
|
9827
9945
|
if (istate.localLvals?.has(node)) {
|
|
9828
9946
|
return null;
|
|
@@ -9851,7 +9969,7 @@ function getLhsConstraint(istate, node) {
|
|
|
9851
9969
|
/* Array */
|
|
9852
9970
|
);
|
|
9853
9971
|
if (arr) {
|
|
9854
|
-
result = arr;
|
|
9972
|
+
result = arrayTypeAtIndex(arr, istate.typeMap.get(node.property));
|
|
9855
9973
|
}
|
|
9856
9974
|
}
|
|
9857
9975
|
const updateResult = (value2) => {
|
|
@@ -10154,23 +10272,9 @@ function evaluateNode(istate, node) {
|
|
|
10154
10272
|
node
|
|
10155
10273
|
});
|
|
10156
10274
|
} else {
|
|
10157
|
-
const value2 = relaxType(
|
|
10158
|
-
args.reduce(
|
|
10159
|
-
(cur, next) => {
|
|
10160
|
-
unionInto(cur, next.value);
|
|
10161
|
-
return cur;
|
|
10162
|
-
},
|
|
10163
|
-
{
|
|
10164
|
-
type: 0
|
|
10165
|
-
/* Never */
|
|
10166
|
-
}
|
|
10167
|
-
)
|
|
10168
|
-
);
|
|
10275
|
+
const value2 = args.map((arg) => relaxType(arg.value));
|
|
10169
10276
|
push({
|
|
10170
|
-
value:
|
|
10171
|
-
type: 512
|
|
10172
|
-
/* Array */
|
|
10173
|
-
} : { type: 512, value: value2 },
|
|
10277
|
+
value: { type: 512, value: value2 },
|
|
10174
10278
|
embeddedEffects,
|
|
10175
10279
|
node
|
|
10176
10280
|
});
|
|
@@ -10329,10 +10433,11 @@ function evaluateNode(istate, node) {
|
|
|
10329
10433
|
type: 524287
|
|
10330
10434
|
/* Any */
|
|
10331
10435
|
};
|
|
10436
|
+
const atype = arrayTypeAtIndex(avalue, property.value);
|
|
10332
10437
|
if (result) {
|
|
10333
|
-
unionInto(result = cloneType(result),
|
|
10438
|
+
unionInto(result = cloneType(result), atype);
|
|
10334
10439
|
} else {
|
|
10335
|
-
result =
|
|
10440
|
+
result = atype;
|
|
10336
10441
|
}
|
|
10337
10442
|
}
|
|
10338
10443
|
if (objectType.type & 1024) {
|
|
@@ -11005,6 +11110,20 @@ function typeFromTypeStateNodes(state, sns, classVsObj) {
|
|
|
11005
11110
|
}
|
|
11006
11111
|
);
|
|
11007
11112
|
}
|
|
11113
|
+
function arrayLiteralKeyFromType(k) {
|
|
11114
|
+
if (k && k.value != null) {
|
|
11115
|
+
if (k.type === 8 || k.type === 16) {
|
|
11116
|
+
return Number(k.value);
|
|
11117
|
+
}
|
|
11118
|
+
}
|
|
11119
|
+
return null;
|
|
11120
|
+
}
|
|
11121
|
+
function arrayLiteralKeyFromExpr(key) {
|
|
11122
|
+
if (key.type === "Literal") {
|
|
11123
|
+
return arrayLiteralKeyFromType(typeFromLiteral(key));
|
|
11124
|
+
}
|
|
11125
|
+
return null;
|
|
11126
|
+
}
|
|
11008
11127
|
function objectLiteralKeyFromExpr(key) {
|
|
11009
11128
|
switch (key.type) {
|
|
11010
11129
|
case "Literal": {
|
|
@@ -11080,18 +11199,8 @@ function typeFromSingleTypeSpec(state, type, stack) {
|
|
|
11080
11199
|
case "ArrayExpression": {
|
|
11081
11200
|
return {
|
|
11082
11201
|
type: 512,
|
|
11083
|
-
value: type.elements.
|
|
11084
|
-
(
|
|
11085
|
-
unionInto(
|
|
11086
|
-
prev,
|
|
11087
|
-
typeFromTypespec(state, cur)
|
|
11088
|
-
);
|
|
11089
|
-
return prev;
|
|
11090
|
-
},
|
|
11091
|
-
{
|
|
11092
|
-
type: 0
|
|
11093
|
-
/* Never */
|
|
11094
|
-
}
|
|
11202
|
+
value: type.elements.map(
|
|
11203
|
+
(cur) => typeFromTypespec(state, cur)
|
|
11095
11204
|
)
|
|
11096
11205
|
};
|
|
11097
11206
|
}
|
|
@@ -11394,6 +11503,21 @@ function castType(type, target) {
|
|
|
11394
11503
|
}
|
|
11395
11504
|
return result;
|
|
11396
11505
|
}
|
|
11506
|
+
function reducedType(elems) {
|
|
11507
|
+
if (!Array.isArray(elems)) {
|
|
11508
|
+
return elems;
|
|
11509
|
+
}
|
|
11510
|
+
return elems.reduce(
|
|
11511
|
+
(p, t) => {
|
|
11512
|
+
unionInto(p, t);
|
|
11513
|
+
return p;
|
|
11514
|
+
},
|
|
11515
|
+
{
|
|
11516
|
+
type: 0
|
|
11517
|
+
/* Never */
|
|
11518
|
+
}
|
|
11519
|
+
);
|
|
11520
|
+
}
|
|
11397
11521
|
function mustBeTrue(arg) {
|
|
11398
11522
|
return (arg.type === 8 || arg.type === 16) && arg.value != null && Number(arg.value) !== 0 || (arg.type & TruthyTypes) !== 0 && (arg.type & ~TruthyTypes) === 0;
|
|
11399
11523
|
}
|
|
@@ -11419,7 +11543,7 @@ function display(type) {
|
|
|
11419
11543
|
case 256:
|
|
11420
11544
|
return JSON.stringify(tv.value);
|
|
11421
11545
|
case 512:
|
|
11422
|
-
return display(tv.value)
|
|
11546
|
+
return Array.isArray(tv.value) ? `[${tv.value.map((t) => display(t)).join(", ")}]` : `Array<${display(tv.value)}>`;
|
|
11423
11547
|
case 1024:
|
|
11424
11548
|
return tv.value.value ? `Dictionary<${display(tv.value.key)}, ${display(tv.value.value)}>` : `{ ${Array.from(tv.value).map(
|
|
11425
11549
|
([key, value2]) => `${display(typeFromObjectLiteralKey(key))} as ${display(
|
|
@@ -11470,7 +11594,7 @@ function display(type) {
|
|
|
11470
11594
|
const valueStr = value2 != null && displayOne({ type: bit, value: value2 });
|
|
11471
11595
|
if (!valueStr) {
|
|
11472
11596
|
parts.push(name);
|
|
11473
|
-
} else if (bit & (32768 | 65536 | 262144 | 131072 | 2048 | 256 | 1024)) {
|
|
11597
|
+
} else if (bit & (32768 | 65536 | 262144 | 131072 | 2048 | 256 | 512 | 1024)) {
|
|
11474
11598
|
parts.push(valueStr);
|
|
11475
11599
|
} else {
|
|
11476
11600
|
parts.push(`${name}<${valueStr}${valueStr.endsWith(">") ? " " : ""}>`);
|
|
@@ -11704,9 +11828,30 @@ function couldBeValue(pair, shallow) {
|
|
|
11704
11828
|
case 131072:
|
|
11705
11829
|
return pair.avalue === pair.bvalue;
|
|
11706
11830
|
case 512:
|
|
11707
|
-
|
|
11831
|
+
if (shallow)
|
|
11832
|
+
return true;
|
|
11833
|
+
if (Array.isArray(pair.avalue)) {
|
|
11834
|
+
const bv = pair.bvalue;
|
|
11835
|
+
if (Array.isArray(bv)) {
|
|
11836
|
+
if (pair.avalue.length !== bv.length) {
|
|
11837
|
+
return false;
|
|
11838
|
+
}
|
|
11839
|
+
return pair.avalue.every((a, i) => couldBe(a, bv[i]));
|
|
11840
|
+
}
|
|
11841
|
+
return pair.avalue.every((a) => couldBe(a, bv));
|
|
11842
|
+
}
|
|
11843
|
+
if (Array.isArray(pair.bvalue)) {
|
|
11844
|
+
const av = pair.avalue;
|
|
11845
|
+
return pair.bvalue.every((b) => couldBe(av, b));
|
|
11846
|
+
}
|
|
11847
|
+
return couldBe(pair.avalue, pair.bvalue);
|
|
11708
11848
|
case 1024: {
|
|
11709
|
-
|
|
11849
|
+
if (shallow)
|
|
11850
|
+
return true;
|
|
11851
|
+
if (!pair.avalue.value || !pair.bvalue.value) {
|
|
11852
|
+
return true;
|
|
11853
|
+
}
|
|
11854
|
+
return couldBe(pair.avalue.key, pair.bvalue.key) && couldBe(pair.avalue.value, pair.bvalue.value);
|
|
11710
11855
|
}
|
|
11711
11856
|
case 2048: {
|
|
11712
11857
|
return pair.avalue.args.length === pair.bvalue.args.length && couldBe(pair.avalue.result, pair.bvalue.result) && pair.avalue.args.every((arg, i) => couldBe(arg, pair.bvalue.args[i]));
|
|
@@ -12507,7 +12652,11 @@ function updateAffected(blockState, objectType, baseDecl, assignedPath, affected
|
|
|
12507
12652
|
/* Array */
|
|
12508
12653
|
);
|
|
12509
12654
|
if (atype) {
|
|
12510
|
-
|
|
12655
|
+
if (Array.isArray(atype)) {
|
|
12656
|
+
atype.forEach((value2) => unionInto(newType, value2));
|
|
12657
|
+
} else {
|
|
12658
|
+
unionInto(newType, atype);
|
|
12659
|
+
}
|
|
12511
12660
|
}
|
|
12512
12661
|
}
|
|
12513
12662
|
if (type.type & 1024) {
|
|
@@ -12632,7 +12781,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
12632
12781
|
next = t;
|
|
12633
12782
|
}
|
|
12634
12783
|
if (cur.type & 512) {
|
|
12635
|
-
|
|
12784
|
+
let avalue = getUnionComponent(
|
|
12636
12785
|
cur,
|
|
12637
12786
|
512
|
|
12638
12787
|
/* Array */
|
|
@@ -12640,10 +12789,28 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
12640
12789
|
type: 524287
|
|
12641
12790
|
/* Any */
|
|
12642
12791
|
};
|
|
12643
|
-
if (
|
|
12644
|
-
|
|
12792
|
+
if (Array.isArray(avalue)) {
|
|
12793
|
+
const index = arrayLiteralKeyFromExpr(me.property);
|
|
12794
|
+
if (index != null && avalue[index] != null) {
|
|
12795
|
+
if (!next) {
|
|
12796
|
+
assocValue[i].keyStr = index;
|
|
12797
|
+
}
|
|
12798
|
+
avalue = avalue[index];
|
|
12799
|
+
}
|
|
12800
|
+
if (next || i !== l || !newValue) {
|
|
12801
|
+
const n = next ? cloneType(next) : {
|
|
12802
|
+
type: 0
|
|
12803
|
+
/* Never */
|
|
12804
|
+
};
|
|
12805
|
+
(0, import_chunk_SG7ODKRM.forEach)(avalue, (v) => unionInto(n, v));
|
|
12806
|
+
next = n;
|
|
12807
|
+
}
|
|
12645
12808
|
} else {
|
|
12646
|
-
next
|
|
12809
|
+
if (next) {
|
|
12810
|
+
unionInto(next = cloneType(next), avalue);
|
|
12811
|
+
} else {
|
|
12812
|
+
next = avalue;
|
|
12813
|
+
}
|
|
12647
12814
|
}
|
|
12648
12815
|
}
|
|
12649
12816
|
let isExact2 = false;
|
|
@@ -12669,6 +12836,7 @@ function propagateTypes(state, func, graph, optimizeEquivalencies, copyPropStore
|
|
|
12669
12836
|
};
|
|
12670
12837
|
}
|
|
12671
12838
|
} else {
|
|
12839
|
+
delete assocValue[i].keyStr;
|
|
12672
12840
|
if (n) {
|
|
12673
12841
|
unionInto(next = cloneType(next), n);
|
|
12674
12842
|
next.type |= 1;
|
|
@@ -13899,16 +14067,29 @@ function updateByAssocPath(path7, property, update) {
|
|
|
13899
14067
|
}
|
|
13900
14068
|
} else if (update) {
|
|
13901
14069
|
if (object.type & 512) {
|
|
13902
|
-
|
|
13903
|
-
setUnionComponent(
|
|
14070
|
+
let avalue = getUnionComponent(
|
|
13904
14071
|
object,
|
|
13905
|
-
512
|
|
13906
|
-
|
|
13907
|
-
object,
|
|
13908
|
-
512
|
|
13909
|
-
/* Array */
|
|
13910
|
-
))
|
|
14072
|
+
512
|
|
14073
|
+
/* Array */
|
|
13911
14074
|
);
|
|
14075
|
+
if (Array.isArray(avalue)) {
|
|
14076
|
+
const key = pathElem.keyStr;
|
|
14077
|
+
const relaxed = relaxType(property);
|
|
14078
|
+
if (typeof key === "number" && key >= 0 && key < avalue.length) {
|
|
14079
|
+
avalue = avalue.slice();
|
|
14080
|
+
avalue[key] = relaxed;
|
|
14081
|
+
} else {
|
|
14082
|
+
avalue = avalue.map((v) => {
|
|
14083
|
+
v = cloneType(v);
|
|
14084
|
+
unionInto(v, relaxed);
|
|
14085
|
+
return v;
|
|
14086
|
+
});
|
|
14087
|
+
}
|
|
14088
|
+
} else {
|
|
14089
|
+
avalue = valueToStore(avalue);
|
|
14090
|
+
}
|
|
14091
|
+
object = cloneType(object);
|
|
14092
|
+
setUnionComponent(object, 512, avalue);
|
|
13912
14093
|
}
|
|
13913
14094
|
if (object.type & 1024) {
|
|
13914
14095
|
const dvalue = getUnionComponent(
|
|
@@ -13927,7 +14108,7 @@ function updateByAssocPath(path7, property, update) {
|
|
|
13927
14108
|
value: valueToStore(dvalue.value)
|
|
13928
14109
|
});
|
|
13929
14110
|
} else {
|
|
13930
|
-
if (pathElem.keyStr) {
|
|
14111
|
+
if (typeof pathElem.keyStr === "string") {
|
|
13931
14112
|
object = cloneType(object);
|
|
13932
14113
|
const relaxed = cloneType(relaxType(property));
|
|
13933
14114
|
relaxed.type &= ~1;
|
|
@@ -17454,6 +17635,16 @@ function add_one_resource(state, doc, module2, e) {
|
|
|
17454
17635
|
loc: e.loc
|
|
17455
17636
|
}
|
|
17456
17637
|
] : [];
|
|
17638
|
+
items.push({
|
|
17639
|
+
type: "ClassElement",
|
|
17640
|
+
item: {
|
|
17641
|
+
type: "FunctionDeclaration",
|
|
17642
|
+
id: (0, import_chunk_MBTLUWXR.makeIdentifier)("initialize", loc),
|
|
17643
|
+
body: null,
|
|
17644
|
+
params: [],
|
|
17645
|
+
loc: e.loc
|
|
17646
|
+
}
|
|
17647
|
+
});
|
|
17457
17648
|
return {
|
|
17458
17649
|
type: "ClassDeclaration",
|
|
17459
17650
|
body: { type: "ClassBody", body: items, loc: e.loc },
|
|
@@ -19524,6 +19715,8 @@ function parseCode(view, lineTable) {
|
|
|
19524
19715
|
case 20:
|
|
19525
19716
|
case 54:
|
|
19526
19717
|
case 47:
|
|
19718
|
+
case 10:
|
|
19719
|
+
case 11:
|
|
19527
19720
|
return { op, offset, size: 1 };
|
|
19528
19721
|
case 1:
|
|
19529
19722
|
case 15:
|
|
@@ -19532,8 +19725,6 @@ function parseCode(view, lineTable) {
|
|
|
19532
19725
|
case 43:
|
|
19533
19726
|
case 46:
|
|
19534
19727
|
case 53:
|
|
19535
|
-
case 10:
|
|
19536
|
-
case 11:
|
|
19537
19728
|
return { op, arg: view.getUint8(current++), offset, size: 2 };
|
|
19538
19729
|
case 25:
|
|
19539
19730
|
case 35:
|
|
@@ -19656,10 +19847,18 @@ function opcodeSize(op) {
|
|
|
19656
19847
|
unhandledType(op);
|
|
19657
19848
|
}
|
|
19658
19849
|
}
|
|
19659
|
-
function emitBytecode(bytecode, view, offset, linktable) {
|
|
19850
|
+
function emitBytecode(bytecode, view, offset, linktable, shift_hack) {
|
|
19660
19851
|
view.setUint8(offset++, bytecode.op);
|
|
19661
|
-
if (bytecode.arg == null)
|
|
19852
|
+
if (bytecode.arg == null) {
|
|
19853
|
+
if (shift_hack && (bytecode.op === 10 || bytecode.op === 11)) {
|
|
19854
|
+
view.setUint8(
|
|
19855
|
+
offset++,
|
|
19856
|
+
0
|
|
19857
|
+
/* nop */
|
|
19858
|
+
);
|
|
19859
|
+
}
|
|
19662
19860
|
return offset;
|
|
19861
|
+
}
|
|
19663
19862
|
switch (bytecode.op) {
|
|
19664
19863
|
case 1:
|
|
19665
19864
|
case 15:
|
|
@@ -19668,8 +19867,6 @@ function emitBytecode(bytecode, view, offset, linktable) {
|
|
|
19668
19867
|
case 43:
|
|
19669
19868
|
case 46:
|
|
19670
19869
|
case 53:
|
|
19671
|
-
case 10:
|
|
19672
|
-
case 11:
|
|
19673
19870
|
view.setUint8(offset++, bytecode.arg);
|
|
19674
19871
|
break;
|
|
19675
19872
|
case 25:
|
|
@@ -22678,6 +22875,7 @@ var init_optimize2 = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
22678
22875
|
function emitFunc(func, view, start, updateInfo, context) {
|
|
22679
22876
|
cleanCfg2(func, context);
|
|
22680
22877
|
groupBlocks(func);
|
|
22878
|
+
const shift_hack = context.header.ciqVersion < 327680;
|
|
22681
22879
|
const { liveInLocals } = getLocalsInfo(func);
|
|
22682
22880
|
const liveLocalRanges = /* @__PURE__ */ new Map();
|
|
22683
22881
|
const { localRanges, offsetMap } = updateInfo;
|
|
@@ -22772,7 +22970,7 @@ function emitFunc(func, view, start, updateInfo, context) {
|
|
|
22772
22970
|
bytecode.arg = taken;
|
|
22773
22971
|
bytecode.op = bytecode.op === 40 ? 41 : 40;
|
|
22774
22972
|
}
|
|
22775
|
-
offset = emitBytecode(bytecode, view, offset, linktable);
|
|
22973
|
+
offset = emitBytecode(bytecode, view, offset, linktable, shift_hack);
|
|
22776
22974
|
});
|
|
22777
22975
|
if (block.next != null && block.next !== blocks[i + 1]?.offset) {
|
|
22778
22976
|
const bc = {
|
|
@@ -22781,7 +22979,7 @@ function emitFunc(func, view, start, updateInfo, context) {
|
|
|
22781
22979
|
offset: block.offset,
|
|
22782
22980
|
size: 3
|
|
22783
22981
|
};
|
|
22784
|
-
offset = emitBytecode(bc, view, offset, linktable);
|
|
22982
|
+
offset = emitBytecode(bc, view, offset, linktable, shift_hack);
|
|
22785
22983
|
}
|
|
22786
22984
|
});
|
|
22787
22985
|
(0, import_node_assert13.default)(exceptionStack.length === 0);
|
|
@@ -28111,7 +28309,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28111
28309
|
const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
|
|
28112
28310
|
Object.values(fnMap).map((v) => v.output)
|
|
28113
28311
|
);
|
|
28114
|
-
if (source_time < opt_time &&
|
|
28312
|
+
if (source_time < opt_time && 1707701537178 < opt_time) {
|
|
28115
28313
|
return {
|
|
28116
28314
|
hasTests,
|
|
28117
28315
|
diagnostics: prevDiagnostics,
|
|
@@ -28150,7 +28348,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
|
|
|
28150
28348
|
hasTests: hasTests2,
|
|
28151
28349
|
diagnostics,
|
|
28152
28350
|
sdkVersion,
|
|
28153
|
-
optimizerVersion: "1.1.
|
|
28351
|
+
optimizerVersion: "1.1.41",
|
|
28154
28352
|
...Object.fromEntries(
|
|
28155
28353
|
configOptionsToCheck.map((option) => [option, config[option]])
|
|
28156
28354
|
)
|
|
@@ -29037,6 +29235,7 @@ var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29037
29235
|
init_union_type,
|
|
29038
29236
|
init_worker_pool,
|
|
29039
29237
|
init_worker_task,
|
|
29238
|
+
init_xml_util,
|
|
29040
29239
|
intersection,
|
|
29041
29240
|
isClassVariable,
|
|
29042
29241
|
isCondBranch,
|
|
@@ -29059,8 +29258,10 @@ var init_sdk_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
29059
29258
|
mustBeTrue,
|
|
29060
29259
|
opcodeSize,
|
|
29061
29260
|
optimizeFunc,
|
|
29261
|
+
optimizeMonkeyC,
|
|
29062
29262
|
optimizeProgram,
|
|
29063
29263
|
parseSdkVersion,
|
|
29264
|
+
parseXml,
|
|
29064
29265
|
performTask,
|
|
29065
29266
|
readPrg,
|
|
29066
29267
|
readPrgWithOffsets,
|
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_BJHWDTEM.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_BJHWDTEM.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_BJHWDTEM.defaultConfig,
|
|
25
|
+
display: () => import_chunk_BJHWDTEM.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_BJHWDTEM.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_BJHWDTEM.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_BJHWDTEM.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_BJHWDTEM.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_BJHWDTEM.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_BJHWDTEM.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_BJHWDTEM.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_BJHWDTEM.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_BJHWDTEM.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_BJHWDTEM.simulateProgram
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_chunk_BJHWDTEM = require("./chunk-BJHWDTEM.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_BJHWDTEM.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_BJHWDTEM.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_BJHWDTEM.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_BJHWDTEM.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_BJHWDTEM.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_BJHWDTEM.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_BJHWDTEM.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_BJHWDTEM.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_BJHWDTEM.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_BJHWDTEM.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_BJHWDTEM.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_BJHWDTEM.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_BJHWDTEM.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_BJHWDTEM = require("./chunk-BJHWDTEM.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_BJHWDTEM.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
|
@@ -115,10 +115,10 @@ export interface Orv extends Argless {
|
|
|
115
115
|
export interface Modv extends Argless {
|
|
116
116
|
op: Opcodes.modv;
|
|
117
117
|
}
|
|
118
|
-
export interface Shlv extends
|
|
118
|
+
export interface Shlv extends Argless {
|
|
119
119
|
op: Opcodes.shlv;
|
|
120
120
|
}
|
|
121
|
-
export interface Shrv extends
|
|
121
|
+
export interface Shrv extends Argless {
|
|
122
122
|
op: Opcodes.shrv;
|
|
123
123
|
}
|
|
124
124
|
export interface Xorv extends Argless {
|
|
@@ -261,7 +261,7 @@ export interface Argc extends ByteArg {
|
|
|
261
261
|
export type Bytecode = Nop | Incsp | Popv | Addv | Subv | Mulv | Divv | Andv | Orv | Modv | Shlv | Shrv | Xorv | Getv | Putv | Invokem | Agetv | Aputv | Lgetv | Lputv | Newa | Newc | Return | Ret | News | Goto | Eq | Lt | Lte | Gt | Gte | Ne | Isnull | Isa | Canhazplz | Jsr | Ts | Ipush | Fpush | Spush | Bt | Bf | Frpush | Bpush | Npush | Invv | Dup | Newd | Getm | Lpush | Dpush | Throw | Cpush | Argc | Newba;
|
|
262
262
|
export declare function parseCode(view: DataView, lineTable: Map<number, LineNumber>): Bytecode[];
|
|
263
263
|
export declare function opcodeSize(op: Opcodes): 1 | 2 | 3 | 5 | 9;
|
|
264
|
-
export declare function emitBytecode(bytecode: Bytecode, view: DataView, offset: number, linktable: Map<number, number
|
|
264
|
+
export declare function emitBytecode(bytecode: Bytecode, view: DataView, offset: number, linktable: Map<number, number>, shift_hack: boolean): number;
|
|
265
265
|
export declare function getOpInfo(bytecode: Bytecode): {
|
|
266
266
|
pop: number;
|
|
267
267
|
push: number;
|
|
@@ -102,7 +102,7 @@ export interface StringType extends AbstractValue {
|
|
|
102
102
|
}
|
|
103
103
|
export interface ArrayType extends AbstractValue {
|
|
104
104
|
type: TypeTag.Array;
|
|
105
|
-
value?: ExactOrUnion | undefined;
|
|
105
|
+
value?: ExactOrUnion | ExactOrUnion[] | undefined;
|
|
106
106
|
}
|
|
107
107
|
export interface DictionaryType extends AbstractValue {
|
|
108
108
|
type: TypeTag.Dictionary;
|
|
@@ -190,6 +190,8 @@ export declare function cloneType<T extends ExactOrUnion>(t: T): T;
|
|
|
190
190
|
export declare function relaxType(type: ExactOrUnion): ExactOrUnion;
|
|
191
191
|
export declare function typeFromTypeStateNode(state: ProgramStateAnalysis, sn: StateNodeDecl, classVsObj?: boolean): ExactOrUnion;
|
|
192
192
|
export declare function typeFromTypeStateNodes(state: ProgramStateAnalysis, sns: StateNodeDecl[], classVsObj?: boolean): ExactOrUnion;
|
|
193
|
+
export declare function arrayLiteralKeyFromType(k: ExactOrUnion | null | undefined): number | null;
|
|
194
|
+
export declare function arrayLiteralKeyFromExpr(key: mctree.Expression): number | null;
|
|
193
195
|
export declare function objectLiteralKeyFromExpr(key: mctree.Expression): string | null;
|
|
194
196
|
export declare function objectLiteralKeyFromType(key: ExactOrUnion): string | null;
|
|
195
197
|
export declare function typeFromObjectLiteralKey(key: string): ValueTypes;
|
|
@@ -198,6 +200,7 @@ export declare function typeFromTypespec(state: ProgramStateAnalysis, ts: mctree
|
|
|
198
200
|
export declare function typeFromLiteral(literal: mctree.Literal): ExactTypes;
|
|
199
201
|
export declare function mcExprFromType(type: ValueTypes): mctree.Expression | null;
|
|
200
202
|
export declare function castType(type: ExactOrUnion, target: UnionTypeTags): ExactOrUnion;
|
|
203
|
+
export declare function reducedType(elems: ExactOrUnion[] | ExactOrUnion): ExactOrUnion;
|
|
201
204
|
export declare const TruthyTypes: number;
|
|
202
205
|
export declare function mustBeTrue(arg: ExactOrUnion): boolean;
|
|
203
206
|
export declare function mustBeFalse(arg: ExactOrUnion): 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_BJHWDTEM = require("./chunk-BJHWDTEM.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_BJHWDTEM.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_BJHWDTEM.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.41",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build-debug": "node esbuild.mjs",
|
|
23
23
|
"build-release": "node esbuild.mjs --release",
|
|
24
24
|
"prepack": "node esbuild.mjs --release && mkdir -p bin && cp test/cft-font-info.js bin",
|
|
25
|
-
"test": "npm run test-mocha && npm run test-optimized && npm run test-unopt && npm run test-post-only && npm run test-remote && npm run test-remote-tests && npm run test-personality",
|
|
25
|
+
"test": "npm run test-mocha && npm run test-analysis && npm run test-optimized && npm run test-unopt && npm run test-post-only && npm run test-remote && npm run test-remote-tests && npm run test-personality",
|
|
26
26
|
"test-mocha": "npx mocha --timeout 999999 build/mocha.cjs",
|
|
27
27
|
"test-remote": "node ./test/test.js --showInfo --postOptimize --product=pick-one --github",
|
|
28
28
|
"test-remote-tests": "node ./test/test.js --showInfo --postOptimize --product=pick-one --run-tests --github",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"test-post-only": "node test/test.js --showInfo --typeCheckLevel Strict --skipOptimization --postOptimize --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
|
|
32
32
|
"test-garmin-opt": "node test/test.js --typeCheckLevel Strict --skipOptimization --garminOptLevel=2 --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
|
|
33
33
|
"test-personality": "node test/test-personality.js",
|
|
34
|
+
"test-analysis": "node test/test.js --showInfo --typeCheckLevel Strict --product=fr955 --sourceFile 'test/analysis/*.mc'",
|
|
34
35
|
"eslint": "npx eslint ."
|
|
35
36
|
},
|
|
36
37
|
"bin": {
|