]> andersk Git - splint.git/blobdiff - src/qtype.c
Added files for the splint.sf.net repository as part of the merge process.
[splint.git] / src / qtype.c
index 5bdc8660781035773cc00b4d61235dbda3137710..d2849875930ea90304fe65f189c3a0eea4b2d7a6 100644 (file)
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -28,7 +28,7 @@
 ** qtypes are mutable
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 
 /*@notnull@*/ qtype qtype_create (ctype c)
@@ -56,11 +56,14 @@ qtype qtype_unknown ()
 
 qtype qtype_addQual (qtype qt, qual q)
 {
+  DPRINTF (("Add qual: %s / %s", qtype_unparse (qt), qual_unparse (q)));
+
   if (qtype_isDefined (qt))
     {
       qt->quals = qualList_add (qt->quals, q);
     }
 
+  DPRINTF (("==> %s", qtype_unparse (qt)));
   return qt;
 }
 
@@ -122,6 +125,8 @@ qtype qtype_mergeImplicitAlt (/*@returned@*/ qtype q1, /*@only@*/ qtype q2)
 
 qtype qtype_mergeAlt (/*@returned@*/ qtype q1, /*@only@*/ qtype q2)
 {
+  DPRINTF (("Merge alt: %s + %s", qtype_unparse (q1), qtype_unparse (q2)));
+
   if (qtype_isDefined (q1) && qtype_isDefined (q2))
     {
       if (context_getFlag (FLG_IMPCONJ))
@@ -132,7 +137,6 @@ qtype qtype_mergeAlt (/*@returned@*/ qtype q1, /*@only@*/ qtype q2)
        {
          q1->type = ctype_makeExplicitConj (q1->type, q2->type);
        }
-
       
       if (!qualList_isEmpty (q2->quals))
        {
@@ -146,12 +150,14 @@ qtype qtype_mergeAlt (/*@returned@*/ qtype q1, /*@only@*/ qtype q2)
 
 qtype qtype_combine (/*@returned@*/ qtype q1, ctype ct)
 {
+  DPRINTF (("Combine: %s %s", qtype_unparse (q1), ctype_unparse (ct)));
   if (qtype_isDefined (q1))
     {
       /* ct is modifier (or q1->type is unknown) */
       q1->type = ctype_combine (q1->type, ct); 
     }
 
+  DPRINTF (("Combine: %s %s", qtype_unparse (q1), ctype_unparse (ct)));
   return q1;
 }
 
@@ -159,12 +165,67 @@ qtype qtype_resolve (/*@returned@*/ qtype q)
 {
   if (qtype_isDefined (q))
     {
+      DPRINTF (("Resolving: %s", qtype_unparse (q)));
       q->type = ctype_resolve (q->type);
+      DPRINTF (("Resolving: %s", qtype_unparse (q)));
     }
 
   return q;
 }
 
+/* drl 04-24-2002 added for code generation */
+bool qtype_isArray (qtype q) /*@*/
+{
+  if (qtype_isDefined (q))
+    {
+      bool ret;
+      ret = ctype_isArray(q->type);
+      return ret;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+bool qtype_isFixedArray (qtype q) /*@*/
+{
+  if (qtype_isDefined (q))
+    {
+      bool ret;
+      ret = ctype_isFixedArray(q->type);
+      return ret;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+cstring qtype_unparseArrayType (qtype q)
+{
+  cstring ret, temp;
+
+  llassert( qtype_isDefined (q) &&( qtype_isFixedArray(q)|| qtype_isArray(q) ) );
+  
+  temp = message ("%q%s", qualList_unparse (q->quals), ctype_unparse (q->type) );
+  ret = cstring_beforeChar(temp, '[');
+  cstring_free(temp);
+  return ret;
+}
+
+cstring qtype_unparseArraySize (qtype q)
+{
+  cstring ret, temp;
+  
+  llassert( qtype_isDefined (q) && qtype_isFixedArray(q) );
+  
+  temp = message ("%s", ctype_unparse (q->type) );
+  ret = cstring_copy(cstring_afterChar(temp, '[') );
+  cstring_free(temp);
+  return ret;
+}
+
 cstring qtype_unparse (qtype q)
 {
   if (qtype_isDefined (q))
@@ -182,7 +243,9 @@ qtype qtype_newBase (/*@returned@*/ qtype q, ctype ct)
 {
   if (qtype_isDefined (q))
     {
+      DPRINTF (("new base: %s -> %s", qtype_unparse (q), ctype_unparse (ct)));
       q->type = ctype_newBase (ct, q->type);
+      DPRINTF (("new base: %s -> %s", qtype_unparse (q), ctype_unparse (ct)));
     }
 
   return q;
@@ -196,6 +259,7 @@ qtype qtype_newQbase (qtype q1, qtype q2)
       q1->quals = qualList_appendList (q1->quals, q2->quals);
     }
 
+  DPRINTF (("new base: %s -> %s", qtype_unparse (q1), qtype_unparse (q1)));
   return q1;
 }
 
@@ -204,6 +268,12 @@ void qtype_adjustPointers (int n, qtype q)
   if (qtype_isDefined (q))
     {
       q->type = ctype_adjustPointers (n, q->type);
+
+      if (hasInnerConstQual() )
+       {
+         q->quals = qualList_add (q->quals,   qual_createPlain( QU_INNERCONST) );
+       }
+      resetInnerConstQual ();
     }
 }
 
This page took 0.050693 seconds and 4 git commands to generate.