[hir] Add Type to Place

This commit is contained in:
Sathya Gunasekaran
2022-12-12 21:10:50 +00:00
parent e2e5e389af
commit b8cf85d77d
4 changed files with 22 additions and 1 deletions
+13 -1
View File
@@ -21,8 +21,8 @@ import {
Place,
ReturnTerminal,
SourceLocation,
Terminal,
ThrowTerminal,
Type,
} from "./HIR";
import HIRBuilder, { Environment } from "./HIRBuilder";
import todo, { todoInvariant } from "./todo";
@@ -83,6 +83,7 @@ export function lower(
memberPath: null,
effect: Effect.Unknown,
loc: param.loc ?? GeneratedSource,
type: Type.Any,
};
params.push(place);
});
@@ -890,6 +891,7 @@ function lowerExpression(
memberPath: null,
effect: Effect.Unknown,
loc: left.loc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -908,6 +910,7 @@ function lowerExpression(
memberPath: null,
effect: Effect.Unknown,
loc: left.loc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -1006,6 +1009,7 @@ function lowerExpression(
memberPath: [...(object.memberPath ?? []), property.node.name],
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
return place;
}
@@ -1082,6 +1086,7 @@ function lowerConditional(
memberPath: null,
effect: Effect.Read,
loc,
type: Type.Any,
};
// Block for code following the if
const continuationBlock = builder.reserve();
@@ -1153,6 +1158,7 @@ function lowerJsxElementName(
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
return place;
} else {
@@ -1162,6 +1168,7 @@ function lowerJsxElementName(
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -1202,6 +1209,7 @@ function lowerJsxElement(
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -1225,6 +1233,7 @@ function lowerJsxElement(
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -1255,6 +1264,7 @@ function lowerExpressionToPlace(
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
builder.push({
id: makeInstructionId(0),
@@ -1303,6 +1313,7 @@ function lowerLVal(builder: HIRBuilder, exprPath: NodePath<t.LVal>): Place {
memberPath: null,
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
return place;
}
@@ -1322,6 +1333,7 @@ function lowerLVal(builder: HIRBuilder, exprPath: NodePath<t.LVal>): Place {
memberPath: [...(object.memberPath ?? []), propertyPath.node.name],
effect: Effect.Unknown,
loc: exprLoc,
type: Type.Any,
};
return place;
}
+5
View File
@@ -270,6 +270,7 @@ export type Place = {
memberPath: Array<string> | null;
effect: Effect;
loc: SourceLocation;
type: Type;
};
/**
@@ -398,3 +399,7 @@ export function makeInstructionId(id: number): InstructionId {
);
return id as InstructionId;
}
export enum Type {
Any,
}
@@ -16,6 +16,7 @@ import {
InstructionValue,
Phi,
Place,
Type,
ValueKind,
} from "./HIR";
import { printMixedHIR, printPlace, printSourceLocation } from "./PrintHIR";
@@ -77,6 +78,7 @@ export default function inferReferenceEffects(fn: HIRFunction) {
identifier: fn.id as any,
loc: fn.loc,
effect: Effect.Freeze,
type: Type.Any,
};
const value: InstructionValue = {
kind: "Primitive",
+2
View File
@@ -16,6 +16,7 @@ import {
makeInstructionId,
Phi,
Place,
Type,
} from "./HIR";
import { eachInstructionValueOperand, eachTerminalOperand } from "./visitors";
@@ -153,6 +154,7 @@ export function leaveSSA(fn: HIRFunction) {
identifier,
effect: Effect.Mutate,
loc: GeneratedSource,
type: Type.Any,
},
kind: InstructionKind.Let,
},