@markw65/monkeyc-optimizer 1.1.15 → 1.1.17
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 +41 -11
- package/build/api.cjs +86 -14515
- package/build/chunk-BGKDODLS.cjs +4858 -0
- package/build/chunk-IAUHYWVN.cjs +5717 -0
- package/build/chunk-YCLY27QH.cjs +23708 -0
- package/build/optimizer.cjs +58 -17007
- package/build/sdk-util.cjs +49 -11286
- package/build/src/api.d.ts +1 -1
- package/build/src/logger.d.ts +2 -0
- package/build/src/optimizer.d.ts +14 -4
- package/build/src/readprg/array-init.d.ts +2 -0
- package/build/src/readprg/bytecode.d.ts +8 -1
- package/build/src/readprg/dce.d.ts +1 -1
- package/build/src/readprg/emit.d.ts +2 -0
- package/build/src/readprg/exceptions.d.ts +2 -1
- package/build/src/type-flow/dead-store.d.ts +1 -1
- package/build/src/util.d.ts +2 -2
- package/build/src/worker-pool.d.ts +1 -1
- package/build/src/worker-task.d.ts +18 -3
- package/build/util.cjs +66 -8006
- package/package.json +9 -10
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): (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 | ModuleStateNode | FunctionStateNode | ClassStateNode | TypedefStateNode | ProgramStateNode | import("./optimizer-types").BlockStateNode | VariableStateNode | EnumStateNode)[];
|
|
30
30
|
export declare function formatAstLongLines(node: mctree.Node): string;
|
|
31
31
|
export declare function createDocumentationMap(functionDocumentation: {
|
|
32
32
|
name: string;
|
package/build/src/logger.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function logger(module: string, level: number, message: unknown): void;
|
|
2
2
|
export declare function wouldLog(module: string, level: number): boolean;
|
|
3
|
+
export declare function bumpLogging(module: string | null, amount: number): void;
|
|
4
|
+
export declare function setBanner(b: (() => string) | null): void;
|
|
3
5
|
export declare function log(message: unknown): void;
|
|
4
6
|
export declare function setLogger(log: (message: string) => void): void;
|
package/build/src/optimizer.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { get_jungle, JungleBuildDependencies, JungleError, JungleResourceMap, ResolvedJungle, Target } from "./jungles";
|
|
2
|
+
import { get_jungle, JungleBuildDependencies, JungleError, JungleQualifier, JungleResourceMap, ResolvedJungle, Target } from "./jungles";
|
|
3
3
|
import { launchSimulator, simulateProgram } from "./launch";
|
|
4
4
|
import { manifestProducts } from "./manifest";
|
|
5
|
-
import { BuildConfig, FilesToOptimizeMap, ProgramStateAnalysis } from "./optimizer-types";
|
|
5
|
+
import { BuildConfig, FilesToOptimizeMap, ProgramState, ProgramStateAnalysis } from "./optimizer-types";
|
|
6
6
|
import { xmlUtil } from "./sdk-util";
|
|
7
7
|
import { TypeMap } from "./type-flow/interp";
|
|
8
8
|
import { copyRecursiveAsNeeded } from "./util";
|
|
9
9
|
export * from "./optimizer-types";
|
|
10
|
-
export { display } from "./type-flow/types";
|
|
11
|
-
export { copyRecursiveAsNeeded, get_jungle, JungleBuildDependencies, JungleError, JungleResourceMap, launchSimulator, manifestProducts, mctree, ResolvedJungle, simulateProgram, };
|
|
10
|
+
export { display, ExactOrUnion } from "./type-flow/types";
|
|
11
|
+
export { copyRecursiveAsNeeded, get_jungle, JungleBuildDependencies, JungleError, JungleResourceMap, launchSimulator, manifestProducts, mctree, ResolvedJungle, simulateProgram, TypeMap, };
|
|
12
12
|
export declare const defaultConfig: {
|
|
13
13
|
outputPath: string;
|
|
14
14
|
workspace: string;
|
|
@@ -80,6 +80,16 @@ export declare type Analysis = {
|
|
|
80
80
|
state: ProgramStateAnalysis;
|
|
81
81
|
typeMap?: TypeMap | null | undefined;
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* @param {BuildConfig} config
|
|
85
|
+
* @param {*} buildConfig
|
|
86
|
+
* @param {string[]} dependencyFiles
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
export declare function generateOneConfig(buildConfig: JungleQualifier, manifestXML: xmlUtil.Document, dependencyFiles: string[], config: BuildConfig): Promise<{
|
|
90
|
+
hasTests: boolean;
|
|
91
|
+
diagnostics: ProgramState["diagnostics"];
|
|
92
|
+
}>;
|
|
83
93
|
export declare function getProjectAnalysis(targets: Target[], analysis: PreAnalysis | null, manifestXML: xmlUtil.Document, options: BuildConfig): Promise<Analysis | PreAnalysis>;
|
|
84
94
|
/**
|
|
85
95
|
*
|
|
@@ -29,6 +29,7 @@ export declare type Context = {
|
|
|
29
29
|
bytecodes: Bytecode[];
|
|
30
30
|
key?: crypto.KeyObject;
|
|
31
31
|
debugXml: xmlUtil.Document;
|
|
32
|
+
nextOffset: number;
|
|
32
33
|
};
|
|
33
34
|
export declare type Block = {
|
|
34
35
|
offset: number;
|
|
@@ -36,6 +37,7 @@ export declare type Block = {
|
|
|
36
37
|
try?: ExceptionEntry[];
|
|
37
38
|
next?: number;
|
|
38
39
|
taken?: number;
|
|
40
|
+
exsucc?: number;
|
|
39
41
|
preds?: Set<number>;
|
|
40
42
|
};
|
|
41
43
|
export declare type FuncEntry = {
|
|
@@ -46,12 +48,17 @@ export declare type FuncEntry = {
|
|
|
46
48
|
export declare function offsetToString(offset: number): string;
|
|
47
49
|
export declare function fixSectionSize(section: SectionKinds, sections: Context["sections"], newSize: number): void;
|
|
48
50
|
export declare function optimizeBytecode(context: Context): void;
|
|
51
|
+
export declare function functionBanner(func: FuncEntry, context: Context | null, pass: string): () => string;
|
|
49
52
|
export declare function printFunction(func: FuncEntry, context: Context | null): void;
|
|
53
|
+
export declare function functionToString(func: FuncEntry, context: Context | null): string;
|
|
50
54
|
export declare function blockToString(block: Block, context: Context | null): string;
|
|
51
55
|
export declare function bytecodeToString(bytecode: Bytecode, symbolTable: SymbolTable | null | undefined): string;
|
|
52
56
|
export declare function findFunctions({ bytecodes, symbolTable, exceptionsMap, }: Context): Map<number, FuncEntry>;
|
|
53
57
|
export declare function makeArgless(bc: Bytecode, op: Opcodes): void;
|
|
54
58
|
export declare function equalBlocks(b1: Block, b2: Block): boolean;
|
|
59
|
+
export declare function removeBlock(func: FuncEntry, offset: number): void;
|
|
55
60
|
export declare function removePred(func: FuncEntry, target: number, pred: number): void;
|
|
56
61
|
export declare function addPred(func: FuncEntry, target: number, pred: number): void;
|
|
57
|
-
export declare function redirect(func: FuncEntry, block: Block, from: number, to: number): boolean;
|
|
62
|
+
export declare function redirect(func: FuncEntry, block: Block, from: number, to: number | null | undefined): boolean;
|
|
63
|
+
export declare function splitBlock(func: FuncEntry, block: Block, offset: number): void;
|
|
64
|
+
export declare function countFallthroughPreds(func: FuncEntry, block: Block): number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, FuncEntry } from "./bytecode";
|
|
2
2
|
export declare function localDCE(func: FuncEntry, context: Context): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context, FuncEntry } from "./bytecode";
|
|
2
|
+
import { ExceptionsMap } from "./exceptions";
|
|
2
3
|
import { LineNumber } from "./linenum";
|
|
3
4
|
export declare type LocalsMap = Map<number, {
|
|
4
5
|
startPc: number;
|
|
@@ -8,5 +9,6 @@ export declare type UpdateInfo = {
|
|
|
8
9
|
offsetMap: Map<number, number>;
|
|
9
10
|
localsMap: Map<FuncEntry, LocalsMap>;
|
|
10
11
|
lineMap: LineNumber[];
|
|
12
|
+
exceptionsMap: ExceptionsMap;
|
|
11
13
|
};
|
|
12
14
|
export declare function emitFunc(func: FuncEntry, view: DataView, start: number, updateInfo: UpdateInfo, context: Context): number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context } from "./bytecode";
|
|
2
|
+
import { UpdateInfo } from "./emit";
|
|
2
3
|
export declare type ExceptionEntry = {
|
|
3
4
|
tryStart: number;
|
|
4
5
|
tryEnd: number;
|
|
@@ -6,4 +7,4 @@ export declare type ExceptionEntry = {
|
|
|
6
7
|
};
|
|
7
8
|
export declare type ExceptionsMap = Map<number, ExceptionEntry[]>;
|
|
8
9
|
export declare function parseExceptions(view: DataView): ExceptionsMap;
|
|
9
|
-
export declare function fixupExceptions(context: Context,
|
|
10
|
+
export declare function fixupExceptions(context: Context, updateInfo: UpdateInfo): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { NodeEquivMap } from "
|
|
2
|
+
import { NodeEquivMap } from "../type-flow";
|
|
3
3
|
import { FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
|
|
4
4
|
import { TypeFlowBlock, TypeStateKey } from "./type-flow-util";
|
|
5
5
|
export declare type CopyPropStores = Map<mctree.Node, {
|
package/build/src/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { logger, log, wouldLog } from "./logger";
|
|
1
|
+
import glob from "fast-glob";
|
|
2
|
+
export { logger, log, wouldLog, setBanner, bumpLogging } from "./logger";
|
|
3
3
|
export declare function globa(pattern: string, options?: glob.Options & {
|
|
4
4
|
mark?: boolean;
|
|
5
5
|
}): Promise<Array<string>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { WorkerTask, WorkerTaskResult } from "./worker-task";
|
|
2
|
-
export declare function startPool(parallelism?: number):
|
|
2
|
+
export declare function startPool(parallelism?: number): boolean;
|
|
3
3
|
export declare function stopPool(): void;
|
|
4
4
|
export declare function runTaskInPool<T extends WorkerTask>(task: T): Promise<WorkerTaskResult<T>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { JungleQualifier } from "./jungles";
|
|
1
2
|
import { BuildConfig } from "./optimizer";
|
|
3
|
+
import { xmlUtil } from "./sdk-util";
|
|
2
4
|
interface BaseNode {
|
|
3
5
|
type: string;
|
|
4
6
|
data: unknown;
|
|
@@ -10,13 +12,22 @@ interface BuildOptimizedProject extends BaseNode {
|
|
|
10
12
|
options: BuildConfig;
|
|
11
13
|
};
|
|
12
14
|
}
|
|
15
|
+
interface GenerateOneConfig extends BaseNode {
|
|
16
|
+
type: "generateOneConfig";
|
|
17
|
+
data: {
|
|
18
|
+
buildConfig: JungleQualifier;
|
|
19
|
+
manifestXML: xmlUtil.Document;
|
|
20
|
+
dependencyFiles: string[];
|
|
21
|
+
config: BuildConfig;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
13
24
|
interface GenerateOptimizedProject extends BaseNode {
|
|
14
25
|
type: "generateOptimizedProject";
|
|
15
26
|
data: {
|
|
16
27
|
options: BuildConfig;
|
|
17
28
|
};
|
|
18
29
|
}
|
|
19
|
-
export declare type WorkerTask = BuildOptimizedProject | GenerateOptimizedProject;
|
|
30
|
+
export declare type WorkerTask = BuildOptimizedProject | GenerateOptimizedProject | GenerateOneConfig;
|
|
20
31
|
export declare const workerTaskHandlers: {
|
|
21
32
|
readonly buildOptimizedProject: (data: BuildOptimizedProject["data"]) => Promise<{
|
|
22
33
|
exe: string;
|
|
@@ -28,17 +39,21 @@ export declare const workerTaskHandlers: {
|
|
|
28
39
|
}>;
|
|
29
40
|
readonly generateOptimizedProject: (data: GenerateOptimizedProject["data"]) => Promise<{
|
|
30
41
|
jungleFiles: string | undefined;
|
|
31
|
-
xml:
|
|
42
|
+
xml: xmlUtil.Document;
|
|
32
43
|
program: string;
|
|
33
44
|
hasTests: boolean;
|
|
34
45
|
diagnostics?: undefined;
|
|
35
46
|
} | {
|
|
36
47
|
jungleFiles: string;
|
|
37
|
-
xml:
|
|
48
|
+
xml: xmlUtil.Document;
|
|
38
49
|
program: string;
|
|
39
50
|
hasTests: boolean;
|
|
40
51
|
diagnostics: Record<string, import("./optimizer-types").Diagnostic[]>;
|
|
41
52
|
}>;
|
|
53
|
+
readonly generateOneConfig: (data: GenerateOneConfig["data"]) => Promise<{
|
|
54
|
+
hasTests: boolean;
|
|
55
|
+
diagnostics: Record<string, import("./optimizer-types").Diagnostic[]> | undefined;
|
|
56
|
+
}>;
|
|
42
57
|
};
|
|
43
58
|
declare type RemovePromise<T> = T extends Promise<infer U> ? U : T;
|
|
44
59
|
export declare type WorkerTaskResult<T> = T extends WorkerTask ? RemovePromise<ReturnType<typeof workerTaskHandlers[T["type"]]>> : never;
|