MCPcopy Index your code
hub / github.com/GraxCode/zelixkiller / createConstant

Method createConstant

src/me/lpk/analysis/StackHelper.java:23–88  ·  view source on GitHub ↗
(AbstractInsnNode insn)

Source from the content-addressed store, hash-verified

21public class StackHelper {
22
23 public InsnValue createConstant(AbstractInsnNode insn) throws AnalyzerException {
24 switch (insn.getOpcode()) {
25 case Opcodes.ACONST_NULL:
26 return InsnValue.NULL_REFERENCE_VALUE;
27 case Opcodes.ICONST_M1:
28 case Opcodes.ICONST_0:
29 case Opcodes.ICONST_1:
30 case Opcodes.ICONST_2:
31 case Opcodes.ICONST_3:
32 case Opcodes.ICONST_4:
33 case Opcodes.ICONST_5:
34 case Opcodes.BIPUSH:
35 case Opcodes.SIPUSH:
36 return InsnValue.intValue(insn);
37 case Opcodes.LCONST_0:
38 case Opcodes.LCONST_1:
39 return InsnValue.longValue(insn.getOpcode());
40 case Opcodes.FCONST_0:
41 case Opcodes.FCONST_1:
42 case Opcodes.FCONST_2:
43 return InsnValue.floatValue(insn.getOpcode());
44 case Opcodes.DCONST_0:
45 case Opcodes.DCONST_1:
46 return InsnValue.doubleValue(insn.getOpcode());
47 case Opcodes.LDC:
48 Object obj = ((LdcInsnNode) insn).cst;
49 if (obj instanceof Type) {
50 return new InsnValue((Type) obj);
51 } else {
52 Type t = Type.getType(obj.getClass());
53 int sort = t.getSort();
54 // Non-included types:
55 // Type.ARRAY
56 // Type.VOID
57 // Type.METHOD
58 switch (sort) {
59 case Type.BOOLEAN:
60 return InsnValue.intValue((int) obj);
61 case Type.CHAR:
62 return InsnValue.charValue((char) obj);
63 case Type.BYTE:
64 return InsnValue.byteValue((byte) obj);
65 case Type.SHORT:
66 return InsnValue.shortValue((short) obj);
67 case Type.INT:
68 return InsnValue.intValue((int) obj);
69 case Type.FLOAT:
70 return InsnValue.floatValue((float) obj);
71 case Type.LONG:
72 return InsnValue.longValue((long) obj);
73 case Type.DOUBLE:
74 return InsnValue.doubleValue((double) obj);
75 case Type.OBJECT:
76 return new InsnValue(t, obj);
77 }
78 return new InsnValue(t);
79 }
80 case Opcodes.NEW:

Callers 1

executeMethod · 0.80

Calls 8

intValueMethod · 0.95
longValueMethod · 0.95
floatValueMethod · 0.95
doubleValueMethod · 0.95
charValueMethod · 0.95
byteValueMethod · 0.95
shortValueMethod · 0.95
getTypeMethod · 0.80

Tested by

no test coverage detected