Skip to main content

JsExpr

Enum JsExpr 

Source
pub enum JsExpr {
Show 20 variants Identifier(String, Span, Trivia), Literal(NargoValue, Span, Trivia), Unary { op: String, argument: Box<JsExpr>, span: Span, trivia: Trivia, }, Binary { left: Box<JsExpr>, op: String, right: Box<JsExpr>, span: Span, trivia: Trivia, }, Call { callee: Box<JsExpr>, args: Vec<JsExpr>, span: Span, trivia: Trivia, }, Member { object: Box<JsExpr>, property: Box<JsExpr>, computed: bool, span: Span, trivia: Trivia, }, OptionalMember { object: Box<JsExpr>, property: Box<JsExpr>, computed: bool, span: Span, trivia: Trivia, }, OptionalCall { callee: Box<JsExpr>, args: Vec<JsExpr>, span: Span, trivia: Trivia, }, NullishCoalescing { left: Box<JsExpr>, right: Box<JsExpr>, span: Span, trivia: Trivia, }, LogicalAssignment { op: String, left: Box<JsExpr>, right: Box<JsExpr>, span: Span, trivia: Trivia, }, Array(Vec<JsExpr>, Span, Trivia), Object(HashMap<String, JsExpr>, Span, Trivia), ArrowFunction { params: Vec<String>, body: Box<JsExpr>, span: Span, trivia: Trivia, }, TseElement { tag: String, attributes: Vec<TseAttribute>, children: Vec<JsExpr>, span: Span, trivia: Trivia, }, Conditional { test: Box<JsExpr>, consequent: Box<JsExpr>, alternate: Box<JsExpr>, span: Span, trivia: Trivia, }, TemplateLiteral { quasis: Vec<String>, expressions: Vec<JsExpr>, span: Span, trivia: Trivia, }, Spread(Box<JsExpr>, Span, Trivia), TypeOf(Box<JsExpr>, Span, Trivia), InstanceOf { left: Box<JsExpr>, right: Box<JsExpr>, span: Span, trivia: Trivia, }, Other(String, Span, Trivia),
}
Expand description

JavaScript 表达式

Variants§

§

Identifier(String, Span, Trivia)

标识符

§

Literal(NargoValue, Span, Trivia)

字面量

§

Unary

一元表达式

Fields

§op: String

操作符

§argument: Box<JsExpr>

参数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Binary

二元表达式

Fields

§left: Box<JsExpr>

左操作数

§op: String

操作符

§right: Box<JsExpr>

右操作数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Call

函数调用

Fields

§callee: Box<JsExpr>

调用目标

§args: Vec<JsExpr>

参数列表

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Member

成员访问

Fields

§object: Box<JsExpr>

对象

§property: Box<JsExpr>

属性

§computed: bool

是否为计算属性

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

OptionalMember

可选链成员访问

Fields

§object: Box<JsExpr>

对象

§property: Box<JsExpr>

属性

§computed: bool

是否为计算属性

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

OptionalCall

可选链函数调用

Fields

§callee: Box<JsExpr>

调用目标

§args: Vec<JsExpr>

参数列表

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

NullishCoalescing

空值合并表达式

Fields

§left: Box<JsExpr>

左操作数

§right: Box<JsExpr>

右操作数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

LogicalAssignment

逻辑赋值表达式

Fields

§op: String

操作符

§left: Box<JsExpr>

左操作数

§right: Box<JsExpr>

右操作数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Array(Vec<JsExpr>, Span, Trivia)

数组字面量

§

Object(HashMap<String, JsExpr>, Span, Trivia)

对象字面量

§

ArrowFunction

箭头函数

Fields

§params: Vec<String>

参数列表

§body: Box<JsExpr>

函数体

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

TseElement

TSE 元素

Fields

§tag: String

标签名

§attributes: Vec<TseAttribute>

属性列表

§children: Vec<JsExpr>

子元素

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Conditional

条件表达式

Fields

§test: Box<JsExpr>

条件

§consequent: Box<JsExpr>

真分支

§alternate: Box<JsExpr>

假分支

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

TemplateLiteral

模板字面量

Fields

§quasis: Vec<String>

模板字符串片段

§expressions: Vec<JsExpr>

表达式

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Spread(Box<JsExpr>, Span, Trivia)

展开表达式

§

TypeOf(Box<JsExpr>, Span, Trivia)

类型测试表达式

§

InstanceOf

实例测试表达式

Fields

§left: Box<JsExpr>

左操作数

§right: Box<JsExpr>

右操作数

§span: Span

位置信息

§trivia: Trivia

Trivia 信息

§

Other(String, Span, Trivia)

其他表达式

Implementations§

Source§

impl JsExpr

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_constant(&self) -> bool

检查表达式是否为常量

Source§

impl JsExpr

Source

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

接受访问者

Trait Implementations§

Source§

impl Clone for JsExpr

Source§

fn clone(&self) -> JsExpr

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 JsExpr

Source§

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

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

impl<'de> Deserialize<'de> for JsExpr

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 JsExpr

Source§

fn eq(&self, other: &JsExpr) -> 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 JsExpr

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 JsExpr

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>,