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

Reusable orchestration object built on top of Compiler_Frontend. More...

#include <Compiler_Generic_Driver.H>

Collaboration diagram for Aleph::Compiler_Generic_Driver:
[legend]

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
 

Detailed Description

Reusable orchestration object built on top of Compiler_Frontend.

Definition at line 71 of file Compiler_Generic_Driver.H.

Constructor & Destructor Documentation

◆ Compiler_Generic_Driver() [1/2]

Aleph::Compiler_Generic_Driver::Compiler_Generic_Driver ( Compiler_Frontend &  frontend_impl,
const Compiler_Generic_Driver_Options &  options = {},
const size_t  arena_size = 1 << 20 
)
inlineexplicit

Builds one generic driver over a concrete frontend implementation.

Parameters
frontend_implFrontend used for parse/sema/HIR/IR stages.
optionsRuntime and backend configuration.
arena_sizeArena size used by bytecode lowering.

Definition at line 316 of file Compiler_Generic_Driver.H.

◆ Compiler_Generic_Driver() [2/2]

Aleph::Compiler_Generic_Driver::Compiler_Generic_Driver ( const Compiler_Generic_Driver &  )
delete

Member Function Documentation

◆ append_error()

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

◆ append_run_failure_if_needed()

◆ arena_size()

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

Returns the configured bytecode arena size.

Definition at line 333 of file Compiler_Generic_Driver.H.

References arena_bytes_.

◆ artifacts()

const DynArray< Compiler_Driver_Artifact > & Aleph::Compiler_Generic_Driver::artifacts ( ) const
inlinenoexcept

Returns all recorded artifacts from the last run.

Definition at line 501 of file Compiler_Generic_Driver.H.

References artifacts_.

◆ bind_host_function()

bool Aleph::Compiler_Generic_Driver::bind_host_function ( const std::string &  name,
const Interpreter_Host_Function  callback,
void *  user_data = nullptr 
)
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_.

◆ bytecode_module()

const Compiler_Bytecode_Module * Aleph::Compiler_Generic_Driver::bytecode_module ( ) const
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_.

◆ c_emission()

const Compiler_C_Backend_Emission & Aleph::Compiler_Generic_Driver::c_emission ( ) const
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_.

◆ clear()

◆ collect_frontend_state()

◆ diagnostics_text()

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

◆ emit_c()

◆ errors()

const DynArray< std::string > & Aleph::Compiler_Generic_Driver::errors ( ) const
inlinenoexcept

Returns non-diagnostic driver-level hard errors.

Definition at line 489 of file Compiler_Generic_Driver.H.

References errors_.

◆ execute_files()

bool Aleph::Compiler_Generic_Driver::execute_files ( const DynArray< std::string > &  paths,
const Compiler_Driver_Action  action = Compiler_Driver_Action::Run 
)
inline

◆ execute_hir_runtime()

◆ execute_source()

bool Aleph::Compiler_Generic_Driver::execute_source ( const std::string &  name,
const std::string &  text,
const Compiler_Driver_Action  action = Compiler_Driver_Action::Run 
)
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().

◆ execute_sources()

◆ finalize()

◆ find_artifact()

const Compiler_Driver_Artifact * Aleph::Compiler_Generic_Driver::find_artifact ( std::string_view  label) const
inlinenoexcept

Finds one artifact by exact label.

Definition at line 507 of file Compiler_Generic_Driver.H.

References artifacts_.

◆ frontend_impl()

const Compiler_Frontend & Aleph::Compiler_Generic_Driver::frontend_impl ( ) const
inlinenoexcept

Returns the frontend used by this driver.

Definition at line 459 of file Compiler_Generic_Driver.H.

References frontend_.

◆ last_action()

Compiler_Driver_Action Aleph::Compiler_Generic_Driver::last_action ( ) const
inlinenoexcept

Returns the last requested action.

Definition at line 465 of file Compiler_Generic_Driver.H.

References last_action_.

◆ lower_bytecode()

◆ ok()

bool Aleph::Compiler_Generic_Driver::ok ( ) const
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().

◆ operator=()

Compiler_Generic_Driver & Aleph::Compiler_Generic_Driver::operator= ( const Compiler_Generic_Driver &  )
delete

◆ options()

const Compiler_Generic_Driver_Options & Aleph::Compiler_Generic_Driver::options ( ) const
inlinenoexcept

Returns the immutable driver configuration.

Definition at line 327 of file Compiler_Generic_Driver.H.

References config_.

◆ read_file_text()

static bool Aleph::Compiler_Generic_Driver::read_file_text ( const std::string &  path,
std::string &  out_text 
)
inlinestaticprivate

Definition at line 297 of file Compiler_Generic_Driver.H.

References Aleph::blossom_maximum_cardinality_matching(), and out.

Referenced by execute_files().

◆ record_diagnostics_artifact()

void Aleph::Compiler_Generic_Driver::record_diagnostics_artifact ( )
inlineprivate

◆ record_driver_messages_artifact()

void Aleph::Compiler_Generic_Driver::record_driver_messages_artifact ( )
inlineprivate

◆ record_import_order_artifact()

◆ record_module_bindings_artifact()

◆ record_module_linkage_artifact()

◆ record_module_metadata_artifact()

◆ record_module_name_table_artifact()

◆ record_module_semantic_environment_artifact()

◆ record_text_artifact()

◆ run_output()

const Compiler_Driver_Run_Output & Aleph::Compiler_Generic_Driver::run_output ( ) const
inlinenoexcept

Returns the run summary from the last run action.

Definition at line 483 of file Compiler_Generic_Driver.H.

References run_output_.

◆ warnings()

const DynArray< std::string > & Aleph::Compiler_Generic_Driver::warnings ( ) const
inlinenoexcept

Returns non-fatal driver-level warnings.

Definition at line 495 of file Compiler_Generic_Driver.H.

References warnings_.

Member Data Documentation

◆ arena_bytes_

size_t Aleph::Compiler_Generic_Driver::arena_bytes_ = 0
private

Definition at line 77 of file Compiler_Generic_Driver.H.

Referenced by arena_size().

◆ artifacts_

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

◆ bytecode_ctx_

Compiler_Bytecode_Context Aleph::Compiler_Generic_Driver::bytecode_ctx_
private

Definition at line 75 of file Compiler_Generic_Driver.H.

Referenced by clear(), and lower_bytecode().

◆ bytecode_module_

Compiler_Bytecode_Module* Aleph::Compiler_Generic_Driver::bytecode_module_ = nullptr
private

Definition at line 83 of file Compiler_Generic_Driver.H.

Referenced by bytecode_module(), clear(), and lower_bytecode().

◆ c_emission_

Compiler_C_Backend_Emission Aleph::Compiler_Generic_Driver::c_emission_
private

Definition at line 84 of file Compiler_Generic_Driver.H.

Referenced by c_emission(), clear(), and emit_c().

◆ config_

Compiler_Generic_Driver_Options Aleph::Compiler_Generic_Driver::config_
private

Definition at line 74 of file Compiler_Generic_Driver.H.

Referenced by emit_c(), and options().

◆ errors_

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

◆ frontend_

◆ last_action_

Compiler_Driver_Action Aleph::Compiler_Generic_Driver::last_action_ = Compiler_Driver_Action::Parse_Only
private

Definition at line 86 of file Compiler_Generic_Driver.H.

Referenced by clear(), finalize(), and last_action().

◆ run_output_

Compiler_Driver_Run_Output Aleph::Compiler_Generic_Driver::run_output_
private

◆ runtime_

Interpreter_Runtime Aleph::Compiler_Generic_Driver::runtime_
private

Definition at line 76 of file Compiler_Generic_Driver.H.

Referenced by bind_host_function(), clear(), and execute_hir_runtime().

◆ warnings_

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

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