@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.
- package/README.md +14 -1
- package/build/api.cjs +33 -33
- package/build/{chunk-ZDTW2QRS.cjs → chunk-563GVBVT.cjs} +1142 -757
- package/build/optimizer.cjs +17 -17
- package/build/sdk-util.cjs +14 -14
- package/build/src/api.d.ts +1 -1
- package/build/src/optimizer-types.d.ts +1 -0
- package/build/src/readprg/array-init.d.ts +2 -1
- package/build/src/readprg/bytecode.d.ts +2 -0
- package/build/src/readprg/cflow.d.ts +8 -1
- package/build/src/readprg/interp.d.ts +7 -6
- package/build/src/readprg/locals.d.ts +3 -2
- package/build/src/readprg.d.ts +4 -3
- package/build/src/type-flow/type-flow-util.d.ts +1 -1
- package/build/src/worker-task.d.ts +1 -0
- package/build/worker-thread.cjs +3 -3
- package/package.json +1 -1
package/build/optimizer.cjs
CHANGED
|
@@ -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: () =>
|
|
22
|
-
buildOptimizedProject: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_563GVBVT.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_563GVBVT.buildOptimizedProject,
|
|
23
23
|
copyRecursiveAsNeeded: () => import_chunk_HHQDDCTP.copyRecursiveAsNeeded,
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
generateApiMirTests: () =>
|
|
27
|
-
generateOneConfig: () =>
|
|
28
|
-
generateOptimizedProject: () =>
|
|
29
|
-
getConfig: () =>
|
|
30
|
-
getProjectAnalysis: () =>
|
|
31
|
-
get_jungle: () =>
|
|
32
|
-
isErrorWithLocation: () =>
|
|
33
|
-
launchSimulator: () =>
|
|
34
|
-
manifestProducts: () =>
|
|
35
|
-
mctree: () =>
|
|
36
|
-
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
|
|
39
|
+
var import_chunk_563GVBVT = require("./chunk-563GVBVT.cjs");
|
|
40
40
|
var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
|
|
41
|
-
(0,
|
|
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,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -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: () =>
|
|
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_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
|
|
35
|
+
var import_chunk_563GVBVT = require("./chunk-563GVBVT.cjs");
|
|
36
36
|
var import_chunk_HHQDDCTP = require("./chunk-HHQDDCTP.cjs");
|
|
37
|
-
(0,
|
|
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,
|
package/build/src/api.d.ts
CHANGED
|
@@ -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 |
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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;
|
package/build/src/readprg.d.ts
CHANGED
|
@@ -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): [
|
|
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;
|
package/build/worker-thread.cjs
CHANGED
|
@@ -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
|
|
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,
|
|
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,
|
|
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