Changeset 15351


Ignore:
Timestamp:
07/23/20 05:12:10 (3 years ago)
Author:
Mark Evenson
Message:

Further (INCOMPLETE) work on byte vectors

GOAL: completely remove allocation of any UnsignedByte32 in

make_array.java. Surprised that it mostly works this way…

Fix directAllocation for SimpleArray_CharBuffer.

TODO: ensure that :nio-buffer argument is used in all cases.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/SimpleArray_CharBuffer.java

    r15350 r15351  
    5656    this.directAllocation = directAllocation;
    5757    if (directAllocation) {
    58       ByteBuffer b = ByteBuffer.allocate(totalSize * 2);
     58      ByteBuffer b = ByteBuffer.allocateDirect(totalSize * 2);
    5959      data = b.asCharBuffer();
    6060    } else {
  • trunk/abcl/src/org/armedbear/lisp/SimpleArray_UnsignedByte32.java

    r15348 r15351  
    3535
    3636import static org.armedbear.lisp.Lisp.*;
     37
     38/*
     39 N.b. this implementation has problems somewhere with converting bytes
     40
     41      Not fixing currently, as this type is unused with NIO
     42
     43(let* ((unspecialized
     44         #(2025373960 3099658457 3238582529 148439321
     45           3099658456 3238582528 3000000000 1000000000
     46           2000000000 2900000000 2400000000 2800000000
     47           0 1))
     48       (array
     49         (make-array (length unspecialized)
     50                     :element-type '(unsigned-byte 32)
     51                     :initial-contents unspecialized)))
     52  (prove:plan (length array))
     53  (loop :for i :below (length array)
     54        :doing
     55           (let ((x0
     56                   (elt unspecialized i))
     57                 (x1
     58                   (elt array i)))
     59           (prove:ok
     60            (equal x0 x1)
     61            (format nil "~a: ~a equals ~a" i x0 x1)))))
     62*/
    3763
    3864public final class SimpleArray_UnsignedByte32 extends AbstractArray
  • trunk/abcl/src/org/armedbear/lisp/make_array.java

    r15348 r15351  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id$
    65 *
    76 * This program is free software; you can redistribute it and/or
     
    3736import static org.armedbear.lisp.Lisp.*;
    3837
    39 // ### %make-array dimensions element-type initial-element initial-element-p
    40 // initial-contents adjustable fill-pointer displaced-to displaced-index-offset
     38// ### %make-array dimensions element-type initial-element initial-element-p initial-contents adjustable fill-pointer displaced-to displaced-index-offset nio-buffer nio-buffer-provided-p
    4139// => new-array
    42 public final class make_array extends Primitive
     40public final class make_array
     41  extends Primitive
    4342{
    44   public make_array()
    45   {
     43  public make_array() {
    4644    super("%make-array", PACKAGE_SYS, false);
    4745  }
    4846
    4947  @Override
    50   public LispObject execute(LispObject[] args)
    51   {
     48  public LispObject execute(LispObject[] args) {
    5249    // What a mess without keywords, but it still works

    53     if (args.length != 13)
     50    if (args.length != 13) {
    5451      return error(new WrongNumberOfArgumentsException(this, 13));
     52    }
    5553    LispObject dimensions = args[0];
    5654    LispObject elementType = args[1];
     
    6866    LispObject nioBufferProvided = args[12];
    6967   
    70     if (initialElementProvided != NIL && initialContents != NIL)
    71       {
     68    if (initialElementProvided != NIL && initialContents != NIL) {
    7269        return error(new LispError("MAKE-ARRAY: cannot specify both " +
    7370                                    "initial element and initial contents."));
    74       }
     71    }
    7572    final int rank = dimensions.listp() ? dimensions.length() : 1;
    7673    int[] dimv = new int[rank];
    77     if (dimensions.listp())
    78       {
    79         for (int i = 0; i < rank; i++)
    80           {
    81             LispObject dim = dimensions.car();
    82             dimv[i] = Fixnum.getValue(dim);
    83             dimensions = dimensions.cdr();
    84           }
    85       }
    86     else
     74    if (dimensions.listp()) {
     75      for (int i = 0; i < rank; i++) {
     76        LispObject dim = dimensions.car();
     77        dimv[i] = Fixnum.getValue(dim);
     78        dimensions = dimensions.cdr();
     79      }
     80    } else {
    8781      dimv[0] = Fixnum.getValue(dimensions);
    88     if (displacedTo != NIL)
    89       {
     82    }
     83    if (displacedTo != NIL) {
    9084        // FIXME Make sure element type (if specified) is compatible with
    9185        // displaced-to array.
    9286        final AbstractArray array = checkArray(displacedTo);
    93         if (initialElementProvided != NIL)
     87        if (initialElementProvided != NIL) {
    9488          return error(new LispError("Initial element must not be specified for a displaced array."));
    95         if (initialContents != NIL)
     89        }
     90        if (initialContents != NIL) {
    9691          return error(new LispError("Initial contents must not be specified for a displaced array."));
     92        }
    9793        final int displacement;
    98         if (displacedIndexOffset != NIL)
     94        if (displacedIndexOffset != NIL) {
    9995          displacement = Fixnum.getValue(displacedIndexOffset);
    100         else
     96        } else {
    10197          displacement = 0;
     98        }
    10299        if (rank == 1)
    103100          {
     
    112109                // an abstract array doesn't have a directAllocation  ???
    113110                v = new ComplexVector_ByteBuffer(dimv[0], array, displacement, directAllocation);
    114               } else if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     111              } else { // if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY))
    115112                v = new ComplexVector_UnsignedByte8(dimv[0], array, displacement);
    116113              }
    117114            } else if (arrayElementType.equal(UNSIGNED_BYTE_32)) {
    118               v = new ComplexVector_UnsignedByte32(dimv[0], array, displacement);
     115              if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     116                // an abstract array doesn't have a directAllocation  ???
     117                v = new ComplexVector_IntBuffer(dimv[0], array, displacement, directAllocation);
     118              } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY))
     119                v = new ComplexVector_UnsignedByte32(dimv[0], array, displacement);
     120              }
    119121            } else {
    120122              v = new ComplexVector(dimv[0], array, displacement);
     
    126128          }
    127129        return new ComplexArray(dimv, array, displacement);
    128       }
     130    }
     131
    129132    LispObject upgradedType = getUpgradedArrayElementType(elementType);
    130     if (rank == 0)
    131       {
     133    if (rank == 0) {
    132134        LispObject data;
    133         if (initialElementProvided != NIL)
     135        if (initialElementProvided != NIL) {
    134136          data = initialElement;
    135         else
     137        } else {
    136138          data = initialContents;
     139        }
    137140        return new ZeroRankArray(upgradedType, data, adjustable != NIL);
    138       }
    139     if (rank == 1)
    140       {
    141         final int size = dimv[0];
    142         if (size < 0 || size >= ARRAY_DIMENSION_MAX)
    143           {
    144             StringBuilder sb = new StringBuilder();
    145             sb.append("The size specified for this array (");
    146             sb.append(size);
    147             sb.append(')');
    148             if (size >= ARRAY_DIMENSION_MAX)
    149               {
    150                 sb.append(" is >= ARRAY-DIMENSION-LIMIT (");
    151                 sb.append(ARRAY_DIMENSION_MAX);
    152                 sb.append(").");
    153               }
    154             else
    155               sb.append(" is negative.");
    156             return error(new LispError(sb.toString()));
    157           }
    158         final AbstractVector v;
    159         final LispObject defaultInitialElement;
    160         if (upgradedType == Symbol.CHARACTER)
    161           {
    162             if (fillPointer != NIL || adjustable != NIL)
    163               v = new ComplexString(size);
    164             else
    165               v = new SimpleString(size);
    166             defaultInitialElement = LispCharacter.getInstance('\0');
    167           }
    168         else if (upgradedType == Symbol.BIT)
    169           {
    170             if (fillPointer != NIL || adjustable != NIL)
    171               v = new ComplexBitVector(size);
    172             else
    173               v = new SimpleBitVector(size);
    174             defaultInitialElement = Fixnum.ZERO;
    175           }
    176         else if (upgradedType.equal(UNSIGNED_BYTE_8))
    177           {
    178             if (fillPointer != NIL || adjustable != NIL) {
    179               if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    180                 v = new ComplexVector_ByteBuffer(size, directAllocation);
    181               } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    182                 v = new ComplexVector_UnsignedByte8(size);
    183               }
    184             } else {
    185               if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    186                 if (!nioBuffer.equals(NIL)) {
    187                   v = new BasicVector_ByteBuffer((java.nio.ByteBuffer)(((JavaObject)nioBuffer).getObject()),
    188                                                  directAllocation);
    189                 } else {
    190                   v = new BasicVector_ByteBuffer(size, directAllocation);
    191                 }
    192               } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    193                 v = new BasicVector_UnsignedByte8(size);
    194               }
    195             }
    196 
    197             defaultInitialElement = Fixnum.ZERO;
    198           }
    199         else if (upgradedType.equal(UNSIGNED_BYTE_16) &&
    200                  fillPointer == NIL && adjustable == NIL)
    201           {
    202             if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    203               v = new BasicVector_CharBuffer(size, directAllocation);
    204             } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    205               v = new BasicVector_UnsignedByte16(size);
    206             }
    207 
    208             defaultInitialElement = Fixnum.ZERO;
    209           }
    210         else if (upgradedType.equal(UNSIGNED_BYTE_32))
    211           {
    212             if (fillPointer != NIL || adjustable != NIL)
    213               v = new ComplexVector_UnsignedByte32(size);
    214             else {
    215               if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    216                 v = new BasicVector_IntBuffer(size, directAllocation);
    217               } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    218                 v = new BasicVector_UnsignedByte32(size);
    219               }
    220             }
    221             defaultInitialElement = Fixnum.ZERO;
    222           }
    223         else if (upgradedType == NIL)
    224           {
    225             v = new NilVector(size);
    226             defaultInitialElement = null;
    227           }
    228         else
    229           {
    230             if (fillPointer != NIL || adjustable != NIL)
    231               v = new ComplexVector(size);
    232             else
    233               v = new SimpleVector(size);
    234             defaultInitialElement = NIL;
    235           }
    236         if (initialElementProvided != NIL)
    237           {
    238             // Initial element was specified.
    239             v.fill(initialElement);
    240           }
    241         else if (initialContents != NIL)
    242           {
    243             if (initialContents.listp())
    244               {
    245                 LispObject list = initialContents;
    246                 for (int i = 0; i < size; i++)
    247                   {
    248                     v.aset(i, list.car());
    249                     list = list.cdr();
    250                   }
    251               }
    252             else if (initialContents.vectorp())
    253               {
    254                 for (int i = 0; i < size; i++)
    255                   v.aset(i, initialContents.elt(i));
    256               }
    257             else
    258               return type_error(initialContents, Symbol.SEQUENCE);
    259           }
    260         else
    261           {
    262             if (defaultInitialElement != null)
    263               v.fill(defaultInitialElement);
    264           }
    265         if (fillPointer != NIL)
    266           v.setFillPointer(fillPointer);
     141    } else if (rank == 1) {
     142      final int size = dimv[0];
     143      if (size < 0 || size >= ARRAY_DIMENSION_MAX) {
     144        StringBuilder sb = new StringBuilder();
     145        sb.append("The size specified for this array (");
     146        sb.append(size);
     147        sb.append(')');
     148        if (size >= ARRAY_DIMENSION_MAX) {
     149          sb.append(" is >= ARRAY-DIMENSION-LIMIT (");
     150          sb.append(ARRAY_DIMENSION_MAX);
     151          sb.append(").");
     152        } else {
     153          sb.append(" is negative.");}
     154        return error(new LispError(sb.toString()));
     155      }
     156      final AbstractVector v;
     157      final LispObject defaultInitialElement;
     158      if (upgradedType == Symbol.CHARACTER) {
     159        if (fillPointer != NIL || adjustable != NIL) {
     160          v = new ComplexString(size);
     161        } else {
     162          v = new SimpleString(size);
     163        }
     164        defaultInitialElement = LispCharacter.getInstance('\0');
     165      } else if (upgradedType == Symbol.BIT) {
     166        if (fillPointer != NIL || adjustable != NIL) {
     167          v = new ComplexBitVector(size);
     168        } else {
     169          v = new SimpleBitVector(size);
     170        }
     171        defaultInitialElement = Fixnum.ZERO;
     172      } else if (upgradedType.equal(UNSIGNED_BYTE_8)) {
     173        if (fillPointer != NIL || adjustable != NIL) {
     174          if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     175            v = new ComplexVector_ByteBuffer(size, directAllocation);
     176          } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     177            v = new ComplexVector_UnsignedByte8(size);
     178          }
     179        } else {
     180          if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     181            if (!nioBuffer.equals(NIL)) {
     182              v = new BasicVector_ByteBuffer((java.nio.ByteBuffer)(((JavaObject)nioBuffer).getObject()),
     183                                             directAllocation);
     184            } else {
     185              v = new BasicVector_ByteBuffer(size, directAllocation);
     186            }
     187          } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     188            v = new BasicVector_UnsignedByte8(size);
     189          }
     190        }
     191        defaultInitialElement = Fixnum.ZERO;
     192      } else if (upgradedType.equal(UNSIGNED_BYTE_16)
     193                 && fillPointer == NIL && adjustable == NIL) {
     194        if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     195          v = new BasicVector_CharBuffer(size, directAllocation);
     196        } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     197          v = new BasicVector_UnsignedByte16(size);
     198        }
     199        defaultInitialElement = Fixnum.ZERO;
     200      } else if (upgradedType.equal(UNSIGNED_BYTE_32)) {
     201        if (fillPointer != NIL || adjustable != NIL) {
     202          v = new ComplexVector_UnsignedByte32(size);
     203        } else {
     204          if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     205            v = new BasicVector_IntBuffer(size, directAllocation);
     206          } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     207            v = new BasicVector_UnsignedByte32(size);
     208          }
     209        }
     210        defaultInitialElement = Fixnum.ZERO;
     211      } else if (upgradedType == NIL) {
     212        v = new NilVector(size);
     213        defaultInitialElement = null;
     214      } else {
     215        if (fillPointer != NIL || adjustable != NIL) {
     216          v = new ComplexVector(size);
     217        } else {
     218          v = new SimpleVector(size);
     219        }
     220        defaultInitialElement = NIL;
     221      }
     222      if (initialElementProvided != NIL) {
     223        // Initial element was specified.
     224        v.fill(initialElement);
     225      } else if (initialContents != NIL) {
     226        if (initialContents.listp()) {
     227          LispObject list = initialContents;
     228          for (int i = 0; i < size; i++) {
     229            v.aset(i, list.car());
     230            list = list.cdr();
     231          }
     232        } else if (initialContents.vectorp()) {
     233          for (int i = 0; i < size; i++) {
     234            v.aset(i, initialContents.elt(i));
     235          }
     236        } else {
     237          return type_error(initialContents, Symbol.SEQUENCE);
     238        }
     239      } else {
     240        if (defaultInitialElement != null) {
     241          v.fill(defaultInitialElement);
     242        }
     243      }
     244      if (fillPointer != NIL) {
     245        v.setFillPointer(fillPointer);
     246      }
    267247        return v;
    268       }
    269     // rank > 1
    270     AbstractArray array;
    271     if (adjustable == NIL)
    272       {
    273         if (upgradedType.equal(UNSIGNED_BYTE_8))
    274           {
    275             if (initialContents != NIL)
    276               {
    277                 if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    278                   array = new SimpleArray_ByteBuffer(dimv, initialContents, directAllocation);
    279                 } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    280                   array = new SimpleArray_UnsignedByte8(dimv, initialContents);
    281                 }
    282               }
    283             else
    284               {
    285                 if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    286                   array = new SimpleArray_ByteBuffer(dimv, directAllocation);
    287                 } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    288                   array = new SimpleArray_UnsignedByte8(dimv);
    289                 }
    290                 if (initialElementProvided != NIL) {
    291                   array.fill(initialElement);
    292                 } else {
    293                   array.fill(Fixnum.ZERO);
    294                 }
    295               }
    296           }
    297         else if (upgradedType.equal(UNSIGNED_BYTE_16)) {
     248    } else { // rank > 1
     249      AbstractArray array;
     250      if (adjustable == NIL) {
     251        if (upgradedType.equal(UNSIGNED_BYTE_8)) {
     252          if (initialContents != NIL) {
     253            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     254              array = new SimpleArray_ByteBuffer(dimv, initialContents, directAllocation);
     255            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     256              array = new SimpleArray_UnsignedByte8(dimv, initialContents);
     257            }
     258          } else {
     259            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     260              array = new SimpleArray_ByteBuffer(dimv, directAllocation);
     261            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     262              array = new SimpleArray_UnsignedByte8(dimv);
     263            }
     264            if (initialElementProvided != NIL) {
     265              array.fill(initialElement);
     266            } else {
     267              array.fill(Fixnum.ZERO);
     268            }
     269          }
     270        } else if (upgradedType.equal(UNSIGNED_BYTE_16)) {
    298271          if (initialContents != NIL) {
    299272            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     
    314287            }
    315288          }
    316         }
    317         // N.b. There is no implementation of SimpleArray with
    318         // contents (unsigned-byte 32) using either a
    319         // primitive array or an nio.Buffer
    320         else if (upgradedType.equal(UNSIGNED_BYTE_32))
    321           {
    322             if (initialContents != NIL)
    323               {
    324                 array = new SimpleArray_UnsignedByte32(dimv, initialContents);
    325               }
    326             else
    327               {
    328                 array = new SimpleArray_UnsignedByte32(dimv);
    329                 if (initialElementProvided != NIL)
    330                   array.fill(initialElement);
    331                 else
    332                   array.fill(Fixnum.ZERO);
    333               }
    334           }
    335         else
    336           {
    337             if (initialContents != NIL)
    338               {
    339                 array = new SimpleArray_T(dimv, upgradedType, initialContents);
    340               }
    341             else
    342               {
    343                 array = new SimpleArray_T(dimv, upgradedType);
    344                 if (initialElementProvided != NIL)
    345                   array.fill(initialElement);
    346                 else
    347                   array.fill(NIL);
    348               }
    349           }
    350       }
    351     else
    352       {
    353         // Adjustable.
    354         if (upgradedType.equal(UNSIGNED_BYTE_8))
    355           {
    356             if (initialContents != NIL) {
    357               if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    358                 array = new ComplexArray_ByteBuffer(dimv, initialContents);
    359               } else {  //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    360                 array = new ComplexArray_UnsignedByte8(dimv, initialContents);
    361               }
    362             } else {
    363               if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    364                 array = new ComplexArray_ByteBuffer(dimv);
    365               } else  { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    366                 array = new ComplexArray_UnsignedByte8(dimv);
    367               }
    368               if (initialElementProvided != NIL)
    369                 array.fill(initialElement);
    370               else
    371                 array.fill(Fixnum.ZERO);
    372               }
    373           }
    374         else if (upgradedType.equal(UNSIGNED_BYTE_32))
    375           {
    376             if (initialContents != NIL)
    377               {
    378                 array = new ComplexArray_UnsignedByte32(dimv, initialContents);
    379               }
    380             else
    381               {
    382                 array = new ComplexArray_UnsignedByte32(dimv);
    383                 if (initialElementProvided != NIL)
    384                   array.fill(initialElement);
    385                 else
    386                   array.fill(Fixnum.ZERO);
    387               }
    388           }
    389         else
    390           {
    391             if (initialContents != NIL)
    392               {
    393                 array = new ComplexArray(dimv, upgradedType, initialContents);
    394               }
    395             else
    396               {
    397                 array = new ComplexArray(dimv, upgradedType);
    398                 if (initialElementProvided != NIL)
    399                   array.fill(initialElement);
    400                 else
    401                   array.fill(NIL);
    402               }
    403           }
    404       }
    405     return array;
     289        } else if (upgradedType.equal(UNSIGNED_BYTE_32)) {
     290          if (initialContents != NIL) {
     291            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     292              array = new SimpleArray_IntBuffer(dimv, initialContents, directAllocation);
     293            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     294              array = new SimpleArray_UnsignedByte32(dimv, initialContents);
     295            }
     296          } else {
     297            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     298              array = new SimpleArray_IntBuffer(dimv, directAllocation);
     299            } else {
     300              array = new SimpleArray_UnsignedByte32(dimv);
     301            }
     302            if (initialElementProvided != NIL) {
     303              array.fill(initialElement);
     304            } else {
     305              array.fill(Fixnum.ZERO);
     306            }
     307          }
     308        } else {
     309          if (initialContents != NIL) {
     310            array = new SimpleArray_T(dimv, upgradedType, initialContents);
     311          } else {
     312            array = new SimpleArray_T(dimv, upgradedType);
     313            if (initialElementProvided != NIL) {
     314              array.fill(initialElement);
     315            } else {
     316              array.fill(NIL);
     317            }
     318          }
     319        }
     320      } else { // Adjustable.
     321        if (upgradedType.equal(UNSIGNED_BYTE_8)) {
     322          if (initialContents != NIL) {
     323            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     324              array = new ComplexArray_ByteBuffer(dimv, initialContents);
     325            } else {  //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     326              array = new ComplexArray_UnsignedByte8(dimv, initialContents);
     327            }
     328          } else {
     329            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     330              array = new ComplexArray_ByteBuffer(dimv);
     331            } else  { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     332              array = new ComplexArray_UnsignedByte8(dimv);
     333            }
     334            if (initialElementProvided != NIL) {
     335              array.fill(initialElement);
     336            } else {
     337              array.fill(Fixnum.ZERO);
     338            }
     339          } // FIXME add specialization on (unsigned-byte 16)
     340        } else if (upgradedType.equal(UNSIGNED_BYTE_32)) {
     341          if (initialContents != NIL) {
     342            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     343              array = new ComplexArray_IntBuffer(dimv, initialContents, directAllocation);
     344            } else {  //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     345              array = new ComplexArray_UnsignedByte32(dimv, initialContents);
     346            }
     347          } else {
     348            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
     349              array = new ComplexArray_IntBuffer(dimv, directAllocation);
     350            } else {  //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
     351              array = new ComplexArray_UnsignedByte32(dimv);
     352            }
     353            if (initialElementProvided != NIL) {
     354              array.fill(initialElement);
     355            } else {
     356              array.fill(Fixnum.ZERO);
     357            }
     358          }
     359        } else {
     360          if (initialContents != NIL) {
     361            array = new ComplexArray(dimv, upgradedType, initialContents);
     362          } else {
     363            array = new ComplexArray(dimv, upgradedType);
     364            if (initialElementProvided != NIL) {
     365              array.fill(initialElement);
     366            } else {
     367              array.fill(NIL);
     368            }
     369          }
     370        }
     371      }
     372      return array;
     373    }
    406374  }
    407375
Note: See TracChangeset for help on using the changeset viewer.