forked from JavaTX/JavaCompilerCore
44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
package de.dhbwstuttgart.syntaxtree.statement;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.antlr.v4.runtime.Token;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
|
|
|
public class SwitchBlock extends Block {
|
|
|
|
private List<SwitchLabel> labels = new ArrayList<>();
|
|
|
|
private boolean defaultBlock = false;
|
|
public final boolean isExpression; // This is for single expressions that yield a value
|
|
|
|
public SwitchBlock(List<SwitchLabel> labels, Block statements, boolean isExpression, Token offset) {
|
|
super(statements.getStatements(), offset);
|
|
this.labels = labels;
|
|
this.isExpression = isExpression;
|
|
}
|
|
|
|
public SwitchBlock(List<SwitchLabel> labels, Block statements, boolean isDefault, boolean isExpression, Token offset) {
|
|
super(statements.getStatements(), offset);
|
|
this.labels = labels;
|
|
this.defaultBlock = isDefault;
|
|
this.isExpression = isExpression;
|
|
}
|
|
|
|
public boolean isDefault() {
|
|
return defaultBlock;
|
|
}
|
|
|
|
public List<SwitchLabel> getLabels() {
|
|
return labels;
|
|
}
|
|
|
|
@Override
|
|
public void accept(StatementVisitor visitor) {
|
|
visitor.visit(this);
|
|
}
|
|
|
|
}
|