13#ifndef NSBACI_SERVICES_RUNTIME_PROGRAM_H
14#define NSBACI_SERVICES_RUNTIME_PROGRAM_H
17#include <unordered_map>
34using Stack = std::vector<StackValue>;
61 Program(
const Program&) =
delete;
62 Program& operator=(
const Program&) =
delete;
64 Program(Program&&) =
default;
65 Program& operator=(Program&&) =
default;
127 nsbaci::types::ThreadID threadId);
const nsbaci::compiler::Instruction & getInstruction(uint32_t addr) const
Gets instruction at the given address.
Definition program.cpp:23
size_t instructionCount() const
Gets the total number of instructions.
Definition program.cpp:31
void writeMemory(nsbaci::types::MemoryAddr addr, int32_t value)
Write a value to memory.
Definition program.cpp:52
void createSemaphore(nsbaci::types::MemoryAddr addr, int32_t initialCount)
Create a semaphore at the given address.
Definition program.cpp:59
bool hasSemaphore(nsbaci::types::MemoryAddr addr) const
Check if a semaphore exists at the given address.
Definition program.cpp:81
int32_t readMemory(nsbaci::types::MemoryAddr addr) const
Read a value from memory.
Definition program.cpp:45
nsbaci::types::Memory & memory()
Access to global memory.
Definition program.cpp:33
void addSymbol(nsbaci::types::SymbolInfo info)
Add a symbol to the symbol table.
Definition program.cpp:41
nsbaci::types::ThreadID semaphoreSignal(nsbaci::types::MemoryAddr addr)
Signal (V operation) on a semaphore.
Definition program.cpp:73
const nsbaci::types::SymbolTable & symbols() const
Access to symbol table.
Definition program.cpp:37
bool semaphoreWait(nsbaci::types::MemoryAddr addr, nsbaci::types::ThreadID threadId)
Wait (P operation) on a semaphore.
Definition program.cpp:64
Type definitions for compiler-related operations.
Instruction definitions for nsbaci compiler.
std::vector< Instruction > InstructionStream
Vector of instructions representing a compiled program.
Definition instruction.h:210
Runtime services namespace for nsbaci.
Type definitions namespace for nsbaci (runtime-specific).
uint32_t MemoryAddr
Type alias for memory addresses.
Definition compilerTypes.h:31
std::unordered_map< MemoryAddr, nsbaci::services::runtime::Semaphore > SemaphoreTable
Maps memory addresses to semaphores.
Definition semaphore.h:58
std::vector< int32_t > Memory
Memory block for runtime data.
Definition program.h:37
std::vector< StackValue > Stack
Runtime stack.
Definition program.h:34
int32_t StackValue
Stack value type (can hold int or address).
Definition program.h:31
std::unordered_map< VarName, SymbolInfo > SymbolTable
Lookup table mapping variable names to their symbol info.
Definition compilerTypes.h:42
Semaphore implementation for process synchronization.
Represents a single instruction in the virtual machine.
Definition instruction.h:184
Information about a variable/symbol.
Definition compilerTypes.h:34