[armedbear-cvs] r11562 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Sat Jan 17 13:57:00 UTC 2009


Author: ehuelsmann
Date: Sat Jan 17 13:56:59 2009
New Revision: 11562

Log:
Change and document the internal adjustArray() protocol: we can't use NIL as a marker for "absent initial contents": It's valid for ZeroRankArray.


Modified:
   trunk/abcl/src/org/armedbear/lisp/AbstractArray.java
   trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte16.java
   trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte32.java
   trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java
   trunk/abcl/src/org/armedbear/lisp/ComplexArray.java
   trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte32.java
   trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte8.java
   trunk/abcl/src/org/armedbear/lisp/ComplexBitVector.java
   trunk/abcl/src/org/armedbear/lisp/ComplexString.java
   trunk/abcl/src/org/armedbear/lisp/ComplexVector.java
   trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte32.java
   trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte8.java
   trunk/abcl/src/org/armedbear/lisp/SimpleArray_T.java
   trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte16.java
   trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte32.java
   trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte8.java
   trunk/abcl/src/org/armedbear/lisp/SimpleBitVector.java
   trunk/abcl/src/org/armedbear/lisp/SimpleString.java
   trunk/abcl/src/org/armedbear/lisp/SimpleVector.java
   trunk/abcl/src/org/armedbear/lisp/ZeroRankArray.java
   trunk/abcl/src/org/armedbear/lisp/adjust_array.java

Modified: trunk/abcl/src/org/armedbear/lisp/AbstractArray.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/AbstractArray.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/AbstractArray.java	Sat Jan 17 13:56:59 2009
@@ -316,13 +316,30 @@
         }
     }
 
-  public abstract AbstractArray adjustArray(int[] dims,
+    /** Returns a newly allocated array or the current array with
+     * adjusted dimensions.
+     *
+     * @param dims
+     * @param initialElement @c null if none
+     * @param initialContents @c null if none
+     * @return @c this or a new array
+     * @throws org.armedbear.lisp.ConditionThrowable
+     */
+    public abstract AbstractArray adjustArray(int[] dims,
                                               LispObject initialElement,
                                               LispObject initialContents)
-    throws ConditionThrowable;
+        throws ConditionThrowable;
 
-  public abstract AbstractArray adjustArray(int[] dims,
+    /**
+     * 
+     * @param dims
+     * @param displacedTo
+     * @param displacement
+     * @return
+     * @throws org.armedbear.lisp.ConditionThrowable
+     */
+    public abstract AbstractArray adjustArray(int[] dims,
                                               AbstractArray displacedTo,
                                               int displacement)
-    throws ConditionThrowable;
+        throws ConditionThrowable;
 }

Modified: trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte16.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte16.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte16.java	Sat Jan 17 13:56:59 2009
@@ -263,7 +263,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             LispObject[] newElements = new LispObject[newCapacity];
             if (initialContents.listp()) {
                 LispObject list = initialContents;
@@ -282,8 +282,9 @@
             LispObject[] newElements = new LispObject[newCapacity];
             System.arraycopy(elements, 0, newElements, 0,
                              Math.min(capacity, newCapacity));
-            for (int i = capacity; i < newCapacity; i++)
-                newElements[i] = initialElement;
+            if (initialElement != null)
+                for (int i = capacity; i < newCapacity; i++)
+                    newElements[i] = initialElement;
             return new BasicVector_UnsignedByte16(newElements);
         }
         // No change.

Modified: trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte32.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte32.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte32.java	Sat Jan 17 13:56:59 2009
@@ -275,7 +275,7 @@
                                      LispObject initialContents)
     throws ConditionThrowable
   {
-    if (initialContents != NIL)
+    if (initialContents != null)
       {
         LispObject[] newElements = new LispObject[newCapacity];
         if (initialContents.listp())
@@ -301,8 +301,9 @@
         LispObject[] newElements = new LispObject[newCapacity];
         System.arraycopy(elements, 0, newElements, 0,
                          Math.min(capacity, newCapacity));
-        for (int i = capacity; i < newCapacity; i++)
-          newElements[i] = initialElement;
+        if (initialElement != null)
+            for (int i = capacity; i < newCapacity; i++)
+                newElements[i] = initialElement;
         return new BasicVector_UnsignedByte32(newElements);
       }
     // No change.

Modified: trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/BasicVector_UnsignedByte8.java	Sat Jan 17 13:56:59 2009
@@ -273,7 +273,7 @@
                                      LispObject initialContents)
     throws ConditionThrowable
   {
-    if (initialContents != NIL)
+    if (initialContents != null)
       {
         LispObject[] newElements = new LispObject[newCapacity];
         if (initialContents.listp())
@@ -299,8 +299,9 @@
         LispObject[] newElements = new LispObject[newCapacity];
         System.arraycopy(elements, 0, newElements, 0,
                          Math.min(capacity, newCapacity));
-        for (int i = capacity; i < newCapacity; i++)
-          newElements[i] = initialElement;
+        if (initialElement != null)
+            for (int i = capacity; i < newCapacity; i++)
+                newElements[i] = initialElement;
         return new BasicVector_UnsignedByte8(newElements);
       }
     // No change.

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexArray.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexArray.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexArray.java	Sat Jan 17 13:56:59 2009
@@ -242,13 +242,14 @@
                                               LispObject initialContents)
             throws ConditionThrowable {
         if (isAdjustable()) {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 setInitialContents(0, dims, initialContents, 0);
             else {
                 //### FIXME Take the easy way out: we don't want to reorganize
                 // all of the array code yet
                 SimpleArray_T tempArray = new SimpleArray_T(dims, elementType);
-                tempArray.fill(initialElement);
+                if (initialElement != null)
+                    tempArray.fill(initialElement);
                 SimpleArray_T.copyArray(this, tempArray);
                 this.data = tempArray.data;
 
@@ -257,11 +258,12 @@
             }
             return this;
         } else {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 return new ComplexArray(dims, elementType, initialContents);
             else {
                 ComplexArray newArray = new ComplexArray(dims, elementType);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 return newArray;
             }
         }

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte32.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte32.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte32.java	Sat Jan 17 13:56:59 2009
@@ -239,13 +239,14 @@
                                               LispObject initialContents)
             throws ConditionThrowable {
         if (isAdjustable()) {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 setInitialContents(0, dims, initialContents, 0);
             else {
                 //### FIXME Take the easy way out: we don't want to reorganize
                 // all of the array code yet
                 SimpleArray_UnsignedByte32 tempArray = new SimpleArray_UnsignedByte32(dims);
-                tempArray.fill(initialElement);
+                if (initialElement != null)
+                    tempArray.fill(initialElement);
                 SimpleArray_UnsignedByte32.copyArray(this, tempArray);
                 this.data = tempArray.data;
 
@@ -254,11 +255,12 @@
             }
             return this;
         } else {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 return new ComplexArray_UnsignedByte32(dims, initialContents);
             else {
                 ComplexArray_UnsignedByte32 newArray = new ComplexArray_UnsignedByte32(dims);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 return newArray;
             }
         }

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte8.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte8.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexArray_UnsignedByte8.java	Sat Jan 17 13:56:59 2009
@@ -241,13 +241,14 @@
                                               LispObject initialContents)
             throws ConditionThrowable {
         if (isAdjustable()) {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 setInitialContents(0, dims, initialContents, 0);
             else {
                 //### FIXME Take the easy way out: we don't want to reorganize
                 // all of the array code yet
                 SimpleArray_UnsignedByte8 tempArray = new SimpleArray_UnsignedByte8(dims);
-                tempArray.fill(initialElement);
+                if (initialElement != null)
+                    tempArray.fill(initialElement);
                 SimpleArray_UnsignedByte8.copyArray(this, tempArray);
                 this.data = tempArray.data;
 
@@ -256,11 +257,12 @@
             }
             return this;
         } else {
-            if (initialContents != NIL)
+            if (initialContents != null)
                 return new ComplexArray_UnsignedByte8(dims, initialContents);
             else {
                 ComplexArray_UnsignedByte8 newArray = new ComplexArray_UnsignedByte8(dims);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 return newArray;
             }
         }

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexBitVector.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexBitVector.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexBitVector.java	Sat Jan 17 13:56:59 2009
@@ -345,7 +345,7 @@
             int size = newCapacity >>> 6;
             if ((newCapacity & LONG_MASK) != 0)
                 ++size;
-            if (initialContents != NIL) {
+            if (initialContents != null) {
                 bits = new long[size];
                 capacity = newCapacity;
                 if (initialContents.listp()) {
@@ -364,7 +364,7 @@
                 System.arraycopy(bits, 0, newBits, 0,
                                  Math.min(bits.length, newBits.length));
                 bits = newBits;
-                if (newCapacity > capacity) {
+                if (newCapacity > capacity && initialElement != null) {
                     int n = Fixnum.getValue(initialElement);
                     if (n == 1)
                         for (int i = capacity; i < newCapacity; i++)

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexString.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexString.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexString.java	Sat Jan 17 13:56:59 2009
@@ -602,7 +602,7 @@
                                      LispObject initialContents)
     throws ConditionThrowable
   {
-    if (initialContents != NIL)
+    if (initialContents != null)
       {
         // "If INITIAL-CONTENTS is supplied, it is treated as for MAKE-
         // ARRAY. In this case none of the original contents of array
@@ -658,7 +658,7 @@
                              Math.min(capacity, newCapacity));
             chars = newElements;
           }
-        if (initialElement != NIL && capacity < newCapacity)
+        if (initialElement != null && capacity < newCapacity)
           {
             // Initialize new elements.
             final char c = LispCharacter.getValue(initialElement);

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexVector.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexVector.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexVector.java	Sat Jan 17 13:56:59 2009
@@ -370,7 +370,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             // "If INITIAL-CONTENTS is supplied, it is treated as for MAKE-
             // ARRAY. In this case none of the original contents of array
             // appears in the resulting array."
@@ -401,8 +401,9 @@
                 elements = newElements;
             }
             // Initialize new elements (if any).
-            for (int i = capacity; i < newCapacity; i++)
-                elements[i] = initialElement;
+            if (initialElement != null)
+                for (int i = capacity; i < newCapacity; i++)
+                    elements[i] = initialElement;
         }
         capacity = newCapacity;
         array = null;

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte32.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte32.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte32.java	Sat Jan 17 13:56:59 2009
@@ -372,7 +372,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             // "If INITIAL-CONTENTS is supplied, it is treated as for MAKE-
             // ARRAY. In this case none of the original contents of array
             // appears in the resulting array."
@@ -403,7 +403,7 @@
                 elements = newElements;
             }
             // Initialize new elements (if aapplicable).
-            if (initialElement != NIL) {
+            if (initialElement != null) {
                 for (int i = capacity; i < newCapacity; i++)
                     elements[i] = initialElement;
             }

Modified: trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte8.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte8.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ComplexVector_UnsignedByte8.java	Sat Jan 17 13:56:59 2009
@@ -384,7 +384,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             // "If INITIAL-CONTENTS is supplied, it is treated as for MAKE-
             // ARRAY. In this case none of the original contents of array
             // appears in the resulting array."
@@ -415,7 +415,7 @@
                 elements = newElements;
             }
             // Initialize new elements (if aapplicable).
-            if (initialElement != NIL) {
+            if (initialElement != null) {
                 byte b = coerceLispObjectToJavaByte(initialElement);
                 for (int i = capacity; i < newCapacity; i++)
                     elements[i] = b;

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleArray_T.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleArray_T.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleArray_T.java	Sat Jan 17 13:56:59 2009
@@ -327,14 +327,15 @@
                                    LispObject initialContents)
     throws ConditionThrowable
   {
-    if (initialContents != NIL)
+    if (initialContents != null)
       return new SimpleArray_T(dimv, elementType, initialContents);
     for (int i = 0; i < dimv.length; i++)
       {
         if (dimv[i] != this.dimv[i])
           {
             SimpleArray_T newArray = new SimpleArray_T(dimv, elementType);
-            newArray.fill(initialElement);
+            if (initialElement != null)
+                newArray.fill(initialElement);
             copyArray(this, newArray);
             return newArray;
           }

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte16.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte16.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte16.java	Sat Jan 17 13:56:59 2009
@@ -303,13 +303,14 @@
                                      LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL)
+        if (initialContents != null)
             return new SimpleArray_UnsignedByte16(dimv, initialContents);
         for (int i = 0; i < dimv.length; i++) {
             if (dimv[i] != this.dimv[i]) {
                 SimpleArray_UnsignedByte16 newArray =
                     new SimpleArray_UnsignedByte16(dimv);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 copyArray(this, newArray);
                 return newArray;
             }

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte32.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte32.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte32.java	Sat Jan 17 13:56:59 2009
@@ -293,13 +293,14 @@
                                      LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL)
+        if (initialContents != null)
             return new SimpleArray_UnsignedByte32(dimv, initialContents);
         for (int i = 0; i < dimv.length; i++) {
             if (dimv[i] != this.dimv[i]) {
                 SimpleArray_UnsignedByte32 newArray =
                     new SimpleArray_UnsignedByte32(dimv);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 copyArray(this, newArray);
                 return newArray;
             }

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte8.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte8.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte8.java	Sat Jan 17 13:56:59 2009
@@ -290,13 +290,14 @@
                                      LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL)
+        if (initialContents != null)
             return new SimpleArray_UnsignedByte8(dimv, initialContents);
         for (int i = 0; i < dimv.length; i++) {
             if (dimv[i] != this.dimv[i]) {
                 SimpleArray_UnsignedByte8 newArray =
                     new SimpleArray_UnsignedByte8(dimv);
-                newArray.fill(initialElement);
+                if (initialElement != null)
+                    newArray.fill(initialElement);
                 copyArray(this, newArray);
                 return newArray;
             }

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleBitVector.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleBitVector.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleBitVector.java	Sat Jan 17 13:56:59 2009
@@ -199,7 +199,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             SimpleBitVector v = new SimpleBitVector(newCapacity);
             if (initialContents.listp()) {
                 LispObject list = initialContents;
@@ -223,7 +223,7 @@
                 else
                     v.clearBit(i);
             }
-            if (initialElement != NIL && capacity < newCapacity) {
+            if (initialElement != null && capacity < newCapacity) {
                 int n = Fixnum.getValue(initialElement);
                 if (n == 1)
                     for (int i = capacity; i < newCapacity; i++)

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleString.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleString.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleString.java	Sat Jan 17 13:56:59 2009
@@ -465,7 +465,7 @@
                                        LispObject initialContents)
         throws ConditionThrowable
     {
-        if (initialContents != NIL) {
+        if (initialContents != null) {
             char[] newChars = new char[newCapacity];
             if (initialContents.listp()) {
                 LispObject list = initialContents;
@@ -483,7 +483,7 @@
         if (capacity != newCapacity) {
             char[] newChars = new char[newCapacity];
             System.arraycopy(chars, 0, newChars, 0, Math.min(newCapacity, capacity));
-            if (initialElement != NIL && capacity < newCapacity) {
+            if (initialElement != null && capacity < newCapacity) {
                 final char c = LispCharacter.getValue(initialElement);
                 for (int i = capacity; i < newCapacity; i++)
                     newChars[i] = c;

Modified: trunk/abcl/src/org/armedbear/lisp/SimpleVector.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SimpleVector.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/SimpleVector.java	Sat Jan 17 13:56:59 2009
@@ -336,7 +336,7 @@
                                      LispObject initialContents)
     throws ConditionThrowable
   {
-    if (initialContents != NIL)
+    if (initialContents != null)
       {
         LispObject[] newData = new LispObject[newCapacity];
         if (initialContents.listp())
@@ -362,8 +362,9 @@
         LispObject[] newData = new LispObject[newCapacity];
         System.arraycopy(data, 0, newData, 0,
                          Math.min(capacity, newCapacity));
-        for (int i = capacity; i < newCapacity; i++)
-          newData[i] = initialElement;
+        if (initialElement != null)
+            for (int i = capacity; i < newCapacity; i++)
+                newData[i] = initialElement;
         return new SimpleVector(newData);
       }
     // No change.

Modified: trunk/abcl/src/org/armedbear/lisp/ZeroRankArray.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ZeroRankArray.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/ZeroRankArray.java	Sat Jan 17 13:56:59 2009
@@ -169,15 +169,15 @@
                                               LispObject initialContents)
     throws ConditionThrowable {
       if (isAdjustable()) {
-          if (initialContents != NIL)
+          // initial element doesn't matter:
+          // we're not creating new elements
+          if (initialContents != null)
               data = initialContents;
-          else
-              data = initialElement;
           return this;
       } else {
           return new ZeroRankArray(elementType,
-                  initialContents != NIL ? initialContents : initialElement,
-                  false);
+                  initialContents != null ? initialContents :
+                      initialElement != null ? initialElement : data, false);
       }
   }
 

Modified: trunk/abcl/src/org/armedbear/lisp/adjust_array.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/adjust_array.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/adjust_array.java	Sat Jan 17 13:56:59 2009
@@ -51,14 +51,14 @@
         AbstractArray array = checkArray(args[0]);
         LispObject dimensions = args[1];
         LispObject elementType = args[2];
-        LispObject initialElement = args[3];
-        LispObject initialElementProvided = args[4];
-        LispObject initialContents = args[5];
-        LispObject initialContentsProvided = args[6];
+        boolean initialElementProvided = args[4] != NIL;
+        boolean initialContentsProvided = args[6] != NIL;
+        LispObject initialElement = initialElementProvided ? args[3] : null;
+        LispObject initialContents = initialContentsProvided ? args[5] : null;
         LispObject fillPointer = args[7];
         LispObject displacedTo = args[8];
         LispObject displacedIndexOffset = args[9];
-        if (initialElementProvided != NIL && initialContentsProvided != NIL) {
+        if (initialElementProvided && initialContentsProvided) {
             return error(new LispError("ADJUST-ARRAY: cannot specify both initial element and initial contents."));
         }
         if (elementType != array.getElementType() &&
@@ -67,10 +67,9 @@
             return error(new LispError("ADJUST-ARRAY: incompatible element type."));
         }
         if (array.getRank() == 0) {
-            return array.adjustArray(new int[0], NIL,
-                    (initialContentsProvided != NIL) ? initialContents : initialElement);
+            return array.adjustArray(new int[0], initialElement, initialContents);
         }
-        if (initialElementProvided == NIL && array.getElementType() == T)
+        if (!initialElementProvided && array.getElementType() == T)
             initialElement = Fixnum.ZERO;
         if (array.getRank() == 1) {
             final int newSize;




More information about the armedbear-cvs mailing list