[be] Cleanup BuildHIR
Joe Savona committed
Feb 9, 2023 at 11:41 UTC
8eb5feb847e4c399fb9525ca816477bf422994d3
2 files changed
+6
-60
compiler/forget/src/HIR/BuildHIR.ts
+4
-58
@@ -1373,7 +1373,7 @@ function lowerExpression(
1373
if (expr.get("quasi").get("expressions").length !== 0) {
1374
builder.errors.push({
1375
reason:
1376
- "(BuildHIR::lowerAssignment) Handle tagged template with interpolations",
1376
+ "(BuildHIR::lowerExpression) Handle tagged template with interpolations",
1377
severity: ErrorSeverity.Todo,
1378
nodePath: exprPath,
1379
});
@@ -1387,7 +1387,7 @@ function lowerExpression(
1387
if (value.raw !== value.cooked) {
1388
builder.errors.push({
1389
reason:
1390
- "(BuildHIR::lowerAssignment) Handle tagged template where cooked value is different from raw value",
1390
+ "(BuildHIR::lowerExpression) Handle tagged template where cooked value is different from raw value",
1391
severity: ErrorSeverity.Todo,
1392
nodePath: exprPath,
1393
});
@@ -1408,7 +1408,7 @@ function lowerExpression(
1408
1409
if (subexprs.length !== quasis.length - 1) {
1410
builder.errors.push({
1411
- reason: `(BuildHIR::lowerAssignment) Unexpected quasi and subexpression lengths in TemplateLiteral.`,
1411
+ reason: `(BuildHIR::lowerExpression) Unexpected quasi and subexpression lengths in TemplateLiteral.`,
1412
severity: ErrorSeverity.InvalidInput,
1413
nodePath: exprPath,
1414
});
@@ -1524,7 +1524,7 @@ function lowerMemberExpression(
1524
if (!expr.node.computed) {
1525
if (!property.isIdentifier()) {
1526
builder.errors.push({
1527
- reason: `(BuildHIR::lowerExpression) Handle ${property.type} property`,
1527
+ reason: `(BuildHIR::lowerMemberExpression) Handle ${property.type} property`,
1528
severity: ErrorSeverity.Todo,
1529
nodePath: property,
1530
});
@@ -1570,60 +1570,6 @@ function lowerMemberExpression(
1570
}
1571
}
1572
1573
-function lowerConditional(
1574
- builder: HIRBuilder,
1575
- test: Place,
1576
- loc: SourceLocation,
1577
- consequent: () => InstructionValue,
1578
- alternate: () => InstructionValue
1579
-): Place {
1580
- const place: Place = buildTemporaryPlace(builder, loc);
1581
- // Block for code following the if
1582
- const continuationBlock = builder.reserve("block");
1583
- // Block for the consequent (if the test is truthy)
1584
- const consequentBlock = builder.enter("value", (blockId) => {
1585
- let value = consequent();
1586
- builder.push({
1587
- id: makeInstructionId(0),
1588
- value,
1589
- lvalue: { place: { ...place }, kind: InstructionKind.Const },
1590
- loc: value.loc,
1591
- });
1592
- return {
1593
- kind: "goto",
1594
- block: continuationBlock.id,
1595
- variant: GotoVariant.Break,
1596
- id: makeInstructionId(0),
1597
- };
1598
- });
1599
- // Block for the alternate (if the test is not truthy)
1600
- const alternateBlock = builder.enter("value", (blockId) => {
1601
- let value = alternate();
1602
- builder.push({
1603
- id: makeInstructionId(0),
1604
- value,
1605
- lvalue: { place: { ...place }, kind: InstructionKind.Const },
1606
- loc: value.loc,
1607
- });
1608
- return {
1609
- kind: "goto",
1610
- block: continuationBlock.id,
1611
- variant: GotoVariant.Break,
1612
- id: makeInstructionId(0),
1613
- };
1614
- });
1615
- const terminal: IfTerminal = {
1616
- kind: "if",
1617
- test,
1618
- consequent: consequentBlock,
1619
- alternate: alternateBlock,
1620
- fallthrough: continuationBlock.id,
1621
- id: makeInstructionId(0),
1622
- };
1623
- builder.terminateWithContinuation(terminal, continuationBlock);
1624
- return place;
1625
-}
1626
-
1573
function lowerJsxElementName(
1574
builder: HIRBuilder,
1575
exprPath: NodePath<
compiler/forget/src/__tests__/fixtures/hir/error.todo-kitchensink.expect.md
+2
-2
@@ -303,7 +303,7 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
303
36 | }
304
37 |
305
306
-[ReactForget] TodoError: (BuildHIR::lowerAssignment) Handle tagged template with interpolations
306
+[ReactForget] TodoError: (BuildHIR::lowerExpression) Handle tagged template with interpolations
307
36 | }
308
37 |
309
> 38 | graphql`
@@ -312,7 +312,7 @@ function foo([a, b], { c, d, e = "e" }, f = "f", ...args) {
312
40 | `;
313
41 |
314
315
-[ReactForget] TodoError: (BuildHIR::lowerAssignment) Handle tagged template where cooked value is different from raw value
315
+[ReactForget] TodoError: (BuildHIR::lowerExpression) Handle tagged template where cooked value is different from raw value
316
40 | `;
317
41 |
318
> 42 | graphql`\\t\n`;