Phasor 3.1.1
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 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 : uint8_t {
  NONE , INT , REGISTER , CONSTANT_IDX ,
  VARIABLE_IDX , FUNCTION_IDX
}
 Operand types for instructions. More...

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 17 of file PhasorIR.hpp.

Member Enumeration Documentation

◆ OperandType

enum class Phasor::PhasorIR::OperandType : uint8_t
strongprivate

Operand types for instructions.

Enumerator
NONE 

No operand.

INT 

Integer operand.

REGISTER 

Register operand.

CONSTANT_IDX 

Index into constant pool.

VARIABLE_IDX 

Index into variable mapping.

FUNCTION_IDX 

Index into function entries.

Definition at line 40 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 454 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 214 of file PhasorIR.cpp.

Here is the caller graph for this function:

◆ getOperandCount()

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

Definition at line 24 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 158 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 641 of file PhasorIR.cpp.

Here is the call graph for this function:
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 624 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 283 of file PhasorIR.cpp.

Here is the call graph for this function:
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 244 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 53 of file PhasorIR.hpp.

◆ stringToOpCodeMap

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

Definition at line 54 of file PhasorIR.hpp.


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