@markw65/monkeyc-optimizer 1.0.18 → 1.0.21
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 +46 -0
- package/build/api.cjs +275 -135
- package/build/optimizer.cjs +316 -139
- package/build/src/inliner.d.ts +3 -2
- package/build/src/launch.d.ts +2 -1
- package/build/src/mc-rewrite.d.ts +8 -1
- package/build/src/optimizer.d.ts +28 -2
- package/build/src/util.d.ts +2 -3
- package/package.json +2 -2
package/build/src/inliner.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ export declare enum InlineStatus {
|
|
|
4
4
|
AsExpression = 1,
|
|
5
5
|
AsStatement = 2
|
|
6
6
|
}
|
|
7
|
-
export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode,
|
|
7
|
+
export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): boolean;
|
|
8
8
|
declare type InlineBody = mctree.BlockStatement | mctree.ExpressionStatement["expression"];
|
|
9
9
|
export declare function unused(expression: mctree.ExpressionStatement["expression"]): mctree.ExpressionStatement[];
|
|
10
10
|
export declare function unused(expression: mctree.ExpressionStatement["expression"], top: true): mctree.ExpressionStatement[] | null;
|
|
11
|
-
export declare
|
|
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;
|
|
12
13
|
export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
|
|
13
14
|
export {};
|
package/build/src/launch.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { LineHandler } from "./util";
|
|
1
2
|
export declare function launchSimulator(): Promise<void>;
|
|
2
|
-
export declare function simulateProgram(prg: string, device: string, test?: boolean): Promise<void>;
|
|
3
|
+
export declare function simulateProgram(prg: string, device: string, test?: boolean, logger?: LineHandler | LineHandler[]): Promise<void>;
|
|
@@ -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
|
@@ -117,16 +117,17 @@ declare global {
|
|
|
117
117
|
lookupType?: (node: mctree.Node, name?: string | null, stack?: ProgramStateStack) => [string, StateNodeDecl[], ProgramStateStack] | [null, null, null];
|
|
118
118
|
traverse?: (node: mctree.Node) => void | null | false | mctree.Node | mctree.Node[];
|
|
119
119
|
inType?: boolean;
|
|
120
|
+
inlining?: true;
|
|
120
121
|
exposed?: {
|
|
121
122
|
[key: string]: true;
|
|
122
123
|
};
|
|
123
124
|
calledFunctions?: {
|
|
124
|
-
[key: string]:
|
|
125
|
+
[key: string]: mctree.FunctionDeclaration[];
|
|
125
126
|
};
|
|
126
127
|
localsStack?: {
|
|
127
128
|
node?: mctree.Node;
|
|
128
129
|
map?: {
|
|
129
|
-
[key: string]:
|
|
130
|
+
[key: string]: boolean | string;
|
|
130
131
|
};
|
|
131
132
|
inners?: {
|
|
132
133
|
[key: string]: true;
|
|
@@ -138,6 +139,14 @@ declare global {
|
|
|
138
139
|
constants?: {
|
|
139
140
|
[key: string]: mctree.Literal;
|
|
140
141
|
};
|
|
142
|
+
diagnostics?: Record<string, {
|
|
143
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
144
|
+
loc: {
|
|
145
|
+
start: mctree.Position;
|
|
146
|
+
end: mctree.Position;
|
|
147
|
+
};
|
|
148
|
+
message: string;
|
|
149
|
+
}[]>;
|
|
141
150
|
};
|
|
142
151
|
type Finalized<T, Keys extends keyof T> = T & {
|
|
143
152
|
[key in Keys]-?: NonNullable<T[key]>;
|
|
@@ -172,17 +181,34 @@ export declare function buildOptimizedProject(product: string | null, options: B
|
|
|
172
181
|
program: string;
|
|
173
182
|
product: string | null;
|
|
174
183
|
hasTests: boolean | undefined;
|
|
184
|
+
diagnostics: Record<string, {
|
|
185
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
186
|
+
loc: {
|
|
187
|
+
start: mctree.Position;
|
|
188
|
+
end: mctree.Position;
|
|
189
|
+
};
|
|
190
|
+
message: string;
|
|
191
|
+
}[]> | undefined;
|
|
175
192
|
}>;
|
|
176
193
|
export declare function generateOptimizedProject(options: BuildConfig): Promise<{
|
|
177
194
|
jungleFiles: string | undefined;
|
|
178
195
|
program: string;
|
|
179
196
|
xml?: undefined;
|
|
180
197
|
hasTests?: undefined;
|
|
198
|
+
diagnostics?: undefined;
|
|
181
199
|
} | {
|
|
182
200
|
jungleFiles: string;
|
|
183
201
|
xml: import("./manifest").ManifestXML;
|
|
184
202
|
program: string;
|
|
185
203
|
hasTests: boolean;
|
|
204
|
+
diagnostics: Record<string, {
|
|
205
|
+
type: "ERROR" | "WARNING" | "INFO";
|
|
206
|
+
loc: {
|
|
207
|
+
start: mctree.Position;
|
|
208
|
+
end: mctree.Position;
|
|
209
|
+
};
|
|
210
|
+
message: string;
|
|
211
|
+
}[]>;
|
|
186
212
|
}>;
|
|
187
213
|
export declare type PreAnalysis = {
|
|
188
214
|
fnMap: FilesToOptimizeMap;
|
package/build/src/util.d.ts
CHANGED
|
@@ -2,12 +2,11 @@ import * as glob from "glob";
|
|
|
2
2
|
export declare function globa(pattern: string, options?: glob.IOptions): Promise<Array<string>>;
|
|
3
3
|
export declare function last_modified(inputs: string[]): Promise<number>;
|
|
4
4
|
export declare function first_modified(inputs: string[]): Promise<number>;
|
|
5
|
-
export declare function pushUnique<T>(arr: T[], value:
|
|
6
|
-
declare type LineHandler = (line: string) => void;
|
|
5
|
+
export declare function pushUnique<T, U extends T>(arr: T[], value: U): void;
|
|
6
|
+
export declare type LineHandler = (line: string) => void;
|
|
7
7
|
export declare function spawnByLine(command: string, args: string[], lineHandlers: LineHandler | LineHandler[], options?: {
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
}): Promise<void>;
|
|
10
10
|
export declare function readByLine(file: string, lineHandler: LineHandler): Promise<unknown>;
|
|
11
11
|
export declare function promiseAll<T>(promiseFn: (i: number) => Promise<T>, parallelism: number): Promise<T[]>;
|
|
12
12
|
export declare function copyRecursiveAsNeeded(source: string, target: string, filter?: (src: string, tgt: string) => boolean): Promise<void>;
|
|
13
|
-
export {};
|
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.21",
|
|
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.24"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/glob": "^7.2.0",
|