Collector

Struct Collector 

Source
pub struct Collector<'env> { /* private fields */ }

Implementations§

Source§

impl Collector<'_>

Source

pub fn as_node(&self) -> ModuleNode<'_>

Source

pub fn as_node_mut(&mut self) -> ModuleNodeMut<'_>

Source

pub fn scope(&mut self, name: Sym, is_ty: bool, f: impl Fn(&mut Collector<'_>))

Source

pub fn in_foreign_scope<F, T>(&mut self, path: &[PathPart], f: F) -> Option<T>
where F: Fn(&mut Collector<'_>) -> T,

Methods from Deref<Target = Environment>§

Source

pub fn eval(&mut self, node: &impl Interpret) -> IResult<ConValue>

Reflexively evaluates a node

Source

pub fn call(&mut self, name: Sym, args: &[ConValue]) -> IResult<ConValue>

Calls a function inside the Environment’s scope, and returns the result

Source

pub fn modules_mut(&mut self) -> &mut ModuleTree

Source

pub fn modules(&self) -> &ModuleTree

Source

pub fn bind(&mut self, name: impl Into<Sym>, value: impl Into<ConValue>)

Binds a value to the given name in the current scope.

Source

pub fn bind_raw(&mut self, name: Sym, id: usize) -> Option<()>

Source

pub fn add_builtins(&mut self, builtins: &'static [Builtin]) -> &mut Self

Adds builtins

§Panics

Will panic if stack contains more than the globals frame!

Source

pub fn push_frame(&mut self, name: &'static str, frame: StackFrame)

Source

pub fn pop_frame(&mut self) -> Option<(StackFrame, &'static str)>

Source

pub fn frame(&mut self, name: &'static str) -> Frame<'_>

Enters a nested scope, returning a Frame stack-guard.

Frame implements Deref/DerefMut for Environment.

Source

pub fn with_frame<'e>( &'e mut self, name: &'static str, frame: StackFrame, ) -> Frame<'e>

Enters a nested scope, assigning the contents of frame, and returning a Frame stack-guard.

Frame implements Deref/DerefMut for Environment.

Source

pub fn get_mut(&mut self, name: Sym) -> IResult<&mut ConValue>

Resolves a variable mutably.

Returns a mutable reference to the variable’s record, if it exists.

Source

pub fn get(&self, name: Sym) -> IResult<ConValue>

Resolves a variable immutably.

Returns a reference to the variable’s contents, if it is defined and initialized.

Source

pub fn id_of(&self, name: Sym) -> IResult<usize>

Resolves the index associated with a [Sym]

Source

pub fn get_id(&self, id: usize) -> Option<&ConValue>

Source

pub fn get_id_mut(&mut self, id: usize) -> Option<&mut ConValue>

Source

pub fn get_slice(&self, start: usize, len: usize) -> Option<&[ConValue]>

Source

pub fn get_slice_mut( &mut self, start: usize, len: usize, ) -> Option<&mut [ConValue]>

Source

pub fn insert(&mut self, k: Sym, v: ConValue)

Inserts a new ConValue into this Environment

Source

pub fn insert_fn(&mut self, decl: &FnDecl)

A convenience function for registering a [FnDecl] as a Function

Source

pub fn insert_tup_constructor(&mut self, name: Sym, arity: usize)

Source

pub fn pos(&self) -> usize

Gets the current stack top position

Source

pub fn stack_alloc(&mut self, value: ConValue) -> IResult<usize>

Allocates a local variable

Source

pub fn alloca(&mut self, value: ConValue, len: usize) -> ConValue

Allocates some space on the stack

Trait Implementations§

Source§

impl<'env> Deref for Collector<'env>

Source§

type Target = Environment

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Collector<'_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, 'env> Visit<'a> for Collector<'env>

Source§

fn visit_file(&mut self, value: &'a File)

Source§

fn visit_block(&mut self, value: &'a Block)

Source§

fn visit_module(&mut self, value: &'a Module)

Source§

fn visit_alias(&mut self, value: &'a Alias)

Source§

fn visit_enum(&mut self, value: &'a Enum)

Source§

fn visit_struct(&mut self, value: &'a Struct)

Source§

fn visit_const(&mut self, value: &'a Const)

Source§

fn visit_static(&mut self, value: &'a Static)

Source§

fn visit_function(&mut self, value: &'a Function)

Source§

fn visit_impl(&mut self, value: &'a Impl)

Source§

fn visit_use(&mut self, value: &'a Use)

§

fn visit<W>(&mut self, walker: &'a W) -> &mut Self
where W: Walk,

Visits a Walker
§

fn visit_children<W>(&mut self, walker: &'a W)
where W: Walk,

Visits the children of a Walker
§

fn visit_span(&mut self, value: &'a Span)

§

fn visit_mutability(&mut self, value: &'a Mutability)

§

fn visit_visibility(&mut self, value: &'a Visibility)

§

fn visit_sym(&mut self, value: &'a Interned<'static, str>)

§

fn visit_literal(&mut self, value: &'a Literal)

§

fn visit_bool(&mut self, value: &'a bool)

§

fn visit_char(&mut self, value: &'a char)

§

fn visit_int(&mut self, value: &'a u128)

§

fn visit_smuggled_float(&mut self, value: &'a u64)

§

fn visit_string(&mut self, value: &'a str)

§

fn visit_attrs(&mut self, value: &'a Attrs)

§

fn visit_meta(&mut self, value: &'a Meta)

§

fn visit_meta_kind(&mut self, value: &'a MetaKind)

§

fn visit_item(&mut self, value: &'a Item)

§

fn visit_item_kind(&mut self, value: &'a ItemKind)

§

fn visit_generics(&mut self, value: &'a Generics)

§

fn visit_struct_kind(&mut self, value: &'a StructKind)

§

fn visit_struct_member(&mut self, value: &'a StructMember)

§

fn visit_variant(&mut self, value: &'a Variant)

§

fn visit_impl_kind(&mut self, value: &'a ImplKind)

§

fn visit_use_tree(&mut self, value: &'a UseTree)

§

fn visit_ty(&mut self, value: &'a Ty)

§

fn visit_ty_kind(&mut self, value: &'a TyKind)

§

fn visit_ty_array(&mut self, value: &'a TyArray)

§

fn visit_ty_slice(&mut self, value: &'a TySlice)

§

fn visit_ty_tuple(&mut self, value: &'a TyTuple)

§

fn visit_ty_ref(&mut self, value: &'a TyRef)

§

fn visit_ty_ptr(&mut self, value: &'a TyPtr)

§

fn visit_ty_fn(&mut self, value: &'a TyFn)

§

fn visit_path(&mut self, value: &'a Path)

§

fn visit_path_part(&mut self, value: &'a PathPart)

§

fn visit_stmt(&mut self, value: &'a Stmt)

§

fn visit_stmt_kind(&mut self, value: &'a StmtKind)

§

fn visit_semi(&mut self, value: &'a Semi)

§

fn visit_expr(&mut self, value: &'a Expr)

§

fn visit_expr_kind(&mut self, value: &'a ExprKind)

§

fn visit_closure(&mut self, value: &'a Closure)

§

fn visit_quote(&mut self, value: &'a Quote)

§

fn visit_let(&mut self, value: &'a Let)

§

fn visit_pattern(&mut self, value: &'a Pattern)

§

fn visit_match(&mut self, value: &'a Match)

§

fn visit_match_arm(&mut self, value: &'a MatchArm)

§

fn visit_assign(&mut self, value: &'a Assign)

§

fn visit_modify(&mut self, value: &'a Modify)

§

fn visit_modify_kind(&mut self, value: &'a ModifyKind)

§

fn visit_binary(&mut self, value: &'a Binary)

§

fn visit_binary_kind(&mut self, value: &'a BinaryKind)

§

fn visit_unary(&mut self, value: &'a Unary)

§

fn visit_unary_kind(&mut self, value: &'a UnaryKind)

§

fn visit_cast(&mut self, value: &'a Cast)

§

fn visit_member(&mut self, value: &'a Member)

§

fn visit_member_kind(&mut self, value: &'a MemberKind)

§

fn visit_index(&mut self, value: &'a Index)

§

fn visit_structor(&mut self, value: &'a Structor)

§

fn visit_fielder(&mut self, value: &'a Fielder)

§

fn visit_array(&mut self, value: &'a Array)

§

fn visit_array_rep(&mut self, value: &'a ArrayRep)

§

fn visit_addrof(&mut self, value: &'a AddrOf)

§

fn visit_group(&mut self, value: &'a Group)

§

fn visit_tuple(&mut self, value: &'a Tuple)

§

fn visit_while(&mut self, value: &'a While)

§

fn visit_if(&mut self, value: &'a If)

§

fn visit_for(&mut self, value: &'a For)

§

fn visit_else(&mut self, value: &'a Else)

§

fn visit_break(&mut self, value: &'a Break)

§

fn visit_return(&mut self, value: &'a Return)

§

fn visit_continue(&mut self)

Auto Trait Implementations§

§

impl<'env> Freeze for Collector<'env>

§

impl<'env> !RefUnwindSafe for Collector<'env>

§

impl<'env> !Send for Collector<'env>

§

impl<'env> !Sync for Collector<'env>

§

impl<'env> Unpin for Collector<'env>

§

impl<'env> !UnwindSafe for Collector<'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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.