<commit_before>package scalan.compilation.lms.cxx.sharedptr

import java.io.PrintWriter

import scala.virtualization.lms.internal.{CLikeCodegen, GenerationFailedException, Expressions, GenericCodegen}


trait CxxShptrCodegen extends CLikeCodegen {
  val IR: Expressions
  import IR._

  trait size_t
  trait SharedPtr[T]

  def toShptrManifest(m: Manifest[_]): Manifest[_] = {
    val nArgs = m.typeArguments.length
    val newM = nArgs match {
      case 0 => m
      case 1 => Manifest.classType(m.runtimeClass, toShptrManifest(m.typeArguments(0)))
      case n => Manifest.classType(m.runtimeClass, toShptrManifest(m.typeArguments(0)), m.typeArguments.drop(1).map(toShptrManifest): _*)
    }

    wrapSharedPtr(newM)
  }

  def wrapSharedPtr:PartialFunction[Manifest[_],Manifest[_]] = {
    case m if m <:< Manifest.AnyVal => m
    case m if m.runtimeClass == classOf[scala.Tuple2[_, _]] => m
    case m if m.runtimeClass == classOf[Variable[_]] => m
    case m if m.runtimeClass == classOf[_=>_] => m
    case m =><commit_msg>exclude SharedPtr manifest from wrapping into SharedPtr<commit_after>package scalan.compilation.lms.cxx.sharedptr

import java.io.PrintWriter

import scala.virtualization.lms.internal.{CLikeCodegen, GenerationFailedException, Expressions, GenericCodegen}


trait CxxShptrCodegen extends CLikeCodegen {
  val IR: Expressions
  import IR._

  trait size_t
  trait SharedPtr[T]

  def toShptrManifest(m: Manifest[_]): Manifest[_] = {
    if( m.runtimeClass == classOf[SharedPtr[_]] )
      m
    else {
      val nArgs = m.typeArguments.length
      val newM = nArgs match {
        case 0 => m
        case 1 => Manifest.classType(m.runtimeClass, toShptrManifest(m.typeArguments(0)))
        case n => Manifest.classType(m.runtimeClass, toShptrManifest(m.typeArguments(0)), m.typeArguments.drop(1).map(toShptrManifest): _*)
      }

      wrapSharedPtr(newM)
    }
  }

  def wrapSharedPtr:PartialFunction[Manifest[_],Manifest[_]] = {
    case m if m <:< Manifest.AnyVal => m
    case m if m.runtimeClass == classOf[SharedPtr[_]] => m
    case m if m.runtimeClass == classOf[scala.Tuple2[_, _]] => m
    case m if m.runtimeClass == classOf[Variable[_]] => m
    case m if m.runtimeClass == classOf[_=>_] => m
    case m =>
{'fraction_non_alphanumeric': 0.12, 'fraction_numerical': 0.005333333333333333, 'mean_word_length': 3.8722943722943723, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, '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': '3637661', 'n_tokens_mistral': 757, 'n_tokens_neox': 750, 'n_words': 165}