contur2
Loading...
Searching...
No Matches
contur::InterpreterEngine Class Referencefinal

Bytecode interpreter execution engine. More...

#include <interpreter_engine.h>

Inheritance diagram for contur::InterpreterEngine:
Collaboration diagram for contur::InterpreterEngine:

Public Member Functions

 InterpreterEngine (ICPU &cpu, IMemory &memory)
 Constructs an InterpreterEngine.
 ~InterpreterEngine () override
 InterpreterEngine (const InterpreterEngine &)=delete
InterpreterEngineoperator= (const InterpreterEngine &)=delete
 InterpreterEngine (InterpreterEngine &&) noexcept
InterpreterEngineoperator= (InterpreterEngine &&) noexcept
ExecutionResult execute (ProcessImage &process, std::size_t tickBudget) override
 Executes the given process for up to tickBudget ticks.
void halt (ProcessId pid) override
 Forcibly halts execution of the given process.
std::string_view name () const noexcept override
 Returns the human-readable name of this engine.
Public Member Functions inherited from contur::IExecutionEngine
virtual ~IExecutionEngine ()=default

Private Attributes

std::unique_ptr< Impl > impl_

Additional Inherited Members

Protected Member Functions inherited from contur::IExecutionEngine
 IExecutionEngine ()=default
 IExecutionEngine (const IExecutionEngine &)=default
IExecutionEngineoperator= (const IExecutionEngine &)=default
 IExecutionEngine (IExecutionEngine &&)=default
IExecutionEngineoperator= (IExecutionEngine &&)=default

Detailed Description

Bytecode interpreter execution engine.

Wraps an ICPU and IMemory, loads the process's code segment into memory before each execution burst, and steps instruction-by-instruction up to the given tick budget. Reports results via ExecutionResult.

Usage:

PhysicalMemory memory(256);
Cpu cpu(memory);
InterpreterEngine engine(cpu, memory);
auto result = engine.execute(process, 10);
if (result.reason == StopReason::ProcessExited) { /* done */ }
Concrete CPU implementation.
Definition cpu.h:30
InterpreterEngine(ICPU &cpu, IMemory &memory)
Constructs an InterpreterEngine.
Simulated physical RAM — a linear array of Block cells.
@ ProcessExited
Process executed Halt or Int Exit — normal termination.

Definition at line 35 of file interpreter_engine.h.

Constructor & Destructor Documentation

◆ InterpreterEngine() [1/3]

contur::InterpreterEngine::InterpreterEngine ( ICPU & cpu,
IMemory & memory )
explicit

Constructs an InterpreterEngine.

Parameters
cpuReference to the CPU (must outlive the engine).
memoryReference to the memory subsystem (must outlive the engine).

◆ ~InterpreterEngine()

contur::InterpreterEngine::~InterpreterEngine ( )
override

◆ InterpreterEngine() [2/3]

contur::InterpreterEngine::InterpreterEngine ( const InterpreterEngine & )
delete

◆ InterpreterEngine() [3/3]

contur::InterpreterEngine::InterpreterEngine ( InterpreterEngine && )
noexcept

Member Function Documentation

◆ execute()

ExecutionResult contur::InterpreterEngine::execute ( ProcessImage & process,
std::size_t tickBudget )
nodiscardoverridevirtual

Executes the given process for up to tickBudget ticks.

The engine runs the process until one of:

  • The tick budget is exhausted (preemption)
  • The process exits (Halt / Int Exit)
  • An error or interrupt occurs that requires kernel attention
Parameters
processThe process image to execute (registers + code).
tickBudgetMaximum number of ticks (instructions) to execute.
Returns
An ExecutionResult describing the outcome.

Implements contur::IExecutionEngine.

◆ halt()

void contur::InterpreterEngine::halt ( ProcessId pid)
overridevirtual

Forcibly halts execution of the given process.

Parameters
pidThe process ID to halt.

Implements contur::IExecutionEngine.

◆ name()

std::string_view contur::InterpreterEngine::name ( ) const
nodiscardoverridevirtualnoexcept

Returns the human-readable name of this engine.

Returns
"Interpreter" or "Native", etc.

Implements contur::IExecutionEngine.

◆ operator=() [1/2]

InterpreterEngine & contur::InterpreterEngine::operator= ( const InterpreterEngine & )
delete

◆ operator=() [2/2]

InterpreterEngine & contur::InterpreterEngine::operator= ( InterpreterEngine && )
noexcept

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::InterpreterEngine::impl_
private

Definition at line 62 of file interpreter_engine.h.


The documentation for this class was generated from the following file: