ctype
ctype_createAbstract (typeId u)
{
- /* requires: ctype_createAbstract (u) is never called more than once for any u. */
- /* [ tested by cttable_addFullSafe, not really required ] */
+ /* requires: ctype_createAbstract (u) is never called more than once for any u. */
+ /* [ tested by cttable_addFullSafe, not really required ] */
+
return (cttable_addFullSafe (ctentry_makeNew (CTK_PLAIN, ctbase_createAbstract (u))));
}
bool
ctype_isUA (ctype c)
{
- return (!ctype_isUnknown (c) && ctbase_isUA (ctype_getCtbase (c)));
+ return (!ctype_isUnknown (c)
+ && ctbase_isUA (ctype_getCtbase (c)));
}
bool
ctype
ctype_makeExplicitConj (ctype c1, ctype c2)
{
- if (ctype_isFunction (c1) && !ctype_isFunction (c2))
+ if (ctype_isAnytype (c1) || ctype_isAnytype (c2))
+ {
+ return ctype_makeAnytype ();
+ }
+ else if (ctype_isFunction (c1) && !ctype_isFunction (c2))
{
ctype ret = ctype_makeExplicitConj (ctype_getReturnType (c1), c2);
static ctype ivbf = ctype_unknown; /* int | void * | bool | float */
static ctype cuc = ctype_unknown; /* char | unsigned char */
+static ctype cany = ctype_unknown;
+
+ctype
+ctype_makeAnytype ()
+{
+ if (cany == ctype_unknown)
+ {
+ cany = ctype_makeConj (ctype_unknown, ctype_dne);
+ llassert (ctype_isAnytype (cany));
+ }
+
+ DPRINTF (("make anytype: %s", ctype_unparse (cany)));
+ return cany;
+}
+
+bool
+ctype_isAnytype (ctype c)
+{
+ return (c == cany);
+}
+
static void
ctype_recordConj (ctype c)
{
DPRINTF (("Make conj: %s / %s", ctype_unparse (c1), ctype_unparse (c2)));
- if (ctype_isUnknown (c1))
+ if (ctype_isAnytype (c1))
+ {
+ return c1;
+ }
+ else if (ctype_isAnytype (c2))
+ {
+ return c2;
+ }
+ else if (ctype_isUnknown (c1))
{
return c2;
}
{
;
}
-
return (cttable_addComplex (ctbase_makeConj (c1, c2, FALSE)));
}
cstring
ctype_unparseDeclaration (ctype c, /*@only@*/ cstring name)
{
- llassert (! (ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
+ llassert (!(ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
if (ctype_isUnknown (c))
{
{
return cstring_makeLiteralTemp ("-");
}
- else if (ctype_isUnknown (c))
- {
- return cstring_makeLiteralTemp ("?");
- }
else if (ctype_isAnytype (c))
{
return cstring_makeLiteralTemp ("<any>");
}
+ else if (ctype_isUnknown (c))
+ {
+ return cstring_makeLiteralTemp ("?");
+ }
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))
+ if (ctype_isUnknown (c) && !ctype_isAnytype (c))
{
+ DPRINTF (("Resolving to int: %s", ctype_unparse (c)));
return ctype_int;
}
- else if (c == ctype_anytype)
- {
- return ctype_unknown;
- }
- else
- {
- return c;
- }
+
+ return c;
}
ctype ctype_fromQual (qual q)