}
}
public void compile(ByteCompiler context)
{
Code code = context.getCode();
ConstantPool pool = code.getPool();
boolean needloop =
(_start != null) ||
(_end != null) ||
(_release != null) ||
(_statement != null);
if (needloop) {
if (_init != null) {
_init.compile(context, Node.GET);
} else {
code.getstatic(pool.addFieldRef(context.TYPE_ANY, "UNDEFINED",
"Lanvil/core/Any;"));
}
code.dup();
int contextframe = pool.addMethodRef(context.TYPE_CONTEXT, "frame",
"()Lanvil/script/StackFrame;");
code.aload_first();
code.invokevirtual(contextframe);
code.swap();
code.invokevirtual(pool.addMethodRef("anvil/script/StackFrame",
"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) {
_init.compile(context, Node.GET);
code.pop();
}
}
}