<commit_before>package ir.ast

import ir.{Type, UndefType}

import scala.language.implicitConversions

/**
 * Abstract class representing a declaration.
 * Currently only a function declaration is a legal kind of declaration.
 * There are no other forms of declarations possible.
 */
abstract class Decl

/**
 * An instance of this class represents a function declaration.
 *
 * The type of the declared function is implemented in the type checker and not
 * here.
 *
 * @param arity The arity of the declared function
 */
abstract class FunDecl(val arity: Int) extends Decl {

  /**
   * Indicating if it is possible to generate code for this function declaration.
   * Might be overwritten by a subclass or by mixing in the `isGenerable` trait.
   */
  def isGenerable: Boolean


  def checkType(argType: Type, setType: Boolean): Type


  /**
   * Sequentially compose with a FunDecl (convert it to a Lambda).
   * @param f A FunDecl object.
   * @return An object representing the sequential composition of `this` and `f`
   *         (wrapped in a lambda)
   */
  def comp(f: FunDecl): Lambda = this o f

  /**
   * Sequential composition operator syntax.
   * @param f The lambda expression to sequentially compose with.
   * @return An object representing the sequential function composition of
   *         `this` and `f`.
   */
  def o(f: FunDecl): Lambda = {
    val params = Array.fill(f.arity)(Param(UndefType))
    Lambda(params, this(f(params:_*)))
  }

  /**
   * Reverse function composition. I.e. g >>> f == f o g
   * @param f The function to compose with (from the right).
   * @return `f o this`
   */
  def >>>(f: FunDecl): Lambda = f o this

  /**
   * Alternative syntax for function composition.
   * I.e. g <<< f = g o f
   * @param f The function to compose with (from the left).
   * @return `this o f`
   */
  def <<<(f: FunDecl): Lambda = this o f


  /**
   * Function call. This method returns an object representing the function call
   * of `this` with `args`.
   * This method will fail at runtime if the number of given `args` does not
   * match the length of `params`!
   * @param args The arguments to call the function (`this`) with.
   * @return An object (of type FunCall) representing the function call of
   *         `this` with `args`.
   */
  def apply(args : Expr*) : Expr = {
    assert (args.length == arity)
    new FunCall(this, args:_*)
  }

  /**
   * Alternative function call operator syntax. Calls `this.apply(arg)`.
   * @param arg The argument to call the function with.
   * @return An object (of type FunCall) representing the function call of
   *         `this` with `arg`.
   */
  @deprecated("Use `<<:` function instead, as this is right-associative")
  def $(arg: Expr) : Expr = apply(arg)

  /**
   * Alternative function call method. Used by the Java bindings. Calls<commit_msg>Removing deprecation from $ operator<commit_after>package ir.ast

import ir.{Type, UndefType}

import scala.language.implicitConversions

/**
 * Abstract class representing a declaration.
 * Currently only a function declaration is a legal kind of declaration.
 * There are no other forms of declarations possible.
 */
abstract class Decl

/**
 * An instance of this class represents a function declaration.
 *
 * The type of the declared function is implemented in the type checker and not
 * here.
 *
 * @param arity The arity of the declared function
 */
abstract class FunDecl(val arity: Int) extends Decl {

  /**
   * Indicating if it is possible to generate code for this function declaration.
   * Might be overwritten by a subclass or by mixing in the `isGenerable` trait.
   */
  def isGenerable: Boolean


  def checkType(argType: Type, setType: Boolean): Type


  /**
   * Sequentially compose with a FunDecl (convert it to a Lambda).
   * @param f A FunDecl object.
   * @return An object representing the sequential composition of `this` and `f`
   *         (wrapped in a lambda)
   */
  def comp(f: FunDecl): Lambda = this o f

  /**
   * Sequential composition operator syntax.
   * @param f The lambda expression to sequentially compose with.
   * @return An object representing the sequential function composition of
   *         `this` and `f`.
   */
  def o(f: FunDecl): Lambda = {
    val params = Array.fill(f.arity)(Param(UndefType))
    Lambda(params, this(f(params:_*)))
  }

  /**
   * Reverse function composition. I.e. g >>> f == f o g
   * @param f The function to compose with (from the right).
   * @return `f o this`
   */
  def >>>(f: FunDecl): Lambda = f o this

  /**
   * Alternative syntax for function composition.
   * I.e. g <<< f = g o f
   * @param f The function to compose with (from the left).
   * @return `this o f`
   */
  def <<<(f: FunDecl): Lambda = this o f


  /**
   * Function call. This method returns an object representing the function call
   * of `this` with `args`.
   * This method will fail at runtime if the number of given `args` does not
   * match the length of `params`!
   * @param args The arguments to call the function (`this`) with.
   * @return An object (of type FunCall) representing the function call of
   *         `this` with `args`.
   */
  def apply(args : Expr*) : Expr = {
    assert (args.length == arity)
    new FunCall(this, args:_*)
  }

  /**
   * Alternative function call operator syntax. Calls `this.apply(arg)`.
   * @param arg The argument to call the function with.
   * @return An object (of type FunCall) representing the function call of
   *         `this` with `arg`.
   */
  def $(arg: Expr) : Expr = apply(arg)

  /**
   * Alternative function call method. Used by the Java bindings. Calls
{'fraction_non_alphanumeric': 0.1027142096860032, 'fraction_numerical': 0.0, 'mean_word_length': 2.953716690042076, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '4482000', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1613, 'n_words': 715}