@markw65/monkeyc-optimizer 1.1.34 → 1.1.35

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +959 -0
  2. package/README.md +9 -1
  3. package/build/api.cjs +31 -31
  4. package/build/{chunk-QBCVUVLD.cjs → chunk-Q5WTV4CN.cjs} +944 -2248
  5. package/build/optimizer.cjs +17 -17
  6. package/build/sdk-util.cjs +14 -14
  7. package/build/src/api.d.ts +1 -1
  8. package/build/src/type-flow/types.d.ts +1 -1
  9. package/build/worker-thread.cjs +3 -3
  10. package/package.json +2 -1
  11. package/build/src/readprg/switch.d.ts +0 -5
  12. package/build/src/src/api.d.ts +0 -51
  13. package/build/src/src/ast.d.ts +0 -59
  14. package/build/src/src/build.d.ts +0 -7
  15. package/build/src/src/cftinfo.d.ts +0 -32
  16. package/build/src/src/control-flow.d.ts +0 -22
  17. package/build/src/src/data-flow.d.ts +0 -107
  18. package/build/src/src/driver.d.ts +0 -2
  19. package/build/src/src/function-info.d.ts +0 -14
  20. package/build/src/src/inliner.d.ts +0 -13
  21. package/build/src/src/jungles.d.ts +0 -66
  22. package/build/src/src/launch.d.ts +0 -5
  23. package/build/src/src/logger.d.ts +0 -6
  24. package/build/src/src/manifest.d.ts +0 -11
  25. package/build/src/src/mc-rewrite.d.ts +0 -13
  26. package/build/src/src/negative-fixups.d.ts +0 -1
  27. package/build/src/src/optimizer-types.d.ts +0 -249
  28. package/build/src/src/optimizer.d.ts +0 -100
  29. package/build/src/src/pragma-checker.d.ts +0 -3
  30. package/build/src/src/pre.d.ts +0 -2
  31. package/build/src/src/projects.d.ts +0 -26
  32. package/build/src/src/readprg/array-init.d.ts +0 -3
  33. package/build/src/src/readprg/bytecode.d.ts +0 -72
  34. package/build/src/src/readprg/cflow.d.ts +0 -17
  35. package/build/src/src/readprg/data.d.ts +0 -4
  36. package/build/src/src/readprg/dce.d.ts +0 -6
  37. package/build/src/src/readprg/emit.d.ts +0 -23
  38. package/build/src/src/readprg/exceptions.d.ts +0 -10
  39. package/build/src/src/readprg/header.d.ts +0 -15
  40. package/build/src/src/readprg/interp.d.ts +0 -21
  41. package/build/src/src/readprg/linenum.d.ts +0 -29
  42. package/build/src/src/readprg/locals.d.ts +0 -3
  43. package/build/src/src/readprg/opcodes.d.ts +0 -279
  44. package/build/src/src/readprg/optimize.d.ts +0 -3
  45. package/build/src/src/readprg/pre.d.ts +0 -2
  46. package/build/src/src/readprg/sharing.d.ts +0 -2
  47. package/build/src/src/readprg/signer.d.ts +0 -8
  48. package/build/src/src/readprg/symbols.d.ts +0 -19
  49. package/build/src/src/readprg.d.ts +0 -25
  50. package/build/src/src/resources.d.ts +0 -12
  51. package/build/src/src/sdk-util.d.ts +0 -28
  52. package/build/src/src/type-flow/could-be.d.ts +0 -5
  53. package/build/src/src/type-flow/dead-store.d.ts +0 -18
  54. package/build/src/src/type-flow/interp-binary.d.ts +0 -4
  55. package/build/src/src/type-flow/interp-call.d.ts +0 -16
  56. package/build/src/src/type-flow/interp.d.ts +0 -33
  57. package/build/src/src/type-flow/intersection-type.d.ts +0 -4
  58. package/build/src/src/type-flow/minimize-locals.d.ts +0 -4
  59. package/build/src/src/type-flow/minimize-modules.d.ts +0 -3
  60. package/build/src/src/type-flow/optimize.d.ts +0 -7
  61. package/build/src/src/type-flow/sub-type.d.ts +0 -2
  62. package/build/src/src/type-flow/type-flow-util.d.ts +0 -27
  63. package/build/src/src/type-flow/types.d.ts +0 -204
  64. package/build/src/src/type-flow/union-type.d.ts +0 -4
  65. package/build/src/src/type-flow.d.ts +0 -18
  66. package/build/src/src/unused-exprs.d.ts +0 -3
  67. package/build/src/src/util.d.ts +0 -33
  68. package/build/src/src/variable-renamer.d.ts +0 -4
  69. package/build/src/src/visitor.d.ts +0 -5
  70. package/build/src/src/worker-pool.d.ts +0 -4
  71. package/build/src/src/worker-task.d.ts +0 -88
  72. package/build/src/src/worker-thread.d.ts +0 -1
  73. package/build/src/src/xml-util.d.ts +0 -172
  74. package/build/src/test/mocha/bytecode.spec.d.ts +0 -1
  75. package/build/src/test/mocha/coudbe.spec.d.ts +0 -2
  76. package/build/src/test/mocha/intersection.spec.d.ts +0 -2
  77. package/build/src/test/mocha/root.spec.d.ts +0 -1
  78. package/build/src/test/mocha/subtype.spec.d.ts +0 -2
  79. package/build/src/test/mocha/test-utils.d.ts +0 -6
  80. package/build/src/test/mocha/types.spec.d.ts +0 -1
@@ -1,249 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { EnumStringMember } from "@markw65/prettier-plugin-monkeyc/build/estree-types";
3
- import { xmlUtil } from "./sdk-util";
4
- import { ExactOrUnion } from "./type-flow/types";
5
- export type DiagnosticType = "ERROR" | "WARNING" | "INFO";
6
- export type LookupRules = "COMPILER1" | "COMPILER2" | "DEFAULT";
7
- export type EnforceStatic = "YES" | "NO";
8
- export type BuildConfig = {
9
- workspace?: string;
10
- jungleFiles?: string;
11
- developerKeyPath?: string;
12
- typeCheckLevel?: string;
13
- optimizationLevel?: string;
14
- compilerOptions?: string;
15
- compilerWarnings?: boolean;
16
- simulatorBuild?: boolean;
17
- releaseBuild?: boolean;
18
- testBuild?: boolean;
19
- products?: string[];
20
- buildDir?: string;
21
- outputPath?: string;
22
- program?: string;
23
- skipOptimization?: boolean;
24
- checkManifest?: boolean;
25
- device?: string;
26
- ignoredExcludeAnnotations?: string;
27
- ignoredAnnotations?: string;
28
- ignoredSourcePaths?: string;
29
- returnCommand?: boolean;
30
- checkBuildPragmas?: boolean;
31
- checkInvalidSymbols?: DiagnosticType | "OFF";
32
- checkCompilerLookupRules?: DiagnosticType | "OFF";
33
- compilerLookupRules?: LookupRules;
34
- enforceStatic?: EnforceStatic;
35
- sizeBasedPRE?: boolean | string;
36
- prettier?: Record<string, unknown>;
37
- extensionVersion?: string;
38
- useLocalOptimizer?: boolean;
39
- propagateTypes?: boolean;
40
- trustDeclaredTypes?: boolean;
41
- minimizeLocals?: boolean;
42
- minimizeModules?: boolean;
43
- postBuildOptimizer?: boolean;
44
- singleUseCopyProp?: boolean;
45
- iterateOptimizer?: boolean;
46
- covarianceWarnings?: boolean;
47
- checkTypes?: DiagnosticType | "OFF";
48
- removeArgc?: boolean;
49
- postBuildPRE?: boolean;
50
- };
51
- export type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier;
52
- export type StateNodeDecls = {
53
- [key: string]: StateNodeDecl[];
54
- };
55
- export type ImportUsing = {
56
- node: mctree.Using | mctree.ImportModule;
57
- module?: ModuleStateNode | null | undefined;
58
- };
59
- export declare const enum StateNodeAttributes {
60
- NONE = 0,
61
- PUBLIC = 1,
62
- PROTECTED = 2,
63
- PRIVATE = 4,
64
- STATIC = 8
65
- }
66
- interface BaseStateNode {
67
- type: string;
68
- node: mctree.Node | null | undefined;
69
- name: string | null | undefined;
70
- fullName: string | null | undefined;
71
- decls?: StateNodeDecls | undefined;
72
- type_decls?: StateNodeDecls | undefined;
73
- stack?: ProgramStateStack | undefined;
74
- attributes: StateNodeAttributes;
75
- }
76
- export interface ProgramStateNode extends BaseStateNode {
77
- type: "Program";
78
- node: mctree.Program | undefined;
79
- name: "$";
80
- fullName: "$";
81
- stack?: undefined;
82
- }
83
- export interface ModuleStateNode extends BaseStateNode {
84
- type: "ModuleDeclaration";
85
- node: mctree.ModuleDeclaration;
86
- name: string;
87
- fullName: string;
88
- }
89
- export interface ClassStateNode extends BaseStateNode {
90
- type: "ClassDeclaration";
91
- node: mctree.ClassDeclaration;
92
- name: string;
93
- fullName: string;
94
- superClass?: ClassStateNode[] | true;
95
- hasInvoke?: boolean;
96
- superClasses?: Set<StateNode>;
97
- }
98
- export type FunctionInfo = {
99
- modifiedDecls: Set<VariableStateNode>;
100
- calledFuncs: Set<FunctionStateNode>;
101
- resolvedDecls?: Set<VariableStateNode>;
102
- callsExposed?: boolean;
103
- modifiedUnknown?: boolean;
104
- modifiedNames?: Set<string>;
105
- };
106
- export interface FunctionStateNode extends BaseStateNode {
107
- type: "FunctionDeclaration";
108
- node: mctree.FunctionDeclaration;
109
- name: string;
110
- fullName: string;
111
- stack?: ProgramStateStack;
112
- decls?: undefined;
113
- info?: FunctionInfo | false;
114
- next_info?: FunctionInfo;
115
- }
116
- export interface BlockStateNode extends BaseStateNode {
117
- type: "BlockStatement";
118
- name: undefined;
119
- fullName: string;
120
- node: mctree.BlockStatement | mctree.ForStatement;
121
- stack?: undefined;
122
- }
123
- export interface TypedefStateNode extends BaseStateNode {
124
- type: "TypedefDeclaration";
125
- node: mctree.TypedefDeclaration;
126
- name: string;
127
- fullName: string;
128
- isExpanding?: true;
129
- isRecursive?: true;
130
- resolvedType?: ExactOrUnion;
131
- }
132
- export interface VariableStateNode extends BaseStateNode {
133
- type: "VariableDeclarator";
134
- node: mctree.VariableDeclarator;
135
- name: string;
136
- fullName: string;
137
- stack: ProgramStateStack;
138
- used?: true;
139
- resolvedType?: ExactOrUnion | undefined;
140
- }
141
- export interface EnumStateNode extends BaseStateNode {
142
- type: "EnumDeclaration";
143
- node: mctree.EnumDeclaration;
144
- name: string;
145
- fullName: string;
146
- stack: ProgramStateStack;
147
- resolvedType?: ExactOrUnion;
148
- }
149
- interface DiagnosticBase {
150
- loc: mctree.SourceLocation;
151
- message: string;
152
- }
153
- export interface DiagnosticInfo extends DiagnosticBase {
154
- loc: Finalized<mctree.SourceLocation, "source">;
155
- }
156
- export interface Diagnostic extends DiagnosticBase {
157
- type: DiagnosticType;
158
- related?: DiagnosticInfo[];
159
- extra?: {
160
- uri: string;
161
- message: string;
162
- };
163
- }
164
- type ProgramStateStackElem = {
165
- sn: StateNode;
166
- usings?: Record<string, ImportUsing>;
167
- imports?: ImportUsing[];
168
- };
169
- export type StateNode = ProgramStateNode | FunctionStateNode | BlockStateNode | ClassStateNode | ModuleStateNode | TypedefStateNode | VariableStateNode | EnumStateNode;
170
- export type ProgramStateStack = ProgramStateStackElem[];
171
- export type LookupDefinition = {
172
- parent: StateNode | null;
173
- results: StateNodeDecl[];
174
- };
175
- export type LookupResult = [string, LookupDefinition[]] | [null, null] | [false, false];
176
- export type ByNameStateNodeDecls = ModuleStateNode | ClassStateNode | FunctionStateNode | ProgramStateNode;
177
- export type ProgramState = {
178
- allFunctions?: Record<string, FunctionStateNode[]>;
179
- allClasses?: ClassStateNode[];
180
- invokeInfo?: FunctionInfo;
181
- allDeclarations?: Record<string, ByNameStateNodeDecls[]>;
182
- fnMap?: FilesToOptimizeMap;
183
- rezAst?: mctree.Program;
184
- manifestXML?: xmlUtil.Document;
185
- stack?: ProgramStateStack;
186
- top?: () => ProgramStateStackElem;
187
- currentFunction?: FunctionStateNode;
188
- removeNodeComments?: (node: mctree.Node, ast: mctree.Program) => void;
189
- shouldExclude?: (node: mctree.Node) => boolean;
190
- pre?: (node: mctree.Node, state: ProgramStateLive) => null | false | (keyof mctree.NodeAll)[];
191
- post?: (node: mctree.Node, state: ProgramStateLive) => null | false | mctree.Node | mctree.Node[];
192
- lookup?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack | null) => LookupResult;
193
- lookupValue?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack | null) => LookupResult;
194
- lookupType?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack | null) => LookupResult;
195
- lookupNonlocal?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack | null) => LookupResult;
196
- stackClone?: () => ProgramStateStack;
197
- traverse?: (node: mctree.Node) => void | null | false | mctree.Node | mctree.Node[];
198
- inType?: number;
199
- inlining?: true;
200
- config?: BuildConfig;
201
- sdk?: string;
202
- sdkVersion?: number;
203
- lookupRules?: LookupRules;
204
- nextExposed?: Record<string, true>;
205
- exposed?: Record<string, true>;
206
- usedByName?: Record<string, true>;
207
- calledFunctions?: {
208
- [key: string]: mctree.FunctionDeclaration[];
209
- };
210
- localsStack?: {
211
- node?: mctree.Node;
212
- map?: {
213
- [key: string]: boolean | string;
214
- };
215
- inners?: {
216
- [key: string]: true;
217
- };
218
- }[];
219
- index?: {
220
- [key: string]: unknown[];
221
- };
222
- constants?: {
223
- [key: string]: mctree.Literal;
224
- };
225
- diagnostics?: Record<string, Diagnostic[]>;
226
- inlineDiagnostics?: Record<string, Diagnostic[]>;
227
- enumMap?: Map<EnumStringMember, EnumStateNode>;
228
- };
229
- export type Finalized<T, Keys extends keyof T> = T & {
230
- [key in Keys]-?: NonNullable<T[key]>;
231
- };
232
- export type ProgramStateLive = Finalized<ProgramState, "stack" | "top" | "lookup" | "lookupValue" | "lookupType" | "lookupNonlocal" | "stackClone" | "traverse" | "index" | "constants" | "removeNodeComments" | "inType" | "nextExposed" | "lookupRules">;
233
- export type ProgramStateAnalysis = Finalized<ProgramStateLive, "allClasses" | "allFunctions" | "fnMap" | "allDeclarations" | "invokeInfo">;
234
- export type ProgramStateOptimizer = Finalized<ProgramStateAnalysis, "localsStack" | "exposed" | "calledFunctions" | "usedByName">;
235
- export type ExcludeAnnotationsMap = {
236
- [key: string]: boolean;
237
- };
238
- export type FilesToOptimizeMap = {
239
- [key: string]: {
240
- output: string;
241
- barrel: string;
242
- excludeAnnotations: ExcludeAnnotationsMap;
243
- monkeyCSource?: string;
244
- ast?: mctree.Program;
245
- parserError?: Error;
246
- hasTests?: boolean;
247
- };
248
- };
249
- export {};
@@ -1,100 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { get_jungle, JungleBuildDependencies, JungleError, JungleQualifier, JungleResourceMap, ResolvedJungle, Target } from "./jungles";
3
- import { launchSimulator, simulateProgram } from "./launch";
4
- import { manifestProducts } from "./manifest";
5
- import { BuildConfig, FilesToOptimizeMap, ProgramState, ProgramStateAnalysis } from "./optimizer-types";
6
- import { xmlUtil } from "./sdk-util";
7
- import { TypeMap } from "./type-flow/interp";
8
- import { copyRecursiveAsNeeded } from "./util";
9
- export * from "./optimizer-types";
10
- export { display, ExactOrUnion } from "./type-flow/types";
11
- export { copyRecursiveAsNeeded, get_jungle, JungleBuildDependencies, JungleError, JungleResourceMap, launchSimulator, manifestProducts, mctree, ResolvedJungle, simulateProgram, TypeMap, };
12
- export declare const defaultConfig: {
13
- outputPath: string;
14
- workspace: string;
15
- };
16
- export interface ErrorWithLocation extends Error {
17
- location?: NonNullable<mctree.Node["loc"]>;
18
- }
19
- export declare function isErrorWithLocation(e: Error): e is ErrorWithLocation;
20
- declare global {
21
- var lastModifiedSource: number;
22
- }
23
- /**
24
- * @param {BuildConfig} options
25
- * @returns {Promise<BuildConfig>}
26
- */
27
- export declare function getConfig(options: BuildConfig): Promise<BuildConfig>;
28
- /**
29
- *
30
- * WARNING WARNING WARNING WARNING WARNING WARNING
31
- *
32
- * prettier-extension-monkeyc can dynamically import this
33
- * function from a local copy of @markw65/monkeyc-optimizer,
34
- * rather than using the version that ships with the
35
- * extension.
36
- *
37
- * For this to work, buildOptimizedProject's signature cannot
38
- * change (or at least, can only change in a backward compatible
39
- * way).
40
- *
41
- * DON'T CHANGE THIS FUNCTION's SIGNATURE
42
- *
43
- * @param {string | null} product
44
- * @param {BuildConfig} options
45
- * @returns
46
- */
47
- export declare function buildOptimizedProject(product: string | null, options: BuildConfig): Promise<{
48
- exe: string;
49
- args: string[];
50
- program: string;
51
- product: string | null;
52
- hasTests: boolean;
53
- diagnostics: Record<string, import("./optimizer-types").Diagnostic[]> | undefined;
54
- }>;
55
- export declare function generateOptimizedProject(options: BuildConfig): Promise<{
56
- jungleFiles: string | undefined;
57
- xml: xmlUtil.Document;
58
- program: string;
59
- hasTests: boolean;
60
- diagnostics?: undefined;
61
- } | {
62
- jungleFiles: string;
63
- xml: xmlUtil.Document;
64
- program: string;
65
- hasTests: boolean;
66
- diagnostics: Record<string, import("./optimizer-types").Diagnostic[]>;
67
- }>;
68
- export type PreAnalysis = {
69
- fnMap: FilesToOptimizeMap;
70
- paths: string[];
71
- };
72
- declare type RequiredNonNull<T> = {
73
- [K1 in keyof T]-?: {
74
- [K2 in keyof T[K1]]-?: NonNullable<T[K1][K2]>;
75
- };
76
- };
77
- export type Analysis = {
78
- fnMap: RequiredNonNull<FilesToOptimizeMap>;
79
- paths: string[];
80
- state: ProgramStateAnalysis;
81
- typeMap?: TypeMap | null | undefined;
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
- sdkVersion: number | undefined;
93
- }>;
94
- export declare function getProjectAnalysis(targets: Target[], analysis: PreAnalysis | null, manifestXML: xmlUtil.Document, options: BuildConfig): Promise<Analysis | PreAnalysis>;
95
- /**
96
- *
97
- * @param {BuildConfig} options
98
- * @returns
99
- */
100
- export declare function generateApiMirTests(options: BuildConfig): Promise<void>;
@@ -1,3 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { ProgramState, ProgramStateOptimizer } from "./optimizer-types";
3
- export declare function pragmaChecker(state: ProgramStateOptimizer, ast: mctree.Program, diagnostics: NonNullable<ProgramState["diagnostics"]>[string] | null | undefined): void;
@@ -1,2 +0,0 @@
1
- import { FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
2
- export declare function sizeBasedPRE(state: ProgramStateAnalysis, func: FunctionStateNode): void;
@@ -1,26 +0,0 @@
1
- import { BuildConfig } from "./optimizer-types";
2
- export type RemoteProject = string | {
3
- root: string;
4
- options?: BuildConfig;
5
- rename?: {
6
- from: string;
7
- to: string;
8
- }[];
9
- build?: boolean;
10
- comment?: string;
11
- exclude?: string;
12
- include?: string;
13
- sourcePath?: string;
14
- jungleContent?: string[];
15
- garminOptLevel?: number;
16
- test?: boolean | string[];
17
- branch?: string;
18
- };
19
- export declare const githubProjects: RemoteProject[];
20
- export declare function fetchGitProjects(projects: RemoteProject[], testOnly: boolean, skipRemote: boolean): Promise<(string | {
21
- jungle: string;
22
- build: boolean | null;
23
- options: BuildConfig | null;
24
- garminOptLevel: number | null;
25
- products: string[] | null;
26
- })[]>;
@@ -1,3 +0,0 @@
1
- import { Block, Context, FuncEntry } from "./bytecode";
2
- import { InterpState } from "./interp";
3
- export declare function optimizeArrayInit(func: FuncEntry, block: Block, index: number, context: Context, interpState: InterpState | null): boolean;
@@ -1,72 +0,0 @@
1
- /// <reference types="node" />
2
- import * as crypto from "node:crypto";
3
- import { BuildConfig } from "../optimizer-types";
4
- import { xmlUtil } from "../sdk-util";
5
- import { ExceptionEntry, ExceptionsMap } from "./exceptions";
6
- import { Header } from "./header";
7
- import { LineNumber } from "./linenum";
8
- import { Bytecode, Opcodes } from "./opcodes";
9
- import { SymbolTable } from "./symbols";
10
- export declare const enum SectionKinds {
11
- HEADER = -805253120,
12
- TEXT = -1059145026,
13
- DATA = -629491010,
14
- SYMBOLS = 1461170197,
15
- LINENUM = -1059161423,
16
- EXCEPTIONS = 248410373,
17
- SIGNATURE = -507453934,
18
- STORE_SIG = 20833
19
- }
20
- export type SectionInfo = {
21
- offset: number;
22
- length: number;
23
- view: DataView;
24
- };
25
- export type Logger = (module: string, level: number, message: string) => void;
26
- export type Context = {
27
- config: BuildConfig;
28
- filepath: string;
29
- sections: Record<number, SectionInfo>;
30
- header: Header;
31
- symbolTable: SymbolTable;
32
- lineTable: Map<number, LineNumber>;
33
- exceptionsMap: ExceptionsMap;
34
- bytecodes: Bytecode[];
35
- key?: crypto.KeyObject;
36
- debugXml: xmlUtil.Document;
37
- nextOffset: number;
38
- nextLocalId: number;
39
- };
40
- export type Block = {
41
- offset: number;
42
- bytecodes: Bytecode[];
43
- try?: ExceptionEntry[];
44
- next?: number;
45
- taken?: number;
46
- exsucc?: number;
47
- preds?: Set<number>;
48
- };
49
- export type FuncEntry = {
50
- name?: string;
51
- offset: number;
52
- argc?: number;
53
- blocks: Map<number, Block>;
54
- };
55
- export declare function offsetToString(offset: number): string;
56
- export declare function fixSectionSize(section: SectionKinds, sections: Context["sections"], newSize: number): void;
57
- export declare function optimizeBytecode(context: Context): void;
58
- export declare function functionBanner(func: FuncEntry, context: Context | null, pass: string, extra?: (block: Block, footer: boolean) => string): () => string;
59
- export declare function printFunction(func: FuncEntry, context: Context | null): void;
60
- export declare function functionToString(func: FuncEntry, context: Context | null, extra?: (block: Block, footer: boolean) => string): string;
61
- export declare function blockToString(block: Block, context: Context | null): string;
62
- export declare function lineInfoToString(lineInfo: LineNumber, context: Context | null): string;
63
- export declare function bytecodeToString(bytecode: Bytecode, symbolTable: SymbolTable | null | undefined): string;
64
- export declare function findFunctions({ bytecodes, symbolTable, exceptionsMap, }: Context): Map<number, FuncEntry>;
65
- export declare function makeArgless(bc: Bytecode, op: Opcodes): void;
66
- export declare function equalBlocks(b1: Block, b2: Block): boolean;
67
- export declare function removeBlock(func: FuncEntry, offset: number): void;
68
- export declare function removePred(func: FuncEntry, target: number, pred: number): void;
69
- export declare function addPred(func: FuncEntry, target: number, pred: number): void;
70
- export declare function redirect(func: FuncEntry, block: Block, from: number, to: number | null | undefined): boolean;
71
- export declare function splitBlock(func: FuncEntry, block: Block, offset: number): void;
72
- export declare function countFallthroughPreds(func: FuncEntry, block: Block): number;
@@ -1,17 +0,0 @@
1
- import { Block, FuncEntry } from "./bytecode";
2
- import { Bytecode } from "./opcodes";
3
- export declare function postOrderTraverse(func: FuncEntry, visitor: (block: Block) => void): void;
4
- export declare function intersect<T>(a: Set<T>, b: Set<T>): Set<T>;
5
- export type DomLike = Map<number, Set<number>>;
6
- export declare function computePostDominators(func: FuncEntry): DomLike;
7
- export declare function computeDominators(func: FuncEntry): DomLike;
8
- 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;
9
- export declare const enum RpoFlags {
10
- Nothing = 0,
11
- EnqueueTaken = 1,
12
- EnqueueNext = 2,
13
- SkipTaken = 4,
14
- SkipNext = 8,
15
- RestartBlock = 16
16
- }
17
- export declare function rpoPropagate<T>(func: FuncEntry, preBlock: (block: Block) => T, processBc: ((block: Block, bc: Bytecode, state: T) => RpoFlags | null | undefined | void) | null, postBlock: (block: Block, state: T) => void, merge: (from: Block, state: T, succBlock: Block, isExSucc: boolean) => boolean): void;
@@ -1,4 +0,0 @@
1
- import { Context } from "./bytecode";
2
- import { SymbolTable } from "./symbols";
3
- export declare function parseData(view: DataView, symbols: SymbolTable): void;
4
- export declare function fixupData(context: Context, offsetMap: Map<number, number>): void;
@@ -1,6 +0,0 @@
1
- import { Context, FuncEntry } from "./bytecode";
2
- export declare function localDCE(func: FuncEntry, context: Context): boolean;
3
- export declare function computeLiveLocals(func: FuncEntry): {
4
- liveInLocals: Map<number, Set<number>>;
5
- liveOutLocals: Map<number, Set<number>>;
6
- };
@@ -1,23 +0,0 @@
1
- import { Context, FuncEntry } from "./bytecode";
2
- import { ExceptionsMap } from "./exceptions";
3
- import { LineNumber } from "./linenum";
4
- type LocalXmlInfo = {
5
- name: string;
6
- startPc: number;
7
- endPc: number;
8
- isParam: boolean;
9
- slot: number;
10
- id: number;
11
- };
12
- export type LocalsMap = Map<number, {
13
- startPc: number;
14
- endPc: number;
15
- }>;
16
- export type UpdateInfo = {
17
- offsetMap: Map<number, number>;
18
- localRanges: LocalXmlInfo[];
19
- lineMap: LineNumber[];
20
- exceptionsMap: ExceptionsMap;
21
- };
22
- export declare function emitFunc(func: FuncEntry, view: DataView, start: number, updateInfo: UpdateInfo, context: Context): number;
23
- export {};
@@ -1,10 +0,0 @@
1
- import { Context } from "./bytecode";
2
- import { UpdateInfo } from "./emit";
3
- export type ExceptionEntry = {
4
- tryStart: number;
5
- tryEnd: number;
6
- handler: number;
7
- };
8
- export type ExceptionsMap = Map<number, ExceptionEntry[]>;
9
- export declare function parseExceptions(view: DataView): ExceptionsMap;
10
- export declare function fixupExceptions(context: Context, updateInfo: UpdateInfo): void;
@@ -1,15 +0,0 @@
1
- import { Context } from "./bytecode";
2
- import { UpdateInfo } from "./emit";
3
- export type SectionOffset = {
4
- data: number;
5
- code: number;
6
- };
7
- export type Header = {
8
- ciqVersion: number;
9
- backgroundOffsets: SectionOffset;
10
- appLock: boolean;
11
- glanceOffsets: SectionOffset;
12
- flags: number;
13
- };
14
- export declare function parseHeader(view: DataView): Header;
15
- export declare function fixupHeader(context: Context, updateInfo: UpdateInfo): void;
@@ -1,21 +0,0 @@
1
- import { ExactOrUnion } from "../optimizer";
2
- import { Context, FuncEntry } from "./bytecode";
3
- import { Bytecode, Lputv } from "./opcodes";
4
- interface InterpItemInfo {
5
- type: ExactOrUnion;
6
- equivs?: Set<number>;
7
- }
8
- export type InterpState = {
9
- stack: InterpItemInfo[];
10
- locals: InterpItemInfo[];
11
- loopBlock?: true;
12
- };
13
- export declare function cloneState(state: InterpState | null | undefined): InterpState;
14
- export declare function interpBytecode(bc: Bytecode, localState: InterpState, context: Context): void;
15
- export declare function interpFunc(func: FuncEntry, context: Context): {
16
- liveInState: Map<number, InterpState>;
17
- equivSets: Map<Lputv, Set<number>>;
18
- changes: number;
19
- };
20
- export declare function instForType(type: ExactOrUnion, offset: number): Bytecode | null;
21
- export {};
@@ -1,29 +0,0 @@
1
- import { xmlUtil } from "../sdk-util";
2
- import { Context } from "./bytecode";
3
- import { UpdateInfo } from "./emit";
4
- interface BaseLineNumber {
5
- pc: number;
6
- file?: number | undefined;
7
- fileStr?: string | undefined;
8
- symbol?: number | undefined;
9
- symbolStr?: string | undefined;
10
- line: number;
11
- }
12
- interface LineNumberSym extends BaseLineNumber {
13
- file: number;
14
- symbol: number;
15
- fileStr?: undefined;
16
- symbolStr?: undefined;
17
- }
18
- interface LineNumberStr extends BaseLineNumber {
19
- file?: undefined;
20
- symbol?: undefined;
21
- fileStr: string;
22
- symbolStr: string;
23
- parent?: string | undefined;
24
- id: number;
25
- }
26
- export type LineNumber = LineNumberStr | LineNumberSym;
27
- export declare function parseLineNum(view: DataView, debugXml: xmlUtil.Document): Map<number, LineNumber>;
28
- export declare function fixupLineNum(context: Context, updateInfo: UpdateInfo): void;
29
- export {};
@@ -1,3 +0,0 @@
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;