Skip to main content

Checker

Struct Checker 

Source
pub(crate) struct Checker {
    diagnostics: Vec<Diagnostic>,
    globals: HashMap<String, Declared>,
    program: Program,
    fn_signatures: Vec<Signature>,
    view_params: Vec<Vec<(String, Type)>>,
    fn_effects: FnEffects,
    body: Body,
    effects: Effects,
}

Fields§

§diagnostics: Vec<Diagnostic>§globals: HashMap<String, Declared>

Top-level names from every file: a program is one namespace.

§program: Program§fn_signatures: Vec<Signature>§view_params: Vec<Vec<(String, Type)>>§fn_effects: FnEffects§body: Body§effects: Effects

Implementations§

Source§

impl Checker

Source

pub(super) fn built_in_call( &mut self, function: &'static Function, args: &[Arg], span: Span, ) -> Expr

Source

fn window_request( &mut self, name: &str, action: WindowAction, args: Args<'_>, span: Span, ) -> Expr

open_window(settings) or close_window(settings). Opening and closing windows changes the app, so the UI can’t do it while it is shown.

Source

fn window_name(&mut self, expr: &Expr) -> Option<WindowId>

The window expr names.

Source

fn download(&mut self, args: Args<'_>, span: Span) -> Expr

download(url, to: folder, progress: $percent, status: $text, …), with settings it leaves out at their defaults. It changes the bound state later, from another thread, so it counts as writing all of it now.

Source

fn download_command( &mut self, command: DownloadCommand, args: Args<'_>, span: Span, ) -> Expr

cancel_download(id) and the like. Asking changes what the download writes to state, so it counts as writing.

Source

fn format_bytes( &mut self, function: &Function, args: Args<'_>, span: Span, ) -> Expr

format_bytes(n), which only reads, so the UI may show it.

Source

fn dialog( &mut self, name: &str, kind: DialogKind, args: Args<'_>, span: Span, ) -> Expr

pick_file($path, title: …, types: […], from: …) and its siblings. The answer is written later, once the user closes the dialog, so it counts as writing it now.

Source

fn is_in_list_item(place: &Place) -> bool

Whether the bound place is inside a list’s item, whose position can change. A bound place rooted in a local is a for variable over a list’s items.

Source

fn optional_text(&mut self, arg: Option<&Expr>, span: Span) -> Expr

Source

fn optional_texts(&mut self, arg: Option<&Expr>, span: Span) -> Expr

A [string] setting, empty when left out.

Source

fn optional_int(&mut self, arg: Option<&Expr>, default: i64, span: Span) -> Expr

Source§

impl Checker

Source

pub(super) fn const_points(&mut self, expr: &Expr) -> Option<f32>

A size in points, written as a number literal.

Source

pub(super) fn const_number(&mut self, expr: &Expr) -> Option<i64>

A whole number written literally, such as 10 or -10.

Source

pub(super) fn const_string(&mut self, expr: &Expr) -> Option<String>

Text written as a plain string literal, without interpolation.

Source

pub(super) fn const_bool(&mut self, expr: &Expr) -> Option<bool>

true or false, written literally.

Source

pub(super) fn const_member<T: Copy>( &mut self, expr: &Expr, options: &[(&str, T)], ) -> Option<T>

One of options, written as .name.

Source§

impl Checker

Source

pub(super) fn expr(&mut self, expr: &Expr, expected: Option<&Type>) -> Expr

Checks expr; expected guides literals that can’t stand alone, such as [].

Source

pub(super) fn expect(&mut self, expr: &Expr, expected: &Type) -> Expr

Checks expr and reports it unless it has type expected.

Source

fn string(&mut self, parts: &[StringPart]) -> ExprKind

Source

fn name(&mut self, name: &str, span: Span) -> Expr

Source

fn list(&mut self, items: &[Expr], expected: Option<&Type>, span: Span) -> Expr

Source

fn unary(&mut self, op: UnaryOp, operand: &Expr, span: Span) -> Expr

Source

fn binary(&mut self, op: BinaryOp, lhs: &Expr, rhs: &Expr, span: Span) -> Expr

Source

pub(super) fn binary_type( &mut self, op: BinaryOp, lhs: &Type, rhs: &Type, span: Span, ) -> Type

Source

fn call(&mut self, callee: &Expr, args: &[Arg], span: Span) -> Expr

Source

fn call_function( &mut self, function: FnId, name: &str, args: &[Arg], span: Span, ) -> Expr

Source

fn construct(&mut self, id: StructId, args: &[Arg], span: Span) -> Expr

Source

fn method( &mut self, base: &Expr, name: &Ident, args: &[Arg], span: Span, ) -> Expr

Source

fn no_args(&mut self, method: &str, args: &[Arg])

Source

fn no_method(&mut self, ty: &Type, name: &Ident) -> Expr

Source

fn field(&mut self, base: &Expr, name: &Ident, span: Span) -> Expr

Source

fn field_index(&mut self, ty: &Type, name: &Ident) -> Option<(usize, Type)>

The field’s position and type, or None after reporting why there is no such field.

Source

fn index(&mut self, base: &Expr, index: &Expr, span: Span) -> Expr

Source

pub(super) fn place(&mut self, expr: &Expr) -> Option<Place>

Converts an assignable expression into a place, or reports why it can’t be changed.

Source

pub(super) fn writes_state(&self, place: &Place) -> bool

Whether place changes state: directly, or through a for variable aliasing it.

Source

pub(super) fn bound_place( &mut self, owner: &str, label: Option<&str>, arg: Option<&Expr>, ty: &Type, span: Span, ) -> Option<Place>

The place a $place argument binds, or None after reporting why it can’t be bound. owner names what takes the binding in error messages, such as “checkbox”. The place arg binds, for owner’s parameter label, or its positional one.

Source

pub(super) fn note_write(&mut self, place: &Place)

Records a write to place, or reports that a loop’s counter can’t be written.

Source

fn window_misused(&mut self, name: &str, span: Span) -> Expr

A window’s name used as a value or called, which only opening and closing it take.

Source

pub(super) fn error_expr( &mut self, message: impl Into<String>, span: Span, ) -> Expr

Source

pub(super) fn required_arg( &mut self, arg: Option<&Expr>, ty: &Type, span: Span, missing: impl FnOnce() -> String, ) -> Expr

Checks a required argument, or reports it missing and stands in an error expression.

Source§

impl Checker

Source

pub(super) fn menu_bar(&mut self, menus: &[ElementCall<'_>]) -> MenuBar

The menu bar’s menus, written as top-level menu(…) calls, in order.

Source

pub(super) fn context_menu( &mut self, name: &str, block: Option<&Block>, span: Span, ) -> Option<Node>

A context_menu, whose items take no shortcuts: they act on what was clicked, and the stack a menu is in can show many times.

Source

fn menu_entries( &mut self, stmts: &[Stmt], shortcuts: Option<&mut HashMap<Shortcut, Span>>, ) -> Vec<MenuEntry<Block>>

The entries of a menu’s block: items, separators and submenus. Items may take shortcuts when there are shortcuts to add them to.

Source

fn menu_entry( &mut self, stmt: &Stmt, shortcuts: Option<&mut HashMap<Shortcut, Span>>, ) -> Option<MenuEntry<Block>>

Source

fn menu( &mut self, call: &ElementCall<'_>, shortcuts: Option<&mut HashMap<Shortcut, Span>>, ) -> Option<Menu<Block>>

Source

fn menu_block<'a>( &mut self, name: &str, block: Option<&'a Block>, span: Span, ) -> Option<&'a Block>

The block holding a menu’s items, which every menu needs.

Source

fn menu_item( &mut self, call: &ElementCall<'_>, shortcuts: Option<&mut HashMap<Shortcut, Span>>, ) -> Option<MenuEntry<Block>>

Source

fn fixed_title( &mut self, name: &str, title: Option<&Expr>, span: Span, ) -> Option<String>

A menu’s or item’s title, which is written literally.

Source

fn shortcut( &mut self, expr: &Expr, shortcuts: Option<&mut HashMap<Shortcut, Span>>, ) -> Option<Shortcut>

A shortcut written literally, which no other item and no system command uses, in a menu whose items take shortcuts.

Source§

impl Checker

Source

pub(super) fn block(&mut self, block: &Block) -> Block

Source

fn stmt(&mut self, stmt: &Stmt) -> Option<Stmt>

Source

fn assign(&mut self, target: &Expr, op: AssignOp, value: &Expr) -> Option<Stmt>

Source

fn if_stmt(&mut self, if_stmt: &IfStmt) -> Stmt

Source

pub(super) fn loop_head(&mut self, iterable: &Iterable, has_index: bool) -> Loop

Checks what a for loops over and allocates its variables. The item aliases each element when the list is a place. Self::in_loop names the variables.

Source

fn list_head(&mut self, list: &Expr) -> (Iterable, LocalInfo)

Source

pub(super) fn in_loop<T>( &mut self, index: Option<&Ident>, item: &Ident, head: &Loop, check: impl FnOnce(&mut Self) -> T, ) -> T

Runs check on a loop’s body with the loop’s variables named.

Source

fn return_stmt(&mut self, value: Option<&Expr>, span: Span) -> Stmt

Source§

impl Checker

Source

pub(super) fn window( &mut self, call: &ElementCall<'_>, named: bool, ) -> Option<WindowDef>

A window’s definition; one without a named window must start open, since no code can open it.

Source

pub(super) fn ui_block(&mut self, stmts: &[Stmt]) -> Nodes

Source

fn ui_nodes(&mut self, stmts: &[Stmt]) -> Vec<Node>

Source

fn ui_stmt(&mut self, stmt: &Stmt) -> Option<Node>

Source

fn ui_if(&mut self, if_stmt: &IfStmt, span: Span) -> Node

Source

fn element( &mut self, name: &str, args: &[Arg], block: Option<&Block>, span: Span, ) -> Option<Node>

Source

fn built_in_element( &mut self, element: &'static Element, args: &[Arg], block: Option<&Block>, span: Span, ) -> Option<Node>

Source

fn stack_style( &mut self, axis: Axis, scrolls: bool, args: &mut Args<'_>, ) -> StackStyle

A stack’s settings; a scroll area always grows, so it isn’t asked.

Source

fn image(&mut self, name: &str, args: &mut Args<'_>, span: Span) -> Option<Node>

Source

fn text_field( &mut self, name: &str, args: &mut Args<'_>, block: Option<&Block>, span: Span, ) -> Option<Node>

Source

fn line_count(&mut self, expr: &Expr) -> Option<u32>

How many lines a text field is tall: at least one, and no more than fit a screen.

Source

fn button( &mut self, name: &str, args: &mut Args<'_>, block: Option<&Block>, span: Span, ) -> Option<Node>

Source

fn toggle( &mut self, name: &str, label: &str, style: ToggleStyle, args: &mut Args<'_>, span: Span, ) -> Option<Node>

A checkbox or switch, whose binding is labelled label.

Source

fn slider( &mut self, name: &str, args: &mut Args<'_>, span: Span, ) -> Option<Node>

Source

fn picker( &mut self, name: &str, args: &mut Args<'_>, span: Span, ) -> Option<Node>

Source

fn nav_item( &mut self, name: &str, args: &mut Args<'_>, span: Span, ) -> Option<Node>

Source

fn icon(&mut self, args: &mut Args<'_>) -> Icon

Source

fn label_style(&mut self, args: &mut Args<'_>) -> LabelStyle

Source

fn view_call( &mut self, name: &str, args: Args<'_>, block: Option<&Block>, span: Span, ) -> Option<Node>

Source

fn one_covering_each(&mut self, stmts: &[Stmt])

Reports each element in stmts that covers its stack after the first of its kind: a stack has one context menu and one drop target.

Source

fn none_covering(&mut self, body: &[Stmt])

Reports an element that covers its stack straight in a for’s body, which would cover the stack around the loop once for each item.

Source

pub(super) fn no_block(&mut self, name: &str, block: Option<&Block>)

Reports a block given to name, which takes none.

Source

fn required_text( &mut self, element: &str, expr: Option<&Expr>, span: Span, ) -> Option<Dynamic>

Source

fn text(&mut self, element: &str, expr: &Expr) -> Dynamic

Text the UI shows; it updates whenever the state it reads changes.

Source

fn number(&mut self, expr: &Expr) -> Dynamic

An int the UI shows; it updates whenever the state it reads changes.

Source

fn condition(&mut self, expr: &Expr) -> Dynamic

A bool the UI shows; it updates whenever the state it reads changes.

Source

fn shown(&mut self, expr: &Expr, ty: &Type) -> Dynamic

A value of type ty the UI shows; it updates whenever the state it reads changes.

Source

fn binding( &mut self, element: &str, label: Option<&str>, expr: Option<&Expr>, ty: &Type, span: Span, ) -> Option<Binding>

Source

pub(super) fn action(&mut self, block: &Block) -> Block

A button’s action: statements that may change state.

Source

fn dynamic<T>( &mut self, span: Span, check: impl FnOnce(&mut Self) -> T, ) -> (T, StateSet)

Checks UI code and returns the state it reads. Building the UI must not change state, since it runs again whenever that state changes.

Source§

impl Checker

Source

fn check_files(&mut self, files: &[&File])

Source

fn declare_types(&mut self, files: &[&File])

Source

fn declare_signatures(&mut self, files: &[&File])

Source

fn declare_windows(&mut self, files: &[&File])

Names the windows that have one, by their position among the app’s windows.

Source

fn resolve_params(&mut self, params: &[TypedName]) -> Vec<(String, Type)>

Source

fn check_states(&mut self, files: &[&File]) -> Vec<(Span, Effects)>

Checks each state’s starting value; returns their effects, which are validated once the functions they call have been checked.

Source

fn check_functions(&mut self, files: &[&File])

Source

fn check_state_values(&mut self, state_effects: &[(Span, Effects)])

Source

fn check_views(&mut self, files: &[&File])

Source

fn check_top_level(&mut self, files: &[&File])

Windows, then the menus of the menu bar, which share one body for their actions.

Source

fn declare_global(&mut self, name: &Ident, global: Global)

Source

fn global(&self, name: &str) -> Option<Global>

Source

fn resolve_type(&mut self, ty: &TypeExpr) -> Type

Source

fn measure<T>(&mut self, check: impl FnOnce(&mut Self) -> T) -> (T, Effects)

Runs check with a fresh record of effects and returns what it read and wrote.

Source

fn type_name(&self, ty: &Type) -> String

Source

fn require(&mut self, actual: &Type, expected: &Type, span: Span)

Reports a mismatch unless either side already has an error.

Source

fn error(&mut self, message: impl Into<String>, span: Span)

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.