mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
refactor(ast): change plain_function to accept FunctionBody as a required parameter (#6709)
The `plain_function` method is used to construct js-only AST, and the `FunctionBody` is never empty in js
This commit is contained in:
parent
1370c2da70
commit
0e9b695634
2 changed files with 16 additions and 11 deletions
|
|
@ -176,11 +176,21 @@ impl<'a> AstBuilder<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
id: Option<BindingIdentifier<'a>>,
|
id: Option<BindingIdentifier<'a>>,
|
||||||
params: FormalParameters<'a>,
|
params: FormalParameters<'a>,
|
||||||
body: Option<FunctionBody<'a>>,
|
body: FunctionBody<'a>,
|
||||||
) -> Box<'a, Function<'a>> {
|
) -> Box<'a, Function<'a>> {
|
||||||
self.alloc(
|
self.alloc(self.function(
|
||||||
self.function(r#type, span, id, false, false, false, NONE, NONE, params, NONE, body),
|
r#type,
|
||||||
)
|
span,
|
||||||
|
id,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
NONE,
|
||||||
|
NONE,
|
||||||
|
params,
|
||||||
|
NONE,
|
||||||
|
Some(body),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- Modules ---------- */
|
/* ---------- Modules ---------- */
|
||||||
|
|
|
||||||
|
|
@ -336,13 +336,8 @@ impl<'a, 'ctx> TypeScriptNamespace<'a, 'ctx> {
|
||||||
let items = ctx.ast.vec1(ctx.ast.plain_formal_parameter(SPAN, pattern));
|
let items = ctx.ast.vec1(ctx.ast.plain_formal_parameter(SPAN, pattern));
|
||||||
ctx.ast.formal_parameters(SPAN, FormalParameterKind::FormalParameter, items, NONE)
|
ctx.ast.formal_parameters(SPAN, FormalParameterKind::FormalParameter, items, NONE)
|
||||||
};
|
};
|
||||||
let function = ctx.ast.plain_function(
|
let function =
|
||||||
FunctionType::FunctionExpression,
|
ctx.ast.plain_function(FunctionType::FunctionExpression, SPAN, None, params, body);
|
||||||
SPAN,
|
|
||||||
None,
|
|
||||||
params,
|
|
||||||
Some(body),
|
|
||||||
);
|
|
||||||
function.scope_id.set(Some(scope_id));
|
function.scope_id.set(Some(scope_id));
|
||||||
*ctx.scopes_mut().get_flags_mut(scope_id) =
|
*ctx.scopes_mut().get_flags_mut(scope_id) =
|
||||||
ScopeFlags::Function | ScopeFlags::StrictMode;
|
ScopeFlags::Function | ScopeFlags::StrictMode;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue