use of org.mvel2.asm.Label in project mvel by mikebrock.
the class TraceMethodVisitor method visitLocalVariable.
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
buf.setLength(0);
buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
appendDescriptor(FIELD_DESCRIPTOR, desc);
buf.append(' ');
appendLabel(start);
buf.append(' ');
appendLabel(end);
buf.append(' ').append(index).append('\n');
if (signature != null) {
buf.append(tab2);
appendDescriptor(FIELD_SIGNATURE, signature);
TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
SignatureReader r = new SignatureReader(signature);
r.acceptType(sv);
buf.append(tab2).append("// declaration: ").append(sv.getDeclaration()).append('\n');
}
text.add(buf.toString());
if (mv != null) {
mv.visitLocalVariable(name, desc, signature, start, end, index);
}
}
use of org.mvel2.asm.Label in project drools by kiegroup.
the class TraitMapPropertyWrapperClassBuilderImpl method buildContainsValue.
protected void buildContainsValue(ClassWriter cw, String wrapperName, ClassDefinition trait, ClassDefinition core) {
String internalWrapper = BuildUtils.getInternalType(wrapperName);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "containsValue", "(" + Type.getDescriptor(Object.class) + ")Z", null, null);
mv.visitCode();
// null check
mv.visitVarInsn(ALOAD, 1);
Label l99 = new Label();
mv.visitJumpInsn(IFNONNULL, l99);
for (FieldDefinition field : core.getFieldsDefinitions()) {
if (!BuildUtils.isPrimitive(field.getTypeName())) {
extractAndTestNotNull(mv, wrapperName, core, field);
}
}
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitInsn(ACONST_NULL);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "containsValue", "(" + Type.getDescriptor(Object.class) + ")Z", true);
mv.visitInsn(IRETURN);
mv.visitLabel(l99);
// non-null values check
for (FieldDefinition field : core.getFieldsDefinitions()) {
mv.visitVarInsn(ALOAD, 1);
TraitFactoryImpl.invokeExtractor(mv, wrapperName, core, field);
if (BuildUtils.isPrimitive(field.getTypeName())) {
TraitFactoryImpl.valueOf(mv, field.getTypeName());
}
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(Object.class), "equals", "(" + Type.getDescriptor(Object.class) + ")Z", false);
Label l0 = new Label();
mv.visitJumpInsn(IFEQ, l0);
mv.visitInsn(ICONST_1);
mv.visitInsn(IRETURN);
mv.visitLabel(l0);
}
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "containsValue", "(" + Type.getDescriptor(Object.class) + ")Z", true);
mv.visitInsn(IRETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.mvel2.asm.Label in project drools by kiegroup.
the class TraitMapPropertyWrapperClassBuilderImpl method buildRemove.
protected void buildRemove(ClassWriter cw, String wrapperName, ClassDefinition trait, ClassDefinition core, BitSet mask) {
String internalWrapper = BuildUtils.getInternalType(wrapperName);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "remove", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), null, null);
mv.visitCode();
for (FieldDefinition field : core.getFieldsDefinitions()) {
invokeRemove(mv, wrapperName, core, field.getName(), field);
}
int j = 0;
for (FieldDefinition field : trait.getFieldsDefinitions()) {
boolean isSoftField = TraitRegistryImpl.isSoftField(field, j++, mask);
if (isSoftField) {
mv.visitLdcInsn(field.getName());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(String.class), "equals", "(" + Type.getDescriptor(Object.class) + ")Z", false);
Label l2 = new Label();
mv.visitJumpInsn(IFEQ, l2);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitLdcInsn(field.getName());
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "get", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), true);
mv.visitVarInsn(ASTORE, 2);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitLdcInsn(field.getName());
mv.visitInsn(AsmUtil.zero(field.getTypeName()));
if (BuildUtils.isPrimitive(field.getTypeName())) {
TraitFactoryImpl.valueOf(mv, field.getTypeName());
}
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "put", "(" + Type.getDescriptor(Object.class) + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), true);
mv.visitInsn(POP);
mv.visitVarInsn(ALOAD, 2);
mv.visitInsn(ARETURN);
mv.visitLabel(l2);
}
}
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "remove", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), true);
mv.visitVarInsn(ASTORE, 2);
mv.visitVarInsn(ALOAD, 2);
mv.visitInsn(ARETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.mvel2.asm.Label in project drools by kiegroup.
the class TraitTriplePropertyWrapperClassBuilderImpl method initSoftField.
protected void initSoftField(MethodVisitor mv, String wrapperName, FieldDefinition field, ClassDefinition core, String internalWrapper) {
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, wrapperName, "store", Type.getDescriptor(TripleStore.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitLdcInsn(field.resolveAlias());
mv.visitMethodInsn(INVOKEVIRTUAL, wrapperName, "propertyKey", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Triple.class), false);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleStore.class), "contains", "(" + Type.getDescriptor(Triple.class) + ")Z", false);
Label l0 = new Label();
mv.visitJumpInsn(IFNE, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, wrapperName, "store", Type.getDescriptor(TripleStore.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitLdcInsn(field.resolveAlias());
mv.visitInsn(AsmUtil.zero(field.getTypeName()));
if (BuildUtils.isPrimitive(field.getTypeName())) {
TraitFactoryImpl.valueOf(mv, field.getTypeName());
}
mv.visitMethodInsn(INVOKEVIRTUAL, wrapperName, "property", "(" + Type.getDescriptor(String.class) + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Triple.class), false);
mv.visitInsn(ICONST_1);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleStore.class), "put", "(" + Type.getDescriptor(Triple.class) + "Z)Z", false);
if (core.isFullTraiting()) {
super.registerLogicalField(mv, internalWrapper, field, core);
}
mv.visitInsn(POP);
mv.visitLabel(l0);
}
use of org.mvel2.asm.Label in project drools by kiegroup.
the class TraitTriplePropertyWrapperClassBuilderImpl method buildRemove.
protected void buildRemove(ClassWriter cw, String wrapperName, ClassDefinition trait, ClassDefinition core, BitSet mask) {
String internalWrapper = BuildUtils.getInternalType(wrapperName);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "remove", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), null, null);
mv.visitCode();
int stack = 0;
for (FieldDefinition field : core.getFieldsDefinitions()) {
stack = Math.max(stack, BuildUtils.sizeOf(field.getTypeName()));
invokeRemove(mv, wrapperName, core, field.getName(), field);
}
int j = 0;
for (FieldDefinition field : trait.getFieldsDefinitions()) {
boolean isSoftField = TraitRegistryImpl.isSoftField(field, j++, mask);
if (isSoftField) {
stack = Math.max(stack, BuildUtils.sizeOf(field.getTypeName()));
mv.visitLdcInsn(field.getName());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(String.class), "equals", "(" + Type.getDescriptor(Object.class) + ")Z", false);
Label l2 = new Label();
mv.visitJumpInsn(IFEQ, l2);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "store", Type.getDescriptor(TripleStore.class));
mv.visitVarInsn(ALOAD, 0);
mv.visitLdcInsn(field.getName());
mv.visitMethodInsn(INVOKEVIRTUAL, internalWrapper, "propertyKey", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Triple.class), false);
mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(TripleStore.class), "get", "(" + Type.getDescriptor(Triple.class) + ")" + Type.getDescriptor(Triple.class), false);
mv.visitVarInsn(ASTORE, 2);
mv.visitVarInsn(ALOAD, 0);
mv.visitLdcInsn(field.getName());
mv.visitInsn(AsmUtil.zero(field.getTypeName()));
if (BuildUtils.isPrimitive(field.getTypeName())) {
TraitFactoryImpl.valueOf(mv, field.getTypeName());
}
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "put", "(" + Type.getDescriptor(String.class) + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), false);
mv.visitInsn(POP);
mv.visitVarInsn(ALOAD, 2);
mv.visitInsn(ARETURN);
mv.visitLabel(l2);
}
}
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "remove", "(" + Type.getDescriptor(Object.class) + ")" + Type.getDescriptor(Object.class), false);
mv.visitVarInsn(ASTORE, 2);
mv.visitVarInsn(ALOAD, 2);
mv.visitInsn(ARETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
Aggregations