64 lines
924 B
C++
64 lines
924 B
C++
#pragma once
|
|
|
|
#include <spider/runtime/common.hpp>
|
|
|
|
namespace spider {
|
|
|
|
/**
|
|
* A memory container.
|
|
* As a reminder, the amount of RAM
|
|
* is designed by the host.
|
|
*/
|
|
class RAM {
|
|
private:
|
|
u8* _mem;
|
|
u64 _size;
|
|
u8 _oob; // Out of bounds reference
|
|
|
|
public:
|
|
|
|
RAM(u64 length);
|
|
|
|
RAM(const RAM& other);
|
|
|
|
RAM(RAM&& other) noexcept;
|
|
|
|
~RAM();
|
|
|
|
public:
|
|
|
|
RAM& operator=(const RAM& other);
|
|
|
|
RAM& operator=(RAM&& other) noexcept;
|
|
|
|
public: // Unsafe access
|
|
|
|
u8& operator[](u64 i);
|
|
|
|
u8 operator[](u64 i) const;
|
|
|
|
public: // managed access (oob = 0)
|
|
|
|
u8& at(u64 i);
|
|
|
|
u8 at(u64 i) const;
|
|
|
|
public:
|
|
|
|
void resize(u64 new_size);
|
|
|
|
u64 size() const;
|
|
|
|
public:
|
|
|
|
u8* begin();
|
|
|
|
u8* end();
|
|
|
|
const u8* begin() const;
|
|
|
|
const u8* end() const;
|
|
|
|
};
|
|
|
|
} |