@markw65/monkeyc-optimizer 1.1.83 → 1.1.84
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 +8 -0
- package/build/api.cjs +40 -38
- package/build/{chunk-UNU55JJ3.cjs → chunk-ZWQB5L34.cjs} +1676 -1426
- package/build/optimizer.cjs +18 -18
- package/build/sdk-util.cjs +14 -14
- package/build/src/api.d.ts +2 -1
- package/build/src/optimizer-types.d.ts +2 -2
- package/build/src/type-flow/array-type.d.ts +10 -0
- package/build/src/type-flow/effective-type.d.ts +2 -0
- package/build/src/type-flow/interp-call.d.ts +2 -1
- package/build/src/type-flow/interp.d.ts +1 -0
- package/build/src/type-flow/types.d.ts +0 -7
- package/build/src/type-flow/union-type.d.ts +1 -0
- package/build/worker-thread.cjs +3 -3
- package/package.json +1 -1
package/build/optimizer.cjs
CHANGED
|
@@ -18,30 +18,30 @@ 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
|
-
buildConfigDescription: () =>
|
|
23
|
-
buildOptimizedProject: () =>
|
|
21
|
+
StateNodeAttributes: () => import_chunk_ZWQB5L34.StateNodeAttributes,
|
|
22
|
+
buildConfigDescription: () => import_chunk_ZWQB5L34.buildConfigDescription,
|
|
23
|
+
buildOptimizedProject: () => import_chunk_ZWQB5L34.buildOptimizedProject,
|
|
24
24
|
copyRecursiveAsNeeded: () => import_chunk_X7QCZR3F.copyRecursiveAsNeeded,
|
|
25
|
-
defaultConfig: () =>
|
|
26
|
-
display: () =>
|
|
27
|
-
generateOneConfig: () =>
|
|
28
|
-
generateOptimizedProject: () =>
|
|
29
|
-
getConfig: () =>
|
|
30
|
-
getFnMapAnalysis: () =>
|
|
31
|
-
getProjectAnalysis: () =>
|
|
32
|
-
get_jungle: () =>
|
|
33
|
-
isErrorWithLocation: () =>
|
|
34
|
-
launchSimulator: () =>
|
|
35
|
-
manifestProducts: () =>
|
|
36
|
-
mctree: () =>
|
|
37
|
-
simulateProgram: () =>
|
|
25
|
+
defaultConfig: () => import_chunk_ZWQB5L34.defaultConfig,
|
|
26
|
+
display: () => import_chunk_ZWQB5L34.display,
|
|
27
|
+
generateOneConfig: () => import_chunk_ZWQB5L34.generateOneConfig,
|
|
28
|
+
generateOptimizedProject: () => import_chunk_ZWQB5L34.generateOptimizedProject,
|
|
29
|
+
getConfig: () => import_chunk_ZWQB5L34.getConfig,
|
|
30
|
+
getFnMapAnalysis: () => import_chunk_ZWQB5L34.getFnMapAnalysis,
|
|
31
|
+
getProjectAnalysis: () => import_chunk_ZWQB5L34.getProjectAnalysis,
|
|
32
|
+
get_jungle: () => import_chunk_ZWQB5L34.get_jungle,
|
|
33
|
+
isErrorWithLocation: () => import_chunk_ZWQB5L34.isErrorWithLocation,
|
|
34
|
+
launchSimulator: () => import_chunk_ZWQB5L34.launchSimulator,
|
|
35
|
+
manifestProducts: () => import_chunk_ZWQB5L34.manifestProducts,
|
|
36
|
+
mctree: () => import_chunk_ZWQB5L34.mctree,
|
|
37
|
+
simulateProgram: () => import_chunk_ZWQB5L34.simulateProgram
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(optimizer_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_chunk_ZWQB5L34 = require("./chunk-ZWQB5L34.cjs");
|
|
41
41
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
42
42
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
43
43
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
44
|
-
(0,
|
|
44
|
+
(0, import_chunk_ZWQB5L34.init_optimizer)();
|
|
45
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
46
|
0 && (module.exports = {
|
|
47
47
|
StateNodeAttributes,
|
package/build/sdk-util.cjs
CHANGED
|
@@ -18,25 +18,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var sdk_util_exports = {};
|
|
20
20
|
__export(sdk_util_exports, {
|
|
21
|
-
SectionKinds: () =>
|
|
22
|
-
appSupport: () =>
|
|
23
|
-
connectiq: () =>
|
|
24
|
-
getDeviceInfo: () =>
|
|
25
|
-
getFunctionDocumentation: () =>
|
|
26
|
-
getLanguages: () =>
|
|
27
|
-
getSdkPath: () =>
|
|
28
|
-
isWin: () =>
|
|
29
|
-
optimizeProgram: () =>
|
|
30
|
-
readPrg: () =>
|
|
31
|
-
readPrgWithOffsets: () =>
|
|
32
|
-
xmlUtil: () =>
|
|
21
|
+
SectionKinds: () => import_chunk_ZWQB5L34.SectionKinds,
|
|
22
|
+
appSupport: () => import_chunk_ZWQB5L34.appSupport,
|
|
23
|
+
connectiq: () => import_chunk_ZWQB5L34.connectiq,
|
|
24
|
+
getDeviceInfo: () => import_chunk_ZWQB5L34.getDeviceInfo,
|
|
25
|
+
getFunctionDocumentation: () => import_chunk_ZWQB5L34.getFunctionDocumentation,
|
|
26
|
+
getLanguages: () => import_chunk_ZWQB5L34.getLanguages,
|
|
27
|
+
getSdkPath: () => import_chunk_ZWQB5L34.getSdkPath,
|
|
28
|
+
isWin: () => import_chunk_ZWQB5L34.isWin,
|
|
29
|
+
optimizeProgram: () => import_chunk_ZWQB5L34.optimizeProgram,
|
|
30
|
+
readPrg: () => import_chunk_ZWQB5L34.readPrg,
|
|
31
|
+
readPrgWithOffsets: () => import_chunk_ZWQB5L34.readPrgWithOffsets,
|
|
32
|
+
xmlUtil: () => import_chunk_ZWQB5L34.xml_util_exports
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(sdk_util_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_ZWQB5L34 = require("./chunk-ZWQB5L34.cjs");
|
|
36
36
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
37
37
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.cjs");
|
|
38
38
|
var import_chunk_ABYVSU2C = require("./chunk-ABYVSU2C.cjs");
|
|
39
|
-
(0,
|
|
39
|
+
(0, import_chunk_ZWQB5L34.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
|
@@ -31,7 +31,7 @@ export declare function findNamesInScope(declStack: StateNode[][], pattern: stri
|
|
|
31
31
|
readonly parent: StateNode;
|
|
32
32
|
readonly depth: number;
|
|
33
33
|
}])[];
|
|
34
|
-
export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | ProgramStateNode | FunctionStateNode | ModuleStateNode | ClassStateNode | TypedefStateNode | VariableStateNode | import("./optimizer-types").BlockStateNode
|
|
34
|
+
export declare function mapVarDeclsByType(state: ProgramStateAnalysis, decls: StateNodeDecl[], node: mctree.Node, typeMap: TypeMap | null | undefined): (mctree.Identifier | mctree.EnumStringMember | mctree.AsIdentifier | ProgramStateNode | FunctionStateNode | ModuleStateNode | ClassStateNode | TypedefStateNode | VariableStateNode | EnumStateNode | import("./optimizer-types").BlockStateNode)[];
|
|
35
35
|
export declare function formatScopedName(node: mctree.ScopedName | mctree.ThisExpression): string;
|
|
36
36
|
export declare function formatAstLongLines(node: mctree.Node): Promise<string>;
|
|
37
37
|
export declare function createDocumentationMap(functionDocumentation: {
|
|
@@ -54,6 +54,7 @@ export declare function isLocal(v: VariableStateNode): boolean;
|
|
|
54
54
|
export declare function isClassVariable(v: VariableStateNode): boolean;
|
|
55
55
|
export declare function resolveDiagnostics(diagnostics?: PreDiagnostic[]): Promise<Diagnostic[]> | undefined;
|
|
56
56
|
export declare function resolveDiagnosticsMap(diagnosticsMap: Record<string, PreDiagnostic[]>): Promise<Record<string, Diagnostic[]>>;
|
|
57
|
+
export declare function clearDiagnostics(state: ProgramState, node: mctree.Node): void;
|
|
57
58
|
export declare function diagnostic(state: ProgramState, node: mctree.Node, message: string | Promise<string> | null, type?: DiagnosticType, extra?: Diagnostic["extra"]): void;
|
|
58
59
|
export declare function diagnosticHelper(diagnostics: Record<string, PreDiagnostic[]>, node: mctree.Node, message: string | Promise<string> | null, type: DiagnosticType | undefined, extra: Diagnostic["extra"] | undefined): void;
|
|
59
60
|
export declare function getSuperClasses(klass: ClassStateNode): Set<StateNode> | null;
|
|
@@ -138,7 +138,7 @@ export type ProgramState = {
|
|
|
138
138
|
allClasses?: ClassStateNode[];
|
|
139
139
|
nestedClasses?: Record<string, ClassStateNode[]>;
|
|
140
140
|
allModules?: Set<ModuleStateNode>;
|
|
141
|
-
|
|
141
|
+
allCached?: Set<TypedefStateNode | VariableStateNode | EnumStateNode>;
|
|
142
142
|
invokeInfo?: FunctionInfo;
|
|
143
143
|
allDeclarations?: Record<string, ByNameStateNodeDecls[]>;
|
|
144
144
|
fnMap?: FilesToOptimizeMap;
|
|
@@ -192,7 +192,7 @@ export type Finalized<T, Keys extends keyof T> = T & {
|
|
|
192
192
|
[key in Keys]-?: NonNullable<T[key]>;
|
|
193
193
|
};
|
|
194
194
|
export type ProgramStateLive = Finalized<ProgramState, "stack" | "top" | "lookup" | "lookupValue" | "lookupType" | "lookupNonlocal" | "stackClone" | "traverse" | "index" | "constants" | "removeNodeComments" | "inType" | "nextExposed" | "lookupRules">;
|
|
195
|
-
export type ProgramStateAnalysis = Finalized<ProgramStateLive, "allClasses" | "nestedClasses" | "allModules" | "
|
|
195
|
+
export type ProgramStateAnalysis = Finalized<ProgramStateLive, "allClasses" | "nestedClasses" | "allModules" | "allCached" | "allFunctions" | "fnMap" | "allDeclarations" | "invokeInfo">;
|
|
196
196
|
export type ProgramStateOptimizer = Finalized<ProgramStateAnalysis, "localsStack" | "exposed" | "calledFunctions" | "usedByName">;
|
|
197
197
|
export type ExcludeAnnotationsMap = {
|
|
198
198
|
[key: string]: boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mctree } from "@markw65/prettier-plugin-monkeyc";
|
|
2
|
+
import { ArrayType, ExactOrUnion } from "./types";
|
|
3
|
+
export type ArrayTypeData = NonNullable<ArrayType["value"]>;
|
|
4
|
+
export declare function tupleForEach(t: ArrayTypeData, tupleFn: (v: ExactOrUnion[]) => unknown, arrayFn: (v: ExactOrUnion) => unknown): void;
|
|
5
|
+
export declare function tupleMap<T, U, V>(t: ArrayTypeData, tupleFn: (v: ExactOrUnion[]) => U | null, arrayFn: (v: ExactOrUnion) => V | null, reduceFn: (v: Array<U | V>) => T): T;
|
|
6
|
+
export declare function tupleReduce(v: Array<ExactOrUnion | ExactOrUnion[]>): import("./types").UnionType | import("./types").NumberType | import("./types").LongType | import("./types").FloatType | import("./types").DoubleType | import("./types").CharType | import("./types").StringType | ArrayType | import("./types").DictionaryType | import("./types").MethodType | import("./types").ModuleType | import("./types").FunctionType | import("./types").ClassType | import("./types").ObjectType | import("./types").EnumType | import("./types").SymbolType | import("./types").TypedefType | ExactOrUnion[] | Set<ExactOrUnion | ExactOrUnion[]>;
|
|
7
|
+
export declare function reducedArrayType(t: ArrayTypeData): ExactOrUnion;
|
|
8
|
+
export declare function restrictArrayData(constraint: ArrayTypeData, tracked: ArrayTypeData): ArrayTypeData;
|
|
9
|
+
export declare function checkArrayCovariance(arg: ArrayTypeData, param: ArrayTypeData): boolean;
|
|
10
|
+
export declare function safeReferenceArg(arg: mctree.Expression): boolean;
|
|
@@ -12,6 +12,7 @@ type SysCallHelperResult = {
|
|
|
12
12
|
argEffects?: true;
|
|
13
13
|
diagnostic?: string;
|
|
14
14
|
};
|
|
15
|
-
type SysCallHelper = (istate: InterpState, func: FunctionStateNode, calleeObj: ExactOrUnion, getArgs: () => Array<ExactOrUnion
|
|
15
|
+
type SysCallHelper = (istate: InterpState, func: FunctionStateNode, calleeObj: ExactOrUnion, getArgs: () => Array<ExactOrUnion>, callNode: mctree.CallExpression) => SysCallHelperResult;
|
|
16
16
|
export declare function sysCallInfo(state: ProgramStateAnalysis, func: FunctionStateNode): SysCallHelper | null;
|
|
17
|
+
export declare function extraReferenceTypeChecks(istate: InterpState, report: (sourceType: string, targetType: string) => void, targetType: ExactOrUnion, sourceType: ExactOrUnion, sourceNode: mctree.Expression): void;
|
|
17
18
|
export {};
|
|
@@ -38,6 +38,7 @@ export declare function evaluateUnaryTypes(op: mctree.UnaryOperator, argument: E
|
|
|
38
38
|
type: ExactOrUnion;
|
|
39
39
|
} & OpMatch;
|
|
40
40
|
export declare function deEnumerate(t: ExactOrUnion): ExactOrUnion;
|
|
41
|
+
export declare function getLhsConstraint(istate: InterpState, node: mctree.MemberExpression | mctree.Identifier): import("./types").UnionType | import("./types").NumberType | import("./types").LongType | import("./types").FloatType | import("./types").DoubleType | import("./types").CharType | import("./types").StringType | import("./types").ArrayType | import("./types").DictionaryType | import("./types").MethodType | import("./types").ModuleType | import("./types").FunctionType | import("./types").ClassType | ObjectType | import("./types").EnumType | import("./types").SymbolType | import("./types").TypedefType | null | undefined;
|
|
41
42
|
export declare function evaluateNode(istate: InterpState, node: mctree.Node): void;
|
|
42
43
|
export declare function roundToFloat(value: number): number;
|
|
43
44
|
export declare function mustBeIdentical(a: ExactOrUnion, b: ExactOrUnion): boolean;
|
|
@@ -212,12 +212,5 @@ export declare function getStateNodeDeclsWithExactFromType(state: ProgramStateAn
|
|
|
212
212
|
sn: StateNode;
|
|
213
213
|
exact: boolean;
|
|
214
214
|
}[];
|
|
215
|
-
export declare function isTupleUnion(t: ExactOrUnion[] | ExactOrUnion[][]): t is ExactOrUnion[][];
|
|
216
|
-
export declare function tupleForEach(t: NonNullable<ArrayType["value"]>, tupleFn: (v: ExactOrUnion[]) => unknown, arrayFn: (v: ExactOrUnion) => unknown): void;
|
|
217
|
-
export declare function tupleMap<T, U, V>(t: NonNullable<ArrayType["value"]>, tupleFn: (v: ExactOrUnion[]) => U | null, arrayFn: (v: ExactOrUnion) => V | null, reduceFn: (v: Array<U | V>) => T): T;
|
|
218
|
-
export declare function tupleReduce(v: Array<ExactOrUnion | ExactOrUnion[]>): UnionType | NumberType | LongType | FloatType | DoubleType | CharType | StringType | ArrayType | DictionaryType | MethodType | ModuleType | FunctionType | ClassType | ObjectType | EnumType | SymbolType | TypedefType | ExactOrUnion[] | Set<ExactOrUnion | ExactOrUnion[]>;
|
|
219
|
-
export declare function reducedArrayType(t: Set<ExactOrUnion[] | ExactOrUnion> | ExactOrUnion[] | ExactOrUnion): ExactOrUnion;
|
|
220
|
-
export declare function checkArrayCovariance(arg: NonNullable<ArrayType["value"]>, param: NonNullable<ArrayType["value"]>): boolean;
|
|
221
|
-
export declare function safeReferenceArg(arg: mctree.Expression): boolean;
|
|
222
215
|
export declare function typeFromEnumValue(arg: EnumType["value"] | null): UnionType | NumberType | LongType | FloatType | DoubleType | CharType | StringType | ArrayType | DictionaryType | MethodType | ModuleType | FunctionType | ClassType | ObjectType | EnumType | SymbolType | TypedefType;
|
|
223
216
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExactOrUnion, TypeTag } from "./types";
|
|
2
|
+
export declare function union(to: ExactOrUnion, from: ExactOrUnion): ExactOrUnion;
|
|
2
3
|
export declare function unionInto(to: ExactOrUnion, from: ExactOrUnion): boolean;
|
|
3
4
|
export declare function unionHelper(to: ExactOrUnion, from: ExactOrUnion, widenDepth: number): boolean;
|
|
4
5
|
export declare function clearValuesUnder(v: ExactOrUnion, tag: TypeTag, clearTag?: boolean): void;
|
package/build/worker-thread.cjs
CHANGED
|
@@ -21,17 +21,17 @@ __export(worker_thread_exports, {
|
|
|
21
21
|
default: () => worker_thread_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(worker_thread_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_chunk_ZWQB5L34 = require("./chunk-ZWQB5L34.cjs");
|
|
25
25
|
var import_chunk_X7QCZR3F = require("./chunk-X7QCZR3F.cjs");
|
|
26
26
|
var import_chunk_JDC43A3I = require("./chunk-JDC43A3I.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_ZWQB5L34.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_ZWQB5L34.performTask)(task));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
package/package.json
CHANGED