Struct LookupContext

Source
pub struct LookupContext<'a> {
    pub types: HashMap<TypeIdent, &'a ToplevelItem<TypeDecl>>,
    pub functions: HashMap<FunctionId, &'a ToplevelItem<FnDecl>>,
    pub main: Option<&'a ToplevelItem<MainDecl>>,
}

Fields§

§types: HashMap<TypeIdent, &'a ToplevelItem<TypeDecl>>

Types are resolved by their name

§functions: HashMap<FunctionId, &'a ToplevelItem<FnDecl>>

Functions are resolved by their name and - if present - named arguments and their receiver type

fn foo(a: i32, b: i32) -> i32 is identified as foo fn foo(bar a: i32, b: i32) -> i32 is identified as foo:bar fn foo(self: i32, b: i32) -> i32 is identified as i32::foo

§main: Option<&'a ToplevelItem<MainDecl>>

Implementations§

Source§

impl<'a> LookupContext<'a>

Source

pub fn new() -> Self

Source

pub fn add_from(&mut self, asts: &'a SegmentedAsts) -> Result<(), LookupError>

Source

pub fn with(self, asts: &'a SegmentedAsts) -> Result<Self, LookupError>

Trait Implementations§

Source§

impl<'a> Debug for LookupContext<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for LookupContext<'a>

Source§

fn default() -> LookupContext<'a>

Returns the “default value” for a type. Read more
Source§

impl Lookup for LookupContext<'_>

Source§

fn resolve_type(&self, name: &TypeIdent) -> Option<&ToplevelItem<TypeDecl>>

Source§

fn resolve_function( &self, receiver: Option<&TypeIdent>, name: &Ident, labels: &[&str], ) -> Option<&ToplevelItem<FnDecl>>

Auto Trait Implementations§

§

impl<'a> Freeze for LookupContext<'a>

§

impl<'a> RefUnwindSafe for LookupContext<'a>

§

impl<'a> Send for LookupContext<'a>

§

impl<'a> Sync for LookupContext<'a>

§

impl<'a> Unpin for LookupContext<'a>

§

impl<'a> UnwindSafe for LookupContext<'a>

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.