extension ILType {
{%- for array in arrays %}
    fileprivate static let {{array|format_il_type}}: ILType =
        .createJsArrayType(ofElementType: .{{array.kind|format_il_type(primitive_with_suffix=True)}})
{%- endfor %}
}

{%- for array in arrays %}
    {%- if loop.first %}

/// As Fuzzilli runs, the OperationMutator and VariadicInputReducer will modify
/// the `CreateArray` operation to increase or decrease the element count. This
/// allows arrays to be arbitrarily long.
///
/// `findOrGenerateType` is preferred over specifying `inputs` because
/// Fuzzilli only uses CodeGenerators to produce types in `inputs`, while
/// `findOrGenerateType` uses a variety of sources (e.g. `builtins`, other
/// method properties and methods). An input is specified (i.e. `.one`)
/// to prevent the CodeGenerator from being scheduled first when there are
/// no visible variables, as `findOrGenerateType` causes a crash if there
/// are no visibile variables.
    {%- endif %}
private let Mojo{{array|format_unique_name}}Generator = CodeGenerator(
    "Mojo{{array|format_unique_name}}Generator",
    inputs: .one,
    produces: [.{{array|format_il_type}}]
) { b, _ in
    let elem = b.findOrGenerateType(.{{array.kind|format_il_type}})
    var elements: [Variable] = [elem]
{%- if array.kind.is_nullable %}

    // Currently, arrays do not encode in anyway that their element is an
    // optional type. Since this array has an optional element type,
    // pre-populate it with elements, with a chance of loading undefined
    // for each.
    for _ in 0..<10 {
       if probability(0.5) {
           elements.append(b.loadUndefined())
       } else {
           elements.append(b.randomVariable(forUseAs: .{{array.kind|format_il_type}}))
       }
    }
{%- endif %}
    b.createArray(
        with: elements,
        elementGroupName:
            ObjectGroup.
                {{- array.kind|format_unique_name(primitive_with_suffix=True)|to_camel(True) -}}
                .name)
}
{%- endfor %}
