<commit_before>/* ************************************************************** *
 *                                                                *
 * Copyright (c) 2005-2012, <NAME>, All rights reserved.  *
 *                                                                *
 *                                                                *
 * This software is distributed under the modified BSD License.   *
 * ************************************************************** */
package onion.compiler

import onion.compiler.toolbox.SymbolGenerator
import toolbox.SymbolGenerator

/**
 * @author <NAME>
 *
 */
class LocalContext {
  private var contextFrame = new LocalFrame(null)
  private val generator = new SymbolGenerator("symbol#")
  var isClosure: Boolean = false
  var isStatic: Boolean = false
  var isGlobal: Boolean = false
  var method: IRT.MethodRef = null
  var constructor: IRT.ConstructorDefinition = null
  private var isMethod: Boolean = false

  def setGlobal(isGlobal: Boolean): Unit = {
    this.isGlobal = isGlobal
  }

  def setClosure(isClosure: Boolean): Unit = {
    this.isClosure = isClosure
  }

  def setStatic(isStatic: Boolean): Unit = {
    this.isStatic = isStatic
  }

  def newName: String = {
    generator.generate
  }

  def returnType: IRT.TypeRef = {
    if (isMethod) {
      method.returnType
    } else {
      IRT.BasicTypeRef.VOID
    }
  }

  def setMethod(method: IRT.MethodRef): Unit = {
    this.method = method
    this.isMethod = true
  }

  def setConstructor(constructor: IRT.ConstructorDefinition): Unit = {
    this.constructor = constructor
    this.isMethod = false
  }

  def openFrame(): Unit = {
    contextFrame = new LocalFrame(contextFrame)
  }

  def closeFrame(): Unit = {
    contextFrame = contextFrame.parent
  }

  def depth: Int = {
    if (contextFrame == null) {
      -1
    } else {
      contextFrame.depth
    }
  }

  def getContextFrame: LocalFrame = {
    contextFrame
  }

  def setContextFrame(frame: LocalFrame): Unit = {
    this.contextFrame = frame
  }

  def openScope[A](body: => A): A = contextFrame.open(body)

  def open[A](block: => A): A = contextFrame.open(block)

  def lookup(name: String): ClosureLocalBinding = {
    contextFrame.lookup(name)
  }

  def lookupOnlyCurrentScope(name: String): ClosureLocalBinding = {
    contextFrame.lookupOnlyCurrentScope(name)
  }

  def add(name: String, `type` : IRT.TypeRef): Int = {
    contextFrame.add(name, `type`)
  }

  def add(`type` : IRT.TypeRef): String = {
    var name: String = newName
    contextFrame.add(name, `type`)
    name
  }

}<commit_msg>Remove unused code<commit_after>/* ************************************************************** *
 *                                                                *
 * Copyright (c) 2005-2012, <NAME>, All rights reserved.  *
 *                                                                *
 *                                                                *
 * This software is distributed under the modified BSD License.   *
 * ************************************************************** */
package onion.compiler

import onion.compiler.toolbox.SymbolGenerator
import toolbox.SymbolGenerator

/**
 * @author <NAME>
 *
 */
class LocalContext {
  private var contextFrame = new LocalFrame(null)
  private val generator = new SymbolGenerator("symbol#")
  var isClosure: Boolean = false
  var isStatic: Boolean = false
  var isGlobal: Boolean = false
  var method: IRT.MethodRef = null
  var constructor: IRT.ConstructorDefinition = null
  private var isMethod: Boolean = false

  def setGlobal(isGlobal: Boolean): Unit = {
    this.isGlobal = isGlobal
  }

  def setClosure(isClosure: Boolean): Unit = {
    this.isClosure = isClosure
  }

  def setStatic(isStatic: Boolean): Unit = {
    this.isStatic = isStatic
  }

  def newName: String = {
    generator.generate
  }

  def returnType: IRT.TypeRef = {
    if (isMethod) {
      method.returnType
    } else {
      IRT.BasicTypeRef.VOID
    }
  }

  def setMethod(method: IRT.MethodRef): Unit = {
    this.method = method
    this.isMethod = true
  }

  def setConstructor(constructor: IRT.ConstructorDefinition): Unit = {
    this.constructor = constructor
    this.isMethod = false
  }

  def openFrame(): Unit = {
    contextFrame = new LocalFrame(contextFrame)
  }

  def closeFrame(): Unit = {
    contextFrame = contextFrame.parent
  }

  def depth: Int = {
    if (contextFrame == null) {
      -1
    } else {
      contextFrame.depth
    }
  }

  def getContextFrame: LocalFrame = {
    contextFrame
  }

  def setContextFrame(frame: LocalFrame): Unit = {
    this.contextFrame = frame
  }

  def openScope[A](body: => A): A = contextFrame.open(body)

  def lookup(name: String): ClosureLocalBinding = {
    contextFrame.lookup(name)
  }

  def lookupOnlyCurrentScope(name: String): ClosureLocalBinding = {
    contextFrame.lookupOnlyCurrentScope(name)
  }

  def add(name: String, `type` : IRT.TypeRef): Int = {
    contextFrame.add(name, `type`)
  }

  def add(`type` : IRT.TypeRef): String = {
    val name = newName
    contextFrame.add(name, `type`)
    name
  }

}
{'fraction_non_alphanumeric': 0.14757923391016917, 'fraction_numerical': 0.00349990278047832, 'mean_word_length': 2.473328831870358, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3427497', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1430, 'n_words': 350}