<commit_before>package org.unisonweb

object UnisonToScala {

  import compilation._
  import org.unisonweb.util.Unboxed

  type Env = (Array[U], Array[B], StackPtr, Result)

  def toUnboxed1(p: (Term.Name, Computation)): Env => Unboxed.F1[Param,Value] =
    toUnboxed1(Builtins.lambdaFor(p))

  def toUnboxed1(f: Value.Lambda): Env => Unboxed.F1[Param,Value] = {
    require (f.arity == 1)
    f.body match {
      case body: Computation.C1U =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F1[Param, Value] {
            // todo: can I just call body.raw(u1) here instead of body.apply?
            def apply[x] = kvx => (u1,a,u2,x) => kvx(body.raw(u1), body.outputType, u2, x)
          }
      case _body =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F1[Param,Value] {
            def apply[x] = kvx => (u1,a,u2,x) => {
              val out = evalLam(f, r, top, stackU, U0, u1, stackB, null, a)
              kvx(out, r.boxed, u2, x)
            }
          }
    }
  }

  def toUnboxed2(p: (Term.Name, Computation)): Env => Unboxed.F2[Value,Value,Value] =
    toUnboxed2(Builtins.lambdaFor(p))

  def toUnboxed2(f: Value.Lambda): Env => Unboxed.F2[Value,Value,Value] = {
    require(f.arity == 2)
    f.body match {
      case body: Computation.C2U =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F2[Param, Param, Value] {
            def apply[x] = kvx => (u1, a, u2, b, u3, x) => kvx(body.raw(u1, u2), body.outputType, u3, x)
          }

      case body =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F2[Param, Param, Value] {
            def apply[x] = kvx => (u1, a, u2, b, u3, x) => {
              val out = evalLam(f, r, top, stackU, u1, u2, stackB, a, b)
              kvx(out, r.boxed, u3, x)
            }
          }
    }
  }
}<commit_msg>I don't think I need these here anymore for C2Us.<commit_after>package org.unisonweb

object UnisonToScala {

  import compilation._
  import org.unisonweb.util.Unboxed

  type Env = (Array[U], Array[B], StackPtr, Result)

  def toUnboxed1(p: (Term.Name, Computation)): Env => Unboxed.F1[Param,Value] =
    toUnboxed1(Builtins.lambdaFor(p))

  def toUnboxed1(f: Value.Lambda): Env => Unboxed.F1[Param,Value] = {
    require (f.arity == 1)
    f.body match {
      case body: Computation.C1U =>
        _env =>
          new Unboxed.F1[Param, Value] {
            def apply[x] = kvx => (u1,a,u2,x) => kvx(body.raw(u1), body.outputType, u2, x)
          }
      case _body =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F1[Param,Value] {
            def apply[x] = kvx => (u1,a,u2,x) => {
              val out = evalLam(f, r, top, stackU, U0, u1, stackB, null, a)
              kvx(out, r.boxed, u2, x)
            }
          }
    }
  }

  def toUnboxed2(p: (Term.Name, Computation)): Env => Unboxed.F2[Value,Value,Value] =
    toUnboxed2(Builtins.lambdaFor(p))

  def toUnboxed2(f: Value.Lambda): Env => Unboxed.F2[Value,Value,Value] = {
    require(f.arity == 2)
    f.body match {
      case body: Computation.C2U =>
        _env =>
          new Unboxed.F2[Param, Param, Value] {
            def apply[x] = kvx => (u1, a, u2, b, u3, x) => kvx(body.raw(u1, u2), body.outputType, u3, x)
          }

      case _body =>
        env =>
          val (stackU, stackB, top, r) = env
          new Unboxed.F2[Param, Param, Value] {
            def apply[x] = kvx => (u1, a, u2, b, u3, x) => {
              val out = evalLam(f, r, top, stackU, u1, u2, stackB, a, b)
              kvx(out, r.boxed, u3, x)
            }
          }
    }
  }
}
{'fraction_non_alphanumeric': 0.15405478708977488, 'fraction_numerical': 0.021697857336588012, 'mean_word_length': 1.9935064935064934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2269353', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1427, 'n_words': 333}