|
47 | 47 | TYPE_KIND_FIXED_SIZE_VEC = 16
|
48 | 48 | TYPE_KIND_REGULAR_UNION = 17
|
49 | 49 | TYPE_KIND_OS_STRING = 18
|
| 50 | +TYPE_KIND_STD_VECDEQUE = 19 |
50 | 51 |
|
51 | 52 | ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$"
|
52 | 53 | ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR"
|
|
62 | 63 | STD_VEC_FIELD_NAMES = [STD_VEC_FIELD_NAME_BUF,
|
63 | 64 | STD_VEC_FIELD_NAME_LENGTH]
|
64 | 65 |
|
| 66 | +# std::collections::VecDeque<> related constants |
| 67 | +STD_VECDEQUE_FIELD_NAME_TAIL = "tail" |
| 68 | +STD_VECDEQUE_FIELD_NAME_HEAD = "head" |
| 69 | +STD_VECDEQUE_FIELD_NAME_BUF = "buf" |
| 70 | +STD_VECDEQUE_FIELD_NAMES = [STD_VECDEQUE_FIELD_NAME_TAIL, |
| 71 | + STD_VECDEQUE_FIELD_NAME_HEAD, |
| 72 | + STD_VECDEQUE_FIELD_NAME_BUF] |
| 73 | + |
65 | 74 | # std::String related constants
|
66 | 75 | STD_STRING_FIELD_NAMES = ["vec"]
|
67 | 76 |
|
@@ -161,6 +170,11 @@ def __classify_struct(self):
|
161 | 170 | self.__conforms_to_field_layout(STD_VEC_FIELD_NAMES)):
|
162 | 171 | return TYPE_KIND_STD_VEC
|
163 | 172 |
|
| 173 | + # STD COLLECTION VECDEQUE |
| 174 | + if (unqualified_type_name.startswith("VecDeque<") and |
| 175 | + self.__conforms_to_field_layout(STD_VECDEQUE_FIELD_NAMES)): |
| 176 | + return TYPE_KIND_STD_VECDEQUE |
| 177 | + |
164 | 178 | # STD STRING
|
165 | 179 | if (unqualified_type_name.startswith("String") and
|
166 | 180 | self.__conforms_to_field_layout(STD_STRING_FIELD_NAMES)):
|
@@ -325,6 +339,25 @@ def extract_length_ptr_and_cap_from_std_vec(vec_val):
|
325 | 339 | assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR
|
326 | 340 | return (length, data_ptr, capacity)
|
327 | 341 |
|
| 342 | + |
| 343 | +def extract_tail_head_ptr_and_cap_from_std_vecdeque(vec_val): |
| 344 | + assert vec_val.type.get_type_kind() == TYPE_KIND_STD_VECDEQUE |
| 345 | + tail_field_index = STD_VECDEQUE_FIELD_NAMES.index(STD_VECDEQUE_FIELD_NAME_TAIL) |
| 346 | + head_field_index = STD_VECDEQUE_FIELD_NAMES.index(STD_VECDEQUE_FIELD_NAME_HEAD) |
| 347 | + buf_field_index = STD_VECDEQUE_FIELD_NAMES.index(STD_VECDEQUE_FIELD_NAME_BUF) |
| 348 | + |
| 349 | + tail = vec_val.get_child_at_index(tail_field_index).as_integer() |
| 350 | + head = vec_val.get_child_at_index(head_field_index).as_integer() |
| 351 | + buf = vec_val.get_child_at_index(buf_field_index) |
| 352 | + |
| 353 | + vec_ptr_val = buf.get_child_at_index(0) |
| 354 | + capacity = buf.get_child_at_index(1).as_integer() |
| 355 | + unique_ptr_val = vec_ptr_val.get_child_at_index(0) |
| 356 | + data_ptr = unique_ptr_val.get_child_at_index(0) |
| 357 | + assert data_ptr.type.get_dwarf_type_kind() == DWARF_TYPE_CODE_PTR |
| 358 | + return (tail, head, data_ptr, capacity) |
| 359 | + |
| 360 | + |
328 | 361 | def extract_length_and_ptr_from_slice(slice_val):
|
329 | 362 | assert (slice_val.type.get_type_kind() == TYPE_KIND_SLICE or
|
330 | 363 | slice_val.type.get_type_kind() == TYPE_KIND_STR_SLICE)
|
|
0 commit comments