Expand description
JavaScript abstract syntax tree.
Every node here has a direct lowering in compiler.rs. JS is
statement-oriented with brace-delimited blocks, so the tree separates Stmt
(blocks of these form a program/function body) from Expr. Numbers are all
IEEE-754 f64, matching JavaScript’s single number type.
Structs§
- Class
Member - One member of a class body: a method, accessor, or field, on the instance or static side.
- Class
Node - A
classdeclaration/expression body. - Declarator
- A single declarator inside a
var/let/const. - Export
Spec local as exportedinsideexport { … }. Without afromclauselocalnames a binding of this module; with one it is a name the requested module exports.- Import
Decl import … from "specifier" with { … }— the bindings may be empty (import "m"evaluates the module for its effects only).- Param
- A formal parameter.
- Stmt
- A statement plus its 1-based source line and the
Posof its first token. - Switch
Case - One
case/defaultclause of aswitch.
Enums§
- Assign
Op - The operator carried by a COMPOUND assignment (
a += b,a ??= b). - BinOp
- A binary operator (
a <op> b).&&/||/??areLogicalOpbecause they short-circuit and yield an operand value, not a coerced boolean. - Decl
Kind - The kind of a variable declaration.
- Export
Decl - The forms of an
exportdeclaration (16.2.3). - Expr
- A JavaScript expression.
- FnBody
- A function/arrow body: either a brace-delimited statement list or (arrow) a single expression whose value is returned.
- Import
Spec - One binding an
importdeclaration introduces (16.2.2). - Logical
Op - A short-circuiting logical operator.
- Member
Kind - The kind of a class member.
- Prop
- A property of an object literal.
- Stmt
Kind - A JavaScript statement.
- UnOp
- A unary prefix operator.
- Update
Op - The update (increment/decrement) operator, prefix or postfix.
Type Aliases§
- Pos
- A source position: one past the UTF-8 byte offset of a token in the text the
node was parsed from, so
0means “none” (a synthetic node, or text the parser could not map back — seeParser::spans). The compiler stores it in thelinesentry of the op the node lowers to, and the loader rebases it into the host’s source address space, which is what an error’s source arrow and a stack frame’sfile:line:columnare read from. - Span
- A source range as UTF-8 byte offsets
(start, end)into the text the parser read.(0, 0)means none was recorded (a${…}template field is re-parsed from a copy, so its offsets would not point into the script).Function.prototype.toStringreturns this slice (20.2.3.5).