aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/patio/instructions/PatioSwitch.java
blob: 28923ea7b2390b0cfe8598619df50b53883f7e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package org.shedlang.compiler.patio.instructions;

import org.shedlang.compiler.patio.operands.PatioLocalRef;
import org.shedlang.compiler.patio.operands.PatioOperand;
import org.shedlang.compiler.sources.Source;

import java.util.List;

/// Find a case with a value matching that of the instruction's value. If such a
/// case is found, execute the body of that case, otherwise execute the default
/// body.
///
/// Each block must have the same number of results as destinations. Each result
/// is assigned to the destination with the same index.
public record PatioSwitch(
    List<PatioLocalRef> destinations,
    PatioOperand value,
    List<PatioSwitchCase> cases,
    PatioBlock defaultBody,
    Source source
) implements PatioInstruction {
    @Override
    public boolean isBlockTerminator() {
        return true;
    }
}