Generates the code to unreify the result of the given method. For a method "int m (int i, String s)", this code is the bytecode corresponding to the "((Integer)...).intValue()" expression. @param cv the code visitor to be used to generate the bytecode. @author Eric Bruneton @author Pat Niemeyer
(String returnType, CodeVisitor cv)
| 709 | * @author Pat Niemeyer |
| 710 | */ |
| 711 | private static void generateReturnCode(String returnType, CodeVisitor cv) { |
| 712 | if (returnType.equals("V")) { |
| 713 | cv.visitInsn(POP); |
| 714 | cv.visitInsn(RETURN); |
| 715 | } else if (isPrimitive(returnType)) { |
| 716 | int opcode = IRETURN; |
| 717 | String type; |
| 718 | String meth; |
| 719 | if (returnType.equals("B")) { |
| 720 | type = "java/lang/Byte"; |
| 721 | meth = "byteValue"; |
| 722 | } else if (returnType.equals("I")) { |
| 723 | type = "java/lang/Integer"; |
| 724 | meth = "intValue"; |
| 725 | } else if (returnType.equals("Z")) { |
| 726 | type = "java/lang/Boolean"; |
| 727 | meth = "booleanValue"; |
| 728 | } else if (returnType.equals("D")) { |
| 729 | opcode = DRETURN; |
| 730 | type = "java/lang/Double"; |
| 731 | meth = "doubleValue"; |
| 732 | } else if (returnType.equals("F")) { |
| 733 | opcode = FRETURN; |
| 734 | type = "java/lang/Float"; |
| 735 | meth = "floatValue"; |
| 736 | } else if (returnType.equals("J")) { |
| 737 | opcode = LRETURN; |
| 738 | type = "java/lang/Long"; |
| 739 | meth = "longValue"; |
| 740 | } else if (returnType.equals("C")) { |
| 741 | type = "java/lang/Character"; |
| 742 | meth = "charValue"; |
| 743 | } else /*if (returnType.equals("S") )*/ { |
| 744 | type = "java/lang/Short"; |
| 745 | meth = "shortValue"; |
| 746 | } |
| 747 | |
| 748 | String desc = returnType; |
| 749 | cv.visitTypeInsn(CHECKCAST, type); // type is correct here |
| 750 | cv.visitMethodInsn(INVOKEVIRTUAL, type, meth, "()" + desc); |
| 751 | cv.visitInsn(opcode); |
| 752 | } else { |
| 753 | cv.visitTypeInsn(CHECKCAST, descriptorToClassName(returnType)); |
| 754 | cv.visitInsn(ARETURN); |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | |
| 759 | /** |
no test coverage detected