| 178 | |
| 179 | |
| 180 | void RenderLayer::ApplyToLinearViewObject( |
| 181 | Ref<LinearViewObject> obj, |
| 182 | Ref<LinearViewObject> prev, |
| 183 | Ref<LinearViewObject> next, |
| 184 | std::vector<LinearDisassemblyLine>& lines |
| 185 | ) |
| 186 | { |
| 187 | // Hack: HLIL bodies don't have basic blocks |
| 188 | if (!lines.empty() && |
| 189 | (obj->GetIdentifier().name == "HLIL Function Body" |
| 190 | || obj->GetIdentifier().name == "HLIL SSA Function Body" |
| 191 | || obj->GetIdentifier().name == "Language Representation Function Body")) |
| 192 | { |
| 193 | ApplyToHighLevelILBody(lines[0].function, lines); |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | std::vector<LinearDisassemblyLine> blockLines; |
| 198 | std::vector<LinearDisassemblyLine> finalLines; |
| 199 | Ref<BasicBlock> lastBlock; |
| 200 | |
| 201 | auto finishBlock = [&]() |
| 202 | { |
| 203 | if (!blockLines.empty()) |
| 204 | { |
| 205 | if (lastBlock) |
| 206 | { |
| 207 | // Convert linear lines to disassembly lines for the apply() |
| 208 | // and then convert back for linear view |
| 209 | std::vector<LinearDisassemblyLine> newBlockLines; |
| 210 | std::vector<DisassemblyTextLine> disasmLines; |
| 211 | std::vector<LinearDisassemblyLine> miscLines; |
| 212 | |
| 213 | auto processDisasm = [&]() |
| 214 | { |
| 215 | if (!disasmLines.empty()) |
| 216 | { |
| 217 | ApplyToBlock(lastBlock, disasmLines); |
| 218 | Ref<Function> func = blockLines[0].function; |
| 219 | Ref<BasicBlock> block = blockLines[0].block; |
| 220 | for (auto& blockLine: disasmLines) |
| 221 | { |
| 222 | LinearDisassemblyLine newLine; |
| 223 | newLine.type = CodeDisassemblyLineType; |
| 224 | newLine.function = func; |
| 225 | newLine.block = block; |
| 226 | newLine.contents = blockLine; |
| 227 | newBlockLines.push_back(newLine); |
| 228 | } |
| 229 | disasmLines.clear(); |
| 230 | } |
| 231 | }; |
| 232 | |
| 233 | auto processMisc = [&]() |
| 234 | { |
| 235 | if (!miscLines.empty()) |
| 236 | { |
| 237 | ApplyToMiscLinearLines(obj, prev, next, miscLines); |
no test coverage detected