mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Refactor namespaces to use ids
This commit is contained in:
parent
7329198ad7
commit
44ed318672
9 changed files with 164 additions and 72 deletions
|
@ -618,25 +618,39 @@ public class HighFunction extends PcodeSyntaxTree {
|
|||
}
|
||||
}
|
||||
|
||||
static public void createNamespaceTag(StringBuilder buf, Namespace namespc) {
|
||||
if (namespc == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> arr = new ArrayList<String>();
|
||||
Namespace curspc = namespc;
|
||||
while (curspc != null) {
|
||||
arr.add(0, curspc.getName());
|
||||
if (curspc instanceof Library) {
|
||||
break; // Treat library namespace as root
|
||||
/**
|
||||
* Append an XML <parent> tag to the buffer describing the formal path elements
|
||||
* from the root (global) namespace up to the given namespace
|
||||
* @param buf is the buffer to write to
|
||||
* @param namespace is the namespace being described
|
||||
* @param includeId is true if the XML tag should include namespace ids
|
||||
*/
|
||||
static public void createNamespaceTag(StringBuilder buf, Namespace namespace,
|
||||
boolean includeId) {
|
||||
buf.append("<parent>\n");
|
||||
if (namespace != null) {
|
||||
ArrayList<Namespace> arr = new ArrayList<Namespace>();
|
||||
Namespace curspc = namespace;
|
||||
while (curspc != null) {
|
||||
arr.add(0, curspc);
|
||||
if (curspc instanceof Library) {
|
||||
break; // Treat library namespace as root
|
||||
}
|
||||
curspc = curspc.getParentNamespace();
|
||||
}
|
||||
buf.append("<val/>\n"); // Force global scope to have empty name
|
||||
for (int i = 1; i < arr.size(); ++i) {
|
||||
Namespace curScope = arr.get(i);
|
||||
buf.append("<val");
|
||||
if (includeId) {
|
||||
SpecXmlUtils.encodeUnsignedIntegerAttribute(buf, "id", curScope.getID());
|
||||
}
|
||||
buf.append('>');
|
||||
SpecXmlUtils.xmlEscape(buf, curScope.getName());
|
||||
buf.append("</val>\n");
|
||||
}
|
||||
curspc = curspc.getParentNamespace();
|
||||
}
|
||||
buf.append("<val/>\n"); // Force global scope to have empty name
|
||||
for (int i = 1; i < arr.size(); ++i) {
|
||||
buf.append("<val>");
|
||||
SpecXmlUtils.xmlEscape(buf, arr.get(i));
|
||||
buf.append("</val>\n");
|
||||
}
|
||||
buf.append("</parent>\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -338,9 +338,7 @@ public class LocalSymbolMap {
|
|||
resBuf.append("<scope");
|
||||
SpecXmlUtils.xmlEscapeAttribute(resBuf, "name", func.getFunction().getName());
|
||||
resBuf.append(">\n");
|
||||
resBuf.append("<parent>\n");
|
||||
HighFunction.createNamespaceTag(resBuf, namespace);
|
||||
resBuf.append("</parent>\n");
|
||||
HighFunction.createNamespaceTag(resBuf, namespace, false);
|
||||
resBuf.append("<rangelist/>\n"); // Empty address range
|
||||
resBuf.append("<symbollist>\n");
|
||||
Iterator<HighSymbol> iter = symbolMap.values().iterator();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue