]> andersk Git - splint.git/blobdiff - src/ctbase.i
Merged this branch with the one in the splint.sf.net repository.
[splint.git] / src / ctbase.i
index 5e3d374b02999ce27059f533e00114b21462706c..56d31aae37054e245a398329a56b0e465102b092 100644 (file)
@@ -72,6 +72,7 @@ static bool ctentry_isInteresting (ctentry p_c) /*@*/;
 static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, size_t p_size) /*@*/ ;
 static bool ctbase_isAnytype (/*@notnull@*/ ctbase p_b) /*@*/ ;
 
+cstring ctbase_unparseFunctionPointer (ctbase c, /*@only@*/ cstring name) /*@*/ ;
 /* 
 ** These are file-static macros (used in ctype.c).  No way to
 ** declare them as static in C.
@@ -90,6 +91,9 @@ static bool ctbase_isAnytype (/*@notnull@*/ ctbase p_b) /*@*/ ;
 # define ctentry_setPtr(c,b)      ((c)->ptr = (b))
 
 # define ctbase_fixUser(c)        (c = ctbase_realType(c))
+
+/*drl added 04/14/2002 */
+# define ctentry_getCtbase(c)       ((c)->ctbase)
 /*@=allmacros@*/ /*@=macrospec@*/ /*@=namechecks@*/
 
 static ctype cttable_addComplex (/*@notnull@*/ /*@only@*/ ctbase p_cnew);
@@ -493,9 +497,29 @@ ctbase_unparse (ctbase c)
          return (message ("%t *", c->contents.base));
        }
     case CT_FIXEDARRAY:
-      return (message ("%t [%d]", 
-                      c->contents.farray->base, 
-                      (int) c->contents.farray->size));
+      if (ctype_isFixedArray ( c->contents.farray->base ) &&(willOutputCode) )
+       
+       {
+         cstring tmp, tmp2, ret;
+         
+         tmp = ctype_unparse( c->contents.farray->base);
+         tmp2 = cstring_beforeChar(tmp, '[');
+         
+         ret = message("%q [%d] %s ",
+                       tmp2,
+                       c->contents.farray->size,
+                       cstring_afterChar(tmp, '[')
+                       );
+         return ret;
+       }
+      
+      else
+       {
+         return (message ("%t [%d]", 
+                  c->contents.farray->base, 
+                  (int) c->contents.farray->size));
+       }
+      
     case CT_ARRAY:
       return (message ("%t []", c->contents.base));
     case CT_FCN:
@@ -512,7 +536,7 @@ ctbase_unparse (ctbase c)
       else
        {
          return (message ("struct { %q }", 
-                          uentryList_unparseAbbrev (c->contents.su->fields))); 
+                          uentryList_unparse (c->contents.su->fields)));       
        }
     case CT_UNION:
       if (cstring_isDefined (c->contents.su->name) &&
@@ -610,6 +634,10 @@ static /*@only@*/ cstring
                       uentryList_unparse (c->contents.fcn->params),
                       c->contents.fcn->rval));
     case CT_STRUCT:
+      if (context_getFlag(FLG_GENERATECODE) )
+       {
+         DPRINTF( (message("struct %s { %s }",  c->contents.su->name, uentryList_unparse(c->contents.su->fields) ) ));
+       }
       return (message ("struct %s { ... } ", c->contents.su->name));
     case CT_UNION:
       return (message ("union %s { ... }", c->contents.su->name));
@@ -709,7 +737,7 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/
     case CT_PTR:
       if (ctype_isFunction (c->contents.base))
        {
-         return ctbase_unparseDeclaration (ctype_getCtbase (c->contents.base), name);
+         return ctbase_unparseFunctionPointer (ctype_getCtbase (c->contents.base), name);
        }
       else
        {
@@ -813,6 +841,105 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/
   BADEXIT;
 }
 
+
+
+/*drl added 04/22/2002*/
+ /*@only@*/ cstring
+ctbase_doUnparseFunctionPointer (ctbase c, /*@only@*/ cstring name, cstring quals) /*@*/ 
+{
+  cstring s;
+  
+  if (ctbase_isUndefined (c))
+    {
+      return name;
+    }
+
+  if (c->type == CT_FCN)
+    {
+      s = message ("%s (*%q)(%q)", quals, name, 
+                  uentryList_unparseParamsComplete (c->contents.fcn->params));
+      
+         return (ctbase_unparseDeclaration 
+                 (ctype_getCtbase (c->contents.fcn->rval), s));
+    }
+  else
+    {
+      llassert (c->type == CT_PTR);
+      llassert(FALSE);
+      //  s = message("%q", ctype_unparseFunction ( c->contents.base, name)  );
+         
+     s = message("%q", ctbase_unparse /*Declaration*/ (c) /* name)*/ );
+      return s;
+
+    }
+}
+
+
+/*drl added 04/22/2002*/
+ /*@only@*/ cstring
+ctbase_unparseFunctionPointer (ctbase c, /*@only@*/ cstring name) /*@*/ 
+{
+  cstring s;
+  
+  if (ctbase_isUndefined (c))
+    {
+      return name;
+    }
+
+  if (c->type == CT_FCN)
+    {
+      //      llassert(FALSE);
+      s = message ("(*%q)(%q)", name, 
+                  uentryList_unparseParamsComplete (c->contents.fcn->params));
+      
+         return (ctbase_unparseDeclaration 
+                 (ctype_getCtbase (c->contents.fcn->rval), s));
+    }
+  else
+    {
+      llassert (c->type == CT_PTR);
+      s = message("%q", ctype_unparseFunction ( c->contents.base, name)  );
+         
+   //    s = message("%q", ctbase_unparse /*Declaration*/ (c) /* name)*/ );
+      return s;
+
+    }
+}
+
+
+/*drl added 3/10/2002*/
+
+ /*@only@*/ cstring
+ctbase_unparseFunction (ctbase c, /*@only@*/ cstring name) /*@*/ 
+{
+  cstring s;
+  
+  if (ctbase_isUndefined (c))
+    {
+      return name;
+    }
+
+  if (c->type == CT_FCN)
+    {
+      s = message ("%q(%q)", name, 
+                  uentryList_unparseParamsComplete (c->contents.fcn->params));
+      
+         return (ctbase_unparseDeclaration 
+                 (ctype_getCtbase (c->contents.fcn->rval), s));
+    }
+  else
+    {
+      
+      llassert (c->type == CT_PTR);
+
+      
+      s = message("%q", ctbase_unparse /*Declaration*/ (c) /* name)*/ );
+      return s;
+
+    }
+}
+
+
 static ctbase ctbase_undump (d_char *c) /*@requires maxRead(*c) >= 2 @*/
 {
   ctbase res;
This page took 0.061521 seconds and 4 git commands to generate.