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

Class LangModule

libchigraph/include/chi/LangModule.hpp:16–52  ·  view source on GitHub ↗

The module that provides built-in operations like literals, math operations, etc

Source from the content-addressed store, hash-verified

14namespace chi {
15/// The module that provides built-in operations like literals, math operations, etc
16struct LangModule : ChiModule {
17 /// Default constructor, usually called from Context::loadModule("lang")
18 /// \param ctx The Context to construct from
19 LangModule(Context& ctx);
20
21 /// Destructor
22 ~LangModule();
23
24 Result nodeTypeFromName(boost::string_view name, const nlohmann::json& jsonData,
25 std::unique_ptr<NodeType>* toFill) override;
26
27 DataType typeFromName(boost::string_view name) override;
28
29 std::vector<std::string> nodeTypeNames() const override {
30 std::vector<std::string> ret;
31 ret.reserve(nodes.size());
32
33 std::transform(nodes.begin(), nodes.end(), std::back_inserter(ret),
34 [](auto pair) { return pair.first; });
35
36 return ret;
37 }
38
39 std::vector<std::string> typeNames() const override {
40 return {"i32", "i1", "float", "i8*"}; // TODO: do i need more?
41 }
42
43 Result addForwardDeclarations(llvm::Module& module) const override;
44
45 Result generateModule(llvm::Module& /*module*/) override;
46
47private:
48 std::unordered_map<std::string,
49 std::function<std::unique_ptr<NodeType>(const nlohmann::json&, Result&)>>
50 nodes;
51 std::unordered_map<std::string, llvm::DIType*> mDebugTypes;
52};
53} // namespace chi
54
55#endif // CHI_LANG_MODULE_HPP

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected