-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache unpickled quotes witout definitions
- Loading branch information
1 parent
b1a3e6d
commit 94f069e
Showing
4 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dotty.tools.dotc.quoted | ||
|
||
import dotty.tools.dotc.core.Contexts._ | ||
import dotty.tools.dotc.util.Property | ||
import dotty.tools.dotc.reporting.trace | ||
import dotty.tools.dotc.ast.tpd | ||
|
||
import scala.collection.mutable | ||
|
||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters