Merge remote-tracking branch 'origin/GP-6008_ghidra1_SourceTypePriorityUse--SQUASHED' into Ghidra_12.0

This commit is contained in:
ghidra1 2025-09-24 09:18:36 -04:00
commit ed4ad257f2
20 changed files with 131 additions and 144 deletions

View file

@ -43,8 +43,7 @@ import ghidra.program.model.symbol.*;
public class AutoRenameSimpleLabels extends GhidraScript { public class AutoRenameSimpleLabels extends GhidraScript {
boolean isDefaultName(Symbol symbol) { boolean isDefaultName(Symbol symbol) {
return symbol.getSource() == SourceType.DEFAULT || return symbol.getSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS);
symbol.getSource() == SourceType.ANALYSIS;
} }
@Override @Override
@ -61,6 +60,9 @@ public class AutoRenameSimpleLabels extends GhidraScript {
//get this instruction's info //get this instruction's info
Symbol s = iter.next(); Symbol s = iter.next();
Address startAddr = s.getAddress(); Address startAddr = s.getAddress();
if (!startAddr.isLoadedMemoryAddress()) {
continue;
}
// read the instruction type and operand // read the instruction type and operand
Instruction inst = getInstructionAt(startAddr); Instruction inst = getInstructionAt(startAddr);

View file

@ -43,12 +43,11 @@ public class LabelDataScript extends GhidraScript {
(!data.getBaseDataType().getName().toLowerCase().contains("string")) && (!data.getBaseDataType().getName().toLowerCase().contains("string")) &&
(!data.getBaseDataType().getName().toLowerCase().contains("unicode"))) { (!data.getBaseDataType().getName().toLowerCase().contains("unicode"))) {
Symbol sym = symbolTable.getPrimarySymbol(data.getMinAddress()); Symbol sym = symbolTable.getPrimarySymbol(data.getMinAddress());
if ((sym != null) && ((sym.getSource() == SourceType.DEFAULT) || if (sym != null &&
(sym.getSource() == SourceType.ANALYSIS))) { sym.getSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
String newLabel = String newLabel = data.getDefaultLabelPrefix(null) +
data.getDefaultLabelPrefix(null) + "_" + "_" + SymbolUtilities
SymbolUtilities.replaceInvalidChars( .replaceInvalidChars(data.getDefaultValueRepresentation(), false) +
data.getDefaultValueRepresentation(), false) +
"_" + data.getMinAddress().toString(); "_" + data.getMinAddress().toString();
Symbol newSym = symbolTable.createLabel(data.getMinAddress(), newLabel, Symbol newSym = symbolTable.createLabel(data.getMinAddress(), newLabel,
SourceType.ANALYSIS); SourceType.ANALYSIS);

View file

@ -145,8 +145,10 @@ public class NewFunctionStackAnalysisCmd extends BackgroundCommand<Program> {
} }
private boolean checkForX86(Program p) { private boolean checkForX86(Program p) {
return program.getLanguage().getProcessor().equals( return program.getLanguage()
Processor.findOrPossiblyCreateProcessor(X86_NAME)) && program.getDefaultPointerSize() <= 32; .getProcessor()
.equals(Processor.findOrPossiblyCreateProcessor(X86_NAME)) &&
program.getDefaultPointerSize() <= 32;
} }
/** /**
@ -221,7 +223,7 @@ public class NewFunctionStackAnalysisCmd extends BackgroundCommand<Program> {
private boolean isProtectedVariable(Variable var) { private boolean isProtectedVariable(Variable var) {
return !var.isStackVariable() || !Undefined.isUndefined(var.getDataType()) || return !var.isStackVariable() || !Undefined.isUndefined(var.getDataType()) ||
var.getSource() == SourceType.IMPORTED || var.getSource() == SourceType.USER_DEFINED || var.getSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED) ||
var.isCompoundVariable(); var.isCompoundVariable();
} }
@ -339,9 +341,11 @@ public class NewFunctionStackAnalysisCmd extends BackgroundCommand<Program> {
return; return;
} }
} }
long extendedOffset = extendOffset(address.getOffset(), stackReg.getBitLength()); long extendedOffset =
extendOffset(address.getOffset(), stackReg.getBitLength());
defineFuncVariable(symEval, func, instr, opIndex, (int) extendedOffset, sortedVariables); defineFuncVariable(symEval, func, instr, opIndex, (int) extendedOffset,
sortedVariables);
} }
} }
@ -634,8 +638,8 @@ public class NewFunctionStackAnalysisCmd extends BackgroundCommand<Program> {
// return true; // return true;
// } // }
private void defineFuncVariable(SymbolicPropogator symEval, Function func, Instruction instr, int opIndex, int stackOffset, private void defineFuncVariable(SymbolicPropogator symEval, Function func, Instruction instr,
List<Variable> sortedVariables) { int opIndex, int stackOffset, List<Variable> sortedVariables) {
ReferenceManager refMgr = program.getReferenceManager(); ReferenceManager refMgr = program.getReferenceManager();
int refSize = getRefSize(symEval, instr, opIndex); int refSize = getRefSize(symEval, instr, opIndex);

View file

@ -224,7 +224,7 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
if (symbol.getSymbolType() == SymbolType.FUNCTION) { if (symbol.getSymbolType() == SymbolType.FUNCTION) {
Function function = (Function) symbol.getObject(); Function function = (Function) symbol.getObject();
if (!function.isThunk() && if (!function.isThunk() &&
function.getSignatureSource().isHigherPriorityThan(SourceType.ANALYSIS)) { function.getSignatureSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
return true; return true;
} }
} }
@ -297,8 +297,7 @@ public abstract class AbstractDemanglerAnalyzer extends AbstractAnalyzer {
return; return;
} }
String errorString = demangled.getErrorMessage(); String errorString = demangled.getErrorMessage();
logApplyErrorMessage(log, demangled, mangledContext.getAddress(), null, logApplyErrorMessage(log, demangled, mangledContext.getAddress(), null, errorString);
errorString);
} }
catch (Exception e) { catch (Exception e) {
logApplyErrorMessage(log, demangled, mangledContext.getAddress(), e, null); logApplyErrorMessage(log, demangled, mangledContext.getAddress(), e, null);

View file

@ -427,7 +427,7 @@ public class ConstantPropagationContextEvaluator extends ContextEvaluatorAdapter
} }
SourceType mostTrusted = getMostTrustedParameterSource(func); SourceType mostTrusted = getMostTrustedParameterSource(func);
if (SourceType.ANALYSIS.isLowerPriorityThan(mostTrusted)) { if (mostTrusted.isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
return; return;
} }
} }

View file

@ -225,6 +225,8 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
continue; continue;
} }
// NOTE: DWARF may have applied function signature with IMPORTED source type but
// this analyzer must apply more details
Function func = markupSession.createFunctionIfMissing(funcname, funcns, funcAddr); Function func = markupSession.createFunctionIfMissing(funcname, funcns, funcAddr);
if (func == null || if (func == null ||
func.getSignatureSource().isHigherPriorityThan(SourceType.IMPORTED)) { func.getSignatureSource().isHigherPriorityThan(SourceType.IMPORTED)) {
@ -503,8 +505,8 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
Address mbStart = max.subtract(offset_from_eom + len - 1); Address mbStart = max.subtract(offset_from_eom + len - 1);
MemoryBlock newMB = MemoryBlock newMB =
MemoryBlockUtils.createUninitializedBlock(program, false, "ARTIFICAL_GOLANG_CONTEXT", MemoryBlockUtils.createUninitializedBlock(program, false, "ARTIFICAL_GOLANG_CONTEXT",
mbStart, len, "Artifical memory block created to hold Go context data types", mbStart, len, "Artifical memory block created to hold Go context data types", null,
null, true, true, false, null); true, true, false, null);
newMB.setArtificial(true); newMB.setArtificial(true);
return newMB.getStart(); return newMB.getStart();
} }
@ -1034,7 +1036,6 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
Register register, java.util.function.Function<GoType, DataType> returnTypeMapper) { Register register, java.util.function.Function<GoType, DataType> returnTypeMapper) {
} }
private GoRttiMapper goBinary; private GoRttiMapper goBinary;
private Program program; private Program program;
private MarkupSession markupSession; private MarkupSession markupSession;

View file

@ -109,8 +109,9 @@ public class PefAnalyzer extends AbstractAnalyzer {
} }
Function function = functions.next(); Function function = functions.next();
try { try {
program.getProgramContext().setRegisterValue(function.getEntryPoint(), program.getProgramContext()
function.getEntryPoint(), regVal); .setRegisterValue(function.getEntryPoint(), function.getEntryPoint(),
regVal);
} }
catch (ContextChangeException e) { catch (ContextChangeException e) {
// should never happen when changing r2 register // should never happen when changing r2 register
@ -149,11 +150,8 @@ public class PefAnalyzer extends AbstractAnalyzer {
return; return;
} }
Function function = listing.getFunctionContaining(instruction.getMinAddress()); Function function = listing.getFunctionContaining(instruction.getMinAddress());
if (function == null) { if (function == null ||
return; function.getSymbol().getSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
}
if (function.getSymbol().getSource() == SourceType.IMPORTED ||
function.getSymbol().getSource() == SourceType.USER_DEFINED) {
return; return;
} }
Symbol symbol = symbolTable.getPrimarySymbol(symbolAddress); Symbol symbol = symbolTable.getPrimarySymbol(symbolAddress);

View file

@ -717,11 +717,9 @@ public class ClearFlowAndRepairCmd extends BackgroundCommand<Program> {
continue; // do not include data continue; // do not include data
} }
Symbol s = symbolTable.getPrimarySymbol(blockAddr); Symbol s = symbolTable.getPrimarySymbol(blockAddr);
if (s != null && s.getSymbolType() == SymbolType.FUNCTION) { if (s != null && s.getSymbolType() == SymbolType.FUNCTION &&
SourceType source = s.getSource(); s.getSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
if (source == SourceType.USER_DEFINED || source == SourceType.IMPORTED) { continue;
continue; // keep imported or user-defined function
}
// TODO: GP-5872 Clearing thunks explicitly created by loader or pattern // TODO: GP-5872 Clearing thunks explicitly created by loader or pattern
// generally have default SourceType and may not have references // generally have default SourceType and may not have references
// to them. We need to prevent these thunks from getting cleared. // to them. We need to prevent these thunks from getting cleared.

View file

@ -378,8 +378,7 @@ public class DemangledFunction extends DemangledObject {
if (f != null && f.getSymbol().getSource() == SourceType.USER_DEFINED) { if (f != null && f.getSymbol().getSource() == SourceType.USER_DEFINED) {
return true; return true;
} }
if (f == null || f.getSignatureSource() == SourceType.DEFAULT || if (f == null || f.getSignatureSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
f.getSignatureSource() == SourceType.ANALYSIS) {
return false; return false;
} }
return super.isAlreadyDemangled(program, address); return super.isAlreadyDemangled(program, address);
@ -809,7 +808,7 @@ public class DemangledFunction extends DemangledObject {
continue; continue;
} }
// if the parameters source is higher than // if the parameters source is higher than
if (parameter.getSource().isHigherPriorityThan(SourceType.ANALYSIS)) { if (parameter.getSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
return true; return true;
} }
} }

View file

@ -150,12 +150,12 @@ public class DecompilerParameterIdCmd extends BackgroundCommand<Program> {
// since decompile could fail and leave the source types changed. // since decompile could fail and leave the source types changed.
Parameter retParam = func.getReturn(); Parameter retParam = func.getReturn();
if (retParam != null) { if (retParam != null) {
if (!retParam.getSource().isHigherPriorityThan(sourceTypeClearLevel)) { if (retParam.getSource().isLowerOrEqualPriorityThan(sourceTypeClearLevel)) {
func.setReturn(retParam.getDataType(), retParam.getVariableStorage(), func.setReturn(retParam.getDataType(), retParam.getVariableStorage(),
SourceType.DEFAULT); SourceType.DEFAULT);
} }
} }
if (!func.getSignatureSource().isHigherPriorityThan(sourceTypeClearLevel)) { if (func.getSignatureSource().isLowerOrEqualPriorityThan(sourceTypeClearLevel)) {
func.setSignatureSource(SourceType.DEFAULT); func.setSignatureSource(SourceType.DEFAULT);
} }
} }

View file

@ -174,12 +174,10 @@ public class OverridePrototypeAction extends AbstractDecompilerAction {
// for the initial signature. HighFunction does not make it easy to grab // for the initial signature. HighFunction does not make it easy to grab
// existing override prototype // existing override prototype
if (calledfunc != null) { if (calledfunc != null &&
SourceType signatureSource = calledfunc.getSignatureSource(); calledfunc.getSignatureSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
if (signatureSource == SourceType.DEFAULT || signatureSource == SourceType.ANALYSIS) {
calledfunc = null; // ignore calledfunc = null; // ignore
} }
}
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();

View file

@ -63,6 +63,8 @@ public class DecompilerParameterIDValidator extends PostAnalysisValidator {
if (inst != null) { if (inst != null) {
final SourceType signatureSource = func.getSignatureSource(); final SourceType signatureSource = func.getSignatureSource();
// TODO: There is a misconception that ANALYSIS source type can be used to
// determine if Param ID Analyzer has been used. This should be re-examined.
if (signatureSource == SourceType.ANALYSIS) { if (signatureSource == SourceType.ANALYSIS) {
++numFuncsWithParameterID; ++numFuncsWithParameterID;
} }

View file

@ -273,9 +273,8 @@ public class ApplyFidEntriesCommand extends BackgroundCommand<Program> {
SymbolTable symbolTable = program.getSymbolTable(); SymbolTable symbolTable = program.getSymbolTable();
SymbolIterator symbols = symbolTable.getSymbolsAsIterator(function.getEntryPoint()); SymbolIterator symbols = symbolTable.getSymbolsAsIterator(function.getEntryPoint());
for (Symbol symbol : symbols) { for (Symbol symbol : symbols) {
SourceType sourceType = symbol.getSource(); if (symbol.getSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
if (sourceType == SourceType.USER_DEFINED || sourceType == SourceType.IMPORTED) { return true; // symbol has trusted source
return true;
} }
} }
return false; return false;

View file

@ -2341,25 +2341,6 @@ public class DefaultPdbApplicator implements PdbApplicator {
} }
} }
//==============================================================================================
boolean shouldForcePrimarySymbol(Address address, boolean forceIfMangled) {
Symbol primarySymbol = program.getSymbolTable().getPrimarySymbol(address);
if (primarySymbol != null) {
if (primarySymbol.getName().startsWith("?") && forceIfMangled &&
applicatorOptions.allowDemotePrimaryMangledSymbols()) {
return true;
}
SourceType primarySymbolSource = primarySymbol.getSource();
if (!SourceType.ANALYSIS.isHigherPriorityThan(primarySymbolSource)) {
return true;
}
}
return false;
}
//============================================================================================== //==============================================================================================
boolean addToPlateUnique(Address address, String comment) { boolean addToPlateUnique(Address address, String comment) {
if (StringUtils.isBlank(comment)) { if (StringUtils.isBlank(comment)) {
@ -2411,8 +2392,8 @@ public class DefaultPdbApplicator implements PdbApplicator {
Function existingFunction = program.getListing().getFunctionAt(address); Function existingFunction = program.getListing().getFunctionAt(address);
if (existingFunction != null) { // Maybe I should care if there is a data type there too. if (existingFunction != null) { // Maybe I should care if there is a data type there too.
if (existingFunction.getSignatureSource().isHigherPriorityThan(SourceType.ANALYSIS)) { if (existingFunction.getSignatureSource()
// Existing is USER or IMPORTED .isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
return doCreateSymbol(address, symbolPath, false, plateAddition); return doCreateSymbol(address, symbolPath, false, plateAddition);
} }
} }

View file

@ -79,8 +79,7 @@ public class FunctionSymbolApplier extends AbstractBlockContextApplier
return applicator.getAddress(symbol); return applicator.getAddress(symbol);
} }
private void processSymbol(MsSymbolIterator iter) private void processSymbol(MsSymbolIterator iter) throws CancelledException, PdbException {
throws CancelledException, PdbException {
Address address = applicator.getAddress(symbol); Address address = applicator.getAddress(symbol);
String name = symbol.getName(); String name = symbol.getName();
@ -186,8 +185,7 @@ public class FunctionSymbolApplier extends AbstractBlockContextApplier
} }
// Remaining are non-thunks // Remaining are non-thunks
if (function.getSignatureSource().isHigherPriorityThan(SourceType.ANALYSIS)) { if (function.getSignatureSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
// return if IMPORTED or USER_DEFINED
return false; return false;
} }

View file

@ -86,8 +86,7 @@ public class ManagedProcedureSymbolApplier extends AbstractBlockContextApplier
// TODO. Investigate more. This is not working for at least one CLI dll in that we are // TODO. Investigate more. This is not working for at least one CLI dll in that we are
// not getting correct addresses. There is no omap and the one section is unnamed. // not getting correct addresses. There is no omap and the one section is unnamed.
private void processSymbol(MsSymbolIterator iter) private void processSymbol(MsSymbolIterator iter) throws CancelledException, PdbException {
throws CancelledException, PdbException {
Address address = applicator.getAddress(symbol); Address address = applicator.getAddress(symbol);
String name = symbol.getName(); String name = symbol.getName();
@ -124,8 +123,7 @@ public class ManagedProcedureSymbolApplier extends AbstractBlockContextApplier
} }
@Override @Override
public void deferredApply(MsSymbolIterator iter) public void deferredApply(MsSymbolIterator iter) throws PdbException, CancelledException {
throws PdbException, CancelledException {
// Pealing the symbol off again, as the iterator is coming in fresh, and we need the symbol // Pealing the symbol off again, as the iterator is coming in fresh, and we need the symbol
getValidatedSymbol(iter, true); getValidatedSymbol(iter, true);
@ -260,9 +258,8 @@ public class ManagedProcedureSymbolApplier extends AbstractBlockContextApplier
return; // silently return. return; // silently return.
} }
// Currently just placing a comment. // Currently just placing a comment.
String comment = String comment = context.getIndent(symbolBlockNestingLevel + 1) +
context.getIndent(symbolBlockNestingLevel + 1) + "static local (stored at " + "static local (stored at " + address + ") " + dataType.getName() + " " + name;
address + ") " + dataType.getName() + " " + name;
context.getComments().addPreComment(currentBlockAddress, comment); context.getComments().addPreComment(currentBlockAddress, comment);
} }
@ -300,8 +297,7 @@ public class ManagedProcedureSymbolApplier extends AbstractBlockContextApplier
private boolean setFunctionDefinition(Function function, Address address, private boolean setFunctionDefinition(Function function, Address address,
AbstractManagedProcedureMsSymbol symbol) throws CancelledException, PdbException { AbstractManagedProcedureMsSymbol symbol) throws CancelledException, PdbException {
if (function.getSignatureSource().isHigherPriorityThan(SourceType.ANALYSIS)) { if (function.getSignatureSource().isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
// return if IMPORTED or USER_DEFINED
return false; return false;
} }

View file

@ -106,8 +106,7 @@ public class SimilarSymbolNameProgramCorrelator extends VTAbstractProgramCorrela
if (!addressSet.contains(symbol.getAddress())) { if (!addressSet.contains(symbol.getAddress())) {
continue; continue;
} }
if (symbol.getSource() == SourceType.DEFAULT || if (symbol.getSource().isLowerOrEqualPriorityThan(SourceType.ANALYSIS)) {
symbol.getSource() == SourceType.ANALYSIS) {
continue; continue;
} }

View file

@ -979,38 +979,29 @@ public class FunctionSignatureStringable extends Stringable {
private boolean isFirstHigherPriorityWhenUserPriority(SourceType first, SourceType second, private boolean isFirstHigherPriorityWhenUserPriority(SourceType first, SourceType second,
boolean replaceSamePriorityNames) { boolean replaceSamePriorityNames) {
if (first == second && first != SourceType.DEFAULT) { if (first == SourceType.DEFAULT) {
return false;
}
if (first == second) {
return replaceSamePriorityNames; return replaceSamePriorityNames;
} }
if (first == SourceType.USER_DEFINED) { return first.isHigherPriorityThan(second);
return (second == SourceType.IMPORTED || second == SourceType.ANALYSIS ||
second == SourceType.DEFAULT);
}
if (first == SourceType.IMPORTED) {
return (second == SourceType.ANALYSIS || second == SourceType.DEFAULT);
}
if (first == SourceType.ANALYSIS) {
return (second == SourceType.DEFAULT);
}
return false;
} }
private boolean isFirstHigherPriorityWhenImportedPriority(SourceType first, SourceType second, private boolean isFirstHigherPriorityWhenImportedPriority(SourceType first, SourceType second,
boolean replaceSamePriorityNames) { boolean replaceSamePriorityNames) {
if (first == second && first != SourceType.DEFAULT) { if (first == SourceType.DEFAULT) {
return false;
}
if (first == second) {
return replaceSamePriorityNames; return replaceSamePriorityNames;
} }
// NOTE: If a new SourceType is added with a priority in between IMPORTED and USER_DEFINED
// VT and this code will need to change.
if (first == SourceType.IMPORTED) { if (first == SourceType.IMPORTED) {
return (second == SourceType.USER_DEFINED || second == SourceType.ANALYSIS || return true; // IMPORTED is highest priority
second == SourceType.DEFAULT);
} }
if (first == SourceType.USER_DEFINED) { return first.isHigherPriorityThan(second);
return (second == SourceType.ANALYSIS || second == SourceType.DEFAULT);
}
if (first == SourceType.ANALYSIS) {
return (second == SourceType.DEFAULT);
}
return false;
} }
private void replaceParameterComments(Function toFunction, CommentChoices commentChoice) { private void replaceParameterComments(Function toFunction, CommentChoices commentChoice) {

View file

@ -585,12 +585,9 @@ public class FunctionDB extends DatabaseObject implements Function {
if (Undefined.isUndefined(variableDataType)) { if (Undefined.isUndefined(variableDataType)) {
return; return;
} }
SourceType type = SourceType.ANALYSIS; // TODO: It seems that the lowest parameter priority should win out (see GP-6013)
if (variableSourceType != type && variableSourceType.isHigherPriorityThan(type)) { if (variableSourceType.isHigherPriorityThan(getStoredSignatureSource())) {
type = variableSourceType; setSignatureSource(variableSourceType);
}
if (type.isHigherPriorityThan(getStoredSignatureSource())) {
setSignatureSource(type);
} }
} }
@ -604,14 +601,14 @@ public class FunctionDB extends DatabaseObject implements Function {
boolean isReturnUndefined = Undefined.isUndefined(returnType); boolean isReturnUndefined = Undefined.isUndefined(returnType);
SourceType type = isReturnUndefined ? SourceType.DEFAULT : SourceType.ANALYSIS; SourceType type = isReturnUndefined ? SourceType.DEFAULT : SourceType.ANALYSIS;
// TODO: It seems that the lowest parameter priority should win out (see GP-6013)
Parameter[] parameters = getParameters(); Parameter[] parameters = getParameters();
for (Parameter parameter : parameters) { for (Parameter parameter : parameters) {
if (Undefined.isUndefined(parameter.getDataType())) { if (Undefined.isUndefined(parameter.getDataType())) {
continue; continue;
} }
SourceType paramSourceType = parameter.getSource(); SourceType paramSourceType = parameter.getSource();
if (paramSourceType != SourceType.ANALYSIS && if (paramSourceType.isHigherOrEqualPriorityThan(SourceType.IMPORTED)) {
paramSourceType.isHigherPriorityThan(SourceType.ANALYSIS)) {
type = paramSourceType; type = paramSourceType;
} }
else { else {
@ -1458,7 +1455,7 @@ public class FunctionDB extends DatabaseObject implements Function {
symbolMap.put(s, paramDb); symbolMap.put(s, paramDb);
} }
if (source.isHigherPriorityThan(getStoredSignatureSource())) { if (source != getStoredSignatureSource()) {
setSignatureSource(source); setSignatureSource(source);
} }

View file

@ -42,7 +42,7 @@ public enum SourceType {
} }
/** /**
* Determines if this source type is a higher priority than the one being * Determine if this source type has a higher priority than the one being
* passed to this method as a parameter. * passed to this method as a parameter.
* USER_DEFINED objects are higher priority than IMPORTED objects which are higher * USER_DEFINED objects are higher priority than IMPORTED objects which are higher
* priority than ANALYSIS objects which are higher priority than DEFAULT objects. * priority than ANALYSIS objects which are higher priority than DEFAULT objects.
@ -55,7 +55,20 @@ public enum SourceType {
} }
/** /**
* Determines if this source type is a lower priority than the one being * Determine if this source type has the same or higher priority than the one being
* passed to this method as a parameter.
* USER_DEFINED objects are higher priority than IMPORTED objects which are higher
* priority than ANALYSIS objects which are higher priority than DEFAULT objects.
* @param source the source type whose priority is to be compared with this one's.
* @return true if this source type is a higher priority.
* false if this source type is the same priority or lower priority.
*/
public boolean isHigherOrEqualPriorityThan(SourceType source) {
return this.priority >= source.priority;
}
/**
* Determine if this source type has a lower priority than the one being
* passed to this method as a parameter. * passed to this method as a parameter.
* DEFAULT objects are lower priority than ANALYSIS objects which are lower * DEFAULT objects are lower priority than ANALYSIS objects which are lower
* priority than IMPORTED objects which are lower priority than USER_DEFINED objects. * priority than IMPORTED objects which are lower priority than USER_DEFINED objects.
@ -66,4 +79,17 @@ public enum SourceType {
public boolean isLowerPriorityThan(SourceType source) { public boolean isLowerPriorityThan(SourceType source) {
return this.priority < source.priority; return this.priority < source.priority;
} }
/**
* Determine if this source type has the same or lower priority than the one being
* passed to this method as a parameter.
* DEFAULT objects are lower priority than ANALYSIS objects which are lower
* priority than IMPORTED objects which are lower priority than USER_DEFINED objects.
* @param source the source type whose priority is to be compared with this one's.
* @return true if this source type is a lower priority.
* false if this source type is the same priority or higher priority.
*/
public boolean isLowerOrEqualPriorityThan(SourceType source) {
return this.priority <= source.priority;
}
} }