You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2016/03/15 18:58:51 UTC

groovy git commit: revert 2d9c0225462edea0a73279b6216ece4f6024d517 "remove unused or obsolete code (closes #291)" for IndyArrayAccess because the methods not unused

Repository: groovy
Updated Branches:
  refs/heads/master 99dcfc57d -> e18983a99


revert 2d9c0225462edea0a73279b6216ece4f6024d517 "remove unused or obsolete code (closes #291)" for IndyArrayAccess because the methods not unused


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e18983a9
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e18983a9
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e18983a9

Branch: refs/heads/master
Commit: e18983a99b228fe698a7f5d3a6b89734006d43c2
Parents: 99dcfc5
Author: pascalschumacher <pa...@gmx.net>
Authored: Tue Mar 15 18:58:38 2016 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Tue Mar 15 18:58:38 2016 +0100

----------------------------------------------------------------------
 .../groovy/vmplugin/v7/IndyArrayAccess.java     | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e18983a9/src/main/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java b/src/main/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
index daca062..8709c47 100644
--- a/src/main/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
+++ b/src/main/org/codehaus/groovy/vmplugin/v7/IndyArrayAccess.java
@@ -96,6 +96,29 @@ public class IndyArrayAccess {
         return handle;
     }
 
+    private static int getLength(Object array) {
+        if (array instanceof Object[]) return ((Object[])array).length;
+        if (array instanceof boolean[]) return ((boolean[])array).length;
+        if (array instanceof byte[]) return ((byte[])array).length;
+        if (array instanceof char[]) return ((char[])array).length;
+        if (array instanceof short[]) return ((short[])array).length;
+        if (array instanceof int[]) return ((int[])array).length;
+        if (array instanceof long[]) return ((long[])array).length;
+        if (array instanceof float[]) return ((float[])array).length;
+        if (array instanceof double[]) return ((double[])array).length;
+        return 0;
+    }
+
+    private static int normalizeIndex(Object array, int i) {
+        int temp = i;
+        int size = getLength(array);
+        i += size;
+        if (i < 0) {
+            throw new ArrayIndexOutOfBoundsException("Negative array index [" + temp + "] too large for array size " + size);
+        }
+        return i;
+    }
+
     public static boolean notNegative(int index) {
         return index>=0;
     }