]> git.proxmox.com Git - rustc.git/blobdiff - src/etc/debugger_pretty_printers_common.py
New upstream version 1.13.0+dfsg1
[rustc.git] / src / etc / debugger_pretty_printers_common.py
index b2bb7859661ab63aae27658359731647887741f9..eb562877c85732702a0d449808f67f4d463fd030 100644 (file)
@@ -324,3 +324,20 @@ def extract_length_and_ptr_from_slice(slice_val):
 
     assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
     return (length, data_ptr)
+
+UNQUALIFIED_TYPE_MARKERS = frozenset(["(", "[", "&", "*"])
+
+def extract_type_name(qualified_type_name):
+    """Extracts the type name from a fully qualified path"""
+    if qualified_type_name[0] in UNQUALIFIED_TYPE_MARKERS:
+        return qualified_type_name
+
+    end_of_search = qualified_type_name.find("<")
+    if end_of_search < 0:
+        end_of_search = len(qualified_type_name)
+
+    index = qualified_type_name.rfind("::", 0, end_of_search)
+    if index < 0:
+        return qualified_type_name
+    else:
+        return qualified_type_name[index + 2:]