chigraph
master
Systems programming language written for beginners in LLVM
|
A generic node type. More...
#include <chi/NodeType.hpp>
Public Member Functions | |
NodeType (ChiModule &mod, std::string name={}, std::string description={}) | |
Constructor. More... | |
virtual | ~NodeType () |
Destructor. | |
virtual std::unique_ptr< NodeType > | clone () const =0 |
Clones the type. More... | |
virtual Result | codegen (NodeCompiler &compiler, llvm::BasicBlock &codegenInto, size_t execInputID, const llvm::DebugLoc &nodeLocation, const std::vector< llvm::Value *> &io, const std::vector< llvm::BasicBlock *> &outputBlocks)=0 |
A virtual function that is called when this node needs to be called. More... | |
Context & | context () const |
Get the Context this NodeType belongs to. More... | |
bool | converter () |
Get if this node is a converter. | |
const std::vector< NamedDataType > & | dataInputs () const |
Get the data inputs for the node. More... | |
const std::vector< NamedDataType > & | dataOutputs () const |
Get the data outputs for the node. More... | |
std::string | description () const |
Get the description of the NodeType. More... | |
const std::vector< std::string > & | execInputs () const |
Get the execution inputs for the node. More... | |
const std::vector< std::string > & | execOutputs () const |
Get the execution outputs for the node. More... | |
ChiModule & | module () const |
Get the ChiModule this NodeType belongs to. More... | |
std::string | name () const |
Get the name of the NodeType in the ChiModule. More... | |
bool | pure () |
Get if this node is pure. More... | |
std::string | qualifiedName () const |
Get the qualified name of the node type, like module.name():name() More... | |
virtual nlohmann::json | toJSON () const |
Create the JSON necessary to store the object. More... | |
Protected Member Functions | |
void | makeConverter () |
Make this a converter node. More... | |
void | makePure () |
Make this node pure For more info on what this means, see https://en.wikipedia.org/wiki/Pure_function Also, UE4 implements it https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Functions/#purevsstopimpure Pure nodes only have no inexecs and no outexecs When they are called they are backpropagated and all called They should usually be cheap and sideaffectless. | |
NodeInstance * | nodeInstance () const |
Get the node instance. More... | |
void | setDataInputs (std::vector< NamedDataType > newInputs) |
Set the data inputs for the NodeType. More... | |
void | setDataOutputs (std::vector< NamedDataType > newOutputs) |
Set the data outputs for the NodeType. More... | |
void | setDescription (std::string newDesc) |
Set the description of the node. More... | |
void | setExecInputs (std::vector< std::string > newInputs) |
Set the exec inputs for the NodeType. More... | |
void | setExecOutputs (std::vector< std::string > newOutputs) |
Set the exec outputs for the NodeType. More... | |
void | setName (std::string newName) |
Set the name of the type. More... | |
A generic node type.
All user made types are of JsonNo deType type, which is defined in JsonModule.cpp. This allows for easy extension of the language.
Definition at line 19 of file NodeType.hpp.
chi::NodeType::NodeType | ( | ChiModule & | mod, |
std::string | name = {} , |
||
std::string | description = {} |
||
) |
Constructor.
mod | The module to create the NodeType in |
name | The name of the NodeType |
description | The description of the NodeType |
Definition at line 9 of file NodeType.cpp.
References description(), name(), and ~NodeType().
|
pure virtual |
Clones the type.
Referenced by toJSON().
|
pure virtual |
A virtual function that is called when this node needs to be called.
compiler | The compiler |
execInputID | The ID of the exec input |
nodeLocation | The location of the node |
io | This has the values that are the inputs and outputs of the function. This vector will always have the size of inputs.size() + outputs.size() and starts with the inputs. The types are gaurenteed to be the same as inputs and outputs |
outputBlocks | The blocks that can be outputted. This will be the same size as numOutputExecs. |
Referenced by chi::NodeCompiler::compile_stage2().
|
inline |
Get the Context this NodeType belongs to.
Definition at line 70 of file NodeType.hpp.
|
inline |
Get the data inputs for the node.
Definition at line 73 of file NodeType.hpp.
Referenced by chi::NodeCompiler::compile_stage2(), chi::connectData(), chi::disconnectData(), makeConverter(), and chi::NodeInstance::setType().
|
inline |
Get the data outputs for the node.
Definition at line 76 of file NodeType.hpp.
Referenced by chi::connectData(), chi::disconnectData(), makeConverter(), chi::NodeCompiler::NodeCompiler(), and chi::NodeInstance::setType().
|
inline |
Get the description of the NodeType.
Definition at line 64 of file NodeType.hpp.
Referenced by NodeType().
|
inline |
Get the execution inputs for the node.
Definition at line 79 of file NodeType.hpp.
Referenced by chi::connectExec().
|
inline |
Get the execution outputs for the node.
Definition at line 82 of file NodeType.hpp.
Referenced by chi::connectExec(), and chi::disconnectExec().
|
protected |
Make this a converter node.
pure() == true
Allows for this node to be created automatically for conversions Definition at line 44 of file NodeType.cpp.
References dataInputs(), dataOutputs(), and pure().
Referenced by converter().
|
inline |
Get the ChiModule this NodeType belongs to.
Definition at line 67 of file NodeType.hpp.
Referenced by qualifiedName().
|
inline |
Get the name of the NodeType in the ChiModule.
Definition at line 61 of file NodeType.hpp.
Referenced by NodeType(), and qualifiedName().
|
protected |
Get the node instance.
Definition at line 52 of file NodeType.cpp.
Referenced by converter().
|
inline |
Get if this node is pure.
Definition at line 86 of file NodeType.hpp.
Referenced by makeConverter(), and chi::NodeCompiler::pure().
std::string chi::NodeType::qualifiedName | ( | ) | const |
Get the qualified name of the node type, like module.name():name()
Definition at line 17 of file NodeType.cpp.
References chi::ChiModule::fullName(), module(), and name().
Referenced by chi::connectData(), chi::connectExec(), chi::disconnectData(), chi::disconnectExec(), and chi::validateFunctionConnectionsAreTwoWay().
|
protected |
Set the data inputs for the NodeType.
newInputs | The new inputs |
Definition at line 19 of file NodeType.cpp.
Referenced by converter().
|
protected |
Set the data outputs for the NodeType.
newOutputs | The new outputs |
Definition at line 24 of file NodeType.cpp.
Referenced by converter().
|
protected |
Set the description of the node.
newDesc | The new description |
Definition at line 56 of file NodeType.cpp.
Referenced by converter().
|
protected |
Set the exec inputs for the NodeType.
newInputs | The new inputs |
Definition at line 29 of file NodeType.cpp.
Referenced by converter(), and makePure().
|
protected |
Set the exec outputs for the NodeType.
newOutputs | The new outputs |
Definition at line 33 of file NodeType.cpp.
Referenced by converter(), and makePure().
|
protected |
Set the name of the type.
newName | The new name |
Definition at line 54 of file NodeType.cpp.
Referenced by converter().
|
inlinevirtual |
Create the JSON necessary to store the object.
Definition at line 54 of file NodeType.hpp.
References clone().
Referenced by chi::connectData(), and chi::disconnectData().