view lphobos/std/array.d @ 1628:6c36e3f49b28

Merge DMD r324: bugzilla 3663 and 3664 - fwd ref regressions --- dmd/class.c | 2 +- dmd/enum.c | 4 +++- dmd/enum.h | 2 ++ dmd/mars.c | 2 +- dmd/struct.c | 5 ++++- 5 files changed, 11 insertions(+), 4 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:23 -0300
parents fd32135dca3e
children
line wrap: on
line source


module std.array;

private import std.c.stdio;

class ArrayBoundsError : Error
{
  private:

    uint linnum;
    char[] filename;

  public:
    this(char[] filename, uint linnum)
    {
	this.linnum = linnum;
	this.filename = filename;

	char[] buffer = new char[19 + filename.length + linnum.sizeof * 3 + 1];
	int len;
	len = sprintf(buffer.ptr, "ArrayBoundsError %.*s(%u)", filename, linnum);
	super(buffer[0..len]);
    }
}


/********************************************
 * Called by the compiler generated module assert function.
 * Builds an ArrayBoundsError exception and throws it.
 */

extern (C) static void _d_array_bounds(char[] filename, uint line)
{
    //printf("_d_assert(%s, %d)\n", (char *)filename, line);
    ArrayBoundsError a = new ArrayBoundsError(filename, line);
    //printf("assertion %p created\n", a);
    throw a;
}