exceptions.texi (2430B)
1 @node exceptions 2 @chapter Exceptional states 3 4 5 @section Ending execution 6 7 The @code{vise} VM will terminate execution when it runs out of bytecode. 8 9 There may be several different causes of this. 10 11 Each case described below references the way the Engine implementation handles an ending execution. 12 13 14 @subsection Halting 15 16 If the last instruction executed was @code{HALT}, the template of the node where execution terminated should be displayed. 17 18 If the template is missing or empty, the last value of the last returned unprocessed symbol from @code{LOAD} (or @code{RELOAD}) should be displayed instead. 19 20 If neither exists, it will be considered an @ref{abnormal_termination, abnormal termination} instead. 21 22 Otherwise, the execution is considered to have terminated gracefully. 23 24 After ending, VM run should start from the topmost node, equivalent to an @code{MOVE ^} instruction. 25 26 @anchor{abnormal_termination} 27 @subsection Termination 28 29 When the VM runs out of bytecode, and the last instruction execution was @emph{not} @code{HALT}, then the @code{TERMINATE} flag will be set. 30 31 This will block any future execution of the VM, until the @code{TERMINATE} flag has been explicitly reset. 32 33 34 @anchor{default_error} 35 @subsection Default error case 36 37 When encountering unhandled error states (e.g. external code that returns errors and thus sets @code{LOADFAIL}), the remaining bytecode is purged, and execution is moved to a builtin node called @code{_catch}. 38 39 The node has no bytecode by default. If encountered, and if no bytecode has been provided, execution will be stuck on the node @code{_catch} forever. 40 41 42 @subsection The @code{CROAK} instruction 43 44 The @code{CROAK} instruction may have one of two outcomes. 45 46 If encountered while not input (i.e. signal flag @code{READIN} is not set), this will cause a @ref{abnormal_termination, termination}. 47 48 Otherwise, it will execute the @ref{default_error, default error case}. 49 50 51 52 @section Resuming execution 53 54 Depending on the state of the execution end, certain explicit steps may be required. 55 56 57 @subsection Graceful exit 58 59 Execution will resume from the topmode node, and all flags that are not user-defined will have been reset. 60 61 62 @subsection After termination 63 64 The @code{TERMINATE} flag, once set, will block any further execution by the VM until it is cleared explicitly by code outside the VM (and the engine). 65 66 This is the case even if additional bytecode has been loaded into the state.