public void writeArray(CstArray array, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    CstArray.List list = array.getList();
    int size = list.size();

    if (annotates) {
      out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    for (int i = 0; i < size; i++) {
      Constant cst = list.get(i);
      if (annotates) {
        out.annotate("  [" + Integer.toHexString(i) + "] " + constantToHuman(cst));
      }
      writeConstant(cst);
    }

    if (annotates) {
      out.endAnnotation();
    }
  }
Writes out the encoded form of the given array, that is, as an {@code encoded_array} and not
including a {@code value_type} prefix. If the output stream keeps (debugging) annotations and
{@code topLevel} is {@code true}, then this method will write (debugging) annotations.

@param array {@code non-null;} array instance to write
@param topLevel {@code true} iff the given annotation is the top-level annotation or {@code
    false} if it is a sub-annotation of some other annotation
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/ValueEncoder.java