2 ** LCLint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2001 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on lclint: lclint-request@cs.virginia.edu
21 ** To report a bug: lclint-bug@cs.virginia.edu
22 ** For more information: http://lclint.cs.virginia.edu
25 ** mtDeclarationPieces.c
28 # include "lclintMacros.nf"
30 # include "mtgrammar.h"
32 extern mtDeclarationPieces mtDeclarationPieces_create (void) /*@*/
34 return mtDeclarationPieces_undefined;
37 extern mtDeclarationPieces mtDeclarationPieces_append (mtDeclarationPieces node,
38 /*@only@*/ mtDeclarationPiece piece)
41 mtDeclarationPieces tnode = node;
42 mtDeclarationPieces res = (mtDeclarationPieces) dmalloc (sizeof (*node));
44 res->thisPiece = piece;
45 res->rest = mtDeclarationPieces_undefined;
47 if (mtDeclarationPieces_isUndefined (node)) {
51 while (mtDeclarationPieces_isDefined (tnode->rest))
60 extern cstring mtDeclarationPieces_unparse (mtDeclarationPieces node) /*@*/
62 cstring res = cstring_newEmpty ();
64 while (mtDeclarationPieces_isDefined (node))
66 res = message ("%q%q; ", res, mtDeclarationPiece_unparse (node->thisPiece));
74 mtDeclarationPieces_findPiece (mtDeclarationPieces pieces, mtPieceKind kind)
76 bool foundone = FALSE;
77 mtDeclarationPiece res = mtDeclarationPiece_undefined;
79 while (mtDeclarationPieces_isDefined (pieces))
81 if (mtDeclarationPiece_matchKind (pieces->thisPiece, kind))
85 llassert (mtDeclarationPiece_isDefined (res));
88 message ("Metastate declaration has duplicate pieces: %q / %q",
89 mtDeclarationPiece_unparse (res),
90 mtDeclarationPiece_unparse (pieces->thisPiece)),
91 g_currentloc); /*@i43 pieces's should have locs! */
96 llassert (mtDeclarationPiece_isUndefined (res));
97 res = pieces->thisPiece;
101 pieces = pieces->rest;
107 extern void mtDeclarationPieces_free (/*@only@*/ mtDeclarationPieces node)
109 if (mtDeclarationPieces_isDefined (node))
111 mtDeclarationPiece_free (node->thisPiece);
112 mtDeclarationPieces_free (node->rest);