summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/internal/pickling/UnPickler.scala2
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl22
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala23
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala7
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/Entity.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala2
-rw-r--r--src/compiler/scala/tools/nsc/io/Lexer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala2
14 files changed, 68 insertions, 23 deletions
diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
index 00dc04de80..9aa3d8a2c3 100644
--- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
@@ -509,7 +509,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
val tpe = if (tag == EMPTYtree) NoType else readTypeRef()
// Set by the three functions to follow. If symbol is non-null
- // after the the new tree 't' has been created, t has its Symbol
+ // after the new tree 't' has been created, t has its Symbol
// set to symbol; and it always has its Type set to tpe.
var symbol: Symbol = null
var mods: Modifiers = null
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 4275ef7ba1..7e51930fa4 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -58,12 +58,17 @@ if uname | grep -q ^CYGWIN; then
cygwin="$(uname)"
fi
+unset mingw
+if uname | grep -q ^MINGW; then
+ mingw="$(uname)"
+fi
+
# Finding the root folder for this Scala distribution
SCALA_HOME="$(findScalaHome)"
SEP=":"
# Possible additional command line options
-CYGWIN_OPT=""
+WINDOWS_OPT=""
EMACS_OPT=""
[[ -n "$EMACS" ]] && EMACS_OPT="-Denv.emacs=$EMACS"
@@ -94,10 +99,16 @@ if [[ -n "$cygwin" ]]; then
fi
SCALA_HOME="$(cygpath --$format "$SCALA_HOME")"
TOOL_CLASSPATH="$(cygpath --path --$format "$TOOL_CLASSPATH")"
+elif [[ -n "$mingw" ]]; then
+ SCALA_HOME="$(cmd //c echo "$SCALA_HOME")"
+ TOOL_CLASSPATH="$(cmd //c echo "$TOOL_CLASSPATH")"
+fi
+
+if [[ -n "$cygwin$mingw" ]]; then
case "$TERM" in
rxvt* | xterm*)
stty -icanon min 1 -echo
- CYGWIN_OPT="-Djline.terminal=scala.tools.jline.UnixTerminal"
+ WINDOWS_OPT="-Djline.terminal=scala.tools.jline.UnixTerminal"
;;
esac
fi
@@ -110,9 +121,10 @@ fi
declare -a java_args
declare -a scala_args
-# default to the boot classpath for speed, except on cygwin/mingw.
+# default to the boot classpath for speed, except on cygwin/mingw because
+# JLine on Windows requires a custom DLL to be loaded.
unset usebootcp
-if [[ -z $cygwin ]]; then
+if [[ -z "$cygwin$mingw" ]]; then
usebootcp="true"
fi
@@ -181,7 +193,7 @@ execCommand \
-Dscala.home="$SCALA_HOME" \
-Dscala.usejavacp=true \
$EMACS_OPT \
- $CYGWIN_OPT \
+ $WINDOWS_OPT \
@properties@ @class@ @toolflags@ "$@@"
# record the exit status lest it be overwritten:
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index f65481e29a..13f608ed4e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -310,7 +310,7 @@ abstract class TreeBuilder {
* for (P <- G) E ==> G.foreach (P => E)
*
* Here and in the following (P => E) is interpreted as the function (P => E)
- * if P is a a variable pattern and as the partial function { case P => E } otherwise.
+ * if P is a variable pattern and as the partial function { case P => E } otherwise.
*
* 2.
*
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
index 8130c99978..1978a23d90 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
@@ -284,7 +284,7 @@ trait Linearizers {
handler.startBlock +=: lb
}
- // The first block emitted after a try-catch must be the the one that the try / catch
+ // The first block emitted after a try-catch must be the one that the try / catch
// blocks jump to (because in msil, these jumps cannot be emitted manually)
var firstAfter: Option[BasicBlock] = None
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala
index 70aa8ff54e..865bacffaa 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala
@@ -7,7 +7,7 @@ package scala.tools.nsc
package backend.jvm
import ch.epfl.lamp.fjbg._
-import java.io.{ DataOutputStream, OutputStream, File => JFile }
+import java.io.{ DataOutputStream, FileOutputStream, OutputStream, File => JFile }
import scala.tools.nsc.io._
import scala.tools.nsc.util.ScalaClassLoader
import scala.tools.util.JavapClass
@@ -85,7 +85,7 @@ trait BytecodeWriters {
emitJavap(bytes, javapFile)
}
}
-
+
trait ClassBytecodeWriter extends BytecodeWriter {
def writeClass(label: String, jclass: JClass, sym: Symbol) {
val outfile = getFile(sym, jclass, ".class")
@@ -96,4 +96,20 @@ trait BytecodeWriters {
informProgress("wrote '" + label + "' to " + outfile)
}
}
+
+ trait DumpBytecodeWriter extends BytecodeWriter {
+ val baseDir = Directory(settings.Ydumpclasses.value).createDirectory()
+
+ abstract override def writeClass(label: String, jclass: JClass, sym: Symbol) {
+ super.writeClass(label, jclass, sym)
+
+ val pathName = jclass.getName()
+ var dumpFile = pathName.split("[./]").foldLeft(baseDir: Path) (_ / _) changeExtension "class" toFile;
+ dumpFile.parent.createDirectory()
+ val outstream = new DataOutputStream(new FileOutputStream(dumpFile.path))
+
+ try jclass writeTo outstream
+ finally outstream.close()
+ }
+ }
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 3fe5b83515..e80927f620 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -129,7 +129,12 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
new DirectToJarfileWriter(f.file)
case _ =>
- if (settings.Ygenjavap.isDefault) new ClassBytecodeWriter { }
+ if (settings.Ygenjavap.isDefault) {
+ if(settings.Ydumpclasses.isDefault)
+ new ClassBytecodeWriter { }
+ else
+ new ClassBytecodeWriter with DumpBytecodeWriter { }
+ }
else new ClassBytecodeWriter with JavapBytecodeWriter { }
}
@@ -308,6 +313,18 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
private var innerClassBuffer = mutable.LinkedHashSet[Symbol]()
+ /** Drop redundant interfaces (ones which are implemented by some
+ * other parent) from the immediate parents. This is important on
+ * android because there is otherwise an interface explosion.
+ */
+ private def minimizeInterfaces(interfaces: List[Symbol]): List[Symbol] = (
+ interfaces filterNot (int1 =>
+ interfaces exists (int2 =>
+ (int1 ne int2) && (int2 isSubClass int1)
+ )
+ )
+ )
+
def genClass(c: IClass) {
clasz = c
innerClassBuffer.clear()
@@ -322,7 +339,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
}
val ifaces = superInterfaces match {
case Nil => JClass.NO_INTERFACES
- case _ => mkArray(superInterfaces map (x => javaName(x.typeSymbol)))
+ case _ => mkArray(minimizeInterfaces(superInterfaces map (_.typeSymbol)) map javaName)
}
jclass = fjbgContext.JClass(javaFlags(c.symbol),
@@ -469,7 +486,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
// push the class
jcode emitPUSH javaType(c.symbol).asInstanceOf[JReferenceType]
- // push the the string array of field information
+ // push the string array of field information
jcode emitPUSH fieldList.length
jcode emitANEWARRAY strKind
push(fieldList)
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index 813958af85..5e5320ca9a 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -563,8 +563,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
if (!nameLink.isEmpty)
<a href={nameLink}>{nameHtml}</a>
else nameHtml
- }
- {
+ }{
def tparamsToHtml(mbr: Entity): NodeSeq = mbr match {
case hk: HigherKinded =>
val tpss = hk.typeParams
@@ -580,8 +579,8 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
case _ => NodeSeq.Empty
}
tparamsToHtml(mbr)
- }
- { if (isReduced) NodeSeq.Empty else {
+ }{
+ if (isReduced) NodeSeq.Empty else {
def paramsToHtml(vlsss: List[List[ValueParam]]): NodeSeq = {
def param0(vl: ValueParam): NodeSeq =
// notice the }{ in the next lines, they are necessary to avoid a undesired withspace in output
diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
index 266b9294dd..6eb14a4907 100644
--- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
@@ -376,7 +376,7 @@ trait ParameterEntity extends Entity {
/** A type parameter to a class, trait, or method. */
trait TypeParam extends ParameterEntity with HigherKinded {
- /** The variance of this type type parameter. Valid values are "+", "-", and the empty string. */
+ /** The variance of this type parameter. Valid values are "+", "-", and the empty string. */
def variance: String
/** The lower bound for this type parameter, if it has been defined. */
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index c2e27cd205..f2d59206e0 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -128,7 +128,7 @@ trait CompilerControl { self: Global =>
}
/** Sets sync var `response` to the smallest fully attributed tree that encloses position `pos`.
- * Note: Unlike for most other ask... operations, the source file belonging to `pos` needs not be be loaded.
+ * Note: Unlike for most other ask... operations, the source file belonging to `pos` needs not be loaded.
*/
def askTypeAt(pos: Position, response: Response[Tree]) =
postWorkItem(new AskTypeAtItem(pos, response))
diff --git a/src/compiler/scala/tools/nsc/io/Lexer.scala b/src/compiler/scala/tools/nsc/io/Lexer.scala
index 8f103f9b98..5ffb5b4d4f 100644
--- a/src/compiler/scala/tools/nsc/io/Lexer.scala
+++ b/src/compiler/scala/tools/nsc/io/Lexer.scala
@@ -281,7 +281,7 @@ class Lexer(rd: Reader) {
/** The current token is a delimiter consisting of given character, reads next token,
* otherwise raises an error.
* @param c the given delimiter character to compare current token with
- * @throws MalformedInput if the the current token `token` is not a delimiter, or
+ * @throws MalformedInput if the current token `token` is not a delimiter, or
* consists of a character different from `c`.
*/
def accept(ch: Char) {
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 6be15e4e98..7fcfb6fc6d 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -139,6 +139,7 @@ trait ScalaSettings extends AbsScalaSettings
val Yshowsyms = BooleanSetting ("-Yshow-syms", "Print the AST symbol hierarchy after each phase.")
val skip = PhasesSetting ("-Yskip", "Skip")
val Ygenjavap = StringSetting ("-Ygen-javap", "dir", "Generate a parallel output directory of .javap files.", "")
+ val Ydumpclasses = StringSetting ("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "")
val Ynosqueeze = BooleanSetting ("-Yno-squeeze", "Disable creation of compact code in matching.")
val Ystatistics = BooleanSetting ("-Ystatistics", "Print compiler statistics.") .
withPostSetHook(set => util.Statistics.enabled = set.value)
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index 68a53e57a1..f3f823d197 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -95,7 +95,7 @@ abstract class LiftCode extends Transform with TypingTransformers {
buf.append(", " + "List(" + annotations + ")")
var s = buf.toString
- if (s.endsWith(", Map()")) s = s.substring(0, s.length - ", Map()".length)
+ if (s.endsWith(", List()")) s = s.substring(0, s.length - ", List()".length)
if (s.endsWith(", newTypeName(\"\")")) s = s.substring(0, s.length - ", newTypeName(\"\")".length)
if (s.endsWith("Set()")) s = s.substring(0, s.length - "Set()".length)
"Modifiers(" + s + ")"
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index cc88f471ab..e4ebe13217 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -227,7 +227,7 @@ trait NamesDefaults { self: Analyzer =>
// super constructor calls
case Select(sp @ Super(_, _), _) if isConstr =>
// 'moduleQual' fixes #3207. selection of the companion module of the
- // superclass needs to have the same prefix as the the superclass.
+ // superclass needs to have the same prefix as the superclass.
blockWithoutQualifier(moduleQual(baseFun.pos, sp.symbol.tpe.parents.head))
// self constructor calls (in secondary constructors)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 3c72dc8413..c9991614e4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -284,7 +284,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
}
/** Add a protected accessor, if needed, and return a tree that calls
- * the accessor and returns the the same member. The result is already
+ * the accessor and returns the same member. The result is already
* typed.
*/
private def makeAccessor(tree: Select, targs: List[Tree]): Tree = {