13#ifndef NSBACI_SERVICES_RUNTIME_INTERPRETER_H
14#define NSBACI_SERVICES_RUNTIME_INTERPRETER_H
27 explicit InterpreterResult(std::vector<nsbaci::Error> errs)
32 InterpreterResult(InterpreterResult&&)
noexcept =
default;
33 InterpreterResult& operator=(InterpreterResult&&)
noexcept =
default;
35 InterpreterResult(
const InterpreterResult&) =
default;
36 InterpreterResult& operator=(
const InterpreterResult&) =
default;
79 Interpreter() =
default;
80 virtual ~Interpreter() =
default;
Base result class declaration for nsbaci services.
Represents an error with a message and optional code.
Definition error.h:28
virtual void setOutputCallback(OutputCallback callback)=0
Set the output callback for print operations.
virtual void setDrawingCallback(DrawingCallback callback)=0
Set the drawing callback for drawing operations.
virtual bool isWaitingForInput() const =0
Check if interpreter is waiting for input.
virtual InterpreterResult executeInstruction(Thread &t, Program &program)=0
Executes the current instruction for the given thread with the program context.
virtual void provideInput(const std::string &input)=0
Provide input to a thread waiting for input.
virtual void reset()=0
Reset interpreter state for a new run.
Represents a compiled program ready for execution.
Definition program.h:54
Represents a thread in the runtime service.
Definition thread.h:31
Type definitions for drawing-related operations.
Runtime services namespace for nsbaci.
std::function< void(const std::string &)> OutputCallback
Callback type for output operations.
Definition interpreter.h:62
std::function< void(const nsbaci::types::DrawCommand &)> DrawingCallback
Callback type for drawing operations.
Definition interpreter.h:68
std::function< void(const std::string &)> InputRequestCallback
Callback type for input requests.
Definition interpreter.h:65
Program class declaration for nsbaci runtime service.
Definition interpreter.h:25
bool createThread
Should create a new thread.
Definition interpreter.h:49
bool shouldBlock
Thread should be blocked (semaphore wait).
Definition interpreter.h:43
std::string output
Output produced by this instruction.
Definition interpreter.h:40
bool coendWait
Waiting for cobegin threads to finish.
Definition interpreter.h:47
int32_t expectedThreadCount
Number of threads to wait for at coend.
Definition interpreter.h:48
bool signalSemaphore
Signal was called on a semaphore.
Definition interpreter.h:51
bool shouldYield
Thread should yield after instruction.
Definition interpreter.h:45
bool needsInput
Thread is waiting for input.
Definition interpreter.h:38
uint32_t newThreadPC
PC for new thread (if createThread is true).
Definition interpreter.h:50
std::string inputPrompt
Prompt to show for input.
Definition interpreter.h:39
uint32_t blockingSemaphore
Address of semaphore causing block.
Definition interpreter.h:44
uint32_t signaledSemaphore
Address of semaphore that was signaled.
Definition interpreter.h:52
bool cobeginStart
Starting a cobegin block.
Definition interpreter.h:46
Base result structure for all service operations.
Definition baseResult.h:56
BaseResult()
Default constructor creates a successful result.
Definition baseResult.h:60
Represents a single drawing command to be executed.
Definition drawingTypes.h:240
Thread class declaration for nsbaci runtime service.