Skip to main content

Env

Struct Env 

Source
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

Source

pub fn new() -> Rc<Env>

An empty environment.

Source

pub fn load(&self, decls: &[Decl])

Load declarations into the environment (§5, §8).

Source

pub fn report(&self, d: Diag)

Raise a diagnostic.

Source

pub fn diag_set(&self, diags: Vec<Diag>)

replace every diagnostic (the run entry points sort them, §6.7)

Source

pub fn remove_root(&self, name: &str)

Forget a root.

Source

pub fn root_names(&self) -> Vec<String>

The roots’ names, in order.

Source

pub fn registry_retain(&self, pred: impl FnMut(&Rc<RefCell<RecInst>>) -> bool)

Keep the instances a predicate accepts.

Source

pub fn diagnostics_vec(&self) -> Vec<Diag>

The diagnostics raised so far.

Source

pub fn diag_len(&self) -> usize

How many diagnostics were raised.

Source

pub fn diag_truncate(&self, n: usize)

Forget the diagnostics after the first n.

Source

pub fn root(&self, name: &str) -> Option<Value>

A root’s value.

Source

pub fn set_root(&self, name: &str, v: Value)

Set a root’s value.

Source

pub fn root_values(&self) -> Vec<Value>

The roots’ values, in order.

Source

pub fn registry_push(&self, inst: Rc<RefCell<RecInst>>)

Register an instance.

Source

pub fn registry_snapshot(&self) -> Vec<Rc<RefCell<RecInst>>>

The instances registered so far.

Source

pub fn const_num(&self, v: &Value) -> Value

A numeric constant’s value where a type expects a number (a size, a bound).

Source

pub fn resolve_dim( &self, name: &str, visiting: &mut Vec<String>, ) -> Result<DimVec, String>

Resolve a dimension by name to its base dimensions.

Source

pub fn unit_info(&self, sym: &str) -> Result<(String, f64), String>

A unit’s dimension key and factor against the base unit.

Source

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

Source

pub fn resolve( self: &Rc<Env>, ast: &TypeAst, name: Option<&str>, ) -> Result<RT, String>

Resolve a type annotation to a resolved type (§3), memoized under name for a named type.

Auto Trait Implementations§

§

impl !Freeze for Env

§

impl !RefUnwindSafe for Env

§

impl !Send for Env

§

impl !Sync for Env

§

impl !UnwindSafe for Env

§

impl Unpin for Env

§

impl UnsafeUnpin for Env

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.