mirror of https://github.com/aamine/cbc
45 lines
1.0 KiB
Java
45 lines
1.0 KiB
Java
package net.loveruby.cflat.ast;
|
|
import java.util.*;
|
|
|
|
public class BlockNode extends StmtNode {
|
|
protected List<DefinedVariable> variables;
|
|
protected List<StmtNode> stmts;
|
|
protected LocalScope scope;
|
|
|
|
public BlockNode(Location loc, List<DefinedVariable> vars, List<StmtNode> stmts) {
|
|
super(loc);
|
|
this.variables = vars;
|
|
this.stmts = stmts;
|
|
}
|
|
|
|
public List<DefinedVariable> variables() {
|
|
return variables;
|
|
}
|
|
|
|
public List<StmtNode> stmts() {
|
|
return stmts;
|
|
}
|
|
|
|
public StmtNode tailStmt() {
|
|
if (stmts.isEmpty()) return null;
|
|
return stmts.get(stmts.size() - 1);
|
|
}
|
|
|
|
public LocalScope scope() {
|
|
return scope;
|
|
}
|
|
|
|
public void setScope(LocalScope scope) {
|
|
this.scope = scope;
|
|
}
|
|
|
|
protected void _dump(Dumper d) {
|
|
d.printNodeList("variables", variables);
|
|
d.printNodeList("stmts", stmts);
|
|
}
|
|
|
|
public BlockNode accept(ASTVisitor visitor) {
|
|
return visitor.visit(this);
|
|
}
|
|
}
|