# HG changeset patch # User Paul Boddie # Date 1386522272 -3600 # Node ID 54289e78af86253ac5d3a0364ac9881d66be9525 # Parent 5d8bc0f435248e148c4de530b2fb826320563a16 Moved the exceptions document into the low-level concepts document. diff -r 5d8bc0f43524 -r 54289e78af86 docs/exceptions.txt --- a/docs/exceptions.txt Sun Dec 08 18:00:53 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -Exception Handling -================== - -Active Exceptions -================= - -When an exception is raised, an exception instance is defined as the active -exception. This active exception remains in force until either a new exception -is raised in any handling of the exception, or upon exit of a handler where -the active exception has been caught (thus resetting the active exception). - -NOTE: Currently, if classes are used with "raise" statements, no instantiation -NOTE: of such classes occurs. This should be remedied. - -Instructions ------------- - -StoreException records the current value reference using the exception -register. - -LoadException obtains the current exception and puts it in the value register. - -CheckException checks the current exception against a class referenced by the -current value. - -ClearException resets the exception register. - -Handlers -======== - -An exception handler stack is defined such that when a try...except or -try...finally block is entered, a new handler is defined. - -When an exception is raised, the program jumps to the most recently defined -handler. Inside the handler, the stack entry for the handler will be removed. - -Depending on the nature of the handler and whether the exception is handled, -the program may jump to the next most recent handler, and so on. - -If no handler is defined when an exception is raised or re-raised, the program -should terminate. This might be done by having a "handler #0" which explicitly -terminates the program. - -Instructions ------------- - -PushHandler(block) defines an active handler at the location indicated by the -given block. - -PopHandler(n) removes the n topmost active handlers. A single handler is -typically removed when leaving a try block, but potentially more handlers are -removed when such a block is exited using a return statement. diff -r 5d8bc0f43524 -r 54289e78af86 docs/lowlevel.txt --- a/docs/lowlevel.txt Sun Dec 08 18:00:53 2013 +0100 +++ b/docs/lowlevel.txt Sun Dec 08 18:04:32 2013 +0100 @@ -11,6 +11,7 @@ * Instantiation * List and tuple representations * Instruction evaluation model + * Exception handling Objects and Structures ====================== @@ -363,3 +364,51 @@ Using the approach where arguments are treated like attributes in some kind of structure, we could choose to allocate frames in places other than a stack. This would produce something somewhat similar to a plain tuple object. + +Exception Handling +================== + +Active Exceptions +----------------- + +When an exception is raised, an exception instance is defined as the active +exception. This active exception remains in force until either a new exception +is raised in any handling of the exception, or upon exit of a handler where +the active exception has been caught (thus resetting the active exception). + +The following operations can be employed to achieve this: + +StoreException records the current value reference using the exception +register. + +LoadException obtains the current exception and puts it in the value register. + +CheckException checks the current exception against a class referenced by the +current value. + +ClearException resets the exception register. + +Handlers +-------- + +An exception handler stack is defined such that when a try...except or +try...finally block is entered, a new handler is defined. + +When an exception is raised, the program jumps to the most recently defined +handler. Inside the handler, the stack entry for the handler will be removed. + +Depending on the nature of the handler and whether the exception is handled, +the program may jump to the next most recent handler, and so on. + +If no handler is defined when an exception is raised or re-raised, the program +should terminate. This might be done by having a "handler #0" which explicitly +terminates the program. + +The following operations can be employed to achieve this: + +PushHandler(block) defines an active handler at the location indicated by the +given block. + +PopHandler(n) removes the n topmost active handlers. A single handler is +typically removed when leaving a try block, but potentially more handlers are +removed when such a block is exited using a return statement.