Struct swc_ecma_utils::function::FunctionWrapper
source · pub struct FunctionWrapper<T> {
pub binding_ident: Option<Ident>,
pub function: Expr,
pub ignore_function_name: bool,
pub ignore_function_length: bool,
/* private fields */
}
Fields§
§binding_ident: Option<Ident>
§function: Expr
§ignore_function_name: bool
§ignore_function_length: bool
Trait Implementations§
source§impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
source§fn from(value: FunctionWrapper<Expr>) -> Self
fn from(value: FunctionWrapper<Expr>) -> Self
Converts to this type from the input type.
source§impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
source§fn from(value: FunctionWrapper<FnDecl>) -> Self
fn from(value: FunctionWrapper<FnDecl>) -> Self
Converts to this type from the input type.
source§impl Into<Expr> for FunctionWrapper<Expr>
impl Into<Expr> for FunctionWrapper<Expr>
source§fn into(self) -> Expr
fn into(self) -> Expr
If a function has a function name, it may be called recursively. We use the named expression to hoist the function name internally Therefore, its recursive calls refer to the correct identity.
Else if a function has a binding name, it may be called recursively as well. But it refer the binding name which exist the outer scope. It is safe to using anonymous expression wrapper.
Optimization: A function without a name cannot be recursively referenced by Ident. It’s safe to return the expr without wrapper if the params.len is 0.
Auto Trait Implementations§
impl<T> RefUnwindSafe for FunctionWrapper<T>where T: RefUnwindSafe,
impl<T> Send for FunctionWrapper<T>where T: Send,
impl<T> Sync for FunctionWrapper<T>where T: Sync,
impl<T> Unpin for FunctionWrapper<T>where T: Unpin,
impl<T> UnwindSafe for FunctionWrapper<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
source§impl<T> ExprFactory for Twhere
T: Into<Expr>,
impl<T> ExprFactory for Twhere T: Into<Expr>,
source§fn as_arg(self) -> ExprOrSpread
fn as_arg(self) -> ExprOrSpread
fn as_pat_or_expr(self) -> PatOrExpr
source§fn into_return_stmt(self) -> ReturnStmt
fn into_return_stmt(self) -> ReturnStmt
Creates a statement whcih return
self
.fn as_callee(self) -> Callee
fn as_iife(self) -> CallExpr
source§fn into_lazy_arrow(self, params: Vec<Pat>) -> ArrowExpr
fn into_lazy_arrow(self, params: Vec<Pat>) -> ArrowExpr
create a ArrowExpr which return self Read more
source§fn into_lazy_fn(self, params: Vec<Param>) -> Function
fn into_lazy_fn(self, params: Vec<Param>) -> Function
create a Function which return self Read more
fn into_lazy_auto(self, params: Vec<Pat>, support_arrow: bool) -> Expr
source§fn into_var_decl(self, kind: VarDeclKind, name: Pat) -> VarDecl
fn into_var_decl(self, kind: VarDeclKind, name: Pat) -> VarDecl
create a var declartor using self as init Read more
fn into_new_expr(self, span: Span, args: Option<Vec<ExprOrSpread>>) -> NewExpr
fn apply(self, span: Span, this: Box<Expr>, args: Vec<ExprOrSpread>) -> Expr
fn call_fn(self, span: Span, args: Vec<ExprOrSpread>) -> Expr
fn as_call(self, span: Span, args: Vec<ExprOrSpread>) -> Expr
fn as_fn_decl(self) -> Option<FnDecl>
fn as_class_decl(self) -> Option<ClassDecl>
fn wrap_with_paren(self) -> Expr
source§fn make_bin<T>(self, op: BinaryOp, right: T) -> Exprwhere
T: Into<Expr>,
fn make_bin<T>(self, op: BinaryOp, right: T) -> Exprwhere T: Into<Expr>,
Creates a binary expr
$self $op $rhs
source§fn make_assign_to(self, op: AssignOp, left: PatOrExpr) -> Expr
fn make_assign_to(self, op: AssignOp, left: PatOrExpr) -> Expr
Creates a assign expr
$lhs $op $self
fn make_member<T>(self, prop: T) -> Exprwhere T: Into<Ident>,
fn computed_member<T>(self, prop: T) -> Exprwhere T: Into<Expr>,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.