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 
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
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
const std::string & name() const
Get the name of the type.
Definition: GraphStruct.hpp:43
Forward declares all the chigraph data types.
A class holding a compound type defined in a GraphModule.
Definition: GraphStruct.hpp:18
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
GraphModule & module() const
Get the module.
Definition: GraphStruct.hpp:30
GraphStruct(GraphModule &mod, std::string name)
GraphType constructor; don&#39;t use this use GraphModule::newStruct.
Definition: GraphStruct.cpp:21
The class that handles the loading, creation, storing, and compilation of modules It also stores a LL...
Definition: Context.hpp:55
Context & context() const
Get the context.
Definition: GraphStruct.hpp:26
DataType dataType()
Get the DataType of the struct.
void removeType(size_t id, bool updateReferences=true)
Remove a type from a struct.
Definition: GraphStruct.cpp:97
const std::vector< NamedDataType > & types() const
Get the types the struct contains.
Definition: GraphStruct.hpp:47
Defines the DataType class.
void addType(DataType ty, std::string name, size_t addBefore, bool updateReferences=true)
Add a new type to the struct.
Definition: GraphStruct.cpp:68
Module that holds graph functions.
Definition: GraphModule.hpp:16
The namespace where chigraph lives.
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