🧬 Core Library
Molecule
Container for quarks and atoms. The main data structure in The Guardian.
Methods
void add_string(name, value) |
Add a string value |
void add_number(name, value) |
Add a numeric value (double) |
void add_bool(name, value) |
Add a boolean value |
void add_molecule(name, value) |
Add a nested molecule |
std::string get_string(name) |
Get a string value |
double get_number(name) |
Get a numeric value |
bool get_bool(name) |
Get a boolean value |
std::shared_ptr<Molecule> get_molecule(name) |
Get a nested molecule |
bool has_string(name) |
Check if string exists |
bool has_number(name) |
Check if number exists |
bool has_bool(name) |
Check if bool exists |
bool has_molecule(name) |
Check if molecule exists |
void remove(name) |
Remove a value by name |
void dump() |
Print all contents (debug) |
size_t size() |
Get total size in bytes |
Quark
Primitive values — int, float, bool, string, char.
Constructors
Quark(int v) |
Integer quark |
Quark(double v) |
Float quark |
Quark(bool v) |
Boolean quark |
Quark(const std::string& v) |
String quark |
Methods
std::string to_string() |
Convert to string |
size_t size() |
Get size in bytes |
💾 Memory Library
MemoryManager
LUT-based memory safety — no GC, no leaks, no UB.
Methods
void* allocate(size_t size) |
Allocate memory |
void deallocate(void* ptr) |
Free memory |
void register_pointer(ptr, size, name) |
Track a pointer |
void unregister_pointer(ptr) |
Stop tracking a pointer |
bool is_valid_pointer(ptr) |
Check if pointer is valid |
Stats get_stats() |
Get allocation stats |
void print_stats() |
Print allocation stats |
void reset() |
Reset everything |
MemoryPool
Efficient fixed-size block allocator.
Methods
MemoryPool(size_t block_size = 4096) |
Constructor |
void* allocate(size_t size) |
Allocate from pool |
void deallocate(void* ptr) |
Free to pool |
void reset() |
Reset pool |
size_t used() |
Get used memory |
size_t total() |
Get total memory |
GbinFormat
Guardian Binary Format — fast, extensible serialization.
Methods
void set_version(uint16_t v) |
Set format version |
uint16_t get_version() |
Get format version |
void set_data(const vector<uint8_t>& data) |
Set binary data |
const vector<uint8_t>& get_data() |
Get binary data |
void push_byte(uint8_t byte) |
Push a byte |
void push_int(int value) |
Push an integer |
void push_float(float value) |
Push a float |
void push_string(const string& str) |
Push a string |
vector<uint8_t> serialize() |
Serialize to bytes |
bool deserialize(const vector<uint8_t>& data) |
Deserialize from bytes |
bool read(const string& path) |
Read from file |
bool write(const string& path) |
Write to file |
FormatRegistry
Register and lookup custom formats.
Methods
void register_format(name, format) |
Register a format |
shared_ptr<Format> get_format(name) |
Get a format |
bool has_format(name) |
Check if format exists |
vector<string> list_formats() |
List all formats |
🖥️ VM Library
VM
Bytecode execution engine with 40+ opcodes.
Methods
void load(const vector<uint8_t>& bytecode) |
Load bytecode |
void run() |
Execute bytecode |
void reset() |
Reset VM state |
bool is_running() |
Check if running |
void push(const Value& val) |
Push to stack |
Value pop() |
Pop from stack |
Value peek() |
Peek at stack top |
CodeGen
Generate bytecode programmatically.
Methods
void emit(opcode) |
Emit an opcode |
void emit(opcode, operand) |
Emit opcode with operand |
void pushInt(value) |
Push integer |
void pushString(value) |
Push string |
void print() |
Print top of stack |
void println() |
Print with newline |
void halt() |
Halt execution |
vector<uint8_t> getBytecode() |
Get generated bytecode |
📝 Parser Library
Lexer
Tokenize source code.
Methods
Lexer(const string& source) |
Constructor |
vector<Token> tokenize() |
Tokenize source |
Parser
Parse tokens into AST.
Methods
Parser(const vector<Token>& tokens) |
Constructor |
unique_ptr<ASTNode> parse() |
Parse to AST |
🔷 Value Types
Value
Universal value type — can be a quark or atom.
Constructors
Value() |
Null value |
Value(int v) |
Integer value |
Value(double v) |
Float value |
Value(bool v) |
Boolean value |
Value(const string& v) |
String value |
Value(const vector<Value>& arr) |
Array value |
Value(const unordered_map<string, Value>& dict) |
Dict value |
Value(shared_ptr<Molecule> m) |
Molecule value |
Methods
std::string to_string() |
Convert to string |