MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / insert

Method insert

plugins/pdb-ng/src/struct_grouper.rs:126–266  ·  view source on GitHub ↗
(&mut self, other: WorkingStruct, recursion: usize)

Source from the content-addressed store, hash-verified

124 }
125
126 pub fn insert(&mut self, other: WorkingStruct, recursion: usize) -> Result<()> {
127 log(|| {
128 format!("{}self: {:#?}", " ".repeat(recursion), self)
129 .replace("\n", &("\n".to_owned() + &" ".repeat(recursion)))
130 });
131 log(|| {
132 format!("{}other: {:#?}", " ".repeat(recursion), other)
133 .replace("\n", &("\n".to_owned() + &" ".repeat(recursion)))
134 });
135
136 self.extend_to(other.end());
137
138 // There are 2 cases we have to deal with here:
139 // a. `other` starts after the end of the last group => insert `other` into the last group
140 // b. `other` starts before the end of the last group => collect all the children inserted after it starts and put them into a struct
141 // start a new struct with `other`
142
143 if self.children.is_empty() {
144 self.children.push(other);
145 return Ok(());
146 }
147
148 // This is really gross.
149 // But also I need to ship this before I leave for France
150 // TODO: Clean this up
151
152 if other.start()
153 >= self
154 .children
155 .last()
156 .ok_or_else(|| anyhow!("Expected we have children #A"))?
157 .end()
158 {
159 self.children.push(other);
160 } else {
161 // Create a structure with fields from self.children
162 if self
163 .children
164 .last()
165 .ok_or_else(|| anyhow!("Expected we have children #B"))?
166 .index
167 .is_none()
168 && self
169 .children
170 .last()
171 .ok_or_else(|| anyhow!("Expected we have children #C"))?
172 .start()
173 < other.start()
174 {
175 self.children
176 .last_mut()
177 .ok_or_else(|| anyhow!("Expected we have children #D"))?
178 .insert(other, recursion + 1)?;
179 return Ok(());
180 }
181
182 // If we're a union, we don't have to bother pushing a struct+union combo
183 if self.is_union {

Callers 15

collect_nameMethod · 0.45
resolve_missing_ntrsMethod · 0.45
parse_typesMethod · 0.45
handle_type_indexMethod · 0.45
handle_procedure_typeMethod · 0.45
parse_union_fieldsMethod · 0.45
insert_this_pointerMethod · 0.45
can_fit_in_registerMethod · 0.45
group_structureFunction · 0.45

Calls 11

extend_toMethod · 0.80
lastMethod · 0.80
last_mutMethod · 0.80
logFunction · 0.70
replaceMethod · 0.45
to_ownedMethod · 0.45
endMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
startMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected