interpreter

Function interpreter 

Source
pub unsafe fn interpreter(
    st: &mut State,
    start: Utf8Iter<'_>,
    io: Arc<Mutex<IOStreams>>,
    ll: LogLevel,
    kill: Option<&Receiver<()>>,
    restrict: bool,
) -> Result<ExecResult>
Expand description

Interpreter entry point, executes ADC commands to modify state.

§Arguments

  • st: State struct to work on, modified in-place
  • start: Initial commands to run
  • io: Bundle of IO stream handles
    • io.0: Input, read by ? one line at a time
    • io.1: Output, written to by printing commands
    • io.2: Error messages, one per line
  • ll: Level of verbosity for io.2
  • kill: Receiver for a kill signal from a parent thread, effect is practically immediate. Some(_) will also enable restrict.
  • restrict: Restricted mode switch, enable for untrusted input. If false, the interpreter may read/write files and execute OS commands, subject to any OS-level permissions.

§Errors

Any IO errors (except those specified here) that arise when accessing the IOStreams are returned early, aborting the interpreter.

This will result in an incomplete, although internally consistent, State. Keep that possibility to a minimum when preparing custom IOStreams.

§Safety

If built without the no_os feature (default), passing kill = None and restrict = false enables OS interactions that are fundamentally unsound in multithreaded contexts.

Simultaneously/asynchronously executing multiple instances of this function with said arguments is Undefined Behavior. Do not rely on known values of st and start for safety.

Alternatively, interpreter_no_os provides a safe wrapper.