From 982baae07693ff1a566b4d90e47be60291342e82 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 6 Feb 2010 04:15:08 +0000 Subject: 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. --- src/compiler/scala/tools/nsc/Global.scala | 61 +++++------ src/compiler/scala/tools/nsc/MSILGlobal.scala | 42 -------- .../scala/tools/nsc/backend/JavaPlatform.scala | 36 +++++++ .../scala/tools/nsc/backend/MSILPlatform.scala | 43 ++++++++ .../scala/tools/nsc/backend/Platform.scala | 24 +++++ .../nsc/symtab/classfile/ClassfileParser.scala | 2 +- .../tools/nsc/symtab/classfile/ICodeReader.scala | 2 +- src/compiler/scala/tools/nsc/util/ClassPath.scala | 118 ++++++++++++++------- .../scala/tools/nsc/util/MsilClassPath.scala | 30 +++--- src/scalap/scala/tools/scalap/Main.scala | 9 +- 10 files changed, 229 insertions(+), 138 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/MSILGlobal.scala create mode 100644 src/compiler/scala/tools/nsc/backend/JavaPlatform.scala create mode 100644 src/compiler/scala/tools/nsc/backend/MSILPlatform.scala create mode 100644 src/compiler/scala/tools/nsc/backend/Platform.scala (limited to 'src') 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 } diff --git a/src/compiler/scala/tools/nsc/MSILGlobal.scala b/src/compiler/scala/tools/nsc/MSILGlobal.scala deleted file mode 100644 index 660c3398f0..0000000000 --- a/src/compiler/scala/tools/nsc/MSILGlobal.scala +++ /dev/null @@ -1,42 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2010 LAMP/EPFL - * @author Paul Phillips - */ - -package scala.tools.nsc - -import reporters.{ Reporter, ConsoleReporter } -import util.MsilClassPath -import backend.msil.GenMSIL - -/** A subclass of Global which isolates the dependencies on msil.jar. - */ - -class MSILGlobal(settings: Settings, reporter: Reporter) extends Global(settings, reporter) { - // alternate constructors ------------------------------------------ - def this(reporter: Reporter) = this(new Settings(err => reporter.error(null, err)), reporter) - def this(settings: Settings) = this(settings, new ConsoleReporter(settings)) - - // phaseName = "msil" - object genMSIL extends { - val global: MSILGlobal.this.type = MSILGlobal.this - val runsAfter = List[String]("dce") - val runsRightAfter = None - } with GenMSIL - - override lazy val classPath: MsilClassPath = new MsilClassPath( - settings.assemextdirs.value, settings.assemrefs.value, - settings.sourcepath.value, validClassPathName - ) - - override def rootLoader: LazyType = new loaders.NamespaceLoader(classPath) - - override protected def computeInternalPhases() { - super.computeInternalPhases() - phasesSet += genMSIL // generate .msil files - } - - if (settings.verbose.value) - inform("[AssemRefs = " + settings.assemrefs.value + "]") -} - diff --git a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala new file mode 100644 index 0000000000..02199759b9 --- /dev/null +++ b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala @@ -0,0 +1,36 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package backend + +import io.AbstractFile +import util.JavaClassPath +import util.ClassPath.{ JavaContext, DefaultJavaContext } + +trait JavaPlatform extends Platform[AbstractFile] { + import global._ + + lazy val classPath: JavaClassPath = { + val context = + if (isInlinerOn) new JavaContext + else DefaultJavaContext + + new JavaClassPath( + settings.bootclasspath.value, settings.extdirs.value, + settings.classpath.value, settings.sourcepath.value, + settings.Xcodebase.value, context + ) + } + + def rootLoader = new loaders.JavaPackageLoader(classPath) + + private def depAnalysisPhase = if (settings.make.value != "all") List(dependencyAnalysis) else Nil + def platformPhases = List( + flatten, // get rid of inner classes + liftcode, // generate reified trees + genJVM // generate .class files + ) ::: depAnalysisPhase +} diff --git a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala new file mode 100644 index 0000000000..99878cc842 --- /dev/null +++ b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala @@ -0,0 +1,43 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package backend + +import ch.epfl.lamp.compiler.msil.{ Type => MSILType } +import util.MsilClassPath +import util.MsilClassPath.MsilContext +import util.ClassPath.{ isTraitImplementation } +import msil.GenMSIL + +trait MSILPlatform extends Platform[MSILType] { + import global._ + + if (settings.verbose.value) + inform("[AssemRefs = " + settings.assemrefs.value + "]") + + // phaseName = "msil" + object genMSIL extends { + val global: MSILPlatform.this.global.type = MSILPlatform.this.global + val runsAfter = List[String]("dce") + val runsRightAfter = None + } with GenMSIL + + lazy val classPath: MsilClassPath = { + val context = + if (isInlinerOn) new MsilContext + else new MsilContext { + override def isValidName(name: String) = !isTraitImplementation(name) + } + + new MsilClassPath(settings.assemextdirs.value, settings.assemrefs.value, settings.sourcepath.value, context) + } + + def rootLoader = new loaders.NamespaceLoader(classPath) + + def platformPhases = List( + genMSIL // generate .msil files + ) +} diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala new file mode 100644 index 0000000000..3ab0e4e8a7 --- /dev/null +++ b/src/compiler/scala/tools/nsc/backend/Platform.scala @@ -0,0 +1,24 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package backend + +import util.{ ClassPath } + +/** The platform dependent pieces of Global. + */ + +trait Platform[T] { + val global: Global + import global._ + + // Unless inlining is on, we can exclude $class.class files from the classpath. + protected def isInlinerOn = settings.inline.value + + def classPath: ClassPath[T] + def rootLoader: global.LazyType + def platformPhases: List[SubComponent] +} diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 538a606243..745761a065 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -952,7 +952,7 @@ abstract class ClassfileParser { for (entry <- innerClasses.valuesIterator) { // create a new class member for immediate inner classes if (entry.outerName == externalName) { - val file = global.classPath.findAbstractFile(entry.externalName.toString) getOrElse { + val file = global.classPath.findSourceFile(entry.externalName.toString) getOrElse { throw new AssertionError(entry.externalName) } enterClassAndModule(entry, new global.loaders.ClassfileLoader(file), entry.jflags) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 8a77be6d83..0e00f640ca 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -50,7 +50,7 @@ abstract class ICodeReader extends ClassfileParser { log("Reading class: " + cls + " isScalaModule?: " + isScalaModule) val name = cls.fullName('.') + (if (sym.hasFlag(MODULE)) "$" else "") - classPath.findAbstractFile(name) match { + classPath.findSourceFile(name) match { case Some(classFile) => parse(classFile, sym) case _ => log("Could not find: " + cls) } diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 9bfe343aee..b00e4c0950 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -60,33 +60,76 @@ object ClassPath { else splitPath(path) /** A useful name filter. */ - val noTraitImplFilter: String => Boolean = name => !(name endsWith "$class.class") + def isTraitImplementation(name: String) = name endsWith "$class.class" import java.net.MalformedURLException def specToURL(spec: String): Option[URL] = try Some(new URL(spec)) catch { case _: MalformedURLException => None } + + /** A class modeling aspects of a ClassPath which should be + * propagated to any classpaths it creates. + */ + abstract class ClassPathContext[T] { + /** A filter which can be used to exclude entities from the classpath + * based on their name. + */ + def isValidName(name: String): Boolean = true + + /** From the representation to its identifier. + */ + def toBinaryName(rep: T): String + } + + class JavaContext extends ClassPathContext[AbstractFile] { + def toBinaryName(rep: AbstractFile) = { + assert(rep.name endsWith ".class", rep.name) + rep.name dropRight 6 + } + } + + object DefaultJavaContext extends JavaContext { + override def isValidName(name: String) = !isTraitImplementation(name) + } + + /** From the source file to its identifier. + */ + def toSourceName(f: AbstractFile): String = { + val nme = f.name + if (nme.endsWith(".scala")) + nme dropRight 6 + else if (nme.endsWith(".java")) + nme dropRight 5 + else + throw new FatalError("Unexpected source file ending: " + nme) + } } +import ClassPath._ /** * Represents a package which contains classes and other packages */ abstract class ClassPath[T] { type AnyClassRep = ClassPath[T]#ClassRep + /** * The short name of the package (without prefix) */ def name: String + + /** Info which should be propagated to any sub-classpaths. + */ + def context: ClassPathContext[T] + + /** Lists of entities. + */ val classes: List[AnyClassRep] val packages: List[ClassPath[T]] val sourcepaths: List[AbstractFile] - protected def nameOfBinaryRepresentation(binary: T): String = binary match { - case f: AbstractFile => - assert(f.name endsWith ".class", f.name) - f.name dropRight 6 - case _ => - throw new FatalError("Unexpected binary class representation: " + binary) - } + + /** Creation controlled so context is retained. + */ + def createSourcePath(dir: AbstractFile) = new SourcePath[T](dir, context) /** * Represents classes which can be loaded with a ClassfileLoader/MSILTypeLoader @@ -94,27 +137,16 @@ abstract class ClassPath[T] { */ case class ClassRep(binary: Option[T], source: Option[AbstractFile]) { def name: String = binary match { - case Some(x) => nameOfBinaryRepresentation(x) + case Some(x) => context.toBinaryName(x) case _ => assert(source.isDefined) - val nme = source.get.name - if (nme.endsWith(".scala")) - nme dropRight 6 - else if (nme.endsWith(".java")) - nme dropRight 5 - else - throw new FatalError("Unexpected source file ending: " + nme) + toSourceName(source.get) } } - /** A filter which can be used to exclude entities from the classpath - * based on their name. - */ - def validName: String => Boolean - /** Filters for assessing validity of various entities. */ - def validClassFile(name: String) = (name endsWith ".class") && validName(name) + def validClassFile(name: String) = (name endsWith ".class") && context.isValidName(name) def validPackage(name: String) = (name != "META-INF") && (name != "") && (name.head != '.') def validSourceFile(name: String) = validSourceExtensions exists (name endsWith _) def validSourceExtensions = List(".scala", ".java") @@ -139,7 +171,7 @@ abstract class ClassPath[T] { } } } - def findAbstractFile(name: String): Option[AbstractFile] = { + def findSourceFile(name: String): Option[AbstractFile] = { findClass(name) match { case Some(ClassRep(Some(x: AbstractFile), _)) => Some(x) case _ => None @@ -147,10 +179,14 @@ abstract class ClassPath[T] { } } +trait AbstractFileClassPath extends ClassPath[AbstractFile] { + def createDirectoryPath(dir: AbstractFile): DirectoryClassPath = new DirectoryClassPath(dir, context) +} + /** * A Classpath containing source files */ -class SourcePath[T](dir: AbstractFile, val validName: String => Boolean) extends ClassPath[T] { +class SourcePath[T](dir: AbstractFile, val context: ClassPathContext[T]) extends ClassPath[T] { def name = dir.name lazy val classes: List[ClassRep] = dir partialMap { @@ -158,7 +194,7 @@ class SourcePath[T](dir: AbstractFile, val validName: String => Boolean) extends } toList lazy val packages: List[SourcePath[T]] = dir partialMap { - case f if f.isDirectory && validPackage(f.name) => new SourcePath[T](f, validName) + case f if f.isDirectory && validPackage(f.name) => createSourcePath(f) } toList val sourcepaths: List[AbstractFile] = List(dir) @@ -169,7 +205,7 @@ class SourcePath[T](dir: AbstractFile, val validName: String => Boolean) extends /** * A directory (or a .jar file) containing classfiles and packages */ -class DirectoryClassPath(dir: AbstractFile, val validName: String => Boolean) extends ClassPath[AbstractFile] { +class DirectoryClassPath(dir: AbstractFile, val context: ClassPathContext[AbstractFile]) extends AbstractFileClassPath { def name = dir.name lazy val classes: List[ClassRep] = dir partialMap { @@ -177,7 +213,7 @@ class DirectoryClassPath(dir: AbstractFile, val validName: String => Boolean) ex } toList lazy val packages: List[DirectoryClassPath] = dir partialMap { - case f if f.isDirectory && validPackage(f.name) => new DirectoryClassPath(f, validName) + case f if f.isDirectory && validPackage(f.name) => createDirectoryPath(f) } toList val sourcepaths: List[AbstractFile] = Nil @@ -229,17 +265,18 @@ abstract class MergedClassPath[T] extends ClassPath[T] { lazy val sourcepaths: List[AbstractFile] = entries.flatMap(_.sourcepaths) - private def addPackage(to: ClassPath[T], pkg: ClassPath[T]) = to match { - case cp: MergedClassPath[_] => - newMergedClassPath(cp.entries ::: List(pkg)) - case _ => - newMergedClassPath(List(to, pkg)) + private def addPackage(to: ClassPath[T], pkg: ClassPath[T]) = { + def expand = to match { + case cp: MergedClassPath[_] => cp.entries + case _ => List(to) + } + newMergedClassPath(expand :+ pkg) } - private def newMergedClassPath(entrs: List[ClassPath[T]]): MergedClassPath[T] = + private def newMergedClassPath(entrs: List[ClassPath[T]]) = new MergedClassPath[T] { protected val entries = entrs - override def validName = outer.validName + val context = outer.context } override def toString() = "merged classpath "+ entries.mkString("(", "\n", ")") @@ -255,8 +292,8 @@ class JavaClassPath( user: String, source: String, Xcodebase: String, - val validName: String => Boolean = ClassPath.noTraitImplFilter -) extends MergedClassPath[AbstractFile] { + val context: JavaContext +) extends MergedClassPath[AbstractFile] with AbstractFileClassPath { protected val entries: List[ClassPath[AbstractFile]] = assembleEntries() @@ -264,8 +301,7 @@ class JavaClassPath( import ClassPath._ val etr = new ListBuffer[ClassPath[AbstractFile]] - def addFilesInPath(path: String, expand: Boolean, - ctr: AbstractFile => ClassPath[AbstractFile] = x => new DirectoryClassPath(x, validName)) { + def addFilesInPath(path: String, expand: Boolean, ctr: AbstractFile => ClassPath[AbstractFile] = x => createDirectoryPath(x)) { for (fileName <- expandPath(path, expandStar = expand)) { val file = AbstractFile.getDirectory(fileName) if (file ne null) etr += ctr(file) @@ -283,7 +319,7 @@ class JavaClassPath( val name = file.name.toLowerCase if (name.endsWith(".jar") || name.endsWith(".zip") || file.isDirectory) { val archive = AbstractFile.getDirectory(new File(dir.file, name)) - if (archive ne null) etr += new DirectoryClassPath(archive, validName) + if (archive ne null) etr += createDirectoryPath(archive) } } } @@ -299,13 +335,13 @@ class JavaClassPath( url <- specToURL(spec) archive <- Option(AbstractFile getURL url) } { - etr += new DirectoryClassPath(archive, validName) + etr += createDirectoryPath(archive) } } // 5. Source path if (source != "") - addFilesInPath(source, false, x => new SourcePath[AbstractFile](x, validName)) + addFilesInPath(source, false, x => createSourcePath(x)) etr.toList } diff --git a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala index b55e44c822..aacaf1b7ad 100644 --- a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala @@ -13,10 +13,11 @@ import java.net.URL import java.util.StringTokenizer import scala.util.Sorting -import scala.collection.mutable.{ListBuffer, ArrayBuffer, HashSet => MutHashSet} +import scala.collection.mutable.{ ListBuffer, HashSet => MutHashSet } import scala.tools.nsc.io.AbstractFile -import ch.epfl.lamp.compiler.msil.{Type => MSILType, Assembly} +import ch.epfl.lamp.compiler.msil.{ Type => MSILType, Assembly } +import ClassPath.ClassPathContext /** Keeping the MSIL classpath code in its own file is important to make sure * we don't accidentally introduce a dependency on msil.jar in the jvm. @@ -33,22 +34,23 @@ object MsilClassPath { } res } + + class MsilContext extends ClassPathContext[MSILType] { + def toBinaryName(rep: MSILType) = rep.Name + } } +import MsilClassPath.MsilContext /** * A assembly file (dll / exe) containing classes and namespaces */ -class AssemblyClassPath(types: Array[MSILType], namespace: String, val validName: String => Boolean) extends ClassPath[MSILType] { +class AssemblyClassPath(types: Array[MSILType], namespace: String, val context: MsilContext) extends ClassPath[MSILType] { def name = { val i = namespace.lastIndexOf('.') if (i < 0) namespace else namespace drop (i + 1) } - def this(assemFile: AbstractFile, validName: String => Boolean) { - this(MsilClassPath.collectTypes(assemFile), "", validName) - } - private lazy val first: Int = { var m = 0 var n = types.length - 1 @@ -88,7 +90,7 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val validName i += 1 } for (ns <- nsSet.toList) - yield new AssemblyClassPath(types, ns, validName) + yield new AssemblyClassPath(types, ns, context) } val sourcepaths: List[AbstractFile] = Nil @@ -100,9 +102,11 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val validName * The classpath when compiling with target:msil. Binary files are represented as * MSILType values. */ -class MsilClassPath(ext: String, user: String, source: String, val validName: String => Boolean) extends MergedClassPath[MSILType] { +class MsilClassPath(ext: String, user: String, source: String, val context: MsilContext) extends MergedClassPath[MSILType] { protected val entries: List[ClassPath[MSILType]] = assembleEntries() - override protected def nameOfBinaryRepresentation(binary: MSILType) = binary.Name + + def createAssemblyPath(assemFile: AbstractFile) = + new AssemblyClassPath(MsilClassPath collectTypes assemFile, "", context) private def assembleEntries(): List[ClassPath[MSILType]] = { import ClassPath._ @@ -117,7 +121,7 @@ class MsilClassPath(ext: String, user: String, source: String, val validName: St val name = file.name.toLowerCase if (name.endsWith(".dll") || name.endsWith(".exe")) { names += name - etr += new AssemblyClassPath(file, validName) + etr += createAssemblyPath(file) } } } @@ -130,7 +134,7 @@ class MsilClassPath(ext: String, user: String, source: String, val validName: St val name = file.name.toLowerCase if (name.endsWith(".dll") || name.endsWith(".exe")) { names += name - etr += new AssemblyClassPath(file, validName) + etr += createAssemblyPath(file) } } } @@ -146,7 +150,7 @@ class MsilClassPath(ext: String, user: String, source: String, val validName: St // 3. Source path for (dirName <- expandPath(source, expandStar = false)) { val file = AbstractFile.getDirectory(dirName) - if (file ne null) etr += new SourcePath[MSILType](file, validName) + if (file ne null) etr += new SourcePath[MSILType](file, context) } etr.toList diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index 28e48a34d0..90f1963d14 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -12,7 +12,8 @@ package scala.tools.scalap import java.io.{File, PrintStream, OutputStreamWriter, ByteArrayOutputStream} import scalax.rules.scalasig._ import tools.nsc.io.AbstractFile -import tools.nsc.util.{ClassPath, JavaClassPath} +import tools.nsc.util.{ ClassPath, JavaClassPath } +import ClassPath.DefaultJavaContext /**The main object used to execute scalap on the command-line. * @@ -266,9 +267,9 @@ object Main { val path = arguments.getArgument("-classpath") match { case None => arguments.getArgument("-cp") match { case None => EmptyClasspath - case Some(path) => new JavaClassPath("", "", path, "", "") + case Some(path) => new JavaClassPath("", "", path, "", "", DefaultJavaContext) } - case Some(path) => new JavaClassPath("", "", path, "", "") + case Some(path) => new JavaClassPath("", "", path, "", "", DefaultJavaContext) } // print the classpath if output is verbose if (verbose) { @@ -284,9 +285,9 @@ object Main { * The short name of the package (without prefix) */ def name: String = "" + val context = DefaultJavaContext val classes: List[ClassRep] = Nil val packages: List[ClassPath[AbstractFile]] = Nil val sourcepaths: List[AbstractFile] = Nil - val validName: String => Boolean = ClassPath.noTraitImplFilter } } -- cgit v1.2.3