Package com.dragome.compiler.ast

Examples of com.dragome.compiler.ast.ConditionalBranch


        }

      }
      else if (stmt instanceof ConditionalBranch)
      {
        ConditionalBranch cond= (ConditionalBranch) stmt;

        if (bytes.getIndex() == cond.getTargetIndex())
        {

        }
        else
        {
          Node elseNode= graph.getOrCreateNode(bytes.getIndex());

          Node ifNode;
          if (cond.getTargetIndex() <= pc)
          {
            Node[] nodes= graph.getOrSplitNodeAt(cNode, cond.getTargetIndex());
            cNode= nodes[0];
            ifNode= nodes[1];
          }
          else
          {
            ifNode= graph.getOrCreateNode(cond.getTargetIndex());
          }

          BooleanExpression be= new BooleanExpression(cond.getExpression());

          graph.addIfElseEdge(cNode, ifNode, elseNode, be);
          expressionsToVariables(cNode, false);
          cNode= null;

          if (lastJump != null && tryStatements.size() > 0 && (cond.getBeginIndex() - 1 == lastJump.getEndIndex()))
            whileTryProblemDetected= true;

          for (TryStatement tryStatement : tryStatements)
          {
            boolean nextToTryBegining= tryStatement.getBeginIndex() - 1 == cond.getEndIndex();
            boolean sameThanTryBegining= tryStatement.getBeginIndex() == cond.getBeginIndex();
            //      sameThanTryBegining= false; //TODO identificar si es un while!
            if (nextToTryBegining || sameThanTryBegining)
              whileTryProblemDetected= true;
          }

          if (!whileTryProblemDetected)
            for (CodeException codeException : code.getExceptionTable())
            {
              boolean nextToTryBegining= codeException.getEndPC() == cond.getTargetIndex();
              if (nextToTryBegining)
                whileTryProblemDetected= true;
            }

          if (whileTryProblemDetected)
View Full Code Here


    return methodBinding.getName() + "#" + methodBinding.getSignature();
  }

  ConditionalBranch createConditional(int currentIndex, InfixExpression.Operator operator) throws IOException
  {
    ConditionalBranch c= new ConditionalBranch(currentIndex + bytes.readShort());
    InfixExpression be= new InfixExpression(operator);
    Expression rightOperand= stack.pop();
    be.setOperands(stack.pop(), rightOperand);
    c.setExpression(be);
    return c;
  }
View Full Code Here

    return c;
  }

  ConditionalBranch createConditional(int currentIndex, InfixExpression.Operator operator, Expression rightOperand) throws IOException
  {
    ConditionalBranch c= new ConditionalBranch(currentIndex + bytes.readShort());
    Expression leftOperand= stack.pop();

    if (leftOperand.getTypeBinding() != null && leftOperand.getTypeBinding() == Type.BOOLEAN)
    {
      if (operator == InfixExpression.Operator.EQUALS && NumberLiteral.isZero(rightOperand))
      {
        c.setExpression(Optimizer.negate(leftOperand));
      }
      else
      {
        c.setExpression(leftOperand);
      }
    }
    else
    {
      InfixExpression be= new InfixExpression(operator);
      be.setOperands(leftOperand, rightOperand);
      c.setExpression(be);
    }

    return c;
  }
View Full Code Here

TOP

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

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.