Skip to main content

JsStmt

Enum JsStmt 

Source
pub enum JsStmt {
Show 20 variants Expr(JsExpr, Span, Trivia), VariableDecl { kind: String, id: String, init: Option<JsExpr>, span: Span, trivia: Trivia, }, Import { source: String, specifiers: Vec<String>, span: Span, trivia: Trivia, }, Export { declaration: Box<JsStmt>, span: Span, trivia: Trivia, }, ExportAll { source: String, span: Span, trivia: Trivia, }, ExportNamed { source: Option<String>, specifiers: Vec<String>, span: Span, trivia: Trivia, }, FunctionDecl { id: String, params: Vec<String>, body: Vec<JsStmt>, is_async: bool, span: Span, trivia: Trivia, }, Return(Option<JsExpr>, Span, Trivia), If { test: JsExpr, consequent: Box<JsStmt>, alternate: Option<Box<JsStmt>>, span: Span, trivia: Trivia, }, While { test: JsExpr, body: Box<JsStmt>, span: Span, trivia: Trivia, }, For { init: Option<Box<JsStmt>>, test: Option<JsExpr>, update: Option<JsExpr>, body: Box<JsStmt>, span: Span, trivia: Trivia, }, ForIn { left: Box<JsStmt>, right: JsExpr, body: Box<JsStmt>, span: Span, trivia: Trivia, }, ForOf { left: Box<JsStmt>, right: JsExpr, body: Box<JsStmt>, span: Span, trivia: Trivia, }, Try { block: Box<JsStmt>, handler: Option<(String, Box<JsStmt>)>, finalizer: Option<Box<JsStmt>>, span: Span, trivia: Trivia, }, Switch { discriminant: JsExpr, cases: Vec<(Option<JsExpr>, Vec<JsStmt>)>, span: Span, trivia: Trivia, }, Throw(JsExpr, Span, Trivia), Block(Vec<JsStmt>, Span, Trivia), Break(Span, Trivia), Continue(Span, Trivia), Other(String, Span, Trivia),
}
Expand description

JavaScript 语句

Variants§

§

Expr(JsExpr, Span, Trivia)

表达式语句

§

VariableDecl

变量声明

Fields

§kind: String

声明类型(var, let, const)

§id: String

变量名

§init: Option<JsExpr>

初始值

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Import

导入语句

Fields

§source: String

导入源

§specifiers: Vec<String>

导入说明符

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Export

导出语句

Fields

§declaration: Box<JsStmt>

导出声明

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

ExportAll

导出所有

Fields

§source: String

导出源

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

ExportNamed

导出命名

Fields

§source: Option<String>

导出源

§specifiers: Vec<String>

导出说明符

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

FunctionDecl

函数声明

Fields

§id: String

函数名

§params: Vec<String>

参数列表

§body: Vec<JsStmt>

函数体

§is_async: bool

是否为异步函数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Return(Option<JsExpr>, Span, Trivia)

返回语句

§

If

if 语句

Fields

§test: JsExpr

条件

§consequent: Box<JsStmt>

真分支

§alternate: Option<Box<JsStmt>>

假分支

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

While

while 语句

Fields

§test: JsExpr

条件

§body: Box<JsStmt>

循环体

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

For

for 语句

Fields

§init: Option<Box<JsStmt>>

初始化

§test: Option<JsExpr>

条件

§update: Option<JsExpr>

更新

§body: Box<JsStmt>

循环体

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

ForIn

for-in 语句

Fields

§left: Box<JsStmt>

变量

§right: JsExpr

表达式

§body: Box<JsStmt>

循环体

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

ForOf

for-of 语句

Fields

§left: Box<JsStmt>

变量

§right: JsExpr

表达式

§body: Box<JsStmt>

循环体

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Try

try/catch 语句

Fields

§block: Box<JsStmt>

try 块

§handler: Option<(String, Box<JsStmt>)>

catch 块

§finalizer: Option<Box<JsStmt>>

finally 块

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Switch

switch 语句

Fields

§discriminant: JsExpr

表达式

§cases: Vec<(Option<JsExpr>, Vec<JsStmt>)>

分支

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Throw(JsExpr, Span, Trivia)

throw 语句

§

Block(Vec<JsStmt>, Span, Trivia)

块语句

§

Break(Span, Trivia)

break 语句

§

Continue(Span, Trivia)

continue 语句

§

Other(String, Span, Trivia)

其他语句

Implementations§

Source§

impl JsStmt

Source

pub fn span(&self) -> Span

获取语句的位置信息

Source

pub fn trivia(&self) -> &Trivia

获取语句的 trivia 信息

Source

pub fn validate(&self, depth: usize) -> Result<()>

验证语句的有效性

Source

pub fn optimize(&mut self)

优化语句

Source

pub fn is_empty(&self) -> bool

检查语句是否为空

Source§

impl JsStmt

Source

pub fn accept<R>(&self, visitor: &mut dyn JsStmtVisitor<R>) -> R

接受访问者

Trait Implementations§

Source§

impl Clone for JsStmt

Source§

fn clone(&self) -> JsStmt

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 JsStmt

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JsStmt

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for JsStmt

Source§

fn eq(&self, other: &JsStmt) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for JsStmt

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsStmt

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,