use of controlP5.Label in project jodd by oblac.
the class ProxettaAsmUtil method visitReturn.
// ---------------------------------------------------------------- return
/**
* Visits return opcodes.
*/
public static void visitReturn(MethodVisitor mv, MethodInfo methodInfo, boolean isLast) {
switch(methodInfo.getReturnOpcodeType()) {
case 'V':
if (isLast) {
mv.visitInsn(POP);
}
mv.visitInsn(RETURN);
break;
case 'B':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.byteValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'C':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.charValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'S':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.shortValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'I':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.intValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'Z':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(ICONST_0);
mv.visitInsn(IRETURN);
mv.visitLabel(label);
AsmUtil.booleanValue(mv);
}
mv.visitInsn(IRETURN);
break;
case 'J':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(LCONST_0);
mv.visitInsn(LRETURN);
mv.visitLabel(label);
AsmUtil.longValue(mv);
}
mv.visitInsn(LRETURN);
break;
case 'F':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(FCONST_0);
mv.visitInsn(FRETURN);
mv.visitLabel(label);
AsmUtil.floatValue(mv);
}
mv.visitInsn(FRETURN);
break;
case 'D':
if (isLast) {
mv.visitInsn(DUP);
Label label = new Label();
mv.visitJumpInsn(IFNONNULL, label);
mv.visitInsn(POP);
mv.visitInsn(DCONST_0);
mv.visitInsn(DRETURN);
mv.visitLabel(label);
AsmUtil.doubleValue(mv);
}
mv.visitInsn(DRETURN);
break;
default:
mv.visitInsn(ARETURN);
break;
}
}
use of controlP5.Label in project intellij-community by JetBrains.
the class AdvancedEnhancer method emitBindCallbacks.
private void emitBindCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.PRIVATE_FINAL_STATIC, BIND_CALLBACKS, null);
Local me = e.make_local();
e.load_arg(0);
e.checkcast_this();
e.store_local(me);
$Label end = e.make_label();
e.load_local(me);
e.getfield(BOUND_FIELD);
e.if_jump(e.NE, end);
e.load_local(me);
e.push(1);
e.putfield(BOUND_FIELD);
e.getfield(THREAD_CALLBACKS_FIELD);
e.invoke_virtual(THREAD_LOCAL, THREAD_LOCAL_GET);
e.dup();
$Label found_callback = e.make_label();
e.ifnonnull(found_callback);
e.pop();
e.getfield(STATIC_CALLBACKS_FIELD);
e.dup();
e.ifnonnull(found_callback);
e.pop();
e.goTo(end);
e.mark(found_callback);
e.checkcast(CALLBACK_ARRAY);
e.load_local(me);
e.swap();
for (int i = callbackTypes.length - 1; i >= 0; i--) {
if (i != 0) {
e.dup2();
}
e.aaload(i);
e.checkcast(callbackTypes[i]);
e.putfield(getCallbackField(i));
}
e.mark(end);
e.return_value();
e.end_method();
}
use of controlP5.Label in project tomee by apache.
the class Cmp2Generator method createOpenEJB_removeCmr.
// private void createPrintln(MethodVisitor mv, String message) {
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitLdcInsn(message);
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
// }
// private void createPrintField(MethodVisitor mv, String fieldName, String descriptor) {
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitLdcInsn(fieldName + "=");
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V");
//
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETFIELD, implClassName, fieldName, descriptor);
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V");
// }
/**
* Emit the remove logic for an individual CMR field.
* Like the addCmr logic, each field is guarded by an
* if test on the property name.
*
* @param mv
* @param cmrField
*/
private void createOpenEJB_removeCmr(final MethodVisitor mv, final CmrField cmrField) {
// if (${cmrField.name}.equals(arg1))
mv.visitLdcInsn(cmrField.getName());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false);
// if not equal jump to end
final Label end = new Label();
mv.visitJumpInsn(IFEQ, end);
// collection valued CMR field. Remove the object from the collection.
if (cmrField.getCmrStyle() != CmrStyle.SINGLE) {
// ${cmrField.name}.remove(arg2)
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEINTERFACE, cmrField.getCmrStyle().getCollectionType().getInternalName(), "remove", "(Ljava/lang/Object;)Z", true);
mv.visitInsn(POP);
// return;
mv.visitInsn(RETURN);
} else {
// single valued, so just null out the field.
// this.${cmrField.name} = null;
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
mv.visitFieldInsn(PUTFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
// return;
mv.visitInsn(RETURN);
}
// end of if statement
mv.visitLabel(end);
}
use of controlP5.Label in project tomee by apache.
the class MakeTxLookup method createNewHibernateStrategy.
private static void createNewHibernateStrategy(final File basedir, final String target, final String abstractJtaPlatformPackage) throws Exception {
final ClassWriter cw = new ClassWriter(0);
MethodVisitor mv;
cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, target.replace('.', '/'), null, abstractJtaPlatformPackage + "/AbstractJtaPlatform", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, abstractJtaPlatformPackage + "/AbstractJtaPlatform", "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PROTECTED, "locateTransactionManager", "()Ljavax/transaction/TransactionManager;", null, null);
mv.visitCode();
mv.visitMethodInsn(INVOKESTATIC, "org/apache/openejb/OpenEJB", "getTransactionManager", "()Ljavax/transaction/TransactionManager;", false);
mv.visitInsn(ARETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PROTECTED, "locateUserTransaction", "()Ljavax/transaction/UserTransaction;", null, null);
mv.visitCode();
final Label l0 = new Label();
final Label l1 = new Label();
final Label l2 = new Label();
mv.visitTryCatchBlock(l0, l1, l2, "javax/naming/NamingException");
mv.visitLabel(l0);
mv.visitMethodInsn(INVOKESTATIC, "org/apache/openejb/loader/SystemInstance", "get", "()Lorg/apache/openejb/loader/SystemInstance;", false);
mv.visitLdcInsn(Type.getType("Lorg/apache/openejb/spi/ContainerSystem;"));
mv.visitMethodInsn(INVOKEVIRTUAL, "org/apache/openejb/loader/SystemInstance", "getComponent", "(Ljava/lang/Class;)Ljava/lang/Object;", false);
mv.visitTypeInsn(CHECKCAST, "org/apache/openejb/spi/ContainerSystem");
mv.visitMethodInsn(INVOKEINTERFACE, "org/apache/openejb/spi/ContainerSystem", "getJNDIContext", "()Ljavax/naming/Context;", true);
mv.visitLdcInsn("comp/UserTransaction");
mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/Context", "lookup", "(Ljava/lang/String;)Ljava/lang/Object;", true);
mv.visitTypeInsn(CHECKCAST, "javax/transaction/UserTransaction");
mv.visitLabel(l1);
mv.visitInsn(ARETURN);
mv.visitLabel(l2);
mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { "javax/naming/NamingException" });
mv.visitVarInsn(ASTORE, 1);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
cw.visitEnd();
write(basedir, cw, target.replace('.', '/'));
}
use of controlP5.Label in project bgpcep by opendaylight.
the class Type1LabelParser method serializeLabel.
@Override
public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject instanceof Type1LabelCase, "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
final ByteBuf body = Unpooled.buffer(LABEL_LENGTH);
final Type1Label type1Label = ((Type1LabelCase) subobject).getType1Label();
Preconditions.checkArgument(type1Label != null, "Type1Label is mandatory.");
writeUnsignedInt(type1Label.getType1Label(), body);
LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
}
Aggregations