![]() |
Phasor 3.3.0
Stack VM based Programming Language
|
Bytecode binary format serializer. More...
#include <BytecodeSerializer.hpp>
Public Member Functions | |
| std::vector< u8 > | 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 (u8 value) |
| Helper method to write UInt8. | |
| void | writeUInt16 (u16 value) |
| Helper method to write UInt16. | |
| void | writeUInt32 (u32 value) |
| Helper method to write UInt32. | |
| void | writeInt32 (i32 value) |
| Helper method to write Int32. | |
| void | writeInt64 (i64 value) |
| Helper method to write Int64. | |
| void | writeDouble (f64 value) |
| Helper method to write Double. | |
| void | writeString (const std::string &str) |
| Helper method to write String. | |
| void | writeValue (const Value &val) |
| Write a single Value (recursive — handles nested structs/arrays). | |
| void | writeHeader (u32 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. | |
| void | writeStructSection (const std::vector< StructInfo > &structs) |
| Helper method to write Struct Section. | |
Static Private Member Functions | |
| static u32 | calculateCRC32 (const std::vector< u8 > &data) |
| Calculate CRC32 checksum. | |
Private Attributes | |
| std::vector< u8 > | buffer |
Bytecode binary format serializer.
Definition at line 19 of file BytecodeSerializer.hpp.
Calculate CRC32 checksum.
Definition at line 39 of file BytecodeSerializer.cpp.
| bool Phasor::BytecodeSerializer::saveToFile | ( | const Bytecode & | bytecode, |
| const std::filesystem::path & | filename ) |
Save bytecode to .phsb file.
Definition at line 281 of file BytecodeSerializer.cpp.
Serialize bytecode to binary buffer.
Definition at line 255 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Constants Table.
Definition at line 180 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Double.
Definition at line 84 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Function Table.
Definition at line 214 of file BytecodeSerializer.cpp.
|
private |
Section writers.
Helper method to write header
Definition at line 172 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Instruction Table.
Definition at line 201 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Int32.
Definition at line 73 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Int64.
Definition at line 78 of file BytecodeSerializer.cpp.
|
private |
Helper method to write String.
Definition at line 92 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Struct Section.
Write struct type definitions section (0x05).
Binary layout: u8 section_id = 0x05 u32 structCount for each StructInfo: string name i32 firstConstIndex i32 fieldCount string fieldName[0..fieldCount-1]
Definition at line 237 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt16.
Definition at line 59 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt32.
Definition at line 65 of file BytecodeSerializer.cpp.
|
private |
Helper method to write UInt8.
Definition at line 54 of file BytecodeSerializer.cpp.
|
private |
Write a single Value (recursive — handles nested structs/arrays).
Definition at line 111 of file BytecodeSerializer.cpp.
|
private |
Helper method to write Variable Map Table.
Definition at line 188 of file BytecodeSerializer.cpp.
|
private |
Definition at line 29 of file BytecodeSerializer.hpp.