Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

clauseStack.c File Reference

#include "lclintMacros.nf"
#include "basic.h"

Go to the source code of this file.

Functions

clauseStack clauseStack_new ()
void clauseStack_push (clauseStack s, clause el)
void clauseStack_pop (clauseStack s)
clause clauseStack_top (clauseStack s)
void clauseStack_switchTop (clauseStack s, clause x)
void clauseStack_removeFirst (clauseStack s, clause key)
int clauseStack_controlDepth (clauseStack s)
cstring clauseStack_unparse (clauseStack s)
void clauseStack_clear (clauseStack s)
void clauseStack_free (clauseStack s)


Function Documentation

void clauseStack_clear ( clauseStack s )
 

Definition at line 175 of file clauseStack.c.

Referenced by context_exitAllClauses().

00176 {
00177   s->nspace += s->nelements;
00178   s->nelements = 0;
00179 }

int clauseStack_controlDepth ( clauseStack s )
 

Definition at line 136 of file clauseStack.c.

00137 {
00138   int depth = 0;
00139   int i;
00140 
00141   for (i = 0; i < s->nelements; i++)
00142     {
00143       clause current = s->elements[i];
00144 
00145       if (clause_isConditional (current))
00146         {
00147           depth++;
00148         }
00149     }
00150 
00151   return depth;
00152 }

void clauseStack_free ( clauseStack s )
 

Definition at line 182 of file clauseStack.c.

Referenced by context_destroyMod().

00183 {
00184   sfree (s->elements); 
00185   sfree (s);
00186 }

clauseStack clauseStack_new ( )
 

Definition at line 36 of file clauseStack.c.

Referenced by context_initMod().

00037 {
00038   clauseStack s = (clauseStack) dmalloc (sizeof (*s));
00039   
00040   s->nelements = 0;
00041   s->nspace = clauseStackBASESIZE; 
00042   s->elements = (clause *) dmalloc (sizeof (*s->elements) * clauseStackBASESIZE);
00043   s->current = 0;
00044   
00045   return (s);
00046 }

void clauseStack_pop ( clauseStack s )
 

Definition at line 83 of file clauseStack.c.

Referenced by clauseStack_removeFirst(), context_exitAllClauses(), context_exitAndClause(), context_exitClause(), context_exitDoWhileClause(), context_exitForClause(), context_exitIterClause(), context_exitOrClause(), context_exitSwitch(), context_exitTrueClause(), and context_exitWhileClause().

00084 {
00085   s->nelements--;
00086   s->nspace++;
00087   }

void clauseStack_push ( clauseStack s,
clause el )
 

Definition at line 73 of file clauseStack.c.

00074 {
00075   if (s->nspace <= 0)
00076     clauseStack_grow (s);
00077   
00078   s->nspace--;
00079   s->elements[s->nelements] = el;
00080   s->nelements++;
00081   }

void clauseStack_removeFirst ( clauseStack s,
clause key )
 

Definition at line 102 of file clauseStack.c.

Referenced by context_exitInner().

00103 {
00104   if (clauseStack_top (s) == key) 
00105     {
00106       clauseStack_pop (s);
00107     }
00108   else
00109     {
00110       int i;
00111       
00112       for (i = s->nelements - 2; i >= 0; i--)
00113         {
00114           clause el = s->elements[i];
00115           
00116           if (el == key) 
00117             {
00118               int j;
00119 
00120               for (j = i; j < s->nelements - 1; j++)
00121                 {
00122                   s->elements[j] = s->elements[j + 1];
00123                 }
00124 
00125               s->nelements--;
00126               s->nspace++;
00127               return;
00128             }
00129         }
00130       
00131       llbuglit ("clauseStack_removeFirst: not found");
00132     }
00133 }

void clauseStack_switchTop ( clauseStack s,
clause x )
 

Definition at line 94 of file clauseStack.c.

00095 {
00096   llassert (s->nelements > 0);
00097   
00098   s->elements[s->nelements - 1] = x;
00099 }

clause clauseStack_top ( clauseStack s )
 

Definition at line 89 of file clauseStack.c.

Referenced by clauseStack_removeFirst(), and context_exitAllClauses().

00090 {
00091   return (s->elements[s->nelements - 1]);
00092 }

cstring clauseStack_unparse ( clauseStack s )
 

Definition at line 155 of file clauseStack.c.

Referenced by context_exitWhileClause(), and context_unparseClauses().

00156 {
00157   int i;
00158   cstring st = cstring_makeLiteral ("[");
00159   
00160   for (i = 0; i < s->nelements; i++)
00161     {
00162       if (i == 0)
00163         {
00164           st = message ("%q %s", st, clause_unparse (s->elements[i]));
00165         }
00166       else
00167         st = message ("%q, %s", st, clause_unparse (s->elements[i]));
00168     }
00169   
00170   st = message ("%q ]", st);
00171   return st;
00172 }


Generated at Fri Nov 3 18:57:50 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000