Explorer

core.optimize-binary-call

description
Fold a call to plus / minus / multiply when both arguments are numbers
type
Fn(
  name: String,
  function: @core.callee,
  arguments: List<Record{name: String, value: @core.expression}>
) -> @core.expression
expression
fn(name$0, function$1, arguments$2) =>
  let left$3 = @core.optimize-expression(expr: @core.call-argument(arguments: $2, name: "left"));
  let right$4 = @core.optimize-expression(expr: @core.call-argument(arguments: $2, name: "right"));
  let rebuilt$5 = #call({function: $1, arguments: [{name: "left", value: $3}, {name: "right", value: $4}]});
  match $3 {
    #number(left_number$6) =>
      match $4 {
        #number(right_number$7) =>
          match $0 {
            "plus" =>
              #number(@core.plus(left: $6, right: $7)),
            "minus" =>
              #number(@core.minus(left: $6, right: $7)),
            "multiply" =>
              #number(@core.multiply(left: $6, right: $7)),
            _ =>
              $5
          },
        _ =>
          $5
      },
    _ =>
      $5
  }
visibility
public
core.optimize-binary-call (project definy, branch auto-release, snapshot oiQgPqhJm-TbM4kexXeRHBaJB_tS7gwBSewII64P-44)
id: d-ngPisl-sFGlGezkqVi7o8Am9MAHlvzRIRsd1jtqoE
content hash: TRitkhXS842IfyzS5Y11UFpxauJgzPPSieIzKhqtDjs