@markw65/monkeyc-optimizer 1.1.19 → 1.1.20

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.
@@ -18,27 +18,27 @@ 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_O5LFMOIG.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_O5LFMOIG.buildOptimizedProject,
23
- copyRecursiveAsNeeded: () => import_chunk_IAUHYWVN.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_O5LFMOIG.defaultConfig,
25
- display: () => import_chunk_O5LFMOIG.display,
26
- generateApiMirTests: () => import_chunk_O5LFMOIG.generateApiMirTests,
27
- generateOneConfig: () => import_chunk_O5LFMOIG.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_O5LFMOIG.generateOptimizedProject,
29
- getConfig: () => import_chunk_O5LFMOIG.getConfig,
30
- getProjectAnalysis: () => import_chunk_O5LFMOIG.getProjectAnalysis,
31
- get_jungle: () => import_chunk_O5LFMOIG.get_jungle,
32
- isErrorWithLocation: () => import_chunk_O5LFMOIG.isErrorWithLocation,
33
- launchSimulator: () => import_chunk_O5LFMOIG.launchSimulator,
34
- manifestProducts: () => import_chunk_O5LFMOIG.manifestProducts,
35
- mctree: () => import_chunk_O5LFMOIG.mctree,
36
- simulateProgram: () => import_chunk_O5LFMOIG.simulateProgram
21
+ StateNodeAttributes: () => import_chunk_DCGJCC63.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_DCGJCC63.buildOptimizedProject,
23
+ copyRecursiveAsNeeded: () => import_chunk_APACX34C.copyRecursiveAsNeeded,
24
+ defaultConfig: () => import_chunk_DCGJCC63.defaultConfig,
25
+ display: () => import_chunk_DCGJCC63.display,
26
+ generateApiMirTests: () => import_chunk_DCGJCC63.generateApiMirTests,
27
+ generateOneConfig: () => import_chunk_DCGJCC63.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_DCGJCC63.generateOptimizedProject,
29
+ getConfig: () => import_chunk_DCGJCC63.getConfig,
30
+ getProjectAnalysis: () => import_chunk_DCGJCC63.getProjectAnalysis,
31
+ get_jungle: () => import_chunk_DCGJCC63.get_jungle,
32
+ isErrorWithLocation: () => import_chunk_DCGJCC63.isErrorWithLocation,
33
+ launchSimulator: () => import_chunk_DCGJCC63.launchSimulator,
34
+ manifestProducts: () => import_chunk_DCGJCC63.manifestProducts,
35
+ mctree: () => import_chunk_DCGJCC63.mctree,
36
+ simulateProgram: () => import_chunk_DCGJCC63.simulateProgram
37
37
  });
38
38
  module.exports = __toCommonJS(optimizer_exports);
39
- var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
40
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
41
- (0, import_chunk_O5LFMOIG.init_optimizer)();
39
+ var import_chunk_DCGJCC63 = require("./chunk-DCGJCC63.cjs");
40
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
41
+ (0, import_chunk_DCGJCC63.init_optimizer)();
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  StateNodeAttributes,
@@ -18,23 +18,23 @@ 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_O5LFMOIG.SectionKinds,
22
- appSupport: () => import_chunk_O5LFMOIG.appSupport,
23
- connectiq: () => import_chunk_O5LFMOIG.connectiq,
24
- getDeviceInfo: () => import_chunk_O5LFMOIG.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_O5LFMOIG.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_O5LFMOIG.getLanguages,
27
- getSdkPath: () => import_chunk_O5LFMOIG.getSdkPath,
28
- isWin: () => import_chunk_O5LFMOIG.isWin,
29
- optimizeProgram: () => import_chunk_O5LFMOIG.optimizeProgram,
30
- readPrg: () => import_chunk_O5LFMOIG.readPrg,
31
- readPrgWithOffsets: () => import_chunk_O5LFMOIG.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_O5LFMOIG.xml_util_exports
21
+ SectionKinds: () => import_chunk_DCGJCC63.SectionKinds,
22
+ appSupport: () => import_chunk_DCGJCC63.appSupport,
23
+ connectiq: () => import_chunk_DCGJCC63.connectiq,
24
+ getDeviceInfo: () => import_chunk_DCGJCC63.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_DCGJCC63.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_DCGJCC63.getLanguages,
27
+ getSdkPath: () => import_chunk_DCGJCC63.getSdkPath,
28
+ isWin: () => import_chunk_DCGJCC63.isWin,
29
+ optimizeProgram: () => import_chunk_DCGJCC63.optimizeProgram,
30
+ readPrg: () => import_chunk_DCGJCC63.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_DCGJCC63.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_DCGJCC63.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
36
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
37
- (0, import_chunk_O5LFMOIG.init_sdk_util)();
35
+ var import_chunk_DCGJCC63 = require("./chunk-DCGJCC63.cjs");
36
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
37
+ (0, import_chunk_DCGJCC63.init_sdk_util)();
38
38
  // Annotate the CommonJS export names for ESM import in node:
39
39
  0 && (module.exports = {
40
40
  SectionKinds,
@@ -1,6 +1,7 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
2
  import { BaseEvent, Block } from "./control-flow";
3
3
  import { FunctionStateNode, ProgramStateAnalysis, StateNodeDecl } from "./optimizer-types";
4
+ import { GenericQueue } from "./util";
4
5
  export declare type RefNode = mctree.Identifier | mctree.MemberExpression | mctree.Literal;
5
6
  export declare type MemberDecl = {
6
7
  type: "MemberDecl";
@@ -101,10 +102,6 @@ export declare function buildDataFlowGraph(state: ProgramStateAnalysis, func: Fu
101
102
  identifiers: Set<string>;
102
103
  graph: Block<Event>;
103
104
  };
104
- export declare class DataflowQueue {
105
- private enqueued;
106
- private queue;
107
- enqueue(block: DataFlowBlock): void;
108
- dequeue(): DataFlowBlock;
109
- empty(): boolean;
105
+ export declare class DataflowQueue extends GenericQueue<DataFlowBlock> {
106
+ constructor();
110
107
  }
@@ -51,9 +51,9 @@ export declare type FuncEntry = {
51
51
  export declare function offsetToString(offset: number): string;
52
52
  export declare function fixSectionSize(section: SectionKinds, sections: Context["sections"], newSize: number): void;
53
53
  export declare function optimizeBytecode(context: Context): void;
54
- export declare function functionBanner(func: FuncEntry, context: Context | null, pass: string): () => string;
54
+ export declare function functionBanner(func: FuncEntry, context: Context | null, pass: string, footer?: (block: Block) => string): () => string;
55
55
  export declare function printFunction(func: FuncEntry, context: Context | null): void;
56
- export declare function functionToString(func: FuncEntry, context: Context | null): string;
56
+ export declare function functionToString(func: FuncEntry, context: Context | null, footer?: (block: Block) => string): string;
57
57
  export declare function blockToString(block: Block, context: Context | null): string;
58
58
  export declare function bytecodeToString(bytecode: Bytecode, symbolTable: SymbolTable | null | undefined): string;
59
59
  export declare function findFunctions({ bytecodes, symbolTable, exceptionsMap, }: Context): Map<number, FuncEntry>;
@@ -1,2 +1,3 @@
1
1
  import { Context, FuncEntry } from "./bytecode";
2
2
  export declare function localDCE(func: FuncEntry, context: Context): boolean;
3
+ export declare function computeLiveLocals(func: FuncEntry): Map<number, Set<number>>;
@@ -23,3 +23,11 @@ export declare function readByLine(file: string, lineHandler: LineHandler): Prom
23
23
  export declare function promiseAll<T>(promiseFn: (i: number) => Promise<T> | null, parallelism: number): Promise<T[]>;
24
24
  export declare function copyRecursiveAsNeeded(source: string, target: string, filter?: (src: string, tgt: string) => boolean): Promise<void>;
25
25
  export declare function popcount(x: number): number;
26
+ export declare class GenericQueue<Block> {
27
+ private enqueued;
28
+ private queue;
29
+ constructor(sort: (a: Block, b: Block) => number);
30
+ enqueue(block: Block): void;
31
+ dequeue(): Block;
32
+ empty(): boolean;
33
+ }
package/build/util.cjs CHANGED
@@ -18,33 +18,35 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var util_exports = {};
20
20
  __export(util_exports, {
21
- bumpLogging: () => import_chunk_IAUHYWVN.bumpLogging,
22
- copyRecursiveAsNeeded: () => import_chunk_IAUHYWVN.copyRecursiveAsNeeded,
23
- every: () => import_chunk_IAUHYWVN.every,
24
- first_modified: () => import_chunk_IAUHYWVN.first_modified,
25
- forEach: () => import_chunk_IAUHYWVN.forEach,
26
- globSome: () => import_chunk_IAUHYWVN.globSome,
27
- globa: () => import_chunk_IAUHYWVN.globa,
28
- last_modified: () => import_chunk_IAUHYWVN.last_modified,
29
- log: () => import_chunk_IAUHYWVN.log,
30
- logger: () => import_chunk_IAUHYWVN.logger,
31
- map: () => import_chunk_IAUHYWVN.map,
32
- popcount: () => import_chunk_IAUHYWVN.popcount,
33
- promiseAll: () => import_chunk_IAUHYWVN.promiseAll,
34
- pushUnique: () => import_chunk_IAUHYWVN.pushUnique,
35
- readByLine: () => import_chunk_IAUHYWVN.readByLine,
36
- reduce: () => import_chunk_IAUHYWVN.reduce,
37
- sameArrays: () => import_chunk_IAUHYWVN.sameArrays,
38
- setBanner: () => import_chunk_IAUHYWVN.setBanner,
39
- some: () => import_chunk_IAUHYWVN.some,
40
- spawnByLine: () => import_chunk_IAUHYWVN.spawnByLine,
41
- wouldLog: () => import_chunk_IAUHYWVN.wouldLog
21
+ GenericQueue: () => import_chunk_APACX34C.GenericQueue,
22
+ bumpLogging: () => import_chunk_APACX34C.bumpLogging,
23
+ copyRecursiveAsNeeded: () => import_chunk_APACX34C.copyRecursiveAsNeeded,
24
+ every: () => import_chunk_APACX34C.every,
25
+ first_modified: () => import_chunk_APACX34C.first_modified,
26
+ forEach: () => import_chunk_APACX34C.forEach,
27
+ globSome: () => import_chunk_APACX34C.globSome,
28
+ globa: () => import_chunk_APACX34C.globa,
29
+ last_modified: () => import_chunk_APACX34C.last_modified,
30
+ log: () => import_chunk_APACX34C.log,
31
+ logger: () => import_chunk_APACX34C.logger,
32
+ map: () => import_chunk_APACX34C.map,
33
+ popcount: () => import_chunk_APACX34C.popcount,
34
+ promiseAll: () => import_chunk_APACX34C.promiseAll,
35
+ pushUnique: () => import_chunk_APACX34C.pushUnique,
36
+ readByLine: () => import_chunk_APACX34C.readByLine,
37
+ reduce: () => import_chunk_APACX34C.reduce,
38
+ sameArrays: () => import_chunk_APACX34C.sameArrays,
39
+ setBanner: () => import_chunk_APACX34C.setBanner,
40
+ some: () => import_chunk_APACX34C.some,
41
+ spawnByLine: () => import_chunk_APACX34C.spawnByLine,
42
+ wouldLog: () => import_chunk_APACX34C.wouldLog
42
43
  });
43
44
  module.exports = __toCommonJS(util_exports);
44
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
45
- (0, import_chunk_IAUHYWVN.init_util)();
45
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
46
+ (0, import_chunk_APACX34C.init_util)();
46
47
  // Annotate the CommonJS export names for ESM import in node:
47
48
  0 && (module.exports = {
49
+ GenericQueue,
48
50
  bumpLogging,
49
51
  copyRecursiveAsNeeded,
50
52
  every,
@@ -18,14 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var worker_pool_exports = {};
20
20
  __export(worker_pool_exports, {
21
- runTaskInPool: () => import_chunk_O5LFMOIG.runTaskInPool,
22
- startPool: () => import_chunk_O5LFMOIG.startPool,
23
- stopPool: () => import_chunk_O5LFMOIG.stopPool
21
+ runTaskInPool: () => import_chunk_DCGJCC63.runTaskInPool,
22
+ startPool: () => import_chunk_DCGJCC63.startPool,
23
+ stopPool: () => import_chunk_DCGJCC63.stopPool
24
24
  });
25
25
  module.exports = __toCommonJS(worker_pool_exports);
26
- var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
27
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
28
- (0, import_chunk_O5LFMOIG.init_worker_pool)();
26
+ var import_chunk_DCGJCC63 = require("./chunk-DCGJCC63.cjs");
27
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
28
+ (0, import_chunk_DCGJCC63.init_worker_pool)();
29
29
  // Annotate the CommonJS export names for ESM import in node:
30
30
  0 && (module.exports = {
31
31
  runTaskInPool,
@@ -21,15 +21,15 @@ __export(worker_thread_exports, {
21
21
  default: () => worker_thread_default
22
22
  });
23
23
  module.exports = __toCommonJS(worker_thread_exports);
24
- var import_chunk_O5LFMOIG = require("./chunk-O5LFMOIG.cjs");
25
- var import_chunk_IAUHYWVN = require("./chunk-IAUHYWVN.cjs");
24
+ var import_chunk_DCGJCC63 = require("./chunk-DCGJCC63.cjs");
25
+ var import_chunk_APACX34C = require("./chunk-APACX34C.cjs");
26
26
  var import_node_worker_threads = require("node:worker_threads");
27
- var require_worker_thread = (0, import_chunk_IAUHYWVN.__commonJS)({
27
+ var require_worker_thread = (0, import_chunk_APACX34C.__commonJS)({
28
28
  "src/worker-thread.ts"() {
29
- (0, import_chunk_O5LFMOIG.init_worker_task)();
29
+ (0, import_chunk_DCGJCC63.init_worker_task)();
30
30
  if (import_node_worker_threads.parentPort) {
31
31
  import_node_worker_threads.parentPort.on("message", async (task) => {
32
- return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_O5LFMOIG.performTask)(task));
32
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_DCGJCC63.performTask)(task));
33
33
  });
34
34
  }
35
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "commonjs",
4
- "version": "1.1.19",
4
+ "version": "1.1.20",
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",