Package railo.transformer.bytecode

Examples of railo.transformer.bytecode.Body


          printOut.setCheckPSQ(true);
          if(e!=expr)printOut.setExpr(expr);
        }
      }
      else if(stat instanceof Tag){
        Body b=((Tag)stat).getBody();
        if(b!=null)
          translateChildren(b.getStatements().iterator());
      }
      else if(stat instanceof Body){
        translateChildren(((Body)stat).getStatements().iterator());
      }
    }
View Full Code Here


   * @see railo.transformer.bytecode.statement.tag.TagBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter)
   */
  public void _writeOut(BytecodeContext bc) throws BytecodeException {
    GeneratorAdapter adapter = bc.getAdapter();
    adapter.visitLabel(begin);
    Body tryBody=new BodyBase();
    List<Tag> catches=new ArrayList<Tag>();
    Tag tmpFinal=null;

    tryBody.setParent(getBody().getParent());
   
    List<Statement> statements = getBody().getStatements();
    Statement stat;
    Tag tag;
    {
    Iterator<Statement> it = statements.iterator();
    while(it.hasNext()) {
      stat= it.next();
      if(stat instanceof Tag) {
        tag=(Tag) stat;
        if(tag.getTagLibTag().getTagClassName().equals("railo.runtime.tag.Catch"))  {
          catches.add(tag);
          continue;
        }
        else if(tag.getTagLibTag().getTagClassName().equals("railo.runtime.tag.Finally"))  {
          tmpFinal=tag;
          continue;
        }
      }
      tryBody.addStatement(stat);
    };
    }
    final Tag _finally=tmpFinal;
   
    // has no try body, if there is no try body, no catches are executed, only finally
    if(!tryBody.hasStatements()) {
     
      if(_finally!=null && _finally.getBody()!=null)_finally.getBody().writeOut(bc);
      return;
    }
    TryCatchFinallyVisitor tcfv=new TryCatchFinallyVisitor(new OnFinally() {
     
      public void writeOut(BytecodeContext bc) throws BytecodeException {
        /*GeneratorAdapter ga = bc.getAdapter();
        if(fcf!=null && fcf.getAfterFinalGOTOLabel()!=null)
          ASMUtil.visitLabel(ga,fcf.getFinalEntryLabel());
        */
        if(_finally!=null) {
         
          ExpressionUtil.visitLine(bc, _finally.getStart());
          _finally.getBody().writeOut(bc);
         
        }
        /*if(fcf!=null){
          Label l=fcf.getAfterFinalGOTOLabel();
          if(l!=null)ga.visitJumpInsn(Opcodes.GOTO, l);
        }*/
      }
    },getFlowControlFinal());
   
   
    // Try
    tcfv.visitTryBegin(bc);
      tryBody.writeOut(bc);
    int e=tcfv.visitTryEndCatchBeging(bc);
      // if(e instanceof railo.runtime.exp.Abort) throw e;
      Label abortEnd=new Label();
      adapter.loadLocal(e);
      // Abort.isAbort(t);
View Full Code Here

  public void _writeOut(BytecodeContext bc) throws BytecodeException {
    _writeOut(bc,Function.PAGE_TYPE_REGULAR);
  }

  public void _writeOut(BytecodeContext bc, int type) throws BytecodeException {
    Body functionBody = new BodyBase();
    Function func = createFunction(bc.getPage(),functionBody);
    func.setParent(getParent());

    List<Statement> statements = getBody().getStatements();
    Statement stat;
    Tag tag;
   
    // supress WS between cffunction and the last cfargument
    Tag last=null;
    if(bc.getSupressWSbeforeArg()){
      // check if there is a cfargument at all
      Iterator<Statement> it = statements.iterator();
      while (it.hasNext()) {
        stat = it.next();
        if (stat instanceof Tag) {
          tag = (Tag) stat;
          if (tag.getTagLibTag().getTagClassName().equals("railo.runtime.tag.Argument")) {
            last=tag;
          }
        }
      }
     
      // check if there are only literal WS printouts
      if(last!=null) {
        it = statements.iterator();
        while (it.hasNext()) {
          stat = it.next();
          if(stat==last) break;
         
          if(stat instanceof PrintOut){
            PrintOut po=(PrintOut) stat;
            Expression expr = po.getExpr();
            if(!(expr instanceof LitString) || !StringUtil.isWhiteSpace(((LitString)expr).getString())) {
              last=null;
              break;
            }
          }
        }
      }
    }
   
   
   
    Iterator<Statement> it = statements.iterator();
    boolean beforeLastArgument=last!=null;
    while (it.hasNext()) {
      stat = it.next();
      if(beforeLastArgument) {
        if(stat==last) {
          beforeLastArgument=false;
        }
        else if(stat instanceof PrintOut){
          PrintOut po=(PrintOut) stat;
          Expression expr = po.getExpr();
          if(expr instanceof LitString) {
            LitString ls=(LitString) expr;
            if(StringUtil.isWhiteSpace(ls.getString())) continue;
          }
        }
       
      }
      if (stat instanceof Tag) {
        tag = (Tag) stat;
        if (tag.getTagLibTag().getTagClassName().equals(
            "railo.runtime.tag.Argument")) {
          addArgument(func, tag);
          continue;
        }
      }
      functionBody.addStatement(stat);
    }
    func._writeOut(bc,type);

  }
View Full Code Here

 
  /**
   * @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(Element)
   */
  public void evaluate(Tag tag) throws EvaluatorException {
    Body body=tag.getBody();
        int catchCount=0;
        int noCatchCount=0;
        int finallyCount=0;
       
        // count catch tag and other in body
        if(body!=null) {
          List stats = body.getStatements();
        Iterator it = stats.iterator();
          Statement stat;
          Tag t;
            String name;
            while(it.hasNext()) {
View Full Code Here

  }

  public void _writeOut(BytecodeContext bc) throws BytecodeException {
    GeneratorAdapter adapter = bc.getAdapter();
    Label end = new Label();
    Body ifBody=getBody();
   
    List stats = ifBody.getStatements();
    Iterator it = stats.iterator();
    Tag t;
    Label endIf=writeOutElseIfStart(bc, this);
    boolean hasElse=false;
    while(it.hasNext()) {
View Full Code Here

TOP

Related Classes of railo.transformer.bytecode.Body

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.