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 "llbasic.h"
00034
00035 stDeclNodeList
00036 stDeclNodeList_new ()
00037 {
00038 stDeclNodeList s = (stDeclNodeList) dmalloc (sizeof (*s));
00039
00040 s->nelements = 0;
00041 s->nspace = stDeclNodeListBASESIZE;
00042 s->elements = (stDeclNode *)
00043 dmalloc (sizeof (*s->elements) * stDeclNodeListBASESIZE);
00044
00045 return (s);
00046 }
00047
00048 static void
00049 stDeclNodeList_grow (stDeclNodeList s)
00050 {
00051 int i;
00052 stDeclNode *newelements;
00053
00054 s->nspace += stDeclNodeListBASESIZE;
00055
00056 newelements = (stDeclNode *) dmalloc (sizeof (*newelements)
00057 * (s->nelements + s->nspace));
00058
00059 for (i = 0; i < s->nelements; i++)
00060 {
00061 newelements[i] = s->elements[i];
00062 }
00063
00064 sfree (s->elements);
00065 s->elements = newelements;
00066 }
00067
00068 stDeclNodeList
00069 stDeclNodeList_add (stDeclNodeList s, stDeclNode el)
00070 {
00071 if (s->nspace <= 0)
00072 stDeclNodeList_grow (s);
00073
00074 s->nspace--;
00075 s->elements[s->nelements] = el;
00076 s->nelements++;
00077
00078 return s;
00079 }
00080
00081 stDeclNodeList
00082 stDeclNodeList_copy (stDeclNodeList s)
00083 {
00084 stDeclNodeList r = stDeclNodeList_new ();
00085
00086 stDeclNodeList_elements (s, x)
00087 {
00088 r = stDeclNodeList_add (r, stDeclNode_copy (x));
00089 } end_stDeclNodeList_elements;
00090
00091 return r;
00092 }
00093
00094 cstring
00095 stDeclNodeList_unparse (stDeclNodeList s)
00096 {
00097 bool first = TRUE;
00098 cstring st = cstring_undefined;
00099
00100 stDeclNodeList_elements (s, current)
00101 {
00102 if (first)
00103 {
00104 st = message ("%q %q;", lclTypeSpecNode_unparse (current->lcltypespec),
00105 declaratorNodeList_unparse (current->declarators));
00106 first = FALSE;
00107 }
00108 else
00109 {
00110 st = message ("%q %q %q;", st, lclTypeSpecNode_unparse (current->lcltypespec),
00111 declaratorNodeList_unparse (current->declarators));
00112 }
00113 } end_stDeclNodeList_elements;
00114
00115 return st;
00116 }
00117
00118 void
00119 stDeclNodeList_free (stDeclNodeList s)
00120 {
00121 int i;
00122 for (i = 0; i < s->nelements; i++)
00123 {
00124 stDeclNode_free (s->elements[i]);
00125 }
00126
00127 sfree (s->elements);
00128 sfree (s);
00129 }