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 initDeclNodeList
00036 initDeclNodeList_new ()
00037 {
00038 initDeclNodeList s = (initDeclNodeList) dmalloc (sizeof (*s));
00039
00040 s->nelements = 0;
00041 s->nspace = initDeclNodeListBASESIZE;
00042 s->elements = (initDeclNode *)
00043 dmalloc (sizeof (*s->elements) * initDeclNodeListBASESIZE);
00044
00045 return (s);
00046 }
00047
00048 static void
00049 initDeclNodeList_grow (initDeclNodeList s)
00050 {
00051 int i;
00052 initDeclNode *newelements;
00053
00054 s->nspace += initDeclNodeListBASESIZE;
00055 newelements = (initDeclNode *) dmalloc (sizeof (*newelements)
00056 * (s->nelements + s->nspace));
00057
00058 for (i = 0; i < s->nelements; i++)
00059 {
00060 newelements[i] = s->elements[i];
00061 }
00062
00063 sfree (s->elements);
00064 s->elements = newelements;
00065 }
00066
00067 initDeclNodeList
00068 initDeclNodeList_add (initDeclNodeList s, initDeclNode el)
00069 {
00070 if (s->nspace <= 0)
00071 initDeclNodeList_grow (s);
00072
00073 s->nspace--;
00074 s->elements[s->nelements] = el;
00075 s->nelements++;
00076
00077 return s;
00078 }
00079
00080 cstring
00081 initDeclNodeList_unparse (initDeclNodeList s)
00082 {
00083 cstring st = cstring_undefined;
00084 bool first = TRUE;
00085
00086 initDeclNodeList_elements (s, current)
00087 {
00088 if (first)
00089 {
00090 first = FALSE;
00091 st = declaratorNode_unparse (current->declarator);
00092 }
00093 else
00094 {
00095 st = message ("%q, %q", st, declaratorNode_unparse (current->declarator));
00096 }
00097
00098 if (current->value != (termNode) 0)
00099 {
00100 st = message ("%q = %q", st, termNode_unparse (current->value));
00101 }
00102 } end_initDeclNodeList_elements;
00103
00104 return st;
00105 }
00106
00107 void
00108 initDeclNodeList_free (initDeclNodeList s)
00109 {
00110 int i;
00111 for (i = 0; i < s->nelements; i++)
00112 {
00113 initDeclNode_free (s->elements[i]);
00114 }
00115
00116 sfree (s->elements);
00117 sfree (s);
00118 }