Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1209)

Unified Diff: compiler/lib/implementation/arrays.dart

Issue 9865025: Revert "Removes dartc reliance on its own libraries, now can be targeted at any implementation's li… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiler/lib/implementation/array.js ('k') | compiler/lib/implementation/bool.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/lib/implementation/arrays.dart
diff --git a/compiler/lib/implementation/arrays.dart b/compiler/lib/implementation/arrays.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ee70f0b9cf8abae0412b82de1f93b871b202b5f2
--- /dev/null
+++ b/compiler/lib/implementation/arrays.dart
@@ -0,0 +1,79 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// TODO(ngeoffray): Rename to Lists.
+class Arrays {
+
+ static void copy(List<Object> src, int srcStart,
+ List<Object> dst, int dstStart, int count) {
+ if (srcStart === null) srcStart = 0;
+ if (dstStart === null) dstStart = 0;
+
+ if (srcStart < dstStart) {
+ for (int i = srcStart + count - 1, j = dstStart + count - 1;
+ i >= srcStart; i--, j--) {
+ dst[j] = src[i];
+ }
+ } else {
+ for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) {
+ dst[j] = src[i];
+ }
+ }
+ }
+
+ /**
+ * Returns the index in the array [a] of the given [element], starting
+ * the search at index [startIndex] to [endIndex] (exclusive).
+ * Returns -1 if [element] is not found.
+ */
+ static int indexOf(List a,
+ Object element,
+ int startIndex,
+ int endIndex) {
+ if (startIndex >= a.length) {
+ return -1;
+ }
+ if (startIndex < 0) {
+ startIndex = 0;
+ }
+ for (int i = startIndex; i < endIndex; i++) {
+ if (a[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the last index in the array [a] of the given [element], starting
+ * the search at index [startIndex] to 0.
+ * Returns -1 if [element] is not found.
+ */
+ static int lastIndexOf(List a, Object element, int startIndex) {
+ if (startIndex < 0) {
+ return -1;
+ }
+ if (startIndex >= a.length) {
+ startIndex = a.length - 1;
+ }
+ for (int i = startIndex; i >= 0; i--) {
+ if (a[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ static void rangeCheck(List 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);
+ }
+ }
+}
« no previous file with comments | « compiler/lib/implementation/array.js ('k') | compiler/lib/implementation/bool.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698