Phasor 2.2.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
Phasor::PhasorIR Class Reference

Phasor IR Serializer/Deserializer. More...

#include <PhasorIR.hpp>

Static Public Member Functions

static std::vector< uint8_t > serialize (const Bytecode &bytecode)
 Serialize bytecode to Phasor IR format.
static Bytecode deserialize (const std::vector< uint8_t > &data)
 Deserialize Phasor IR format to bytecode.
static bool saveToFile (const Bytecode &bytecode, const std::filesystem::path &filename)
 Save bytecode to .phir file.
static Bytecode loadFromFile (const std::filesystem::path &filename)
 Load bytecode from .phir file.
static std::string opCodeToString (OpCode op)
 Helper to convert OpCode to string.
static OpCode stringToOpCode (const std::string &str)
 Helper to convert string to OpCode.
static std::string escapeString (const std::string &str)
 Helper to escape strings for text format.
static std::string unescapeString (const std::string &str)
 Helper to unescape strings from text format.

Private Types

enum class  OperandType {
  NONE , INT , REGISTER , CONSTANT_IDX ,
  VARIABLE_IDX , FUNCTION_IDX
}

Static Private Member Functions

static int getOperandCount (OpCode op)
static OperandType getOperandType (OpCode op, int operandIndex)

Static Private Attributes

static const std::unordered_map< OpCode, std::string > opCodeToStringMap
static const std::unordered_map< std::string, OpCodestringToOpCodeMap

Detailed Description

Phasor IR Serializer/Deserializer.

Definition at line 16 of file PhasorIR.hpp.

Member Enumeration Documentation

◆ OperandType

enum class Phasor::PhasorIR::OperandType
strongprivate
Enumerator
NONE 
INT 
REGISTER 
CONSTANT_IDX 
VARIABLE_IDX 
FUNCTION_IDX 

Definition at line 44 of file PhasorIR.hpp.

Member Function Documentation

◆ deserialize()

Bytecode Phasor::PhasorIR::deserialize ( const std::vector< uint8_t > & data)
static

Deserialize Phasor IR format to bytecode.

Definition at line 594 of file PhasorIR.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ escapeString()

std::string Phasor::PhasorIR::escapeString ( const std::string & str)
static

Helper to escape strings for text format.

Definition at line 353 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ getOperandCount()

int Phasor::PhasorIR::getOperandCount ( OpCode op)
staticprivate

Definition at line 143 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ getOperandType()

PhasorIR::OperandType Phasor::PhasorIR::getOperandType ( OpCode op,
int operandIndex )
staticprivate

Definition at line 277 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ loadFromFile()

Bytecode Phasor::PhasorIR::loadFromFile ( const std::filesystem::path & filename)
static

Load bytecode from .phir file.

Definition at line 781 of file PhasorIR.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opCodeToString()

std::string Phasor::PhasorIR::opCodeToString ( OpCode op)
static

Helper to convert OpCode to string.

Definition at line 333 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ saveToFile()

bool Phasor::PhasorIR::saveToFile ( const Bytecode & bytecode,
const std::filesystem::path & filename )
static

Save bytecode to .phir file.

Definition at line 764 of file PhasorIR.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialize()

std::vector< uint8_t > Phasor::PhasorIR::serialize ( const Bytecode & bytecode)
static

Serialize bytecode to Phasor IR format.

Definition at line 422 of file PhasorIR.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stringToOpCode()

OpCode Phasor::PhasorIR::stringToOpCode ( const std::string & str)
static

Helper to convert string to OpCode.

Definition at line 343 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ unescapeString()

std::string Phasor::PhasorIR::unescapeString ( const std::string & str)
static

Helper to unescape strings from text format.

Definition at line 383 of file PhasorIR.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ opCodeToStringMap

const std::unordered_map< OpCode, std::string > Phasor::PhasorIR::opCodeToStringMap
staticprivate

Definition at line 57 of file PhasorIR.hpp.

◆ stringToOpCodeMap

const std::unordered_map< std::string, OpCode > Phasor::PhasorIR::stringToOpCodeMap
staticprivate
Initial value:
= [] {
std::unordered_map<std::string, OpCode> map;
for (const auto &pair : PhasorIR::opCodeToStringMap)
{
map[pair.second] = pair.first;
}
return map;
}()
static const std::unordered_map< OpCode, std::string > opCodeToStringMap
Definition PhasorIR.hpp:57

Definition at line 58 of file PhasorIR.hpp.


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