Package anvil.codec

Examples of anvil.codec.ExceptionHandler


        "push", "(Lanvil/core/Any;)V"));

      _framelocal = code.addLocal();
      code.astore(_framelocal);

      ExceptionHandler handler = code.startExceptionHandler(true);
      _handler = handler;
      Target tostart = code.getTarget();
      if (_start != null) {
        _start.compile(context, Node.GET_BOOLEAN);
        Source istrue = code.if_ne();
        handler.callFinally();
        handler.jumpOut();
        istrue.bind();
      }
      if (_statement != null) {
        _statement.compile(context);
      }
      if (_end != null) {
        _end.compile(context, Node.GET_BOOLEAN);
        code.if_ne(tostart);
      }
      handler.endTry();
      if (_statement == null || !_statement.isBlocked()) {
        handler.callFinally();
        handler.jumpOut();
      }
      handler.endProtectedRegion();

      handler.startCatch(0);
      int thrown = code.addLocal();
      code.astore(thrown);
      handler.callFinally();
      code.aload(thrown);
      code.athrow();
      handler.endCatches();
       _handler = null;

      // finally
      handler.startFinally();
      int returnto = code.addLocal();
      code.astore(returnto);
      code.aload_first();
      code.invokevirtual(contextframe);
      code.invokevirtual(pool.addMethodRef("anvil/script/StackFrame",
        "pop", "()Lanvil/core/Any;"));
      code.pop();
      if (_release != null) {
        _release.compile(context, Node.GET);
        code.pop();
      }
      code.ret(returnto);
      handler.endFinally();
      handler.end();
     
      code.endLocal(_framelocal);
     
    } else {
      if (_init != null) {
View Full Code Here


    int lock = code.addLocal();
    _expression.compile(context, Expression.GET);
    code.astore(lock);
    code.aload(lock);
    code.monitorenter();
    ExceptionHandler handler = code.startExceptionHandler(true);
    _handler = handler;
    if (_statement == null) {
      code.nop();
    } else {
      _statement.compile(context);
    }
    handler.endTry();
    if (!_statement.isBlocked()) {
      handler.callFinally();
      handler.jumpOut();
    }
    handler.endProtectedRegion();
    handler.startCatch(0);
    int thrown = code.addLocal();
    code.astore(thrown);
    handler.callFinally();
    code.aload(thrown);
    code.athrow();
    handler.endCatches();
    _handler = null;

    handler.startFinally();
    int returnto = code.addLocal();
    code.astore(returnto);
    code.aload(lock);
    code.monitorexit();
    code.ret(returnto);
    handler.endFinally();

    handler.end();
    code.endLocal(lock);
  }
View Full Code Here

    boolean has_try = (_catches > 0) || (_finally != null);
    if (has_try) {
      Code code = context.getCode();

      // try
      ExceptionHandler handler = code.startExceptionHandler(_finally != null);
      _handler = handler;
      if (_statement == EMPTY) {
        code.nop();
      } else {
        _statement.compile(context);
      }
      handler.endTry();
      if (!_statement.isBlocked()) {
        handler.callFinally();
        handler.jumpOut();
      }

      // catch
      if (_catches > 0) {
        handler.startCatch(code.getPool().addClass("anvil/script/ScriptException"));
        int l_throwable = code.addLocal();
        int l_data = code.addLocal();
        code.astore(l_throwable);
        code.aload(l_throwable);
        code.invokevirtual(code.getPool().addMethodRef("anvil/script/ScriptException", "getData", "()Lanvil/core/Any;"));
        code.astore(l_data);
        for(int i=0; i<_catches; i++) {
          _catch[i].compile(context, handler, l_data);
        }
        code.aload(l_throwable);
        code.athrow();
      }

      handler.endProtectedRegion();

      if (_finally != null) {
        handler.startCatch(0);
        int thrown = code.addLocal();
        code.astore(thrown);
        handler.callFinally();
        code.aload(thrown);
        code.athrow();
      }
      handler.endCatches();
      _handler = null;

      // finally
      if (_finally != null) {
        handler.startFinally();
        int returnto = code.addLocal();
        code.astore(returnto);
        _finally.compile(context);
        if (!_finally.isBlocked()) {
          code.ret(returnto);
        }
        handler.endFinally();
      }
     
      handler.end();
     
    } else {
      _statement.compile(context);
    }
  }
View Full Code Here

TOP

Related Classes of anvil.codec.ExceptionHandler

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.