use super::path::Path;
use super::resolver::PathResolver;
use crate::{defs::namespace::Namespace, haystack::val::Dict, val::Value};
pub trait Eval {
fn eval<R: PathResolver>(&self, context: &EvalContext<R>) -> bool;
}
pub struct EvalContext<'a, 'b, R: PathResolver> {
pub dict: &'a Dict,
pub ns: &'b Namespace,
pub resolver: &'a R,
}
impl<'a, 'b, R: PathResolver> EvalContext<'a, 'b, R> {
pub fn make(dict: &'a Dict, ns: &'b Namespace, resolver: &'a R) -> Self {
Self { dict, ns, resolver }
}
pub fn resolve_for_dict(&self, dict: &Dict, path: &Path) -> Value {
self.resolver.resolve_for(dict, path)
}
pub fn resolve(&self, path: &Path) -> Value {
self.resolver.resolve_for(self.dict, path)
}
}