Explorer

core.compile-call

description
Wasm instructions for a call. A call of a function part calls its Wasm function directly (call, or return_call for opcode return_call_indirect) with no captured variables; other callees are closures called with call_indirect (opcode)
type
Fn(
  e: Record{function: @core.callee, arguments: List<Record{name: String, value: @core.expression}>},
  env: List<Record{variable_id: Number, local: Number}>,
  depth: Number,
  fn_base: Number,
  ctx: Record{
    parts: List<Record{id: String, expression: @core.expression, base: Number}>,
    inlining: List<String>,
    part_index: List<List<Record{id: String, expression: @core.expression, base: Number}>>,
    strings: List<Record{value: String, address: Number}>
  },
  opcode: Number
) -> List<Number>
expression
fn(e$43, env$1, depth$2, fn_base$3, ctx$4, opcode$200) =>
  let function$96 = @core.callee-to-expression(callee: $43.function);
  let arguments$97 = $43.arguments;
  match @core.compile-direct-callee(function: $43.function, ctx: $4) {
    #some(index$300) =>
      @core.list-concat(
        left: match @core.equal(left: @core.list-length(value: $97), right: 0) {
          true =>
            [@wasm.ref-null, @core.wasm-type-values, @wasm.ref-null, @core.wasm-type-values],
          false =>
            @core.list-concat(
              left: [@wasm.ref-null, @core.wasm-type-values],
              right: @core.list-concat(
                left: @core.compile-call-arguments-ranked(arguments: $97, rank: 0, env: $1, depth: $2, fn_base: $3, ctx: $4),
                right: @core.list-concat(
                  left: [@wasm.gc-prefix, @wasm.array-new-fixed, @core.wasm-type-values],
                  right: @wasm.unsigned-leb128(n: @core.list-length(value: $97))
                )
              )
            )
        },
        right: @core.list-concat(left: [@core.minus(left: $200, right: 1)], right: @wasm.unsigned-leb128(n: $300))
      ),
    #none(_) =>
      @core.list-concat(
        left: @core.compile-expr-instructions(expr: $96, env: $1, depth: $2, fn_base: $3, ctx: $4),
        right: @core.list-concat(
          left: @core.list-concat(left: [@wasm.local-set], right: @wasm.unsigned-leb128(n: $2)),
          right: @core.list-concat(
            left: @core.list-concat(
              left: [@wasm.local-get],
              right: @core.list-concat(left: @wasm.unsigned-leb128(n: $2), right: [@wasm.call, 19])
            ),
            right: @core.list-concat(
              left: match @core.equal(left: @core.list-length(value: $97), right: 0) {
                true =>
                  [@wasm.ref-null, @core.wasm-type-values],
                false =>
                  @core.list-concat(
                    left: @core.compile-call-arguments-ranked(
                      arguments: $97,
                      rank: 0,
                      env: $1,
                      depth: @core.plus(left: $2, right: 1),
                      fn_base: @core.plus(left: $3, right: @core.count-functions(expr: $96)),
                      ctx: $4
                    ),
                    right: @core.list-concat(
                      left: [@wasm.gc-prefix, @wasm.array-new-fixed, @core.wasm-type-values],
                      right: @wasm.unsigned-leb128(n: @core.list-length(value: $97))
                    )
                  )
              },
              right: @core.list-concat(
                left: @core.list-concat(left: [@wasm.local-get], right: @wasm.unsigned-leb128(n: $2)),
                right: [@wasm.call, 29, $200, @core.wasm-type-closure-function, 0]
              )
            )
          )
        )
      )
  }
visibility
public
core.compile-call (project definy, branch compiled-tests, snapshot i6TqClmqVS9FK8rKOvJ43l6Tevx8pvYJ5-zaQqNwemc)
id: Yx2UtWcQhAPHoNprezWbE0Ze2AuY5At91X24Eeg47Mw
content hash: XeiTcSQEKbeYv5Y-4HDhHlvmHu5o9aQldpisEYRUA4k