]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
28bf4b0b | 2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. |
885824d3 | 3 | ** See ../LICENSE for license information. |
4 | ** | |
5 | */ | |
6 | /* | |
7 | ** fileloc.h | |
8 | */ | |
9 | ||
10 | # ifndef FILELOC_H | |
11 | # define FILELOC_H | |
12 | ||
13 | # include "fileId.h" | |
14 | ||
15 | typedef enum | |
16 | { | |
17 | FL_NORMAL, FL_SPEC, FL_LIB, FL_STDLIB, FL_STDHDR, FL_IMPORT, FL_BUILTIN, | |
bb25bea6 | 18 | FL_PREPROC, FL_RC, FL_EXTERNAL |
885824d3 | 19 | } flkind; |
20 | ||
28bf4b0b | 21 | struct s_fileloc |
885824d3 | 22 | { |
23 | flkind kind; | |
24 | fileId fid; | |
25 | int lineno; | |
26 | int column; | |
27 | } ; | |
28 | ||
29 | /* typedef in forwardTypes */ | |
30 | typedef /*@only@*/ fileloc o_fileloc; | |
31 | ||
32 | extern fileloc fileloc_update (/*@only@*/ fileloc p_old, fileloc p_fnew) | |
33 | /*@modifies p_old@*/ ; | |
34 | ||
35 | extern fileloc fileloc_create (fileId p_fid, int p_line, int p_col) /*@*/ ; | |
36 | extern bool fileloc_isSystemFile (fileloc p_f1) /*@*/ ; | |
28bf4b0b | 37 | extern bool fileloc_isXHFile (fileloc p_f1) /*@*/ ; |
885824d3 | 38 | |
39 | # ifndef NOLCL | |
40 | extern fileloc fileloc_createSpec (fileId p_fid, int p_line, int p_col) /*@*/ ; | |
41 | # endif | |
42 | ||
43 | extern fileloc fileloc_createLib (cstring p_ln) /*@*/ ; | |
44 | extern fileloc fileloc_createRc (cstring p_name) /*@*/ ; | |
45 | extern fileloc fileloc_decColumn (fileloc p_f, int p_x) /*@*/ ; | |
46 | extern void fileloc_subColumn (fileloc p_f, int p_x) /*@modifies p_f@*/ ; | |
47 | extern fileloc fileloc_getBuiltin (void) /*@*/ ; | |
48 | extern /*@observer@*/ fileloc fileloc_observeBuiltin (void) /*@*/ ; | |
49 | extern fileloc fileloc_createBuiltin (void) /*@*/ ; | |
50 | ||
51 | # ifndef NOLCL | |
52 | extern fileloc fileloc_createImport (cstring p_fname, int p_lineno) /*@*/ ; | |
53 | # endif | |
54 | ||
55 | extern bool fileloc_isSpecialFile (fileloc p_f) /*@*/ ; | |
56 | extern bool fileloc_sameBaseFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
57 | extern /*@observer@*/ cstring fileloc_filename (fileloc p_f) /*@*/ ; | |
58 | extern int fileloc_column (fileloc p_f) /*@*/ ; | |
28bf4b0b | 59 | extern cstring fileloc_unparse (fileloc p_f) /*@*/ ; |
885824d3 | 60 | extern cstring fileloc_unparseRaw (cstring p_fname, int p_lineno) /*@*/ ; |
61 | extern cstring fileloc_unparseRawCol (cstring p_fname, int p_lineno, int p_col) /*@*/ ; | |
62 | extern bool fileloc_sameFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
28bf4b0b | 63 | extern bool fileloc_sameFileAndLine (fileloc p_f1, fileloc p_f2) /*@*/ ; |
885824d3 | 64 | extern void fileloc_free (/*@only@*/ fileloc p_f); |
65 | extern void fileloc_reallyFree (/*@only@*/ fileloc p_f); | |
66 | extern int fileloc_lineno (fileloc p_f) /*@*/ ; | |
67 | extern bool fileloc_equal (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
68 | extern bool fileloc_lessthan (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
69 | extern int fileloc_compare (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
70 | extern /*@observer@*/ cstring fileloc_getBase (fileloc p_f) /*@*/ ; | |
71 | extern bool fileloc_isHeader (fileloc p_f) /*@*/ ; | |
72 | extern bool fileloc_isSpec (fileloc p_f) /*@*/ ; | |
73 | extern bool fileloc_isRealSpec (fileloc p_f) /*@*/ ; | |
74 | extern fileloc fileloc_copy (fileloc p_f) /*@*/ ; | |
75 | extern cstring fileloc_unparseDirect (fileloc p_fl) /*@*/ ; | |
76 | extern bool fileloc_notAfter (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
77 | extern bool fileloc_almostSameFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
78 | extern fileloc fileloc_noColumn (fileloc p_f) /*@*/ ; | |
79 | extern /*@observer@*/ fileloc fileloc_getExternal (void) /*@*/ ; | |
80 | extern fileloc fileloc_createExternal (void) /*@*/ ; | |
81 | ||
82 | extern bool fileloc_isExternal (/*@sef@*/ fileloc p_f) /*@*/; | |
83 | # define fileloc_isExternal(f) \ | |
84 | (fileloc_isDefined(f) && ((f)->kind == FL_EXTERNAL)) | |
85 | ||
86 | extern /*@falsenull@*/ bool fileloc_isDefined (/*@null@*/ fileloc p_f) /*@*/ ; | |
87 | extern /*@truenull@*/ bool fileloc_isUndefined (/*@null@*/ fileloc p_f) /*@*/ ; | |
88 | extern bool fileloc_isInvalid (/*@sef@*/ /*@null@*/ fileloc p_f) /*@*/ ; | |
89 | ||
90 | /*@constant null fileloc fileloc_undefined; @*/ | |
28bf4b0b | 91 | # define fileloc_undefined ((fileloc) NULL) |
885824d3 | 92 | # define fileloc_isDefined(f) ((f) != fileloc_undefined) |
93 | # define fileloc_isUndefined(f) ((f) == fileloc_undefined) | |
94 | # define fileloc_isInvalid(f) (!(fileloc_isValid(f))) | |
95 | ||
96 | extern bool fileloc_isLib (fileloc p_f) /*@*/ ; | |
885824d3 | 97 | |
98 | # ifndef NOLCL | |
99 | extern fileloc fileloc_fromTok (ltoken p_t) /*@*/ ; | |
100 | # endif | |
101 | ||
102 | /*@constant int UNKNOWN_LINE; @*/ | |
103 | # define UNKNOWN_LINE (0) | |
104 | ||
105 | /*@constant int UNKNOWN_COLUMN; @*/ | |
106 | # define UNKNOWN_COLUMN (0) | |
107 | ||
108 | extern /*@unused@*/ bool fileloc_linenoDefined (/*@sef@*/ fileloc p_f) /*@*/ ; | |
109 | extern /*@unused@*/ bool fileloc_columnDefined (/*@sef@*/ fileloc p_f) /*@*/ ; | |
110 | ||
111 | # define fileloc_linenoDefined(f) \ | |
112 | (fileloc_isValid (f) && (f)->lineno != UNKNOWN_LINE) | |
113 | ||
114 | # define fileloc_columnDefined(f) \ | |
115 | (fileloc_isValid (f) && (f)->column != UNKNOWN_COLUMN) | |
116 | ||
117 | # ifndef NOLCL | |
118 | extern void fileloc_setColumnUndefined (/*@sef@*/ fileloc p_f) /*@modifies p_f@*/; | |
119 | # define fileloc_setColumnUndefined(f) \ | |
120 | (fileloc_isDefined(f) ? (f)->column = UNKNOWN_COLUMN : UNKNOWN_COLUMN) | |
121 | # endif | |
122 | ||
123 | extern /*@falsenull@*/ bool fileloc_isValid (/*@sef@*/ fileloc p_f); | |
124 | # define fileloc_isValid(f) \ | |
125 | (fileloc_isDefined(f) && ((f)->lineno >= 0)) | |
126 | ||
127 | extern bool fileloc_isImport (/*@sef@*/ fileloc p_fl); | |
128 | # define fileloc_isImport(fl) (fileloc_isDefined(fl) && (fl)->kind == FL_IMPORT) | |
129 | ||
130 | extern bool fileloc_isPreproc (/*@sef@*/ fileloc p_fl); | |
131 | # define fileloc_isPreproc(fl) (fileloc_isDefined(fl) && (fl)->kind == FL_PREPROC) | |
132 | ||
133 | extern void fileloc_setLineno (/*@sef@*/ fileloc p_f, int p_i) /*@modifies p_f@*/ ; | |
134 | # define fileloc_setLineno(fl, i) \ | |
135 | (fileloc_isDefined(fl) ? ((fl)->lineno = (i), (fl)->column = 1) : (i)) | |
136 | ||
137 | extern void fileloc_nextLine (/*@sef@*/ fileloc p_f) /*@modifies p_f@*/ ; | |
138 | # define fileloc_nextLine(fl) \ | |
139 | (fileloc_isDefined(fl) ? ((fl)->lineno++, (fl)->column = 1) : 0) | |
140 | ||
141 | extern void fileloc_addLine (/*@sef@*/ fileloc p_f, int p_i) /*@modifies p_f@*/ ; | |
142 | # define fileloc_addLine(fl, i) \ | |
143 | (fileloc_isDefined(fl) ? ((fl)->lineno += (i), (fl)->column = 1) : (i)) | |
144 | ||
145 | extern fileId fileloc_fileId (/*@sef@*/ fileloc p_fl) /*@*/ ; | |
146 | # define fileloc_fileId(fl) \ | |
147 | (fileloc_isDefined (fl) ? (fl)->fid : fileId_invalid) | |
148 | ||
149 | extern void fileloc_setColumn (/*@sef@*/ fileloc p_fl, int p_i) /*@modifies p_fl@*/ ; | |
150 | # define fileloc_setColumn(fl, i) \ | |
151 | (fileloc_isDefined (fl) ? ((fl)->column = (i)) : (i)) | |
152 | ||
153 | extern void fileloc_addColumn (/*@sef@*/ fileloc p_fl, int p_i) /*@modifies p_fl@*/ ; | |
154 | # define fileloc_addColumn(fl, i) \ | |
155 | (fileloc_isDefined (fl) ? ((fl)->column += (i)) : (i)) | |
156 | ||
157 | extern void fileloc_incColumn (/*@sef@*/ fileloc p_fl) /*@modifies p_fl@*/ ; | |
158 | # define fileloc_incColumn(fl) \ | |
159 | (fileloc_isDefined (fl) ? ((fl)->column++) : 0) | |
160 | ||
161 | extern bool fileloc_isBuiltin (/*@sef@*/ fileloc p_fl) /*@*/ ; | |
162 | # define fileloc_isBuiltin(fl) \ | |
163 | (fileloc_isDefined (fl) && ((fl)->kind == FL_BUILTIN)) | |
164 | ||
165 | extern fileloc fileloc_updateFileId (/*@only@*/ fileloc p_old, fileId p_s) /*@*/ ; | |
166 | extern fileloc fileloc_makePreproc (fileloc p_loc) /*@*/ ; | |
167 | extern fileloc fileloc_makePreprocPrevious (fileloc p_loc) /*@*/ ; | |
168 | ||
885824d3 | 169 | extern bool fileloc_isStandardLibrary (fileloc p_f) /*@*/ ; |
885824d3 | 170 | extern bool fileloc_isStandardLib (fileloc p_f) /*@*/ ; |
28bf4b0b | 171 | |
885824d3 | 172 | extern cstring fileloc_unparseFilename (fileloc p_f) /*@*/ ; |
173 | extern bool fileloc_withinLines (fileloc p_f1, fileloc p_f2, int p_n) /*@*/ ; | |
174 | extern bool fileloc_isUser (fileloc p_f) /*@*/ ; | |
175 | extern bool fileloc_sameModule (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
176 | ||
177 | # else | |
178 | # error "Multiple include" | |
179 | # endif | |
180 | ||
181 | ||
182 | ||
183 | ||
184 | ||
185 |