@markw65/monkeyc-optimizer 1.1.54 → 1.1.56

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 CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to the "monkeyc-optimizer" package will be documented in this file.
4
4
 
5
+ ### 1.1.56
6
+
7
+ - Fix regression caused by the fix to #24 (Fixes #26)
8
+ - Fix bug in the post build optimizer for system 7 devices, caused by not handling the new argcincsp bytecode
9
+
10
+ ### 1.1.55
11
+
12
+ - Allow class typedef lookups from static methods
13
+ - Fix method lookups on enum values
14
+
5
15
  ### 1.1.54
6
16
 
7
17
  - Fix return types of Dictionary.values() and Dictionary.keys()
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: () => import_chunk_5K64MLXC.checkCompilerVersion,
22
- collectNamespaces: () => import_chunk_5K64MLXC.collectNamespaces,
23
- createDocumentationMap: () => import_chunk_5K64MLXC.createDocumentationMap,
24
- diagnostic: () => import_chunk_5K64MLXC.diagnostic,
25
- diagnosticHelper: () => import_chunk_5K64MLXC.diagnosticHelper,
26
- findNamesInScope: () => import_chunk_5K64MLXC.findNamesInScope,
27
- findUsingForNode: () => import_chunk_5K64MLXC.findUsingForNode,
28
- formatAst: () => import_chunk_5K64MLXC.formatAst,
29
- formatAstLongLines: () => import_chunk_5K64MLXC.formatAstLongLines,
30
- formatScopedName: () => import_chunk_5K64MLXC.formatScopedName,
31
- getApiFunctionInfo: () => import_chunk_5K64MLXC.getApiFunctionInfo,
32
- getApiMapping: () => import_chunk_5K64MLXC.getApiMapping,
33
- getSuperClasses: () => import_chunk_5K64MLXC.getSuperClasses,
21
+ checkCompilerVersion: () => import_chunk_M3LMSSY7.checkCompilerVersion,
22
+ collectNamespaces: () => import_chunk_M3LMSSY7.collectNamespaces,
23
+ createDocumentationMap: () => import_chunk_M3LMSSY7.createDocumentationMap,
24
+ diagnostic: () => import_chunk_M3LMSSY7.diagnostic,
25
+ diagnosticHelper: () => import_chunk_M3LMSSY7.diagnosticHelper,
26
+ findNamesInScope: () => import_chunk_M3LMSSY7.findNamesInScope,
27
+ findUsingForNode: () => import_chunk_M3LMSSY7.findUsingForNode,
28
+ formatAst: () => import_chunk_M3LMSSY7.formatAst,
29
+ formatAstLongLines: () => import_chunk_M3LMSSY7.formatAstLongLines,
30
+ formatScopedName: () => import_chunk_M3LMSSY7.formatScopedName,
31
+ getApiFunctionInfo: () => import_chunk_M3LMSSY7.getApiFunctionInfo,
32
+ getApiMapping: () => import_chunk_M3LMSSY7.getApiMapping,
33
+ getSuperClasses: () => import_chunk_M3LMSSY7.getSuperClasses,
34
34
  hasProperty: () => import_chunk_MBTLUWXR.hasProperty,
35
- isClassVariable: () => import_chunk_5K64MLXC.isClassVariable,
36
- isLocal: () => import_chunk_5K64MLXC.isLocal,
37
- isLookupCandidate: () => import_chunk_5K64MLXC.isLookupCandidate,
38
- isStateNode: () => import_chunk_5K64MLXC.isStateNode,
39
- lookupByFullName: () => import_chunk_5K64MLXC.lookupByFullName,
40
- lookupNext: () => import_chunk_5K64MLXC.lookupNext,
41
- lookupResultContains: () => import_chunk_5K64MLXC.lookupResultContains,
42
- lookupWithType: () => import_chunk_5K64MLXC.lookupWithType,
43
- makeToyboxLink: () => import_chunk_5K64MLXC.makeToyboxLink,
44
- mapVarDeclsByType: () => import_chunk_5K64MLXC.mapVarDeclsByType,
45
- markInvokeClassMethod: () => import_chunk_5K64MLXC.markInvokeClassMethod,
46
- parseSdkVersion: () => import_chunk_5K64MLXC.parseSdkVersion,
47
- resolveDiagnostics: () => import_chunk_5K64MLXC.resolveDiagnostics,
48
- resolveDiagnosticsMap: () => import_chunk_5K64MLXC.resolveDiagnosticsMap,
49
- sameLookupResult: () => import_chunk_5K64MLXC.sameLookupResult,
35
+ isClassVariable: () => import_chunk_M3LMSSY7.isClassVariable,
36
+ isLocal: () => import_chunk_M3LMSSY7.isLocal,
37
+ isLookupCandidate: () => import_chunk_M3LMSSY7.isLookupCandidate,
38
+ isStateNode: () => import_chunk_M3LMSSY7.isStateNode,
39
+ lookupByFullName: () => import_chunk_M3LMSSY7.lookupByFullName,
40
+ lookupNext: () => import_chunk_M3LMSSY7.lookupNext,
41
+ lookupResultContains: () => import_chunk_M3LMSSY7.lookupResultContains,
42
+ lookupWithType: () => import_chunk_M3LMSSY7.lookupWithType,
43
+ makeToyboxLink: () => import_chunk_M3LMSSY7.makeToyboxLink,
44
+ mapVarDeclsByType: () => import_chunk_M3LMSSY7.mapVarDeclsByType,
45
+ markInvokeClassMethod: () => import_chunk_M3LMSSY7.markInvokeClassMethod,
46
+ parseSdkVersion: () => import_chunk_M3LMSSY7.parseSdkVersion,
47
+ resolveDiagnostics: () => import_chunk_M3LMSSY7.resolveDiagnostics,
48
+ resolveDiagnosticsMap: () => import_chunk_M3LMSSY7.resolveDiagnosticsMap,
49
+ sameLookupResult: () => import_chunk_M3LMSSY7.sameLookupResult,
50
50
  traverseAst: () => import_chunk_MBTLUWXR.traverseAst,
51
- variableDeclarationName: () => import_chunk_5K64MLXC.variableDeclarationName,
52
- visitReferences: () => import_chunk_5K64MLXC.visitReferences,
53
- visit_resources: () => import_chunk_5K64MLXC.visit_resources,
54
- visitorNode: () => import_chunk_5K64MLXC.visitorNode
51
+ variableDeclarationName: () => import_chunk_M3LMSSY7.variableDeclarationName,
52
+ visitReferences: () => import_chunk_M3LMSSY7.visitReferences,
53
+ visit_resources: () => import_chunk_M3LMSSY7.visit_resources,
54
+ visitorNode: () => import_chunk_M3LMSSY7.visitorNode
55
55
  });
56
56
  module.exports = __toCommonJS(api_exports);
57
- var import_chunk_5K64MLXC = require("./chunk-5K64MLXC.cjs");
57
+ var import_chunk_M3LMSSY7 = require("./chunk-M3LMSSY7.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, import_chunk_5K64MLXC.init_api)();
61
+ (0, import_chunk_M3LMSSY7.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 chunk_5K64MLXC_exports = {};
30
- __export(chunk_5K64MLXC_exports, {
29
+ var chunk_M3LMSSY7_exports = {};
30
+ __export(chunk_M3LMSSY7_exports, {
31
31
  EnumTagsConst: () => EnumTagsConst,
32
32
  LastTypeTag: () => LastTypeTag,
33
33
  ObjectLikeTagsConst: () => ObjectLikeTagsConst,
@@ -133,7 +133,7 @@ __export(chunk_5K64MLXC_exports, {
133
133
  visitorNode: () => visitorNode,
134
134
  xml_util_exports: () => xml_util_exports
135
135
  });
136
- module.exports = __toCommonJS(chunk_5K64MLXC_exports);
136
+ module.exports = __toCommonJS(chunk_M3LMSSY7_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");
@@ -18247,13 +18247,53 @@ function isLookupCandidate(node) {
18247
18247
  }
18248
18248
  function lookupNext(state, results, decls, property) {
18249
18249
  return results.reduce((current, lookupDef) => {
18250
- const items = lookupDef.results.map((module2) => {
18250
+ const items = [];
18251
+ const addToItems = (sns) => sns.forEach((module2) => {
18251
18252
  if (!isStateNode(module2)) {
18252
- return null;
18253
+ if (module2.type !== "EnumStringMember")
18254
+ return;
18255
+ if (!module2.init) {
18256
+ addToItems(lookupByFullName(state, "Toybox.Lang.Number"));
18257
+ return;
18258
+ }
18259
+ if (module2.init.type === "Literal") {
18260
+ const [, type] = (0, import_chunk_MBTLUWXR.getNodeValue)(module2.init);
18261
+ switch (type) {
18262
+ case "Null":
18263
+ break;
18264
+ case "Boolean":
18265
+ case "Char":
18266
+ case "Double":
18267
+ case "Float":
18268
+ case "Long":
18269
+ case "Number":
18270
+ case "String":
18271
+ addToItems(lookupByFullName(state, `Toybox.Lang.${type}`));
18272
+ break;
18273
+ default:
18274
+ unhandledType(type);
18275
+ }
18276
+ return;
18277
+ }
18278
+ [
18279
+ "Boolean",
18280
+ "Char",
18281
+ "Double",
18282
+ "Float",
18283
+ "Long",
18284
+ "Number",
18285
+ "String"
18286
+ ].forEach(
18287
+ (type) => addToItems(lookupByFullName(state, `Toybox.Lang.${type}`))
18288
+ );
18289
+ return;
18253
18290
  }
18254
18291
  const res = checkOne(state, module2, decls, property);
18255
- return res ? { parent: module2, results: res } : null;
18256
- }).filter((r) => r != null);
18292
+ if (res) {
18293
+ items.push({ parent: module2, results: res });
18294
+ }
18295
+ });
18296
+ addToItems(lookupDef.results);
18257
18297
  if (!items.length)
18258
18298
  return current;
18259
18299
  return current ? current.concat(items) : items;
@@ -18327,8 +18367,8 @@ function lookup(state, decls, node, name, maybeStack, nonlocal, ignoreImports) {
18327
18367
  case "ClassDeclaration":
18328
18368
  if (inStatic && state.config?.enforceStatic !== "NO") {
18329
18369
  inStatic = false;
18330
- if ((0, import_chunk_MBTLUWXR.hasProperty)(si.decls, node.name)) {
18331
- const r = si.decls[node.name].filter((s) => {
18370
+ if ((0, import_chunk_MBTLUWXR.hasProperty)(si[decls], node.name)) {
18371
+ const r = si[decls][node.name].filter((s) => {
18332
18372
  switch (s.type) {
18333
18373
  case "FunctionDeclaration":
18334
18374
  case "VariableDeclarator":
@@ -19279,6 +19319,8 @@ var init_api = (0, import_chunk_ABYVSU2C.__esm)({
19279
19319
  init_type_flow_util();
19280
19320
  init_types();
19281
19321
  (0, import_chunk_SG7ODKRM.init_util)();
19322
+ (0, import_chunk_MBTLUWXR.init_ast)();
19323
+ init_data_flow();
19282
19324
  init_visitor();
19283
19325
  }
19284
19326
  });
@@ -22573,6 +22615,7 @@ function sizeBasedPRE2(func, context) {
22573
22615
  case 24:
22574
22616
  return BigInt(bc.arg) << 8n | BigInt(bc.op);
22575
22617
  case 1:
22618
+ case 74:
22576
22619
  if (incSp != null) {
22577
22620
  incSp = false;
22578
22621
  }
@@ -22635,7 +22678,7 @@ function sizeBasedPRE2(func, context) {
22635
22678
  }
22636
22679
  });
22637
22680
  });
22638
- let nextSlot = func.argc + (incSp?.arg ?? 0);
22681
+ let nextSlot = func.argc + (incSp?.op === 1 ? incSp.arg : incSp?.arg.incsp ?? 0);
22639
22682
  const bytecode = (op, arg) => {
22640
22683
  const bc = { op, arg, size: opcodeSize(op), offset: context.nextOffset++ };
22641
22684
  if (arg == null)
@@ -22720,7 +22763,11 @@ function sizeBasedPRE2(func, context) {
22720
22763
  }
22721
22764
  });
22722
22765
  if (incSp) {
22723
- incSp.arg += insertionBlocks.size;
22766
+ if (incSp.op === 1) {
22767
+ incSp.arg += insertionBlocks.size;
22768
+ } else {
22769
+ incSp.arg.incsp += insertionBlocks.size;
22770
+ }
22724
22771
  } else {
22725
22772
  const startBlock = func.blocks.get(func.offset);
22726
22773
  const index = startBlock.bytecodes.length === 0 || startBlock.bytecodes[0].op !== 53 ? 0 : 1;
@@ -28983,7 +29030,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
28983
29030
  const opt_time = await (0, import_chunk_SG7ODKRM.first_modified)(
28984
29031
  Object.values(fnMap).map((v) => v.output)
28985
29032
  );
28986
- if (source_time < opt_time && 1713154555665 < opt_time) {
29033
+ if (source_time < opt_time && 1713286417604 < opt_time) {
28987
29034
  return {
28988
29035
  hasTests,
28989
29036
  diagnostics: prevDiagnostics,
@@ -29022,7 +29069,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
29022
29069
  hasTests: hasTests2,
29023
29070
  diagnostics,
29024
29071
  sdkVersion,
29025
- optimizerVersion: "1.1.54",
29072
+ optimizerVersion: "1.1.56",
29026
29073
  ...Object.fromEntries(
29027
29074
  configOptionsToCheck.map((option) => [option, config[option]])
29028
29075
  )
@@ -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: () => import_chunk_5K64MLXC.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_5K64MLXC.buildOptimizedProject,
21
+ StateNodeAttributes: () => import_chunk_M3LMSSY7.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_M3LMSSY7.buildOptimizedProject,
23
23
  copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_5K64MLXC.defaultConfig,
25
- display: () => import_chunk_5K64MLXC.display,
26
- generateOneConfig: () => import_chunk_5K64MLXC.generateOneConfig,
27
- generateOptimizedProject: () => import_chunk_5K64MLXC.generateOptimizedProject,
28
- getConfig: () => import_chunk_5K64MLXC.getConfig,
29
- getProjectAnalysis: () => import_chunk_5K64MLXC.getProjectAnalysis,
30
- get_jungle: () => import_chunk_5K64MLXC.get_jungle,
31
- isErrorWithLocation: () => import_chunk_5K64MLXC.isErrorWithLocation,
32
- launchSimulator: () => import_chunk_5K64MLXC.launchSimulator,
33
- manifestProducts: () => import_chunk_5K64MLXC.manifestProducts,
34
- mctree: () => import_chunk_5K64MLXC.mctree,
35
- simulateProgram: () => import_chunk_5K64MLXC.simulateProgram
24
+ defaultConfig: () => import_chunk_M3LMSSY7.defaultConfig,
25
+ display: () => import_chunk_M3LMSSY7.display,
26
+ generateOneConfig: () => import_chunk_M3LMSSY7.generateOneConfig,
27
+ generateOptimizedProject: () => import_chunk_M3LMSSY7.generateOptimizedProject,
28
+ getConfig: () => import_chunk_M3LMSSY7.getConfig,
29
+ getProjectAnalysis: () => import_chunk_M3LMSSY7.getProjectAnalysis,
30
+ get_jungle: () => import_chunk_M3LMSSY7.get_jungle,
31
+ isErrorWithLocation: () => import_chunk_M3LMSSY7.isErrorWithLocation,
32
+ launchSimulator: () => import_chunk_M3LMSSY7.launchSimulator,
33
+ manifestProducts: () => import_chunk_M3LMSSY7.manifestProducts,
34
+ mctree: () => import_chunk_M3LMSSY7.mctree,
35
+ simulateProgram: () => import_chunk_M3LMSSY7.simulateProgram
36
36
  });
37
37
  module.exports = __toCommonJS(optimizer_exports);
38
- var import_chunk_5K64MLXC = require("./chunk-5K64MLXC.cjs");
38
+ var import_chunk_M3LMSSY7 = require("./chunk-M3LMSSY7.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, import_chunk_5K64MLXC.init_optimizer)();
42
+ (0, import_chunk_M3LMSSY7.init_optimizer)();
43
43
  // Annotate the CommonJS export names for ESM import in node:
44
44
  0 && (module.exports = {
45
45
  StateNodeAttributes,
@@ -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: () => import_chunk_5K64MLXC.SectionKinds,
22
- appSupport: () => import_chunk_5K64MLXC.appSupport,
23
- connectiq: () => import_chunk_5K64MLXC.connectiq,
24
- getDeviceInfo: () => import_chunk_5K64MLXC.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_5K64MLXC.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_5K64MLXC.getLanguages,
27
- getSdkPath: () => import_chunk_5K64MLXC.getSdkPath,
28
- isWin: () => import_chunk_5K64MLXC.isWin,
29
- optimizeProgram: () => import_chunk_5K64MLXC.optimizeProgram,
30
- readPrg: () => import_chunk_5K64MLXC.readPrg,
31
- readPrgWithOffsets: () => import_chunk_5K64MLXC.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_5K64MLXC.xml_util_exports
21
+ SectionKinds: () => import_chunk_M3LMSSY7.SectionKinds,
22
+ appSupport: () => import_chunk_M3LMSSY7.appSupport,
23
+ connectiq: () => import_chunk_M3LMSSY7.connectiq,
24
+ getDeviceInfo: () => import_chunk_M3LMSSY7.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_M3LMSSY7.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_M3LMSSY7.getLanguages,
27
+ getSdkPath: () => import_chunk_M3LMSSY7.getSdkPath,
28
+ isWin: () => import_chunk_M3LMSSY7.isWin,
29
+ optimizeProgram: () => import_chunk_M3LMSSY7.optimizeProgram,
30
+ readPrg: () => import_chunk_M3LMSSY7.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_M3LMSSY7.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_M3LMSSY7.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_5K64MLXC = require("./chunk-5K64MLXC.cjs");
35
+ var import_chunk_M3LMSSY7 = require("./chunk-M3LMSSY7.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, import_chunk_5K64MLXC.init_sdk_util)();
39
+ (0, import_chunk_M3LMSSY7.init_sdk_util)();
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  SectionKinds,
@@ -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 import_chunk_5K64MLXC = require("./chunk-5K64MLXC.cjs");
24
+ var import_chunk_M3LMSSY7 = require("./chunk-M3LMSSY7.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, import_chunk_5K64MLXC.init_worker_task)();
31
+ (0, import_chunk_M3LMSSY7.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, import_chunk_5K64MLXC.performTask)(task));
34
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_M3LMSSY7.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.54",
4
+ "version": "1.1.56",
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",