aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/shid/instructions/ShidSwitch.java
blob: 2f4a0b24997f15f115fcee196c3a658e421974cb (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.shid.instructions;

import org.shedlang.compiler.sources.Source;
import org.shedlang.compiler.types.SimpleStructType;

import java.util.List;

/**
 * Pop a value from the temporary value stack, find the case corresponding to
 * that value's type, and execute the case's body. If there is no such case, the
 * behaviour of this instruction is not defined.
 * <p>
 * Each case body should push exactly one value onto the temporary value stack.
 */
public record ShidSwitch(
    List<Case> cases,
    Source source
) implements ShidInstruction {
    public record Case(SimpleStructType caseType, ShidBlock body, Source source) {
    }

    @Override
    public boolean isBlockTerminator() {
        return false;
    }
}