Index: compiler/lib/implementation/arrays.dart |
=================================================================== |
--- compiler/lib/implementation/arrays.dart (revision 402) |
+++ compiler/lib/implementation/arrays.dart (working copy) |
@@ -63,4 +63,16 @@ |
} |
return -1; |
} |
+ |
+ static void rangeCheck(Array a, int start, int length) { |
+ if (length < 0) { |
+ throw new IllegalArgumentException("negative length $length"); |
+ } |
+ if (start < 0 || start > a.length) { |
+ throw new IndexOutOfRangeException(start); |
+ } |
+ if (start + length > a.length) { |
+ throw new IndexOutOfRangeException(start + length); |
+ } |
+ } |
} |