MCPcopy Create free account
hub / github.com/FabricMC/Matcher / gatherArgs

Method gatherArgs

src/main/java/matcher/type/MethodInstance.java:64–123  ·  view source on GitHub ↗
(MethodInstance method, String desc, MethodNode asmNode)

Source from the content-addressed store, hash-verified

62 }
63
64 private static MethodVarInstance[] gatherArgs(MethodInstance method, String desc, MethodNode asmNode) {
65 Type[] argTypes = Type.getArgumentTypes(desc);
66 if (argTypes.length == 0) return emptyVars;
67
68 MethodVarInstance[] args = new MethodVarInstance[argTypes.length];
69 List<LocalVariableNode> locals;
70 InsnList il;
71 AbstractInsnNode firstInsn;
72
73 if (asmNode != null) {
74 locals = asmNode.localVariables;
75 il = asmNode.instructions;
76 firstInsn = il.getFirst();
77 } else {
78 locals = null;
79 il = null;
80 firstInsn = null;
81 }
82
83 int lvIdx = method.isStatic ? 0 : 1;
84
85 for (int i = 0; i < argTypes.length; i++) {
86 Type asmType = argTypes[i];
87 ClassInstance type = method.cls.getEnv().getCreateClassInstance(asmType.getDescriptor());
88 int asmIndex = -1;
89 int startInsn = -1;
90 int endInsn = -1;
91 String name = null;
92
93 if (locals != null) {
94 for (int j = 0; j < locals.size(); j++) {
95 LocalVariableNode n = locals.get(j);
96
97 if (n.index == lvIdx && n.start == firstInsn) {
98 assert n.desc.equals(type.id);
99
100 asmIndex = j;
101 startInsn = il.indexOf(n.start);
102 endInsn = il.indexOf(n.end);
103 name = n.name;
104
105 break;
106 }
107 }
108 }
109
110 MethodVarInstance arg = new MethodVarInstance(method, true, i, lvIdx, asmIndex,
111 type, startInsn, endInsn, 0,
112 name,
113 name == null || method.nameObfuscatedLocal || method.cls.nameObfuscated || !Util.isValidJavaIdentifier(name));
114 args[i] = arg;
115
116 method.classRefs.add(type);
117 type.methodTypeRefs.add(method);
118
119 lvIdx += type.getSlotSize();
120 }
121

Callers 1

MethodInstanceMethod · 0.95

Calls 7

isValidJavaIdentifierMethod · 0.95
getSlotSizeMethod · 0.95
sizeMethod · 0.80
getEnvMethod · 0.65
getMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected