|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Reusable orchestration object for compiler pipeline experiments. More...
#include <Compiler_Driver.H>
Public Member Functions | |
| Compiler_Driver (const Compiler_Driver_Options &options={}, const size_t arena_size=1<< 20) | |
| Constructs a driver with one stable set of pipeline options. | |
| Compiler_Driver (const Compiler_Driver &)=delete | |
| Compiler_Driver & | operator= (const Compiler_Driver &)=delete |
| const Compiler_Driver_Options & | options () const noexcept |
| Returns the immutable construction-time configuration. | |
| size_t | arena_size () const noexcept |
| Returns the arena size shared by the internal contexts. | |
| void | clear () noexcept |
| Clears all stage outputs while preserving host prelude 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. | |
| Compiler_Driver_Action | last_action () const noexcept |
| Returns the last requested action. | |
| const Source_Manager & | source_manager () const noexcept |
| Returns the shared source manager for the last run. | |
| const Diagnostic_Engine & | diagnostic_engine () const noexcept |
| Returns the diagnostic engine populated by the last run. | |
| const Compiler_Typed_Semantic_Analyzer & | typed_analysis () const noexcept |
| Returns the typed semantic analyzer state from the last run. | |
| const DynArray< Compiler_Module * > & | parsed_ast_modules () const noexcept |
| Returns the parsed per-file AST modules from the last run. | |
| const Compiler_Module * | merged_ast_module () const noexcept |
| Returns the merged AST module from the last run. | |
| const Compiler_HIR_Module * | hir_module () const noexcept |
| Returns the lowered HIR module from the last run, when available. | |
| const Compiler_IR_Module * | ir_module () const noexcept |
| Returns the lowered IR module from the last run, when available. | |
| 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 label. | |
| std::string | diagnostics_text () const |
| Renders diagnostics from the last run as plain text. | |
Private Member Functions | |
| void | append_error (const std::string &text) |
| void | append_warning (const std::string &text) |
| void | emit_driver_diagnostic (const Source_Span &span, const std::string &code, const std::string &message, const std::string ¬e="", const std::string &help="") |
| void | record_text_artifact (const std::string &label, std::string text) |
| size_t | find_source_index (std::string_view name) const noexcept |
| void | record_import_order_artifact () |
| void | record_ast_artifacts () |
| bool | resolve_import_order () |
| void | merge_modules_from_order () |
| void | record_diagnostics_artifact () |
| void | record_driver_messages_artifact () |
| bool | parse_registered_sources () |
| bool | run_typed_semantics () |
| bool | lower_hir () |
| bool | lower_ir () |
| bool | lower_bytecode () |
| bool | emit_c () |
| bool | execute_hir_runtime () |
| void | append_run_failure_if_needed () |
| bool | finalize (const Compiler_Driver_Action action) |
| bool | prepare_inputs (const DynArray< Compiler_Driver_Source > &inputs) |
Private Attributes | |
| Compiler_Driver_Options | config_ |
| Source_Manager | sources_ |
| Diagnostic_Engine | diagnostics_ |
| Compiler_Ast_Context | ast_ctx_ |
| Compiler_HIR_Context | hir_ctx_ |
| Compiler_IR_Context | ir_ctx_ |
| Compiler_Bytecode_Context | bytecode_ctx_ |
| Compiler_Typed_Semantic_Analyzer | typed_ |
| Interpreter_Runtime | runtime_ |
| size_t | arena_bytes_ = 0 |
| DynArray< std::string > | source_names_ |
| DynArray< Source_File_Id > | source_file_ids_ |
| DynArray< Compiler_Module * > | parsed_modules_ |
| DynArray< size_t > | merge_order_ |
| DynArray< Compiler_Driver_Artifact > | artifacts_ |
| DynArray< std::string > | errors_ |
| DynArray< std::string > | warnings_ |
| Compiler_Module * | merged_ast_ = nullptr |
| Compiler_HIR_Module * | hir_module_ = nullptr |
| Compiler_IR_Module * | ir_module_ = nullptr |
| 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 for compiler pipeline experiments.
A driver object owns all contexts required by the current pipeline stages so that pointers returned by getters remain valid until clear() or destruction. The object can be reused across multiple runs; host functions bound into the embedded Interpreter_Runtime prelude remain installed.
Definition at line 106 of file Compiler_Driver.H.
|
inlineexplicit |
Constructs a driver with one stable set of pipeline options.
| options | Shared parser/sema/runtime/backend configuration. |
| arena_size | Arena capacity used by AST/HIR/IR/bytecode contexts. |
Definition at line 432 of file Compiler_Driver.H.
|
delete |
Definition at line 135 of file Compiler_Driver.H.
References Aleph::DynArray< T >::append(), and errors_.
|
inlineprivate |
Definition at line 374 of file Compiler_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Interpreter_Runtime_Error::code, Aleph::Interpreter_Execution_Result::error, Aleph::message(), Aleph::Interpreter_Runtime_Error::message, Aleph::Interpreter_Execution_Result::ok(), and Aleph::Compiler_Driver_Run_Output::result.
Definition at line 140 of file Compiler_Driver.H.
References Aleph::DynArray< T >::append(), and warnings_.
|
inlinenoexcept |
Returns the arena size shared by the internal contexts.
Definition at line 450 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns all recorded artifacts from the last run.
Definition at line 727 of file Compiler_Driver.H.
|
inline |
Binds one host function into the persistent runtime prelude.
Definition at line 486 of file Compiler_Driver.H.
References Aleph::Interpreter_Runtime::bind_host_function(), and Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Returns the lowered bytecode module from the last run, when available.
Definition at line 697 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns the C emission payload from the last emit-c action.
Definition at line 703 of file Compiler_Driver.H.
|
inlinenoexcept |
Clears all stage outputs while preserving host prelude bindings.
Definition at line 456 of file Compiler_Driver.H.
References Aleph::Diagnostic_Engine::clear(), Aleph::Compiler_Typed_Semantic_Analyzer::clear(), Aleph::DynArray< T >::clear(), Aleph::Parse_Only, Aleph::Compiler_Bytecode_Context::reset(), Aleph::Compiler_Ast_Context::reset(), Aleph::Compiler_HIR_Context::reset(), Aleph::Compiler_IR_Context::reset(), Aleph::Interpreter_Runtime::reset(), and Aleph::Interpreter_Runtime::set_diagnostics().
|
inlinenoexcept |
Returns the diagnostic engine populated by the last run.
Definition at line 661 of file Compiler_Driver.H.
|
inline |
Renders diagnostics from the last run as plain text.
Definition at line 746 of file Compiler_Driver.H.
References out, and Aleph::Diagnostic_Engine::render_plain().
|
inlineprivate |
Definition at line 351 of file Compiler_Driver.H.
References Aleph::Compiler_Driver_Options::c_backend_options, Aleph::compiler_emit_c_module(), Aleph::Compiler_Driver_Detail::merge_report(), and Aleph::Compiler_C_Backend_Emission::source.
|
inlineprivate |
Definition at line 145 of file Compiler_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Diagnostic_Builder::code(), Aleph::code(), diagnostics_, Aleph::Diagnostic_Builder::emit(), Aleph::Diagnostic_Engine::error(), Aleph::Diagnostic_Builder::help(), Aleph::message(), and Aleph::Diagnostic_Builder::note().
Returns non-diagnostic driver-level hard errors.
Definition at line 715 of file Compiler_Driver.H.
|
inline |
Runs the pipeline over source files loaded from disk.
| paths | Ordered file paths to register in the Source_Manager. |
| action | Final stage requested by the caller. |
true when the requested action finished successfully. Definition at line 564 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Emit_Bytecode, Aleph::Emit_C, Aleph::HIR, Aleph::IR, Aleph::DynArray< T >::is_empty(), Aleph::Source_Manager::load_file(), Aleph::Parse_Only, Aleph::Run, Aleph::Sema_Only, and Aleph::DynArray< T >::size().
|
inlineprivate |
Definition at line 358 of file Compiler_Driver.H.
References Aleph::Interpreter_Runtime::evaluate_module(), Aleph::Compiler_Driver_Run_Output::executed, Aleph::Compiler_Driver_Run_Output::globals_text, Aleph::interpreter_dump_globals(), Aleph::interpreter_value_to_string(), Aleph::Interpreter_Execution_Result::ok(), Aleph::Compiler_Driver_Detail::render_run_result(), Aleph::Compiler_Driver_Run_Output::result, Aleph::Interpreter_Execution_Result::value, and Aleph::Compiler_Driver_Run_Output::value_text.
|
inline |
Convenience overload for a single in-memory source.
Definition at line 633 of file Compiler_Driver.H.
References Aleph::DynArray< T >::append(), and Aleph::blossom_maximum_cardinality_matching().
|
inline |
Runs the pipeline over in-memory sources.
| inputs | Ordered source units to parse and merge. |
| action | Final stage requested by the caller. |
true when the requested action finished without diagnostics or driver-level hard errors. Definition at line 500 of file Compiler_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Emit_Bytecode, Aleph::Emit_C, Aleph::HIR, Aleph::IR, Aleph::Parse_Only, Aleph::Run, and Aleph::Sema_Only.
|
inlineprivate |
Definition at line 395 of file Compiler_Driver.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Finds one artifact by label.
| label | Exact artifact label to look up. |
nullptr if absent. Definition at line 737 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), and Aleph::DynArray< T >::size().
Referenced by main().
|
inlineprivatenoexcept |
Definition at line 164 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::size(), and source_names_.
|
inlinenoexcept |
Returns the lowered HIR module from the last run, when available.
Definition at line 685 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns the lowered IR module from the last run, when available.
Definition at line 691 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns the last requested action.
Definition at line 649 of file Compiler_Driver.H.
|
inlineprivate |
|
inlineprivate |
Definition at line 310 of file Compiler_Driver.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_dump_hir_module(), and Aleph::Compiler_Typed_Semantic_Analyzer::type_context().
|
inlineprivate |
|
inlineprivate |
Definition at line 234 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_merge_spans(), Aleph::Compiler_Module::functions, Aleph::Compiler_Ast_Context::make(), Aleph::DynArray< T >::size(), Aleph::Compiler_Module::source_name, Aleph::Compiler_Ast_Node::span, Aleph::Compiler_Module::statements, and Aleph::Compiler_Module::type_declarations.
|
inlinenoexcept |
Returns the merged AST module from the last run.
Definition at line 679 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns whether the last driver action finished successfully.
Definition at line 643 of file Compiler_Driver.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::Diagnostic_Engine::has_errors(), and Aleph::DynArray< T >::is_empty().
|
delete |
|
inlinenoexcept |
Returns the immutable construction-time configuration.
Definition at line 444 of file Compiler_Driver.H.
|
inlineprivate |
Definition at line 279 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::DynArray< T >::clear(), Aleph::Diagnostic_Engine::has_errors(), Aleph::DynArray< T >::is_empty(), Aleph::Compiler_Driver_Options::parser_options, and Aleph::DynArray< T >::size().
|
inlinenoexcept |
Returns the parsed per-file AST modules from the last run.
Definition at line 673 of file Compiler_Driver.H.
|
inlineprivate |
Definition at line 403 of file Compiler_Driver.H.
References Aleph::Source_Manager::add_virtual_file(), Aleph::DynArray< T >::append(), and Aleph::blossom_maximum_cardinality_matching().
|
inlineprivate |
Definition at line 180 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::Compiler_Driver_Detail::artifact_label(), Aleph::compiler_dump_module(), and Aleph::DynArray< T >::size().
|
inlineprivate |
Definition at line 266 of file Compiler_Driver.H.
References out, and Aleph::Diagnostic_Engine::render_plain().
|
inlineprivate |
Definition at line 273 of file Compiler_Driver.H.
References Aleph::Compiler_Driver_Detail::render_messages().
|
inlineprivate |
Definition at line 172 of file Compiler_Driver.H.
References Aleph::DynArray< T >::append(), Aleph::DynArray< T >::size(), and source_names_.
|
inlineprivate |
Definition at line 159 of file Compiler_Driver.H.
References Aleph::Compiler_Driver_Detail::append_artifact(), and artifacts_.
|
inlineprivate |
Definition at line 190 of file Compiler_Driver.H.
References Aleph::DynArray< T >::access(), Aleph::and, Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::DynArray< T >::clear(), Aleph::compiler_resolve_module_order(), Aleph::Diagnostic_Engine::has_errors(), Aleph::Import, Aleph::Missing_Dependency, and Aleph::DynArray< T >::size().
|
inlinenoexcept |
Returns the run summary from the last run action.
Definition at line 709 of file Compiler_Driver.H.
|
inlineprivate |
|
inlinenoexcept |
Returns the shared source manager for the last run.
Definition at line 655 of file Compiler_Driver.H.
|
inlinenoexcept |
Returns the typed semantic analyzer state from the last run.
Definition at line 667 of file Compiler_Driver.H.
Returns non-fatal driver-level warnings.
Definition at line 721 of file Compiler_Driver.H.
|
private |
Definition at line 117 of file Compiler_Driver.H.
|
private |
Definition at line 123 of file Compiler_Driver.H.
Referenced by record_text_artifact().
|
private |
Definition at line 111 of file Compiler_Driver.H.
|
private |
Definition at line 114 of file Compiler_Driver.H.
|
private |
Definition at line 130 of file Compiler_Driver.H.
|
private |
Definition at line 131 of file Compiler_Driver.H.
|
private |
Definition at line 108 of file Compiler_Driver.H.
|
private |
Definition at line 110 of file Compiler_Driver.H.
Referenced by emit_driver_diagnostic().
|
private |
Definition at line 124 of file Compiler_Driver.H.
Referenced by append_error().
|
private |
Definition at line 112 of file Compiler_Driver.H.
|
private |
Definition at line 128 of file Compiler_Driver.H.
|
private |
Definition at line 113 of file Compiler_Driver.H.
|
private |
Definition at line 129 of file Compiler_Driver.H.
|
private |
Definition at line 133 of file Compiler_Driver.H.
|
private |
Definition at line 122 of file Compiler_Driver.H.
|
private |
Definition at line 127 of file Compiler_Driver.H.
|
private |
Definition at line 121 of file Compiler_Driver.H.
|
private |
Definition at line 132 of file Compiler_Driver.H.
|
private |
Definition at line 116 of file Compiler_Driver.H.
|
private |
Definition at line 120 of file Compiler_Driver.H.
|
private |
Definition at line 119 of file Compiler_Driver.H.
Referenced by find_source_index(), and record_import_order_artifact().
|
private |
Definition at line 109 of file Compiler_Driver.H.
|
private |
Definition at line 115 of file Compiler_Driver.H.
|
private |
Definition at line 125 of file Compiler_Driver.H.
Referenced by append_warning().