本文整理汇总了Java中sun.tools.asm.CatchData类的典型用法代码示例。如果您正苦于以下问题:Java CatchData类的具体用法?Java CatchData怎么用?Java CatchData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CatchData类属于sun.tools.asm包,在下文中一共展示了CatchData类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: code
import sun.tools.asm.CatchData; //导入依赖的package包/类
/**
* Code
*/
public void code(Environment env, Context ctx, Assembler asm) {
CodeContext newctx = new CodeContext(ctx, this);
TryData td = new TryData();
for (int i = 0 ; i < args.length ; i++) {
Type t = ((CatchStatement)args[i]).field.getType();
if (t.isType(TC_CLASS)) {
td.add(env.getClassDeclaration(t));
} else {
td.add(t);
}
}
asm.add(where, opc_try, td);
if (body != null) {
body.code(env, newctx, asm);
}
asm.add(td.getEndLabel());
asm.add(where, opc_goto, newctx.breakLabel);
for (int i = 0 ; i < args.length ; i++) {
CatchData cd = td.getCatch(i);
asm.add(cd.getLabel());
args[i].code(env, newctx, asm);
asm.add(where, opc_goto, newctx.breakLabel);
}
asm.add(newctx.breakLabel);
}
示例2: code
import sun.tools.asm.CatchData; //导入依赖的package包/类
/**
* Code
*/
public void code(Environment env, Context ctx, Assembler asm) {
ClassDefinition clazz = ctx.field.getClassDefinition();
expr.codeValue(env, ctx, asm);
ctx = new Context(ctx);
if (needReturnSlot) {
Type returnType = ctx.field.getType().getReturnType();
LocalMember localfield = new LocalMember(0, clazz, 0, returnType,
idFinallyReturnValue);
ctx.declare(env, localfield);
env.debugOutput("Assigning return slot to " + localfield.number);
}
LocalMember f1 = new LocalMember(where, clazz, 0, Type.tObject, null);
LocalMember f2 = new LocalMember(where, clazz, 0, Type.tInt, null);
Integer num1 = new Integer(ctx.declare(env, f1));
Integer num2 = new Integer(ctx.declare(env, f2));
Label endLabel = new Label();
TryData td = new TryData();
td.add(null);
// lock the object
asm.add(where, opc_astore, num1);
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorenter);
// Main body
CodeContext bodyctx = new CodeContext(ctx, this);
asm.add(where, opc_try, td);
if (body != null) {
body.code(env, bodyctx, asm);
} else {
asm.add(where, opc_nop);
}
asm.add(bodyctx.breakLabel);
asm.add(td.getEndLabel());
// Cleanup afer body
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_goto, endLabel);
// Catch code
CatchData cd = td.getCatch(0);
asm.add(cd.getLabel());
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_athrow);
// Final body
asm.add(bodyctx.contLabel);
asm.add(where, opc_astore, num2);
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_ret, num2);
asm.add(endLabel);
}
示例3: code
import sun.tools.asm.CatchData; //导入依赖的package包/类
/**
* Code
*/
public void code(Environment env, Context ctx, Assembler asm) {
ClassDefinition clazz = ctx.field.getClassDefinition();
expr.codeValue(env, ctx, asm);
ctx = new Context(ctx);
if (needReturnSlot) {
Type returnType = ctx.field.getType().getReturnType();
LocalMember localfield = new LocalMember(0, clazz, 0, returnType,
idFinallyReturnValue);
ctx.declare(env, localfield);
Environment.debugOutput("Assigning return slot to " + localfield.number);
}
LocalMember f1 = new LocalMember(where, clazz, 0, Type.tObject, null);
LocalMember f2 = new LocalMember(where, clazz, 0, Type.tInt, null);
Integer num1 = ctx.declare(env, f1);
Integer num2 = ctx.declare(env, f2);
Label endLabel = new Label();
TryData td = new TryData();
td.add(null);
// lock the object
asm.add(where, opc_astore, num1);
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorenter);
// Main body
CodeContext bodyctx = new CodeContext(ctx, this);
asm.add(where, opc_try, td);
if (body != null) {
body.code(env, bodyctx, asm);
} else {
asm.add(where, opc_nop);
}
asm.add(bodyctx.breakLabel);
asm.add(td.getEndLabel());
// Cleanup afer body
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_goto, endLabel);
// Catch code
CatchData cd = td.getCatch(0);
asm.add(cd.getLabel());
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_athrow);
// Final body
asm.add(bodyctx.contLabel);
asm.add(where, opc_astore, num2);
asm.add(where, opc_aload, num1);
asm.add(where, opc_monitorexit);
asm.add(where, opc_ret, num2);
asm.add(endLabel);
}