@markw65/monkeyc-optimizer 1.0.43 → 1.0.45

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.0.43",
4
+ "version": "1.0.45",
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",
@@ -21,8 +21,9 @@
21
21
  "build-debug": "webpack --mode development",
22
22
  "build-release": "webpack --mode production",
23
23
  "prepack": "webpack --mode production",
24
- "test": "npm run test-optimized && npm run test-unopt && npm run test-remote",
24
+ "test": "npm run test-optimized && npm run test-unopt && npm run test-remote && npm run test-remote-tests",
25
25
  "test-remote": "node ./test/test.js --product=pick-one --github",
26
+ "test-remote-tests": "node ./test/test.js --product=pick-one --run-tests --github",
26
27
  "test-optimized": "node test/test.js --typeCheckLevel Strict --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
27
28
  "test-unopt": "node test/test.js --typeCheckLevel Strict --skipOptimization --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
28
29
  "test-garmin-opt": "node test/test.js --typeCheckLevel Strict --skipOptimization --garminOptLevel=2 --run-tests --product=fenix5 --product=fr235 --jungle ./test/OptimizerTests/monkey.jungle",
@@ -38,7 +39,7 @@
38
39
  "author": "markw65",
39
40
  "license": "MIT",
40
41
  "dependencies": {
41
- "@markw65/prettier-plugin-monkeyc": "^1.0.39"
42
+ "@markw65/prettier-plugin-monkeyc": "^1.0.41"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/glob": "^8.0.0",
@@ -1,324 +0,0 @@
1
- declare type InclusiveUnionKeys<U> = U extends unknown ? keyof U : never;
2
- declare type InclusiveUnion<U> = {
3
- [K in InclusiveUnionKeys<U>]: U extends any ? K extends keyof U ? U[K] : never : never;
4
- };
5
- declare type SubfieldsOfType<T, U> = {
6
- [K in keyof T as T[K] extends U ? K : never]: T[K];
7
- };
8
- export declare type NodeAll = InclusiveUnion<Node>;
9
- export declare type NodeSubFields = SubfieldsOfType<NodeAll, Node>;
10
- export declare type NodeSubArrays = SubfieldsOfType<NodeAll, Node[]>;
11
- interface BaseNode {
12
- type: string;
13
- loc?: SourceLocation | null | undefined;
14
- start?: number;
15
- end?: number;
16
- range?: [number, number] | undefined;
17
- }
18
- export declare type Node = Identifier | Literal | Program | SwitchCase | CatchClause | VariableDeclarator | EnumStringBody | EnumStringMember | Statement | Expression | Property | Declaration | ImportStatement | AsTypeSpec | TypeSpecList | ClassElement | ClassBody | Comment;
19
- export interface Comment extends BaseNode {
20
- type: "Line" | "Block";
21
- value: string;
22
- }
23
- interface SourceLocation {
24
- source?: string | null | undefined;
25
- start: Position;
26
- end: Position;
27
- }
28
- export interface Position {
29
- /** >= 1 */
30
- line: number;
31
- /** >= 0 */
32
- column: number;
33
- }
34
- export interface Program extends BaseNode {
35
- type: "Program";
36
- body: Array<Declaration | ImportStatement>;
37
- comments?: Array<Comment> | undefined;
38
- }
39
- export interface ModuleDeclaration extends BaseDeclaration {
40
- type: "ModuleDeclaration";
41
- body: Array<Declaration | ImportStatement>;
42
- id: Identifier;
43
- }
44
- interface BaseFunction extends BaseNode {
45
- params: Array<Identifier | AsExpression>;
46
- body: BlockStatement;
47
- }
48
- export declare type Statement = ExpressionStatement | BlockStatement | ReturnStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | Declaration;
49
- interface BaseStatement extends BaseNode {
50
- }
51
- export interface BlockStatement extends BaseStatement {
52
- type: "BlockStatement";
53
- body: Array<Statement>;
54
- innerComments?: Array<Comment> | undefined;
55
- }
56
- export interface ExpressionStatement extends BaseStatement {
57
- type: "ExpressionStatement";
58
- expression: Expression;
59
- }
60
- export interface IfStatement extends BaseStatement {
61
- type: "IfStatement";
62
- test: Expression;
63
- consequent: Statement;
64
- alternate?: Statement | null | undefined;
65
- }
66
- export interface BreakStatement extends BaseStatement {
67
- type: "BreakStatement";
68
- }
69
- export interface ContinueStatement extends BaseStatement {
70
- type: "ContinueStatement";
71
- }
72
- export interface SwitchStatement extends BaseStatement {
73
- type: "SwitchStatement";
74
- discriminant: Expression;
75
- cases: Array<SwitchCase>;
76
- }
77
- export interface ReturnStatement extends BaseStatement {
78
- type: "ReturnStatement";
79
- argument?: Expression | null | undefined;
80
- }
81
- export interface ThrowStatement extends BaseStatement {
82
- type: "ThrowStatement";
83
- argument: Expression;
84
- }
85
- export interface TryStatement extends BaseStatement {
86
- type: "TryStatement";
87
- block: BlockStatement;
88
- handler?: CatchClause | CatchClauses | null | undefined;
89
- finalizer?: BlockStatement | null | undefined;
90
- }
91
- export interface WhileStatement extends BaseStatement {
92
- type: "WhileStatement";
93
- test: Expression;
94
- body: Statement;
95
- }
96
- export interface DoWhileStatement extends BaseStatement {
97
- type: "DoWhileStatement";
98
- body: Statement;
99
- test: Expression;
100
- }
101
- export interface ForStatement extends BaseStatement {
102
- type: "ForStatement";
103
- init?: VariableDeclaration | Expression | null | undefined;
104
- test?: Expression | null | undefined;
105
- update?: Expression | null | undefined;
106
- body: Statement;
107
- }
108
- export declare type Declaration = ClassDeclaration | EnumDeclaration | FunctionDeclaration | ModuleDeclaration | TypedefDeclaration | VariableDeclaration;
109
- interface BaseDeclaration extends BaseStatement {
110
- attrs?: AttributeList;
111
- }
112
- export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
113
- type: "FunctionDeclaration";
114
- id: Identifier;
115
- body: BlockStatement;
116
- optimizable?: boolean;
117
- hasOverride?: boolean;
118
- }
119
- export interface VariableDeclaration extends BaseDeclaration {
120
- type: "VariableDeclaration";
121
- declarations: Array<VariableDeclarator>;
122
- kind: "var" | "const";
123
- }
124
- export interface VariableDeclarator extends BaseNode {
125
- type: "VariableDeclarator";
126
- id: Identifier | AsExpression;
127
- init?: Expression | null | undefined;
128
- kind: "var" | "const";
129
- }
130
- declare type Expression = ThisExpression | ArrayExpression | ObjectExpression | Literal | UnaryExpression | UpdateExpression | BinaryExpression | AsExpression | AssignmentExpression | LogicalExpression | MemberExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier;
131
- export interface BaseExpression extends BaseNode {
132
- enumType?: string | Node;
133
- }
134
- export interface ThisExpression extends BaseExpression {
135
- type: "ThisExpression";
136
- text: string;
137
- }
138
- export interface ArrayExpression extends BaseExpression {
139
- type: "ArrayExpression";
140
- elements: Array<Expression>;
141
- }
142
- export interface ObjectExpression extends BaseExpression {
143
- type: "ObjectExpression";
144
- properties: Array<Property>;
145
- }
146
- export interface Property extends BaseNode {
147
- type: "Property";
148
- key: Expression;
149
- value: Expression;
150
- kind: "init";
151
- }
152
- export interface SequenceExpression extends BaseExpression {
153
- type: "SequenceExpression";
154
- expressions: Array<Expression>;
155
- }
156
- interface BaseUnaryExpression extends BaseExpression {
157
- type: "UnaryExpression";
158
- prefix: true;
159
- }
160
- interface TrueUnaryExpression extends BaseUnaryExpression {
161
- operator: UnaryOperator;
162
- argument: Expression;
163
- }
164
- interface SymbolExpression extends BaseUnaryExpression {
165
- operator: ":";
166
- argument: Identifier;
167
- }
168
- export declare type UnaryExpression = TrueUnaryExpression | SymbolExpression;
169
- export interface BinaryExpression extends BaseExpression {
170
- type: "BinaryExpression";
171
- operator: BinaryOperator;
172
- left: Expression;
173
- right: Expression;
174
- }
175
- export interface AsExpression extends BaseExpression {
176
- type: "BinaryExpression";
177
- operator: "as";
178
- left: Expression;
179
- right: TypeSpecList;
180
- }
181
- export interface AssignmentExpression extends BaseExpression {
182
- type: "AssignmentExpression";
183
- operator: AssignmentOperator;
184
- left: Identifier | MemberExpression;
185
- right: Expression;
186
- }
187
- export interface UpdateExpression extends BaseExpression {
188
- type: "UpdateExpression";
189
- operator: UpdateOperator;
190
- argument: Expression;
191
- prefix: boolean;
192
- }
193
- export interface LogicalExpression extends BaseExpression {
194
- type: "LogicalExpression";
195
- operator: LogicalOperator;
196
- left: Expression;
197
- right: Expression;
198
- }
199
- export interface ConditionalExpression extends BaseExpression {
200
- type: "ConditionalExpression";
201
- test: Expression;
202
- alternate: Expression;
203
- consequent: Expression;
204
- }
205
- interface BaseCallExpression extends BaseExpression {
206
- callee: Expression;
207
- arguments: Array<Expression>;
208
- }
209
- export declare type CallExpression = SimpleCallExpression | NewExpression;
210
- export interface SimpleCallExpression extends BaseCallExpression {
211
- type: "CallExpression";
212
- }
213
- export interface NewExpression extends BaseCallExpression {
214
- type: "NewExpression";
215
- }
216
- export interface MemberExpression extends BaseExpression {
217
- type: "MemberExpression";
218
- object: Expression;
219
- property: Expression;
220
- computed: boolean;
221
- }
222
- export interface SwitchCase extends BaseNode {
223
- type: "SwitchCase";
224
- test?: Expression | null | undefined;
225
- consequent: Array<Statement>;
226
- }
227
- export interface CatchClause extends BaseNode {
228
- type: "CatchClause";
229
- param: Identifier | null;
230
- body: BlockStatement;
231
- }
232
- export interface CatchClauses extends BaseNode {
233
- type: "CatchClauses";
234
- catches: CatchClause[];
235
- }
236
- export interface Identifier extends BaseNode, BaseExpression {
237
- type: "Identifier";
238
- name: string;
239
- }
240
- export interface Literal extends BaseNode, BaseExpression {
241
- type: "Literal";
242
- value: string | boolean | number | null;
243
- raw?: string | undefined;
244
- }
245
- export declare type UnaryOperator = "-" | "+" | "!" | "~" | " as";
246
- export declare type BinaryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "has" | "instanceof";
247
- export declare type LogicalOperator = "||" | "&&";
248
- export declare type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | "|=" | "^=" | "&=";
249
- export declare type UpdateOperator = "++" | "--";
250
- export interface ClassDeclaration extends BaseDeclaration {
251
- type: "ClassDeclaration";
252
- id: Identifier;
253
- superClass?: Expression | null | undefined;
254
- body: ClassBody;
255
- }
256
- export interface ClassBody extends BaseStatement {
257
- type: "ClassBody";
258
- body: Array<ClassElement>;
259
- }
260
- export interface ClassElement extends BaseStatement {
261
- type: "ClassElement";
262
- item: Omit<Declaration, "ModuleDeclaration">;
263
- }
264
- export interface EnumDeclaration extends BaseDeclaration {
265
- type: "EnumDeclaration";
266
- id?: Identifier | null;
267
- body: EnumStringBody;
268
- }
269
- export interface EnumStringBody extends BaseNode {
270
- type: "EnumStringBody";
271
- members: Array<EnumStringMember | Identifier>;
272
- enumType?: string | Node;
273
- }
274
- export interface EnumStringMember extends BaseNode {
275
- type: "EnumStringMember";
276
- id: Identifier;
277
- init: Expression;
278
- enumType?: string | Node;
279
- }
280
- export interface TypedefDeclaration extends BaseDeclaration {
281
- type: "TypedefDeclaration";
282
- id: Identifier;
283
- ts: AsTypeSpec;
284
- }
285
- export interface AsTypeSpec extends Omit<UnaryExpression, "operator" | "argument"> {
286
- operator: " as";
287
- argument: TypeSpecList;
288
- }
289
- export interface TypeSpecList extends BaseNode {
290
- type: "TypeSpecList";
291
- ts: Array<TypeSpecPart>;
292
- }
293
- export interface TypeSpecPart extends BaseNode {
294
- type: "TypeSpecPart";
295
- name: Identifier | MemberExpression;
296
- body?: BlockStatement;
297
- callspec?: MethodDefinition;
298
- generics?: Array<TypeSpecList>;
299
- }
300
- export interface MethodDefinition extends BaseNode {
301
- type: "MethodDefinition";
302
- kind: "method";
303
- key: "";
304
- params: Array<Identifier | AsExpression>;
305
- returnType: AsTypeSpec;
306
- }
307
- export declare type AccessSpecifier = "static" | "private" | "protected" | "hidden" | "public";
308
- export interface AttributeList extends BaseNode {
309
- type: "AttributeList";
310
- attrs?: Attribute[];
311
- access?: AccessSpecifier[];
312
- }
313
- declare type Attribute = SymbolExpression | CallExpression;
314
- export declare type ImportStatement = ImportModule | Using;
315
- export interface ImportModule extends BaseNode {
316
- type: "ImportModule";
317
- id: MemberExpression;
318
- }
319
- export interface Using extends BaseNode {
320
- type: "Using";
321
- id: MemberExpression;
322
- as: Identifier;
323
- }
324
- export {};