File: exception.fs

package info (click to toggle)
gforth 0.7.2%2Bdfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,332 kB
  • ctags: 2,064
  • sloc: ansic: 8,506; sh: 3,643; lisp: 1,780; makefile: 984; yacc: 186; sed: 141; lex: 102; awk: 21
file content (37 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
\ exception

\ This file is in the public domain. NO WARRANTY.

\ this implementation tries to be as close to the following proposal
\ as possible (we cannot guarantee unusedness nor are we allowed to
\ use values in the range -4095..-256).

\ EXCEPTION ( c-addr u -- n ) exception

\ n is a previously unused THROW value in the range
\ {-4095...-256}. Consecutive calls to EXCEPTION return consecutive
\ decreasing numbers.

\ The system may use the string denoted by c-addr u when reporting
\ that exception (if it is not caught).

\ Typical Use

\ s" Out of GC-managed memory" EXCEPTION CONSTANT gc-out-of-memory
\ ...
\ ... gc-out-of-memory THROW ...

\ The program uses the following words
\ from CORE :
\ Variable ! : 2drop @ +! ; 
\ from BLOCK-EXT :
\ \ 
\ from FILE :
\ ( 

variable next-exception -10753 next-exception !

: exception ( c-addr u -- n )
    2drop
    next-exception @
    -1 next-exception +! ;