Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: xref.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)xref.fth 1.2 03/12/08 13:22:28 | |
43 | purpose: | |
44 | copyright: Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | \ XREF enables the whole thing. | |
48 | [ifdef] XREF | |
49 | ||
50 | \ We can't use the d# operators because they don't always exist | |
51 | \ when we load this.. | |
52 | ||
53 | defer xref-prev-include-hook ' noop is xref-prev-include-hook | |
54 | defer xref-prev-include-exit-hook ' noop is xref-prev-include-exit-hook | |
55 | decimal | |
56 | ||
57 | : xref-push-file ( str,len -- str,len ) | |
58 | true 50 45 fsyscall | |
59 | xref-prev-include-hook | |
60 | ; | |
61 | ||
62 | : xref-pop-file ( -- ) | |
63 | false 50 45 fsyscall | |
64 | xref-prev-include-exit-hook | |
65 | ; | |
66 | ||
67 | : (xref-notify) ( str,len ref? -- str,len ) 49 45 fsyscall ; | |
68 | ||
69 | : xref-state ( n -- ) 51 45 fsyscall ; | |
70 | ||
71 | \ If source-id has been set to 0 or -1 | |
72 | \ (as by evaluate or in user-interpretation state) | |
73 | \ an attempt to get a line # will crash. | |
74 | : xref-line#? ( -- n true | false ) | |
75 | source-id dup 0= over -1 = or if | |
76 | drop false | |
77 | exit then | |
78 | file-line true | |
79 | ; | |
80 | ||
81 | : (xref-definition) ( str,len -- str,len ) xref-line#? if 1 (xref-notify) then ; | |
82 | : (xref-reference) ( str,len -- str,len ) xref-line#? if 0 (xref-notify) then ; | |
83 | : (xref-hide) ( str,len -- str,len ) 2 (xref-notify) ; | |
84 | : (xref-reveal) ( str,len -- str,len ) 3 (xref-notify) ; | |
85 | : (xref-string) ( str,len -- str,len ) xref-line#? if 4 (xref-notify) then ; | |
86 | ||
87 | : xref-init ( -- ok? ) -1 xref-state ; | |
88 | ||
89 | \ Defined in the host; needed in meta-compilation-target | |
90 | \ so "IS" won't get confused | |
91 | [ifnexist] include-hook | |
92 | headers | |
93 | defer include-hook ' noop is include-hook | |
94 | defer include-exit-hook ' noop is include-exit-hook | |
95 | headerless | |
96 | [then] | |
97 | ||
98 | : (xref-on) ( -- ) | |
99 | ['] include-hook behavior is xref-prev-include-hook | |
100 | ['] include-exit-hook behavior is xref-prev-include-exit-hook | |
101 | ['] xref-push-file is include-hook | |
102 | ['] xref-pop-file is include-exit-hook | |
103 | ['] (xref-definition) is xref-header-hook | |
104 | ['] (xref-reference) is xref-find-hook | |
105 | ['] (xref-hide) is xref-hide-hook | |
106 | ['] (xref-reveal) is xref-reveal-hook | |
107 | ['] (xref-string) is xref-string-hook | |
108 | ['] noop is xref-on | |
109 | 1 xref-state | |
110 | ; | |
111 | ||
112 | : (xref-off) ( -- ) | |
113 | ['] (xref-on) is xref-on | |
114 | ['] xref-prev-include-hook behavior is include-hook | |
115 | ['] xref-prev-include-exit-hook behavior is include-exit-hook | |
116 | ['] noop ( acf ) | |
117 | dup is xref-header-hook ( acf ) | |
118 | dup is xref-find-hook ( acf ) | |
119 | dup is xref-hide-hook ( acf ) | |
120 | dup is xref-reveal-hook ( acf ) | |
121 | dup is xref-string-hook ( acf ) | |
122 | drop ( ) | |
123 | 0 xref-state ( ) | |
124 | ; | |
125 | hex | |
126 | ||
127 | ' (xref-off) is xref-off | |
128 | ' (xref-on) is xref-on | |
129 | [then] |