Moved OS dependent constants from constants.h to osd.h
[splint-patched.git] / src / lclctypes.c
blobb9164a0d8d18078787c36058c29414a60bb6af4b
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
5 **
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
15 **
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
25 ** lclctypes.c
27 ** This contains definitions used in processing C builtin types.
29 ** WARNING: there is a different file ctype.c for handling types
30 ** in the C checking of splint. This is only for handling
31 ** C builtin types in LCL files.
33 ** AUTHORS:
35 ** Gary Feldman, Technical Languages and Environements, DECspec project
36 ** Joe Wild, Technical Languages and Environements, DECspec project
40 # include "splintMacros.nf"
41 # include "basic.h"
43 typedef struct
45 bits pt;
46 TypeSpec ts;
47 } Lclctype2sortType;
49 static Lclctype2sortType lclctype2type[] =
51 { fixBits (TS_VOID, 0), TYS_VOID},
52 { fixBits (TS_UNKNOWN, 0), TYS_NONE},
53 { fixBits (TS_CHAR, 0), TYS_CHAR},
54 { fixBits (TS_SIGNED, fixBits (TS_CHAR, 0)), TYS_SCHAR},
55 { fixBits (TS_UNSIGNED, fixBits (TS_CHAR, 0)), TYS_UCHAR},
57 { fixBits (TS_SIGNED, fixBits (TS_SHORT, fixBits (TS_INT, 0))), TYS_SSINT},
58 { fixBits (TS_SIGNED, fixBits (TS_SHORT, 0)), TYS_SSINT},
59 { fixBits (TS_SHORT, fixBits (TS_INT, 0)), TYS_SSINT},
60 { fixBits (TS_SHORT, 0), TYS_SSINT},
62 { fixBits (TS_UNSIGNED, fixBits (TS_SHORT, fixBits (TS_INT, 0))), TYS_USINT},
63 { fixBits (TS_UNSIGNED, fixBits (TS_SHORT, 0)), TYS_USINT},
65 { fixBits (TS_SIGNED, fixBits (TS_INT, 0)), TYS_SINT},
66 { fixBits (TS_SIGNED, 0), TYS_SINT},
68 { fixBits (TS_INT, 0), TYS_INT},
69 { 0, TYS_INT},
71 { fixBits (TS_UNSIGNED, fixBits (TS_INT, 0)), TYS_UINT},
72 { fixBits (TS_UNSIGNED, 0), TYS_UINT},
74 { fixBits (TS_SIGNED, fixBits (TS_LONG, fixBits (TS_INT, 0))), TYS_SLINT},
75 { fixBits (TS_SIGNED, fixBits (TS_LONG, 0)), TYS_SLINT},
76 { fixBits (TS_LONG, fixBits (TS_INT, 0)), TYS_SLINT},
77 { fixBits (TS_LONG, 0), TYS_SLINT},
79 { fixBits (TS_UNSIGNED, fixBits (TS_LONG, fixBits (TS_INT, 0))), TYS_ULINT},
80 { fixBits (TS_UNSIGNED, fixBits (TS_LONG, 0)), TYS_ULINT},
82 { fixBits (TS_FLOAT, 0), TYS_FLOAT},
83 { fixBits (TS_DOUBLE, 0), TYS_DOUBLE},
84 { fixBits (TS_LONG, fixBits (TS_DOUBLE, 0)), TYS_LDOUBLE},
86 { fixBits (TS_STRUCT, 0), TYS_STRUCT},
87 { fixBits (TS_UNION, 0), TYS_UNION},
88 { fixBits (TS_ENUM, 0), TYS_ENUM},
89 { fixBits (TS_TYPEDEF, 0), TYS_TYPENAME}
92 lsymbol
93 lclctype_toSortDebug (bits t)
95 int i;
96 int lsize;
97 static ob_mstring OLD_Type2sortName[] =
99 "error", /* TYS_NONE */
100 "void", /* TYS_VOID */
101 "char", /* TYS_CHAR */
102 "signed_char", /* TYS_SCHAR */
103 "char", /* TYS_UCHAR */
104 "short_int", /* TYS_SSINT */
105 "unsigned_short_int", /* TYS_USINT */
106 "int", /* TYS_INT */
107 "int", /* TYS_SINT */
108 "unsigned_int", /* TYS_UINT */
109 "long_int", /* TYS_SLINT */
110 "unsigned_long_int", /* TYS_ULINT */
111 "float", /* TYS_FLOAT */
112 "double", /* TYS_DOUBLE */
113 "long_double", /* TYS_LDOUBLE */
114 "error", /* TYS_ENUM */
115 "error", /* TYS_STRUCT */
116 "error", /* TYS_UNION */
117 "error" /* TYS_TYPENAME */
120 lsize = size_toInt (sizeof (lclctype2type) / sizeof (lclctype2type[0]));
122 for (i = 0; i < lsize; i++)
124 if (lclctype2type[i].pt == t)
126 return lsymbol_fromChars (OLD_Type2sortName[(int)lclctype2type[i].ts]);
129 return lsymbol_fromChars ("_error");
133 lsymbol
134 lclctype_toSort (bits t)
136 int i;
137 static ob_mstring Type2sortName[] =
139 /* _error must have underscore, LSL/LCL interface convention */
140 "_error", /* TYS_NONE */
141 "void", /* TYS_VOID */
142 "char", /* TYS_CHAR */
143 "char", /* TYS_SCHAR */
144 "char", /* TYS_UCHAR */
145 "int", /* TYS_SSINT */
146 "int", /* TYS_USINT */
147 "int", /* TYS_INT */
148 "int", /* TYS_SINT */
149 "int", /* TYS_UINT */
150 "int", /* TYS_SLINT */
151 "int", /* TYS_ULINT */
152 "double", /* TYS_FLOAT */
153 "double", /* TYS_DOUBLE */
154 "double", /* TYS_LDOUBLE */
155 "error", /* TYS_ENUM */
156 "error", /* TYS_STRUCT */
157 "error", /* TYS_UNION */
158 "error" /* TYS_TYPENAME */
161 int lsize = size_toInt (sizeof (lclctype2type) / sizeof (lclctype2type[0]));
163 for (i = 0; i < lsize; i++)
165 if (lclctype2type[i].pt == t)
167 return lsymbol_fromChars (Type2sortName[(int)lclctype2type[i].ts]);
171 return lsymbol_fromChars ("_error");