chigraph  master
Systems programming language written for beginners in LLVM
chi::ChiModule Struct Referenceabstract

An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module. More...

#include <chi/ChiModule.hpp>

+ Inheritance diagram for chi::ChiModule:

Public Member Functions

 ChiModule (Context &contextArg, boost::filesystem::path moduleFullName)
 Default constructor. More...
 
virtual ~ChiModule ()=default
 Destructor.
 
Result addDependency (boost::filesystem::path newDepFullPath)
 Add a dependency to the module Loads the module from context() if it isn't already loaded. More...
 
virtual Result addForwardDeclarations (llvm::Module &module) const =0
 Adds forward declartions for the functions in this module. More...
 
Contextcontext () const
 Get the Context that this module belongs to. More...
 
const std::set< boost::filesystem::path > & dependencies () const
 Get the dependencies. More...
 
std::string fullName () const
 Get the full name of the module. More...
 
boost::filesystem::path fullNamePath () const
 Get the full name of the module in a path. More...
 
virtual Result generateModule (llvm::Module &module)=0
 Generate a llvm::Module from the module. More...
 
std::time_t lastEditTime () const
 Get the time that this module was last edited. More...
 
virtual Result nodeTypeFromName (boost::string_view name, const nlohmann::json &jsonData, std::unique_ptr< NodeType > *toFill)=0
 Create a node type that is in the module from the name and json. More...
 
virtual std::vector< std::string > nodeTypeNames () const =0
 Get the possible node type names. More...
 
bool removeDependency (std::string depName)
 Remove a dependency Does not unload from context. More...
 
std::string shortName () const
 Get the short name of the module (the last bit) More...
 
virtual DataType typeFromName (boost::string_view name)=0
 Get a DataType from the name. More...
 
virtual std::vector< std::string > typeNames () const =0
 Get the possible DataType names. More...
 
void updateLastEditTime (std::time_t newLastEditTime=std::time(nullptr))
 Update the last edit time, signifying that it's been edited. More...
 

Detailed Description

An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module.

Definition at line 24 of file ChiModule.hpp.

Constructor & Destructor Documentation

◆ ChiModule()

chi::ChiModule::ChiModule ( Context contextArg,
boost::filesystem::path  moduleFullName 
)

Default constructor.

This is usually run by Context::loadModule

Parameters
contextArgThe context to create the module insides
moduleFullNameThe full name of the module

Definition at line 8 of file ChiModule.cpp.

Member Function Documentation

◆ addDependency()

Result chi::ChiModule::addDependency ( boost::filesystem::path  newDepFullPath)

Add a dependency to the module Loads the module from context() if it isn't already loaded.

Parameters
newDepFullPathThe dependency, full path
Returns
The result

Definition at line 13 of file ChiModule.cpp.

References context(), and chi::Context::loadModule().

Referenced by dependencies(), and chi::GraphModule::GraphModule().

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

◆ addForwardDeclarations()

virtual Result chi::ChiModule::addForwardDeclarations ( llvm::Module &  module) const
pure virtual

Adds forward declartions for the functions in this module.

Parameters
moduleThe module to add forward declartions to
Returns
The Result

Implemented in chi::LangModule, and chi::GraphModule.

Referenced by context().

+ Here is the caller graph for this function:

◆ context()

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

Get the Context that this module belongs to.

Returns
The context

Definition at line 68 of file ChiModule.hpp.

References addForwardDeclarations(), and generateModule().

Referenced by addDependency(), chi::createGraphFunctionDeclarationFromJson(), chi::GraphModule::createNodeTypeFromCCode(), chi::GraphModule::generateModule(), chi::jsonToGraphStruct(), chi::LangModule::LangModule(), chi::Debugger::nodeFromFrame(), chi::GraphModule::nodeTypeFromName(), chi::GraphModule::removeFunction(), chi::GraphModule::saveToDisk(), chi::GraphModule::sourceFilePath(), chi::Debugger::start(), and chi::LangModule::typeFromName().

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

◆ dependencies()

const std::set<boost::filesystem::path>& chi::ChiModule::dependencies ( ) const
inline

Get the dependencies.

Returns
The dependencies

Definition at line 83 of file ChiModule.hpp.

References addDependency().

Referenced by chi::Context::compileModule(), and chi::graphModuleToJson().

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

◆ fullName()

◆ fullNamePath()

boost::filesystem::path chi::ChiModule::fullNamePath ( ) const
inline

Get the full name of the module in a path.

Returns
The full name, as a boost::filesystem::path

Definition at line 64 of file ChiModule.hpp.

Referenced by chi::Context::compileModule().

+ Here is the caller graph for this function:

◆ generateModule()

virtual Result chi::ChiModule::generateModule ( llvm::Module &  module)
pure virtual

Generate a llvm::Module from the module.

Usually called by Context::compileModule

Parameters
moduleThe llvm::Module to fill into – must be already filled with forward declarations of dependencies
Returns
The Result

Implemented in chi::LangModule, and chi::GraphModule.

Referenced by chi::Context::compileModule(), and context().

+ Here is the caller graph for this function:

◆ lastEditTime()

std::time_t chi::ChiModule::lastEditTime ( ) const
inline

Get the time that this module was last edited.

Returns
The std::time_t at which it was last edited

Definition at line 101 of file ChiModule.hpp.

Referenced by chi::Context::compileModule().

+ Here is the caller graph for this function:

◆ nodeTypeFromName()

virtual Result chi::ChiModule::nodeTypeFromName ( boost::string_view  name,
const nlohmann::json &  jsonData,
std::unique_ptr< NodeType > *  toFill 
)
pure virtual

Create a node type that is in the module from the name and json.

Parameters
nameThe name of the node type to create
jsonDataThe extra JSON data for the node
Return values
toFillThe NodeType object 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

Implemented in chi::GraphModule, and chi::LangModule.

◆ nodeTypeNames()

virtual std::vector<std::string> chi::ChiModule::nodeTypeNames ( ) const
pure virtual

Get the possible node type names.

Returns
A std::vector of the possible names

Implemented in chi::GraphModule, and chi::LangModule.

◆ removeDependency()

bool chi::ChiModule::removeDependency ( std::string  depName)
inline

Remove a dependency Does not unload from context.

Parameters
depNameThe name of the dependency to remove
Returns
If one was removed

Definition at line 95 of file ChiModule.hpp.

◆ shortName()

std::string chi::ChiModule::shortName ( ) const
inline

Get the short name of the module (the last bit)

Returns
The name

Definition at line 58 of file ChiModule.hpp.

Referenced by chi::Context::compileModule(), chi::GraphModule::pathToCSources(), and chi::validateFunction().

+ Here is the caller graph for this function:

◆ typeFromName()

virtual DataType chi::ChiModule::typeFromName ( boost::string_view  name)
pure virtual

Get a DataType from the name.

Parameters
nameThe name of the type
Returns
The data type, or an invalid DataType if failed

Implemented in chi::GraphModule, and chi::LangModule.

Referenced by chi::Context::typeFromModule().

+ Here is the caller graph for this function:

◆ typeNames()

virtual std::vector<std::string> chi::ChiModule::typeNames ( ) const
pure virtual

Get the possible DataType names.

Returns
A std::vector of all the names of types this module has

Implemented in chi::GraphModule, and chi::LangModule.

◆ updateLastEditTime()

void chi::ChiModule::updateLastEditTime ( std::time_t  newLastEditTime = std::time(nullptr))
inline

Update the last edit time, signifying that it's been edited.

Parameters
newLastEditTimeThe new time, or current time for default

Definition at line 105 of file ChiModule.hpp.

Referenced by chi::GraphFunction::addDataInput(), chi::GraphFunction::addDataOutput(), chi::GraphFunction::addExecInput(), chi::GraphFunction::addExecOutput(), chi::GraphStruct::addType(), chi::connectData(), chi::connectExec(), chi::disconnectData(), chi::disconnectExec(), chi::GraphModule::getOrCreateFunction(), chi::GraphFunction::getOrCreateLocalVariable(), chi::GraphModule::getOrCreateStruct(), chi::GraphFunction::getOrInsertEntryNode(), chi::GraphFunction::insertNode(), chi::Context::loadModule(), chi::GraphStruct::modifyType(), chi::GraphFunction::removeDataInput(), chi::GraphFunction::removeDataOutput(), chi::GraphFunction::removeExecInput(), chi::GraphFunction::removeExecOutput(), chi::GraphModule::removeFunction(), chi::GraphFunction::removeLocalVariable(), chi::GraphFunction::removeNode(), chi::GraphModule::removeStruct(), chi::GraphStruct::removeType(), chi::GraphFunction::renameDataInput(), chi::GraphFunction::renameDataOutput(), chi::GraphFunction::renameExecInput(), chi::GraphFunction::renameExecOutput(), chi::GraphFunction::renameLocalVariable(), chi::GraphFunction::retypeDataInput(), chi::GraphFunction::retypeLocalVariable(), chi::GraphStruct::setName(), chi::GraphFunction::setName(), and chi::NodeInstance::setType().

+ Here is the caller graph for this function:

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