Пример #1
0
  /**
   * @see
   *     railo.transformer.bytecode.statement.StatementBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter)
   */
  public void _writeOut(BytecodeContext bc) throws BytecodeException {
    GeneratorAdapter adapter = bc.getAdapter();

    adapter.visitLabel(begin);

    // Reference ref=null;
    final int lRef = adapter.newLocal(Types.REFERENCE);
    adapter.visitInsn(Opcodes.ACONST_NULL);
    adapter.storeLocal(lRef);

    // has no try body, if there is no try body, no catches are executed, only finally
    if (!tryBody.hasStatements()) {
      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);
  }
Пример #2
0
  private void _writeOutFinally(BytecodeContext bc, int lRef) throws BytecodeException {
    // ref.remove(pc);
    // Reference r=null;
    GeneratorAdapter adapter = bc.getAdapter();

    // if(fcf!=null &&
    // fcf.getAfterFinalGOTOLabel()!=null)ASMUtil.visitLabel(adapter,fcf.getFinalEntryLabel());
    ExpressionUtil.visitLine(bc, finallyLine);

    // if (reference != null)
    //    reference.removeEL(pagecontext);
    Label removeEnd = new Label();
    adapter.loadLocal(lRef);
    adapter.ifNull(removeEnd);
    adapter.loadLocal(lRef);
    adapter.loadArg(0);
    adapter.invokeInterface(Types.REFERENCE, REMOVE_EL);
    adapter.pop();
    adapter.visitLabel(removeEnd);

    if (finallyBody != null) finallyBody.writeOut(bc); // finally
    /*if(fcf!=null){
    	Label l = fcf.getAfterFinalGOTOLabel();
    	if(l!=null)adapter.visitJumpInsn(Opcodes.GOTO, l);
    }*/
  }
Пример #3
0
 /**
  * sets finally body
  *
  * @param body
  */
 public void setFinally(Body body, Position finallyLine) {
   body.setParent(this);
   this.finallyBody = body;
   this.finallyLine = finallyLine;
 }
Пример #4
0
 /**
  * Constructor of the class
  *
  * @param body
  * @param line
  */
 public TryCatchFinally(Body body, Position start, Position end) {
   super(start, end);
   this.tryBody = body;
   body.setParent(this);
 }
Пример #5
0
 /**
  * @param type
  * @param name
  * @param body
  * @param line
  */
 public void addCatch(ExprString type, VariableRef name, Body body, Position line) {
   body.setParent(this);
   catches.add(new Catch(type, name, body, line));
 }