@samitouri / QOS-React-2 / commits / 9f7878c7c0

[easy] remove `isFallthrough` arg from `mapTerminalSuccessors`

The argument was unused and a confusing boolean argument that's easy to mix up. Suggesting to remove it until we see a need for it at which point we might want to introduce an enum to make the argument more obvious.

Jan Kassens committed Nov 28, 2022 at 17:48 UTC 9f7878c7c01eb0c7d6d95ed156850b02bbb02f32
1 file changed +10 -10
compiler/forget/src/HIR/visitors.ts
+10 -10
@@ -146,11 +146,11 @@ export function mapInstructionOperands(
146 */
147 export function mapTerminalSuccessors(
148 terminal: Terminal,
149 - fn: (block: BlockId, isFallthrough: boolean) => BlockId
149 + fn: (block: BlockId) => BlockId
150 ): Terminal {
151 switch (terminal.kind) {
152 case "goto": {
153 - const target = fn(terminal.block, false);
153 + const target = fn(terminal.block);
154 return {
155 kind: "goto",
156 block: target,
@@ -159,10 +159,10 @@ export function mapTerminalSuccessors(
159 };
160 }
161 case "if": {
162 - const consequent = fn(terminal.consequent, false);
163 - const alternate = fn(terminal.alternate, false);
162 + const consequent = fn(terminal.consequent);
163 + const alternate = fn(terminal.alternate);
164 const fallthrough =
165 - terminal.fallthrough !== null ? fn(terminal.fallthrough, true) : null;
165 + terminal.fallthrough !== null ? fn(terminal.fallthrough) : null;
166 return {
167 kind: "if",
168 test: terminal.test,
@@ -174,14 +174,14 @@ export function mapTerminalSuccessors(
174 }
175 case "switch": {
176 const cases = terminal.cases.map((case_) => {
177 - const target = fn(case_.block, false);
177 + const target = fn(case_.block);
178 return {
179 test: case_.test,
180 block: target,
181 };
182 });
183 const fallthrough =
184 - terminal.fallthrough !== null ? fn(terminal.fallthrough, true) : null;
184 + terminal.fallthrough !== null ? fn(terminal.fallthrough) : null;
185 return {
186 kind: "switch",
187 test: terminal.test,
@@ -202,9 +202,9 @@ export function mapTerminalSuccessors(
202 return terminal;
203 }
204 case "while": {
205 - const test = fn(terminal.test, false);
206 - const loop = fn(terminal.loop, true);
207 - const fallthrough = fn(terminal.fallthrough, true);
205 + const test = fn(terminal.test);
206 + const loop = fn(terminal.loop);
207 + const fallthrough = fn(terminal.fallthrough);
208 return {
209 kind: "while",
210 loc: terminal.loc,