/*
   * Dispatch code analysis AND request saturation of inner emulation
   */
  public void analyseCode() {

    if (ignoreFurtherInvestigation) return;
    try {
      if (types != null) {
        for (int i = 0, count = types.length; i < count; i++) {
          types[i].analyseCode(scope);
        }
      }

      this.scope.temporaryAnalysisIndex = 0;
      int maxVars = this.scope.localIndex;
      for (Iterator iter = this.scope.externalCompilationUnits.iterator(); iter.hasNext(); ) {
        CompilationUnitScope externalScope = (CompilationUnitScope) iter.next();
        externalScope.temporaryAnalysisIndex = maxVars;
        maxVars += externalScope.localIndex;
      }
      FlowInfo flowInfo = FlowInfo.initial(maxVars);
      FlowContext flowContext = new FlowContext(null, this);

      if (statements != null) {
        List functions = null;
        for (int i = 0, length = this.statements.length; i < length; i++) {
          // if this is not a function then analyse it
          if (!(this.statements[i] instanceof AbstractMethodDeclaration)) {
            flowInfo = ((Statement) statements[i]).analyseCode(scope, flowContext, flowInfo);
          } else {
            // if this is a function then store it until all non functions are finished
            if (functions == null) functions = new ArrayList();
            functions.add(statements[i]);
          }
        }
        if (functions != null) {
          for (int f = 0; f < functions.size(); f++) {
            ((Statement) functions.get(f)).analyseCode(this.scope, null, flowInfo.copy());
          }
        }

        //				for (int i = 0, count = statements.length; i < count; i++) {
        //					if (statements[i] instanceof  AbstractMethodDeclaration)
        //					{
        //						((AbstractMethodDeclaration)statements[i]).analyseCode(this.scope, null,
        // flowInfo.copy());
        //					}
        //					else
        //					flowInfo=((Statement)statements[i]).analyseCode(scope,flowContext,flowInfo);
        //				}
      }
    } catch (AbortCompilationUnit e) {
      this.ignoreFurtherInvestigation = true;
      return;
    }
  }
 private void reportNLSProblems() {
   if (this.nlsTags != null || this.stringLiterals != null) {
     final int stringLiteralsLength = this.stringLiteralsPtr;
     final int nlsTagsLength = this.nlsTags == null ? 0 : this.nlsTags.length;
     if (stringLiteralsLength == 0) {
       if (nlsTagsLength != 0) {
         for (int i = 0; i < nlsTagsLength; i++) {
           NLSTag tag = this.nlsTags[i];
           if (tag != null) {
             scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
           }
         }
       }
     } else if (nlsTagsLength == 0) {
       // resize string literals
       if (this.stringLiterals.length != stringLiteralsLength) {
         System.arraycopy(
             this.stringLiterals,
             0,
             (stringLiterals = new StringLiteral[stringLiteralsLength]),
             0,
             stringLiteralsLength);
       }
       Arrays.sort(this.stringLiterals, STRING_LITERAL_COMPARATOR);
       for (int i = 0; i < stringLiteralsLength; i++) {
         scope.problemReporter().nonExternalizedStringLiteral(this.stringLiterals[i]);
       }
     } else {
       // need to iterate both arrays to find non matching elements
       if (this.stringLiterals.length != stringLiteralsLength) {
         System.arraycopy(
             this.stringLiterals,
             0,
             (stringLiterals = new StringLiteral[stringLiteralsLength]),
             0,
             stringLiteralsLength);
       }
       Arrays.sort(this.stringLiterals, STRING_LITERAL_COMPARATOR);
       int indexInLine = 1;
       int lastLineNumber = -1;
       StringLiteral literal = null;
       int index = 0;
       int i = 0;
       stringLiteralsLoop:
       for (; i < stringLiteralsLength; i++) {
         literal = this.stringLiterals[i];
         final int literalLineNumber = literal.lineNumber;
         if (lastLineNumber != literalLineNumber) {
           indexInLine = 1;
           lastLineNumber = literalLineNumber;
         } else {
           indexInLine++;
         }
         if (index < nlsTagsLength) {
           nlsTagsLoop:
           for (; index < nlsTagsLength; index++) {
             NLSTag tag = this.nlsTags[index];
             if (tag == null) continue nlsTagsLoop;
             int tagLineNumber = tag.lineNumber;
             if (literalLineNumber < tagLineNumber) {
               scope.problemReporter().nonExternalizedStringLiteral(literal);
               continue stringLiteralsLoop;
             } else if (literalLineNumber == tagLineNumber) {
               if (tag.index == indexInLine) {
                 this.nlsTags[index] = null;
                 index++;
                 continue stringLiteralsLoop;
               } else {
                 nlsTagsLoop2:
                 for (int index2 = index + 1; index2 < nlsTagsLength; index2++) {
                   NLSTag tag2 = this.nlsTags[index2];
                   if (tag2 == null) continue nlsTagsLoop2;
                   int tagLineNumber2 = tag2.lineNumber;
                   if (literalLineNumber == tagLineNumber2) {
                     if (tag2.index == indexInLine) {
                       this.nlsTags[index2] = null;
                       continue stringLiteralsLoop;
                     } else {
                       continue nlsTagsLoop2;
                     }
                   } else {
                     scope.problemReporter().nonExternalizedStringLiteral(literal);
                     continue stringLiteralsLoop;
                   }
                 }
                 scope.problemReporter().nonExternalizedStringLiteral(literal);
                 continue stringLiteralsLoop;
               }
             } else {
               scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
               continue nlsTagsLoop;
             }
           }
         }
         // all nls tags have been processed, so remaining string literals are not externalized
         break stringLiteralsLoop;
       }
       for (; i < stringLiteralsLength; i++) {
         scope.problemReporter().nonExternalizedStringLiteral(this.stringLiterals[i]);
       }
       if (index < nlsTagsLength) {
         for (; index < nlsTagsLength; index++) {
           NLSTag tag = this.nlsTags[index];
           if (tag != null) {
             scope.problemReporter().unnecessaryNLSTags(tag.start, tag.end);
           }
         }
       }
     }
   }
 }