@markw65/monkeyc-optimizer 1.1.25 → 1.1.27
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 +28 -0
- package/bin/cft-font-info.js +63 -0
- package/build/api.cjs +36 -34
- package/build/cftinfo.cjs +112 -0
- package/build/chunk-ABYVSU2C.cjs +74 -0
- package/build/{chunk-SNWJ2FZL.cjs → chunk-DD4VX53Y.cjs} +1052 -1160
- package/build/chunk-MBTLUWXR.cjs +375 -0
- package/build/{chunk-QFQPBQSO.cjs → chunk-PVBIKZYZ.cjs} +110 -153
- package/build/optimizer.cjs +21 -19
- package/build/sdk-util.cjs +17 -15
- package/build/src/api.d.ts +1 -1
- package/build/src/ast.d.ts +1 -1
- package/build/src/cftinfo.d.ts +32 -0
- package/build/src/control-flow.d.ts +3 -3
- package/build/src/data-flow.d.ts +5 -5
- package/build/src/inliner.d.ts +2 -2
- package/build/src/jungles.d.ts +16 -12
- package/build/src/manifest.d.ts +1 -1
- package/build/src/optimizer-types.d.ts +25 -22
- package/build/src/optimizer.d.ts +2 -2
- package/build/src/projects.d.ts +1 -1
- package/build/src/readprg/bytecode.d.ts +5 -5
- package/build/src/readprg/cflow.d.ts +3 -2
- package/build/src/readprg/emit.d.ts +3 -3
- package/build/src/readprg/exceptions.d.ts +2 -2
- package/build/src/readprg/header.d.ts +2 -2
- package/build/src/readprg/interp.d.ts +1 -1
- package/build/src/readprg/linenum.d.ts +1 -1
- package/build/src/readprg/opcodes.d.ts +2 -2
- package/build/src/resources.d.ts +2 -2
- package/build/src/sdk-util.d.ts +1 -1
- package/build/src/type-flow/dead-store.d.ts +1 -1
- package/build/src/type-flow/interp-call.d.ts +2 -2
- package/build/src/type-flow/interp.d.ts +4 -3
- package/build/src/type-flow/type-flow-util.d.ts +1 -1
- package/build/src/type-flow/types.d.ts +18 -18
- package/build/src/type-flow.d.ts +1 -1
- package/build/src/util.d.ts +1 -1
- package/build/src/worker-task.d.ts +3 -3
- package/build/src/xml-util.d.ts +9 -9
- package/build/util.cjs +25 -24
- package/build/worker-thread.cjs +7 -7
- package/package.json +14 -9
package/build/optimizer.cjs
CHANGED
|
@@ -18,27 +18,29 @@ 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: () =>
|
|
23
|
-
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: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_DD4VX53Y.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_DD4VX53Y.buildOptimizedProject,
|
|
23
|
+
copyRecursiveAsNeeded: () => import_chunk_PVBIKZYZ.copyRecursiveAsNeeded,
|
|
24
|
+
defaultConfig: () => import_chunk_DD4VX53Y.defaultConfig,
|
|
25
|
+
display: () => import_chunk_DD4VX53Y.display,
|
|
26
|
+
generateApiMirTests: () => import_chunk_DD4VX53Y.generateApiMirTests,
|
|
27
|
+
generateOneConfig: () => import_chunk_DD4VX53Y.generateOneConfig,
|
|
28
|
+
generateOptimizedProject: () => import_chunk_DD4VX53Y.generateOptimizedProject,
|
|
29
|
+
getConfig: () => import_chunk_DD4VX53Y.getConfig,
|
|
30
|
+
getProjectAnalysis: () => import_chunk_DD4VX53Y.getProjectAnalysis,
|
|
31
|
+
get_jungle: () => import_chunk_DD4VX53Y.get_jungle,
|
|
32
|
+
isErrorWithLocation: () => import_chunk_DD4VX53Y.isErrorWithLocation,
|
|
33
|
+
launchSimulator: () => import_chunk_DD4VX53Y.launchSimulator,
|
|
34
|
+
manifestProducts: () => import_chunk_DD4VX53Y.manifestProducts,
|
|
35
|
+
mctree: () => import_chunk_DD4VX53Y.mctree,
|
|
36
|
+
simulateProgram: () => import_chunk_DD4VX53Y.simulateProgram
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(optimizer_exports);
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
(
|
|
39
|
+
var import_chunk_DD4VX53Y = require("./chunk-DD4VX53Y.cjs");
|
|
40
|
+
var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
|
|
41
|
+
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
42
|
+
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
43
|
+
(0, import_chunk_DD4VX53Y.init_optimizer)();
|
|
42
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
45
|
0 && (module.exports = {
|
|
44
46
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,23 +18,25 @@ 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_DD4VX53Y.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_DD4VX53Y.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_DD4VX53Y.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_DD4VX53Y.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_DD4VX53Y.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_DD4VX53Y.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_DD4VX53Y.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_DD4VX53Y.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_DD4VX53Y.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_DD4VX53Y.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_DD4VX53Y.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_DD4VX53Y.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
(
|
|
35
|
+
var import_chunk_DD4VX53Y = require("./chunk-DD4VX53Y.cjs");
|
|
36
|
+
var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
|
|
37
|
+
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
38
|
+
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
+
(0, import_chunk_DD4VX53Y.init_sdk_util)();
|
|
38
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
41
|
0 && (module.exports = {
|
|
40
42
|
SectionKinds,
|
package/build/src/api.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function isStateNode(node: {
|
|
|
14
14
|
type: string;
|
|
15
15
|
}): node is StateNode;
|
|
16
16
|
export declare function variableDeclarationName(node: mctree.TypedIdentifier | mctree.InstanceofIdentifier): string;
|
|
17
|
-
|
|
17
|
+
type DeclKind = "decls" | "type_decls";
|
|
18
18
|
export declare function sameLookupResult(a: LookupDefinition[], b: LookupDefinition[]): boolean;
|
|
19
19
|
export declare function lookupResultContains(a: LookupDefinition[], b: LookupDefinition[]): boolean;
|
|
20
20
|
export declare function isLookupCandidate(node: mctree.MemberExpression): false | mctree.Identifier;
|
package/build/src/ast.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface BooleanLiteral extends mctree.Literal {
|
|
|
27
27
|
interface NullLiteral extends mctree.Literal {
|
|
28
28
|
value: null;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
type LiteralValues = [NumberLiteral, "Number" | "Float" | "Double"] | [LongLiteral, "Long"] | [StringLiteral, "String"] | [CharLiteral, "Char"] | [BooleanLiteral, "Boolean"] | [NullLiteral, "Null"];
|
|
31
31
|
export declare function getNodeValue(node: mctree.Literal): LiteralValues;
|
|
32
32
|
export declare function getNodeValue(node: mctree.Node): LiteralValues | [null, null];
|
|
33
33
|
export declare function wrap<T extends mctree.Node>(node: T, loc?: mctree.SourceLocation | null): T;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function getCFTFontInfoFromBuffer(name: string, data: Buffer): {
|
|
3
|
+
name: string;
|
|
4
|
+
height: number;
|
|
5
|
+
ascent: number;
|
|
6
|
+
internalLeading: number;
|
|
7
|
+
charInfo: {
|
|
8
|
+
code: number;
|
|
9
|
+
char: string;
|
|
10
|
+
width: number;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export declare function getCFTFontInfo(filename: string): Promise<{
|
|
14
|
+
name: string;
|
|
15
|
+
height: number;
|
|
16
|
+
ascent: number;
|
|
17
|
+
internalLeading: number;
|
|
18
|
+
charInfo: {
|
|
19
|
+
code: number;
|
|
20
|
+
char: string;
|
|
21
|
+
width: number;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
export declare function getDeviceFontInfo(dirname: string): Promise<{
|
|
25
|
+
device: string;
|
|
26
|
+
fontSets: {
|
|
27
|
+
[k: string]: {
|
|
28
|
+
[k: string]: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
langMap: Record<string, string>;
|
|
32
|
+
}>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
2
|
import { ProgramStateAnalysis, FunctionStateNode } from "./optimizer-types";
|
|
3
|
-
export
|
|
3
|
+
export type BaseEvent = {
|
|
4
4
|
type: string;
|
|
5
5
|
mayThrow: boolean;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
export
|
|
7
|
+
type EventConstraint<_T> = BaseEvent;
|
|
8
|
+
export type Block<T extends EventConstraint<T>> = {
|
|
9
9
|
node?: mctree.Node;
|
|
10
10
|
preds?: Block<T>[];
|
|
11
11
|
succs?: Block<T>[];
|
package/build/src/data-flow.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ 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
4
|
import { GenericQueue } from "./util";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type RefNode = mctree.Identifier | mctree.MemberExpression | mctree.Literal;
|
|
6
|
+
export type MemberDecl = {
|
|
7
7
|
type: "MemberDecl";
|
|
8
8
|
node: mctree.MemberExpression;
|
|
9
9
|
base: StateNodeDecl | StateNodeDecl[];
|
|
10
10
|
path: mctree.MemberExpression[];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type EventDecl = StateNodeDecl | StateNodeDecl[] | mctree.Literal | MemberDecl | {
|
|
13
13
|
type: "Unknown";
|
|
14
14
|
node: mctree.MemberExpression | mctree.Identifier | mctree.ThisExpression;
|
|
15
15
|
};
|
|
@@ -86,12 +86,12 @@ export interface FlowEventInstanceof extends BaseEvent {
|
|
|
86
86
|
right_decl: EventDecl;
|
|
87
87
|
right_node?: undefined;
|
|
88
88
|
}
|
|
89
|
-
export
|
|
89
|
+
export type FlowEvent = FlowEventDecl | FlowEventNode | FlowEventTruthy | FlowEventInstanceof;
|
|
90
90
|
export interface ExnEvent extends BaseEvent {
|
|
91
91
|
type: "exn";
|
|
92
92
|
node: mctree.Node;
|
|
93
93
|
}
|
|
94
|
-
export
|
|
94
|
+
export type Event = RefEvent | KillEvent | DefEvent | ModEvent | FlowEvent | ExnEvent;
|
|
95
95
|
export interface DataFlowBlock extends Block<Event> {
|
|
96
96
|
order?: number;
|
|
97
97
|
}
|
package/build/src/inliner.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import { FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
|
|
|
3
3
|
export declare function inlinableSubExpression(expr: mctree.Expression): mctree.SimpleCallExpression | null;
|
|
4
4
|
export declare function inlineRequested(state: ProgramStateAnalysis, func: FunctionStateNode): boolean;
|
|
5
5
|
export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): boolean;
|
|
6
|
-
|
|
6
|
+
type InlineBody = mctree.BlockStatement | mctree.ExpressionStatement["expression"];
|
|
7
7
|
export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"]): mctree.Statement[];
|
|
8
8
|
export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"], top: true): mctree.Statement[] | null;
|
|
9
9
|
export declare function inlineDiagnostic(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, message: string | null): void;
|
|
10
|
-
export
|
|
10
|
+
export type InlineContext = mctree.ReturnStatement | mctree.IfStatement | mctree.AssignmentExpression | mctree.ExpressionStatement | mctree.VariableDeclarator;
|
|
11
11
|
export declare function inlineFunction(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): InlineBody | null;
|
|
12
12
|
export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
|
|
13
13
|
export {};
|
package/build/src/jungles.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ManifestXML } from "./manifest";
|
|
2
2
|
import { BuildConfig } from "./optimizer-types.js";
|
|
3
3
|
import { DeviceInfo, xmlUtil } from "./sdk-util";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type JungleBuildDependencies = Record<string, xmlUtil.Document | true>;
|
|
5
|
+
export type JungleError = Error & {
|
|
6
6
|
buildDependencies?: JungleBuildDependencies;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type Target = {
|
|
9
9
|
product: string;
|
|
10
10
|
qualifier: JungleQualifier;
|
|
11
11
|
shape?: string;
|
|
@@ -15,34 +15,36 @@ export declare type Target = {
|
|
|
15
15
|
key: string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type LangResourcePaths = {
|
|
19
19
|
[key: string]: string[];
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
type BarrelAnnotations = {
|
|
22
22
|
[key: string]: string[];
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type BarrelMap = {
|
|
25
25
|
[key: string]: ResolvedBarrel;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
type OptBarrelMap = Record<string, {
|
|
28
28
|
rawBarrelDir: string;
|
|
29
29
|
manifest: string;
|
|
30
30
|
jungleFiles: string[];
|
|
31
31
|
optBarrelDir: string;
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
33
|
+
export type JungleQualifier = {
|
|
34
34
|
sourcePath?: string[];
|
|
35
35
|
sourceExcludes?: string[];
|
|
36
36
|
excludeAnnotations?: string[];
|
|
37
37
|
resourcePath?: string[];
|
|
38
|
+
personality?: string[];
|
|
38
39
|
lang?: LangResourcePaths;
|
|
39
40
|
barrelPath?: (string | string[])[];
|
|
40
41
|
annotations?: BarrelAnnotations;
|
|
41
42
|
barrelMap?: BarrelMap;
|
|
42
43
|
optBarrels?: OptBarrelMap;
|
|
43
44
|
resourceMap?: JungleResourceMap;
|
|
45
|
+
products?: string[];
|
|
44
46
|
};
|
|
45
|
-
|
|
47
|
+
type JungleInfoBase = {
|
|
46
48
|
jungles: string[];
|
|
47
49
|
manifest: string;
|
|
48
50
|
xml: ManifestXML;
|
|
@@ -51,11 +53,13 @@ declare type JungleInfoBase = {
|
|
|
51
53
|
buildDependencies: JungleBuildDependencies;
|
|
52
54
|
devices: DeviceInfo;
|
|
53
55
|
};
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
+
export type JungleResourceMap = Record<string, xmlUtil.Document>;
|
|
57
|
+
export type ResolvedJungle = JungleInfoBase & {
|
|
56
58
|
targets: Target[];
|
|
59
|
+
typeCheckLevel?: string;
|
|
60
|
+
optimizationLevel?: string;
|
|
57
61
|
};
|
|
58
|
-
export
|
|
62
|
+
export type ResolvedBarrel = JungleInfoBase & {
|
|
59
63
|
qualifier: JungleQualifier;
|
|
60
64
|
};
|
|
61
65
|
export declare function get_jungle(jungles: string, options: BuildConfig, resources?: JungleResourceMap | undefined): Promise<ResolvedJungle>;
|
package/build/src/manifest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { xmlUtil } from "./sdk-util";
|
|
2
|
-
export
|
|
2
|
+
export type ManifestXML = xmlUtil.Document;
|
|
3
3
|
export declare function readManifest(manifest: string): Promise<ManifestXML>;
|
|
4
4
|
export declare function writeManifest(filename: string, xml: ManifestXML): Promise<void>;
|
|
5
5
|
export declare function manifestProducts(manifest: ManifestXML): string[];
|
|
@@ -2,14 +2,15 @@ import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
|
2
2
|
import { EnumStringMember } from "@markw65/prettier-plugin-monkeyc/build/estree-types";
|
|
3
3
|
import { xmlUtil } from "./sdk-util";
|
|
4
4
|
import { ExactOrUnion } from "./type-flow/types";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
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
9
|
workspace?: string;
|
|
10
10
|
jungleFiles?: string;
|
|
11
11
|
developerKeyPath?: string;
|
|
12
12
|
typeCheckLevel?: string;
|
|
13
|
+
optimizationLevel?: string;
|
|
13
14
|
compilerOptions?: string;
|
|
14
15
|
compilerWarnings?: boolean;
|
|
15
16
|
simulatorBuild?: boolean;
|
|
@@ -47,15 +48,16 @@ export declare type BuildConfig = {
|
|
|
47
48
|
removeArgc?: boolean;
|
|
48
49
|
postBuildPRE?: boolean;
|
|
49
50
|
};
|
|
50
|
-
export
|
|
51
|
-
export
|
|
51
|
+
export type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier;
|
|
52
|
+
export type StateNodeDecls = {
|
|
52
53
|
[key: string]: StateNodeDecl[];
|
|
53
54
|
};
|
|
54
|
-
export
|
|
55
|
+
export type ImportUsing = {
|
|
55
56
|
node: mctree.Using | mctree.ImportModule;
|
|
56
57
|
module?: ModuleStateNode | null | undefined;
|
|
57
58
|
};
|
|
58
|
-
export declare enum StateNodeAttributes {
|
|
59
|
+
export declare const enum StateNodeAttributes {
|
|
60
|
+
NONE = 0,
|
|
59
61
|
PUBLIC = 1,
|
|
60
62
|
PROTECTED = 2,
|
|
61
63
|
PRIVATE = 4,
|
|
@@ -93,7 +95,7 @@ export interface ClassStateNode extends BaseStateNode {
|
|
|
93
95
|
hasInvoke?: boolean;
|
|
94
96
|
superClasses?: Set<StateNode>;
|
|
95
97
|
}
|
|
96
|
-
export
|
|
98
|
+
export type FunctionInfo = {
|
|
97
99
|
modifiedDecls: Set<VariableStateNode>;
|
|
98
100
|
calledFuncs: Set<FunctionStateNode>;
|
|
99
101
|
resolvedDecls?: Set<VariableStateNode>;
|
|
@@ -159,20 +161,20 @@ export interface Diagnostic extends DiagnosticBase {
|
|
|
159
161
|
message: string;
|
|
160
162
|
};
|
|
161
163
|
}
|
|
162
|
-
|
|
164
|
+
type ProgramStateStackElem = {
|
|
163
165
|
sn: StateNode;
|
|
164
166
|
usings?: Record<string, ImportUsing>;
|
|
165
167
|
imports?: ImportUsing[];
|
|
166
168
|
};
|
|
167
|
-
export
|
|
168
|
-
export
|
|
169
|
-
export
|
|
169
|
+
export type StateNode = ProgramStateNode | FunctionStateNode | BlockStateNode | ClassStateNode | ModuleStateNode | TypedefStateNode | VariableStateNode | EnumStateNode;
|
|
170
|
+
export type ProgramStateStack = ProgramStateStackElem[];
|
|
171
|
+
export type LookupDefinition = {
|
|
170
172
|
parent: StateNode | null;
|
|
171
173
|
results: StateNodeDecl[];
|
|
172
174
|
};
|
|
173
|
-
export
|
|
174
|
-
export
|
|
175
|
-
export
|
|
175
|
+
export type LookupResult = [string, LookupDefinition[]] | [null, null] | [false, false];
|
|
176
|
+
export type ByNameStateNodeDecls = ModuleStateNode | ClassStateNode | FunctionStateNode | ProgramStateNode;
|
|
177
|
+
export type ProgramState = {
|
|
176
178
|
allFunctions?: Record<string, FunctionStateNode[]>;
|
|
177
179
|
allClasses?: ClassStateNode[];
|
|
178
180
|
invokeInfo?: FunctionInfo;
|
|
@@ -224,18 +226,19 @@ export declare type ProgramState = {
|
|
|
224
226
|
inlineDiagnostics?: Record<string, Diagnostic[]>;
|
|
225
227
|
enumMap?: Map<EnumStringMember, EnumStateNode>;
|
|
226
228
|
};
|
|
227
|
-
export
|
|
229
|
+
export type Finalized<T, Keys extends keyof T> = T & {
|
|
228
230
|
[key in Keys]-?: NonNullable<T[key]>;
|
|
229
231
|
};
|
|
230
|
-
export
|
|
231
|
-
export
|
|
232
|
-
export
|
|
233
|
-
export
|
|
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 = {
|
|
234
236
|
[key: string]: boolean;
|
|
235
237
|
};
|
|
236
|
-
export
|
|
238
|
+
export type FilesToOptimizeMap = {
|
|
237
239
|
[key: string]: {
|
|
238
240
|
output: string;
|
|
241
|
+
barrel: string;
|
|
239
242
|
excludeAnnotations: ExcludeAnnotationsMap;
|
|
240
243
|
monkeyCSource?: string;
|
|
241
244
|
ast?: mctree.Program;
|
package/build/src/optimizer.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare function generateOptimizedProject(options: BuildConfig): Promise<
|
|
|
65
65
|
hasTests: boolean;
|
|
66
66
|
diagnostics: Record<string, import("./optimizer-types").Diagnostic[]>;
|
|
67
67
|
}>;
|
|
68
|
-
export
|
|
68
|
+
export type PreAnalysis = {
|
|
69
69
|
fnMap: FilesToOptimizeMap;
|
|
70
70
|
paths: string[];
|
|
71
71
|
};
|
|
@@ -74,7 +74,7 @@ declare type RequiredNonNull<T> = {
|
|
|
74
74
|
[K2 in keyof T[K1]]-?: NonNullable<T[K1][K2]>;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
export
|
|
77
|
+
export type Analysis = {
|
|
78
78
|
fnMap: RequiredNonNull<FilesToOptimizeMap>;
|
|
79
79
|
paths: string[];
|
|
80
80
|
state: ProgramStateAnalysis;
|
package/build/src/projects.d.ts
CHANGED
|
@@ -17,13 +17,13 @@ export declare const enum SectionKinds {
|
|
|
17
17
|
SIGNATURE = -507453934,
|
|
18
18
|
STORE_SIG = 20833
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export type SectionInfo = {
|
|
21
21
|
offset: number;
|
|
22
22
|
length: number;
|
|
23
23
|
view: DataView;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export type Logger = (module: string, level: number, message: string) => void;
|
|
26
|
+
export type Context = {
|
|
27
27
|
config: BuildConfig;
|
|
28
28
|
filepath: string;
|
|
29
29
|
sections: Record<number, SectionInfo>;
|
|
@@ -37,7 +37,7 @@ export declare type Context = {
|
|
|
37
37
|
nextOffset: number;
|
|
38
38
|
nextLocalId: number;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type Block = {
|
|
41
41
|
offset: number;
|
|
42
42
|
bytecodes: Bytecode[];
|
|
43
43
|
try?: ExceptionEntry[];
|
|
@@ -46,7 +46,7 @@ export declare type Block = {
|
|
|
46
46
|
exsucc?: number;
|
|
47
47
|
preds?: Set<number>;
|
|
48
48
|
};
|
|
49
|
-
export
|
|
49
|
+
export type FuncEntry = {
|
|
50
50
|
name?: string;
|
|
51
51
|
offset: number;
|
|
52
52
|
argc?: number;
|
|
@@ -2,11 +2,12 @@ import { Block, FuncEntry } from "./bytecode";
|
|
|
2
2
|
import { Bytecode } from "./opcodes";
|
|
3
3
|
export declare function postOrderTraverse(func: FuncEntry, visitor: (block: Block) => void): void;
|
|
4
4
|
export declare function intersect<T>(a: Set<T>, b: Set<T>): Set<T>;
|
|
5
|
-
export
|
|
5
|
+
export type DomLike = Map<number, Set<number>>;
|
|
6
6
|
export declare function computePostDominators(func: FuncEntry): DomLike;
|
|
7
7
|
export declare function computeDominators(func: FuncEntry): DomLike;
|
|
8
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 enum RpoFlags {
|
|
9
|
+
export declare const enum RpoFlags {
|
|
10
|
+
Nothing = 0,
|
|
10
11
|
EnqueueTaken = 1,
|
|
11
12
|
EnqueueNext = 2,
|
|
12
13
|
SkipTaken = 4,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, FuncEntry } from "./bytecode";
|
|
2
2
|
import { ExceptionsMap } from "./exceptions";
|
|
3
3
|
import { LineNumber } from "./linenum";
|
|
4
|
-
|
|
4
|
+
type LocalXmlInfo = {
|
|
5
5
|
name: string;
|
|
6
6
|
startPc: number;
|
|
7
7
|
endPc: number;
|
|
@@ -9,11 +9,11 @@ declare type LocalXmlInfo = {
|
|
|
9
9
|
slot: number;
|
|
10
10
|
id: number;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type LocalsMap = Map<number, {
|
|
13
13
|
startPc: number;
|
|
14
14
|
endPc: number;
|
|
15
15
|
}>;
|
|
16
|
-
export
|
|
16
|
+
export type UpdateInfo = {
|
|
17
17
|
offsetMap: Map<number, number>;
|
|
18
18
|
localRanges: LocalXmlInfo[];
|
|
19
19
|
lineMap: LineNumber[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from "./bytecode";
|
|
2
2
|
import { UpdateInfo } from "./emit";
|
|
3
|
-
export
|
|
3
|
+
export type ExceptionEntry = {
|
|
4
4
|
tryStart: number;
|
|
5
5
|
tryEnd: number;
|
|
6
6
|
handler: number;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type ExceptionsMap = Map<number, ExceptionEntry[]>;
|
|
9
9
|
export declare function parseExceptions(view: DataView): ExceptionsMap;
|
|
10
10
|
export declare function fixupExceptions(context: Context, updateInfo: UpdateInfo): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from "./bytecode";
|
|
2
2
|
import { UpdateInfo } from "./emit";
|
|
3
|
-
export
|
|
3
|
+
export type SectionOffset = {
|
|
4
4
|
data: number;
|
|
5
5
|
code: number;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type Header = {
|
|
8
8
|
ciqVersion: number;
|
|
9
9
|
backgroundOffsets: SectionOffset;
|
|
10
10
|
appLock: boolean;
|
|
@@ -23,7 +23,7 @@ interface LineNumberStr extends BaseLineNumber {
|
|
|
23
23
|
parent?: string | undefined;
|
|
24
24
|
id: number;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
26
|
+
export type LineNumber = LineNumberStr | LineNumberSym;
|
|
27
27
|
export declare function parseLineNum(view: DataView, debugXml: xmlUtil.Document): Map<number, LineNumber>;
|
|
28
28
|
export declare function fixupLineNum(context: Context, updateInfo: UpdateInfo): void;
|
|
29
29
|
export {};
|
|
@@ -139,7 +139,7 @@ export interface Agetv extends Argless {
|
|
|
139
139
|
export interface Aputv extends Argless {
|
|
140
140
|
op: Opcodes.aputv;
|
|
141
141
|
}
|
|
142
|
-
export
|
|
142
|
+
export type LocalRange = {
|
|
143
143
|
name: string;
|
|
144
144
|
id: number;
|
|
145
145
|
isParam?: true | undefined;
|
|
@@ -258,7 +258,7 @@ export interface Newba extends Argless {
|
|
|
258
258
|
export interface Argc extends ByteArg {
|
|
259
259
|
op: Opcodes.argc;
|
|
260
260
|
}
|
|
261
|
-
export
|
|
261
|
+
export type Bytecode = Nop | Incsp | Popv | Addv | Subv | Mulv | Divv | Andv | Orv | Modv | Shlv | Shrv | Xorv | Getv | Putv | Invokem | Agetv | Aputv | Lgetv | Lputv | Newa | Newc | Return | Ret | News | Goto | Eq | Lt | Lte | Gt | Gte | Ne | Isnull | Isa | Canhazplz | Jsr | Ts | Ipush | Fpush | Spush | Bt | Bf | Frpush | Bpush | Npush | Invv | Dup | Newd | Getm | Lpush | Dpush | Throw | Cpush | Argc | Newba;
|
|
262
262
|
export declare function parseCode(view: DataView, lineTable: Map<number, LineNumber>): Bytecode[];
|
|
263
263
|
export declare function opcodeSize(op: Opcodes): 1 | 2 | 3 | 5 | 9;
|
|
264
264
|
export declare function emitBytecode(bytecode: Bytecode, view: DataView, offset: number, linktable: Map<number, number>): number;
|
package/build/src/resources.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
|
2
2
|
import { JungleResourceMap } from "./jungles";
|
|
3
3
|
import { ProgramState } from "./optimizer-types";
|
|
4
4
|
import { xmlUtil } from "./sdk-util";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type Visit = (e: xmlUtil.Element, module: string | null, parent: xmlUtil.Element | null) => void;
|
|
6
|
+
type Visitor = {
|
|
7
7
|
visit?: Visit;
|
|
8
8
|
error?: (node: xmlUtil.Element, parent: string | null) => void;
|
|
9
9
|
} & xmlUtil.Visitor;
|
package/build/src/sdk-util.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const isWin: boolean;
|
|
|
5
5
|
export declare const appSupport: string;
|
|
6
6
|
export declare const connectiq: string;
|
|
7
7
|
export declare function getSdkPath(): Promise<string>;
|
|
8
|
-
export
|
|
8
|
+
export type DeviceInfo = {
|
|
9
9
|
[key: string]: {
|
|
10
10
|
appTypes: {
|
|
11
11
|
memoryLimit: number;
|
|
@@ -2,7 +2,7 @@ import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
|
2
2
|
import { NodeEquivMap } from "../type-flow";
|
|
3
3
|
import { FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
|
|
4
4
|
import { TypeFlowBlock, TypeStateKey } from "./type-flow-util";
|
|
5
|
-
export
|
|
5
|
+
export type CopyPropStores = Map<mctree.Node, {
|
|
6
6
|
ref: mctree.Node;
|
|
7
7
|
ant: boolean;
|
|
8
8
|
}>;
|
|
@@ -4,13 +4,13 @@ import { InterpStackElem, InterpState } from "./interp";
|
|
|
4
4
|
import { ExactOrUnion } from "./types";
|
|
5
5
|
export declare function evaluateCall(istate: InterpState, node: mctree.CallExpression, callee: ExactOrUnion, args: ExactOrUnion[]): InterpStackElem;
|
|
6
6
|
export declare function checkCallArgs(istate: InterpState, node: mctree.CallExpression, callees: FunctionStateNode | FunctionStateNode[], args: ExactOrUnion[]): InterpStackElem;
|
|
7
|
-
|
|
7
|
+
type SysCallHelperResult = {
|
|
8
8
|
calleeObj?: ExactOrUnion;
|
|
9
9
|
returnType?: ExactOrUnion;
|
|
10
10
|
argTypes?: ExactOrUnion[];
|
|
11
11
|
effectFree?: true;
|
|
12
12
|
argEffects?: true;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type SysCallHelper = (state: ProgramStateAnalysis, func: FunctionStateNode, calleeObj: ExactOrUnion, getArgs: () => Array<ExactOrUnion>) => SysCallHelperResult;
|
|
15
15
|
export declare function sysCallInfo(state: ProgramStateAnalysis, func: FunctionStateNode): SysCallHelper | null;
|
|
16
16
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
2
|
import { DiagnosticType, FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
|
|
3
3
|
import { ExactOrUnion } from "./types";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type TypeMap = Map<mctree.Node, ExactOrUnion>;
|
|
5
|
+
export type InterpStackElem = {
|
|
6
6
|
value: ExactOrUnion;
|
|
7
7
|
embeddedEffects: boolean;
|
|
8
8
|
node: mctree.Expression | mctree.TypeSpecList | mctree.InstanceOfCase;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type InterpState = {
|
|
11
11
|
state: ProgramStateAnalysis;
|
|
12
12
|
stack: InterpStackElem[];
|
|
13
13
|
typeMap?: TypeMap;
|
|
14
|
+
localLvals?: Set<mctree.Node>;
|
|
14
15
|
func?: FunctionStateNode;
|
|
15
16
|
pre?: (node: mctree.Node) => mctree.Node | false | null | void;
|
|
16
17
|
post?: (node: mctree.Node) => mctree.Node | false | null | void;
|