941
});
942
return;
943
}
944
+ if (stmt.get("finalizer").node != null) {
945
+ builder.errors.push({
946
+ reason: `(BuildHIR::lowerStatement) Handle TryStatement with a finalizer ('finally') clause`,
947
+ severity: ErrorSeverity.Todo,
948
+ loc: stmt.node.loc ?? null,
949
+ suggestions: null,
950
+ });
951
+ }
952
+
953
+ const handlerBindingPath = handlerPath.get("param");
954
+ let handlerBinding: {
955
+ place: Place;
956
+ path: NodePath<t.Identifier | t.ArrayPattern | t.ObjectPattern>;
957
+ } | null = null;
958
+ if (handlerBindingPath.node != null && handlerBindingPath.hasNode()) {
959
+ const place: Place = {
960
+ kind: "Identifier",
961
+ identifier: builder.makeTemporary(),
962
+ effect: Effect.Unknown,
963
+ loc: handlerBindingPath.node.loc ?? GeneratedSource,
964
+ };
965
+ lowerValueToTemporary(builder, {
966
+ kind: "DeclareLocal",
967
+ lvalue: {
968
+ kind: InstructionKind.Catch,
969
+ place: { ...place },
970
+ },
971
+ loc: handlerBindingPath.node.loc ?? GeneratedSource,
972
+ });
973
+
974
+ handlerBinding = {
975
+ path: handlerBindingPath,
976
+ place,
977
+ };
978
+ }
979
+
980
const handler = builder.enter("block", (_blockId) => {
981
+ if (handlerBinding !== null) {
982
+ lowerAssignment(
983
+ builder,
984
+ handlerBinding.path.node.loc ?? GeneratedSource,
985
+ InstructionKind.Catch,
986
+ handlerBinding.path,
987
+ { ...handlerBinding.place }
988
+ );
989
+ }
990
lowerStatement(builder, handlerPath.get("body"));
991
return {
992
kind: "goto",
996
loc: handlerPath.node.loc ?? GeneratedSource,
997
};
998
});
954
- if (stmt.get("finalizer").node != null) {
955
- builder.errors.push({
956
- reason: `(BuildHIR::lowerStatement) Handle TryStatement with a finalizer ('finally') clause`,
957
- severity: ErrorSeverity.Todo,
958
- loc: stmt.node.loc ?? null,
959
- suggestions: null,
960
- });
961
- }
999
1000
const block = builder.enter("block", (_blockId) => {
1001
const block = stmt.get("block");
1015
{
1016
kind: "try",
1017
block,
1018
+ handlerBinding:
1019
+ handlerBinding !== null ? { ...handlerBinding.place } : null,
1020
handler,
1021
fallthrough: continuationBlock.id,
1022
id: makeInstructionId(0),