]> andersk Git - splint.git/blobdiff - src/constraintTerm.c
Fixed internal error that occured if user tried to load a lcd file they created for...
[splint.git] / src / constraintTerm.c
index bac71fc45ff02306c7f57682625519577a3314e7..868c9d551622252f1e82f7cac0020eefc82b9f06 100644 (file)
@@ -1,11 +1,35 @@
 /*
-** constraintExpr.c
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
+**         Massachusetts Institute of Technology
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License as published by the
+** Free Software Foundation; either version 2 of the License, or (at your
+** option) any later version.
+** 
+** This program is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+** General Public License for more details.
+** 
+** The GNU General Public License is available from http://www.gnu.org/ or
+** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+** MA 02111-1307, USA.
+**
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
+*/
+
+/*
+** constraintTerm.c
 */
 
 /* #define DEBUGPRINT 1 */
 
 # include <ctype.h> /* for isdigit */
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "cgrammar.h"
 # include "cgrammar_tokens.h"
 # include "exprNodeSList.h"
 
 /*@-czechfcns@*/
+/*@-nullderef@*/ /* !!! DRL needs to fix this code! */
+/*@-nullstate@*/ /* !!! DRL needs to fix this code! */
+/*@-nullpass@*/ /* !!! DRL needs to fix this code! */
+/*@-temptrans@*/ /* !!! DRL needs to fix this code! */
 
-/*@access exprNode @*/
+/*@access exprNode@*/ /* !!! NO! Don't do this recklessly! */
 
 bool constraintTerm_isDefined (constraintTerm t)
 {
@@ -399,7 +427,20 @@ long constraintTerm_getValue (constraintTerm term)
   BADEXIT;
 }
 
-static /*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
+/*drl added this 10.30.001
+ */
+
+/*@exposed@*/ exprNode constraintTerm_getExprNode (constraintTerm t)
+{
+  llassert (t != NULL);
+  
+  llassert (t->kind == EXPRNODE);
+
+  return t->value.expr;
+
+}
+
+ /*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
 {
   llassert (t != NULL);
   if (t->kind == EXPRNODE)
@@ -421,7 +462,7 @@ bool constraintTerm_probSame (constraintTerm term1, constraintTerm term2)
 
   llassert (term1 !=NULL && term2 !=NULL);
      
- DPRINTF ( (message
+ DPRINTF ((message
            ("Comparing srefs for %s and  %s ", constraintTerm_print(term1), constraintTerm_print(term2)
             )
            )
@@ -473,7 +514,7 @@ bool constraintTerm_similar (constraintTerm term1, constraintTerm term2)
       return FALSE;
     }
   
-  DPRINTF( (message
+  DPRINTF((message
            ("Comparing srefs for %s and  %s ", constraintTerm_print(term1), constraintTerm_print(term2)
             )
            )
@@ -540,6 +581,10 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
            fprintf(f, "Param %s %d\n", cstring_toCharsSafe(ctString), (int) param );
            cstring_free(ctString);
          }
+       else if (sRef_isField (s) )
+         {
+           fprintf(f, "sRef_dump %s\n", cstring_toCharsSafe(sRef_dump(s)) );
+         }
        else
          {
            u = sRef_getUentry(s);
@@ -560,7 +605,7 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 }
 
 
-/*@only@*/ constraintTerm constraintTerm_undump ( FILE *f)
+/*@only@*/ constraintTerm constraintTerm_undump (FILE *f)
 {
   constraintTermType kind;
   constraintTerm ret;
@@ -570,13 +615,17 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
   char *str;
   char *os;
 
-  str = mstring_create (MAX_DUMP_LINE_LENGTH);
-  os = str;
+  os = mstring_create (MAX_DUMP_LINE_LENGTH);
+
   str = fgets (os, MAX_DUMP_LINE_LENGTH, f);
 
+  llassert (str != NULL);
+
   kind = (constraintTermType) reader_getInt(&str);
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  llassert (str != NULL);
+
   switch (kind)
     {
       
@@ -606,6 +655,11 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
            s = sRef_makeParam (param, t, stateInfo_makeLoc (g_currentloc));
            free (ostr2);
          }
+       else if (strcmp (term, "sRef_dump" ) == 0 )
+         {
+           reader_checkChar(&str, ' ');
+           s = sRef_undump (&str);
+         }
        else  /* This must be an identified that we can search for in usymTab */
          {
            cstring termStr = cstring_makeLiteralTemp(term);
@@ -658,4 +712,28 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 
 
 
+/* drl added sometime before 10/17/001*/
+ctype constraintTerm_getCType (constraintTerm term)
+{
+  ctype ct;
+  
+  switch (term->kind)
+    {
+    case EXPRNODE:
+      ct = exprNode_getType (term->value.expr);
+      break;
+
+    case INTLITERAL:
+      /*@i888*/ /* hack */
+      ct = ctype_signedintegral;
+      break;
+      
+    case SREF:
+      ct = sRef_getType (term->value.sref) ;
+      break;
+    default:
+      BADEXIT;
+    }
+  return ct;
+}
 
This page took 0.047646 seconds and 4 git commands to generate.