Struct BlockScope

Source
pub struct BlockScope<'a, 'b> {
    pub root: &'a FunctionScope<'b>,
    pub parent: Option<&'a BlockScope<'a, 'b>>,
    pub variable_defs: BTreeMap<String, (TypeId, bool, Span)>,
    pub constant_defs: RefCell<BTreeMap<String, Constant>>,
    pub typ: BlockScopeType,
}

Fields§

§root: &'a FunctionScope<'b>§parent: Option<&'a BlockScope<'a, 'b>>§variable_defs: BTreeMap<String, (TypeId, bool, Span)>

Maps Name -> (Type, is_const, span)

§constant_defs: RefCell<BTreeMap<String, Constant>>§typ: BlockScopeType

Implementations§

Source§

impl<'a, 'b> BlockScope<'a, 'b>

Source

pub fn new(root: &'a FunctionScope<'b>, typ: BlockScopeType) -> Self

Source

pub fn new_child(&'a self, typ: BlockScopeType) -> Self

Source

pub fn add_var( &mut self, name: &str, typ: TypeId, is_const: bool, span: Span, ) -> Result<(), AlreadyDefined>

Add a variable to the block scope.

Trait Implementations§

Source§

impl AnalyzerContext for BlockScope<'_, '_>

Source§

fn db(&self) -> &dyn AnalyzerDb

Source§

fn resolve_name( &self, name: &str, span: Span, ) -> Result<Option<NamedThing>, IncompleteItem>

Source§

fn add_expression(&self, node: &Node<Expr>, attributes: ExpressionAttributes)

Attribute contextual information to an expression node. Read more
Source§

fn update_expression( &self, node: &Node<Expr>, f: &dyn Fn(&mut ExpressionAttributes), )

Update the expression attributes. Read more
Source§

fn expr_typ(&self, expr: &Node<Expr>) -> Type

Returns a type of an expression. Read more
Source§

fn add_constant(&self, name: &Node<SmolStr>, expr: &Node<Expr>, value: Constant)

Add evaluated constant value in a constant declaration to the context.
Source§

fn constant_value_by_name( &self, name: &SmolStr, span: Span, ) -> Result<Option<Constant>, IncompleteItem>

Returns constant value from variable name.
Source§

fn parent(&self) -> Item

Returns an item enclosing current context. Read more
Source§

fn module(&self) -> ModuleId

Returns the module enclosing current context.
Source§

fn parent_function(&self) -> FunctionId

Returns a function id that encloses a context. Read more
Source§

fn add_call(&self, node: &Node<Expr>, call_type: CallType)

Panics Read more
Source§

fn get_call(&self, node: &Node<Expr>) -> Option<CallType>

Source§

fn is_in_function(&self) -> bool

Returns true if the context is in function scope.
Source§

fn inherits_type(&self, typ: BlockScopeType) -> bool

Returns true if the scope or any of its parents is of the given type.
Source§

fn resolve_path( &self, path: &Path, span: Span, ) -> Result<NamedThing, FatalError>

Resolves the given path and registers all errors
Source§

fn resolve_visible_path(&self, path: &Path) -> Option<NamedThing>

Resolves the given path only if it is visible. Does not register any errors
Source§

fn resolve_any_path(&self, path: &Path) -> Option<NamedThing>

Resolves the given path. Does not register any errors
Source§

fn add_diagnostic(&self, diag: Diagnostic)

Source§

fn get_context_type(&self) -> Option<TypeId>

Returns the Context type, if it is defined.
Source§

fn error( &self, message: &str, label_span: Span, label: &str, ) -> DiagnosticVoucher

Source§

fn root_item(&self) -> Item

Returns a non-function item that encloses a context. Read more
Source§

fn type_error( &self, message: &str, span: Span, expected: TypeId, actual: TypeId, ) -> DiagnosticVoucher

Source§

fn not_yet_implemented(&self, feature: &str, span: Span) -> DiagnosticVoucher

Source§

fn fancy_error( &self, message: &str, labels: Vec<Label>, notes: Vec<String>, ) -> DiagnosticVoucher

Source§

fn duplicate_name_error( &self, message: &str, name: &str, original: Span, duplicate: Span, ) -> DiagnosticVoucher

Source§

fn name_conflict_error( &self, name_kind: &str, name: &str, original: &NamedThing, original_span: Option<Span>, duplicate_span: Span, ) -> DiagnosticVoucher

Source§

fn register_diag(&self, diag: Diagnostic) -> DiagnosticVoucher

Auto Trait Implementations§

§

impl<'a, 'b> !Freeze for BlockScope<'a, 'b>

§

impl<'a, 'b> !RefUnwindSafe for BlockScope<'a, 'b>

§

impl<'a, 'b> !Send for BlockScope<'a, 'b>

§

impl<'a, 'b> !Sync for BlockScope<'a, 'b>

§

impl<'a, 'b> Unpin for BlockScope<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for BlockScope<'a, 'b>

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.