ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::IRCompiler Class Referencefinal

#include <IRCompiler.hpp>

Collaboration diagram for Ark::internal::IRCompiler:
[legend]

Public Member Functions

 IRCompiler (unsigned debug)
 Create a new IRCompiler.
 
void process (const std::vector< IR::Block > &pages, const std::vector< std::string > &symbols, const std::vector< ValTableElem > &values)
 Turn a given IR into bytecode.
 
void dumpToStream (std::ostream &stream) const
 Dump the IR given to process to an output stream.
 
const bytecode_tbytecode () const noexcept
 Return the constructed bytecode object.
 

Private Member Functions

void compile ()
 
void pushWord (const Word &word)
 Push a word to the m_bytecode.
 
void pushFileHeader () noexcept
 Push the file headers (magic, version used, timestamp)
 
void pushSymAndValTables (const std::vector< std::string > &symbols, const std::vector< ValTableElem > &values)
 Push the symbols and values tables.
 

Private Attributes

Logger m_logger
 
bytecode_t m_bytecode
 
std::vector< IR::Blockm_ir
 

Detailed Description

Definition at line 26 of file IRCompiler.hpp.

Constructor & Destructor Documentation

◆ IRCompiler()

Ark::internal::IRCompiler::IRCompiler ( unsigned debug)
explicit

Create a new IRCompiler.

Parameters
debugdebug level

Definition at line 16 of file IRCompiler.cpp.

Member Function Documentation

◆ bytecode()

const bytecode_t & Ark::internal::IRCompiler::bytecode ( ) const
nodiscardnoexcept

Return the constructed bytecode object.

Returns
const bytecode_t&

Definition at line 93 of file IRCompiler.cpp.

References m_bytecode.

Referenced by Ark::Welder::generateBytecode().

◆ compile()

◆ dumpToStream()

void Ark::internal::IRCompiler::dumpToStream ( std::ostream & stream) const

◆ process()

void Ark::internal::IRCompiler::process ( const std::vector< IR::Block > & pages,
const std::vector< std::string > & symbols,
const std::vector< ValTableElem > & values )

Turn a given IR into bytecode.

Parameters
pageslist of lists of IR entities generated by the compiler
symbolssymbol table generated by the compiler
valuesvalue table generated by the compiler

Definition at line 20 of file IRCompiler.cpp.

References Ark::internal::CODE_SEGMENT_START, compile(), Ark::internal::HALT, m_bytecode, m_ir, m_logger, pushFileHeader(), pushSymAndValTables(), Ark::internal::Logger::traceEnd(), and Ark::internal::Logger::traceStart().

Referenced by Ark::Welder::generateBytecode().

◆ pushFileHeader()

void Ark::internal::IRCompiler::pushFileHeader ( )
privatenoexcept

Push the file headers (magic, version used, timestamp)

Definition at line 172 of file IRCompiler.cpp.

References ARK_VERSION_MAJOR, ARK_VERSION_MINOR, ARK_VERSION_PATCH, and m_bytecode.

Referenced by process().

◆ pushSymAndValTables()

void Ark::internal::IRCompiler::pushSymAndValTables ( const std::vector< std::string > & symbols,
const std::vector< ValTableElem > & values )
private

◆ pushWord()

void Ark::internal::IRCompiler::pushWord ( const Word & word)
private

Push a word to the m_bytecode.

Parameters
word

Definition at line 164 of file IRCompiler.cpp.

References Ark::internal::Word::byte_1, Ark::internal::Word::byte_2, Ark::internal::Word::byte_3, m_bytecode, and Ark::internal::Word::opcode.

Referenced by compile().

Member Data Documentation

◆ m_bytecode

bytecode_t Ark::internal::IRCompiler::m_bytecode
private

Definition at line 61 of file IRCompiler.hpp.

Referenced by bytecode(), compile(), process(), pushFileHeader(), pushSymAndValTables(), and pushWord().

◆ m_ir

std::vector<IR::Block> Ark::internal::IRCompiler::m_ir
private

Definition at line 62 of file IRCompiler.hpp.

Referenced by compile(), dumpToStream(), and process().

◆ m_logger

Logger Ark::internal::IRCompiler::m_logger
private

Definition at line 60 of file IRCompiler.hpp.

Referenced by process().


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