]> andersk Git - splint.git/blobdiff - src/ctbase.i
Fixed configuration problem (hopefully).
[splint.git] / src / ctbase.i
index cea6f1846a237b7e0b8a6d13ffb4bc7c18cc090f..5e3d374b02999ce27059f533e00114b21462706c 100644 (file)
@@ -69,7 +69,8 @@ static void cttable_grow (void);
 static ctype cttable_addDerived (ctkind p_ctk, /*@keep@*/ ctbase p_cnew, ctype p_base);
 static ctype cttable_addFull (/*@keep@*/ ctentry p_cnew);
 static bool ctentry_isInteresting (ctentry p_c) /*@*/;
-static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, long p_size) /*@*/ ;
+static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, size_t p_size) /*@*/ ;
+static bool ctbase_isAnytype (/*@notnull@*/ ctbase p_b) /*@*/ ;
 
 /* 
 ** These are file-static macros (used in ctype.c).  No way to
@@ -168,7 +169,7 @@ typedef struct
 typedef struct
 {
   ctype base;
-  long size;
+  size_t size;
 } *tfixed;
  
 typedef union 
@@ -277,7 +278,7 @@ static bool ctuid_isAP (ctuid c) /*@*/
 
 static typeId ctbase_typeId (ctbase p_c);
 static /*@only@*/ cstring ctbase_dump (ctbase p_c);
-static /*@only@*/ ctbase ctbase_undump (char **p_c);
+static /*@only@*/ ctbase ctbase_undump (char **p_c) /*@requires maxRead(*p_c) >= 2 @*/;
 static int ctbase_compare (ctbase p_c1, ctbase p_c2, bool p_strict);
 static bool ctbase_matchArg (ctbase p_c1, ctbase p_c2);
 static /*@notnull@*/ /*@only@*/ ctbase 
@@ -492,7 +493,8 @@ ctbase_unparse (ctbase c)
          return (message ("%t *", c->contents.base));
        }
     case CT_FIXEDARRAY:
-      return (message ("%t [%d]", c->contents.farray->base, 
+      return (message ("%t [%d]", 
+                      c->contents.farray->base, 
                       (int) c->contents.farray->size));
     case CT_ARRAY:
       return (message ("%t []", c->contents.base));
@@ -537,7 +539,11 @@ ctbase_unparse (ctbase c)
                           enumNameList_unparseBrief (c->contents.cenum->members)));
        }
     case CT_CONJ:
-      if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
        {
          if (!ctype_isSimple (c->contents.conj->a) ||
              !ctype_isSimple (c->contents.conj->b))
@@ -608,7 +614,14 @@ static /*@only@*/ cstring
     case CT_UNION:
       return (message ("union %s { ... }", c->contents.su->name));
     case CT_CONJ:
-      return (message ("%t", c->contents.conj->a));
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else
+       {
+         return (message ("%t", c->contents.conj->a));
+       }
     BADDEFAULT;
     }
   BADEXIT;
@@ -656,9 +669,16 @@ ctbase_unparseNotypes (ctbase c)
     case CT_ENUMLIST:
       return (message ("[enumlist]"));
     case CT_CONJ:
-      return (message ("%q/%q", 
-                      ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)),
-                      ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b))));
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else
+       {
+         return (message ("%q/%q", 
+                          ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)),
+                          ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b))));
+       }
     BADDEFAULT;
     }
   BADEXIT;
@@ -753,8 +773,12 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/
                           enumNameList_unparseBrief (c->contents.cenum->members),
                           name));
        }
-    case CT_CONJ:      
-      if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
+    case CT_CONJ:
+      if (ctbase_isAnytype (c))
+       {
+         return (message ("<any> %q", name));
+       }
+      else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
        {
          if (!ctype_isSimple (c->contents.conj->a) ||
              !ctype_isSimple (c->contents.conj->b))
@@ -789,7 +813,7 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/
   BADEXIT;
 }
 
-static ctbase ctbase_undump (d_char *c)
+static ctbase ctbase_undump (d_char *c) /*@requires maxRead(*c) >= 2 @*/
 {
   ctbase res;
   char p = **c;
@@ -827,10 +851,10 @@ static ctbase ctbase_undump (d_char *c)
     case 'F':
       {
        ctype ct = ctype_undump (c);
-       int size;
+       size_t size;
 
        reader_checkChar (c, '/');
-       size = reader_getInt (c);
+       size = size_fromInt (reader_getInt (c));
        reader_checkChar (c, '|');
        return (ctbase_makeFixedArray (ct, size));
       }
@@ -943,7 +967,7 @@ static ctbase ctbase_undump (d_char *c)
       llerror (FLG_SYNTAX, 
               message ("Bad Library line (type): %s", cstring_fromChars (*c)));
 
-      while (**c != '\0')
+  /*drl bee: pbr*/      while (**c != '\0')
        {
          (*c)++;
        }
@@ -1165,6 +1189,19 @@ ctbase_expectFunction (ctype c)
   return (f);
 }
 
+static bool
+ctbase_isExpectFunction (/*@notnull@*/ ctbase ct) /*@*/
+{
+  return (ct->type == CT_EXPFCN);
+}
+
+static ctype
+ctbase_getExpectFunction (/*@notnull@*/ ctbase ct)
+{
+  llassert (ctbase_isExpectFunction (ct));
+  return ct->contents.base;
+}
+
 static bool
 ctbase_genMatch (ctbase c1, ctbase c2, bool force, bool arg, bool def, bool deep)
 {
@@ -1654,7 +1691,7 @@ ctbase_makeArray (ctype b)
 }
 
 static /*@notnull@*/ /*@only@*/ ctbase
-ctbase_makeFixedArray (ctype b, long size)
+ctbase_makeFixedArray (ctype b, size_t size)
 {
   ctbase c = ctbase_new ();
 
@@ -1825,6 +1862,23 @@ static /*@only@*/ ctbase
   return (c);
 }
 
+static bool ctbase_isAnytype (/*@notnull@*/ ctbase b)
+{
+  /*
+  ** A unknown|dne conj is a special representation for an anytype.
+  */
+
+  if (b->type == CT_CONJ)
+    {
+      /*@access ctype@*/
+      return (b->contents.conj->a == ctype_unknown
+             && b->contents.conj->b == ctype_dne);
+      /*@noaccess ctype@*/ 
+    }
+  
+  return FALSE;
+}
+
 static ctype
 ctbase_getConjA (/*@notnull@*/ ctbase c)
 {
@@ -2499,12 +2553,14 @@ ctbase_almostEqual (ctbase c1, ctbase c2)
   called by ctype_getArraySize
 */
 
-long int ctbase_getArraySize (ctbase ctb)
+size_t ctbase_getArraySize (ctbase ctb)
 {
-  llassert (ctbase_isDefined (ctb) );
+  /*drl 1/25/2002 fixed discovered by Jim Francis */
+  ctbase r;
   
-  llassert (ctbase_isFixedArray(ctb) );
-  
-  return (ctb->contents.farray->size);
+  llassert (ctbase_isDefined (ctb) );
+  r = ctbase_realType (ctb);
+  llassert (ctbase_isFixedArray(r) );
 
+  return (r->contents.farray->size);
 }
This page took 0.116819 seconds and 4 git commands to generate.