renaming less datatype sensitive

This commit is contained in:
caheckman 2019-09-17 11:30:48 -04:00
parent b2a422329c
commit 1257f06c17
3 changed files with 56 additions and 49 deletions

View file

@ -72,37 +72,43 @@ public class HighFunctionDBUtil {
/**
* Commit all parameters associated with HighFunction to the underlying database.
* @param highFunction
* @param renameConflicts if true any name conflicts will be resolved
* by renaming the conflicting local variable/label
* @param source source type
* @param highFunction is the associated HighFunction
* @param useDataTypes is true if the HighFunction's parameter data-types should be committed
* @param source is the signature source type to set
* @throws DuplicateNameException if commit of parameters caused conflict with other
* local variable/label. Should not occur if renameConflicts is true.
* @throws InvalidInputException
* local variable/label.
* @throws InvalidInputException if specified storage is invalid
*/
public static void commitParamsToDatabase(HighFunction highFunction, boolean renameConflicts,
public static void commitParamsToDatabase(HighFunction highFunction, boolean useDataTypes,
SourceType source) throws DuplicateNameException, InvalidInputException {
Function function = highFunction.getFunction();
List<Parameter> params = getParameters(highFunction);
List<Parameter> params = getParameters(highFunction, useDataTypes);
commitParamsToDatabase(function, highFunction.getFunctionPrototype(), params,
highFunction.getFunctionPrototype().isVarArg(), renameConflicts, source);
highFunction.getFunctionPrototype().isVarArg(), true, source);
}
private static List<Parameter> getParameters(HighFunction highFunction)
private static List<Parameter> getParameters(HighFunction highFunction, boolean useDataTypes)
throws InvalidInputException {
Function function = highFunction.getFunction();
Program program = function.getProgram();
DataTypeManager dtm = program.getDataTypeManager();
LocalSymbolMap symbolMap = highFunction.getLocalSymbolMap();
List<Parameter> params = new ArrayList<Parameter>();
int paramCnt = symbolMap.getNumParams();
for (int i = 0; i < paramCnt; ++i) {
HighParam param = symbolMap.getParam(i);
String name = param.getName();
boolean nameLocked = param.getSymbol().isNameLocked();
name = (nameLocked ? name : null);
params.add(new ParameterImpl(name, param.getDataType(), param.getStorage(), program));
DataType dataType;
if (useDataTypes) {
dataType = param.getDataType();
}
else {
dataType = Undefined.getUndefinedDataType(param.getSize());
dataType = dataType.clone(dtm);
}
params.add(new ParameterImpl(name, dataType, param.getStorage(), program));
}
return params;
}
@ -407,28 +413,33 @@ public class HighFunctionDBUtil {
HighFunction highFunction = variable.getHighFunction();
Function function = highFunction.getFunction();
Program program = function.getProgram();
DataTypeManager dtm = program.getDataTypeManager();
dataType = dataType != null ? dataType.clone(dtm) : variable.getDataType();
if (dataType.getLength() <= 0) {
throw new InvalidInputException("Data type is not fixed-length: " + dataType.getName());
boolean resized = false;
if (dataType != null) {
dataType = dataType.clone(program.getDataTypeManager());
if (dataType.getLength() <= 0) {
throw new InvalidInputException(
"Data type is not fixed-length: " + dataType.getName());
}
resized = (dataType.getLength() != variable.getSize());
}
boolean resized = (dataType.getLength() != variable.getSize());
boolean isRename = name != null;
if (variable instanceof HighParam) {
HighParam param = (HighParam) variable;
Parameter dbParam = getDatabaseParameter(param);
VariableStorage storage = param.getStorage();
if (resized && function.hasCustomVariableStorage()) {
VariableStorage newStorage =
VariableUtilities.resizeStorage(storage, dataType, true, function);
dbParam.setDataType(dataType, newStorage, false, source);
}
else {
dbParam.setDataType(dataType, source);
if (dataType != null) {
if (resized && function.hasCustomVariableStorage()) {
VariableStorage newStorage =
VariableUtilities.resizeStorage(storage, dataType, true, function);
dbParam.setDataType(dataType, newStorage, false, source);
}
else {
dbParam.setDataType(dataType, source);
}
}
if (name != null && !name.equals(dbParam.getName())) {
dbParam.setName(name, source);
@ -440,6 +451,15 @@ public class HighFunctionDBUtil {
boolean usesHashStorage = storage.isHashStorage();
Variable var = clearConflictingLocalVariables(local);
if (dataType == null) {
if (var != null) {
dataType = var.getDataType(); // Use preexisting datatype
}
else {
dataType = Undefined.getUndefinedDataType(variable.getSize());
dataType = dataType.clone(program.getDataTypeManager());
}
}
if (resized) {
if (usesHashStorage) {
throw new InvalidInputException(
@ -495,7 +515,9 @@ public class HighFunctionDBUtil {
}
}
setGlobalDataType(global, dataType);
if (dataType != null) {
setGlobalDataType(global, dataType);
}
if (name != null) {
try {