| chigraph master Systems programming language written for beginners in LLVM

NodeType.cpp
Go to the documentation of this file.
1
3 #include "chi/NodeType.hpp"
4 #include "chi/ChiModule.hpp"
5 #include "chi/DataType.hpp"
6
7 namespace chi {
8
9 NodeType::NodeType(ChiModule& mod, std::string name, std::string description)
10 : mModule{&mod},
11 mContext{&mod.context()},
12 mName{std::move(name)},
13 mDescription{std::move(description)} {}
14
15 NodeType::~NodeType() = default;
16
17 std::string NodeType::qualifiedName() const { return module().fullName() + ":" + name(); }
18
19 void NodeType::setDataInputs(
20 std::vector<chi::NamedDataType, std::allocator<chi::NamedDataType> > newInputs) {
21 mDataInputs = std::move(newInputs);
22 }
23
24 void NodeType::setDataOutputs(
25 std::vector<chi::NamedDataType, std::allocator<chi::NamedDataType> > newOutputs) {
26 mDataOutputs = std::move(newOutputs);
27 }
28
29 void NodeType::setExecInputs(std::vector<std::string> newInputs) {
30 mExecInputs = std::move(newInputs);
31 }
32
33 void NodeType::setExecOutputs(std::vector<std::string> newOutputs) {
34 mExecOutputs = std::move(newOutputs);
35 }
36
37 void NodeType::makePure() {
38 setExecInputs({});
39 setExecOutputs({});
40
41 mPure = true;
42 }
43
44 void NodeType::makeConverter() {
45 assert(pure() && "Cannot have a nonpure converter node");
46 assert(dataInputs().size() == 1 && "A converter node must have one data input");
47 assert(dataOutputs().size() == 1 && "A converter node must have one data output");
48
49 mConverter = true;
50 }
51
52 NodeInstance* NodeType::nodeInstance() const { return mNodeInstance; }
53
54 void NodeType::setName(std::string newName) { mName = std::move(newName); }
55
56 void NodeType::setDescription(std::string newDesc) { mDescription = std::move(newDesc); }
57 } // namespace chi
chi::NodeType::module
ChiModule & module() const
Get the ChiModule this NodeType belongs to.
Definition: NodeType.hpp:67
chi::NodeType::dataOutputs
const std::vector< NamedDataType > & dataOutputs() const
Get the data outputs for the node.
Definition: NodeType.hpp:76
chi::NodeInstance
An instance of a node.
Definition: NodeInstance.hpp:19
chi::NodeType::makeConverter
void makeConverter()
Make this a converter node.
Definition: NodeType.cpp:44
chi::NodeType::setDescription
void setDescription(std::string newDesc)
Set the description of the node.
Definition: NodeType.cpp:56
chi::NodeType::name
std::string name() const
Get the name of the NodeType in the ChiModule.
Definition: NodeType.hpp:61
chi::NamedDataType
Basicaly a std::pair<std::string, DataType>, except it has nicer names.
Definition: DataType.hpp:72
chi::NodeType::makePure
void makePure()
Make this node pure For more info on what this means, see https://en.wikipedia.org/wiki/Pure_function...
Definition: NodeType.cpp:37
chi::NodeType::description
std::string description() const
Get the description of the NodeType.
Definition: NodeType.hpp:64
chi::NodeType::nodeInstance
NodeInstance * nodeInstance() const
Get the node instance.
Definition: NodeType.cpp:52
chi::ChiModule::fullName
std::string fullName() const
Get the full name of the module.
Definition: ChiModule.hpp:61
chi::NodeType::NodeType
NodeType(ChiModule &mod, std::string name={}, std::string description={})
Constructor.
Definition: NodeType.cpp:9
chi::ChiModule
An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module...
Definition: ChiModule.hpp:24
chi::NodeType::setExecOutputs
void setExecOutputs(std::vector< std::string > newOutputs)
Set the exec outputs for the NodeType.
Definition: NodeType.cpp:33
chi::NodeType::setDataOutputs
void setDataOutputs(std::vector< NamedDataType > newOutputs)
Set the data outputs for the NodeType.
Definition: NodeType.cpp:24
chi::NodeType::setExecInputs
void setExecInputs(std::vector< std::string > newInputs)
Set the exec inputs for the NodeType.
Definition: NodeType.cpp:29
chi::NodeType::pure
bool pure()
Get if this node is pure.
Definition: NodeType.hpp:86
chi::NodeType::setName
void setName(std::string newName)
Set the name of the type.
Definition: NodeType.cpp:54
chi::NodeType::~NodeType
virtual ~NodeType()
Destructor.
NodeType.hpp
Defines the NodeType class.
DataType.hpp
Defines the DataType class.
ChiModule.hpp
Defines the ChiModule class.
chi::NodeType::dataInputs
const std::vector< NamedDataType > & dataInputs() const
Get the data inputs for the node.
Definition: NodeType.hpp:73
chi
The namespace where chigraph lives.
Definition: BitcodeParser.hpp:12
chi::NodeType::qualifiedName
std::string qualifiedName() const
Get the qualified name of the node type, like module.name():name()
Definition: NodeType.cpp:17
chi::NodeType::setDataInputs
void setDataInputs(std::vector< NamedDataType > newInputs)
Set the data inputs for the NodeType.
Definition: NodeType.cpp:19