<commit_before>/* NSC -- new Scala compiler
 * Copyright 2005-2006 LAMP/EPFL
 * @author  <NAME>
 */

// $Id$

package scala.tools.nsc.backend.jvm

import java.io.File
import java.nio.ByteBuffer

import scala.collection.immutable.{Set, ListSet}
import scala.collection.mutable.{Map, HashMap, HashSet}
import scala.tools.nsc.symtab._
import scala.tools.nsc.util.{Position, NoPosition}

import ch.epfl.lamp.fjbg._

/** This class ...
 *
 *  @author  <NAME>
 *  @version 1.0
 */
abstract class GenJVM extends SubComponent {
  import global._
  import icodes._
  import icodes.opcodes._

  val phaseName = "jvm"

  /** Create a new phase */
  override def newPhase(p: Phase) = new JvmPhase(p)

  /** JVM code generation phase
   */
  class JvmPhase(prev: Phase) extends StdPhase(prev) {

    override def erasedTypes = true
    object codeGenerator extends BytecodeGenerator

    override def run: Unit = {
      if (settings.debug.value) inform("[running phase " + name + " on icode]")
      if (settings.Xdce.value)
        icodes.classes.retain { (sym: Symbol, cls: IClass) => !inliner.isClosureClass(sym) || deadCode.liveClosures(sym) }

      classes.values foreach codeGenerator.genClass
    }

    override def apply(unit: CompilationUnit): Unit =
      abort("JVM works on icode classes, not on compilation units!")
  }

  var pickledBytes = 0 // statistics

  /**
   * Java bytecode generator.
   *
   */
  class BytecodeGenerator {
    val MIN_SWITCH_DENSITY = 0.7
    val StringBufferClass = if (settings.target.value == "jvm-1.5") "java.lang.StringBuilder" else "java.lang.StringBuffer"
    val BoxesUtility = "scala.runtime.BoxesUtility"

    val stringBufferType = new JObjectType(StringBufferClass)
    val toStringType = new JMethodType(JObjectType.JAVA_LANG_STRING, JType.EMPTY_ARRAY)

    // Scala attributes
    val SerializableAttr = definitions.SerializableAttr
    val SerialVersionUID = definitions.getClass("scala.SerialVersionUID")
    val CloneableAttr    = definitions.getClass("scala.cloneable")
    val TransientAtt     = definitions.getClass("scala.transient")
    val VolatileAttr     = definitions.getClass("scala.volatile")
    val RemoteAttr       = definitions.getClass("scala.remote")
    val ThrowsAttr       = definitions.getClass("scala.throws")

    val CloneableClass   =
      if (forCLDC) null else definitions.getClass("java.lang.Cloneable")
    val RemoteInterface  =
      if (forCLDC) null else definitions.getClass("java.rmi.Remote")
    val RemoteException  =
      if (forCLDC) null else definitions.getClass("java.rmi.RemoteException").tpe

    var clasz: IClass = _
    var method: IMethod = _
    var code: Code = _
    var jclass: JClass = _
    var jmethod: JMethod = _
    var jcode: JExtendedCode = _

    var innerClasses: Set[Symbol] = ListSet.empty // referenced inner classes

    val fjbgContext =
      if (settings.target.value == "jvm-1.5") new FJBGContext(49, 0)
      else new FJBGContext()

    val emitSource = settings.debuginfo.level >= 1
    val emitLines  = settings.debuginfo.level >= 2
    val emitVars   = settings.debuginfo.level >= 3

    /**
     * @param jclass ...<commit_msg>Made remote & co.<commit_after>/* NSC -- new Scala compiler
 * Copyright 2005-2006 LAMP/EPFL
 * @author  <NAME>
 */

// $Id$

package scala.tools.nsc.backend.jvm

import java.io.File
import java.nio.ByteBuffer

import scala.collection.immutable.{Set, ListSet}
import scala.collection.mutable.{Map, HashMap, HashSet}
import scala.tools.nsc.symtab._
import scala.tools.nsc.util.{Position, NoPosition}

import ch.epfl.lamp.fjbg._

/** This class ...
 *
 *  @author  <NAME>
 *  @version 1.0
 */
abstract class GenJVM extends SubComponent {
  import global._
  import icodes._
  import icodes.opcodes._

  val phaseName = "jvm"

  /** Create a new phase */
  override def newPhase(p: Phase) = new JvmPhase(p)

  /** JVM code generation phase
   */
  class JvmPhase(prev: Phase) extends StdPhase(prev) {

    override def erasedTypes = true
    object codeGenerator extends BytecodeGenerator

    override def run: Unit = {
      if (settings.debug.value) inform("[running phase " + name + " on icode]")
      if (settings.Xdce.value)
        icodes.classes.retain { (sym: Symbol, cls: IClass) => !inliner.isClosureClass(sym) || deadCode.liveClosures(sym) }

      classes.values foreach codeGenerator.genClass
    }

    override def apply(unit: CompilationUnit): Unit =
      abort("JVM works on icode classes, not on compilation units!")
  }

  var pickledBytes = 0 // statistics

  /**
   * Java bytecode generator.
   *
   */
  class BytecodeGenerator {
    val MIN_SWITCH_DENSITY = 0.7
    val StringBufferClass = if (settings.target.value == "jvm-1.5") "java.lang.StringBuilder" else "java.lang.StringBuffer"
    val BoxesUtility = "scala.runtime.BoxesUtility"

    val stringBufferType = new JObjectType(StringBufferClass)
    val toStringType = new JMethodType(JObjectType.JAVA_LANG_STRING, JType.EMPTY_ARRAY)

    // Scala attributes
    val SerializableAttr = definitions.SerializableAttr
    val SerialVersionUID = definitions.getClass("scala.SerialVersionUID")
    val CloneableAttr    = definitions.getClass("scala.cloneable")
    val TransientAtt     = definitions.getClass("scala.transient")
    val VolatileAttr     = definitions.getClass("scala.volatile")
    val RemoteAttr       = definitions.getClass("scala.remote")
    val ThrowsAttr       = definitions.getClass("scala.throws")

    lazy val CloneableClass  = definitions.getClass("java.lang.Cloneable")
    lazy val RemoteInterface = definitions.getClass("java.rmi.Remote")
    lazy val RemoteException = definitions.getClass("java.rmi.RemoteException").tpe

    var clasz: IClass = _
    var method: IMethod = _
    var code: Code = _
    var jclass: JClass = _
    var jmethod: JMethod = _
    var jcode: JExtendedCode = _

    var innerClasses: Set[Symbol] = ListSet.empty // referenced inner classes

    val fjbgContext =
      if (settings.target.value == "jvm-1.5") new FJBGContext(49, 0)
      else new FJBGContext()

    val emitSource = settings.debuginfo.level >= 1
    val emitLines  = settings.debuginfo.level >= 2
    val emitVars   = settings.debuginfo.level >= 3

    /**
     * @param jclass ...
{'fraction_non_alphanumeric': 0.10877587036739933, 'fraction_numerical': 0.007380073800738007, 'mean_word_length': 3.29043358568479, 'pattern_counts': {'":': 0, '<': 7, '<?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': '931571', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1949, 'n_words': 475}