Package com.dragome.compiler.ast

Examples of com.dragome.compiler.ast.Block


    String signatureReplaced= normalizeExpression(signature);

    if (typeDecl.getClassName().equals("java.lang.String") && method.isInstanceConstructor())
    {

      Block body= method.getBody();

      body.removeChild(body.getFirstChild());

      MethodInvocation consume= (MethodInvocation) body.getLastChild();
      body.removeChild(consume);

      ReturnStatement r= new ReturnStatement(0, 0);
      r.setExpression((Expression) consume.getArguments().get(0));
      body.appendChild(r);

      print("_dragomeJs.StringInit" + signatureReplaced + " = function(");
      closingString= "};\n";
    }
    else
View Full Code Here


  public void visit(TryStatement tryStmt)
  {
    println("try {");
    visit_(tryStmt.getTryBlock());
    indent("} ");
    Block clauses= tryStmt.getCatchStatements();
    CatchClause clause= (CatchClause) clauses.getFirstChild();

    String ex= null;
    if (clause != null)
    {
      ex= clause.getException().getName();
    }

    //  if (clauses.getChildCount() == 1)
    //  {
    //      print("catch(" + ex + ") ");
    //      clause.visit(this);
    //  }
    if (clauses.getChildCount() > 0)
    {
      println("catch(" + ex + ") {");
      depth++;
      indent();
      while (clause != null)
      {
        if (clause.getException().getType() != null)
          print("if (dragomeJs.isInstanceof(" + ex + ", " + normalizeExpression(Utils.getSignature(clause.getException().getType())) + ")) ");
        else
          print("if (true)");

        clause.visit(this);
        clause= (CatchClause) clause.getNextSibling();
        if (clause == null)
          break;
        print(" else ");
      }

      print(" else throw dragomeJs.nullSaveException(" + ex + "); ");

      println("");
      depth--;
      indent("}");
    }

    Block finallyBlock= tryStmt.getFinallyBlock();
    if (finallyBlock != null)
    {
      println(" finally {");
      visit_(finallyBlock);
      indent("}");
View Full Code Here

    return getNodes().size();
  }

  public Block reduceDumb()
  {
    Block block= new Block();

    for (Node node : getNodes())
    {
      block.appendChild(node.block);

      if (node.isBranch())
      {
        IfStatement ifStmt= new IfStatement();
        ConditionalEdge cEdge= node.getConditionalEdge(true);
        ifStmt.setExpression(cEdge.getBooleanExpression().getExpression());
        ifStmt.setIfBlock(new Block());
        Block targetBlock= cEdge.target.block;
        ifStmt.getIfBlock().appendChild(new BreakStatement(targetBlock));
        ifStmt.setElseBlock(new Block());
        targetBlock= node.getConditionalEdge(false).target.block;
        ifStmt.getElseBlock().appendChild(new BreakStatement(targetBlock));
        block.appendChild(ifStmt);
      }
      else
View Full Code Here

  {
    int pc= node.getInitialPc();
    for (int i= 0; i < tryStatements.size(); i++)
    {
      TryStatement tryStmt= (TryStatement) tryStatements.get(i);
      Block block= tryStmt.getTryBlock();
      if (pc >= block.getBeginIndex() && pc <= block.getEndIndex())
        return tryStmt;
    }
    return null;
  }
View Full Code Here

    if (size() != 1)
    {
      //throw new RuntimeException("Could not reduce graph");
    }

    Block block= new Block();

    rollOut(getSource(), block);

    return block;
  }
View Full Code Here

    graph.removeNode(tryBodyNode);

    finallyNode= head.getFinallyNode();
    if (finallyNode != null)
    {
      Block b= finallyNode.block;

      b.removeChild(b.getFirstChild());

      b.removeChild(b.getLastChild());
      graph.rerootOutEdges(finallyNode, newNode, false);
      graph.removeInEdges(finallyNode);
      graph.removeNode(finallyNode);
    }
View Full Code Here

    graph.rollOut(tryBodyNode, stmt.getTryBlock());

    if (finallyNode != null)
    {
      stmt.setFinallyBlock(new Block());
      graph.rollOut(finallyNode, stmt.getFinallyBlock());
    }

    CatchClause cc= (CatchClause) stmt.getCatchStatements().getFirstChild();
    Iterator iter= catchNodes.iterator();
View Full Code Here

  }

  void rollOut_(Block block)
  {
    WhileStatement loopStmt= new WhileStatement();
    Block loopBody= new Block();
    loopStmt.setBlock(loopBody);
    loopStmt.setExpression(new BooleanLiteral(true));

    block.appendChild(loopStmt);
View Full Code Here

  }

  void produceJump(Edge edge, Block labeledBlock)
  {
    Node referer= edge.getOrgSource();
    Block breakBlock;
    if (edge instanceof ConditionalEdge)
    {
      ConditionalEdge condEdge= (ConditionalEdge) edge;
      BooleanExpression condExpr= condEdge.getBooleanExpression();
      Expression expr= Optimizer.simplifyBooleanExpression(condExpr.getExpression(), condEdge.isNegate());
      IfStatement ifStmt= new IfStatement();
      ifStmt.setExpression(expr);
      referer.block.appendChild(ifStmt);
      Block ifBlock= new Block();
      ifStmt.setIfBlock(ifBlock);
      breakBlock= ifBlock;
    }
    else
    {
View Full Code Here

    graph.removeNode(tail);
  }

  void rollOut_(Block block)
  {
    Block labeledBlock= block;

    Iterator iter= inEdgesForTail.iterator();
    while (iter.hasNext())
    {
      Edge edge= (Edge) iter.next();
      if (!edge.isGlobal())
        continue;

      if (labeledBlock == block)
      {
        labeledBlock= new Block();
        block.appendChild(labeledBlock);
      }

      produceJump(edge, labeledBlock);
    }
View Full Code Here

TOP

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

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.