![]() |
Phasor 3.3.0
Stack VM based Programming Language
|
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::unordered_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::unordered_map< std::string, int > &functionEntries) |
| Helper method to write Function Table. | |
Static Private Member Functions | |
| static uint32_t | calculateCRC32 (const std::vector< uint8_t > &data) |
| Calculate CRC32 checksum. | |
Private Attributes | |
| std::vector< uint8_t > | buffer |
Bytecode binary format serializer.
Definition at line 17 of file BytecodeSerializer.hpp.
|
staticprivate |
Calculate CRC32 checksum.
Definition at line 42 of file BytecodeSerializer.cpp.
| bool Phasor::BytecodeSerializer::saveToFile | ( | const Bytecode & | bytecode, |
| const std::filesystem::path & | filename ) |
Save bytecode to .phsb file.
Definition at line 229 of file BytecodeSerializer.cpp.
| std::vector< uint8_t > Phasor::BytecodeSerializer::serialize | ( | const Bytecode & | bytecode | ) |
Serialize bytecode to binary buffer.
Definition at line 198 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Constants Table.
Definition at line 116 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Double.
Definition at line 89 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Function Table.
Definition at line 186 of file BytecodeSerializer.cpp.
|
private |
Section writers.
Helper method to write header
Definition at line 108 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Instruction Table.
Definition at line 172 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Int32.
Definition at line 76 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Int64.
Definition at line 81 of file BytecodeSerializer.cpp.
|
private |
Helper method to write String.
Definition at line 99 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt16.
Definition at line 62 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt32.
Definition at line 68 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt8.
Definition at line 57 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Variable Map Table.
Definition at line 159 of file BytecodeSerializer.cpp.
|
private |
Definition at line 27 of file BytecodeSerializer.hpp.