@markw65/monkeyc-optimizer 1.1.34 → 1.1.35

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +959 -0
  2. package/README.md +9 -1
  3. package/build/api.cjs +31 -31
  4. package/build/{chunk-QBCVUVLD.cjs → chunk-Q5WTV4CN.cjs} +944 -2248
  5. package/build/optimizer.cjs +17 -17
  6. package/build/sdk-util.cjs +14 -14
  7. package/build/src/api.d.ts +1 -1
  8. package/build/src/type-flow/types.d.ts +1 -1
  9. package/build/worker-thread.cjs +3 -3
  10. package/package.json +2 -1
  11. package/build/src/readprg/switch.d.ts +0 -5
  12. package/build/src/src/api.d.ts +0 -51
  13. package/build/src/src/ast.d.ts +0 -59
  14. package/build/src/src/build.d.ts +0 -7
  15. package/build/src/src/cftinfo.d.ts +0 -32
  16. package/build/src/src/control-flow.d.ts +0 -22
  17. package/build/src/src/data-flow.d.ts +0 -107
  18. package/build/src/src/driver.d.ts +0 -2
  19. package/build/src/src/function-info.d.ts +0 -14
  20. package/build/src/src/inliner.d.ts +0 -13
  21. package/build/src/src/jungles.d.ts +0 -66
  22. package/build/src/src/launch.d.ts +0 -5
  23. package/build/src/src/logger.d.ts +0 -6
  24. package/build/src/src/manifest.d.ts +0 -11
  25. package/build/src/src/mc-rewrite.d.ts +0 -13
  26. package/build/src/src/negative-fixups.d.ts +0 -1
  27. package/build/src/src/optimizer-types.d.ts +0 -249
  28. package/build/src/src/optimizer.d.ts +0 -100
  29. package/build/src/src/pragma-checker.d.ts +0 -3
  30. package/build/src/src/pre.d.ts +0 -2
  31. package/build/src/src/projects.d.ts +0 -26
  32. package/build/src/src/readprg/array-init.d.ts +0 -3
  33. package/build/src/src/readprg/bytecode.d.ts +0 -72
  34. package/build/src/src/readprg/cflow.d.ts +0 -17
  35. package/build/src/src/readprg/data.d.ts +0 -4
  36. package/build/src/src/readprg/dce.d.ts +0 -6
  37. package/build/src/src/readprg/emit.d.ts +0 -23
  38. package/build/src/src/readprg/exceptions.d.ts +0 -10
  39. package/build/src/src/readprg/header.d.ts +0 -15
  40. package/build/src/src/readprg/interp.d.ts +0 -21
  41. package/build/src/src/readprg/linenum.d.ts +0 -29
  42. package/build/src/src/readprg/locals.d.ts +0 -3
  43. package/build/src/src/readprg/opcodes.d.ts +0 -279
  44. package/build/src/src/readprg/optimize.d.ts +0 -3
  45. package/build/src/src/readprg/pre.d.ts +0 -2
  46. package/build/src/src/readprg/sharing.d.ts +0 -2
  47. package/build/src/src/readprg/signer.d.ts +0 -8
  48. package/build/src/src/readprg/symbols.d.ts +0 -19
  49. package/build/src/src/readprg.d.ts +0 -25
  50. package/build/src/src/resources.d.ts +0 -12
  51. package/build/src/src/sdk-util.d.ts +0 -28
  52. package/build/src/src/type-flow/could-be.d.ts +0 -5
  53. package/build/src/src/type-flow/dead-store.d.ts +0 -18
  54. package/build/src/src/type-flow/interp-binary.d.ts +0 -4
  55. package/build/src/src/type-flow/interp-call.d.ts +0 -16
  56. package/build/src/src/type-flow/interp.d.ts +0 -33
  57. package/build/src/src/type-flow/intersection-type.d.ts +0 -4
  58. package/build/src/src/type-flow/minimize-locals.d.ts +0 -4
  59. package/build/src/src/type-flow/minimize-modules.d.ts +0 -3
  60. package/build/src/src/type-flow/optimize.d.ts +0 -7
  61. package/build/src/src/type-flow/sub-type.d.ts +0 -2
  62. package/build/src/src/type-flow/type-flow-util.d.ts +0 -27
  63. package/build/src/src/type-flow/types.d.ts +0 -204
  64. package/build/src/src/type-flow/union-type.d.ts +0 -4
  65. package/build/src/src/type-flow.d.ts +0 -18
  66. package/build/src/src/unused-exprs.d.ts +0 -3
  67. package/build/src/src/util.d.ts +0 -33
  68. package/build/src/src/variable-renamer.d.ts +0 -4
  69. package/build/src/src/visitor.d.ts +0 -5
  70. package/build/src/src/worker-pool.d.ts +0 -4
  71. package/build/src/src/worker-task.d.ts +0 -88
  72. package/build/src/src/worker-thread.d.ts +0 -1
  73. package/build/src/src/xml-util.d.ts +0 -172
  74. package/build/src/test/mocha/bytecode.spec.d.ts +0 -1
  75. package/build/src/test/mocha/coudbe.spec.d.ts +0 -2
  76. package/build/src/test/mocha/intersection.spec.d.ts +0 -2
  77. package/build/src/test/mocha/root.spec.d.ts +0 -1
  78. package/build/src/test/mocha/subtype.spec.d.ts +0 -2
  79. package/build/src/test/mocha/test-utils.d.ts +0 -6
  80. package/build/src/test/mocha/types.spec.d.ts +0 -1
@@ -18,29 +18,29 @@ 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_QBCVUVLD.StateNodeAttributes,
22
- buildOptimizedProject: () => import_chunk_QBCVUVLD.buildOptimizedProject,
21
+ StateNodeAttributes: () => import_chunk_Q5WTV4CN.StateNodeAttributes,
22
+ buildOptimizedProject: () => import_chunk_Q5WTV4CN.buildOptimizedProject,
23
23
  copyRecursiveAsNeeded: () => import_chunk_PVBIKZYZ.copyRecursiveAsNeeded,
24
- defaultConfig: () => import_chunk_QBCVUVLD.defaultConfig,
25
- display: () => import_chunk_QBCVUVLD.display,
26
- generateApiMirTests: () => import_chunk_QBCVUVLD.generateApiMirTests,
27
- generateOneConfig: () => import_chunk_QBCVUVLD.generateOneConfig,
28
- generateOptimizedProject: () => import_chunk_QBCVUVLD.generateOptimizedProject,
29
- getConfig: () => import_chunk_QBCVUVLD.getConfig,
30
- getProjectAnalysis: () => import_chunk_QBCVUVLD.getProjectAnalysis,
31
- get_jungle: () => import_chunk_QBCVUVLD.get_jungle,
32
- isErrorWithLocation: () => import_chunk_QBCVUVLD.isErrorWithLocation,
33
- launchSimulator: () => import_chunk_QBCVUVLD.launchSimulator,
34
- manifestProducts: () => import_chunk_QBCVUVLD.manifestProducts,
35
- mctree: () => import_chunk_QBCVUVLD.mctree,
36
- simulateProgram: () => import_chunk_QBCVUVLD.simulateProgram
24
+ defaultConfig: () => import_chunk_Q5WTV4CN.defaultConfig,
25
+ display: () => import_chunk_Q5WTV4CN.display,
26
+ generateApiMirTests: () => import_chunk_Q5WTV4CN.generateApiMirTests,
27
+ generateOneConfig: () => import_chunk_Q5WTV4CN.generateOneConfig,
28
+ generateOptimizedProject: () => import_chunk_Q5WTV4CN.generateOptimizedProject,
29
+ getConfig: () => import_chunk_Q5WTV4CN.getConfig,
30
+ getProjectAnalysis: () => import_chunk_Q5WTV4CN.getProjectAnalysis,
31
+ get_jungle: () => import_chunk_Q5WTV4CN.get_jungle,
32
+ isErrorWithLocation: () => import_chunk_Q5WTV4CN.isErrorWithLocation,
33
+ launchSimulator: () => import_chunk_Q5WTV4CN.launchSimulator,
34
+ manifestProducts: () => import_chunk_Q5WTV4CN.manifestProducts,
35
+ mctree: () => import_chunk_Q5WTV4CN.mctree,
36
+ simulateProgram: () => import_chunk_Q5WTV4CN.simulateProgram
37
37
  });
38
38
  module.exports = __toCommonJS(optimizer_exports);
39
- var import_chunk_QBCVUVLD = require("./chunk-QBCVUVLD.cjs");
39
+ var import_chunk_Q5WTV4CN = require("./chunk-Q5WTV4CN.cjs");
40
40
  var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.cjs");
41
41
  var import_chunk_MBTLUWXR = require("./chunk-MBTLUWXR.cjs");
42
42
  var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
43
- (0, import_chunk_QBCVUVLD.init_optimizer)();
43
+ (0, import_chunk_Q5WTV4CN.init_optimizer)();
44
44
  // Annotate the CommonJS export names for ESM import in node:
45
45
  0 && (module.exports = {
46
46
  StateNodeAttributes,
@@ -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_QBCVUVLD.SectionKinds,
22
- appSupport: () => import_chunk_QBCVUVLD.appSupport,
23
- connectiq: () => import_chunk_QBCVUVLD.connectiq,
24
- getDeviceInfo: () => import_chunk_QBCVUVLD.getDeviceInfo,
25
- getFunctionDocumentation: () => import_chunk_QBCVUVLD.getFunctionDocumentation,
26
- getLanguages: () => import_chunk_QBCVUVLD.getLanguages,
27
- getSdkPath: () => import_chunk_QBCVUVLD.getSdkPath,
28
- isWin: () => import_chunk_QBCVUVLD.isWin,
29
- optimizeProgram: () => import_chunk_QBCVUVLD.optimizeProgram,
30
- readPrg: () => import_chunk_QBCVUVLD.readPrg,
31
- readPrgWithOffsets: () => import_chunk_QBCVUVLD.readPrgWithOffsets,
32
- xmlUtil: () => import_chunk_QBCVUVLD.xml_util_exports
21
+ SectionKinds: () => import_chunk_Q5WTV4CN.SectionKinds,
22
+ appSupport: () => import_chunk_Q5WTV4CN.appSupport,
23
+ connectiq: () => import_chunk_Q5WTV4CN.connectiq,
24
+ getDeviceInfo: () => import_chunk_Q5WTV4CN.getDeviceInfo,
25
+ getFunctionDocumentation: () => import_chunk_Q5WTV4CN.getFunctionDocumentation,
26
+ getLanguages: () => import_chunk_Q5WTV4CN.getLanguages,
27
+ getSdkPath: () => import_chunk_Q5WTV4CN.getSdkPath,
28
+ isWin: () => import_chunk_Q5WTV4CN.isWin,
29
+ optimizeProgram: () => import_chunk_Q5WTV4CN.optimizeProgram,
30
+ readPrg: () => import_chunk_Q5WTV4CN.readPrg,
31
+ readPrgWithOffsets: () => import_chunk_Q5WTV4CN.readPrgWithOffsets,
32
+ xmlUtil: () => import_chunk_Q5WTV4CN.xml_util_exports
33
33
  });
34
34
  module.exports = __toCommonJS(sdk_util_exports);
35
- var import_chunk_QBCVUVLD = require("./chunk-QBCVUVLD.cjs");
35
+ var import_chunk_Q5WTV4CN = require("./chunk-Q5WTV4CN.cjs");
36
36
  var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.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_QBCVUVLD.init_sdk_util)();
39
+ (0, import_chunk_Q5WTV4CN.init_sdk_util)();
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  SectionKinds,
@@ -26,7 +26,7 @@ export declare function findNamesInScope(declStack: StateNode[][], pattern: stri
26
26
  readonly parent: StateNode;
27
27
  readonly depth: number;
28
28
  }])[];
29
- export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | FunctionStateNode | ModuleStateNode | ClassStateNode | TypedefStateNode | ProgramStateNode | EnumStateNode | import("./optimizer-types").BlockStateNode | VariableStateNode)[];
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
30
  export declare function formatAstLongLines(node: mctree.Node): string;
31
31
  export declare function createDocumentationMap(functionDocumentation: {
32
32
  name: string;
@@ -26,7 +26,7 @@ export declare const enum TypeTag {
26
26
  Typedef = 262144,
27
27
  Any = 524287
28
28
  }
29
- export declare function typeTagName(tag: TypeTag): "Symbol" | "Object" | "Number" | "Float" | "Double" | "Long" | "String" | "Char" | "Boolean" | "Null" | "Never" | "False" | "True" | "Decimal" | "Numeric" | "Array" | "Dictionary" | "Method" | "Module" | "Function" | "Class" | "Enum" | "Typedef" | "Any";
29
+ export declare function typeTagName(tag: TypeTag): "Never" | "Null" | "False" | "True" | "Boolean" | "Number" | "Long" | "Float" | "Double" | "Decimal" | "Numeric" | "Char" | "String" | "Array" | "Dictionary" | "Method" | "Module" | "Function" | "Class" | "Object" | "Enum" | "Symbol" | "Typedef" | "Any";
30
30
  export declare const LastTypeTag = TypeTag.Typedef;
31
31
  export declare const SingletonTypeTagsConst: number;
32
32
  export declare const UnionDataTypeTagsConst: number;
@@ -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_QBCVUVLD = require("./chunk-QBCVUVLD.cjs");
24
+ var import_chunk_Q5WTV4CN = require("./chunk-Q5WTV4CN.cjs");
25
25
  var import_chunk_PVBIKZYZ = require("./chunk-PVBIKZYZ.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_QBCVUVLD.init_worker_task)();
31
+ (0, import_chunk_Q5WTV4CN.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_QBCVUVLD.performTask)(task));
34
+ return import_node_worker_threads.parentPort.postMessage(await (0, import_chunk_Q5WTV4CN.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.34",
4
+ "version": "1.1.35",
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",
@@ -36,6 +36,7 @@
36
36
  "cft-font-info": "bin/cft-font-info.js"
37
37
  },
38
38
  "files": [
39
+ "CHANGELOG.md",
39
40
  "build/optimizer.cjs",
40
41
  "build/util.cjs",
41
42
  "build/sdk-util.cjs",
@@ -1,5 +0,0 @@
1
- import { Block, FuncEntry } from "./bytecode";
2
- export declare function isSwitchLike(func: FuncEntry, block: Block, index: number): false | {
3
- xpush: import("./opcodes").Ipush | import("./opcodes").Fpush | import("./opcodes").Spush | import("./opcodes").Bpush | import("./opcodes").Lpush | import("./opcodes").Dpush | import("./opcodes").Cpush;
4
- index: number;
5
- };
@@ -1,51 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { hasProperty, traverseAst } from "./ast";
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";
5
- import { visit_resources } from "./resources";
6
- import { xmlUtil } from "./sdk-util";
7
- import { TypeMap } from "./type-flow/interp";
8
- export { visitorNode, visitReferences } from "./visitor";
9
- export { traverseAst, hasProperty, visit_resources };
10
- export declare function parseSdkVersion(version: string | undefined): number;
11
- export declare function checkCompilerVersion(version: string, sdkVer: number): boolean | undefined;
12
- export declare function getApiMapping(state?: ProgramState, resourcesMap?: Record<string, JungleResourceMap>, manifestXML?: xmlUtil.Document): Promise<ProgramStateNode>;
13
- export declare function isStateNode(node: {
14
- type: string;
15
- }): node is StateNode;
16
- export declare function variableDeclarationName(node: mctree.TypedIdentifier | mctree.InstanceofIdentifier): string;
17
- type DeclKind = "decls" | "type_decls";
18
- export declare function sameLookupResult(a: LookupDefinition[], b: LookupDefinition[]): boolean;
19
- export declare function lookupResultContains(a: LookupDefinition[], b: LookupDefinition[]): boolean;
20
- export declare function isLookupCandidate(node: mctree.MemberExpression): false | mctree.Identifier;
21
- export declare function lookupNext(state: ProgramStateLive, results: LookupDefinition[], decls: DeclKind, property: mctree.Identifier): LookupDefinition[] | null;
22
- export declare function lookupWithType(state: ProgramStateAnalysis, node: mctree.Node, typeMap: TypeMap | undefined | null, nonLocal?: boolean, stack?: ProgramStateStack | null): LookupResult;
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;
25
- export declare function findNamesInScope(declStack: StateNode[][], pattern: string | RegExp): (readonly [StateNodeDecl, {
26
- readonly parent: StateNode;
27
- readonly depth: number;
28
- }])[];
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;
31
- export declare function createDocumentationMap(functionDocumentation: {
32
- name: string;
33
- parent: string;
34
- doc: string;
35
- }[]): Promise<Map<string, string>>;
36
- export declare function makeToyboxLink(result: StateNodeDecl): string | null;
37
- export declare function lookupByFullName(state: ProgramStateAnalysis, fullName: string): StateNodeDecl[];
38
- export declare function findUsingForNode(state: ProgramStateLive, stack: ProgramStateStack, i: number, node: mctree.Identifier): ModuleStateNode | {
39
- name: string;
40
- decls: {
41
- parent: StateNode;
42
- results: StateNodeDecl[];
43
- };
44
- }[] | null;
45
- export declare function getApiFunctionInfo(state: ProgramState, func: FunctionStateNode): FunctionInfo | false;
46
- export declare function markInvokeClassMethod(state: ProgramStateAnalysis, func: FunctionStateNode): void;
47
- export declare function isLocal(v: VariableStateNode): boolean;
48
- 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;
51
- export declare function getSuperClasses(klass: ClassStateNode): Set<StateNode> | null;
@@ -1,59 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import type { xmlUtil } from "./sdk-util";
3
- export declare function traverseAst(node: mctree.Node, pre?: null | ((node: mctree.Node) => void | null | false | (keyof mctree.NodeAll)[]), post?: (node: mctree.Node, parent: mctree.Node | undefined) => void | null | false | mctree.Node | mctree.Node[], parent?: mctree.Node | undefined): false | void | null | mctree.Node | mctree.Node[];
4
- export declare function isStatement(node: mctree.Node): node is mctree.Statement;
5
- export declare function isExpression(node: mctree.Node): node is mctree.Expression;
6
- export declare function mayThrow(node: mctree.Node): boolean;
7
- export declare function hasProperty<T extends null extends T ? unknown : undefined extends T ? unknown : never>(obj: T, prop: string): obj is NonNullable<T>;
8
- export declare function hasProperty<T>(obj: T, prop: string): boolean;
9
- export declare function withLoc<T extends mctree.Node>(node: T, start: mctree.Node | null, end?: mctree.Node | undefined | false): T;
10
- export declare function withLocDeep<T extends mctree.Node>(node: T, start: mctree.Node | null, end?: mctree.Node | undefined | false, inplace?: boolean): T;
11
- export declare function cloneDeep<T extends mctree.Node>(node: T): T;
12
- interface NumberLiteral extends mctree.Literal {
13
- value: number;
14
- }
15
- interface LongLiteral extends mctree.Literal {
16
- value: number | bigint;
17
- }
18
- interface StringLiteral extends mctree.Literal {
19
- value: string;
20
- }
21
- interface CharLiteral extends mctree.Literal {
22
- value: string;
23
- }
24
- interface BooleanLiteral extends mctree.Literal {
25
- value: boolean;
26
- }
27
- interface NullLiteral extends mctree.Literal {
28
- value: null;
29
- }
30
- type LiteralValues = [NumberLiteral, "Number" | "Float" | "Double"] | [LongLiteral, "Long"] | [StringLiteral, "String"] | [CharLiteral, "Char"] | [BooleanLiteral, "Boolean"] | [NullLiteral, "Null"];
31
- export declare function getNodeValue(node: mctree.Literal): LiteralValues;
32
- export declare function getNodeValue(node: mctree.Node): LiteralValues | [null, null];
33
- export declare function wrap<T extends mctree.Node>(node: T, loc?: mctree.SourceLocation | null): T;
34
- export declare function locRange(start: mctree.SourceLocation, end: mctree.SourceLocation): {
35
- source: string | null | undefined;
36
- start: mctree.Position;
37
- end: mctree.Position;
38
- };
39
- export declare function adjustLoc(loc: xmlUtil.SourceLocation, start?: number, end?: number): {
40
- readonly source: string | null | undefined;
41
- readonly start: {
42
- readonly offset: number;
43
- readonly line: number;
44
- readonly column: number;
45
- };
46
- readonly end: {
47
- readonly offset: number;
48
- readonly line: number;
49
- readonly column: number;
50
- };
51
- };
52
- export declare function makeIdentifier(name: string, loc?: mctree.SourceLocation | null | undefined): {
53
- type: "Identifier";
54
- name: string;
55
- };
56
- export declare function makeMemberExpression(object: mctree.ScopedName, property: mctree.Identifier): mctree.DottedName;
57
- export declare function makeScopedName(dotted: string, l?: mctree.SourceLocation): mctree.ScopedName;
58
- export declare function getLiteralNode(node: mctree.Node | null | undefined): null | mctree.Literal | mctree.AsExpression;
59
- export {};
@@ -1,7 +0,0 @@
1
- import { BuildConfig } from "./optimizer-types";
2
- export declare function build_project(product: string | null, options: BuildConfig, lineCallback?: (line: string) => void): Promise<{
3
- exe: string;
4
- args: string[];
5
- program: string;
6
- product: string | null;
7
- }>;
@@ -1,32 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function getCFTFontInfoFromBuffer(name: string, data: Buffer): {
3
- name: string;
4
- height: number;
5
- ascent: number;
6
- internalLeading: number;
7
- charInfo: {
8
- code: number;
9
- char: string;
10
- width: number;
11
- }[];
12
- };
13
- export declare function getCFTFontInfo(filename: string): Promise<{
14
- name: string;
15
- height: number;
16
- ascent: number;
17
- internalLeading: number;
18
- charInfo: {
19
- code: number;
20
- char: string;
21
- width: number;
22
- }[];
23
- }>;
24
- export declare function getDeviceFontInfo(dirname: string): Promise<{
25
- device: string;
26
- fontSets: {
27
- [k: string]: {
28
- [k: string]: string;
29
- };
30
- };
31
- langMap: Record<string, string>;
32
- }>;
@@ -1,22 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { ProgramStateAnalysis, FunctionStateNode } from "./optimizer-types";
3
- export type BaseEvent = {
4
- type: string;
5
- mayThrow: boolean;
6
- };
7
- type EventConstraint<_T> = BaseEvent;
8
- export type Block<T extends EventConstraint<T>> = {
9
- node?: mctree.Node;
10
- preds?: Block<T>[];
11
- succs?: Block<T>[];
12
- expreds?: Block<T>[];
13
- exsucc?: Block<T>;
14
- bogopred?: Block<T>;
15
- events?: T[];
16
- };
17
- export declare function buildReducedGraph<T extends EventConstraint<T>>(state: ProgramStateAnalysis, func: FunctionStateNode, refsForUpdate: boolean, notice: (node: mctree.Node, stmt: mctree.Node, mayThrow: boolean | 1, containedEvents: () => T[]) => T | T[] | null): Block<T>;
18
- export declare function postOrderTraverse<T extends EventConstraint<T>>(head: Block<T>, visitor: (block: Block<T>) => void): void;
19
- export declare function preOrderTraverse<T extends EventConstraint<T>>(head: Block<T>, visitor: (block: Block<T>) => void): void;
20
- export declare function getPostOrder<T extends EventConstraint<T>>(head: Block<T>): Block<T>[];
21
- export declare function getPreOrder<T extends EventConstraint<T>>(head: Block<T>): Block<T>[];
22
- export {};
@@ -1,107 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { BaseEvent, Block } from "./control-flow";
3
- import { FunctionStateNode, ProgramStateAnalysis, StateNodeDecl } from "./optimizer-types";
4
- import { GenericQueue } from "./util";
5
- export type RefNode = mctree.Identifier | mctree.MemberExpression | mctree.Literal;
6
- export type MemberDecl = {
7
- type: "MemberDecl";
8
- node: mctree.MemberExpression;
9
- base: StateNodeDecl | StateNodeDecl[];
10
- path: mctree.MemberExpression[];
11
- };
12
- export type EventDecl = StateNodeDecl | StateNodeDecl[] | mctree.Literal | MemberDecl | {
13
- type: "Unknown";
14
- node: mctree.MemberExpression | mctree.Identifier | mctree.ThisExpression;
15
- };
16
- export interface RefEvent extends BaseEvent {
17
- type: "ref";
18
- node: RefNode;
19
- decl: EventDecl;
20
- }
21
- export interface KillEvent extends BaseEvent {
22
- type: "kil";
23
- node: mctree.Node;
24
- decl: StateNodeDecl | StateNodeDecl[];
25
- }
26
- export interface DefEvent extends BaseEvent {
27
- type: "def";
28
- node: mctree.AssignmentExpression | mctree.UpdateExpression | mctree.VariableDeclarator;
29
- decl: EventDecl;
30
- rhs?: EventDecl;
31
- containedEvents?: Array<RefEvent | ModEvent>;
32
- }
33
- export interface ModEvent extends BaseEvent {
34
- type: "mod";
35
- node: mctree.Node;
36
- decl?: EventDecl | undefined | null;
37
- before?: boolean;
38
- id?: RefNode;
39
- callees?: FunctionStateNode[] | null;
40
- calleeDecl?: EventDecl | undefined;
41
- calleeObj?: EventDecl | undefined;
42
- }
43
- export declare enum FlowKind {
44
- LEFT_EQ_RIGHT_DECL = 0,
45
- LEFT_NE_RIGHT_DECL = 1,
46
- LEFT_EQ_RIGHT_NODE = 2,
47
- LEFT_NE_RIGHT_NODE = 3,
48
- LEFT_TRUTHY = 4,
49
- LEFT_FALSEY = 5,
50
- INSTANCEOF = 6,
51
- NOTINSTANCE = 7
52
- }
53
- export interface FlowEventDecl extends BaseEvent {
54
- type: "flw";
55
- node: mctree.BinaryExpression | mctree.UnaryExpression;
56
- decl?: undefined;
57
- kind: FlowKind.LEFT_EQ_RIGHT_DECL | FlowKind.LEFT_NE_RIGHT_DECL;
58
- left: EventDecl;
59
- right_decl: EventDecl;
60
- right_node?: undefined;
61
- }
62
- export interface FlowEventNode extends BaseEvent {
63
- type: "flw";
64
- node: mctree.BinaryExpression | mctree.UnaryExpression;
65
- decl?: undefined;
66
- kind: FlowKind.LEFT_EQ_RIGHT_NODE | FlowKind.LEFT_NE_RIGHT_NODE;
67
- left: EventDecl;
68
- right_decl?: undefined;
69
- right_node: mctree.Expression;
70
- }
71
- export interface FlowEventTruthy extends BaseEvent {
72
- type: "flw";
73
- node: mctree.Node;
74
- decl?: undefined;
75
- kind: FlowKind.LEFT_TRUTHY | FlowKind.LEFT_FALSEY;
76
- left: EventDecl;
77
- right_decl?: undefined;
78
- right_node?: undefined;
79
- }
80
- export interface FlowEventInstanceof extends BaseEvent {
81
- type: "flw";
82
- node: mctree.InstanceofExpression | mctree.UnaryExpression;
83
- decl?: undefined;
84
- kind: FlowKind.INSTANCEOF | FlowKind.NOTINSTANCE;
85
- left: EventDecl;
86
- right_decl: EventDecl;
87
- right_node?: undefined;
88
- }
89
- export type FlowEvent = FlowEventDecl | FlowEventNode | FlowEventTruthy | FlowEventInstanceof;
90
- export interface ExnEvent extends BaseEvent {
91
- type: "exn";
92
- node: mctree.Node;
93
- }
94
- export type Event = RefEvent | KillEvent | DefEvent | ModEvent | FlowEvent | ExnEvent;
95
- export interface DataFlowBlock extends Block<Event> {
96
- order?: number;
97
- }
98
- export declare function declFullName(decl: EventDecl): string;
99
- export declare function declName(decl: EventDecl): string | undefined;
100
- export declare function unhandledType(node: never): never;
101
- export declare function buildDataFlowGraph(state: ProgramStateAnalysis, func: FunctionStateNode, wantsLiteral: (literal: mctree.Literal) => boolean, trackInsertionPoints: boolean, wantsAllRefs: boolean): {
102
- identifiers: Set<string>;
103
- graph: Block<Event>;
104
- };
105
- export declare class DataflowQueue extends GenericQueue<DataFlowBlock> {
106
- constructor();
107
- }
@@ -1,2 +0,0 @@
1
- export declare function driver(): Promise<void>;
2
- export declare function error(message: string): never;
@@ -1,14 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { VariableStateNode, FunctionStateNode, LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
3
- export declare function cloneSet<T>(ae: Set<T>): Set<T>;
4
- export declare function mergeSet<T>(a: Set<T>, b: Set<T>): void;
5
- export declare function recordModifiedDecl(func: FunctionStateNode, decl: VariableStateNode): null;
6
- export declare function recordModifiedDecls(func: FunctionStateNode, lookupDefs: LookupDefinition[]): void;
7
- export declare function recordModifiedName(func: FunctionStateNode, name: string): void;
8
- export declare function recordModifiedUnknown(func: FunctionStateNode): void;
9
- export declare function recordCalledFunc(func: FunctionStateNode, callee: FunctionStateNode): null;
10
- export declare function recordCalledFuncs(func: FunctionStateNode, callees: FunctionStateNode[]): void;
11
- export declare function functionMayModify(state: ProgramStateAnalysis, func: FunctionStateNode, decl: VariableStateNode): boolean;
12
- export declare function findCallees(lookupDefs: LookupDefinition[]): FunctionStateNode[] | null;
13
- export declare function findCalleesForNew(lookupDefs: LookupDefinition[]): FunctionStateNode[];
14
- export declare function findCalleesByNode(state: ProgramStateAnalysis, callee: mctree.Expression): FunctionStateNode[] | null;
@@ -1,13 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { FunctionStateNode, ProgramStateAnalysis } from "./optimizer-types";
3
- export declare function inlinableSubExpression(expr: mctree.Expression): mctree.SimpleCallExpression | null;
4
- export declare function inlineRequested(state: ProgramStateAnalysis, func: FunctionStateNode): boolean;
5
- export declare function shouldInline(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): boolean;
6
- type InlineBody = mctree.BlockStatement | mctree.ExpressionStatement["expression"];
7
- export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"]): mctree.Statement[];
8
- export declare function unused(state: ProgramStateAnalysis, expression: mctree.ExpressionStatement["expression"], top: true): mctree.Statement[] | null;
9
- export declare function inlineDiagnostic(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, message: string | null): void;
10
- export type InlineContext = mctree.ReturnStatement | mctree.IfStatement | mctree.AssignmentExpression | mctree.ExpressionStatement | mctree.VariableDeclarator;
11
- export declare function inlineFunction(state: ProgramStateAnalysis, func: FunctionStateNode, call: mctree.CallExpression, context: InlineContext | null): InlineBody | null;
12
- export declare function applyTypeIfNeeded(node: mctree.Node): mctree.Node;
13
- export {};
@@ -1,66 +0,0 @@
1
- import { ManifestXML } from "./manifest";
2
- import { BuildConfig } from "./optimizer-types.js";
3
- import { DeviceInfo, xmlUtil } from "./sdk-util";
4
- export type JungleBuildDependencies = Record<string, xmlUtil.Document | true>;
5
- export type JungleError = Error & {
6
- buildDependencies?: JungleBuildDependencies;
7
- };
8
- export type Target = {
9
- product: string;
10
- qualifier: JungleQualifier;
11
- shape?: string;
12
- group?: {
13
- optimizerConfig: JungleQualifier;
14
- dir?: string;
15
- key: string;
16
- };
17
- };
18
- type LangResourcePaths = {
19
- [key: string]: string[];
20
- };
21
- type BarrelAnnotations = {
22
- [key: string]: string[];
23
- };
24
- type BarrelMap = {
25
- [key: string]: ResolvedBarrel;
26
- };
27
- type OptBarrelMap = Record<string, {
28
- rawBarrelDir: string;
29
- manifest: string;
30
- jungleFiles: string[];
31
- optBarrelDir: string;
32
- }>;
33
- export type JungleQualifier = {
34
- sourcePath?: string[];
35
- sourceExcludes?: string[];
36
- excludeAnnotations?: string[];
37
- resourcePath?: string[];
38
- personality?: string[];
39
- lang?: LangResourcePaths;
40
- barrelPath?: (string | string[])[];
41
- annotations?: BarrelAnnotations;
42
- barrelMap?: BarrelMap;
43
- optBarrels?: OptBarrelMap;
44
- resourceMap?: JungleResourceMap;
45
- products?: string[];
46
- };
47
- type JungleInfoBase = {
48
- jungles: string[];
49
- manifest: string;
50
- xml: ManifestXML;
51
- annotations?: string[];
52
- resources: JungleResourceMap;
53
- buildDependencies: JungleBuildDependencies;
54
- devices: DeviceInfo;
55
- };
56
- export type JungleResourceMap = Record<string, xmlUtil.Document>;
57
- export type ResolvedJungle = JungleInfoBase & {
58
- targets: Target[];
59
- typeCheckLevel?: string;
60
- optimizationLevel?: string;
61
- };
62
- export type ResolvedBarrel = JungleInfoBase & {
63
- qualifier: JungleQualifier;
64
- };
65
- export declare function get_jungle(jungles: string, options: BuildConfig, resources?: JungleResourceMap | undefined): Promise<ResolvedJungle>;
66
- export {};
@@ -1,5 +0,0 @@
1
- import { LineHandler } from "./util";
2
- export declare function launchSimulator(force?: boolean): Promise<void>;
3
- export declare function checkIfSimulatorRunning(): Promise<boolean>;
4
- export declare function checkIfSimulatorRunningOn(port: number): Promise<boolean>;
5
- export declare function simulateProgram(prg: string, device: string, test?: boolean | string, logger?: LineHandler | LineHandler[]): Promise<void>;
@@ -1,6 +0,0 @@
1
- export declare function logger(module: string, level: number, message: unknown): void;
2
- export declare function wouldLog(module: string, level: number): boolean;
3
- export declare function bumpLogging(module: string | null, amount: number): void;
4
- export declare function setBanner(b: (() => string) | null): void;
5
- export declare function log(message: unknown): void;
6
- export declare function setLogger(log: (message: string) => void): void;
@@ -1,11 +0,0 @@
1
- import { xmlUtil } from "./sdk-util";
2
- export type ManifestXML = xmlUtil.Document;
3
- export declare function readManifest(manifest: string): Promise<ManifestXML>;
4
- export declare function writeManifest(filename: string, xml: ManifestXML): Promise<void>;
5
- export declare function manifestProducts(manifest: ManifestXML): string[];
6
- export declare function manifestBarrels(manifest: ManifestXML): string[];
7
- export declare function manifestDropBarrels(manifest: ManifestXML): void;
8
- export declare function manifestBarrelName(manifestName: string, manifest: ManifestXML): string;
9
- export declare function manifestAnnotations(manifest: ManifestXML): string[] | undefined;
10
- export declare function manifestLanguages(manifest: ManifestXML): string[] | undefined;
11
- export declare function checkManifest(manifest: ManifestXML, products: string[]): Promise<boolean>;
@@ -1,13 +0,0 @@
1
- import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { JungleResourceMap } from "./jungles";
3
- import { BuildConfig, FilesToOptimizeMap, LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
4
- import { xmlUtil } from "./sdk-util";
5
- export declare function getFileSources(fnMap: FilesToOptimizeMap): Promise<void>;
6
- export declare function getFileASTs(fnMap: FilesToOptimizeMap): Promise<boolean>;
7
- export declare function analyze(fnMap: FilesToOptimizeMap, resourcesMap: Record<string, JungleResourceMap>, manifestXML: xmlUtil.Document | undefined, config: BuildConfig): Promise<ProgramStateAnalysis>;
8
- export declare function reportMissingSymbols(state: ProgramStateAnalysis, config?: BuildConfig): void;
9
- export declare function getLiteralFromDecls(lookupDefns: LookupDefinition[]): mctree.Literal | mctree.AsExpression | null;
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;
12
- sdkVersion: number | undefined;
13
- }>;
@@ -1 +0,0 @@
1
- export declare const negativeFixups: string[];