![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
The welder joins all the compiler passes. More...
#include <Welder.hpp>
Public Member Functions | |
| Welder (unsigned debug, const std::vector< std::filesystem::path > &lib_env, uint16_t features=DefaultFeatures) | |
| Create a new Welder. | |
| void | registerSymbol (const std::string &name) |
| Register a symbol as a global in the compiler. | |
| bool | computeASTFromFile (const std::string &filename) |
| bool | computeASTFromString (const std::string &code) |
| bool | computeASTFromStringWithKnownSymbols (const std::string &code, const std::vector< std::string > &symbols) |
| Compile code from a string, with a set of known symbols (useful for the debugger) | |
| bool | generateBytecode () |
| Compile the AST processed by computeASTFromFile / computeASTFromString. | |
| bool | generateBytecodeUsingTables (const std::vector< std::string > &symbols, const std::vector< Value > &constants, std::size_t start_page_at_offset) |
| Compile the AST processed by computeASTFromFile / computeASTFromString, with prefilled symbols and constants tables (useful for the debugger) | |
| bool | saveBytecodeToFile (const std::string &filename) |
| Save the generated bytecode to a given file. | |
| void | redirectLogsTo (std::ostream &os) |
| Redirect the logs to a given stream. | |
| const internal::Node & | ast () const noexcept |
| std::string | textualIR () const noexcept |
| const bytecode_t & | bytecode () const noexcept |
Private Member Functions | |
| void | dumpIRToFile () const |
| bool | computeAST (const std::string &filename, const std::string &code) |
Private Attributes | |
| std::vector< std::filesystem::path > | m_lib_env |
| uint16_t | m_features |
| std::filesystem::path | m_root_file |
| std::vector< std::string > | m_imports |
| std::vector< internal::IR::Block > | m_ir |
| bytecode_t | m_bytecode |
| internal::Node | m_computed_ast |
| internal::Parser | m_parser |
| internal::ImportSolver | m_import_solver |
| internal::MacroProcessor | m_macro_processor |
| internal::Optimizer | m_ast_optimizer |
| internal::NameResolutionPass | m_name_resolver |
| internal::Logger | m_logger |
| internal::ASTLowerer | m_lowerer |
| internal::IROptimizer | m_ir_optimizer |
| internal::IRCompiler | m_ir_compiler |
The welder joins all the compiler passes.
Definition at line 38 of file Welder.hpp.
| Ark::Welder::Welder | ( | unsigned | debug, |
| const std::vector< std::filesystem::path > & | lib_env, | ||
| uint16_t | features = DefaultFeatures ) |
Create a new Welder.
| debug | debug level |
| lib_env | list of paths to the standard library |
| features | feature flags to toggle features on/off |
Definition at line 19 of file Welder.cpp.
|
nodiscardnoexcept |
Definition at line 150 of file Welder.cpp.
References m_computed_ast.
Referenced by JsonCompiler::compile().
|
nodiscardnoexcept |
Definition at line 162 of file Welder.cpp.
References m_bytecode.
Referenced by Ark::internal::Debugger::compile(), Ark::State::compile(), Ark::State::doString(), and main().
|
private |
Definition at line 184 of file Welder.cpp.
References ARK_NO_NAME_FILE, Ark::internal::ImportSolver::ast(), Ark::internal::MacroProcessor::ast(), Ark::internal::NameResolutionPass::ast(), Ark::internal::Optimizer::ast(), Ark::internal::Parser::ast(), Ark::FeatureASTOptimizer, Ark::FeatureImportSolver, Ark::FeatureMacroProcessor, Ark::FeatureNameResolver, Ark::FeatureTestFailOnException, Ark::Diagnostics::generate(), Ark::Diagnostics::generateWithCode(), Ark::internal::Parser::imports(), m_ast_optimizer, m_computed_ast, m_features, m_import_solver, m_macro_processor, m_name_resolver, m_parser, m_root_file, Ark::internal::ImportSolver::process(), Ark::internal::MacroProcessor::process(), Ark::internal::NameResolutionPass::process(), Ark::internal::Optimizer::process(), Ark::internal::Parser::process(), and Ark::internal::ImportSolver::setup().
Referenced by computeASTFromFile(), computeASTFromString(), and computeASTFromStringWithKnownSymbols().
| bool Ark::Welder::computeASTFromFile | ( | const std::string & | filename | ) |
| filename |
Definition at line 38 of file Welder.cpp.
References computeAST(), m_root_file, and Ark::Utils::readFile().
Referenced by Ark::State::compile(), JsonCompiler::feed(), and main().
| bool Ark::Welder::computeASTFromString | ( | const std::string & | code | ) |
| code |
Definition at line 46 of file Welder.cpp.
References ARK_NO_NAME_FILE, computeAST(), and m_root_file.
Referenced by Ark::State::doString().
| bool Ark::Welder::computeASTFromStringWithKnownSymbols | ( | const std::string & | code, |
| const std::vector< std::string > & | symbols ) |
Compile code from a string, with a set of known symbols (useful for the debugger)
| code | |
| symbols |
Definition at line 53 of file Welder.cpp.
References Ark::internal::NameResolutionPass::addDefinedSymbol(), ARK_NO_NAME_FILE, computeAST(), m_name_resolver, and m_root_file.
Referenced by Ark::internal::Debugger::compile().
|
private |
Definition at line 167 of file Welder.cpp.
References ARK_CACHE_DIRNAME, Ark::internal::IRCompiler::dumpToStream(), m_ir_compiler, and m_root_file.
Referenced by generateBytecode().
| bool Ark::Welder::generateBytecode | ( | ) |
Compile the AST processed by computeASTFromFile / computeASTFromString.
Definition at line 62 of file Welder.cpp.
References Ark::internal::IRCompiler::bytecode(), dumpIRToFile(), Ark::FeatureDumpIR, Ark::FeatureIROptimizer, Ark::FeatureTestFailOnException, Ark::Diagnostics::generate(), Ark::internal::ASTLowerer::intermediateRepresentation(), Ark::internal::IROptimizer::intermediateRepresentation(), m_bytecode, m_computed_ast, m_features, m_ir, m_ir_compiler, m_ir_optimizer, m_lowerer, Ark::internal::ASTLowerer::process(), Ark::internal::IRCompiler::process(), Ark::internal::IROptimizer::process(), Ark::internal::ASTLowerer::symbols(), and Ark::internal::ASTLowerer::values().
Referenced by Ark::State::compile(), Ark::State::doString(), generateBytecodeUsingTables(), and main().
| bool Ark::Welder::generateBytecodeUsingTables | ( | const std::vector< std::string > & | symbols, |
| const std::vector< Value > & | constants, | ||
| std::size_t | start_page_at_offset ) |
Compile the AST processed by computeASTFromFile / computeASTFromString, with prefilled symbols and constants tables (useful for the debugger)
| symbols | |
| constants | |
| start_page_at_offset |
Definition at line 93 of file Welder.cpp.
References Ark::internal::ASTLowerer::addToTables(), generateBytecode(), m_lowerer, Ark::Number, Ark::internal::ASTLowerer::offsetPagesBy(), Ark::PageAddr, and Ark::String.
Referenced by Ark::internal::Debugger::compile().
| void Ark::Welder::redirectLogsTo | ( | std::ostream & | os | ) |
Redirect the logs to a given stream.
| os | output stream |
Definition at line 138 of file Welder.cpp.
References Ark::internal::Pass::configureLogger(), Ark::internal::Logger::configureOutputStream(), m_ast_optimizer, m_import_solver, m_ir_compiler, m_ir_optimizer, m_logger, m_lowerer, m_macro_processor, and m_name_resolver.
Referenced by Ark::State::compile(), and Ark::State::doString().
| void Ark::Welder::registerSymbol | ( | const std::string & | name | ) |
Register a symbol as a global in the compiler.
| name |
Definition at line 33 of file Welder.cpp.
References Ark::internal::NameResolutionPass::addDefinedSymbol(), and m_name_resolver.
Referenced by Ark::State::compile(), and Ark::State::doString().
| bool Ark::Welder::saveBytecodeToFile | ( | const std::string & | filename | ) |
Save the generated bytecode to a given file.
| filename |
Definition at line 123 of file Welder.cpp.
References Ark::internal::Logger::info(), m_bytecode, and m_logger.
Referenced by Ark::State::compile().
|
nodiscardnoexcept |
Definition at line 155 of file Welder.cpp.
References Ark::internal::IRCompiler::dumpToStream(), and m_ir_compiler.
|
private |
Definition at line 126 of file Welder.hpp.
Referenced by computeAST(), and redirectLogsTo().
|
private |
Definition at line 120 of file Welder.hpp.
Referenced by bytecode(), generateBytecode(), and saveBytecodeToFile().
|
private |
Definition at line 121 of file Welder.hpp.
Referenced by ast(), computeAST(), and generateBytecode().
|
private |
Definition at line 115 of file Welder.hpp.
Referenced by computeAST(), and generateBytecode().
|
private |
Definition at line 124 of file Welder.hpp.
Referenced by computeAST(), and redirectLogsTo().
|
private |
Definition at line 118 of file Welder.hpp.
|
private |
Definition at line 119 of file Welder.hpp.
Referenced by generateBytecode().
|
private |
Definition at line 132 of file Welder.hpp.
Referenced by dumpIRToFile(), generateBytecode(), redirectLogsTo(), and textualIR().
|
private |
Definition at line 131 of file Welder.hpp.
Referenced by generateBytecode(), and redirectLogsTo().
|
private |
Definition at line 114 of file Welder.hpp.
|
private |
Definition at line 129 of file Welder.hpp.
Referenced by redirectLogsTo(), and saveBytecodeToFile().
|
private |
Definition at line 130 of file Welder.hpp.
Referenced by generateBytecode(), generateBytecodeUsingTables(), and redirectLogsTo().
|
private |
Definition at line 125 of file Welder.hpp.
Referenced by computeAST(), and redirectLogsTo().
|
private |
Definition at line 127 of file Welder.hpp.
Referenced by computeAST(), computeASTFromStringWithKnownSymbols(), redirectLogsTo(), and registerSymbol().
|
private |
Definition at line 123 of file Welder.hpp.
Referenced by computeAST().
|
private |
Definition at line 117 of file Welder.hpp.
Referenced by computeAST(), computeASTFromFile(), computeASTFromString(), computeASTFromStringWithKnownSymbols(), and dumpIRToFile().