@markw65/monkeyc-optimizer 1.1.51 → 1.1.53
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/CHANGELOG.md +11 -0
- package/build/api.cjs +34 -34
- package/build/{chunk-HKWBVOEL.cjs → chunk-32NRMXAJ.cjs} +552 -142
- package/build/optimizer.cjs +16 -16
- package/build/sdk-util.cjs +14 -14
- package/build/src/optimizer-types.d.ts +1 -2
- package/build/src/readprg/bytecode.d.ts +1 -0
- package/build/src/readprg/header.d.ts +1 -0
- package/build/src/readprg/opcodes.d.ts +104 -3
- package/build/src/sdk-util.d.ts +1 -0
- package/build/worker-thread.cjs +3 -3
- package/package.json +2 -2
package/build/optimizer.cjs
CHANGED
|
@@ -18,28 +18,28 @@ 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: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_32NRMXAJ.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_32NRMXAJ.buildOptimizedProject,
|
|
23
23
|
copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
generateOneConfig: () =>
|
|
27
|
-
generateOptimizedProject: () =>
|
|
28
|
-
getConfig: () =>
|
|
29
|
-
getProjectAnalysis: () =>
|
|
30
|
-
get_jungle: () =>
|
|
31
|
-
isErrorWithLocation: () =>
|
|
32
|
-
launchSimulator: () =>
|
|
33
|
-
manifestProducts: () =>
|
|
34
|
-
mctree: () =>
|
|
35
|
-
simulateProgram: () =>
|
|
24
|
+
defaultConfig: () => import_chunk_32NRMXAJ.defaultConfig,
|
|
25
|
+
display: () => import_chunk_32NRMXAJ.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_32NRMXAJ.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_32NRMXAJ.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_32NRMXAJ.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_32NRMXAJ.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_32NRMXAJ.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_32NRMXAJ.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_32NRMXAJ.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_32NRMXAJ.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_32NRMXAJ.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_32NRMXAJ.simulateProgram
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
38
|
-
var
|
|
38
|
+
var import_chunk_32NRMXAJ = require("./chunk-32NRMXAJ.cjs");
|
|
39
39
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
40
40
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
41
41
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
42
|
-
(0,
|
|
42
|
+
(0, import_chunk_32NRMXAJ.init_optimizer)();
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
|
45
45
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,25 +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_32NRMXAJ.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_32NRMXAJ.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_32NRMXAJ.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_32NRMXAJ.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_32NRMXAJ.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_32NRMXAJ.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_32NRMXAJ.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_32NRMXAJ.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_32NRMXAJ.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_32NRMXAJ.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_32NRMXAJ.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_32NRMXAJ.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_32NRMXAJ = require("./chunk-32NRMXAJ.cjs");
|
|
36
36
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
37
37
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
38
38
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
-
(0,
|
|
39
|
+
(0, import_chunk_32NRMXAJ.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { EnumStringMember } from "@markw65/prettier-plugin-monkeyc/build/estree-types";
|
|
3
2
|
import { xmlUtil } from "./sdk-util";
|
|
4
3
|
import { ExactOrUnion } from "./type-flow/types";
|
|
5
4
|
export type DiagnosticType = "ERROR" | "WARNING" | "INFO";
|
|
@@ -228,7 +227,7 @@ export type ProgramState = {
|
|
|
228
227
|
};
|
|
229
228
|
diagnostics?: Record<string, PreDiagnostic[]>;
|
|
230
229
|
inlineDiagnostics?: Record<string, Diagnostic[]>;
|
|
231
|
-
enumMap?: Map<EnumStringMember, EnumStateNode>;
|
|
230
|
+
enumMap?: Map<mctree.EnumStringMember, EnumStateNode>;
|
|
232
231
|
};
|
|
233
232
|
export type Finalized<T, Keys extends keyof T> = T & {
|
|
234
233
|
[key in Keys]-?: NonNullable<T[key]>;
|
|
@@ -54,7 +54,28 @@ export declare enum Opcodes {
|
|
|
54
54
|
throw = 51,
|
|
55
55
|
cpush = 52,
|
|
56
56
|
argc = 53,
|
|
57
|
-
newba = 54
|
|
57
|
+
newba = 54,
|
|
58
|
+
ipushz = 55,
|
|
59
|
+
ipush1 = 56,
|
|
60
|
+
ipush2 = 57,
|
|
61
|
+
ipush3 = 58,
|
|
62
|
+
fpushz = 59,
|
|
63
|
+
lpushz = 60,
|
|
64
|
+
dpushz = 61,
|
|
65
|
+
btpush = 62,
|
|
66
|
+
bfpush = 63,
|
|
67
|
+
apush = 64,
|
|
68
|
+
bapush = 65,
|
|
69
|
+
hpush = 66,
|
|
70
|
+
getselfv = 67,
|
|
71
|
+
getself = 68,
|
|
72
|
+
getmv = 69,
|
|
73
|
+
getlocalv = 70,
|
|
74
|
+
getsv = 71,
|
|
75
|
+
invokemz = 72,
|
|
76
|
+
aputvdup = 73,
|
|
77
|
+
argcincsp = 74,
|
|
78
|
+
isnotnull = 75
|
|
58
79
|
}
|
|
59
80
|
interface BaseOpcode {
|
|
60
81
|
op: Opcodes;
|
|
@@ -76,6 +97,9 @@ export interface ByteArg extends BaseOpcode {
|
|
|
76
97
|
export interface ShortArg extends BaseOpcode {
|
|
77
98
|
arg: number;
|
|
78
99
|
}
|
|
100
|
+
export interface ThreeByteArg extends BaseOpcode {
|
|
101
|
+
arg: number;
|
|
102
|
+
}
|
|
79
103
|
export interface WordArg extends BaseOpcode {
|
|
80
104
|
arg: number;
|
|
81
105
|
}
|
|
@@ -127,18 +151,27 @@ export interface Xorv extends Argless {
|
|
|
127
151
|
export interface Getv extends Argless {
|
|
128
152
|
op: Opcodes.getv;
|
|
129
153
|
}
|
|
154
|
+
export interface Getselfv extends WordArg {
|
|
155
|
+
op: Opcodes.getselfv;
|
|
156
|
+
}
|
|
130
157
|
export interface Putv extends Argless {
|
|
131
158
|
op: Opcodes.putv;
|
|
132
159
|
}
|
|
133
160
|
export interface Invokem extends ByteArg {
|
|
134
161
|
op: Opcodes.invokem;
|
|
135
162
|
}
|
|
163
|
+
export interface Invokemz extends Argless {
|
|
164
|
+
op: Opcodes.invokemz;
|
|
165
|
+
}
|
|
136
166
|
export interface Agetv extends Argless {
|
|
137
167
|
op: Opcodes.agetv;
|
|
138
168
|
}
|
|
139
169
|
export interface Aputv extends Argless {
|
|
140
170
|
op: Opcodes.aputv;
|
|
141
171
|
}
|
|
172
|
+
export interface Aputvdup extends Argless {
|
|
173
|
+
op: Opcodes.aputvdup;
|
|
174
|
+
}
|
|
142
175
|
export type LocalRange = {
|
|
143
176
|
name: string;
|
|
144
177
|
id: number;
|
|
@@ -150,6 +183,9 @@ export interface LocalInst extends ByteArg {
|
|
|
150
183
|
export interface Lgetv extends LocalInst {
|
|
151
184
|
op: Opcodes.lgetv;
|
|
152
185
|
}
|
|
186
|
+
export interface Getself extends Argless {
|
|
187
|
+
op: Opcodes.getself;
|
|
188
|
+
}
|
|
153
189
|
export interface Lputv extends LocalInst {
|
|
154
190
|
op: Opcodes.lputv;
|
|
155
191
|
}
|
|
@@ -180,6 +216,15 @@ export interface Bf extends ShortArg {
|
|
|
180
216
|
export interface Jsr extends ShortArg {
|
|
181
217
|
op: Opcodes.jsr;
|
|
182
218
|
}
|
|
219
|
+
export interface Apush extends WordArg {
|
|
220
|
+
op: Opcodes.apush;
|
|
221
|
+
}
|
|
222
|
+
export interface Bapush extends WordArg {
|
|
223
|
+
op: Opcodes.bapush;
|
|
224
|
+
}
|
|
225
|
+
export interface Hpush extends WordArg {
|
|
226
|
+
op: Opcodes.hpush;
|
|
227
|
+
}
|
|
183
228
|
export interface Eq extends Argless {
|
|
184
229
|
op: Opcodes.eq;
|
|
185
230
|
}
|
|
@@ -201,6 +246,9 @@ export interface Ne extends Argless {
|
|
|
201
246
|
export interface Isnull extends Argless {
|
|
202
247
|
op: Opcodes.isnull;
|
|
203
248
|
}
|
|
249
|
+
export interface Isnotnull extends Argless {
|
|
250
|
+
op: Opcodes.isnotnull;
|
|
251
|
+
}
|
|
204
252
|
export interface Isa extends Argless {
|
|
205
253
|
op: Opcodes.isa;
|
|
206
254
|
}
|
|
@@ -213,9 +261,24 @@ export interface Ts extends Argless {
|
|
|
213
261
|
export interface Ipush extends WordArg {
|
|
214
262
|
op: Opcodes.ipush;
|
|
215
263
|
}
|
|
264
|
+
export interface Ipushz extends Argless {
|
|
265
|
+
op: Opcodes.ipushz;
|
|
266
|
+
}
|
|
267
|
+
export interface Ipush1 extends ByteArg {
|
|
268
|
+
op: Opcodes.ipush1;
|
|
269
|
+
}
|
|
270
|
+
export interface Ipush2 extends ShortArg {
|
|
271
|
+
op: Opcodes.ipush2;
|
|
272
|
+
}
|
|
273
|
+
export interface Ipush3 extends ThreeByteArg {
|
|
274
|
+
op: Opcodes.ipush3;
|
|
275
|
+
}
|
|
216
276
|
export interface Fpush extends FloatArg {
|
|
217
277
|
op: Opcodes.fpush;
|
|
218
278
|
}
|
|
279
|
+
export interface Fpushz extends Argless {
|
|
280
|
+
op: Opcodes.fpushz;
|
|
281
|
+
}
|
|
219
282
|
export interface Spush extends WordArg {
|
|
220
283
|
op: Opcodes.spush;
|
|
221
284
|
}
|
|
@@ -225,6 +288,12 @@ export interface Frpush extends Argless {
|
|
|
225
288
|
export interface Bpush extends ByteArg {
|
|
226
289
|
op: Opcodes.bpush;
|
|
227
290
|
}
|
|
291
|
+
export interface Btpush extends Argless {
|
|
292
|
+
op: Opcodes.btpush;
|
|
293
|
+
}
|
|
294
|
+
export interface Bfpush extends Argless {
|
|
295
|
+
op: Opcodes.bfpush;
|
|
296
|
+
}
|
|
228
297
|
export interface Npush extends Argless {
|
|
229
298
|
op: Opcodes.npush;
|
|
230
299
|
}
|
|
@@ -240,12 +309,36 @@ export interface Newd extends Argless {
|
|
|
240
309
|
export interface Getm extends Argless {
|
|
241
310
|
op: Opcodes.getm;
|
|
242
311
|
}
|
|
312
|
+
export interface Getmv extends BaseOpcode {
|
|
313
|
+
op: Opcodes.getmv;
|
|
314
|
+
arg: {
|
|
315
|
+
module: number;
|
|
316
|
+
var: number;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
export interface Getlocalv extends BaseOpcode {
|
|
320
|
+
op: Opcodes.getlocalv;
|
|
321
|
+
arg: {
|
|
322
|
+
local: number;
|
|
323
|
+
var: number;
|
|
324
|
+
};
|
|
325
|
+
range?: LocalRange;
|
|
326
|
+
}
|
|
327
|
+
export interface Getsv extends WordArg {
|
|
328
|
+
op: Opcodes.getsv;
|
|
329
|
+
}
|
|
243
330
|
export interface Lpush extends LongArg {
|
|
244
331
|
op: Opcodes.lpush;
|
|
245
332
|
}
|
|
333
|
+
export interface Lpushz extends Argless {
|
|
334
|
+
op: Opcodes.lpushz;
|
|
335
|
+
}
|
|
246
336
|
export interface Dpush extends DoubleArg {
|
|
247
337
|
op: Opcodes.dpush;
|
|
248
338
|
}
|
|
339
|
+
export interface Dpushz extends Argless {
|
|
340
|
+
op: Opcodes.dpushz;
|
|
341
|
+
}
|
|
249
342
|
export interface Throw extends Argless {
|
|
250
343
|
op: Opcodes.throw;
|
|
251
344
|
}
|
|
@@ -258,9 +351,16 @@ export interface Newba extends Argless {
|
|
|
258
351
|
export interface Argc extends ByteArg {
|
|
259
352
|
op: Opcodes.argc;
|
|
260
353
|
}
|
|
261
|
-
export
|
|
354
|
+
export interface Argcincsp extends BaseOpcode {
|
|
355
|
+
op: Opcodes.argcincsp;
|
|
356
|
+
arg: {
|
|
357
|
+
argc: number;
|
|
358
|
+
incsp: number;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
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 | Ipushz | Ipush1 | Ipush2 | Ipush3 | Fpushz | Lpushz | Dpushz | Btpush | Bfpush | Apush | Bapush | Hpush | Getselfv | Getself | Getmv | Getlocalv | Getsv | Invokemz | Aputvdup | Argcincsp | Isnotnull;
|
|
262
362
|
export declare function parseCode(view: DataView, lineTable: Map<number, LineNumber>): Bytecode[];
|
|
263
|
-
export declare function opcodeSize(op: Opcodes): 1 | 2 | 3 | 5 | 9;
|
|
363
|
+
export declare function opcodeSize(op: Opcodes): 1 | 2 | 3 | 4 | 5 | 6 | 9;
|
|
264
364
|
export declare function emitBytecode(bytecode: Bytecode, view: DataView, offset: number, linktable: Map<number, number>, shift_hack: boolean): number;
|
|
265
365
|
export declare function getOpInfo(bytecode: Bytecode): {
|
|
266
366
|
pop: number;
|
|
@@ -274,6 +374,7 @@ export declare const enum Effects {
|
|
|
274
374
|
Call = 8
|
|
275
375
|
}
|
|
276
376
|
export declare function getOpEffects(bytecode: Bytecode): number;
|
|
377
|
+
export declare function opReadsLocal(bytecode: Bytecode): number | null;
|
|
277
378
|
export declare function isBoolOp(op: Opcodes): boolean;
|
|
278
379
|
export declare function isCondBranch(op: Opcodes): boolean;
|
|
279
380
|
export {};
|
package/build/src/sdk-util.d.ts
CHANGED
package/build/worker-thread.cjs
CHANGED
|
@@ -21,17 +21,17 @@ __export(worker_thread_exports, {
|
|
|
21
21
|
default: () => worker_thread_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(worker_thread_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_chunk_32NRMXAJ = require("./chunk-32NRMXAJ.cjs");
|
|
25
25
|
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
26
26
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
27
27
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
28
28
|
var import_node_worker_threads = require("node:worker_threads");
|
|
29
29
|
var require_worker_thread = (0, import_chunk_ABYVSU2C.__commonJS)({
|
|
30
30
|
"src/worker-thread.ts"() {
|
|
31
|
-
(0,
|
|
31
|
+
(0, import_chunk_32NRMXAJ.init_worker_task)();
|
|
32
32
|
if (import_node_worker_threads.parentPort) {
|
|
33
33
|
import_node_worker_threads.parentPort.on("message", async (task) => {
|
|
34
|
-
return import_node_worker_threads.parentPort.postMessage(await (0,
|
|
34
|
+
return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_32NRMXAJ.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markw65/monkeyc-optimizer",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.53",
|
|
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",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"author": "markw65",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@markw65/prettier-plugin-monkeyc": "^1.0.
|
|
55
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.56"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@markw65/peggy-optimizer": "^1.0.1",
|