mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
Merge remote-tracking branch 'origin/GP-4428_ghizard_add_method_to_DataTypeNamingUtil_to_get_String_rep_of_mangled_name_without_renaming--SQUASHED'
This commit is contained in:
commit
434c3f315d
@ -34,10 +34,28 @@ public class DataTypeNamingUtil {
|
|||||||
* functionDefinition. Generated name will start with {@code _func}.
|
* functionDefinition. Generated name will start with {@code _func}.
|
||||||
* @param functionDefinition function definition whose name should be set
|
* @param functionDefinition function definition whose name should be set
|
||||||
* @return name applied to functionDefinition
|
* @return name applied to functionDefinition
|
||||||
* @throws IllegalArgumentException if generated name contains unsupported characters
|
|
||||||
*/
|
*/
|
||||||
public static String setMangledAnonymousFunctionName(
|
public static String setMangledAnonymousFunctionName(
|
||||||
FunctionDefinitionDataType functionDefinition) throws IllegalArgumentException {
|
FunctionDefinitionDataType functionDefinition) {
|
||||||
|
String name = generateMangledSignature(functionDefinition);
|
||||||
|
try {
|
||||||
|
functionDefinition.setName(name);
|
||||||
|
}
|
||||||
|
catch (InvalidNameException e) {
|
||||||
|
// Note that we created the name using generateMangledSignature(functionDefinition).
|
||||||
|
// An invalid name is a programming error on our part.
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a simple mangled function signature. Generated string will start with
|
||||||
|
* {@code _func}.
|
||||||
|
* @param functionDefinition function definition is used for generating the name
|
||||||
|
* @return generated name
|
||||||
|
*/
|
||||||
|
public static String generateMangledSignature(FunctionDefinitionDataType functionDefinition) {
|
||||||
|
|
||||||
DataType returnType = functionDefinition.getReturnType();
|
DataType returnType = functionDefinition.getReturnType();
|
||||||
ParameterDefinition[] parameters = functionDefinition.getArguments();
|
ParameterDefinition[] parameters = functionDefinition.getArguments();
|
||||||
@ -64,11 +82,9 @@ public class DataTypeNamingUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String name = sb.toString();
|
String name = sb.toString();
|
||||||
try {
|
if (!DataUtilities.isValidDataTypeName(name)) {
|
||||||
functionDefinition.setName(name);
|
// Note that we created the name. An invalid name is a programming error on our part.
|
||||||
}
|
throw new AssertionError("Unexpected bad name: " + name);
|
||||||
catch (InvalidNameException e) {
|
|
||||||
throw new IllegalArgumentException(e);
|
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user