1 8 package org.codehaus.aspectwerkz.transform.inlining.compiler; 9 10 import org.objectweb.asm.CodeVisitor; 11 import org.objectweb.asm.Type; 12 13 22 public class HandlerJoinPointCompiler extends AbstractJoinPointCompiler { 23 24 29 HandlerJoinPointCompiler(final CompilationInfo.Model model) { 30 super(model); 31 } 32 33 36 protected void createJoinPointSpecificFields() { 37 String [] fieldNames = null; 39 Type fieldType = Type.getType(m_calleeClassSignature); 40 fieldNames = new String [1]; 41 String fieldName = ARGUMENT_FIELD + 0; 42 fieldNames[0] = fieldName; 43 m_cw.visitField(ACC_PRIVATE, fieldName, fieldType.getDescriptor(), null, null); 44 m_fieldNames = fieldNames; 45 m_cw.visitField( 46 ACC_PRIVATE + ACC_STATIC, 47 SIGNATURE_FIELD_NAME, 48 HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE, 49 null, 50 null 51 ); 52 } 53 54 59 protected void createSignature(final CodeVisitor cv) { 60 cv.visitFieldInsn(GETSTATIC, m_joinPointClassName, TARGET_CLASS_FIELD_NAME, CLASS_CLASS_SIGNATURE); 61 62 cv.visitMethodInsn( 63 INVOKESTATIC, 64 SIGNATURE_FACTORY_CLASS, 65 NEW_CATCH_CLAUSE_SIGNATURE_METHOD_NAME, 66 NEW_HANDLER_SIGNATURE_METHOD_SIGNATURE 67 ); 68 cv.visitFieldInsn( 69 PUTSTATIC, m_joinPointClassName, SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 70 ); 71 72 } 73 74 82 protected void createInlinedJoinPointInvocation(final CodeVisitor cv, 83 final boolean isOptimizedJoinPoint, 84 final int argStartIndex, 85 final int joinPointIndex) { 86 cv.visitVarInsn(ALOAD, 0); } 89 90 96 protected void createJoinPointInvocation(final CodeVisitor cv) { 97 cv.visitInsn(ACONST_NULL); 98 } 99 100 105 protected Type getJoinPointReturnType() { 106 return Type.getType(m_calleeClassSignature); 107 } 108 109 114 protected Type[] getJoinPointArgumentTypes() { 115 return new Type[]{Type.getType(m_calleeClassSignature)}; } 117 118 121 protected void createGetRttiMethod() { 122 CodeVisitor cv = m_cw.visitMethod(ACC_PUBLIC, GET_RTTI_METHOD_NAME, GET_RTTI_METHOD_SIGNATURE, null, null); 123 124 cv.visitTypeInsn(NEW, HANDLER_RTTI_IMPL_CLASS_NAME); 126 cv.visitInsn(DUP); 127 cv.visitFieldInsn( 128 GETSTATIC, m_joinPointClassName, SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 129 ); 130 cv.visitVarInsn(ALOAD, 0); 131 cv.visitFieldInsn(GETFIELD, m_joinPointClassName, CALLER_INSTANCE_FIELD_NAME, m_callerClassSignature); 132 cv.visitVarInsn(ALOAD, 0); 133 cv.visitFieldInsn(GETFIELD, m_joinPointClassName, CALLEE_INSTANCE_FIELD_NAME, m_calleeClassSignature); 134 cv.visitMethodInsn( 135 INVOKESPECIAL, HANDLER_RTTI_IMPL_CLASS_NAME, INIT_METHOD_NAME, HANDLER_RTTI_IMPL_INIT_SIGNATURE 136 ); 137 138 cv.visitInsn(ARETURN); 139 cv.visitMaxs(0, 0); 140 } 141 142 145 protected void createGetSignatureMethod() { 146 CodeVisitor cv = m_cw.visitMethod( 147 ACC_PUBLIC, 148 GET_SIGNATURE_METHOD_NAME, 149 GET_SIGNATURE_METHOD_SIGNATURE, 150 null, 151 null 152 ); 153 cv.visitFieldInsn( 154 GETSTATIC, m_joinPointClassName, 155 SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 156 ); 157 cv.visitInsn(ARETURN); 158 cv.visitMaxs(0, 0); 159 } 160 } | Popular Tags |