4 #ifndef CHI_GRAPH_MODULE_HPP 5 #define CHI_GRAPH_MODULE_HPP 12 #include <boost/bimap.hpp> 22 const std::vector<boost::filesystem::path>&
dependencies = {});
34 std::unique_ptr<NodeType>* toFill)
override;
39 std::vector<std::string>
typeNames()
const override;
73 std::vector<NamedDataType> dataOuts,
74 std::vector<std::string> execIns,
75 std::vector<std::string> execOuts,
bool* inserted =
nullptr);
81 bool removeFunction(boost::string_view name,
bool deleteReferences =
true);
95 const std::vector<std::unique_ptr<GraphFunction>>&
functions()
const {
return mFunctions; }
102 const std::vector<std::unique_ptr<GraphStruct>>& structs()
const {
return mStructs; }
146 std::vector<std::string> clangArgs,
147 std::unique_ptr<NodeType>* toFill);
157 std::vector<std::unique_ptr<GraphFunction>> mFunctions;
158 std::vector<std::unique_ptr<GraphStruct>> mStructs;
160 bool mCEnabled =
false;
164 #endif // CHI_GRAPH_MODULE_HPP Result saveToDisk() const
Serialize to disk in the context.
this is an AST-like representation of a function in a graph It is used for IDE-like behavior...
Result generateModule(llvm::Module &module) override
Generate a llvm::Module from the module.
Forward declares all the chigraph data types.
boost::filesystem::path pathToCSources() const
Get the path to the .c directory. It is not garunteed to exist, even if cEnabled() is true...
A class holding a compound type defined in a GraphModule.
boost::bimap< unsigned, NodeInstance * > createLineNumberAssoc() const
Create the associations from line number and function in debug info.
const std::vector< std::unique_ptr< GraphFunction > > & functions() const
Get functions.
GraphFunction * functionFromName(boost::string_view name) const
Get a function from the name.
GraphStruct * structFromName(boost::string_view name) const
Get a struct by name.
void setCEnabled(bool newValue)
Set if C support is enabled.
bool removeStruct(boost::string_view name)
Remove a struct from the module by name.
GraphFunction * getOrCreateFunction(std::string name, std::vector< NamedDataType > dataIns, std::vector< NamedDataType > dataOuts, std::vector< std::string > execIns, std::vector< std::string > execOuts, bool *inserted=nullptr)
Create a new function if it does't already exist.
std::string fullName() const
Get the full name of the module.
The class that handles the loading, creation, storing, and compilation of modules It also stores a LL...
An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module...
boost::filesystem::path sourceFilePath() const
Get the path to the source file It's not garunteed to exist, because it could have not been saved...
bool cEnabled() const
Gets if C support is enabled.
std::vector< std::string > nodeTypeNames() const override
Get the possible node type names.
GraphStruct * getOrCreateStruct(std::string name, bool *inserted=nullptr)
Create a new struct in the module.
const std::set< boost::filesystem::path > & dependencies() const
Get the dependencies.
Result addForwardDeclarations(llvm::Module &module) const override
Adds forward declartions for the functions in this module.
std::vector< std::string > typeNames() const override
Get the possible DataType names.
Result nodeTypeFromName(boost::string_view name, const nlohmann::json &jsonData, std::unique_ptr< NodeType > *toFill) override
Create a node type that is in the module from the name and json.
GraphModule(Context &cont, boost::filesystem::path fullName, const std::vector< boost::filesystem::path > &dependencies={})
Construct a GraphModule.
Defines the ChiModule class.
DataType typeFromName(boost::string_view name) override
Get a DataType from the name.
Module that holds graph functions.
The namespace where chigraph lives.
A type of data Loose wrapper around llvm::Type*, except it knows which ChiModule it's in and it embed...
std::string shortName() const
Get the short name of the module (the last bit)
The result object, used for identifiying errors with good diagnostics.
Result createNodeTypeFromCCode(boost::string_view code, boost::string_view functionName, std::vector< std::string > clangArgs, std::unique_ptr< NodeType > *toFill)
From C code, create a NodeType.
bool removeFunction(boost::string_view name, bool deleteReferences=true)
Remove a function from the module.