| chigraph master Systems programming language written for beginners in LLVM

GraphStruct.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #ifndef CHI_STRUCT_TYPE_HPP
7 #define CHI_STRUCT_TYPE_HPP
8
9 #include <string>
10 #include <vector>
11
12 #include "chi/DataType.hpp"
13 #include "chi/Fwd.hpp"
14
15 namespace chi {
16
18 struct GraphStruct {
22 GraphStruct(GraphModule& mod, std::string name);
23
26 Context& context() const { return *mContext; }
27
30 GraphModule& module() const { return *mModule; }
31
39 std::vector<NodeInstance*> setName(std::string newName, bool updateReferences = true);
40
43 const std::string& name() const { return mName; }
44
47 const std::vector<NamedDataType>& types() const { return mTypes; }
48
56 void addType(DataType ty, std::string name, size_t addBefore, bool updateReferences = true);
57
63 void modifyType(size_t id, DataType newTy, std::string newName, bool updateReferences = true);
64
68 void removeType(size_t id, bool updateReferences = true);
69
72 DataType dataType();
73
74 private:
75 void updateNodeReferences();
76
77 GraphModule* mModule;
78 Context* mContext;
79
80 std::vector<NamedDataType> mTypes;
81
82 std::string mName;
83
84 DataType mDataType;
85 };
86 } // namespace chi
87
88 #endif // CHI_STRUCT_TYPE_HPP
chi::GraphStruct::setName
std::vector< NodeInstance * > setName(std::string newName, bool updateReferences=true)
Set the name of the struct, and optionally update all references in the context.
Definition: GraphStruct.cpp:24
chi::GraphStruct::name
const std::string & name() const
Get the name of the type.
Definition: GraphStruct.hpp:43
Fwd.hpp
Forward declares all the chigraph data types.
chi::GraphStruct
A class holding a compound type defined in a GraphModule.
Definition: GraphStruct.hpp:18
chi::GraphStruct::modifyType
void modifyType(size_t id, DataType newTy, std::string newName, bool updateReferences=true)
Change the type and name of a type.
Definition: GraphStruct.cpp:82
chi::GraphStruct::module
GraphModule & module() const
Get the module.
Definition: GraphStruct.hpp:30
chi::GraphStruct::GraphStruct
GraphStruct(GraphModule &mod, std::string name)
GraphType constructor; don&#39;t use this use GraphModule::newStruct.
Definition: GraphStruct.cpp:21
chi::Context
The class that handles the loading, creation, storing, and compilation of modules It also stores a LL...
Definition: Context.hpp:55
chi::GraphStruct::context
Context & context() const
Get the context.
Definition: GraphStruct.hpp:26
chi::GraphStruct::dataType
DataType dataType()
Get the DataType of the struct.
Definition: GraphStruct.cpp:111
chi::GraphStruct::removeType
void removeType(size_t id, bool updateReferences=true)
Remove a type from a struct.
Definition: GraphStruct.cpp:97
chi::GraphStruct::types
const std::vector< NamedDataType > & types() const
Get the types the struct contains.
Definition: GraphStruct.hpp:47
DataType.hpp
Defines the DataType class.
chi::GraphStruct::addType
void addType(DataType ty, std::string name, size_t addBefore, bool updateReferences=true)
Add a new type to the struct.
Definition: GraphStruct.cpp:68
chi::GraphModule
Module that holds graph functions.
Definition: GraphModule.hpp:16
chi
The namespace where chigraph lives.
Definition: BitcodeParser.hpp:12
chi::DataType
A type of data Loose wrapper around llvm::Type*, except it knows which ChiModule it&#39;s in and it embed...
Definition: DataType.hpp:17