chigraph  master
Systems programming language written for beginners in LLVM
chi Namespace Reference

The namespace where chigraph lives. More...

Classes

struct  ChiModule
 An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module. More...
 
struct  Context
 The class that handles the loading, creation, storing, and compilation of modules It also stores a LLVMContext object to be used everywhere. More...
 
struct  DataType
 A type of data Loose wrapper around llvm::Type*, except it knows which ChiModule it's in and it embeds debug types. More...
 
class  Debugger
 Helper class for using LLDB with chigraph. More...
 
struct  DefaultModuleCache
 
struct  Flags
 A template class for type-safe flags. More...
 
struct  FunctionCompiler
 Class for compiling GraphFunctions into llvm::Functions. More...
 
struct  GraphFunction
 this is an AST-like representation of a function in a graph It is used for IDE-like behavior, codegen, and JSON generation. More...
 
struct  GraphModule
 Module that holds graph functions. More...
 
struct  GraphStruct
 A class holding a compound type defined in a GraphModule. More...
 
struct  LangModule
 The module that provides built-in operations like literals, math operations, etc. More...
 
struct  ModuleCache
 This class provides an interface for creating module caches. More...
 
struct  NamedDataType
 Basicaly a std::pair<std::string, DataType>, except it has nicer names. More...
 
struct  NodeCompiler
 Helper to compile nodes. More...
 
struct  NodeInstance
 An instance of a node. More...
 
struct  NodeType
 A generic node type. More...
 
struct  Result
 The result object, used for identifiying errors with good diagnostics. More...
 
struct  Subprocess
 Provides an platform-independent abstraction for creating subprocesses. More...
 

Enumerations

enum  CompileSettings {
  CompileSettings::UseCache = 1u,
  CompileSettings::LinkDependencies = 1u << 1,
  CompileSettings::Default = UseCache | LinkDependencies
}
 Settings for compiling modules. More...
 
enum  VCSType {
  Git,
  Unknown
}
 

Functions

Result compileCToLLVM (const boost::filesystem::path &ctollvmPath, llvm::LLVMContext &llvmContext, std::vector< std::string > arguments, boost::string_view inputCCode, std::unique_ptr< llvm::Module > *toFill)
 Use chi-ctollvm to compile C source code to a llvm module It also uses stdCIncludePaths to find basic include paths. More...
 
Result compileFunction (const GraphFunction &func, llvm::Module *mod, llvm::DICompileUnit *debugCU, llvm::DIBuilder &debugBuilder)
 Compile the graph to an llvm::Function (usually called from JsonModule::generateModule) More...
 
std::vector< NodeInstance * > dependentPuresRecursive (const NodeInstance &inst)
 Get the pures a NodeInstance relies on These are all the dependent pures (it's fetched recursively) They are in the order of dependency, for examply if node X depends on node Y, then node Y will come before node X. More...
 
boost::filesystem::path executablePath ()
 Get the path of the executable. More...
 
Result fetchModule (const fs::path &workspacePath, const fs::path &name, bool recursive)
 
Result fetchModule (const boost::filesystem::path &workspacePath, const boost::filesystem::path &name, bool recursive)
 Downloads a module from a remote URL, currently supports. More...
 
Result interpretLLVMIR (std::unique_ptr< llvm::Module > mod, llvm::CodeGenOpt::Level optLevel=llvm::CodeGenOpt::Default, const std::vector< llvm::GenericValue > &args={}, llvm::Function *funcToRun=nullptr, llvm::GenericValue *ret=nullptr)
 Interpret LLVM IR, just a convenience function. More...
 
Result interpretLLVMIRAsMain (std::unique_ptr< llvm::Module > mod, llvm::CodeGenOpt::Level optLevel=llvm::CodeGenOpt::Default, const std::vector< std::string > &args={}, llvm::Function *funcToRun=nullptr, int *ret=nullptr)
 Interpret LLVM IR as if it were the main function. More...
 
unsigned lineNumberFromNode (NodeInstance &inst)
 Get the mapped line number from a node. More...
 
Result operator+ (const Result &lhs, const Result &rhs)
 
Resultoperator+= (Result &lhs, const Result &rhs)
 
Result parseBitcodeFile (const boost::filesystem::path &file, llvm::LLVMContext &ctx, std::unique_ptr< llvm::Module > *toFill)
 Parse a bitcode file. More...
 
Result parseBitcodeString (const std::string &bitcode, llvm::LLVMContext &ctx, std::unique_ptr< llvm::Module > *toFill)
 
std::pair< std::string, std::string > parseColonPair (const std::string &in)
 Parse a colonated pair Example: lang:i32 would turn into {lang, i32}. More...
 
std::tuple< VCSType, std::string, std::string > resolveUrlFromModuleName (const boost::filesystem::path &path)
 Get the URL for a VCS repository from a module name. More...
 
std::string stringifyLLVMType (llvm::Type *ty)
 Turns a type into a string. More...
 
boost::filesystem::path workspaceFromChildPath (const boost::filesystem::path &path)
 Get the workspace directory from a child of the workspace directory Example: say you have a workspace at ~/chi/ If you used this with ~/chi/src/ it would return ~/chi/. More...
 
Function Validation

Functions for making sure that generated functions are valid (also usable as a linter tools)

Result validateFunction (const GraphFunction &func)
 Validate that a function is compilable. More...
 
Result validateFunctionConnectionsAreTwoWay (const GraphFunction &func)
 Make sure that connections connect back and that they have the same types. More...
 
Result validateFunctionNodeInputs (const GraphFunction &func)
 Make sure that nodes are called before their outputs are used. More...
 
Result validateFunctionExecOutputs (const GraphFunction &func)
 Make sure nodes have an output connection. More...
 
Result validateFunctionEntryType (const GraphFunction &func)
 Make sure the function entry type aligns with the function type. More...
 
Result validateFunctionExitTypes (const GraphFunction &func)
 Make sure the function exit types align with the function type. More...
 
Result validateFunctionMainSignature (const GraphFunction &func)
 Make sure it's a valid signautre for a main function. More...
 
Json Serialization/Deserialization
Result jsonToGraphModule (Context &createInside, const nlohmann::json &input, const boost::filesystem::path &fullName, GraphModule **toFill=nullptr)
 Load a GraphModule from json. More...
 
Result createGraphFunctionDeclarationFromJson (GraphModule &createInside, const nlohmann::json &input, GraphFunction **toFill=nullptr)
 Create a forward declaration of a function in a module with an empty graph. More...
 
Result jsonToGraphFunction (GraphFunction &createInside, const nlohmann::json &input)
 Load a GraphFunction–must already exist (use createGraphFunctionDeclarationFromJson) More...
 
Result jsonToGraphStruct (GraphModule &mod, boost::string_view name, const nlohmann::json &input, GraphStruct **toFill=nullptr)
 Load a GraphStruct from json. More...
 
std::pair< std::string, std::string > parseObjectPair (const nlohmann::json &object)
 Parse something that looks like: {"hello": "there"} into {"hello", "there"}. More...
 
nlohmann::json graphFunctionToJson (const GraphFunction &func)
 Serialize a GraphFunction to json. More...
 
nlohmann::json graphModuleToJson (const GraphModule &mod)
 Serialize a JsonModule to json. More...
 
nlohmann::json graphStructToJson (const GraphStruct &struc)
 Serialize a GraphStruct to json. More...
 
Name Mangling

Functions for mangling names into names used natively

std::string mangleFunctionName (std::string fullModuleName, const std::string &name)
 Mangle a function name. More...
 
std::pair< std::string, std::string > unmangleFunctionName (std::string mangled)
 Unmangle a function name. More...
 
Connection Manipulation

Functions for connecting and disconnecting nodes

Result connectData (NodeInstance &lhs, size_t lhsConnID, NodeInstance &rhs, size_t rhsConnID)
 Connects two nodes' data connections. More...
 
Result connectExec (NodeInstance &lhs, size_t lhsConnID, NodeInstance &rhs, size_t rhsConnID)
 Connects two nodes' exec connections. More...
 
Result disconnectData (NodeInstance &lhs, size_t lhsConnID, NodeInstance &rhs)
 Disconnect a data connection. More...
 
Result disconnectExec (NodeInstance &lhs, size_t lhsConnID)
 Disconnect a exec connection. More...
 
Standard include finder
Result stdCIncludePaths (std::vector< boost::filesystem::path > &toFill)
 Gets the location of the standard C library to include.
 

Detailed Description

The namespace where chigraph lives.

Enumeration Type Documentation

◆ CompileSettings

enum chi::CompileSettings
strong

Settings for compiling modules.

Enumerator
UseCache 

Use the cache in lib.

LinkDependencies 

Link in dependencies If this is set, it will be a ready to run module If not, it'll contain forward declarations for dependencies and full definitons For functions in that module.

Default 

Default, which is both.

Definition at line 26 of file Context.hpp.

Function Documentation

◆ compileCToLLVM()

Result chi::compileCToLLVM ( const boost::filesystem::path &  ctollvmPath,
llvm::LLVMContext &  llvmContext,
std::vector< std::string >  arguments,
boost::string_view  inputCCode,
std::unique_ptr< llvm::Module > *  toFill 
)

Use chi-ctollvm to compile C source code to a llvm module It also uses stdCIncludePaths to find basic include paths.

Parameters
[in]ctollvmPathThe path to the chi-ctollvm executable.
[in]llvmContextThe LLVM context to create the module into
[in]argumentsThe arguments to clang. Can include input files if desired.
[in]inputCCodeThe C code to compile. If arguments contains input files, then this can be empty.
[out]toFillThe unique pointer module to create the module inside
Returns
The Result

Definition at line 17 of file CCompiler.cpp.

References chi::Result::addEntry(), chi::Result::addScopedContext(), chi::Subprocess::attachStringToStdErr(), chi::Subprocess::attachStringToStdOut(), chi::Subprocess::closeStdIn(), chi::Subprocess::exitCode(), chi::Subprocess::pushToStdIn(), chi::Subprocess::setArguments(), chi::Subprocess::start(), and stdCIncludePaths().

Referenced by chi::GraphModule::createNodeTypeFromCCode(), and chi::GraphModule::generateModule().

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

◆ compileFunction()

Result chi::compileFunction ( const GraphFunction func,
llvm::Module *  mod,
llvm::DICompileUnit *  debugCU,
llvm::DIBuilder &  debugBuilder 
)

Compile the graph to an llvm::Function (usually called from JsonModule::generateModule)

Parameters
funcThe function to compile
modThe module to codgen into, should already be a valid module
debugCUThe compilation unit that the GraphFunction resides in.
debugBuilderThe debug builder to build debug info
Returns
The result

Definition at line 371 of file FunctionCompiler.cpp.

Referenced by chi::FunctionCompiler::compiled().

+ Here is the caller graph for this function:

◆ connectData()

Result chi::connectData ( NodeInstance lhs,
size_t  lhsConnID,
NodeInstance rhs,
size_t  rhsConnID 
)

Connects two nodes' data connections.

Parameters
lhsThe node to the left, the node outputting the data
lhsConnIDThe ID of data connection in lhs to be connected
rhsThe node to the right, that takes in the data as a parameter
rhsConnIDThe ID of data input in rhs
Precondition
lhs.function() == rhs.connection()
Returns
The result

Definition at line 128 of file NodeInstance.cpp.

References chi::Result::addEntry(), chi::NodeType::dataInputs(), chi::NodeType::dataOutputs(), disconnectData(), chi::NodeInstance::function(), chi::NodeInstance::inputDataConnections, chi::NodeInstance::module(), chi::NodeInstance::outputDataConnections, chi::NodeType::qualifiedName(), chi::NodeType::toJSON(), chi::NodeInstance::type(), and chi::ChiModule::updateLastEditTime().

Referenced by jsonToGraphFunction(), and chi::NodeInstance::module().

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

◆ connectExec()

Result chi::connectExec ( NodeInstance lhs,
size_t  lhsConnID,
NodeInstance rhs,
size_t  rhsConnID 
)

Connects two nodes' exec connections.

Parameters
lhsThe node to the left, the node outputting the connections
lhsConnIDThe ID of exec connection in lhs to be connected
rhsThe node to the right, that takes in the exec as a parameter
rhsConnIDThe ID of exec input in rhs
Precondition
lhs.function() == rhs.connection()
Returns
The result

Definition at line 186 of file NodeInstance.cpp.

References chi::Result::addEntry(), disconnectExec(), chi::NodeType::execInputs(), chi::NodeType::execOutputs(), chi::NodeInstance::function(), chi::NodeInstance::inputExecConnections, chi::NodeInstance::module(), chi::NodeInstance::outputExecConnections, chi::NodeType::qualifiedName(), chi::NodeInstance::type(), and chi::ChiModule::updateLastEditTime().

Referenced by jsonToGraphFunction(), and chi::NodeInstance::module().

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

◆ createGraphFunctionDeclarationFromJson()

Result chi::createGraphFunctionDeclarationFromJson ( GraphModule createInside,
const nlohmann::json &  input,
GraphFunction **  toFill = nullptr 
)

Create a forward declaration of a function in a module with an empty graph.

Parameters
[in]createInsidethe GraphModule to create the forward declaration in
[in]inputThe input JSON
[out]toFillThe GraphFunction* to fill, optional
Returns
The Result

Definition at line 121 of file JsonDeserializer.cpp.

References chi::Result::addEntry(), chi::ChiModule::context(), chi::ChiModule::fullName(), chi::GraphModule::getOrCreateFunction(), parseColonPair(), parseObjectPair(), chi::GraphFunction::setDescription(), and chi::Context::typeFromModule().

Referenced by jsonToGraphModule().

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

◆ dependentPuresRecursive()

std::vector< NodeInstance * > chi::dependentPuresRecursive ( const NodeInstance inst)

Get the pures a NodeInstance relies on These are all the dependent pures (it's fetched recursively) They are in the order of dependency, for examply if node X depends on node Y, then node Y will come before node X.

Warning
Recursive based on how many pures are in a chain. Cyclic pure dependencies will crash. TODO: make sure they don't crash, and issue a nice error
Parameters
instThe NodeInstance to get the dependent pures for
Returns
All the directly dependent pures
Postcondition
all the elements in the return are pure

Definition at line 244 of file NodeCompiler.cpp.

References chi::NodeInstance::inputDataConnections.

Referenced by chi::FunctionCompiler::compile(), chi::NodeCompiler::compile_stage1(), and chi::NodeCompiler::jumpBackInst().

+ Here is the caller graph for this function:

◆ disconnectData()

Result chi::disconnectData ( NodeInstance lhs,
size_t  lhsConnID,
NodeInstance rhs 
)

Disconnect a data connection.

Parameters
lhsThe left hand node
lhsConnIDThe ID of the data connection to disconnect
rhsThe node that the data port is connected to
Precondition
lhs.function() == rhs.connection()
Returns
The result

Definition at line 229 of file NodeInstance.cpp.

References chi::Result::addEntry(), chi::NodeType::dataInputs(), chi::NodeType::dataOutputs(), chi::NodeInstance::function(), chi::NodeInstance::inputDataConnections, chi::NodeInstance::module(), chi::NodeInstance::outputDataConnections, chi::NodeType::qualifiedName(), chi::NodeInstance::stringId(), chi::NodeType::toJSON(), chi::NodeInstance::type(), and chi::ChiModule::updateLastEditTime().

Referenced by connectData(), chi::NodeInstance::module(), chi::GraphFunction::removeNode(), and chi::NodeInstance::setType().

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

◆ disconnectExec()

Result chi::disconnectExec ( NodeInstance lhs,
size_t  lhsConnID 
)

Disconnect a exec connection.

Parameters
lhsThe left hand node in the connection
lhsConnIDThe ID of the connection on lhs
Returns
The result

Definition at line 294 of file NodeInstance.cpp.

References chi::Result::addEntry(), chi::NodeType::execOutputs(), chi::NodeInstance::module(), chi::NodeInstance::outputExecConnections, chi::NodeType::qualifiedName(), chi::NodeInstance::stringId(), chi::NodeInstance::type(), and chi::ChiModule::updateLastEditTime().

Referenced by connectExec(), chi::NodeInstance::module(), chi::GraphFunction::removeNode(), and chi::NodeInstance::setType().

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

◆ executablePath()

boost::filesystem::path chi::executablePath ( )

Get the path of the executable.

Returns
The exectuable path

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

+ Here is the caller graph for this function:

◆ fetchModule()

Result chi::fetchModule ( const boost::filesystem::path &  workspacePath,
const boost::filesystem::path &  name,
bool  recursive 
)

Downloads a module from a remote URL, currently supports.

  • github
    Parameters
    workspacePathThe path to the workspace
    Precondition
    fs::is_regular_file(workspacePath / ".chigraphworkspace")
    Parameters
    nameThe name of the module to fetch
    recursiveShould all dependencies be cloned as well?
    Returns
    The Result

◆ graphFunctionToJson()

nlohmann::json chi::graphFunctionToJson ( const GraphFunction func)

Serialize a GraphFunction to json.

Parameters
funcThe function to serialize
Returns
The serialized function

Definition at line 15 of file JsonSerializer.cpp.

References chi::GraphFunction::dataInputs(), chi::GraphFunction::dataOutputs(), chi::GraphFunction::description(), chi::GraphFunction::execInputs(), chi::GraphFunction::execOutputs(), chi::GraphFunction::localVariables(), chi::GraphFunction::name(), and chi::GraphFunction::nodes().

Referenced by graphModuleToJson().

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

◆ graphModuleToJson()

nlohmann::json chi::graphModuleToJson ( const GraphModule mod)

Serialize a JsonModule to json.

Parameters
modThe module to serialize
Returns
The serialized module

Definition at line 97 of file JsonSerializer.cpp.

References chi::GraphModule::cEnabled(), chi::ChiModule::dependencies(), chi::GraphModule::functions(), graphFunctionToJson(), and graphStructToJson().

Referenced by chi::GraphModule::saveToDisk().

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

◆ graphStructToJson()

nlohmann::json chi::graphStructToJson ( const GraphStruct struc)

Serialize a GraphStruct to json.

Parameters
strucThe struct to serialize
Returns
The serialized struct

Definition at line 117 of file JsonSerializer.cpp.

References chi::GraphStruct::types().

Referenced by graphModuleToJson().

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

◆ interpretLLVMIR()

Result chi::interpretLLVMIR ( std::unique_ptr< llvm::Module >  mod,
llvm::CodeGenOpt::Level  optLevel = llvm::CodeGenOpt::Default,
const std::vector< llvm::GenericValue > &  args = {},
llvm::Function *  funcToRun = nullptr,
llvm::GenericValue *  ret = nullptr 
)

Interpret LLVM IR, just a convenience function.

Parameters
[in]modThe LLVM Module to interpret
[in]optLevelHow much the optimization should be applied. The default is roughly equilivant to -O2
[in]argsThe arguments to pass to the function, empty by default
[in]funcToRunThe function to run. By default it uses "main".
[out]retThe GenericValue to fill with the result of the function. Optional
Returns
The Result

Definition at line 528 of file Context.cpp.

References chi::Result::addEntry().

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

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

◆ interpretLLVMIRAsMain()

Result chi::interpretLLVMIRAsMain ( std::unique_ptr< llvm::Module >  mod,
llvm::CodeGenOpt::Level  optLevel = llvm::CodeGenOpt::Default,
const std::vector< std::string > &  args = {},
llvm::Function *  funcToRun = nullptr,
int *  ret = nullptr 
)

Interpret LLVM IR as if it were the main function.

Parameters
[in]modThe module to interpret
[in]optLevelThe optimization level
[in]argsThe arguments to main
[in]funcToRunThe function, defaults to "main" from mod
[out]retThe return from main. Optional.
Returns
The Result

Definition at line 564 of file Context.cpp.

References chi::Result::addEntry().

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

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

◆ jsonToGraphFunction()

Result chi::jsonToGraphFunction ( GraphFunction createInside,
const nlohmann::json &  input 
)

Load a GraphFunction–must already exist (use createGraphFunctionDeclarationFromJson)

Parameters
createInsideThe GraphFunction to create the graph for
inputThe JSON to load
Returns
The Result

Definition at line 232 of file JsonDeserializer.cpp.

References chi::Result::addEntry(), connectData(), connectExec(), chi::GraphFunction::context(), chi::GraphFunction::getOrCreateLocalVariable(), chi::GraphFunction::insertNode(), chi::GraphFunction::nodes(), chi::Context::nodeTypeFromModule(), parseColonPair(), and chi::Context::typeFromModule().

Referenced by jsonToGraphModule().

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

◆ jsonToGraphModule()

Result chi::jsonToGraphModule ( Context createInside,
const nlohmann::json &  input,
const boost::filesystem::path &  fullName,
GraphModule **  toFill = nullptr 
)

Load a GraphModule from json.

Parameters
[in]createInsideThe Context to create the module in
[in]inputThe JSON to load
[in]fullNameThe full name of the module being loaded
[out]toFillThe GraphModule* to set, optional
Returns
The Result

Definition at line 14 of file JsonDeserializer.cpp.

References chi::Result::addEntry(), chi::Result::addScopedContext(), createGraphFunctionDeclarationFromJson(), jsonToGraphFunction(), jsonToGraphStruct(), chi::Context::newGraphModule(), and chi::Context::workspacePath().

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

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

◆ jsonToGraphStruct()

Result chi::jsonToGraphStruct ( GraphModule mod,
boost::string_view  name,
const nlohmann::json &  input,
GraphStruct **  toFill = nullptr 
)

Load a GraphStruct from json.

Parameters
[in]modThe module to create it inside
[in]nameThe name of the GraphStruct to create
[in]inputThe JSON to load
[out]toFillThe object to fill, optional
Returns
The Result

Definition at line 450 of file JsonDeserializer.cpp.

References chi::Result::addEntry(), chi::ChiModule::context(), chi::GraphModule::getOrCreateStruct(), parseColonPair(), parseObjectPair(), and chi::Context::typeFromModule().

Referenced by jsonToGraphModule().

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

◆ lineNumberFromNode()

unsigned chi::lineNumberFromNode ( NodeInstance inst)

Get the mapped line number from a node.

Parameters
instThe instance to get the line number for
Returns
The line number

Definition at line 282 of file Debugger.cpp.

References chi::GraphModule::createLineNumberAssoc(), and chi::NodeInstance::module().

Referenced by chi::Debugger::lldbDebugger(), and chi::Debugger::setBreakpoint().

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

◆ mangleFunctionName()

std::string chi::mangleFunctionName ( std::string  fullModuleName,
const std::string &  name 
)

Mangle a function name.

Parameters
fullModuleNameThe full name of the module. Example github.com/russelltg/test/lib
nameThe name of the function
Returns
The mangled name

Definition at line 9 of file NameMangler.cpp.

Referenced by chi::GraphModule::addForwardDeclarations(), and chi::FunctionCompiler::initialize().

+ Here is the caller graph for this function:

◆ parseBitcodeFile()

Result chi::parseBitcodeFile ( const boost::filesystem::path &  file,
llvm::LLVMContext &  ctx,
std::unique_ptr< llvm::Module > *  toFill 
)

Parse a bitcode file.

Convenience function to make it LLVM version independent and reutrn a result

Definition at line 56 of file BitcodeParser.cpp.

References chi::Result::addEntry().

Referenced by chi::Context::compileModule(), and chi::DefaultModuleCache::retrieveFromCache().

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

◆ parseColonPair()

std::pair<std::string, std::string> chi::parseColonPair ( const std::string &  in)
inline

Parse a colonated pair Example: lang:i32 would turn into {lang, i32}.

Parameters
inThe colonated pair
Returns
{first, second}

Definition at line 355 of file GraphFunction.hpp.

References chi::GraphFunction::module(), and chi::GraphFunction::name().

Referenced by createGraphFunctionDeclarationFromJson(), jsonToGraphFunction(), jsonToGraphStruct(), and chi::GraphModule::nodeTypeFromName().

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

◆ parseObjectPair()

std::pair< std::string, std::string > chi::parseObjectPair ( const nlohmann::json &  object)

Parse something that looks like: {"hello": "there"} into {"hello", "there"}.

Parameters
objectThe json object
Returns
{"key", "value"}

Definition at line 491 of file JsonDeserializer.cpp.

Referenced by createGraphFunctionDeclarationFromJson(), jsonToGraphStruct(), and chi::GraphModule::nodeTypeFromName().

+ Here is the caller graph for this function:

◆ resolveUrlFromModuleName()

std::tuple< VCSType, std::string, std::string > chi::resolveUrlFromModuleName ( const boost::filesystem::path &  path)

Get the URL for a VCS repository from a module name.

Parameters
pathThe module name
Returns
{The type of VCS that it is, the URL to clone, the relative path to clone to}

Definition at line 303 of file Fetcher.cpp.

◆ stringifyLLVMType()

std::string chi::stringifyLLVMType ( llvm::Type *  ty)

Turns a type into a string.

Parameters
tyThe type to stringify
Returns
The return string

Definition at line 474 of file Context.cpp.

Referenced by chi::GraphModule::createNodeTypeFromCCode(), and chi::Context::moduleCache().

+ Here is the caller graph for this function:

◆ unmangleFunctionName()

std::pair< std::string, std::string > chi::unmangleFunctionName ( std::string  mangled)

Unmangle a function name.

Parameters
mangledThe mangled name
Returns
The unmangled name; {moduleName, functionName}

Definition at line 45 of file NameMangler.cpp.

Referenced by chi::Debugger::nodeFromFrame().

+ Here is the caller graph for this function:

◆ validateFunction()

Result chi::validateFunction ( const GraphFunction func)

Validate that a function is compilable.

If this succeeds, then it should be compilable Calls validateFunctionConnectionsAreTwoWay and validateFunctionNodeInputs

Parameters
funcThe function to check
Returns
The Result

Definition at line 15 of file FunctionValidator.cpp.

References chi::GraphFunction::module(), chi::GraphFunction::name(), chi::ChiModule::shortName(), validateFunctionConnectionsAreTwoWay(), validateFunctionEntryType(), validateFunctionExecOutputs(), validateFunctionExitTypes(), validateFunctionMainSignature(), and validateFunctionNodeInputs().

Referenced by chi::FunctionCompiler::initialize().

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

◆ validateFunctionConnectionsAreTwoWay()

Result chi::validateFunctionConnectionsAreTwoWay ( const GraphFunction func)

Make sure that connections connect back and that they have the same types.

Parameters
funcThe function to check
Returns
The Result

Definition at line 31 of file FunctionValidator.cpp.

References chi::Result::addEntry(), chi::Result::addScopedContext(), chi::ChiModule::fullName(), chi::NodeInstance::inputDataConnections, chi::GraphFunction::module(), chi::GraphFunction::name(), chi::GraphFunction::nodes(), chi::NodeInstance::outputExecConnections, chi::NodeType::qualifiedName(), chi::NodeInstance::stringId(), and chi::NodeInstance::type().

Referenced by validateFunction().

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

◆ validateFunctionEntryType()

Result chi::validateFunctionEntryType ( const GraphFunction func)

Make sure the function entry type aligns with the function type.

Parameters
funcThe function to check
Returns
The Result

Definition at line 249 of file FunctionValidator.cpp.

References chi::Result::addEntry(), chi::GraphFunction::dataInputs(), chi::GraphFunction::entryNode(), chi::ChiModule::fullName(), chi::GraphFunction::module(), and chi::GraphFunction::name().

Referenced by validateFunction().

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

◆ validateFunctionExecOutputs()

Result chi::validateFunctionExecOutputs ( const GraphFunction func)

Make sure nodes have an output connection.

Parameters
funcThe function to check
Returns
The Result

Definition at line 222 of file FunctionValidator.cpp.

References chi::Result::addEntry(), chi::Result::addScopedContext(), chi::ChiModule::fullName(), chi::GraphFunction::module(), chi::GraphFunction::name(), and chi::GraphFunction::nodes().

Referenced by validateFunction().

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

◆ validateFunctionExitTypes()

Result chi::validateFunctionExitTypes ( const GraphFunction func)

Make sure the function exit types align with the function type.

Parameters
funcThe function to check
Returns
The Result

Definition at line 281 of file FunctionValidator.cpp.

References chi::Result::addEntry(), chi::GraphFunction::dataOutputs(), and chi::GraphFunction::nodesWithType().

Referenced by validateFunction().

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

◆ validateFunctionMainSignature()

Result chi::validateFunctionMainSignature ( const GraphFunction func)

Make sure it's a valid signautre for a main function.

Parameters
funcThe function to verify
Returns
The Result

Definition at line 310 of file FunctionValidator.cpp.

References chi::Result::addEntry(), chi::GraphFunction::dataInputs(), chi::GraphFunction::dataOutputs(), chi::GraphFunction::execInputs(), and chi::GraphFunction::execOutputs().

Referenced by validateFunction().

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

◆ validateFunctionNodeInputs()

Result chi::validateFunctionNodeInputs ( const GraphFunction func)

Make sure that nodes are called before their outputs are used.

Parameters
funcThe function to check
Returns
The Result

Definition at line 198 of file FunctionValidator.cpp.

References chi::Result::addScopedContext(), chi::GraphFunction::entryNode(), chi::ChiModule::fullName(), chi::GraphFunction::module(), and chi::GraphFunction::name().

Referenced by validateFunction().

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

◆ workspaceFromChildPath()

fs::path chi::workspaceFromChildPath ( const boost::filesystem::path &  path)

Get the workspace directory from a child of the workspace directory Example: say you have a workspace at ~/chi/ If you used this with ~/chi/src/ it would return ~/chi/.

Parameters
pathThe child path
Returns
The workspace path, or an empty path if it wasn't found

Definition at line 462 of file Context.cpp.

Referenced by chi::Context::Context(), and chi::Context::moduleCache().

+ Here is the caller graph for this function: