Files
revng-revng/lib/Backend/DecompiledYAMLToC.cpp
T
Djordje Todorovic 286eb4d734 c-backend: Introduce PTMLCBuilder
This will be used to generate plain C.
2023-06-09 15:40:23 +02:00

33 lines
1.1 KiB
C++

//
// Copyright rev.ng Labs Srl. See LICENSE.md for details.
//
#include "llvm/Support/raw_ostream.h"
#include "revng-c/Backend/DecompiledYAMLToC.h"
using namespace revng::pipes;
void printSingleCFile(llvm::raw_ostream &Out,
ptml::PTMLCBuilder &ThePTMLCBuilder,
const DecompiledCCodeInYAMLStringMap &Functions,
const std::set<MetaAddress> &Targets) {
auto Scope = ThePTMLCBuilder.getTag(ptml::tags::Div).scope(Out);
// Print headers
Out << ThePTMLCBuilder.getIncludeQuote("revng-model-declarations.h")
<< ThePTMLCBuilder.getIncludeQuote("revng-qemu-helpers-declarations.h")
<< "\n";
if (Targets.empty()) {
// If Targets is empty print all the Functions' bodies
for (const auto &[MetaAddress, CFunction] : Functions)
Out << CFunction << '\n';
} else {
// Otherwise only print the bodies of the Targets
auto End = Functions.end();
for (const auto &MetaAddress : Targets)
if (auto It = Functions.find(MetaAddress); It != End)
Out << It->second << '\n';
}
}