All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dotty.tools.dotc.quoted.QuotesCache.scala Maven / Gradle / Ivy

There is a newer version: 3.6.4-RC1-bin-20241220-0bfa1af-NIGHTLY
Show newest version
package dotty.tools.dotc.quoted

import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.util.Property
import dotty.tools.dotc.ast.tpd


object QuotesCache {
  import tpd.*

  /** A key to be used in a context property that caches the unpickled trees */
  private val QuotesCacheKey = new Property.Key[collection.mutable.Map[String | List[String], Tree]]


  /** Get the cached tree of the quote */
  def getTree(pickled: String | List[String])(using Context): Option[Tree] =
    ctx.property(QuotesCacheKey).get.get(pickled)

  /** Update the cached tree of the quote */
  def update(pickled: String | List[String], tree: Tree)(using Context): Unit =
    ctx.property(QuotesCacheKey).get.update(pickled, tree)

  /** Context with a cache for quote trees and tasty bytes */
  def init(ctx: FreshContext): ctx.type =
    ctx.setProperty(QuotesCacheKey, collection.mutable.Map.empty)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy