![]() |
Spicy
|
#include <unit.h>
Public Member Functions | |
| ~Unit () | |
| declaration::Module * | module () const |
| const auto & | uid () const |
| void | setUID (const declaration::module::UID &uid) |
| Result< Nothing > | codegen () |
| Result< Nothing > | print (std::ostream &out) const |
| Result< Nothing > | createPrototypes (std::ostream &out) |
| Result< CxxCode > | cxxCode () const |
| Result< linker::MetaData > | linkerMetaData () const |
| bool | isCompiledHILTI () const |
| bool | requiresCompilation () |
| void | setRequiresCompilation () |
| std::shared_ptr< Context > | context () const |
| const Options & | options () const |
Static Public Member Functions | |
| static Result< std::shared_ptr< Unit > > | fromSource (const std::shared_ptr< Context > &context, Builder *builder, const hilti::rt::filesystem::path &path) |
| static Result< std::shared_ptr< Unit > > | fromCXX (const std::shared_ptr< Context > &context, std::shared_ptr< detail::cxx::Unit > cxx, const hilti::rt::filesystem::path &path="") |
| static std::shared_ptr< Unit > | fromExistingUID (const std::shared_ptr< Context > &context, declaration::module::UID uid) |
| static Result< std::shared_ptr< Unit > > | link (const std::shared_ptr< Context > &context, const std::vector< linker::MetaData > &mds) |
Container for a single HILTI code module. For each HILTI source file, one compiler unit gets instantiated. That unit then drives the process to compile the module AST into C++ code. While that's in progress, the unit maintains state about the process, such as a list of dependencies this unit requires.
| Unit::~Unit | ( | ) |
Destructor.
Triggers generation of C++ code from the compiled AST.
|
inline |
Returns the compiler context in use.
Prints out C++ prototypes that host applications can use to interface with the generated C++ code. Must be called only after compile() was successful.
| out | stream to print the code to |
Returns the generated C++ code. Must be called only after compile() was successful.
|
static |
Factory method that instantiates a unit from existing C++ source code that's to compiled.
| context | global compiler context |
| path | path associated with the C++ code, if any |
|
static |
Factory method that instantiates a unit from an existing source file that it will parse.
| context | global compiler context |
| path | path to parse the module from |
| bool Unit::isCompiledHILTI | ( | ) | const |
Returns true if this unit has HILTI source code available. This is usually the case, but we also represent HILTI's linker output as a unit and there's no corresponding HILTI source code for that.
|
static |
Entry point for the HILTI linker, The linker combines meta data from several compiled HILTI modules and creates an additional unit from it, with its C++ code representing logic the HILTI runtime library will draw upon.
| context | compiler context to use |
| mds | set of meta data from modules to be linked together |
|
inline |
Returns the unit's meta data for the internal HILTI linker.
| declaration::Module * Unit::module | ( | ) | const |
Returns the root node of the module's AST. Must only be called if isCompiledHilti() returns true.
|
inline |
Returns the compiler options in use.
Prints out a HILTI module by recreating its code from the internal AST. Must be called only after compile() was successful.
| out | stream to print the code to |
| bool Unit::requiresCompilation | ( | ) |
Returns true if the AST has been determined to contain code that needs to be compiled as its own C++ module, rather than just declaration for other units.
|
inline |
Explicitly marks the unit as requiring compilation down to C++, overriding any automatic determination.
|
inline |
|
inline |
Returns the unique module ID associated with the unit.