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 varDeclarationNodeList varDeclarationNodeList_new ()
00036 {
00037 varDeclarationNodeList s = (varDeclarationNodeList) dmalloc (sizeof (*s));
00038
00039 s->nelements = 0;
00040 s->nspace = varDeclarationNodeListBASESIZE;
00041 s->elements = (varDeclarationNode *)
00042 dmalloc (sizeof (*s->elements) * varDeclarationNodeListBASESIZE);
00043
00044 return (s);
00045 }
00046
00047 static void
00048 varDeclarationNodeList_grow (varDeclarationNodeList s)
00049 {
00050 int i;
00051 varDeclarationNode *newelements;
00052
00053 s->nspace += varDeclarationNodeListBASESIZE;
00054
00055 newelements = (varDeclarationNode *) 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 void
00068 varDeclarationNodeList_addh (varDeclarationNodeList s, varDeclarationNode el)
00069 {
00070 if (s->nspace <= 0)
00071 varDeclarationNodeList_grow (s);
00072
00073 s->nspace--;
00074 s->elements[s->nelements] = el;
00075 s->nelements++;
00076 }
00077
00078 cstring
00079 varDeclarationNodeList_unparse (varDeclarationNodeList s)
00080 {
00081 cstring st = cstring_undefined;
00082
00083 varDeclarationNodeList_elements (s, current)
00084 {
00085 if (current->isPrivate)
00086 st = message ("%q private ", st);
00087
00088 st = message ("%q%q %q;\n", st, lclTypeSpecNode_unparse (current->type),
00089 initDeclNodeList_unparse (current->decls));
00090 } end_varDeclarationNodeList_elements;
00091
00092 return st;
00093 }
00094
00095
00096 void
00097 varDeclarationNodeList_free (varDeclarationNodeList s)
00098 {
00099 int i;
00100 for (i = 0; i < s->nelements; i++)
00101 {
00102 varDeclarationNode_free (s->elements[i]);
00103 }
00104
00105 sfree (s->elements);
00106 sfree (s);
00107 }