use of org.mvel2.asm.ClassWriter in project drools by kiegroup.
the class TraitTriplePropertyWrapperClassBuilderImpl method buildContainsKey.
protected void buildContainsKey(ClassWriter cw, ClassDefinition core) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "containsKey", "(" + Type.getDescriptor(Object.class) + ")Z", null, null);
mv.visitCode();
for (FieldDefinition field : core.getFieldsDefinitions()) {
invokeContainsKey(mv, field.getName());
}
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "containsKey", "(" + Type.getDescriptor(Object.class) + ")Z", false);
mv.visitInsn(IRETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.mvel2.asm.ClassWriter in project drools by kiegroup.
the class TraitTriplePropertyWrapperClassBuilderImpl method buildContainsValue.
protected void buildContainsValue(ClassWriter cw, String wrapperName, ClassDefinition core) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "containsValue", "(" + Type.getDescriptor(Object.class) + ")Z", null, null);
mv.visitCode();
boolean hasNillable = false;
for (FieldDefinition field : core.getFieldsDefinitions()) {
if (!BuildUtils.isPrimitive(field.getTypeName())) {
hasNillable = true;
}
}
Label l99 = null;
if (hasNillable) {
mv.visitVarInsn(ALOAD, 1);
l99 = new Label();
mv.visitJumpInsn(IFNONNULL, l99);
}
core.getFieldsDefinitions().size();
for (FieldDefinition field : core.getFieldsDefinitions()) {
if (!BuildUtils.isPrimitive(field.getTypeName())) {
extractAndTestNotNull(mv, wrapperName, core, field);
}
}
if (hasNillable) {
mv.visitLabel(l99);
}
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(TripleBasedStruct.class), "containsValue", "(" + Type.getDescriptor(Object.class) + ")Z", false);
mv.visitInsn(IRETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.mvel2.asm.ClassWriter in project drools by kiegroup.
the class TraitMapPropertyWrapperClassBuilderImpl method buildClear.
protected void buildClear(ClassWriter cw, String wrapperName, ClassDefinition trait, ClassDefinition core, BitSet mask) {
String internalWrapper = BuildUtils.getInternalType(wrapperName);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "clear", "()V", null, null);
mv.visitCode();
for (FieldDefinition field : core.getFieldsDefinitions()) {
if (field.isKey())
continue;
TraitFactoryImpl.invokeInjector(mv, wrapperName, core, field, true, 1);
}
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalWrapper, "map", Type.getDescriptor(Map.class));
mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Map.class), "clear", "()V", true);
initSoftFields(mv, trait, core, internalWrapper, mask, 0);
mv.visitInsn(RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.mvel2.asm.ClassWriter in project mvel by mvel.
the class ASMAccessorOptimizer method _initJIT2.
private void _initJIT2() {
if (isAdvancedDebugging()) {
buildLog = new StringAppender();
}
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
synchronized (Runtime.getRuntime()) {
cw.visit(OPCODES_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className = "ASMAccessorImpl_" + valueOf(cw.hashCode()).replaceAll("\\-", "_") + (System.currentTimeMillis() / 10) + ((int) (Math.random() * 100)), null, "java/lang/Object", new String[] { NAMESPACE + "compiler/Accessor" });
}
MethodVisitor m = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
m.visitCode();
m.visitVarInsn(Opcodes.ALOAD, 0);
m.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
m.visitInsn(RETURN);
m.visitMaxs(1, 1);
m.visitEnd();
(mv = cw.visitMethod(ACC_PUBLIC, "setValue", "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE + "integration/VariableResolverFactory;Ljava/lang/Object;)Ljava/lang/Object;", null, null)).visitCode();
}
Aggregations