Trait gluon_vm::macros::Macro

source ·
pub trait Macro: Trace + DowncastArc + Send + Sync {
    // Required method
    fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>(
        &self,
        env: &'b mut MacroExpander<'a>,
        symbols: &'c mut Symbols,
        arena: &'b mut OwnedArena<'ast, Symbol>,
        args: &'b mut [SpannedExpr<'ast, Symbol>]
    ) -> MacroFuture<'r, 'ast>;

    // Provided methods
    fn get_capability<T>(
        &self,
        thread: &Thread,
        arc_self: &Arc<dyn Macro>
    ) -> Option<T>
       where Self: Sized,
             T: Any { ... }
    fn get_capability_impl(
        &self,
        thread: &Thread,
        arc_self: &Arc<dyn Macro>,
        id: TypeId
    ) -> Option<Box<dyn Any>> { ... }
}
Expand description

A trait which abstracts over macros.

A macro is similiar to a function call but is run at compile time instead of at runtime.

Required Methods§

source

fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>( &self, env: &'b mut MacroExpander<'a>, symbols: &'c mut Symbols, arena: &'b mut OwnedArena<'ast, Symbol>, args: &'b mut [SpannedExpr<'ast, Symbol>] ) -> MacroFuture<'r, 'ast>

Creating a symbol in symbols will put it in the same scope as the code surrounding the expansion. If you want to create a unique symbol then call Symbol::from or create a new Symbols table

Provided Methods§

source

fn get_capability<T>( &self, thread: &Thread, arc_self: &Arc<dyn Macro> ) -> Option<T>
where Self: Sized, T: Any,

source

fn get_capability_impl( &self, thread: &Thread, arc_self: &Arc<dyn Macro>, id: TypeId ) -> Option<Box<dyn Any>>

Implementations§

source§

impl dyn Macro

source

pub fn is<__T: Macro>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

source

pub fn downcast<__T: Macro>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

source

pub fn downcast_rc<__T: Macro>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

source

pub fn downcast_ref<__T: Macro>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

source

pub fn downcast_mut<__T: Macro>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

source§

impl dyn Macro

source

pub fn downcast_arc<T: Macro>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where Self: Send + Sync,

Implementations on Foreign Types§

source§

impl<M> Macro for Box<M>
where M: Macro + ?Sized,

source§

fn get_capability_impl( &self, thread: &Thread, arc_self: &Arc<dyn Macro>, id: TypeId ) -> Option<Box<dyn Any>>

source§

fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>( &self, env: &'b mut MacroExpander<'a>, symbols: &'c mut Symbols, arena: &'b mut OwnedArena<'ast, Symbol>, args: &'b mut [SpannedExpr<'ast, Symbol>] ) -> MacroFuture<'r, 'ast>

source§

impl<M> Macro for Arc<M>
where M: Macro + ?Sized,

source§

fn get_capability_impl( &self, thread: &Thread, arc_self: &Arc<dyn Macro>, id: TypeId ) -> Option<Box<dyn Any>>

source§

fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>( &self, env: &'b mut MacroExpander<'a>, symbols: &'c mut Symbols, arena: &'b mut OwnedArena<'ast, Symbol>, args: &'b mut [SpannedExpr<'ast, Symbol>] ) -> MacroFuture<'r, 'ast>

Implementors§