@samitouri / QOS-React-2 / commits / 34bca247d6

[hir] Terminate function within BuildHIR

All the block building logic is encapsulated in BuildHIR.

Sathya Gunasekaran committed Apr 11, 2023 at 15:40 UTC 34bca247d69c60d9318892e335959a3001839a9e
2 files changed +10 -10
compiler/forget/src/HIR/BuildHIR.ts
+10
@@ -153,6 +153,16 @@ export function lower(
153 return Err(builder.errors);
154 }
155
156 + builder.terminate(
157 + {
158 + kind: "return",
159 + loc: GeneratedSource,
160 + value: null,
161 + id: makeInstructionId(0),
162 + },
163 + null
164 + );
165 +
166 return Ok({
167 id,
168 params,
compiler/forget/src/HIR/HIRBuilder.ts
-10
@@ -17,7 +17,6 @@ import {
17 BasicBlock,
18 BlockId,
19 BlockKind,
20 - GeneratedSource,
20 GotoVariant,
21 HIR,
22 Identifier,
@@ -257,15 +256,6 @@ export default class HIRBuilder {
256 * Construct a final CFG from this context
257 */
258 build(): HIR {
260 - this.terminate(
261 - {
262 - kind: "return",
263 - loc: GeneratedSource,
264 - value: null,
265 - id: makeInstructionId(0),
266 - },
267 - null
268 - );
259 let ir: HIR = {
260 blocks: this.#completed,
261 entry: this.#entry,