Esempio n. 1
0
Expression *Type::getInternalTypeInfo(Scope *sc)
{   TypeInfoDeclaration *tid;
    Expression *e;
    Type *t;
    static TypeInfoDeclaration *internalTI[TMAX];

    //printf("Type::getInternalTypeInfo() %s\n", toChars());
    t = toBasetype();
    switch (t->ty)
    {
    case Tsarray:
#if 0
        // convert to corresponding dynamic array type
        t = t->nextOf()->mutableOf()->arrayOf();
#endif
        break;

    case Tclass:
        if (static_cast<TypeClass *>(t)->sym->isInterfaceDeclaration())
        break;
        goto Linternal;

    case Tarray:
    #if DMDV2
        // convert to corresponding dynamic array type
        t = t->nextOf()->mutableOf()->arrayOf();
    #endif
        if (t->nextOf()->ty != Tclass)
        break;
        goto Linternal;

    case Tfunction:
    case Tdelegate:
    case Tpointer:
    Linternal:
        tid = internalTI[t->ty];
        if (!tid)
        {   tid = new TypeInfoDeclaration(t, 1);
        internalTI[t->ty] = tid;
        }
        e = new VarExp(0, tid);
        e = e->addressOf(sc);
        e->type = tid->type;    // do this so we don't get redundant dereference
        return e;

    default:
        break;
    }
    //printf("\tcalling getTypeInfo() %s\n", t->toChars());
    return t->getTypeInfo(sc);
}
Esempio n. 2
0
File: glue.c Progetto: Geod24/dnet
unsigned Type::totym()
{   unsigned t;

    switch (ty)
    {
	case Tvoid:	t = TYvoid;	break;
	case Tint8:	t = TYschar;	break;
	case Tuns8:	t = TYuchar;	break;
	case Tint16:	t = TYshort;	break;
	case Tuns16:	t = TYushort;	break;
	case Tint32:	t = TYint;	break;
	case Tuns32:	t = TYuint;	break;
	case Tint64:	t = TYllong;	break;
	case Tuns64:	t = TYullong;	break;
	case Tfloat32:	t = TYfloat;	break;
	case Tfloat64:	t = TYdouble;	break;
	case Tfloat80:	t = TYldouble;	break;
	case Timaginary32: t = TYifloat; break;
	case Timaginary64: t = TYidouble; break;
	case Timaginary80: t = TYildouble; break;
	case Tcomplex32: t = TYcfloat;	break;
	case Tcomplex64: t = TYcdouble;	break;
	case Tcomplex80: t = TYcldouble; break;
	//case Tbit:	t = TYuchar;	break;
	case Tbool:	t = TYbool;	break;
	case Tchar:	t = TYchar;	break;
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
	case Twchar:	t = TYwchar_t;	break;
	case Tdchar:	t = TYdchar;	break;
#else
	case Twchar:	t = TYwchar_t;	break;
	case Tdchar:
		t = (global.params.symdebug == 1) ? TYdchar : TYulong;
		break;
#endif

	case Taarray:	t = TYaarray;	break;
	case Tclass:
	case Treference:
	case Tpointer:	t = TYnptr;	break;
	case Tdelegate:	t = TYdelegate;	break;
	case Tarray:	t = TYdarray;	break;
#if SARRAYVALUE
	case Tsarray:	t = TYstruct;	break;
#else
	case Tsarray:	t = TYarray;	break;
#endif
	case Tstruct:	t = TYstruct;	break;

	case Tenum:
	case Ttypedef:
	     t = toBasetype()->totym();
	     break;

	case Tident:
	case Ttypeof:
#ifdef DEBUG
	    printf("ty = %d, '%s'\n", ty, toChars());
#endif
	    error(0, "forward reference of %s", toChars());
	    t = TYint;
	    break;

	default:
#ifdef DEBUG
	    printf("ty = %d, '%s'\n", ty, toChars());
	    halt();
#endif
	    assert(0);
    }

#if DMDV2
    // Add modifiers
    switch (mod)
    {
	case 0:
	    break;
	case MODconst:
	    t |= mTYconst;
	    break;
	case MODinvariant:
	    t |= mTYimmutable;
	    break;
	case MODshared:
	    t |= mTYshared;
	    break;
	case MODshared | MODconst:
	    t |= mTYshared | mTYconst;
	    break;
	default:
	    assert(0);
    }
#endif

    return t;
}
Esempio n. 3
0
File: argtypes.c Progetto: Nishi/dmd
TypeTuple *TypeEnum::toArgTypes()
{
    return toBasetype()->toArgTypes();
}
Esempio n. 4
0
File: glue.c Progetto: iteratif/dmd
unsigned Type::totym()
{   unsigned t;

    switch (ty)
    {
        case Tvoid:     t = TYvoid;     break;
        case Tint8:     t = TYschar;    break;
        case Tuns8:     t = TYuchar;    break;
        case Tint16:    t = TYshort;    break;
        case Tuns16:    t = TYushort;   break;
        case Tint32:    t = TYint;      break;
        case Tuns32:    t = TYuint;     break;
        case Tint64:    t = TYllong;    break;
        case Tuns64:    t = TYullong;   break;
        case Tfloat32:  t = TYfloat;    break;
        case Tfloat64:  t = TYdouble;   break;
        case Tfloat80:  t = TYldouble;  break;
        case Timaginary32: t = TYifloat; break;
        case Timaginary64: t = TYidouble; break;
        case Timaginary80: t = TYildouble; break;
        case Tcomplex32: t = TYcfloat;  break;
        case Tcomplex64: t = TYcdouble; break;
        case Tcomplex80: t = TYcldouble; break;
        case Tbool:     t = TYbool;     break;
        case Tchar:     t = TYchar;     break;
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
        case Twchar:    t = TYwchar_t;  break;
        case Tdchar:    t = TYdchar;    break;
#else
        case Twchar:    t = TYwchar_t;  break;
        case Tdchar:
                t = (global.params.symdebug == 1) ? TYdchar : TYulong;
                break;
#endif

        case Taarray:   t = TYaarray;   break;
        case Tclass:
        case Treference:
        case Tpointer:  t = TYnptr;     break;
        case Tdelegate: t = TYdelegate; break;
        case Tarray:    t = TYdarray;   break;
#if SARRAYVALUE
        case Tsarray:   t = TYstruct;   break;
#else
        case Tsarray:   t = TYarray;    break;
#endif
        case Tstruct:   t = TYstruct;   break;

        case Tenum:
        case Ttypedef:
             t = toBasetype()->totym();
             break;

        case Tident:
        case Ttypeof:
            error(0, "forward reference of %s", toChars());
            t = TYint;
            break;

        case Tnull:
            t = TYnptr;
            break;

        case Tvector:
        {   TypeVector *tv = (TypeVector *)this;
            TypeBasic *tb = tv->elementType();
            switch (tb->ty)
            {   case Tvoid:
                case Tint8:     t = TYschar16;  break;
                case Tuns8:     t = TYuchar16;  break;
                case Tint16:    t = TYshort8;   break;
                case Tuns16:    t = TYushort8;  break;
                case Tint32:    t = TYlong4;    break;
                case Tuns32:    t = TYulong4;   break;
                case Tint64:    t = TYllong2;   break;
                case Tuns64:    t = TYullong2;  break;
                case Tfloat32:  t = TYfloat4;   break;
                case Tfloat64:  t = TYdouble2;  break;
                default:
                    assert(0);
                    break;
            }
            if (tv->size(0) == 32)
                error(0, "AVX vector types not supported");
            break;
        }

        default:
#ifdef DEBUG
            printf("ty = %d, '%s'\n", ty, toChars());
            halt();
#endif
            assert(0);
    }

#if DMDV2
    // Add modifiers
    switch (mod)
    {
        case 0:
            break;
        case MODconst:
        case MODwild:
            t |= mTYconst;
            break;
        case MODimmutable:
            t |= mTYimmutable;
            break;
        case MODshared:
            t |= mTYshared;
            break;
        case MODshared | MODwild:
        case MODshared | MODconst:
            t |= mTYshared | mTYconst;
            break;
        default:
            assert(0);
    }
#endif

    return t;
}