@markw65/monkeyc-optimizer 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -574,3 +574,7 @@ Bug Fixes
574
574
  - Bug fixes
575
575
  - Fixes a bug that could ignore side effects from Method.invoke
576
576
  - Fixes a crash in the inliner, when trying to inline a function with multiple returns
577
+
578
+ ### 1.1.1
579
+
580
+ - Fix the package spec to include the new .d.ts files
@@ -12233,7 +12233,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
12233
12233
  // the oldest optimized file, we don't need to regenerate
12234
12234
  const source_time = await (0,external_util_cjs_namespaceObject.last_modified)(Object.keys(fnMap).concat(dependencyFiles));
12235
12235
  const opt_time = await (0,external_util_cjs_namespaceObject.first_modified)(Object.values(fnMap).map((v) => v.output));
12236
- if (source_time < opt_time && 1673220499844 < opt_time) {
12236
+ if (source_time < opt_time && 1673222947102 < opt_time) {
12237
12237
  return { hasTests, diagnostics: prevDiagnostics };
12238
12238
  }
12239
12239
  }
@@ -12260,7 +12260,7 @@ async function generateOneConfig(buildConfig, manifestXML, dependencyFiles, conf
12260
12260
  return promises_namespaceObject.writeFile(external_path_.join(output, "build-info.json"), JSON.stringify({
12261
12261
  hasTests,
12262
12262
  diagnostics,
12263
- optimizerVersion: "1.1.0",
12263
+ optimizerVersion: "1.1.1",
12264
12264
  ...Object.fromEntries(configOptionsToCheck.map((option) => [option, config[option]])),
12265
12265
  }))
12266
12266
  .then(() => ({ hasTests, diagnostics }));
@@ -0,0 +1,2 @@
1
+ import { ExactOrUnion } from "./types";
2
+ export declare function couldBe(a: ExactOrUnion, b: ExactOrUnion): boolean;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,4 @@
1
+ import { ProgramStateAnalysis } from "../optimizer-types";
2
+ import { ExactOrUnion } from "./types";
3
+ import { mctree } from "@markw65/prettier-plugin-monkeyc";
4
+ export declare function evaluateCall(state: ProgramStateAnalysis, node: mctree.CallExpression, callee: ExactOrUnion, _args: ExactOrUnion[]): ExactOrUnion;
@@ -0,0 +1,23 @@
1
+ import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
+ import { FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
3
+ import { ExactOrUnion } from "./types";
4
+ export declare type TypeMap = Map<mctree.Node, ExactOrUnion>;
5
+ export declare type InterpStackElem = {
6
+ value: ExactOrUnion;
7
+ embeddedEffects: boolean;
8
+ node: mctree.Expression | mctree.TypeSpecList | mctree.InstanceOfCase;
9
+ };
10
+ export declare type InterpState = {
11
+ state: ProgramStateAnalysis;
12
+ stack: InterpStackElem[];
13
+ typeMap?: TypeMap;
14
+ func?: FunctionStateNode;
15
+ pre?: (node: mctree.Node) => mctree.Node | false | null | void;
16
+ post?: (node: mctree.Node) => mctree.Node | false | null | void;
17
+ };
18
+ export declare function popIstate(istate: InterpState, node: mctree.Node): InterpStackElem;
19
+ export declare function evaluateExpr(state: ProgramStateAnalysis, expr: mctree.Expression, typeMap?: TypeMap): InterpStackElem;
20
+ export declare function evaluate(istate: InterpState, node: mctree.Expression): InterpStackElem;
21
+ export declare function evaluate(istate: InterpState, node: mctree.Node): InterpStackElem | undefined;
22
+ export declare function evaluateNode(istate: InterpState, node: mctree.Node): void;
23
+ export declare function roundToFloat(value: number): number;
@@ -0,0 +1,4 @@
1
+ import { ExactOrUnion } from "./types";
2
+ export declare function expandTypedef(t: ExactOrUnion): ExactOrUnion;
3
+ export declare function intersection(a: ExactOrUnion, b: ExactOrUnion): ExactOrUnion;
4
+ export declare function restrictByEquality(a: ExactOrUnion, b: ExactOrUnion): ExactOrUnion;
@@ -0,0 +1,6 @@
1
+ import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
+ import { FunctionStateNode, ProgramStateAnalysis } from "../optimizer-types";
3
+ import { InterpState } from "./interp";
4
+ export declare function optimizeFunction(state: ProgramStateAnalysis, func: FunctionStateNode): void;
5
+ export declare function beforeEvaluate(istate: InterpState, node: mctree.Node): mctree.Node | null | false;
6
+ export declare function afterEvaluate(istate: InterpState, node: mctree.Node): mctree.Node | null | false;
@@ -0,0 +1,2 @@
1
+ import { ExactOrUnion } from "./types";
2
+ export declare function subtypeOf(a: ExactOrUnion, b: ExactOrUnion): boolean;
@@ -0,0 +1,201 @@
1
+ import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
+ import { ClassStateNode, EnumStateNode, FunctionStateNode, ModuleStateNode, ProgramStateAnalysis, ProgramStateStack, StateNodeDecl, TypedefStateNode } from "../optimizer-types";
3
+ /**
4
+ * TypeBit gives the position of the 1 bit in TypeTag
5
+ */
6
+ export declare enum TypeBit {
7
+ Null = 0,
8
+ False = 1,
9
+ True = 2,
10
+ Number = 3,
11
+ Long = 4,
12
+ Float = 5,
13
+ Double = 6,
14
+ Char = 7,
15
+ String = 8,
16
+ Array = 9,
17
+ Dictionary = 10,
18
+ Module = 11,
19
+ Function = 12,
20
+ Class = 13,
21
+ Object = 14,
22
+ Enum = 15,
23
+ Symbol = 16,
24
+ Typedef = 17
25
+ }
26
+ export declare enum TypeTag {
27
+ Never = 0,
28
+ Null = 1,
29
+ False = 2,
30
+ True = 4,
31
+ Boolean = 6,
32
+ Number = 8,
33
+ Long = 16,
34
+ Float = 32,
35
+ Double = 64,
36
+ Numeric = 120,
37
+ Char = 128,
38
+ String = 256,
39
+ Array = 512,
40
+ Dictionary = 1024,
41
+ Module = 2048,
42
+ Function = 4096,
43
+ Class = 8192,
44
+ Object = 16384,
45
+ Enum = 32768,
46
+ Symbol = 65536,
47
+ Typedef = 131072,
48
+ Any = 262143
49
+ }
50
+ export declare const SingleTonTypeTagsConst: number;
51
+ export declare const UnionDataTypeTagsConst: number;
52
+ export declare const ValueTypeTagsConst: number;
53
+ export declare const ObjectLikeTagsConst: number;
54
+ declare type ExactTypeTags = TypeTag.Null | TypeTag.False | TypeTag.True | TypeTag.Number | TypeTag.Long | TypeTag.Float | TypeTag.Double | TypeTag.Char | TypeTag.String | TypeTag.Array | TypeTag.Dictionary | TypeTag.Module | TypeTag.Function | TypeTag.Class | TypeTag.Object | TypeTag.Enum | TypeTag.Symbol | TypeTag.Typedef;
55
+ export declare type EnumeratedTypeTags = ExactTypeTags | TypeTag.Never | TypeTag.Any;
56
+ export declare type UnionTypeTags = number;
57
+ interface AbstractValue {
58
+ type: UnionTypeTags;
59
+ value?: unknown;
60
+ }
61
+ export declare type ExactTypes = NullType | FalseType | TrueType | NumberType | LongType | FloatType | DoubleType | CharType | StringType | ArrayType | DictionaryType | ModuleType | FunctionType | ClassType | ObjectType | EnumType | SymbolType | TypedefType;
62
+ declare type WithValue<T> = T extends ExactTypes ? T extends SingletonType ? T : T & {
63
+ value: NonNullable<T["value"]>;
64
+ } : never;
65
+ export declare type ValueTypes = WithValue<ExactTypes>;
66
+ export declare type ExtendedTypes = ExactTypes | NeverType | AnyType;
67
+ export interface NeverType extends AbstractValue {
68
+ type: 0;
69
+ value?: undefined;
70
+ }
71
+ export interface NullType extends AbstractValue {
72
+ type: TypeTag.Null;
73
+ value?: undefined;
74
+ }
75
+ export interface FalseType extends AbstractValue {
76
+ type: TypeTag.False;
77
+ value?: undefined;
78
+ }
79
+ export interface TrueType extends AbstractValue {
80
+ type: TypeTag.True;
81
+ value?: undefined;
82
+ }
83
+ export interface NumberType extends AbstractValue {
84
+ type: TypeTag.Number;
85
+ value?: number | undefined;
86
+ }
87
+ export interface LongType extends AbstractValue {
88
+ type: TypeTag.Long;
89
+ value?: bigint | undefined;
90
+ }
91
+ export interface FloatType extends AbstractValue {
92
+ type: TypeTag.Float;
93
+ value?: number | undefined;
94
+ }
95
+ export interface DoubleType extends AbstractValue {
96
+ type: TypeTag.Double;
97
+ value?: number | undefined;
98
+ }
99
+ export interface CharType extends AbstractValue {
100
+ type: TypeTag.Char;
101
+ value?: string | undefined;
102
+ }
103
+ export interface StringType extends AbstractValue {
104
+ type: TypeTag.String;
105
+ value?: string | undefined;
106
+ }
107
+ export interface ArrayType extends AbstractValue {
108
+ type: TypeTag.Array;
109
+ value?: ExactOrUnion | undefined;
110
+ }
111
+ export interface DictionaryType extends AbstractValue {
112
+ type: TypeTag.Dictionary;
113
+ value?: {
114
+ key: ExactOrUnion;
115
+ value: ExactOrUnion;
116
+ } | undefined;
117
+ }
118
+ export interface ModuleType extends AbstractValue {
119
+ type: TypeTag.Module;
120
+ value?: ModuleStateNode | ModuleStateNode[] | undefined;
121
+ }
122
+ export interface FunctionType extends AbstractValue {
123
+ type: TypeTag.Function;
124
+ value?: FunctionStateNode | FunctionStateNode[] | undefined;
125
+ }
126
+ export interface ClassType extends AbstractValue {
127
+ type: TypeTag.Class;
128
+ value?: ClassStateNode | ClassStateNode[] | undefined;
129
+ }
130
+ export interface TypedefType extends AbstractValue {
131
+ type: TypeTag.Typedef;
132
+ value?: TypedefStateNode | TypedefStateNode[] | undefined;
133
+ }
134
+ export interface ObjectType extends AbstractValue {
135
+ type: TypeTag.Object;
136
+ value?: {
137
+ klass: ClassType;
138
+ obj?: Record<string, ExactOrUnion>;
139
+ } | undefined;
140
+ }
141
+ export interface EnumType extends AbstractValue {
142
+ type: TypeTag.Enum;
143
+ value?: {
144
+ enum: EnumStateNode;
145
+ value?: ExactOrUnion | undefined;
146
+ } | undefined;
147
+ }
148
+ export interface SymbolType extends AbstractValue {
149
+ type: TypeTag.Symbol;
150
+ value?: string | undefined;
151
+ }
152
+ export interface AnyType extends AbstractValue {
153
+ type: -1;
154
+ value?: undefined;
155
+ }
156
+ export declare type SingletonType = NullType | FalseType | TrueType;
157
+ export declare type UnionData = {
158
+ mask: TypeTag;
159
+ [TypeTag.Array]?: NonNullable<ArrayType["value"]>;
160
+ [TypeTag.Dictionary]?: NonNullable<DictionaryType["value"]>;
161
+ [TypeTag.Module]?: NonNullable<ModuleType["value"]>;
162
+ [TypeTag.Function]?: NonNullable<FunctionType["value"]>;
163
+ [TypeTag.Class]?: NonNullable<ClassType["value"]>;
164
+ [TypeTag.Object]?: NonNullable<ObjectType["value"]>;
165
+ [TypeTag.Enum]?: NonNullable<EnumType["value"]>;
166
+ };
167
+ export declare type UnionDataKey = Exclude<keyof UnionData, "mask">;
168
+ export interface UnionType extends AbstractValue {
169
+ value?: UnionData | undefined;
170
+ }
171
+ export declare type ExactOrUnion = UnionType | ExactTypes;
172
+ export declare type SingleValue = NonNullable<ValueTypes["value"]>;
173
+ declare type TagValue<TAG> = Extract<ValueTypes, {
174
+ type: TAG;
175
+ }>["value"];
176
+ export declare type ArrayValueType = TagValue<TypeTag.Array>;
177
+ export declare type DictionaryValueType = TagValue<TypeTag.Dictionary>;
178
+ export declare type ObjectValueType = TagValue<TypeTag.Object>;
179
+ export declare type EnumValueType = TagValue<TypeTag.Enum>;
180
+ export declare type TypedefValueType = TagValue<TypeTag.Typedef>;
181
+ export declare type StateDeclValueType = TagValue<TypeTag.Module> | TagValue<TypeTag.Function> | TagValue<TypeTag.Class>;
182
+ export declare function isExact(v: AbstractValue): v is ExactTypes;
183
+ export declare function isUnion(v: AbstractValue): v is UnionType;
184
+ export declare function isSingleton(v: AbstractValue): v is SingletonType;
185
+ export declare function hasValue(v: AbstractValue): v is WithValue<ExactTypes>;
186
+ export declare function cloneType<T extends ExactOrUnion>(t: T): T;
187
+ export declare function typeFromTypeStateNode(state: ProgramStateAnalysis, sn: StateNodeDecl, classVsObj?: boolean): ExactOrUnion;
188
+ export declare function typeFromTypeStateNodes(state: ProgramStateAnalysis, sns: StateNodeDecl[], classVsObj?: boolean): ExactOrUnion;
189
+ export declare function typeFromTypespec(state: ProgramStateAnalysis, ts: mctree.TypeSpecList, stack?: ProgramStateStack | undefined): ExactOrUnion;
190
+ export declare function typeFromLiteral(literal: mctree.Literal): ExactTypes;
191
+ export declare function mcExprFromType(type: ValueTypes): mctree.Expression | null;
192
+ export declare function castType(type: ExactOrUnion, target: UnionTypeTags): ExactOrUnion;
193
+ export declare const TruthyTypes: number;
194
+ export declare function mustBeTrue(arg: ExactOrUnion): boolean;
195
+ export declare function mustBeFalse(arg: ExactOrUnion): boolean;
196
+ export declare function display(type: ExactOrUnion): string;
197
+ export declare function hasUnionData(tag: TypeTag): boolean;
198
+ export declare function getObjectValue(t: ExactOrUnion): ObjectType["value"] | null;
199
+ export declare function forEachUnionComponent(v: ExactOrUnion, bits: TypeTag, fn: (tag: UnionDataKey, value: SingleValue | null | undefined) => boolean | void): void;
200
+ export declare function getUnionComponent(v: ExactOrUnion, tag: TypeTag): SingleValue | null;
201
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ExactOrUnion, TypeTag } from "./types";
2
+ export declare function unionInto(to: ExactOrUnion, from: ExactOrUnion): boolean;
3
+ export declare function clearValuesUnder(v: ExactOrUnion, tag: TypeTag, clearTag?: boolean): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markw65/monkeyc-optimizer",
3
3
  "type": "module",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
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",
@@ -35,7 +35,7 @@
35
35
  "build/util.cjs",
36
36
  "build/sdk-util.cjs",
37
37
  "build/api.cjs",
38
- "build/src/*.d.ts"
38
+ "build/src/**/*.d.ts"
39
39
  ],
40
40
  "author": "markw65",
41
41
  "license": "MIT",