mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-2451 addressing code review comments
GP-2451_James_program_specific_address_spaces_pcode_field
This commit is contained in:
parent
fb05c4ecd2
commit
c9b1b3c9ab
2 changed files with 20 additions and 8 deletions
|
@ -86,9 +86,8 @@ public class PcodeFieldFactory extends FieldFactory {
|
|||
|
||||
ArrayList<TextFieldElement> elements = new ArrayList<>();
|
||||
|
||||
List<AttributedString> pcodeListing =
|
||||
formatter.formatOps(instr.getProgram().getLanguage(),
|
||||
Arrays.asList(instr.getPcode(true)));
|
||||
List<AttributedString> pcodeListing = formatter.formatOps(instr.getProgram().getLanguage(),
|
||||
instr.getProgram().getAddressFactory(), Arrays.asList(instr.getPcode(true)));
|
||||
int lineCnt = pcodeListing.size();
|
||||
for (int i = 0; i < lineCnt; i++) {
|
||||
elements.add(new TextFieldElement(pcodeListing.get(i), i, 0));
|
||||
|
@ -129,8 +128,8 @@ public class PcodeFieldFactory extends FieldFactory {
|
|||
Instruction instr = (Instruction) obj;
|
||||
Program program = instr.getProgram();
|
||||
|
||||
List<AttributedString> attributedStrings =
|
||||
formatter.formatOps(program.getLanguage(), Arrays.asList(instr.getPcode(true)));
|
||||
List<AttributedString> attributedStrings = formatter.formatOps(program.getLanguage(),
|
||||
program.getAddressFactory(), Arrays.asList(instr.getPcode(true)));
|
||||
List<String> strings = new ArrayList<>(attributedStrings.size());
|
||||
for (AttributedString attributedString : attributedStrings) {
|
||||
strings.add(attributedString.getText());
|
||||
|
|
|
@ -26,15 +26,28 @@ import ghidra.program.model.pcode.Varnode;
|
|||
|
||||
public interface PcodeFormatter<T> {
|
||||
/**
|
||||
* Format the the p-code ops
|
||||
* Format the p-code ops
|
||||
*
|
||||
* @param language the language generating the p-code
|
||||
* @param pcodeOps the p-code ops
|
||||
* @return the formatted result
|
||||
*/
|
||||
default T formatOps(Language language, List<PcodeOp> pcodeOps) {
|
||||
return formatTemplates(language,
|
||||
getPcodeOpTemplates(language.getAddressFactory(), pcodeOps));
|
||||
return formatOps(language, language.getAddressFactory(), pcodeOps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the pcode ops with a specified {@link AddressFactory}. For use when the
|
||||
* pcode ops can reference program-specific address spaces.
|
||||
*
|
||||
* @param language the language generating the p-code
|
||||
* @param addrFactory addressFactory to use when generating pcodeop templates
|
||||
* @param pcodeOps p-code ops to format
|
||||
* @return the formatted result
|
||||
*
|
||||
*/
|
||||
default T formatOps(Language language, AddressFactory addrFactory, List<PcodeOp> pcodeOps) {
|
||||
return formatTemplates(language, getPcodeOpTemplates(addrFactory, pcodeOps));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue