Skip to main content

StmtKind

Enum StmtKind 

Source
pub enum StmtKind {
Show 15 variants Let { name: String, value: Expr, is_const: bool, }, Assign { target: AssignTarget, op: AssignOp, value: Expr, }, If { condition: Expr, body: Vec<Stmt>, else_ifs: Vec<(Expr, Vec<Stmt>)>, else_body: Option<Vec<Stmt>>, }, While { condition: Expr, body: Vec<Stmt>, }, Repeat { count: Expr, body: Vec<Stmt>, }, ForIn { var: String, iterable: Expr, body: Vec<Stmt>, }, FnDecl { name: String, params: Vec<String>, body: Vec<Stmt>, }, MethodDecl { type_name: String, method_name: String, params: Vec<String>, body: Vec<Stmt>, }, Return { value: Option<Expr>, }, Break, Continue, Use { path: String, items: Option<Vec<String>>, alias: Option<String>, }, StructDecl { name: String, fields: Vec<String>, }, EnumDecl { name: String, variants: Vec<VariantDecl>, }, ExprStmt(Expr),
}

Variants§

§

Let

let NAME = expr (value binding, mutable) and const NAME = expr (constant binding, immutable). The is_const flag flips enforcement at use/assign sites: reassigning a constant is a compile-time error (the parser refuses any assignment whose LHS is an all-uppercase identifier — see [parse_assign]).

Fields

§name: String
§value: Expr
§is_const: bool
§

Assign

Fields

§value: Expr
§

If

Fields

§condition: Expr
§body: Vec<Stmt>
§else_ifs: Vec<(Expr, Vec<Stmt>)>
§else_body: Option<Vec<Stmt>>
§

While

Fields

§condition: Expr
§body: Vec<Stmt>
§

Repeat

Fields

§count: Expr
§body: Vec<Stmt>
§

ForIn

Fields

§iterable: Expr
§body: Vec<Stmt>
§

FnDecl

Fields

§name: String
§params: Vec<String>
§body: Vec<Stmt>
§

MethodDecl

fn Type.method(self, ...) { body } — declares a method on a user-defined struct or enum. At call time (obj.method(...)) the receiver is passed as the first parameter (conventionally named self), followed by the rest.

Fields

§type_name: String
§method_name: String
§params: Vec<String>
§body: Vec<Stmt>
§

Return

Fields

§value: Option<Expr>
§

Break

§

Continue

§

Use

use foo.bar.baz — resolves the module named by the dot-joined path through BopHost::resolve_module, evaluates its top-level statements in a fresh scope, and injects its exports into the importer’s scope. The shape of the injection depends on the optional items / alias:

  • use foo — glob: all non-private top-level names land unqualified.
  • use foo.{a, b} — selective: only a and b land unqualified. _-prefixed names can be explicitly listed.
  • use foo as m — aliased: all exports (including _-prefixed) hang off a new m namespace value. Access via m.a, m.Entity, etc.
  • use foo.{a, b} as m — selective + aliased: m namespace contains only a and b.

Glob imports skip _-prefixed top-level names (privacy convention). Aliased and selective imports pass them through when the user asks for them explicitly.

Fields

§path: String
§items: Option<Vec<String>>

Some iff the caller used the selective .{a, b} form. The listed names are injected (whatever shape they have); anything not listed is skipped.

§alias: Option<String>

Some("m") iff the caller used the as m form. Exports are bound inside a Value::Module under this name rather than in the caller’s scope directly.

§

StructDecl

struct Point { x, y } — registers a user-defined struct type with the listed field names. Field values get their types from the construction site (Point { x: 1, y: 2 }).

Fields

§name: String
§fields: Vec<String>
§

EnumDecl

enum Shape { Circle(radius), Rectangle { w, h }, Empty } — registers a user-defined sum type with named variants.

Fields

§name: String
§variants: Vec<VariantDecl>
§

ExprStmt(Expr)

Trait Implementations§

Source§

impl Clone for StmtKind

Source§

fn clone(&self) -> StmtKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StmtKind

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.