Package railo.transformer.bytecode.visitor

Examples of railo.transformer.bytecode.visitor.OnFinally


    // int count=0; 
    int count=adapter.newLocal(Types.INT_VALUE);
    adapter.push(0);
    adapter.storeLocal(count);
   
    TryFinallyVisitor tfv=new TryFinallyVisitor(new OnFinally() {
      public void writeOut(BytecodeContext bc) {
        bc.getAdapter().loadLocal(br);
        bc.getAdapter().invokeStatic(IO_UTIL, CLOSE_EL);
      }
    },null);
View Full Code Here


  public void _writeOut(BytecodeContext bc) throws BytecodeException {
    GeneratorAdapter adapter = bc.getAdapter();
   
    Stack<OnFinally> finallies = bc.getOnFinallyStack();
    int len=finallies.size();
    OnFinally onFinally;
   
    if(expr==null)ASMConstants.NULL(adapter);
    else expr.writeOut(bc, Expression.MODE_REF);
    if(len>0) {
      int rtn = adapter.newLocal(Types.OBJECT);
      adapter.storeLocal(rtn, Types.OBJECT);
      for(int i=len-1;i>=0;i--) {
       
        onFinally=finallies.get(i);
        onFinally.writeOut(bc);
      }
      adapter.loadLocal(rtn, Types.OBJECT);
    }
    if(bc.getMethod().getReturnType().equals(Types.VOID)) {
      adapter.pop();
View Full Code Here

      if(finallyBody!=null)finallyBody.writeOut(bc);
      return;
    }
   
   
    TryCatchFinallyVisitor tcfv=new TryCatchFinallyVisitor(new OnFinally() {
     
      public void writeOut(BytecodeContext bc) throws BytecodeException {
        _writeOutFinally(bc,lRef);
      }
    },getFlowControlFinal());
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());
View Full Code Here

      adapter.visitInsn(Opcodes.ISUB);
      adapter.storeLocal(current);
     
     
      // Try
      TryFinallyVisitor tfv=new TryFinallyVisitor(new OnFinally() {
        public void writeOut(BytecodeContext bc) {
          // query.reset();
         
          // query.go(startAt);
          adapter.loadLocal(tag.getQuery());
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);
View Full Code Here

    adapter.loadArg(0);
    adapter.invokeVirtual(Types.PAGE_CONTEXT, SET_SILENT);
    adapter.storeLocal(silentMode);
   
    // call must be
    TryFinallyVisitor tfv=new TryFinallyVisitor(new OnFinally() {
      public void writeOut(BytecodeContext bc) {
        //if(fcf!=null && fcf.getAfterFinalGOTOLabel()!=null)ASMUtil.visitLabel(adapter,fcf.getFinalEntryLabel());
        // if(!silentMode)pc.unsetSilent();
        Label _if=new Label();
        adapter.loadLocal(silentMode);
View Full Code Here

    adapter.push(tlt.getTagClassName());
    adapter.invokeVirtual(Types.PAGE_CONTEXT, USE);
    adapter.checkCast(currType);
    adapter.storeLocal(currLocal);
 
  TryFinallyVisitor outerTcfv=new TryFinallyVisitor(new OnFinally() {
    public void writeOut(BytecodeContext bc) {

      adapter.loadArg(0);
      adapter.loadLocal(currLocal);
      adapter.invokeVirtual(Types.PAGE_CONTEXT, RE_USE);
    }
  },null);
  if(doReuse)outerTcfv.visitTryBegin(bc);
   
  // appendix
    if(tlt.hasAppendix()) {
      adapter.loadLocal(currLocal);
      adapter.push(tag.getAppendix());
      adapter.invokeVirtual(currType, SET_APPENDIX);
    }
 
  // hasBody
    boolean hasBody=tag.getBody()!=null;
    if(tlt.isBodyFree() && tlt.hasBodyMethodExists()) {
      adapter.loadLocal(currLocal);
      adapter.push(hasBody);
      adapter.invokeVirtual(currType, HAS_BODY);
    }
   
  // attributes
    Attribute attr;
   
    // attributeCollection
    attr=tag.getAttribute("attributecollection");
    if(attr!=null){
      int attrType = tag.getTagLibTag().getAttributeType();
      if(TagLibTag.ATTRIBUTE_TYPE_NONAME!=attrType) {
        tag.removeAttribute("attributecollection");
        // TagUtil.setAttributeCollection(Tag, Struct)
        adapter.loadArg(0);
        adapter.loadLocal(currLocal);
        adapter.cast(currType, TAG);
       
        ///
        Map missings = tag.getMissingAttributes();
        if(missings.size()>0) {
          ArrayVisitor av=new ArrayVisitor();
                av.visitBegin(adapter,MISSING_ATTRIBUTE,missings.size());
                Map.Entry entry;
                int count=0;
                Iterator it = missings.entrySet().iterator();
                while(it.hasNext()){
                  entry=(Entry) it.next();
              av.visitBeginItem(adapter, count++);
                Variable.registerKey(bc, LitString.toExprString((String)entry.getKey()));
                adapter.push((String)entry.getValue());
                adapter.invokeStatic(MISSING_ATTRIBUTE, NEW_INSTANCE_MAX);
              av.visitEndItem(bc.getAdapter());
                }
                av.visitEnd();
        }
        else {
          ASMConstants.NULL(adapter);
        }
        ///
        attr.getValue().writeOut(bc, Expression.MODE_REF);
       
        adapter.push(attrType);
        adapter.invokeStatic(TAG_UTIL, SET_ATTRIBUTE_COLLECTION);
      }
    }


    // metadata
    Map<String, Attribute> metadata = tag.getMetaData();
    if(metadata!=null){
      Iterator<Attribute> it = metadata.values().iterator();
      while(it.hasNext()) {
        attr=it.next();
          adapter.loadLocal(currLocal);
          adapter.push(attr.getName());
          attr.getValue().writeOut(bc, Expression.MODE_REF);
          adapter.invokeVirtual(currType, SET_META_DATA);
      }
    }
   
   
   
    String methodName;
    Map attributes = tag.getAttributes();

    // static attributes
    Iterator it = attributes.values().iterator();
    while(it.hasNext()) {
      attr=(Attribute) it.next();
      if(!attr.isDynamicType()){
        Type type = CastOther.getType(attr.getType());
        methodName=tag.getTagLibTag().getSetter(attr,type);
        adapter.loadLocal(currLocal);
        attr.getValue().writeOut(bc, Types.isPrimitiveType(type)?Expression.MODE_VALUE:Expression.MODE_REF);
        adapter.invokeVirtual(currType, new Method(methodName,Type.VOID_TYPE,new Type[]{type}));
      }
    }
   
    // dynamic attributes
    it = attributes.values().iterator();
    while(it.hasNext()) {
      attr=(Attribute) it.next();
      if(attr.isDynamicType()){
        adapter.loadLocal(currLocal);
        adapter.visitInsn(Opcodes.ACONST_NULL);
        //adapter.push(attr.getName());
        Variable.registerKey(bc, LitString.toExprString(attr.getName()));
        attr.getValue().writeOut(bc, Expression.MODE_REF);
        adapter.invokeVirtual(currType, SET_DYNAMIC_ATTRIBUTE);
      }
    }
   
   
  // Body
    if(hasBody){
      final int state=adapter.newLocal(Types.INT_VALUE);
     
      // int state=tag.doStartTag();
      adapter.loadLocal(currLocal);
      adapter.invokeVirtual(currType, DO_START_TAG);
      adapter.storeLocal(state);
     
      // if (state!=Tag.SKIP_BODY)
      Label endBody=new Label();
      adapter.loadLocal(state);
      adapter.push(javax.servlet.jsp.tagext.Tag.SKIP_BODY);
      adapter.visitJumpInsn(Opcodes.IF_ICMPEQ, endBody);
        // pc.initBody(tag, state);
        adapter.loadArg(0);
        adapter.loadLocal(currLocal);
        adapter.loadLocal(state);
        adapter.invokeVirtual(Types.PAGE_CONTEXT, INIT_BODY);
       
       
        OnFinally onFinally = new OnFinally() {
         
          public void writeOut(BytecodeContext bc) {
            Label endIf = new Label();
            /*if(tlt.handleException() && fcf!=null && fcf.getAfterFinalGOTOLabel()!=null){
              ASMUtil.visitLabel(adapter, fcf.getFinalEntryLabel());
View Full Code Here

      value.writeOut(bc, Expression.MODE_REF);
      adapter.invokeStatic(FOR_EACH_UTIL, TO_ITERATOR);
      //adapter.invokeStatic(COLLECTION_UTIL, TO_ITERATOR);
      // Iterator it=...
      adapter.storeLocal(it);
      TryFinallyVisitor tfv=new TryFinallyVisitor(new OnFinally() {
       
        @Override
        public void writeOut(BytecodeContext bc) throws BytecodeException {
          GeneratorAdapter a = bc.getAdapter();
          //if(fcf!=null && fcf.getAfterFinalGOTOLabel()!=null)ASMUtil.visitLabel(a,fcf.getFinalEntryLabel());
View Full Code Here

TOP

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

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.