Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/cranelift/isle/veri/veri_engine/src/interp.rs
1693 views
1
/// Interpret and build an assumption context from the LHS and RHS of rules.
2
use crate::type_inference::RuleSemantics;
3
use veri_ir::{BoundVar, Expr};
4
5
use std::collections::HashMap;
6
use std::fmt::Debug;
7
8
use cranelift_isle as isle;
9
use isle::sema::{RuleId, VarId};
10
11
/// Assumption consist of single verification IR expressions, which must have
12
/// boolean type.
13
#[derive(Clone, Debug)]
14
pub struct Assumption {
15
assume: Expr,
16
}
17
18
impl Assumption {
19
/// Create a new assumption, checking type.
20
pub fn new(assume: Expr) -> Self {
21
// assert!(assume.ty().is_bool());
22
Self { assume }
23
}
24
25
/// Get the assumption as an expression.
26
pub fn assume(&self) -> &Expr {
27
&self.assume
28
}
29
}
30
pub struct Context<'ctx> {
31
pub quantified_vars: Vec<BoundVar>,
32
pub free_vars: Vec<BoundVar>,
33
pub assumptions: Vec<Assumption>,
34
pub var_map: HashMap<VarId, BoundVar>,
35
36
// For type checking
37
pub typesols: &'ctx HashMap<RuleId, RuleSemantics>,
38
}
39
40
impl<'ctx> Context<'ctx> {
41
pub fn new(typesols: &'ctx HashMap<RuleId, RuleSemantics>) -> Context<'ctx> {
42
Context {
43
quantified_vars: vec![],
44
free_vars: vec![],
45
assumptions: vec![],
46
var_map: HashMap::new(),
47
typesols,
48
}
49
}
50
}
51
52