![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
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 | generateBytecode () |
Compile the AST processed by computeASTFromFile / computeASTFromString. | |
bool | saveBytecodeToFile (const std::string &filename) |
Save the generated bytecode to a given file. | |
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::IROptimizer | m_ir_optimizer |
internal::IRCompiler | m_ir_compiler |
internal::Compiler | m_compiler |
The welder joins all the compiler passes.
Definition at line 37 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 16 of file Welder.cpp.
|
nodiscardnoexcept |
Definition at line 96 of file Welder.cpp.
References m_computed_ast.
Referenced by JsonCompiler::compile().
|
nodiscardnoexcept |
Definition at line 108 of file Welder.cpp.
References m_bytecode.
Referenced by Ark::State::doString().
|
private |
Definition at line 126 of file Welder.cpp.
References 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::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(), and computeASTFromString().
bool Ark::Welder::computeASTFromFile | ( | const std::string & | filename | ) |
filename |
Definition at line 35 of file Welder.cpp.
References computeAST(), m_root_file, and Ark::Utils::readFile().
Referenced by Ark::State::compile(), and JsonCompiler::feed().
bool Ark::Welder::computeASTFromString | ( | const std::string & | code | ) |
code |
Definition at line 43 of file Welder.cpp.
References ARK_NO_NAME_FILE, computeAST(), and m_root_file.
Referenced by Ark::State::doString().
|
private |
Definition at line 113 of file Welder.cpp.
References 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 50 of file Welder.cpp.
References Ark::internal::IRCompiler::bytecode(), dumpIRToFile(), Ark::FeatureDumpIR, Ark::FeatureIROptimizer, Ark::FeatureTestFailOnException, Ark::Diagnostics::generate(), Ark::internal::Compiler::intermediateRepresentation(), Ark::internal::IROptimizer::intermediateRepresentation(), m_bytecode, m_compiler, m_computed_ast, m_features, m_ir, m_ir_compiler, m_ir_optimizer, Ark::internal::Compiler::process(), Ark::internal::IRCompiler::process(), Ark::internal::IROptimizer::process(), Ark::internal::Compiler::symbols(), and Ark::internal::Compiler::values().
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 30 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 81 of file Welder.cpp.
References Ark::internal::Logger::info(), m_bytecode, and m_logger.
Referenced by Ark::State::compile().
|
nodiscardnoexcept |
Definition at line 101 of file Welder.cpp.
References Ark::internal::IRCompiler::dumpToStream(), and m_ir_compiler.
|
private |
Definition at line 99 of file Welder.hpp.
Referenced by computeAST().
|
private |
Definition at line 93 of file Welder.hpp.
Referenced by bytecode(), generateBytecode(), and saveBytecodeToFile().
|
private |
Definition at line 105 of file Welder.hpp.
Referenced by generateBytecode().
|
private |
Definition at line 94 of file Welder.hpp.
Referenced by ast(), computeAST(), and generateBytecode().
|
private |
Definition at line 88 of file Welder.hpp.
Referenced by computeAST(), and generateBytecode().
|
private |
Definition at line 97 of file Welder.hpp.
Referenced by computeAST().
|
private |
Definition at line 91 of file Welder.hpp.
|
private |
Definition at line 92 of file Welder.hpp.
Referenced by generateBytecode().
|
private |
Definition at line 104 of file Welder.hpp.
Referenced by dumpIRToFile(), generateBytecode(), and textualIR().
|
private |
Definition at line 103 of file Welder.hpp.
Referenced by generateBytecode().
|
private |
Definition at line 87 of file Welder.hpp.
|
private |
Definition at line 102 of file Welder.hpp.
Referenced by saveBytecodeToFile().
|
private |
Definition at line 98 of file Welder.hpp.
Referenced by computeAST().
|
private |
Definition at line 100 of file Welder.hpp.
Referenced by computeAST(), and registerSymbol().
|
private |
Definition at line 96 of file Welder.hpp.
Referenced by computeAST().
|
private |
Definition at line 90 of file Welder.hpp.
Referenced by computeAST(), computeASTFromFile(), computeASTFromString(), and dumpIRToFile().