§tiro::compiler
Translates a set of source files into a module.
#include "tiropp/compiler.hpp"
§Public Functions
Name | |
---|---|
compiler(std::string_view module_name) Constructs a new compiler instance for a module with the given name. | |
compiler(std::string_view module_name, compiler_settings settings) Constructs a new compiler instance for a module with the given name and the given settings. | |
compiler(tiro_compiler_t raw_compiler) | |
void | add_file(std::string_view file_name, std::string_view file_content) Add a source file to the compiler's source set. |
void | run() Run the compiler on the set of source files provided via add_file . |
bool | has_module() const Returns true if the compiler has successfully compiled a bytecode module. |
compiled_module | take_module() Extracts the compiled module from the compiler and returns it. |
std::string | dump_cst() const Returns a dump of the compiler's concrete syntax tree. |
std::string | dump_ast() const Returns a dump of the compiler's abstract syntax tree. |
std::string | dump_ir() const Returns a dump of the compiler's internal representation. |
std::string | dump_bytecode() const Returns a dump of the disassembled bytecode. |
tiro_compiler_t | raw_compiler() const |
§Public Functions Documentation
§function compiler
inline explicit compiler(std::string_view module_name)
Constructs a new compiler instance for a module with the given name.
§function compiler
inline explicit compiler(std::string_view module_name,compiler_settings settings)
Constructs a new compiler instance for a module with the given name and the given settings.
§function compiler
inline explicit compiler(tiro_compiler_t raw_compiler)
§function add_file
inline void add_file(std::string_view file_name,std::string_view file_content)
Add a source file to the compiler's source set.
Can only be called before compilation started.
file_name
should be unique in the current source set.
§function run
inline void run()
Run the compiler on the set of source files provided via add_file
.
Requires at least one source file. This function can only be called once for every compiler instance.
§function has_module
inline bool has_module() const
Returns true if the compiler has successfully compiled a bytecode module.
§function take_module
inline compiled_module take_module()
Extracts the compiled module from the compiler and returns it.
For this to work, run() must have completed successfully.
§function dump_cst
inline std::string dump_cst() const
Returns a dump of the compiler's concrete syntax tree.
Can only be called after a call to run(), and only if the enable_dump_cst
option was set to true.
§function dump_ast
inline std::string dump_ast() const
Returns a dump of the compiler's abstract syntax tree.
Can only be called after a call to run(), and only if the enable_dump_ast
option was set to true.
§function dump_ir
inline std::string dump_ir() const
Returns a dump of the compiler's internal representation.
Can only be called after a call to run(), and only if the enable_dump_ir
option was set to true.
§function dump_bytecode
inline std::string dump_bytecode() const
Returns a dump of the disassembled bytecode.
Can only be called after a call to run(), and only if the enable_bytecode
option was set to true.
§function raw_compiler
inline tiro_compiler_t raw_compiler() const
Updated on 2022-02-27 at 21:17:13 +0100