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
00031
00032 # include "lclintMacros.nf"
00033 # include "basic.h"
00034
00035 ctypeList
00036 ctypeList_new ()
00037 {
00038 ctypeList s = (ctypeList) dmalloc (sizeof (*s));
00039
00040 s->nelements = 0;
00041 s->nspace = ctypeListBASESIZE;
00042 s->elements = (ctype *) dmalloc (sizeof (*s->elements) * ctypeListBASESIZE);
00043
00044 return (s);
00045 }
00046
00047 static void
00048 ctypeList_grow ( ctypeList s)
00049 {
00050 int i;
00051 ctype *newelements;
00052
00053 s->nspace += ctypeListBASESIZE;
00054 newelements = (ctype *) dmalloc (sizeof (*newelements) * (s->nelements + s->nspace));
00055
00056 if (newelements == (ctype *) 0)
00057 {
00058 llfatalerror (cstring_makeLiteral ("ctypeList_grow: out of memory!"));
00059 }
00060
00061 for (i = 0; i < s->nelements; i++)
00062 {
00063 newelements[i] = s->elements[i];
00064 }
00065
00066 sfree (s->elements);
00067 s->elements = newelements;
00068 }
00069
00070 void ctypeList_addh (ctypeList s, ctype el)
00071 {
00072 llassert (ctypeList_isDefined (s));
00073 llassert (ctypeListBASESIZE > 0);
00074
00075 if (s->nspace <= 0) ctypeList_grow (s);
00076
00077 s->nspace--;
00078 s->elements[s->nelements] = el;
00079 s->nelements++;
00080 }
00081
00082 cstring
00083 ctypeList_unparse (ctypeList ct)
00084 {
00085 cstring s = cstring_undefined;
00086 int i;
00087 bool first = TRUE;
00088
00089 if (ctypeList_isUndefined (ct) || ctypeList_size (ct) == 0)
00090 {
00091 return (cstring_makeLiteral ("void"));
00092 }
00093
00094 for (i = 0; i < ct->nelements; i++)
00095 {
00096 if (first)
00097 {
00098 s = cstring_copy (ctype_unparse (ct->elements[i]));
00099 first = FALSE;
00100 }
00101 else
00102 {
00103 s = message ("%q, %s", s, ctype_unparse (ct->elements[i]));
00104 }
00105 }
00106
00107 return s;
00108 }
00109
00110 void
00111 ctypeList_free ( ctypeList s)
00112 {
00113 if (ctypeList_isDefined (s))
00114 {
00115 int i;
00116 for (i = 0; i < s->nelements; i++)
00117 {
00118
00119 }
00120
00121 sfree (s->elements);
00122 sfree (s);
00123 }
00124 }
00125
00126
00127
00128
00129
00130
00131