** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-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
*/
/*
ctkind_fromInt (int i)
{
/*@+enumint@*/
- if (i < CTK_UNKNOWN || i > CTK_COMPLEX)
+ if (i < CTK_ANYTYPE || i > CTK_COMPLEX)
{
llcontbug (message ("ctkind_fromInt: out of range: %d", i));
return CTK_INVALID;
}
}
-ctype ctype_makeFixedArray (ctype c, long size)
+ctype ctype_makeFixedArray (ctype c, size_t size)
{
- return (cttable_addDerived (CTK_ARRAY, ctbase_makeFixedArray (c, size), c));
+ ctype res;
+ res = cttable_addDerived (CTK_ARRAY, ctbase_makeFixedArray (c, size), c);
+ return res;
+}
+
+ctype ctype_makeInnerFixedArray (ctype c, size_t size)
+{
+ ctype res;
+
+ if (ctype_isFixedArray (c))
+ {
+ ctype cb = ctype_baseArrayPtr (c);
+ size_t osize = ctype_getArraySize (c);
+
+ res = ctype_makeFixedArray (ctype_makeInnerFixedArray (cb, size), osize);
+ }
+ else if (ctype_isArray (c))
+ {
+ ctype cb = ctype_baseArrayPtr (c);
+
+ res = ctype_makeArray (ctype_makeInnerFixedArray (cb, size));
+ }
+ else
+ {
+ res = ctype_makeFixedArray (c, size);
+ }
+
+ DPRINTF (("Make inner fixed array: %s", ctype_unparse (res)));
+ return res;
+}
+
+ctype ctype_makeInnerArray (ctype c)
+{
+ ctype res;
+
+ DPRINTF (("Make inner array: %s", ctype_unparse (c)));
+
+ if (ctype_isFixedArray (c))
+ {
+ ctype cb = ctype_baseArrayPtr (c);
+ size_t osize = ctype_getArraySize (c);
+
+ res = ctype_makeFixedArray (ctype_makeInnerArray (cb), osize);
+ }
+ else
+ {
+ res = ctype_makeArray (c);
+ }
+
+ DPRINTF (("Make inner array: %s", ctype_unparse (res)));
+ return res;
}
ctype
ctentry cte = ctype_getCtentry (c);
ctype clp = ctentry_getArray (cte);
+ DPRINTF (("Make array: %s", ctype_unparse (c)));
+
if /*@+enumint@*/ (clp == CTK_DNE) /*@=enumint@*/
{
ctype cnew = cttable_addDerived (CTK_ARRAY, ctbase_makeArray (c), c);
return (cnew);
}
else
- return clp;
+ {
+ return clp;
+ }
}
/*
return (cttable_addComplex (ctbase_expectFunction (c)));
}
+ctype ctype_dontExpectFunction (ctype c)
+{
+ ctbase ctb = ctype_getCtbase (c);
+
+ /* what about this?
+ if (!ctype_isAP (c))
+ {
+ c = ctype_makePointer (c);
+ }
+ */
+
+ return (ctbase_getExpectFunction (ctb));
+}
+
/*
** makeRealFunction: function returning base
*/
return (ctype_isArray (c) && !ctype_isFixedArray (c));
}
-bool ctype_isFixedArray (ctype c)
-{
- if (ctype_isElips (c)) return FALSE;
-
- return (ctbase_isFixedArray (ctype_getCtbaseSafe (c)));
-}
-
bool
ctype_isArrayPtr (ctype c)
{
{
return cstring_makeLiteralTemp ("?");
}
+ else if (ctype_isAnytype (c))
+ {
+ return cstring_makeLiteralTemp ("<any>");
+ }
else
{
/*@-modobserver@*/
switch (ctentry_getKind (cte))
{
+ case CTK_ANYTYPE:
case CTK_UNKNOWN:
case CTK_INVALID:
case CTK_PLAIN:
ctype ctype_resolve (ctype c)
{
- if (ctype_isUnknown (c)) return ctype_int;
- return c;
+ if (ctype_isUnknown (c))
+ {
+ return ctype_int;
+ }
+ else if (c == ctype_anytype)
+ {
+ return ctype_unknown;
+ }
+ else
+ {
+ return c;
+ }
}
ctype ctype_fromQual (qual q)
llbuglit ("ctype_getCtbase: ctype dne");
if (c == ctype_elipsMarker)
llbuglit ("ctype_getCtbase: elips marker");
-
+ if (c == ctype_anytype)
+ llbuglit ("ctype_getCtbase: ctype anytype");
+
llfatalbug (message ("ctype_getCtbase: ctype out of range: %d", c));
BADEXIT;
}
}
else if (c == CTK_UNKNOWN)
llcontbuglit ("ctype_getCtentry: ctype unknown");
+ else if (c == CTK_ANYTYPE)
+ llcontbuglit ("ctype_getCtentry: ctype unknown");
else if (c == CTK_INVALID)
llcontbuglit ("ctype_getCtentry: ctype invalid (ctype_undefined)");
else if (c == CTK_DNE)
/*@=enumint@*/
}
+
+bool ctype_isFixedArray (ctype c)
+{
+ if (ctype_isElips (c)) return FALSE;
+
+ return (ctbase_isFixedArray (ctype_getCtbaseSafe (c)));
+}
+
+
/*drl 11/28/2000 */
/* requires that the type is an fixed array */
/* return the size of the array */
-long int ctype_getArraySize (ctype c)
+size_t ctype_getArraySize (ctype c)
{
- long int size;
- ctentry cte = ctype_getCtentry (c);
+ size_t size;
+
ctbase ctb;
llassert (ctype_isFixedArray (c));
- llassert ((ctentry_getKind (cte) == CTK_COMPLEX) || (ctentry_getKind (cte) == CTK_ARRAY));
- ctb = cte->ctbase;
+ ctb = ctype_getCtbaseSafe(c);
size = ctbase_getArraySize (ctb);
DPRINTF ((message ("ctype_getArraySize: got fixed array size of %s / %d ",