Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

lclctypes.c

Go to the documentation of this file.
00001 /*
00002 ** LCLint - annotation-assisted static program checker
00003 ** Copyright (C) 1994-2000 University of Virginia,
00004 **         Massachusetts Institute of Technology
00005 **
00006 ** This program is free software; you can redistribute it and/or modify it
00007 ** under the terms of the GNU General Public License as published by the
00008 ** Free Software Foundation; either version 2 of the License, or (at your
00009 ** option) any later version.
00010 ** 
00011 ** This program is distributed in the hope that it will be useful, but
00012 ** WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** General Public License for more details.
00015 ** 
00016 ** The GNU General Public License is available from http://www.gnu.org/ or
00017 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018 ** MA 02111-1307, USA.
00019 **
00020 ** For information on lclint: lclint-request@cs.virginia.edu
00021 ** To report a bug: lclint-bug@cs.virginia.edu
00022 ** For more information: http://lclint.cs.virginia.edu
00023 */
00024 /*
00025 ** lclctypes.c
00026 **
00027 ** This contains definitions used in processing C builtin types.
00028 **
00029 ** WARNING: there is a different file ctype.c for handling types
00030 **          in the C checking of lclint.  This is only for handling
00031 **          C builtin types in LCL files.
00032 **
00033 **  AUTHORS:
00034 **
00035 **      Gary Feldman, Technical Languages and Environements, DECspec project
00036 **      Joe Wild, Technical Languages and Environements, DECspec project
00037 **
00038 */
00039 
00040 # include "lclintMacros.nf"
00041 # include "llbasic.h"
00042 
00043 typedef struct
00044 {
00045   bits pt;
00046   TypeSpec ts;
00047 } Lclctype2sortType;
00048 
00049 static Lclctype2sortType lclctype2type[] =
00050 {
00051   { fixBits (TS_VOID, 0), TYS_VOID},
00052   { fixBits (TS_UNKNOWN, 0), TYS_NONE},
00053   { fixBits (TS_CHAR, 0), TYS_CHAR},
00054   { fixBits (TS_SIGNED, fixBits (TS_CHAR, 0)), TYS_SCHAR},
00055   { fixBits (TS_UNSIGNED, fixBits (TS_CHAR, 0)), TYS_UCHAR},
00056 
00057   { fixBits (TS_SIGNED, fixBits (TS_SHORT, fixBits (TS_INT, 0))), TYS_SSINT},
00058   { fixBits (TS_SIGNED, fixBits (TS_SHORT, 0)), TYS_SSINT},
00059   { fixBits (TS_SHORT, fixBits (TS_INT, 0)), TYS_SSINT},
00060   { fixBits (TS_SHORT, 0), TYS_SSINT},
00061 
00062   { fixBits (TS_UNSIGNED, fixBits (TS_SHORT, fixBits (TS_INT, 0))), TYS_USINT},
00063   { fixBits (TS_UNSIGNED, fixBits (TS_SHORT, 0)), TYS_USINT},
00064 
00065   { fixBits (TS_SIGNED, fixBits (TS_INT, 0)), TYS_SINT},
00066   { fixBits (TS_SIGNED, 0), TYS_SINT},
00067 
00068   { fixBits (TS_INT, 0), TYS_INT},
00069   { 0, TYS_INT},
00070 
00071   { fixBits (TS_UNSIGNED, fixBits (TS_INT, 0)), TYS_UINT},
00072   { fixBits (TS_UNSIGNED, 0), TYS_UINT},
00073 
00074   { fixBits (TS_SIGNED, fixBits (TS_LONG, fixBits (TS_INT, 0))), TYS_SLINT},
00075   { fixBits (TS_SIGNED, fixBits (TS_LONG, 0)), TYS_SLINT},
00076   { fixBits (TS_LONG, fixBits (TS_INT, 0)), TYS_SLINT},
00077   { fixBits (TS_LONG, 0), TYS_SLINT},
00078 
00079   { fixBits (TS_UNSIGNED, fixBits (TS_LONG, fixBits (TS_INT, 0))), TYS_ULINT},
00080   { fixBits (TS_UNSIGNED, fixBits (TS_LONG, 0)), TYS_ULINT},
00081 
00082   { fixBits (TS_FLOAT, 0), TYS_FLOAT},
00083   { fixBits (TS_DOUBLE, 0), TYS_DOUBLE},
00084   { fixBits (TS_LONG, fixBits (TS_DOUBLE, 0)), TYS_LDOUBLE},
00085 
00086   { fixBits (TS_STRUCT, 0), TYS_STRUCT},
00087   { fixBits (TS_UNION, 0), TYS_UNION},
00088   { fixBits (TS_ENUM, 0), TYS_ENUM},
00089   { fixBits (TS_TYPEDEF, 0), TYS_TYPENAME}
00090 };
00091 
00092 lsymbol
00093 lclctype_toSortDebug (bits t)
00094 {
00095   int i;
00096   int lsize;
00097   static ob_mstring OLD_Type2sortName[] =
00098     {
00099       "error",                  /* TYS_NONE     */
00100       "void",                   /* TYS_VOID     */
00101       "char",                   /* TYS_CHAR     */
00102       "signed_char",            /* TYS_SCHAR    */
00103       "char",                   /* TYS_UCHAR    */
00104       "short_int",              /* TYS_SSINT    */
00105       "unsigned_short_int",     /* TYS_USINT    */
00106       "int",                    /* TYS_INT        */
00107       "int",                    /* TYS_SINT     */
00108       "unsigned_int",           /* TYS_UINT     */
00109       "long_int",               /* TYS_SLINT    */
00110       "unsigned_long_int",      /* TYS_ULINT    */
00111       "float",                  /* TYS_FLOAT    */
00112       "double",                 /* TYS_DOUBLE   */
00113       "long_double",            /* TYS_LDOUBLE  */
00114       "error",                  /* TYS_ENUM     */
00115       "error",                  /* TYS_STRUCT   */
00116       "error",                  /* TYS_UNION    */
00117       "error"                   /* TYS_TYPENAME */
00118       };
00119 
00120   lsize = size_toInt (sizeof (lclctype2type) / sizeof (lclctype2type[0]));
00121 
00122   for (i = 0; i < lsize; i++)
00123     {
00124       if (lclctype2type[i].pt == t)
00125         {
00126           return lsymbol_fromChars (OLD_Type2sortName[(int)lclctype2type[i].ts]);
00127         }
00128     }
00129   return lsymbol_fromChars ("_error");
00130 }
00131 
00132 
00133 lsymbol
00134 lclctype_toSort (bits t)
00135 {
00136   int i;
00137   static ob_mstring Type2sortName[] =
00138     {
00139       /* _error must have underscore, LSL/LCL interface convention */
00140       "_error",                 /* TYS_NONE     */
00141       "void",                   /* TYS_VOID     */
00142       "char",                   /* TYS_CHAR     */
00143       "char",                   /* TYS_SCHAR    */
00144       "char",                   /* TYS_UCHAR    */
00145       "int",                    /* TYS_SSINT    */
00146       "int",                    /* TYS_USINT    */
00147       "int",                    /* TYS_INT      */
00148       "int",                    /* TYS_SINT     */
00149       "int",                    /* TYS_UINT     */
00150       "int",                    /* TYS_SLINT    */
00151       "int",                    /* TYS_ULINT    */
00152       "double",                 /* TYS_FLOAT    */
00153       "double",                 /* TYS_DOUBLE   */
00154       "double",                 /* TYS_LDOUBLE  */
00155       "error",                  /* TYS_ENUM     */
00156       "error",                  /* TYS_STRUCT   */
00157       "error",                  /* TYS_UNION    */
00158       "error"                   /* TYS_TYPENAME         */
00159       };
00160 
00161   int lsize = size_toInt (sizeof (lclctype2type) / sizeof (lclctype2type[0]));
00162 
00163   for (i = 0; i < lsize; i++)
00164     {
00165       if (lclctype2type[i].pt == t)
00166         {
00167           return lsymbol_fromChars (Type2sortName[(int)lclctype2type[i].ts]);
00168         }
00169     }
00170 
00171   return lsymbol_fromChars ("_error");
00172 }

Generated at Fri Nov 3 18:57:41 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000