2007-12-24 16:19:51 +08:00
|
|
|
package net.loveruby.cflat.ast;
|
|
|
|
import net.loveruby.cflat.asm.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class SwitchNode extends Node implements BreakableStmt {
|
|
|
|
protected LabelPool pool;
|
2008-01-02 19:53:41 +08:00
|
|
|
protected ExprNode cond;
|
2007-12-24 16:19:51 +08:00
|
|
|
protected List cases;
|
|
|
|
protected Label endLabel;
|
|
|
|
|
2008-01-02 19:53:41 +08:00
|
|
|
public SwitchNode(LabelPool pool, ExprNode cond, List cases) {
|
2007-12-24 16:19:51 +08:00
|
|
|
super();
|
|
|
|
this.pool = pool;
|
|
|
|
this.cond = cond;
|
|
|
|
this.cases = cases;
|
|
|
|
}
|
|
|
|
|
2008-01-02 19:53:41 +08:00
|
|
|
public ExprNode cond() {
|
2007-12-24 16:19:51 +08:00
|
|
|
return cond;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Iterator cases() {
|
|
|
|
return cases.iterator();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Label endLabel() {
|
|
|
|
if (endLabel == null) {
|
|
|
|
endLabel = pool.newLabel();
|
|
|
|
}
|
|
|
|
return endLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void accept(ASTVisitor visitor) {
|
|
|
|
visitor.visit(this);
|
|
|
|
}
|
|
|
|
}
|