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 storeRefNodeList
00036 storeRefNodeList_new ()
00037 {
00038 storeRefNodeList s = (storeRefNodeList) dmalloc (sizeof (*s));
00039
00040 s->nelements = 0;
00041 s->nspace = storeRefNodeListBASESIZE;
00042 s->elements = (storeRefNode *)
00043 dmalloc (sizeof (*s->elements) * storeRefNodeListBASESIZE);
00044
00045 return (s);
00046 }
00047
00048 static void
00049 storeRefNodeList_grow (storeRefNodeList s)
00050 {
00051 int i;
00052 storeRefNode *newelements;
00053
00054 s->nspace += storeRefNodeListBASESIZE;
00055
00056 newelements = (storeRefNode *) 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 storeRefNodeList
00069 storeRefNodeList_add (storeRefNodeList s, storeRefNode el)
00070 {
00071 if (s->nspace <= 0)
00072 storeRefNodeList_grow (s);
00073
00074 s->nspace--;
00075 s->elements[s->nelements] = el;
00076 s->nelements++;
00077
00078 return s;
00079 }
00080
00081 storeRefNodeList
00082 storeRefNodeList_copy (storeRefNodeList s)
00083 {
00084 storeRefNodeList r = storeRefNodeList_new ();
00085
00086 storeRefNodeList_elements (s, x)
00087 {
00088 r = storeRefNodeList_add (r, storeRefNode_copy (x));
00089 } end_storeRefNodeList_elements;
00090
00091 return r;
00092 }
00093
00094 cstring
00095 storeRefNodeList_unparse (storeRefNodeList s)
00096 {
00097 bool first = TRUE;
00098 cstring st = cstring_undefined;
00099
00100 storeRefNodeList_elements (s, current)
00101 {
00102 if (first)
00103 {
00104 first = FALSE;
00105 }
00106 else
00107 {
00108 st = message ("%q, ", st);
00109 }
00110
00111 switch (current->kind)
00112 {
00113 case SRN_OBJ:
00114 st = message ("%qobj", st);
00115 break;
00116 case SRN_TERM:
00117 st = message ("%q%q", st, termNode_unparse (current->content.term));
00118 break;
00119 case SRN_TYPE:
00120 st = message ("%q%q", st, lclTypeSpecNode_unparse (current->content.type));
00121 break;
00122 case SRN_SPECIAL:
00123 st = message ("%q%q", st, sRef_unparse (current->content.ref));
00124 break;
00125 }
00126 } end_storeRefNodeList_elements;
00127
00128 return st;
00129 }
00130
00131 void
00132 storeRefNodeList_free (storeRefNodeList s)
00133 {
00134 int i;
00135 for (i = 0; i < s->nelements; i++)
00136 {
00137 storeRefNode_free (s->elements[i]);
00138 }
00139
00140 sfree (s->elements);
00141 sfree (s);
00142 }