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 # include "lclintMacros.nf"
00029 # include "basic.h"
00030
00031 idDecl
00032 idDecl_create ( cstring s, qtype t)
00033 {
00034 idDecl d = (idDecl) dmalloc (sizeof (*d));
00035
00036 d->id = s;
00037 d->typ = t;
00038
00039 return (d);
00040 }
00041
00042 void
00043 idDecl_free (idDecl t)
00044 {
00045 if (idDecl_isDefined (t))
00046 {
00047 cstring_free (t->id);
00048 qtype_free (t->typ);
00049 sfree (t);
00050 }
00051 }
00052
00053 cstring
00054 idDecl_unparse (idDecl d)
00055 {
00056 if (idDecl_isDefined (d))
00057 {
00058 return (message ("%s : %q", d->id, qtype_unparse (d->typ)));
00059 }
00060 else
00061 {
00062 return (cstring_makeLiteral ("<undefined id>"));
00063 }
00064 }
00065
00066 cstring
00067 idDecl_observeId (idDecl d)
00068 {
00069 if (idDecl_isDefined (d))
00070 {
00071 return (d->id);
00072 }
00073 else
00074 {
00075 return cstring_undefined;
00076 }
00077 }
00078
00079 qtype
00080 idDecl_getTyp (idDecl d)
00081 {
00082 llassert (idDecl_isDefined (d));
00083
00084 return d->typ;
00085 }
00086
00087 ctype
00088 idDecl_getCtype (idDecl d)
00089 {
00090 if (idDecl_isDefined (d))
00091 {
00092 return (qtype_getType (d->typ));
00093 }
00094 else
00095 {
00096 return ctype_unknown;
00097 }
00098 }
00099
00100 qualList
00101 idDecl_getQuals (idDecl d)
00102 {
00103 if (idDecl_isDefined (d))
00104 {
00105 return (qtype_getQuals (d->typ));
00106 }
00107 else
00108 {
00109 return qualList_undefined;
00110 }
00111 }
00112
00113 void
00114 idDecl_addQual (idDecl d, qual q)
00115 {
00116 llassert (idDecl_isDefined (d));
00117
00118 (void) qtype_addQual (d->typ, q);
00119 }
00120
00121 void
00122 idDecl_setTyp (idDecl d, qtype c)
00123 {
00124 llassert (idDecl_isDefined (d));
00125
00126 qtype_free (d->typ);
00127 d->typ = c;
00128 }
00129
00130 idDecl
00131 idDecl_replaceCtype ( idDecl d, ctype c)
00132 {
00133 llassert (idDecl_isDefined (d));
00134
00135 qtype_setType (d->typ, c);
00136 return d;
00137 }
00138
00139 idDecl
00140 idDecl_fixBase ( idDecl t, qtype b)
00141 {
00142 llassert (idDecl_isDefined (t));
00143
00144 t->typ = qtype_newQbase (t->typ, b);
00145 return t;
00146 }
00147
00148 idDecl
00149 idDecl_fixParamBase ( idDecl t, qtype b)
00150 {
00151 qtype q;
00152 ctype c;
00153
00154 llassert (idDecl_isDefined (t));
00155
00156 q = qtype_newQbase (t->typ, b);
00157 c = qtype_getType (q);
00158
00159
00160
00161
00162
00163
00164 if (ctype_isFunction (c) && !ctype_isPointer (c))
00165 {
00166 qtype_setType (q, ctype_makePointer (c));
00167 }
00168
00169 t->typ = q;
00170
00171 return t;
00172 }
00173
00174 idDecl
00175 idDecl_expectFunction ( idDecl d)
00176 {
00177 llassert (idDecl_isDefined (d));
00178
00179 qtype_setType (d->typ, ctype_expectFunction (qtype_getType (d->typ)));
00180 return d;
00181 }