|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Compiler_Frontend implementation backed by the current MVP language stack.
More...
#include <Compiler_MVP_Frontend.H>
Public Member Functions | |
| Compiler_MVP_Frontend (const Compiler_MVP_Frontend_Options &options={}, const size_t arena_size=1<< 20) | |
| Constructs the reference MVP frontend. | |
| const char * | name () const noexcept override |
| Returns the stable frontend name. | |
| size_t | arena_size () const noexcept |
| Returns the configured shared arena size. | |
| const Compiler_MVP_Frontend_Options & | options () const noexcept |
| Returns the immutable frontend configuration. | |
| void | clear () noexcept override |
| Clears all frontend-owned state from the previous run. | |
| bool | load_sources (const DynArray< Compiler_Driver_Source > &inputs) override |
| Registers the ordered input sources for the next run. | |
| bool | parse () override |
| Parses all previously loaded sources. | |
| bool | analyze () override |
| Runs semantic analysis on the parsed program. | |
| bool | lower_hir () override |
| Lowers the analyzed program into common HIR. | |
| bool | lower_ir () override |
| Lowers the analyzed program into common IR. | |
| Diagnostic_Engine * | diagnostic_engine () noexcept override |
| Returns the diagnostic engine populated by the frontend. | |
| const Diagnostic_Engine * | diagnostic_engine () const noexcept override |
| Returns the diagnostic engine populated by the frontend. | |
| const Compiler_Type_Context * | type_context () const noexcept override |
| Returns the optional shared type context for dumps and backends. | |
| const Compiler_Module * | merged_ast_module () const noexcept |
| const DynArray< Compiler_Module * > & | parsed_ast_modules () const noexcept |
| const Compiler_HIR_Module * | hir_module () const noexcept override |
| Returns the lowered HIR module from the last run, when available. | |
| const Compiler_IR_Module * | ir_module () const noexcept override |
| Returns the lowered IR module from the last run, when available. | |
| const DynArray< Compiler_Module_Descriptor > & | module_descriptors () const noexcept override |
| Returns parsed module descriptors for reusable import orchestration. | |
| const DynArray< size_t > & | module_merge_order () const noexcept override |
| Returns the dependency-first merge order from the last parse. | |
| const DynArray< Compiler_Module_Metadata > & | module_metadata () const noexcept override |
| Returns reusable metadata for the top-level surface of each module. | |
| const DynArray< Compiler_Driver_Artifact > & | artifacts () const noexcept override |
| Returns all frontend-produced artifacts from the last run. | |
| const Compiler_Driver_Artifact * | find_artifact (std::string_view label) const noexcept override |
| Finds one frontend artifact by exact label. | |
| const DynArray< std::string > & | errors () const noexcept override |
| Returns hard frontend-level errors outside the diagnostic engine. | |
| const DynArray< std::string > & | warnings () const noexcept override |
| Returns non-fatal frontend-level warnings. | |
| std::string | diagnostics_text () const |
| Renders accumulated diagnostics as plain text. | |
Public Member Functions inherited from Aleph::Compiler_Frontend | |
| virtual | ~Compiler_Frontend ()=default |
Private Member Functions | |
| void | append_error (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 () |
Private Attributes | |
| Compiler_MVP_Frontend_Options | config |
| Source_Manager | sources |
| Diagnostic_Engine | diagnostics |
| Compiler_Ast_Context | ast_ctx |
| Compiler_HIR_Context | hir_ctx |
| Compiler_IR_Context | ir_ctx |
| Compiler_Typed_Semantic_Analyzer | typed |
| size_t | arena_bytes = 0 |
| DynArray< std::string > | source_names |
| DynArray< Source_File_Id > | source_file_ids |
| DynArray< Compiler_Module_Descriptor > | module_descriptors_ |
| DynArray< Compiler_Module_Metadata > | module_metadata_ |
| 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_Frontend implementation backed by the current MVP language stack.
Definition at line 66 of file Compiler_MVP_Frontend.H.
|
inlineexplicit |
Constructs the reference MVP frontend.
| options | Parser and typed semantic configuration. |
| arena_size | Arena capacity used by AST/HIR/IR contexts. |
Definition at line 203 of file Compiler_MVP_Frontend.H.
|
inlineoverridevirtual |
Runs semantic analysis on the parsed program.
Implements Aleph::Compiler_Frontend.
Definition at line 350 of file Compiler_MVP_Frontend.H.
References Aleph::Compiler_Typed_Semantic_Analyzer::analyze_module(), Aleph::blossom_maximum_cardinality_matching(), diagnostics, Aleph::Compiler_Typed_Semantic_Analyzer::dump_inference(), Aleph::Diagnostic_Engine::has_errors(), merged_ast_, record_text_artifact(), and typed.
Definition at line 91 of file Compiler_MVP_Frontend.H.
References Aleph::DynArray< T >::append(), and errors_.
Referenced by load_sources(), and lower_ir().
|
inlinenoexcept |
Returns the configured shared arena size.
Definition at line 217 of file Compiler_MVP_Frontend.H.
References arena_bytes.
|
inlineoverridevirtualnoexcept |
Returns all frontend-produced artifacts from the last run.
Implements Aleph::Compiler_Frontend.
Definition at line 431 of file Compiler_MVP_Frontend.H.
References artifacts_.
|
inlineoverridevirtualnoexcept |
Clears all frontend-owned state from the previous run.
Implements Aleph::Compiler_Frontend.
Definition at line 228 of file Compiler_MVP_Frontend.H.
References artifacts_, ast_ctx, Aleph::Diagnostic_Engine::clear(), Aleph::Compiler_Typed_Semantic_Analyzer::clear(), Aleph::DynArray< T >::clear(), diagnostics, errors_, hir_ctx, hir_module_, ir_ctx, ir_module_, merge_order_, merged_ast_, module_descriptors_, module_metadata_, parsed_modules, Aleph::Compiler_Ast_Context::reset(), Aleph::Compiler_HIR_Context::reset(), Aleph::Compiler_IR_Context::reset(), source_file_ids, source_names, sources, typed, and warnings_.
|
inlineoverridevirtualnoexcept |
Returns the diagnostic engine populated by the frontend.
Implements Aleph::Compiler_Frontend.
Definition at line 386 of file Compiler_MVP_Frontend.H.
References diagnostics.
|
inlineoverridevirtualnoexcept |
Returns the diagnostic engine populated by the frontend.
Implements Aleph::Compiler_Frontend.
Definition at line 381 of file Compiler_MVP_Frontend.H.
References diagnostics.
|
inline |
Renders accumulated diagnostics as plain text.
Definition at line 455 of file Compiler_MVP_Frontend.H.
References diagnostics, out, and Aleph::Diagnostic_Engine::render_plain().
|
inlineprivate |
Definition at line 96 of file Compiler_MVP_Frontend.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().
Referenced by resolve_import_order().
|
inlineoverridevirtualnoexcept |
Returns hard frontend-level errors outside the diagnostic engine.
Implements Aleph::Compiler_Frontend.
Definition at line 444 of file Compiler_MVP_Frontend.H.
References errors_.
|
inlineoverridevirtualnoexcept |
Finds one frontend artifact by exact label.
Implements Aleph::Compiler_Frontend.
Definition at line 436 of file Compiler_MVP_Frontend.H.
References artifacts_.
|
inlineprivatenoexcept |
Definition at line 115 of file Compiler_MVP_Frontend.H.
References Aleph::DynArray< T >::access(), name(), Aleph::DynArray< T >::size(), and source_names.
Referenced by load_sources().
|
inlineoverridevirtualnoexcept |
Returns the lowered HIR module from the last run, when available.
Implements Aleph::Compiler_Frontend.
Definition at line 406 of file Compiler_MVP_Frontend.H.
References hir_module_.
|
inlineoverridevirtualnoexcept |
Returns the lowered IR module from the last run, when available.
Implements Aleph::Compiler_Frontend.
Definition at line 411 of file Compiler_MVP_Frontend.H.
References ir_module_.
|
inlineoverridevirtual |
Registers the ordered input sources for the next run.
| inputs | Input sources to register in frontend-specific storage. |
true if the inputs are acceptable. Implements Aleph::Compiler_Frontend.
Definition at line 252 of file Compiler_MVP_Frontend.H.
References Aleph::Source_Manager::add_virtual_file(), Aleph::DynArray< T >::append(), append_error(), Aleph::blossom_maximum_cardinality_matching(), find_source_index(), source_file_ids, source_names, and sources.
|
inlineoverridevirtual |
Lowers the analyzed program into common HIR.
Implements Aleph::Compiler_Frontend.
Definition at line 357 of file Compiler_MVP_Frontend.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_dump_hir_module(), hir_ctx, hir_module_, merged_ast_, record_text_artifact(), Aleph::Compiler_Typed_Semantic_Analyzer::type_context(), and typed.
|
inlineoverridevirtual |
Lowers the analyzed program into common IR.
Implementations may lower from HIR or directly from language-specific semantic state, as long as the resulting Compiler_IR_Module follows the public IR contracts.
Implements Aleph::Compiler_Frontend.
Definition at line 365 of file Compiler_MVP_Frontend.H.
References append_error(), Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_dump_ir_module(), errors_, hir_module_, ir_ctx, ir_module_, Aleph::Compiler_Driver_Detail::merge_report(), record_text_artifact(), Aleph::Compiler_Typed_Semantic_Analyzer::type_context(), typed, Aleph::validate_ir_module(), and warnings_.
|
inlineprivate |
Definition at line 165 of file Compiler_MVP_Frontend.H.
References Aleph::DynArray< T >::access(), Aleph::and, ast_ctx, Aleph::blossom_maximum_cardinality_matching(), Aleph::compiler_merge_spans(), Aleph::Compiler_Module::functions, Aleph::Compiler_Ast_Context::make(), merge_order_, merged_ast_, Aleph::DynArray< T >::size(), Aleph::Compiler_Module::source_name, Aleph::Compiler_Ast_Node::span, Aleph::Compiler_Module::statements, and Aleph::Compiler_Module::type_declarations.
Referenced by parse().
|
inlinenoexcept |
Definition at line 396 of file Compiler_MVP_Frontend.H.
References merged_ast_.
|
inlineoverridevirtualnoexcept |
Returns parsed module descriptors for reusable import orchestration.
Frontends that do not model imports may return an empty array.
Reimplemented from Aleph::Compiler_Frontend.
Definition at line 416 of file Compiler_MVP_Frontend.H.
References module_descriptors_.
|
inlineoverridevirtualnoexcept |
Returns the dependency-first merge order from the last parse.
Frontends that do not reorder modules may return an empty array.
Reimplemented from Aleph::Compiler_Frontend.
Definition at line 421 of file Compiler_MVP_Frontend.H.
References merge_order_.
|
inlineoverridevirtualnoexcept |
Returns reusable metadata for the top-level surface of each module.
Until the platform grows explicit export syntax, frontends typically map this to all top-level declarations that the module contributes.
Reimplemented from Aleph::Compiler_Frontend.
Definition at line 426 of file Compiler_MVP_Frontend.H.
References module_metadata_.
Returns the stable frontend name.
Implements Aleph::Compiler_Frontend.
Definition at line 211 of file Compiler_MVP_Frontend.H.
Referenced by find_source_index().
|
inlinenoexcept |
Returns the immutable frontend configuration.
Definition at line 223 of file Compiler_MVP_Frontend.H.
References config.
|
inlineoverridevirtual |
Parses all previously loaded sources.
Implements Aleph::Compiler_Frontend.
Definition at line 275 of file Compiler_MVP_Frontend.H.
References Aleph::DynArray< T >::access(), Aleph::DynArray< T >::append(), ast_ctx, Aleph::blossom_maximum_cardinality_matching(), config, diagnostics, Aleph::Function, Aleph::Global, Aleph::Diagnostic_Engine::has_errors(), Aleph::Import, Aleph::DynArray< T >::is_empty(), Aleph::Let, merge_modules_from_order(), merge_order_, module_descriptors_, module_metadata_, Aleph::Compiler_Module_Metadata::name, Aleph::Compiler_Module_Descriptor::name, parsed_modules, Aleph::Compiler_MVP_Frontend_Options::parser_options, record_ast_artifacts(), resolve_import_order(), Aleph::DynArray< T >::size(), source_file_ids, source_names, sources, and Aleph::Type.
|
inlinenoexcept |
Definition at line 401 of file Compiler_MVP_Frontend.H.
References parsed_modules.
|
inlineprivate |
Definition at line 129 of file Compiler_MVP_Frontend.H.
References Aleph::DynArray< T >::access(), Aleph::Compiler_Driver_Detail::artifact_label(), Aleph::compiler_dump_module(), merged_ast_, parsed_modules, record_import_order_artifact(), record_text_artifact(), and source_names.
Referenced by parse().
|
inlineprivate |
Definition at line 123 of file Compiler_MVP_Frontend.H.
References Aleph::compiler_render_module_order(), merge_order_, module_descriptors_, and record_text_artifact().
Referenced by record_ast_artifacts().
|
inlineprivate |
Definition at line 110 of file Compiler_MVP_Frontend.H.
References Aleph::Compiler_Driver_Detail::append_artifact(), and artifacts_.
Referenced by analyze(), lower_hir(), lower_ir(), record_ast_artifacts(), and record_import_order_artifact().
|
inlineprivate |
Definition at line 139 of file Compiler_MVP_Frontend.H.
References Aleph::and, Aleph::DynArray< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::DynArray< T >::clear(), Aleph::compiler_resolve_module_order(), diagnostics, emit_driver_diagnostic(), Aleph::Diagnostic_Engine::has_errors(), merge_order_, Aleph::Missing_Dependency, and module_descriptors_.
Referenced by parse().
|
inlineoverridevirtualnoexcept |
Returns the optional shared type context for dumps and backends.
Frontends that do not use Compiler_Types.H may return nullptr.
Implements Aleph::Compiler_Frontend.
Definition at line 391 of file Compiler_MVP_Frontend.H.
References Aleph::Compiler_Typed_Semantic_Analyzer::type_context(), and typed.
|
inlineoverridevirtualnoexcept |
Returns non-fatal frontend-level warnings.
Implements Aleph::Compiler_Frontend.
Definition at line 449 of file Compiler_MVP_Frontend.H.
References warnings_.
|
private |
Definition at line 75 of file Compiler_MVP_Frontend.H.
Referenced by arena_size().
|
private |
Definition at line 83 of file Compiler_MVP_Frontend.H.
Referenced by artifacts(), clear(), find_artifact(), and record_text_artifact().
|
private |
Definition at line 71 of file Compiler_MVP_Frontend.H.
Referenced by clear(), merge_modules_from_order(), and parse().
|
private |
Definition at line 68 of file Compiler_MVP_Frontend.H.
|
private |
Definition at line 70 of file Compiler_MVP_Frontend.H.
Referenced by analyze(), clear(), diagnostic_engine(), diagnostic_engine(), diagnostics_text(), emit_driver_diagnostic(), parse(), and resolve_import_order().
|
private |
Definition at line 84 of file Compiler_MVP_Frontend.H.
Referenced by append_error(), clear(), errors(), and lower_ir().
|
private |
Definition at line 72 of file Compiler_MVP_Frontend.H.
Referenced by clear(), and lower_hir().
|
private |
Definition at line 88 of file Compiler_MVP_Frontend.H.
Referenced by clear(), hir_module(), lower_hir(), and lower_ir().
|
private |
Definition at line 73 of file Compiler_MVP_Frontend.H.
Referenced by clear(), and lower_ir().
|
private |
Definition at line 89 of file Compiler_MVP_Frontend.H.
Referenced by clear(), ir_module(), and lower_ir().
|
private |
Definition at line 82 of file Compiler_MVP_Frontend.H.
Referenced by clear(), merge_modules_from_order(), module_merge_order(), parse(), record_import_order_artifact(), and resolve_import_order().
|
private |
Definition at line 87 of file Compiler_MVP_Frontend.H.
Referenced by analyze(), clear(), lower_hir(), merge_modules_from_order(), merged_ast_module(), and record_ast_artifacts().
|
private |
Definition at line 79 of file Compiler_MVP_Frontend.H.
Referenced by clear(), module_descriptors(), parse(), record_import_order_artifact(), and resolve_import_order().
|
private |
Definition at line 80 of file Compiler_MVP_Frontend.H.
Referenced by clear(), module_metadata(), and parse().
|
private |
Definition at line 81 of file Compiler_MVP_Frontend.H.
Referenced by clear(), parse(), parsed_ast_modules(), and record_ast_artifacts().
|
private |
Definition at line 78 of file Compiler_MVP_Frontend.H.
Referenced by clear(), load_sources(), and parse().
|
private |
Definition at line 77 of file Compiler_MVP_Frontend.H.
Referenced by clear(), find_source_index(), load_sources(), parse(), and record_ast_artifacts().
|
private |
Definition at line 69 of file Compiler_MVP_Frontend.H.
Referenced by clear(), load_sources(), and parse().
|
private |
Definition at line 74 of file Compiler_MVP_Frontend.H.
Referenced by analyze(), clear(), lower_hir(), lower_ir(), and type_context().
|
private |
Definition at line 85 of file Compiler_MVP_Frontend.H.
Referenced by clear(), lower_ir(), and warnings().