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 importNodeList
00036 importNodeList_new ()
00037 {
00038 importNodeList s = (importNodeList) dmalloc (sizeof (*s));
00039
00040 s->nelements = 0;
00041 s->nspace = importNodeListBASESIZE;
00042 s->elements = (importNode *)
00043 dmalloc (sizeof (*s->elements) * importNodeListBASESIZE);
00044
00045 return (s);
00046 }
00047
00048 static void
00049 importNodeList_grow (importNodeList s)
00050 {
00051 int i;
00052 importNode *newelements;
00053
00054 s->nspace += importNodeListBASESIZE;
00055
00056 newelements = (importNode *) 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 importNodeList
00069 importNodeList_add (importNodeList s, importNode el)
00070 {
00071 if (s->nspace <= 0)
00072 importNodeList_grow (s);
00073
00074 s->nspace--;
00075 s->elements[s->nelements] = el;
00076 s->nelements++;
00077 return s;
00078 }
00079
00080 cstring
00081 importNodeList_unparse (importNodeList s)
00082 {
00083 bool first = TRUE;
00084 cstring st = cstring_undefined;
00085
00086 importNodeList_elements (s, current)
00087 {
00088 if (first)
00089 {
00090 st = cstring_copy (ltoken_unparse (current->val));
00091 first = FALSE;
00092 }
00093 else
00094 {
00095 st = message ("%q, %s", st, ltoken_unparse (current->val));
00096 }
00097 } end_importNodeList_elements;
00098
00099 return st;
00100 }
00101
00102 void
00103 importNodeList_free (importNodeList s)
00104 {
00105 int i;
00106
00107 for (i = 0; i < s->nelements; i++)
00108 {
00109 importNode_free (s->elements[i]);
00110 }
00111
00112 sfree (s->elements);
00113 sfree (s);
00114 }