mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
f05c08547d
By using this class we can create ptml::Tags without XML tags. It is useful in the revng-c part when we want to generate Plain C. All PTML Tags, from now on, should be created via this class only. In addition, port `Yield` library to be using this.
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/Model/Binary.h"
|
|
#include "revng/Pipeline/Pipe.h"
|
|
#include "revng/Pipeline/RegisterContainerFactory.h"
|
|
#include "revng/Pipeline/RegisterPipe.h"
|
|
#include "revng/Pipes/Kinds.h"
|
|
#include "revng/Pipes/ModelGlobal.h"
|
|
#include "revng/Yield/Function.h"
|
|
#include "revng/Yield/Pipes/YieldControlFlow.h"
|
|
#include "revng/Yield/SVG.h"
|
|
|
|
using ptml::PTMLBuilder;
|
|
|
|
namespace revng::pipes {
|
|
|
|
void YieldControlFlow::run(pipeline::Context &Context,
|
|
const FunctionAssemblyStringMap &Input,
|
|
FunctionControlFlowStringMap &Output) {
|
|
// Access the model
|
|
const auto &Model = revng::getModelFromContext(Context);
|
|
ptml::PTMLBuilder ThePTMLBuilder;
|
|
|
|
for (auto [Address, S] : Input) {
|
|
auto MaybeFunction = TupleTree<yield::Function>::deserialize(S);
|
|
revng_assert(MaybeFunction && MaybeFunction->verify());
|
|
revng_assert((*MaybeFunction)->Entry() == Address);
|
|
|
|
Output.insert_or_assign((*MaybeFunction)->Entry(),
|
|
yield::svg::controlFlowGraph(ThePTMLBuilder,
|
|
**MaybeFunction,
|
|
*Model));
|
|
}
|
|
}
|
|
|
|
void YieldControlFlow::print(const pipeline::Context &,
|
|
llvm::raw_ostream &OS,
|
|
llvm::ArrayRef<std::string> Files) const {
|
|
OS << "[this is a pure pipe, no command exists for its invocation]\n";
|
|
}
|
|
|
|
} // end namespace revng::pipes
|
|
|
|
using namespace revng::pipes;
|
|
static RegisterFunctionStringMap<FunctionControlFlowStringMap> GraphContainer;
|
|
|
|
static pipeline::RegisterPipe<revng::pipes::YieldControlFlow> CFGPipe;
|