79
func.get("params").forEach((param) => {
80
if (param.isIdentifier()) {
81
const identifier = builder.resolveIdentifier(param);
82
+ if (identifier === null) {
83
+ builder.errors.push({
84
+ reason: `(BuildHIR::lower) Could not find binding for param '${param.node.name}'`,
85
+ severity: ErrorSeverity.Invariant,
86
+ nodePath: param,
87
+ });
88
+ return;
89
+ }
90
const place: Place = {
91
kind: "Identifier",
92
identifier,
1599
}
1600
const tag: string = exprPath.node.name;
1601
if (tag.match(/^[A-Z]/)) {
1594
- const identifier = builder.resolveIdentifier(exprPath);
1595
- const place: Place = {
1596
- kind: "Identifier",
1597
- identifier: identifier,
1598
- effect: Effect.Unknown,
1599
- loc: exprLoc,
1600
- };
1601
- return place;
1602
+ return lowerIdentifier(builder, exprPath);
1603
} else {
1604
const place: Place = buildTemporaryPlace(builder, exprLoc);
1605
builder.push({
1729
1730
function lowerIdentifier(
1731
builder: HIRBuilder,
1731
- exprPath: NodePath<t.Identifier>
1732
+ exprPath: NodePath<t.Identifier | t.JSXIdentifier>
1733
): Place {
1734
const exprNode = exprPath.node;
1735
const exprLoc = exprNode.loc ?? GeneratedSource;
1736
const identifier = builder.resolveIdentifier(exprPath);
1737
+ if (identifier === null) {
1738
+ const place = buildTemporaryPlace(
1739
+ builder,
1740
+ exprPath.node.loc ?? GeneratedSource
1741
+ );
1742
+ const global = builder.resolveGlobal(exprPath);
1743
+ let value: InstructionValue;
1744
+ if (global !== null) {
1745
+ value = { kind: "LoadGlobal", name: global.name, loc: place.loc };
1746
+ } else {
1747
+ value = { kind: "UnsupportedNode", node: exprPath.node, loc: place.loc };
1748
+ }
1749
+ builder.push({
1750
+ id: makeInstructionId(0),
1751
+ value,
1752
+ loc: place.loc,
1753
+ lvalue: {
1754
+ place: { ...place },
1755
+ kind: InstructionKind.Const,
1756
+ },
1757
+ });
1758
+ return place;
1759
+ }
1760
const place: Place = {
1761
kind: "Identifier",
1762
identifier: identifier,