Reorganise analysis

This commit is contained in:
Tony Garnock-Jones 2019-10-24 14:50:44 +01:00
parent e730b22f6d
commit ec249fc759
1 changed files with 17 additions and 17 deletions

View File

@ -490,23 +490,6 @@ pub struct Analyzer {
}
impl Analyzer {
pub fn analyze(a: &Assertion) -> AnalysisResults {
let mut z = Analyzer {
const_paths: Vec::new(),
const_vals: Vec::new(),
capture_paths: Vec::new(),
path: Vec::new(),
};
let skeleton = z.walk(a);
AnalysisResults {
skeleton,
const_paths: z.const_paths,
const_vals: Arc::new(z.const_vals),
capture_paths: z.capture_paths,
assertion: a.clone(),
}
}
fn walk(&mut self, mut a: &Assertion) -> Skeleton {
while let Some(fields) = a.value().as_simple_record("Capture", Some(1)) {
self.capture_paths.push(self.path.clone());
@ -537,6 +520,23 @@ impl Analyzer {
}
}
pub fn analyze(a: &Assertion) -> AnalysisResults {
let mut z = Analyzer {
const_paths: Vec::new(),
const_vals: Vec::new(),
capture_paths: Vec::new(),
path: Vec::new(),
};
let skeleton = z.walk(a);
AnalysisResults {
skeleton,
const_paths: z.const_paths,
const_vals: Arc::new(z.const_vals),
capture_paths: z.capture_paths,
assertion: a.clone(),
}
}
pub fn instantiate_assertion(a: &Assertion, cs: Captures) -> CachedAssertion {
let mut capture_paths = Vec::new();
let mut path = Vec::new();