Skip to content

Commit

Permalink
Merge pull request #306 from monarchdodra/sliceNothrow
Browse files Browse the repository at this point in the history
Slice nothrow
  • Loading branch information
andralex committed Sep 25, 2012
2 parents b2aebc0 + 92f92aa commit 19fe0bf
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/rt/arrayassign.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to)
char[10] tmp = void;
string msg = "lengths don't match for array copy,"c;
msg ~= tmp.intToString(to.length) ~ " = " ~ tmp.intToString(from.length);
throw new Exception(msg);
throw new Error(msg);
}

auto element_size = ti.tsize();
Expand Down Expand Up @@ -92,7 +92,7 @@ extern (C) void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to)
char[10] tmp = void;
string msg = "lengths don't match for array initialization,"c;
msg ~= tmp.intToString(to.length) ~ " = " ~ tmp.intToString(from.length);
throw new Exception(msg);
throw new Error(msg);
}

auto element_size = ti.tsize();
Expand Down
3 changes: 2 additions & 1 deletion src/rt/arraybyte.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
}

alias byte T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */

Expand Down
10 changes: 6 additions & 4 deletions src/rt/arraycast.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ module rt.arraycast;
* Runtime helper to convert dynamic array of one
* type to dynamic array of another.
* Adjusts the length of the array.
* Throws exception if new length is not aligned.
* Throws an error if new length is not aligned.
*/

extern (C)

@trusted nothrow
void[] _d_arraycast(size_t tsize, size_t fsize, void[] a)
{
auto length = a.length;

auto nbytes = length * fsize;
if (nbytes % tsize != 0)
{
throw new Exception("array cast misalignment");
throw new Error("array cast misalignment");
}
length = nbytes / tsize;
*cast(size_t *)&a = length; // jam new length
Expand All @@ -56,20 +57,21 @@ unittest
* Runtime helper to convert dynamic array of bits
* dynamic array of another.
* Adjusts the length of the array.
* Throws exception if new length is not aligned.
* Throws an error if new length is not aligned.
*/

version (none)
{
extern (C)

@trusted nothrow
void[] _d_arraycast_frombit(uint tsize, void[] a)
{
uint length = a.length;

if (length & 7)
{
throw new Exception("bit[] array cast misalignment");
throw new Error("bit[] array cast misalignment");
}
length /= 8 * tsize;
*cast(size_t *)&a = length; // jam new length
Expand Down
6 changes: 3 additions & 3 deletions src/rt/arraycat.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private
debug import core.stdc.stdio;
}

extern (C):
extern (C) @trusted nothrow:

byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
{
Expand All @@ -28,7 +28,7 @@ byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)

if (to.length != from.length)
{
throw new Exception("lengths don't match for array copy");
throw new Error("lengths don't match for array copy");
}
else if (to.ptr + to.length * size <= from.ptr ||
from.ptr + from.length * size <= to.ptr)
Expand All @@ -37,7 +37,7 @@ byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
}
else
{
throw new Exception("overlapping array copy");
throw new Error("overlapping array copy");
}
return to;
}
3 changes: 2 additions & 1 deletion src/rt/arraydouble.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
Expand All @@ -49,7 +50,7 @@ bool disjoint(T)(T[] a, T[] b)

alias double T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */

Expand Down
3 changes: 2 additions & 1 deletion src/rt/arrayfloat.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
}

alias float T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */
/* ======================================================================== */
Expand Down
3 changes: 2 additions & 1 deletion src/rt/arrayint.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
}

alias int T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */

Expand Down
3 changes: 2 additions & 1 deletion src/rt/arrayreal.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
}

alias real T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */

Expand Down
3 changes: 2 additions & 1 deletion src/rt/arrayshort.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ else

//version = log;

@trusted pure nothrow
bool disjoint(T)(T[] a, T[] b)
{
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
}

alias short T;

extern (C):
extern (C) @trusted nothrow:

/* ======================================================================== */

Expand Down

0 comments on commit 19fe0bf

Please sign in to comment.