]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/CCode/Source/Pccts/h/slist.cpp
6 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public
7 * domain. An individual or company may do whatever they wish with
8 * source code distributed with SORCERER or the code generated by
9 * SORCERER, including the incorporation of SORCERER, or its output, into
10 * commerical software.
12 * We encourage users to develop software with SORCERER. However, we do
13 * ask that credit is given to us for developing SORCERER. By "credit",
14 * we mean that if you incorporate our source code into one of your
15 * programs (commercial product, research project, or otherwise) that you
16 * acknowledge this fact somewhere in the documentation, research report,
17 * etc... If you like SORCERER and have developed a nice tool with the
18 * output, please mention that you developed it using SORCERER. In
19 * addition, we ask that this header remain intact in our source code.
20 * As long as these guidelines are kept, we expect to continue enhancing
21 * this system and expect to make other tools available as they are
26 * Parr Research Corporation
27 * with Purdue University and AHPCRC, University of Minnesota
31 #define ANTLR_SUPPORT_CODE
34 #include "pccts_stdarg.h" // MR23
36 /* Iterate over a list of elements; returns ptr to a new element
37 * in list upon every call and NULL when no more are left.
38 * Very useful like this:
41 * while ( (p=mylist->iterate(&cursor)) ) {
42 * // place with element p
45 * The cursor must be initialized to point to the list to iterate over.
48 iterate(SListNode
**cursor
)
52 if ( cursor
== NULL
|| *cursor
==NULL
) return NULL
;
53 if ( head
== *cursor
) { *cursor
= (*cursor
)->next(); }
54 e
= (*cursor
)->elem();
55 (*cursor
) = (*cursor
)->next();
59 /* add an element to end of list. */
63 SListNode
*p
, *tail
=NULL
;
64 require(e
!=NULL
, "slist_add: attempting to add NULL list element");
67 require(p
!=NULL
, "add: cannot alloc new list node");
73 else /* find end of list */
85 if ( head
==NULL
) return; /* empty list */
86 for (p
= head
; p
!=NULL
; p
=q
)
96 PCCTS_AST
*t
=NULL
, *last
=NULL
;
99 for (p
= head
; p
!=NULL
; p
=p
->next())
101 PCCTS_AST
*u
= (PCCTS_AST
*)p
->elem();
102 if ( last
==NULL
) last
= t
= u
;
103 else { last
->setRight(u
); last
= u
; }
109 int SList::printMessage(FILE* pFile
, const char* pFormat
, ...)
112 va_start( marker
, pFormat
);
113 int iRet
= vfprintf(pFile
, pFormat
, marker
);