src/com/google/javascript/jscomp/NodeUtil.java
/**
   * @param n The expression to check.
   * @return Whether the expression is unconditionally executed only once in the
   *     containing execution scope.
   */
@param n The expression to check.
@return Whether the expression is unconditionally executed only once in the
containing execution scope.
@param n The expression to check . @return Whether the expression is unconditionally executed only once in the containing execution scope .
static boolean isExecutedExactlyOnce(Node n) {
    inspect: do {
      Node parent = n.getParent();
      switch (parent.getToken()) {
        case IF:
        case HOOK:
        case AND:
        case OR:
          if (parent.getFirstChild() != n) {
            return false;
          }
          continue inspect;
        case FOR:
        case FOR_IN:
          if (parent.isForIn()) {
            if (parent.getSecondChild() != n) {
              return false;
            }
          } else {
            if (parent.getFirstChild() != n) {
              return false;
            }
          }
          continue inspect;
        case WHILE:
        case DO:
          return false;
        case TRY:
          if (!hasFinally(parent) || parent.getLastChild() != n) {
            return false;
          }
          continue inspect;
        case CASE:
        case DEFAULT_CASE:
          return false;
        case SCRIPT:
        case FUNCTION:
          break inspect;
        default:
          break;
      }
    } while ((n = n.getParent()) != null);
    return true;
  }
static boolean isExecutedExactlyOnce ( Node n ) { inspect : do { Node parent = n . getParent ( ) ; switch ( parent . getToken ( ) ) { case IF : case HOOK : case AND : case OR : if ( parent . getFirstChild ( ) != n ) { return false ; } continue inspect ; case FOR : case FOR_IN : if ( parent . isForIn ( ) ) { if ( parent . getSecondChild ( ) != n ) { return false ; } } else { if ( parent . getFirstChild ( ) != n ) { return false ; } } continue inspect ; case WHILE : case DO : return false ; case TRY : if ( ! hasFinally ( parent ) || parent . getLastChild ( ) != n ) { return false ; } continue inspect ; case CASE : case DEFAULT_CASE : return false ; case SCRIPT : case FUNCTION : break inspect ; default : break ; } } while ( ( n = n . getParent ( ) ) != null ) ; return true ; }
@param n The expression to check.
@param n The expression to check .
// other ancestors may be conditional // other ancestors may be conditional // Consider all code under a try/catch to be conditionally executed. // Done, we've reached the scope root.