Package com.dragome.compiler.ast

Examples of com.dragome.compiler.ast.ExceptionHandler


  {
    ExceptionHandlers handlers= new ExceptionHandlers(code);

    Iterator<ExceptionHandler> handleIterator= handlers.iterator();

    ExceptionHandler handle= handleIterator.hasNext() ? handleIterator.next() : null;
    while (handle != null)
    {
      boolean hasFinally= false;
      int start= handle.getStartPC();
      int end= handle.getEndPC();

      TryStatement tryStmt= new TryStatement();
      tryStmt.header= (TryHeaderNode) graph.createNode(TryHeaderNode.class);
      tryStmt.header.tryStmt= tryStmt;

      Block tryBlock= new Block(start, end);
      tryStmt.setTryBlock(tryBlock);

      // tryStmt.setBeginIndex(start);

      tryStatements.add(tryStmt);

      CatchClause cStmt= null;

      // Collect all non-default handlers. The range of each handler is
      // from the 'store'-instruction to the beginning of the next
      // handler.
      while (handle != null && !handle.isDefault() && handle.getStartPC() == start && handle.getEndPC() == end)
      {
        if (cStmt != null)
        {
          cStmt.setEndIndex(handle.getHandlerPC() - 1);
        }
        cStmt= createCatchClause(tryStmt, handle);
        handle= handleIterator.hasNext() ? handleIterator.next() : null;
      }

      int foo= -1;
      if (handle != null && handle.isDefault() && handle.getStartPC() == start)
      {
        // Collect first default handler.
        hasFinally= true;
        if (cStmt != null)
        {
          cStmt.setEndIndex(handle.getHandlerPC() - 1);
          tryStmt.setEndIndex(handle.getHandlerPC() - 1);
          // Warning: We only set a lower bound for the end index. The
          // correct index is set later
          // when the finally statement is analysed.
        }
        cStmt= createCatchClause(tryStmt, handle);
        foo= handle.getHandlerPC();
        handle= handleIterator.hasNext() ? handleIterator.next() : null;
      }

      // Last catch stmt has no endIndex, yet!

      while (handle != null && handle.isDefault() && (handle.getHandlerPC() == foo))
      {
        // Skip all remaining default handlers.
        throw new RuntimeException("remaining default handlers");
        // handle = handleIterator.hasNext()?handleIterator.next():null;
      }
View Full Code Here

TOP

Related Classes of com.dragome.compiler.ast.ExceptionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.