2002-07-20 Han-Wen <hanwen@cs.uu.nl>
[bpt/guile.git] / libguile / srcprop.h
1 /* classes: h_files */
2
3 #ifndef SCM_SRCPROP_H
4 #define SCM_SRCPROP_H
5
6 /* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this software; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
22 *
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
25 *
26 * The exception is that, if you link the GUILE library with other files
27 * to produce an executable, this does not by itself cause the
28 * resulting executable to be covered by the GNU General Public License.
29 * Your use of that executable is in no way restricted on account of
30 * linking the GUILE library code into it.
31 *
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
34 *
35 * This exception applies only to the code released by the
36 * Free Software Foundation under the name GUILE. If you copy
37 * code from other Free Software Foundation releases into a copy of
38 * GUILE, as the General Public License permits, the exception does
39 * not apply to the code that you add in this way. To avoid misleading
40 * anyone as to the status of such modified files, you must delete
41 * this exception notice from them.
42 *
43 * If you write modifications of your own for GUILE, it is your choice
44 * whether to permit this exception to apply to your modifications.
45 * If you do not wish that, delete this exception notice.
46 *
47 * The author can be reached at djurfeldt@nada.kth.se
48 * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
49
50 \f
51
52 #include "libguile/__scm.h"
53
54 \f
55
56 /* {The old whash table interface}
57 * *fixme* This is a temporary solution until weak hash table access
58 * has been optimized for speed (which is quite necessary, if they are
59 * used for recording of source code positions...)
60 */
61
62 #define scm_whash_handle SCM
63
64 #define scm_whash_get_handle(whash, key) scm_hash_fn_get_handle (whash, key, scm_ihashq, scm_sloppy_assq, 0)
65 #define SCM_WHASHFOUNDP(h) (!SCM_FALSEP (h))
66 #define SCM_WHASHREF(whash, handle) SCM_CDR (handle)
67 #define SCM_WHASHSET(whash, handle, obj) SCM_SETCDR (handle, obj)
68 #define scm_whash_create_handle(whash, key) scm_hash_fn_create_handle_x (whash, key, SCM_UNSPECIFIED, scm_ihashq, scm_sloppy_assq, 0)
69 #define scm_whash_lookup(whash, obj) scm_hash_fn_ref (whash, obj, SCM_BOOL_F, scm_ihashq, scm_sloppy_assq, 0)
70 #define scm_whash_insert(whash, key, obj) \
71 do { \
72 register SCM w = (whash); \
73 SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \
74 } while (0)
75
76
77 /* {Source properties}
78 */
79
80 SCM_API scm_t_bits scm_tc16_srcprops;
81
82 typedef struct scm_t_srcprops
83 {
84 unsigned long pos;
85 SCM fname;
86 SCM copy;
87 SCM plist;
88 } scm_t_srcprops;
89
90 #define SRCPROPS_CHUNKSIZE 2047 /* Number of srcprops per chunk */
91 typedef struct scm_t_srcprops_chunk
92 {
93 struct scm_t_srcprops_chunk *next;
94 scm_t_srcprops srcprops[1];
95 } scm_t_srcprops_chunk;
96
97 #define SCM_SOURCE_PROPERTY_FLAG_BREAK (1L << 16)
98
99 #define SRCPROPSP(p) (SCM_TYP16_PREDICATE (scm_tc16_srcprops, p))
100 #define SRCPROPBRK(p) (SCM_CELL_WORD_0 (p) & SCM_SOURCE_PROPERTY_FLAG_BREAK)
101 #define SRCPROPPOS(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->pos
102 #define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12)
103 #define SRCPROPCOL(p) (SRCPROPPOS(p) & 0x0fffL)
104 #define SRCPROPFNAME(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->fname
105 #define SRCPROPCOPY(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->copy
106 #define SRCPROPPLIST(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->plist
107 #define SETSRCPROPBRK(p) \
108 (SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) \
109 | SCM_SOURCE_PROPERTY_FLAG_BREAK))
110 #define CLEARSRCPROPBRK(p) \
111 (SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) \
112 & ~SCM_SOURCE_PROPERTY_FLAG_BREAK))
113 #define SRCPROPMAKPOS(l, c) (((l) << 12) + (c))
114 #define SETSRCPROPPOS(p, l, c) (SRCPROPPOS (p) = SRCPROPMAKPOS (l, c))
115 #define SETSRCPROPLINE(p, l) SETSRCPROPPOS (p, l, SRCPROPCOL (p))
116 #define SETSRCPROPCOL(p, c) SETSRCPROPPOS (p, SRCPROPLINE (p), c)
117
118 #define PROCTRACEP(x) (!SCM_FALSEP (scm_procedure_property (x, scm_sym_trace)))
119
120 SCM_API SCM scm_sym_filename;
121 SCM_API SCM scm_sym_copy;
122 SCM_API SCM scm_sym_line;
123 SCM_API SCM scm_sym_column;
124 SCM_API SCM scm_sym_breakpoint;
125
126 \f
127
128 SCM_API int scm_c_source_property_breakpoint_p (SCM form);
129 SCM_API SCM scm_srcprops_to_plist (SCM obj);
130 SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist);
131 SCM_API SCM scm_source_property (SCM obj, SCM key);
132 SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum);
133 SCM_API SCM scm_source_properties (SCM obj);
134 SCM_API SCM scm_set_source_properties_x (SCM obj, SCM props);
135 SCM_API void scm_finish_srcprop (void);
136 SCM_API void scm_init_srcprop (void);
137
138 #if SCM_ENABLE_DEPRECATED == 1
139 #define SRCBRKP(x) (scm_source_property_breakpoint_p (x))
140 #endif
141
142 #endif /* SCM_SRCPROP_H */
143
144 /*
145 Local Variables:
146 c-file-style: "gnu"
147 End:
148 */