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

The module that provides built-in operations like literals, math operations, etc. More...

#include <chi/LangModule.hpp>

+ Inheritance diagram for chi::LangModule:
+ Collaboration diagram for chi::LangModule:

Public Member Functions

 LangModule (Context &ctx)
 Default constructor, usually called from Context::loadModule("lang") More...
 
 ~LangModule ()
 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...
 
Result addForwardDeclarations (llvm::Module &module) const override
 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...
 
Result generateModule (llvm::Module &) override
 Generate a llvm::Module from the module. More...
 
std::time_t lastEditTime () const
 Get the time that this module was last edited. More...
 
Result nodeTypeFromName (boost::string_view name, const nlohmann::json &jsonData, std::unique_ptr< NodeType > *toFill) override
 Create a node type that is in the module from the name and json. More...
 
std::vector< std::string > nodeTypeNames () const override
 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...
 
DataType typeFromName (boost::string_view name) override
 Get a DataType from the name. More...
 
std::vector< std::string > typeNames () const override
 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

The module that provides built-in operations like literals, math operations, etc.

Definition at line 16 of file LangModule.hpp.

Constructor & Destructor Documentation

◆ LangModule()

chi::LangModule::LangModule ( Context ctx)

Default constructor, usually called from Context::loadModule("lang")

Parameters
ctxThe Context to construct from

Definition at line 529 of file LangModule.cpp.

References chi::ChiModule::context(), chi::Context::llvmContext(), chi::Context::typeFromModule(), and typeFromName().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDependency()

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

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 chi::ChiModule::context(), and chi::Context::loadModule().

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

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

◆ addForwardDeclarations()

Result chi::LangModule::addForwardDeclarations ( llvm::Module &  module) const
overridevirtual

Adds forward declartions for the functions in this module.

Parameters
moduleThe module to add forward declartions to
Returns
The Result

Implements chi::ChiModule.

Definition at line 910 of file LangModule.cpp.

Referenced by typeNames().

+ Here is the caller graph for this function:

◆ context()

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

Get the Context that this module belongs to.

Returns
The context

Definition at line 68 of file ChiModule.hpp.

References chi::ChiModule::addForwardDeclarations(), and chi::ChiModule::generateModule().

Referenced by chi::ChiModule::addDependency(), chi::createGraphFunctionDeclarationFromJson(), chi::GraphModule::createNodeTypeFromCCode(), chi::GraphModule::generateModule(), chi::jsonToGraphStruct(), LangModule(), chi::Debugger::nodeFromFrame(), chi::GraphModule::nodeTypeFromName(), chi::GraphModule::removeFunction(), chi::GraphModule::saveToDisk(), chi::GraphModule::sourceFilePath(), chi::Debugger::start(), and 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
inlineinherited

Get the dependencies.

Returns
The dependencies

Definition at line 83 of file ChiModule.hpp.

References chi::ChiModule::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
inlineinherited

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

Result chi::LangModule::generateModule ( llvm::Module &  module)
overridevirtual

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

Implements chi::ChiModule.

Definition at line 912 of file LangModule.cpp.

Referenced by typeNames().

+ Here is the caller graph for this function:

◆ lastEditTime()

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

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

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

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

Implements chi::ChiModule.

Definition at line 847 of file LangModule.cpp.

References chi::Result::addEntry().

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

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

◆ nodeTypeNames()

std::vector<std::string> chi::LangModule::nodeTypeNames ( ) const
inlineoverridevirtual

Get the possible node type names.

Returns
A std::vector of the possible names

Implements chi::ChiModule.

Definition at line 29 of file LangModule.hpp.

◆ removeDependency()

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

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
inlineinherited

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

DataType chi::LangModule::typeFromName ( boost::string_view  name)
overridevirtual

Get a DataType from the name.

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

Implements chi::ChiModule.

Definition at line 871 of file LangModule.cpp.

References chi::ChiModule::context(), and chi::Context::llvmContext().

Referenced by chi::FunctionCompiler::createSubroutineType(), and LangModule().

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

◆ typeNames()

std::vector<std::string> chi::LangModule::typeNames ( ) const
inlineoverridevirtual

Get the possible DataType names.

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

Implements chi::ChiModule.

Definition at line 39 of file LangModule.hpp.

References addForwardDeclarations(), and generateModule().

+ Here is the call graph for this function:

◆ updateLastEditTime()

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

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: