Search in sources :

Example 21 with ClassWriter

use of org.mvel2.asm.ClassWriter in project drools by kiegroup.

the class ClassGenerator method createClassWriter.

public static ClassWriter createClassWriter(ClassLoader classLoader, int access, String name, String signature, String superName, String[] interfaces) {
    ClassWriter cw = new InternalClassWriter(classLoader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
    cw.visit(ClassLevel.getJavaVersion(classLoader), access, name, signature, superName, interfaces);
    return cw;
}
Also used : ClassWriter(org.mvel2.asm.ClassWriter)

Example 22 with ClassWriter

use of org.mvel2.asm.ClassWriter in project mvel by mvel.

the class ModuleHashesAttribute method write.

@Override
protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) {
    ByteVector v = new ByteVector();
    int index = cw.newUTF8(algorithm);
    v.putShort(index);
    int count = (modules == null) ? 0 : modules.size();
    v.putShort(count);
    for (int i = 0; i < count; i++) {
        String module = modules.get(i);
        v.putShort(cw.newModule(module));
        byte[] hash = hashes.get(i);
        v.putShort(hash.length);
        for (byte b : hash) {
            v.putByte(b);
        }
    }
    return v;
}
Also used : ByteVector(org.mvel2.asm.ByteVector)

Example 23 with ClassWriter

use of org.mvel2.asm.ClassWriter in project mvel by mvel.

the class ModuleResolutionAttribute method write.

@Override
protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) {
    ByteVector v = new ByteVector();
    v.putShort(resolution);
    return v;
}
Also used : ByteVector(org.mvel2.asm.ByteVector)

Example 24 with ClassWriter

use of org.mvel2.asm.ClassWriter in project mvel by mvel.

the class ModuleTargetAttribute method write.

@Override
protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) {
    ByteVector v = new ByteVector();
    int index = (platform == null) ? 0 : cw.newUTF8(platform);
    v.putShort(index);
    return v;
}
Also used : ByteVector(org.mvel2.asm.ByteVector)

Example 25 with ClassWriter

use of org.mvel2.asm.ClassWriter in project mvel by mvel.

the class ASMAccessorOptimizer method _initJIT.

/**
 * Does all the boilerplate for initiating the JIT.
 */
private void _initJIT() {
    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, "getValue", "(Ljava/lang/Object;Ljava/lang/Object;L" + NAMESPACE + "integration/VariableResolverFactory;)Ljava/lang/Object;", null, null)).visitCode();
}
Also used : StringAppender(org.mvel2.util.StringAppender) ClassWriter(org.mvel2.asm.ClassWriter) MethodVisitor(org.mvel2.asm.MethodVisitor)

Aggregations

MethodVisitor (org.mvel2.asm.MethodVisitor)58 ClassWriter (org.mvel2.asm.ClassWriter)32 FieldDefinition (org.drools.core.factmodel.FieldDefinition)23 FieldVisitor (org.mvel2.asm.FieldVisitor)23 Map (java.util.Map)20 Label (org.mvel2.asm.Label)20 BitSet (java.util.BitSet)12 ClassGenerator.createClassWriter (org.drools.core.rule.builder.dialect.asm.ClassGenerator.createClassWriter)12 ClassGenerator.createClassWriter (org.drools.mvel.asm.ClassGenerator.createClassWriter)12 Serializable (java.io.Serializable)8 Type (org.mvel2.asm.Type)8 IOException (java.io.IOException)7 Method (java.lang.reflect.Method)7 ObjectInput (java.io.ObjectInput)6 ObjectOutput (java.io.ObjectOutput)6 Externalizable (java.io.Externalizable)4 Collection (java.util.Collection)4 Thing (org.drools.core.factmodel.traits.Thing)4 TraitFieldTMS (org.drools.core.factmodel.traits.TraitFieldTMS)3 ReactiveObject (org.drools.core.phreak.ReactiveObject)3