⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

AstNode

Enum AstNode 

Source
pub enum AstNode {
Show 34 variants Program(Vec<AstNodeId>), VarDecl { name: String, init: Option<AstNodeId>, kind: VarKind, }, FuncDecl { name: String, params: Vec<String>, body: AstNodeId, }, Return(Option<AstNodeId>), If { condition: AstNodeId, then_branch: AstNodeId, else_branch: Option<AstNodeId>, }, While { condition: AstNodeId, body: AstNodeId, }, For { init: Option<AstNodeId>, condition: Option<AstNodeId>, update: Option<AstNodeId>, body: AstNodeId, }, Block(Vec<AstNodeId>), ExprStatement(AstNodeId), BinaryExpr { op: BinOp, left: AstNodeId, right: AstNodeId, }, UnaryExpr { op: UnaryOp, operand: AstNodeId, }, AssignExpr { target: AstNodeId, value: AstNodeId, }, CompoundAssign { op: BinOp, target: AstNodeId, value: AstNodeId, }, CallExpr { callee: AstNodeId, args: Vec<AstNodeId>, }, MemberExpr { object: AstNodeId, property: String, }, IndexExpr { object: AstNodeId, index: AstNodeId, }, ObjectLiteral(Vec<(String, AstNodeId)>), ArrayLiteral(Vec<AstNodeId>), StringLit(String), NumberLit(JsNumber), BoolLit(bool), NullLit, UndefinedLit, Identifier(String), This, FuncExpr { params: Vec<String>, body: AstNodeId, }, ArrowFunc { params: Vec<String>, body: AstNodeId, }, NewExpr { callee: AstNodeId, args: Vec<AstNodeId>, }, TypeofExpr(AstNodeId), Throw(AstNodeId), TryCatch { try_body: AstNodeId, catch_param: Option<String>, catch_body: Option<AstNodeId>, finally_body: Option<AstNodeId>, }, Break, Continue, Empty,
}
Expand description

AST node

Variants§

§

Program(Vec<AstNodeId>)

Program root: list of top-level statements

§

VarDecl

Variable declaration: (name, optional initializer)

Fields

§name: String
§init: Option<AstNodeId>
§kind: VarKind
§

FuncDecl

Function declaration

Fields

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

Return(Option<AstNodeId>)

Return statement

§

If

If statement

Fields

§condition: AstNodeId
§then_branch: AstNodeId
§else_branch: Option<AstNodeId>
§

While

While loop

Fields

§condition: AstNodeId
§

For

For loop

Fields

§init: Option<AstNodeId>
§condition: Option<AstNodeId>
§update: Option<AstNodeId>
§

Block(Vec<AstNodeId>)

Block statement { … }

§

ExprStatement(AstNodeId)

Expression statement

§

BinaryExpr

Binary expression

Fields

§

UnaryExpr

Unary expression

Fields

§operand: AstNodeId
§

AssignExpr

Assignment expression

Fields

§target: AstNodeId
§

CompoundAssign

Compound assignment (+=, -=, etc.)

Fields

§target: AstNodeId
§

CallExpr

Function call

Fields

§callee: AstNodeId
§args: Vec<AstNodeId>
§

MemberExpr

Member access (obj.prop)

Fields

§object: AstNodeId
§property: String
§

IndexExpr

Index access (obj[expr])

Fields

§object: AstNodeId
§

ObjectLiteral(Vec<(String, AstNodeId)>)

Object literal { key: value, … }

§

ArrayLiteral(Vec<AstNodeId>)

Array literal [expr, …]

§

StringLit(String)

String literal

§

NumberLit(JsNumber)

Number literal

§

BoolLit(bool)

Boolean literal

§

NullLit

Null literal

§

UndefinedLit

Undefined

§

Identifier(String)

Identifier reference

§

This

this keyword

§

FuncExpr

Function expression

Fields

§params: Vec<String>
§

ArrowFunc

Arrow function (params) => body

Fields

§params: Vec<String>
§

NewExpr

new Foo(args)

Fields

§callee: AstNodeId
§args: Vec<AstNodeId>
§

TypeofExpr(AstNodeId)

typeof expr

§

Throw(AstNodeId)

throw expr

§

TryCatch

try/catch/finally

Fields

§try_body: AstNodeId
§catch_param: Option<String>
§catch_body: Option<AstNodeId>
§finally_body: Option<AstNodeId>
§

Break

break

§

Continue

continue

§

Empty

Empty statement

Trait Implementations§

Source§

impl Clone for AstNode

Source§

fn clone(&self) -> AstNode

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AstNode

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for AstNode

§

impl RefUnwindSafe for AstNode

§

impl Send for AstNode

§

impl Sync for AstNode

§

impl Unpin for AstNode

§

impl UnwindSafe for AstNode

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.