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

Bytecode binary format serializer. More...

#include <BytecodeSerializer.hpp>

Public Member Functions

std::vector< uint8_t > serialize (const Bytecode &bytecode)
 Serialize bytecode to binary buffer.
bool saveToFile (const Bytecode &bytecode, const std::filesystem::path &filename)
 Save bytecode to .phsb file.

Private Member Functions

void writeUInt8 (uint8_t value)
 Helper method to write UInt8.
void writeUInt16 (uint16_t value)
 Helper method to write UInt16.
void writeUInt32 (uint32_t value)
 Helper method to write UInt32.
void writeInt32 (int32_t value)
 Helper method to write Int32.
void writeInt64 (int64_t value)
 Helper method to write Int64.
void writeDouble (double value)
 Helper method to write Double.
void writeString (const std::string &str)
 Helper method to write String.
void writeHeader (uint32_t dataChecksum)
 Section writers.
void writeConstantPool (const std::vector< Value > &constants)
 Helper method to write Constants Table.
void writeVariableMapping (const std::map< std::string, int > &variables, int nextVarIndex)
 Helper method to write Variable Map Table.
void writeInstructions (const std::vector< Instruction > &instructions)
 Helper method to write Instruction Table.
void writeFunctionEntries (const std::map< std::string, int > &functionEntries)
 Helper method to write Function Table.
uint32_t calculateCRC32 (const std::vector< uint8_t > &data)
 Calculate CRC32 checksum.

Private Attributes

std::vector< uint8_t > buffer

Detailed Description

Bytecode binary format serializer.

Definition at line 16 of file BytecodeSerializer.hpp.

Member Function Documentation

◆ calculateCRC32()

uint32_t Phasor::BytecodeSerializer::calculateCRC32 ( const std::vector< uint8_t > & data)
private

Calculate CRC32 checksum.

Definition at line 53 of file BytecodeSerializer.cpp.

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

◆ saveToFile()

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

Save bytecode to .phsb file.

Definition at line 243 of file BytecodeSerializer.cpp.

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

◆ serialize()

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

Serialize bytecode to binary buffer.

Definition at line 212 of file BytecodeSerializer.cpp.

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

◆ writeConstantPool()

void Phasor::BytecodeSerializer::writeConstantPool ( const std::vector< Value > & constants)
private

Helper method to write Constants Table.

Definition at line 127 of file BytecodeSerializer.cpp.

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

◆ writeDouble()

void Phasor::BytecodeSerializer::writeDouble ( double value)
private

Helper method to write Double.

Definition at line 100 of file BytecodeSerializer.cpp.

Here is the caller graph for this function:

◆ writeFunctionEntries()

void Phasor::BytecodeSerializer::writeFunctionEntries ( const std::map< std::string, int > & functionEntries)
private

Helper method to write Function Table.

Definition at line 200 of file BytecodeSerializer.cpp.

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

◆ writeHeader()

void Phasor::BytecodeSerializer::writeHeader ( uint32_t dataChecksum)
private

Section writers.

Helper method to write header

Definition at line 119 of file BytecodeSerializer.cpp.

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

◆ writeInstructions()

void Phasor::BytecodeSerializer::writeInstructions ( const std::vector< Instruction > & instructions)
private

Helper method to write Instruction Table.

Definition at line 184 of file BytecodeSerializer.cpp.

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

◆ writeInt32()

void Phasor::BytecodeSerializer::writeInt32 ( int32_t value)
private

Helper method to write Int32.

Definition at line 87 of file BytecodeSerializer.cpp.

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

◆ writeInt64()

void Phasor::BytecodeSerializer::writeInt64 ( int64_t value)
private

Helper method to write Int64.

Definition at line 92 of file BytecodeSerializer.cpp.

Here is the caller graph for this function:

◆ writeString()

void Phasor::BytecodeSerializer::writeString ( const std::string & str)
private

Helper method to write String.

Definition at line 110 of file BytecodeSerializer.cpp.

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

◆ writeUInt16()

void Phasor::BytecodeSerializer::writeUInt16 ( uint16_t value)
private

Helper method to write UInt16.

Definition at line 73 of file BytecodeSerializer.cpp.

Here is the caller graph for this function:

◆ writeUInt32()

void Phasor::BytecodeSerializer::writeUInt32 ( uint32_t value)
private

Helper method to write UInt32.

Definition at line 79 of file BytecodeSerializer.cpp.

Here is the caller graph for this function:

◆ writeUInt8()

void Phasor::BytecodeSerializer::writeUInt8 ( uint8_t value)
private

Helper method to write UInt8.

Definition at line 68 of file BytecodeSerializer.cpp.

Here is the caller graph for this function:

◆ writeVariableMapping()

void Phasor::BytecodeSerializer::writeVariableMapping ( const std::map< std::string, int > & variables,
int nextVarIndex )
private

Helper method to write Variable Map Table.

Definition at line 171 of file BytecodeSerializer.cpp.

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

Member Data Documentation

◆ buffer

std::vector<uint8_t> Phasor::BytecodeSerializer::buffer
private

Definition at line 26 of file BytecodeSerializer.hpp.


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