@markw65/monkeyc-optimizer 1.0.16 → 1.0.19
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 +42 -0
- package/build/api.cjs +501 -332
- package/build/optimizer.cjs +551 -175
- package/build/sdk-util.cjs +1 -1
- package/build/src/api.d.ts +1 -1
- package/build/src/inliner.d.ts +12 -2
- package/build/src/mc-rewrite.d.ts +8 -1
- package/build/src/optimizer.d.ts +28 -3
- package/build/src/pragma-checker.d.ts +2 -0
- package/build/src/variable-renamer.d.ts +1 -0
- package/build/util.cjs +1 -1
- package/package.json +2 -2
package/build/sdk-util.cjs
CHANGED
package/build/src/api.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export declare function hasProperty<T>(obj: T, prop: string): boolean;
|
|
|
5
5
|
export declare function isStateNode(node: StateNodeDecl): node is StateNode;
|
|
6
6
|
export declare function variableDeclarationName(node: mctree.TypedIdentifier): string;
|
|
7
7
|
export declare function collectNamespaces(ast: mctree.Program, stateIn?: ProgramState): ProgramStateNode;
|
|
8
|
-
export declare function traverseAst(node: mctree.Node, pre?: null | ((node: mctree.Node) => void | null | false | (keyof mctree.NodeAll)[]), post?: (node: mctree.Node) => void | null | false | mctree.Node): false | void | null | mctree.Node;
|
|
8
|
+
export declare function traverseAst(node: mctree.Node, pre?: null | ((node: mctree.Node) => void | null | false | (keyof mctree.NodeAll)[]), post?: (node: mctree.Node) => void | null | false | mctree.Node | mctree.Node[]): false | void | null | mctree.Node | mctree.Node[];
|
|
9
9
|
export declare function formatAst(node: mctree.Node, monkeyCSource?: string | null): string;
|
package/build/src/inliner.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
export declare
|
|
3
|
-
|
|
2
|
+
export declare enum InlineStatus {
|
|
3
|
+
Never = 0,
|
|
4
|
+
AsExpression = 1,
|
|
5
|
+
AsStatement = 2
|
|
6
|
+
}
|
|
7
|
+
export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): boolean;
|
|
8
|
+
declare type InlineBody = mctree.BlockStatement | mctree.ExpressionStatement["expression"];
|
|
9
|
+
export declare function unused(expression: mctree.ExpressionStatement["expression"]): mctree.ExpressionStatement[];
|
|
10
|
+
export declare function unused(expression: mctree.ExpressionStatement["expression"], top: true): mctree.ExpressionStatement[] | null;
|
|
11
|
+
export declare type InlineContext = mctree.ReturnStatement | mctree.AssignmentExpression | mctree.ExpressionStatement;
|
|
12
|
+
export declare function inlineFunction(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): InlineBody | null;
|
|
4
13
|
export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
|
|
14
|
+
export {};
|
|
@@ -4,4 +4,11 @@ export declare function getFileASTs(fnMap: FilesToOptimizeMap): Promise<boolean>
|
|
|
4
4
|
export declare function analyze(fnMap: FilesToOptimizeMap): Promise<ProgramStateAnalysis>;
|
|
5
5
|
export declare function getLiteralFromDecls(decls: StateNodeDecl[]): null;
|
|
6
6
|
export declare function getLiteralNode(node: mctree.Node | null | undefined): null | mctree.Literal | mctree.AsExpression;
|
|
7
|
-
export declare function optimizeMonkeyC(fnMap: FilesToOptimizeMap): Promise<
|
|
7
|
+
export declare function optimizeMonkeyC(fnMap: FilesToOptimizeMap): Promise<Record<string, {
|
|
8
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
9
|
+
loc: {
|
|
10
|
+
start: mctree.Position;
|
|
11
|
+
end: mctree.Position;
|
|
12
|
+
};
|
|
13
|
+
message: string;
|
|
14
|
+
}[]> | undefined>;
|
package/build/src/optimizer.d.ts
CHANGED
|
@@ -111,11 +111,11 @@ declare global {
|
|
|
111
111
|
removeNodeComments?: (node: mctree.Node, ast: mctree.Program) => void;
|
|
112
112
|
shouldExclude?: (node: mctree.Node) => boolean;
|
|
113
113
|
pre?: (node: mctree.Node, state: ProgramStateLive) => null | false | (keyof mctree.NodeAll)[];
|
|
114
|
-
post?: (node: mctree.Node, state: ProgramStateLive) => null | false | mctree.Node;
|
|
114
|
+
post?: (node: mctree.Node, state: ProgramStateLive) => null | false | mctree.Node | mctree.Node[];
|
|
115
115
|
lookup?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack) => [string, StateNodeDecl[], ProgramStateStack] | [null, null, null];
|
|
116
116
|
lookupValue?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack) => [string, StateNodeDecl[], ProgramStateStack] | [null, null, null];
|
|
117
117
|
lookupType?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack) => [string, StateNodeDecl[], ProgramStateStack] | [null, null, null];
|
|
118
|
-
traverse?: (node: mctree.Node) => void | null | false | mctree.Node;
|
|
118
|
+
traverse?: (node: mctree.Node) => void | null | false | mctree.Node | mctree.Node[];
|
|
119
119
|
inType?: boolean;
|
|
120
120
|
exposed?: {
|
|
121
121
|
[key: string]: true;
|
|
@@ -126,7 +126,7 @@ declare global {
|
|
|
126
126
|
localsStack?: {
|
|
127
127
|
node?: mctree.Node;
|
|
128
128
|
map?: {
|
|
129
|
-
[key: string]:
|
|
129
|
+
[key: string]: boolean | string;
|
|
130
130
|
};
|
|
131
131
|
inners?: {
|
|
132
132
|
[key: string]: true;
|
|
@@ -138,6 +138,14 @@ declare global {
|
|
|
138
138
|
constants?: {
|
|
139
139
|
[key: string]: mctree.Literal;
|
|
140
140
|
};
|
|
141
|
+
diagnostics?: Record<string, {
|
|
142
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
143
|
+
loc: {
|
|
144
|
+
start: mctree.Position;
|
|
145
|
+
end: mctree.Position;
|
|
146
|
+
};
|
|
147
|
+
message: string;
|
|
148
|
+
}[]>;
|
|
141
149
|
};
|
|
142
150
|
type Finalized<T, Keys extends keyof T> = T & {
|
|
143
151
|
[key in Keys]-?: NonNullable<T[key]>;
|
|
@@ -172,17 +180,34 @@ export declare function buildOptimizedProject(product: string | null, options: B
|
|
|
172
180
|
program: string;
|
|
173
181
|
product: string | null;
|
|
174
182
|
hasTests: boolean | undefined;
|
|
183
|
+
diagnostics: Record<string, {
|
|
184
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
185
|
+
loc: {
|
|
186
|
+
start: mctree.Position;
|
|
187
|
+
end: mctree.Position;
|
|
188
|
+
};
|
|
189
|
+
message: string;
|
|
190
|
+
}[]> | undefined;
|
|
175
191
|
}>;
|
|
176
192
|
export declare function generateOptimizedProject(options: BuildConfig): Promise<{
|
|
177
193
|
jungleFiles: string | undefined;
|
|
178
194
|
program: string;
|
|
179
195
|
xml?: undefined;
|
|
180
196
|
hasTests?: undefined;
|
|
197
|
+
diagnostics?: undefined;
|
|
181
198
|
} | {
|
|
182
199
|
jungleFiles: string;
|
|
183
200
|
xml: import("./manifest").ManifestXML;
|
|
184
201
|
program: string;
|
|
185
202
|
hasTests: boolean;
|
|
203
|
+
diagnostics: Record<string, {
|
|
204
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
205
|
+
loc: {
|
|
206
|
+
start: mctree.Position;
|
|
207
|
+
end: mctree.Position;
|
|
208
|
+
};
|
|
209
|
+
message: string;
|
|
210
|
+
}[]>;
|
|
186
211
|
}>;
|
|
187
212
|
export declare type PreAnalysis = {
|
|
188
213
|
fnMap: FilesToOptimizeMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renameVariable(state: ProgramStateAnalysis, locals: NonNullable<ProgramStateAnalysis["localsStack"]>[number], declName: string): string | null;
|
package/build/util.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
0 && (module.exports = {globa,last_modified,
|
|
1
|
+
0 && (module.exports = {copyRecursiveAsNeeded,first_modified,globa,last_modified,promiseAll,pushUnique,readByLine,spawnByLine});
|
|
2
2
|
/******/ (() => { // webpackBootstrap
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markw65/monkeyc-optimizer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"author": "markw65",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@markw65/prettier-plugin-monkeyc": "^1.0.
|
|
37
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.22"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/glob": "^7.2.0",
|