Skip to main content

Function

Struct Function 

Source
pub struct Function { /* private fields */ }

Implementations§

Source§

impl Function

Source

pub fn new(parent_scope: Weak<dyn Scope>, function: FunctionDef) -> Rc<Self>

Creates a function from its parsed definition.

Source

pub fn name(&self) -> &str

Source

pub fn return_type(&self) -> Option<&[String]>

Source

pub fn args(&self) -> &[(Vec<String>, String)]

Source

pub fn statements(&self) -> &[Statement]

Source

pub fn call( &self, env: Rc<dyn Env>, args: Vec<Slot>, ) -> Result<Option<Slot>, RiddleError>

Invokes the function in a fresh local environment.

The call validates argument count and type compatibility, executes all function statements, and checks the declared return type (if any).

Trait Implementations§

Source§

impl Scope for Function

Source§

fn core(&self) -> Rc<dyn Core>

Source§

fn scope(&self) -> Option<Rc<dyn Scope>>

Source§

fn get_fields(&self) -> Vec<Rc<Field>>

Source§

fn get_field(&self, name: &str) -> Option<Rc<Field>>

Source§

fn get_function( &self, name: &str, types: &[Rc<dyn Type>], ) -> Option<Rc<Function>>

Source§

fn get_type(&self, name: &str) -> Option<Rc<dyn Type>>

Source§

fn get_predicate(&self, name: &str) -> Option<Rc<Predicate>>

Source§

fn as_class(self: Rc<Self>) -> Option<Rc<dyn Class>>

Auto Trait Implementations§

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, 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.