@markw65/monkeyc-optimizer 1.1.36 → 1.1.38
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 +31 -0
- package/build/api.cjs +38 -32
- package/build/{chunk-FD2NCZK4.cjs → chunk-IMIM4BE2.cjs} +2755 -3115
- package/build/{chunk-PVBIKZYZ.cjs → chunk-SG7ODKRM.cjs} +40 -11
- package/build/optimizer.cjs +18 -20
- package/build/sdk-util.cjs +15 -15
- package/build/src/api.d.ts +10 -7
- package/build/src/data-flow.d.ts +1 -1
- package/build/src/logger.d.ts +2 -1
- package/build/src/mc-rewrite.d.ts +2 -2
- package/build/src/optimizer-types.d.ts +4 -1
- package/build/src/optimizer.d.ts +5 -11
- package/build/src/pragma-checker.d.ts +2 -2
- package/build/src/pre.d.ts +1 -1
- package/build/src/type-flow/dead-store.d.ts +1 -1
- package/build/src/type-flow/interp-binary.d.ts +10 -3
- package/build/src/type-flow/interp.d.ts +4 -1
- package/build/src/type-flow/type-flow-util.d.ts +2 -2
- package/build/src/type-flow/types.d.ts +8 -1
- package/build/src/util.d.ts +6 -1
- package/build/src/worker-task.d.ts +3 -3
- package/build/util.cjs +28 -24
- package/build/worker-thread.cjs +4 -4
- package/package.json +3 -2
|
@@ -26,8 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_SG7ODKRM_exports = {};
|
|
30
|
+
__export(chunk_SG7ODKRM_exports, {
|
|
31
|
+
AwaitedError: () => AwaitedError,
|
|
31
32
|
GenericQueue: () => GenericQueue,
|
|
32
33
|
bumpLogging: () => bumpLogging,
|
|
33
34
|
copyRecursiveAsNeeded: () => copyRecursiveAsNeeded,
|
|
@@ -40,6 +41,7 @@ __export(chunk_PVBIKZYZ_exports, {
|
|
|
40
41
|
init_util: () => init_util,
|
|
41
42
|
last_modified: () => last_modified,
|
|
42
43
|
log: () => log,
|
|
44
|
+
logPromise: () => logPromise,
|
|
43
45
|
logger: () => logger,
|
|
44
46
|
map: () => map,
|
|
45
47
|
popcount: () => popcount,
|
|
@@ -53,7 +55,7 @@ __export(chunk_PVBIKZYZ_exports, {
|
|
|
53
55
|
spawnByLine: () => spawnByLine,
|
|
54
56
|
wouldLog: () => wouldLog
|
|
55
57
|
});
|
|
56
|
-
module.exports = __toCommonJS(
|
|
58
|
+
module.exports = __toCommonJS(chunk_SG7ODKRM_exports);
|
|
57
59
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
58
60
|
var child_process = __toESM(require("child_process"));
|
|
59
61
|
var fsc = __toESM(require("fs"));
|
|
@@ -5442,17 +5444,31 @@ function bumpLogging(module2, amount) {
|
|
|
5442
5444
|
function setBanner(b) {
|
|
5443
5445
|
banner = b;
|
|
5444
5446
|
}
|
|
5445
|
-
function log(
|
|
5447
|
+
function log(...messages) {
|
|
5446
5448
|
if (banner) {
|
|
5447
5449
|
const b = banner;
|
|
5448
5450
|
banner = null;
|
|
5449
5451
|
theLogger(b());
|
|
5450
5452
|
}
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5453
|
+
messages.forEach((message) => {
|
|
5454
|
+
if (livePromises || message.then) {
|
|
5455
|
+
livePromises++;
|
|
5456
|
+
logPromise = logPromise.then(() => Promise.resolve(message)).then((m) => {
|
|
5457
|
+
livePromises--;
|
|
5458
|
+
if (theLogger === console.log) {
|
|
5459
|
+
theLogger(m);
|
|
5460
|
+
} else {
|
|
5461
|
+
theLogger(`${m}`);
|
|
5462
|
+
}
|
|
5463
|
+
});
|
|
5464
|
+
} else {
|
|
5465
|
+
if (theLogger === console.log) {
|
|
5466
|
+
theLogger(message);
|
|
5467
|
+
} else {
|
|
5468
|
+
theLogger(`${message}`);
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
});
|
|
5456
5472
|
}
|
|
5457
5473
|
function getLoggerSettings() {
|
|
5458
5474
|
const ls = /* @__PURE__ */ new Map();
|
|
@@ -5469,7 +5485,7 @@ function getLoggerSettings() {
|
|
|
5469
5485
|
}
|
|
5470
5486
|
return ls;
|
|
5471
5487
|
}
|
|
5472
|
-
var loggerSettings, loggerLevelOffset, theLogger, banner;
|
|
5488
|
+
var loggerSettings, loggerLevelOffset, theLogger, banner, logPromise, livePromises;
|
|
5473
5489
|
var init_logger = (0, import_chunk_ABYVSU2C.__esm)({
|
|
5474
5490
|
"src/logger.ts"() {
|
|
5475
5491
|
"use strict";
|
|
@@ -5477,6 +5493,8 @@ var init_logger = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
5477
5493
|
loggerLevelOffset = 0;
|
|
5478
5494
|
theLogger = console.log;
|
|
5479
5495
|
banner = null;
|
|
5496
|
+
logPromise = Promise.resolve();
|
|
5497
|
+
livePromises = 0;
|
|
5480
5498
|
}
|
|
5481
5499
|
});
|
|
5482
5500
|
function globa(pattern, options) {
|
|
@@ -5673,7 +5691,7 @@ function popcount(x) {
|
|
|
5673
5691
|
x += x >> 16;
|
|
5674
5692
|
return x & 127;
|
|
5675
5693
|
}
|
|
5676
|
-
var import_fast_glob, import_priorityqueuejs, GenericQueue;
|
|
5694
|
+
var import_fast_glob, import_priorityqueuejs, GenericQueue, AwaitedError;
|
|
5677
5695
|
var init_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
5678
5696
|
"src/util.ts"() {
|
|
5679
5697
|
import_fast_glob = (0, import_chunk_ABYVSU2C.__toESM)(require_out4());
|
|
@@ -5700,6 +5718,15 @@ var init_util = (0, import_chunk_ABYVSU2C.__esm)({
|
|
|
5700
5718
|
return this.queue.isEmpty();
|
|
5701
5719
|
}
|
|
5702
5720
|
};
|
|
5721
|
+
AwaitedError = class extends Error {
|
|
5722
|
+
constructor(messagePromise) {
|
|
5723
|
+
super();
|
|
5724
|
+
this.messagePromise = messagePromise;
|
|
5725
|
+
}
|
|
5726
|
+
resolve() {
|
|
5727
|
+
return this.messagePromise.then((message) => this.message = message);
|
|
5728
|
+
}
|
|
5729
|
+
};
|
|
5703
5730
|
}
|
|
5704
5731
|
});
|
|
5705
5732
|
/*! Bundled license information:
|
|
@@ -5752,6 +5779,7 @@ run-parallel/index.js:
|
|
|
5752
5779
|
*/
|
|
5753
5780
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5754
5781
|
0 && (module.exports = {
|
|
5782
|
+
AwaitedError,
|
|
5755
5783
|
GenericQueue,
|
|
5756
5784
|
bumpLogging,
|
|
5757
5785
|
copyRecursiveAsNeeded,
|
|
@@ -5764,6 +5792,7 @@ run-parallel/index.js:
|
|
|
5764
5792
|
init_util,
|
|
5765
5793
|
last_modified,
|
|
5766
5794
|
log,
|
|
5795
|
+
logPromise,
|
|
5767
5796
|
logger,
|
|
5768
5797
|
map,
|
|
5769
5798
|
popcount,
|
package/build/optimizer.cjs
CHANGED
|
@@ -18,29 +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: () =>
|
|
23
|
-
copyRecursiveAsNeeded: () =>
|
|
24
|
-
defaultConfig: () =>
|
|
25
|
-
display: () =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
simulateProgram: () => import_chunk_FD2NCZK4.simulateProgram
|
|
21
|
+
StateNodeAttributes: () => import_chunk_IMIM4BE2.StateNodeAttributes,
|
|
22
|
+
buildOptimizedProject: () => import_chunk_IMIM4BE2.buildOptimizedProject,
|
|
23
|
+
copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
|
|
24
|
+
defaultConfig: () => import_chunk_IMIM4BE2.defaultConfig,
|
|
25
|
+
display: () => import_chunk_IMIM4BE2.display,
|
|
26
|
+
generateOneConfig: () => import_chunk_IMIM4BE2.generateOneConfig,
|
|
27
|
+
generateOptimizedProject: () => import_chunk_IMIM4BE2.generateOptimizedProject,
|
|
28
|
+
getConfig: () => import_chunk_IMIM4BE2.getConfig,
|
|
29
|
+
getProjectAnalysis: () => import_chunk_IMIM4BE2.getProjectAnalysis,
|
|
30
|
+
get_jungle: () => import_chunk_IMIM4BE2.get_jungle,
|
|
31
|
+
isErrorWithLocation: () => import_chunk_IMIM4BE2.isErrorWithLocation,
|
|
32
|
+
launchSimulator: () => import_chunk_IMIM4BE2.launchSimulator,
|
|
33
|
+
manifestProducts: () => import_chunk_IMIM4BE2.manifestProducts,
|
|
34
|
+
mctree: () => import_chunk_IMIM4BE2.mctree,
|
|
35
|
+
simulateProgram: () => import_chunk_IMIM4BE2.simulateProgram
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(optimizer_exports);
|
|
39
|
-
var
|
|
40
|
-
var
|
|
38
|
+
var import_chunk_IMIM4BE2 = require("./chunk-IMIM4BE2.cjs");
|
|
39
|
+
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
41
40
|
var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
|
|
42
41
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
43
|
-
(0,
|
|
42
|
+
(0, import_chunk_IMIM4BE2.init_optimizer)();
|
|
44
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
44
|
0 && (module.exports = {
|
|
46
45
|
StateNodeAttributes,
|
|
@@ -48,7 +47,6 @@ var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
|
48
47
|
copyRecursiveAsNeeded,
|
|
49
48
|
defaultConfig,
|
|
50
49
|
display,
|
|
51
|
-
generateApiMirTests,
|
|
52
50
|
generateOneConfig,
|
|
53
51
|
generateOptimizedProject,
|
|
54
52
|
getConfig,
|
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_IMIM4BE2.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_IMIM4BE2.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_IMIM4BE2.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_IMIM4BE2.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_IMIM4BE2.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_IMIM4BE2.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_IMIM4BE2.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_IMIM4BE2.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_IMIM4BE2.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_IMIM4BE2.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_IMIM4BE2.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_IMIM4BE2.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var import_chunk_IMIM4BE2 = require("./chunk-IMIM4BE2.cjs");
|
|
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_IMIM4BE2.init_sdk_util)();
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
SectionKinds,
|
package/build/src/api.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
2
|
import { hasProperty, traverseAst } from "./ast";
|
|
3
3
|
import { JungleResourceMap } from "./jungles";
|
|
4
|
-
import { ClassStateNode, Diagnostic, DiagnosticType, EnumStateNode, FunctionInfo, FunctionStateNode, LookupDefinition, LookupResult, ModuleStateNode, ProgramState, ProgramStateAnalysis, ProgramStateLive, ProgramStateNode, ProgramStateStack, StateNode, StateNodeDecl, TypedefStateNode, VariableStateNode } from "./optimizer-types";
|
|
4
|
+
import { ClassStateNode, Diagnostic, DiagnosticType, EnumStateNode, FunctionInfo, FunctionStateNode, LookupDefinition, LookupResult, ModuleStateNode, PreDiagnostic, ProgramState, ProgramStateAnalysis, ProgramStateLive, ProgramStateNode, ProgramStateStack, StateNode, StateNodeDecl, TypedefStateNode, VariableStateNode } from "./optimizer-types";
|
|
5
5
|
import { visit_resources } from "./resources";
|
|
6
6
|
import { xmlUtil } from "./sdk-util";
|
|
7
7
|
import { TypeMap } from "./type-flow/interp";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { visitReferences, visitorNode } from "./visitor";
|
|
9
|
+
export { hasProperty, traverseAst, visit_resources };
|
|
10
10
|
export declare function parseSdkVersion(version: string | undefined): number;
|
|
11
11
|
export declare function checkCompilerVersion(version: string, sdkVer: number): boolean | undefined;
|
|
12
12
|
export declare function getApiMapping(state?: ProgramState, resourcesMap?: Record<string, JungleResourceMap>, manifestXML?: xmlUtil.Document): Promise<ProgramStateNode>;
|
|
@@ -21,13 +21,14 @@ export declare function isLookupCandidate(node: mctree.MemberExpression): false
|
|
|
21
21
|
export declare function lookupNext(state: ProgramStateLive, results: LookupDefinition[], decls: DeclKind, property: mctree.Identifier): LookupDefinition[] | null;
|
|
22
22
|
export declare function lookupWithType(state: ProgramStateAnalysis, node: mctree.Node, typeMap: TypeMap | undefined | null, nonLocal?: boolean, stack?: ProgramStateStack | null): LookupResult;
|
|
23
23
|
export declare function collectNamespaces(ast: mctree.Program, stateIn?: ProgramState): ProgramStateNode;
|
|
24
|
-
export declare function formatAst(node: mctree.Node, monkeyCSource?: string | null, options?: Record<string, unknown> | null): string
|
|
24
|
+
export declare function formatAst(node: mctree.Node, monkeyCSource?: string | null, options?: Record<string, unknown> | null): Promise<string>;
|
|
25
25
|
export declare function findNamesInScope(declStack: StateNode[][], pattern: string | RegExp): (readonly [StateNodeDecl, {
|
|
26
26
|
readonly parent: StateNode;
|
|
27
27
|
readonly depth: number;
|
|
28
28
|
}])[];
|
|
29
29
|
export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | FunctionStateNode | ClassStateNode | ModuleStateNode | ProgramStateNode | VariableStateNode | import("./optimizer-types").BlockStateNode | TypedefStateNode | EnumStateNode)[];
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function formatScopedName(node: mctree.ScopedName | mctree.ThisExpression): string;
|
|
31
|
+
export declare function formatAstLongLines(node: mctree.Node): Promise<string>;
|
|
31
32
|
export declare function createDocumentationMap(functionDocumentation: {
|
|
32
33
|
name: string;
|
|
33
34
|
parent: string;
|
|
@@ -46,6 +47,8 @@ export declare function getApiFunctionInfo(state: ProgramState, func: FunctionSt
|
|
|
46
47
|
export declare function markInvokeClassMethod(state: ProgramStateAnalysis, func: FunctionStateNode): void;
|
|
47
48
|
export declare function isLocal(v: VariableStateNode): boolean;
|
|
48
49
|
export declare function isClassVariable(v: VariableStateNode): boolean;
|
|
49
|
-
export declare function
|
|
50
|
-
export declare function
|
|
50
|
+
export declare function resolveDiagnostics(diagnostics?: PreDiagnostic[]): Promise<Diagnostic[]> | undefined;
|
|
51
|
+
export declare function resolveDiagnosticsMap(diagnosticsMap: Record<string, PreDiagnostic[]>): Promise<Record<string, Diagnostic[]>>;
|
|
52
|
+
export declare function diagnostic(state: ProgramState, node: mctree.Node, message: string | Promise<string> | null, type?: DiagnosticType, extra?: Diagnostic["extra"]): void;
|
|
53
|
+
export declare function diagnosticHelper(diagnostics: Record<string, PreDiagnostic[]>, node: mctree.Node, message: string | Promise<string> | null, type: DiagnosticType | undefined, extra: Diagnostic["extra"] | undefined): void;
|
|
51
54
|
export declare function getSuperClasses(klass: ClassStateNode): Set<StateNode> | null;
|
package/build/src/data-flow.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export type Event = RefEvent | KillEvent | DefEvent | ModEvent | FlowEvent | Exn
|
|
|
95
95
|
export interface DataFlowBlock extends Block<Event> {
|
|
96
96
|
order?: number;
|
|
97
97
|
}
|
|
98
|
-
export declare function declFullName(decl: EventDecl): string
|
|
98
|
+
export declare function declFullName(decl: EventDecl): Promise<string>;
|
|
99
99
|
export declare function declName(decl: EventDecl): string | undefined;
|
|
100
100
|
export declare function unhandledType(node: never): never;
|
|
101
101
|
export declare function buildDataFlowGraph(state: ProgramStateAnalysis, func: FunctionStateNode, wantsLiteral: (literal: mctree.Literal) => boolean, trackInsertionPoints: boolean, wantsAllRefs: boolean): {
|
package/build/src/logger.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export declare function logger(module: string, level: number, message: unknown):
|
|
|
2
2
|
export declare function wouldLog(module: string, level: number): boolean;
|
|
3
3
|
export declare function bumpLogging(module: string | null, amount: number): void;
|
|
4
4
|
export declare function setBanner(b: (() => string) | null): void;
|
|
5
|
-
export declare
|
|
5
|
+
export declare let logPromise: Promise<unknown>;
|
|
6
|
+
export declare function log(...messages: unknown[]): void;
|
|
6
7
|
export declare function setLogger(log: (message: string) => void): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
2
|
import { JungleResourceMap } from "./jungles";
|
|
3
|
-
import { BuildConfig, FilesToOptimizeMap, LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
|
|
3
|
+
import { BuildConfig, Diagnostic, FilesToOptimizeMap, LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
|
|
4
4
|
import { xmlUtil } from "./sdk-util";
|
|
5
5
|
export declare function getFileSources(fnMap: FilesToOptimizeMap): Promise<void>;
|
|
6
6
|
export declare function getFileASTs(fnMap: FilesToOptimizeMap): Promise<boolean>;
|
|
@@ -8,6 +8,6 @@ export declare function analyze(fnMap: FilesToOptimizeMap, resourcesMap: Record<
|
|
|
8
8
|
export declare function reportMissingSymbols(state: ProgramStateAnalysis, config?: BuildConfig): void;
|
|
9
9
|
export declare function getLiteralFromDecls(lookupDefns: LookupDefinition[]): mctree.Literal | mctree.AsExpression | null;
|
|
10
10
|
export declare function optimizeMonkeyC(fnMap: FilesToOptimizeMap, resourcesMap: Record<string, JungleResourceMap>, manifestXML: xmlUtil.Document, config: BuildConfig): Promise<{
|
|
11
|
-
diagnostics: Record<string,
|
|
11
|
+
diagnostics: Record<string, Diagnostic[]> | undefined;
|
|
12
12
|
sdkVersion: number | undefined;
|
|
13
13
|
}>;
|
|
@@ -161,6 +161,9 @@ export interface Diagnostic extends DiagnosticBase {
|
|
|
161
161
|
message: string;
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
+
export type PreDiagnostic = Omit<Diagnostic, "message"> & {
|
|
165
|
+
message: string | Promise<string> | null;
|
|
166
|
+
};
|
|
164
167
|
type ProgramStateStackElem = {
|
|
165
168
|
sn: StateNode;
|
|
166
169
|
usings?: Record<string, ImportUsing>;
|
|
@@ -222,7 +225,7 @@ export type ProgramState = {
|
|
|
222
225
|
constants?: {
|
|
223
226
|
[key: string]: mctree.Literal;
|
|
224
227
|
};
|
|
225
|
-
diagnostics?: Record<string,
|
|
228
|
+
diagnostics?: Record<string, PreDiagnostic[]>;
|
|
226
229
|
inlineDiagnostics?: Record<string, Diagnostic[]>;
|
|
227
230
|
enumMap?: Map<EnumStringMember, EnumStateNode>;
|
|
228
231
|
};
|
package/build/src/optimizer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import {
|
|
2
|
+
import { JungleBuildDependencies, JungleError, JungleQualifier, JungleResourceMap, ResolvedJungle, Target, get_jungle } from "./jungles";
|
|
3
3
|
import { launchSimulator, simulateProgram } from "./launch";
|
|
4
4
|
import { manifestProducts } from "./manifest";
|
|
5
5
|
import { BuildConfig, FilesToOptimizeMap, ProgramState, ProgramStateAnalysis } from "./optimizer-types";
|
|
@@ -7,8 +7,8 @@ import { xmlUtil } from "./sdk-util";
|
|
|
7
7
|
import { TypeMap } from "./type-flow/interp";
|
|
8
8
|
import { copyRecursiveAsNeeded } from "./util";
|
|
9
9
|
export * from "./optimizer-types";
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
10
|
+
export { ExactOrUnion, display } from "./type-flow/types";
|
|
11
|
+
export { JungleBuildDependencies, JungleError, JungleResourceMap, ResolvedJungle, TypeMap, copyRecursiveAsNeeded, get_jungle, launchSimulator, manifestProducts, mctree, simulateProgram, };
|
|
12
12
|
export declare const defaultConfig: {
|
|
13
13
|
outputPath: string;
|
|
14
14
|
workspace: string;
|
|
@@ -50,7 +50,7 @@ export declare function buildOptimizedProject(product: string | null, options: B
|
|
|
50
50
|
program: string;
|
|
51
51
|
product: string | null;
|
|
52
52
|
hasTests: boolean;
|
|
53
|
-
diagnostics: Record<string, import("./optimizer-types").
|
|
53
|
+
diagnostics: Record<string, import("./optimizer-types").PreDiagnostic[]> | undefined;
|
|
54
54
|
}>;
|
|
55
55
|
export declare function generateOptimizedProject(options: BuildConfig): Promise<{
|
|
56
56
|
jungleFiles: string | undefined;
|
|
@@ -63,7 +63,7 @@ export declare function generateOptimizedProject(options: BuildConfig): Promise<
|
|
|
63
63
|
xml: xmlUtil.Document;
|
|
64
64
|
program: string;
|
|
65
65
|
hasTests: boolean;
|
|
66
|
-
diagnostics: Record<string, import("./optimizer-types").
|
|
66
|
+
diagnostics: Record<string, import("./optimizer-types").PreDiagnostic[]>;
|
|
67
67
|
}>;
|
|
68
68
|
export type PreAnalysis = {
|
|
69
69
|
fnMap: FilesToOptimizeMap;
|
|
@@ -92,9 +92,3 @@ export declare function generateOneConfig(buildConfig: JungleQualifier, manifest
|
|
|
92
92
|
sdkVersion: number | undefined;
|
|
93
93
|
}>;
|
|
94
94
|
export declare function getProjectAnalysis(targets: Target[], analysis: PreAnalysis | null, manifestXML: xmlUtil.Document, options: BuildConfig): Promise<Analysis | PreAnalysis>;
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {BuildConfig} options
|
|
98
|
-
* @returns
|
|
99
|
-
*/
|
|
100
|
-
export declare function generateApiMirTests(options: BuildConfig): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import {
|
|
3
|
-
export declare function pragmaChecker(state: ProgramStateOptimizer, ast: mctree.Program, diagnostics:
|
|
2
|
+
import { Diagnostic, ProgramStateOptimizer } from "./optimizer-types";
|
|
3
|
+
export declare function pragmaChecker(state: ProgramStateOptimizer, ast: mctree.Program, diagnostics: Diagnostic[] | null | undefined): Promise<void>;
|
package/build/src/pre.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
|
|
2
|
-
export declare function sizeBasedPRE(state: ProgramStateAnalysis, func: FunctionStateNode): void
|
|
2
|
+
export declare function sizeBasedPRE(state: ProgramStateAnalysis, func: FunctionStateNode): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { NodeEquivMap } from "../type-flow";
|
|
3
2
|
import { FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
|
|
3
|
+
import { NodeEquivMap } from "../type-flow";
|
|
4
4
|
import { TypeFlowBlock, TypeStateKey } from "./type-flow-util";
|
|
5
5
|
export type CopyPropStores = Map<mctree.Node, {
|
|
6
6
|
ref: mctree.Node;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { ExactOrUnion } from "./types";
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import { ExactOrUnion, TypeTag } from "./types";
|
|
3
|
+
export type OpMatch = {
|
|
4
|
+
mismatch?: Map<TypeTag, TypeTag>;
|
|
5
|
+
};
|
|
6
|
+
export declare function evaluateBinaryTypes(op: mctree.BinaryOperator | "instanceof", left: ExactOrUnion, right: ExactOrUnion): {
|
|
7
|
+
type: ExactOrUnion;
|
|
8
|
+
} & OpMatch;
|
|
9
|
+
export declare function evaluateLogicalTypes(op: mctree.LogicalOperator, left: ExactOrUnion, right: ExactOrUnion): {
|
|
10
|
+
type: ExactOrUnion;
|
|
11
|
+
} & OpMatch;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
2
|
import { DiagnosticType, FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
|
|
3
|
+
import { OpMatch } from "./interp-binary";
|
|
3
4
|
import { ExactOrUnion, ObjectType } from "./types";
|
|
4
5
|
export type TypeMap = Map<mctree.Node, ExactOrUnion>;
|
|
5
6
|
export type InterpStackElem = {
|
|
@@ -24,7 +25,9 @@ export declare function evaluateExpr(state: ProgramStateAnalysis, expr: mctree.E
|
|
|
24
25
|
export declare function preEvaluate(istate: InterpState, node: mctree.Node): null | (keyof mctree.NodeAll)[];
|
|
25
26
|
export declare function evaluate(istate: InterpState, node: mctree.Expression): InterpStackElem;
|
|
26
27
|
export declare function evaluate(istate: InterpState, node: mctree.Node): InterpStackElem | undefined;
|
|
27
|
-
export declare function evaluateUnaryTypes(op: mctree.UnaryOperator, argument: ExactOrUnion):
|
|
28
|
+
export declare function evaluateUnaryTypes(op: mctree.UnaryOperator, argument: ExactOrUnion): {
|
|
29
|
+
type: ExactOrUnion;
|
|
30
|
+
} & OpMatch;
|
|
28
31
|
export declare function deEnumerate(t: ExactOrUnion): ExactOrUnion;
|
|
29
32
|
export declare function evaluateNode(istate: InterpState, node: mctree.Node): void;
|
|
30
33
|
export declare function roundToFloat(value: number): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
-
import { DataFlowBlock as TypeFlowBlock
|
|
2
|
+
import { Event, EventDecl, DataFlowBlock as TypeFlowBlock } from "../data-flow";
|
|
3
3
|
import { ProgramStateAnalysis, StateNode, VariableStateNode } from "../optimizer-types";
|
|
4
4
|
import { InterpState } from "./interp";
|
|
5
5
|
import { ExactOrUnion } from "./types";
|
|
@@ -14,7 +14,7 @@ export type TypeStateKey = Exclude<EventDecl, {
|
|
|
14
14
|
export declare function tsKey(key: TypeStateKey): string;
|
|
15
15
|
export declare function sourceLocation(loc: mctree.SourceLocation | null | undefined): string;
|
|
16
16
|
export declare function printBlockHeader(block: TypeFlowBlock): void;
|
|
17
|
-
export declare function describeEvent(event: Event): string
|
|
17
|
+
export declare function describeEvent(event: Event): Promise<string>;
|
|
18
18
|
export declare function printBlockEvents(block: TypeFlowBlock, extra?: (event: Event) => string): void;
|
|
19
19
|
export declare function printBlockTrailer(block: TypeFlowBlock): void;
|
|
20
20
|
export declare function findObjectDeclsByProperty(state: ProgramStateAnalysis, object: ExactOrUnion, next: mctree.DottedMemberExpression): readonly [null, null] | [StateNode[], StateNode[]];
|
|
@@ -41,6 +41,9 @@ interface AbstractValue {
|
|
|
41
41
|
value?: unknown;
|
|
42
42
|
}
|
|
43
43
|
export type ExactTypes = NullType | FalseType | TrueType | NumberType | LongType | FloatType | DoubleType | CharType | StringType | ArrayType | DictionaryType | MethodType | ModuleType | FunctionType | ClassType | ObjectType | EnumType | SymbolType | TypedefType;
|
|
44
|
+
export type ObjectLiteralType = Map<string, ExactOrUnion> & {
|
|
45
|
+
value?: undefined;
|
|
46
|
+
};
|
|
44
47
|
type ExactPairHelper<T> = T extends ExactTypes ? {
|
|
45
48
|
type: T["type"];
|
|
46
49
|
avalue: T["value"];
|
|
@@ -106,7 +109,7 @@ export interface DictionaryType extends AbstractValue {
|
|
|
106
109
|
value?: {
|
|
107
110
|
key: ExactOrUnion;
|
|
108
111
|
value: ExactOrUnion;
|
|
109
|
-
} | undefined;
|
|
112
|
+
} | ObjectLiteralType | undefined;
|
|
110
113
|
}
|
|
111
114
|
export interface MethodType extends AbstractValue {
|
|
112
115
|
type: TypeTag.Method;
|
|
@@ -184,8 +187,12 @@ export declare function isSingleton(v: AbstractValue): v is SingletonType;
|
|
|
184
187
|
export declare function hasValue(v: AbstractValue): v is WithValue<ExactTypes>;
|
|
185
188
|
export declare function hasNoData(v: AbstractValue, t: TypeTag): boolean;
|
|
186
189
|
export declare function cloneType<T extends ExactOrUnion>(t: T): T;
|
|
190
|
+
export declare function relaxType(type: ExactOrUnion): ExactOrUnion;
|
|
187
191
|
export declare function typeFromTypeStateNode(state: ProgramStateAnalysis, sn: StateNodeDecl, classVsObj?: boolean): ExactOrUnion;
|
|
188
192
|
export declare function typeFromTypeStateNodes(state: ProgramStateAnalysis, sns: StateNodeDecl[], classVsObj?: boolean): ExactOrUnion;
|
|
193
|
+
export declare function objectLiteralKeyFromExpr(key: mctree.Expression): string | null;
|
|
194
|
+
export declare function objectLiteralKeyFromType(key: ExactOrUnion): string | null;
|
|
195
|
+
export declare function typeFromObjectLiteralKey(key: string): ValueTypes;
|
|
189
196
|
export declare function typeFromSingleTypeSpec(state: ProgramStateAnalysis, type: mctree.TypeSpecPart | mctree.ObjectExpression, stack?: ProgramStateStack | undefined): ExactOrUnion;
|
|
190
197
|
export declare function typeFromTypespec(state: ProgramStateAnalysis, ts: mctree.TypeSpecList, stack?: ProgramStateStack | undefined): ExactOrUnion;
|
|
191
198
|
export declare function typeFromLiteral(literal: mctree.Literal): ExactTypes;
|
package/build/src/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import glob from "fast-glob";
|
|
2
|
-
export {
|
|
2
|
+
export { bumpLogging, log, logPromise, logger, setBanner, wouldLog, } from "./logger";
|
|
3
3
|
export declare function globa(pattern: string, options?: glob.Options & {
|
|
4
4
|
mark?: boolean;
|
|
5
5
|
}): Promise<Array<string>>;
|
|
@@ -31,3 +31,8 @@ export declare class GenericQueue<Block> {
|
|
|
31
31
|
dequeue(): Block;
|
|
32
32
|
empty(): boolean;
|
|
33
33
|
}
|
|
34
|
+
export declare class AwaitedError extends Error {
|
|
35
|
+
private messagePromise;
|
|
36
|
+
constructor(messagePromise: Promise<string>);
|
|
37
|
+
resolve(): Promise<string>;
|
|
38
|
+
}
|
|
@@ -52,7 +52,7 @@ export declare const workerTaskHandlers: {
|
|
|
52
52
|
program: string;
|
|
53
53
|
product: string | null;
|
|
54
54
|
hasTests: boolean;
|
|
55
|
-
diagnostics: Record<string, import("./optimizer-types").
|
|
55
|
+
diagnostics: Record<string, import("./optimizer-types").PreDiagnostic[]> | undefined;
|
|
56
56
|
}>;
|
|
57
57
|
readonly generateOptimizedProject: (data: GenerateOptimizedProject["data"]) => Promise<{
|
|
58
58
|
jungleFiles: string | undefined;
|
|
@@ -65,11 +65,11 @@ export declare const workerTaskHandlers: {
|
|
|
65
65
|
xml: xmlUtil.Document;
|
|
66
66
|
program: string;
|
|
67
67
|
hasTests: boolean;
|
|
68
|
-
diagnostics: Record<string, import("./optimizer-types").
|
|
68
|
+
diagnostics: Record<string, import("./optimizer-types").PreDiagnostic[]>;
|
|
69
69
|
}>;
|
|
70
70
|
readonly generateOneConfig: (data: GenerateOneConfig["data"]) => Promise<{
|
|
71
71
|
hasTests: boolean;
|
|
72
|
-
diagnostics: Record<string, import("./optimizer-types").
|
|
72
|
+
diagnostics: Record<string, import("./optimizer-types").PreDiagnostic[]> | undefined;
|
|
73
73
|
sdkVersion: number | undefined;
|
|
74
74
|
}>;
|
|
75
75
|
readonly optimizePrgAndDebug: (data: OptimizePrgAndDebug["data"]) => Promise<{
|
package/build/util.cjs
CHANGED
|
@@ -18,35 +18,38 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var util_exports = {};
|
|
20
20
|
__export(util_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
AwaitedError: () => import_chunk_SG7ODKRM.AwaitedError,
|
|
22
|
+
GenericQueue: () => import_chunk_SG7ODKRM.GenericQueue,
|
|
23
|
+
bumpLogging: () => import_chunk_SG7ODKRM.bumpLogging,
|
|
24
|
+
copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
|
|
25
|
+
every: () => import_chunk_SG7ODKRM.every,
|
|
26
|
+
first_modified: () => import_chunk_SG7ODKRM.first_modified,
|
|
27
|
+
forEach: () => import_chunk_SG7ODKRM.forEach,
|
|
28
|
+
globSome: () => import_chunk_SG7ODKRM.globSome,
|
|
29
|
+
globa: () => import_chunk_SG7ODKRM.globa,
|
|
30
|
+
last_modified: () => import_chunk_SG7ODKRM.last_modified,
|
|
31
|
+
log: () => import_chunk_SG7ODKRM.log,
|
|
32
|
+
logPromise: () => import_chunk_SG7ODKRM.logPromise,
|
|
33
|
+
logger: () => import_chunk_SG7ODKRM.logger,
|
|
34
|
+
map: () => import_chunk_SG7ODKRM.map,
|
|
35
|
+
popcount: () => import_chunk_SG7ODKRM.popcount,
|
|
36
|
+
promiseAll: () => import_chunk_SG7ODKRM.promiseAll,
|
|
37
|
+
pushUnique: () => import_chunk_SG7ODKRM.pushUnique,
|
|
38
|
+
readByLine: () => import_chunk_SG7ODKRM.readByLine,
|
|
39
|
+
reduce: () => import_chunk_SG7ODKRM.reduce,
|
|
40
|
+
sameArrays: () => import_chunk_SG7ODKRM.sameArrays,
|
|
41
|
+
setBanner: () => import_chunk_SG7ODKRM.setBanner,
|
|
42
|
+
some: () => import_chunk_SG7ODKRM.some,
|
|
43
|
+
spawnByLine: () => import_chunk_SG7ODKRM.spawnByLine,
|
|
44
|
+
wouldLog: () => import_chunk_SG7ODKRM.wouldLog
|
|
43
45
|
});
|
|
44
46
|
module.exports = __toCommonJS(util_exports);
|
|
45
|
-
var
|
|
47
|
+
var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
|
|
46
48
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
47
|
-
(0,
|
|
49
|
+
(0, import_chunk_SG7ODKRM.init_util)();
|
|
48
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
51
|
0 && (module.exports = {
|
|
52
|
+
AwaitedError,
|
|
50
53
|
GenericQueue,
|
|
51
54
|
bumpLogging,
|
|
52
55
|
copyRecursiveAsNeeded,
|
|
@@ -57,6 +60,7 @@ var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
|
57
60
|
globa,
|
|
58
61
|
last_modified,
|
|
59
62
|
log,
|
|
63
|
+
logPromise,
|
|
60
64
|
logger,
|
|
61
65
|
map,
|
|
62
66
|
popcount,
|
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
|
|
25
|
-
var
|
|
24
|
+
var import_chunk_IMIM4BE2 = require("./chunk-IMIM4BE2.cjs");
|
|
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_IMIM4BE2.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_IMIM4BE2.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.38",
|
|
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",
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
"author": "markw65",
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@markw65/
|
|
52
|
+
"@markw65/peggy-optimizer": "^1.0.1",
|
|
53
|
+
"@markw65/prettier-plugin-monkeyc": "^1.0.53"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/chai": "^4.3.4",
|