pub enum Expression {
Show 32 variants
Number(f64),
BigIntLit(String),
Str(String),
Bool(bool),
Null,
Undefined,
Identifier(Rc<str>),
This,
TemplateLiteral {
quasis: Box<Vec<String>>,
exprs: Box<Vec<Expression>>,
},
TaggedTemplate {
tag: Box<Expression>,
quasis: Box<Vec<String>>,
raw: Box<Vec<String>>,
exprs: Box<Vec<Expression>>,
},
Elision,
Array(Vec<Expression>),
Object(Vec<Property>),
Function {
name: Option<Rc<str>>,
params: Rc<Vec<Param>>,
body: Rc<FnBody>,
is_arrow: bool,
is_async: bool,
is_generator: bool,
},
Await(Box<Expression>),
Yield {
argument: Option<Box<Expression>>,
delegate: bool,
},
Unary {
op: UnaryOp,
expr: Box<Expression>,
},
Update {
op: &'static str,
prefix: bool,
target: Box<Expression>,
},
Binary {
op: BinaryOp,
left: Box<Expression>,
right: Box<Expression>,
},
Logical {
op: LogicalOp,
left: Box<Expression>,
right: Box<Expression>,
},
Assign {
op: &'static str,
target: Box<Expression>,
value: Box<Expression>,
},
Conditional {
test: Box<Expression>,
consequent: Box<Expression>,
alternate: Box<Expression>,
},
Member {
object: Box<Expression>,
property: Rc<str>,
optional: bool,
},
Index {
object: Box<Expression>,
index: Box<Expression>,
optional: bool,
},
Call {
callee: Box<Expression>,
arguments: Vec<Expression>,
optional: bool,
},
New {
callee: Box<Expression>,
arguments: Vec<Expression>,
},
Spread(Box<Expression>),
Class {
name: Option<String>,
superclass: Option<Box<Expression>>,
members: Box<Vec<ClassMember>>,
},
Super,
Sequence(Vec<Expression>),
NewTarget,
Regex(Box<(String, String)>),
}Variants§
Number(f64)
BigIntLit(String)
BigInt リテラル(数値部分の文字列。0x/0o/0b 接頭辞を含み得る)。
Str(String)
Bool(bool)
Null
Undefined
Identifier(Rc<str>)
This
TemplateLiteral
TaggedTemplate
タグ付きテンプレート tag`...${e}...`(ES2015)。quasis/raw は
TemplateLiteral と同様 exprs より1つ多い。tag(strings, ...values) 呼出しで
strings は quasis の配列に .raw(raw の配列)を added property として持つ。
Elision
配列リテラルの穴([1,,3] の 2 番目)。値は undefined だが、要素として存在しない(2026-11-12)。
Array(Vec<Expression>)
Object(Vec<Property>)
Function
関数式・アロー関数。本体と引数は Rc で共有する(【2026-10-17】従来は評価のたびに
本体の構文木を丸ごと複製しており、YouTube の base.js(全体が 1 つの即時関数)で
約 100MB の複製が起きていた)。
Fields
Await(Box<Expression>)
await expr。
Yield
yield expr / yield* expr。
Unary
Update
Binary
Logical
Assign
Conditional
Member
Index
Call
New
Spread(Box<Expression>)
スプレッド要素 ...expr(配列リテラル/呼出引数/オブジェクト内で展開される)。
Class
class 式/宣言。
Super
super(super(...) / super.x)。
Sequence(Vec<Expression>)
カンマ演算子 a, b, c。全要素を順に評価し、最後の値を返す
(途中の要素の副作用も実行する。for(i=0,j=10; ...) 等で使われる)。
NewTarget
new.target(MetaProperty。new 経由の呼び出しではコンストラクタ関数自身、
通常呼び出しでは undefined)。
Regex(Box<(String, String)>)
正規表現リテラル /pattern/flags。(pattern, flags)。稀なので箱に入れて Expression を小さく保つ。
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§impl Debug for Expression
impl Debug for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl !RefUnwindSafe for Expression
impl !Send for Expression
impl !Sync for Expression
impl !UnwindSafe for Expression
impl Freeze for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more