mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
JS: Remove hoisting code from functions
'buildFunctionBody' no longer needs to handle hoisting, because hoisting now happens when visiting the block statement that is the body of the function. Note that curly-brace functions contain a block statement as their body, not a list of statements.
This commit is contained in:
@@ -586,14 +586,6 @@ public class CFGExtractor {
|
||||
public static List<Identifier> of(Program p) {
|
||||
return of(p.getBody());
|
||||
}
|
||||
|
||||
public static List<Identifier> of(IFunction fn) {
|
||||
Node body = fn.getBody();
|
||||
if (body instanceof BlockStatement) return of(((BlockStatement) body).getBody());
|
||||
// if the body of the function is missing or is an expression, then there are
|
||||
// no hoisted functions
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1096,8 +1088,6 @@ public class CFGExtractor {
|
||||
if (nd.hasRest()) paramsAndDefaults.add((Expression) nd.getRest());
|
||||
|
||||
Node entry = getEntryNode(nd);
|
||||
List<Identifier> fns = HoistedFunDecls.of(nd);
|
||||
hoistedFns.addAll(fns);
|
||||
|
||||
// if this is the constructor of a class without a superclass, we need to
|
||||
// initialise all fields before running the body of the constructor
|
||||
@@ -1117,7 +1107,7 @@ public class CFGExtractor {
|
||||
if (firstField != null) fst = Collections.singleton(First.of(firstField));
|
||||
fst =
|
||||
visitSequence(
|
||||
nd instanceof FunctionDeclaration ? null : nd.getId(), paramsAndDefaults, fns, fst);
|
||||
nd instanceof FunctionDeclaration ? null : nd.getId(), paramsAndDefaults, fst);
|
||||
writeSuccessors(entry, fst);
|
||||
|
||||
this.ctxt.pop();
|
||||
|
||||
Reference in New Issue
Block a user