MCPcopy Create free account
hub / github.com/chigraph/chigraph / ChiModule

Class ChiModule

libchigraph/include/chi/ChiModule.hpp:24–117  ·  view source on GitHub ↗

An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module

Source from the content-addressed store, hash-verified

22/// An abstract class that represents a module of code in Chigraph
23/// Can be compiled to a llvm::Module
24struct ChiModule {
25 /// Default constructor. This is usually run by Context::loadModule
26 /// \param contextArg The context to create the module insides
27 /// \param moduleFullName The full name of the module
28 ChiModule(Context& contextArg, boost::filesystem::path moduleFullName);
29
30 /// Destructor
31 virtual ~ChiModule() = default;
32
33 /// Create a node type that is in the module from the name and json
34 /// \param name The name of the node type to create
35 /// \param jsonData The extra JSON data for the node
36 /// \retval toFill The NodeType object to fill
37 /// \pre toFill isn't null (the value the unique_ptr points to be can be null, but not the
38 /// pointer to the unique_ptr)
39 /// \return The result
40 virtual Result nodeTypeFromName(boost::string_view name, const nlohmann::json& jsonData,
41 std::unique_ptr<NodeType>* toFill) = 0;
42
43 /// Get a DataType from the name
44 /// \param name The name of the type
45 /// \return The data type, or an invalid DataType if failed
46 virtual DataType typeFromName(boost::string_view name) = 0;
47
48 /// Get the possible node type names
49 /// \return A std::vector of the possible names
50 virtual std::vector<std::string> nodeTypeNames() const = 0;
51
52 /// Get the possible DataType names
53 /// \return A `std::vector` of all the names of types this module has
54 virtual std::vector<std::string> typeNames() const = 0;
55
56 /// Get the short name of the module (the last bit)
57 /// \return The name
58 std::string shortName() const { return mName; }
59 /// Get the full name of the module
60 /// \return The full name
61 std::string fullName() const { return mFullName.generic_string(); }
62 /// Get the full name of the module in a path
63 /// \return The full name, as a boost::filesystem::path
64 boost::filesystem::path fullNamePath() const { return mFullName; }
65 /// Get the Context that this module belongs to
66 /// \return The context
67
68 Context& context() const { return *mContext; }
69
70 /// Adds forward declartions for the functions in this module
71 /// \param module The module to add forward declartions to
72 /// \return The Result
73 virtual Result addForwardDeclarations(llvm::Module& module) const = 0;
74
75 /// Generate a llvm::Module from the module. Usually called by Context::compileModule
76 /// \param module The llvm::Module to fill into -- must be already filled with forward
77 /// declarations of dependencies
78 /// \return The Result
79 virtual Result generateModule(llvm::Module& module) = 0;
80
81 /// Get the dependencies

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected