JsonArray dimList = new JsonArray(sourceInfo, program.getJavaScriptObject());
JType currentElementType = arrayType;
JLiteral classLit = x.getLeafTypeClassLiteral();
for (int i = 0; i < dims; ++i) {
// Walk down each type from most dims to least.
JArrayType curArrayType = (JArrayType) currentElementType;
JExpression castableTypeMap = getOrCreateCastMap(sourceInfo, curArrayType);
castableTypeMaps.getExprs().add(castableTypeMap);
JRuntimeTypeReference elementTypeIdLit = getElementRuntimeTypeReference(sourceInfo,
curArrayType);
elementTypeReferences.getExprs().add(elementTypeIdLit);
dimList.getExprs().add(x.dims.get(i));
currentElementType = curArrayType.getElementType();
}
JType leafElementType = currentElementType;
JIntLiteral leafElementTypeCategory = getTypeCategoryLiteral(leafElementType);
call.addArgs(classLit, castableTypeMaps, elementTypeReferences, leafElementTypeCategory,
dimList, program.getLiteralInt(dims));