chigraph  master
Systems programming language written for beginners in LLVM
chi::GraphFunction Struct Reference

this is an AST-like representation of a function in a graph It is used for IDE-like behavior, codegen, and JSON generation. More...

#include <chi/GraphFunction.hpp>

Public Member Functions

 GraphFunction (GraphModule &mod, std::string name, std::vector< NamedDataType > dataIns, std::vector< NamedDataType > dataOuts, std::vector< std::string > execIns, std::vector< std::string > execOuts)
 Construct a graph–don't call this directly use GraphModule::getorCreateFunction. More...
 
 GraphFunction (const GraphFunction &)=delete
 
 GraphFunction (GraphFunction &&)=delete
 
 ~GraphFunction ()=default
 Destructor.
 
Contextcontext () const
 Get the context. More...
 
Result createEntryNodeType (std::unique_ptr< NodeType > *toFill) const
 Create a fresh NodeType for an entry. More...
 
Result createExitNodeType (std::unique_ptr< NodeType > *toFill) const
 Create a fresh NodeType for an exit. More...
 
const std::string & description () const
 Get the description of the function. More...
 
llvm::FunctionType * functionType () const
 Get the LLVM function type for the function. More...
 
GraphModulemodule () const
 Get the GraphModule that contains this GraphFunction. More...
 
std::string name () const
 Get the name of the function. More...
 
GraphFunctionoperator= (const GraphFunction &)=delete
 
GraphFunctionoperator= (GraphFunction &&)=delete
 
std::string qualifiedName () const
 Get the qualified name of the function Same as module().fullName() + ":" + name();. More...
 
void setDescription (std::string newDesc)
 Set the description of the function. More...
 
std::vector< NodeInstance * > setName (boost::string_view newName, bool updateReferences=true)
 Set the name of the function. More...
 
Node Manipulation

Functions for mainpulating nodes; getting, adding

std::unordered_map< boost::uuids::uuid, std::unique_ptr< NodeInstance > > & nodes ()
 Get the nodes in the function Usually called by connectData or connectExec or GraphFunction. More...
 
const std::unordered_map< boost::uuids::uuid, std::unique_ptr< NodeInstance > > & nodes () const
 Get the nodes in the function Usually called by connectData or connectExec or GraphFunction. More...
 
NodeInstancenodeByID (const boost::uuids::uuid &id) const
 Get a node with a given ID. More...
 
NodeInstanceentryNode () const noexcept
 Gets the node with type lang:entry returns nullptr on failure Also returns nullptr if there are two entry nodes, which is illegal. More...
 
Result insertNode (std::unique_ptr< NodeType > type, float x, float y, boost::uuids::uuid id=boost::uuids::random_generator()(), NodeInstance **toFill=nullptr)
 Add a node to the graph. More...
 
std::vector< NodeInstance * > nodesWithType (const boost::filesystem::path &module, boost::string_view name) const noexcept
 Gets the nodes with a given type. More...
 
Result insertNode (const boost::filesystem::path &moduleName, boost::string_view typeName, const nlohmann::json &typeJSON, float x, float y, boost::uuids::uuid id=boost::uuids::random_generator()(), NodeInstance **toFill=nullptr)
 Add a node to the graph using module, type, and json. More...
 
Result removeNode (NodeInstance &nodeToRemove)
 Remove a node from the function. More...
 
Result getOrInsertEntryNode (float x, float y, boost::uuids::uuid id=boost::uuids::random_generator()(), NodeInstance **toFill=nullptr)
 Creates an entry node if it doesn't already exist, else just return it. More...
 
Data input modifiers
const std::vector< NamedDataType > & dataInputs () const
 Get the function data inputs in the format {type, docstring}. More...
 
void addDataInput (const DataType &type, std::string name, size_t addBefore=(std::numeric_limits< size_t >::max)())
 Add an input to the end of the argument list. More...
 
void removeDataInput (size_t idx)
 Remove an input from the argument list Also removes invalid connections If idx is out of range, this function does nothing. More...
 
void renameDataInput (size_t idx, std::string newName)
 Rename a data input This also updates the entry node If idx is out of range, this function does nothing. More...
 
void retypeDataInput (size_t idx, DataType newType)
 Change the type of a data input This also updates the entry node and disconnects invalid connections. More...
 
Data output modifiers
const std::vector< NamedDataType > & dataOutputs () const
 Get the function data outputs in the format {type, docstring}. More...
 
void addDataOutput (const DataType &type, std::string name, size_t addBefore=(std::numeric_limits< size_t >::max)())
 Add an data output to the end of the argument list. More...
 
void removeDataOutput (size_t idx)
 Remove an data output from the argument list Also removes invalid connections If idx is out of range, this function does nothing. More...
 
void renameDataOutput (size_t idx, std::string newName)
 Modify an data output (change it's type and docstring) More...
 
void retypeDataOutput (size_t idx, DataType newType)
 Change the type of a data output This also updates all exit nodes and disconnects invalid connections. More...
 
Exec input modifiers
const std::vector< std::string > & execInputs () const
 Get the function exec inputs. More...
 
void addExecInput (std::string name, size_t addBefore=(std::numeric_limits< size_t >::max)())
 Add an exec input to the end of the argument list. More...
 
void removeExecInput (size_t idx)
 Remove an exec input from the argument list If idx is out of range, this function does nothing. More...
 
void renameExecInput (size_t idx, std::string name)
 Change the name for an exec input If idx is out of range, this function does nothing. More...
 
Exec output modifiers

Getters/modifers for exec output

const std::vector< std::string > & execOutputs () const
 Get the function exec outputs. More...
 
void addExecOutput (std::string name, size_t addBefore=(std::numeric_limits< size_t >::max)())
 Add an exec output to the end of the argument list. More...
 
void removeExecOutput (size_t idx)
 Remove an exec output from the argument list If idx is out of range, this function does nothing. More...
 
void renameExecOutput (size_t idx, std::string name)
 Rename an exec output If idx is out of range, this function does nothing. More...
 
Local Variable Manipulation functions
const std::vector< NamedDataType > & localVariables () const
 Get the local variables. More...
 
NamedDataType localVariableFromName (boost::string_view name) const
 Get a local varaible by name. More...
 
NamedDataType getOrCreateLocalVariable (std::string name, DataType type, bool *inserted=nullptr)
 Create a new local varaible in the module. More...
 
bool removeLocalVariable (boost::string_view name)
 Remove a local variable from the function by name. More...
 
void renameLocalVariable (std::string oldName, std::string newName)
 Rename a local variable. More...
 
void retypeLocalVariable (boost::string_view name, DataType newType)
 Set a new type to a local variable. More...
 

Detailed Description

this is an AST-like representation of a function in a graph It is used for IDE-like behavior, codegen, and JSON generation.

Definition at line 23 of file GraphFunction.hpp.

Constructor & Destructor Documentation

◆ GraphFunction()

chi::GraphFunction::GraphFunction ( GraphModule mod,
std::string  name,
std::vector< NamedDataType dataIns,
std::vector< NamedDataType dataOuts,
std::vector< std::string >  execIns,
std::vector< std::string >  execOuts 
)

Construct a graph–don't call this directly use GraphModule::getorCreateFunction.

Parameters
modThe owning module
nameThe name of the function
dataInsThe data inputs to the function
dataOutsThe data outputs of the function
execInsThe exec inputs to the function
execOutsThe exec outputs to the function

Definition at line 25 of file GraphFunction.cpp.

References name().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDataInput()

void chi::GraphFunction::addDataInput ( const DataType type,
std::string  name,
size_t  addBefore = (std::numeric_limits<size_t>::max)() 
)

Add an input to the end of the argument list.

Parameters
typeThe new input type
nameThe name of the input (just for documentation)
addBeforeThe input ID to add before, default is end

Definition at line 212 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataInputs().

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

◆ addDataOutput()

void chi::GraphFunction::addDataOutput ( const DataType type,
std::string  name,
size_t  addBefore = (std::numeric_limits<size_t>::max)() 
)

Add an data output to the end of the argument list.

Parameters
typeThe new output type
nameThe name of the output (just for documentation)
addBeforeThe output to add before, default is end

Definition at line 248 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataOutputs().

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

◆ addExecInput()

void chi::GraphFunction::addExecInput ( std::string  name,
size_t  addBefore = (std::numeric_limits<size_t>::max)() 
)

Add an exec input to the end of the argument list.

Parameters
nameThe name of the input (just for documentation)
addBeforethe input to add after

Definition at line 299 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by execInputs().

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

◆ addExecOutput()

void chi::GraphFunction::addExecOutput ( std::string  name,
size_t  addBefore = (std::numeric_limits<size_t>::max)() 
)

Add an exec output to the end of the argument list.

Parameters
nameThe name of the output (just for documentation)
addBeforeThe output to add after

Definition at line 328 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by execOutputs().

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

◆ context()

Context& chi::GraphFunction::context ( ) const
inline

Get the context.

Returns
The context

Definition at line 310 of file GraphFunction.hpp.

Referenced by createEntryNodeType(), createExitNodeType(), functionType(), insertNode(), chi::jsonToGraphFunction(), and setName().

+ Here is the caller graph for this function:

◆ createEntryNodeType()

Result chi::GraphFunction::createEntryNodeType ( std::unique_ptr< NodeType > *  toFill) const

Create a fresh NodeType for an entry.

Parameters
[out]toFillThe NodeType pointer to fill
Precondition
toFill isn't null (the value the unique_ptr points to be can be null, but not the pointer to the unique_ptr)
Returns
The result

Definition at line 156 of file GraphFunction.cpp.

References context(), dataInputs(), execInputs(), and chi::Context::nodeTypeFromModule().

Referenced by getOrInsertEntryNode(), nodes(), and renameExecOutput().

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

◆ createExitNodeType()

Result chi::GraphFunction::createExitNodeType ( std::unique_ptr< NodeType > *  toFill) const

Create a fresh NodeType for an exit.

Parameters
[out]toFillThe NodeType pointer to fill
Precondition
toFill isn't null (the value the unique_ptr points to be can be null, but not the pointer to the unique_ptr)
Returns
The result

Definition at line 174 of file GraphFunction.cpp.

References context(), dataOutputs(), execOutputs(), and chi::Context::nodeTypeFromModule().

Referenced by nodes(), and renameExecOutput().

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

◆ dataInputs()

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

Get the function data inputs in the format {type, docstring}.

Returns
The inputs

Definition at line 145 of file GraphFunction.hpp.

References addDataInput(), removeDataInput(), renameDataInput(), and retypeDataInput().

Referenced by createEntryNodeType(), entryNode(), functionType(), chi::graphFunctionToJson(), chi::validateFunctionEntryType(), and chi::validateFunctionMainSignature().

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

◆ dataOutputs()

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

Get the function data outputs in the format {type, docstring}.

Returns
The outputs

Definition at line 180 of file GraphFunction.hpp.

References addDataOutput(), removeDataOutput(), renameDataOutput(), and retypeDataOutput().

Referenced by createExitNodeType(), functionType(), chi::graphFunctionToJson(), chi::validateFunctionExitTypes(), and chi::validateFunctionMainSignature().

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

◆ description()

const std::string& chi::GraphFunction::description ( ) const
inline

Get the description of the function.

Returns
The description

Definition at line 303 of file GraphFunction.hpp.

Referenced by chi::graphFunctionToJson().

+ Here is the caller graph for this function:

◆ entryNode()

NodeInstance * chi::GraphFunction::entryNode ( ) const
noexcept

Gets the node with type lang:entry returns nullptr on failure Also returns nullptr if there are two entry nodes, which is illegal.

Returns
the entry node

Definition at line 44 of file GraphFunction.cpp.

References dataInputs(), execInputs(), and nodesWithType().

Referenced by getOrInsertEntryNode(), nodes(), chi::validateFunctionEntryType(), and chi::validateFunctionNodeInputs().

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

◆ execInputs()

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

Get the function exec inputs.

Returns
The exec outputs

Definition at line 216 of file GraphFunction.hpp.

References addExecInput(), removeExecInput(), and renameExecInput().

Referenced by createEntryNodeType(), entryNode(), chi::graphFunctionToJson(), and chi::validateFunctionMainSignature().

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

◆ execOutputs()

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

Get the function exec outputs.

Returns
The exec outputs

Definition at line 241 of file GraphFunction.hpp.

References addExecOutput(), removeExecOutput(), and renameExecOutput().

Referenced by createExitNodeType(), chi::graphFunctionToJson(), and chi::validateFunctionMainSignature().

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

◆ functionType()

llvm::FunctionType * chi::GraphFunction::functionType ( ) const

Get the LLVM function type for the function.

Returns
The function type

Definition at line 281 of file GraphFunction.cpp.

References context(), dataInputs(), and dataOutputs().

Referenced by nodes().

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

◆ getOrCreateLocalVariable()

NamedDataType chi::GraphFunction::getOrCreateLocalVariable ( std::string  name,
DataType  type,
bool *  inserted = nullptr 
)

Create a new local varaible in the module.

Parameters
nameThe name of the local variable
typeThe type of the local
insertedTrue if the local varaiable was new, optional
Returns
The new local variable or the already existing one

Definition at line 387 of file GraphFunction.cpp.

References localVariableFromName(), module(), and chi::ChiModule::updateLastEditTime().

Referenced by chi::jsonToGraphFunction(), and localVariables().

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

◆ getOrInsertEntryNode()

Result chi::GraphFunction::getOrInsertEntryNode ( float  x,
float  y,
boost::uuids::uuid  id = boost::uuids::random_generator()(),
NodeInstance **  toFill = nullptr 
)

Creates an entry node if it doesn't already exist, else just return it.

Parameters
xThe x coordinate of the new entry, or changes the existing entry node to be at this X location
yThe y coordinate of the new entry, or changes the existing entry node to be at this Y location
idThe ID of the node, disregarded if there is already an entry
Return values
toFillThe NodeInstance* to fill, optional
Returns
The Result

Definition at line 192 of file GraphFunction.cpp.

References createEntryNodeType(), entryNode(), insertNode(), module(), and chi::ChiModule::updateLastEditTime().

Referenced by nodes().

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

◆ insertNode() [1/2]

Result chi::GraphFunction::insertNode ( std::unique_ptr< NodeType type,
float  x,
float  y,
boost::uuids::uuid  id = boost::uuids::random_generator()(),
NodeInstance **  toFill = nullptr 
)

Add a node to the graph.

Parameters
[in]typeThe type of the node
[in]xThe x location of the node
[in]yThe y location of the node
[in]idThe node ID
[out]toFillThe nodeInstance to fill to, optional.
Returns
The result

Definition at line 64 of file GraphFunction.cpp.

References chi::Result::addEntry(), module(), nodes(), and chi::ChiModule::updateLastEditTime().

Referenced by getOrInsertEntryNode(), insertNode(), chi::jsonToGraphFunction(), and nodes().

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

◆ insertNode() [2/2]

Result chi::GraphFunction::insertNode ( const boost::filesystem::path &  moduleName,
boost::string_view  typeName,
const nlohmann::json &  typeJSON,
float  x,
float  y,
boost::uuids::uuid  id = boost::uuids::random_generator()(),
NodeInstance **  toFill = nullptr 
)

Add a node to the graph using module, type, and json.

Parameters
moduleNameThe name of the module that typeName is in
typeNameThe name of the node type in the module with the name moduleName
typeJSONThe JSON to be passed to create the type
xThe x location of the node
yThe y location of the node
idThe node ID
Return values
toFillThe NodeInstance* to fill to, optional
Returns
The Result

Definition at line 100 of file GraphFunction.cpp.

References context(), insertNode(), module(), chi::Context::nodeTypeFromModule(), and chi::ChiModule::updateLastEditTime().

+ Here is the call graph for this function:

◆ localVariableFromName()

NamedDataType chi::GraphFunction::localVariableFromName ( boost::string_view  name) const

Get a local varaible by name.

Parameters
nameThe name of the variable
Returns
The local or {} if not found

Definition at line 379 of file GraphFunction.cpp.

Referenced by getOrCreateLocalVariable(), and localVariables().

+ Here is the caller graph for this function:

◆ localVariables()

const std::vector<NamedDataType>& chi::GraphFunction::localVariables ( ) const
inline

Get the local variables.

Returns
The local variables

Definition at line 265 of file GraphFunction.hpp.

References getOrCreateLocalVariable(), localVariableFromName(), removeLocalVariable(), renameLocalVariable(), and retypeLocalVariable().

Referenced by chi::graphFunctionToJson().

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

◆ module()

◆ name()

std::string chi::GraphFunction::name ( ) const
inline

Get the name of the function.

Returns
The name of the function

Definition at line 313 of file GraphFunction.hpp.

References qualifiedName(), and setName().

Referenced by GraphFunction(), chi::graphFunctionToJson(), nodesWithType(), chi::parseColonPair(), qualifiedName(), chi::GraphModule::removeFunction(), removeLocalVariable(), setName(), chi::validateFunction(), chi::validateFunctionConnectionsAreTwoWay(), chi::validateFunctionEntryType(), chi::validateFunctionExecOutputs(), and chi::validateFunctionNodeInputs().

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

◆ nodeByID()

NodeInstance * chi::GraphFunction::nodeByID ( const boost::uuids::uuid &  id) const

Get a node with a given ID.

Parameters
idThe ID of the node
Returns
The NodeInstance, or nullptr if the ID wasn't found

Definition at line 38 of file GraphFunction.cpp.

References nodes().

Referenced by nodes().

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

◆ nodes() [1/2]

std::unordered_map<boost::uuids::uuid, std::unique_ptr<NodeInstance> >& chi::GraphFunction::nodes ( )
inline

Get the nodes in the function Usually called by connectData or connectExec or GraphFunction.

Returns
The nodes, mapped by id, value

Definition at line 51 of file GraphFunction.hpp.

Referenced by chi::graphFunctionToJson(), insertNode(), chi::jsonToGraphFunction(), nodeByID(), removeNode(), chi::validateFunctionConnectionsAreTwoWay(), and chi::validateFunctionExecOutputs().

+ Here is the caller graph for this function:

◆ nodes() [2/2]

const std::unordered_map<boost::uuids::uuid, std::unique_ptr<NodeInstance> >& chi::GraphFunction::nodes ( ) const
inline

Get the nodes in the function Usually called by connectData or connectExec or GraphFunction.

Returns
The nodes, mapped by id, value

Definition at line 55 of file GraphFunction.hpp.

References createEntryNodeType(), createExitNodeType(), entryNode(), functionType(), getOrInsertEntryNode(), insertNode(), module(), nodeByID(), nodesWithType(), and removeNode().

+ Here is the call graph for this function:

◆ nodesWithType()

std::vector< NodeInstance * > chi::GraphFunction::nodesWithType ( const boost::filesystem::path &  module,
boost::string_view  name 
) const
noexcept

Gets the nodes with a given type.

Parameters
moduleThe module the type is in
nameThe name of the type
Returns
A vector of NodeInstance

Definition at line 87 of file GraphFunction.cpp.

References module(), and name().

Referenced by entryNode(), nodes(), removeLocalVariable(), renameExecOutput(), renameLocalVariable(), retypeLocalVariable(), and chi::validateFunctionExitTypes().

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

◆ qualifiedName()

std::string chi::GraphFunction::qualifiedName ( ) const

Get the qualified name of the function Same as module().fullName() + ":" + name();.

Returns
The qualified name

Definition at line 530 of file GraphFunction.cpp.

References chi::ChiModule::fullName(), module(), and name().

Referenced by name(), and retypeLocalVariable().

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

◆ removeDataInput()

void chi::GraphFunction::removeDataInput ( size_t  idx)

Remove an input from the argument list Also removes invalid connections If idx is out of range, this function does nothing.

Parameters
idxThe index to delete

Definition at line 224 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataInputs().

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

◆ removeDataOutput()

void chi::GraphFunction::removeDataOutput ( size_t  idx)

Remove an data output from the argument list Also removes invalid connections If idx is out of range, this function does nothing.

Parameters
idxThe index to delete

Definition at line 260 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataOutputs().

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

◆ removeExecInput()

void chi::GraphFunction::removeExecInput ( size_t  idx)

Remove an exec input from the argument list If idx is out of range, this function does nothing.

Parameters
idxThe index to delete

Definition at line 312 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by execInputs().

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

◆ removeExecOutput()

void chi::GraphFunction::removeExecOutput ( size_t  idx)

Remove an exec output from the argument list If idx is out of range, this function does nothing.

Parameters
idxThe index to delete

Definition at line 341 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by execOutputs().

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

◆ removeLocalVariable()

bool chi::GraphFunction::removeLocalVariable ( boost::string_view  name)

Remove a local variable from the function by name.

Parameters
nameThe name of the local variable to remove
Returns
True if a local was actually removed, false if no local by that name existed

Definition at line 405 of file GraphFunction.cpp.

References module(), name(), nodesWithType(), removeNode(), and chi::ChiModule::updateLastEditTime().

Referenced by localVariables().

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

◆ removeNode()

Result chi::GraphFunction::removeNode ( NodeInstance nodeToRemove)

Remove a node from the function.

Also disconnect it's connections.

Parameters
nodeToRemoveThe node to remove
Returns
The result

Definition at line 114 of file GraphFunction.cpp.

References chi::disconnectData(), chi::disconnectExec(), chi::NodeInstance::id(), chi::NodeInstance::inputDataConnections, chi::NodeInstance::inputExecConnections, module(), nodes(), chi::NodeInstance::outputDataConnections, chi::NodeInstance::outputExecConnections, and chi::ChiModule::updateLastEditTime().

Referenced by nodes(), and removeLocalVariable().

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

◆ renameDataInput()

void chi::GraphFunction::renameDataInput ( size_t  idx,
std::string  newName 
)

Rename a data input This also updates the entry node If idx is out of range, this function does nothing.

Parameters
idxThe index to rename
newNameThe new name

Definition at line 232 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataInputs().

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

◆ renameDataOutput()

void chi::GraphFunction::renameDataOutput ( size_t  idx,
std::string  newName 
)

Modify an data output (change it's type and docstring)

Rename a data output This also updates all exit nodes If idx is out of range, this function does nothing.

Parameters
idxThe index to rename
newNameThe new name

Definition at line 268 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataOutputs().

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

◆ renameExecInput()

void chi::GraphFunction::renameExecInput ( size_t  idx,
std::string  name 
)

Change the name for an exec input If idx is out of range, this function does nothing.

Parameters
idxThe index to change
nameThe new name.

Definition at line 320 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by execInputs().

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

◆ renameExecOutput()

void chi::GraphFunction::renameExecOutput ( size_t  idx,
std::string  name 
)

Rename an exec output If idx is out of range, this function does nothing.

Parameters
idxThe index to change
nameThe new name.

Definition at line 349 of file GraphFunction.cpp.

References createEntryNodeType(), createExitNodeType(), module(), nodesWithType(), and chi::ChiModule::updateLastEditTime().

Referenced by execOutputs().

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

◆ renameLocalVariable()

void chi::GraphFunction::renameLocalVariable ( std::string  oldName,
std::string  newName 
)

Rename a local variable.

Parameters
oldNameThe name of the existing local to change
newNameThe new name of the local

Definition at line 428 of file GraphFunction.cpp.

References module(), nodesWithType(), chi::GraphModule::nodeTypeFromName(), and chi::ChiModule::updateLastEditTime().

Referenced by localVariables().

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

◆ retypeDataInput()

void chi::GraphFunction::retypeDataInput ( size_t  idx,
DataType  newType 
)

Change the type of a data input This also updates the entry node and disconnects invalid connections.

If idx is out of range, this function does nothing.

Parameters
idxThe index to retype
newTypeThe new type

Definition at line 240 of file GraphFunction.cpp.

References module(), and chi::ChiModule::updateLastEditTime().

Referenced by dataInputs().

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

◆ retypeDataOutput()

void chi::GraphFunction::retypeDataOutput ( size_t  idx,
DataType  newType 
)

Change the type of a data output This also updates all exit nodes and disconnects invalid connections.

If idx is out of range, this function does nothing.

Parameters
idxThe index to retype
newTypeThe new type

Definition at line 276 of file GraphFunction.cpp.

Referenced by dataOutputs().

+ Here is the caller graph for this function:

◆ retypeLocalVariable()

void chi::GraphFunction::retypeLocalVariable ( boost::string_view  name,
DataType  newType 
)

Set a new type to a local variable.

Parameters
nameThe name of the local to change
newTypeThe new type

Definition at line 469 of file GraphFunction.cpp.

References module(), nodesWithType(), chi::GraphModule::nodeTypeFromName(), chi::DataType::qualifiedName(), qualifiedName(), and chi::ChiModule::updateLastEditTime().

Referenced by localVariables().

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

◆ setDescription()

void chi::GraphFunction::setDescription ( std::string  newDesc)
inline

Set the description of the function.

Parameters
newDescThe new description

Definition at line 299 of file GraphFunction.hpp.

Referenced by chi::createGraphFunctionDeclarationFromJson().

+ Here is the caller graph for this function:

◆ setName()

std::vector< NodeInstance * > chi::GraphFunction::setName ( boost::string_view  newName,
bool  updateReferences = true 
)

Set the name of the function.

Parameters
newNamethe new name for the function
updateReferencesshould the references be updated? If true, all modules in the context will be scanned and updated
Returns
All the updated nodes

Definition at line 506 of file GraphFunction.cpp.

References context(), chi::Context::findInstancesOfType(), module(), name(), chi::Context::nodeTypeFromModule(), and chi::ChiModule::updateLastEditTime().

Referenced by name().

+ 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: