@markw65/monkeyc-optimizer 1.0.17 → 1.0.20

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.
@@ -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, args: mctree.Node[]): InlineStatus;
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 function inlineFunction(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, inlineStatus: InlineStatus): InlineBody | 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;
12
13
  export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
13
14
  export {};
@@ -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<void>;
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>;
@@ -121,12 +121,12 @@ declare global {
121
121
  [key: string]: true;
122
122
  };
123
123
  calledFunctions?: {
124
- [key: string]: unknown[];
124
+ [key: string]: mctree.FunctionDeclaration[];
125
125
  };
126
126
  localsStack?: {
127
127
  node?: mctree.Node;
128
128
  map?: {
129
- [key: string]: true | 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;
@@ -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: T): void;
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.17",
4
+ "version": "1.0.20",
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.21"
37
+ "@markw65/prettier-plugin-monkeyc": "^1.0.22"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/glob": "^7.2.0",