use of de.fraunhofer.aisec.cpg.graph.types.ReferenceType in project cpg by Fraunhofer-AISEC.
the class Util method generateParamName.
private static String generateParamName(int i, @NonNull Type targetType) {
Deque<String> hierarchy = new ArrayDeque<>();
Type currLevel = targetType;
while (currLevel != null) {
if (currLevel instanceof FunctionPointerType) {
hierarchy.push("Fptr");
currLevel = null;
} else if (currLevel instanceof PointerType) {
hierarchy.push("Ptr");
currLevel = ((PointerType) currLevel).getElementType();
} else if (currLevel instanceof ReferenceType) {
hierarchy.push("Ref");
currLevel = ((ReferenceType) currLevel).getElementType();
} else {
hierarchy.push(currLevel.getTypeName());
currLevel = null;
}
}
StringBuilder paramName = new StringBuilder();
while (!hierarchy.isEmpty()) {
String part = hierarchy.pop();
if (part.isEmpty()) {
continue;
}
if (paramName.length() > 0) {
paramName.append(part.substring(0, 1).toUpperCase());
if (part.length() >= 2) {
paramName.append(part.substring(1));
}
} else {
paramName.append(part.toLowerCase());
}
}
paramName.append(i);
return paramName.toString();
}
Aggregations