Package railo.transformer.bytecode.visitor

Examples of railo.transformer.bytecode.visitor.TryCatchFinallyVisitor


      if(finallyBody!=null)finallyBody.writeOut(bc);
      return;
    }
   
   
    TryCatchFinallyVisitor tcfv=new TryCatchFinallyVisitor(new OnFinally() {
     
      public void writeOut(BytecodeContext bc) throws BytecodeException {
        _writeOutFinally(bc,lRef);
      }
    },getFlowControlFinal());

    // try
    tcfv.visitTryBegin(bc);
      tryBody.writeOut(bc);
    int lThrow = tcfv.visitTryEndCatchBeging(bc);
      _writeOutCatch(bc, lRef, lThrow);
    tcfv.visitCatchEnd(bc);
   
  }
View Full Code Here


    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);
      adapter.invokeStatic(Types.ABORT, TryCatchFinally.IS_ABORT);
      //adapter.instanceOf(Types.ABORT);
     
     
     
          adapter.ifZCmp(Opcodes.IFEQ, abortEnd);
            adapter.loadLocal(e);
            adapter.throwException();
          adapter.visitLabel(abortEnd);
       

          // PageExceptionImpl old=pc.getCatch();
          int old=adapter.newLocal(Types.PAGE_EXCEPTION);
          adapter.loadArg(0);
          adapter.invokeVirtual(Types.PAGE_CONTEXT, GET_CATCH);
      adapter.storeLocal(old);
     
          // PageException pe=Caster.toPageEception(e);
          int pe=adapter.newLocal(Types.PAGE_EXCEPTION);
          adapter.loadLocal(e);
          adapter.invokeStatic(Types.CASTER, TO_PAGE_EXCEPTION);
      adapter.storeLocal(pe);
     
      Iterator<Tag> it = catches.iterator();
      Attribute attrType;
      Expression type;
      Label endAllIfs=new Label();
      Tag tagElse=null;
      while(it.hasNext()) {
        tag=it.next();
        Label endIf=new Label();
        attrType = tag.getAttribute("type");
        type=ANY;
        if(attrType!=null)type=attrType.getValue();

        if(type instanceof LitString && ((LitString)type).getString().equalsIgnoreCase("any")){
          tagElse=tag;
          continue;
        }
       
        ExpressionUtil.visitLine(bc, tag.getStart());
       
        // if(pe.typeEqual(@type)
        adapter.loadLocal(pe);
        type.writeOut(bc, Expression.MODE_REF);
        adapter.invokeVirtual(Types.PAGE_EXCEPTION, TYPE_EQUAL);
       
        adapter.ifZCmp(Opcodes.IFEQ, endIf);
          catchBody(bc,adapter,tag,pe,true,true);
         
              adapter.visitJumpInsn(Opcodes.GOTO, endAllIfs);
             
              adapter.visitLabel(endIf);
       
       
      }
      // else
      if(tagElse!=null){
        catchBody(bc, adapter, tagElse, pe, true,true);
      }
      else{
        // pc.setCatch(pe,true);
        adapter.loadArg(0);
            adapter.loadLocal(pe);
            adapter.push(false);
            adapter.push(true);
            adapter.invokeVirtual(Types.PAGE_CONTEXT, SET_CATCH3);
       
        //throw pe;
        adapter.loadLocal(pe);
        adapter.throwException();
      }
      adapter.visitLabel(endAllIfs);
     
   
    // PageExceptionImpl old=pc.getCatch();
        adapter.loadArg(0);
        adapter.loadLocal(old);
        adapter.invokeVirtual(Types.PAGE_CONTEXT, SET_CATCH_PE);
     
    tcfv.visitCatchEnd(bc);
  }
View Full Code Here

      adapter.push(Undefined.MODE_NO_LOCAL_AND_ARGUMENTS);
      adapter.invokeInterface(Types.UNDEFINED, SET_MODE);
      adapter.storeLocal(oldCheckArgs);
   
     
    TryCatchFinallyVisitor tcf=new TryCatchFinallyVisitor(new OnFinally() {
     
      public void writeOut(BytecodeContext bc) {

        // undefined.setMode(oldMode);
        adapter.loadArg(0);
        adapter.invokeVirtual(Types.PAGE_CONTEXT, UNDEFINED_SCOPE);
        adapter.loadLocal(oldCheckArgs,Types.INT_VALUE);
        adapter.invokeInterface(Types.UNDEFINED, SET_MODE);
        adapter.pop();
       
          // c.afterCall(pc,_oldData);
          adapter.loadArg(1);
          adapter.loadArg(0);
          adapter.loadLocal(oldData);
          adapter.invokeVirtual(Types.COMPONENT_IMPL, AFTER_CALL);
       
       
      }
    },null);
    tcf.visitTryBegin(bc);
      // oldData=c.beforeCall(pc);
      adapter.loadArg(1);
      adapter.loadArg(0);
      adapter.invokeVirtual(Types.COMPONENT_IMPL, BEFORE_CALL);
      adapter.storeLocal(oldData);
      ExpressionUtil.visitLine(bc, component.getStart());
      writeOutCallBody(bc,component.getBody(),IFunction.PAGE_TYPE_COMPONENT);
      ExpressionUtil.visitLine(bc, component.getEnd());
    int t = tcf.visitTryEndCatchBeging(bc);
      // BodyContentUtil.flushAndPop(pc,bc);
      adapter.loadArg(0);
      adapter.loadLocal(localBC);
      adapter.invokeStatic(Types.BODY_CONTENT_UTIL, FLUSH_AND_POP);
   
      // throw Caster.toPageException(t);
      adapter.loadLocal(t);
      adapter.invokeStatic(Types.CASTER, TO_PAGE_EXCEPTION);
      adapter.throwException();
    tcf.visitCatchEnd(bc);
   
    adapter.loadArg(0);
    adapter.loadLocal(localBC);
    adapter.invokeStatic(Types.BODY_CONTENT_UTIL, CLEAR_AND_POP);
 
View Full Code Here

          }
        };
       
       
        if(tlt.handleException()) {
          TryCatchFinallyVisitor tcfv=new TryCatchFinallyVisitor(onFinally,fcf);
          tcfv.visitTryBegin(bc);
            doTry(bc,adapter,tag,currLocal,currType);
          int t=tcfv.visitTryEndCatchBeging(bc);
            // tag.doCatch(t);
            adapter.loadLocal(currLocal);
            adapter.loadLocal(t);
            //adapter.visitVarInsn(Opcodes.ALOAD,t);
            adapter.invokeVirtual(currType, DO_CATCH);
          tcfv.visitCatchEnd(bc);
        }
        else {
          TryFinallyVisitor tfv=new TryFinallyVisitor(onFinally,fcf);
          tfv.visitTryBegin(bc);
            doTry(bc,adapter,tag,currLocal,currType);
View Full Code Here

TOP

Related Classes of railo.transformer.bytecode.visitor.TryCatchFinallyVisitor

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.