summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-06 04:15:08 +0000
committerPaul Phillips <paulp@improving.org>2010-02-06 04:15:08 +0000
commit982baae07693ff1a566b4d90e47be60291342e82 (patch)
treeda942c895b7922206f55a8cf3ca063d2e94c4c03 /src/compiler/scala/tools/nsc/Global.scala
parent9691e49efe3f0e25727476b8c6546a39c79e33be (diff)
downloadscala-982baae07693ff1a566b4d90e47be60291342e82.tar.gz
scala-982baae07693ff1a566b4d90e47be60291342e82.tar.bz2
scala-982baae07693ff1a566b4d90e47be60291342e82.zip
A more MSIL-aware attempt at isolating the plat...
A more MSIL-aware attempt at isolating the platform dependent pieces of Global and ClassPath so we don't introduce unwanted dependencies. Introduces a small interface backend.Platform which encapsulates that data. Review by rytz, odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index f82bae8afa..a463e35027 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -6,29 +6,28 @@
package scala.tools.nsc
-import java.io.{File, FileOutputStream, PrintWriter}
-import java.io.{IOException, FileNotFoundException}
-import java.nio.charset._
+import java.io.{ File, FileOutputStream, PrintWriter, IOException, FileNotFoundException }
+import java.nio.charset.{ Charset, IllegalCharsetNameException, UnsupportedCharsetException }
import compat.Platform.currentTime
-import scala.tools.nsc.io.{SourceReader, AbstractFile, Path}
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.util.{ClassPath, JavaClassPath, SourceFile, BatchSourceFile, OffsetPosition, RangePosition}
-import scala.collection.mutable.{HashSet, HashMap, ListBuffer}
+import io.{ SourceReader, AbstractFile, Path }
+import reporters.{ Reporter, ConsoleReporter }
+import util.{ ClassPath, SourceFile, Statistics, BatchSourceFile }
+import collection.mutable.{ HashSet, HashMap, ListBuffer }
-import symtab._
+import symtab.{ Flags, SymbolTable, SymbolLoaders }
import symtab.classfile.{PickleBuffer, Pickler}
-import dependencies.{DependencyAnalysis}
-import util.Statistics
+import dependencies.DependencyAnalysis
import plugins.Plugins
import ast._
import ast.parser._
import typechecker._
import transform._
-import backend.icode.{ICodes, GenICode, Checkers}
-import backend.ScalaPrimitives
+
+import backend.icode.{ ICodes, GenICode, Checkers }
+import backend.{ ScalaPrimitives, Platform, MSILPlatform, JavaPlatform }
import backend.jvm.GenJVM
-import backend.opt.{Inliners, ClosureElimination, DeadCodeElimination}
+import backend.opt.{ Inliners, ClosureElimination, DeadCodeElimination }
import backend.icode.analysis._
class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
@@ -45,7 +44,16 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def this(settings: Settings) =
this(settings, new ConsoleReporter(settings))
- //def this() = this(new Settings, new ConsoleReporter)
+ // platform specific elements
+
+ type ThisPlatform = Platform[_] { val global: Global.this.type }
+
+ lazy val platform: ThisPlatform =
+ if (forMSIL) new { val global: Global.this.type = Global.this } with MSILPlatform
+ else new { val global: Global.this.type = Global.this } with JavaPlatform
+
+ def classPath: ClassPath[_] = platform.classPath
+ def rootLoader: LazyType = platform.rootLoader
// sub-components --------------------------------------------------
@@ -209,18 +217,6 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
}
}
- // Unless inlining is on, we can exclude $class.class files from the classpath.
- protected def validClassPathName: String => Boolean =
- if (settings.inline.value) _ => true
- else ClassPath.noTraitImplFilter
-
- lazy val classPath: ClassPath[_] =
- new JavaClassPath(
- settings.bootclasspath.value, settings.extdirs.value,
- settings.classpath.value, settings.sourcepath.value,
- settings.Xcodebase.value, validClassPathName
- )
-
if (settings.verbose.value)
inform("[Classpath = " + classPath + "]")
@@ -238,8 +234,6 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this
}
- def rootLoader: LazyType = new loaders.JavaPackageLoader(classPath.asInstanceOf[JavaClassPath])
-
// ------------ Phases -------------------------------------------}
var globalPhase: Phase = NoPhase
@@ -535,20 +529,15 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
phasesSet += closureElimination // optimization: get rid of uncalled closures
phasesSet += deadCode // optimization: get rid of dead cpde
phasesSet += terminal // The last phase in the compiler chain
-
- if (forJVM) {
- phasesSet += flatten // get rid of inner classes
- phasesSet += liftcode // generate reified trees
- phasesSet += genJVM // generate .class files
- if (settings.make.value != "all")
- phasesSet += dependencyAnalysis
- }
}
+ protected def computePlatformPhases() = platform.platformPhases foreach (phasesSet += _)
+
/* Helper method for sequncing the phase assembly
*/
private def computePhaseDescriptors: List[SubComponent] = {
computeInternalPhases() // Global.scala
+ computePlatformPhases() // backend/Platform.scala
computePluginPhases() // plugins/Plugins.scala
buildCompilerFromPhasesSet() // PhaseAssembly.scala
}