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_main_module() -> Self
sourceimpl Context
impl 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(&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,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
level: usize
) -> Self
pub fn with_capacity(
name: Str,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
capacity: usize,
level: usize
) -> Self
pub fn mono(
name: Str,
kind: ContextKind,
outer: Option<Context>,
level: usize
) -> Self
pub fn poly(
name: Str,
kind: ContextKind,
params: Vec<ParamSpec>,
outer: Option<Context>,
level: usize
) -> Self
pub fn poly_trait<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
level: usize
) -> Self
pub fn poly_class<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
level: usize
) -> Self
pub fn mono_trait<S: Into<Str>>(name: S, level: usize) -> Self
pub fn mono_class<S: Into<Str>>(name: S, level: usize) -> Self
pub fn methods<S: Into<Str>>(name: S, level: usize) -> Self
pub fn poly_patch<S: Into<Str>>(
name: S,
params: Vec<ParamSpec>,
level: usize
) -> Self
pub fn module(name: Str, capacity: usize) -> Self
pub fn instant(name: Str, capacity: usize, outer: Context) -> Self
pub fn caused_by(&self) -> AtomicStr
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