From 74483771dcdfc963b28325d8ea3698df273370a1 Mon Sep 17 00:00:00 2001 From: mpociecha Date: Fri, 28 Nov 2014 17:36:00 +0100 Subject: Abstract over ClassPath and ClassRep This commit is intended to create the possibility to plug in into the compiler an alternative classpath representation which would be possibly more efficient, use less memory etc. Such an implementation - at least at the beginning - should exist next to the currently existing one and be possible to turn on using a flag. Several places in the compiler have a direct dependency on the classpath implementation. Examples include backend's icode generator and reader, SymbolLoaders, ClassfileParser. After closer inspection, one realizes that all those places depend only on a very small subset of classpath logic: they need to lookup classes from classpath. Hence there's introduced ClassFileLookup trait that encapsulates that functionality. The ClassPath extends that trait and an alternative one also must do it. There's also added ClassRepresentation - the base trait for ClassRep (the inner class of ClassPath). Thanks to that the compiler uses a type which is not directly related to the particular classpath representation as it was doing until now. --- src/scalap/scala/tools/scalap/Main.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/scalap') diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index c72f416a89..1faa855444 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -11,7 +11,7 @@ package tools.scalap import java.io.{ PrintStream, OutputStreamWriter, ByteArrayOutputStream } import scala.reflect.NameTransformer import scalax.rules.scalasig._ -import scala.tools.nsc.util.{ ClassPath, JavaClassPath } +import scala.tools.nsc.util.{ ClassFileLookup, ClassPath, JavaClassPath } import scala.tools.util.PathResolver import ClassPath.DefaultJavaContext import scala.tools.nsc.io.AbstractFile @@ -96,7 +96,7 @@ class Main { /** Executes scalap with the given arguments and classpath for the * class denoted by `classname`. */ - def process(args: Arguments, path: ClassPath[AbstractFile])(classname: String): Unit = { + def process(args: Arguments, path: ClassFileLookup[AbstractFile])(classname: String): Unit = { // find the classfile val encName = classname match { case "scala.AnyRef" => "java.lang.Object" -- cgit v1.2.3