Eliminate layout::Cursor from cton_frontend.

Replace all uses with a FuncCursor.

Avoid the anti-pattern of passing parts of a function around as
independent references.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-21 12:16:32 -07:00
parent 03dee5e442
commit 1cd91b6f30
4 changed files with 172 additions and 485 deletions

View File

@@ -80,9 +80,10 @@ impl TopoOrder {
#[cfg(test)]
mod test {
use cursor::{Cursor, FuncCursor};
use flowgraph::ControlFlowGraph;
use dominator_tree::DominatorTree;
use ir::{Function, InstBuilder, Cursor, CursorBase};
use ir::{Function, InstBuilder};
use std::iter;
use super::*;
@@ -105,13 +106,12 @@ mod test {
let ebb1 = func.dfg.make_ebb();
{
let dfg = &mut func.dfg;
let cur = &mut Cursor::new(&mut func.layout);
let mut cur = FuncCursor::new(&mut func);
cur.insert_ebb(ebb0);
dfg.ins(cur).jump(ebb1, &[]);
cur.ins().jump(ebb1, &[]);
cur.insert_ebb(ebb1);
dfg.ins(cur).jump(ebb1, &[]);
cur.ins().jump(ebb1, &[]);
}
let cfg = ControlFlowGraph::with_function(&func);