]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
c0de361f | 2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2003. |
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 | |
885824d3 | 39 | extern fileloc fileloc_createSpec (fileId p_fid, int p_line, int p_col) /*@*/ ; |
885824d3 | 40 | extern fileloc fileloc_createLib (cstring p_ln) /*@*/ ; |
41 | extern fileloc fileloc_createRc (cstring p_name) /*@*/ ; | |
42 | extern fileloc fileloc_decColumn (fileloc p_f, int p_x) /*@*/ ; | |
43 | extern void fileloc_subColumn (fileloc p_f, int p_x) /*@modifies p_f@*/ ; | |
44 | extern fileloc fileloc_getBuiltin (void) /*@*/ ; | |
45 | extern /*@observer@*/ fileloc fileloc_observeBuiltin (void) /*@*/ ; | |
46 | extern fileloc fileloc_createBuiltin (void) /*@*/ ; | |
885824d3 | 47 | extern fileloc fileloc_createImport (cstring p_fname, int p_lineno) /*@*/ ; |
885824d3 | 48 | |
6fcd0b1e | 49 | extern void fileloc_destroyMod (void) /*@modifies internalState@*/ ; |
885824d3 | 50 | extern bool fileloc_isSpecialFile (fileloc p_f) /*@*/ ; |
51 | extern bool fileloc_sameBaseFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
52 | extern /*@observer@*/ cstring fileloc_filename (fileloc p_f) /*@*/ ; | |
53 | extern int fileloc_column (fileloc p_f) /*@*/ ; | |
28bf4b0b | 54 | extern cstring fileloc_unparse (fileloc p_f) /*@*/ ; |
885824d3 | 55 | extern cstring fileloc_unparseRaw (cstring p_fname, int p_lineno) /*@*/ ; |
56 | extern cstring fileloc_unparseRawCol (cstring p_fname, int p_lineno, int p_col) /*@*/ ; | |
57 | extern bool fileloc_sameFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
28bf4b0b | 58 | extern bool fileloc_sameFileAndLine (fileloc p_f1, fileloc p_f2) /*@*/ ; |
885824d3 | 59 | extern void fileloc_free (/*@only@*/ fileloc p_f); |
60 | extern void fileloc_reallyFree (/*@only@*/ fileloc p_f); | |
61 | extern int fileloc_lineno (fileloc p_f) /*@*/ ; | |
62 | extern bool fileloc_equal (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
63 | extern bool fileloc_lessthan (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
64 | extern int fileloc_compare (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
65 | extern /*@observer@*/ cstring fileloc_getBase (fileloc p_f) /*@*/ ; | |
66 | extern bool fileloc_isHeader (fileloc p_f) /*@*/ ; | |
67 | extern bool fileloc_isSpec (fileloc p_f) /*@*/ ; | |
68 | extern bool fileloc_isRealSpec (fileloc p_f) /*@*/ ; | |
69 | extern fileloc fileloc_copy (fileloc p_f) /*@*/ ; | |
70 | extern cstring fileloc_unparseDirect (fileloc p_fl) /*@*/ ; | |
71 | extern bool fileloc_notAfter (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
72 | extern bool fileloc_almostSameFile (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
73 | extern fileloc fileloc_noColumn (fileloc p_f) /*@*/ ; | |
74 | extern /*@observer@*/ fileloc fileloc_getExternal (void) /*@*/ ; | |
75 | extern fileloc fileloc_createExternal (void) /*@*/ ; | |
76 | ||
77 | extern bool fileloc_isExternal (/*@sef@*/ fileloc p_f) /*@*/; | |
78 | # define fileloc_isExternal(f) \ | |
79 | (fileloc_isDefined(f) && ((f)->kind == FL_EXTERNAL)) | |
80 | ||
0e41eb0e | 81 | extern /*@falsewhennull@*/ bool fileloc_isDefined (/*@null@*/ fileloc p_f) /*@*/ ; |
82 | extern /*@nullwhentrue@*/ bool fileloc_isUndefined (/*@null@*/ fileloc p_f) /*@*/ ; | |
885824d3 | 83 | extern bool fileloc_isInvalid (/*@sef@*/ /*@null@*/ fileloc p_f) /*@*/ ; |
84 | ||
85 | /*@constant null fileloc fileloc_undefined; @*/ | |
28bf4b0b | 86 | # define fileloc_undefined ((fileloc) NULL) |
885824d3 | 87 | # define fileloc_isDefined(f) ((f) != fileloc_undefined) |
88 | # define fileloc_isUndefined(f) ((f) == fileloc_undefined) | |
89 | # define fileloc_isInvalid(f) (!(fileloc_isValid(f))) | |
90 | ||
91 | extern bool fileloc_isLib (fileloc p_f) /*@*/ ; | |
885824d3 | 92 | |
885824d3 | 93 | extern fileloc fileloc_fromTok (ltoken p_t) /*@*/ ; |
885824d3 | 94 | |
95 | /*@constant int UNKNOWN_LINE; @*/ | |
96 | # define UNKNOWN_LINE (0) | |
97 | ||
98 | /*@constant int UNKNOWN_COLUMN; @*/ | |
99 | # define UNKNOWN_COLUMN (0) | |
100 | ||
101 | extern /*@unused@*/ bool fileloc_linenoDefined (/*@sef@*/ fileloc p_f) /*@*/ ; | |
102 | extern /*@unused@*/ bool fileloc_columnDefined (/*@sef@*/ fileloc p_f) /*@*/ ; | |
103 | ||
104 | # define fileloc_linenoDefined(f) \ | |
105 | (fileloc_isValid (f) && (f)->lineno != UNKNOWN_LINE) | |
106 | ||
107 | # define fileloc_columnDefined(f) \ | |
108 | (fileloc_isValid (f) && (f)->column != UNKNOWN_COLUMN) | |
109 | ||
885824d3 | 110 | extern void fileloc_setColumnUndefined (/*@sef@*/ fileloc p_f) /*@modifies p_f@*/; |
111 | # define fileloc_setColumnUndefined(f) \ | |
112 | (fileloc_isDefined(f) ? (f)->column = UNKNOWN_COLUMN : UNKNOWN_COLUMN) | |
885824d3 | 113 | |
0e41eb0e | 114 | extern /*@falsewhennull@*/ bool fileloc_isValid (/*@sef@*/ fileloc p_f); |
885824d3 | 115 | # define fileloc_isValid(f) \ |
116 | (fileloc_isDefined(f) && ((f)->lineno >= 0)) | |
117 | ||
118 | extern bool fileloc_isImport (/*@sef@*/ fileloc p_fl); | |
119 | # define fileloc_isImport(fl) (fileloc_isDefined(fl) && (fl)->kind == FL_IMPORT) | |
120 | ||
121 | extern bool fileloc_isPreproc (/*@sef@*/ fileloc p_fl); | |
122 | # define fileloc_isPreproc(fl) (fileloc_isDefined(fl) && (fl)->kind == FL_PREPROC) | |
123 | ||
124 | extern void fileloc_setLineno (/*@sef@*/ fileloc p_f, int p_i) /*@modifies p_f@*/ ; | |
125 | # define fileloc_setLineno(fl, i) \ | |
126 | (fileloc_isDefined(fl) ? ((fl)->lineno = (i), (fl)->column = 1) : (i)) | |
127 | ||
128 | extern void fileloc_nextLine (/*@sef@*/ fileloc p_f) /*@modifies p_f@*/ ; | |
129 | # define fileloc_nextLine(fl) \ | |
130 | (fileloc_isDefined(fl) ? ((fl)->lineno++, (fl)->column = 1) : 0) | |
131 | ||
132 | extern void fileloc_addLine (/*@sef@*/ fileloc p_f, int p_i) /*@modifies p_f@*/ ; | |
133 | # define fileloc_addLine(fl, i) \ | |
134 | (fileloc_isDefined(fl) ? ((fl)->lineno += (i), (fl)->column = 1) : (i)) | |
135 | ||
136 | extern fileId fileloc_fileId (/*@sef@*/ fileloc p_fl) /*@*/ ; | |
137 | # define fileloc_fileId(fl) \ | |
138 | (fileloc_isDefined (fl) ? (fl)->fid : fileId_invalid) | |
139 | ||
140 | extern void fileloc_setColumn (/*@sef@*/ fileloc p_fl, int p_i) /*@modifies p_fl@*/ ; | |
141 | # define fileloc_setColumn(fl, i) \ | |
142 | (fileloc_isDefined (fl) ? ((fl)->column = (i)) : (i)) | |
143 | ||
144 | extern void fileloc_addColumn (/*@sef@*/ fileloc p_fl, int p_i) /*@modifies p_fl@*/ ; | |
145 | # define fileloc_addColumn(fl, i) \ | |
146 | (fileloc_isDefined (fl) ? ((fl)->column += (i)) : (i)) | |
147 | ||
148 | extern void fileloc_incColumn (/*@sef@*/ fileloc p_fl) /*@modifies p_fl@*/ ; | |
149 | # define fileloc_incColumn(fl) \ | |
150 | (fileloc_isDefined (fl) ? ((fl)->column++) : 0) | |
151 | ||
152 | extern bool fileloc_isBuiltin (/*@sef@*/ fileloc p_fl) /*@*/ ; | |
153 | # define fileloc_isBuiltin(fl) \ | |
154 | (fileloc_isDefined (fl) && ((fl)->kind == FL_BUILTIN)) | |
155 | ||
156 | extern fileloc fileloc_updateFileId (/*@only@*/ fileloc p_old, fileId p_s) /*@*/ ; | |
157 | extern fileloc fileloc_makePreproc (fileloc p_loc) /*@*/ ; | |
158 | extern fileloc fileloc_makePreprocPrevious (fileloc p_loc) /*@*/ ; | |
159 | ||
53a89507 | 160 | extern /*@only@*/ cstring fileloc_outputFilename (fileloc) /*@*/ ; |
161 | ||
885824d3 | 162 | extern bool fileloc_isStandardLibrary (fileloc p_f) /*@*/ ; |
885824d3 | 163 | extern bool fileloc_isStandardLib (fileloc p_f) /*@*/ ; |
28bf4b0b | 164 | |
885824d3 | 165 | extern cstring fileloc_unparseFilename (fileloc p_f) /*@*/ ; |
166 | extern bool fileloc_withinLines (fileloc p_f1, fileloc p_f2, int p_n) /*@*/ ; | |
167 | extern bool fileloc_isUser (fileloc p_f) /*@*/ ; | |
168 | extern bool fileloc_sameModule (fileloc p_f1, fileloc p_f2) /*@*/ ; | |
169 | ||
7ebcc5bb | 170 | extern bool fileloc_storable (/*@sef@*/ fileloc p_f) /*@*/; |
171 | # define fileloc_storable(f) ((f) != g_currentloc || fileloc_isBuiltin (f) || fileloc_isExternal (f)) | |
172 | ||
173 | ||
885824d3 | 174 | # else |
175 | # error "Multiple include" | |
176 | # endif | |
177 | ||
178 | ||
179 | ||
180 | ||
181 | ||
182 |