Add adt_def into Switch, since it's convenient to have in trans

This commit is contained in:
Niko Matsakis 2015-10-21 17:28:51 -04:00
parent b5d3580843
commit 3ab29d3378
2 changed files with 4 additions and 2 deletions

View File

@ -92,6 +92,7 @@ pub fn perform_test(&mut self,
.collect();
self.cfg.terminate(block, Terminator::Switch {
discr: lvalue.clone(),
adt_def: adt_def,
targets: target_blocks.clone()
});
target_blocks

View File

@ -247,6 +247,7 @@ pub enum Terminator<'tcx> {
/// lvalue evaluates to some enum; jump depending on the branch
Switch {
discr: Lvalue<'tcx>,
adt_def: AdtDef<'tcx>,
targets: Vec<BasicBlock>,
},
@ -279,7 +280,7 @@ pub fn successors(&self) -> &[BasicBlock] {
Goto { target: ref b } => slice::ref_slice(b),
Panic { target: ref b } => slice::ref_slice(b),
If { cond: _, targets: ref b } => b,
Switch { discr: _, targets: ref b } => b,
Switch { discr: _, adt_def: _, targets: ref b } => b,
Diverge => &[],
Return => &[],
Call { data: _, targets: ref b } => b,
@ -318,7 +319,7 @@ fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
write!(fmt, "panic -> {:?}", target),
If { cond: ref lv, ref targets } =>
write!(fmt, "if({:?}) -> {:?}", lv, targets),
Switch { discr: ref lv, ref targets } =>
Switch { discr: ref lv, adt_def: _, ref targets } =>
write!(fmt, "switch({:?}) -> {:?}", lv, targets),
Diverge =>
write!(fmt, "diverge"),