Skip to content

Commit 94a593b

Browse files
committed
rename entry and exit to getEntryNode and getExitNode respectively
1 parent 366a16f commit 94a593b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

javascript/extractor/src/com/semmle/js/extractor/CFGExtractor.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,10 @@ public <Q, A> A accept(Visitor<Q, A> v, Q q) {
797797
private final HashMap<IStatementContainer, Node> entryNodeCache =
798798
new LinkedHashMap<IStatementContainer, Node>();
799799

800-
private Node entry(IStatementContainer nd) {
800+
/**
801+
* Gets the entry node (a node without predecessors) for either a Function or a Program `nd`.
802+
*/
803+
private Node getEntryNode(IStatementContainer nd) {
801804
Node entry = entryNodeCache.get(nd);
802805
if (entry == null) {
803806
entry =
@@ -821,7 +824,10 @@ public <Q, A> A accept(Visitor<Q, A> v, Q q) {
821824
private final HashMap<IStatementContainer, Node> exitNodeCache =
822825
new LinkedHashMap<IStatementContainer, Node>();
823826

824-
private Node exit(IStatementContainer nd) {
827+
/**
828+
* Gets the exit node (a node without sucessors) for either a Function or a Program `nd`.
829+
*/
830+
private Node getExitNode(IStatementContainer nd) {
825831
Node exit = exitNodeCache.get(nd);
826832
if (exit == null) {
827833
exit =
@@ -909,7 +915,7 @@ public Object visit(IFunction nd, Void v) {
909915
}
910916

911917
private Object visit(IStatementContainer nd) {
912-
if (type == JumpType.RETURN) return exit((IStatementContainer) nd);
918+
if (type == JumpType.RETURN) return getExitNode((IStatementContainer) nd);
913919
return null;
914920
}
915921
},
@@ -956,7 +962,7 @@ public Void visit(Expression nd, SuccessorInfo i) {
956962
@Override
957963
public Void visit(Program nd, SuccessorInfo i) {
958964
this.ctxt.push(nd);
959-
Node entry = this.entry(nd);
965+
Node entry = getEntryNode(nd);
960966

961967
List<ImportDeclaration> imports = scanImports(nd);
962968
hoistedImports.addAll(imports);
@@ -966,7 +972,7 @@ public Void visit(Program nd, SuccessorInfo i) {
966972
List<Identifier> fns = HoistedFunDecls.of(nd);
967973
hoistedFns.addAll(fns);
968974

969-
Object fst = this.seq(importSpecifiers, fns, nd.getBody(), this.exit(nd));
975+
Object fst = this.seq(importSpecifiers, fns, nd.getBody(), this.getExitNode(nd));
970976
writeSuccessors(entry, fst);
971977
this.ctxt.pop();
972978
return null;
@@ -1007,7 +1013,7 @@ private void buildFunctionBody(IFunction nd) {
10071013
}
10081014
if (nd.hasRest()) paramsAndDefaults.add((Expression) nd.getRest());
10091015

1010-
Node entry = this.entry(nd);
1016+
Node entry = getEntryNode(nd);
10111017
List<Identifier> fns = HoistedFunDecls.of(nd);
10121018
hoistedFns.addAll(fns);
10131019

@@ -1025,7 +1031,7 @@ private void buildFunctionBody(IFunction nd) {
10251031
}
10261032
}
10271033

1028-
Object fst = this.seq(nd.getBody(), this.exit(nd));
1034+
Object fst = this.seq(nd.getBody(), this.getExitNode(nd));
10291035
if (firstField != null) fst = First.of(firstField);
10301036
fst =
10311037
this.seq(

0 commit comments

Comments
 (0)