]> git.lizzy.rs Git - rust.git/commitdiff
Added fix to LLDB formatter
authorKelvin Ly <kelvin.ly1618@gmail.com>
Mon, 5 Jan 2015 04:35:29 +0000 (23:35 -0500)
committerKelvin Ly <kelvin.ly1618@gmail.com>
Mon, 5 Jan 2015 04:35:29 +0000 (23:35 -0500)
src/etc/gdb_rust_pretty_printing.py
src/etc/lldb_rust_formatters.py

index 3abef3dda83aabf55770e69a98076c88df180676..6e9aa6e80ce8cf734acf4ad8d7479a9324d86028 100755 (executable)
@@ -62,10 +62,10 @@ def rust_pretty_printer_lookup_function(val):
         assert first_variant_name.startswith("RUST$ENCODED$ENUM$")
         # This is a space-optimized enum
         last_separator_index = first_variant_name.rfind("$")
-        start_index = len("RUST$ENCODED$ENUM")
-        disr_field_indices = first_variant_name[start_index + 1 :
-                                              last_separator_index]
-        disr_field_indices = [int(index) for index in disr_field_indices.split("$")]
+        start_index = len("RUST$ENCODED$ENUM$")
+        disr_field_indices = first_variant_name[start_index :
+                                              last_separator_index].split("$")
+        disr_field_indices = [int(index) for index in disr_field_indices]
 
         sole_variant_val = val[enum_members[0]]
         discriminant = sole_variant_val
index f4f1a5121d1957a06862c97efa11f89a4fa25c5d..b9bb3ec4fe9191b08ba01f590dac2c4d569b33fb 100644 (file)
@@ -79,11 +79,11 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
   has_field_names = type_has_field_names(t)
 
   if has_field_names:
-      template = "%(type_name)s {\n%(body)s\n}"
-      separator = ", \n"
+    template = "%(type_name)s {\n%(body)s\n}"
+    separator = ", \n"
   else:
-      template = "%(type_name)s(%(body)s)"
-      separator = ", "
+    template = "%(type_name)s(%(body)s)"
+    separator = ", "
 
   if type_name.startswith("("):
     # this is a tuple, so don't print the type name
@@ -125,20 +125,20 @@ def print_enum_val(val, internal_dict):
       if last_separator_index == -1:
         return "<invalid enum encoding: %s>" % first_variant_name
 
-      second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index)
-      if second_last_separator_index == -1:
-        return "<invalid enum encoding: %s>" % first_variant_name
+      start_index = len("RUST$ENCODED$ENUM$")
 
-      # Extract index of the discriminator field
+      # Extract indices of the discriminator field
       try:
-        disr_field_index = first_variant_name[second_last_separator_index + 1 :
-                                              last_separator_index]
-        disr_field_index = int(disr_field_index)
+        disr_field_indices = first_variant_name[start_index :
+                                              last_separator_index].split("$")
+        disr_field_indices = [int(index) for index in dis_field_indices]
       except:
         return "<invalid enum encoding: %s>" % first_variant_name
 
       # Read the discriminant
-      disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index)
+      disr_val = val.GetChildAtIndex(0)
+      for index in disr_field_indices:
+        disr_val = disr_val.GetChildAtIndex(disr_field_index)
 
       # If the discriminant field is a fat pointer we have to consider the
       # first word as the true discriminant