Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Compiler_C_Backend::Emitter Class Reference
Collaboration diagram for Aleph::Compiler_C_Backend::Emitter:
[legend]

Public Member Functions

 Emitter (const Compiler_C_Backend_Options &options_in, const Compiler_IR_Module &module_in, const Compiler_Type_Context *types_in)
 Builds an emitter over one module and one option set.
 
Compiler_C_Backend_Emission run ()
 Emits the full C translation unit.
 

Private Member Functions

void fail (const std::string &message)
 
void warn (const std::string &message)
 
std::string type_comment (const Compiler_Type_Id type_id) const
 
void initialize_symbols ()
 
void validate_input ()
 
std::string function_symbol (const size_t index) const
 
std::string function_descriptor_symbol (const size_t index) const
 
bool emit_constant_expression (const Compiler_IR_Instruction &inst, std::string &expression, std::string &error) const
 
void emit_runtime_prelude (std::ostream &out) const
 
void emit_module_layout (std::ostream &out) const
 
void emit_prototypes (std::ostream &out) const
 
void emit_function_signature (std::ostream &out, const std::string &symbol) const
 
void emit_slot_declarations (std::ostream &out, const Compiler_IR_Function &function) const
 
void emit_value_declarations (std::ostream &out, const Compiler_IR_Function &function) const
 
void emit_parameter_bindings (std::ostream &out, const Compiler_IR_Function &function) const
 
void emit_instruction_comment (std::ostream &out, const Compiler_IR_Instruction &inst) const
 
void emit_instruction (std::ostream &out, const Compiler_IR_Instruction &inst, const Compiler_IR_Function &function)
 
void emit_terminator (std::ostream &out, const Compiler_IR_Block &block, const Compiler_IR_Function &function)
 
void emit_function_body (std::ostream &out, const Compiler_IR_Function &function, const std::string &symbol)
 
void emit_function (const size_t index, std::ostream &out)
 
void emit_top_level (std::ostream &out)
 
void emit_function_descriptors (std::ostream &out) const
 
void emit_main (std::ostream &out)
 

Private Attributes

const Compiler_C_Backend_Options * options_ = nullptr
 
const Compiler_IR_Module * module_ = nullptr
 
const Compiler_Type_Context * types_ = nullptr
 
Compiler_C_Backend_Emission emission_
 
Symbol_Names names_
 

Detailed Description

Definition at line 273 of file Compiler_Backend_C.H.

Constructor & Destructor Documentation

◆ Emitter()

Aleph::Compiler_C_Backend::Emitter::Emitter ( const Compiler_C_Backend_Options &  options_in,
const Compiler_IR_Module &  module_in,
const Compiler_Type_Context *  types_in 
)
inline

Builds an emitter over one module and one option set.

Definition at line 1237 of file Compiler_Backend_C.H.

References initialize_symbols().

Member Function Documentation

◆ emit_constant_expression()

◆ emit_function()

void Aleph::Compiler_C_Backend::Emitter::emit_function ( const size_t  index,
std::ostream &  out 
)
inlineprivate

◆ emit_function_body()

◆ emit_function_descriptors()

◆ emit_function_signature()

void Aleph::Compiler_C_Backend::Emitter::emit_function_signature ( std::ostream &  out,
const std::string &  symbol 
) const
inlineprivate

◆ emit_instruction()

void Aleph::Compiler_C_Backend::Emitter::emit_instruction ( std::ostream &  out,
const Compiler_IR_Instruction &  inst,
const Compiler_IR_Function &  function 
)
inlineprivate

Definition at line 827 of file Compiler_Backend_C.H.

References Aleph::Amp, Aleph::AndAnd, Aleph::Bang, Aleph::Binary, Aleph::blossom_maximum_cardinality_matching(), Aleph::Compiler_Backend_C_Detail::c_string_literal(), Aleph::Call, Aleph::Compiler_C_Backend::Symbol_Names::call_symbol, Aleph::Caret, Aleph::compiler_ir_invalid_id(), Aleph::Constant, emit_constant_expression(), emit_instruction_comment(), Aleph::EqEq, Aleph::Compiler_C_Backend::Symbol_Names::equal_symbol, Aleph::error(), fail(), function_descriptor_symbol(), Aleph::Function_Ref, Aleph::Compiler_Backend_C_Detail::global_name(), Aleph::Greater, Aleph::GreaterEq, Aleph::Less, Aleph::LessEq, Aleph::Load, Aleph::Compiler_Backend_C_Detail::local_name(), Aleph::Compiler_C_Backend::Symbol_Names::make_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_function_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_int_symbol, Aleph::message(), Aleph::Minus, names_, Aleph::NotEq, Aleph::OrOr, out, Aleph::Compiler_C_Backend::Symbol_Names::panic_symbol, Aleph::Percent, Aleph::Pipe, Aleph::Plus, Aleph::Compiler_C_Backend::Symbol_Names::require_assigned_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_int_symbol, Aleph::Slash, Aleph::Star, Aleph::Store, Aleph::Tilde, Aleph::Compiler_Backend_C_Detail::token_name(), Aleph::Unary, value, Aleph::Compiler_Backend_C_Detail::value_name(), and Aleph::Compiler_C_Backend::Symbol_Names::value_type_name.

Referenced by emit_function_body().

◆ emit_instruction_comment()

◆ emit_main()

◆ emit_module_layout()

◆ emit_parameter_bindings()

◆ emit_prototypes()

◆ emit_runtime_prelude()

void Aleph::Compiler_C_Backend::Emitter::emit_runtime_prelude ( std::ostream &  out) const
inlineprivate

Definition at line 423 of file Compiler_Backend_C.H.

References Aleph::Compiler_C_Backend::Symbol_Names::call_symbol, Aleph::Compiler_C_Backend::Symbol_Names::equal_symbol, Aleph::Compiler_C_Backend::Symbol_Names::function_pointer_type_name, Aleph::Compiler_C_Backend::Symbol_Names::function_type_name, Aleph::Compiler_Backend_C_Detail::indent(), Aleph::Compiler_C_Backend::Symbol_Names::make_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_char_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_function_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_int_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_invalid_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_string_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_unit_symbol, Aleph::Compiler_C_Backend::Symbol_Names::module_struct_name, names_, out, Aleph::Compiler_C_Backend::Symbol_Names::panic_symbol, Aleph::Compiler_C_Backend::Symbol_Names::prefix, Aleph::Compiler_C_Backend::Symbol_Names::print_value_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_assigned_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_function_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_int_symbol, Aleph::Compiler_C_Backend::Symbol_Names::tag_bool_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_char_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_enum_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_function_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_int_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_invalid_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_name_symbol, Aleph::Compiler_C_Backend::Symbol_Names::tag_string_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_unit_name, and Aleph::Compiler_C_Backend::Symbol_Names::value_type_name.

Referenced by run().

◆ emit_slot_declarations()

◆ emit_terminator()

◆ emit_top_level()

void Aleph::Compiler_C_Backend::Emitter::emit_top_level ( std::ostream &  out)
inlineprivate

◆ emit_value_declarations()

void Aleph::Compiler_C_Backend::Emitter::emit_value_declarations ( std::ostream &  out,
const Compiler_IR_Function &  function 
) const
inlineprivate

◆ fail()

void Aleph::Compiler_C_Backend::Emitter::fail ( const std::string &  message)
inlineprivate

◆ function_descriptor_symbol()

std::string Aleph::Compiler_C_Backend::Emitter::function_descriptor_symbol ( const size_t  index) const
inlineprivate

◆ function_symbol()

std::string Aleph::Compiler_C_Backend::Emitter::function_symbol ( const size_t  index) const
inlineprivate

◆ initialize_symbols()

void Aleph::Compiler_C_Backend::Emitter::initialize_symbols ( )
inlineprivate

Definition at line 299 of file Compiler_Backend_C.H.

References Aleph::DynArray< T >::append(), Aleph::Compiler_C_Backend_Emission::c_prefix, Aleph::Compiler_C_Backend::Symbol_Names::call_symbol, Aleph::Compiler_C_Backend_Emission::dump_globals_symbol, Aleph::Compiler_C_Backend::Symbol_Names::dump_globals_symbol, emission_, Aleph::Compiler_C_Backend::Symbol_Names::equal_symbol, Aleph::Compiler_C_Backend_Emission::function_descriptor_symbols, Aleph::Compiler_C_Backend::Symbol_Names::function_pointer_type_name, Aleph::Compiler_C_Backend_Emission::function_symbols, Aleph::Compiler_C_Backend::Symbol_Names::function_type_name, Aleph::Compiler_IR_Module::functions, Aleph::Compiler_C_Backend::Symbol_Names::make_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_char_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_function_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_int_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_invalid_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_string_symbol, Aleph::Compiler_C_Backend::Symbol_Names::make_unit_symbol, module_, Aleph::Compiler_C_Backend_Emission::module_init_symbol, Aleph::Compiler_C_Backend::Symbol_Names::module_init_symbol, Aleph::Compiler_C_Backend_Options::module_name, Aleph::Compiler_C_Backend_Emission::module_struct_name, Aleph::Compiler_C_Backend::Symbol_Names::module_struct_name, names_, options_, Aleph::Compiler_C_Backend::Symbol_Names::panic_symbol, Aleph::Compiler_C_Backend::Symbol_Names::prefix, Aleph::Compiler_C_Backend_Emission::print_value_symbol, Aleph::Compiler_C_Backend::Symbol_Names::print_value_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_assigned_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_bool_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_function_symbol, Aleph::Compiler_C_Backend::Symbol_Names::require_int_symbol, Aleph::Compiler_Backend_C_Detail::sanitize_identifier(), Aleph::Compiler_C_Backend::Symbol_Names::tag_bool_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_char_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_enum_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_function_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_int_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_invalid_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_name_symbol, Aleph::Compiler_C_Backend::Symbol_Names::tag_string_name, Aleph::Compiler_C_Backend::Symbol_Names::tag_unit_name, Aleph::Compiler_IR_Module::top_level, Aleph::Compiler_C_Backend_Emission::top_level_symbol, Aleph::Compiler_C_Backend::Symbol_Names::top_level_symbol, Aleph::Compiler_Backend_C_Detail::upper_identifier(), Aleph::Compiler_C_Backend::Symbol_Names::upper_prefix, Aleph::Compiler_C_Backend_Emission::value_type_name, and Aleph::Compiler_C_Backend::Symbol_Names::value_type_name.

Referenced by Emitter().

◆ run()

◆ type_comment()

std::string Aleph::Compiler_C_Backend::Emitter::type_comment ( const Compiler_Type_Id  type_id) const
inlineprivate

◆ validate_input()

void Aleph::Compiler_C_Backend::Emitter::validate_input ( )
inlineprivate

◆ warn()

void Aleph::Compiler_C_Backend::Emitter::warn ( const std::string &  message)
inlineprivate

Member Data Documentation

◆ emission_

Compiler_C_Backend_Emission Aleph::Compiler_C_Backend::Emitter::emission_
private

◆ module_

const Compiler_IR_Module* Aleph::Compiler_C_Backend::Emitter::module_ = nullptr
private

◆ names_

◆ options_

const Compiler_C_Backend_Options* Aleph::Compiler_C_Backend::Emitter::options_ = nullptr
private

◆ types_

const Compiler_Type_Context* Aleph::Compiler_C_Backend::Emitter::types_ = nullptr
private

Definition at line 277 of file Compiler_Backend_C.H.

Referenced by type_comment().


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