@markw65/monkeyc-optimizer 1.1.36 → 1.1.37

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.
@@ -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 chunk_PVBIKZYZ_exports = {};
30
- __export(chunk_PVBIKZYZ_exports, {
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(chunk_PVBIKZYZ_exports);
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(message) {
5447
+ function log(...messages) {
5446
5448
  if (banner) {
5447
5449
  const b = banner;
5448
5450
  banner = null;
5449
5451
  theLogger(b());
5450
5452
  }
5451
- if (theLogger === console.log) {
5452
- theLogger(message);
5453
- } else {
5454
- theLogger(`${message}`);
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,
@@ -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: () => import_chunk_FD2NCZK4.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_FD2NCZK4.buildOptimizedProject,
23
- copyRecursiveAsNeeded: () => import_chunk_PVBIKZYZ.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_FD2NCZK4.defaultConfig,
25
- display: () => import_chunk_FD2NCZK4.display,
26
- generateApiMirTests: () => import_chunk_FD2NCZK4.generateApiMirTests,
27
- generateOneConfig: () => import_chunk_FD2NCZK4.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_FD2NCZK4.generateOptimizedProject,
29
- getConfig: () => import_chunk_FD2NCZK4.getConfig,
30
- getProjectAnalysis: () => import_chunk_FD2NCZK4.getProjectAnalysis,
31
- get_jungle: () => import_chunk_FD2NCZK4.get_jungle,
32
- isErrorWithLocation: () => import_chunk_FD2NCZK4.isErrorWithLocation,
33
- launchSimulator: () => import_chunk_FD2NCZK4.launchSimulator,
34
- manifestProducts: () => import_chunk_FD2NCZK4.manifestProducts,
35
- mctree: () => import_chunk_FD2NCZK4.mctree,
36
- simulateProgram: () => import_chunk_FD2NCZK4.simulateProgram
21
+ StateNodeAttributes: () => import_chunk_E67DP34P.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_E67DP34P.buildOptimizedProject,
23
+ copyRecursiveAsNeeded: () => import_chunk_SG7ODKRM.copyRecursiveAsNeeded,
24
+ defaultConfig: () => import_chunk_E67DP34P.defaultConfig,
25
+ display: () => import_chunk_E67DP34P.display,
26
+ generateOneConfig: () => import_chunk_E67DP34P.generateOneConfig,
27
+ generateOptimizedProject: () => import_chunk_E67DP34P.generateOptimizedProject,
28
+ getConfig: () => import_chunk_E67DP34P.getConfig,
29
+ getProjectAnalysis: () => import_chunk_E67DP34P.getProjectAnalysis,
30
+ get_jungle: () => import_chunk_E67DP34P.get_jungle,
31
+ isErrorWithLocation: () => import_chunk_E67DP34P.isErrorWithLocation,
32
+ launchSimulator: () => import_chunk_E67DP34P.launchSimulator,
33
+ manifestProducts: () => import_chunk_E67DP34P.manifestProducts,
34
+ mctree: () => import_chunk_E67DP34P.mctree,
35
+ simulateProgram: () => import_chunk_E67DP34P.simulateProgram
37
36
  });
38
37
  module.exports = __toCommonJS(optimizer_exports);
39
- var import_chunk_FD2NCZK4 = require("./chunk-FD2NCZK4.cjs");
40
- var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
38
+ var import_chunk_E67DP34P = require("./chunk-E67DP34P.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, import_chunk_FD2NCZK4.init_optimizer)();
42
+ (0, import_chunk_E67DP34P.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,
@@ -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: () => import_chunk_FD2NCZK4.SectionKinds,
22
- appSupport: () => import_chunk_FD2NCZK4.appSupport,
23
- connectiq: () => import_chunk_FD2NCZK4.connectiq,
24
- getDeviceInfo: () => import_chunk_FD2NCZK4.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_FD2NCZK4.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_FD2NCZK4.getLanguages,
27
- getSdkPath: () => import_chunk_FD2NCZK4.getSdkPath,
28
- isWin: () => import_chunk_FD2NCZK4.isWin,
29
- optimizeProgram: () => import_chunk_FD2NCZK4.optimizeProgram,
30
- readPrg: () => import_chunk_FD2NCZK4.readPrg,
31
- readPrgWithOffsets: () => import_chunk_FD2NCZK4.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_FD2NCZK4.xml_util_exports
21
+ SectionKinds: () => import_chunk_E67DP34P.SectionKinds,
22
+ appSupport: () => import_chunk_E67DP34P.appSupport,
23
+ connectiq: () => import_chunk_E67DP34P.connectiq,
24
+ getDeviceInfo: () => import_chunk_E67DP34P.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_E67DP34P.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_E67DP34P.getLanguages,
27
+ getSdkPath: () => import_chunk_E67DP34P.getSdkPath,
28
+ isWin: () => import_chunk_E67DP34P.isWin,
29
+ optimizeProgram: () => import_chunk_E67DP34P.optimizeProgram,
30
+ readPrg: () => import_chunk_E67DP34P.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_E67DP34P.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_E67DP34P.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_FD2NCZK4 = require("./chunk-FD2NCZK4.cjs");
36
- var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
35
+ var import_chunk_E67DP34P = require("./chunk-E67DP34P.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, import_chunk_FD2NCZK4.init_sdk_util)();
39
+ (0, import_chunk_E67DP34P.init_sdk_util)();
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  SectionKinds,
@@ -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 { visitorNode, visitReferences } from "./visitor";
9
- export { traverseAst, hasProperty, visit_resources };
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 formatAstLongLines(node: mctree.Node): string;
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,6 @@ 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 diagnostic(state: ProgramState, node: mctree.Node, message: string | null, type?: DiagnosticType, extra?: Diagnostic["extra"]): void;
50
- export declare function diagnosticHelper(diagnostics: Record<string, Diagnostic[]>, node: mctree.Node, message: string | null, type: DiagnosticType | undefined, extra: Diagnostic["extra"] | undefined, uniqueLocs: boolean): void;
50
+ export declare function diagnostic(state: ProgramState, node: mctree.Node, message: string | Promise<string> | null, type?: DiagnosticType, extra?: Diagnostic["extra"]): void;
51
+ 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
52
  export declare function getSuperClasses(klass: ClassStateNode): Set<StateNode> | null;
@@ -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): {
@@ -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 function log(message: unknown): void;
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, import("./optimizer-types").Diagnostic[]> | undefined;
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, Diagnostic[]>;
228
+ diagnostics?: Record<string, PreDiagnostic[]>;
226
229
  inlineDiagnostics?: Record<string, Diagnostic[]>;
227
230
  enumMap?: Map<EnumStringMember, EnumStateNode>;
228
231
  };
@@ -1,5 +1,5 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { get_jungle, JungleBuildDependencies, JungleError, JungleQualifier, JungleResourceMap, ResolvedJungle, Target } from "./jungles";
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 { display, ExactOrUnion } from "./type-flow/types";
11
- export { copyRecursiveAsNeeded, get_jungle, JungleBuildDependencies, JungleError, JungleResourceMap, launchSimulator, manifestProducts, mctree, ResolvedJungle, simulateProgram, TypeMap, };
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").Diagnostic[]> | undefined;
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").Diagnostic[]>;
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 { ProgramState, ProgramStateOptimizer } from "./optimizer-types";
3
- export declare function pragmaChecker(state: ProgramStateOptimizer, ast: mctree.Program, diagnostics: NonNullable<ProgramState["diagnostics"]>[string] | null | undefined): void;
2
+ import { Diagnostic, ProgramStateOptimizer } from "./optimizer-types";
3
+ export declare function pragmaChecker(state: ProgramStateOptimizer, ast: mctree.Program, diagnostics: Diagnostic[] | null | undefined): Promise<void>;
@@ -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 declare function evaluateBinaryTypes(op: mctree.BinaryOperator | "instanceof", left: ExactOrUnion, right: ExactOrUnion): ExactOrUnion;
4
- export declare function evaluateLogicalTypes(op: mctree.LogicalOperator, left: ExactOrUnion, right: ExactOrUnion): ExactOrUnion;
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): 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, Event, EventDecl } from "../data-flow";
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,14 @@ 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): {
191
+ type: number;
192
+ };
187
193
  export declare function typeFromTypeStateNode(state: ProgramStateAnalysis, sn: StateNodeDecl, classVsObj?: boolean): ExactOrUnion;
188
194
  export declare function typeFromTypeStateNodes(state: ProgramStateAnalysis, sns: StateNodeDecl[], classVsObj?: boolean): ExactOrUnion;
195
+ export declare function objectLiteralKeyFromExpr(key: mctree.Expression): string | null;
196
+ export declare function objectLiteralKeyFromType(key: ExactOrUnion): string | null;
197
+ export declare function typeFromObjectLiteralKey(key: string): ValueTypes;
189
198
  export declare function typeFromSingleTypeSpec(state: ProgramStateAnalysis, type: mctree.TypeSpecPart | mctree.ObjectExpression, stack?: ProgramStateStack | undefined): ExactOrUnion;
190
199
  export declare function typeFromTypespec(state: ProgramStateAnalysis, ts: mctree.TypeSpecList, stack?: ProgramStateStack | undefined): ExactOrUnion;
191
200
  export declare function typeFromLiteral(literal: mctree.Literal): ExactTypes;
@@ -1,5 +1,5 @@
1
1
  import glob from "fast-glob";
2
- export { logger, log, wouldLog, setBanner, bumpLogging } from "./logger";
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").Diagnostic[]> | undefined;
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").Diagnostic[]>;
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").Diagnostic[]> | undefined;
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
- GenericQueue: () => import_chunk_PVBIKZYZ.GenericQueue,
22
- bumpLogging: () => import_chunk_PVBIKZYZ.bumpLogging,
23
- copyRecursiveAsNeeded: () => import_chunk_PVBIKZYZ.copyRecursiveAsNeeded,
24
- every: () => import_chunk_PVBIKZYZ.every,
25
- first_modified: () => import_chunk_PVBIKZYZ.first_modified,
26
- forEach: () => import_chunk_PVBIKZYZ.forEach,
27
- globSome: () => import_chunk_PVBIKZYZ.globSome,
28
- globa: () => import_chunk_PVBIKZYZ.globa,
29
- last_modified: () => import_chunk_PVBIKZYZ.last_modified,
30
- log: () => import_chunk_PVBIKZYZ.log,
31
- logger: () => import_chunk_PVBIKZYZ.logger,
32
- map: () => import_chunk_PVBIKZYZ.map,
33
- popcount: () => import_chunk_PVBIKZYZ.popcount,
34
- promiseAll: () => import_chunk_PVBIKZYZ.promiseAll,
35
- pushUnique: () => import_chunk_PVBIKZYZ.pushUnique,
36
- readByLine: () => import_chunk_PVBIKZYZ.readByLine,
37
- reduce: () => import_chunk_PVBIKZYZ.reduce,
38
- sameArrays: () => import_chunk_PVBIKZYZ.sameArrays,
39
- setBanner: () => import_chunk_PVBIKZYZ.setBanner,
40
- some: () => import_chunk_PVBIKZYZ.some,
41
- spawnByLine: () => import_chunk_PVBIKZYZ.spawnByLine,
42
- wouldLog: () => import_chunk_PVBIKZYZ.wouldLog
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 import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
47
+ var import_chunk_SG7ODKRM = require("./chunk-SG7ODKRM.cjs");
46
48
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
47
- (0, import_chunk_PVBIKZYZ.init_util)();
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,
@@ -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 import_chunk_FD2NCZK4 = require("./chunk-FD2NCZK4.cjs");
25
- var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
24
+ var import_chunk_E67DP34P = require("./chunk-E67DP34P.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, import_chunk_FD2NCZK4.init_worker_task)();
31
+ (0, import_chunk_E67DP34P.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, import_chunk_FD2NCZK4.performTask)(task));
34
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_E67DP34P.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.36",
4
+ "version": "1.1.37",
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/prettier-plugin-monkeyc": "^1.0.52"
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",