@samitouri / QOS-React-2 / commits / 9bfad00410

[type-infer] Implement Hindley Milner type inference

Based on the lambda calculus of ForgetScript, this infers the types of primitives, objects and functions.

Sathya Gunasekaran committed Dec 14, 2022 at 15:36 UTC 9bfad004107b5597000775717dbbebd64f2d12f2
113 files changed +3042 -1949
compiler/forget/src/HIR/BuildHIR.ts
+1 -13
@@ -22,7 +22,7 @@ import {
22 ReturnTerminal,
23 SourceLocation,
24 ThrowTerminal,
25 - Type,
25 + makeType,
26 } from "./HIR";
27 import HIRBuilder, { Environment } from "./HIRBuilder";
28 import todo, { todoInvariant } from "./todo";
@@ -83,7 +83,6 @@ export function lower(
83 memberPath: null,
84 effect: Effect.Unknown,
85 loc: param.loc ?? GeneratedSource,
86 - type: Type.Any,
86 };
87 params.push(place);
88 });
@@ -892,7 +891,6 @@ function lowerExpression(
891 memberPath: null,
892 effect: Effect.Unknown,
893 loc: left.loc,
895 - type: Type.Any,
894 };
895 builder.push({
896 id: makeInstructionId(0),
@@ -911,7 +909,6 @@ function lowerExpression(
909 memberPath: null,
910 effect: Effect.Unknown,
911 loc: left.loc,
914 - type: Type.Any,
912 };
913 builder.push({
914 id: makeInstructionId(0),
@@ -1010,7 +1007,6 @@ function lowerExpression(
1007 memberPath: [...(object.memberPath ?? []), property.node.name],
1008 effect: Effect.Unknown,
1009 loc: exprLoc,
1013 - type: Type.Any,
1010 };
1011 return place;
1012 }
@@ -1087,7 +1083,6 @@ function lowerConditional(
1083 memberPath: null,
1084 effect: Effect.Read,
1085 loc,
1090 - type: Type.Any,
1086 };
1087 // Block for code following the if
1088 const continuationBlock = builder.reserve();
@@ -1159,7 +1154,6 @@ function lowerJsxElementName(
1154 memberPath: null,
1155 effect: Effect.Unknown,
1156 loc: exprLoc,
1162 - type: Type.Any,
1157 };
1158 return place;
1159 } else {
@@ -1169,7 +1163,6 @@ function lowerJsxElementName(
1163 memberPath: null,
1164 effect: Effect.Unknown,
1165 loc: exprLoc,
1172 - type: Type.Any,
1166 };
1167 builder.push({
1168 id: makeInstructionId(0),
@@ -1210,7 +1203,6 @@ function lowerJsxElement(
1203 memberPath: null,
1204 effect: Effect.Unknown,
1205 loc: exprLoc,
1213 - type: Type.Any,
1206 };
1207 builder.push({
1208 id: makeInstructionId(0),
@@ -1234,7 +1226,6 @@ function lowerJsxElement(
1226 memberPath: null,
1227 effect: Effect.Unknown,
1228 loc: exprLoc,
1237 - type: Type.Any,
1229 };
1230 builder.push({
1231 id: makeInstructionId(0),
@@ -1265,7 +1256,6 @@ function lowerExpressionToPlace(
1256 memberPath: null,
1257 effect: Effect.Unknown,
1258 loc: exprLoc,
1268 - type: Type.Any,
1259 };
1260 builder.push({
1261 id: makeInstructionId(0),
@@ -1315,7 +1305,6 @@ function lowerLVal(builder: HIRBuilder, exprPath: NodePath<t.LVal>): Place {
1305 memberPath: null,
1306 effect: Effect.Unknown,
1307 loc: exprLoc,
1318 - type: Type.Any,
1308 };
1309 return place;
1310 }
@@ -1335,7 +1324,6 @@ function lowerLVal(builder: HIRBuilder, exprPath: NodePath<t.LVal>): Place {
1324 memberPath: [...(object.memberPath ?? []), propertyPath.node.name],
1325 effect: Effect.Unknown,
1326 loc: exprLoc,
1338 - type: Type.Any,
1327 };
1328 return place;
1329 }
compiler/forget/src/HIR/EnterSSA.ts
+2
@@ -5,6 +5,7 @@ import {
5 Identifier,
6 IdentifierId,
7 makeInstructionId,
8 + makeType,
9 Phi,
10 Place,
11 } from "./HIR";
@@ -57,6 +58,7 @@ class SSABuilder {
58 end: makeInstructionId(0),
59 },
60 scope: null, // reset along w the mutable range
61 + type: makeType(),
62 };
63 }
64
compiler/forget/src/HIR/HIR.ts
+109 -8
@@ -316,7 +316,6 @@ export type Place = {
316 memberPath: Array<string> | null;
317 effect: Effect;
318 loc: SourceLocation;
319 - type: Type;
319 };
320
321 /**
@@ -343,15 +342,17 @@ export type MutableRange = {
342 * Represents a user-defined variable (has a name) or a temporary variable (no name).
343 */
344 export type Identifier = {
346 - // unique value to distinguish a variable, since name is not guaranteed to exist or be unique
345 + // unique value to distinguish a variable, since name is not guaranteed to
346 + // exist or be unique
347 id: IdentifierId;
348 // null for temporaries. name is primarily used for debugging.
349 name: string | null;
350 // The range for which this variable is mutable
351 mutableRange: MutableRange;
352 - // The ID of the reactive scope which will compute this value. Multiple variables may have
353 - // the same scope id.
352 + // The ID of the reactive scope which will compute this value. Multiple
353 + // variables may have the same scope id.
354 scope: ReactiveScope | null;
355 + type: Type;
356 };
357
358 /**
@@ -445,8 +446,108 @@ export function makeInstructionId(id: number): InstructionId {
446 return id as InstructionId;
447 }
448
448 -export enum Type {
449 - Any,
450 - Primitive,
451 - Object,
449 +export type Type =
450 + | PrimitiveType
451 + | FunctionType
452 + | ObjectType
453 + | PropType
454 + | PolyType
455 + | TypeVar;
456 +export type PrimitiveType = { kind: "Primitive" };
457 +export type FunctionType = {
458 + kind: "Function";
459 + argTypes: Array<Type>;
460 + returnType: Type;
461 +};
462 +export type ObjectType = { kind: "Object"; properties: Map<string, Type> };
463 +export type PropType = { kind: "Prop"; objectType: Type; name: string };
464 +export type TypeVar = {
465 + kind: "Type";
466 + name: string;
467 +};
468 +export type PolyType = {
469 + kind: "Poly";
470 +};
471 +
472 +let typeCounter = 0;
473 +export function makeType(): Type {
474 + return {
475 + kind: "Type",
476 + name: `t${typeCounter++}`, //TODO(gsn): Use a TypeID here
477 + };
478 +}
479 +
480 +export function typeEquals(tA: Type, tB: Type): boolean {
481 + if (tA.kind !== tB.kind) return false;
482 + return (
483 + typeVarEquals(tA, tB) ||
484 + funcTypeEquals(tA, tB) ||
485 + objectTypeEquals(tA, tB) ||
486 + propTypeEquals(tA, tB) ||
487 + primitiveTypeEquals(tA, tB) ||
488 + polyTypeEquals(tA, tB)
489 + );
490 +}
491 +
492 +function typeVarEquals(tA: Type, tB: Type): boolean {
493 + if (tA.kind === "Type" && tB.kind === "Type") {
494 + return tA.name === tB.name;
495 + }
496 + return false;
497 +}
498 +
499 +function primitiveTypeEquals(tA: Type, tB: Type): boolean {
500 + return tA.kind === "Primitive" && tB.kind === "Primitive";
501 +}
502 +
503 +function polyTypeEquals(tA: Type, tB: Type): boolean {
504 + return tA.kind === "Poly" && tB.kind === "Poly";
505 +}
506 +
507 +function objectTypeEquals(tA: Type, tB: Type): boolean {
508 + if (tA.kind === "Object" && tB.kind === "Object") {
509 + if (tA.properties.size !== tB.properties.size) {
510 + return false;
511 + }
512 +
513 + for (const key of tA.properties.keys()) {
514 + if (tA.properties.get(key) !== tB.properties.get(key)) return false;
515 + }
516 +
517 + return true;
518 + }
519 +
520 + return false;
521 +}
522 +
523 +function propTypeEquals(tA: Type, tB: Type): boolean {
524 + if (tA.kind === "Prop" && tB.kind === "Prop") {
525 + if (tA.name !== tB.name) {
526 + return false;
527 + }
528 + return objectTypeEquals(tA.objectType, tB.objectType);
529 + }
530 +
531 + return false;
532 +}
533 +
534 +function funcTypeEquals(tA: Type, tB: Type): boolean {
535 + if (tA.kind === "Function" && tB.kind === "Function") {
536 + if (tA.returnType !== tB.returnType) {
537 + return false;
538 + }
539 +
540 + if (tA.argTypes.length !== tB.argTypes.length) {
541 + return false;
542 + }
543 +
544 + for (let i = 0; i < tA.argTypes.length; i++) {
545 + if (!typeVarEquals(tA.argTypes[i], tB.argTypes[i])) {
546 + return false;
547 + }
548 + }
549 +
550 + return true;
551 + }
552 + return false;
553 }
compiler/forget/src/HIR/HIRBuilder.ts
+3
@@ -20,6 +20,7 @@ import {
20 makeBlockId,
21 makeIdentifierId,
22 makeInstructionId,
23 + makeType,
24 Terminal,
25 } from "./HIR";
26 import { printInstruction } from "./PrintHIR";
@@ -115,6 +116,7 @@ export default class HIRBuilder {
116 name: null,
117 mutableRange: { start: makeInstructionId(0), end: makeInstructionId(0) },
118 scope: null,
119 + type: makeType(),
120 };
121 }
122
@@ -130,6 +132,7 @@ export default class HIRBuilder {
132 end: makeInstructionId(0),
133 },
134 scope: null,
135 + type: makeType(),
136 };
137 this.#bindings.set(node, identifier);
138 }
compiler/forget/src/HIR/InferReferenceEffects.ts
+1 -2
@@ -14,9 +14,9 @@ import {
14 HIRFunction,
15 IdentifierId,
16 InstructionValue,
17 + makeType,
18 Phi,
19 Place,
19 - Type,
20 ValueKind,
21 } from "./HIR";
22 import { printMixedHIR, printPlace, printSourceLocation } from "./PrintHIR";
@@ -78,7 +78,6 @@ export default function inferReferenceEffects(fn: HIRFunction) {
78 identifier: fn.id as any,
79 loc: fn.loc,
80 effect: Effect.Freeze,
81 - type: Type.Any,
81 };
82 const value: InstructionValue = {
83 kind: "Primitive",
compiler/forget/src/HIR/InferTypes.ts
+309 -116
@@ -1,163 +1,356 @@
1 +import * as t from "@babel/types";
2 import invariant from "invariant";
2 -import DisjointSet from "./DisjointSet";
3 import {
4 HIRFunction,
5 - Identifier,
5 Instruction,
7 - LValue,
8 - Place,
6 + makeType,
7 + PropType,
8 Type,
9 + typeEquals,
10 + TypeVar,
11 + Place,
12 + LValue,
13 } from "./HIR";
11 -import { printInstructionValue } from "./PrintHIR";
14 +import { eachInstructionOperand } from "./visitors";
15
13 -type AbstractValue = AbstractObject | AbstractPrimitive;
14 -type AbstractObject = {
15 - kind: "Object";
16 - values: Map<string, AbstractValue>;
17 -};
18 -type AbstractPrimitive = {
19 - kind: "Primitive";
20 - value: number | boolean | string | null | undefined;
16 +function isPrimitiveBinaryOp(op: t.BinaryExpression["operator"]) {
17 + switch (op) {
18 + case "+":
19 + case "-":
20 + case "/":
21 + case "%":
22 + case "*":
23 + case "**":
24 + case "&":
25 + case "|":
26 + case ">>":
27 + case ">>":
28 + case "<<":
29 + case "^":
30 + case "==":
31 + case "==":
32 + case "!=":
33 + case "!=":
34 + case ">":
35 + case "<":
36 + case ">=":
37 + case "<=":
38 + case "|>":
39 + return true;
40 + default:
41 + return false;
42 + }
43 +}
44 +
45 +export function inferTypes(func: HIRFunction) {
46 + const unifier = new Unifier();
47 + for (const e of generate(func, unifier)) {
48 + unifier.unify(e.left, e.right);
49 + }
50 + apply(func, unifier);
51 +}
52 +
53 +function apply(func: HIRFunction, unifier: Unifier) {
54 + for (const [_, block] of func.body.blocks) {
55 + for (const instr of block.instructions) {
56 + for (const place of eachInstructionOperand(instr)) {
57 + place.identifier.type = unifier.get(place.identifier.type);
58 + }
59 + const { lvalue } = instr;
60 + if (lvalue !== null) {
61 + lvalue.place.identifier.type = unifier.get(
62 + lvalue.place.identifier.type
63 + );
64 + }
65 + }
66 + }
67 +}
68 +
69 +type TypeEquation = {
70 + left: Type;
71 + right: Type;
72 };
73
23 -function typeOf(value: AbstractValue) {
24 - switch (value.kind) {
25 - case "Primitive":
26 - return Type.Primitive;
27 - case "Object":
28 - return Type.Object;
29 - default:
30 - return Type.Any;
74 +function* generate(func: HIRFunction, unifier: Unifier) {
75 + for (const [_, block] of func.body.blocks) {
76 + for (const instr of block.instructions) {
77 + yield* generateTypeEquation(instr, unifier);
78 + }
79 }
80 }
81
34 -class AbstractState {
35 - #values = new Map<Identifier, AbstractValue>();
82 +function generateTypeEquation(
83 + instr: Instruction,
84 + unifier: Unifier
85 +): Array<TypeEquation> {
86 + const equations: Array<TypeEquation> = [];
87 + const { lvalue, value } = instr;
88 + const left: Type | null = assignTypeForLvalue(lvalue, equations, unifier);
89
37 - read(alias: Place): AbstractValue {
38 - // Simple alias:
39 - // read(alias);
40 - if (alias.memberPath === null) {
41 - let value = this.#values.get(alias.identifier);
90 + switch (value.kind) {
91 + case "Primitive": {
92 + if (left !== null) {
93 + equations.push({
94 + left,
95 + right: { kind: "Primitive" },
96 + });
97 + }
98 + break;
99 + }
100
43 - // Don't know what this is, let's default to an Object conservatively.
44 - if (value === undefined) {
45 - value = { kind: "Object", values: new Map() };
101 + case "Identifier": {
102 + if (left !== null) {
103 + let right: Type = assignTypeForPlace(value, equations);
104 + equations.push({
105 + left,
106 + right,
107 + });
108 }
109
48 - this.#values.set(alias.identifier, value);
49 - return value;
110 + break;
111 }
112
52 - if (alias.memberPath.length > 1) {
53 - // TODO(gsn): Correctly handle nested member paths when reading values
54 - return { kind: "Object", values: new Map() };
113 + case "BinaryExpression": {
114 + if (isPrimitiveBinaryOp(value.operator)) {
115 + equations.push({
116 + left: value.left.identifier.type,
117 + right: { kind: "Primitive" },
118 + });
119 + equations.push({
120 + left: value.right.identifier.type,
121 + right: { kind: "Primitive" },
122 + });
123 + }
124 +
125 + if (left !== null) {
126 + equations.push({
127 + left,
128 + right: { kind: "Primitive" },
129 + });
130 + }
131 +
132 + break;
133 }
134
57 - // Complex alias:
58 - // read(alias.memberPath);
59 - let object = this.#values.get(alias.identifier);
135 + // TODO(gsn): This is potentially unsafe if we're modeling JavaScript as
136 + // these should be PolyTypes. Modeling PolyTypes seems overkill for Forget
137 + // as we're super conservative anyway. Should we not model function
138 + // application?
139 + case "CallExpression": {
140 + const argTypes = value.args.map((a) => a.identifier.type);
141
61 - // Don't know what this is, let's default to an Object conservatively.
62 - if (object === undefined) {
63 - object = { kind: "Object", values: new Map() };
64 - this.#values.set(alias.identifier, object);
142 + equations.push({
143 + left: value.callee.identifier.type,
144 + right: {
145 + kind: "Function",
146 + argTypes,
147 + returnType: left ?? makeType(),
148 + },
149 + });
150 +
151 + break;
152 }
153
67 - // We're doing a member lookup on a non object.
68 - //
69 - // alias = 1;
70 - // read(alias.memberPath);
71 - if (object.kind !== "Object") {
72 - // Update alias to be an object
73 - object = { kind: "Object", values: new Map() };
74 - this.#values.set(alias.identifier, object);
154 + case "ObjectExpression": {
155 + invariant(left !== null, "invald object expression");
156 + const properties = new Map(
157 + [...(value.properties?.entries() ?? [])].map(([prop, place]) => [
158 + prop,
159 + place.identifier.type,
160 + ])
161 + );
162
76 - // Conservatively type the value as object.
77 - //
78 - // NOTE(gsn): Should this be an AbstractUnknown rather than an
79 - // AbstractObject?
80 - let value: AbstractObject = { kind: "Object", values: new Map() };
81 - object.values.set(alias.memberPath[0], value);
82 - return value;
163 + equations.push({
164 + left,
165 + right: {
166 + kind: "Object",
167 + properties,
168 + },
169 + });
170 + break;
171 }
172 + }
173 + return equations;
174 +}
175
85 - let value = object.values.get(alias.memberPath[0]);
176 +function assignTypeForPlace(
177 + value: Place,
178 + equations: Array<TypeEquation>
179 +): Type {
180 + if (value.memberPath === null) {
181 + return value.identifier.type;
182 + }
183
87 - // We don't have a value for this member path.
88 - //
89 - // alias = {};
90 - // read(alias.memberPath);
91 - if (value === undefined) {
92 - // Conservatively type the value as object.
93 - value = {
94 - kind: "Object",
95 - values: new Map(),
96 - };
97 - object.values.set(alias.memberPath[0], value);
98 - return value;
184 + if (value.memberPath.length > 1) {
185 + // TODO(gsn): Lower nested memberPaths in HIR
186 + return makeType();
187 + }
188 +
189 + const propName = value.memberPath[0];
190 + const propType = makeType();
191 + equations.push({
192 + left: propType,
193 + right: {
194 + kind: "Prop",
195 + objectType: value.identifier.type,
196 + name: propName,
197 + },
198 + });
199 +
200 + return propType;
201 +}
202 +
203 +function assignTypeForLvalue(
204 + lvalue: LValue | null,
205 + equations: Array<TypeEquation>,
206 + unifier: Unifier
207 +): Type | null {
208 + if (lvalue === null) return null;
209 +
210 + return (
211 + unifier.generalize(lvalue.place.identifier.type, lvalue.place.memberPath) ??
212 + assignTypeForPlace(lvalue.place, equations)
213 + );
214 +}
215 +
216 +type Substitution = Map<string, Type>;
217 +class Unifier {
218 + substitutions: Substitution = new Map();
219 +
220 + unify(tA: Type, tB: Type) {
221 + if (typeEquals(tA, tB)) {
222 + return;
223 }
224
101 - // We have a value for this memberPath!
102 - //
103 - // alias.memberPath = value;
104 - // read(alias.memberPath);
105 - return value;
225 + if (tA.kind === "Type") {
226 + this.bindVariableTo(tA, tB);
227 + return;
228 + }
229 +
230 + if (tB.kind === "Type") {
231 + this.bindVariableTo(tB, tA);
232 + return;
233 + }
234 +
235 + if (tA.kind === "Function" && tB.kind === "Function") {
236 + const len = Math.min(tA.argTypes.length, tB.argTypes.length);
237 + for (let i = 0; i < len; i++) {
238 + this.unify(tA.argTypes[i], tB.argTypes[i]);
239 + }
240 + this.unify(tA.returnType, tB.returnType);
241 + }
242 }
243
108 - store(lvalue: LValue, value: AbstractValue) {
109 - // TODO(gsn): Handle stores for complex lvalue
110 - if (lvalue.place.memberPath !== null) {
244 + bindVariableTo(v: TypeVar, type: Type): void {
245 + if (this.substitutions.has(v.name)) {
246 + this.unify(this.substitutions.get(v.name)!, type);
247 return;
248 }
249
114 - // Simple lvalue:
115 - // lvalue = alias;
116 - // lvalue = alias.memberPath;
117 - lvalue.place.type = typeOf(value);
118 - this.#values.set(lvalue.place.identifier, value);
250 + if (type.kind === "Type" && this.substitutions.has(type.name)) {
251 + this.unify(v, this.substitutions.get(type.name)!);
252 + return;
253 + }
254 +
255 + if (type.kind === "Prop") {
256 + this.bindToProp(v, type);
257 + return;
258 + }
259 +
260 + if (this.occursCheck(v, type)) {
261 + throw new Error("cycle detected");
262 + }
263 +
264 + this.substitutions.set(v.name, type);
265 }
120 -}
266
122 -export function inferTypes(func: HIRFunction) {
123 - const state = new AbstractState();
124 - for (const [_, block] of func.body.blocks) {
125 - for (const instr of block.instructions) {
126 - inferInstr(instr, state);
267 + bindToProp(type: TypeVar, prop: PropType) {
268 + let object = prop.objectType;
269 +
270 + if (object.kind === "Type" && this.substitutions.has(object.name)) {
271 + object = this.substitutions.get(object.name)!;
272 + }
273 +
274 + if (object.kind === "Object") {
275 + if (!object.properties.has(prop.name)) {
276 + object.properties.set(prop.name, type);
277 + return;
278 + }
279 +
280 + this.unify(object.properties.get(prop.name)!, type);
281 + return;
282 }
283 +
284 + this.substitutions.set(type.name, prop);
285 }
129 -}
286
131 -function inferInstr(instr: Instruction, state: AbstractState) {
132 - const { lvalue, value: instrValue } = instr;
133 - let alias: Place | null = null;
134 - let value: AbstractValue | null = null;
135 - switch (instrValue.kind) {
136 - case "Primitive": {
137 - value = {
138 - kind: "Primitive",
139 - value: instrValue.value,
140 - };
141 - break;
287 + occursCheck(v: TypeVar, type: Type): boolean {
288 + if (typeEquals(v, type)) return true;
289 +
290 + if (type.kind === "Type" && this.substitutions.has(type.name)) {
291 + return this.occursCheck(v, this.substitutions.get(type.name)!);
292 }
143 - case "Identifier": {
144 - alias = instrValue;
145 - value = state.read(alias);
146 - break;
293 +
294 + if (type.kind === "Function") {
295 + return (
296 + this.occursCheck(v, type.returnType) ||
297 + type.argTypes.some((a) => this.occursCheck(v, a))
298 + );
299 }
148 - default:
149 - return;
300 +
301 + if (type.kind === "Object") {
302 + return [...type.properties.values()].some((p) => this.occursCheck(v, p));
303 + }
304 +
305 + if (type.kind === "Prop") {
306 + return this.occursCheck(v, type.objectType);
307 + }
308 +
309 + return false;
310 }
311
152 - invariant(
153 - value !== null,
154 - `expected ${printInstructionValue(instrValue)} to be an alias or value`
155 - );
312 + get(type: Type): Type {
313 + if (type.kind === "Primitive") {
314 + return type;
315 + }
316 +
317 + if (type.kind === "Type") {
318 + if (this.substitutions.has(type.name)) {
319 + return this.get(this.substitutions.get(type.name)!);
320 + } else {
321 + return type;
322 + }
323 + }
324 +
325 + if (type.kind === "Function") {
326 + return {
327 + kind: "Function",
328 + argTypes: type.argTypes.map((a) => this.get(a)),
329 + returnType: this.get(type.returnType),
330 + };
331 + }
332
157 - // TODO(gsn): handle this.
158 - if (lvalue === null) {
159 - return;
333 + return type;
334 }
335
162 - state.store(lvalue, value);
336 + generalize(objectType: Type, name: Array<string> | null): Type | null {
337 + if (objectType.kind === "Type" && this.substitutions.has(objectType.name)) {
338 + objectType = this.substitutions.get(objectType.name)!;
339 + }
340 +
341 + if (
342 + name !== null &&
343 + objectType.kind === "Object" &&
344 + objectType.properties.has(name[0])
345 + ) {
346 + const newType: Type = {
347 + kind: "Poly",
348 + };
349 +
350 + objectType.properties.set(name[0], newType);
351 + return newType;
352 + }
353 +
354 + return null;
355 + }
356 }
compiler/forget/src/HIR/LeaveSSA.ts
-2
@@ -16,7 +16,6 @@ import {
16 makeInstructionId,
17 Phi,
18 Place,
19 - Type,
19 } from "./HIR";
20 import { eachInstructionValueOperand, eachTerminalOperand } from "./visitors";
21
@@ -163,7 +162,6 @@ export function leaveSSA(fn: HIRFunction) {
162 identifier,
163 effect: Effect.Mutate,
164 loc: GeneratedSource,
166 - type: Type.Any,
165 },
166 kind: InstructionKind.Let,
167 },
compiler/forget/src/HIR/Pipeline.ts
+6 -1
@@ -20,10 +20,12 @@ import { inferReactiveScopes } from "./InferReactiveScopes";
20 import { inferReactiveScopeVariables } from "./InferReactiveScopeVariables";
21 import { log } from "./logger";
22 import { printFunction } from "./PrintHIR";
23 +import { inferTypes } from "./InferTypes";
24
25 export type CompilerFlags = {
26 eliminateRedundantPhi: boolean;
27 inferReferenceEffects: boolean;
28 + inferTypes: boolean;
29 inferMutableRanges: boolean;
30 inferReactiveScopeVariables: boolean;
31 inferReactiveScopes: boolean;
@@ -53,7 +55,10 @@ export default function (
55 eliminateRedundantPhi(ir);
56 logStep("eliminateRedundantPhi", ir);
57 }
56 -
58 + if (flags.inferTypes) {
59 + inferTypes(ir);
60 + logStep("inferTypes", ir);
61 + }
62 if (flags.inferReferenceEffects) {
63 inferReferenceEffects(ir);
64 logStep("inferReferenceEffects", ir);
compiler/forget/src/HIR/PrintHIR.ts
+19 -4
@@ -20,8 +20,10 @@ import {
20 MutableRange,
21 Phi,
22 Place,
23 + ReactiveScope,
24 SourceLocation,
25 Terminal,
26 + Type,
27 } from "./HIR";
28 import { eachReactiveScope } from "./visitors";
29
@@ -310,19 +312,32 @@ export function printLValue(lval: LValue): string {
312
313 export function printPlace(place: Place): string {
314 const items = [place.effect, " ", printIdentifier(place.identifier)];
313 - if (place.memberPath != null) {
315 + if (place.memberPath !== null) {
316 for (const path of place.memberPath) {
317 items.push(".");
318 items.push(path);
319 }
320 + } else {
321 + items.push(printType(place.identifier.type));
322 }
323 return items.filter((x) => x != null).join("");
324 }
325
326 export function printIdentifier(id: Identifier): string {
323 - return `${id.name ?? ""}\$${id.id}${
324 - id.scope !== null ? `_@${id.scope.id}` : ""
325 - }`;
327 + return `${printName(id.name)}\$${id.id}${printScope(id.scope)}`;
328 +}
329 +
330 +function printName(name: string | null): string {
331 + return name ?? "";
332 +}
333 +
334 +function printScope(scope: ReactiveScope | null): string {
335 + return `${scope !== null ? `_@${scope.id}` : ""}`;
336 +}
337 +
338 +function printType(type: Type): string {
339 + if (type.kind === "Type") return "";
340 + return `:T${type.kind}`;
341 }
342
343 export function printSourceLocation(loc: SourceLocation): string {
compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md
+6 -6
@@ -24,7 +24,7 @@ function Component(props) {
24
25 ```
26 bb0:
27 - [1] Const mutate a$4_@0[1:7] = Array []
27 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
28 [2] Call mutate a$4_@0.push(read props$3.a)
29 [3] If (read props$3.b) then:bb1 else:bb2 fallthrough=bb2
30 bb2:
@@ -34,7 +34,7 @@ bb2:
34 bb1:
35 predecessor blocks: bb0 bb2
36 [6] Call mutate a$4_@0.push(read props$3.d)
37 - [7] Return freeze a$4_@0
37 + [7] Return freeze a$4_@0:TFunction
38 scope0 [1:7]:
39 - dependency: read props$3.a
40 - dependency: read props$3.d
@@ -48,11 +48,11 @@ function Component(
48 props,
49 ) {
50 scope @0 [1:7] deps=[read props$3.a, read props$3.d, read props$3.c] {
51 - [1] Const mutate a$4_@0[1:7] = Array []
51 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
52 [2] Call mutate a$4_@0.push(read props$3.a)
53 if (read props$3.b) {
54 [6] Call mutate a$4_@0.push(read props$3.d)
55 - return freeze a$4_@0
55 + return freeze a$4_@0:TFunction
56 }
57 [4] Call mutate a$4_@0.push(read props$3.c)
58 }
@@ -67,7 +67,7 @@ flowchart TB
67 %% Basic Blocks
68 subgraph bb0
69 bb0_instrs["
70 - [1] Const mutate a$4_@0[1:7] = Array []
70 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
71 [2] Call mutate a$4_@0.push(read props$3.a)
72 "]
73 bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
@@ -82,7 +82,7 @@ flowchart TB
82 bb1_instrs["
83 [6] Call mutate a$4_@0.push(read props$3.d)
84 "]
85 - bb1_instrs --> bb1_terminal(["Return freeze a$4_@0"])
85 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@0:TFunction"])
86 end
87
88 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/_bug_expression-with-assignment.expect.md
+19 -19
@@ -15,17 +15,17 @@ function f() {
15
16 ```
17 bb0:
18 - [1] Const mutate x$4_@0 = 1
19 - [2] Const mutate x$5_@1 = 2
20 - [3] Const mutate $6_@2 = Binary read x$5_@1 + read x$5_@1
21 - [4] Const mutate $7_@3 = Binary read $6_@2 + read x$5_@1
22 - [5] Return read $7_@3
18 + [1] Const mutate x$4_@0:TPrimitive = 1
19 + [2] Const mutate x$5_@1:TPrimitive = 2
20 + [3] Const mutate $6_@2:TPrimitive = Binary read x$5_@1:TPrimitive + read x$5_@1:TPrimitive
21 + [4] Const mutate $7_@3:TPrimitive = Binary read $6_@2:TPrimitive + read x$5_@1:TPrimitive
22 + [5] Return read $7_@3:TPrimitive
23 scope2 [3:4]:
24 - - dependency: read x$5_@1
25 - - dependency: read x$5_@1
24 + - dependency: read x$5_@1:TPrimitive
25 + - dependency: read x$5_@1:TPrimitive
26 scope3 [4:5]:
27 - - dependency: read $6_@2
28 - - dependency: read x$5_@1
27 + - dependency: read $6_@2:TPrimitive
28 + - dependency: read x$5_@1:TPrimitive
29 ```
30
31 ## Reactive Scopes
@@ -33,11 +33,11 @@ scope3 [4:5]:
33 ```
34 function f(
35 ) {
36 - [1] Const mutate x$4_@0 = 1
37 - [2] Const mutate x$5_@1 = 2
38 - [3] Const mutate $6_@2 = Binary read x$5_@1 + read x$5_@1
39 - [4] Const mutate $7_@3 = Binary read $6_@2 + read x$5_@1
40 - return read $7_@3
36 + [1] Const mutate x$4_@0:TPrimitive = 1
37 + [2] Const mutate x$5_@1:TPrimitive = 2
38 + [3] Const mutate $6_@2:TPrimitive = Binary read x$5_@1:TPrimitive + read x$5_@1:TPrimitive
39 + [4] Const mutate $7_@3:TPrimitive = Binary read $6_@2:TPrimitive + read x$5_@1:TPrimitive
40 + return read $7_@3:TPrimitive
41 }
42
43 ```
@@ -49,12 +49,12 @@ flowchart TB
49 %% Basic Blocks
50 subgraph bb0
51 bb0_instrs["
52 - [1] Const mutate x$4_@0 = 1
53 - [2] Const mutate x$5_@1 = 2
54 - [3] Const mutate $6_@2 = Binary read x$5_@1 + read x$5_@1
55 - [4] Const mutate $7_@3 = Binary read $6_@2 + read x$5_@1
52 + [1] Const mutate x$4_@0:TPrimitive = 1
53 + [2] Const mutate x$5_@1:TPrimitive = 2
54 + [3] Const mutate $6_@2:TPrimitive = Binary read x$5_@1:TPrimitive + read x$5_@1:TPrimitive
55 + [4] Const mutate $7_@3:TPrimitive = Binary read $6_@2:TPrimitive + read x$5_@1:TPrimitive
56 "]
57 - bb0_instrs --> bb0_terminal(["Return read $7_@3"])
57 + bb0_instrs --> bb0_terminal(["Return read $7_@3:TPrimitive"])
58 end
59
60 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/_bug_inverted-if-else.expect.md
+3 -3
@@ -20,7 +20,7 @@ function foo(a, b, c) {
20
21 ```
22 bb0:
23 - [1] Const mutate x$8_@0 = null
23 + [1] Const mutate x$8_@0:TPrimitive = null
24 [2] If (read a$5) then:bb3 else:bb2 fallthrough=bb2
25 bb3:
26 predecessor blocks: bb0
@@ -47,7 +47,7 @@ function foo(
47 b,
48 c,
49 ) {
50 - [1] Const mutate x$8_@0 = null
50 + [1] Const mutate x$8_@0:TPrimitive = null
51 if (read a$5) {
52 [3] Const mutate x$9_@1 = read b$6
53 }
@@ -63,7 +63,7 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Const mutate x$8_@0 = null
66 + [1] Const mutate x$8_@0:TPrimitive = null
67 "]
68 bb0_instrs --> bb0_terminal(["If (read a$5)"])
69 end
compiler/forget/src/__tests__/fixtures/hir/alias-nested-member-path-mutate.expect.md
+12 -12
@@ -18,11 +18,11 @@ function component() {
18 ```
19 bb0:
20 [1] Const mutate z$5_@0[1:7] = Array []
21 - [2] Const mutate y$6_@0[1:7] = Object { }
21 + [2] Const mutate y$6_@0:TObject[1:7] = Object { }
22 [3] Reassign mutate y$6_@0.z[1:7] = read z$5_@0
23 - [4] Const mutate x$7_@0[1:7] = Object { }
24 - [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0
25 - [6] Call mutate mutate$4(mutate x$7_@0.y.z)
23 + [4] Const mutate x$7_@0:TObject[1:7] = Object { }
24 + [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0:TObject
25 + [6] Call mutate mutate$4:TFunction(mutate x$7_@0.y.z)
26 [7] Return
27
28 ```
@@ -34,11 +34,11 @@ function component(
34 ) {
35 scope @0 [1:7] deps=[] {
36 [1] Const mutate z$5_@0[1:7] = Array []
37 - [2] Const mutate y$6_@0[1:7] = Object { }
37 + [2] Const mutate y$6_@0:TObject[1:7] = Object { }
38 [3] Reassign mutate y$6_@0.z[1:7] = read z$5_@0
39 - [4] Const mutate x$7_@0[1:7] = Object { }
40 - [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0
41 - [6] Call mutate mutate$4(mutate x$7_@0.y.z)
39 + [4] Const mutate x$7_@0:TObject[1:7] = Object { }
40 + [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0:TObject
41 + [6] Call mutate mutate$4:TFunction(mutate x$7_@0.y.z)
42 }
43 return
44 }
@@ -53,11 +53,11 @@ flowchart TB
53 subgraph bb0
54 bb0_instrs["
55 [1] Const mutate z$5_@0[1:7] = Array []
56 - [2] Const mutate y$6_@0[1:7] = Object { }
56 + [2] Const mutate y$6_@0:TObject[1:7] = Object { }
57 [3] Reassign mutate y$6_@0.z[1:7] = read z$5_@0
58 - [4] Const mutate x$7_@0[1:7] = Object { }
59 - [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0
60 - [6] Call mutate mutate$4(mutate x$7_@0.y.z)
58 + [4] Const mutate x$7_@0:TObject[1:7] = Object { }
59 + [5] Reassign mutate x$7_@0.y[1:7] = read y$6_@0:TObject
60 + [6] Call mutate mutate$4:TFunction(mutate x$7_@0.y.z)
61 "]
62 bb0_instrs --> bb0_terminal(["Return"])
63 end
compiler/forget/src/__tests__/fixtures/hir/alias-nested-member-path.expect.md
+14 -14
@@ -18,15 +18,15 @@ function component() {
18 ```
19 bb0:
20 [1] Const mutate z$4_@0 = Array []
21 - [2] Const mutate y$5_@1[2:4] = Object { }
21 + [2] Const mutate y$5_@1:TObject[2:4] = Object { }
22 [3] Reassign mutate y$5_@1.z[2:4] = read z$4_@0
23 - [4] Const mutate x$6_@2[4:6] = Object { }
24 - [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1
25 - [6] Return freeze x$6_@2
23 + [4] Const mutate x$6_@2:TObject[4:6] = Object { }
24 + [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1:TObject
25 + [6] Return freeze x$6_@2:TObject
26 scope1 [2:4]:
27 - dependency: read z$4_@0
28 scope2 [4:6]:
29 - - dependency: read y$5_@1
29 + - dependency: read y$5_@1:TObject
30 ```
31
32 ## Reactive Scopes
@@ -38,14 +38,14 @@ function component(
38 [1] Const mutate z$4_@0 = Array []
39 }
40 scope @1 [2:4] deps=[read z$4_@0] {
41 - [2] Const mutate y$5_@1[2:4] = Object { }
41 + [2] Const mutate y$5_@1:TObject[2:4] = Object { }
42 [3] Reassign mutate y$5_@1.z[2:4] = read z$4_@0
43 }
44 - scope @2 [4:6] deps=[read y$5_@1] {
45 - [4] Const mutate x$6_@2[4:6] = Object { }
46 - [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1
44 + scope @2 [4:6] deps=[read y$5_@1:TObject] {
45 + [4] Const mutate x$6_@2:TObject[4:6] = Object { }
46 + [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1:TObject
47 }
48 - return freeze x$6_@2
48 + return freeze x$6_@2:TObject
49 }
50
51 ```
@@ -58,12 +58,12 @@ flowchart TB
58 subgraph bb0
59 bb0_instrs["
60 [1] Const mutate z$4_@0 = Array []
61 - [2] Const mutate y$5_@1[2:4] = Object { }
61 + [2] Const mutate y$5_@1:TObject[2:4] = Object { }
62 [3] Reassign mutate y$5_@1.z[2:4] = read z$4_@0
63 - [4] Const mutate x$6_@2[4:6] = Object { }
64 - [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1
63 + [4] Const mutate x$6_@2:TObject[4:6] = Object { }
64 + [5] Reassign mutate x$6_@2.y[4:6] = read y$5_@1:TObject
65 "]
66 - bb0_instrs --> bb0_terminal(["Return freeze x$6_@2"])
66 + bb0_instrs --> bb0_terminal(["Return freeze x$6_@2:TObject"])
67 end
68
69 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md
+36 -36
@@ -27,27 +27,27 @@ function mutate(x, y) {}
27
28 ```
29 bb0:
30 - [1] Let mutate a$8_@0[1:12] = Object { }
31 - [2] Let mutate b$9_@0[1:12] = Object { }
32 - [3] Let mutate c$10_@0[1:12] = Object { }
30 + [1] Let mutate a$8_@0:TObject[1:12] = Object { }
31 + [2] Let mutate b$9_@0:TObject[1:12] = Object { }
32 + [3] Let mutate c$10_@0:TObject[1:12] = Object { }
33 [4] While test=bb1 loop=bb3 fallthrough=bb2
34 bb1:
35 predecessor blocks: bb0 bb3
36 [5] If (read cond$7) then:bb3 else:bb2 fallthrough=bb2
37 bb3:
38 predecessor blocks: bb1
39 - [6] Const mutate z$13_@0[1:12] = read a$8_@0
40 - [7] Reassign mutate a$8_@0[1:12] = read b$9_@0
41 - [8] Reassign mutate b$9_@0[1:12] = read c$10_@0
42 - [9] Reassign mutate c$10_@0[1:12] = read z$13_@0
43 - [10] Call mutate mutate$6(mutate a$8_@0, mutate b$9_@0)
39 + [6] Const mutate z$13_@0[1:12] = read a$8_@0:TObject
40 + [7] Reassign mutate a$8_@0:TObject[1:12] = read b$9_@0:TObject
41 + [8] Reassign mutate b$9_@0:TObject[1:12] = read c$10_@0:TObject
42 + [9] Reassign mutate c$10_@0:TObject[1:12] = read z$13_@0
43 + [10] Call mutate mutate$6:TFunction(mutate a$8_@0:TObject, mutate b$9_@0:TObject)
44 [11] Goto(Continue) bb1
45 bb2:
46 predecessor blocks: bb1
47 - [12] read a$8_@0
48 - [13] read b$9_@0
49 - [14] read c$10_@0
50 - [15] Return freeze a$8_@0
47 + [12] read a$8_@0:TObject
48 + [13] read b$9_@0:TObject
49 + [14] read c$10_@0:TObject
50 + [15] Return freeze a$8_@0:TObject
51 scope0 [1:12]:
52 - dependency: read cond$7
53 ```
@@ -59,23 +59,23 @@ function foo(
59 cond,
60 ) {
61 scope @0 [1:12] deps=[read cond$7] {
62 - [1] Let mutate a$8_@0[1:12] = Object { }
63 - [2] Let mutate b$9_@0[1:12] = Object { }
64 - [3] Let mutate c$10_@0[1:12] = Object { }
62 + [1] Let mutate a$8_@0:TObject[1:12] = Object { }
63 + [2] Let mutate b$9_@0:TObject[1:12] = Object { }
64 + [3] Let mutate c$10_@0:TObject[1:12] = Object { }
65 while (
66 read cond$7
67 ) {
68 - [6] Const mutate z$13_@0[1:12] = read a$8_@0
69 - [7] Reassign mutate a$8_@0[1:12] = read b$9_@0
70 - [8] Reassign mutate b$9_@0[1:12] = read c$10_@0
71 - [9] Reassign mutate c$10_@0[1:12] = read z$13_@0
72 - [10] Call mutate mutate$6(mutate a$8_@0, mutate b$9_@0)
68 + [6] Const mutate z$13_@0[1:12] = read a$8_@0:TObject
69 + [7] Reassign mutate a$8_@0:TObject[1:12] = read b$9_@0:TObject
70 + [8] Reassign mutate b$9_@0:TObject[1:12] = read c$10_@0:TObject
71 + [9] Reassign mutate c$10_@0:TObject[1:12] = read z$13_@0
72 + [10] Call mutate mutate$6:TFunction(mutate a$8_@0:TObject, mutate b$9_@0:TObject)
73 }
74 }
75 - [12] read a$8_@0
76 - [13] read b$9_@0
77 - [14] read c$10_@0
78 - return freeze a$8_@0
75 + [12] read a$8_@0:TObject
76 + [13] read b$9_@0:TObject
77 + [14] read c$10_@0:TObject
78 + return freeze a$8_@0:TObject
79 }
80
81 ```
@@ -87,9 +87,9 @@ flowchart TB
87 %% Basic Blocks
88 subgraph bb0
89 bb0_instrs["
90 - [1] Let mutate a$8_@0[1:12] = Object { }
91 - [2] Let mutate b$9_@0[1:12] = Object { }
92 - [3] Let mutate c$10_@0[1:12] = Object { }
90 + [1] Let mutate a$8_@0:TObject[1:12] = Object { }
91 + [2] Let mutate b$9_@0:TObject[1:12] = Object { }
92 + [3] Let mutate c$10_@0:TObject[1:12] = Object { }
93 "]
94 bb0_instrs --> bb0_terminal(["While"])
95 end
@@ -98,21 +98,21 @@ flowchart TB
98 end
99 subgraph bb3
100 bb3_instrs["
101 - [6] Const mutate z$13_@0[1:12] = read a$8_@0
102 - [7] Reassign mutate a$8_@0[1:12] = read b$9_@0
103 - [8] Reassign mutate b$9_@0[1:12] = read c$10_@0
104 - [9] Reassign mutate c$10_@0[1:12] = read z$13_@0
105 - [10] Call mutate mutate$6(mutate a$8_@0, mutate b$9_@0)
101 + [6] Const mutate z$13_@0[1:12] = read a$8_@0:TObject
102 + [7] Reassign mutate a$8_@0:TObject[1:12] = read b$9_@0:TObject
103 + [8] Reassign mutate b$9_@0:TObject[1:12] = read c$10_@0:TObject
104 + [9] Reassign mutate c$10_@0:TObject[1:12] = read z$13_@0
105 + [10] Call mutate mutate$6:TFunction(mutate a$8_@0:TObject, mutate b$9_@0:TObject)
106 "]
107 bb3_instrs --> bb3_terminal(["Goto"])
108 end
109 subgraph bb2
110 bb2_instrs["
111 - [12] read a$8_@0
112 - [13] read b$9_@0
113 - [14] read c$10_@0
111 + [12] read a$8_@0:TObject
112 + [13] read b$9_@0:TObject
113 + [14] read c$10_@0:TObject
114 "]
115 - bb2_instrs --> bb2_terminal(["Return freeze a$8_@0"])
115 + bb2_instrs --> bb2_terminal(["Return freeze a$8_@0:TObject"])
116 end
117
118 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md
+39 -39
@@ -20,23 +20,23 @@ function g(a) {
20
21 ```
22 bb0:
23 - [1] Const mutate x$5_@0 = 1
24 - [2] Const mutate $6_@1 = 1
25 - [3] Const mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
26 - [4] Const mutate $8_@3 = 1
27 - [5] Const mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
28 - [6] Const mutate $10_@5 = 1
29 - [7] Const mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
23 + [1] Const mutate x$5_@0:TPrimitive = 1
24 + [2] Const mutate $6_@1:TPrimitive = 1
25 + [3] Const mutate x$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read $6_@1:TPrimitive
26 + [4] Const mutate $8_@3:TPrimitive = 1
27 + [5] Const mutate x$9_@4:TPrimitive = Binary read x$7_@2:TPrimitive + read $8_@3:TPrimitive
28 + [6] Const mutate $10_@5:TPrimitive = 1
29 + [7] Const mutate x$11_@6:TPrimitive = Binary read x$9_@4:TPrimitive >>> read $10_@5:TPrimitive
30 [8] Return
31 scope2 [3:4]:
32 - - dependency: read x$5_@0
33 - - dependency: read $6_@1
32 + - dependency: read x$5_@0:TPrimitive
33 + - dependency: read $6_@1:TPrimitive
34 scope4 [5:6]:
35 - - dependency: read x$7_@2
36 - - dependency: read $8_@3
35 + - dependency: read x$7_@2:TPrimitive
36 + - dependency: read $8_@3:TPrimitive
37 scope6 [7:8]:
38 - - dependency: read x$9_@4
39 - - dependency: read $10_@5
38 + - dependency: read x$9_@4:TPrimitive
39 + - dependency: read $10_@5:TPrimitive
40 ```
41
42 ## Reactive Scopes
@@ -44,13 +44,13 @@ scope6 [7:8]:
44 ```
45 function f(
46 ) {
47 - [1] Const mutate x$5_@0 = 1
48 - [2] Const mutate $6_@1 = 1
49 - [3] Const mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
50 - [4] Const mutate $8_@3 = 1
51 - [5] Const mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
52 - [6] Const mutate $10_@5 = 1
53 - [7] Const mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
47 + [1] Const mutate x$5_@0:TPrimitive = 1
48 + [2] Const mutate $6_@1:TPrimitive = 1
49 + [3] Const mutate x$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read $6_@1:TPrimitive
50 + [4] Const mutate $8_@3:TPrimitive = 1
51 + [5] Const mutate x$9_@4:TPrimitive = Binary read x$7_@2:TPrimitive + read $8_@3:TPrimitive
52 + [6] Const mutate $10_@5:TPrimitive = 1
53 + [7] Const mutate x$11_@6:TPrimitive = Binary read x$9_@4:TPrimitive >>> read $10_@5:TPrimitive
54 return
55 }
56
@@ -63,13 +63,13 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Const mutate x$5_@0 = 1
67 - [2] Const mutate $6_@1 = 1
68 - [3] Const mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
69 - [4] Const mutate $8_@3 = 1
70 - [5] Const mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
71 - [6] Const mutate $10_@5 = 1
72 - [7] Const mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
66 + [1] Const mutate x$5_@0:TPrimitive = 1
67 + [2] Const mutate $6_@1:TPrimitive = 1
68 + [3] Const mutate x$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read $6_@1:TPrimitive
69 + [4] Const mutate $8_@3:TPrimitive = 1
70 + [5] Const mutate x$9_@4:TPrimitive = Binary read x$7_@2:TPrimitive + read $8_@3:TPrimitive
71 + [6] Const mutate $10_@5:TPrimitive = 1
72 + [7] Const mutate x$11_@6:TPrimitive = Binary read x$9_@4:TPrimitive >>> read $10_@5:TPrimitive
73 "]
74 bb0_instrs --> bb0_terminal(["Return"])
75 end
@@ -93,10 +93,10 @@ function f$0() {
93
94 ```
95 bb0:
96 - [1] Const mutate $5_@0 = 1
97 - [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
98 - [3] Const mutate $6_@2 = 2
99 - [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
96 + [1] Const mutate $5_@0:TPrimitive = 1
97 + [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0:TPrimitive
98 + [3] Const mutate $6_@2:TPrimitive = 2
99 + [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2:TPrimitive
100 [5] Return
101 scope2 [3:4]:
102 - dependency: mutate a$4_@1.b.c
@@ -108,11 +108,11 @@ scope2 [3:4]:
108 function g(
109 a,
110 ) {
111 - [1] Const mutate $5_@0 = 1
111 + [1] Const mutate $5_@0:TPrimitive = 1
112 scope @1 [0:5] deps=[] {
113 - [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
114 - [3] Const mutate $6_@2 = 2
115 - [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
113 + [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0:TPrimitive
114 + [3] Const mutate $6_@2:TPrimitive = 2
115 + [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2:TPrimitive
116 }
117 return
118 }
@@ -126,10 +126,10 @@ flowchart TB
126 %% Basic Blocks
127 subgraph bb0
128 bb0_instrs["
129 - [1] Const mutate $5_@0 = 1
130 - [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
131 - [3] Const mutate $6_@2 = 2
132 - [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
129 + [1] Const mutate $5_@0:TPrimitive = 1
130 + [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0:TPrimitive
131 + [3] Const mutate $6_@2:TPrimitive = 2
132 + [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2:TPrimitive
133 "]
134 bb0_instrs --> bb0_terminal(["Return"])
135 end
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+30 -30
@@ -56,21 +56,21 @@ function foo$0() {}
56
57 ```
58 bb0:
59 - [1] Const mutate a$10_@0[1:7] = Array []
60 - [2] Const mutate b$11_@0[1:7] = Object { }
61 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
62 - [4] Const mutate $12_@1 = "div"
63 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
64 - [6] Call mutate foo$4(mutate b$11_@0)
65 - [7] Const mutate $14_@3 = "div"
66 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
59 + [1] Const mutate a$10_@0:TObject[1:7] = Array []
60 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
61 + [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
62 + [4] Const mutate $12_@1:TPrimitive = "div"
63 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0:TObject} ></read $12_@1:TPrimitive>
64 + [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
65 + [7] Const mutate $14_@3:TPrimitive = "div"
66 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
67 [9] Return read $15_@4
68 scope2 [5:6]:
69 - - dependency: read $12_@1
69 + - dependency: read $12_@1:TPrimitive
70 scope4 [8:9]:
71 - - dependency: read $14_@3
72 - - dependency: read a$10_@0
73 - - dependency: freeze b$11_@0
71 + - dependency: read $14_@3:TPrimitive
72 + - dependency: read a$10_@0:TObject
73 + - dependency: freeze b$11_@0:TObject
74 ```
75
76 ## Reactive Scopes
@@ -80,18 +80,18 @@ function Component(
80 props,
81 ) {
82 scope @0 [1:7] deps=[] {
83 - [1] Const mutate a$10_@0[1:7] = Array []
84 - [2] Const mutate b$11_@0[1:7] = Object { }
85 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
86 - [4] Const mutate $12_@1 = "div"
87 - scope @2 [5:6] deps=[read $12_@1] {
88 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
83 + [1] Const mutate a$10_@0:TObject[1:7] = Array []
84 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
85 + [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
86 + [4] Const mutate $12_@1:TPrimitive = "div"
87 + scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
88 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0:TObject} ></read $12_@1:TPrimitive>
89 }
90 - [6] Call mutate foo$4(mutate b$11_@0)
90 + [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
91 }
92 - [7] Const mutate $14_@3 = "div"
93 - scope @4 [8:9] deps=[read $14_@3, read a$10_@0, freeze b$11_@0] {
94 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
92 + [7] Const mutate $14_@3:TPrimitive = "div"
93 + scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0:TObject, freeze b$11_@0:TObject] {
94 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
95 }
96 return read $15_@4
97 }
@@ -105,14 +105,14 @@ flowchart TB
105 %% Basic Blocks
106 subgraph bb0
107 bb0_instrs["
108 - [1] Const mutate a$10_@0[1:7] = Array []
109 - [2] Const mutate b$11_@0[1:7] = Object { }
110 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
111 - [4] Const mutate $12_@1 = 'div'
112 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
113 - [6] Call mutate foo$4(mutate b$11_@0)
114 - [7] Const mutate $14_@3 = 'div'
115 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
108 + [1] Const mutate a$10_@0:TObject[1:7] = Array []
109 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
110 + [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
111 + [4] Const mutate $12_@1:TPrimitive = 'div'
112 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0:TObject} ></read $12_@1:TPrimitive>
113 + [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
114 + [7] Const mutate $14_@3:TPrimitive = 'div'
115 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
116 "]
117 bb0_instrs --> bb0_terminal(["Return read $15_@4"])
118 end
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+102 -102
@@ -35,94 +35,94 @@ function Component(props) {
35
36 ```
37 bb0:
38 - [1] Const mutate items$30_@0 = read props$29.items
39 - [2] Const mutate maxItems$31_@1 = read props$29.maxItems
40 - [3] Const mutate renderedItems$32_@2[3:33] = Array []
41 - [4] Const mutate seen$33_@2[3:33] = New mutate Set$6()
42 - [5] Const mutate $34_@4 = 0
43 - [6] Const mutate max$35_@5 = Call mutate Math$8.max(read $34_@4, read maxItems$31_@1)
38 + [1] Const mutate items$30_@0:TProp = read props$29.items
39 + [2] Const mutate maxItems$31_@1:TProp = read props$29.maxItems
40 + [3] Const mutate renderedItems$32_@2:TFunction[3:33] = Array []
41 + [4] Const mutate seen$33_@2:TFunction[3:33] = New mutate Set$6()
42 + [5] Const mutate $34_@4:TPrimitive = 0
43 + [6] Const mutate max$35_@5:TPrimitive = Call mutate Math$8.max(read $34_@4:TPrimitive, read maxItems$31_@1:TProp)
44 [7] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
45 bb3:
46 predecessor blocks: bb0
47 - [8] Let mutate i$36_@2[3:33] = 0
47 + [8] Let mutate i$36_@2:TPrimitive[3:33] = 0
48 [9] Goto bb1
49 bb1:
50 predecessor blocks: bb3 bb4
51 - [10] Const mutate $39_@2[3:33] = Binary read i$36_@2 < read items$30_@0.length
52 - [11] If (read $39_@2) then:bb5 else:bb2 fallthrough=bb2
51 + [10] Const mutate $39_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive < read items$30_@0.length
52 + [11] If (read $39_@2:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
53 bb5:
54 predecessor blocks: bb1
55 - [12] Const mutate item$40_@2[3:33] = Call read items$30_@0.at(read i$36_@2)
56 - [13] Const mutate $41_@6 = null
57 - [14] Const mutate $42_@2[3:33] = Binary read item$40_@2 == read $41_@6
58 - [15] Let mutate $43_@2[3:33] = undefined
59 - [15] If (read $42_@2) then:bb10 else:bb11 fallthrough=bb9
55 + [12] Const mutate item$40_@2:TPrimitive[3:33] = Call read items$30_@0.at(read i$36_@2:TPrimitive)
56 + [13] Const mutate $41_@6:TPrimitive = null
57 + [14] Const mutate $42_@2:TPrimitive[3:33] = Binary read item$40_@2:TPrimitive == read $41_@6:TPrimitive
58 + [15] Let mutate $43_@2:TPrimitive[3:33] = undefined
59 + [15] If (read $42_@2:TPrimitive) then:bb10 else:bb11 fallthrough=bb9
60 bb10:
61 predecessor blocks: bb5
62 - [16] Const mutate $43_@2[3:33] = read $42_@2
62 + [16] Const mutate $43_@2:TPrimitive[3:33] = read $42_@2:TPrimitive
63 [17] Goto bb9
64 bb11:
65 predecessor blocks: bb5
66 - [18] Const mutate $43_@2[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2)
66 + [18] Const mutate $43_@2:TPrimitive[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2:TPrimitive)
67 [19] Goto bb9
68 bb9:
69 predecessor blocks: bb10 bb11
70 - [20] If (read $43_@2) then:bb7 else:bb6 fallthrough=bb6
70 + [20] If (read $43_@2:TPrimitive) then:bb7 else:bb6 fallthrough=bb6
71 bb7:
72 predecessor blocks: bb9
73 [21] Goto(Continue) bb4
74 bb6:
75 predecessor blocks: bb9
76 - [22] Call mutate seen$33_@2.add(mutate item$40_@2)
77 - [23] Const mutate $49_@7 = "div"
78 - [24] Const mutate $50_@8 = JSX <read $49_@7>{freeze item$40_@2}</read $49_@7>
76 + [22] Call mutate seen$33_@2.add(mutate item$40_@2:TPrimitive)
77 + [23] Const mutate $49_@7:TPrimitive = "div"
78 + [24] Const mutate $50_@8 = JSX <read $49_@7:TPrimitive>{freeze item$40_@2:TPrimitive}</read $49_@7:TPrimitive>
79 [25] Call mutate renderedItems$32_@2.push(read $50_@8)
80 - [26] Const mutate $55_@9 = Binary read renderedItems$32_@2.length >= read max$35_@5
81 - [27] If (read $55_@9) then:bb2 else:bb12 fallthrough=bb12
80 + [26] Const mutate $55_@9:TPrimitive = Binary read renderedItems$32_@2.length >= read max$35_@5:TPrimitive
81 + [27] If (read $55_@9:TPrimitive) then:bb2 else:bb12 fallthrough=bb12
82 bb12:
83 predecessor blocks: bb6
84 [28] Goto(Continue) bb4
85 bb4:
86 predecessor blocks: bb7 bb12
87 - [29] Const mutate $56_@2[3:33] = 1
88 - [30] Reassign mutate i$36_@2[3:33] = Binary read i$36_@2 + read $56_@2
89 - [31] read i$36_@2
87 + [29] Const mutate $56_@2:TPrimitive[3:33] = 1
88 + [30] Reassign mutate i$36_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive + read $56_@2:TPrimitive
89 + [31] read i$36_@2:TPrimitive
90 [32] Goto bb1
91 bb2:
92 predecessor blocks: bb6 bb1
93 - [33] Const mutate count$66_@11 = read renderedItems$32_@2.length
94 - [34] Const mutate $67_@12 = "div"
93 + [33] Const mutate count$66_@11:TProp = read renderedItems$32_@2.length
94 + [34] Const mutate $67_@12:TPrimitive = "div"
95 [35] Const mutate $68_@13 = "\n "
96 - [36] Const mutate $69_@14 = "h1"
96 + [36] Const mutate $69_@14:TPrimitive = "h1"
97 [37] Const mutate $70_@15 = " Items"
98 - [38] Const mutate $71_@16 = JSX <read $69_@14>{freeze count$66_@11}{read $70_@15}</read $69_@14>
98 + [38] Const mutate $71_@16 = JSX <read $69_@14:TPrimitive>{freeze count$66_@11:TProp}{read $70_@15}</read $69_@14:TPrimitive>
99 [39] Const mutate $72_@17 = "\n "
100 [40] Const mutate $73_@18 = "\n "
101 - [41] Const mutate $74_@19 = JSX <read $67_@12>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2}{read $73_@18}</read $67_@12>
101 + [41] Const mutate $74_@19 = JSX <read $67_@12:TPrimitive>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2:TFunction}{read $73_@18}</read $67_@12:TPrimitive>
102 [42] Return read $74_@19
103 scope0 [1:2]:
104 - dependency: read props$29.items
105 scope1 [2:3]:
106 - dependency: read props$29.maxItems
107 scope5 [6:7]:
108 - - dependency: read $34_@4
109 - - dependency: read maxItems$31_@1
108 + - dependency: read $34_@4:TPrimitive
109 + - dependency: read maxItems$31_@1:TProp
110 scope8 [24:25]:
111 - - dependency: read $49_@7
111 + - dependency: read $49_@7:TPrimitive
112 scope9 [26:27]:
113 - - dependency: read max$35_@5
113 + - dependency: read max$35_@5:TPrimitive
114 scope11 [33:34]:
115 - dependency: read renderedItems$32_@2.length
116 scope16 [38:39]:
117 - - dependency: read $69_@14
118 - - dependency: freeze count$66_@11
117 + - dependency: read $69_@14:TPrimitive
118 + - dependency: freeze count$66_@11:TProp
119 - dependency: read $70_@15
120 scope19 [41:42]:
121 - - dependency: read $67_@12
121 + - dependency: read $67_@12:TPrimitive
122 - dependency: read $68_@13
123 - dependency: read $71_@16
124 - dependency: read $72_@17
125 - - dependency: freeze renderedItems$32_@2
125 + - dependency: freeze renderedItems$32_@2:TFunction
126 - dependency: read $73_@18
127 ```
128
@@ -132,61 +132,61 @@ scope19 [41:42]:
132 function Component(
133 props,
134 ) {
135 - [1] Const mutate items$30_@0 = read props$29.items
136 - [2] Const mutate maxItems$31_@1 = read props$29.maxItems
135 + [1] Const mutate items$30_@0:TProp = read props$29.items
136 + [2] Const mutate maxItems$31_@1:TProp = read props$29.maxItems
137 scope @2 [3:33] deps=[] {
138 - [3] Const mutate renderedItems$32_@2[3:33] = Array []
139 - [4] Const mutate seen$33_@2[3:33] = New mutate Set$6()
140 - [5] Const mutate $34_@4 = 0
141 - scope @5 [6:7] deps=[read $34_@4, read maxItems$31_@1] {
142 - [6] Const mutate max$35_@5 = Call mutate Math$8.max(read $34_@4, read maxItems$31_@1)
138 + [3] Const mutate renderedItems$32_@2:TFunction[3:33] = Array []
139 + [4] Const mutate seen$33_@2:TFunction[3:33] = New mutate Set$6()
140 + [5] Const mutate $34_@4:TPrimitive = 0
141 + scope @5 [6:7] deps=[read $34_@4:TPrimitive, read maxItems$31_@1:TProp] {
142 + [6] Const mutate max$35_@5:TPrimitive = Call mutate Math$8.max(read $34_@4:TPrimitive, read maxItems$31_@1:TProp)
143 }
144 for (
145 - [8] Let mutate i$36_@2[3:33] = 0
145 + [8] Let mutate i$36_@2:TPrimitive[3:33] = 0
146 ;
147 - [10] Const mutate $39_@2[3:33] = Binary read i$36_@2 < read items$30_@0.length
148 - read $39_@2
147 + [10] Const mutate $39_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive < read items$30_@0.length
148 + read $39_@2:TPrimitive
149 ;
150 - [29] Const mutate $56_@2[3:33] = 1
151 - [30] Reassign mutate i$36_@2[3:33] = Binary read i$36_@2 + read $56_@2
152 - read i$36_@2
150 + [29] Const mutate $56_@2:TPrimitive[3:33] = 1
151 + [30] Reassign mutate i$36_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive + read $56_@2:TPrimitive
152 + read i$36_@2:TPrimitive
153 ) {
154 - [12] Const mutate item$40_@2[3:33] = Call read items$30_@0.at(read i$36_@2)
155 - [13] Const mutate $41_@6 = null
156 - [14] Const mutate $42_@2[3:33] = Binary read item$40_@2 == read $41_@6
157 - [15] Let mutate $43_@2[3:33] = undefined
158 - if (read $42_@2) {
159 - [16] Const mutate $43_@2[3:33] = read $42_@2
154 + [12] Const mutate item$40_@2:TPrimitive[3:33] = Call read items$30_@0.at(read i$36_@2:TPrimitive)
155 + [13] Const mutate $41_@6:TPrimitive = null
156 + [14] Const mutate $42_@2:TPrimitive[3:33] = Binary read item$40_@2:TPrimitive == read $41_@6:TPrimitive
157 + [15] Let mutate $43_@2:TPrimitive[3:33] = undefined
158 + if (read $42_@2:TPrimitive) {
159 + [16] Const mutate $43_@2:TPrimitive[3:33] = read $42_@2:TPrimitive
160 } else {
161 - [18] Const mutate $43_@2[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2)
161 + [18] Const mutate $43_@2:TPrimitive[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2:TPrimitive)
162 }
163 - if (read $43_@2) {
163 + if (read $43_@2:TPrimitive) {
164 continue
165 }
166 - [22] Call mutate seen$33_@2.add(mutate item$40_@2)
167 - [23] Const mutate $49_@7 = "div"
168 - scope @8 [24:25] deps=[read $49_@7] {
169 - [24] Const mutate $50_@8 = JSX <read $49_@7>{freeze item$40_@2}</read $49_@7>
166 + [22] Call mutate seen$33_@2.add(mutate item$40_@2:TPrimitive)
167 + [23] Const mutate $49_@7:TPrimitive = "div"
168 + scope @8 [24:25] deps=[read $49_@7:TPrimitive] {
169 + [24] Const mutate $50_@8 = JSX <read $49_@7:TPrimitive>{freeze item$40_@2:TPrimitive}</read $49_@7:TPrimitive>
170 }
171 [25] Call mutate renderedItems$32_@2.push(read $50_@8)
172 - [26] Const mutate $55_@9 = Binary read renderedItems$32_@2.length >= read max$35_@5
173 - if (read $55_@9) {
172 + [26] Const mutate $55_@9:TPrimitive = Binary read renderedItems$32_@2.length >= read max$35_@5:TPrimitive
173 + if (read $55_@9:TPrimitive) {
174 break
175 }
176 }
177 }
178 - [33] Const mutate count$66_@11 = read renderedItems$32_@2.length
179 - [34] Const mutate $67_@12 = "div"
178 + [33] Const mutate count$66_@11:TProp = read renderedItems$32_@2.length
179 + [34] Const mutate $67_@12:TPrimitive = "div"
180 [35] Const mutate $68_@13 = "\n "
181 - [36] Const mutate $69_@14 = "h1"
181 + [36] Const mutate $69_@14:TPrimitive = "h1"
182 [37] Const mutate $70_@15 = " Items"
183 - scope @16 [38:39] deps=[read $69_@14, freeze count$66_@11, read $70_@15] {
184 - [38] Const mutate $71_@16 = JSX <read $69_@14>{freeze count$66_@11}{read $70_@15}</read $69_@14>
183 + scope @16 [38:39] deps=[read $69_@14:TPrimitive, freeze count$66_@11:TProp, read $70_@15] {
184 + [38] Const mutate $71_@16 = JSX <read $69_@14:TPrimitive>{freeze count$66_@11:TProp}{read $70_@15}</read $69_@14:TPrimitive>
185 }
186 [39] Const mutate $72_@17 = "\n "
187 [40] Const mutate $73_@18 = "\n "
188 - scope @19 [41:42] deps=[read $67_@12, read $68_@13, read $71_@16, read $72_@17, freeze renderedItems$32_@2, read $73_@18] {
189 - [41] Const mutate $74_@19 = JSX <read $67_@12>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2}{read $73_@18}</read $67_@12>
188 + scope @19 [41:42] deps=[read $67_@12:TPrimitive, read $68_@13, read $71_@16, read $72_@17, freeze renderedItems$32_@2:TFunction, read $73_@18] {
189 + [41] Const mutate $74_@19 = JSX <read $67_@12:TPrimitive>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2:TFunction}{read $73_@18}</read $67_@12:TPrimitive>
190 }
191 return read $74_@19
192 }
@@ -200,86 +200,86 @@ flowchart TB
200 %% Basic Blocks
201 subgraph bb0
202 bb0_instrs["
203 - [1] Const mutate items$30_@0 = read props$29.items
204 - [2] Const mutate maxItems$31_@1 = read props$29.maxItems
205 - [3] Const mutate renderedItems$32_@2[3:33] = Array []
206 - [4] Const mutate seen$33_@2[3:33] = New mutate Set$6()
207 - [5] Const mutate $34_@4 = 0
208 - [6] Const mutate max$35_@5 = Call mutate Math$8.max(read $34_@4, read maxItems$31_@1)
203 + [1] Const mutate items$30_@0:TProp = read props$29.items
204 + [2] Const mutate maxItems$31_@1:TProp = read props$29.maxItems
205 + [3] Const mutate renderedItems$32_@2:TFunction[3:33] = Array []
206 + [4] Const mutate seen$33_@2:TFunction[3:33] = New mutate Set$6()
207 + [5] Const mutate $34_@4:TPrimitive = 0
208 + [6] Const mutate max$35_@5:TPrimitive = Call mutate Math$8.max(read $34_@4:TPrimitive, read maxItems$31_@1:TProp)
209 "]
210 bb0_instrs --> bb0_terminal(["For"])
211 end
212 subgraph bb3
213 bb3_instrs["
214 - [8] Let mutate i$36_@2[3:33] = 0
214 + [8] Let mutate i$36_@2:TPrimitive[3:33] = 0
215 "]
216 bb3_instrs --> bb3_terminal(["Goto"])
217 end
218 subgraph bb1
219 bb1_instrs["
220 - [10] Const mutate $39_@2[3:33] = Binary read i$36_@2 < read items$30_@0.length
220 + [10] Const mutate $39_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive < read items$30_@0.length
221 "]
222 - bb1_instrs --> bb1_terminal(["If (read $39_@2)"])
222 + bb1_instrs --> bb1_terminal(["If (read $39_@2:TPrimitive)"])
223 end
224 subgraph bb5
225 bb5_instrs["
226 - [12] Const mutate item$40_@2[3:33] = Call read items$30_@0.at(read i$36_@2)
227 - [13] Const mutate $41_@6 = null
228 - [14] Const mutate $42_@2[3:33] = Binary read item$40_@2 == read $41_@6
229 - [15] Let mutate $43_@2[3:33] = undefined
226 + [12] Const mutate item$40_@2:TPrimitive[3:33] = Call read items$30_@0.at(read i$36_@2:TPrimitive)
227 + [13] Const mutate $41_@6:TPrimitive = null
228 + [14] Const mutate $42_@2:TPrimitive[3:33] = Binary read item$40_@2:TPrimitive == read $41_@6:TPrimitive
229 + [15] Let mutate $43_@2:TPrimitive[3:33] = undefined
230 "]
231 - bb5_instrs --> bb5_terminal(["If (read $42_@2)"])
231 + bb5_instrs --> bb5_terminal(["If (read $42_@2:TPrimitive)"])
232 end
233 subgraph bb10
234 bb10_instrs["
235 - [16] Const mutate $43_@2[3:33] = read $42_@2
235 + [16] Const mutate $43_@2:TPrimitive[3:33] = read $42_@2:TPrimitive
236 "]
237 bb10_instrs --> bb10_terminal(["Goto"])
238 end
239 subgraph bb11
240 bb11_instrs["
241 - [18] Const mutate $43_@2[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2)
241 + [18] Const mutate $43_@2:TPrimitive[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2:TPrimitive)
242 "]
243 bb11_instrs --> bb11_terminal(["Goto"])
244 end
245 subgraph bb9
246 - bb9_terminal(["If (read $43_@2)"])
246 + bb9_terminal(["If (read $43_@2:TPrimitive)"])
247 end
248 subgraph bb7
249 bb7_terminal(["Goto"])
250 end
251 subgraph bb6
252 bb6_instrs["
253 - [22] Call mutate seen$33_@2.add(mutate item$40_@2)
254 - [23] Const mutate $49_@7 = 'div'
255 - [24] Const mutate $50_@8 = JSX <read $49_@7>{freeze item$40_@2}</read $49_@7>
253 + [22] Call mutate seen$33_@2.add(mutate item$40_@2:TPrimitive)
254 + [23] Const mutate $49_@7:TPrimitive = 'div'
255 + [24] Const mutate $50_@8 = JSX <read $49_@7:TPrimitive>{freeze item$40_@2:TPrimitive}</read $49_@7:TPrimitive>
256 [25] Call mutate renderedItems$32_@2.push(read $50_@8)
257 - [26] Const mutate $55_@9 = Binary read renderedItems$32_@2.length >= read max$35_@5
257 + [26] Const mutate $55_@9:TPrimitive = Binary read renderedItems$32_@2.length >= read max$35_@5:TPrimitive
258 "]
259 - bb6_instrs --> bb6_terminal(["If (read $55_@9)"])
259 + bb6_instrs --> bb6_terminal(["If (read $55_@9:TPrimitive)"])
260 end
261 subgraph bb12
262 bb12_terminal(["Goto"])
263 end
264 subgraph bb4
265 bb4_instrs["
266 - [29] Const mutate $56_@2[3:33] = 1
267 - [30] Reassign mutate i$36_@2[3:33] = Binary read i$36_@2 + read $56_@2
268 - [31] read i$36_@2
266 + [29] Const mutate $56_@2:TPrimitive[3:33] = 1
267 + [30] Reassign mutate i$36_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive + read $56_@2:TPrimitive
268 + [31] read i$36_@2:TPrimitive
269 "]
270 bb4_instrs --> bb4_terminal(["Goto"])
271 end
272 subgraph bb2
273 bb2_instrs["
274 - [33] Const mutate count$66_@11 = read renderedItems$32_@2.length
275 - [34] Const mutate $67_@12 = 'div'
274 + [33] Const mutate count$66_@11:TProp = read renderedItems$32_@2.length
275 + [34] Const mutate $67_@12:TPrimitive = 'div'
276 [35] Const mutate $68_@13 = '\n '
277 - [36] Const mutate $69_@14 = 'h1'
277 + [36] Const mutate $69_@14:TPrimitive = 'h1'
278 [37] Const mutate $70_@15 = ' Items'
279 - [38] Const mutate $71_@16 = JSX <read $69_@14>{freeze count$66_@11}{read $70_@15}</read $69_@14>
279 + [38] Const mutate $71_@16 = JSX <read $69_@14:TPrimitive>{freeze count$66_@11:TProp}{read $70_@15}</read $69_@14:TPrimitive>
280 [39] Const mutate $72_@17 = '\n '
281 [40] Const mutate $73_@18 = '\n '
282 - [41] Const mutate $74_@19 = JSX <read $67_@12>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2}{read $73_@18}</read $67_@12>
282 + [41] Const mutate $74_@19 = JSX <read $67_@12:TPrimitive>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2:TFunction}{read $73_@18}</read $67_@12:TPrimitive>
283 "]
284 bb2_instrs --> bb2_terminal(["Return read $74_@19"])
285 end
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+45 -45
@@ -78,17 +78,17 @@ function Component(props) {
78
79 ```
80 bb0:
81 - [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
81 + [1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
82 [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
83 [3] If (read props$4.b) then:bb2 else:bb1 fallthrough=bb1
84 bb2:
85 predecessor blocks: bb0
86 - [4] Const mutate $6_@1 = null
87 - [5] Return read $6_@1
86 + [4] Const mutate $6_@1:TPrimitive = null
87 + [5] Return read $6_@1:TPrimitive
88 bb1:
89 predecessor blocks: bb0
90 [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
91 - [7] Return freeze a_DEBUG$5_@0
91 + [7] Return freeze a_DEBUG$5_@0:TFunction
92 scope0 [1:7]:
93 - dependency: read props$4.a
94 - dependency: read props$4.b
@@ -102,15 +102,15 @@ function Component(
102 props,
103 ) {
104 scope @0 [1:7] deps=[read props$4.a, read props$4.b, read props$4.d] {
105 - [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
105 + [1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
106 [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
107 if (read props$4.b) {
108 - [4] Const mutate $6_@1 = null
109 - return read $6_@1
108 + [4] Const mutate $6_@1:TPrimitive = null
109 + return read $6_@1:TPrimitive
110 }
111 [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
112 }
113 - return freeze a_DEBUG$5_@0
113 + return freeze a_DEBUG$5_@0:TFunction
114 }
115
116 ```
@@ -122,22 +122,22 @@ flowchart TB
122 %% Basic Blocks
123 subgraph bb0
124 bb0_instrs["
125 - [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
125 + [1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
126 [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
127 "]
128 bb0_instrs --> bb0_terminal(["If (read props$4.b)"])
129 end
130 subgraph bb2
131 bb2_instrs["
132 - [4] Const mutate $6_@1 = null
132 + [4] Const mutate $6_@1:TPrimitive = null
133 "]
134 - bb2_instrs --> bb2_terminal(["Return read $6_@1"])
134 + bb2_instrs --> bb2_terminal(["Return read $6_@1:TPrimitive"])
135 end
136 subgraph bb1
137 bb1_instrs["
138 [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
139 "]
140 - bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$5_@0"])
140 + bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$5_@0:TFunction"])
141 end
142
143 %% Jumps
@@ -165,7 +165,7 @@ function Component$0(props$4) {
165
166 ```
167 bb0:
168 - [1] Const mutate a$4_@0[1:7] = Array []
168 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
169 [2] Call mutate a$4_@0.push(read props$3.a)
170 [3] If (read props$3.b) then:bb2 else:bb1 fallthrough=bb1
171 bb2:
@@ -175,7 +175,7 @@ bb2:
175 bb1:
176 predecessor blocks: bb2 bb0
177 [6] Call mutate a$4_@0.push(read props$3.d)
178 - [7] Return freeze a$4_@0
178 + [7] Return freeze a$4_@0:TFunction
179 scope0 [1:7]:
180 - dependency: read props$3.a
181 - dependency: read props$3.c
@@ -190,14 +190,14 @@ function Component(
190 props,
191 ) {
192 scope @0 [1:7] deps=[read props$3.a, read props$3.c, read props$3.b, read props$3.d] {
193 - [1] Const mutate a$4_@0[1:7] = Array []
193 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
194 [2] Call mutate a$4_@0.push(read props$3.a)
195 if (read props$3.b) {
196 [4] Call mutate a$4_@0.push(read props$3.c)
197 }
198 [6] Call mutate a$4_@0.push(read props$3.d)
199 }
200 - return freeze a$4_@0
200 + return freeze a$4_@0:TFunction
201 }
202
203 ```
@@ -209,7 +209,7 @@ flowchart TB
209 %% Basic Blocks
210 subgraph bb0
211 bb0_instrs["
212 - [1] Const mutate a$4_@0[1:7] = Array []
212 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
213 [2] Call mutate a$4_@0.push(read props$3.a)
214 "]
215 bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
@@ -224,7 +224,7 @@ flowchart TB
224 bb1_instrs["
225 [6] Call mutate a$4_@0.push(read props$3.d)
226 "]
227 - bb1_instrs --> bb1_terminal(["Return freeze a$4_@0"])
227 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@0:TFunction"])
228 end
229
230 %% Jumps
@@ -253,18 +253,18 @@ function Component$0(props$3) {
253
254 ```
255 bb0:
256 - [1] Const mutate a$5_@0[1:8] = Array []
256 + [1] Const mutate a$5_@0:TFunction[1:8] = Array []
257 [2] Call mutate a$5_@0.push(read props$4.a)
258 [3] If (read props$4.b) then:bb2 else:bb1 fallthrough=bb1
259 bb2:
260 predecessor blocks: bb0
261 [4] Call mutate a$5_@0.push(read props$4.c)
262 - [5] Const mutate $6_@1 = null
263 - [6] Return read $6_@1
262 + [5] Const mutate $6_@1:TPrimitive = null
263 + [6] Return read $6_@1:TPrimitive
264 bb1:
265 predecessor blocks: bb0
266 [7] Call mutate a$5_@0.push(read props$4.d)
267 - [8] Return freeze a$5_@0
267 + [8] Return freeze a$5_@0:TFunction
268 scope0 [1:8]:
269 - dependency: read props$4.a
270 - dependency: read props$4.c
@@ -279,16 +279,16 @@ function Component(
279 props,
280 ) {
281 scope @0 [1:8] deps=[read props$4.a, read props$4.c, read props$4.b, read props$4.d] {
282 - [1] Const mutate a$5_@0[1:8] = Array []
282 + [1] Const mutate a$5_@0:TFunction[1:8] = Array []
283 [2] Call mutate a$5_@0.push(read props$4.a)
284 if (read props$4.b) {
285 [4] Call mutate a$5_@0.push(read props$4.c)
286 - [5] Const mutate $6_@1 = null
287 - return read $6_@1
286 + [5] Const mutate $6_@1:TPrimitive = null
287 + return read $6_@1:TPrimitive
288 }
289 [7] Call mutate a$5_@0.push(read props$4.d)
290 }
291 - return freeze a$5_@0
291 + return freeze a$5_@0:TFunction
292 }
293
294 ```
@@ -300,7 +300,7 @@ flowchart TB
300 %% Basic Blocks
301 subgraph bb0
302 bb0_instrs["
303 - [1] Const mutate a$5_@0[1:8] = Array []
303 + [1] Const mutate a$5_@0:TFunction[1:8] = Array []
304 [2] Call mutate a$5_@0.push(read props$4.a)
305 "]
306 bb0_instrs --> bb0_terminal(["If (read props$4.b)"])
@@ -308,15 +308,15 @@ flowchart TB
308 subgraph bb2
309 bb2_instrs["
310 [4] Call mutate a$5_@0.push(read props$4.c)
311 - [5] Const mutate $6_@1 = null
311 + [5] Const mutate $6_@1:TPrimitive = null
312 "]
313 - bb2_instrs --> bb2_terminal(["Return read $6_@1"])
313 + bb2_instrs --> bb2_terminal(["Return read $6_@1:TPrimitive"])
314 end
315 subgraph bb1
316 bb1_instrs["
317 [7] Call mutate a$5_@0.push(read props$4.d)
318 "]
319 - bb1_instrs --> bb1_terminal(["Return freeze a$5_@0"])
319 + bb1_instrs --> bb1_terminal(["Return freeze a$5_@0:TFunction"])
320 end
321
322 %% Jumps
@@ -345,17 +345,17 @@ function Component$0(props$4) {
345
346 ```
347 bb0:
348 - [1] Const mutate a$4_@0[1:7] = Array []
348 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
349 [2] Call mutate a$4_@0.push(read props$3.a)
350 [3] If (read props$3.b) then:bb2 else:bb1 fallthrough=bb1
351 bb2:
352 predecessor blocks: bb0
353 [4] Call mutate a$4_@0.push(read props$3.c)
354 - [5] Return freeze a$4_@0
354 + [5] Return freeze a$4_@0:TFunction
355 bb1:
356 predecessor blocks: bb0
357 [6] Call mutate a$4_@0.push(read props$3.d)
358 - [7] Return freeze a$4_@0
358 + [7] Return freeze a$4_@0:TFunction
359 scope0 [1:7]:
360 - dependency: read props$3.a
361 - dependency: read props$3.c
@@ -370,15 +370,15 @@ function Component(
370 props,
371 ) {
372 scope @0 [1:7] deps=[read props$3.a, read props$3.c, read props$3.b, read props$3.d] {
373 - [1] Const mutate a$4_@0[1:7] = Array []
373 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
374 [2] Call mutate a$4_@0.push(read props$3.a)
375 if (read props$3.b) {
376 [4] Call mutate a$4_@0.push(read props$3.c)
377 - return freeze a$4_@0
377 + return freeze a$4_@0:TFunction
378 }
379 [6] Call mutate a$4_@0.push(read props$3.d)
380 }
381 - return freeze a$4_@0
381 + return freeze a$4_@0:TFunction
382 }
383
384 ```
@@ -390,7 +390,7 @@ flowchart TB
390 %% Basic Blocks
391 subgraph bb0
392 bb0_instrs["
393 - [1] Const mutate a$4_@0[1:7] = Array []
393 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
394 [2] Call mutate a$4_@0.push(read props$3.a)
395 "]
396 bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
@@ -399,13 +399,13 @@ flowchart TB
399 bb2_instrs["
400 [4] Call mutate a$4_@0.push(read props$3.c)
401 "]
402 - bb2_instrs --> bb2_terminal(["Return freeze a$4_@0"])
402 + bb2_instrs --> bb2_terminal(["Return freeze a$4_@0:TFunction"])
403 end
404 subgraph bb1
405 bb1_instrs["
406 [6] Call mutate a$4_@0.push(read props$3.d)
407 "]
408 - bb1_instrs --> bb1_terminal(["Return freeze a$4_@0"])
408 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@0:TFunction"])
409 end
410
411 %% Jumps
@@ -434,7 +434,7 @@ function Component$0(props$3) {
434
435 ```
436 bb0:
437 - [1] Const mutate a$4_@0[1:7] = Array []
437 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
438 [2] Call mutate a$4_@0.push(read props$3.a)
439 [3] If (read props$3.b) then:bb1 else:bb2 fallthrough=bb2
440 bb2:
@@ -444,7 +444,7 @@ bb2:
444 bb1:
445 predecessor blocks: bb0 bb2
446 [6] Call mutate a$4_@0.push(read props$3.d)
447 - [7] Return freeze a$4_@0
447 + [7] Return freeze a$4_@0:TFunction
448 scope0 [1:7]:
449 - dependency: read props$3.a
450 - dependency: read props$3.d
@@ -458,11 +458,11 @@ function Component(
458 props,
459 ) {
460 scope @0 [1:7] deps=[read props$3.a, read props$3.d, read props$3.c] {
461 - [1] Const mutate a$4_@0[1:7] = Array []
461 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
462 [2] Call mutate a$4_@0.push(read props$3.a)
463 if (read props$3.b) {
464 [6] Call mutate a$4_@0.push(read props$3.d)
465 - return freeze a$4_@0
465 + return freeze a$4_@0:TFunction
466 }
467 [4] Call mutate a$4_@0.push(read props$3.c)
468 }
@@ -477,7 +477,7 @@ flowchart TB
477 %% Basic Blocks
478 subgraph bb0
479 bb0_instrs["
480 - [1] Const mutate a$4_@0[1:7] = Array []
480 + [1] Const mutate a$4_@0:TFunction[1:7] = Array []
481 [2] Call mutate a$4_@0.push(read props$3.a)
482 "]
483 bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
@@ -492,7 +492,7 @@ flowchart TB
492 bb1_instrs["
493 [6] Call mutate a$4_@0.push(read props$3.d)
494 "]
495 - bb1_instrs --> bb1_terminal(["Return freeze a$4_@0"])
495 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@0:TFunction"])
496 end
497
498 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+30 -30
@@ -35,9 +35,9 @@ function mayMutate() {}
35
36 ```
37 bb0:
38 - [1] Const mutate a$7_@0[1:9] = Array []
39 - [2] Const mutate b$8_@0[1:9] = Array []
40 - [3] If (read b$8_@0) then:bb2 else:bb1 fallthrough=bb1
38 + [1] Const mutate a$7_@0:TFunction[1:9] = Array []
39 + [2] Const mutate b$8_@0:TFunction[1:9] = Array []
40 + [3] If (read b$8_@0:TFunction) then:bb2 else:bb1 fallthrough=bb1
41 bb2:
42 predecessor blocks: bb0
43 [4] Call mutate a$7_@0.push(read props$6.p0)
@@ -51,11 +51,11 @@ bb4:
51 [8] Goto bb3
52 bb3:
53 predecessor blocks: bb4 bb1
54 - [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@0} ></read Foo$4>
54 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0:TFunction} b={freeze b$8_@0:TFunction} ></read Foo$4>
55 [10] Return read $16_@2
56 scope2 [9:10]:
57 - - dependency: freeze a$7_@0
58 - - dependency: freeze b$8_@0
57 + - dependency: freeze a$7_@0:TFunction
58 + - dependency: freeze b$8_@0:TFunction
59 ```
60
61 ## Reactive Scopes
@@ -65,17 +65,17 @@ function Component(
65 props,
66 ) {
67 scope @0 [1:9] deps=[] {
68 - [1] Const mutate a$7_@0[1:9] = Array []
69 - [2] Const mutate b$8_@0[1:9] = Array []
70 - if (read b$8_@0) {
68 + [1] Const mutate a$7_@0:TFunction[1:9] = Array []
69 + [2] Const mutate b$8_@0:TFunction[1:9] = Array []
70 + if (read b$8_@0:TFunction) {
71 [4] Call mutate a$7_@0.push(read props$6.p0)
72 }
73 if (read props$6.p1) {
74 [7] Call mutate b$8_@0.push(read props$6.p2)
75 }
76 }
77 - scope @2 [9:10] deps=[freeze a$7_@0, freeze b$8_@0] {
78 - [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@0} ></read Foo$4>
77 + scope @2 [9:10] deps=[freeze a$7_@0:TFunction, freeze b$8_@0:TFunction] {
78 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0:TFunction} b={freeze b$8_@0:TFunction} ></read Foo$4>
79 }
80 return read $16_@2
81 }
@@ -89,10 +89,10 @@ flowchart TB
89 %% Basic Blocks
90 subgraph bb0
91 bb0_instrs["
92 - [1] Const mutate a$7_@0[1:9] = Array []
93 - [2] Const mutate b$8_@0[1:9] = Array []
92 + [1] Const mutate a$7_@0:TFunction[1:9] = Array []
93 + [2] Const mutate b$8_@0:TFunction[1:9] = Array []
94 "]
95 - bb0_instrs --> bb0_terminal(["If (read b$8_@0)"])
95 + bb0_instrs --> bb0_terminal(["If (read b$8_@0:TFunction)"])
96 end
97 subgraph bb2
98 bb2_instrs["
@@ -111,7 +111,7 @@ flowchart TB
111 end
112 subgraph bb3
113 bb3_instrs["
114 - [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@0} ></read Foo$4>
114 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0:TFunction} b={freeze b$8_@0:TFunction} ></read Foo$4>
115 "]
116 bb3_instrs --> bb3_terminal(["Return read $16_@2"])
117 end
@@ -148,9 +148,9 @@ function Component$0(props$6) {
148
149 ```
150 bb0:
151 - [1] Const mutate a$9_@0[1:10] = Array []
152 - [2] Const mutate b$10_@0[1:10] = Array []
153 - [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4(mutate b$10_@0)
151 + [1] Const mutate a$9_@0:TFunction[1:10] = Array []
152 + [2] Const mutate b$10_@0:TFunction[1:10] = Array []
153 + [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction)
154 [4] If (read $11_@0) then:bb2 else:bb1 fallthrough=bb1
155 bb2:
156 predecessor blocks: bb0
@@ -165,11 +165,11 @@ bb4:
165 [9] Goto bb3
166 bb3:
167 predecessor blocks: bb4 bb1
168 - [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
168 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0:TFunction} b={freeze b$10_@0:TFunction} ></read Foo$6>
169 [11] Return read $19_@2
170 scope2 [10:11]:
171 - - dependency: freeze a$9_@0
172 - - dependency: freeze b$10_@0
171 + - dependency: freeze a$9_@0:TFunction
172 + - dependency: freeze b$10_@0:TFunction
173 ```
174
175 ## Reactive Scopes
@@ -179,9 +179,9 @@ function Component(
179 props,
180 ) {
181 scope @0 [1:10] deps=[] {
182 - [1] Const mutate a$9_@0[1:10] = Array []
183 - [2] Const mutate b$10_@0[1:10] = Array []
184 - [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4(mutate b$10_@0)
182 + [1] Const mutate a$9_@0:TFunction[1:10] = Array []
183 + [2] Const mutate b$10_@0:TFunction[1:10] = Array []
184 + [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction)
185 if (read $11_@0) {
186 [5] Call mutate a$9_@0.push(read props$8.p0)
187 }
@@ -189,8 +189,8 @@ function Component(
189 [8] Call mutate b$10_@0.push(read props$8.p2)
190 }
191 }
192 - scope @2 [10:11] deps=[freeze a$9_@0, freeze b$10_@0] {
193 - [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
192 + scope @2 [10:11] deps=[freeze a$9_@0:TFunction, freeze b$10_@0:TFunction] {
193 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0:TFunction} b={freeze b$10_@0:TFunction} ></read Foo$6>
194 }
195 return read $19_@2
196 }
@@ -204,9 +204,9 @@ flowchart TB
204 %% Basic Blocks
205 subgraph bb0
206 bb0_instrs["
207 - [1] Const mutate a$9_@0[1:10] = Array []
208 - [2] Const mutate b$10_@0[1:10] = Array []
209 - [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4(mutate b$10_@0)
207 + [1] Const mutate a$9_@0:TFunction[1:10] = Array []
208 + [2] Const mutate b$10_@0:TFunction[1:10] = Array []
209 + [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction)
210 "]
211 bb0_instrs --> bb0_terminal(["If (read $11_@0)"])
212 end
@@ -227,7 +227,7 @@ flowchart TB
227 end
228 subgraph bb3
229 bb3_instrs["
230 - [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
230 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0:TFunction} b={freeze b$10_@0:TFunction} ></read Foo$6>
231 "]
232 bb3_instrs --> bb3_terminal(["Return read $19_@2"])
233 end
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+26 -26
@@ -57,20 +57,20 @@ function Foo$0() {}
57 ```
58 bb0:
59 [1] Const mutate a$10_@0[1:7] = Array []
60 - [2] Const mutate b$11_@0[1:7] = Object { }
61 - [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0)
62 - [4] Const mutate $12_@1 = "div"
63 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
64 - [6] New mutate Foo$4(mutate b$11_@0)
65 - [7] Const mutate $14_@3 = "div"
66 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
60 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
61 + [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject)
62 + [4] Const mutate $12_@1:TPrimitive = "div"
63 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
64 + [6] New mutate Foo$4(mutate b$11_@0:TObject)
65 + [7] Const mutate $14_@3:TPrimitive = "div"
66 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
67 [9] Return read $15_@4
68 scope2 [5:6]:
69 - - dependency: read $12_@1
69 + - dependency: read $12_@1:TPrimitive
70 scope4 [8:9]:
71 - - dependency: read $14_@3
71 + - dependency: read $14_@3:TPrimitive
72 - dependency: read a$10_@0
73 - - dependency: freeze b$11_@0
73 + - dependency: freeze b$11_@0:TObject
74 ```
75
76 ## Reactive Scopes
@@ -81,17 +81,17 @@ function Component(
81 ) {
82 scope @0 [1:7] deps=[] {
83 [1] Const mutate a$10_@0[1:7] = Array []
84 - [2] Const mutate b$11_@0[1:7] = Object { }
85 - [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0)
86 - [4] Const mutate $12_@1 = "div"
87 - scope @2 [5:6] deps=[read $12_@1] {
88 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
84 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
85 + [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject)
86 + [4] Const mutate $12_@1:TPrimitive = "div"
87 + scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
88 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
89 }
90 - [6] New mutate Foo$4(mutate b$11_@0)
90 + [6] New mutate Foo$4(mutate b$11_@0:TObject)
91 }
92 - [7] Const mutate $14_@3 = "div"
93 - scope @4 [8:9] deps=[read $14_@3, read a$10_@0, freeze b$11_@0] {
94 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
92 + [7] Const mutate $14_@3:TPrimitive = "div"
93 + scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
94 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
95 }
96 return read $15_@4
97 }
@@ -106,13 +106,13 @@ flowchart TB
106 subgraph bb0
107 bb0_instrs["
108 [1] Const mutate a$10_@0[1:7] = Array []
109 - [2] Const mutate b$11_@0[1:7] = Object { }
110 - [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0)
111 - [4] Const mutate $12_@1 = 'div'
112 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
113 - [6] New mutate Foo$4(mutate b$11_@0)
114 - [7] Const mutate $14_@3 = 'div'
115 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
109 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
110 + [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject)
111 + [4] Const mutate $12_@1:TPrimitive = 'div'
112 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
113 + [6] New mutate Foo$4(mutate b$11_@0:TObject)
114 + [7] Const mutate $14_@3:TPrimitive = 'div'
115 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
116 "]
117 bb0_instrs --> bb0_terminal(["Return read $15_@4"])
118 end
compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md
+26 -26
@@ -22,22 +22,22 @@ function foo(a, b) {
22
23 ```
24 bb0:
25 - [1] Const mutate x$8_@0[1:3] = Array []
25 + [1] Const mutate x$8_@0:TFunction[1:3] = Array []
26 [2] Call mutate x$8_@0.push(read a$6)
27 - [3] Const mutate $9_@1 = "div"
28 - [4] JSX <read $9_@1>{freeze x$8_@0}</read $9_@1>
29 - [5] Const mutate y$10_@2[5:12] = Array []
27 + [3] Const mutate $9_@1:TPrimitive = "div"
28 + [4] JSX <read $9_@1:TPrimitive>{freeze x$8_@0:TFunction}</read $9_@1:TPrimitive>
29 + [5] Const mutate y$10_@2:TFunction[5:12] = Array []
30 [6] If (read x$8_@0.length) then:bb2 else:bb1 fallthrough=bb1
31 bb2:
32 predecessor blocks: bb0
33 - [7] Call mutate y$10_@2.push(read x$8_@0)
33 + [7] Call mutate y$10_@2.push(read x$8_@0:TFunction)
34 [8] Goto bb1
35 bb1:
36 predecessor blocks: bb2 bb0
37 - [9] If (read b$7) then:bb4 else:bb3 fallthrough=bb3
37 + [9] If (read b$7:TFunction) then:bb4 else:bb3 fallthrough=bb3
38 bb4:
39 predecessor blocks: bb1
40 - [10] Call mutate y$10_@2.push(read b$7)
40 + [10] Call mutate y$10_@2.push(read b$7:TFunction)
41 [11] Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
@@ -45,12 +45,12 @@ bb3:
45 scope0 [1:3]:
46 - dependency: read a$6
47 scope1 [3:4]:
48 - - dependency: freeze x$8_@0
48 + - dependency: freeze x$8_@0:TFunction
49 scope2 [5:12]:
50 - - dependency: read x$8_@0
50 + - dependency: read x$8_@0:TFunction
51 - dependency: read x$8_@0.length
52 - - dependency: read b$7
53 - - dependency: read b$7
52 + - dependency: read b$7:TFunction
53 + - dependency: read b$7:TFunction
54 ```
55
56 ## Reactive Scopes
@@ -61,18 +61,18 @@ function foo(
61 b,
62 ) {
63 scope @0 [1:3] deps=[read a$6] {
64 - [1] Const mutate x$8_@0[1:3] = Array []
64 + [1] Const mutate x$8_@0:TFunction[1:3] = Array []
65 [2] Call mutate x$8_@0.push(read a$6)
66 }
67 - [3] Const mutate $9_@1 = "div"
68 - [4] JSX <read $9_@1>{freeze x$8_@0}</read $9_@1>
69 - scope @2 [5:12] deps=[read x$8_@0, read x$8_@0.length, read b$7, read b$7] {
70 - [5] Const mutate y$10_@2[5:12] = Array []
67 + [3] Const mutate $9_@1:TPrimitive = "div"
68 + [4] JSX <read $9_@1:TPrimitive>{freeze x$8_@0:TFunction}</read $9_@1:TPrimitive>
69 + scope @2 [5:12] deps=[read x$8_@0:TFunction, read x$8_@0.length, read b$7:TFunction, read b$7:TFunction] {
70 + [5] Const mutate y$10_@2:TFunction[5:12] = Array []
71 if (read x$8_@0.length) {
72 - [7] Call mutate y$10_@2.push(read x$8_@0)
72 + [7] Call mutate y$10_@2.push(read x$8_@0:TFunction)
73 }
74 - if (read b$7) {
75 - [10] Call mutate y$10_@2.push(read b$7)
74 + if (read b$7:TFunction) {
75 + [10] Call mutate y$10_@2.push(read b$7:TFunction)
76 }
77 }
78 return
@@ -87,26 +87,26 @@ flowchart TB
87 %% Basic Blocks
88 subgraph bb0
89 bb0_instrs["
90 - [1] Const mutate x$8_@0[1:3] = Array []
90 + [1] Const mutate x$8_@0:TFunction[1:3] = Array []
91 [2] Call mutate x$8_@0.push(read a$6)
92 - [3] Const mutate $9_@1 = 'div'
93 - [4] JSX <read $9_@1>{freeze x$8_@0}</read $9_@1>
94 - [5] Const mutate y$10_@2[5:12] = Array []
92 + [3] Const mutate $9_@1:TPrimitive = 'div'
93 + [4] JSX <read $9_@1:TPrimitive>{freeze x$8_@0:TFunction}</read $9_@1:TPrimitive>
94 + [5] Const mutate y$10_@2:TFunction[5:12] = Array []
95 "]
96 bb0_instrs --> bb0_terminal(["If (read x$8_@0.length)"])
97 end
98 subgraph bb2
99 bb2_instrs["
100 - [7] Call mutate y$10_@2.push(read x$8_@0)
100 + [7] Call mutate y$10_@2.push(read x$8_@0:TFunction)
101 "]
102 bb2_instrs --> bb2_terminal(["Goto"])
103 end
104 subgraph bb1
105 - bb1_terminal(["If (read b$7)"])
105 + bb1_terminal(["If (read b$7:TFunction)"])
106 end
107 subgraph bb4
108 bb4_instrs["
109 - [10] Call mutate y$10_@2.push(read b$7)
109 + [10] Call mutate y$10_@2.push(read b$7:TFunction)
110 "]
111 bb4_instrs --> bb4_terminal(["Goto"])
112 end
compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md
+9 -9
@@ -24,9 +24,9 @@ function foo(x, y, z) {
24
25 ```
26 bb0:
27 - [1] Const mutate items$9_@0[1:10] = Array [read z$8]
27 + [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8]
28 [2] Call mutate items$9_@0.push(read x$6)
29 - [3] Const mutate items2$10_@1[3:7] = Array []
29 + [3] Const mutate items2$10_@1:TFunction[3:7] = Array []
30 [4] If (read x$6) then:bb2 else:bb1 fallthrough=bb1
31 bb2:
32 predecessor blocks: bb0
@@ -41,7 +41,7 @@ bb4:
41 [9] Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
44 - [10] Return freeze items2$10_@1
44 + [10] Return freeze items2$10_@1:TFunction
45 scope0 [1:10]:
46 - dependency: read z$8
47 - dependency: read x$6
@@ -61,10 +61,10 @@ function foo(
61 z,
62 ) {
63 scope @0 [1:10] deps=[read z$8, read x$6, read x$6, read y$7] {
64 - [1] Const mutate items$9_@0[1:10] = Array [read z$8]
64 + [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8]
65 [2] Call mutate items$9_@0.push(read x$6)
66 scope @1 [3:7] deps=[read y$7, read x$6] {
67 - [3] Const mutate items2$10_@1[3:7] = Array []
67 + [3] Const mutate items2$10_@1:TFunction[3:7] = Array []
68 if (read x$6) {
69 [5] Call mutate items2$10_@1.push(read y$7)
70 }
@@ -73,7 +73,7 @@ function foo(
73 [8] Call mutate items$9_@0.push(read x$6)
74 }
75 }
76 - return freeze items2$10_@1
76 + return freeze items2$10_@1:TFunction
77 }
78
79 ```
@@ -85,9 +85,9 @@ flowchart TB
85 %% Basic Blocks
86 subgraph bb0
87 bb0_instrs["
88 - [1] Const mutate items$9_@0[1:10] = Array [read z$8]
88 + [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8]
89 [2] Call mutate items$9_@0.push(read x$6)
90 - [3] Const mutate items2$10_@1[3:7] = Array []
90 + [3] Const mutate items2$10_@1:TFunction[3:7] = Array []
91 "]
92 bb0_instrs --> bb0_terminal(["If (read x$6)"])
93 end
@@ -107,7 +107,7 @@ flowchart TB
107 bb4_instrs --> bb4_terminal(["Goto"])
108 end
109 subgraph bb3
110 - bb3_terminal(["Return freeze items2$10_@1"])
110 + bb3_terminal(["Return freeze items2$10_@1:TFunction"])
111 end
112
113 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md
+15 -15
@@ -23,7 +23,7 @@ function foo(a, b, c) {
23
24 ```
25 bb0:
26 - [1] Const mutate x$10_@0[1:8] = Array []
26 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
27 [2] If (read a$7) then:bb2 else:bb1 fallthrough=bb1
28 bb2:
29 predecessor blocks: bb0
@@ -33,8 +33,8 @@ bb4:
33 [4] If (read c$9) then:bb6 else:bb1 fallthrough=bb1
34 bb6:
35 predecessor blocks: bb4
36 - [5] Const mutate $11_@1 = 0
37 - [6] Call mutate x$10_@0.push(read $11_@1)
36 + [5] Const mutate $11_@1:TPrimitive = 0
37 + [6] Call mutate x$10_@0.push(read $11_@1:TPrimitive)
38 [7] Goto bb1
39 bb1:
40 predecessor blocks: bb6 bb4 bb2 bb0
@@ -44,8 +44,8 @@ bb8:
44 [9] Return read a$7
45 bb7:
46 predecessor blocks: bb1
47 - [10] Const mutate $13_@2 = null
48 - [11] Return read $13_@2
47 + [10] Const mutate $13_@2:TPrimitive = null
48 + [11] Return read $13_@2:TPrimitive
49 scope0 [1:8]:
50 - dependency: read c$9
51 - dependency: read b$8
@@ -61,12 +61,12 @@ function foo(
61 c,
62 ) {
63 scope @0 [1:8] deps=[read c$9, read b$8, read a$7] {
64 - [1] Const mutate x$10_@0[1:8] = Array []
64 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
65 if (read a$7) {
66 if (read b$8) {
67 if (read c$9) {
68 - [5] Const mutate $11_@1 = 0
69 - [6] Call mutate x$10_@0.push(read $11_@1)
68 + [5] Const mutate $11_@1:TPrimitive = 0
69 + [6] Call mutate x$10_@0.push(read $11_@1:TPrimitive)
70 }
71 }
72 }
@@ -74,8 +74,8 @@ function foo(
74 if (read a$7.length) {
75 return read a$7
76 }
77 - [10] Const mutate $13_@2 = null
78 - return read $13_@2
77 + [10] Const mutate $13_@2:TPrimitive = null
78 + return read $13_@2:TPrimitive
79 }
80
81 ```
@@ -87,7 +87,7 @@ flowchart TB
87 %% Basic Blocks
88 subgraph bb0
89 bb0_instrs["
90 - [1] Const mutate x$10_@0[1:8] = Array []
90 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
91 "]
92 bb0_instrs --> bb0_terminal(["If (read a$7)"])
93 end
@@ -99,8 +99,8 @@ flowchart TB
99 end
100 subgraph bb6
101 bb6_instrs["
102 - [5] Const mutate $11_@1 = 0
103 - [6] Call mutate x$10_@0.push(read $11_@1)
102 + [5] Const mutate $11_@1:TPrimitive = 0
103 + [6] Call mutate x$10_@0.push(read $11_@1:TPrimitive)
104 "]
105 bb6_instrs --> bb6_terminal(["Goto"])
106 end
@@ -112,9 +112,9 @@ flowchart TB
112 end
113 subgraph bb7
114 bb7_instrs["
115 - [10] Const mutate $13_@2 = null
115 + [10] Const mutate $13_@2:TPrimitive = null
116 "]
117 - bb7_instrs --> bb7_terminal(["Return read $13_@2"])
117 + bb7_instrs --> bb7_terminal(["Return read $13_@2:TPrimitive"])
118 end
119
120 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md
+6 -6
@@ -20,8 +20,8 @@ function foo(x) {}
20 bb0:
21 [1] Const mutate a$5_@0 = Array []
22 [2] Const mutate b$6_@1 = read a$5_@0
23 - [3] Call read useFreeze$3(freeze a$5_@0)
24 - [4] Call mutate foo$4(read b$6_@1)
23 + [3] Call read useFreeze$3:TFunction(freeze a$5_@0)
24 + [4] Call mutate foo$4:TFunction(read b$6_@1)
25 [5] Return
26 scope1 [2:3]:
27 - dependency: read a$5_@0
@@ -37,8 +37,8 @@ function Component(
37 [1] Const mutate a$5_@0 = Array []
38 }
39 [2] Const mutate b$6_@1 = read a$5_@0
40 - [3] Call read useFreeze$3(freeze a$5_@0)
41 - [4] Call mutate foo$4(read b$6_@1)
40 + [3] Call read useFreeze$3:TFunction(freeze a$5_@0)
41 + [4] Call mutate foo$4:TFunction(read b$6_@1)
42 return
43 }
44
@@ -53,8 +53,8 @@ flowchart TB
53 bb0_instrs["
54 [1] Const mutate a$5_@0 = Array []
55 [2] Const mutate b$6_@1 = read a$5_@0
56 - [3] Call read useFreeze$3(freeze a$5_@0)
57 - [4] Call mutate foo$4(read b$6_@1)
56 + [3] Call read useFreeze$3:TFunction(freeze a$5_@0)
57 + [4] Call mutate foo$4:TFunction(read b$6_@1)
58 "]
59 bb0_instrs --> bb0_terminal(["Return"])
60 end
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+6 -6
@@ -98,8 +98,8 @@ function foo$0() {}
98 ```
99 bb0:
100 [1] Const mutate x$11_@0 = Array []
101 - [2] Const mutate y$12_@1 = Call read useFreeze$4(freeze x$11_@0)
102 - [3] Call mutate foo$5(read y$12_@1, read x$11_@0)
101 + [2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
102 + [3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
103 [4] Const mutate $13_@2 = "\n "
104 [5] Const mutate $14_@3 = "\n "
105 [6] Const mutate $15_@4 = "\n "
@@ -127,9 +127,9 @@ function Component(
127 [1] Const mutate x$11_@0 = Array []
128 }
129 scope @1 [2:3] deps=[freeze x$11_@0, read x$11_@0] {
130 - [2] Const mutate y$12_@1 = Call read useFreeze$4(freeze x$11_@0)
130 + [2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
131 }
132 - [3] Call mutate foo$5(read y$12_@1, read x$11_@0)
132 + [3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
133 [4] Const mutate $13_@2 = "\n "
134 [5] Const mutate $14_@3 = "\n "
135 [6] Const mutate $15_@4 = "\n "
@@ -149,8 +149,8 @@ flowchart TB
149 subgraph bb0
150 bb0_instrs["
151 [1] Const mutate x$11_@0 = Array []
152 - [2] Const mutate y$12_@1 = Call read useFreeze$4(freeze x$11_@0)
153 - [3] Call mutate foo$5(read y$12_@1, read x$11_@0)
152 + [2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
153 + [3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
154 [4] Const mutate $13_@2 = '\n '
155 [5] Const mutate $14_@3 = '\n '
156 [6] Const mutate $15_@4 = '\n '
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md
+9 -9
@@ -20,9 +20,9 @@ function call(x) {}
20 ```
21 bb0:
22 [1] Const mutate a$4_@0 = Array []
23 - [2] Call read useFreeze$2(freeze a$4_@0)
24 - [3] Call read useFreeze$2(read a$4_@0)
25 - [4] Call mutate call$3(read a$4_@0)
23 + [2] Call read useFreeze$2:TFunction(freeze a$4_@0)
24 + [3] Call read useFreeze$2:TFunction(read a$4_@0)
25 + [4] Call mutate call$3:TFunction(read a$4_@0)
26 [5] Return read a$4_@0
27
28 ```
@@ -35,9 +35,9 @@ function Component(
35 scope @0 [1:2] deps=[] {
36 [1] Const mutate a$4_@0 = Array []
37 }
38 - [2] Call read useFreeze$2(freeze a$4_@0)
39 - [3] Call read useFreeze$2(read a$4_@0)
40 - [4] Call mutate call$3(read a$4_@0)
38 + [2] Call read useFreeze$2:TFunction(freeze a$4_@0)
39 + [3] Call read useFreeze$2:TFunction(read a$4_@0)
40 + [4] Call mutate call$3:TFunction(read a$4_@0)
41 return read a$4_@0
42 }
43
@@ -51,9 +51,9 @@ flowchart TB
51 subgraph bb0
52 bb0_instrs["
53 [1] Const mutate a$4_@0 = Array []
54 - [2] Call read useFreeze$2(freeze a$4_@0)
55 - [3] Call read useFreeze$2(read a$4_@0)
56 - [4] Call mutate call$3(read a$4_@0)
54 + [2] Call read useFreeze$2:TFunction(freeze a$4_@0)
55 + [3] Call read useFreeze$2:TFunction(read a$4_@0)
56 + [4] Call mutate call$3:TFunction(read a$4_@0)
57 "]
58 bb0_instrs --> bb0_terminal(["Return read a$4_@0"])
59 end
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+36 -36
@@ -26,32 +26,32 @@ function call(x) {}
26
27 ```
28 bb0:
29 - [1] Const mutate cond$8_@0 = read props$7.cond
30 - [2] Const mutate x$9_@1 = read props$7.x
31 - [3] Const mutate a$10_@2 = undefined
32 - [4] Let mutate a$11_@3[4:9] = undefined
33 - [4] If (read cond$8_@0) then:bb2 else:bb3 fallthrough=bb1
29 + [1] Const mutate cond$8_@0:TProp = read props$7.cond
30 + [2] Const mutate x$9_@1:TProp = read props$7.x
31 + [3] Const mutate a$10_@2:TPrimitive = undefined
32 + [4] Let mutate a$11_@3:TProp[4:9] = undefined
33 + [4] If (read cond$8_@0:TProp) then:bb2 else:bb3 fallthrough=bb1
34 bb2:
35 predecessor blocks: bb0
36 - [5] Reassign mutate a$11_@3[4:9] = read x$9_@1
36 + [5] Reassign mutate a$11_@3:TProp[4:9] = read x$9_@1:TProp
37 [6] Goto bb1
38 bb3:
39 predecessor blocks: bb0
40 - [7] Reassign mutate a$11_@3[4:9] = Array []
40 + [7] Reassign mutate a$11_@3:TProp[4:9] = Array []
41 [8] Goto bb1
42 bb1:
43 predecessor blocks: bb2 bb3
44 - [9] Call read useFreeze$5(freeze a$11_@3)
45 - [10] Call read useFreeze$5(read a$11_@3)
46 - [11] Call mutate call$6(read a$11_@3)
47 - [12] Return read a$11_@3
44 + [9] Call read useFreeze$5:TFunction(freeze a$11_@3:TProp)
45 + [10] Call read useFreeze$5:TFunction(read a$11_@3:TProp)
46 + [11] Call mutate call$6:TFunction(read a$11_@3:TProp)
47 + [12] Return read a$11_@3:TProp
48 scope0 [1:2]:
49 - dependency: read props$7.cond
50 scope1 [2:3]:
51 - dependency: read props$7.x
52 scope3 [4:9]:
53 - - dependency: read x$9_@1
54 - - dependency: read cond$8_@0
53 + - dependency: read x$9_@1:TProp
54 + - dependency: read cond$8_@0:TProp
55 ```
56
57 ## Reactive Scopes
@@ -60,21 +60,21 @@ scope3 [4:9]:
60 function Component(
61 props,
62 ) {
63 - [1] Const mutate cond$8_@0 = read props$7.cond
64 - [2] Const mutate x$9_@1 = read props$7.x
65 - [3] Const mutate a$10_@2 = undefined
66 - scope @3 [4:9] deps=[read x$9_@1, read cond$8_@0] {
67 - [4] Let mutate a$11_@3[4:9] = undefined
68 - if (read cond$8_@0) {
69 - [5] Reassign mutate a$11_@3[4:9] = read x$9_@1
63 + [1] Const mutate cond$8_@0:TProp = read props$7.cond
64 + [2] Const mutate x$9_@1:TProp = read props$7.x
65 + [3] Const mutate a$10_@2:TPrimitive = undefined
66 + scope @3 [4:9] deps=[read x$9_@1:TProp, read cond$8_@0:TProp] {
67 + [4] Let mutate a$11_@3:TProp[4:9] = undefined
68 + if (read cond$8_@0:TProp) {
69 + [5] Reassign mutate a$11_@3:TProp[4:9] = read x$9_@1:TProp
70 } else {
71 - [7] Reassign mutate a$11_@3[4:9] = Array []
71 + [7] Reassign mutate a$11_@3:TProp[4:9] = Array []
72 }
73 }
74 - [9] Call read useFreeze$5(freeze a$11_@3)
75 - [10] Call read useFreeze$5(read a$11_@3)
76 - [11] Call mutate call$6(read a$11_@3)
77 - return read a$11_@3
74 + [9] Call read useFreeze$5:TFunction(freeze a$11_@3:TProp)
75 + [10] Call read useFreeze$5:TFunction(read a$11_@3:TProp)
76 + [11] Call mutate call$6:TFunction(read a$11_@3:TProp)
77 + return read a$11_@3:TProp
78 }
79
80 ```
@@ -86,32 +86,32 @@ flowchart TB
86 %% Basic Blocks
87 subgraph bb0
88 bb0_instrs["
89 - [1] Const mutate cond$8_@0 = read props$7.cond
90 - [2] Const mutate x$9_@1 = read props$7.x
91 - [3] Const mutate a$10_@2 = undefined
92 - [4] Let mutate a$11_@3[4:9] = undefined
89 + [1] Const mutate cond$8_@0:TProp = read props$7.cond
90 + [2] Const mutate x$9_@1:TProp = read props$7.x
91 + [3] Const mutate a$10_@2:TPrimitive = undefined
92 + [4] Let mutate a$11_@3:TProp[4:9] = undefined
93 "]
94 - bb0_instrs --> bb0_terminal(["If (read cond$8_@0)"])
94 + bb0_instrs --> bb0_terminal(["If (read cond$8_@0:TProp)"])
95 end
96 subgraph bb2
97 bb2_instrs["
98 - [5] Reassign mutate a$11_@3[4:9] = read x$9_@1
98 + [5] Reassign mutate a$11_@3:TProp[4:9] = read x$9_@1:TProp
99 "]
100 bb2_instrs --> bb2_terminal(["Goto"])
101 end
102 subgraph bb3
103 bb3_instrs["
104 - [7] Reassign mutate a$11_@3[4:9] = Array []
104 + [7] Reassign mutate a$11_@3:TProp[4:9] = Array []
105 "]
106 bb3_instrs --> bb3_terminal(["Goto"])
107 end
108 subgraph bb1
109 bb1_instrs["
110 - [9] Call read useFreeze$5(freeze a$11_@3)
111 - [10] Call read useFreeze$5(read a$11_@3)
112 - [11] Call mutate call$6(read a$11_@3)
110 + [9] Call read useFreeze$5:TFunction(freeze a$11_@3:TProp)
111 + [10] Call read useFreeze$5:TFunction(read a$11_@3:TProp)
112 + [11] Call mutate call$6:TFunction(read a$11_@3:TProp)
113 "]
114 - bb1_instrs --> bb1_terminal(["Return read a$11_@3"])
114 + bb1_instrs --> bb1_terminal(["Return read a$11_@3:TProp"])
115 end
116
117 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+12 -12
@@ -185,13 +185,13 @@ function Foo$0() {}
185
186 ```
187 bb0:
188 - [1] Const mutate a$9_@1[1:7] = Call mutate compute$3(read props$8.a)
189 - [2] Const mutate b$10_@1[1:7] = Call mutate compute$3(read props$8.b)
188 + [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a)
189 + [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b)
190 [3] If (read props$8.c) then:bb2 else:bb1 fallthrough=bb1
191 bb2:
192 predecessor blocks: bb0
193 - [4] Call mutate mutate$5(mutate a$9_@1)
194 - [5] Call mutate mutate$5(mutate b$10_@1)
193 + [4] Call mutate mutate$5:TFunction(mutate a$9_@1)
194 + [5] Call mutate mutate$5:TFunction(mutate b$10_@1)
195 [6] Goto bb1
196 bb1:
197 predecessor blocks: bb2 bb0
@@ -211,11 +211,11 @@ function Component(
211 props,
212 ) {
213 scope @1 [1:7] deps=[read props$8.a] {
214 - [1] Const mutate a$9_@1[1:7] = Call mutate compute$3(read props$8.a)
215 - [2] Const mutate b$10_@1[1:7] = Call mutate compute$3(read props$8.b)
214 + [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a)
215 + [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b)
216 if (read props$8.c) {
217 - [4] Call mutate mutate$5(mutate a$9_@1)
218 - [5] Call mutate mutate$5(mutate b$10_@1)
217 + [4] Call mutate mutate$5:TFunction(mutate a$9_@1)
218 + [5] Call mutate mutate$5:TFunction(mutate b$10_@1)
219 }
220 }
221 scope @2 [7:8] deps=[freeze a$9_@1, freeze b$10_@1] {
@@ -233,15 +233,15 @@ flowchart TB
233 %% Basic Blocks
234 subgraph bb0
235 bb0_instrs["
236 - [1] Const mutate a$9_@1[1:7] = Call mutate compute$3(read props$8.a)
237 - [2] Const mutate b$10_@1[1:7] = Call mutate compute$3(read props$8.b)
236 + [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a)
237 + [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b)
238 "]
239 bb0_instrs --> bb0_terminal(["If (read props$8.c)"])
240 end
241 subgraph bb2
242 bb2_instrs["
243 - [4] Call mutate mutate$5(mutate a$9_@1)
244 - [5] Call mutate mutate$5(mutate b$10_@1)
243 + [4] Call mutate mutate$5:TFunction(mutate a$9_@1)
244 + [5] Call mutate mutate$5:TFunction(mutate b$10_@1)
245 "]
246 bb2_instrs --> bb2_terminal(["Goto"])
247 end
compiler/forget/src/__tests__/fixtures/hir/independent.expect.md
+6 -6
@@ -28,8 +28,8 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$8_@0 = Call mutate compute$3(read props$7.a)
32 - [2] Const mutate b$9_@1 = Call mutate compute$3(read props$7.b)
31 + [1] Const mutate a$8_@0 = Call mutate compute$3:TFunction(read props$7.a)
32 + [2] Const mutate b$9_@1 = Call mutate compute$3:TFunction(read props$7.b)
33 [3] Const mutate $10_@2 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@1} ></read Foo$5>
34 [4] Return read $10_@2
35 scope0 [1:2]:
@@ -48,10 +48,10 @@ function Component(
48 props,
49 ) {
50 scope @0 [1:2] deps=[read props$7.a] {
51 - [1] Const mutate a$8_@0 = Call mutate compute$3(read props$7.a)
51 + [1] Const mutate a$8_@0 = Call mutate compute$3:TFunction(read props$7.a)
52 }
53 scope @1 [2:3] deps=[read props$7.b] {
54 - [2] Const mutate b$9_@1 = Call mutate compute$3(read props$7.b)
54 + [2] Const mutate b$9_@1 = Call mutate compute$3:TFunction(read props$7.b)
55 }
56 scope @2 [3:4] deps=[freeze a$8_@0, freeze b$9_@1] {
57 [3] Const mutate $10_@2 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@1} ></read Foo$5>
@@ -68,8 +68,8 @@ flowchart TB
68 %% Basic Blocks
69 subgraph bb0
70 bb0_instrs["
71 - [1] Const mutate a$8_@0 = Call mutate compute$3(read props$7.a)
72 - [2] Const mutate b$9_@1 = Call mutate compute$3(read props$7.b)
71 + [1] Const mutate a$8_@0 = Call mutate compute$3:TFunction(read props$7.a)
72 + [2] Const mutate b$9_@1 = Call mutate compute$3:TFunction(read props$7.b)
73 [3] Const mutate $10_@2 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@1} ></read Foo$5>
74 "]
75 bb0_instrs --> bb0_terminal(["Return read $10_@2"])
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+9 -9
@@ -142,12 +142,12 @@ function Foo$0() {}
142
143 ```
144 bb0:
145 - [1] Const mutate a$9_@0[1:6] = Call mutate compute$3(read props$8.a)
146 - [2] Const mutate b$10_@0[1:6] = Call mutate compute$3(read props$8.b)
145 + [1] Const mutate a$9_@0[1:6] = Call mutate compute$3:TFunction(read props$8.a)
146 + [2] Const mutate b$10_@0[1:6] = Call mutate compute$3:TFunction(read props$8.b)
147 [3] If (read props$8.c) then:bb2 else:bb1 fallthrough=bb1
148 bb2:
149 predecessor blocks: bb0
150 - [4] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
150 + [4] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
151 [5] Goto bb1
152 bb1:
153 predecessor blocks: bb2 bb0
@@ -169,10 +169,10 @@ function Component(
169 props,
170 ) {
171 scope @0 [1:6] deps=[read props$8.a, read props$8.b, read props$8.c] {
172 - [1] Const mutate a$9_@0[1:6] = Call mutate compute$3(read props$8.a)
173 - [2] Const mutate b$10_@0[1:6] = Call mutate compute$3(read props$8.b)
172 + [1] Const mutate a$9_@0[1:6] = Call mutate compute$3:TFunction(read props$8.a)
173 + [2] Const mutate b$10_@0[1:6] = Call mutate compute$3:TFunction(read props$8.b)
174 if (read props$8.c) {
175 - [4] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
175 + [4] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
176 }
177 }
178 scope @1 [6:7] deps=[freeze a$9_@0, freeze b$10_@0] {
@@ -190,14 +190,14 @@ flowchart TB
190 %% Basic Blocks
191 subgraph bb0
192 bb0_instrs["
193 - [1] Const mutate a$9_@0[1:6] = Call mutate compute$3(read props$8.a)
194 - [2] Const mutate b$10_@0[1:6] = Call mutate compute$3(read props$8.b)
193 + [1] Const mutate a$9_@0[1:6] = Call mutate compute$3:TFunction(read props$8.a)
194 + [2] Const mutate b$10_@0[1:6] = Call mutate compute$3:TFunction(read props$8.b)
195 "]
196 bb0_instrs --> bb0_terminal(["If (read props$8.c)"])
197 end
198 subgraph bb2
199 bb2_instrs["
200 - [4] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
200 + [4] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
201 "]
202 bb2_instrs --> bb2_terminal(["Goto"])
203 end
compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md
+9 -9
@@ -28,9 +28,9 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$9_@0[1:4] = Call mutate compute$3(read props$8.a)
32 - [2] Const mutate b$10_@0[1:4] = Call mutate compute$3(read props$8.b)
33 - [3] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
31 + [1] Const mutate a$9_@0[1:4] = Call mutate compute$3:TFunction(read props$8.a)
32 + [2] Const mutate b$10_@0[1:4] = Call mutate compute$3:TFunction(read props$8.b)
33 + [3] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
34 [4] Const mutate $11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
35 [5] Return read $11_@1
36 scope0 [1:4]:
@@ -48,9 +48,9 @@ function Component(
48 props,
49 ) {
50 scope @0 [1:4] deps=[read props$8.a, read props$8.b] {
51 - [1] Const mutate a$9_@0[1:4] = Call mutate compute$3(read props$8.a)
52 - [2] Const mutate b$10_@0[1:4] = Call mutate compute$3(read props$8.b)
53 - [3] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
51 + [1] Const mutate a$9_@0[1:4] = Call mutate compute$3:TFunction(read props$8.a)
52 + [2] Const mutate b$10_@0[1:4] = Call mutate compute$3:TFunction(read props$8.b)
53 + [3] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
54 }
55 scope @1 [4:5] deps=[freeze a$9_@0, freeze b$10_@0] {
56 [4] Const mutate $11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
@@ -67,9 +67,9 @@ flowchart TB
67 %% Basic Blocks
68 subgraph bb0
69 bb0_instrs["
70 - [1] Const mutate a$9_@0[1:4] = Call mutate compute$3(read props$8.a)
71 - [2] Const mutate b$10_@0[1:4] = Call mutate compute$3(read props$8.b)
72 - [3] Call mutate foo$5(mutate a$9_@0, mutate b$10_@0)
70 + [1] Const mutate a$9_@0[1:4] = Call mutate compute$3:TFunction(read props$8.a)
71 + [2] Const mutate b$10_@0[1:4] = Call mutate compute$3:TFunction(read props$8.b)
72 + [3] Call mutate foo$5:TFunction(mutate a$9_@0, mutate b$10_@0)
73 [4] Const mutate $11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
74 "]
75 bb0_instrs --> bb0_terminal(["Return read $11_@1"])
compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md
+3 -3
@@ -18,7 +18,7 @@ function foo(a, b, c) {
18
19 ```
20 bb0:
21 - [1] Const mutate y$8_@0[1:6] = Array []
21 + [1] Const mutate y$8_@0:TFunction[1:6] = Array []
22 [2] If (read a$5) then:bb3 else:bb1 fallthrough=bb1
23 bb3:
24 predecessor blocks: bb0
@@ -45,7 +45,7 @@ function foo(
45 c,
46 ) {
47 scope @0 [1:6] deps=[read c$7, read b$6, read a$5] {
48 - [1] Const mutate y$8_@0[1:6] = Array []
48 + [1] Const mutate y$8_@0:TFunction[1:6] = Array []
49 if (read a$5) {
50 if (read b$6) {
51 [4] Call mutate y$8_@0.push(read c$7)
@@ -64,7 +64,7 @@ flowchart TB
64 %% Basic Blocks
65 subgraph bb0
66 bb0_instrs["
67 - [1] Const mutate y$8_@0[1:6] = Array []
67 + [1] Const mutate y$8_@0:TFunction[1:6] = Array []
68 "]
69 bb0_instrs --> bb0_terminal(["If (read a$5)"])
70 end
compiler/forget/src/__tests__/fixtures/hir/issue852.expect.md
+14 -14
@@ -15,17 +15,17 @@ function Component(c) {
15
16 ```
17 bb0:
18 - [1] Const mutate x$7_@0[1:3] = Object { c: read c$6 }
19 - [2] Call mutate mutate$3(mutate x$7_@0)
20 - [3] Const mutate a$8_@1 = read x$7_@0
21 - [4] Const mutate b$9_@2 = read a$8_@1
18 + [1] Const mutate x$7_@0:TObject[1:3] = Object { c: read c$6 }
19 + [2] Call mutate mutate$3:TFunction(mutate x$7_@0:TObject)
20 + [3] Const mutate a$8_@1:TObject = read x$7_@0:TObject
21 + [4] Const mutate b$9_@2:TObject = read a$8_@1:TObject
22 [5] Return
23 scope0 [1:3]:
24 - dependency: read c$6
25 scope1 [3:4]:
26 - - dependency: read x$7_@0
26 + - dependency: read x$7_@0:TObject
27 scope2 [4:5]:
28 - - dependency: read a$8_@1
28 + - dependency: read a$8_@1:TObject
29 ```
30
31 ## Reactive Scopes
@@ -35,11 +35,11 @@ function Component(
35 c,
36 ) {
37 scope @0 [1:3] deps=[read c$6] {
38 - [1] Const mutate x$7_@0[1:3] = Object { c: read c$6 }
39 - [2] Call mutate mutate$3(mutate x$7_@0)
38 + [1] Const mutate x$7_@0:TObject[1:3] = Object { c: read c$6 }
39 + [2] Call mutate mutate$3:TFunction(mutate x$7_@0:TObject)
40 }
41 - [3] Const mutate a$8_@1 = read x$7_@0
42 - [4] Const mutate b$9_@2 = read a$8_@1
41 + [3] Const mutate a$8_@1:TObject = read x$7_@0:TObject
42 + [4] Const mutate b$9_@2:TObject = read a$8_@1:TObject
43 return
44 }
45
@@ -52,10 +52,10 @@ flowchart TB
52 %% Basic Blocks
53 subgraph bb0
54 bb0_instrs["
55 - [1] Const mutate x$7_@0[1:3] = Object { c: read c$6 }
56 - [2] Call mutate mutate$3(mutate x$7_@0)
57 - [3] Const mutate a$8_@1 = read x$7_@0
58 - [4] Const mutate b$9_@2 = read a$8_@1
55 + [1] Const mutate x$7_@0:TObject[1:3] = Object { c: read c$6 }
56 + [2] Call mutate mutate$3:TFunction(mutate x$7_@0:TObject)
57 + [3] Const mutate a$8_@1:TObject = read x$7_@0:TObject
58 + [4] Const mutate b$9_@2:TObject = read a$8_@1:TObject
59 "]
60 bb0_instrs --> bb0_terminal(["Return"])
61 end
compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md
+16 -16
@@ -20,28 +20,28 @@ function Foo(props) {
20 ```
21 bb0:
22 [1] Const mutate $14_@0 = "\n Hello "
23 - [2] Const mutate $15_@1 = " "
23 + [2] Const mutate $15_@1:TPrimitive = " "
24 [3] Const mutate $16_@2 = "\n "
25 - [4] Const mutate $17_@3 = "div"
25 + [4] Const mutate $17_@3:TPrimitive = "div"
26 [5] Const mutate $18_@4 = "\n "
27 [6] Const mutate $19_@5 = "Text"
28 [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
29 [8] Const mutate $21_@7 = "\n "
30 - [9] Const mutate $22_@8 = JSX <read $17_@3>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3>
30 + [9] Const mutate $22_@8 = JSX <read $17_@3:TPrimitive>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3:TPrimitive>
31 [10] Const mutate $23_@9 = "\n "
32 - [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9]
32 + [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9]
33 [12] Return read $24_@10
34 scope6 [7:8]:
35 - dependency: read $19_@5
36 scope8 [9:10]:
37 - - dependency: read $17_@3
37 + - dependency: read $17_@3:TPrimitive
38 - dependency: read $18_@4
39 - dependency: read $20_@6
40 - dependency: read $21_@7
41 scope10 [11:12]:
42 - dependency: read $14_@0
43 - dependency: read props$13.greeting
44 - - dependency: read $15_@1
44 + - dependency: read $15_@1:TPrimitive
45 - dependency: read $16_@2
46 - dependency: read $22_@8
47 - dependency: read $23_@9
@@ -54,21 +54,21 @@ function Foo(
54 props,
55 ) {
56 [1] Const mutate $14_@0 = "\n Hello "
57 - [2] Const mutate $15_@1 = " "
57 + [2] Const mutate $15_@1:TPrimitive = " "
58 [3] Const mutate $16_@2 = "\n "
59 - [4] Const mutate $17_@3 = "div"
59 + [4] Const mutate $17_@3:TPrimitive = "div"
60 [5] Const mutate $18_@4 = "\n "
61 [6] Const mutate $19_@5 = "Text"
62 scope @6 [7:8] deps=[read $19_@5] {
63 [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
64 }
65 [8] Const mutate $21_@7 = "\n "
66 - scope @8 [9:10] deps=[read $17_@3, read $18_@4, read $20_@6, read $21_@7] {
67 - [9] Const mutate $22_@8 = JSX <read $17_@3>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3>
66 + scope @8 [9:10] deps=[read $17_@3:TPrimitive, read $18_@4, read $20_@6, read $21_@7] {
67 + [9] Const mutate $22_@8 = JSX <read $17_@3:TPrimitive>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3:TPrimitive>
68 }
69 [10] Const mutate $23_@9 = "\n "
70 - scope @10 [11:12] deps=[read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9] {
71 - [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9]
70 + scope @10 [11:12] deps=[read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9] {
71 + [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9]
72 }
73 return read $24_@10
74 }
@@ -83,16 +83,16 @@ flowchart TB
83 subgraph bb0
84 bb0_instrs["
85 [1] Const mutate $14_@0 = '\n Hello '
86 - [2] Const mutate $15_@1 = ' '
86 + [2] Const mutate $15_@1:TPrimitive = ' '
87 [3] Const mutate $16_@2 = '\n '
88 - [4] Const mutate $17_@3 = 'div'
88 + [4] Const mutate $17_@3:TPrimitive = 'div'
89 [5] Const mutate $18_@4 = '\n '
90 [6] Const mutate $19_@5 = 'Text'
91 [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
92 [8] Const mutate $21_@7 = '\n '
93 - [9] Const mutate $22_@8 = JSX <read $17_@3>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3>
93 + [9] Const mutate $22_@8 = JSX <read $17_@3:TPrimitive>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3:TPrimitive>
94 [10] Const mutate $23_@9 = '\n '
95 - [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9]
95 + [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9]
96 "]
97 bb0_instrs --> bb0_terminal(["Return read $24_@10"])
98 end
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+41 -41
@@ -23,12 +23,12 @@ function g() {}
23
24 ```
25 bb0:
26 - [1] Const mutate $5_@0 = Call mutate f$1()
26 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
27 [2] Let mutate $6_@1[2:7] = undefined
28 [2] If (read $5_@0) then:bb2 else:bb3 fallthrough=bb1
29 bb2:
30 predecessor blocks: bb0
31 - [3] Const mutate $6_@1[2:7] = Call mutate g$4()
31 + [3] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
32 [4] Goto bb1
33 bb3:
34 predecessor blocks: bb0
@@ -48,12 +48,12 @@ scope1 [2:7]:
48 function And(
49 ) {
50 scope @0 [1:2] deps=[] {
51 - [1] Const mutate $5_@0 = Call mutate f$1()
51 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
52 }
53 scope @1 [2:7] deps=[read $5_@0, read $5_@0] {
54 [2] Let mutate $6_@1[2:7] = undefined
55 if (read $5_@0) {
56 - [3] Const mutate $6_@1[2:7] = Call mutate g$4()
56 + [3] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
57 } else {
58 [5] Const mutate $6_@1[2:7] = read $5_@0
59 }
@@ -70,14 +70,14 @@ flowchart TB
70 %% Basic Blocks
71 subgraph bb0
72 bb0_instrs["
73 - [1] Const mutate $5_@0 = Call mutate f$1()
73 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
74 [2] Let mutate $6_@1[2:7] = undefined
75 "]
76 bb0_instrs --> bb0_terminal(["If (read $5_@0)"])
77 end
78 subgraph bb2
79 bb2_instrs["
80 - [3] Const mutate $6_@1[2:7] = Call mutate g$4()
80 + [3] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
81 "]
82 bb2_instrs --> bb2_terminal(["Goto"])
83 end
@@ -115,7 +115,7 @@ function And$0() {
115
116 ```
117 bb0:
118 - [1] Const mutate $5_@0 = Call mutate f$1()
118 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
119 [2] Let mutate $6_@1[2:7] = undefined
120 [2] If (read $5_@0) then:bb2 else:bb3 fallthrough=bb1
121 bb2:
@@ -124,7 +124,7 @@ bb2:
124 [4] Goto bb1
125 bb3:
126 predecessor blocks: bb0
127 - [5] Const mutate $6_@1[2:7] = Call mutate g$4()
127 + [5] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
128 [6] Goto bb1
129 bb1:
130 predecessor blocks: bb2 bb3
@@ -140,14 +140,14 @@ scope1 [2:7]:
140 function Or(
141 ) {
142 scope @0 [1:2] deps=[] {
143 - [1] Const mutate $5_@0 = Call mutate f$1()
143 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
144 }
145 scope @1 [2:7] deps=[read $5_@0, read $5_@0] {
146 [2] Let mutate $6_@1[2:7] = undefined
147 if (read $5_@0) {
148 [3] Const mutate $6_@1[2:7] = read $5_@0
149 } else {
150 - [5] Const mutate $6_@1[2:7] = Call mutate g$4()
150 + [5] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
151 }
152 }
153 return freeze $6_@1
@@ -162,7 +162,7 @@ flowchart TB
162 %% Basic Blocks
163 subgraph bb0
164 bb0_instrs["
165 - [1] Const mutate $5_@0 = Call mutate f$1()
165 + [1] Const mutate $5_@0 = Call mutate f$1:TFunction()
166 [2] Let mutate $6_@1[2:7] = undefined
167 "]
168 bb0_instrs --> bb0_terminal(["If (read $5_@0)"])
@@ -175,7 +175,7 @@ flowchart TB
175 end
176 subgraph bb3
177 bb3_instrs["
178 - [5] Const mutate $6_@1[2:7] = Call mutate g$4()
178 + [5] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction()
179 "]
180 bb3_instrs --> bb3_terminal(["Goto"])
181 end
@@ -207,28 +207,28 @@ function Or$0() {
207
208 ```
209 bb0:
210 - [1] Const mutate $9_@0 = Call mutate f$2()
211 - [2] Const mutate $10_@1 = null
212 - [3] Const mutate $11_@2 = Binary read $9_@0 != read $10_@1
213 - [4] Let mutate $12_@3[4:9] = undefined
214 - [4] If (read $11_@2) then:bb2 else:bb3 fallthrough=bb1
210 + [1] Const mutate $9_@0:TPrimitive = Call mutate f$2:TFunction()
211 + [2] Const mutate $10_@1:TPrimitive = null
212 + [3] Const mutate $11_@2:TPrimitive = Binary read $9_@0:TPrimitive != read $10_@1:TPrimitive
213 + [4] Let mutate $12_@3:TPrimitive[4:9] = undefined
214 + [4] If (read $11_@2:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
215 bb2:
216 predecessor blocks: bb0
217 - [5] Const mutate $12_@3[4:9] = read $9_@0
217 + [5] Const mutate $12_@3:TPrimitive[4:9] = read $9_@0:TPrimitive
218 [6] Goto bb1
219 bb3:
220 predecessor blocks: bb0
221 - [7] Const mutate $12_@3[4:9] = Call mutate g$7()
221 + [7] Const mutate $12_@3:TPrimitive[4:9] = Call mutate g$7:TFunction()
222 [8] Goto bb1
223 bb1:
224 predecessor blocks: bb2 bb3
225 - [9] Return freeze $12_@3
225 + [9] Return freeze $12_@3:TPrimitive
226 scope2 [3:4]:
227 - - dependency: read $9_@0
228 - - dependency: read $10_@1
227 + - dependency: read $9_@0:TPrimitive
228 + - dependency: read $10_@1:TPrimitive
229 scope3 [4:9]:
230 - - dependency: read $9_@0
231 - - dependency: read $11_@2
230 + - dependency: read $9_@0:TPrimitive
231 + - dependency: read $11_@2:TPrimitive
232 ```
233
234 ## Reactive Scopes
@@ -238,19 +238,19 @@ function QuestionQuestion(
238 props,
239 ) {
240 scope @0 [1:2] deps=[] {
241 - [1] Const mutate $9_@0 = Call mutate f$2()
241 + [1] Const mutate $9_@0:TPrimitive = Call mutate f$2:TFunction()
242 }
243 - [2] Const mutate $10_@1 = null
244 - [3] Const mutate $11_@2 = Binary read $9_@0 != read $10_@1
245 - scope @3 [4:9] deps=[read $9_@0, read $11_@2] {
246 - [4] Let mutate $12_@3[4:9] = undefined
247 - if (read $11_@2) {
248 - [5] Const mutate $12_@3[4:9] = read $9_@0
243 + [2] Const mutate $10_@1:TPrimitive = null
244 + [3] Const mutate $11_@2:TPrimitive = Binary read $9_@0:TPrimitive != read $10_@1:TPrimitive
245 + scope @3 [4:9] deps=[read $9_@0:TPrimitive, read $11_@2:TPrimitive] {
246 + [4] Let mutate $12_@3:TPrimitive[4:9] = undefined
247 + if (read $11_@2:TPrimitive) {
248 + [5] Const mutate $12_@3:TPrimitive[4:9] = read $9_@0:TPrimitive
249 } else {
250 - [7] Const mutate $12_@3[4:9] = Call mutate g$7()
250 + [7] Const mutate $12_@3:TPrimitive[4:9] = Call mutate g$7:TFunction()
251 }
252 }
253 - return freeze $12_@3
253 + return freeze $12_@3:TPrimitive
254 }
255
256 ```
@@ -262,27 +262,27 @@ flowchart TB
262 %% Basic Blocks
263 subgraph bb0
264 bb0_instrs["
265 - [1] Const mutate $9_@0 = Call mutate f$2()
266 - [2] Const mutate $10_@1 = null
267 - [3] Const mutate $11_@2 = Binary read $9_@0 != read $10_@1
268 - [4] Let mutate $12_@3[4:9] = undefined
265 + [1] Const mutate $9_@0:TPrimitive = Call mutate f$2:TFunction()
266 + [2] Const mutate $10_@1:TPrimitive = null
267 + [3] Const mutate $11_@2:TPrimitive = Binary read $9_@0:TPrimitive != read $10_@1:TPrimitive
268 + [4] Let mutate $12_@3:TPrimitive[4:9] = undefined
269 "]
270 - bb0_instrs --> bb0_terminal(["If (read $11_@2)"])
270 + bb0_instrs --> bb0_terminal(["If (read $11_@2:TPrimitive)"])
271 end
272 subgraph bb2
273 bb2_instrs["
274 - [5] Const mutate $12_@3[4:9] = read $9_@0
274 + [5] Const mutate $12_@3:TPrimitive[4:9] = read $9_@0:TPrimitive
275 "]
276 bb2_instrs --> bb2_terminal(["Goto"])
277 end
278 subgraph bb3
279 bb3_instrs["
280 - [7] Const mutate $12_@3[4:9] = Call mutate g$7()
280 + [7] Const mutate $12_@3:TPrimitive[4:9] = Call mutate g$7:TFunction()
281 "]
282 bb3_instrs --> bb3_terminal(["Goto"])
283 end
284 subgraph bb1
285 - bb1_terminal(["Return freeze $12_@3"])
285 + bb1_terminal(["Return freeze $12_@3:TPrimitive"])
286 end
287
288 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+30 -30
@@ -122,22 +122,22 @@ function cond$0(x$2) {}
122 bb0:
123 [1] Let mutate a$18_@0[1:23] = Object { }
124 [2] Let mutate b$20_@0[1:23] = Object { }
125 - [3] Let mutate c$22_@0[1:23] = Object { }
125 + [3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
126 [4] Let mutate d$24_@0[1:23] = Object { }
127 [5] While test=bb1 loop=bb3 fallthrough=bb2
128 bb1:
129 predecessor blocks: bb0 bb4
130 - [6] Const mutate $17_@1[6:8] = true
131 - [7] If (read $17_@1) then:bb3 else:bb2 fallthrough=bb2
130 + [6] Const mutate $17_@1:TPrimitive[6:8] = true
131 + [7] If (read $17_@1:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
132 bb3:
133 predecessor blocks: bb1
134 [8] Const mutate z$19_@0[1:23] = read a$18_@0
135 [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
136 - [10] Reassign mutate b$20_@0[1:23] = read c$22_@0
137 - [11] Reassign mutate c$22_@0[1:23] = read d$24_@0
136 + [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
137 + [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
138 [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
139 - [13] Call mutate mutate$7(mutate a$18_@0, mutate b$20_@0)
140 - [14] Const mutate $29_@0[1:23] = Call mutate cond$8(mutate a$18_@0)
139 + [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
140 + [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
141 [15] If (read $29_@0) then:bb2 else:bb4 fallthrough=bb4
142 bb4:
143 predecessor blocks: bb3
@@ -150,14 +150,14 @@ bb7:
150 [18] If (read b$20_@0) then:bb9 else:bb9 fallthrough=bb9
151 bb9:
152 predecessor blocks: bb7
153 - [19] If (read c$22_@0) then:bb11 else:bb11 fallthrough=bb11
153 + [19] If (read c$22_@0:TPrimitive) then:bb11 else:bb11 fallthrough=bb11
154 bb11:
155 predecessor blocks: bb9
156 [20] If (read d$24_@0) then:bb13 else:bb13 fallthrough=bb13
157 bb13:
158 predecessor blocks: bb11
159 - [21] Const mutate $34_@2 = null
160 - [22] Call mutate mutate$7(mutate d$24_@0, read $34_@2)
159 + [21] Const mutate $34_@2:TPrimitive = null
160 + [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34_@2:TPrimitive)
161 [23] Return
162
163 ```
@@ -171,20 +171,20 @@ function Component(
171 scope @0 [1:23] deps=[] {
172 [1] Let mutate a$18_@0[1:23] = Object { }
173 [2] Let mutate b$20_@0[1:23] = Object { }
174 - [3] Let mutate c$22_@0[1:23] = Object { }
174 + [3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
175 [4] Let mutate d$24_@0[1:23] = Object { }
176 scope @1 [6:8] deps=[] {
177 while (
178 - [6] Const mutate $17_@1[6:8] = true
179 - read $17_@1
178 + [6] Const mutate $17_@1:TPrimitive[6:8] = true
179 + read $17_@1:TPrimitive
180 ) {
181 [8] Const mutate z$19_@0[1:23] = read a$18_@0
182 [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
183 - [10] Reassign mutate b$20_@0[1:23] = read c$22_@0
184 - [11] Reassign mutate c$22_@0[1:23] = read d$24_@0
183 + [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
184 + [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
185 [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
186 - [13] Call mutate mutate$7(mutate a$18_@0, mutate b$20_@0)
187 - [14] Const mutate $29_@0[1:23] = Call mutate cond$8(mutate a$18_@0)
186 + [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
187 + [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
188 if (read $29_@0) {
189 break
190 }
@@ -194,12 +194,12 @@ function Component(
194 }
195 if (read b$20_@0) {
196 }
197 - if (read c$22_@0) {
197 + if (read c$22_@0:TPrimitive) {
198 }
199 if (read d$24_@0) {
200 }
201 - [21] Const mutate $34_@2 = null
202 - [22] Call mutate mutate$7(mutate d$24_@0, read $34_@2)
201 + [21] Const mutate $34_@2:TPrimitive = null
202 + [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34_@2:TPrimitive)
203 }
204 return
205 }
@@ -215,26 +215,26 @@ flowchart TB
215 bb0_instrs["
216 [1] Let mutate a$18_@0[1:23] = Object { }
217 [2] Let mutate b$20_@0[1:23] = Object { }
218 - [3] Let mutate c$22_@0[1:23] = Object { }
218 + [3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
219 [4] Let mutate d$24_@0[1:23] = Object { }
220 "]
221 bb0_instrs --> bb0_terminal(["While"])
222 end
223 subgraph bb1
224 bb1_instrs["
225 - [6] Const mutate $17_@1[6:8] = true
225 + [6] Const mutate $17_@1:TPrimitive[6:8] = true
226 "]
227 - bb1_instrs --> bb1_terminal(["If (read $17_@1)"])
227 + bb1_instrs --> bb1_terminal(["If (read $17_@1:TPrimitive)"])
228 end
229 subgraph bb3
230 bb3_instrs["
231 [8] Const mutate z$19_@0[1:23] = read a$18_@0
232 [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
233 - [10] Reassign mutate b$20_@0[1:23] = read c$22_@0
234 - [11] Reassign mutate c$22_@0[1:23] = read d$24_@0
233 + [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
234 + [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
235 [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
236 - [13] Call mutate mutate$7(mutate a$18_@0, mutate b$20_@0)
237 - [14] Const mutate $29_@0[1:23] = Call mutate cond$8(mutate a$18_@0)
236 + [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
237 + [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
238 "]
239 bb3_instrs --> bb3_terminal(["If (read $29_@0)"])
240 end
@@ -248,15 +248,15 @@ flowchart TB
248 bb7_terminal(["If (read b$20_@0)"])
249 end
250 subgraph bb9
251 - bb9_terminal(["If (read c$22_@0)"])
251 + bb9_terminal(["If (read c$22_@0:TPrimitive)"])
252 end
253 subgraph bb11
254 bb11_terminal(["If (read d$24_@0)"])
255 end
256 subgraph bb13
257 bb13_instrs["
258 - [21] Const mutate $34_@2 = null
259 - [22] Call mutate mutate$7(mutate d$24_@0, read $34_@2)
258 + [21] Const mutate $34_@2:TPrimitive = null
259 + [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34_@2:TPrimitive)
260 "]
261 bb13_instrs --> bb13_terminal(["Return"])
262 end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+36 -36
@@ -78,34 +78,34 @@ function mutate$0(x$3, y$4) {}
78
79 ```
80 bb0:
81 - [1] Const mutate a$11_@0 = Object { }
82 - [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0]
83 - [3] Const mutate c$13_@2 = Object { }
84 - [4] Const mutate d$14_@1[2:15] = Object { c: read c$13_@2 }
85 - [5] Const mutate x$15_@1[2:15] = Object { }
81 + [1] Const mutate a$11_@0:TObject = Object { }
82 + [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0:TObject]
83 + [3] Const mutate c$13_@2:TObject = Object { }
84 + [4] Const mutate d$14_@1:TObject[2:15] = Object { c: read c$13_@2:TObject }
85 + [5] Const mutate x$15_@1:TObject[2:15] = Object { }
86 [6] Reassign mutate x$15_@1.b[2:15] = read b$12_@1
87 - [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8(mutate x$15_@1, mutate d$14_@1)
88 - [8] If (read a$11_@0) then:bb1 else:bb1 fallthrough=bb1
87 + [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
88 + [8] If (read a$11_@0:TObject) then:bb1 else:bb1 fallthrough=bb1
89 bb1:
90 predecessor blocks: bb0
91 [9] If (read b$12_@1) then:bb3 else:bb3 fallthrough=bb3
92 bb3:
93 predecessor blocks: bb1
94 - [10] If (read c$13_@2) then:bb5 else:bb5 fallthrough=bb5
94 + [10] If (read c$13_@2:TObject) then:bb5 else:bb5 fallthrough=bb5
95 bb5:
96 predecessor blocks: bb3
97 - [11] If (read d$14_@1) then:bb7 else:bb7 fallthrough=bb7
97 + [11] If (read d$14_@1:TObject) then:bb7 else:bb7 fallthrough=bb7
98 bb7:
99 predecessor blocks: bb5
100 [12] If (read y$16_@1) then:bb9 else:bb9 fallthrough=bb9
101 bb9:
102 predecessor blocks: bb7
103 - [13] Const mutate $17_@3 = null
104 - [14] Call mutate mutate$8(mutate x$15_@1, read $17_@3)
103 + [13] Const mutate $17_@3:TPrimitive = null
104 + [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17_@3:TPrimitive)
105 [15] Return
106 scope1 [2:15]:
107 - - dependency: read a$11_@0
108 - - dependency: read a$11_@0
107 + - dependency: read a$11_@0:TObject
108 + - dependency: read a$11_@0:TObject
109 ```
110
111 ## Reactive Scopes
@@ -115,29 +115,29 @@ function Component(
115 props,
116 ) {
117 scope @0 [1:2] deps=[] {
118 - [1] Const mutate a$11_@0 = Object { }
118 + [1] Const mutate a$11_@0:TObject = Object { }
119 }
120 - scope @1 [2:15] deps=[read a$11_@0, read a$11_@0] {
121 - [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0]
120 + scope @1 [2:15] deps=[read a$11_@0:TObject, read a$11_@0:TObject] {
121 + [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0:TObject]
122 scope @2 [3:4] deps=[] {
123 - [3] Const mutate c$13_@2 = Object { }
123 + [3] Const mutate c$13_@2:TObject = Object { }
124 }
125 - [4] Const mutate d$14_@1[2:15] = Object { c: read c$13_@2 }
126 - [5] Const mutate x$15_@1[2:15] = Object { }
125 + [4] Const mutate d$14_@1:TObject[2:15] = Object { c: read c$13_@2:TObject }
126 + [5] Const mutate x$15_@1:TObject[2:15] = Object { }
127 [6] Reassign mutate x$15_@1.b[2:15] = read b$12_@1
128 - [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8(mutate x$15_@1, mutate d$14_@1)
129 - if (read a$11_@0) {
128 + [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
129 + if (read a$11_@0:TObject) {
130 }
131 if (read b$12_@1) {
132 }
133 - if (read c$13_@2) {
133 + if (read c$13_@2:TObject) {
134 }
135 - if (read d$14_@1) {
135 + if (read d$14_@1:TObject) {
136 }
137 if (read y$16_@1) {
138 }
139 - [13] Const mutate $17_@3 = null
140 - [14] Call mutate mutate$8(mutate x$15_@1, read $17_@3)
139 + [13] Const mutate $17_@3:TPrimitive = null
140 + [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17_@3:TPrimitive)
141 }
142 return
143 }
@@ -151,32 +151,32 @@ flowchart TB
151 %% Basic Blocks
152 subgraph bb0
153 bb0_instrs["
154 - [1] Const mutate a$11_@0 = Object { }
155 - [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0]
156 - [3] Const mutate c$13_@2 = Object { }
157 - [4] Const mutate d$14_@1[2:15] = Object { c: read c$13_@2 }
158 - [5] Const mutate x$15_@1[2:15] = Object { }
154 + [1] Const mutate a$11_@0:TObject = Object { }
155 + [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0:TObject]
156 + [3] Const mutate c$13_@2:TObject = Object { }
157 + [4] Const mutate d$14_@1:TObject[2:15] = Object { c: read c$13_@2:TObject }
158 + [5] Const mutate x$15_@1:TObject[2:15] = Object { }
159 [6] Reassign mutate x$15_@1.b[2:15] = read b$12_@1
160 - [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8(mutate x$15_@1, mutate d$14_@1)
160 + [7] Const mutate y$16_@1[2:15] = Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, mutate d$14_@1:TObject)
161 "]
162 - bb0_instrs --> bb0_terminal(["If (read a$11_@0)"])
162 + bb0_instrs --> bb0_terminal(["If (read a$11_@0:TObject)"])
163 end
164 subgraph bb1
165 bb1_terminal(["If (read b$12_@1)"])
166 end
167 subgraph bb3
168 - bb3_terminal(["If (read c$13_@2)"])
168 + bb3_terminal(["If (read c$13_@2:TObject)"])
169 end
170 subgraph bb5
171 - bb5_terminal(["If (read d$14_@1)"])
171 + bb5_terminal(["If (read d$14_@1:TObject)"])
172 end
173 subgraph bb7
174 bb7_terminal(["If (read y$16_@1)"])
175 end
176 subgraph bb9
177 bb9_instrs["
178 - [13] Const mutate $17_@3 = null
179 - [14] Call mutate mutate$8(mutate x$15_@1, read $17_@3)
178 + [13] Const mutate $17_@3:TPrimitive = null
179 + [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17_@3:TPrimitive)
180 "]
181 bb9_instrs --> bb9_terminal(["Return"])
182 end
compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md
+42 -42
@@ -112,39 +112,39 @@ function cond$0() {}
112
113 ```
114 bb0:
115 - [1] Const mutate a$12_@0[1:18] = Object { }
116 - [2] Const mutate b$13_@0[1:18] = Object { }
117 - [3] Const mutate c$14_@1 = Object { }
118 - [4] Const mutate d$15_@0[1:18] = Object { }
115 + [1] Const mutate a$12_@0:TObject[1:18] = Object { }
116 + [2] Const mutate b$13_@0:TObject[1:18] = Object { }
117 + [3] Const mutate c$14_@1:TObject = Object { }
118 + [4] Const mutate d$15_@0:TObject[1:18] = Object { }
119 [5] While test=bb1 loop=bb3 fallthrough=bb2
120 bb1:
121 predecessor blocks: bb0 bb4
122 - [6] Const mutate $16_@3[6:8] = true
123 - [7] If (read $16_@3) then:bb3 else:bb2 fallthrough=bb2
122 + [6] Const mutate $16_@3:TPrimitive[6:8] = true
123 + [7] If (read $16_@3:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
124 bb3:
125 predecessor blocks: bb1
126 - [8] Call mutate mutate$6(mutate a$12_@0, mutate b$13_@0)
127 - [9] Const mutate $21_@0[1:18] = Call mutate cond$7(mutate a$12_@0)
126 + [8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
127 + [9] Const mutate $21_@0[1:18] = Call mutate cond$7:TFunction(mutate a$12_@0:TObject)
128 [10] If (read $21_@0) then:bb2 else:bb4 fallthrough=bb4
129 bb4:
130 predecessor blocks: bb3
131 [11] Goto(Continue) bb1
132 bb2:
133 predecessor blocks: bb3 bb1
134 - [12] If (read a$12_@0) then:bb7 else:bb7 fallthrough=bb7
134 + [12] If (read a$12_@0:TObject) then:bb7 else:bb7 fallthrough=bb7
135 bb7:
136 predecessor blocks: bb2
137 - [13] If (read b$13_@0) then:bb9 else:bb9 fallthrough=bb9
137 + [13] If (read b$13_@0:TObject) then:bb9 else:bb9 fallthrough=bb9
138 bb9:
139 predecessor blocks: bb7
140 - [14] If (read c$14_@1) then:bb11 else:bb11 fallthrough=bb11
140 + [14] If (read c$14_@1:TObject) then:bb11 else:bb11 fallthrough=bb11
141 bb11:
142 predecessor blocks: bb9
143 - [15] If (read d$15_@0) then:bb13 else:bb13 fallthrough=bb13
143 + [15] If (read d$15_@0:TObject) then:bb13 else:bb13 fallthrough=bb13
144 bb13:
145 predecessor blocks: bb11
146 - [16] Const mutate $28_@4 = null
147 - [17] Call mutate mutate$6(mutate d$15_@0, read $28_@4)
146 + [16] Const mutate $28_@4:TPrimitive = null
147 + [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28_@4:TPrimitive)
148 [18] Return
149
150 ```
@@ -156,34 +156,34 @@ function Component(
156 props,
157 ) {
158 scope @0 [1:18] deps=[] {
159 - [1] Const mutate a$12_@0[1:18] = Object { }
160 - [2] Const mutate b$13_@0[1:18] = Object { }
159 + [1] Const mutate a$12_@0:TObject[1:18] = Object { }
160 + [2] Const mutate b$13_@0:TObject[1:18] = Object { }
161 scope @1 [3:4] deps=[] {
162 - [3] Const mutate c$14_@1 = Object { }
162 + [3] Const mutate c$14_@1:TObject = Object { }
163 }
164 - [4] Const mutate d$15_@0[1:18] = Object { }
164 + [4] Const mutate d$15_@0:TObject[1:18] = Object { }
165 scope @3 [6:8] deps=[] {
166 while (
167 - [6] Const mutate $16_@3[6:8] = true
168 - read $16_@3
167 + [6] Const mutate $16_@3:TPrimitive[6:8] = true
168 + read $16_@3:TPrimitive
169 ) {
170 - [8] Call mutate mutate$6(mutate a$12_@0, mutate b$13_@0)
171 - [9] Const mutate $21_@0[1:18] = Call mutate cond$7(mutate a$12_@0)
170 + [8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
171 + [9] Const mutate $21_@0[1:18] = Call mutate cond$7:TFunction(mutate a$12_@0:TObject)
172 if (read $21_@0) {
173 break
174 }
175 }
176 }
177 - if (read a$12_@0) {
177 + if (read a$12_@0:TObject) {
178 }
179 - if (read b$13_@0) {
179 + if (read b$13_@0:TObject) {
180 }
181 - if (read c$14_@1) {
181 + if (read c$14_@1:TObject) {
182 }
183 - if (read d$15_@0) {
183 + if (read d$15_@0:TObject) {
184 }
185 - [16] Const mutate $28_@4 = null
186 - [17] Call mutate mutate$6(mutate d$15_@0, read $28_@4)
185 + [16] Const mutate $28_@4:TPrimitive = null
186 + [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28_@4:TPrimitive)
187 }
188 return
189 }
@@ -197,23 +197,23 @@ flowchart TB
197 %% Basic Blocks
198 subgraph bb0
199 bb0_instrs["
200 - [1] Const mutate a$12_@0[1:18] = Object { }
201 - [2] Const mutate b$13_@0[1:18] = Object { }
202 - [3] Const mutate c$14_@1 = Object { }
203 - [4] Const mutate d$15_@0[1:18] = Object { }
200 + [1] Const mutate a$12_@0:TObject[1:18] = Object { }
201 + [2] Const mutate b$13_@0:TObject[1:18] = Object { }
202 + [3] Const mutate c$14_@1:TObject = Object { }
203 + [4] Const mutate d$15_@0:TObject[1:18] = Object { }
204 "]
205 bb0_instrs --> bb0_terminal(["While"])
206 end
207 subgraph bb1
208 bb1_instrs["
209 - [6] Const mutate $16_@3[6:8] = true
209 + [6] Const mutate $16_@3:TPrimitive[6:8] = true
210 "]
211 - bb1_instrs --> bb1_terminal(["If (read $16_@3)"])
211 + bb1_instrs --> bb1_terminal(["If (read $16_@3:TPrimitive)"])
212 end
213 subgraph bb3
214 bb3_instrs["
215 - [8] Call mutate mutate$6(mutate a$12_@0, mutate b$13_@0)
216 - [9] Const mutate $21_@0[1:18] = Call mutate cond$7(mutate a$12_@0)
215 + [8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
216 + [9] Const mutate $21_@0[1:18] = Call mutate cond$7:TFunction(mutate a$12_@0:TObject)
217 "]
218 bb3_instrs --> bb3_terminal(["If (read $21_@0)"])
219 end
@@ -221,21 +221,21 @@ flowchart TB
221 bb4_terminal(["Goto"])
222 end
223 subgraph bb2
224 - bb2_terminal(["If (read a$12_@0)"])
224 + bb2_terminal(["If (read a$12_@0:TObject)"])
225 end
226 subgraph bb7
227 - bb7_terminal(["If (read b$13_@0)"])
227 + bb7_terminal(["If (read b$13_@0:TObject)"])
228 end
229 subgraph bb9
230 - bb9_terminal(["If (read c$14_@1)"])
230 + bb9_terminal(["If (read c$14_@1:TObject)"])
231 end
232 subgraph bb11
233 - bb11_terminal(["If (read d$15_@0)"])
233 + bb11_terminal(["If (read d$15_@0:TObject)"])
234 end
235 subgraph bb13
236 bb13_instrs["
237 - [16] Const mutate $28_@4 = null
238 - [17] Call mutate mutate$6(mutate d$15_@0, read $28_@4)
237 + [16] Const mutate $28_@4:TPrimitive = null
238 + [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28_@4:TPrimitive)
239 "]
240 bb13_instrs --> bb13_terminal(["Return"])
241 end
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md
+9 -9
@@ -19,9 +19,9 @@ function foo(a, b, c) {
19
20 ```
21 bb0:
22 - [1] Const mutate x$9_@0[1:6] = Array []
23 - [2] Const mutate y$10_@0[1:6] = Array []
24 - [3] If (read x$9_@0) then:bb1 else:bb1 fallthrough=bb1
22 + [1] Const mutate x$9_@0:TFunction[1:6] = Array []
23 + [2] Const mutate y$10_@0:TFunction[1:6] = Array []
24 + [3] If (read x$9_@0:TFunction) then:bb1 else:bb1 fallthrough=bb1
25 bb1:
26 predecessor blocks: bb0
27 [4] Call mutate y$10_@0.push(read a$6)
@@ -39,9 +39,9 @@ function foo(
39 c,
40 ) {
41 scope @0 [1:6] deps=[] {
42 - [1] Const mutate x$9_@0[1:6] = Array []
43 - [2] Const mutate y$10_@0[1:6] = Array []
44 - if (read x$9_@0) {
42 + [1] Const mutate x$9_@0:TFunction[1:6] = Array []
43 + [2] Const mutate y$10_@0:TFunction[1:6] = Array []
44 + if (read x$9_@0:TFunction) {
45 }
46 [4] Call mutate y$10_@0.push(read a$6)
47 [5] Call mutate x$9_@0.push(read b$7)
@@ -58,10 +58,10 @@ flowchart TB
58 %% Basic Blocks
59 subgraph bb0
60 bb0_instrs["
61 - [1] Const mutate x$9_@0[1:6] = Array []
62 - [2] Const mutate y$10_@0[1:6] = Array []
61 + [1] Const mutate x$9_@0:TFunction[1:6] = Array []
62 + [2] Const mutate y$10_@0:TFunction[1:6] = Array []
63 "]
64 - bb0_instrs --> bb0_terminal(["If (read x$9_@0)"])
64 + bb0_instrs --> bb0_terminal(["If (read x$9_@0:TFunction)"])
65 end
66 subgraph bb1
67 bb1_instrs["
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md
+6 -6
@@ -15,8 +15,8 @@ function foo(a, b) {
15
16 ```
17 bb0:
18 - [1] Const mutate x$7_@0[1:5] = Array []
19 - [2] Const mutate y$8_@0[1:5] = Array []
18 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
19 + [2] Const mutate y$8_@0:TFunction[1:5] = Array []
20 [3] Call mutate x$7_@0.push(read a$5)
21 [4] Call mutate y$8_@0.push(read b$6)
22 [5] Return
@@ -31,8 +31,8 @@ function foo(
31 b,
32 ) {
33 scope @0 [1:5] deps=[] {
34 - [1] Const mutate x$7_@0[1:5] = Array []
35 - [2] Const mutate y$8_@0[1:5] = Array []
34 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
35 + [2] Const mutate y$8_@0:TFunction[1:5] = Array []
36 [3] Call mutate x$7_@0.push(read a$5)
37 [4] Call mutate y$8_@0.push(read b$6)
38 }
@@ -48,8 +48,8 @@ flowchart TB
48 %% Basic Blocks
49 subgraph bb0
50 bb0_instrs["
51 - [1] Const mutate x$7_@0[1:5] = Array []
52 - [2] Const mutate y$8_@0[1:5] = Array []
51 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
52 + [2] Const mutate y$8_@0:TFunction[1:5] = Array []
53 [3] Call mutate x$7_@0.push(read a$5)
54 [4] Call mutate y$8_@0.push(read b$6)
55 "]
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md
+6 -6
@@ -15,8 +15,8 @@ function foo(a, b) {
15
16 ```
17 bb0:
18 - [1] Const mutate x$7_@0[1:5] = Array []
19 - [2] Const mutate y$8_@1[2:4] = Array []
18 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
19 + [2] Const mutate y$8_@1:TFunction[2:4] = Array []
20 [3] Call mutate y$8_@1.push(read b$6)
21 [4] Call mutate x$7_@0.push(read a$5)
22 [5] Return
@@ -33,9 +33,9 @@ function foo(
33 b,
34 ) {
35 scope @0 [1:5] deps=[] {
36 - [1] Const mutate x$7_@0[1:5] = Array []
36 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
37 scope @1 [2:4] deps=[read b$6, read a$5] {
38 - [2] Const mutate y$8_@1[2:4] = Array []
38 + [2] Const mutate y$8_@1:TFunction[2:4] = Array []
39 [3] Call mutate y$8_@1.push(read b$6)
40 }
41 [4] Call mutate x$7_@0.push(read a$5)
@@ -52,8 +52,8 @@ flowchart TB
52 %% Basic Blocks
53 subgraph bb0
54 bb0_instrs["
55 - [1] Const mutate x$7_@0[1:5] = Array []
56 - [2] Const mutate y$8_@1[2:4] = Array []
55 + [1] Const mutate x$7_@0:TFunction[1:5] = Array []
56 + [2] Const mutate y$8_@1:TFunction[2:4] = Array []
57 [3] Call mutate y$8_@1.push(read b$6)
58 [4] Call mutate x$7_@0.push(read a$5)
59 "]
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md
+18 -18
@@ -21,11 +21,11 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$11_@0[1:11] = Array []
24 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
25 [2] If (read a$8) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$12_@1[3:7] = Array []
28 + [3] Const mutate y$12_@1:TFunction[3:7] = Array []
29 [4] If (read b$9) then:bb4 else:bb3 fallthrough=bb3
30 bb4:
31 predecessor blocks: bb2
@@ -33,21 +33,21 @@ bb4:
33 [6] Goto bb3
34 bb3:
35 predecessor blocks: bb4 bb2
36 - [7] Const mutate $13_@2 = "div"
37 - [8] Const mutate $15_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
36 + [7] Const mutate $13_@2:TPrimitive = "div"
37 + [8] Const mutate $15_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
38 [9] Call mutate x$11_@0.push(read $15_@3)
39 [10] Goto bb1
40 bb1:
41 predecessor blocks: bb3 bb0
42 - [11] Return freeze x$11_@0
42 + [11] Return freeze x$11_@0:TFunction
43 scope0 [1:11]:
44 - dependency: read a$8
45 scope1 [3:7]:
46 - dependency: read c$10
47 - dependency: read b$9
48 scope3 [8:9]:
49 - - dependency: read $13_@2
50 - - dependency: freeze y$12_@1
49 + - dependency: read $13_@2:TPrimitive
50 + - dependency: freeze y$12_@1:TFunction
51 ```
52
53 ## Reactive Scopes
@@ -59,22 +59,22 @@ function foo(
59 c,
60 ) {
61 scope @0 [1:11] deps=[read a$8] {
62 - [1] Const mutate x$11_@0[1:11] = Array []
62 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
63 if (read a$8) {
64 scope @1 [3:7] deps=[read c$10, read b$9] {
65 - [3] Const mutate y$12_@1[3:7] = Array []
65 + [3] Const mutate y$12_@1:TFunction[3:7] = Array []
66 if (read b$9) {
67 [5] Call mutate y$12_@1.push(read c$10)
68 }
69 }
70 - [7] Const mutate $13_@2 = "div"
71 - scope @3 [8:9] deps=[read $13_@2, freeze y$12_@1] {
72 - [8] Const mutate $15_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
70 + [7] Const mutate $13_@2:TPrimitive = "div"
71 + scope @3 [8:9] deps=[read $13_@2:TPrimitive, freeze y$12_@1:TFunction] {
72 + [8] Const mutate $15_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
73 }
74 [9] Call mutate x$11_@0.push(read $15_@3)
75 }
76 }
77 - return freeze x$11_@0
77 + return freeze x$11_@0:TFunction
78 }
79
80 ```
@@ -86,13 +86,13 @@ flowchart TB
86 %% Basic Blocks
87 subgraph bb0
88 bb0_instrs["
89 - [1] Const mutate x$11_@0[1:11] = Array []
89 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
90 "]
91 bb0_instrs --> bb0_terminal(["If (read a$8)"])
92 end
93 subgraph bb2
94 bb2_instrs["
95 - [3] Const mutate y$12_@1[3:7] = Array []
95 + [3] Const mutate y$12_@1:TFunction[3:7] = Array []
96 "]
97 bb2_instrs --> bb2_terminal(["If (read b$9)"])
98 end
@@ -104,14 +104,14 @@ flowchart TB
104 end
105 subgraph bb3
106 bb3_instrs["
107 - [7] Const mutate $13_@2 = 'div'
108 - [8] Const mutate $15_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
107 + [7] Const mutate $13_@2:TPrimitive = 'div'
108 + [8] Const mutate $15_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
109 [9] Call mutate x$11_@0.push(read $15_@3)
110 "]
111 bb3_instrs --> bb3_terminal(["Goto"])
112 end
113 subgraph bb1
114 - bb1_terminal(["Return freeze x$11_@0"])
114 + bb1_terminal(["Return freeze x$11_@0:TFunction"])
115 end
116
117 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md
+6 -6
@@ -17,8 +17,8 @@ function foo(a, b, c) {
17
18 ```
19 bb0:
20 - [1] Const mutate x$9_@0[1:8] = Array []
21 - [2] Const mutate y$10_@0[1:8] = Array []
20 + [1] Const mutate x$9_@0:TFunction[1:8] = Array []
21 + [2] Const mutate y$10_@0:TFunction[1:8] = Array []
22 [3] While test=bb1 loop=bb3 fallthrough=bb2
23 bb1:
24 predecessor blocks: bb0 bb3
@@ -43,8 +43,8 @@ function foo(
43 c,
44 ) {
45 scope @0 [1:8] deps=[] {
46 - [1] Const mutate x$9_@0[1:8] = Array []
47 - [2] Const mutate y$10_@0[1:8] = Array []
46 + [1] Const mutate x$9_@0:TFunction[1:8] = Array []
47 + [2] Const mutate y$10_@0:TFunction[1:8] = Array []
48 while (
49 read c$8
50 ) {
@@ -64,8 +64,8 @@ flowchart TB
64 %% Basic Blocks
65 subgraph bb0
66 bb0_instrs["
67 - [1] Const mutate x$9_@0[1:8] = Array []
68 - [2] Const mutate y$10_@0[1:8] = Array []
67 + [1] Const mutate x$9_@0:TFunction[1:8] = Array []
68 + [2] Const mutate y$10_@0:TFunction[1:8] = Array []
69 "]
70 bb0_instrs --> bb0_terminal(["While"])
71 end
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md
+12 -12
@@ -21,11 +21,11 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$9_@0[1:9] = Array []
24 + [1] Const mutate x$9_@0:TFunction[1:9] = Array []
25 [2] If (read a$6) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$10_@0[1:9] = Array []
28 + [3] Const mutate y$10_@0:TFunction[1:9] = Array []
29 [4] If (read b$7) then:bb4 else:bb3 fallthrough=bb3
30 bb4:
31 predecessor blocks: bb2
@@ -33,11 +33,11 @@ bb4:
33 [6] Goto bb3
34 bb3:
35 predecessor blocks: bb4 bb2
36 - [7] Call mutate x$9_@0.push(mutate y$10_@0)
36 + [7] Call mutate x$9_@0.push(mutate y$10_@0:TFunction)
37 [8] Goto bb1
38 bb1:
39 predecessor blocks: bb3 bb0
40 - [9] Return freeze x$9_@0
40 + [9] Return freeze x$9_@0:TFunction
41 scope0 [1:9]:
42 - dependency: read c$8
43 - dependency: read b$7
@@ -53,16 +53,16 @@ function foo(
53 c,
54 ) {
55 scope @0 [1:9] deps=[read c$8, read b$7, read a$6] {
56 - [1] Const mutate x$9_@0[1:9] = Array []
56 + [1] Const mutate x$9_@0:TFunction[1:9] = Array []
57 if (read a$6) {
58 - [3] Const mutate y$10_@0[1:9] = Array []
58 + [3] Const mutate y$10_@0:TFunction[1:9] = Array []
59 if (read b$7) {
60 [5] Call mutate y$10_@0.push(read c$8)
61 }
62 - [7] Call mutate x$9_@0.push(mutate y$10_@0)
62 + [7] Call mutate x$9_@0.push(mutate y$10_@0:TFunction)
63 }
64 }
65 - return freeze x$9_@0
65 + return freeze x$9_@0:TFunction
66 }
67
68 ```
@@ -74,13 +74,13 @@ flowchart TB
74 %% Basic Blocks
75 subgraph bb0
76 bb0_instrs["
77 - [1] Const mutate x$9_@0[1:9] = Array []
77 + [1] Const mutate x$9_@0:TFunction[1:9] = Array []
78 "]
79 bb0_instrs --> bb0_terminal(["If (read a$6)"])
80 end
81 subgraph bb2
82 bb2_instrs["
83 - [3] Const mutate y$10_@0[1:9] = Array []
83 + [3] Const mutate y$10_@0:TFunction[1:9] = Array []
84 "]
85 bb2_instrs --> bb2_terminal(["If (read b$7)"])
86 end
@@ -92,12 +92,12 @@ flowchart TB
92 end
93 subgraph bb3
94 bb3_instrs["
95 - [7] Call mutate x$9_@0.push(mutate y$10_@0)
95 + [7] Call mutate x$9_@0.push(mutate y$10_@0:TFunction)
96 "]
97 bb3_instrs --> bb3_terminal(["Goto"])
98 end
99 subgraph bb1
100 - bb1_terminal(["Return freeze x$9_@0"])
100 + bb1_terminal(["Return freeze x$9_@0:TFunction"])
101 end
102
103 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md
+8 -8
@@ -17,19 +17,19 @@ function Component(props) {
17
18 ```
19 bb0:
20 - [1] Const mutate x$7_@0[1:6] = Object { }
20 + [1] Const mutate x$7_@0:TObject[1:6] = Object { }
21 [2] Const mutate y$8_@0[1:6] = Array []
22 [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@0
23 [4] Const mutate child$9_@0[1:6] = JSX <read Component$0 data={freeze y$8_@0} ></read Component$0>
24 [5] Call mutate x$7_@0.y.push(read props$6.p0)
25 - [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0} >{read child$9_@0}</read Component$0>
25 + [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0:TObject} >{read child$9_@0}</read Component$0>
26 [7] Return read $10_@1
27 scope0 [1:6]:
28 - dependency: read Component$0
29 - dependency: read props$6.p0
30 scope1 [6:7]:
31 - dependency: read Component$0
32 - - dependency: freeze x$7_@0
32 + - dependency: freeze x$7_@0:TObject
33 - dependency: read child$9_@0
34 ```
35
@@ -40,14 +40,14 @@ function Component(
40 props,
41 ) {
42 scope @0 [1:6] deps=[read Component$0, read props$6.p0] {
43 - [1] Const mutate x$7_@0[1:6] = Object { }
43 + [1] Const mutate x$7_@0:TObject[1:6] = Object { }
44 [2] Const mutate y$8_@0[1:6] = Array []
45 [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@0
46 [4] Const mutate child$9_@0[1:6] = JSX <read Component$0 data={freeze y$8_@0} ></read Component$0>
47 [5] Call mutate x$7_@0.y.push(read props$6.p0)
48 }
49 - scope @1 [6:7] deps=[read Component$0, freeze x$7_@0, read child$9_@0] {
50 - [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0} >{read child$9_@0}</read Component$0>
49 + scope @1 [6:7] deps=[read Component$0, freeze x$7_@0:TObject, read child$9_@0] {
50 + [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0:TObject} >{read child$9_@0}</read Component$0>
51 }
52 return read $10_@1
53 }
@@ -61,12 +61,12 @@ flowchart TB
61 %% Basic Blocks
62 subgraph bb0
63 bb0_instrs["
64 - [1] Const mutate x$7_@0[1:6] = Object { }
64 + [1] Const mutate x$7_@0:TObject[1:6] = Object { }
65 [2] Const mutate y$8_@0[1:6] = Array []
66 [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@0
67 [4] Const mutate child$9_@0[1:6] = JSX <read Component$0 data={freeze y$8_@0} ></read Component$0>
68 [5] Call mutate x$7_@0.y.push(read props$6.p0)
69 - [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0} >{read child$9_@0}</read Component$0>
69 + [6] Const mutate $10_@1 = JSX <read Component$0 data={freeze x$7_@0:TObject} >{read child$9_@0}</read Component$0>
70 "]
71 bb0_instrs --> bb0_terminal(["Return read $10_@1"])
72 end
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md
+18 -18
@@ -18,12 +18,12 @@ function foo() {
18
19 ```
20 bb0:
21 - [1] Const mutate x$4_@0[1:6] = Object { }
22 - [2] Const mutate y$5_@1[2:5] = Array []
23 - [3] Const mutate z$6_@1[2:5] = Object { }
24 - [4] Call mutate y$5_@1.push(mutate z$6_@1)
25 - [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
26 - [6] Return freeze x$4_@0
21 + [1] Const mutate x$4_@0:TObject[1:6] = Object { }
22 + [2] Const mutate y$5_@1:TFunction[2:5] = Array []
23 + [3] Const mutate z$6_@1:TObject[2:5] = Object { }
24 + [4] Call mutate y$5_@1.push(mutate z$6_@1:TObject)
25 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1:TFunction
26 + [6] Return freeze x$4_@0:TObject
27 scope1 [2:5]:
28 - dependency: mutate x$4_@0.y
29 ```
@@ -34,15 +34,15 @@ scope1 [2:5]:
34 function foo(
35 ) {
36 scope @0 [1:6] deps=[] {
37 - [1] Const mutate x$4_@0[1:6] = Object { }
37 + [1] Const mutate x$4_@0:TObject[1:6] = Object { }
38 scope @1 [2:5] deps=[mutate x$4_@0.y] {
39 - [2] Const mutate y$5_@1[2:5] = Array []
40 - [3] Const mutate z$6_@1[2:5] = Object { }
41 - [4] Call mutate y$5_@1.push(mutate z$6_@1)
39 + [2] Const mutate y$5_@1:TFunction[2:5] = Array []
40 + [3] Const mutate z$6_@1:TObject[2:5] = Object { }
41 + [4] Call mutate y$5_@1.push(mutate z$6_@1:TObject)
42 }
43 - [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
43 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1:TFunction
44 }
45 - return freeze x$4_@0
45 + return freeze x$4_@0:TObject
46 }
47
48 ```
@@ -54,13 +54,13 @@ flowchart TB
54 %% Basic Blocks
55 subgraph bb0
56 bb0_instrs["
57 - [1] Const mutate x$4_@0[1:6] = Object { }
58 - [2] Const mutate y$5_@1[2:5] = Array []
59 - [3] Const mutate z$6_@1[2:5] = Object { }
60 - [4] Call mutate y$5_@1.push(mutate z$6_@1)
61 - [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
57 + [1] Const mutate x$4_@0:TObject[1:6] = Object { }
58 + [2] Const mutate y$5_@1:TFunction[2:5] = Array []
59 + [3] Const mutate z$6_@1:TObject[2:5] = Object { }
60 + [4] Call mutate y$5_@1.push(mutate z$6_@1:TObject)
61 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1:TFunction
62 "]
63 - bb0_instrs --> bb0_terminal(["Return freeze x$4_@0"])
63 + bb0_instrs --> bb0_terminal(["Return freeze x$4_@0:TObject"])
64 end
65
66 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md
+18 -18
@@ -20,14 +20,14 @@ function foo(a, b, c) {
20
21 ```
22 bb0:
23 - [1] Const mutate x$11_@0[1:11] = Array []
23 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
24 [2] If (read a$8) then:bb2 else:bb3 fallthrough=bb1
25 bb2:
26 predecessor blocks: bb0
27 - [3] Const mutate y$12_@1[3:5] = Array []
27 + [3] Const mutate y$12_@1:TFunction[3:5] = Array []
28 [4] Call mutate y$12_@1.push(read b$9)
29 - [5] Const mutate $13_@2 = "div"
30 - [6] Const mutate $14_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
29 + [5] Const mutate $13_@2:TPrimitive = "div"
30 + [6] Const mutate $14_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
31 [7] Call mutate x$11_@0.push(read $14_@3)
32 [8] Goto bb1
33 bb3:
@@ -36,15 +36,15 @@ bb3:
36 [10] Goto bb1
37 bb1:
38 predecessor blocks: bb2 bb3
39 - [11] Return freeze x$11_@0
39 + [11] Return freeze x$11_@0:TFunction
40 scope0 [1:11]:
41 - dependency: read c$10
42 - dependency: read a$8
43 scope1 [3:5]:
44 - dependency: read b$9
45 scope3 [6:7]:
46 - - dependency: read $13_@2
47 - - dependency: freeze y$12_@1
46 + - dependency: read $13_@2:TPrimitive
47 + - dependency: freeze y$12_@1:TFunction
48 ```
49
50 ## Reactive Scopes
@@ -56,22 +56,22 @@ function foo(
56 c,
57 ) {
58 scope @0 [1:11] deps=[read c$10, read a$8] {
59 - [1] Const mutate x$11_@0[1:11] = Array []
59 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
60 if (read a$8) {
61 scope @1 [3:5] deps=[read b$9] {
62 - [3] Const mutate y$12_@1[3:5] = Array []
62 + [3] Const mutate y$12_@1:TFunction[3:5] = Array []
63 [4] Call mutate y$12_@1.push(read b$9)
64 }
65 - [5] Const mutate $13_@2 = "div"
66 - scope @3 [6:7] deps=[read $13_@2, freeze y$12_@1] {
67 - [6] Const mutate $14_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
65 + [5] Const mutate $13_@2:TPrimitive = "div"
66 + scope @3 [6:7] deps=[read $13_@2:TPrimitive, freeze y$12_@1:TFunction] {
67 + [6] Const mutate $14_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
68 }
69 [7] Call mutate x$11_@0.push(read $14_@3)
70 } else {
71 [9] Call mutate x$11_@0.push(read c$10)
72 }
73 }
74 - return freeze x$11_@0
74 + return freeze x$11_@0:TFunction
75 }
76
77 ```
@@ -83,16 +83,16 @@ flowchart TB
83 %% Basic Blocks
84 subgraph bb0
85 bb0_instrs["
86 - [1] Const mutate x$11_@0[1:11] = Array []
86 + [1] Const mutate x$11_@0:TFunction[1:11] = Array []
87 "]
88 bb0_instrs --> bb0_terminal(["If (read a$8)"])
89 end
90 subgraph bb2
91 bb2_instrs["
92 - [3] Const mutate y$12_@1[3:5] = Array []
92 + [3] Const mutate y$12_@1:TFunction[3:5] = Array []
93 [4] Call mutate y$12_@1.push(read b$9)
94 - [5] Const mutate $13_@2 = 'div'
95 - [6] Const mutate $14_@3 = JSX <read $13_@2>{freeze y$12_@1}</read $13_@2>
94 + [5] Const mutate $13_@2:TPrimitive = 'div'
95 + [6] Const mutate $14_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
96 [7] Call mutate x$11_@0.push(read $14_@3)
97 "]
98 bb2_instrs --> bb2_terminal(["Goto"])
@@ -104,7 +104,7 @@ flowchart TB
104 bb3_instrs --> bb3_terminal(["Goto"])
105 end
106 subgraph bb1
107 - bb1_terminal(["Return freeze x$11_@0"])
107 + bb1_terminal(["Return freeze x$11_@0:TFunction"])
108 end
109
110 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md
+22 -22
@@ -19,10 +19,10 @@ function f(a, b) {
19
20 ```
21 bb0:
22 - [1] Const mutate x$10_@0[1:8] = Array []
23 - [2] Const mutate $11_@1 = 1
24 - [3] Const mutate $12_@2 = Binary read a$8.length === read $11_@1
25 - [4] If (read $12_@2) then:bb2 else:bb1 fallthrough=bb1
22 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
23 + [2] Const mutate $11_@1:TPrimitive = 1
24 + [3] Const mutate $12_@2:TPrimitive = Binary read a$8.length === read $11_@1:TPrimitive
25 + [4] If (read $12_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 [5] If (read b$9) then:bb4 else:bb1 fallthrough=bb1
@@ -32,18 +32,18 @@ bb4:
32 [7] Goto bb1
33 bb1:
34 predecessor blocks: bb4 bb2 bb0
35 - [8] Const mutate $13_@3 = "div"
36 - [9] Const mutate $15_@4 = JSX <read $13_@3>{freeze x$10_@0}</read $13_@3>
35 + [8] Const mutate $13_@3:TPrimitive = "div"
36 + [9] Const mutate $15_@4 = JSX <read $13_@3:TPrimitive>{freeze x$10_@0:TFunction}</read $13_@3:TPrimitive>
37 [10] Return read $15_@4
38 scope0 [1:8]:
39 - dependency: read b$9
40 - dependency: read b$9
41 scope2 [3:4]:
42 - dependency: read a$8.length
43 - - dependency: read $11_@1
43 + - dependency: read $11_@1:TPrimitive
44 scope4 [9:10]:
45 - - dependency: read $13_@3
46 - - dependency: freeze x$10_@0
45 + - dependency: read $13_@3:TPrimitive
46 + - dependency: freeze x$10_@0:TFunction
47 ```
48
49 ## Reactive Scopes
@@ -54,18 +54,18 @@ function f(
54 b,
55 ) {
56 scope @0 [1:8] deps=[read b$9, read b$9] {
57 - [1] Const mutate x$10_@0[1:8] = Array []
58 - [2] Const mutate $11_@1 = 1
59 - [3] Const mutate $12_@2 = Binary read a$8.length === read $11_@1
60 - if (read $12_@2) {
57 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
58 + [2] Const mutate $11_@1:TPrimitive = 1
59 + [3] Const mutate $12_@2:TPrimitive = Binary read a$8.length === read $11_@1:TPrimitive
60 + if (read $12_@2:TPrimitive) {
61 if (read b$9) {
62 [6] Call mutate x$10_@0.push(read b$9)
63 }
64 }
65 }
66 - [8] Const mutate $13_@3 = "div"
67 - scope @4 [9:10] deps=[read $13_@3, freeze x$10_@0] {
68 - [9] Const mutate $15_@4 = JSX <read $13_@3>{freeze x$10_@0}</read $13_@3>
66 + [8] Const mutate $13_@3:TPrimitive = "div"
67 + scope @4 [9:10] deps=[read $13_@3:TPrimitive, freeze x$10_@0:TFunction] {
68 + [9] Const mutate $15_@4 = JSX <read $13_@3:TPrimitive>{freeze x$10_@0:TFunction}</read $13_@3:TPrimitive>
69 }
70 return read $15_@4
71 }
@@ -79,11 +79,11 @@ flowchart TB
79 %% Basic Blocks
80 subgraph bb0
81 bb0_instrs["
82 - [1] Const mutate x$10_@0[1:8] = Array []
83 - [2] Const mutate $11_@1 = 1
84 - [3] Const mutate $12_@2 = Binary read a$8.length === read $11_@1
82 + [1] Const mutate x$10_@0:TFunction[1:8] = Array []
83 + [2] Const mutate $11_@1:TPrimitive = 1
84 + [3] Const mutate $12_@2:TPrimitive = Binary read a$8.length === read $11_@1:TPrimitive
85 "]
86 - bb0_instrs --> bb0_terminal(["If (read $12_@2)"])
86 + bb0_instrs --> bb0_terminal(["If (read $12_@2:TPrimitive)"])
87 end
88 subgraph bb2
89 bb2_terminal(["If (read b$9)"])
@@ -96,8 +96,8 @@ flowchart TB
96 end
97 subgraph bb1
98 bb1_instrs["
99 - [8] Const mutate $13_@3 = 'div'
100 - [9] Const mutate $15_@4 = JSX <read $13_@3>{freeze x$10_@0}</read $13_@3>
99 + [8] Const mutate $13_@3:TPrimitive = 'div'
100 + [9] Const mutate $15_@4 = JSX <read $13_@3:TPrimitive>{freeze x$10_@0:TFunction}</read $13_@3:TPrimitive>
101 "]
102 bb1_instrs --> bb1_terminal(["Return read $15_@4"])
103 end
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+20 -20
@@ -23,32 +23,32 @@ function Component(props) {
23
24 ```
25 bb0:
26 - [1] Let mutate x$7_@0[1:7] = Array []
26 + [1] Let mutate x$7_@0:TFunction[1:7] = Array []
27 [2] Call mutate x$7_@0.push(read props$6.p0)
28 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
28 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
29 [4] If (read props$6.p1) then:bb2 else:bb1 fallthrough=bb1
30 bb2:
31 predecessor blocks: bb0
32 - [5] Reassign mutate x$7_@0[1:7] = Array []
32 + [5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
33 [6] Goto bb1
34 bb1:
35 predecessor blocks: bb2 bb0
36 - [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0} ></read Component$0>
36 + [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
37 [8] Call read y$8_@0.push(read props$6.p2)
38 - [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0} y={read y$8_@0} ></read Component$0>
38 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8_@0:TFunction} ></read Component$0>
39 [10] Return read $15_@2
40 scope0 [1:7]:
41 - dependency: read props$6.p0
42 - dependency: read props$6.p1
43 scope1 [7:8]:
44 - dependency: read Component$0
45 - - dependency: freeze x$7_@0
45 + - dependency: freeze x$7_@0:TFunction
46 - dependency: read y$8_@0.push
47 - dependency: read props$6.p2
48 scope2 [9:10]:
49 - dependency: read Component$0
50 - - dependency: read x$7_@0
51 - - dependency: read y$8_@0
50 + - dependency: read x$7_@0:TFunction
51 + - dependency: read y$8_@0:TFunction
52 ```
53
54 ## Reactive Scopes
@@ -58,19 +58,19 @@ function Component(
58 props,
59 ) {
60 scope @0 [1:7] deps=[read props$6.p0, read props$6.p1] {
61 - [1] Let mutate x$7_@0[1:7] = Array []
61 + [1] Let mutate x$7_@0:TFunction[1:7] = Array []
62 [2] Call mutate x$7_@0.push(read props$6.p0)
63 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
63 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
64 if (read props$6.p1) {
65 - [5] Reassign mutate x$7_@0[1:7] = Array []
65 + [5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
66 }
67 }
68 - scope @1 [7:8] deps=[read Component$0, freeze x$7_@0, read y$8_@0.push, read props$6.p2] {
69 - [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0} ></read Component$0>
68 + scope @1 [7:8] deps=[read Component$0, freeze x$7_@0:TFunction, read y$8_@0.push, read props$6.p2] {
69 + [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
70 }
71 [8] Call read y$8_@0.push(read props$6.p2)
72 - scope @2 [9:10] deps=[read Component$0, read x$7_@0, read y$8_@0] {
73 - [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0} y={read y$8_@0} ></read Component$0>
72 + scope @2 [9:10] deps=[read Component$0, read x$7_@0:TFunction, read y$8_@0:TFunction] {
73 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8_@0:TFunction} ></read Component$0>
74 }
75 return read $15_@2
76 }
@@ -84,23 +84,23 @@ flowchart TB
84 %% Basic Blocks
85 subgraph bb0
86 bb0_instrs["
87 - [1] Let mutate x$7_@0[1:7] = Array []
87 + [1] Let mutate x$7_@0:TFunction[1:7] = Array []
88 [2] Call mutate x$7_@0.push(read props$6.p0)
89 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
89 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
90 "]
91 bb0_instrs --> bb0_terminal(["If (read props$6.p1)"])
92 end
93 subgraph bb2
94 bb2_instrs["
95 - [5] Reassign mutate x$7_@0[1:7] = Array []
95 + [5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
96 "]
97 bb2_instrs --> bb2_terminal(["Goto"])
98 end
99 subgraph bb1
100 bb1_instrs["
101 - [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0} ></read Component$0>
101 + [7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
102 [8] Call read y$8_@0.push(read props$6.p2)
103 - [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0} y={read y$8_@0} ></read Component$0>
103 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8_@0:TFunction} ></read Component$0>
104 "]
105 bb1_instrs --> bb1_terminal(["Return read $15_@2"])
106 end
compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md
+36 -36
@@ -34,7 +34,7 @@ function foo(a, b, c) {
34
35 ```
36 bb0:
37 - [1] Const mutate x$16_@0[1:5] = Array []
37 + [1] Const mutate x$16_@0:TFunction[1:5] = Array []
38 [2] If (read a$13) then:bb2 else:bb1 fallthrough=bb1
39 bb2:
40 predecessor blocks: bb0
@@ -42,48 +42,48 @@ bb2:
42 [4] Goto bb1
43 bb1:
44 predecessor blocks: bb2 bb0
45 - [5] Const mutate $17_@1 = "div"
46 - [6] Const mutate y$19_@2 = JSX <read $17_@1>{freeze x$16_@0}</read $17_@1>
47 - [7] Const mutate $20_@3 = 0
48 - [8] Let mutate x$22_@4[8:15] = undefined
45 + [5] Const mutate $17_@1:TPrimitive = "div"
46 + [6] Const mutate y$19_@2 = JSX <read $17_@1:TPrimitive>{freeze x$16_@0:TFunction}</read $17_@1:TPrimitive>
47 + [7] Const mutate $20_@3:TPrimitive = 0
48 + [8] Let mutate x$22_@4:TFunction[8:15] = undefined
49 [8] Switch (read b$14)
50 - Case read $20_@3: bb5
50 + Case read $20_@3:TPrimitive: bb5
51 Default: bb4
52 Fallthrough: bb3
53 bb5:
54 predecessor blocks: bb1
55 - [9] Reassign mutate x$22_@4[8:15] = Array []
55 + [9] Reassign mutate x$22_@4:TFunction[8:15] = Array []
56 [10] Call mutate x$22_@4.push(read b$14)
57 [11] Goto bb3
58 bb4:
59 predecessor blocks: bb1
60 - [12] Reassign mutate x$22_@4[8:15] = Array []
60 + [12] Reassign mutate x$22_@4:TFunction[8:15] = Array []
61 [13] Call mutate x$22_@4.push(read c$15)
62 [14] Goto bb3
63 bb3:
64 predecessor blocks: bb5 bb4
65 - [15] Const mutate $25_@5 = "div"
65 + [15] Const mutate $25_@5:TPrimitive = "div"
66 [16] Const mutate $26_@6 = "\n "
67 [17] Const mutate $27_@7 = "\n "
68 [18] Const mutate $28_@8 = "\n "
69 - [19] Const mutate $31_@9 = JSX <read $25_@5>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4}{read $28_@8}</read $25_@5>
69 + [19] Const mutate $31_@9 = JSX <read $25_@5:TPrimitive>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4:TFunction}{read $28_@8}</read $25_@5:TPrimitive>
70 [20] Return read $31_@9
71 scope0 [1:5]:
72 - dependency: read a$13
73 - dependency: read a$13
74 scope2 [6:7]:
75 - - dependency: read $17_@1
76 - - dependency: freeze x$16_@0
75 + - dependency: read $17_@1:TPrimitive
76 + - dependency: freeze x$16_@0:TFunction
77 scope4 [8:15]:
78 - dependency: read c$15
79 - dependency: read b$14
80 - dependency: read b$14
81 scope9 [19:20]:
82 - - dependency: read $25_@5
82 + - dependency: read $25_@5:TPrimitive
83 - dependency: read $26_@6
84 - dependency: read y$19_@2
85 - dependency: read $27_@7
86 - - dependency: freeze x$22_@4
86 + - dependency: freeze x$22_@4:TFunction
87 - dependency: read $28_@8
88 ```
89
@@ -96,36 +96,36 @@ function foo(
96 c,
97 ) {
98 scope @0 [1:5] deps=[read a$13, read a$13] {
99 - [1] Const mutate x$16_@0[1:5] = Array []
99 + [1] Const mutate x$16_@0:TFunction[1:5] = Array []
100 if (read a$13) {
101 [3] Call mutate x$16_@0.push(read a$13)
102 }
103 }
104 - [5] Const mutate $17_@1 = "div"
105 - scope @2 [6:7] deps=[read $17_@1, freeze x$16_@0] {
106 - [6] Const mutate y$19_@2 = JSX <read $17_@1>{freeze x$16_@0}</read $17_@1>
104 + [5] Const mutate $17_@1:TPrimitive = "div"
105 + scope @2 [6:7] deps=[read $17_@1:TPrimitive, freeze x$16_@0:TFunction] {
106 + [6] Const mutate y$19_@2 = JSX <read $17_@1:TPrimitive>{freeze x$16_@0:TFunction}</read $17_@1:TPrimitive>
107 }
108 - [7] Const mutate $20_@3 = 0
108 + [7] Const mutate $20_@3:TPrimitive = 0
109 scope @4 [8:15] deps=[read c$15, read b$14, read b$14] {
110 - [8] Let mutate x$22_@4[8:15] = undefined
110 + [8] Let mutate x$22_@4:TFunction[8:15] = undefined
111 switch (read b$14) {
112 - case read $20_@3: {
113 - [9] Reassign mutate x$22_@4[8:15] = Array []
112 + case read $20_@3:TPrimitive: {
113 + [9] Reassign mutate x$22_@4:TFunction[8:15] = Array []
114 [10] Call mutate x$22_@4.push(read b$14)
115 break bb3
116 }
117 default: {
118 - [12] Reassign mutate x$22_@4[8:15] = Array []
118 + [12] Reassign mutate x$22_@4:TFunction[8:15] = Array []
119 [13] Call mutate x$22_@4.push(read c$15)
120 }
121 }
122 }
123 - [15] Const mutate $25_@5 = "div"
123 + [15] Const mutate $25_@5:TPrimitive = "div"
124 [16] Const mutate $26_@6 = "\n "
125 [17] Const mutate $27_@7 = "\n "
126 [18] Const mutate $28_@8 = "\n "
127 - scope @9 [19:20] deps=[read $25_@5, read $26_@6, read y$19_@2, read $27_@7, freeze x$22_@4, read $28_@8] {
128 - [19] Const mutate $31_@9 = JSX <read $25_@5>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4}{read $28_@8}</read $25_@5>
127 + scope @9 [19:20] deps=[read $25_@5:TPrimitive, read $26_@6, read y$19_@2, read $27_@7, freeze x$22_@4:TFunction, read $28_@8] {
128 + [19] Const mutate $31_@9 = JSX <read $25_@5:TPrimitive>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4:TFunction}{read $28_@8}</read $25_@5:TPrimitive>
129 }
130 return read $31_@9
131 }
@@ -139,7 +139,7 @@ flowchart TB
139 %% Basic Blocks
140 subgraph bb0
141 bb0_instrs["
142 - [1] Const mutate x$16_@0[1:5] = Array []
142 + [1] Const mutate x$16_@0:TFunction[1:5] = Array []
143 "]
144 bb0_instrs --> bb0_terminal(["If (read a$13)"])
145 end
@@ -151,34 +151,34 @@ flowchart TB
151 end
152 subgraph bb1
153 bb1_instrs["
154 - [5] Const mutate $17_@1 = 'div'
155 - [6] Const mutate y$19_@2 = JSX <read $17_@1>{freeze x$16_@0}</read $17_@1>
156 - [7] Const mutate $20_@3 = 0
157 - [8] Let mutate x$22_@4[8:15] = undefined
154 + [5] Const mutate $17_@1:TPrimitive = 'div'
155 + [6] Const mutate y$19_@2 = JSX <read $17_@1:TPrimitive>{freeze x$16_@0:TFunction}</read $17_@1:TPrimitive>
156 + [7] Const mutate $20_@3:TPrimitive = 0
157 + [8] Let mutate x$22_@4:TFunction[8:15] = undefined
158 "]
159 bb1_instrs --> bb1_terminal(["Switch (read b$14)"])
160 end
161 subgraph bb5
162 bb5_instrs["
163 - [9] Reassign mutate x$22_@4[8:15] = Array []
163 + [9] Reassign mutate x$22_@4:TFunction[8:15] = Array []
164 [10] Call mutate x$22_@4.push(read b$14)
165 "]
166 bb5_instrs --> bb5_terminal(["Goto"])
167 end
168 subgraph bb4
169 bb4_instrs["
170 - [12] Reassign mutate x$22_@4[8:15] = Array []
170 + [12] Reassign mutate x$22_@4:TFunction[8:15] = Array []
171 [13] Call mutate x$22_@4.push(read c$15)
172 "]
173 bb4_instrs --> bb4_terminal(["Goto"])
174 end
175 subgraph bb3
176 bb3_instrs["
177 - [15] Const mutate $25_@5 = 'div'
177 + [15] Const mutate $25_@5:TPrimitive = 'div'
178 [16] Const mutate $26_@6 = '\n '
179 [17] Const mutate $27_@7 = '\n '
180 [18] Const mutate $28_@8 = '\n '
181 - [19] Const mutate $31_@9 = JSX <read $25_@5>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4}{read $28_@8}</read $25_@5>
181 + [19] Const mutate $31_@9 = JSX <read $25_@5:TPrimitive>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4:TFunction}{read $28_@8}</read $25_@5:TPrimitive>
182 "]
183 bb3_instrs --> bb3_terminal(["Return read $31_@9"])
184 end
@@ -187,7 +187,7 @@ flowchart TB
187 bb0_terminal -- "then" --> bb2
188 bb0_terminal -- "else" --> bb1
189 bb2_terminal --> bb1
190 - bb1_terminal -- "read $20_@3" --> bb5
190 + bb1_terminal -- "read $20_@3:TPrimitive" --> bb5
191 bb1_terminal -- "default" --> bb4
192 bb1_terminal -- "fallthrough" --> bb3
193 bb5_terminal --> bb3
compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md
+11 -11
@@ -21,13 +21,13 @@ function Component(props) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$7_@0[1:7] = Array []
24 + [1] Const mutate x$7_@0:TFunction[1:7] = Array []
25 [2] Call mutate x$7_@0.push(read props$6.p0)
26 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
26 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
27 [4] Const mutate x$9_@1 = Array []
28 [5] Const mutate _$10_@2 = JSX <read Component$0 x={freeze x$9_@1} ></read Component$0>
29 [6] Call mutate y$8_@0.push(read props$6.p1)
30 - [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
30 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0:TFunction} ></read Component$0>
31 [8] Return read $11_@3
32 scope0 [1:7]:
33 - dependency: read props$6.p0
@@ -38,7 +38,7 @@ scope2 [5:6]:
38 scope3 [7:8]:
39 - dependency: read Component$0
40 - dependency: read x$9_@1
41 - - dependency: freeze y$8_@0
41 + - dependency: freeze y$8_@0:TFunction
42 ```
43
44 ## Reactive Scopes
@@ -48,9 +48,9 @@ function Component(
48 props,
49 ) {
50 scope @0 [1:7] deps=[read props$6.p0] {
51 - [1] Const mutate x$7_@0[1:7] = Array []
51 + [1] Const mutate x$7_@0:TFunction[1:7] = Array []
52 [2] Call mutate x$7_@0.push(read props$6.p0)
53 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
53 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
54 scope @1 [4:5] deps=[] {
55 [4] Const mutate x$9_@1 = Array []
56 }
@@ -59,8 +59,8 @@ function Component(
59 }
60 [6] Call mutate y$8_@0.push(read props$6.p1)
61 }
62 - scope @3 [7:8] deps=[read Component$0, read x$9_@1, freeze y$8_@0] {
63 - [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
62 + scope @3 [7:8] deps=[read Component$0, read x$9_@1, freeze y$8_@0:TFunction] {
63 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0:TFunction} ></read Component$0>
64 }
65 return read $11_@3
66 }
@@ -74,13 +74,13 @@ flowchart TB
74 %% Basic Blocks
75 subgraph bb0
76 bb0_instrs["
77 - [1] Const mutate x$7_@0[1:7] = Array []
77 + [1] Const mutate x$7_@0:TFunction[1:7] = Array []
78 [2] Call mutate x$7_@0.push(read props$6.p0)
79 - [3] Const mutate y$8_@0[1:7] = read x$7_@0
79 + [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
80 [4] Const mutate x$9_@1 = Array []
81 [5] Const mutate _$10_@2 = JSX <read Component$0 x={freeze x$9_@1} ></read Component$0>
82 [6] Call mutate y$8_@0.push(read props$6.p1)
83 - [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
83 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0:TFunction} ></read Component$0>
84 "]
85 bb0_instrs --> bb0_terminal(["Return read $11_@3"])
86 end
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+42 -42
@@ -36,46 +36,46 @@ function Component(props) {
36
37 ```
38 bb0:
39 - [1] Const mutate x$7_@0 = undefined
40 - [2] Let mutate x$11_@1[2:18] = undefined
39 + [1] Const mutate x$7_@0:TPrimitive = undefined
40 + [2] Let mutate x$11_@1:TProp[2:18] = undefined
41 [2] If (read props$6.cond) then:bb2 else:bb10 fallthrough=bb1
42 bb2:
43 predecessor blocks: bb0
44 - [3] Const mutate $8_@2 = 2
45 - [4] Const mutate $9_@3 = 1
46 - [5] Const mutate $10_@4 = 0
44 + [3] Const mutate $8_@2:TPrimitive = 2
45 + [4] Const mutate $9_@3:TPrimitive = 1
46 + [5] Const mutate $10_@4:TPrimitive = 0
47 [6] Switch (read props$6.test)
48 - Case read $10_@4: bb8
49 - Case read $9_@3: bb6
50 - Case read $8_@2: bb4
48 + Case read $10_@4:TPrimitive: bb8
49 + Case read $9_@3:TPrimitive: bb6
50 + Case read $8_@2:TPrimitive: bb4
51 Default: bb4
52 Fallthrough: bb1
53 bb8:
54 predecessor blocks: bb2
55 - [7] Reassign mutate x$11_@1[2:18] = read props$6.v0
55 + [7] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v0
56 [8] Goto bb1
57 bb6:
58 predecessor blocks: bb2
59 - [9] Reassign mutate x$11_@1[2:18] = read props$6.v1
59 + [9] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v1
60 [10] Goto bb1
61 bb4:
62 predecessor blocks: bb2
63 - [11] Reassign mutate x$11_@1[2:18] = read props$6.v2
63 + [11] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v2
64 [12] Goto bb1
65 bb10:
66 predecessor blocks: bb0
67 [13] If (read props$6.cond2) then:bb12 else:bb13 fallthrough=bb1
68 bb12:
69 predecessor blocks: bb10
70 - [14] Reassign mutate x$11_@1[2:18] = read props$6.b
70 + [14] Reassign mutate x$11_@1:TProp[2:18] = read props$6.b
71 [15] Goto bb1
72 bb13:
73 predecessor blocks: bb10
74 - [16] Reassign mutate x$11_@1[2:18] = read props$6.c
74 + [16] Reassign mutate x$11_@1:TProp[2:18] = read props$6.c
75 [17] Goto bb1
76 bb1:
77 predecessor blocks: bb8 bb6 bb4 bb12 bb13
78 - [18] read x$11_@1
78 + [18] read x$11_@1:TProp
79 [19] Return
80 scope1 [2:18]:
81 - dependency: read props$6.v2
@@ -94,37 +94,37 @@ scope1 [2:18]:
94 function Component(
95 props,
96 ) {
97 - [1] Const mutate x$7_@0 = undefined
97 + [1] Const mutate x$7_@0:TPrimitive = undefined
98 scope @1 [2:18] deps=[read props$6.v2, read props$6.v1, read props$6.v0, read props$6.test, read props$6.b, read props$6.c, read props$6.cond2, read props$6.cond] {
99 - [2] Let mutate x$11_@1[2:18] = undefined
99 + [2] Let mutate x$11_@1:TProp[2:18] = undefined
100 if (read props$6.cond) {
101 - [3] Const mutate $8_@2 = 2
102 - [4] Const mutate $9_@3 = 1
103 - [5] Const mutate $10_@4 = 0
101 + [3] Const mutate $8_@2:TPrimitive = 2
102 + [4] Const mutate $9_@3:TPrimitive = 1
103 + [5] Const mutate $10_@4:TPrimitive = 0
104 switch (read props$6.test) {
105 - case read $10_@4: {
106 - [7] Reassign mutate x$11_@1[2:18] = read props$6.v0
105 + case read $10_@4:TPrimitive: {
106 + [7] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v0
107 break bb1
108 }
109 - case read $9_@3: {
110 - [9] Reassign mutate x$11_@1[2:18] = read props$6.v1
109 + case read $9_@3:TPrimitive: {
110 + [9] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v1
111 break bb1
112 }
113 - case read $8_@2: {
113 + case read $8_@2:TPrimitive: {
114 }
115 default: {
116 - [11] Reassign mutate x$11_@1[2:18] = read props$6.v2
116 + [11] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v2
117 }
118 }
119 } else {
120 if (read props$6.cond2) {
121 - [14] Reassign mutate x$11_@1[2:18] = read props$6.b
121 + [14] Reassign mutate x$11_@1:TProp[2:18] = read props$6.b
122 } else {
123 - [16] Reassign mutate x$11_@1[2:18] = read props$6.c
123 + [16] Reassign mutate x$11_@1:TProp[2:18] = read props$6.c
124 }
125 }
126 }
127 - [18] read x$11_@1
127 + [18] read x$11_@1:TProp
128 return
129 }
130
@@ -137,34 +137,34 @@ flowchart TB
137 %% Basic Blocks
138 subgraph bb0
139 bb0_instrs["
140 - [1] Const mutate x$7_@0 = undefined
141 - [2] Let mutate x$11_@1[2:18] = undefined
140 + [1] Const mutate x$7_@0:TPrimitive = undefined
141 + [2] Let mutate x$11_@1:TProp[2:18] = undefined
142 "]
143 bb0_instrs --> bb0_terminal(["If (read props$6.cond)"])
144 end
145 subgraph bb2
146 bb2_instrs["
147 - [3] Const mutate $8_@2 = 2
148 - [4] Const mutate $9_@3 = 1
149 - [5] Const mutate $10_@4 = 0
147 + [3] Const mutate $8_@2:TPrimitive = 2
148 + [4] Const mutate $9_@3:TPrimitive = 1
149 + [5] Const mutate $10_@4:TPrimitive = 0
150 "]
151 bb2_instrs --> bb2_terminal(["Switch (read props$6.test)"])
152 end
153 subgraph bb8
154 bb8_instrs["
155 - [7] Reassign mutate x$11_@1[2:18] = read props$6.v0
155 + [7] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v0
156 "]
157 bb8_instrs --> bb8_terminal(["Goto"])
158 end
159 subgraph bb6
160 bb6_instrs["
161 - [9] Reassign mutate x$11_@1[2:18] = read props$6.v1
161 + [9] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v1
162 "]
163 bb6_instrs --> bb6_terminal(["Goto"])
164 end
165 subgraph bb4
166 bb4_instrs["
167 - [11] Reassign mutate x$11_@1[2:18] = read props$6.v2
167 + [11] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v2
168 "]
169 bb4_instrs --> bb4_terminal(["Goto"])
170 end
@@ -173,19 +173,19 @@ flowchart TB
173 end
174 subgraph bb12
175 bb12_instrs["
176 - [14] Reassign mutate x$11_@1[2:18] = read props$6.b
176 + [14] Reassign mutate x$11_@1:TProp[2:18] = read props$6.b
177 "]
178 bb12_instrs --> bb12_terminal(["Goto"])
179 end
180 subgraph bb13
181 bb13_instrs["
182 - [16] Reassign mutate x$11_@1[2:18] = read props$6.c
182 + [16] Reassign mutate x$11_@1:TProp[2:18] = read props$6.c
183 "]
184 bb13_instrs --> bb13_terminal(["Goto"])
185 end
186 subgraph bb1
187 bb1_instrs["
188 - [18] read x$11_@1
188 + [18] read x$11_@1:TProp
189 "]
190 bb1_instrs --> bb1_terminal(["Return"])
191 end
@@ -194,9 +194,9 @@ flowchart TB
194 bb0_terminal -- "then" --> bb2
195 bb0_terminal -- "else" --> bb10
196 bb0_terminal -- "fallthrough" --> bb1
197 - bb2_terminal -- "read $10_@4" --> bb8
198 - bb2_terminal -- "read $9_@3" --> bb6
199 - bb2_terminal -- "read $8_@2" --> bb4
197 + bb2_terminal -- "read $10_@4:TPrimitive" --> bb8
198 + bb2_terminal -- "read $9_@3:TPrimitive" --> bb6
199 + bb2_terminal -- "read $8_@2:TPrimitive" --> bb4
200 bb2_terminal -- "default" --> bb4
201 bb2_terminal -- "fallthrough" --> bb1
202 bb8_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md
+24 -24
@@ -57,14 +57,14 @@ function mutate$0() {}
57
58 ```
59 bb0:
60 - [1] Const mutate a$5_@0 = Object { }
61 - [2] Const mutate b$6_@1[2:8] = Object { }
62 - [3] Const mutate c$7_@1[2:8] = Object { }
63 - [4] Const mutate a$8_@1[2:8] = read b$6_@1
64 - [5] Const mutate b$9_@1[2:8] = read c$7_@1
65 - [6] Const mutate c$10_@1[2:8] = read a$8_@1
66 - [7] Call mutate mutate$4(mutate a$8_@1, mutate b$9_@1)
67 - [8] Return freeze c$10_@1
60 + [1] Const mutate a$5_@0:TObject = Object { }
61 + [2] Const mutate b$6_@1:TObject[2:8] = Object { }
62 + [3] Const mutate c$7_@1:TObject[2:8] = Object { }
63 + [4] Const mutate a$8_@1:TObject[2:8] = read b$6_@1:TObject
64 + [5] Const mutate b$9_@1:TObject[2:8] = read c$7_@1:TObject
65 + [6] Const mutate c$10_@1:TObject[2:8] = read a$8_@1:TObject
66 + [7] Call mutate mutate$4:TFunction(mutate a$8_@1:TObject, mutate b$9_@1:TObject)
67 + [8] Return freeze c$10_@1:TObject
68
69 ```
70
@@ -74,17 +74,17 @@ bb0:
74 function foo(
75 ) {
76 scope @0 [1:2] deps=[] {
77 - [1] Const mutate a$5_@0 = Object { }
77 + [1] Const mutate a$5_@0:TObject = Object { }
78 }
79 scope @1 [2:8] deps=[] {
80 - [2] Const mutate b$6_@1[2:8] = Object { }
81 - [3] Const mutate c$7_@1[2:8] = Object { }
82 - [4] Const mutate a$8_@1[2:8] = read b$6_@1
83 - [5] Const mutate b$9_@1[2:8] = read c$7_@1
84 - [6] Const mutate c$10_@1[2:8] = read a$8_@1
85 - [7] Call mutate mutate$4(mutate a$8_@1, mutate b$9_@1)
80 + [2] Const mutate b$6_@1:TObject[2:8] = Object { }
81 + [3] Const mutate c$7_@1:TObject[2:8] = Object { }
82 + [4] Const mutate a$8_@1:TObject[2:8] = read b$6_@1:TObject
83 + [5] Const mutate b$9_@1:TObject[2:8] = read c$7_@1:TObject
84 + [6] Const mutate c$10_@1:TObject[2:8] = read a$8_@1:TObject
85 + [7] Call mutate mutate$4:TFunction(mutate a$8_@1:TObject, mutate b$9_@1:TObject)
86 }
87 - return freeze c$10_@1
87 + return freeze c$10_@1:TObject
88 }
89
90 ```
@@ -96,15 +96,15 @@ flowchart TB
96 %% Basic Blocks
97 subgraph bb0
98 bb0_instrs["
99 - [1] Const mutate a$5_@0 = Object { }
100 - [2] Const mutate b$6_@1[2:8] = Object { }
101 - [3] Const mutate c$7_@1[2:8] = Object { }
102 - [4] Const mutate a$8_@1[2:8] = read b$6_@1
103 - [5] Const mutate b$9_@1[2:8] = read c$7_@1
104 - [6] Const mutate c$10_@1[2:8] = read a$8_@1
105 - [7] Call mutate mutate$4(mutate a$8_@1, mutate b$9_@1)
99 + [1] Const mutate a$5_@0:TObject = Object { }
100 + [2] Const mutate b$6_@1:TObject[2:8] = Object { }
101 + [3] Const mutate c$7_@1:TObject[2:8] = Object { }
102 + [4] Const mutate a$8_@1:TObject[2:8] = read b$6_@1:TObject
103 + [5] Const mutate b$9_@1:TObject[2:8] = read c$7_@1:TObject
104 + [6] Const mutate c$10_@1:TObject[2:8] = read a$8_@1:TObject
105 + [7] Call mutate mutate$4:TFunction(mutate a$8_@1:TObject, mutate b$9_@1:TObject)
106 "]
107 - bb0_instrs --> bb0_terminal(["Return freeze c$10_@1"])
107 + bb0_instrs --> bb0_terminal(["Return freeze c$10_@1:TObject"])
108 end
109
110 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/simple.expect.md
+23 -23
@@ -18,24 +18,24 @@ bb0:
18 [1] If (read x$8) then:bb2 else:bb1 fallthrough=bb1
19 bb2:
20 predecessor blocks: bb0
21 - [2] Const mutate $10_@0 = false
22 - [3] Const mutate $11_@1 = Call read foo$0(read $10_@0, read y$9)
21 + [2] Const mutate $10_@0:TPrimitive = false
22 + [3] Const mutate $11_@1 = Call read foo$0:TFunction(read $10_@0:TPrimitive, read y$9:TPrimitive)
23 [4] Return freeze $11_@1
24 bb1:
25 predecessor blocks: bb0
26 - [5] Const mutate $12_@2 = 10
27 - [6] Const mutate $13_@3 = Binary read y$9 * read $12_@2
28 - [7] Const mutate $14_@4 = Array [read $13_@3]
26 + [5] Const mutate $12_@2:TPrimitive = 10
27 + [6] Const mutate $13_@3:TPrimitive = Binary read y$9:TPrimitive * read $12_@2:TPrimitive
28 + [7] Const mutate $14_@4 = Array [read $13_@3:TPrimitive]
29 [8] Return freeze $14_@4
30 scope1 [3:4]:
31 - - dependency: read foo$0
32 - - dependency: read $10_@0
33 - - dependency: read y$9
31 + - dependency: read foo$0:TFunction
32 + - dependency: read $10_@0:TPrimitive
33 + - dependency: read y$9:TPrimitive
34 scope3 [6:7]:
35 - - dependency: read y$9
36 - - dependency: read $12_@2
35 + - dependency: read y$9:TPrimitive
36 + - dependency: read $12_@2:TPrimitive
37 scope4 [7:8]:
38 - - dependency: read $13_@3
38 + - dependency: read $13_@3:TPrimitive
39 ```
40
41 ## Reactive Scopes
@@ -46,16 +46,16 @@ function foo(
46 y,
47 ) {
48 if (read x$8) {
49 - [2] Const mutate $10_@0 = false
50 - scope @1 [3:4] deps=[read foo$0, read $10_@0, read y$9] {
51 - [3] Const mutate $11_@1 = Call read foo$0(read $10_@0, read y$9)
49 + [2] Const mutate $10_@0:TPrimitive = false
50 + scope @1 [3:4] deps=[read foo$0:TFunction, read $10_@0:TPrimitive, read y$9:TPrimitive] {
51 + [3] Const mutate $11_@1 = Call read foo$0:TFunction(read $10_@0:TPrimitive, read y$9:TPrimitive)
52 }
53 return freeze $11_@1
54 }
55 - [5] Const mutate $12_@2 = 10
56 - [6] Const mutate $13_@3 = Binary read y$9 * read $12_@2
57 - scope @4 [7:8] deps=[read $13_@3] {
58 - [7] Const mutate $14_@4 = Array [read $13_@3]
55 + [5] Const mutate $12_@2:TPrimitive = 10
56 + [6] Const mutate $13_@3:TPrimitive = Binary read y$9:TPrimitive * read $12_@2:TPrimitive
57 + scope @4 [7:8] deps=[read $13_@3:TPrimitive] {
58 + [7] Const mutate $14_@4 = Array [read $13_@3:TPrimitive]
59 }
60 return freeze $14_@4
61 }
@@ -72,16 +72,16 @@ flowchart TB
72 end
73 subgraph bb2
74 bb2_instrs["
75 - [2] Const mutate $10_@0 = false
76 - [3] Const mutate $11_@1 = Call read foo$0(read $10_@0, read y$9)
75 + [2] Const mutate $10_@0:TPrimitive = false
76 + [3] Const mutate $11_@1 = Call read foo$0:TFunction(read $10_@0:TPrimitive, read y$9:TPrimitive)
77 "]
78 bb2_instrs --> bb2_terminal(["Return freeze $11_@1"])
79 end
80 subgraph bb1
81 bb1_instrs["
82 - [5] Const mutate $12_@2 = 10
83 - [6] Const mutate $13_@3 = Binary read y$9 * read $12_@2
84 - [7] Const mutate $14_@4 = Array [read $13_@3]
82 + [5] Const mutate $12_@2:TPrimitive = 10
83 + [6] Const mutate $13_@3:TPrimitive = Binary read y$9:TPrimitive * read $12_@2:TPrimitive
84 + [7] Const mutate $14_@4 = Array [read $13_@3:TPrimitive]
85 "]
86 bb1_instrs --> bb1_terminal(["Return freeze $14_@4"])
87 end
compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md
+12 -12
@@ -15,13 +15,13 @@ function Component(props) {
15
16 ```
17 bb0:
18 - [1] Const mutate a$6_@0 = 1
19 - [2] Const mutate b$7_@1 = 2
20 - [3] Const mutate x$8_@2 = Array [read a$6_@0, read b$7_@1]
18 + [1] Const mutate a$6_@0:TPrimitive = 1
19 + [2] Const mutate b$7_@1:TPrimitive = 2
20 + [3] Const mutate x$8_@2 = Array [read a$6_@0:TPrimitive, read b$7_@1:TPrimitive]
21 [4] Return freeze x$8_@2
22 scope2 [3:4]:
23 - - dependency: read a$6_@0
24 - - dependency: read b$7_@1
23 + - dependency: read a$6_@0:TPrimitive
24 + - dependency: read b$7_@1:TPrimitive
25 ```
26
27 ## Reactive Scopes
@@ -30,10 +30,10 @@ scope2 [3:4]:
30 function Component(
31 props,
32 ) {
33 - [1] Const mutate a$6_@0 = 1
34 - [2] Const mutate b$7_@1 = 2
35 - scope @2 [3:4] deps=[read a$6_@0, read b$7_@1] {
36 - [3] Const mutate x$8_@2 = Array [read a$6_@0, read b$7_@1]
33 + [1] Const mutate a$6_@0:TPrimitive = 1
34 + [2] Const mutate b$7_@1:TPrimitive = 2
35 + scope @2 [3:4] deps=[read a$6_@0:TPrimitive, read b$7_@1:TPrimitive] {
36 + [3] Const mutate x$8_@2 = Array [read a$6_@0:TPrimitive, read b$7_@1:TPrimitive]
37 }
38 return freeze x$8_@2
39 }
@@ -47,9 +47,9 @@ flowchart TB
47 %% Basic Blocks
48 subgraph bb0
49 bb0_instrs["
50 - [1] Const mutate a$6_@0 = 1
51 - [2] Const mutate b$7_@1 = 2
52 - [3] Const mutate x$8_@2 = Array [read a$6_@0, read b$7_@1]
50 + [1] Const mutate a$6_@0:TPrimitive = 1
51 + [2] Const mutate b$7_@1:TPrimitive = 2
52 + [3] Const mutate x$8_@2 = Array [read a$6_@0:TPrimitive, read b$7_@1:TPrimitive]
53 "]
54 bb0_instrs --> bb0_terminal(["Return freeze x$8_@2"])
55 end
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md
+29 -29
@@ -60,27 +60,27 @@ function foo$0() {}
60 ```
61 bb0:
62 [1] Const mutate a$11_@0[1:10] = Array []
63 - [2] Const mutate b$12_@0[1:10] = Object { }
64 - [3] Call mutate foo$4(mutate a$11_@0, mutate b$12_@0)
65 - [4] Const mutate $13_@1 = Call mutate foo$4()
63 + [2] Const mutate b$12_@0:TObject[1:10] = Object { }
64 + [3] Call mutate foo$4:TFunction(mutate a$11_@0, mutate b$12_@0:TObject)
65 + [4] Const mutate $13_@1 = Call mutate foo$4:TFunction()
66 [5] If (read $13_@1) then:bb2 else:bb1 fallthrough=bb1
67 bb2:
68 predecessor blocks: bb0
69 - [6] Const mutate $14_@2 = "div"
70 - [7] Const mutate _$15_@3 = JSX <read $14_@2 a={freeze a$11_@0} ></read $14_@2>
69 + [6] Const mutate $14_@2:TPrimitive = "div"
70 + [7] Const mutate _$15_@3 = JSX <read $14_@2:TPrimitive a={freeze a$11_@0} ></read $14_@2:TPrimitive>
71 [8] Goto bb1
72 bb1:
73 predecessor blocks: bb2 bb0
74 - [9] Call mutate foo$4(read a$11_@0, mutate b$12_@0)
75 - [10] Const mutate $19_@4 = "div"
76 - [11] Const mutate $20_@5 = JSX <read $19_@4 a={freeze a$11_@0} b={freeze b$12_@0} ></read $19_@4>
74 + [9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject)
75 + [10] Const mutate $19_@4:TPrimitive = "div"
76 + [11] Const mutate $20_@5 = JSX <read $19_@4:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19_@4:TPrimitive>
77 [12] Return read $20_@5
78 scope3 [7:8]:
79 - - dependency: read $14_@2
79 + - dependency: read $14_@2:TPrimitive
80 scope5 [11:12]:
81 - - dependency: read $19_@4
81 + - dependency: read $19_@4:TPrimitive
82 - dependency: freeze a$11_@0
83 - - dependency: freeze b$12_@0
83 + - dependency: freeze b$12_@0:TObject
84 ```
85
86 ## Reactive Scopes
@@ -91,22 +91,22 @@ function Component(
91 ) {
92 scope @0 [1:10] deps=[] {
93 [1] Const mutate a$11_@0[1:10] = Array []
94 - [2] Const mutate b$12_@0[1:10] = Object { }
95 - [3] Call mutate foo$4(mutate a$11_@0, mutate b$12_@0)
94 + [2] Const mutate b$12_@0:TObject[1:10] = Object { }
95 + [3] Call mutate foo$4:TFunction(mutate a$11_@0, mutate b$12_@0:TObject)
96 scope @1 [4:5] deps=[] {
97 - [4] Const mutate $13_@1 = Call mutate foo$4()
97 + [4] Const mutate $13_@1 = Call mutate foo$4:TFunction()
98 }
99 if (read $13_@1) {
100 - [6] Const mutate $14_@2 = "div"
101 - scope @3 [7:8] deps=[read $14_@2] {
102 - [7] Const mutate _$15_@3 = JSX <read $14_@2 a={freeze a$11_@0} ></read $14_@2>
100 + [6] Const mutate $14_@2:TPrimitive = "div"
101 + scope @3 [7:8] deps=[read $14_@2:TPrimitive] {
102 + [7] Const mutate _$15_@3 = JSX <read $14_@2:TPrimitive a={freeze a$11_@0} ></read $14_@2:TPrimitive>
103 }
104 }
105 - [9] Call mutate foo$4(read a$11_@0, mutate b$12_@0)
105 + [9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject)
106 }
107 - [10] Const mutate $19_@4 = "div"
108 - scope @5 [11:12] deps=[read $19_@4, freeze a$11_@0, freeze b$12_@0] {
109 - [11] Const mutate $20_@5 = JSX <read $19_@4 a={freeze a$11_@0} b={freeze b$12_@0} ></read $19_@4>
107 + [10] Const mutate $19_@4:TPrimitive = "div"
108 + scope @5 [11:12] deps=[read $19_@4:TPrimitive, freeze a$11_@0, freeze b$12_@0:TObject] {
109 + [11] Const mutate $20_@5 = JSX <read $19_@4:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19_@4:TPrimitive>
110 }
111 return read $20_@5
112 }
@@ -121,24 +121,24 @@ flowchart TB
121 subgraph bb0
122 bb0_instrs["
123 [1] Const mutate a$11_@0[1:10] = Array []
124 - [2] Const mutate b$12_@0[1:10] = Object { }
125 - [3] Call mutate foo$4(mutate a$11_@0, mutate b$12_@0)
126 - [4] Const mutate $13_@1 = Call mutate foo$4()
124 + [2] Const mutate b$12_@0:TObject[1:10] = Object { }
125 + [3] Call mutate foo$4:TFunction(mutate a$11_@0, mutate b$12_@0:TObject)
126 + [4] Const mutate $13_@1 = Call mutate foo$4:TFunction()
127 "]
128 bb0_instrs --> bb0_terminal(["If (read $13_@1)"])
129 end
130 subgraph bb2
131 bb2_instrs["
132 - [6] Const mutate $14_@2 = 'div'
133 - [7] Const mutate _$15_@3 = JSX <read $14_@2 a={freeze a$11_@0} ></read $14_@2>
132 + [6] Const mutate $14_@2:TPrimitive = 'div'
133 + [7] Const mutate _$15_@3 = JSX <read $14_@2:TPrimitive a={freeze a$11_@0} ></read $14_@2:TPrimitive>
134 "]
135 bb2_instrs --> bb2_terminal(["Goto"])
136 end
137 subgraph bb1
138 bb1_instrs["
139 - [9] Call mutate foo$4(read a$11_@0, mutate b$12_@0)
140 - [10] Const mutate $19_@4 = 'div'
141 - [11] Const mutate $20_@5 = JSX <read $19_@4 a={freeze a$11_@0} b={freeze b$12_@0} ></read $19_@4>
139 + [9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject)
140 + [10] Const mutate $19_@4:TPrimitive = 'div'
141 + [11] Const mutate $20_@5 = JSX <read $19_@4:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19_@4:TPrimitive>
142 "]
143 bb1_instrs --> bb1_terminal(["Return read $20_@5"])
144 end
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+26 -26
@@ -57,20 +57,20 @@ function foo$0() {}
57 ```
58 bb0:
59 [1] Const mutate a$10_@0[1:7] = Array []
60 - [2] Const mutate b$11_@0[1:7] = Object { }
61 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
62 - [4] Const mutate $12_@1 = "div"
63 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
64 - [6] Call mutate foo$4(read a$10_@0, mutate b$11_@0)
65 - [7] Const mutate $14_@3 = "div"
66 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
60 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
61 + [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
62 + [4] Const mutate $12_@1:TPrimitive = "div"
63 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
64 + [6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject)
65 + [7] Const mutate $14_@3:TPrimitive = "div"
66 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
67 [9] Return read $15_@4
68 scope2 [5:6]:
69 - - dependency: read $12_@1
69 + - dependency: read $12_@1:TPrimitive
70 scope4 [8:9]:
71 - - dependency: read $14_@3
71 + - dependency: read $14_@3:TPrimitive
72 - dependency: read a$10_@0
73 - - dependency: freeze b$11_@0
73 + - dependency: freeze b$11_@0:TObject
74 ```
75
76 ## Reactive Scopes
@@ -81,17 +81,17 @@ function Component(
81 ) {
82 scope @0 [1:7] deps=[] {
83 [1] Const mutate a$10_@0[1:7] = Array []
84 - [2] Const mutate b$11_@0[1:7] = Object { }
85 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
86 - [4] Const mutate $12_@1 = "div"
87 - scope @2 [5:6] deps=[read $12_@1] {
88 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
84 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
85 + [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
86 + [4] Const mutate $12_@1:TPrimitive = "div"
87 + scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
88 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
89 }
90 - [6] Call mutate foo$4(read a$10_@0, mutate b$11_@0)
90 + [6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject)
91 }
92 - [7] Const mutate $14_@3 = "div"
93 - scope @4 [8:9] deps=[read $14_@3, read a$10_@0, freeze b$11_@0] {
94 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
92 + [7] Const mutate $14_@3:TPrimitive = "div"
93 + scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
94 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
95 }
96 return read $15_@4
97 }
@@ -106,13 +106,13 @@ flowchart TB
106 subgraph bb0
107 bb0_instrs["
108 [1] Const mutate a$10_@0[1:7] = Array []
109 - [2] Const mutate b$11_@0[1:7] = Object { }
110 - [3] Call mutate foo$4(mutate a$10_@0, mutate b$11_@0)
111 - [4] Const mutate $12_@1 = 'div'
112 - [5] Const mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
113 - [6] Call mutate foo$4(read a$10_@0, mutate b$11_@0)
114 - [7] Const mutate $14_@3 = 'div'
115 - [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
109 + [2] Const mutate b$11_@0:TObject[1:7] = Object { }
110 + [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
111 + [4] Const mutate $12_@1:TPrimitive = 'div'
112 + [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
113 + [6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject)
114 + [7] Const mutate $14_@3:TPrimitive = 'div'
115 + [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
116 "]
117 bb0_instrs --> bb0_terminal(["Return read $15_@4"])
118 end
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+38 -38
@@ -21,36 +21,36 @@ function foo() {
21
22 ```
23 bb0:
24 - [1] Let mutate x$7_@0[1:13] = 1
25 - [2] Const mutate y$8_@1 = 2
26 - [3] Const mutate $9_@2 = 2
27 - [4] Const mutate $10_@3 = Binary read y$8_@1 === read $9_@2
28 - [5] If (read $10_@3) then:bb2 else:bb1 fallthrough=bb1
24 + [1] Let mutate x$7_@0:TPrimitive[1:13] = 1
25 + [2] Const mutate y$8_@1:TPrimitive = 2
26 + [3] Const mutate $9_@2:TPrimitive = 2
27 + [4] Const mutate $10_@3:TPrimitive = Binary read y$8_@1:TPrimitive === read $9_@2:TPrimitive
28 + [5] If (read $10_@3:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
29 bb2:
30 predecessor blocks: bb0
31 - [6] Reassign mutate x$7_@0[1:13] = 3
31 + [6] Reassign mutate x$7_@0:TPrimitive[1:13] = 3
32 [7] Goto bb1
33 bb1:
34 predecessor blocks: bb2 bb0
35 - [8] Const mutate $12_@4 = 3
36 - [9] Const mutate $14_@5 = Binary read y$8_@1 === read $12_@4
37 - [10] If (read $14_@5) then:bb4 else:bb3 fallthrough=bb3
35 + [8] Const mutate $12_@4:TPrimitive = 3
36 + [9] Const mutate $14_@5:TPrimitive = Binary read y$8_@1:TPrimitive === read $12_@4:TPrimitive
37 + [10] If (read $14_@5:TPrimitive) then:bb4 else:bb3 fallthrough=bb3
38 bb4:
39 predecessor blocks: bb1
40 - [11] Reassign mutate x$7_@0[1:13] = 5
40 + [11] Reassign mutate x$7_@0:TPrimitive[1:13] = 5
41 [12] Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
44 - [13] Const mutate y$18_@6 = read x$7_@0
44 + [13] Const mutate y$18_@6 = read x$7_@0:TPrimitive
45 [14] Return
46 scope3 [4:5]:
47 - - dependency: read y$8_@1
48 - - dependency: read $9_@2
47 + - dependency: read y$8_@1:TPrimitive
48 + - dependency: read $9_@2:TPrimitive
49 scope5 [9:10]:
50 - - dependency: read y$8_@1
51 - - dependency: read $12_@4
50 + - dependency: read y$8_@1:TPrimitive
51 + - dependency: read $12_@4:TPrimitive
52 scope6 [13:14]:
53 - - dependency: read x$7_@0
53 + - dependency: read x$7_@0:TPrimitive
54 ```
55
56 ## Reactive Scopes
@@ -59,20 +59,20 @@ scope6 [13:14]:
59 function foo(
60 ) {
61 scope @0 [1:13] deps=[] {
62 - [1] Let mutate x$7_@0[1:13] = 1
63 - [2] Const mutate y$8_@1 = 2
64 - [3] Const mutate $9_@2 = 2
65 - [4] Const mutate $10_@3 = Binary read y$8_@1 === read $9_@2
66 - if (read $10_@3) {
67 - [6] Reassign mutate x$7_@0[1:13] = 3
62 + [1] Let mutate x$7_@0:TPrimitive[1:13] = 1
63 + [2] Const mutate y$8_@1:TPrimitive = 2
64 + [3] Const mutate $9_@2:TPrimitive = 2
65 + [4] Const mutate $10_@3:TPrimitive = Binary read y$8_@1:TPrimitive === read $9_@2:TPrimitive
66 + if (read $10_@3:TPrimitive) {
67 + [6] Reassign mutate x$7_@0:TPrimitive[1:13] = 3
68 }
69 - [8] Const mutate $12_@4 = 3
70 - [9] Const mutate $14_@5 = Binary read y$8_@1 === read $12_@4
71 - if (read $14_@5) {
72 - [11] Reassign mutate x$7_@0[1:13] = 5
69 + [8] Const mutate $12_@4:TPrimitive = 3
70 + [9] Const mutate $14_@5:TPrimitive = Binary read y$8_@1:TPrimitive === read $12_@4:TPrimitive
71 + if (read $14_@5:TPrimitive) {
72 + [11] Reassign mutate x$7_@0:TPrimitive[1:13] = 5
73 }
74 }
75 - [13] Const mutate y$18_@6 = read x$7_@0
75 + [13] Const mutate y$18_@6 = read x$7_@0:TPrimitive
76 return
77 }
78
@@ -85,35 +85,35 @@ flowchart TB
85 %% Basic Blocks
86 subgraph bb0
87 bb0_instrs["
88 - [1] Let mutate x$7_@0[1:13] = 1
89 - [2] Const mutate y$8_@1 = 2
90 - [3] Const mutate $9_@2 = 2
91 - [4] Const mutate $10_@3 = Binary read y$8_@1 === read $9_@2
88 + [1] Let mutate x$7_@0:TPrimitive[1:13] = 1
89 + [2] Const mutate y$8_@1:TPrimitive = 2
90 + [3] Const mutate $9_@2:TPrimitive = 2
91 + [4] Const mutate $10_@3:TPrimitive = Binary read y$8_@1:TPrimitive === read $9_@2:TPrimitive
92 "]
93 - bb0_instrs --> bb0_terminal(["If (read $10_@3)"])
93 + bb0_instrs --> bb0_terminal(["If (read $10_@3:TPrimitive)"])
94 end
95 subgraph bb2
96 bb2_instrs["
97 - [6] Reassign mutate x$7_@0[1:13] = 3
97 + [6] Reassign mutate x$7_@0:TPrimitive[1:13] = 3
98 "]
99 bb2_instrs --> bb2_terminal(["Goto"])
100 end
101 subgraph bb1
102 bb1_instrs["
103 - [8] Const mutate $12_@4 = 3
104 - [9] Const mutate $14_@5 = Binary read y$8_@1 === read $12_@4
103 + [8] Const mutate $12_@4:TPrimitive = 3
104 + [9] Const mutate $14_@5:TPrimitive = Binary read y$8_@1:TPrimitive === read $12_@4:TPrimitive
105 "]
106 - bb1_instrs --> bb1_terminal(["If (read $14_@5)"])
106 + bb1_instrs --> bb1_terminal(["If (read $14_@5:TPrimitive)"])
107 end
108 subgraph bb4
109 bb4_instrs["
110 - [11] Reassign mutate x$7_@0[1:13] = 5
110 + [11] Reassign mutate x$7_@0:TPrimitive[1:13] = 5
111 "]
112 bb4_instrs --> bb4_terminal(["Goto"])
113 end
114 subgraph bb3
115 bb3_instrs["
116 - [13] Const mutate y$18_@6 = read x$7_@0
116 + [13] Const mutate y$18_@6 = read x$7_@0:TPrimitive
117 "]
118 bb3_instrs --> bb3_terminal(["Return"])
119 end
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+24 -24
@@ -18,24 +18,24 @@ function foo() {
18
19 ```
20 bb0:
21 - [1] Let mutate x$5_@0[1:8] = 1
22 - [2] Const mutate y$6_@1 = 2
23 - [3] Const mutate $7_@2 = 2
24 - [4] Const mutate $8_@3 = Binary read y$6_@1 === read $7_@2
25 - [5] If (read $8_@3) then:bb2 else:bb1 fallthrough=bb1
21 + [1] Let mutate x$5_@0:TPrimitive[1:8] = 1
22 + [2] Const mutate y$6_@1:TPrimitive = 2
23 + [3] Const mutate $7_@2:TPrimitive = 2
24 + [4] Const mutate $8_@3:TPrimitive = Binary read y$6_@1:TPrimitive === read $7_@2:TPrimitive
25 + [5] If (read $8_@3:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [6] Reassign mutate x$5_@0[1:8] = 3
28 + [6] Reassign mutate x$5_@0:TPrimitive[1:8] = 3
29 [7] Goto bb1
30 bb1:
31 predecessor blocks: bb2 bb0
32 - [8] Const mutate y$11_@4 = read x$5_@0
32 + [8] Const mutate y$11_@4 = read x$5_@0:TPrimitive
33 [9] Return
34 scope3 [4:5]:
35 - - dependency: read y$6_@1
36 - - dependency: read $7_@2
35 + - dependency: read y$6_@1:TPrimitive
36 + - dependency: read $7_@2:TPrimitive
37 scope4 [8:9]:
38 - - dependency: read x$5_@0
38 + - dependency: read x$5_@0:TPrimitive
39 ```
40
41 ## Reactive Scopes
@@ -44,15 +44,15 @@ scope4 [8:9]:
44 function foo(
45 ) {
46 scope @0 [1:8] deps=[] {
47 - [1] Let mutate x$5_@0[1:8] = 1
48 - [2] Const mutate y$6_@1 = 2
49 - [3] Const mutate $7_@2 = 2
50 - [4] Const mutate $8_@3 = Binary read y$6_@1 === read $7_@2
51 - if (read $8_@3) {
52 - [6] Reassign mutate x$5_@0[1:8] = 3
47 + [1] Let mutate x$5_@0:TPrimitive[1:8] = 1
48 + [2] Const mutate y$6_@1:TPrimitive = 2
49 + [3] Const mutate $7_@2:TPrimitive = 2
50 + [4] Const mutate $8_@3:TPrimitive = Binary read y$6_@1:TPrimitive === read $7_@2:TPrimitive
51 + if (read $8_@3:TPrimitive) {
52 + [6] Reassign mutate x$5_@0:TPrimitive[1:8] = 3
53 }
54 }
55 - [8] Const mutate y$11_@4 = read x$5_@0
55 + [8] Const mutate y$11_@4 = read x$5_@0:TPrimitive
56 return
57 }
58
@@ -65,22 +65,22 @@ flowchart TB
65 %% Basic Blocks
66 subgraph bb0
67 bb0_instrs["
68 - [1] Let mutate x$5_@0[1:8] = 1
69 - [2] Const mutate y$6_@1 = 2
70 - [3] Const mutate $7_@2 = 2
71 - [4] Const mutate $8_@3 = Binary read y$6_@1 === read $7_@2
68 + [1] Let mutate x$5_@0:TPrimitive[1:8] = 1
69 + [2] Const mutate y$6_@1:TPrimitive = 2
70 + [3] Const mutate $7_@2:TPrimitive = 2
71 + [4] Const mutate $8_@3:TPrimitive = Binary read y$6_@1:TPrimitive === read $7_@2:TPrimitive
72 "]
73 - bb0_instrs --> bb0_terminal(["If (read $8_@3)"])
73 + bb0_instrs --> bb0_terminal(["If (read $8_@3:TPrimitive)"])
74 end
75 subgraph bb2
76 bb2_instrs["
77 - [6] Reassign mutate x$5_@0[1:8] = 3
77 + [6] Reassign mutate x$5_@0:TPrimitive[1:8] = 3
78 "]
79 bb2_instrs --> bb2_terminal(["Goto"])
80 end
81 subgraph bb1
82 bb1_instrs["
83 - [8] Const mutate y$11_@4 = read x$5_@0
83 + [8] Const mutate y$11_@4 = read x$5_@0:TPrimitive
84 "]
85 bb1_instrs --> bb1_terminal(["Return"])
86 end
compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md
+4 -4
@@ -26,11 +26,11 @@ bb1:
26 [3] If (read items$5_@0) then:bb3 else:bb2 fallthrough=bb2
27 bb3:
28 predecessor blocks: bb1
29 - [4] Const mutate y$7_@1 = 0
29 + [4] Const mutate y$7_@1:TPrimitive = 0
30 [5] If (read cond$4) then:bb5 else:bb4 fallthrough=bb4
31 bb5:
32 predecessor blocks: bb3
33 - [6] Const mutate y$9_@2 = 1
33 + [6] Const mutate y$9_@2:TPrimitive = 1
34 [7] Goto bb4
35 bb4:
36 predecessor blocks: bb5 bb3
@@ -70,13 +70,13 @@ flowchart TB
70 end
71 subgraph bb3
72 bb3_instrs["
73 - [4] Const mutate y$7_@1 = 0
73 + [4] Const mutate y$7_@1:TPrimitive = 0
74 "]
75 bb3_instrs --> bb3_terminal(["If (read cond$4)"])
76 end
77 subgraph bb5
78 bb5_instrs["
79 - [6] Const mutate y$9_@2 = 1
79 + [6] Const mutate y$9_@2:TPrimitive = 1
80 "]
81 bb5_instrs --> bb5_terminal(["Goto"])
82 end
compiler/forget/src/__tests__/fixtures/hir/ssa-for-trivial-update.expect.md
+27 -27
@@ -16,29 +16,29 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$6_@1[1:13] = 1
19 + [1] Let mutate x$6_@1:TPrimitive[1:13] = 1
20 [2] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
21 bb3:
22 predecessor blocks: bb0
23 - [3] Const mutate i$7_@1[1:13] = 0
23 + [3] Const mutate i$7_@1:TPrimitive[1:13] = 0
24 [4] Goto bb1
25 bb1:
26 predecessor blocks: bb3 bb4
27 - [5] Const mutate $8_@1[1:13] = 10
28 - [6] Const mutate $10_@3[6:8] = Binary read i$7_@1 < read $8_@1
29 - [7] If (read $10_@3) then:bb5 else:bb2 fallthrough=bb2
27 + [5] Const mutate $8_@1:TPrimitive[1:13] = 10
28 + [6] Const mutate $10_@3:TPrimitive[6:8] = Binary read i$7_@1:TPrimitive < read $8_@1:TPrimitive
29 + [7] If (read $10_@3:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
30 bb5:
31 predecessor blocks: bb1
32 - [8] Const mutate $11_@4 = 1
33 - [9] Reassign mutate x$6_@1[1:13] = Binary read x$6_@1 + read $11_@4
32 + [8] Const mutate $11_@4:TPrimitive = 1
33 + [9] Reassign mutate x$6_@1:TPrimitive[1:13] = Binary read x$6_@1:TPrimitive + read $11_@4:TPrimitive
34 [10] Goto(Continue) bb4
35 bb4:
36 predecessor blocks: bb5
37 - [11] read i$7_@1
37 + [11] read i$7_@1:TPrimitive
38 [12] Goto bb1
39 bb2:
40 predecessor blocks: bb1
41 - [13] Return read x$6_@1
41 + [13] Return read x$6_@1:TPrimitive
42
43 ```
44
@@ -48,23 +48,23 @@ bb2:
48 function foo(
49 ) {
50 scope @1 [1:13] deps=[] {
51 - [1] Let mutate x$6_@1[1:13] = 1
51 + [1] Let mutate x$6_@1:TPrimitive[1:13] = 1
52 scope @3 [6:8] deps=[] {
53 for (
54 - [3] Const mutate i$7_@1[1:13] = 0
54 + [3] Const mutate i$7_@1:TPrimitive[1:13] = 0
55 ;
56 - [5] Const mutate $8_@1[1:13] = 10
57 - [6] Const mutate $10_@3[6:8] = Binary read i$7_@1 < read $8_@1
58 - read $10_@3
56 + [5] Const mutate $8_@1:TPrimitive[1:13] = 10
57 + [6] Const mutate $10_@3:TPrimitive[6:8] = Binary read i$7_@1:TPrimitive < read $8_@1:TPrimitive
58 + read $10_@3:TPrimitive
59 ;
60 - read i$7_@1
60 + read i$7_@1:TPrimitive
61 ) {
62 - [8] Const mutate $11_@4 = 1
63 - [9] Reassign mutate x$6_@1[1:13] = Binary read x$6_@1 + read $11_@4
62 + [8] Const mutate $11_@4:TPrimitive = 1
63 + [9] Reassign mutate x$6_@1:TPrimitive[1:13] = Binary read x$6_@1:TPrimitive + read $11_@4:TPrimitive
64 }
65 }
66 }
67 - return read x$6_@1
67 + return read x$6_@1:TPrimitive
68 }
69
70 ```
@@ -76,38 +76,38 @@ flowchart TB
76 %% Basic Blocks
77 subgraph bb0
78 bb0_instrs["
79 - [1] Let mutate x$6_@1[1:13] = 1
79 + [1] Let mutate x$6_@1:TPrimitive[1:13] = 1
80 "]
81 bb0_instrs --> bb0_terminal(["For"])
82 end
83 subgraph bb3
84 bb3_instrs["
85 - [3] Const mutate i$7_@1[1:13] = 0
85 + [3] Const mutate i$7_@1:TPrimitive[1:13] = 0
86 "]
87 bb3_instrs --> bb3_terminal(["Goto"])
88 end
89 subgraph bb1
90 bb1_instrs["
91 - [5] Const mutate $8_@1[1:13] = 10
92 - [6] Const mutate $10_@3[6:8] = Binary read i$7_@1 < read $8_@1
91 + [5] Const mutate $8_@1:TPrimitive[1:13] = 10
92 + [6] Const mutate $10_@3:TPrimitive[6:8] = Binary read i$7_@1:TPrimitive < read $8_@1:TPrimitive
93 "]
94 - bb1_instrs --> bb1_terminal(["If (read $10_@3)"])
94 + bb1_instrs --> bb1_terminal(["If (read $10_@3:TPrimitive)"])
95 end
96 subgraph bb5
97 bb5_instrs["
98 - [8] Const mutate $11_@4 = 1
99 - [9] Reassign mutate x$6_@1[1:13] = Binary read x$6_@1 + read $11_@4
98 + [8] Const mutate $11_@4:TPrimitive = 1
99 + [9] Reassign mutate x$6_@1:TPrimitive[1:13] = Binary read x$6_@1:TPrimitive + read $11_@4:TPrimitive
100 "]
101 bb5_instrs --> bb5_terminal(["Goto"])
102 end
103 subgraph bb4
104 bb4_instrs["
105 - [11] read i$7_@1
105 + [11] read i$7_@1:TPrimitive
106 "]
107 bb4_instrs --> bb4_terminal(["Goto"])
108 end
109 subgraph bb2
110 - bb2_terminal(["Return read x$6_@1"])
110 + bb2_terminal(["Return read x$6_@1:TPrimitive"])
111 end
112
113 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+33 -33
@@ -16,31 +16,31 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$7_@1[1:15] = 1
19 + [1] Let mutate x$7_@1:TPrimitive[1:15] = 1
20 [2] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
21 bb3:
22 predecessor blocks: bb0
23 - [3] Let mutate i$8_@1[1:15] = 0
23 + [3] Let mutate i$8_@1:TPrimitive[1:15] = 0
24 [4] Goto bb1
25 bb1:
26 predecessor blocks: bb3 bb4
27 - [5] Const mutate $9_@1[1:15] = 10
28 - [6] Const mutate $11_@1[1:15] = Binary read i$8_@1 < read $9_@1
29 - [7] If (read $11_@1) then:bb5 else:bb2 fallthrough=bb2
27 + [5] Const mutate $9_@1:TPrimitive[1:15] = 10
28 + [6] Const mutate $11_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive < read $9_@1:TPrimitive
29 + [7] If (read $11_@1:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
30 bb5:
31 predecessor blocks: bb1
32 - [8] Const mutate $12_@3 = 1
33 - [9] Reassign mutate x$7_@1[1:15] = Binary read x$7_@1 + read $12_@3
32 + [8] Const mutate $12_@3:TPrimitive = 1
33 + [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12_@3:TPrimitive
34 [10] Goto(Continue) bb4
35 bb4:
36 predecessor blocks: bb5
37 - [11] Const mutate $15_@1[1:15] = 1
38 - [12] Reassign mutate i$8_@1[1:15] = Binary read i$8_@1 + read $15_@1
39 - [13] read i$8_@1
37 + [11] Const mutate $15_@1:TPrimitive[1:15] = 1
38 + [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15_@1:TPrimitive
39 + [13] read i$8_@1:TPrimitive
40 [14] Goto bb1
41 bb2:
42 predecessor blocks: bb1
43 - [15] Return read x$7_@1
43 + [15] Return read x$7_@1:TPrimitive
44
45 ```
46
@@ -50,23 +50,23 @@ bb2:
50 function foo(
51 ) {
52 scope @1 [1:15] deps=[] {
53 - [1] Let mutate x$7_@1[1:15] = 1
53 + [1] Let mutate x$7_@1:TPrimitive[1:15] = 1
54 for (
55 - [3] Let mutate i$8_@1[1:15] = 0
55 + [3] Let mutate i$8_@1:TPrimitive[1:15] = 0
56 ;
57 - [5] Const mutate $9_@1[1:15] = 10
58 - [6] Const mutate $11_@1[1:15] = Binary read i$8_@1 < read $9_@1
59 - read $11_@1
57 + [5] Const mutate $9_@1:TPrimitive[1:15] = 10
58 + [6] Const mutate $11_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive < read $9_@1:TPrimitive
59 + read $11_@1:TPrimitive
60 ;
61 - [11] Const mutate $15_@1[1:15] = 1
62 - [12] Reassign mutate i$8_@1[1:15] = Binary read i$8_@1 + read $15_@1
63 - read i$8_@1
61 + [11] Const mutate $15_@1:TPrimitive[1:15] = 1
62 + [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15_@1:TPrimitive
63 + read i$8_@1:TPrimitive
64 ) {
65 - [8] Const mutate $12_@3 = 1
66 - [9] Reassign mutate x$7_@1[1:15] = Binary read x$7_@1 + read $12_@3
65 + [8] Const mutate $12_@3:TPrimitive = 1
66 + [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12_@3:TPrimitive
67 }
68 }
69 - return read x$7_@1
69 + return read x$7_@1:TPrimitive
70 }
71
72 ```
@@ -78,40 +78,40 @@ flowchart TB
78 %% Basic Blocks
79 subgraph bb0
80 bb0_instrs["
81 - [1] Let mutate x$7_@1[1:15] = 1
81 + [1] Let mutate x$7_@1:TPrimitive[1:15] = 1
82 "]
83 bb0_instrs --> bb0_terminal(["For"])
84 end
85 subgraph bb3
86 bb3_instrs["
87 - [3] Let mutate i$8_@1[1:15] = 0
87 + [3] Let mutate i$8_@1:TPrimitive[1:15] = 0
88 "]
89 bb3_instrs --> bb3_terminal(["Goto"])
90 end
91 subgraph bb1
92 bb1_instrs["
93 - [5] Const mutate $9_@1[1:15] = 10
94 - [6] Const mutate $11_@1[1:15] = Binary read i$8_@1 < read $9_@1
93 + [5] Const mutate $9_@1:TPrimitive[1:15] = 10
94 + [6] Const mutate $11_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive < read $9_@1:TPrimitive
95 "]
96 - bb1_instrs --> bb1_terminal(["If (read $11_@1)"])
96 + bb1_instrs --> bb1_terminal(["If (read $11_@1:TPrimitive)"])
97 end
98 subgraph bb5
99 bb5_instrs["
100 - [8] Const mutate $12_@3 = 1
101 - [9] Reassign mutate x$7_@1[1:15] = Binary read x$7_@1 + read $12_@3
100 + [8] Const mutate $12_@3:TPrimitive = 1
101 + [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12_@3:TPrimitive
102 "]
103 bb5_instrs --> bb5_terminal(["Goto"])
104 end
105 subgraph bb4
106 bb4_instrs["
107 - [11] Const mutate $15_@1[1:15] = 1
108 - [12] Reassign mutate i$8_@1[1:15] = Binary read i$8_@1 + read $15_@1
109 - [13] read i$8_@1
107 + [11] Const mutate $15_@1:TPrimitive[1:15] = 1
108 + [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15_@1:TPrimitive
109 + [13] read i$8_@1:TPrimitive
110 "]
111 bb4_instrs --> bb4_terminal(["Goto"])
112 end
113 subgraph bb2
114 - bb2_terminal(["Return read x$7_@1"])
114 + bb2_terminal(["Return read x$7_@1:TPrimitive"])
115 end
116
117 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md
+18 -18
@@ -19,25 +19,25 @@ function foo() {
19
20 ```
21 bb0:
22 - [1] Const mutate x$5_@0 = 1
23 - [2] Const mutate y$6_@1 = 2
24 - [3] If (read y$6_@1) then:bb2 else:bb3 fallthrough=bb1
22 + [1] Const mutate x$5_@0:TPrimitive = 1
23 + [2] Const mutate y$6_@1:TPrimitive = 2
24 + [3] If (read y$6_@1:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
25 bb2:
26 predecessor blocks: bb0
27 - [4] Const mutate z$7_@2 = Binary read x$5_@0 + read y$6_@1
27 + [4] Const mutate z$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read y$6_@1:TPrimitive
28 [5] Goto bb1
29 bb3:
30 predecessor blocks: bb0
31 - [6] Const mutate z$8_@3 = read x$5_@0
31 + [6] Const mutate z$8_@3:TPrimitive = read x$5_@0:TPrimitive
32 [7] Goto bb1
33 bb1:
34 predecessor blocks: bb2 bb3
35 [8] Return
36 scope2 [4:5]:
37 - - dependency: read x$5_@0
38 - - dependency: read y$6_@1
37 + - dependency: read x$5_@0:TPrimitive
38 + - dependency: read y$6_@1:TPrimitive
39 scope3 [6:7]:
40 - - dependency: read x$5_@0
40 + - dependency: read x$5_@0:TPrimitive
41 ```
42
43 ## Reactive Scopes
@@ -45,12 +45,12 @@ scope3 [6:7]:
45 ```
46 function foo(
47 ) {
48 - [1] Const mutate x$5_@0 = 1
49 - [2] Const mutate y$6_@1 = 2
50 - if (read y$6_@1) {
51 - [4] Const mutate z$7_@2 = Binary read x$5_@0 + read y$6_@1
48 + [1] Const mutate x$5_@0:TPrimitive = 1
49 + [2] Const mutate y$6_@1:TPrimitive = 2
50 + if (read y$6_@1:TPrimitive) {
51 + [4] Const mutate z$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read y$6_@1:TPrimitive
52 } else {
53 - [6] Const mutate z$8_@3 = read x$5_@0
53 + [6] Const mutate z$8_@3:TPrimitive = read x$5_@0:TPrimitive
54 }
55 return
56 }
@@ -64,20 +64,20 @@ flowchart TB
64 %% Basic Blocks
65 subgraph bb0
66 bb0_instrs["
67 - [1] Const mutate x$5_@0 = 1
68 - [2] Const mutate y$6_@1 = 2
67 + [1] Const mutate x$5_@0:TPrimitive = 1
68 + [2] Const mutate y$6_@1:TPrimitive = 2
69 "]
70 - bb0_instrs --> bb0_terminal(["If (read y$6_@1)"])
70 + bb0_instrs --> bb0_terminal(["If (read y$6_@1:TPrimitive)"])
71 end
72 subgraph bb2
73 bb2_instrs["
74 - [4] Const mutate z$7_@2 = Binary read x$5_@0 + read y$6_@1
74 + [4] Const mutate z$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read y$6_@1:TPrimitive
75 "]
76 bb2_instrs --> bb2_terminal(["Goto"])
77 end
78 subgraph bb3
79 bb3_instrs["
80 - [6] Const mutate z$8_@3 = read x$5_@0
80 + [6] Const mutate z$8_@3:TPrimitive = read x$5_@0:TPrimitive
81 "]
82 bb3_instrs --> bb3_terminal(["Goto"])
83 end
compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md
+23 -23
@@ -28,14 +28,14 @@ function foo(a, b, c, d) {
28
29 ```
30 bb0:
31 - [1] Const mutate x$13_@0 = 0
32 - [2] Const mutate $14_@1 = true
31 + [1] Const mutate x$13_@0:TPrimitive = 0
32 + [2] Const mutate $14_@1:TPrimitive = true
33 [3] Let mutate x$18_@2[3:20] = undefined
34 - [3] If (read $14_@1) then:bb2 else:bb6 fallthrough=bb1
34 + [3] If (read $14_@1:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
35 bb2:
36 predecessor blocks: bb0
37 - [4] Const mutate $15_@3 = true
38 - [5] If (read $15_@3) then:bb4 else:bb5 fallthrough=bb3
37 + [4] Const mutate $15_@3:TPrimitive = true
38 + [5] If (read $15_@3:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
39 bb4:
40 predecessor blocks: bb2
41 [6] Reassign mutate x$18_@2[3:20] = read a$9
@@ -50,8 +50,8 @@ bb3:
50 [11] Goto bb1
51 bb6:
52 predecessor blocks: bb0
53 - [12] Const mutate $19_@4 = true
54 - [13] If (read $19_@4) then:bb8 else:bb9 fallthrough=bb7
53 + [12] Const mutate $19_@4:TPrimitive = true
54 + [13] If (read $19_@4:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
55 bb8:
56 predecessor blocks: bb6
57 [14] Reassign mutate x$18_@2[3:20] = read c$11
@@ -73,7 +73,7 @@ scope2 [3:20]:
73 - dependency: read b$10
74 - dependency: read c$11
75 - dependency: read d$12
76 - - dependency: read $14_@1
76 + - dependency: read $14_@1:TPrimitive
77 ```
78
79 ## Reactive Scopes
@@ -85,21 +85,21 @@ function foo(
85 c,
86 d,
87 ) {
88 - [1] Const mutate x$13_@0 = 0
89 - [2] Const mutate $14_@1 = true
90 - scope @2 [3:20] deps=[read a$9, read b$10, read c$11, read d$12, read $14_@1] {
88 + [1] Const mutate x$13_@0:TPrimitive = 0
89 + [2] Const mutate $14_@1:TPrimitive = true
90 + scope @2 [3:20] deps=[read a$9, read b$10, read c$11, read d$12, read $14_@1:TPrimitive] {
91 [3] Let mutate x$18_@2[3:20] = undefined
92 - if (read $14_@1) {
93 - [4] Const mutate $15_@3 = true
94 - if (read $15_@3) {
92 + if (read $14_@1:TPrimitive) {
93 + [4] Const mutate $15_@3:TPrimitive = true
94 + if (read $15_@3:TPrimitive) {
95 [6] Reassign mutate x$18_@2[3:20] = read a$9
96 } else {
97 [8] Reassign mutate x$18_@2[3:20] = read b$10
98 }
99 [10] read x$18_@2
100 } else {
101 - [12] Const mutate $19_@4 = true
102 - if (read $19_@4) {
101 + [12] Const mutate $19_@4:TPrimitive = true
102 + if (read $19_@4:TPrimitive) {
103 [14] Reassign mutate x$18_@2[3:20] = read c$11
104 } else {
105 [16] Reassign mutate x$18_@2[3:20] = read d$12
@@ -120,17 +120,17 @@ flowchart TB
120 %% Basic Blocks
121 subgraph bb0
122 bb0_instrs["
123 - [1] Const mutate x$13_@0 = 0
124 - [2] Const mutate $14_@1 = true
123 + [1] Const mutate x$13_@0:TPrimitive = 0
124 + [2] Const mutate $14_@1:TPrimitive = true
125 [3] Let mutate x$18_@2[3:20] = undefined
126 "]
127 - bb0_instrs --> bb0_terminal(["If (read $14_@1)"])
127 + bb0_instrs --> bb0_terminal(["If (read $14_@1:TPrimitive)"])
128 end
129 subgraph bb2
130 bb2_instrs["
131 - [4] Const mutate $15_@3 = true
131 + [4] Const mutate $15_@3:TPrimitive = true
132 "]
133 - bb2_instrs --> bb2_terminal(["If (read $15_@3)"])
133 + bb2_instrs --> bb2_terminal(["If (read $15_@3:TPrimitive)"])
134 end
135 subgraph bb4
136 bb4_instrs["
@@ -152,9 +152,9 @@ flowchart TB
152 end
153 subgraph bb6
154 bb6_instrs["
155 - [12] Const mutate $19_@4 = true
155 + [12] Const mutate $19_@4:TPrimitive = true
156 "]
157 - bb6_instrs --> bb6_terminal(["If (read $19_@4)"])
157 + bb6_instrs --> bb6_terminal(["If (read $19_@4:TPrimitive)"])
158 end
159 subgraph bb8
160 bb8_instrs["
compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md
+13 -13
@@ -21,7 +21,7 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$9_@0 = 0
24 + [1] Const mutate x$9_@0:TPrimitive = 0
25 [2] While test=bb1 loop=bb3 fallthrough=bb2
26 bb1:
27 predecessor blocks: bb0 bb5
@@ -40,8 +40,8 @@ bb7:
40 [7] If (read c$8) then:bb9 else:bb8 fallthrough=bb8
41 bb9:
42 predecessor blocks: bb7
43 - [8] Const mutate $13_@1 = 1
44 - [9] Binary read x$9_@0 + read $13_@1
43 + [8] Const mutate $13_@1:TPrimitive = 1
44 + [9] Binary read x$9_@0:TPrimitive + read $13_@1:TPrimitive
45 [10] Goto(Continue) bb7
46 bb8:
47 predecessor blocks: bb7
@@ -51,9 +51,9 @@ bb5:
51 [12] Goto(Continue) bb1
52 bb2:
53 predecessor blocks: bb1
54 - [13] Return read x$9_@0
54 + [13] Return read x$9_@0:TPrimitive
55 scope1 [8:9]:
56 - - dependency: read x$9_@0
56 + - dependency: read x$9_@0:TPrimitive
57 ```
58
59 ## Reactive Scopes
@@ -64,7 +64,7 @@ function foo(
64 b,
65 c,
66 ) {
67 - [1] Const mutate x$9_@0 = 0
67 + [1] Const mutate x$9_@0:TPrimitive = 0
68 while (
69 read a$6
70 ) {
@@ -74,12 +74,12 @@ function foo(
74 while (
75 read c$8
76 ) {
77 - [8] Const mutate $13_@1 = 1
78 - [9] Binary read x$9_@0 + read $13_@1
77 + [8] Const mutate $13_@1:TPrimitive = 1
78 + [9] Binary read x$9_@0:TPrimitive + read $13_@1:TPrimitive
79 }
80 }
81 }
82 - return read x$9_@0
82 + return read x$9_@0:TPrimitive
83 }
84
85 ```
@@ -91,7 +91,7 @@ flowchart TB
91 %% Basic Blocks
92 subgraph bb0
93 bb0_instrs["
94 - [1] Const mutate x$9_@0 = 0
94 + [1] Const mutate x$9_@0:TPrimitive = 0
95 "]
96 bb0_instrs --> bb0_terminal(["While"])
97 end
@@ -112,8 +112,8 @@ flowchart TB
112 end
113 subgraph bb9
114 bb9_instrs["
115 - [8] Const mutate $13_@1 = 1
116 - [9] Binary read x$9_@0 + read $13_@1
115 + [8] Const mutate $13_@1:TPrimitive = 1
116 + [9] Binary read x$9_@0:TPrimitive + read $13_@1:TPrimitive
117 "]
118 bb9_instrs --> bb9_terminal(["Goto"])
119 end
@@ -124,7 +124,7 @@ flowchart TB
124 bb5_terminal(["Goto"])
125 end
126 subgraph bb2
127 - bb2_terminal(["Return read x$9_@0"])
127 + bb2_terminal(["Return read x$9_@0:TPrimitive"])
128 end
129
130 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-reassignment.expect.md
+12 -12
@@ -20,22 +20,22 @@ function foo(a, b, c, d, e) {
20
21 ```
22 bb0:
23 - [1] Let mutate x$12_@0[1:8] = null
23 + [1] Let mutate x$12_@0:TPrimitive[1:8] = null
24 [2] If (read a$7) then:bb2 else:bb3 fallthrough=bb1
25 bb2:
26 predecessor blocks: bb0
27 - [3] Reassign mutate x$12_@0[1:8] = read b$8
27 + [3] Reassign mutate x$12_@0:TPrimitive[1:8] = read b$8
28 [4] Goto bb1
29 bb3:
30 predecessor blocks: bb0
31 [5] If (read c$9) then:bb5 else:bb1 fallthrough=bb1
32 bb5:
33 predecessor blocks: bb3
34 - [6] Reassign mutate x$12_@0[1:8] = read d$10
34 + [6] Reassign mutate x$12_@0:TPrimitive[1:8] = read d$10
35 [7] Goto bb1
36 bb1:
37 predecessor blocks: bb2 bb5 bb3
38 - [8] Return read x$12_@0
38 + [8] Return read x$12_@0:TPrimitive
39 scope0 [1:8]:
40 - dependency: read b$8
41 - dependency: read d$10
@@ -54,16 +54,16 @@ function foo(
54 e,
55 ) {
56 scope @0 [1:8] deps=[read b$8, read d$10, read c$9, read a$7] {
57 - [1] Let mutate x$12_@0[1:8] = null
57 + [1] Let mutate x$12_@0:TPrimitive[1:8] = null
58 if (read a$7) {
59 - [3] Reassign mutate x$12_@0[1:8] = read b$8
59 + [3] Reassign mutate x$12_@0:TPrimitive[1:8] = read b$8
60 } else {
61 if (read c$9) {
62 - [6] Reassign mutate x$12_@0[1:8] = read d$10
62 + [6] Reassign mutate x$12_@0:TPrimitive[1:8] = read d$10
63 }
64 }
65 }
66 - return read x$12_@0
66 + return read x$12_@0:TPrimitive
67 }
68
69 ```
@@ -75,13 +75,13 @@ flowchart TB
75 %% Basic Blocks
76 subgraph bb0
77 bb0_instrs["
78 - [1] Let mutate x$12_@0[1:8] = null
78 + [1] Let mutate x$12_@0:TPrimitive[1:8] = null
79 "]
80 bb0_instrs --> bb0_terminal(["If (read a$7)"])
81 end
82 subgraph bb2
83 bb2_instrs["
84 - [3] Reassign mutate x$12_@0[1:8] = read b$8
84 + [3] Reassign mutate x$12_@0:TPrimitive[1:8] = read b$8
85 "]
86 bb2_instrs --> bb2_terminal(["Goto"])
87 end
@@ -90,12 +90,12 @@ flowchart TB
90 end
91 subgraph bb5
92 bb5_instrs["
93 - [6] Reassign mutate x$12_@0[1:8] = read d$10
93 + [6] Reassign mutate x$12_@0:TPrimitive[1:8] = read d$10
94 "]
95 bb5_instrs --> bb5_terminal(["Goto"])
96 end
97 subgraph bb1
98 - bb1_terminal(["Return read x$12_@0"])
98 + bb1_terminal(["Return read x$12_@0:TPrimitive"])
99 end
100
101 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+6 -6
@@ -55,8 +55,8 @@ function Foo$0() {}
55 ```
56 bb0:
57 [1] Const mutate a$7_@0[1:4] = Array []
58 - [2] Const mutate b$8_@0[1:4] = Object { }
59 - [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0)
58 + [2] Const mutate b$8_@0:TObject[1:4] = Object { }
59 + [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0:TObject)
60 [4] Return freeze c$9_@0
61
62 ```
@@ -69,8 +69,8 @@ function Component(
69 ) {
70 scope @0 [1:4] deps=[] {
71 [1] Const mutate a$7_@0[1:4] = Array []
72 - [2] Const mutate b$8_@0[1:4] = Object { }
73 - [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0)
72 + [2] Const mutate b$8_@0:TObject[1:4] = Object { }
73 + [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0:TObject)
74 }
75 return freeze c$9_@0
76 }
@@ -85,8 +85,8 @@ flowchart TB
85 subgraph bb0
86 bb0_instrs["
87 [1] Const mutate a$7_@0[1:4] = Array []
88 - [2] Const mutate b$8_@0[1:4] = Object { }
89 - [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0)
88 + [2] Const mutate b$8_@0:TObject[1:4] = Object { }
89 + [3] Const mutate c$9_@0[1:4] = New mutate Foo$5(mutate a$7_@0, mutate b$8_@0:TObject)
90 "]
91 bb0_instrs --> bb0_terminal(["Return freeze c$9_@0"])
92 end
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+30 -30
@@ -22,26 +22,26 @@ function foo() {
22
23 ```
24 bb0:
25 - [1] Let mutate x$6_@0[1:10] = 1
26 - [2] Let mutate y$7_@0[1:10] = 2
27 - [3] Const mutate $8_@2 = 1
28 - [4] Const mutate $9_@0[1:10] = Binary read x$6_@0 > read $8_@2
29 - [5] If (read $9_@0) then:bb2 else:bb3 fallthrough=bb1
25 + [1] Let mutate x$6_@0:TPrimitive[1:10] = 1
26 + [2] Let mutate y$7_@0:TPrimitive[1:10] = 2
27 + [3] Const mutate $8_@2:TPrimitive = 1
28 + [4] Const mutate $9_@0:TPrimitive[1:10] = Binary read x$6_@0:TPrimitive > read $8_@2:TPrimitive
29 + [5] If (read $9_@0:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
30 bb2:
31 predecessor blocks: bb0
32 - [6] Reassign mutate x$6_@0[1:10] = 2
32 + [6] Reassign mutate x$6_@0:TPrimitive[1:10] = 2
33 [7] Goto bb1
34 bb3:
35 predecessor blocks: bb0
36 - [8] Reassign mutate y$7_@0[1:10] = 3
36 + [8] Reassign mutate y$7_@0:TPrimitive[1:10] = 3
37 [9] Goto bb1
38 bb1:
39 predecessor blocks: bb2 bb3
40 - [10] Const mutate t$14_@3 = Object { x: read x$6_@0, y: read y$7_@0 }
41 - [11] Return freeze t$14_@3
40 + [10] Const mutate t$14_@3:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
41 + [11] Return freeze t$14_@3:TObject
42 scope3 [10:11]:
43 - - dependency: read x$6_@0
44 - - dependency: read y$7_@0
43 + - dependency: read x$6_@0:TPrimitive
44 + - dependency: read y$7_@0:TPrimitive
45 ```
46
47 ## Reactive Scopes
@@ -50,20 +50,20 @@ scope3 [10:11]:
50 function foo(
51 ) {
52 scope @0 [1:10] deps=[] {
53 - [1] Let mutate x$6_@0[1:10] = 1
54 - [2] Let mutate y$7_@0[1:10] = 2
55 - [3] Const mutate $8_@2 = 1
56 - [4] Const mutate $9_@0[1:10] = Binary read x$6_@0 > read $8_@2
57 - if (read $9_@0) {
58 - [6] Reassign mutate x$6_@0[1:10] = 2
53 + [1] Let mutate x$6_@0:TPrimitive[1:10] = 1
54 + [2] Let mutate y$7_@0:TPrimitive[1:10] = 2
55 + [3] Const mutate $8_@2:TPrimitive = 1
56 + [4] Const mutate $9_@0:TPrimitive[1:10] = Binary read x$6_@0:TPrimitive > read $8_@2:TPrimitive
57 + if (read $9_@0:TPrimitive) {
58 + [6] Reassign mutate x$6_@0:TPrimitive[1:10] = 2
59 } else {
60 - [8] Reassign mutate y$7_@0[1:10] = 3
60 + [8] Reassign mutate y$7_@0:TPrimitive[1:10] = 3
61 }
62 }
63 - scope @3 [10:11] deps=[read x$6_@0, read y$7_@0] {
64 - [10] Const mutate t$14_@3 = Object { x: read x$6_@0, y: read y$7_@0 }
63 + scope @3 [10:11] deps=[read x$6_@0:TPrimitive, read y$7_@0:TPrimitive] {
64 + [10] Const mutate t$14_@3:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
65 }
66 - return freeze t$14_@3
66 + return freeze t$14_@3:TObject
67 }
68
69 ```
@@ -75,30 +75,30 @@ flowchart TB
75 %% Basic Blocks
76 subgraph bb0
77 bb0_instrs["
78 - [1] Let mutate x$6_@0[1:10] = 1
79 - [2] Let mutate y$7_@0[1:10] = 2
80 - [3] Const mutate $8_@2 = 1
81 - [4] Const mutate $9_@0[1:10] = Binary read x$6_@0 > read $8_@2
78 + [1] Let mutate x$6_@0:TPrimitive[1:10] = 1
79 + [2] Let mutate y$7_@0:TPrimitive[1:10] = 2
80 + [3] Const mutate $8_@2:TPrimitive = 1
81 + [4] Const mutate $9_@0:TPrimitive[1:10] = Binary read x$6_@0:TPrimitive > read $8_@2:TPrimitive
82 "]
83 - bb0_instrs --> bb0_terminal(["If (read $9_@0)"])
83 + bb0_instrs --> bb0_terminal(["If (read $9_@0:TPrimitive)"])
84 end
85 subgraph bb2
86 bb2_instrs["
87 - [6] Reassign mutate x$6_@0[1:10] = 2
87 + [6] Reassign mutate x$6_@0:TPrimitive[1:10] = 2
88 "]
89 bb2_instrs --> bb2_terminal(["Goto"])
90 end
91 subgraph bb3
92 bb3_instrs["
93 - [8] Reassign mutate y$7_@0[1:10] = 3
93 + [8] Reassign mutate y$7_@0:TPrimitive[1:10] = 3
94 "]
95 bb3_instrs --> bb3_terminal(["Goto"])
96 end
97 subgraph bb1
98 bb1_instrs["
99 - [10] Const mutate t$14_@3 = Object { x: read x$6_@0, y: read y$7_@0 }
99 + [10] Const mutate t$14_@3:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
100 "]
101 - bb1_instrs --> bb1_terminal(["Return freeze t$14_@3"])
101 + bb1_instrs --> bb1_terminal(["Return freeze t$14_@3:TObject"])
102 end
103
104 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md
+15 -15
@@ -15,13 +15,13 @@ function Component(props) {
15
16 ```
17 bb0:
18 - [1] Const mutate a$6_@0 = 1
19 - [2] Const mutate b$7_@1 = 2
20 - [3] Const mutate x$8_@2 = Object { a: read a$6_@0, b: read b$7_@1 }
21 - [4] Return freeze x$8_@2
18 + [1] Const mutate a$6_@0:TPrimitive = 1
19 + [2] Const mutate b$7_@1:TPrimitive = 2
20 + [3] Const mutate x$8_@2:TObject = Object { a: read a$6_@0:TPrimitive, b: read b$7_@1:TPrimitive }
21 + [4] Return freeze x$8_@2:TObject
22 scope2 [3:4]:
23 - - dependency: read a$6_@0
24 - - dependency: read b$7_@1
23 + - dependency: read a$6_@0:TPrimitive
24 + - dependency: read b$7_@1:TPrimitive
25 ```
26
27 ## Reactive Scopes
@@ -30,12 +30,12 @@ scope2 [3:4]:
30 function Component(
31 props,
32 ) {
33 - [1] Const mutate a$6_@0 = 1
34 - [2] Const mutate b$7_@1 = 2
35 - scope @2 [3:4] deps=[read a$6_@0, read b$7_@1] {
36 - [3] Const mutate x$8_@2 = Object { a: read a$6_@0, b: read b$7_@1 }
33 + [1] Const mutate a$6_@0:TPrimitive = 1
34 + [2] Const mutate b$7_@1:TPrimitive = 2
35 + scope @2 [3:4] deps=[read a$6_@0:TPrimitive, read b$7_@1:TPrimitive] {
36 + [3] Const mutate x$8_@2:TObject = Object { a: read a$6_@0:TPrimitive, b: read b$7_@1:TPrimitive }
37 }
38 - return freeze x$8_@2
38 + return freeze x$8_@2:TObject
39 }
40
41 ```
@@ -47,11 +47,11 @@ flowchart TB
47 %% Basic Blocks
48 subgraph bb0
49 bb0_instrs["
50 - [1] Const mutate a$6_@0 = 1
51 - [2] Const mutate b$7_@1 = 2
52 - [3] Const mutate x$8_@2 = Object { a: read a$6_@0, b: read b$7_@1 }
50 + [1] Const mutate a$6_@0:TPrimitive = 1
51 + [2] Const mutate b$7_@1:TPrimitive = 2
52 + [3] Const mutate x$8_@2:TObject = Object { a: read a$6_@0:TPrimitive, b: read b$7_@1:TPrimitive }
53 "]
54 - bb0_instrs --> bb0_terminal(["Return freeze x$8_@2"])
54 + bb0_instrs --> bb0_terminal(["Return freeze x$8_@2:TObject"])
55 end
56
57 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-alias-mutate-if.expect.md
+24 -24
@@ -22,23 +22,23 @@ function foo(a) {
22
23 ```
24 bb0:
25 - [1] Const mutate b$8_@0[1:11] = Object { }
26 - [2] Const mutate x$9_@0[1:11] = read b$8_@0
25 + [1] Const mutate b$8_@0:TObject[1:11] = Object { }
26 + [2] Const mutate x$9_@0:TObject[1:11] = read b$8_@0:TObject
27 [3] If (read a$7) then:bb2 else:bb3 fallthrough=bb1
28 bb2:
29 predecessor blocks: bb0
30 - [4] Const mutate y$10_@0[1:11] = Object { }
31 - [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0
30 + [4] Const mutate y$10_@0:TObject[1:11] = Object { }
31 + [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0:TObject
32 [6] Goto bb1
33 bb3:
34 predecessor blocks: bb0
35 - [7] Const mutate z$11_@0[1:11] = Object { }
36 - [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0
35 + [7] Const mutate z$11_@0:TObject[1:11] = Object { }
36 + [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0:TObject
37 [9] Goto bb1
38 bb1:
39 predecessor blocks: bb2 bb3
40 - [10] Call mutate mutate$6(mutate b$8_@0)
41 - [11] Return freeze x$9_@0
40 + [10] Call mutate mutate$6:TFunction(mutate b$8_@0:TObject)
41 + [11] Return freeze x$9_@0:TObject
42 scope0 [1:11]:
43 - dependency: read a$7
44 ```
@@ -50,18 +50,18 @@ function foo(
50 a,
51 ) {
52 scope @0 [1:11] deps=[read a$7] {
53 - [1] Const mutate b$8_@0[1:11] = Object { }
54 - [2] Const mutate x$9_@0[1:11] = read b$8_@0
53 + [1] Const mutate b$8_@0:TObject[1:11] = Object { }
54 + [2] Const mutate x$9_@0:TObject[1:11] = read b$8_@0:TObject
55 if (read a$7) {
56 - [4] Const mutate y$10_@0[1:11] = Object { }
57 - [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0
56 + [4] Const mutate y$10_@0:TObject[1:11] = Object { }
57 + [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0:TObject
58 } else {
59 - [7] Const mutate z$11_@0[1:11] = Object { }
60 - [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0
59 + [7] Const mutate z$11_@0:TObject[1:11] = Object { }
60 + [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0:TObject
61 }
62 - [10] Call mutate mutate$6(mutate b$8_@0)
62 + [10] Call mutate mutate$6:TFunction(mutate b$8_@0:TObject)
63 }
64 - return freeze x$9_@0
64 + return freeze x$9_@0:TObject
65 }
66
67 ```
@@ -73,30 +73,30 @@ flowchart TB
73 %% Basic Blocks
74 subgraph bb0
75 bb0_instrs["
76 - [1] Const mutate b$8_@0[1:11] = Object { }
77 - [2] Const mutate x$9_@0[1:11] = read b$8_@0
76 + [1] Const mutate b$8_@0:TObject[1:11] = Object { }
77 + [2] Const mutate x$9_@0:TObject[1:11] = read b$8_@0:TObject
78 "]
79 bb0_instrs --> bb0_terminal(["If (read a$7)"])
80 end
81 subgraph bb2
82 bb2_instrs["
83 - [4] Const mutate y$10_@0[1:11] = Object { }
84 - [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0
83 + [4] Const mutate y$10_@0:TObject[1:11] = Object { }
84 + [5] Reassign mutate x$9_@0.y[1:11] = read y$10_@0:TObject
85 "]
86 bb2_instrs --> bb2_terminal(["Goto"])
87 end
88 subgraph bb3
89 bb3_instrs["
90 - [7] Const mutate z$11_@0[1:11] = Object { }
91 - [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0
90 + [7] Const mutate z$11_@0:TObject[1:11] = Object { }
91 + [8] Reassign mutate x$9_@0.z[1:11] = read z$11_@0:TObject
92 "]
93 bb3_instrs --> bb3_terminal(["Goto"])
94 end
95 subgraph bb1
96 bb1_instrs["
97 - [10] Call mutate mutate$6(mutate b$8_@0)
97 + [10] Call mutate mutate$6:TFunction(mutate b$8_@0:TObject)
98 "]
99 - bb1_instrs --> bb1_terminal(["Return freeze x$9_@0"])
99 + bb1_instrs --> bb1_terminal(["Return freeze x$9_@0:TObject"])
100 end
101
102 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-if.expect.md
+18 -18
@@ -20,21 +20,21 @@ function foo(a) {
20
21 ```
22 bb0:
23 - [1] Const mutate x$6_@0[1:9] = Object { }
23 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
24 [2] If (read a$5) then:bb2 else:bb3 fallthrough=bb1
25 bb2:
26 predecessor blocks: bb0
27 - [3] Const mutate y$7_@1 = Object { }
28 - [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1
27 + [3] Const mutate y$7_@1:TObject = Object { }
28 + [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1:TObject
29 [5] Goto bb1
30 bb3:
31 predecessor blocks: bb0
32 - [6] Const mutate z$8_@2 = Object { }
33 - [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2
32 + [6] Const mutate z$8_@2:TObject = Object { }
33 + [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2:TObject
34 [8] Goto bb1
35 bb1:
36 predecessor blocks: bb2 bb3
37 - [9] Return freeze x$6_@0
37 + [9] Return freeze x$6_@0:TObject
38 scope0 [1:9]:
39 - dependency: read a$5
40 scope1 [3:4]:
@@ -50,20 +50,20 @@ function foo(
50 a,
51 ) {
52 scope @0 [1:9] deps=[read a$5] {
53 - [1] Const mutate x$6_@0[1:9] = Object { }
53 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
54 if (read a$5) {
55 scope @1 [3:4] deps=[mutate x$6_@0.y] {
56 - [3] Const mutate y$7_@1 = Object { }
56 + [3] Const mutate y$7_@1:TObject = Object { }
57 }
58 - [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1
58 + [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1:TObject
59 } else {
60 scope @2 [6:7] deps=[mutate x$6_@0.z] {
61 - [6] Const mutate z$8_@2 = Object { }
61 + [6] Const mutate z$8_@2:TObject = Object { }
62 }
63 - [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2
63 + [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2:TObject
64 }
65 }
66 - return freeze x$6_@0
66 + return freeze x$6_@0:TObject
67 }
68
69 ```
@@ -75,26 +75,26 @@ flowchart TB
75 %% Basic Blocks
76 subgraph bb0
77 bb0_instrs["
78 - [1] Const mutate x$6_@0[1:9] = Object { }
78 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
79 "]
80 bb0_instrs --> bb0_terminal(["If (read a$5)"])
81 end
82 subgraph bb2
83 bb2_instrs["
84 - [3] Const mutate y$7_@1 = Object { }
85 - [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1
84 + [3] Const mutate y$7_@1:TObject = Object { }
85 + [4] Reassign mutate x$6_@0.y[1:9] = read y$7_@1:TObject
86 "]
87 bb2_instrs --> bb2_terminal(["Goto"])
88 end
89 subgraph bb3
90 bb3_instrs["
91 - [6] Const mutate z$8_@2 = Object { }
92 - [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2
91 + [6] Const mutate z$8_@2:TObject = Object { }
92 + [7] Reassign mutate x$6_@0.z[1:9] = read z$8_@2:TObject
93 "]
94 bb3_instrs --> bb3_terminal(["Goto"])
95 end
96 subgraph bb1
97 - bb1_terminal(["Return freeze x$6_@0"])
97 + bb1_terminal(["Return freeze x$6_@0:TObject"])
98 end
99
100 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-if.expect.md
+21 -21
@@ -21,22 +21,22 @@ function foo(a) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$7_@0[1:10] = Object { }
24 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
25 [2] If (read a$6) then:bb2 else:bb3 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$8_@0[1:10] = Object { }
29 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
28 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
29 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
30 [5] Goto bb1
31 bb3:
32 predecessor blocks: bb0
33 - [6] Const mutate z$9_@0[1:10] = Object { }
34 - [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0
33 + [6] Const mutate z$9_@0:TObject[1:10] = Object { }
34 + [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0:TObject
35 [8] Goto bb1
36 bb1:
37 predecessor blocks: bb2 bb3
38 - [9] Call mutate mutate$5(mutate x$7_@0)
39 - [10] Return freeze x$7_@0
38 + [9] Call mutate mutate$5:TFunction(mutate x$7_@0:TObject)
39 + [10] Return freeze x$7_@0:TObject
40 scope0 [1:10]:
41 - dependency: read a$6
42 ```
@@ -48,17 +48,17 @@ function foo(
48 a,
49 ) {
50 scope @0 [1:10] deps=[read a$6] {
51 - [1] Const mutate x$7_@0[1:10] = Object { }
51 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
52 if (read a$6) {
53 - [3] Const mutate y$8_@0[1:10] = Object { }
54 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
53 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
54 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
55 } else {
56 - [6] Const mutate z$9_@0[1:10] = Object { }
57 - [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0
56 + [6] Const mutate z$9_@0:TObject[1:10] = Object { }
57 + [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0:TObject
58 }
59 - [9] Call mutate mutate$5(mutate x$7_@0)
59 + [9] Call mutate mutate$5:TFunction(mutate x$7_@0:TObject)
60 }
61 - return freeze x$7_@0
61 + return freeze x$7_@0:TObject
62 }
63
64 ```
@@ -70,29 +70,29 @@ flowchart TB
70 %% Basic Blocks
71 subgraph bb0
72 bb0_instrs["
73 - [1] Const mutate x$7_@0[1:10] = Object { }
73 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
74 "]
75 bb0_instrs --> bb0_terminal(["If (read a$6)"])
76 end
77 subgraph bb2
78 bb2_instrs["
79 - [3] Const mutate y$8_@0[1:10] = Object { }
80 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
79 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
80 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
81 "]
82 bb2_instrs --> bb2_terminal(["Goto"])
83 end
84 subgraph bb3
85 bb3_instrs["
86 - [6] Const mutate z$9_@0[1:10] = Object { }
87 - [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0
86 + [6] Const mutate z$9_@0:TObject[1:10] = Object { }
87 + [7] Reassign mutate x$7_@0.z[1:10] = read z$9_@0:TObject
88 "]
89 bb3_instrs --> bb3_terminal(["Goto"])
90 end
91 subgraph bb1
92 bb1_instrs["
93 - [9] Call mutate mutate$5(mutate x$7_@0)
93 + [9] Call mutate mutate$5:TFunction(mutate x$7_@0:TObject)
94 "]
95 - bb1_instrs --> bb1_terminal(["Return freeze x$7_@0"])
95 + bb1_instrs --> bb1_terminal(["Return freeze x$7_@0:TObject"])
96 end
97
98 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-inside-if.expect.md
+21 -21
@@ -21,22 +21,22 @@ function foo(a) {
21
22 ```
23 bb0:
24 - [1] Const mutate x$7_@0[1:10] = Object { }
24 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
25 [2] If (read a$6) then:bb2 else:bb3 fallthrough=bb1
26 bb2:
27 predecessor blocks: bb0
28 - [3] Const mutate y$8_@0[1:10] = Object { }
29 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
30 - [5] Call mutate mutate$4(mutate y$8_@0)
28 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
29 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
30 + [5] Call mutate mutate$4:TFunction(mutate y$8_@0:TObject)
31 [6] Goto bb1
32 bb3:
33 predecessor blocks: bb0
34 - [7] Const mutate z$9_@1 = Object { }
35 - [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1
34 + [7] Const mutate z$9_@1:TObject = Object { }
35 + [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1:TObject
36 [9] Goto bb1
37 bb1:
38 predecessor blocks: bb2 bb3
39 - [10] Return freeze x$7_@0
39 + [10] Return freeze x$7_@0:TObject
40 scope0 [1:10]:
41 - dependency: read a$6
42 scope1 [7:8]:
@@ -50,19 +50,19 @@ function foo(
50 a,
51 ) {
52 scope @0 [1:10] deps=[read a$6] {
53 - [1] Const mutate x$7_@0[1:10] = Object { }
53 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
54 if (read a$6) {
55 - [3] Const mutate y$8_@0[1:10] = Object { }
56 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
57 - [5] Call mutate mutate$4(mutate y$8_@0)
55 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
56 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
57 + [5] Call mutate mutate$4:TFunction(mutate y$8_@0:TObject)
58 } else {
59 scope @1 [7:8] deps=[mutate x$7_@0.z] {
60 - [7] Const mutate z$9_@1 = Object { }
60 + [7] Const mutate z$9_@1:TObject = Object { }
61 }
62 - [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1
62 + [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1:TObject
63 }
64 }
65 - return freeze x$7_@0
65 + return freeze x$7_@0:TObject
66 }
67
68 ```
@@ -74,27 +74,27 @@ flowchart TB
74 %% Basic Blocks
75 subgraph bb0
76 bb0_instrs["
77 - [1] Const mutate x$7_@0[1:10] = Object { }
77 + [1] Const mutate x$7_@0:TObject[1:10] = Object { }
78 "]
79 bb0_instrs --> bb0_terminal(["If (read a$6)"])
80 end
81 subgraph bb2
82 bb2_instrs["
83 - [3] Const mutate y$8_@0[1:10] = Object { }
84 - [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0
85 - [5] Call mutate mutate$4(mutate y$8_@0)
83 + [3] Const mutate y$8_@0:TObject[1:10] = Object { }
84 + [4] Reassign mutate x$7_@0.y[1:10] = read y$8_@0:TObject
85 + [5] Call mutate mutate$4:TFunction(mutate y$8_@0:TObject)
86 "]
87 bb2_instrs --> bb2_terminal(["Goto"])
88 end
89 subgraph bb3
90 bb3_instrs["
91 - [7] Const mutate z$9_@1 = Object { }
92 - [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1
91 + [7] Const mutate z$9_@1:TObject = Object { }
92 + [8] Reassign mutate x$7_@0.z[1:10] = read z$9_@1:TObject
93 "]
94 bb3_instrs --> bb3_terminal(["Goto"])
95 end
96 subgraph bb1
97 - bb1_terminal(["Return freeze x$7_@0"])
97 + bb1_terminal(["Return freeze x$7_@0:TObject"])
98 end
99
100 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate.expect.md
+18 -18
@@ -19,12 +19,12 @@ function foo() {
19
20 ```
21 bb0:
22 - [1] Const mutate a$5_@0[1:6] = Object { }
23 - [2] Const mutate x$6_@0[1:6] = read a$5_@0
24 - [3] Const mutate y$7_@0[1:6] = Object { }
25 - [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0
26 - [5] Call mutate mutate$4(mutate a$5_@0)
27 - [6] Return freeze y$7_@0
22 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
23 + [2] Const mutate x$6_@0:TObject[1:6] = read a$5_@0:TObject
24 + [3] Const mutate y$7_@0:TObject[1:6] = Object { }
25 + [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0:TObject
26 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
27 + [6] Return freeze y$7_@0:TObject
28
29 ```
30
@@ -34,13 +34,13 @@ bb0:
34 function foo(
35 ) {
36 scope @0 [1:6] deps=[] {
37 - [1] Const mutate a$5_@0[1:6] = Object { }
38 - [2] Const mutate x$6_@0[1:6] = read a$5_@0
39 - [3] Const mutate y$7_@0[1:6] = Object { }
40 - [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0
41 - [5] Call mutate mutate$4(mutate a$5_@0)
37 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
38 + [2] Const mutate x$6_@0:TObject[1:6] = read a$5_@0:TObject
39 + [3] Const mutate y$7_@0:TObject[1:6] = Object { }
40 + [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0:TObject
41 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
42 }
43 - return freeze y$7_@0
43 + return freeze y$7_@0:TObject
44 }
45
46 ```
@@ -52,13 +52,13 @@ flowchart TB
52 %% Basic Blocks
53 subgraph bb0
54 bb0_instrs["
55 - [1] Const mutate a$5_@0[1:6] = Object { }
56 - [2] Const mutate x$6_@0[1:6] = read a$5_@0
57 - [3] Const mutate y$7_@0[1:6] = Object { }
58 - [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0
59 - [5] Call mutate mutate$4(mutate a$5_@0)
55 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
56 + [2] Const mutate x$6_@0:TObject[1:6] = read a$5_@0:TObject
57 + [3] Const mutate y$7_@0:TObject[1:6] = Object { }
58 + [4] Reassign mutate y$7_@0.x[1:6] = read x$6_@0:TObject
59 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
60 "]
61 - bb0_instrs --> bb0_terminal(["Return freeze y$7_@0"])
61 + bb0_instrs --> bb0_terminal(["Return freeze y$7_@0:TObject"])
62 end
63
64 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md
+6 -6
@@ -16,10 +16,10 @@ function foo() {
16 ```
17 bb0:
18 [1] Const mutate x$4_@0 = Array []
19 - [2] Const mutate y$5_@1[2:5] = Object { x: read x$4_@0 }
19 + [2] Const mutate y$5_@1:TObject[2:5] = Object { x: read x$4_@0 }
20 [3] Const mutate $6_@1[2:5] = Array []
21 [4] Call mutate y$5_@1.x.push(mutate $6_@1)
22 - [5] Return freeze y$5_@1
22 + [5] Return freeze y$5_@1:TObject
23 scope1 [2:5]:
24 - dependency: read x$4_@0
25 ```
@@ -33,11 +33,11 @@ function foo(
33 [1] Const mutate x$4_@0 = Array []
34 }
35 scope @1 [2:5] deps=[read x$4_@0] {
36 - [2] Const mutate y$5_@1[2:5] = Object { x: read x$4_@0 }
36 + [2] Const mutate y$5_@1:TObject[2:5] = Object { x: read x$4_@0 }
37 [3] Const mutate $6_@1[2:5] = Array []
38 [4] Call mutate y$5_@1.x.push(mutate $6_@1)
39 }
40 - return freeze y$5_@1
40 + return freeze y$5_@1:TObject
41 }
42
43 ```
@@ -50,11 +50,11 @@ flowchart TB
50 subgraph bb0
51 bb0_instrs["
52 [1] Const mutate x$4_@0 = Array []
53 - [2] Const mutate y$5_@1[2:5] = Object { x: read x$4_@0 }
53 + [2] Const mutate y$5_@1:TObject[2:5] = Object { x: read x$4_@0 }
54 [3] Const mutate $6_@1[2:5] = Array []
55 [4] Call mutate y$5_@1.x.push(mutate $6_@1)
56 "]
57 - bb0_instrs --> bb0_terminal(["Return freeze y$5_@1"])
57 + bb0_instrs --> bb0_terminal(["Return freeze y$5_@1:TObject"])
58 end
59
60 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-2.expect.md
+9 -9
@@ -17,10 +17,10 @@ function foo() {
17 ```
18 bb0:
19 [1] Const mutate x$4_@0[1:5] = Array []
20 - [2] Const mutate y$5_@0[1:5] = Object { }
20 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
21 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
22 - [4] Call mutate mutate$3(mutate x$4_@0)
23 - [5] Return freeze y$5_@0
22 + [4] Call mutate mutate$3:TFunction(mutate x$4_@0)
23 + [5] Return freeze y$5_@0:TObject
24
25 ```
26
@@ -31,11 +31,11 @@ function foo(
31 ) {
32 scope @0 [1:5] deps=[] {
33 [1] Const mutate x$4_@0[1:5] = Array []
34 - [2] Const mutate y$5_@0[1:5] = Object { }
34 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
35 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
36 - [4] Call mutate mutate$3(mutate x$4_@0)
36 + [4] Call mutate mutate$3:TFunction(mutate x$4_@0)
37 }
38 - return freeze y$5_@0
38 + return freeze y$5_@0:TObject
39 }
40
41 ```
@@ -48,11 +48,11 @@ flowchart TB
48 subgraph bb0
49 bb0_instrs["
50 [1] Const mutate x$4_@0[1:5] = Array []
51 - [2] Const mutate y$5_@0[1:5] = Object { }
51 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
52 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
53 - [4] Call mutate mutate$3(mutate x$4_@0)
53 + [4] Call mutate mutate$3:TFunction(mutate x$4_@0)
54 "]
55 - bb0_instrs --> bb0_terminal(["Return freeze y$5_@0"])
55 + bb0_instrs --> bb0_terminal(["Return freeze y$5_@0:TObject"])
56 end
57
58 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-alias.expect.md
+12 -12
@@ -19,12 +19,12 @@ function foo() {
19
20 ```
21 bb0:
22 - [1] Const mutate a$5_@0[1:6] = Object { }
23 - [2] Const mutate y$6_@0[1:6] = read a$5_@0
22 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
23 + [2] Const mutate y$6_@0:TObject[1:6] = read a$5_@0:TObject
24 [3] Const mutate x$7_@0[1:6] = Array []
25 [4] Reassign mutate y$6_@0.x[1:6] = read x$7_@0
26 - [5] Call mutate mutate$4(mutate a$5_@0)
27 - [6] Return freeze y$6_@0
26 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
27 + [6] Return freeze y$6_@0:TObject
28
29 ```
30
@@ -34,13 +34,13 @@ bb0:
34 function foo(
35 ) {
36 scope @0 [1:6] deps=[] {
37 - [1] Const mutate a$5_@0[1:6] = Object { }
38 - [2] Const mutate y$6_@0[1:6] = read a$5_@0
37 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
38 + [2] Const mutate y$6_@0:TObject[1:6] = read a$5_@0:TObject
39 [3] Const mutate x$7_@0[1:6] = Array []
40 [4] Reassign mutate y$6_@0.x[1:6] = read x$7_@0
41 - [5] Call mutate mutate$4(mutate a$5_@0)
41 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
42 }
43 - return freeze y$6_@0
43 + return freeze y$6_@0:TObject
44 }
45
46 ```
@@ -52,13 +52,13 @@ flowchart TB
52 %% Basic Blocks
53 subgraph bb0
54 bb0_instrs["
55 - [1] Const mutate a$5_@0[1:6] = Object { }
56 - [2] Const mutate y$6_@0[1:6] = read a$5_@0
55 + [1] Const mutate a$5_@0:TObject[1:6] = Object { }
56 + [2] Const mutate y$6_@0:TObject[1:6] = read a$5_@0:TObject
57 [3] Const mutate x$7_@0[1:6] = Array []
58 [4] Reassign mutate y$6_@0.x[1:6] = read x$7_@0
59 - [5] Call mutate mutate$4(mutate a$5_@0)
59 + [5] Call mutate mutate$4:TFunction(mutate a$5_@0:TObject)
60 "]
61 - bb0_instrs --> bb0_terminal(["Return freeze y$6_@0"])
61 + bb0_instrs --> bb0_terminal(["Return freeze y$6_@0:TObject"])
62 end
63
64 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate.expect.md
+9 -9
@@ -17,10 +17,10 @@ function foo() {
17 ```
18 bb0:
19 [1] Const mutate x$4_@0[1:5] = Array []
20 - [2] Const mutate y$5_@0[1:5] = Object { }
20 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
21 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
22 - [4] Call mutate mutate$3(mutate y$5_@0)
23 - [5] Return freeze y$5_@0
22 + [4] Call mutate mutate$3:TFunction(mutate y$5_@0:TObject)
23 + [5] Return freeze y$5_@0:TObject
24
25 ```
26
@@ -31,11 +31,11 @@ function foo(
31 ) {
32 scope @0 [1:5] deps=[] {
33 [1] Const mutate x$4_@0[1:5] = Array []
34 - [2] Const mutate y$5_@0[1:5] = Object { }
34 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
35 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
36 - [4] Call mutate mutate$3(mutate y$5_@0)
36 + [4] Call mutate mutate$3:TFunction(mutate y$5_@0:TObject)
37 }
38 - return freeze y$5_@0
38 + return freeze y$5_@0:TObject
39 }
40
41 ```
@@ -48,11 +48,11 @@ flowchart TB
48 subgraph bb0
49 bb0_instrs["
50 [1] Const mutate x$4_@0[1:5] = Array []
51 - [2] Const mutate y$5_@0[1:5] = Object { }
51 + [2] Const mutate y$5_@0:TObject[1:5] = Object { }
52 [3] Reassign mutate y$5_@0.x[1:5] = read x$4_@0
53 - [4] Call mutate mutate$3(mutate y$5_@0)
53 + [4] Call mutate mutate$3:TFunction(mutate y$5_@0:TObject)
54 "]
55 - bb0_instrs --> bb0_terminal(["Return freeze y$5_@0"])
55 + bb0_instrs --> bb0_terminal(["Return freeze y$5_@0:TObject"])
56 end
57
58 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md
+6 -6
@@ -16,9 +16,9 @@ function foo() {
16 ```
17 bb0:
18 [1] Const mutate x$3_@0 = Array []
19 - [2] Const mutate y$4_@1[2:4] = Object { }
19 + [2] Const mutate y$4_@1:TObject[2:4] = Object { }
20 [3] Reassign mutate y$4_@1.x[2:4] = read x$3_@0
21 - [4] Return freeze y$4_@1
21 + [4] Return freeze y$4_@1:TObject
22 scope1 [2:4]:
23 - dependency: read x$3_@0
24 ```
@@ -32,10 +32,10 @@ function foo(
32 [1] Const mutate x$3_@0 = Array []
33 }
34 scope @1 [2:4] deps=[read x$3_@0] {
35 - [2] Const mutate y$4_@1[2:4] = Object { }
35 + [2] Const mutate y$4_@1:TObject[2:4] = Object { }
36 [3] Reassign mutate y$4_@1.x[2:4] = read x$3_@0
37 }
38 - return freeze y$4_@1
38 + return freeze y$4_@1:TObject
39 }
40
41 ```
@@ -48,10 +48,10 @@ flowchart TB
48 subgraph bb0
49 bb0_instrs["
50 [1] Const mutate x$3_@0 = Array []
51 - [2] Const mutate y$4_@1[2:4] = Object { }
51 + [2] Const mutate y$4_@1:TObject[2:4] = Object { }
52 [3] Reassign mutate y$4_@1.x[2:4] = read x$3_@0
53 "]
54 - bb0_instrs --> bb0_terminal(["Return freeze y$4_@1"])
54 + bb0_instrs --> bb0_terminal(["Return freeze y$4_@1:TObject"])
55 end
56
57 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-reassign.expect.md
+3 -3
@@ -16,7 +16,7 @@ function foo(a, b, c) {
16
17 ```
18 bb0:
19 - [1] Const mutate x$8_@0 = 0
19 + [1] Const mutate x$8_@0:TPrimitive = 0
20 [2] Const mutate x$9_@1 = read a$5
21 [3] Const mutate x$10_@2 = read b$6
22 [4] Const mutate x$11_@3 = read c$7
@@ -37,7 +37,7 @@ function foo(
37 b,
38 c,
39 ) {
40 - [1] Const mutate x$8_@0 = 0
40 + [1] Const mutate x$8_@0:TPrimitive = 0
41 [2] Const mutate x$9_@1 = read a$5
42 [3] Const mutate x$10_@2 = read b$6
43 [4] Const mutate x$11_@3 = read c$7
@@ -53,7 +53,7 @@ flowchart TB
53 %% Basic Blocks
54 subgraph bb0
55 bb0_instrs["
56 - [1] Const mutate x$8_@0 = 0
56 + [1] Const mutate x$8_@0:TPrimitive = 0
57 [2] Const mutate x$9_@1 = read a$5
58 [3] Const mutate x$10_@2 = read b$6
59 [4] Const mutate x$11_@3 = read c$7
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+18 -18
@@ -17,17 +17,17 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$4_@0[1:7] = 1
21 - [2] Const mutate $5_@1 = 1
22 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
23 - [4] If (read $6_@0) then:bb2 else:bb1 fallthrough=bb1
20 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
21 + [2] Const mutate $5_@1:TPrimitive = 1
22 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
23 + [4] If (read $6_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
24 bb2:
25 predecessor blocks: bb0
26 - [5] Reassign mutate x$4_@0[1:7] = 2
26 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
27 [6] Goto bb1
28 bb1:
29 predecessor blocks: bb2 bb0
30 - [7] Return read x$4_@0
30 + [7] Return read x$4_@0:TPrimitive
31
32 ```
33
@@ -37,14 +37,14 @@ bb1:
37 function foo(
38 ) {
39 scope @0 [1:7] deps=[] {
40 - [1] Let mutate x$4_@0[1:7] = 1
41 - [2] Const mutate $5_@1 = 1
42 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
43 - if (read $6_@0) {
44 - [5] Reassign mutate x$4_@0[1:7] = 2
40 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
41 + [2] Const mutate $5_@1:TPrimitive = 1
42 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
43 + if (read $6_@0:TPrimitive) {
44 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
45 }
46 }
47 - return read x$4_@0
47 + return read x$4_@0:TPrimitive
48 }
49
50 ```
@@ -56,20 +56,20 @@ flowchart TB
56 %% Basic Blocks
57 subgraph bb0
58 bb0_instrs["
59 - [1] Let mutate x$4_@0[1:7] = 1
60 - [2] Const mutate $5_@1 = 1
61 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
59 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
60 + [2] Const mutate $5_@1:TPrimitive = 1
61 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
62 "]
63 - bb0_instrs --> bb0_terminal(["If (read $6_@0)"])
63 + bb0_instrs --> bb0_terminal(["If (read $6_@0:TPrimitive)"])
64 end
65 subgraph bb2
66 bb2_instrs["
67 - [5] Reassign mutate x$4_@0[1:7] = 2
67 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
68 "]
69 bb2_instrs --> bb2_terminal(["Goto"])
70 end
71 subgraph bb1
72 - bb1_terminal(["Return read x$4_@0"])
72 + bb1_terminal(["Return read x$4_@0:TPrimitive"])
73 end
74
75 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md
+15 -15
@@ -58,20 +58,20 @@ function log$0() {}
58
59 ```
60 bb0:
61 - [1] Let mutate str$6_@0[1:8] = ""
61 + [1] Let mutate str$6_@0:TPrimitive[1:8] = ""
62 [2] If (read cond$5) then:bb2 else:bb3 fallthrough=bb1
63 bb2:
64 predecessor blocks: bb0
65 - [3] Const mutate str$7_@1 = "other test"
66 - [4] Call mutate log$4(read str$7_@1)
65 + [3] Const mutate str$7_@1:TPrimitive = "other test"
66 + [4] Call mutate log$4:TFunction(read str$7_@1:TPrimitive)
67 [5] Goto bb1
68 bb3:
69 predecessor blocks: bb0
70 - [6] Reassign mutate str$6_@0[1:8] = "fallthrough test"
70 + [6] Reassign mutate str$6_@0:TPrimitive[1:8] = "fallthrough test"
71 [7] Goto bb1
72 bb1:
73 predecessor blocks: bb2 bb3
74 - [8] Call mutate log$4(read str$6_@0)
74 + [8] Call mutate log$4:TFunction(read str$6_@0:TPrimitive)
75 [9] Return
76 scope0 [1:8]:
77 - dependency: read cond$5
@@ -84,15 +84,15 @@ function Foo(
84 cond,
85 ) {
86 scope @0 [1:8] deps=[read cond$5] {
87 - [1] Let mutate str$6_@0[1:8] = ""
87 + [1] Let mutate str$6_@0:TPrimitive[1:8] = ""
88 if (read cond$5) {
89 - [3] Const mutate str$7_@1 = "other test"
90 - [4] Call mutate log$4(read str$7_@1)
89 + [3] Const mutate str$7_@1:TPrimitive = "other test"
90 + [4] Call mutate log$4:TFunction(read str$7_@1:TPrimitive)
91 } else {
92 - [6] Reassign mutate str$6_@0[1:8] = "fallthrough test"
92 + [6] Reassign mutate str$6_@0:TPrimitive[1:8] = "fallthrough test"
93 }
94 }
95 - [8] Call mutate log$4(read str$6_@0)
95 + [8] Call mutate log$4:TFunction(read str$6_@0:TPrimitive)
96 return
97 }
98
@@ -105,26 +105,26 @@ flowchart TB
105 %% Basic Blocks
106 subgraph bb0
107 bb0_instrs["
108 - [1] Let mutate str$6_@0[1:8] = ''
108 + [1] Let mutate str$6_@0:TPrimitive[1:8] = ''
109 "]
110 bb0_instrs --> bb0_terminal(["If (read cond$5)"])
111 end
112 subgraph bb2
113 bb2_instrs["
114 - [3] Const mutate str$7_@1 = 'other test'
115 - [4] Call mutate log$4(read str$7_@1)
114 + [3] Const mutate str$7_@1:TPrimitive = 'other test'
115 + [4] Call mutate log$4:TFunction(read str$7_@1:TPrimitive)
116 "]
117 bb2_instrs --> bb2_terminal(["Goto"])
118 end
119 subgraph bb3
120 bb3_instrs["
121 - [6] Reassign mutate str$6_@0[1:8] = 'fallthrough test'
121 + [6] Reassign mutate str$6_@0:TPrimitive[1:8] = 'fallthrough test'
122 "]
123 bb3_instrs --> bb3_terminal(["Goto"])
124 end
125 subgraph bb1
126 bb1_instrs["
127 - [8] Call mutate log$4(read str$6_@0)
127 + [8] Call mutate log$4:TFunction(read str$6_@0:TPrimitive)
128 "]
129 bb1_instrs --> bb1_terminal(["Return"])
130 end
compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md
+25 -25
@@ -28,14 +28,14 @@ function foo(a, b, c, d) {
28
29 ```
30 bb0:
31 - [1] Const mutate x$13_@0 = 0
32 - [2] Const mutate $14_@1 = true
33 - [3] If (read $14_@1) then:bb2 else:bb6 fallthrough=bb1
31 + [1] Const mutate x$13_@0:TPrimitive = 0
32 + [2] Const mutate $14_@1:TPrimitive = true
33 + [3] If (read $14_@1:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
34 bb2:
35 predecessor blocks: bb0
36 - [4] Const mutate $15_@2 = true
36 + [4] Const mutate $15_@2:TPrimitive = true
37 [5] Let mutate x$16_@3[5:10] = undefined
38 - [5] If (read $15_@2) then:bb4 else:bb5 fallthrough=bb3
38 + [5] If (read $15_@2:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
39 bb4:
40 predecessor blocks: bb2
41 [6] Reassign mutate x$16_@3[5:10] = read a$9
@@ -50,9 +50,9 @@ bb3:
50 [11] Goto bb1
51 bb6:
52 predecessor blocks: bb0
53 - [12] Const mutate $19_@4 = true
53 + [12] Const mutate $19_@4:TPrimitive = true
54 [13] Let mutate x$20_@5[13:18] = undefined
55 - [13] If (read $19_@4) then:bb8 else:bb9 fallthrough=bb7
55 + [13] If (read $19_@4:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
56 bb8:
57 predecessor blocks: bb6
58 [14] Reassign mutate x$20_@5[13:18] = read c$11
@@ -71,11 +71,11 @@ bb1:
71 scope3 [5:10]:
72 - dependency: read a$9
73 - dependency: read b$10
74 - - dependency: read $15_@2
74 + - dependency: read $15_@2:TPrimitive
75 scope5 [13:18]:
76 - dependency: read c$11
77 - dependency: read d$12
78 - - dependency: read $19_@4
78 + - dependency: read $19_@4:TPrimitive
79 ```
80
81 ## Reactive Scopes
@@ -87,13 +87,13 @@ function foo(
87 c,
88 d,
89 ) {
90 - [1] Const mutate x$13_@0 = 0
91 - [2] Const mutate $14_@1 = true
92 - if (read $14_@1) {
93 - [4] Const mutate $15_@2 = true
94 - scope @3 [5:10] deps=[read a$9, read b$10, read $15_@2] {
90 + [1] Const mutate x$13_@0:TPrimitive = 0
91 + [2] Const mutate $14_@1:TPrimitive = true
92 + if (read $14_@1:TPrimitive) {
93 + [4] Const mutate $15_@2:TPrimitive = true
94 + scope @3 [5:10] deps=[read a$9, read b$10, read $15_@2:TPrimitive] {
95 [5] Let mutate x$16_@3[5:10] = undefined
96 - if (read $15_@2) {
96 + if (read $15_@2:TPrimitive) {
97 [6] Reassign mutate x$16_@3[5:10] = read a$9
98 } else {
99 [8] Reassign mutate x$16_@3[5:10] = read b$10
@@ -101,10 +101,10 @@ function foo(
101 }
102 [10] read x$16_@3
103 } else {
104 - [12] Const mutate $19_@4 = true
105 - scope @5 [13:18] deps=[read c$11, read d$12, read $19_@4] {
104 + [12] Const mutate $19_@4:TPrimitive = true
105 + scope @5 [13:18] deps=[read c$11, read d$12, read $19_@4:TPrimitive] {
106 [13] Let mutate x$20_@5[13:18] = undefined
107 - if (read $19_@4) {
107 + if (read $19_@4:TPrimitive) {
108 [14] Reassign mutate x$20_@5[13:18] = read c$11
109 } else {
110 [16] Reassign mutate x$20_@5[13:18] = read d$12
@@ -124,17 +124,17 @@ flowchart TB
124 %% Basic Blocks
125 subgraph bb0
126 bb0_instrs["
127 - [1] Const mutate x$13_@0 = 0
128 - [2] Const mutate $14_@1 = true
127 + [1] Const mutate x$13_@0:TPrimitive = 0
128 + [2] Const mutate $14_@1:TPrimitive = true
129 "]
130 - bb0_instrs --> bb0_terminal(["If (read $14_@1)"])
130 + bb0_instrs --> bb0_terminal(["If (read $14_@1:TPrimitive)"])
131 end
132 subgraph bb2
133 bb2_instrs["
134 - [4] Const mutate $15_@2 = true
134 + [4] Const mutate $15_@2:TPrimitive = true
135 [5] Let mutate x$16_@3[5:10] = undefined
136 "]
137 - bb2_instrs --> bb2_terminal(["If (read $15_@2)"])
137 + bb2_instrs --> bb2_terminal(["If (read $15_@2:TPrimitive)"])
138 end
139 subgraph bb4
140 bb4_instrs["
@@ -156,10 +156,10 @@ flowchart TB
156 end
157 subgraph bb6
158 bb6_instrs["
159 - [12] Const mutate $19_@4 = true
159 + [12] Const mutate $19_@4:TPrimitive = true
160 [13] Let mutate x$20_@5[13:18] = undefined
161 "]
162 - bb6_instrs --> bb6_terminal(["If (read $19_@4)"])
162 + bb6_instrs --> bb6_terminal(["If (read $19_@4:TPrimitive)"])
163 end
164 subgraph bb8
165 bb8_instrs["
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+29 -29
@@ -20,30 +20,30 @@ function foo() {
20
21 ```
22 bb0:
23 - [1] Const mutate y$5_@0 = 2
24 - [2] Const mutate $6_@1 = 1
25 - [3] Const mutate $7_@2 = Binary read y$5_@0 > read $6_@1
26 - [4] Let mutate y$8_@3[4:9] = undefined
27 - [4] If (read $7_@2) then:bb2 else:bb3 fallthrough=bb1
23 + [1] Const mutate y$5_@0:TPrimitive = 2
24 + [2] Const mutate $6_@1:TPrimitive = 1
25 + [3] Const mutate $7_@2:TPrimitive = Binary read y$5_@0:TPrimitive > read $6_@1:TPrimitive
26 + [4] Let mutate y$8_@3:TPrimitive[4:9] = undefined
27 + [4] If (read $7_@2:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
28 bb2:
29 predecessor blocks: bb0
30 - [5] Reassign mutate y$8_@3[4:9] = 1
30 + [5] Reassign mutate y$8_@3:TPrimitive[4:9] = 1
31 [6] Goto bb1
32 bb3:
33 predecessor blocks: bb0
34 - [7] Reassign mutate y$8_@3[4:9] = 2
34 + [7] Reassign mutate y$8_@3:TPrimitive[4:9] = 2
35 [8] Goto bb1
36 bb1:
37 predecessor blocks: bb2 bb3
38 - [9] Const mutate x$11_@4 = read y$8_@3
38 + [9] Const mutate x$11_@4 = read y$8_@3:TPrimitive
39 [10] Return
40 scope2 [3:4]:
41 - - dependency: read y$5_@0
42 - - dependency: read $6_@1
41 + - dependency: read y$5_@0:TPrimitive
42 + - dependency: read $6_@1:TPrimitive
43 scope3 [4:9]:
44 - - dependency: read $7_@2
44 + - dependency: read $7_@2:TPrimitive
45 scope4 [9:10]:
46 - - dependency: read y$8_@3
46 + - dependency: read y$8_@3:TPrimitive
47 ```
48
49 ## Reactive Scopes
@@ -51,18 +51,18 @@ scope4 [9:10]:
51 ```
52 function foo(
53 ) {
54 - [1] Const mutate y$5_@0 = 2
55 - [2] Const mutate $6_@1 = 1
56 - [3] Const mutate $7_@2 = Binary read y$5_@0 > read $6_@1
57 - scope @3 [4:9] deps=[read $7_@2] {
58 - [4] Let mutate y$8_@3[4:9] = undefined
59 - if (read $7_@2) {
60 - [5] Reassign mutate y$8_@3[4:9] = 1
54 + [1] Const mutate y$5_@0:TPrimitive = 2
55 + [2] Const mutate $6_@1:TPrimitive = 1
56 + [3] Const mutate $7_@2:TPrimitive = Binary read y$5_@0:TPrimitive > read $6_@1:TPrimitive
57 + scope @3 [4:9] deps=[read $7_@2:TPrimitive] {
58 + [4] Let mutate y$8_@3:TPrimitive[4:9] = undefined
59 + if (read $7_@2:TPrimitive) {
60 + [5] Reassign mutate y$8_@3:TPrimitive[4:9] = 1
61 } else {
62 - [7] Reassign mutate y$8_@3[4:9] = 2
62 + [7] Reassign mutate y$8_@3:TPrimitive[4:9] = 2
63 }
64 }
65 - [9] Const mutate x$11_@4 = read y$8_@3
65 + [9] Const mutate x$11_@4 = read y$8_@3:TPrimitive
66 return
67 }
68
@@ -75,28 +75,28 @@ flowchart TB
75 %% Basic Blocks
76 subgraph bb0
77 bb0_instrs["
78 - [1] Const mutate y$5_@0 = 2
79 - [2] Const mutate $6_@1 = 1
80 - [3] Const mutate $7_@2 = Binary read y$5_@0 > read $6_@1
81 - [4] Let mutate y$8_@3[4:9] = undefined
78 + [1] Const mutate y$5_@0:TPrimitive = 2
79 + [2] Const mutate $6_@1:TPrimitive = 1
80 + [3] Const mutate $7_@2:TPrimitive = Binary read y$5_@0:TPrimitive > read $6_@1:TPrimitive
81 + [4] Let mutate y$8_@3:TPrimitive[4:9] = undefined
82 "]
83 - bb0_instrs --> bb0_terminal(["If (read $7_@2)"])
83 + bb0_instrs --> bb0_terminal(["If (read $7_@2:TPrimitive)"])
84 end
85 subgraph bb2
86 bb2_instrs["
87 - [5] Reassign mutate y$8_@3[4:9] = 1
87 + [5] Reassign mutate y$8_@3:TPrimitive[4:9] = 1
88 "]
89 bb2_instrs --> bb2_terminal(["Goto"])
90 end
91 subgraph bb3
92 bb3_instrs["
93 - [7] Reassign mutate y$8_@3[4:9] = 2
93 + [7] Reassign mutate y$8_@3:TPrimitive[4:9] = 2
94 "]
95 bb3_instrs --> bb3_terminal(["Goto"])
96 end
97 subgraph bb1
98 bb1_instrs["
99 - [9] Const mutate x$11_@4 = read y$8_@3
99 + [9] Const mutate x$11_@4 = read y$8_@3:TPrimitive
100 "]
101 bb1_instrs --> bb1_terminal(["Return"])
102 end
compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md
+6 -6
@@ -13,8 +13,8 @@ function foo() {
13
14 ```
15 bb0:
16 - [1] Const mutate x$3_@0 = 1
17 - [2] Const mutate y$4_@1 = 2
16 + [1] Const mutate x$3_@0:TPrimitive = 1
17 + [2] Const mutate y$4_@1:TPrimitive = 2
18 [3] Return
19
20 ```
@@ -24,8 +24,8 @@ bb0:
24 ```
25 function foo(
26 ) {
27 - [1] Const mutate x$3_@0 = 1
28 - [2] Const mutate y$4_@1 = 2
27 + [1] Const mutate x$3_@0:TPrimitive = 1
28 + [2] Const mutate y$4_@1:TPrimitive = 2
29 return
30 }
31
@@ -38,8 +38,8 @@ flowchart TB
38 %% Basic Blocks
39 subgraph bb0
40 bb0_instrs["
41 - [1] Const mutate x$3_@0 = 1
42 - [2] Const mutate y$4_@1 = 2
41 + [1] Const mutate x$3_@0:TPrimitive = 1
42 + [2] Const mutate y$4_@1:TPrimitive = 2
43 "]
44 bb0_instrs --> bb0_terminal(["Return"])
45 end
compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md
+14 -14
@@ -17,19 +17,19 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Const mutate x$4_@0 = 1
21 - [2] Const mutate y$5_@1 = 2
22 - [3] If (read y$5_@1) then:bb2 else:bb1 fallthrough=bb1
20 + [1] Const mutate x$4_@0:TPrimitive = 1
21 + [2] Const mutate y$5_@1:TPrimitive = 2
22 + [3] If (read y$5_@1:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23 bb2:
24 predecessor blocks: bb0
25 - [4] Const mutate z$6_@2 = Binary read x$4_@0 + read y$5_@1
25 + [4] Const mutate z$6_@2:TPrimitive = Binary read x$4_@0:TPrimitive + read y$5_@1:TPrimitive
26 [5] Goto bb1
27 bb1:
28 predecessor blocks: bb2 bb0
29 [6] Return
30 scope2 [4:5]:
31 - - dependency: read x$4_@0
32 - - dependency: read y$5_@1
31 + - dependency: read x$4_@0:TPrimitive
32 + - dependency: read y$5_@1:TPrimitive
33 ```
34
35 ## Reactive Scopes
@@ -37,10 +37,10 @@ scope2 [4:5]:
37 ```
38 function foo(
39 ) {
40 - [1] Const mutate x$4_@0 = 1
41 - [2] Const mutate y$5_@1 = 2
42 - if (read y$5_@1) {
43 - [4] Const mutate z$6_@2 = Binary read x$4_@0 + read y$5_@1
40 + [1] Const mutate x$4_@0:TPrimitive = 1
41 + [2] Const mutate y$5_@1:TPrimitive = 2
42 + if (read y$5_@1:TPrimitive) {
43 + [4] Const mutate z$6_@2:TPrimitive = Binary read x$4_@0:TPrimitive + read y$5_@1:TPrimitive
44 }
45 return
46 }
@@ -54,14 +54,14 @@ flowchart TB
54 %% Basic Blocks
55 subgraph bb0
56 bb0_instrs["
57 - [1] Const mutate x$4_@0 = 1
58 - [2] Const mutate y$5_@1 = 2
57 + [1] Const mutate x$4_@0:TPrimitive = 1
58 + [2] Const mutate y$5_@1:TPrimitive = 2
59 "]
60 - bb0_instrs --> bb0_terminal(["If (read y$5_@1)"])
60 + bb0_instrs --> bb0_terminal(["If (read y$5_@1:TPrimitive)"])
61 end
62 subgraph bb2
63 bb2_instrs["
64 - [4] Const mutate z$6_@2 = Binary read x$4_@0 + read y$5_@1
64 + [4] Const mutate z$6_@2:TPrimitive = Binary read x$4_@0:TPrimitive + read y$5_@1:TPrimitive
65 "]
66 bb2_instrs --> bb2_terminal(["Goto"])
67 end
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+58 -58
@@ -28,52 +28,52 @@ function foo() {
28
29 ```
30 bb0:
31 - [1] Const mutate x$10_@0 = 1
32 - [2] Const mutate $11_@1 = 2
33 - [3] Const mutate $12_@2 = Binary read x$10_@0 === read $11_@1
34 - [4] Const mutate $13_@3 = 1
35 - [5] Const mutate $14_@4 = Binary read x$10_@0 === read $13_@3
36 - [6] Let mutate x$16_@5[6:16] = undefined
37 - [6] Switch (read x$10_@0)
38 - Case read $14_@4: bb5
39 - Case read $12_@2: bb3
31 + [1] Const mutate x$10_@0:TPrimitive = 1
32 + [2] Const mutate $11_@1:TPrimitive = 2
33 + [3] Const mutate $12_@2:TPrimitive = Binary read x$10_@0:TPrimitive === read $11_@1:TPrimitive
34 + [4] Const mutate $13_@3:TPrimitive = 1
35 + [5] Const mutate $14_@4:TPrimitive = Binary read x$10_@0:TPrimitive === read $13_@3:TPrimitive
36 + [6] Let mutate x$16_@5:TPrimitive[6:16] = undefined
37 + [6] Switch (read x$10_@0:TPrimitive)
38 + Case read $14_@4:TPrimitive: bb5
39 + Case read $12_@2:TPrimitive: bb3
40 Default: bb2
41 Fallthrough: bb1
42 bb5:
43 predecessor blocks: bb0
44 - [7] Const mutate $15_@6 = 1
45 - [8] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $15_@6
44 + [7] Const mutate $15_@6:TPrimitive = 1
45 + [8] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $15_@6:TPrimitive
46 [9] Goto bb1
47 bb3:
48 predecessor blocks: bb0
49 - [10] Const mutate $17_@7 = 2
50 - [11] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $17_@7
49 + [10] Const mutate $17_@7:TPrimitive = 2
50 + [11] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $17_@7:TPrimitive
51 [12] Goto bb1
52 bb2:
53 predecessor blocks: bb0
54 - [13] Const mutate $19_@8 = 3
55 - [14] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $19_@8
54 + [13] Const mutate $19_@8:TPrimitive = 3
55 + [14] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $19_@8:TPrimitive
56 [15] Goto bb1
57 bb1:
58 predecessor blocks: bb5 bb3 bb2
59 - [16] Const mutate y$22_@9 = read x$16_@5
59 + [16] Const mutate y$22_@9 = read x$16_@5:TPrimitive
60 [17] Return
61 scope2 [3:4]:
62 - - dependency: read x$10_@0
63 - - dependency: read $11_@1
62 + - dependency: read x$10_@0:TPrimitive
63 + - dependency: read $11_@1:TPrimitive
64 scope4 [5:6]:
65 - - dependency: read x$10_@0
66 - - dependency: read $13_@3
65 + - dependency: read x$10_@0:TPrimitive
66 + - dependency: read $13_@3:TPrimitive
67 scope5 [6:16]:
68 - - dependency: read x$10_@0
68 + - dependency: read x$10_@0:TPrimitive
69 scope6 [7:8]:
70 - - dependency: read x$10_@0
70 + - dependency: read x$10_@0:TPrimitive
71 scope7 [10:11]:
72 - - dependency: read x$10_@0
72 + - dependency: read x$10_@0:TPrimitive
73 scope8 [13:14]:
74 - - dependency: read x$10_@0
74 + - dependency: read x$10_@0:TPrimitive
75 scope9 [16:17]:
76 - - dependency: read x$16_@5
76 + - dependency: read x$16_@5:TPrimitive
77 ```
78
79 ## Reactive Scopes
@@ -81,31 +81,31 @@ scope9 [16:17]:
81 ```
82 function foo(
83 ) {
84 - [1] Const mutate x$10_@0 = 1
85 - [2] Const mutate $11_@1 = 2
86 - [3] Const mutate $12_@2 = Binary read x$10_@0 === read $11_@1
87 - [4] Const mutate $13_@3 = 1
88 - [5] Const mutate $14_@4 = Binary read x$10_@0 === read $13_@3
89 - scope @5 [6:16] deps=[read x$10_@0] {
90 - [6] Let mutate x$16_@5[6:16] = undefined
91 - switch (read x$10_@0) {
92 - case read $14_@4: {
93 - [7] Const mutate $15_@6 = 1
94 - [8] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $15_@6
84 + [1] Const mutate x$10_@0:TPrimitive = 1
85 + [2] Const mutate $11_@1:TPrimitive = 2
86 + [3] Const mutate $12_@2:TPrimitive = Binary read x$10_@0:TPrimitive === read $11_@1:TPrimitive
87 + [4] Const mutate $13_@3:TPrimitive = 1
88 + [5] Const mutate $14_@4:TPrimitive = Binary read x$10_@0:TPrimitive === read $13_@3:TPrimitive
89 + scope @5 [6:16] deps=[read x$10_@0:TPrimitive] {
90 + [6] Let mutate x$16_@5:TPrimitive[6:16] = undefined
91 + switch (read x$10_@0:TPrimitive) {
92 + case read $14_@4:TPrimitive: {
93 + [7] Const mutate $15_@6:TPrimitive = 1
94 + [8] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $15_@6:TPrimitive
95 break bb1
96 }
97 - case read $12_@2: {
98 - [10] Const mutate $17_@7 = 2
99 - [11] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $17_@7
97 + case read $12_@2:TPrimitive: {
98 + [10] Const mutate $17_@7:TPrimitive = 2
99 + [11] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $17_@7:TPrimitive
100 break bb1
101 }
102 default: {
103 - [13] Const mutate $19_@8 = 3
104 - [14] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $19_@8
103 + [13] Const mutate $19_@8:TPrimitive = 3
104 + [14] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $19_@8:TPrimitive
105 }
106 }
107 }
108 - [16] Const mutate y$22_@9 = read x$16_@5
108 + [16] Const mutate y$22_@9 = read x$16_@5:TPrimitive
109 return
110 }
111
@@ -118,46 +118,46 @@ flowchart TB
118 %% Basic Blocks
119 subgraph bb0
120 bb0_instrs["
121 - [1] Const mutate x$10_@0 = 1
122 - [2] Const mutate $11_@1 = 2
123 - [3] Const mutate $12_@2 = Binary read x$10_@0 === read $11_@1
124 - [4] Const mutate $13_@3 = 1
125 - [5] Const mutate $14_@4 = Binary read x$10_@0 === read $13_@3
126 - [6] Let mutate x$16_@5[6:16] = undefined
121 + [1] Const mutate x$10_@0:TPrimitive = 1
122 + [2] Const mutate $11_@1:TPrimitive = 2
123 + [3] Const mutate $12_@2:TPrimitive = Binary read x$10_@0:TPrimitive === read $11_@1:TPrimitive
124 + [4] Const mutate $13_@3:TPrimitive = 1
125 + [5] Const mutate $14_@4:TPrimitive = Binary read x$10_@0:TPrimitive === read $13_@3:TPrimitive
126 + [6] Let mutate x$16_@5:TPrimitive[6:16] = undefined
127 "]
128 - bb0_instrs --> bb0_terminal(["Switch (read x$10_@0)"])
128 + bb0_instrs --> bb0_terminal(["Switch (read x$10_@0:TPrimitive)"])
129 end
130 subgraph bb5
131 bb5_instrs["
132 - [7] Const mutate $15_@6 = 1
133 - [8] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $15_@6
132 + [7] Const mutate $15_@6:TPrimitive = 1
133 + [8] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $15_@6:TPrimitive
134 "]
135 bb5_instrs --> bb5_terminal(["Goto"])
136 end
137 subgraph bb3
138 bb3_instrs["
139 - [10] Const mutate $17_@7 = 2
140 - [11] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $17_@7
139 + [10] Const mutate $17_@7:TPrimitive = 2
140 + [11] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $17_@7:TPrimitive
141 "]
142 bb3_instrs --> bb3_terminal(["Goto"])
143 end
144 subgraph bb2
145 bb2_instrs["
146 - [13] Const mutate $19_@8 = 3
147 - [14] Reassign mutate x$16_@5[6:16] = Binary read x$10_@0 + read $19_@8
146 + [13] Const mutate $19_@8:TPrimitive = 3
147 + [14] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $19_@8:TPrimitive
148 "]
149 bb2_instrs --> bb2_terminal(["Goto"])
150 end
151 subgraph bb1
152 bb1_instrs["
153 - [16] Const mutate y$22_@9 = read x$16_@5
153 + [16] Const mutate y$22_@9 = read x$16_@5:TPrimitive
154 "]
155 bb1_instrs --> bb1_terminal(["Return"])
156 end
157
158 %% Jumps
159 - bb0_terminal -- "read $14_@4" --> bb5
160 - bb0_terminal -- "read $12_@2" --> bb3
159 + bb0_terminal -- "read $14_@4:TPrimitive" --> bb5
160 + bb0_terminal -- "read $12_@2:TPrimitive" --> bb3
161 bb0_terminal -- "default" --> bb2
162 bb0_terminal -- "fallthrough" --> bb1
163 bb5_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+18 -18
@@ -16,17 +16,17 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$4_@0[1:7] = 1
20 - [2] Const mutate $5_@1 = 1
21 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
22 - [4] If (read $6_@0) then:bb2 else:bb1 fallthrough=bb1
19 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
20 + [2] Const mutate $5_@1:TPrimitive = 1
21 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
22 + [4] If (read $6_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23 bb2:
24 predecessor blocks: bb0
25 - [5] Reassign mutate x$4_@0[1:7] = 2
25 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
26 [6] Goto bb1
27 bb1:
28 predecessor blocks: bb2 bb0
29 - [7] Throw read x$4_@0
29 + [7] Throw read x$4_@0:TPrimitive
30
31 ```
32
@@ -36,14 +36,14 @@ bb1:
36 function foo(
37 ) {
38 scope @0 [1:7] deps=[] {
39 - [1] Let mutate x$4_@0[1:7] = 1
40 - [2] Const mutate $5_@1 = 1
41 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
42 - if (read $6_@0) {
43 - [5] Reassign mutate x$4_@0[1:7] = 2
39 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
40 + [2] Const mutate $5_@1:TPrimitive = 1
41 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
42 + if (read $6_@0:TPrimitive) {
43 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
44 }
45 }
46 - throw read x$4_@0
46 + throw read x$4_@0:TPrimitive
47 }
48
49 ```
@@ -55,20 +55,20 @@ flowchart TB
55 %% Basic Blocks
56 subgraph bb0
57 bb0_instrs["
58 - [1] Let mutate x$4_@0[1:7] = 1
59 - [2] Const mutate $5_@1 = 1
60 - [3] Const mutate $6_@0[1:7] = Binary read x$4_@0 === read $5_@1
58 + [1] Let mutate x$4_@0:TPrimitive[1:7] = 1
59 + [2] Const mutate $5_@1:TPrimitive = 1
60 + [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
61 "]
62 - bb0_instrs --> bb0_terminal(["If (read $6_@0)"])
62 + bb0_instrs --> bb0_terminal(["If (read $6_@0:TPrimitive)"])
63 end
64 subgraph bb2
65 bb2_instrs["
66 - [5] Reassign mutate x$4_@0[1:7] = 2
66 + [5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
67 "]
68 bb2_instrs --> bb2_terminal(["Goto"])
69 end
70 subgraph bb1
71 - bb1_terminal(["Throw read x$4_@0"])
71 + bb1_terminal(["Throw read x$4_@0:TPrimitive"])
72 end
73
74 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md
+24 -24
@@ -17,25 +17,25 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Const mutate x$5_@0 = 1
20 + [1] Const mutate x$5_@0:TPrimitive = 1
21 [2] While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [3] Const mutate $6_@1[3:6] = 10
25 - [4] Const mutate $8_@2[4:6] = Binary read x$5_@0 < read $6_@1
26 - [5] If (read $8_@2) then:bb3 else:bb2 fallthrough=bb2
24 + [3] Const mutate $6_@1:TPrimitive[3:6] = 10
25 + [4] Const mutate $8_@2:TPrimitive[4:6] = Binary read x$5_@0:TPrimitive < read $6_@1:TPrimitive
26 + [5] If (read $8_@2:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
27 bb3:
28 predecessor blocks: bb1
29 - [6] Const mutate $9_@3 = 1
30 - [7] Binary read x$5_@0 + read $9_@3
29 + [6] Const mutate $9_@3:TPrimitive = 1
30 + [7] Binary read x$5_@0:TPrimitive + read $9_@3:TPrimitive
31 [8] Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
34 - [9] Return read x$5_@0
34 + [9] Return read x$5_@0:TPrimitive
35 scope2 [4:6]:
36 - - dependency: read x$5_@0
36 + - dependency: read x$5_@0:TPrimitive
37 scope3 [6:7]:
38 - - dependency: read x$5_@0
38 + - dependency: read x$5_@0:TPrimitive
39 ```
40
41 ## Reactive Scopes
@@ -43,20 +43,20 @@ scope3 [6:7]:
43 ```
44 function foo(
45 ) {
46 - [1] Const mutate x$5_@0 = 1
46 + [1] Const mutate x$5_@0:TPrimitive = 1
47 scope @1 [3:6] deps=[] {
48 - scope @2 [4:6] deps=[read x$5_@0] {
48 + scope @2 [4:6] deps=[read x$5_@0:TPrimitive] {
49 while (
50 - [3] Const mutate $6_@1[3:6] = 10
51 - [4] Const mutate $8_@2[4:6] = Binary read x$5_@0 < read $6_@1
52 - read $8_@2
50 + [3] Const mutate $6_@1:TPrimitive[3:6] = 10
51 + [4] Const mutate $8_@2:TPrimitive[4:6] = Binary read x$5_@0:TPrimitive < read $6_@1:TPrimitive
52 + read $8_@2:TPrimitive
53 ) {
54 - [6] Const mutate $9_@3 = 1
55 - [7] Binary read x$5_@0 + read $9_@3
54 + [6] Const mutate $9_@3:TPrimitive = 1
55 + [7] Binary read x$5_@0:TPrimitive + read $9_@3:TPrimitive
56 }
57 }
58 }
59 - return read x$5_@0
59 + return read x$5_@0:TPrimitive
60 }
61
62 ```
@@ -68,26 +68,26 @@ flowchart TB
68 %% Basic Blocks
69 subgraph bb0
70 bb0_instrs["
71 - [1] Const mutate x$5_@0 = 1
71 + [1] Const mutate x$5_@0:TPrimitive = 1
72 "]
73 bb0_instrs --> bb0_terminal(["While"])
74 end
75 subgraph bb1
76 bb1_instrs["
77 - [3] Const mutate $6_@1[3:6] = 10
78 - [4] Const mutate $8_@2[4:6] = Binary read x$5_@0 < read $6_@1
77 + [3] Const mutate $6_@1:TPrimitive[3:6] = 10
78 + [4] Const mutate $8_@2:TPrimitive[4:6] = Binary read x$5_@0:TPrimitive < read $6_@1:TPrimitive
79 "]
80 - bb1_instrs --> bb1_terminal(["If (read $8_@2)"])
80 + bb1_instrs --> bb1_terminal(["If (read $8_@2:TPrimitive)"])
81 end
82 subgraph bb3
83 bb3_instrs["
84 - [6] Const mutate $9_@3 = 1
85 - [7] Binary read x$5_@0 + read $9_@3
84 + [6] Const mutate $9_@3:TPrimitive = 1
85 + [7] Binary read x$5_@0:TPrimitive + read $9_@3:TPrimitive
86 "]
87 bb3_instrs --> bb3_terminal(["Goto"])
88 end
89 subgraph bb2
90 - bb2_terminal(["Return read x$5_@0"])
90 + bb2_terminal(["Return read x$5_@0:TPrimitive"])
91 end
92
93 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+21 -21
@@ -17,21 +17,21 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$5_@0[1:9] = 1
20 + [1] Let mutate x$5_@0:TPrimitive[1:9] = 1
21 [2] While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [3] Const mutate $6_@0[1:9] = 10
25 - [4] Const mutate $8_@0[1:9] = Binary read x$5_@0 < read $6_@0
26 - [5] If (read $8_@0) then:bb3 else:bb2 fallthrough=bb2
24 + [3] Const mutate $6_@0:TPrimitive[1:9] = 10
25 + [4] Const mutate $8_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive < read $6_@0:TPrimitive
26 + [5] If (read $8_@0:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
27 bb3:
28 predecessor blocks: bb1
29 - [6] Const mutate $9_@2 = 1
30 - [7] Reassign mutate x$5_@0[1:9] = Binary read x$5_@0 + read $9_@2
29 + [6] Const mutate $9_@2:TPrimitive = 1
30 + [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9_@2:TPrimitive
31 [8] Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
34 - [9] Return read x$5_@0
34 + [9] Return read x$5_@0:TPrimitive
35
36 ```
37
@@ -41,17 +41,17 @@ bb2:
41 function foo(
42 ) {
43 scope @0 [1:9] deps=[] {
44 - [1] Let mutate x$5_@0[1:9] = 1
44 + [1] Let mutate x$5_@0:TPrimitive[1:9] = 1
45 while (
46 - [3] Const mutate $6_@0[1:9] = 10
47 - [4] Const mutate $8_@0[1:9] = Binary read x$5_@0 < read $6_@0
48 - read $8_@0
46 + [3] Const mutate $6_@0:TPrimitive[1:9] = 10
47 + [4] Const mutate $8_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive < read $6_@0:TPrimitive
48 + read $8_@0:TPrimitive
49 ) {
50 - [6] Const mutate $9_@2 = 1
51 - [7] Reassign mutate x$5_@0[1:9] = Binary read x$5_@0 + read $9_@2
50 + [6] Const mutate $9_@2:TPrimitive = 1
51 + [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9_@2:TPrimitive
52 }
53 }
54 - return read x$5_@0
54 + return read x$5_@0:TPrimitive
55 }
56
57 ```
@@ -63,26 +63,26 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Let mutate x$5_@0[1:9] = 1
66 + [1] Let mutate x$5_@0:TPrimitive[1:9] = 1
67 "]
68 bb0_instrs --> bb0_terminal(["While"])
69 end
70 subgraph bb1
71 bb1_instrs["
72 - [3] Const mutate $6_@0[1:9] = 10
73 - [4] Const mutate $8_@0[1:9] = Binary read x$5_@0 < read $6_@0
72 + [3] Const mutate $6_@0:TPrimitive[1:9] = 10
73 + [4] Const mutate $8_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive < read $6_@0:TPrimitive
74 "]
75 - bb1_instrs --> bb1_terminal(["If (read $8_@0)"])
75 + bb1_instrs --> bb1_terminal(["If (read $8_@0:TPrimitive)"])
76 end
77 subgraph bb3
78 bb3_instrs["
79 - [6] Const mutate $9_@2 = 1
80 - [7] Reassign mutate x$5_@0[1:9] = Binary read x$5_@0 + read $9_@2
79 + [6] Const mutate $9_@2:TPrimitive = 1
80 + [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9_@2:TPrimitive
81 "]
82 bb3_instrs --> bb3_terminal(["Goto"])
83 end
84 subgraph bb2
85 - bb2_terminal(["Return read x$5_@0"])
85 + bb2_terminal(["Return read x$5_@0:TPrimitive"])
86 end
87
88 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+40 -40
@@ -32,40 +32,40 @@ function Component(props) {
32
33 ```
34 bb0:
35 - [1] Const mutate x$10_@1[1:12] = Array []
36 - [2] Let mutate y$11_@1[1:12] = undefined
37 - [3] Const mutate $12_@2 = false
38 - [4] Const mutate $13_@3 = true
39 - [5] Const mutate $14_@4 = 1
35 + [1] Const mutate x$10_@1:TFunction[1:12] = Array []
36 + [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
37 + [3] Const mutate $12_@2:TPrimitive = false
38 + [4] Const mutate $13_@3:TPrimitive = true
39 + [5] Const mutate $14_@4:TPrimitive = 1
40 [6] Switch (read props$9.p0)
41 - Case read $14_@4: bb1
42 - Case read $13_@3: bb6
41 + Case read $14_@4:TPrimitive: bb1
42 + Case read $13_@3:TPrimitive: bb6
43 Default: bb1
44 - Case read $12_@2: bb2
44 + Case read $12_@2:TPrimitive: bb2
45 Fallthrough: bb1
46 bb6:
47 predecessor blocks: bb0
48 [7] Call mutate x$10_@1.push(read props$9.p2)
49 - [8] Reassign mutate y$11_@1[1:12] = Array []
49 + [8] Reassign mutate y$11_@1:TPrimitive[1:12] = Array []
50 [9] Goto bb1
51 bb2:
52 predecessor blocks: bb0
53 - [10] Reassign mutate y$11_@1[1:12] = read x$10_@1
53 + [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
54 [11] Goto bb1
55 bb1:
56 predecessor blocks: bb0 bb6 bb2
57 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1} ></read Component$0>
57 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
58 [13] Call read y$11_@1.push(read props$9.p4)
59 - [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1} >{read child$19_@5}</read Component$0>
59 + [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@5}</read Component$0>
60 [15] Return read $22_@6
61 scope5 [12:13]:
62 - dependency: read Component$0
63 - - dependency: freeze x$10_@1
63 + - dependency: freeze x$10_@1:TFunction
64 - dependency: read y$11_@1.push
65 - dependency: read props$9.p4
66 scope6 [14:15]:
67 - dependency: read Component$0
68 - - dependency: freeze y$11_@1
68 + - dependency: freeze y$11_@1:TPrimitive
69 - dependency: read child$19_@5
70 ```
71
@@ -76,34 +76,34 @@ function Component(
76 props,
77 ) {
78 scope @1 [1:12] deps=[] {
79 - [1] Const mutate x$10_@1[1:12] = Array []
80 - [2] Let mutate y$11_@1[1:12] = undefined
81 - [3] Const mutate $12_@2 = false
82 - [4] Const mutate $13_@3 = true
83 - [5] Const mutate $14_@4 = 1
79 + [1] Const mutate x$10_@1:TFunction[1:12] = Array []
80 + [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
81 + [3] Const mutate $12_@2:TPrimitive = false
82 + [4] Const mutate $13_@3:TPrimitive = true
83 + [5] Const mutate $14_@4:TPrimitive = 1
84 switch (read props$9.p0) {
85 - case read $14_@4: {
85 + case read $14_@4:TPrimitive: {
86 break bb1
87 }
88 - case read $13_@3: {
88 + case read $13_@3:TPrimitive: {
89 [7] Call mutate x$10_@1.push(read props$9.p2)
90 - [8] Reassign mutate y$11_@1[1:12] = Array []
90 + [8] Reassign mutate y$11_@1:TPrimitive[1:12] = Array []
91 break bb1
92 }
93 default: {
94 break bb1
95 }
96 - case read $12_@2: {
97 - [10] Reassign mutate y$11_@1[1:12] = read x$10_@1
96 + case read $12_@2:TPrimitive: {
97 + [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
98 }
99 }
100 }
101 - scope @5 [12:13] deps=[read Component$0, freeze x$10_@1, read y$11_@1.push, read props$9.p4] {
102 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1} ></read Component$0>
101 + scope @5 [12:13] deps=[read Component$0, freeze x$10_@1:TFunction, read y$11_@1.push, read props$9.p4] {
102 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
103 }
104 [13] Call read y$11_@1.push(read props$9.p4)
105 - scope @6 [14:15] deps=[read Component$0, freeze y$11_@1, read child$19_@5] {
106 - [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1} >{read child$19_@5}</read Component$0>
105 + scope @6 [14:15] deps=[read Component$0, freeze y$11_@1:TPrimitive, read child$19_@5] {
106 + [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@5}</read Component$0>
107 }
108 return read $22_@6
109 }
@@ -117,41 +117,41 @@ flowchart TB
117 %% Basic Blocks
118 subgraph bb0
119 bb0_instrs["
120 - [1] Const mutate x$10_@1[1:12] = Array []
121 - [2] Let mutate y$11_@1[1:12] = undefined
122 - [3] Const mutate $12_@2 = false
123 - [4] Const mutate $13_@3 = true
124 - [5] Const mutate $14_@4 = 1
120 + [1] Const mutate x$10_@1:TFunction[1:12] = Array []
121 + [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
122 + [3] Const mutate $12_@2:TPrimitive = false
123 + [4] Const mutate $13_@3:TPrimitive = true
124 + [5] Const mutate $14_@4:TPrimitive = 1
125 "]
126 bb0_instrs --> bb0_terminal(["Switch (read props$9.p0)"])
127 end
128 subgraph bb6
129 bb6_instrs["
130 [7] Call mutate x$10_@1.push(read props$9.p2)
131 - [8] Reassign mutate y$11_@1[1:12] = Array []
131 + [8] Reassign mutate y$11_@1:TPrimitive[1:12] = Array []
132 "]
133 bb6_instrs --> bb6_terminal(["Goto"])
134 end
135 subgraph bb2
136 bb2_instrs["
137 - [10] Reassign mutate y$11_@1[1:12] = read x$10_@1
137 + [10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
138 "]
139 bb2_instrs --> bb2_terminal(["Goto"])
140 end
141 subgraph bb1
142 bb1_instrs["
143 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1} ></read Component$0>
143 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
144 [13] Call read y$11_@1.push(read props$9.p4)
145 - [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1} >{read child$19_@5}</read Component$0>
145 + [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@5}</read Component$0>
146 "]
147 bb1_instrs --> bb1_terminal(["Return read $22_@6"])
148 end
149
150 %% Jumps
151 - bb0_terminal -- "read $14_@4" --> bb1
152 - bb0_terminal -- "read $13_@3" --> bb6
151 + bb0_terminal -- "read $14_@4:TPrimitive" --> bb1
152 + bb0_terminal -- "read $13_@3:TPrimitive" --> bb6
153 bb0_terminal -- "default" --> bb1
154 - bb0_terminal -- "read $12_@2" --> bb2
154 + bb0_terminal -- "read $12_@2:TPrimitive" --> bb2
155 bb0_terminal -- "fallthrough" --> bb1
156 bb6_terminal --> bb1
157 bb2_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md
+57 -57
@@ -36,45 +36,45 @@ function foo(x) {
36
37 ```
38 bb0:
39 - [1] Const mutate y$10_@0 = undefined
40 - [2] Const mutate $11_@1 = 5
41 - [3] Const mutate $12_@2 = 4
42 - [4] Const mutate $13_@3 = 3
43 - [5] Const mutate $14_@4 = 2
44 - [6] Const mutate $15_@5 = 1
45 - [7] Const mutate $16_@6 = 0
39 + [1] Const mutate y$10_@0:TPrimitive = undefined
40 + [2] Const mutate $11_@1:TPrimitive = 5
41 + [3] Const mutate $12_@2:TPrimitive = 4
42 + [4] Const mutate $13_@3:TPrimitive = 3
43 + [5] Const mutate $14_@4:TPrimitive = 2
44 + [6] Const mutate $15_@5:TPrimitive = 1
45 + [7] Const mutate $16_@6:TPrimitive = 0
46 [8] Switch (read x$9)
47 - Case read $16_@6: bb10
48 - Case read $15_@5: bb9
49 - Case read $14_@4: bb1
50 - Case read $13_@3: bb5
51 - Case read $12_@2: bb4
52 - Case read $11_@1: bb3
47 + Case read $16_@6:TPrimitive: bb10
48 + Case read $15_@5:TPrimitive: bb9
49 + Case read $14_@4:TPrimitive: bb1
50 + Case read $13_@3:TPrimitive: bb5
51 + Case read $12_@2:TPrimitive: bb4
52 + Case read $11_@1:TPrimitive: bb3
53 Default: bb2
54 Fallthrough: bb1
55 bb10:
56 predecessor blocks: bb0
57 - [9] Const mutate y$17_@7 = 0
57 + [9] Const mutate y$17_@7:TPrimitive = 0
58 [10] Goto bb9
59 bb9:
60 predecessor blocks: bb10 bb0
61 - [11] Const mutate y$18_@8 = 1
61 + [11] Const mutate y$18_@8:TPrimitive = 1
62 [12] Goto bb1
63 bb5:
64 predecessor blocks: bb0
65 - [13] Const mutate y$19_@9 = 3
65 + [13] Const mutate y$19_@9:TPrimitive = 3
66 [14] Goto bb1
67 bb4:
68 predecessor blocks: bb0
69 - [15] Const mutate y$20_@10 = 4
69 + [15] Const mutate y$20_@10:TPrimitive = 4
70 [16] Goto bb3
71 bb3:
72 predecessor blocks: bb4 bb0
73 - [17] Const mutate y$21_@11 = 5
73 + [17] Const mutate y$21_@11:TPrimitive = 5
74 [18] Goto bb2
75 bb2:
76 predecessor blocks: bb3 bb0
77 - [19] Const mutate y$22_@12 = 0
77 + [19] Const mutate y$22_@12:TPrimitive = 0
78 [20] Goto bb1
79 bb1:
80 predecessor blocks: bb9 bb0 bb5 bb2
@@ -88,36 +88,36 @@ bb1:
88 function foo(
89 x,
90 ) {
91 - [1] Const mutate y$10_@0 = undefined
92 - [2] Const mutate $11_@1 = 5
93 - [3] Const mutate $12_@2 = 4
94 - [4] Const mutate $13_@3 = 3
95 - [5] Const mutate $14_@4 = 2
96 - [6] Const mutate $15_@5 = 1
97 - [7] Const mutate $16_@6 = 0
91 + [1] Const mutate y$10_@0:TPrimitive = undefined
92 + [2] Const mutate $11_@1:TPrimitive = 5
93 + [3] Const mutate $12_@2:TPrimitive = 4
94 + [4] Const mutate $13_@3:TPrimitive = 3
95 + [5] Const mutate $14_@4:TPrimitive = 2
96 + [6] Const mutate $15_@5:TPrimitive = 1
97 + [7] Const mutate $16_@6:TPrimitive = 0
98 switch (read x$9) {
99 - case read $16_@6: {
100 - [9] Const mutate y$17_@7 = 0
99 + case read $16_@6:TPrimitive: {
100 + [9] Const mutate y$17_@7:TPrimitive = 0
101 }
102 - case read $15_@5: {
103 - [11] Const mutate y$18_@8 = 1
102 + case read $15_@5:TPrimitive: {
103 + [11] Const mutate y$18_@8:TPrimitive = 1
104 break bb1
105 }
106 - case read $14_@4: {
106 + case read $14_@4:TPrimitive: {
107 break bb1
108 }
109 - case read $13_@3: {
110 - [13] Const mutate y$19_@9 = 3
109 + case read $13_@3:TPrimitive: {
110 + [13] Const mutate y$19_@9:TPrimitive = 3
111 break bb1
112 }
113 - case read $12_@2: {
114 - [15] Const mutate y$20_@10 = 4
113 + case read $12_@2:TPrimitive: {
114 + [15] Const mutate y$20_@10:TPrimitive = 4
115 }
116 - case read $11_@1: {
117 - [17] Const mutate y$21_@11 = 5
116 + case read $11_@1:TPrimitive: {
117 + [17] Const mutate y$21_@11:TPrimitive = 5
118 }
119 default: {
120 - [19] Const mutate y$22_@12 = 0
120 + [19] Const mutate y$22_@12:TPrimitive = 0
121 }
122 }
123 return
@@ -132,49 +132,49 @@ flowchart TB
132 %% Basic Blocks
133 subgraph bb0
134 bb0_instrs["
135 - [1] Const mutate y$10_@0 = undefined
136 - [2] Const mutate $11_@1 = 5
137 - [3] Const mutate $12_@2 = 4
138 - [4] Const mutate $13_@3 = 3
139 - [5] Const mutate $14_@4 = 2
140 - [6] Const mutate $15_@5 = 1
141 - [7] Const mutate $16_@6 = 0
135 + [1] Const mutate y$10_@0:TPrimitive = undefined
136 + [2] Const mutate $11_@1:TPrimitive = 5
137 + [3] Const mutate $12_@2:TPrimitive = 4
138 + [4] Const mutate $13_@3:TPrimitive = 3
139 + [5] Const mutate $14_@4:TPrimitive = 2
140 + [6] Const mutate $15_@5:TPrimitive = 1
141 + [7] Const mutate $16_@6:TPrimitive = 0
142 "]
143 bb0_instrs --> bb0_terminal(["Switch (read x$9)"])
144 end
145 subgraph bb10
146 bb10_instrs["
147 - [9] Const mutate y$17_@7 = 0
147 + [9] Const mutate y$17_@7:TPrimitive = 0
148 "]
149 bb10_instrs --> bb10_terminal(["Goto"])
150 end
151 subgraph bb9
152 bb9_instrs["
153 - [11] Const mutate y$18_@8 = 1
153 + [11] Const mutate y$18_@8:TPrimitive = 1
154 "]
155 bb9_instrs --> bb9_terminal(["Goto"])
156 end
157 subgraph bb5
158 bb5_instrs["
159 - [13] Const mutate y$19_@9 = 3
159 + [13] Const mutate y$19_@9:TPrimitive = 3
160 "]
161 bb5_instrs --> bb5_terminal(["Goto"])
162 end
163 subgraph bb4
164 bb4_instrs["
165 - [15] Const mutate y$20_@10 = 4
165 + [15] Const mutate y$20_@10:TPrimitive = 4
166 "]
167 bb4_instrs --> bb4_terminal(["Goto"])
168 end
169 subgraph bb3
170 bb3_instrs["
171 - [17] Const mutate y$21_@11 = 5
171 + [17] Const mutate y$21_@11:TPrimitive = 5
172 "]
173 bb3_instrs --> bb3_terminal(["Goto"])
174 end
175 subgraph bb2
176 bb2_instrs["
177 - [19] Const mutate y$22_@12 = 0
177 + [19] Const mutate y$22_@12:TPrimitive = 0
178 "]
179 bb2_instrs --> bb2_terminal(["Goto"])
180 end
@@ -183,12 +183,12 @@ flowchart TB
183 end
184
185 %% Jumps
186 - bb0_terminal -- "read $16_@6" --> bb10
187 - bb0_terminal -- "read $15_@5" --> bb9
188 - bb0_terminal -- "read $14_@4" --> bb1
189 - bb0_terminal -- "read $13_@3" --> bb5
190 - bb0_terminal -- "read $12_@2" --> bb4
191 - bb0_terminal -- "read $11_@1" --> bb3
186 + bb0_terminal -- "read $16_@6:TPrimitive" --> bb10
187 + bb0_terminal -- "read $15_@5:TPrimitive" --> bb9
188 + bb0_terminal -- "read $14_@4:TPrimitive" --> bb1
189 + bb0_terminal -- "read $13_@3:TPrimitive" --> bb5
190 + bb0_terminal -- "read $12_@2:TPrimitive" --> bb4
191 + bb0_terminal -- "read $11_@1:TPrimitive" --> bb3
192 bb0_terminal -- "default" --> bb2
193 bb0_terminal -- "fallthrough" --> bb1
194 bb10_terminal --> bb9
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+31 -31
@@ -28,13 +28,13 @@ function Component(props) {
28
29 ```
30 bb0:
31 - [1] Const mutate x$9_@1[1:12] = Array []
32 - [2] Let mutate y$10_@1[1:12] = undefined
33 - [3] Const mutate $11_@2 = false
34 - [4] Const mutate $12_@3 = true
31 + [1] Const mutate x$9_@1:TFunction[1:12] = Array []
32 + [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
33 + [3] Const mutate $11_@2:TPrimitive = false
34 + [4] Const mutate $12_@3:TPrimitive = true
35 [5] Switch (read props$8.p0)
36 - Case read $12_@3: bb4
37 - Case read $11_@2: bb2
36 + Case read $12_@3:TPrimitive: bb4
37 + Case read $11_@2:TPrimitive: bb2
38 Default: bb1
39 Fallthrough: bb1
40 bb4:
@@ -45,22 +45,22 @@ bb4:
45 [9] Goto bb2
46 bb2:
47 predecessor blocks: bb4 bb0
48 - [10] Reassign mutate y$10_@1[1:12] = read x$9_@1
48 + [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
49 [11] Goto bb1
50 bb1:
51 predecessor blocks: bb2 bb0
52 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1} ></read Component$0>
52 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
53 [13] Call read y$10_@1.push(read props$8.p4)
54 - [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1} >{read child$19_@5}</read Component$0>
54 + [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@5}</read Component$0>
55 [15] Return read $23_@6
56 scope5 [12:13]:
57 - dependency: read Component$0
58 - - dependency: freeze x$9_@1
58 + - dependency: freeze x$9_@1:TFunction
59 - dependency: read y$10_@1.push
60 - dependency: read props$8.p4
61 scope6 [14:15]:
62 - dependency: read Component$0
63 - - dependency: read y$10_@1
63 + - dependency: read y$10_@1:TPrimitive
64 - dependency: read child$19_@5
65 ```
66
@@ -71,29 +71,29 @@ function Component(
71 props,
72 ) {
73 scope @1 [1:12] deps=[] {
74 - [1] Const mutate x$9_@1[1:12] = Array []
75 - [2] Let mutate y$10_@1[1:12] = undefined
76 - [3] Const mutate $11_@2 = false
77 - [4] Const mutate $12_@3 = true
74 + [1] Const mutate x$9_@1:TFunction[1:12] = Array []
75 + [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
76 + [3] Const mutate $11_@2:TPrimitive = false
77 + [4] Const mutate $12_@3:TPrimitive = true
78 switch (read props$8.p0) {
79 - case read $12_@3: {
79 + case read $12_@3:TPrimitive: {
80 [6] Call mutate x$9_@1.push(read props$8.p2)
81 [7] Call mutate x$9_@1.push(read props$8.p3)
82 scope @4 [8:9] deps=[] {
83 [8] Const mutate y$13_@4 = Array []
84 }
85 }
86 - case read $11_@2: {
87 - [10] Reassign mutate y$10_@1[1:12] = read x$9_@1
86 + case read $11_@2:TPrimitive: {
87 + [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
88 }
89 }
90 }
91 - scope @5 [12:13] deps=[read Component$0, freeze x$9_@1, read y$10_@1.push, read props$8.p4] {
92 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1} ></read Component$0>
91 + scope @5 [12:13] deps=[read Component$0, freeze x$9_@1:TFunction, read y$10_@1.push, read props$8.p4] {
92 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
93 }
94 [13] Call read y$10_@1.push(read props$8.p4)
95 - scope @6 [14:15] deps=[read Component$0, read y$10_@1, read child$19_@5] {
96 - [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1} >{read child$19_@5}</read Component$0>
95 + scope @6 [14:15] deps=[read Component$0, read y$10_@1:TPrimitive, read child$19_@5] {
96 + [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@5}</read Component$0>
97 }
98 return read $23_@6
99 }
@@ -107,10 +107,10 @@ flowchart TB
107 %% Basic Blocks
108 subgraph bb0
109 bb0_instrs["
110 - [1] Const mutate x$9_@1[1:12] = Array []
111 - [2] Let mutate y$10_@1[1:12] = undefined
112 - [3] Const mutate $11_@2 = false
113 - [4] Const mutate $12_@3 = true
110 + [1] Const mutate x$9_@1:TFunction[1:12] = Array []
111 + [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
112 + [3] Const mutate $11_@2:TPrimitive = false
113 + [4] Const mutate $12_@3:TPrimitive = true
114 "]
115 bb0_instrs --> bb0_terminal(["Switch (read props$8.p0)"])
116 end
@@ -124,22 +124,22 @@ flowchart TB
124 end
125 subgraph bb2
126 bb2_instrs["
127 - [10] Reassign mutate y$10_@1[1:12] = read x$9_@1
127 + [10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
128 "]
129 bb2_instrs --> bb2_terminal(["Goto"])
130 end
131 subgraph bb1
132 bb1_instrs["
133 - [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1} ></read Component$0>
133 + [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
134 [13] Call read y$10_@1.push(read props$8.p4)
135 - [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1} >{read child$19_@5}</read Component$0>
135 + [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@5}</read Component$0>
136 "]
137 bb1_instrs --> bb1_terminal(["Return read $23_@6"])
138 end
139
140 %% Jumps
141 - bb0_terminal -- "read $12_@3" --> bb4
142 - bb0_terminal -- "read $11_@2" --> bb2
141 + bb0_terminal -- "read $12_@3:TPrimitive" --> bb4
142 + bb0_terminal -- "read $11_@2:TPrimitive" --> bb2
143 bb0_terminal -- "default" --> bb1
144 bb0_terminal -- "fallthrough" --> bb1
145 bb4_terminal --> bb2
compiler/forget/src/__tests__/fixtures/hir/transitive-alias-fields.expect.md
+18 -18
@@ -21,14 +21,14 @@ function component() {
21
22 ```
23 bb0:
24 - [1] Const mutate x$6_@0[1:9] = Object { }
25 - [2] Const mutate p$7_@0[1:9] = Object { }
26 - [3] Const mutate q$8_@0[1:9] = Object { }
27 - [4] Const mutate y$9_@0[1:9] = Object { }
28 - [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0
24 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
25 + [2] Const mutate p$7_@0:TObject[1:9] = Object { }
26 + [3] Const mutate q$8_@0:TObject[1:9] = Object { }
27 + [4] Const mutate y$9_@0:TObject[1:9] = Object { }
28 + [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0:TObject
29 [6] Reassign mutate p$7_@0.y[1:9] = read x$6_@0.y
30 [7] Reassign mutate q$8_@0.y[1:9] = read p$7_@0.y
31 - [8] Call mutate mutate$5(mutate q$8_@0)
31 + [8] Call mutate mutate$5:TFunction(mutate q$8_@0:TObject)
32 [9] Return
33
34 ```
@@ -39,14 +39,14 @@ bb0:
39 function component(
40 ) {
41 scope @0 [1:9] deps=[] {
42 - [1] Const mutate x$6_@0[1:9] = Object { }
43 - [2] Const mutate p$7_@0[1:9] = Object { }
44 - [3] Const mutate q$8_@0[1:9] = Object { }
45 - [4] Const mutate y$9_@0[1:9] = Object { }
46 - [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0
42 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
43 + [2] Const mutate p$7_@0:TObject[1:9] = Object { }
44 + [3] Const mutate q$8_@0:TObject[1:9] = Object { }
45 + [4] Const mutate y$9_@0:TObject[1:9] = Object { }
46 + [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0:TObject
47 [6] Reassign mutate p$7_@0.y[1:9] = read x$6_@0.y
48 [7] Reassign mutate q$8_@0.y[1:9] = read p$7_@0.y
49 - [8] Call mutate mutate$5(mutate q$8_@0)
49 + [8] Call mutate mutate$5:TFunction(mutate q$8_@0:TObject)
50 }
51 return
52 }
@@ -60,14 +60,14 @@ flowchart TB
60 %% Basic Blocks
61 subgraph bb0
62 bb0_instrs["
63 - [1] Const mutate x$6_@0[1:9] = Object { }
64 - [2] Const mutate p$7_@0[1:9] = Object { }
65 - [3] Const mutate q$8_@0[1:9] = Object { }
66 - [4] Const mutate y$9_@0[1:9] = Object { }
67 - [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0
63 + [1] Const mutate x$6_@0:TObject[1:9] = Object { }
64 + [2] Const mutate p$7_@0:TObject[1:9] = Object { }
65 + [3] Const mutate q$8_@0:TObject[1:9] = Object { }
66 + [4] Const mutate y$9_@0:TObject[1:9] = Object { }
67 + [5] Reassign mutate x$6_@0.y[1:9] = read y$9_@0:TObject
68 [6] Reassign mutate p$7_@0.y[1:9] = read x$6_@0.y
69 [7] Reassign mutate q$8_@0.y[1:9] = read p$7_@0.y
70 - [8] Call mutate mutate$5(mutate q$8_@0)
70 + [8] Call mutate mutate$5:TFunction(mutate q$8_@0:TObject)
71 "]
72 bb0_instrs --> bb0_terminal(["Return"])
73 end
compiler/forget/src/__tests__/fixtures/hir/type-args-test-binary-operator.expect.md new
+87
@@ -0,0 +1,87 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component(a, b) {
6 + if (a > b) {
7 + let m = {};
8 + }
9 +}
10 +
11 +```
12 +
13 +## HIR
14 +
15 +```
16 +bb0:
17 + [1] Const mutate $7_@0:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
18 + [2] If (read $7_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
19 +bb2:
20 + predecessor blocks: bb0
21 + [3] Const mutate m$8_@1:TObject = Object { }
22 + [4] Goto bb1
23 +bb1:
24 + predecessor blocks: bb2 bb0
25 + [5] Return
26 +scope0 [1:2]:
27 + - dependency: read a$5:TPrimitive
28 + - dependency: read b$6:TPrimitive
29 +```
30 +
31 +## Reactive Scopes
32 +
33 +```
34 +function component(
35 + a,
36 + b,
37 +) {
38 + [1] Const mutate $7_@0:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
39 + if (read $7_@0:TPrimitive) {
40 + scope @1 [3:4] deps=[] {
41 + [3] Const mutate m$8_@1:TObject = Object { }
42 + }
43 + }
44 + return
45 +}
46 +
47 +```
48 +
49 +### CFG
50 +
51 +```mermaid
52 +flowchart TB
53 + %% Basic Blocks
54 + subgraph bb0
55 + bb0_instrs["
56 + [1] Const mutate $7_@0:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
57 + "]
58 + bb0_instrs --> bb0_terminal(["If (read $7_@0:TPrimitive)"])
59 + end
60 + subgraph bb2
61 + bb2_instrs["
62 + [3] Const mutate m$8_@1:TObject = Object { }
63 + "]
64 + bb2_instrs --> bb2_terminal(["Goto"])
65 + end
66 + subgraph bb1
67 + bb1_terminal(["Return"])
68 + end
69 +
70 + %% Jumps
71 + bb0_terminal -- "then" --> bb2
72 + bb0_terminal -- "else" --> bb1
73 + bb2_terminal --> bb1
74 +
75 +```
76 +
77 +## Code
78 +
79 +```javascript
80 +function component$0(a$5, b$6) {
81 + bb1: if (a$5 > b$6) {
82 + const m$8 = {};
83 + }
84 +}
85 +
86 +```
87 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-args-test-binary-operator.js new
+5
@@ -0,0 +1,5 @@
1 +function component(a, b) {
2 + if (a > b) {
3 + let m = {};
4 + }
5 +}
compiler/forget/src/__tests__/fixtures/hir/type-binary-operator.expect.md new
+99
@@ -0,0 +1,99 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let a = some();
7 + let b = someOther();
8 + if (a > b) {
9 + let m = {};
10 + }
11 +}
12 +
13 +```
14 +
15 +## HIR
16 +
17 +```
18 +bb0:
19 + [1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
20 + [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
21 + [3] Const mutate $9_@2:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
22 + [4] If (read $9_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23 +bb2:
24 + predecessor blocks: bb0
25 + [5] Const mutate m$10_@3:TObject = Object { }
26 + [6] Goto bb1
27 +bb1:
28 + predecessor blocks: bb2 bb0
29 + [7] Return
30 +scope2 [3:4]:
31 + - dependency: read a$7_@0:TPrimitive
32 + - dependency: read b$8_@1:TPrimitive
33 +```
34 +
35 +## Reactive Scopes
36 +
37 +```
38 +function component(
39 +) {
40 + scope @0 [1:2] deps=[] {
41 + [1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
42 + }
43 + scope @1 [2:3] deps=[] {
44 + [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
45 + }
46 + [3] Const mutate $9_@2:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
47 + if (read $9_@2:TPrimitive) {
48 + scope @3 [5:6] deps=[] {
49 + [5] Const mutate m$10_@3:TObject = Object { }
50 + }
51 + }
52 + return
53 +}
54 +
55 +```
56 +
57 +### CFG
58 +
59 +```mermaid
60 +flowchart TB
61 + %% Basic Blocks
62 + subgraph bb0
63 + bb0_instrs["
64 + [1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
65 + [2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
66 + [3] Const mutate $9_@2:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
67 + "]
68 + bb0_instrs --> bb0_terminal(["If (read $9_@2:TPrimitive)"])
69 + end
70 + subgraph bb2
71 + bb2_instrs["
72 + [5] Const mutate m$10_@3:TObject = Object { }
73 + "]
74 + bb2_instrs --> bb2_terminal(["Goto"])
75 + end
76 + subgraph bb1
77 + bb1_terminal(["Return"])
78 + end
79 +
80 + %% Jumps
81 + bb0_terminal -- "then" --> bb2
82 + bb0_terminal -- "else" --> bb1
83 + bb2_terminal --> bb1
84 +
85 +```
86 +
87 +## Code
88 +
89 +```javascript
90 +function component$0() {
91 + const a$7 = some$2();
92 + const b$8 = someOther$4();
93 + bb1: if (a$7 > b$8) {
94 + const m$10 = {};
95 + }
96 +}
97 +
98 +```
99 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-binary-operator.js new
+7
@@ -0,0 +1,7 @@
1 +function component() {
2 + let a = some();
3 + let b = someOther();
4 + if (a > b) {
5 + let m = {};
6 + }
7 +}
compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md new
+70
@@ -0,0 +1,70 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let x = { t: 1 };
7 + let p = x.t;
8 +}
9 +
10 +```
11 +
12 +## HIR
13 +
14 +```
15 +bb0:
16 + [1] Const mutate $4_@0:TPrimitive = 1
17 + [2] Const mutate x$5_@1:TObject = Object { t: read $4_@0:TPrimitive }
18 + [3] Const mutate p$6_@2:TPrimitive = read x$5_@1.t
19 + [4] Return
20 +scope1 [2:3]:
21 + - dependency: read $4_@0:TPrimitive
22 +scope2 [3:4]:
23 + - dependency: read x$5_@1.t
24 +```
25 +
26 +## Reactive Scopes
27 +
28 +```
29 +function component(
30 +) {
31 + [1] Const mutate $4_@0:TPrimitive = 1
32 + scope @1 [2:3] deps=[read $4_@0:TPrimitive] {
33 + [2] Const mutate x$5_@1:TObject = Object { t: read $4_@0:TPrimitive }
34 + }
35 + [3] Const mutate p$6_@2:TPrimitive = read x$5_@1.t
36 + return
37 +}
38 +
39 +```
40 +
41 +### CFG
42 +
43 +```mermaid
44 +flowchart TB
45 + %% Basic Blocks
46 + subgraph bb0
47 + bb0_instrs["
48 + [1] Const mutate $4_@0:TPrimitive = 1
49 + [2] Const mutate x$5_@1:TObject = Object { t: read $4_@0:TPrimitive }
50 + [3] Const mutate p$6_@2:TPrimitive = read x$5_@1.t
51 + "]
52 + bb0_instrs --> bb0_terminal(["Return"])
53 + end
54 +
55 + %% Jumps
56 + %% empty
57 +```
58 +
59 +## Code
60 +
61 +```javascript
62 +function component$0() {
63 + const x$5 = {
64 + t: 1,
65 + };
66 + const p$6 = x$5.t;
67 +}
68 +
69 +```
70 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-field-load.js new
+4
@@ -0,0 +1,4 @@
1 +function component() {
2 + let x = { t: 1 };
3 + let p = x.t;
4 +}
compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.expect.md new
+124
@@ -0,0 +1,124 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let x = { u: makeSomePrimitive(), v: makeSomePrimitive() };
7 + let u = x.u;
8 + let v = x.v;
9 + if (u > v) {
10 + }
11 +
12 + let y = x.u;
13 + let z = x.v;
14 +}
15 +
16 +```
17 +
18 +## HIR
19 +
20 +```
21 +bb0:
22 + [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
23 + [2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
24 + [3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
25 + [4] Const mutate u$13_@3:TPrimitive = read x$12_@2.u
26 + [5] Const mutate v$14_@4:TPrimitive = read x$12_@2.v
27 + [6] Const mutate $15_@5:TPrimitive = Binary read u$13_@3:TPrimitive > read v$14_@4:TPrimitive
28 + [7] If (read $15_@5:TPrimitive) then:bb1 else:bb1 fallthrough=bb1
29 +bb1:
30 + predecessor blocks: bb0
31 + [8] Const mutate y$16_@6:TPrimitive = read x$12_@2.u
32 + [9] Const mutate z$17_@7:TPrimitive = read x$12_@2.v
33 + [10] Return
34 +scope2 [3:4]:
35 + - dependency: read $10_@0:TPrimitive
36 + - dependency: read $11_@1:TPrimitive
37 +scope3 [4:5]:
38 + - dependency: read x$12_@2.u
39 +scope4 [5:6]:
40 + - dependency: read x$12_@2.v
41 +scope5 [6:7]:
42 + - dependency: read u$13_@3:TPrimitive
43 + - dependency: read v$14_@4:TPrimitive
44 +scope6 [8:9]:
45 + - dependency: read x$12_@2.u
46 +scope7 [9:10]:
47 + - dependency: read x$12_@2.v
48 +```
49 +
50 +## Reactive Scopes
51 +
52 +```
53 +function component(
54 +) {
55 + scope @0 [1:2] deps=[] {
56 + [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
57 + }
58 + scope @1 [2:3] deps=[] {
59 + [2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
60 + }
61 + scope @2 [3:4] deps=[read $10_@0:TPrimitive, read $11_@1:TPrimitive] {
62 + [3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
63 + }
64 + [4] Const mutate u$13_@3:TPrimitive = read x$12_@2.u
65 + [5] Const mutate v$14_@4:TPrimitive = read x$12_@2.v
66 + [6] Const mutate $15_@5:TPrimitive = Binary read u$13_@3:TPrimitive > read v$14_@4:TPrimitive
67 + if (read $15_@5:TPrimitive) {
68 + }
69 + [8] Const mutate y$16_@6:TPrimitive = read x$12_@2.u
70 + [9] Const mutate z$17_@7:TPrimitive = read x$12_@2.v
71 + return
72 +}
73 +
74 +```
75 +
76 +### CFG
77 +
78 +```mermaid
79 +flowchart TB
80 + %% Basic Blocks
81 + subgraph bb0
82 + bb0_instrs["
83 + [1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
84 + [2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
85 + [3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
86 + [4] Const mutate u$13_@3:TPrimitive = read x$12_@2.u
87 + [5] Const mutate v$14_@4:TPrimitive = read x$12_@2.v
88 + [6] Const mutate $15_@5:TPrimitive = Binary read u$13_@3:TPrimitive > read v$14_@4:TPrimitive
89 + "]
90 + bb0_instrs --> bb0_terminal(["If (read $15_@5:TPrimitive)"])
91 + end
92 + subgraph bb1
93 + bb1_instrs["
94 + [8] Const mutate y$16_@6:TPrimitive = read x$12_@2.u
95 + [9] Const mutate z$17_@7:TPrimitive = read x$12_@2.v
96 + "]
97 + bb1_instrs --> bb1_terminal(["Return"])
98 + end
99 +
100 + %% Jumps
101 + bb0_terminal -- "then" --> bb1
102 + bb0_terminal -- "else" --> bb1
103 +
104 +```
105 +
106 +## Code
107 +
108 +```javascript
109 +function component$0() {
110 + const x$12 = {
111 + u: makeSomePrimitive$2(),
112 + v: makeSomePrimitive$2(),
113 + };
114 + const u$13 = x$12.u;
115 + const v$14 = x$12.v;
116 + bb1: if (u$13 > v$14) {
117 + }
118 +
119 + const y$16 = x$12.u;
120 + const z$17 = x$12.v;
121 +}
122 +
123 +```
124 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.js new
+10
@@ -0,0 +1,10 @@
1 +function component() {
2 + let x = { u: makeSomePrimitive(), v: makeSomePrimitive() };
3 + let u = x.u;
4 + let v = x.v;
5 + if (u > v) {
6 + }
7 +
8 + let y = x.u;
9 + let z = x.v;
10 +}
compiler/forget/src/__tests__/fixtures/hir/type-test-field-store.expect.md new
+77
@@ -0,0 +1,77 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let x = {};
7 + let q = {};
8 + x.t = q;
9 + let z = x.t;
10 +}
11 +
12 +```
13 +
14 +## HIR
15 +
16 +```
17 +bb0:
18 + [1] Const mutate x$4_@0:TObject[1:4] = Object { }
19 + [2] Const mutate q$5_@1:TObject = Object { }
20 + [3] Reassign mutate x$4_@0.t[1:4] = read q$5_@1:TObject
21 + [4] Const mutate z$6_@2:TObject = read x$4_@0.t
22 + [5] Return
23 +scope1 [2:3]:
24 + - dependency: mutate x$4_@0.t
25 +scope2 [4:5]:
26 + - dependency: read x$4_@0.t
27 +```
28 +
29 +## Reactive Scopes
30 +
31 +```
32 +function component(
33 +) {
34 + scope @0 [1:4] deps=[] {
35 + [1] Const mutate x$4_@0:TObject[1:4] = Object { }
36 + scope @1 [2:3] deps=[mutate x$4_@0.t] {
37 + [2] Const mutate q$5_@1:TObject = Object { }
38 + }
39 + [3] Reassign mutate x$4_@0.t[1:4] = read q$5_@1:TObject
40 + }
41 + [4] Const mutate z$6_@2:TObject = read x$4_@0.t
42 + return
43 +}
44 +
45 +```
46 +
47 +### CFG
48 +
49 +```mermaid
50 +flowchart TB
51 + %% Basic Blocks
52 + subgraph bb0
53 + bb0_instrs["
54 + [1] Const mutate x$4_@0:TObject[1:4] = Object { }
55 + [2] Const mutate q$5_@1:TObject = Object { }
56 + [3] Reassign mutate x$4_@0.t[1:4] = read q$5_@1:TObject
57 + [4] Const mutate z$6_@2:TObject = read x$4_@0.t
58 + "]
59 + bb0_instrs --> bb0_terminal(["Return"])
60 + end
61 +
62 + %% Jumps
63 + %% empty
64 +```
65 +
66 +## Code
67 +
68 +```javascript
69 +function component$0() {
70 + const x$4 = {};
71 + const q$5 = {};
72 + x$4.t = q$5;
73 + const z$6 = x$4.t;
74 +}
75 +
76 +```
77 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-test-field-store.js new
+6
@@ -0,0 +1,6 @@
1 +function component() {
2 + let x = {};
3 + let q = {};
4 + x.t = q;
5 + let z = x.t;
6 +}
compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.expect.md new
+103
@@ -0,0 +1,103 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let p = makePrimitive();
7 + p + p; // infer p as primitive
8 + let o = {};
9 +
10 + let x = {};
11 +
12 + x.t = p; // infer x.t as primitive
13 + let z = x.t;
14 +
15 + x.t = o; // generalize x.t
16 + let y = x.t;
17 +}
18 +
19 +```
20 +
21 +## HIR
22 +
23 +```
24 +bb0:
25 + [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$2:TFunction()
26 + [2] Binary read p$7_@0:TPrimitive + read p$7_@0:TPrimitive
27 + [3] Const mutate o$8_@1:TObject = Object { }
28 + [4] Const mutate x$9_@2:TObject[4:8] = Object { }
29 + [5] Reassign mutate x$9_@2.t[4:8] = read p$7_@0:TPrimitive
30 + [6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
31 + [7] Reassign mutate x$9_@2.t[4:8] = read o$8_@1:TObject
32 + [8] Const mutate y$11_@3:TPoly = read x$9_@2.t
33 + [9] Return
34 +scope2 [4:8]:
35 + - dependency: read p$7_@0:TPrimitive
36 + - dependency: read o$8_@1:TObject
37 +scope3 [8:9]:
38 + - dependency: read x$9_@2.t
39 +```
40 +
41 +## Reactive Scopes
42 +
43 +```
44 +function component(
45 +) {
46 + scope @0 [1:2] deps=[] {
47 + [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$2:TFunction()
48 + }
49 + [2] Binary read p$7_@0:TPrimitive + read p$7_@0:TPrimitive
50 + scope @1 [3:4] deps=[] {
51 + [3] Const mutate o$8_@1:TObject = Object { }
52 + }
53 + scope @2 [4:8] deps=[read p$7_@0:TPrimitive, read o$8_@1:TObject] {
54 + [4] Const mutate x$9_@2:TObject[4:8] = Object { }
55 + [5] Reassign mutate x$9_@2.t[4:8] = read p$7_@0:TPrimitive
56 + [6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
57 + [7] Reassign mutate x$9_@2.t[4:8] = read o$8_@1:TObject
58 + }
59 + [8] Const mutate y$11_@3:TPoly = read x$9_@2.t
60 + return
61 +}
62 +
63 +```
64 +
65 +### CFG
66 +
67 +```mermaid
68 +flowchart TB
69 + %% Basic Blocks
70 + subgraph bb0
71 + bb0_instrs["
72 + [1] Const mutate p$7_@0:TPrimitive = Call mutate makePrimitive$2:TFunction()
73 + [2] Binary read p$7_@0:TPrimitive + read p$7_@0:TPrimitive
74 + [3] Const mutate o$8_@1:TObject = Object { }
75 + [4] Const mutate x$9_@2:TObject[4:8] = Object { }
76 + [5] Reassign mutate x$9_@2.t[4:8] = read p$7_@0:TPrimitive
77 + [6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
78 + [7] Reassign mutate x$9_@2.t[4:8] = read o$8_@1:TObject
79 + [8] Const mutate y$11_@3:TPoly = read x$9_@2.t
80 + "]
81 + bb0_instrs --> bb0_terminal(["Return"])
82 + end
83 +
84 + %% Jumps
85 + %% empty
86 +```
87 +
88 +## Code
89 +
90 +```javascript
91 +function component$0() {
92 + const p$7 = makePrimitive$2();
93 + p$7 + p$7;
94 + const o$8 = {};
95 + const x$9 = {};
96 + x$9.t = p$7;
97 + const z$10 = x$9.t;
98 + x$9.t = o$8;
99 + const y$11 = x$9.t;
100 +}
101 +
102 +```
103 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.js new
+13
@@ -0,0 +1,13 @@
1 +function component() {
2 + let p = makePrimitive();
3 + p + p; // infer p as primitive
4 + let o = {};
5 +
6 + let x = {};
7 +
8 + x.t = p; // infer x.t as primitive
9 + let z = x.t;
10 +
11 + x.t = o; // generalize x.t
12 + let y = x.t;
13 +}
compiler/forget/src/__tests__/fixtures/hir/type-test-primitive.expect.md new
+60
@@ -0,0 +1,60 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let x = 1;
7 + let y = 2;
8 +}
9 +
10 +```
11 +
12 +## HIR
13 +
14 +```
15 +bb0:
16 + [1] Const mutate x$3_@0:TPrimitive = 1
17 + [2] Const mutate y$4_@1:TPrimitive = 2
18 + [3] Return
19 +
20 +```
21 +
22 +## Reactive Scopes
23 +
24 +```
25 +function component(
26 +) {
27 + [1] Const mutate x$3_@0:TPrimitive = 1
28 + [2] Const mutate y$4_@1:TPrimitive = 2
29 + return
30 +}
31 +
32 +```
33 +
34 +### CFG
35 +
36 +```mermaid
37 +flowchart TB
38 + %% Basic Blocks
39 + subgraph bb0
40 + bb0_instrs["
41 + [1] Const mutate x$3_@0:TPrimitive = 1
42 + [2] Const mutate y$4_@1:TPrimitive = 2
43 + "]
44 + bb0_instrs --> bb0_terminal(["Return"])
45 + end
46 +
47 + %% Jumps
48 + %% empty
49 +```
50 +
51 +## Code
52 +
53 +```javascript
54 +function component$0() {
55 + const x$3 = 1;
56 + const y$4 = 2;
57 +}
58 +
59 +```
60 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-test-primitive.js new
+4
@@ -0,0 +1,4 @@
1 +function component() {
2 + let x = 1;
3 + let y = 2;
4 +}
compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.expect.md new
+110
@@ -0,0 +1,110 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function component() {
6 + let x = foo();
7 + let y = foo();
8 + if (x > y) {
9 + let z = {};
10 + }
11 +
12 + let z = foo();
13 +}
14 +
15 +```
16 +
17 +## HIR
18 +
19 +```
20 +bb0:
21 + [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
22 + [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
23 + [3] Const mutate $9_@2:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
24 + [4] If (read $9_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
25 +bb2:
26 + predecessor blocks: bb0
27 + [5] Const mutate z$10_@3:TObject = Object { }
28 + [6] Goto bb1
29 +bb1:
30 + predecessor blocks: bb2 bb0
31 + [7] Const mutate z$12_@4:TPrimitive = Call mutate foo$2:TFunction()
32 + [8] Return
33 +scope2 [3:4]:
34 + - dependency: read x$7_@0:TPrimitive
35 + - dependency: read y$8_@1:TPrimitive
36 +```
37 +
38 +## Reactive Scopes
39 +
40 +```
41 +function component(
42 +) {
43 + scope @0 [1:2] deps=[] {
44 + [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
45 + }
46 + scope @1 [2:3] deps=[] {
47 + [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
48 + }
49 + [3] Const mutate $9_@2:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
50 + if (read $9_@2:TPrimitive) {
51 + scope @3 [5:6] deps=[] {
52 + [5] Const mutate z$10_@3:TObject = Object { }
53 + }
54 + }
55 + scope @4 [7:8] deps=[] {
56 + [7] Const mutate z$12_@4:TPrimitive = Call mutate foo$2:TFunction()
57 + }
58 + return
59 +}
60 +
61 +```
62 +
63 +### CFG
64 +
65 +```mermaid
66 +flowchart TB
67 + %% Basic Blocks
68 + subgraph bb0
69 + bb0_instrs["
70 + [1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
71 + [2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
72 + [3] Const mutate $9_@2:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
73 + "]
74 + bb0_instrs --> bb0_terminal(["If (read $9_@2:TPrimitive)"])
75 + end
76 + subgraph bb2
77 + bb2_instrs["
78 + [5] Const mutate z$10_@3:TObject = Object { }
79 + "]
80 + bb2_instrs --> bb2_terminal(["Goto"])
81 + end
82 + subgraph bb1
83 + bb1_instrs["
84 + [7] Const mutate z$12_@4:TPrimitive = Call mutate foo$2:TFunction()
85 + "]
86 + bb1_instrs --> bb1_terminal(["Return"])
87 + end
88 +
89 + %% Jumps
90 + bb0_terminal -- "then" --> bb2
91 + bb0_terminal -- "else" --> bb1
92 + bb2_terminal --> bb1
93 +
94 +```
95 +
96 +## Code
97 +
98 +```javascript
99 +function component$0() {
100 + const x$7 = foo$2();
101 + const y$8 = foo$2();
102 + bb1: if (x$7 > y$8) {
103 + const z$10 = {};
104 + }
105 +
106 + const z$12 = foo$2();
107 +}
108 +
109 +```
110 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.js new
+9
@@ -0,0 +1,9 @@
1 +function component() {
2 + let x = foo();
3 + let y = foo();
4 + if (x > y) {
5 + let z = {};
6 + }
7 +
8 + let z = foo();
9 +}
compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md
+6 -6
@@ -31,11 +31,11 @@ bb5:
31 [4] Goto(Continue) bb1
32 bb4:
33 predecessor blocks: bb3
34 - [5] Call read c$7()
34 + [5] Call read c$7:TFunction()
35 [6] Goto(Continue) bb1
36 bb2:
37 predecessor blocks: bb1
38 - [7] Call read d$8()
38 + [7] Call read d$8:TFunction()
39 [8] Return
40
41 ```
@@ -55,9 +55,9 @@ function foo(
55 if (read b$6) {
56 continue
57 }
58 - [5] Call read c$7()
58 + [5] Call read c$7:TFunction()
59 }
60 - [7] Call read d$8()
60 + [7] Call read d$8:TFunction()
61 return
62 }
63
@@ -82,13 +82,13 @@ flowchart TB
82 end
83 subgraph bb4
84 bb4_instrs["
85 - [5] Call read c$7()
85 + [5] Call read c$7:TFunction()
86 "]
87 bb4_instrs --> bb4_terminal(["Goto"])
88 end
89 subgraph bb2
90 bb2_instrs["
91 - [7] Call read d$8()
91 + [7] Call read d$8:TFunction()
92 "]
93 bb2_instrs --> bb2_terminal(["Return"])
94 end
compiler/forget/src/__tests__/hir-test.ts
+1
@@ -144,6 +144,7 @@ function transform(text: string, file: string): Array<TestOutput> {
144 const { ir, ast } = run(nodePath, {
145 eliminateRedundantPhi: true,
146 inferReferenceEffects: true,
147 + inferTypes: true,
148 inferMutableRanges: true,
149 inferReactiveScopeVariables: true,
150 inferReactiveScopes: true,