pub struct Env {Show 26 fields
pub type_asts: RefCell<HashMap<String, Rc<TypeEntry>>>,
pub type_memo: RefCell<HashMap<String, RT>>,
pub pattern_visiting: RefCell<Vec<String>>,
pub consts: RefCell<HashMap<String, Rc<ConstEntry>>>,
pub funcs: RefCell<HashMap<String, Rc<FuncEntry>>>,
pub duplicates: RefCell<Vec<String>>,
pub outputs: RefCell<Vec<(String, TypeAst, Rc<Expr>)>>,
pub inputs: RefCell<HashMap<String, (TypeAst, Option<Rc<Expr>>)>>,
pub diags: RefCell<HashMap<String, Rc<DiagDecl>>>,
pub registry: RefCell<Rc<RefCell<Vec<Rc<RefCell<RecInst>>>>>>,
pub roots: RefCell<Rc<RefCell<Vec<(String, Value)>>>>,
pub diagnostics: RefCell<Rc<RefCell<Vec<Diag>>>>,
pub const_eval: RefCell<Option<ConstEval>>,
pub expr_eval: RefCell<Option<ExprEval>>,
pub imports: RefCell<HashMap<String, Export>>,
pub namespaces: RefCell<HashMap<String, (Rc<Env>, Rc<RefCell<HashMap<String, Export>>>)>>,
pub dim_decls: RefCell<HashMap<String, Option<Vec<(String, i32)>>>>,
pub dim_memo: RefCell<HashMap<String, DimVec>>,
pub unit_decls: RefCell<HashMap<String, UnitDecl>>,
pub unit_memo: RefCell<HashMap<String, (String, f64)>>,
pub base_unit_of: RefCell<HashMap<String, String>>,
pub space_diags: RefCell<Vec<Diag>>,
pub type_order: RefCell<Vec<String>>,
pub unit_order: RefCell<Vec<String>>,
pub const_diag_sink: RefCell<Option<Rc<RefCell<Vec<Diag>>>>>,
pub tagger: RefCell<Option<Rc<dyn Fn() -> Option<String>>>>,
/* private fields */
}Expand description
the environment of a module: its declarations, its imports, its roots and diagnostics, the unit space
Fields§
§type_asts: RefCell<HashMap<String, Rc<TypeEntry>>>the type declarations
type_memo: RefCell<HashMap<String, RT>>resolved types, memoized
pattern_visiting: RefCell<Vec<String>>the named types being resolved (recursion)
consts: RefCell<HashMap<String, Rc<ConstEntry>>>the constants
funcs: RefCell<HashMap<String, Rc<FuncEntry>>>the functions
duplicates: RefCell<Vec<String>>names declared twice
outputs: RefCell<Vec<(String, TypeAst, Rc<Expr>)>>the outputs: name, type, expression
inputs: RefCell<HashMap<String, (TypeAst, Option<Rc<Expr>>)>>the inputs: type, fallback
diags: RefCell<HashMap<String, Rc<DiagDecl>>>the diagnostic templates
registry: RefCell<Rc<RefCell<Vec<Rc<RefCell<RecInst>>>>>>every instance bound
roots: RefCell<Rc<RefCell<Vec<(String, Value)>>>>the roots’ values, by name
diagnostics: RefCell<Rc<RefCell<Vec<Diag>>>>the diagnostics raised
const_eval: RefCell<Option<ConstEval>>the constant evaluator, once an engine is wired in
expr_eval: RefCell<Option<ExprEval>>the expression evaluator, once an engine is wired in
imports: RefCell<HashMap<String, Export>>the imported names
namespaces: RefCell<HashMap<String, (Rc<Env>, Rc<RefCell<HashMap<String, Export>>>)>>the namespace imports
dim_decls: RefCell<HashMap<String, Option<Vec<(String, i32)>>>>the dimension declarations
dim_memo: RefCell<HashMap<String, DimVec>>dimensions resolved, memoized
unit_decls: RefCell<HashMap<String, UnitDecl>>the unit declarations
unit_memo: RefCell<HashMap<String, (String, f64)>>units resolved to (dimension, factor), memoized
base_unit_of: RefCell<HashMap<String, String>>the base unit of each dimension
space_diags: RefCell<Vec<Diag>>the unit space’s diagnostics (E4073 and friends)
type_order: RefCell<Vec<String>>declaration order (HashMaps do not keep it; diagnostics follow it)
unit_order: RefCell<Vec<String>>the units in declaration order
const_diag_sink: RefCell<Option<Rc<RefCell<Vec<Diag>>>>>installed by the checker: constant-evaluation errors go here instead of the report
tagger: RefCell<Option<Rc<dyn Fn() -> Option<String>>>>installed by the engine: the evaluation step a report is attributed to
Implementations§
Source§impl Env
impl Env
Sourcepub fn diag_set(&self, diags: Vec<Diag>)
pub fn diag_set(&self, diags: Vec<Diag>)
replace every diagnostic (the run entry points sort them, §6.7)
Sourcepub fn remove_root(&self, name: &str)
pub fn remove_root(&self, name: &str)
Forget a root.
Sourcepub fn root_names(&self) -> Vec<String>
pub fn root_names(&self) -> Vec<String>
The roots’ names, in order.
Sourcepub fn registry_retain(&self, pred: impl FnMut(&Rc<RefCell<RecInst>>) -> bool)
pub fn registry_retain(&self, pred: impl FnMut(&Rc<RefCell<RecInst>>) -> bool)
Keep the instances a predicate accepts.
Sourcepub fn diagnostics_vec(&self) -> Vec<Diag>
pub fn diagnostics_vec(&self) -> Vec<Diag>
The diagnostics raised so far.
Sourcepub fn diag_truncate(&self, n: usize)
pub fn diag_truncate(&self, n: usize)
Forget the diagnostics after the first n.
Sourcepub fn root_values(&self) -> Vec<Value>
pub fn root_values(&self) -> Vec<Value>
The roots’ values, in order.
Sourcepub fn registry_push(&self, inst: Rc<RefCell<RecInst>>)
pub fn registry_push(&self, inst: Rc<RefCell<RecInst>>)
Register an instance.
Sourcepub fn const_num(&self, v: &Value) -> Value
pub fn const_num(&self, v: &Value) -> Value
A numeric constant’s value where a type expects a number (a size, a bound).
Sourcepub fn resolve_dim(
&self,
name: &str,
visiting: &mut Vec<String>,
) -> Result<DimVec, String>
pub fn resolve_dim( &self, name: &str, visiting: &mut Vec<String>, ) -> Result<DimVec, String>
Resolve a dimension by name to its base dimensions.
Sourcepub fn unit_info(&self, sym: &str) -> Result<(String, f64), String>
pub fn unit_info(&self, sym: &str) -> Result<(String, f64), String>
A unit’s dimension key and factor against the base unit.
Sourcepub fn finalize_unit_space(&self) -> Vec<Diag>
pub fn finalize_unit_space(&self) -> Vec<Diag>
§3.16 unit/dimension-space findings for the checker: the load-time redeclarations plus unresolvable units and duplicate base units