view tests/mini/s.d @ 1605:1d5721f9ae18

[WIP] Merge DMD r251: bugzilla 111 (appending a dchar to a char[]) This patch needs some work in the code generation, because of the runtime changes (functions "_d_arrayappendcd" and "_d_arrayappendwd" are added). This doesn't affect existing code though, it just makes with patch a little useless, because something like this: char [] s; s ~= '\u6211'; That failed to compile with a nice error message previously to this change, now fails with and ugly error message (a failed assertion). Apparently there is a regression introduced by this patch too, when compiling Dil I get this assertion message: ldc: /home/luca/tesis/ldc/gen/statements.cpp:132: virtual void ReturnStatement::toIR(IRState*): Assertion `p->topfunc()->getReturnType() == llvm::Type::getVoidTy(gIR->context())' failed. 0 ldc 0x08a91628 Thank god we have bisecting capabilities in VCSs now ;) --- dmd/expression.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 6 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:19 -0300
parents d92acb81a583
children
line wrap: on
line source

module s;

interface Inter
{
    void inter();
}

interface Inter2
{
    void inter2();
}

interface InterOne : Inter
{
    void interOne();
}

abstract class ClassAbstract : InterOne
{
    abstract void inter();
    abstract void interOne();
}

class TheClassOne : ClassAbstract
{
    void inter()
    {
    }
    void interOne()
    {
    }
}

class TheClassTwo : TheClassOne, Inter2
{
    long l;
    double d;

    void inter2()
    {
    }
}

extern(C) int printf(char*, ...);

void main()
{
    printf("classinfo test\n");
    {
        auto c = new TheClassOne;
        {
            auto ci = c.classinfo;
            printf("ci = %.*s\n", ci.name.length, ci.name.ptr);
            printf("ci.interfaces.length = %lu\n", ci.interfaces.length);
	    foreach (i, iface; ci.interfaces)
                printf("i[%d] = %.*s\n", i, iface.classinfo.name.length, iface.classinfo.name.ptr);
        }
    }
    {
        auto c = new TheClassTwo;
        {
            auto ci = c.classinfo;
            printf("ci = %.*s\n", ci.name.length, ci.name.ptr);
            printf("ci.interfaces.length = %lu\n", ci.interfaces.length);
	    foreach (i, iface; ci.interfaces)
                printf("i[%d] = %.*s\n", i, iface.classinfo.name.length, iface.classinfo.name.ptr);
        }
        InterOne i = c;
        {
            auto ci = i.classinfo;
            printf("ci = %.*s\n", ci.name.length, ci.name.ptr);
        }
        auto i2 = cast(Inter2)c;
        {
            auto ci = i2.classinfo;
            printf("ci = %.*s\n", ci.name.length, ci.name.ptr);
        }
        auto o = cast(Object)i2;
        {
            auto ci = o.classinfo;
            printf("ci = %.*s\n", ci.name.length, ci.name.ptr);
        }
    }
}