Table of Contents

Interface IExecutionGate

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

Where a program waits when it is stopped, if it is to be resumed.

public interface IExecutionGate

Remarks

A program cannot be resumed from what it leaves behind when it is unwound. A Stop in a function that is called in the middle of an expression has half of the statement that called it evaluated, and the interpreter has nothing that holds half a statement: the state of the program is its call stack and the program counter of each activation, and the rest is on the stack of whoever is evaluating. So a program that is to be resumed does not leave: it waits where it is, and the thread it runs on is held by Suspend(RuntimeHaltKind, SourceLocation?) until the answer comes.

Whoever runs the program on a thread of its own installs a gate in Gate; nothing else needs to know that there is one. A program that is run without one cannot be resumed, and a Stop unwinds it. While no program runs, the gate is the session's: it takes the stops of the handlers of the session's events (RunsAnEventOfTheSession).

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

Methods

Suspend(RuntimeHaltKind, SourceLocation?)

Holds the calling thread until it is told what to do, when that thread runs the program's code: the program's own thread, or a thread that runs the handlers of an event of the program (RunsAnEventOfTheProgram). With no program running, a thread that runs the handlers of an event of the session (RunsAnEventOfTheSession) is held the same way, when a client takes its stop.

SuspensionDecision Suspend(RuntimeHaltKind kind, SourceLocation? location)

Parameters

kind RuntimeHaltKind

Why the program is stopped.

location SourceLocation?

The statement that stopped it, or null when it was not one.

Returns

SuspensionDecision

What to do with the program.

Remarks

A modal form's Show is a call the program waits in, and a click on the form is an event of the program, handled on the thread of the form's window: a Stop or a breakpoint in its handler, or in anything that handler calls, stops the program there, as it does in MS-VBA. While it waits, such a thread makes the calls asked of it (ServeOfTheCallingThread), so that a debugger that reads a control of the form is answered; it handles no event of the program meanwhile (Stopped()).

A form can be shown when no program runs: by a statement typed at the prompt, or by a macro that left it shown when it ended. A click on it is an event of the session, handled on the thread of the form's window, and a Stop or a breakpoint in its handler enters break mode as it does in MS-VBA. No request runs that handler, so the host asks the language server whether a client takes the stop (rdcore/host/debug/stopped); a client that takes it resumes or ends it. When no client takes it, the answer is Abandon, at once: the handler is unwound, and nothing waits.

Any other thread (code that runs beside the program that waits, such as an expression a debugger evaluates, or the handlers of an event that code's calls raised) is not held: it is answered Abandon, which stops that code and not the program.