8#include <unordered_map>
49 const std::unordered_map<std::string, int> &functionEntries);
Bytecode binary format serializer.
std::vector< u8 > serialize(const Bytecode &bytecode)
Serialize bytecode to binary buffer.
void writeDouble(f64 value)
Helper method to write Double.
void writeInstructions(const std::vector< Instruction > &instructions)
Helper method to write Instruction Table.
static u32 calculateCRC32(const std::vector< u8 > &data)
Calculate CRC32 checksum.
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 writeInt64(i64 value)
Helper method to write Int64.
void writeUInt32(u32 value)
Helper method to write UInt32.
void writeInt32(i32 value)
Helper method to write Int32.
void writeStructSection(const std::vector< StructInfo > &structs)
Helper method to write Struct Section.
void writeFunctionEntries(const std::unordered_map< std::string, int > &functionEntries)
Helper method to write Function Table.
bool saveToFile(const Bytecode &bytecode, const std::filesystem::path &filename)
Save bytecode to .phsb file.
void writeHeader(u32 dataChecksum)
Section writers.
void writeUInt8(u8 value)
Helper method to write UInt8.
void writeUInt16(u16 value)
Helper method to write UInt16.
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.
A value in the Phasor VM.
The Phasor Programming Language and Runtime.
Complete bytecode structure.