Table of Contents

Interface IRuntimeSession

Namespace
RDCore.SDK.Runtime.Abstract.Execution
Assembly
RDCore.SDK.dll

The root of an execution session. A single session holds the statically-defined symbols and, depending on the host mode, serves as the run-time or break (debug) session — it is independent of the host's current mode.

public interface IRuntimeSession
Extension Methods

Remarks

⚖️RDCore provides an implementation of this interface licensed under GPLv3.

Properties

CallStack

The session's call stack — pushing and popping an ICallStackFrame per procedure activation is what makes a procedure's locals and parameters visible through ISessionSymbols's Resolver (RD-VBAL §2.3.1.2's local stack frame heap tier).

ICallStack CallStack { get; }

Property Value

ICallStack

Callables

What binds a member to the code that runs it, as the pipeline composed last has it, or null while nothing can run code against the session yet. Set by whatever composes the execution pipeline. It is what runs the procedure that handles an event which something outside the workspace raises, when no program is calling.

ICallableBindingFactory? Callables { get; set; }

Property Value

ICallableBindingFactory

Clock

The calendar and the clock of the standard library's DateTime module (MS-VBAL §6.1.2.4.2), which outlive the call that sets them.

ISessionClock Clock { get; }

Property Value

ISessionClock

Environment

The host environment this session runs in — bitness (Environment.Is64Bit drives LongPtr width and #If Win64 / #If VBA7), locale, code page, …

IRuntimeEnvironmentProfile Environment { get; }

Property Value

IRuntimeEnvironmentProfile

Errors

The session's error state — what the Err object reports (MS-VBAL §6.1.3.2), and what outlives the activation that raised it.

ISessionErrorState Errors { get; }

Property Value

ISessionErrorState

External

What reaches everything that is not the workspace's own code, or null while nothing can run a call against the session yet. Set by whatever composes the execution pipeline. It is what New asks to create an object of a referenced library.

IExternalDispatcher? External { get; set; }

Property Value

IExternalDispatcher

ExternalObjects

The objects of this session that something outside the workspace owns, and who owns them.

ISessionExternalObjects ExternalObjects { get; }

Property Value

ISessionExternalObjects

Files

The file numbers this session has open (MS-VBAL §5.4.5).

IFileChannels Files { get; }

Property Value

IFileChannels

Remarks

Session-scoped because the association an Open makes "remains in effect until... explicitly disassociated using a close-statement" - it outlives the procedure that opened it.

Halt

Whether the program has been stopped by an End or a Stop statement, or from outside, and why.

ISessionHalt Halt { get; }

Property Value

ISessionHalt

Libraries

The descriptions of the libraries the environment has, whether the project references them or not; null when it was given none.

ILibrarySource? Libraries { get; }

Property Value

ILibrarySource

Remarks

The libraries the project references are its symbols already (Symbols). This is what the facts for tooling read of a library it does not reference - the class of an object a program creates by name (ObjectCreationFact) - and it is never a name the code can use.

Lifecycle

What raises the lifecycle events of the session's objects, or null while nothing can run user code against the session yet — a session whose symbols are only being defined. Set by whatever composes the execution pipeline, which is what the handlers run through.

IObjectLifecycle? Lifecycle { get; set; }

Property Value

IObjectLifecycle

Remarks

While it is null, ReleaseReference(VBRuntimeObjectId, IBindingHandle) destroys an object that has no references left without raising Terminate.

Memory

The session's memory allocator — tracks allocation size and fragmentation, MSVBVM-style.

ISessionMemoryAllocator Memory { get; }

Property Value

ISessionMemoryAllocator

Objects

The session's object lifetime manager.

ISessionObjects Objects { get; }

Property Value

ISessionObjects

Output

Where this session's Print output goes (MS-VBAL §5.4.5.8) — the Immediate window's analogue. NullRuntimeOutput when the session was composed without one, so a Debug.Print is a no-op rather than an error.

IRuntimeOutput Output { get; }

Property Value

IRuntimeOutput

RandomNumbers

The state of the standard library's random-number generator (MS-VBAL §6.1.2.10), which outlives the call that seeds it.

ISessionRandomNumberGenerator RandomNumbers { get; }

Property Value

ISessionRandomNumberGenerator

References

The workspace's references in declaration order (RD-VBAL §2.3.1.2): index 0 appears first and is the lowest precedence (the VBA standard library), so a later entry shadows it on a global-scope name collision. This is the precedence order only — a reference's members are resolved through ISymbolResolver, not from here. Preserved exactly as the language server provides it; empty when the session was composed without a project (e.g. a bare REPL).

IReadOnlyList<ReferencePriorityInfo> References { get; }

Property Value

IReadOnlyList<ReferencePriorityInfo>

Storage

The session's value storage — what is bound at each address its allocator handed out.

ISessionStorage Storage { get; }

Property Value

ISessionStorage

Remarks

Reachable from the session because direct, byte-level access to a session's memory is a session-level operation: a debugger reading a variable's bytes, a PEEK, a POKE. Ordinary name-based reads and writes go through Resolver instead.

Symbols

The session's symbol table.

ISessionSymbols Symbols { get; }

Property Value

ISessionSymbols

Turn

Whose turn it is to run code in this session: the program, or an event that something outside the workspace raised.

ISessionTurn Turn { get; }

Property Value

ISessionTurn

Methods

ReleaseReference(VBRuntimeObjectId, IBindingHandle)

Drops handle's reference to instance and, if that was its last remaining reference, destroys the object: frees the storage its live instance allocated (DestroyInstance(VBRuntimeObjectId)) and forgets it (TryRemoveObject(VBRuntimeObjectId)).

bool ReleaseReference(VBRuntimeObjectId instance, IBindingHandle handle)

Parameters

instance VBRuntimeObjectId
handle IBindingHandle

Returns

bool

true if the object was destroyed as a result of this call.

Remarks

This is the only correct way to drop a reference — calling RemoveRef(VBRuntimeObjectId, IBindingHandle) directly leaves the instance's field storage allocated forever once the count reaches zero, since nothing else would go on to call DestroyInstance(VBRuntimeObjectId) for it.