pub struct Class {
pub name: Option<Ident>,
pub super_class: Option<Box<Expr>>,
pub elements: Vec<ClassElement>,
pub span: Span,
pub body_end: Position,
}Expand description
A class body.
Fields§
§name: Option<Ident>Class name: required for declarations, optional for expressions.
super_class: Option<Box<Expr>>extends clause.
elements: Vec<ClassElement>Members, in source order.
span: SpanSource range.
body_end: PositionThe closing } of the body.
A class that writes no constructor still gets one, and the reference creates that
synthetic function at the closing brace: js_parse_class_default_ctor runs with
the } as its current token and hands s->token.ptr to js_new_function_def. The
position is the function’s own source_pos, which is the first entry of its
line table — so class B extends BigInt {} constructed as new B(1) reports its
frame at the }, not at class. span.end cannot stand in: it is one past the
brace, and the brace may be the last character of a line.
Implementations§
Source§impl Class
impl Class
Sourcepub fn has_own_name(&self) -> bool
pub fn has_own_name(&self) -> bool
Whether the class body itself defines name, which an anonymous class then keeps.
class { static name(){} } has an own name property, so assigning one from the
binding would either fail or be shadowed — NamedEvaluation checks for it and
leaves the class alone.