mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
a8a8da3bae
This commit imports all the revng pipes (and other support utilities) to be used with `revng-pipeline`. In particular, the pipes necessary for binary translations have been introduced.
33 lines
921 B
C++
33 lines
921 B
C++
/// \file ModelGlobal.cpp
|
|
/// \brief The model global is a wrapper around a model to be used in the
|
|
/// pipeline context
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/Pipes/ModelGlobal.h"
|
|
|
|
using namespace std;
|
|
using namespace pipeline;
|
|
using namespace revng::pipes;
|
|
|
|
const char ModelGlobal::ID = '0';
|
|
|
|
llvm::Error ModelGlobal::storeToDisk(llvm::StringRef Path) const {
|
|
return serializeToFile(Model.getReadOnlyModel(), Path);
|
|
}
|
|
|
|
llvm::Error ModelGlobal::loadFromDisk(llvm::StringRef Path) {
|
|
if (not llvm::sys::fs::exists(Path))
|
|
return llvm::Error::success();
|
|
|
|
auto MaybeModel = TupleTree<model::Binary>::fromFile(Path);
|
|
if (not MaybeModel)
|
|
return llvm::make_error<llvm::StringError>("Could not parse model",
|
|
MaybeModel.getError());
|
|
|
|
Model = std::move(*MaybeModel);
|
|
return llvm::Error::success();
|
|
}
|