Package com.dragome.compiler.graph

Examples of com.dragome.compiler.graph.Node


    CatchClause cc= (CatchClause) stmt.getCatchStatements().getFirstChild();
    Iterator iter= catchNodes.iterator();
    while (iter.hasNext())
    {
      Node catchNode= (Node) iter.next();
      graph.rollOut(catchNode, cc);
      cc= (CatchClause) cc.getNextSibling();
    }
  }
View Full Code Here


    {
      if (!(e instanceof SwitchEdge))
        continue;

      SwitchEdge edge= (SwitchEdge) e;
      Node caseGroup= edge.target;

      if (prevPotentialFallThroughEdge != null && prevPotentialFallThroughEdge.target == caseGroup)
      {

        graph.removeEdge(prevPotentialFallThroughEdge);
      }

      prevPotentialFallThroughEdge= caseGroup.getLocalOutEdgeOrNull();
    }
  }
View Full Code Here

    {
      if (!(e instanceof SwitchEdge))
        continue;

      SwitchEdge edge= (SwitchEdge) e;
      Node caseGroup= edge.target;
      caseGroups.add(caseGroup);
      caseGroupExpressions.add(edge.expressions);
      graph.rerootOutEdges(caseGroup, newNode, true);
      graph.removeOutEdges(caseGroup);
      graph.removeInEdges(caseGroup);
View Full Code Here

    SwitchStatement switchStmt= new SwitchStatement();
    switchStmt.setExpression(header.switchExpression);

    for (int i= 0; i < caseGroups.size(); i++)
    {
      Node scNode= caseGroups.get(i);
      SwitchCase switchCase= new SwitchCase(scNode.getInitialPc());
      switchCase.setExpressions(caseGroupExpressions.get(i));
      switchStmt.appendChild(switchCase);

      graph.rollOut(scNode, switchCase);
    }
View Full Code Here

    block.appendChildren(newNode.block);
  }

  void produceJump(Edge edge, Block labeledBlock)
  {
    Node referer= edge.getOrgSource();
    Block breakBlock;
    if (edge instanceof ConditionalEdge)
    {
      ConditionalEdge condEdge= (ConditionalEdge) edge;
      BooleanExpression condExpr= condEdge.getBooleanExpression();
View Full Code Here

  private void makeTryFrame(TryStatement stmt)
  {
    TryHeaderNode header= stmt.header;

    Node tryNode= graph.getOrCreateNode(stmt.getBeginIndex());
    tryNode.stack= new ASTNodeStack();
    header.setTryBody(tryNode);

    CatchClause clause= (CatchClause) stmt.getCatchStatements().getFirstChild();
    while (clause != null)
    {
      // Push implicit exception.
      Node catchNode= graph.createNode(clause.getBeginIndex());
      // catchNode.type = NodeType.CATCH;
      catchNode.stack= new ASTNodeStack(new VariableBinding(clause.getException()));
      header.addCatchNode(catchNode);

      clause= (CatchClause) clause.getNextSibling();
View Full Code Here

  {
    Collection<Node> nodes= node.preds();
    Iterator iter= nodes.iterator();
    while (iter.hasNext())
    {
      Node n= (Node) iter.next();
      if (n.stack.size() == 0)
        iter.remove();
    }
    if (nodes.size() > 0)
    {
View Full Code Here

    }

    if (activeNodes.size() == 0)
    {

      Node node= graph.createNode(pc);
      setCurrentNode(node);
      return;
    }

    if (activeNodes.size() == 1)
    {

      Node node= activeNodes.get(0);
      setCurrentNode(node);
      return;
    }

    Node node= graph.getNode(pc);
    if (node == null)
      throw new RuntimeException("No node found at " + pc);

    setCurrentNode(node);
View Full Code Here

  {
    Expression expr= null;
    Iterator iter= sources.iterator();
    while (iter.hasNext())
    {
      Node node= (Node) iter.next();
      Expression e= (Expression) node.stack.get(index);
      if (expr == null)
      {
        expr= e;
      }
View Full Code Here

    logger.debug("Merging ...");

    Iterator iter= sources.iterator();
    while (iter.hasNext())
    {
      Node pred= (Node) iter.next();
      dump(pred.stack, "Stack for " + pred);
    }

    int stackSize= -1;

    iter= sources.iterator();
    while (iter.hasNext())
    {
      Node pred= (Node) iter.next();

      if (stackSize == -1)
      {
        stackSize= pred.stack.size();
      }
      else if (stackSize != pred.stack.size())
      {
        dump(sources);
        throw new RuntimeException("Stack size mismatch");
      }
    }

    for (int index= 0; index < stackSize; index++)
    {
      Object obj= stacksIdentical(sources, index);
      if (obj instanceof Expression)
      {
        target.add((Expression) ((Expression) obj).clone());
        logger.debug("\tIdentical: " + obj);
      }
      else
      {

        VariableBinding vb= methodDecl.createAnonymousVariableBinding((Type) obj, true);

        target.add(vb);

        iter= sources.iterator();
        while (iter.hasNext())
        {
          Node node= (Node) iter.next();
          Expression expr= (Expression) node.stack.get(index);

          Assignment a= new Assignment(Assignment.Operator.ASSIGN);
          a.setLeftHandSide((VariableBinding) vb.clone());
          if (expr instanceof VariableBinding)
View Full Code Here

TOP

Related Classes of com.dragome.compiler.graph.Node

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.