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: EffectsImplementations§
Source§impl Checker
impl Checker
pub(super) fn built_in_call( &mut self, function: &'static Function, args: &[Arg], span: Span, ) -> Expr
Sourcefn window_request(
&mut self,
name: &str,
action: WindowAction,
args: Args<'_>,
span: Span,
) -> Expr
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.
Sourcefn window_name(&mut self, expr: &Expr) -> Option<WindowId>
fn window_name(&mut self, expr: &Expr) -> Option<WindowId>
The window expr names.
Sourcefn download(&mut self, args: Args<'_>, span: Span) -> Expr
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.
Sourcefn download_command(
&mut self,
command: DownloadCommand,
args: Args<'_>,
span: Span,
) -> Expr
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.
Sourcefn format_bytes(
&mut self,
function: &Function,
args: Args<'_>,
span: Span,
) -> Expr
fn format_bytes( &mut self, function: &Function, args: Args<'_>, span: Span, ) -> Expr
format_bytes(n), which only reads, so the UI may show it.
Sourcefn dialog(
&mut self,
name: &str,
kind: DialogKind,
args: Args<'_>,
span: Span,
) -> Expr
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.
Sourcefn is_in_list_item(place: &Place) -> bool
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.
fn optional_text(&mut self, arg: Option<&Expr>, span: Span) -> Expr
Sourcefn optional_texts(&mut self, arg: Option<&Expr>, span: Span) -> Expr
fn optional_texts(&mut self, arg: Option<&Expr>, span: Span) -> Expr
A [string] setting, empty when left out.
fn optional_int(&mut self, arg: Option<&Expr>, default: i64, span: Span) -> Expr
Source§impl Checker
impl Checker
Sourcepub(super) fn const_points(&mut self, expr: &Expr) -> Option<f32>
pub(super) fn const_points(&mut self, expr: &Expr) -> Option<f32>
A size in points, written as a number literal.
Sourcepub(super) fn const_number(&mut self, expr: &Expr) -> Option<i64>
pub(super) fn const_number(&mut self, expr: &Expr) -> Option<i64>
A whole number written literally, such as 10 or -10.
Sourcepub(super) fn const_string(&mut self, expr: &Expr) -> Option<String>
pub(super) fn const_string(&mut self, expr: &Expr) -> Option<String>
Text written as a plain string literal, without interpolation.
Sourcepub(super) fn const_bool(&mut self, expr: &Expr) -> Option<bool>
pub(super) fn const_bool(&mut self, expr: &Expr) -> Option<bool>
true or false, written literally.
Source§impl Checker
impl Checker
Sourcepub(super) fn expr(&mut self, expr: &Expr, expected: Option<&Type>) -> Expr
pub(super) fn expr(&mut self, expr: &Expr, expected: Option<&Type>) -> Expr
Checks expr; expected guides literals that can’t stand alone, such as [].
Sourcepub(super) fn expect(&mut self, expr: &Expr, expected: &Type) -> Expr
pub(super) fn expect(&mut self, expr: &Expr, expected: &Type) -> Expr
Checks expr and reports it unless it has type expected.
fn string(&mut self, parts: &[StringPart]) -> ExprKind
fn name(&mut self, name: &str, span: Span) -> Expr
fn list(&mut self, items: &[Expr], expected: Option<&Type>, span: Span) -> Expr
fn unary(&mut self, op: UnaryOp, operand: &Expr, span: Span) -> Expr
fn binary(&mut self, op: BinaryOp, lhs: &Expr, rhs: &Expr, span: Span) -> Expr
pub(super) fn binary_type( &mut self, op: BinaryOp, lhs: &Type, rhs: &Type, span: Span, ) -> Type
fn call(&mut self, callee: &Expr, args: &[Arg], span: Span) -> Expr
fn call_function( &mut self, function: FnId, name: &str, args: &[Arg], span: Span, ) -> Expr
fn construct(&mut self, id: StructId, args: &[Arg], span: Span) -> Expr
fn method( &mut self, base: &Expr, name: &Ident, args: &[Arg], span: Span, ) -> Expr
fn no_args(&mut self, method: &str, args: &[Arg])
fn no_method(&mut self, ty: &Type, name: &Ident) -> Expr
fn field(&mut self, base: &Expr, name: &Ident, span: Span) -> Expr
Sourcefn field_index(&mut self, ty: &Type, name: &Ident) -> Option<(usize, Type)>
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.
fn index(&mut self, base: &Expr, index: &Expr, span: Span) -> Expr
Sourcepub(super) fn place(&mut self, expr: &Expr) -> Option<Place>
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.
Sourcepub(super) fn writes_state(&self, place: &Place) -> bool
pub(super) fn writes_state(&self, place: &Place) -> bool
Whether place changes state: directly, or through a for variable aliasing it.
Sourcepub(super) fn bound_place(
&mut self,
owner: &str,
label: Option<&str>,
arg: Option<&Expr>,
ty: &Type,
span: Span,
) -> Option<Place>
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.
Sourcepub(super) fn note_write(&mut self, place: &Place)
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.
Sourcefn window_misused(&mut self, name: &str, span: Span) -> Expr
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.
pub(super) fn error_expr( &mut self, message: impl Into<String>, span: Span, ) -> Expr
Source§impl Checker
impl Checker
The menu bar’s menus, written as top-level menu(…) calls, in order.
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.
The entries of a menu’s block: items, separators and submenus. Items may take
shortcuts when there are shortcuts to add them to.
The block holding a menu’s items, which every menu needs.
Source§impl Checker
impl Checker
pub(super) fn block(&mut self, block: &Block) -> Block
fn stmt(&mut self, stmt: &Stmt) -> Option<Stmt>
fn assign(&mut self, target: &Expr, op: AssignOp, value: &Expr) -> Option<Stmt>
fn if_stmt(&mut self, if_stmt: &IfStmt) -> Stmt
Sourcepub(super) fn loop_head(&mut self, iterable: &Iterable, has_index: bool) -> Loop
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.
fn list_head(&mut self, list: &Expr) -> (Iterable, LocalInfo)
Sourcepub(super) fn in_loop<T>(
&mut self,
index: Option<&Ident>,
item: &Ident,
head: &Loop,
check: impl FnOnce(&mut Self) -> T,
) -> T
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.
fn return_stmt(&mut self, value: Option<&Expr>, span: Span) -> Stmt
Source§impl Checker
impl Checker
Sourcepub(super) fn window(
&mut self,
call: &ElementCall<'_>,
named: bool,
) -> Option<WindowDef>
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.
pub(super) fn ui_block(&mut self, stmts: &[Stmt]) -> Nodes
fn ui_nodes(&mut self, stmts: &[Stmt]) -> Vec<Node>
fn ui_stmt(&mut self, stmt: &Stmt) -> Option<Node>
fn ui_if(&mut self, if_stmt: &IfStmt, span: Span) -> Node
fn element( &mut self, name: &str, args: &[Arg], block: Option<&Block>, span: Span, ) -> Option<Node>
fn built_in_element( &mut self, element: &'static Element, args: &[Arg], block: Option<&Block>, span: Span, ) -> Option<Node>
Sourcefn stack_style(
&mut self,
axis: Axis,
scrolls: bool,
args: &mut Args<'_>,
) -> StackStyle
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.
fn image(&mut self, name: &str, args: &mut Args<'_>, span: Span) -> Option<Node>
fn text_field( &mut self, name: &str, args: &mut Args<'_>, block: Option<&Block>, span: Span, ) -> Option<Node>
Sourcefn line_count(&mut self, expr: &Expr) -> Option<u32>
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.
Sourcefn toggle(
&mut self,
name: &str,
label: &str,
style: ToggleStyle,
args: &mut Args<'_>,
span: Span,
) -> Option<Node>
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.
fn slider( &mut self, name: &str, args: &mut Args<'_>, span: Span, ) -> Option<Node>
fn picker( &mut self, name: &str, args: &mut Args<'_>, span: Span, ) -> Option<Node>
fn icon(&mut self, args: &mut Args<'_>) -> Icon
fn label_style(&mut self, args: &mut Args<'_>) -> LabelStyle
fn view_call( &mut self, name: &str, args: Args<'_>, block: Option<&Block>, span: Span, ) -> Option<Node>
Sourcefn one_covering_each(&mut self, stmts: &[Stmt])
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.
Sourcefn none_covering(&mut self, body: &[Stmt])
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.
Sourcepub(super) fn no_block(&mut self, name: &str, block: Option<&Block>)
pub(super) fn no_block(&mut self, name: &str, block: Option<&Block>)
Reports a block given to name, which takes none.
fn required_text( &mut self, element: &str, expr: Option<&Expr>, span: Span, ) -> Option<Dynamic>
Sourcefn text(&mut self, element: &str, expr: &Expr) -> Dynamic
fn text(&mut self, element: &str, expr: &Expr) -> Dynamic
Text the UI shows; it updates whenever the state it reads changes.
Sourcefn number(&mut self, expr: &Expr) -> Dynamic
fn number(&mut self, expr: &Expr) -> Dynamic
An int the UI shows; it updates whenever the state it reads changes.
Sourcefn condition(&mut self, expr: &Expr) -> Dynamic
fn condition(&mut self, expr: &Expr) -> Dynamic
A bool the UI shows; it updates whenever the state it reads changes.
Sourcefn shown(&mut self, expr: &Expr, ty: &Type) -> Dynamic
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.
fn binding( &mut self, element: &str, label: Option<&str>, expr: Option<&Expr>, ty: &Type, span: Span, ) -> Option<Binding>
Source§impl Checker
impl Checker
fn check_files(&mut self, files: &[&File])
fn declare_types(&mut self, files: &[&File])
fn declare_signatures(&mut self, files: &[&File])
Sourcefn declare_windows(&mut self, files: &[&File])
fn declare_windows(&mut self, files: &[&File])
Names the windows that have one, by their position among the app’s windows.
fn resolve_params(&mut self, params: &[TypedName]) -> Vec<(String, Type)>
Sourcefn check_states(&mut self, files: &[&File]) -> Vec<(Span, Effects)>
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.
fn check_functions(&mut self, files: &[&File])
fn check_state_values(&mut self, state_effects: &[(Span, Effects)])
fn check_views(&mut self, files: &[&File])
Sourcefn check_top_level(&mut self, files: &[&File])
fn check_top_level(&mut self, files: &[&File])
Windows, then the menus of the menu bar, which share one body for their actions.
fn declare_global(&mut self, name: &Ident, global: Global)
fn global(&self, name: &str) -> Option<Global>
fn resolve_type(&mut self, ty: &TypeExpr) -> Type
Sourcefn measure<T>(&mut self, check: impl FnOnce(&mut Self) -> T) -> (T, Effects)
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.
fn type_name(&self, ty: &Type) -> String
Sourcefn require(&mut self, actual: &Type, expected: &Type, span: Span)
fn require(&mut self, actual: &Type, expected: &Type, span: Span)
Reports a mismatch unless either side already has an error.