@markw65/monkeyc-optimizer 1.1.21 → 1.1.22

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_ZDTW2QRS.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_ZDTW2QRS.buildOptimizedProject,
21
+ StateNodeAttributes: () => import_chunk_563GVBVT.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_563GVBVT.buildOptimizedProject,
23
23
  copyRecursiveAsNeeded: () => import_chunk_HHQDDCTP.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_ZDTW2QRS.defaultConfig,
25
- display: () => import_chunk_ZDTW2QRS.display,
26
- generateApiMirTests: () => import_chunk_ZDTW2QRS.generateApiMirTests,
27
- generateOneConfig: () => import_chunk_ZDTW2QRS.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_ZDTW2QRS.generateOptimizedProject,
29
- getConfig: () => import_chunk_ZDTW2QRS.getConfig,
30
- getProjectAnalysis: () => import_chunk_ZDTW2QRS.getProjectAnalysis,
31
- get_jungle: () => import_chunk_ZDTW2QRS.get_jungle,
32
- isErrorWithLocation: () => import_chunk_ZDTW2QRS.isErrorWithLocation,
33
- launchSimulator: () => import_chunk_ZDTW2QRS.launchSimulator,
34
- manifestProducts: () => import_chunk_ZDTW2QRS.manifestProducts,
35
- mctree: () => import_chunk_ZDTW2QRS.mctree,
36
- simulateProgram: () => import_chunk_ZDTW2QRS.simulateProgram
24
+ defaultConfig: () => import_chunk_563GVBVT.defaultConfig,
25
+ display: () => import_chunk_563GVBVT.display,
26
+ generateApiMirTests: () => import_chunk_563GVBVT.generateApiMirTests,
27
+ generateOneConfig: () => import_chunk_563GVBVT.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_563GVBVT.generateOptimizedProject,
29
+ getConfig: () => import_chunk_563GVBVT.getConfig,
30
+ getProjectAnalysis: () => import_chunk_563GVBVT.getProjectAnalysis,
31
+ get_jungle: () => import_chunk_563GVBVT.get_jungle,
32
+ isErrorWithLocation: () => import_chunk_563GVBVT.isErrorWithLocation,
33
+ launchSimulator: () => import_chunk_563GVBVT.launchSimulator,
34
+ manifestProducts: () => import_chunk_563GVBVT.manifestProducts,
35
+ mctree: () => import_chunk_563GVBVT.mctree,
36
+ simulateProgram: () => import_chunk_563GVBVT.simulateProgram
37
37
  });
38
38
  module.exports = __toCommonJS(optimizer_exports);
39
- var import_chunk_ZDTW2QRS = require("./chunk-ZDTW2QRS.cjs");
39
+ var import_chunk_563GVBVT = require("./chunk-563GVBVT.cjs");
40
40
  var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
41
- (0, import_chunk_ZDTW2QRS.init_optimizer)();
41
+ (0, import_chunk_563GVBVT.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_ZDTW2QRS.SectionKinds,
22
- appSupport: () => import_chunk_ZDTW2QRS.appSupport,
23
- connectiq: () => import_chunk_ZDTW2QRS.connectiq,
24
- getDeviceInfo: () => import_chunk_ZDTW2QRS.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_ZDTW2QRS.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_ZDTW2QRS.getLanguages,
27
- getSdkPath: () => import_chunk_ZDTW2QRS.getSdkPath,
28
- isWin: () => import_chunk_ZDTW2QRS.isWin,
29
- optimizeProgram: () => import_chunk_ZDTW2QRS.optimizeProgram,
30
- readPrg: () => import_chunk_ZDTW2QRS.readPrg,
31
- readPrgWithOffsets: () => import_chunk_ZDTW2QRS.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_ZDTW2QRS.xml_util_exports
21
+ SectionKinds: () => import_chunk_563GVBVT.SectionKinds,
22
+ appSupport: () => import_chunk_563GVBVT.appSupport,
23
+ connectiq: () => import_chunk_563GVBVT.connectiq,
24
+ getDeviceInfo: () => import_chunk_563GVBVT.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_563GVBVT.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_563GVBVT.getLanguages,
27
+ getSdkPath: () => import_chunk_563GVBVT.getSdkPath,
28
+ isWin: () => import_chunk_563GVBVT.isWin,
29
+ optimizeProgram: () => import_chunk_563GVBVT.optimizeProgram,
30
+ readPrg: () => import_chunk_563GVBVT.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_563GVBVT.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_563GVBVT.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_ZDTW2QRS = require("./chunk-ZDTW2QRS.cjs");
35
+ var import_chunk_563GVBVT = require("./chunk-563GVBVT.cjs");
36
36
  var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
37
- (0, import_chunk_ZDTW2QRS.init_sdk_util)();
37
+ (0, import_chunk_563GVBVT.init_sdk_util)();
38
38
  // Annotate the CommonJS export names for ESM import in node:
39
39
  0 && (module.exports = {
40
40
  SectionKinds,
@@ -26,7 +26,7 @@ export declare function findNamesInScope(declStack: StateNode[][], pattern: stri
26
26
  parent: StateNode;
27
27
  depth: number;
28
28
  }][];
29
- export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | ModuleStateNode | FunctionStateNode | ClassStateNode | TypedefStateNode | ProgramStateNode | import("./optimizer-types").BlockStateNode | VariableStateNode | EnumStateNode)[];
29
+ export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | FunctionStateNode | ClassStateNode | ModuleStateNode | ProgramStateNode | VariableStateNode | import("./optimizer-types").BlockStateNode | TypedefStateNode | EnumStateNode)[];
30
30
  export declare function formatAstLongLines(node: mctree.Node): string;
31
31
  export declare function createDocumentationMap(functionDocumentation: {
32
32
  name: string;
@@ -44,6 +44,7 @@ export declare type BuildConfig = {
44
44
  iterateOptimizer?: boolean;
45
45
  covarianceWarnings?: boolean;
46
46
  checkTypes?: DiagnosticType | "OFF";
47
+ removeArgc?: boolean;
47
48
  };
48
49
  export declare type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier;
49
50
  export declare type StateNodeDecls = {
@@ -1,2 +1,3 @@
1
1
  import { Block, Context, FuncEntry } from "./bytecode";
2
- export declare function optimizeArrayInit(func: FuncEntry, block: Block, index: number, stackPreserving: boolean, context: Context): boolean;
2
+ import { InterpState } from "./interp";
3
+ export declare function optimizeArrayInit(func: FuncEntry, block: Block, index: number, context: Context, interpState: InterpState | null): boolean;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import * as crypto from "node:crypto";
3
+ import { BuildConfig } from "src/optimizer-types";
3
4
  import { xmlUtil } from "../sdk-util";
4
5
  import { ExceptionEntry, ExceptionsMap } from "./exceptions";
5
6
  import { Header } from "./header";
@@ -23,6 +24,7 @@ export declare type SectionInfo = {
23
24
  };
24
25
  export declare type Logger = (module: string, level: number, message: string) => void;
25
26
  export declare type Context = {
27
+ config: BuildConfig;
26
28
  filepath: string;
27
29
  sections: Record<number, SectionInfo>;
28
30
  header: Header;
@@ -5,4 +5,11 @@ export declare function intersect<T>(a: Set<T>, b: Set<T>): Set<T>;
5
5
  export declare type DomLike = Map<number, Set<number>>;
6
6
  export declare function computePostDominators(func: FuncEntry): DomLike;
7
7
  export declare function postOrderPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: (block: Block, bc: Bytecode, state: T) => void, postBlock: (block: Block, state: T) => void, merge: (state: T, predBlock: Block, isExPred: boolean) => boolean): void;
8
- export declare function rpoPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: (block: Block, bc: Bytecode, state: T) => void, postBlock: (block: Block, state: T) => void, merge: (from: Block, state: T, predBlock: Block, isExSucc: boolean) => boolean): void;
8
+ export declare enum RpoFlags {
9
+ EnqueueTaken = 1,
10
+ EnqueueNext = 2,
11
+ SkipTaken = 4,
12
+ SkipNext = 8,
13
+ RestartBlock = 16
14
+ }
15
+ export declare function rpoPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: (block: Block, bc: Bytecode, state: T) => RpoFlags | null | undefined | void, postBlock: (block: Block, state: T) => void, merge: (from: Block, state: T, predBlock: Block, isExSucc: boolean) => boolean): void;
@@ -1,19 +1,20 @@
1
1
  import { ExactOrUnion } from "../optimizer";
2
2
  import { Context, FuncEntry } from "./bytecode";
3
- import { Lputv } from "./opcodes";
3
+ import { Bytecode, Lputv } from "./opcodes";
4
4
  interface InterpItemInfo {
5
5
  type: ExactOrUnion;
6
6
  equivs?: Set<number>;
7
7
  }
8
- interface InterpStackElem extends InterpItemInfo {
9
- dup?: number;
10
- }
11
- declare type InterpState = {
12
- stack: InterpStackElem[];
8
+ export declare type InterpState = {
9
+ stack: InterpItemInfo[];
13
10
  locals: InterpItemInfo[];
11
+ loopBlock?: true;
14
12
  };
13
+ export declare function cloneState(state: InterpState | null | undefined): InterpState;
14
+ export declare function interpBytecode(bc: Bytecode, localState: InterpState, context: Context): void;
15
15
  export declare function interpFunc(func: FuncEntry, context: Context): {
16
16
  liveInState: Map<number, InterpState>;
17
17
  equivSets: Map<Lputv, Set<number>>;
18
18
  };
19
+ export declare function instForType(type: ExactOrUnion, offset: number): Bytecode | null;
19
20
  export {};
@@ -1,2 +1,3 @@
1
- import { FuncEntry } from "./bytecode";
2
- export declare function computeConflictGraph(func: FuncEntry): void;
1
+ import { Context, FuncEntry } from "./bytecode";
2
+ import { Lputv } from "./opcodes";
3
+ export declare function minimizeLocals(func: FuncEntry, equivSets: Map<Lputv, Set<number>>, context: Context): boolean;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import * as crypto from "node:crypto";
4
+ import { BuildConfig } from "./optimizer-types";
4
5
  import { SectionInfo } from "./readprg/bytecode";
5
6
  import { xmlUtil } from "./sdk-util";
6
7
  export declare function readPrg(path: string): Promise<{
@@ -14,12 +15,12 @@ export declare function readPrgWithOffsets(view: DataView): {
14
15
  view: DataView;
15
16
  sections: Record<number, SectionInfo>;
16
17
  };
17
- export declare function optimizeProgram(filepath: string, devKey?: string | undefined, output?: string): Promise<unknown>;
18
- export declare function optimizeProgramBuffer(filepath: string, view: DataView, debugXml: xmlUtil.Document, key: crypto.KeyObject | undefined): {
18
+ export declare function optimizeProgram(filepath: string, devKey?: string | undefined, output?: string, config?: BuildConfig): Promise<unknown>;
19
+ export declare function optimizeProgramBuffer(filepath: string, view: DataView, debugXml: xmlUtil.Document, key: crypto.KeyObject | undefined, config: BuildConfig | undefined): {
19
20
  signature: Buffer | undefined;
20
21
  buffer: Buffer;
21
22
  };
22
- export declare function optimizePrgAndDebug(prgName: string, prgBuffer: ArrayBuffer, prgOffset: number, prgLength: number, xmlName: string, xmlBuffer: ArrayBuffer, xmlOffset: number, xmlLength: number, key: crypto.KeyObject): Promise<{
23
+ export declare function optimizePrgAndDebug(prgName: string, prgBuffer: ArrayBuffer, prgOffset: number, prgLength: number, xmlName: string, xmlBuffer: ArrayBuffer, xmlOffset: number, xmlLength: number, key: crypto.KeyObject, config: BuildConfig | undefined): Promise<{
23
24
  sigBuffer: ArrayBufferLike | undefined;
24
25
  sigOffset: number | undefined;
25
26
  sigLength: number | undefined;
@@ -17,7 +17,7 @@ export declare function printBlockHeader(block: TypeFlowBlock): void;
17
17
  export declare function describeEvent(event: Event): string;
18
18
  export declare function printBlockEvents(block: TypeFlowBlock, extra?: (event: Event) => string): void;
19
19
  export declare function printBlockTrailer(block: TypeFlowBlock): void;
20
- export declare function findObjectDeclsByProperty(state: ProgramStateAnalysis, object: ExactOrUnion, next: mctree.DottedMemberExpression): [StateNode[], StateNode[]] | readonly [null, null];
20
+ export declare function findObjectDeclsByProperty(state: ProgramStateAnalysis, object: ExactOrUnion, next: mctree.DottedMemberExpression): readonly [null, null] | [StateNode[], StateNode[]];
21
21
  export declare function refineObjectTypeByDecls(istate: InterpState, object: ExactOrUnion, trueDecls: StateNode[]): ExactOrUnion;
22
22
  export declare function findNextObjectType(istate: InterpState, trueDecls: StateNode[], next: mctree.DottedMemberExpression): import("./types").UnionType | import("./types").NumberType | import("./types").LongType | import("./types").FloatType | import("./types").DoubleType | import("./types").CharType | import("./types").StringType | import("./types").ArrayType | import("./types").DictionaryType | import("./types").MethodType | import("./types").ModuleType | import("./types").FunctionType | import("./types").ClassType | import("./types").ObjectType | import("./types").EnumType | import("./types").SymbolType | import("./types").TypedefType | null;
23
23
  export declare function resolveDottedMember(istate: InterpState, object: ExactOrUnion, next: mctree.DottedMemberExpression): {
@@ -41,6 +41,7 @@ interface OptimizePrgAndDebug extends BaseNode {
41
41
  xmlOffset: number;
42
42
  xmlLength: number;
43
43
  key: crypto.KeyObject;
44
+ config: BuildConfig | undefined;
44
45
  };
45
46
  }
46
47
  export declare type WorkerTask = BuildOptimizedProject | GenerateOptimizedProject | GenerateOneConfig | OptimizePrgAndDebug;
@@ -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_ZDTW2QRS = require("./chunk-ZDTW2QRS.cjs");
24
+ var import_chunk_563GVBVT = require("./chunk-563GVBVT.cjs");
25
25
  var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
26
26
  var import_node_worker_threads = require("node:worker_threads");
27
27
  var require_worker_thread = (0, import_chunk_HHQDDCTP.__commonJS)({
28
28
  "src/worker-thread.ts"() {
29
- (0, import_chunk_ZDTW2QRS.init_worker_task)();
29
+ (0, import_chunk_563GVBVT.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_ZDTW2QRS.performTask)(task));
32
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_563GVBVT.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.21",
4
+ "version": "1.1.22",
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",