| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | List of all members
chi::GraphStruct Struct Reference

A class holding a compound type defined in a GraphModule. More...

`#include <chi/GraphStruct.hpp>`

## Public Member Functions
| GraphStruct (GraphModule &mod, std::string name)
| GraphType constructor; don't use this use GraphModule::newStruct. More...
void | addType (DataType ty, std::string name, size_t addBefore, bool updateReferences=true)
| Add a new type to the struct. More...
Context & | context () const
| Get the context. More...
DataType | dataType ()
| Get the DataType of the struct. More...
void | modifyType (size_t id, DataType newTy, std::string newName, bool updateReferences=true)
| Change the type and name of a type. More...
GraphModule & | module () const
| Get the module. More...
const std::string & | name () const
| Get the name of the type. More...
void | removeType (size_t id, bool updateReferences=true)
| Remove a type from a struct. More...
std::vector< NodeInstance * > | setName (std::string newName, bool updateReferences=true)
| Set the name of the struct, and optionally update all references in the context. More...
const std::vector< NamedDataType > & | types () const
| Get the types the struct contains. More...

## Detailed Description

A class holding a compound type defined in a GraphModule.

Definition at line 18 of file GraphStruct.hpp.

## Constructor & Destructor Documentation

## ◆ GraphStruct()

chi::GraphStruct::GraphStruct | ( | GraphModule & | mod,
|  | std::string | name
| ) |  |

GraphType constructor; don't use this use GraphModule::newStruct.

Parameters

  mod | Module to add to
  name | name of the type

Definition at line 21 of file GraphStruct.cpp.

References name().

Here is the call graph for this function:

## Member Function Documentation

## ◆ addType()

void chi::GraphStruct::addType | ( | DataType | ty,
|  | std::string | name,
|  | size_t | addBefore,
|  | bool | updateReferences = `true`
| ) |  |

Add a new type to the struct.

Parameters

  ty | The type

Precondition
  `ty.vaid()`

Parameters

  name | The name of the type
  addBefore | The type to add the new type before. Use types().size() to add to the end

Precondition
  `addBefore <= types().size()`

Parameters

  updateReferences | Should the references to make and break nodes be updated?

Definition at line 68 of file GraphStruct.cpp.

References module(), types(), chi::ChiModule::updateLastEditTime(), and chi::DataType::valid().

Referenced by types().

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

## ◆ context()

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

Get the context.

Returns
  The Context

Definition at line 26 of file GraphStruct.hpp.

Referenced by dataType(), and setName().

Here is the caller graph for this function:

## ◆ dataType()

DataType chi::GraphStruct::dataType | ( |  | ) |

Get the DataType of the struct.

Returns
  The DataType

Definition at line 111 of file GraphStruct.cpp.

References context(), chi::Context::findInstancesOfType(), chi::Context::llvmContext(), module(), name(), chi::GraphModule::nodeTypeFromName(), types(), and chi::DataType::valid().

Referenced by types().

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

## ◆ modifyType()

void chi::GraphStruct::modifyType | ( | size_t | id,
|  | DataType | newTy,
|  | std::string | newName,
|  | bool | updateReferences = `true`
| ) |  |

Change the type and name of a type.

Parameters

  id | The ID to change
  newTy | The new type
  newName | The new name
  updateReferences | Should the references to make and break nodes be updated?

Definition at line 82 of file GraphStruct.cpp.

References module(), types(), chi::ChiModule::updateLastEditTime(), and chi::DataType::valid().

Referenced by types().

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

## ◆ module()

GraphModule& chi::GraphStruct::module | ( |  | ) | const
| inline

Get the module.

Returns
  The GraphModule

Definition at line 30 of file GraphStruct.hpp.

References setName().

Referenced by addType(), dataType(), modifyType(), chi::GraphModule::removeStruct(), removeType(), and setName().

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

## ◆ name()

const std::string& chi::GraphStruct::name | ( |  | ) | const
| inline

Get the name of the type.

Returns
  the name

Definition at line 43 of file GraphStruct.hpp.

Referenced by dataType(), GraphStruct(), chi::GraphModule::removeStruct(), and setName().

Here is the caller graph for this function:

## ◆ removeType()

void chi::GraphStruct::removeType | ( | size_t | id,
|  | bool | updateReferences = `true`
| ) |  |

Remove a type from a struct.

Parameters

  id | The ID to remove
  updateReferences | Should the references to make and break nodes be updated?

Definition at line 97 of file GraphStruct.cpp.

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

Referenced by types().

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

## ◆ setName()

std::vector< NodeInstance * > chi::GraphStruct::setName | ( | std::string | newName,
|  | bool | updateReferences = `true`
| ) |  |

Set the name of the struct, and optionally update all references in the context.

Warning
  If updateReferences is false or not all the modules that use this struct are loaded, then there WILL be broken references.

Parameters

  newName | The new name

Precondition
  `!newName.empty()`

Parameters

  updateReferences | Should all the references in the module be updated?

Returns
  The nodes that were updated, garunteed to be empty of `updateReferences` is false

Definition at line 24 of file GraphStruct.cpp.

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

Referenced by module().

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

## ◆ types()

const std::vector<NamedDataType>& chi::GraphStruct::types | ( |  | ) | const
| inline

Get the types the struct contains.

Returns
  The types

Definition at line 47 of file GraphStruct.hpp.

References addType(), dataType(), modifyType(), and removeType().

Referenced by addType(), dataType(), chi::graphStructToJson(), modifyType(), and removeType().

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/GraphStruct.hpp
- lib/core/src/GraphStruct.cpp