pub struct Function {
pub name: Option<Ident>,
pub params: Vec<Pattern>,
pub body: FunctionBody,
pub is_async: bool,
pub is_generator: bool,
pub strict: bool,
pub is_arrow: bool,
pub span: Span,
pub params_span: Span,
pub source_span: Option<Span>,
}Expand description
A function in any of its forms (declaration, expression, arrow, method).
Fields§
§name: Option<Ident>Name: required for declarations, optional for expressions and arrows.
params: Vec<Pattern>Parameters, in source order; a rest parameter is [Pattern::Rest].
body: FunctionBodyBody.
is_async: boolasync
is_generator: boolfunction* / *method / async function*
strict: boolWhether the body is strict: either an enclosing strict context or the
function’s own "use strict" directive.
Recorded per function because strictness is not a property of the source but of
the enclosing context: a "use strict" inside one function body leaves the code
after it sloppy, so the compiler cannot infer a body’s mode from the program’s.
is_arrow: bool=>
span: SpanSource range.
params_span: SpanRange of the parameter list, for error messages and length.
source_span: Option<Span>The range Function.prototype.toString reports, when it is not span.
A class is the constructor function object, so A.toString() reports the whole
class definition while the constructor’s own span — which the line table and
params_span are built from — stays on the constructor(){} member
(class-declaration-explicit-ctor).