Struct erg_compiler::context::Context
source · [−]pub struct Context { /* private fields */ }
Expand description
Represents the context of the current scope
Recursive functions/methods are highlighted with the prefix rec_
, as performance may be significantly degraded.
Implementations
sourceimpl Context
impl Context
pub fn new_module<S: Into<Str>>(
name: S,
cfg: ErgConfig,
mod_cache: SharedModuleCache,
py_mod_cache: SharedModuleCache
) -> Self
sourceimpl Context
impl Context
pub fn get_singular_ctx(
&self,
obj: &Expr,
namespace: &Str
) -> SingleTyCheckResult<&Context>
pub fn get_singular_ctx_from_ident(
&self,
ident: &Identifier,
namespace: &Str
) -> SingleTyCheckResult<&Context>
pub fn get_mut_singular_ctx_from_ident(
&mut self,
ident: &Identifier,
namespace: &Str
) -> SingleTyCheckResult<&mut Context>
pub fn get_mut_singular_ctx(
&mut self,
obj: &Expr,
namespace: &Str
) -> SingleTyCheckResult<&mut Context>
sourcepub fn sort_types<'a>(
&self,
types: impl Iterator<Item = &'a Type>
) -> Vec<&'a Type>
pub fn sort_types<'a>(
&self,
types: impl Iterator<Item = &'a Type>
) -> Vec<&'a Type>
Perform types linearization. TODO: Current implementation may be very inefficient.
C3 linearization requires prior knowledge of inter-type dependencies, and cannot be used for Erg structural subtype linearization
Algorithm:
[Int, Str, Nat, Never, Obj, Str!, Module]
=> [], [Int, Str, Nat, Never, Obj, Str!, Module]
=> [[Int]], [Str, Nat, Never, Obj, Str!, Module]
=> [[Int], [Str]], [Nat, Never, Obj, Str!, Module]
=> ...
=> [[Int, Nat, Never, Obj]], [Str, Str!], [Module]]
=> [[Never, Nat, Int, Obj], [Str!, Str], [Module]]
=> [Never, Nat, Int, Obj, Str!, Str, Module]
=> [Never, Nat, Int, Str!, Str, Module, Obj]
sourceimpl Context
impl Context
pub fn test_refinement_subtyping(&self) -> Result<(), ()>
pub fn test_resolve_trait_inner1(&self) -> Result<(), ()>
pub fn test_instantiation_and_generalization(&self) -> Result<(), ()>
sourceimpl Context
impl Context
pub fn new(
name: Str,
cfg: ErgConfig,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
level: usize
) -> Self
pub fn with_capacity(
name: Str,
cfg: ErgConfig,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn mono(
name: Str,
cfg: ErgConfig,
kind: ContextKind,
outer: Option<Context>,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
level: usize
) -> Self
pub fn poly(
name: Str,
cfg: ErgConfig,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn poly_trait<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_poly_trait<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
capacity: usize
) -> Self
pub fn poly_class<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_poly_class<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
capacity: usize
) -> Self
pub fn mono_trait<S: Into<Str>>(
name: S,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_mono_trait<S: Into<Str>>(name: S, capacity: usize) -> Self
pub fn mono_class<S: Into<Str>>(
name: S,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_mono_class<S: Into<Str>>(name: S, capacity: usize) -> Self
pub fn methods<S: Into<Str>>(
name: S,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_methods<S: Into<Str>>(name: S, capacity: usize) -> Self
pub fn poly_patch<S: Into<Str>>(
name: S,
base: Type,
params: Vec<ParamSpec>,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize,
level: usize
) -> Self
pub fn builtin_poly_patch<S: Into<Str>>(
name: S,
base: Type,
params: Vec<ParamSpec>,
capacity: usize
) -> Self
pub fn module(
name: Str,
cfg: ErgConfig,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
capacity: usize
) -> Self
pub fn builtin_module<S: Into<Str>>(name: S, capacity: usize) -> Self
pub fn instant(
name: Str,
cfg: ErgConfig,
capacity: usize,
mod_cache: Option<SharedModuleCache>,
py_mod_cache: Option<SharedModuleCache>,
outer: Context
) -> Self
pub fn caused_by(&self) -> AtomicStr
pub fn pop(&mut self) -> Context
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more