view gen/utils.h @ 1243:9c2dbbdd34f8

Updated the interal runtime's ClassInfo type to match the one in object.di . Runtime now compiles and runminitest is back to normal except for typeinfo10.d .
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 17 Apr 2009 02:54:16 +0200
parents 79758fd2f48a
children ec1d9dc1d32a
line wrap: on
line source

#ifndef __LDC_GEN_UTILS_H__
#define __LDC_GEN_UTILS_H__

#include "root.h"

/// Very simple templated iterator for DMD ArrayS.
template<class C>
struct ArrayIter
{
    Array& array;
    size_t index;

    ArrayIter(Array& arr, size_t idx = 0)
    :   array(arr), index(idx)
    { }

    bool done()
    {
        return index >= array.dim;
    }
    bool more()
    {
        return index < array.dim;
    }

    C* get()
    {
        return static_cast<C*>(array.data[index]);
    }
    C* operator->()
    {
        return static_cast<C*>(array.data[index]);
    }

    void next()
    {
        ++index;
    }
};

// some aliases
typedef ArrayIter<Dsymbol> DsymbolIter;
typedef ArrayIter<FuncDeclaration> FuncDeclarationIter;
typedef ArrayIter<VarDeclaration> VarDeclarationIter;

#endif