Commit | Line | Data |
---|---|---|
8a5ae618 MD |
1 | /* classes: h_files */ |
2 | ||
b29058ff DH |
3 | #ifndef SCM_SRCPROP_H |
4 | #define SCM_SRCPROP_H | |
5 | ||
6 | /* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc. | |
7 | * | |
8a5ae618 MD |
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. | |
b29058ff | 12 | * |
8a5ae618 MD |
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. | |
b29058ff | 17 | * |
8a5ae618 MD |
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 | |
82892bed JB |
20 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
21 | * Boston, MA 02111-1307 USA | |
8a5ae618 MD |
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 | |
82892bed | 48 | * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ |
d3a6bc94 | 49 | |
8a5ae618 MD |
50 | \f |
51 | ||
b4309c3c | 52 | #include "libguile/__scm.h" |
8a5ae618 MD |
53 | |
54 | \f | |
55 | ||
8a5ae618 MD |
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 | ||
9fec1f77 | 64 | #define scm_whash_get_handle(whash, key) scm_hash_fn_get_handle (whash, key, scm_ihashq, scm_sloppy_assq, 0) |
54778cd3 | 65 | #define SCM_WHASHFOUNDP(h) (!SCM_FALSEP (h)) |
8a5ae618 MD |
66 | #define SCM_WHASHREF(whash, handle) SCM_CDR (handle) |
67 | #define SCM_WHASHSET(whash, handle, obj) SCM_SETCDR (handle, obj) | |
9fec1f77 MD |
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) \ | |
d3a6bc94 | 71 | do { \ |
9fec1f77 MD |
72 | register SCM w = (whash); \ |
73 | SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \ | |
d3a6bc94 | 74 | } while (0) |
9fec1f77 | 75 | |
8a5ae618 MD |
76 | |
77 | /* {Source properties} | |
78 | */ | |
79 | ||
33b001fd | 80 | SCM_API scm_t_bits scm_tc16_srcprops; |
8a5ae618 | 81 | |
92c2555f | 82 | typedef struct scm_t_srcprops |
8a5ae618 MD |
83 | { |
84 | unsigned long pos; | |
85 | SCM fname; | |
86 | SCM copy; | |
87 | SCM plist; | |
92c2555f | 88 | } scm_t_srcprops; |
8a5ae618 MD |
89 | |
90 | #define SRCPROPS_CHUNKSIZE 2047 /* Number of srcprops per chunk */ | |
92c2555f | 91 | typedef struct scm_t_srcprops_chunk |
8a5ae618 | 92 | { |
92c2555f MV |
93 | struct scm_t_srcprops_chunk *next; |
94 | scm_t_srcprops srcprops[1]; | |
95 | } scm_t_srcprops_chunk; | |
1be6b49c | 96 | |
e038c042 DH |
97 | #define SCM_SOURCE_PROPERTY_FLAG_BREAK (1L << 16) |
98 | ||
e841c3e0 | 99 | #define SRCPROPSP(p) (SCM_TYP16_PREDICATE (scm_tc16_srcprops, p)) |
c96d76b8 | 100 | #define SRCPROPBRK(p) (SCM_CELL_WORD_0 (p) & SCM_SOURCE_PROPERTY_FLAG_BREAK) |
92c2555f | 101 | #define SRCPROPPOS(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->pos |
8a5ae618 MD |
102 | #define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12) |
103 | #define SRCPROPCOL(p) (SRCPROPPOS(p) & 0x0fffL) | |
92c2555f MV |
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 | |
e038c042 DH |
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)) | |
8a5ae618 MD |
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 | ||
b29058ff | 118 | #define SRCBRKP(x) (!SCM_IMP (t.arg1 = scm_whash_lookup (scm_source_whash, (x)))\ |
8a5ae618 | 119 | && SRCPROPSP (t.arg1)\ |
c96d76b8 | 120 | && SRCPROPBRK (t.arg1)) |
8a5ae618 | 121 | |
b29058ff | 122 | #define PROCTRACEP(x) (!SCM_FALSEP (scm_procedure_property (x, scm_sym_trace))) |
8a5ae618 | 123 | |
33b001fd MV |
124 | SCM_API SCM scm_sym_filename; |
125 | SCM_API SCM scm_sym_copy; | |
126 | SCM_API SCM scm_sym_line; | |
127 | SCM_API SCM scm_sym_column; | |
128 | SCM_API SCM scm_sym_breakpoint; | |
34019bd6 | 129 | |
8a5ae618 MD |
130 | \f |
131 | ||
1cc91f1b | 132 | |
33b001fd MV |
133 | SCM_API SCM scm_srcprops_to_plist (SCM obj); |
134 | SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist); | |
135 | SCM_API SCM scm_source_property (SCM obj, SCM key); | |
136 | SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum); | |
137 | SCM_API SCM scm_source_properties (SCM obj); | |
138 | SCM_API SCM scm_set_source_properties_x (SCM obj, SCM props); | |
139 | SCM_API void scm_finish_srcprop (void); | |
140 | SCM_API void scm_init_srcprop (void); | |
8a5ae618 | 141 | |
b29058ff | 142 | #endif /* SCM_SRCPROP_H */ |
89e00824 ML |
143 | |
144 | /* | |
145 | Local Variables: | |
146 | c-file-style: "gnu" | |
147 | End: | |
148 | */ |