1 4 package com.tc.aspectwerkz.transform.inlining.compiler; 5 6 import com.tc.asm.MethodVisitor; 7 import com.tc.asm.Type; 8 9 18 public class HandlerJoinPointCompiler extends AbstractJoinPointCompiler { 19 20 25 HandlerJoinPointCompiler(final CompilationInfo.Model model) { 26 super(model); 27 } 28 29 32 protected void createJoinPointSpecificFields() { 33 String [] fieldNames = null; 35 Type fieldType = Type.getType(m_calleeClassSignature); 36 fieldNames = new String [1]; 37 String fieldName = ARGUMENT_FIELD + 0; 38 fieldNames[0] = fieldName; 39 m_cw.visitField(ACC_PRIVATE, fieldName, fieldType.getDescriptor(), null, null); 40 m_fieldNames = fieldNames; 41 m_cw.visitField( 42 ACC_PRIVATE + ACC_STATIC, 43 SIGNATURE_FIELD_NAME, 44 HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE, 45 null, 46 null 47 ); 48 } 49 50 55 protected void createSignature(final MethodVisitor cv) { 56 cv.visitFieldInsn(GETSTATIC, m_joinPointClassName, TARGET_CLASS_FIELD_NAME_IN_JP, CLASS_CLASS_SIGNATURE); 57 58 cv.visitMethodInsn( 59 INVOKESTATIC, 60 SIGNATURE_FACTORY_CLASS, 61 NEW_CATCH_CLAUSE_SIGNATURE_METHOD_NAME, 62 NEW_HANDLER_SIGNATURE_METHOD_SIGNATURE 63 ); 64 cv.visitFieldInsn( 65 PUTSTATIC, m_joinPointClassName, SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 66 ); 67 68 } 69 70 78 protected void createInlinedJoinPointInvocation(final MethodVisitor cv, 79 final CompilerInput input) { 80 cv.visitVarInsn(ALOAD, 0); } 83 84 90 protected void createJoinPointInvocation(final MethodVisitor cv) { 91 cv.visitInsn(ACONST_NULL); 92 } 93 94 99 protected Type getJoinPointReturnType() { 100 return Type.getType(m_calleeClassSignature); 101 } 102 103 108 protected Type[] getJoinPointArgumentTypes() { 109 return new Type[]{Type.getType(m_calleeClassSignature)}; } 111 112 115 protected void createGetRttiMethod() { 116 MethodVisitor cv = m_cw.visitMethod(ACC_PUBLIC, GET_RTTI_METHOD_NAME, GET_RTTI_METHOD_SIGNATURE, null, null); 117 118 cv.visitTypeInsn(NEW, HANDLER_RTTI_IMPL_CLASS_NAME); 120 cv.visitInsn(DUP); 121 cv.visitFieldInsn( 122 GETSTATIC, m_joinPointClassName, SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 123 ); 124 cv.visitVarInsn(ALOAD, 0); 125 cv.visitFieldInsn(GETFIELD, m_joinPointClassName, CALLER_INSTANCE_FIELD_NAME, m_callerClassSignature); 126 cv.visitVarInsn(ALOAD, 0); 127 cv.visitFieldInsn(GETFIELD, m_joinPointClassName, CALLEE_INSTANCE_FIELD_NAME, m_calleeClassSignature); 128 cv.visitMethodInsn( 129 INVOKESPECIAL, HANDLER_RTTI_IMPL_CLASS_NAME, INIT_METHOD_NAME, HANDLER_RTTI_IMPL_INIT_SIGNATURE 130 ); 131 132 cv.visitInsn(ARETURN); 133 cv.visitMaxs(0, 0); 134 } 135 136 139 protected void createGetSignatureMethod() { 140 MethodVisitor cv = m_cw.visitMethod( 141 ACC_PUBLIC, 142 GET_SIGNATURE_METHOD_NAME, 143 GET_SIGNATURE_METHOD_SIGNATURE, 144 null, 145 null 146 ); 147 cv.visitFieldInsn( 148 GETSTATIC, m_joinPointClassName, 149 SIGNATURE_FIELD_NAME, HANDLER_SIGNATURE_IMPL_CLASS_SIGNATURE 150 ); 151 cv.visitInsn(ARETURN); 152 cv.visitMaxs(0, 0); 153 } 154 } | Popular Tags |