00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 # include "lclintMacros.nf"
00031 # include "basic.h"
00032 # include "structNames.h"
00033
00034
00035 # define MARKCHAR_STRUCT '@'
00036
00037
00038 # define MARKCHAR_UNION '$'
00039
00040
00041 # define MARKCHAR_ENUM '&'
00042
00043
00044 # define MARKCHAR_PARAM '%'
00045
00046 cstring fixTagName (cstring s)
00047 {
00048 if (isFakeTag (s))
00049 {
00050 switch (cstring_firstChar (s))
00051 {
00052 case MARKCHAR_STRUCT: return (cstring_makeLiteral ("struct"));
00053 case MARKCHAR_UNION: return (cstring_makeLiteral ("union"));
00054 case MARKCHAR_ENUM: return (cstring_makeLiteral ("enum"));
00055 default: return (message ("<bad tag name: %s>", s));
00056
00057 }
00058 }
00059 else
00060 {
00061 if (cstring_isDefined (s)) {
00062 switch (cstring_firstChar (s))
00063 {
00064 case MARKCHAR_STRUCT:
00065 return (message ("struct %s", cstring_suffix (s, 1)));
00066 case MARKCHAR_UNION:
00067 return (message ("union %s", cstring_suffix (s, 1)));
00068 case MARKCHAR_ENUM:
00069 return (message ("enum %s", cstring_suffix (s, 1)));
00070 BADDEFAULT;
00071 }
00072 } else {
00073 return (cstring_makeLiteral ("<missing tag name>"));
00074 }
00075 }
00076 }
00077
00078 cstring makeParam (cstring s)
00079 {
00080 if (cstring_length(s) > 0 && cstring_firstChar (s) == MARKCHAR_PARAM)
00081 {
00082 llbug (message ("makeParam: %s\n", s));
00083 }
00084
00085 if (cstring_isUndefined (s))
00086 {
00087 return cstring_undefined;
00088 }
00089
00090 return (cstring_prependChar (MARKCHAR_PARAM, s));
00091 }
00092
00093 cstring fixParamName (cstring s)
00094 {
00095 if (cstring_length(s) < 1)
00096 {
00097 return cstring_undefined;
00098 }
00099
00100 if (cstring_firstChar (s) != MARKCHAR_PARAM)
00101 {
00102 llbug (message ("fixParamName (no #): %s", s));
00103 }
00104
00105 return (cstring_suffix (s, 1));
00106 }
00107
00108 cstring makeStruct (cstring s)
00109 {
00110 if (cstring_firstChar (s) == '@')
00111 {
00112 llbug (message ("makeStruct: %s\n", s));
00113 }
00114
00115 return (cstring_prependChar (MARKCHAR_STRUCT, s));
00116 }
00117
00118 cstring makeUnion (cstring s)
00119 {
00120 return (cstring_prependChar (MARKCHAR_UNION, s));
00121 }
00122
00123 cstring makeEnum (cstring s)
00124 {
00125 return (cstring_prependChar (MARKCHAR_ENUM, s));
00126 }
00127
00128 static unsigned int tagno = 1;
00129
00130 void setTagNo (unsigned int n)
00131 {
00132 if (n > tagno)
00133 tagno = n;
00134 }
00135
00136 bool isFakeTag (cstring s)
00137 {
00138 int length = cstring_length (s);
00139
00140 return ((length >= 1 && cstring_firstChar (s) == '!')
00141 || (length >= 2 && cstring_getChar (s, 2) == '!'));
00142 }
00143
00144 cstring fakeTag ()
00145 {
00146 tagno++;
00147
00148 return (message ("!%u", tagno));
00149 }
00150
00151
00152
00153
00154