Codegen TValue are just Expressions (#839)
Jan Kassens committed
Dec 1, 2022 at 12:56 UTC
df58546f4e3556a5f6f30495bd57f7039cdc0f13
1 file changed
+4
-14
compiler/forget/src/HIR/Codegen.ts
+4
-14
@@ -91,12 +91,7 @@ type Temporaries = Map<IdentifierId, t.Expression>;
91
92
class CodegenVisitor
93
implements
94
- Visitor<
95
- Array<t.Statement>,
96
- t.Expression | t.Statement | t.JSXFragment,
97
- t.Statement,
98
- t.SwitchCase
99
- >
94
+ Visitor<Array<t.Statement>, t.Expression, t.Statement, t.SwitchCase>
95
{
96
depth: number = 0;
97
temp: Map<IdentifierId, t.Expression> = new Map();
@@ -105,15 +100,10 @@ class CodegenVisitor
100
this.depth++;
101
return [];
102
}
108
- visitValue(
109
- value: InstructionValue
110
- ): t.Expression | t.Statement | t.JSXFragment {
103
+ visitValue(value: InstructionValue): t.Expression {
104
return codegenInstructionValue(this.temp, value);
105
}
113
- visitInstruction(
114
- instr: Instruction,
115
- value: t.Expression | t.Statement | t.JSXFragment
116
- ): t.Statement {
106
+ visitInstruction(instr: Instruction, value: t.Expression): t.Statement {
107
if (t.isStatement(value)) {
108
return value;
109
}
@@ -256,7 +246,7 @@ function codegenLabel(id: BlockId): string {
246
function codegenInstructionValue(
247
temp: Temporaries,
248
instrValue: InstructionValue
259
-): t.Expression | t.JSXFragment | t.Statement {
249
+): t.Expression {
250
let value: t.Expression;
251
switch (instrValue.kind) {
252
case "ArrayExpression": {