<commit_before>package scalan

import scala.collection.mutable.{Map => MutMap}
import scala.language.higherKinds
import scalan.common.Lazy
import scalan.meta.ScalanAst.SEntityModuleDef
import scalan.util.ReflectionUtil

trait Entities extends Elems { self: Scalan =>
  abstract class EntityElem[A] extends Elem[A] with scala.Equals {
    def parent: Option[Elem[_]]
    def tyArgSubst: Map[String, TypeDesc]
    def convert(x: Rep[Def[_]]): Rep[A] = !!!("should not be called")
    //def getConverterTo[B](eB: Elem[B]): Conv[A,B] = !!!  //TODO make it abstract
    // TODO generate code for this in implementations
    def canEqual(other: Any) = other.isInstanceOf[EntityElem[_]]
    override def equals(other: Any) = other match {
      case other: EntityElem[_] => other.canEqual(this) && tag.tpe =:= other.tag.tpe
      case _ => false
    }
    override def hashCode = tag.tpe.hashCode
  }
  abstract class EntityElem1[A, To, C[_]](val eItem: Elem[A], val cont: Cont[C])
    extends EntityElem[To] {
  }
  trait ConcreteElem[TData, TClass] extends EntityElem[TClass] with ViewElem[TData, TClass] { eClass =>
    def getConverterFrom[E](eEntity: EntityElem[E]): Option[Conv[E, TClass]] = {
      try {
        val convFun: Rep[E => TClass] =
          fun({ x: Rep[E] => eClass.convert(x.asRep[Def[_]])})(Lazy(eEntity), eClass)
        Some(BaseConverter(convFun)(eEntity, eClass))
      }
      catch {
        case e: RuntimeException => None
      }
    }
  }
  trait ConcreteElem1[A, TData, TClass, C[_]]
    extends EntityElem1[A, TClass, C]
       with ViewElem1[A, TData, TClass, C] { eClass =>
  }

  implicit class EntityElemExtensions[A <: Def[_]](e: Elem[A]) {
    def asEntityElem = e.asInstanceOf[EntityElem[A]]
  }

  private[this] val modules = MutMap.empty[String, SEntityModuleDef]

  def allEntities = modules.values.flatMap(_.allEntities)

  def registerModule(moduleInfo: ModuleInfo) = {
    val m = moduleInfo.moduleDef
    if (modules.contains(m.name))<commit_msg>[Core] better getName for EntityElem1<commit_after>package scalan

import scala.collection.mutable.{Map => MutMap}
import scala.language.higherKinds
import scalan.common.Lazy
import scalan.meta.ScalanAst.SEntityModuleDef
import scalan.util.ReflectionUtil

trait Entities extends Elems { self: Scalan =>
  abstract class EntityElem[A] extends Elem[A] with scala.Equals {
    def parent: Option[Elem[_]]
    def tyArgSubst: Map[String, TypeDesc]
    def convert(x: Rep[Def[_]]): Rep[A] = !!!("should not be called")
    //def getConverterTo[B](eB: Elem[B]): Conv[A,B] = !!!  //TODO make it abstract
    // TODO generate code for this in implementations
    def canEqual(other: Any) = other.isInstanceOf[EntityElem[_]]
    override def equals(other: Any) = other match {
      case other: EntityElem[_] => other.canEqual(this) && tag.tpe =:= other.tag.tpe
      case _ => false
    }
    override def hashCode = tag.tpe.hashCode
  }
  abstract class EntityElem1[A, To, C[_]](val eItem: Elem[A], val cont: Cont[C])
    extends EntityElem[To] {
    override def getName = {
      s"${cont.name}[${eItem.name}]"
    }
  }
  trait ConcreteElem[TData, TClass] extends EntityElem[TClass] with ViewElem[TData, TClass] { eClass =>
    def getConverterFrom[E](eEntity: EntityElem[E]): Option[Conv[E, TClass]] = {
      try {
        val convFun: Rep[E => TClass] =
          fun({ x: Rep[E] => eClass.convert(x.asRep[Def[_]])})(Lazy(eEntity), eClass)
        Some(BaseConverter(convFun)(eEntity, eClass))
      }
      catch {
        case e: RuntimeException => None
      }
    }
  }
  trait ConcreteElem1[A, TData, TClass, C[_]]
    extends EntityElem1[A, TClass, C]
       with ViewElem1[A, TData, TClass, C] { eClass =>
  }

  implicit class EntityElemExtensions[A <: Def[_]](e: Elem[A]) {
    def asEntityElem = e.asInstanceOf[EntityElem[A]]
  }

  private[this] val modules = MutMap.empty[String, SEntityModuleDef]

  def allEntities = modules.values.flatMap(_.allEntities)

  def registerModule(moduleInfo: ModuleInfo) = {
    val m = moduleInfo.moduleDef
    if (modules.contains(m.name))
{'fraction_non_alphanumeric': 0.13573883161512026, 'fraction_numerical': 0.0022091310751104565, 'mean_word_length': 3.738372093023256, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3735602', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1389, 'n_words': 327}