Last active
December 12, 2015 03:48
-
-
Save alexcrichton/4709170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod graph { | |
use core::hashmap::linear::LinearMap; | |
pub type NodeId = uint; | |
pub struct Graph<N, E> { | |
priv nodes: LinearMap<NodeId, N>, | |
} | |
impl<N, E> Graph<N, E> { | |
pure fn node(&self, id: NodeId) -> &self/N { | |
self.nodes.get(&id) | |
} | |
} | |
} | |
mod ssa { | |
use graph::*; | |
pub trait Statement { | |
fn each_def(&self, &fn(uint) -> bool); | |
fn phi_info(&self) -> Option<(uint, &self/uint)>; | |
} | |
pub type CFG<T> = Graph<~[@T], ()>; | |
} | |
use ssa::{CFG, Statement}; | |
fn liveness<T: Statement>(c: &CFG<T>) -> bool { | |
let foo = c.node(4); | |
for vec::rev_each(*foo) |ins| { | |
for ins.each_def |_| { | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment