| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | Protected Member Functions | List of all members
chi::NodeType Struct Referenceabstract

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...

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ NodeType()

chi::NodeType::NodeType | ( | ChiModule & | mod,
|  | std::string | name = `{}`,
|  | std::string | description = `{}`
| ) |  |

Constructor.

Parameters

  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().

Here is the call graph for this function:

## Member Function Documentation

## ◆ clone()

virtual std::unique_ptr<NodeType> chi::NodeType::clone | ( |  | ) | const
| pure virtual

Clones the type.

Returns
  The clone

Referenced by toJSON().

Here is the caller graph for this function:

## ◆ codegen()

virtual Result chi::NodeType::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
| ) |  |
| pure virtual

A virtual function that is called when this node needs to be called.

Parameters

  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.

Returns
  The Result

Referenced by chi::NodeCompiler::compile_stage2().

Here is the caller graph for this function:

## ◆ context()

Context& chi::NodeType::context | ( |  | ) | const
| inline

Get the Context this NodeType belongs to.

Returns
  The Context

Definition at line 70 of file NodeType.hpp.

## ◆ dataInputs()

const std::vector<NamedDataType>& chi::NodeType::dataInputs | ( |  | ) | const
| inline

Get the data inputs for the node.

Returns
  The data inputs in the format of {{DataType, description}, ...}

Definition at line 73 of file NodeType.hpp.

Referenced by chi::NodeCompiler::compile_stage2(), chi::connectData(), chi::disconnectData(), makeConverter(), and chi::NodeInstance::setType().

Here is the caller graph for this function:

## ◆ dataOutputs()

const std::vector<NamedDataType>& chi::NodeType::dataOutputs | ( |  | ) | const
| inline

Get the data outputs for the node.

Returns
  The data outputs in the format of {{DataType, description}, ...}

Definition at line 76 of file NodeType.hpp.

Referenced by chi::connectData(), chi::disconnectData(), makeConverter(), chi::NodeCompiler::NodeCompiler(), and chi::NodeInstance::setType().

Here is the caller graph for this function:

## ◆ description()

std::string chi::NodeType::description | ( |  | ) | const
| inline

Get the description of the NodeType.

Returns
  The description

Definition at line 64 of file NodeType.hpp.

Referenced by NodeType().

Here is the caller graph for this function:

## ◆ execInputs()

const std::vector<std::string>& chi::NodeType::execInputs | ( |  | ) | const
| inline

Get the execution inputs for the node.

Returns
  The names of the inputs. The size of this vector is the size of inputs.

Definition at line 79 of file NodeType.hpp.

Referenced by chi::connectExec().

Here is the caller graph for this function:

## ◆ execOutputs()

const std::vector<std::string>& chi::NodeType::execOutputs | ( |  | ) | const
| inline

Get the execution outputs for the node.

Returns
  The names of the outputs. The size is the input count.

Definition at line 82 of file NodeType.hpp.

Referenced by chi::connectExec(), and chi::disconnectExec().

Here is the caller graph for this function:

## ◆ makeConverter()

void chi::NodeType::makeConverter | ( |  | ) |
| protected

Make this a converter node.

Precondition
  `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().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ module()

ChiModule& chi::NodeType::module | ( |  | ) | const
| inline

Get the ChiModule this NodeType belongs to.

Returns
  The ChiModule

Definition at line 67 of file NodeType.hpp.

Referenced by qualifiedName().

Here is the caller graph for this function:

## ◆ name()

std::string chi::NodeType::name | ( |  | ) | const
| inline

Get the name of the NodeType in the ChiModule.

Returns
  The name

Definition at line 61 of file NodeType.hpp.

Referenced by NodeType(), and qualifiedName().

Here is the caller graph for this function:

## ◆ nodeInstance()

NodeInstance * chi::NodeType::nodeInstance | ( |  | ) | const
| protected

Get the node instance.

Returns
  the node instance

Definition at line 52 of file NodeType.cpp.

Referenced by converter().

Here is the caller graph for this function:

## ◆ pure()

bool chi::NodeType::pure | ( |  | ) |
| inline

Get if this node is pure.

Returns
  If it's pure

Definition at line 86 of file NodeType.hpp.

Referenced by makeConverter(), and chi::NodeCompiler::pure().

Here is the caller graph for this function:

## ◆ qualifiedName()

std::string chi::NodeType::qualifiedName | ( |  | ) | const

Get the qualified name of the node type, like module.name():name()

Returns
  The qualified 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().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ setDataInputs()

void chi::NodeType::setDataInputs | ( | std::vector< NamedDataType > | newInputs | ) |
| protected

Set the data inputs for the NodeType.

Parameters

  newInputs | The new inputs

Definition at line 19 of file NodeType.cpp.

Referenced by converter().

Here is the caller graph for this function:

## ◆ setDataOutputs()

void chi::NodeType::setDataOutputs | ( | std::vector< NamedDataType > | newOutputs | ) |
| protected

Set the data outputs for the NodeType.

Parameters

  newOutputs | The new outputs

Definition at line 24 of file NodeType.cpp.

Referenced by converter().

Here is the caller graph for this function:

## ◆ setDescription()

void chi::NodeType::setDescription | ( | std::string | newDesc | ) |
| protected

Set the description of the node.

Parameters

  newDesc | The new description

Definition at line 56 of file NodeType.cpp.

Referenced by converter().

Here is the caller graph for this function:

## ◆ setExecInputs()

void chi::NodeType::setExecInputs | ( | std::vector< std::string > | newInputs | ) |
| protected

Set the exec inputs for the NodeType.

Parameters

  newInputs | The new inputs

Definition at line 29 of file NodeType.cpp.

Referenced by converter(), and makePure().

Here is the caller graph for this function:

## ◆ setExecOutputs()

void chi::NodeType::setExecOutputs | ( | std::vector< std::string > | newOutputs | ) |
| protected

Set the exec outputs for the NodeType.

Parameters

  newOutputs | The new outputs

Definition at line 33 of file NodeType.cpp.

Referenced by converter(), and makePure().

Here is the caller graph for this function:

## ◆ setName()

void chi::NodeType::setName | ( | std::string | newName | ) |
| protected

Set the name of the type.

Parameters

  newName | The new name

Definition at line 54 of file NodeType.cpp.

Referenced by converter().

Here is the caller graph for this function:

## ◆ toJSON()

virtual nlohmann::json chi::NodeType::toJSON | ( |  | ) | const
| inline virtual

Create the JSON necessary to store the object.

Returns
  The json obejct

Definition at line 54 of file NodeType.hpp.

References clone().

Referenced by chi::connectData(), and chi::disconnectData().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following files:

- lib/core/include/chi/NodeType.hpp
- lib/core/src/NodeType.cpp