Skip to main content

Module ast

Module ast 

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

ClassMember
One member of a class body: a method, accessor, or field, on the instance or static side.
ClassNode
A class declaration/expression body.
Declarator
A single declarator inside a var/let/const.
ExportSpec
local as exported inside export { … }. Without a from clause local names a binding of this module; with one it is a name the requested module exports.
ImportDecl
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 Pos of its first token.
SwitchCase
One case/default clause of a switch.

Enums§

AssignOp
The operator carried by a COMPOUND assignment (a += b, a ??= b).
BinOp
A binary operator (a <op> b). &&/||/?? are LogicalOp because they short-circuit and yield an operand value, not a coerced boolean.
DeclKind
The kind of a variable declaration.
ExportDecl
The forms of an export declaration (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.
ImportSpec
One binding an import declaration introduces (16.2.2).
LogicalOp
A short-circuiting logical operator.
MemberKind
The kind of a class member.
Prop
A property of an object literal.
StmtKind
A JavaScript statement.
UnOp
A unary prefix operator.
UpdateOp
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 0 means “none” (a synthetic node, or text the parser could not map back — see Parser::spans). The compiler stores it in the lines entry 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’s file:line:column are 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.toString returns this slice (20.2.3.5).