summaryrefslogtreecommitdiff
path: root/sources/scala/tools/scalac/wholeprog/WholeProgPhase.scala
blob: 4666b577a167e38a62786537e15e461b6932ff5b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

/*
**       The Global analysis phase.
**
**  We add a new phase in the compiler, WholeProgPhase.
**
** [iuli]   3.03.2004                                                   */

import scalac.{Global => scalac_Global}
import scalac.transformer.{WholeProgPhase => scalac_WholeProgPhase}
import scalac.PhaseDescriptor;
import scalac.CompilationUnit;
import scalac.util.Debug;

package scala.tools.scalac.wholeprog {

/**
 * This phase analyzes the whole program and tries to derive some
 * useful facts about it: which classes can be marked final, what
 * methods, fields are never used, and monomorphic call-sites.
 */
class WholeProgPhase(global: scalac_Global, descriptor: PhaseDescriptor)
    extends scalac_WholeProgPhase (global, descriptor) {


  /* Apply the global analysis phase to the given units */
  def applyAll(units: Array[CompilationUnit]): unit = {

    if (!global.args.XdotFile.value.equals("$")) {
      val dotFilePrinter = new PrintDotFile(units);
      dotFilePrinter.makeDotFile(global.args.XdotFile.value);
    }

    if (!global.args.XrootClass.value.equals("$")) {

      var builder: ApplicationBuilder = new ApplicationBuilder(global);
      builder.buildApplication(global.args.XrootClass.value, units);
    }

    if (!global.args.XdotFile.value.equals("$")) {
      val dotFilePrinter = new PrintDotFile(units);
      dotFilePrinter.makeDotFile(global.args.XdotFile.value + "2");
    }
  }

  override def apply(unit: CompilationUnit): Unit =
    throw Debug.abort("!!! Phase " + this + " is currently disabled");

}

}