aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/patio/instructions/PatioBlock.java
blob: fd7932b629a53c1442445a378782797c836f1127 (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
27
28
29
package org.shedlang.compiler.patio.instructions;

import org.shedlang.compiler.patio.operands.PatioOperand;
import org.shedlang.compiler.sources.Source;
import org.shedlang.compiler.util.Lists;

import java.util.List;

/// Execute the instructions in the body of the block. The results may be used in
/// the parent scope, but any other variables (as distinct from values) are no
/// longer in use.
public record PatioBlock(
    List<PatioInstruction> body,
    List<? extends PatioOperand> results,
    Source source
) implements PatioInstruction {
    public PatioBlock addInstruction(PatioInstruction instruction) {
        return new PatioBlock(
            Lists.concat(this.body, List.of(instruction)),
            this.results,
            this.source
        );
    }

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