/// <summary>Clones the annotations of the given instruction into this instruction.</summary> /// <param name="insnNode">the source instruction.</param> /// <returns>this instruction.</returns> protected internal AbstractInsnNode CloneAnnotations(AbstractInsnNode insnNode) { if (insnNode.visibleTypeAnnotations != null) { visibleTypeAnnotations = new List <TypeAnnotationNode>(); for (int i = 0, n = insnNode.visibleTypeAnnotations.Count; i < n; ++i) { var sourceAnnotation = insnNode.visibleTypeAnnotations[i]; var cloneAnnotation = new TypeAnnotationNode(sourceAnnotation.typeRef , sourceAnnotation.typePath, sourceAnnotation.desc); sourceAnnotation.Accept(cloneAnnotation); visibleTypeAnnotations.Add(cloneAnnotation); } } if (insnNode.invisibleTypeAnnotations != null) { invisibleTypeAnnotations = new List <TypeAnnotationNode>(); for (int i = 0, n = insnNode.invisibleTypeAnnotations.Count; i < n; ++i) { var sourceAnnotation = insnNode.invisibleTypeAnnotations[i]; var cloneAnnotation = new TypeAnnotationNode(sourceAnnotation.typeRef , sourceAnnotation.typePath, sourceAnnotation.desc); sourceAnnotation.Accept(cloneAnnotation); invisibleTypeAnnotations.Add(cloneAnnotation); } } return(this); }
public override AnnotationVisitor VisitInsnAnnotation(int typeRef, TypePath typePath , string descriptor, bool visible) { // Find the last real instruction, i.e. the instruction targeted by this annotation. var currentInsn = instructions.GetLast(); while (currentInsn.GetOpcode() == -1) { currentInsn = currentInsn.GetPrevious(); } // Add the annotation to this instruction. var typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor ); if (visible) { currentInsn.visibleTypeAnnotations = Util.Add(currentInsn.visibleTypeAnnotations, typeAnnotation); } else { currentInsn.invisibleTypeAnnotations = Util.Add(currentInsn.invisibleTypeAnnotations , typeAnnotation); } return(typeAnnotation); }
public override AnnotationVisitor VisitTypeAnnotation(int typeRef, TypePath typePath , string descriptor, bool visible) { var typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor ); if (visible) { visibleTypeAnnotations = Util.Add(visibleTypeAnnotations, typeAnnotation); } else { invisibleTypeAnnotations = Util.Add(invisibleTypeAnnotations, typeAnnotation); } return(typeAnnotation); }
public override AnnotationVisitor VisitTryCatchAnnotation(int typeRef, TypePath typePath , string descriptor, bool visible) { var tryCatchBlock = tryCatchBlocks[(typeRef & 0x00FFFF00) >> 8]; var typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor ); if (visible) { tryCatchBlock.visibleTypeAnnotations = Util.Add(tryCatchBlock.visibleTypeAnnotations , typeAnnotation); } else { tryCatchBlock.invisibleTypeAnnotations = Util.Add(tryCatchBlock.invisibleTypeAnnotations , typeAnnotation); } return(typeAnnotation); }