aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/CompilationUnit.scala
blob: f0ce19320c338bf2cbc8b158f5dd25e459527fa9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package dotty.tools
package dotc

import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.pickling.{TastyBuffer, TastyPickler}
import util.SourceFile
import ast.{tpd, untpd}
import TastyBuffer._
import dotty.tools.dotc.core.Symbols._

class CompilationUnit(val source: SourceFile) {

  override def toString = source.toString

  var untpdTree: untpd.Tree = untpd.EmptyTree

  var tpdTree: tpd.Tree = tpd.EmptyTree

  def isJava = source.file.name.endsWith(".java")

  /**
   * Picklers used to create TASTY sections, indexed by toplevel class to which they belong.
   * Sections: Header, ASTs and Positions are populated by `pickler` phase.
   * Subsequent phases can add new sections.
   */
  var picklers: Map[ClassSymbol, TastyPickler] = Map()

  /** TODO: I'd prefer we do not put this in CompilationUnit
   * Addresses in TASTY file of trees, stored by pickling.
   * Note that trees are checked for reference equality,
   * so one can reliably use this function only directly after `pickler`
   */
  var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)

  /** TODO: I'd prefer we do not put this in CompilationUnit
   * Addresses in TASTY file of symbols, stored by pickling.
   * Note that trees are checked for reference equality,
   * so one can reliably use this function only dirrectly after `pickler`
   */
  var addrOfSym: Symbol => Option[Addr] = (_ => None)
}