83 lines
1.4 KiB
C++
83 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <spider/runtime/cpu/CPU.hpp>
|
|
|
|
#include <spider/runtime/memory/RAM.hpp>
|
|
|
|
#include <spider/runtime/reel/InstrReel.hpp>
|
|
|
|
namespace spider {
|
|
|
|
/**
|
|
* The main runtime class.
|
|
* This is where the Spider VM (Runtime) lives
|
|
*/
|
|
class Runtime {
|
|
public:
|
|
|
|
CPU cpu;
|
|
RAM ram;
|
|
InstrReel* reel;
|
|
|
|
public:
|
|
|
|
/**
|
|
* Creates a new runtime, with no memory.
|
|
*/
|
|
Runtime();
|
|
|
|
/**
|
|
* Creates a new runtime, with a specific
|
|
* amount of memory.
|
|
*/
|
|
Runtime(u64 ramSize);
|
|
|
|
/**
|
|
* Runtime Destructor.
|
|
*/
|
|
~Runtime();
|
|
|
|
public:
|
|
|
|
/**
|
|
* Steps the clock of the VM once.
|
|
*/
|
|
void step();
|
|
|
|
/**
|
|
* Steps n-times the clock of the VM.
|
|
*/
|
|
void step(u64 n);
|
|
|
|
public:
|
|
|
|
/**
|
|
* Sets the machine to run continously.
|
|
* If interrupts occur, they will be handled
|
|
* automatically.
|
|
*/
|
|
void run();
|
|
|
|
/**
|
|
* Runs this machine for a set amount of
|
|
* milliseconds.
|
|
*/
|
|
void run(u64 ms);
|
|
|
|
public:
|
|
|
|
/**
|
|
* Resizes the ram, which will preserve
|
|
* data inside the next length.
|
|
*/
|
|
void resizeRAM(u64 length);
|
|
|
|
/**
|
|
* Non-owning reel setup.
|
|
*/
|
|
void hookReel(InstrReel* newReel, bool own = false);
|
|
|
|
};
|
|
|
|
}
|