Example #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);
  }