Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Compiler_MVP_Frontend Class Referencefinal

Compiler_Frontend implementation backed by the current MVP language stack. More...

#include <Compiler_MVP_Frontend.H>

Inheritance diagram for Aleph::Compiler_MVP_Frontend:
[legend]
Collaboration diagram for Aleph::Compiler_MVP_Frontend:
[legend]

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 &note="", 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
 

Detailed Description

Compiler_Frontend implementation backed by the current MVP language stack.

Definition at line 66 of file Compiler_MVP_Frontend.H.

Constructor & Destructor Documentation

◆ Compiler_MVP_Frontend()

Aleph::Compiler_MVP_Frontend::Compiler_MVP_Frontend ( const Compiler_MVP_Frontend_Options &  options = {},
const size_t  arena_size = 1 << 20 
)
inlineexplicit

Constructs the reference MVP frontend.

Parameters
optionsParser and typed semantic configuration.
arena_sizeArena capacity used by AST/HIR/IR contexts.

Definition at line 203 of file Compiler_MVP_Frontend.H.

Member Function Documentation

◆ analyze()

◆ append_error()

void Aleph::Compiler_MVP_Frontend::append_error ( const std::string &  text)
inlineprivate

Definition at line 91 of file Compiler_MVP_Frontend.H.

References Aleph::DynArray< T >::append(), and errors_.

Referenced by load_sources(), and lower_ir().

◆ arena_size()

size_t Aleph::Compiler_MVP_Frontend::arena_size ( ) const
inlinenoexcept

Returns the configured shared arena size.

Definition at line 217 of file Compiler_MVP_Frontend.H.

References arena_bytes.

◆ artifacts()

const DynArray< Compiler_Driver_Artifact > & Aleph::Compiler_MVP_Frontend::artifacts ( ) const
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_.

◆ clear()

◆ diagnostic_engine() [1/2]

const Diagnostic_Engine * Aleph::Compiler_MVP_Frontend::diagnostic_engine ( ) const
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.

◆ diagnostic_engine() [2/2]

Diagnostic_Engine * Aleph::Compiler_MVP_Frontend::diagnostic_engine ( )
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.

◆ diagnostics_text()

std::string Aleph::Compiler_MVP_Frontend::diagnostics_text ( ) const
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().

◆ emit_driver_diagnostic()

void Aleph::Compiler_MVP_Frontend::emit_driver_diagnostic ( const Source_Span &  span,
const std::string &  code,
const std::string &  message,
const std::string &  note = "",
const std::string &  help = "" 
)
inlineprivate

◆ errors()

const DynArray< std::string > & Aleph::Compiler_MVP_Frontend::errors ( ) const
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_.

◆ find_artifact()

const Compiler_Driver_Artifact * Aleph::Compiler_MVP_Frontend::find_artifact ( std::string_view  label) const
inlineoverridevirtualnoexcept

Finds one frontend artifact by exact label.

Implements Aleph::Compiler_Frontend.

Definition at line 436 of file Compiler_MVP_Frontend.H.

References artifacts_.

◆ find_source_index()

size_t Aleph::Compiler_MVP_Frontend::find_source_index ( std::string_view  name) const
inlineprivatenoexcept

◆ hir_module()

const Compiler_HIR_Module * Aleph::Compiler_MVP_Frontend::hir_module ( ) const
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_.

◆ ir_module()

const Compiler_IR_Module * Aleph::Compiler_MVP_Frontend::ir_module ( ) const
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_.

◆ load_sources()

bool Aleph::Compiler_MVP_Frontend::load_sources ( const DynArray< Compiler_Driver_Source > &  inputs)
inlineoverridevirtual

Registers the ordered input sources for the next run.

Parameters
inputsInput sources to register in frontend-specific storage.
Returns
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.

◆ lower_hir()

bool Aleph::Compiler_MVP_Frontend::lower_hir ( )
inlineoverridevirtual

◆ lower_ir()

bool Aleph::Compiler_MVP_Frontend::lower_ir ( )
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_.

◆ merge_modules_from_order()

◆ merged_ast_module()

const Compiler_Module * Aleph::Compiler_MVP_Frontend::merged_ast_module ( ) const
inlinenoexcept

Definition at line 396 of file Compiler_MVP_Frontend.H.

References merged_ast_.

◆ module_descriptors()

const DynArray< Compiler_Module_Descriptor > & Aleph::Compiler_MVP_Frontend::module_descriptors ( ) const
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_.

◆ module_merge_order()

const DynArray< size_t > & Aleph::Compiler_MVP_Frontend::module_merge_order ( ) const
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_.

◆ module_metadata()

const DynArray< Compiler_Module_Metadata > & Aleph::Compiler_MVP_Frontend::module_metadata ( ) const
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_.

◆ name()

const char * Aleph::Compiler_MVP_Frontend::name ( ) const
inlineoverridevirtualnoexcept

Returns the stable frontend name.

Implements Aleph::Compiler_Frontend.

Definition at line 211 of file Compiler_MVP_Frontend.H.

Referenced by find_source_index().

◆ options()

const Compiler_MVP_Frontend_Options & Aleph::Compiler_MVP_Frontend::options ( ) const
inlinenoexcept

Returns the immutable frontend configuration.

Definition at line 223 of file Compiler_MVP_Frontend.H.

References config.

◆ parse()

◆ parsed_ast_modules()

const DynArray< Compiler_Module * > & Aleph::Compiler_MVP_Frontend::parsed_ast_modules ( ) const
inlinenoexcept

Definition at line 401 of file Compiler_MVP_Frontend.H.

References parsed_modules.

◆ record_ast_artifacts()

◆ record_import_order_artifact()

void Aleph::Compiler_MVP_Frontend::record_import_order_artifact ( )
inlineprivate

◆ record_text_artifact()

void Aleph::Compiler_MVP_Frontend::record_text_artifact ( const std::string &  label,
std::string  text 
)
inlineprivate

◆ resolve_import_order()

◆ type_context()

const Compiler_Type_Context * Aleph::Compiler_MVP_Frontend::type_context ( ) const
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.

◆ warnings()

const DynArray< std::string > & Aleph::Compiler_MVP_Frontend::warnings ( ) const
inlineoverridevirtualnoexcept

Returns non-fatal frontend-level warnings.

Implements Aleph::Compiler_Frontend.

Definition at line 449 of file Compiler_MVP_Frontend.H.

References warnings_.

Member Data Documentation

◆ arena_bytes

size_t Aleph::Compiler_MVP_Frontend::arena_bytes = 0
private

Definition at line 75 of file Compiler_MVP_Frontend.H.

Referenced by arena_size().

◆ artifacts_

DynArray<Compiler_Driver_Artifact> Aleph::Compiler_MVP_Frontend::artifacts_
private

Definition at line 83 of file Compiler_MVP_Frontend.H.

Referenced by artifacts(), clear(), find_artifact(), and record_text_artifact().

◆ ast_ctx

Compiler_Ast_Context Aleph::Compiler_MVP_Frontend::ast_ctx
private

Definition at line 71 of file Compiler_MVP_Frontend.H.

Referenced by clear(), merge_modules_from_order(), and parse().

◆ config

Compiler_MVP_Frontend_Options Aleph::Compiler_MVP_Frontend::config
private

Definition at line 68 of file Compiler_MVP_Frontend.H.

Referenced by options(), and parse().

◆ diagnostics

Diagnostic_Engine Aleph::Compiler_MVP_Frontend::diagnostics
private

◆ errors_

DynArray<std::string> Aleph::Compiler_MVP_Frontend::errors_
private

Definition at line 84 of file Compiler_MVP_Frontend.H.

Referenced by append_error(), clear(), errors(), and lower_ir().

◆ hir_ctx

Compiler_HIR_Context Aleph::Compiler_MVP_Frontend::hir_ctx
private

Definition at line 72 of file Compiler_MVP_Frontend.H.

Referenced by clear(), and lower_hir().

◆ hir_module_

Compiler_HIR_Module* Aleph::Compiler_MVP_Frontend::hir_module_ = nullptr
private

Definition at line 88 of file Compiler_MVP_Frontend.H.

Referenced by clear(), hir_module(), lower_hir(), and lower_ir().

◆ ir_ctx

Compiler_IR_Context Aleph::Compiler_MVP_Frontend::ir_ctx
private

Definition at line 73 of file Compiler_MVP_Frontend.H.

Referenced by clear(), and lower_ir().

◆ ir_module_

Compiler_IR_Module* Aleph::Compiler_MVP_Frontend::ir_module_ = nullptr
private

Definition at line 89 of file Compiler_MVP_Frontend.H.

Referenced by clear(), ir_module(), and lower_ir().

◆ merge_order_

DynArray<size_t> Aleph::Compiler_MVP_Frontend::merge_order_
private

◆ merged_ast_

Compiler_Module* Aleph::Compiler_MVP_Frontend::merged_ast_ = nullptr
private

◆ module_descriptors_

DynArray<Compiler_Module_Descriptor> Aleph::Compiler_MVP_Frontend::module_descriptors_
private

◆ module_metadata_

DynArray<Compiler_Module_Metadata> Aleph::Compiler_MVP_Frontend::module_metadata_
private

Definition at line 80 of file Compiler_MVP_Frontend.H.

Referenced by clear(), module_metadata(), and parse().

◆ parsed_modules

DynArray<Compiler_Module *> Aleph::Compiler_MVP_Frontend::parsed_modules
private

Definition at line 81 of file Compiler_MVP_Frontend.H.

Referenced by clear(), parse(), parsed_ast_modules(), and record_ast_artifacts().

◆ source_file_ids

DynArray<Source_File_Id> Aleph::Compiler_MVP_Frontend::source_file_ids
private

Definition at line 78 of file Compiler_MVP_Frontend.H.

Referenced by clear(), load_sources(), and parse().

◆ source_names

DynArray<std::string> Aleph::Compiler_MVP_Frontend::source_names
private

◆ sources

Source_Manager Aleph::Compiler_MVP_Frontend::sources
private

Definition at line 69 of file Compiler_MVP_Frontend.H.

Referenced by clear(), load_sources(), and parse().

◆ typed

Compiler_Typed_Semantic_Analyzer Aleph::Compiler_MVP_Frontend::typed
private

Definition at line 74 of file Compiler_MVP_Frontend.H.

Referenced by analyze(), clear(), lower_hir(), lower_ir(), and type_context().

◆ warnings_

DynArray<std::string> Aleph::Compiler_MVP_Frontend::warnings_
private

Definition at line 85 of file Compiler_MVP_Frontend.H.

Referenced by clear(), lower_ir(), and warnings().


The documentation for this class was generated from the following file: