Java Code Examples for org.benf.cfr.reader.entities.Method#getMethodPrototype()
The following examples show how to use
org.benf.cfr.reader.entities.Method#getMethodPrototype() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemberNameResolver.java From cfr with MIT License | 6 votes |
private void patchBadNames() { Collection<MemberInfo> memberInfos = infoMap.values(); for (MemberInfo memberInfo : memberInfos) { if (!memberInfo.hasClashes()) continue; Set<MethodKey> clashes = memberInfo.getClashes(); for (MethodKey clashKey : clashes) { Map<JavaTypeInstance, Collection<Method>> clashMap = memberInfo.getClashedMethodsFor(clashKey); for (Map.Entry<JavaTypeInstance, Collection<Method>> clashByType : clashMap.entrySet()) { String resolvedName = null; for (Method method : clashByType.getValue()) { MethodPrototype methodPrototype = method.getMethodPrototype(); if (methodPrototype.hasNameBeenFixed()) { if (resolvedName == null) resolvedName = methodPrototype.getFixedName(); } else { // Need to fix. If we've already seen fixed name don't generate, use. If we haven't // generate. if (resolvedName == null) { resolvedName = ClassNameUtils.getTypeFixPrefix(clashByType.getKey()) + methodPrototype.getName(); } methodPrototype.setFixedName(resolvedName); } } } } } }
Example 2
Source File: MemberNameResolver.java From cfr with MIT License | 6 votes |
public void add(Method method) { if (method.isConstructor()) return; MethodPrototype prototype = method.getMethodPrototype(); String name = prototype.getName(); List<JavaTypeInstance> args = Functional.map(prototype.getArgs(), new UnaryFunction<JavaTypeInstance, JavaTypeInstance>() { @Override public JavaTypeInstance invoke(JavaTypeInstance arg) { return arg.getDeGenerifiedType(); } }); MethodKey methodKey = new MethodKey(name, args); JavaTypeInstance type = prototype.getReturnType(); if (type instanceof JavaGenericBaseInstance) return; add(methodKey, prototype.getReturnType(), method, false); }
Example 3
Source File: RecordRewriter.java From cfr with MIT License | 6 votes |
@Override public boolean test(Method in) { MethodPrototype proto = in.getMethodPrototype(); if (!proto.parametersComputed()) return false; List<JavaTypeInstance> protoArgs = proto.getArgs(); if (protoArgs.size() != fields.size()) return false; List<LocalVariable> parameters = proto.getComputedParameters(); // The names MIGHT not match, if we've been obfuscated. That's ok, as long as the parameters are assigned, // at the top level, to the appropriate variable. if (parameters.size() != fields.size()) return false; // If they don't match, we have to rename, as implicit parameters are usable inside constructor. for (int x=0;x<fields.size();++x) { JavaTypeInstance fieldType = fields.get(x).getField().getJavaTypeInstance(); JavaTypeInstance paramType = protoArgs.get(x); if (!fieldType.equals(paramType)) return false; } return true; }
Example 4
Source File: VariableFactory.java From cfr with MIT License | 6 votes |
public VariableFactory(Method method, BytecodeMeta bytecodeMeta) { this.variableNamer = method.getVariableNamer(); this.clashes = bytecodeMeta.getLivenessClashes(); MethodPrototype methodPrototype = method.getMethodPrototype(); List<JavaTypeInstance> args = methodPrototype.getArgs(); this.typedArgs = MapFactory.newMap(); int offset = 0; if (methodPrototype.isInstanceMethod()) { JavaTypeInstance thisType = method.getClassFile().getClassType(); typedArgs.put(offset++, new InferredJavaType(thisType, InferredJavaType.Source.UNKNOWN, true)); } for (JavaTypeInstance arg : args) { typedArgs.put(offset, new InferredJavaType(arg, InferredJavaType.Source.UNKNOWN, true)); offset += arg.getStackType().getComputationCategory(); } if (methodPrototype.parametersComputed()) { for (LocalVariable localVariable : methodPrototype.getComputedParameters()) { cache.put(localVariable, localVariable); } } this.method = method; }
Example 5
Source File: ScopeHidingVariableRewriter.java From cfr with MIT License | 5 votes |
public ScopeHidingVariableRewriter(List<ClassFileField> fieldVariables, Method method, ClassCache classCache) { this.method = method; this.classCache = classCache; MethodPrototype prototype = method.getMethodPrototype(); for (ClassFileField field : fieldVariables) { String fieldName = field.getFieldName(); outerNames.add(fieldName); usedNames.add(fieldName); } if (prototype.parametersComputed()) { for (LocalVariable localVariable : prototype.getComputedParameters()) { checkCollision(localVariable); } } }
Example 6
Source File: LocalClassScopeDiscoverImpl.java From cfr with MIT License | 5 votes |
public LocalClassScopeDiscoverImpl(Options options, Method method, VariableFactory variableFactory) { super(options, method.getMethodPrototype(), variableFactory); scopeType = method.getMethodPrototype().getClassType(); JavaTypeInstance thisClassType = method.getClassFile().getClassType(); while (thisClassType != null) { if (null != localClassTypes.put(thisClassType, Boolean.FALSE)) break; InnerClassInfo innerClassInfo = thisClassType.getInnerClassHereInfo(); if (!innerClassInfo.isInnerClass()) break; thisClassType = innerClassInfo.getOuterClass(); } }