2007-12-24 16:19:51 +08:00
|
|
|
package net.loveruby.cflat.ast;
|
2008-10-24 22:03:31 +08:00
|
|
|
import net.loveruby.cflat.asm.Label;
|
2007-12-24 16:19:51 +08:00
|
|
|
import java.util.*;
|
|
|
|
|
2008-01-05 09:34:27 +08:00
|
|
|
public class SwitchNode extends StmtNode implements BreakableStmt {
|
2008-01-02 19:53:41 +08:00
|
|
|
protected ExprNode cond;
|
2008-09-29 02:46:56 +08:00
|
|
|
protected List<CaseNode> cases;
|
2007-12-24 16:19:51 +08:00
|
|
|
protected Label endLabel;
|
|
|
|
|
2008-10-25 02:40:21 +08:00
|
|
|
public SwitchNode(Location loc, ExprNode cond, List<CaseNode> cases) {
|
2008-01-05 09:34:27 +08:00
|
|
|
super(loc);
|
2007-12-24 16:19:51 +08:00
|
|
|
this.cond = cond;
|
|
|
|
this.cases = cases;
|
2008-10-25 02:40:21 +08:00
|
|
|
this.endLabel = new Label();
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
2008-01-02 19:53:41 +08:00
|
|
|
public ExprNode cond() {
|
2007-12-24 16:19:51 +08:00
|
|
|
return cond;
|
|
|
|
}
|
|
|
|
|
2009-04-04 22:47:11 +08:00
|
|
|
public void setCond(ExprNode cond) {
|
|
|
|
this.cond = cond;
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<CaseNode> cases() {
|
|
|
|
return cases;
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public Label endLabel() {
|
|
|
|
return endLabel;
|
|
|
|
}
|
|
|
|
|
2008-01-04 07:01:49 +08:00
|
|
|
protected void _dump(Dumper d) {
|
|
|
|
d.printMember("cond", cond);
|
|
|
|
d.printNodeList("cases", cases);
|
|
|
|
}
|
|
|
|
|
2009-04-12 14:31:12 +08:00
|
|
|
public <S,E> S accept(ASTVisitor<S,E> visitor) {
|
2009-04-04 22:47:11 +08:00
|
|
|
return visitor.visit(this);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
}
|