274274 */
275275
276276import javascript
277+ private import internal.StmtContainers
277278
278279/**
279280 * A node in the control flow graph, which is an expression, a statement,
280281 * or a synthetic node.
281282 */
282- class ControlFlowNode extends @cfg_node, Locatable {
283+ class ControlFlowNode extends @cfg_node, Locatable , NodeInStmtContainer {
283284 /** Gets a node succeeding this node in the CFG. */
284285 ControlFlowNode getASuccessor ( ) { successor ( this , result ) }
285286
@@ -324,17 +325,6 @@ class ControlFlowNode extends @cfg_node, Locatable {
324325 // note the override in ControlFlowEntryNode below
325326 }
326327
327- /** Gets the function or toplevel whose CFG this node belongs to. */
328- cached
329- StmtContainer getContainer ( ) {
330- result = this .( Expr ) .getContainer ( ) or
331- result = this .( Stmt ) .getContainer ( ) or
332- result = this .( Property ) .getContainer ( ) or
333- result = this .( PropertyPattern ) .getContainer ( ) or
334- result = this .( ClassDefinition ) .getContainer ( ) or
335- result = this .( MemberDeclaration ) .getContainer ( )
336- }
337-
338328 /** Gets the basic block this node belongs to. */
339329 BasicBlock getBasicBlock ( ) { this = result .getANode ( ) }
340330
@@ -364,17 +354,13 @@ class SyntheticControlFlowNode extends @synthetic_cfg_node, ControlFlowNode {
364354
365355/** A synthetic CFG node marking the entry point of a function or toplevel script. */
366356class ControlFlowEntryNode extends SyntheticControlFlowNode , @entry_node {
367- override StmtContainer getContainer ( ) { entry_cfg_node ( this , result ) }
368-
369357 override predicate isUnreachable ( ) { none ( ) }
370358
371359 override string toString ( ) { result = "entry node of " + getContainer ( ) .toString ( ) }
372360}
373361
374362/** A synthetic CFG node marking the exit of a function or toplevel script. */
375363class ControlFlowExitNode extends SyntheticControlFlowNode , @exit_node {
376- override StmtContainer getContainer ( ) { exit_cfg_node ( this , result ) }
377-
378364 override predicate isAFinalNode ( ) { any ( ) }
379365
380366 override string toString ( ) { result = "exit node of " + getContainer ( ) .toString ( ) }
@@ -396,8 +382,6 @@ class GuardControlFlowNode extends SyntheticControlFlowNode, @guard_node {
396382 this = bb .getANode ( ) or
397383 dominates ( bb .getImmediateDominator ( ) )
398384 }
399-
400- override StmtContainer getContainer ( ) { result = getTest ( ) .getContainer ( ) }
401385}
402386
403387/**
0 commit comments