|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Reusable orchestration object built on top of Compiler_Frontend.
More...
#include <Compiler_Generic_Driver.H>
Public Member Functions | |
| Compiler_Generic_Driver (Compiler_Frontend &frontend_impl, const Compiler_Generic_Driver_Options &options={}, const size_t arena_size=1<< 20) | |
| Builds one generic driver over a concrete frontend implementation. | |
| Compiler_Generic_Driver (const Compiler_Generic_Driver &)=delete | |
| Compiler_Generic_Driver & | operator= (const Compiler_Generic_Driver &)=delete |
| const Compiler_Generic_Driver_Options & | options () const noexcept |
| Returns the immutable driver configuration. | |
| size_t | arena_size () const noexcept |
| Returns the configured bytecode arena size. | |
| void | clear () noexcept |
| Clears all driver and frontend state while preserving host bindings. | |
| bool | bind_host_function (const std::string &name, const Interpreter_Host_Function callback, void *user_data=nullptr) |
| Binds one host function into the persistent runtime prelude. | |
| bool | execute_sources (const DynArray< Compiler_Driver_Source > &inputs, const Compiler_Driver_Action action=Compiler_Driver_Action::Run) |
| Runs the pipeline over in-memory sources. | |
| bool | execute_files (const DynArray< std::string > &paths, const Compiler_Driver_Action action=Compiler_Driver_Action::Run) |
| Runs the pipeline over source files loaded from disk. | |
| bool | execute_source (const std::string &name, const std::string &text, const Compiler_Driver_Action action=Compiler_Driver_Action::Run) |
| Convenience overload for a single in-memory source. | |
| bool | ok () const noexcept |
| Returns whether the last driver action finished successfully. | |
| const Compiler_Frontend & | frontend_impl () const noexcept |
| Returns the frontend used by this driver. | |
| Compiler_Driver_Action | last_action () const noexcept |
| Returns the last requested action. | |
| const Compiler_Bytecode_Module * | bytecode_module () const noexcept |
| Returns the lowered bytecode module from the last run, when available. | |
| const Compiler_C_Backend_Emission & | c_emission () const noexcept |
Returns the C emission payload from the last emit-c action. | |
| const Compiler_Driver_Run_Output & | run_output () const noexcept |
Returns the run summary from the last run action. | |
| const DynArray< std::string > & | errors () const noexcept |
| Returns non-diagnostic driver-level hard errors. | |
| const DynArray< std::string > & | warnings () const noexcept |
| Returns non-fatal driver-level warnings. | |
| const DynArray< Compiler_Driver_Artifact > & | artifacts () const noexcept |
| Returns all recorded artifacts from the last run. | |
| const Compiler_Driver_Artifact * | find_artifact (std::string_view label) const noexcept |
| Finds one artifact by exact label. | |
| std::string | diagnostics_text () const |
| Renders diagnostics from the frontend as plain text. | |
Private Member Functions | |
| void | append_error (const std::string &text) |
| void | record_text_artifact (const std::string &label, std::string text) |
| void | collect_frontend_state () |
| void | record_diagnostics_artifact () |
| void | record_import_order_artifact () |
| void | record_module_metadata_artifact () |
| void | record_module_linkage_artifact () |
| void | record_module_bindings_artifact () |
| void | record_module_name_table_artifact () |
| void | record_module_semantic_environment_artifact () |
| void | record_driver_messages_artifact () |
| bool | lower_bytecode () |
| bool | emit_c () |
| bool | execute_hir_runtime () |
| void | append_run_failure_if_needed () |
| bool | finalize (const Compiler_Driver_Action action) |
Static Private Member Functions | |
| static bool | read_file_text (const std::string &path, std::string &out_text) |
Private Attributes | |
| Compiler_Frontend * | frontend_ = nullptr |
| Compiler_Generic_Driver_Options | config_ |
| Compiler_Bytecode_Context | bytecode_ctx_ |
| Interpreter_Runtime | runtime_ |
| size_t | arena_bytes_ = 0 |
| DynArray< Compiler_Driver_Artifact > | artifacts_ |
| DynArray< std::string > | errors_ |
| DynArray< std::string > | warnings_ |
| Compiler_Bytecode_Module * | bytecode_module_ = nullptr |
| Compiler_C_Backend_Emission | c_emission_ |
| Compiler_Driver_Run_Output | run_output_ |
| Compiler_Driver_Action | last_action_ = Compiler_Driver_Action::Parse_Only |
Reusable orchestration object built on top of Compiler_Frontend.
Definition at line 71 of file Compiler_Generic_Driver.H.
|
inlineexplicit |
Builds one generic driver over a concrete frontend implementation.
| frontend_impl | Frontend used for parse/sema/HIR/IR stages. |
| options | Runtime and backend configuration. |
| arena_size | Arena size used by bytecode lowering. |
Definition at line 316 of file Compiler_Generic_Driver.H.
|
delete |
Definition at line 88 of file Compiler_Generic_Driver.H.
References Aleph::DynArray< T >::append(), and errors_.
Referenced by execute_files(), execute_sources(), and lower_bytecode().
|
inlineprivate |
Definition at line 261 of file Compiler_Generic_Driver.H.
References Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Interpreter_Runtime_Error::code, Aleph::Interpreter_Execution_Result::error, errors_, Aleph::message(), Aleph::Interpreter_Runtime_Error::message, Aleph::Interpreter_Execution_Result::ok(), Aleph::Compiler_Driver_Run_Output::result, and run_output_.
Referenced by execute_sources().
|
inlinenoexcept |
Returns the configured bytecode arena size.
Definition at line 333 of file Compiler_Generic_Driver.H.
References arena_bytes_.
|
inlinenoexcept |
Returns all recorded artifacts from the last run.
Definition at line 501 of file Compiler_Generic_Driver.H.
References artifacts_.
|
inline |
Binds one host function into the persistent runtime prelude.
Definition at line 356 of file Compiler_Generic_Driver.H.
References Aleph::Interpreter_Runtime::bind_host_function(), Aleph::blossom_maximum_cardinality_matching(), and runtime_.
|
inlinenoexcept |
Returns the lowered bytecode module from the last run, when available.
Definition at line 471 of file Compiler_Generic_Driver.H.
References bytecode_module_.
|
inlinenoexcept |
Returns the C emission payload from the last emit-c action.
Definition at line 477 of file Compiler_Generic_Driver.H.
References c_emission_.
|
inlinenoexcept |
Clears all driver and frontend state while preserving host bindings.
Definition at line 339 of file Compiler_Generic_Driver.H.
References artifacts_, bytecode_ctx_, bytecode_module_, c_emission_, Aleph::DynArray< T >::clear(), Aleph::Compiler_Frontend::clear(), Aleph::Compiler_Frontend::diagnostic_engine(), errors_, frontend_, last_action_, Aleph::Parse_Only, Aleph::Compiler_Bytecode_Context::reset(), Aleph::Interpreter_Runtime::reset(), run_output_, runtime_, Aleph::Interpreter_Runtime::set_diagnostics(), and warnings_.
Referenced by execute_files(), and execute_sources().
|
inlineprivate |
Definition at line 98 of file Compiler_Generic_Driver.H.
References Aleph::DynArray< T >::append(), Aleph::Compiler_Frontend::artifacts(), artifacts_, Aleph::blossom_maximum_cardinality_matching(), Aleph::Compiler_Frontend::errors(), errors_, frontend_, Aleph::Compiler_Frontend::warnings(), and warnings_.
Referenced by finalize().
|
inline |
Renders diagnostics from the frontend as plain text.
Definition at line 516 of file Compiler_Generic_Driver.H.
References Aleph::Compiler_Frontend::diagnostic_engine(), frontend_, out, and Aleph::Diagnostic_Engine::render_plain().
|
inlineprivate |
Definition at line 238 of file Compiler_Generic_Driver.H.
References Aleph::Compiler_Generic_Driver_Options::c_backend_options, c_emission_, Aleph::compiler_emit_c_module(), config_, errors_, frontend_, Aleph::Compiler_Frontend::ir_module(), Aleph::Compiler_Driver_Detail::merge_report(), record_text_artifact(), Aleph::Compiler_C_Backend_Emission::source, and warnings_.
Referenced by execute_sources().
Returns non-diagnostic driver-level hard errors.
Definition at line 489 of file Compiler_Generic_Driver.H.
References errors_.
|
inline |
Runs the pipeline over source files loaded from disk.
Definition at line 423 of file Compiler_Generic_Driver.H.
References Aleph::DynArray< T >::access(), append_error(), Aleph::blossom_maximum_cardinality_matching(), clear(), execute_sources(), finalize(), read_file_text(), and Aleph::DynArray< T >::size().
|
inlineprivate |
Definition at line 245 of file Compiler_Generic_Driver.H.
References Aleph::Interpreter_Runtime::evaluate_module(), Aleph::Compiler_Driver_Run_Output::executed, frontend_, Aleph::Compiler_Driver_Run_Output::globals_text, Aleph::Compiler_Frontend::hir_module(), Aleph::interpreter_dump_globals(), Aleph::interpreter_value_to_string(), Aleph::Interpreter_Execution_Result::ok(), record_text_artifact(), Aleph::Compiler_Driver_Detail::render_run_result(), Aleph::Compiler_Driver_Run_Output::result, run_output_, runtime_, Aleph::Interpreter_Execution_Result::value, and Aleph::Compiler_Driver_Run_Output::value_text.
Referenced by execute_sources().
|
inline |
Convenience overload for a single in-memory source.
Definition at line 442 of file Compiler_Generic_Driver.H.
References Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), and execute_sources().
|
inline |
Runs the pipeline over in-memory sources.
Definition at line 364 of file Compiler_Generic_Driver.H.
References Aleph::Compiler_Frontend::analyze(), append_error(), append_run_failure_if_needed(), Aleph::blossom_maximum_cardinality_matching(), clear(), Aleph::Emit_Bytecode, Aleph::Emit_C, emit_c(), execute_hir_runtime(), finalize(), frontend_, Aleph::HIR, Aleph::IR, Aleph::Compiler_Frontend::load_sources(), lower_bytecode(), Aleph::Compiler_Frontend::lower_hir(), Aleph::Compiler_Frontend::lower_ir(), Aleph::Compiler_Frontend::parse(), Aleph::Parse_Only, Aleph::Run, and Aleph::Sema_Only.
Referenced by execute_files(), and execute_source().
|
inlineprivate |
Definition at line 282 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), collect_frontend_state(), last_action_, ok(), record_diagnostics_artifact(), record_driver_messages_artifact(), record_import_order_artifact(), record_module_bindings_artifact(), record_module_linkage_artifact(), record_module_metadata_artifact(), record_module_name_table_artifact(), and record_module_semantic_environment_artifact().
Referenced by execute_files(), and execute_sources().
|
inlinenoexcept |
Finds one artifact by exact label.
Definition at line 507 of file Compiler_Generic_Driver.H.
References artifacts_.
|
inlinenoexcept |
Returns the frontend used by this driver.
Definition at line 459 of file Compiler_Generic_Driver.H.
References frontend_.
|
inlinenoexcept |
Returns the last requested action.
Definition at line 465 of file Compiler_Generic_Driver.H.
References last_action_.
|
inlineprivate |
Definition at line 221 of file Compiler_Generic_Driver.H.
References append_error(), Aleph::blossom_maximum_cardinality_matching(), bytecode_ctx_, bytecode_module_, Aleph::compiler_dump_bytecode_module(), errors_, frontend_, Aleph::Compiler_Frontend::ir_module(), Aleph::Compiler_Driver_Detail::merge_report(), record_text_artifact(), Aleph::Compiler_Frontend::type_context(), Aleph::validate_bytecode_module(), and warnings_.
Referenced by execute_sources().
|
inlinenoexcept |
Returns whether the last driver action finished successfully.
Definition at line 452 of file Compiler_Generic_Driver.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::Compiler_Frontend::diagnostic_engine(), errors_, frontend_, and Aleph::DynArray< T >::is_empty().
Referenced by finalize().
|
delete |
|
inlinenoexcept |
Returns the immutable driver configuration.
Definition at line 327 of file Compiler_Generic_Driver.H.
References config_.
|
inlinestaticprivate |
Definition at line 297 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), and out.
Referenced by execute_files().
|
inlineprivate |
Definition at line 113 of file Compiler_Generic_Driver.H.
References Aleph::Compiler_Frontend::diagnostic_engine(), frontend_, out, record_text_artifact(), and Aleph::Diagnostic_Engine::render_plain().
Referenced by finalize().
|
inlineprivate |
Definition at line 215 of file Compiler_Generic_Driver.H.
References errors_, record_text_artifact(), Aleph::Compiler_Driver_Detail::render_messages(), and warnings_.
Referenced by finalize().
|
inlineprivate |
Definition at line 124 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_render_module_order(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_descriptors(), Aleph::Compiler_Frontend::module_merge_order(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 164 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_bind_module_surfaces(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_bindings(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_descriptors(), Aleph::Compiler_Frontend::module_merge_order(), Aleph::Compiler_Frontend::module_metadata(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 149 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_linkage(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_descriptors(), Aleph::Compiler_Frontend::module_merge_order(), Aleph::Compiler_Frontend::module_metadata(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 137 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_render_module_metadata(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_metadata(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 180 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_bind_module_surfaces(), Aleph::compiler_build_module_name_table(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_name_table(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_descriptors(), Aleph::Compiler_Frontend::module_merge_order(), Aleph::Compiler_Frontend::module_metadata(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 197 of file Compiler_Generic_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_bind_module_surfaces(), Aleph::compiler_build_module_name_table(), Aleph::compiler_build_module_semantic_environment(), Aleph::compiler_link_module_surfaces(), Aleph::compiler_render_module_semantic_environment(), Aleph::Compiler_Frontend::find_artifact(), frontend_, Aleph::Compiler_Frontend::module_descriptors(), Aleph::Compiler_Frontend::module_merge_order(), Aleph::Compiler_Frontend::module_metadata(), and record_text_artifact().
Referenced by finalize().
|
inlineprivate |
Definition at line 93 of file Compiler_Generic_Driver.H.
References Aleph::Compiler_Driver_Detail::append_artifact(), and artifacts_.
Referenced by emit_c(), execute_hir_runtime(), lower_bytecode(), record_diagnostics_artifact(), record_driver_messages_artifact(), record_import_order_artifact(), record_module_bindings_artifact(), record_module_linkage_artifact(), record_module_metadata_artifact(), record_module_name_table_artifact(), and record_module_semantic_environment_artifact().
|
inlinenoexcept |
Returns the run summary from the last run action.
Definition at line 483 of file Compiler_Generic_Driver.H.
References run_output_.
Returns non-fatal driver-level warnings.
Definition at line 495 of file Compiler_Generic_Driver.H.
References warnings_.
|
private |
Definition at line 77 of file Compiler_Generic_Driver.H.
Referenced by arena_size().
|
private |
Definition at line 79 of file Compiler_Generic_Driver.H.
Referenced by artifacts(), clear(), collect_frontend_state(), find_artifact(), and record_text_artifact().
|
private |
Definition at line 75 of file Compiler_Generic_Driver.H.
Referenced by clear(), and lower_bytecode().
|
private |
Definition at line 83 of file Compiler_Generic_Driver.H.
Referenced by bytecode_module(), clear(), and lower_bytecode().
|
private |
Definition at line 84 of file Compiler_Generic_Driver.H.
Referenced by c_emission(), clear(), and emit_c().
|
private |
Definition at line 74 of file Compiler_Generic_Driver.H.
|
private |
Definition at line 80 of file Compiler_Generic_Driver.H.
Referenced by append_error(), append_run_failure_if_needed(), clear(), collect_frontend_state(), emit_c(), errors(), lower_bytecode(), ok(), and record_driver_messages_artifact().
|
private |
Definition at line 73 of file Compiler_Generic_Driver.H.
Referenced by clear(), collect_frontend_state(), diagnostics_text(), emit_c(), execute_hir_runtime(), execute_sources(), frontend_impl(), lower_bytecode(), ok(), record_diagnostics_artifact(), record_import_order_artifact(), record_module_bindings_artifact(), record_module_linkage_artifact(), record_module_metadata_artifact(), record_module_name_table_artifact(), and record_module_semantic_environment_artifact().
|
private |
Definition at line 86 of file Compiler_Generic_Driver.H.
Referenced by clear(), finalize(), and last_action().
|
private |
Definition at line 85 of file Compiler_Generic_Driver.H.
Referenced by append_run_failure_if_needed(), clear(), execute_hir_runtime(), and run_output().
|
private |
Definition at line 76 of file Compiler_Generic_Driver.H.
Referenced by bind_host_function(), clear(), and execute_hir_runtime().
|
private |
Definition at line 81 of file Compiler_Generic_Driver.H.
Referenced by clear(), collect_frontend_state(), emit_c(), lower_bytecode(), record_driver_messages_artifact(), and warnings().