Table of Contents

Class SteppableVirtualMachine

Namespace
Pl0.Vm
Assembly
Pl0.Vm.dll

Stateful PL/0 virtual machine with explicit single-step execution.

public sealed class SteppableVirtualMachine
Inheritance
SteppableVirtualMachine
Inherited Members

Fields

DivisionByZeroExitCode

private const int DivisionByZeroExitCode = 206

Field Value

int

InputEofExitCode

private const int InputEofExitCode = 98

Field Value

int

InputFormatExitCode

private const int InputFormatExitCode = 97

Field Value

int

RuntimeErrorExitCode

private const int RuntimeErrorExitCode = 99

Field Value

int

b

private int b

Field Value

int

diagnostics

private readonly List<VmDiagnostic> diagnostics

Field Value

List<VmDiagnostic>

initialized

private bool initialized

Field Value

bool

io

private IPl0Io io

Field Value

IPl0Io

options

private VirtualMachineOptions options

Field Value

VirtualMachineOptions

p

private int p

Field Value

int

program

private IReadOnlyList<Instruction> program

Field Value

IReadOnlyList<Instruction>

stack

private int[] stack

Field Value

int[]

t

private int t

Field Value

int

Properties

IsRunning

Gets a value indicating whether execution can continue.

public bool IsRunning { get; private set; }

Property Value

bool

State

Gets the current VM state snapshot.

public VmState State { get; private set; }

Property Value

VmState

Methods

BinaryOp(Func<int, int, int>)

private bool BinaryOp(Func<int, int, int> op)

Parameters

op Func<int, int, int>

Returns

bool

CaptureState()

private VmState CaptureState()

Returns

VmState

ExecuteInstruction(Instruction)

private bool ExecuteInstruction(Instruction instruction)

Parameters

instruction Instruction

Returns

bool

ExecuteOpr(int)

private bool ExecuteOpr(int code)

Parameters

code int

Returns

bool

Initialize(IReadOnlyList<Instruction>, IPl0Io?, VirtualMachineOptions?)

Initializes the VM and resets state for debugging.

public void Initialize(IReadOnlyList<Instruction> program, IPl0Io? io = null, VirtualMachineOptions? options = null)

Parameters

program IReadOnlyList<Instruction>

P-Code instructions to execute.

io IPl0Io

Optional I/O abstraction.

options VirtualMachineOptions

Optional VM options.

IsValidStackIndex(int)

private bool IsValidStackIndex(int index)

Parameters

index int

Returns

bool

ResolveBase(int)

private int ResolveBase(int level)

Parameters

level int

Returns

int

Step()

Executes exactly one instruction.

public VmStepResult Step()

Returns

VmStepResult

Step result with updated state and status.

TryPeek(int)

private bool TryPeek(int index)

Parameters

index int

Returns

bool

TryPush()

private bool TryPush()

Returns

bool