summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2009-03-10 11:39:04 +0000
committermichelou <michelou@epfl.ch>2009-03-10 11:39:04 +0000
commit40f8fa94026d482f8318481bb64ae0245a39acbc (patch)
treef5f6cd4423ee49f9c77f5222cb6ae4de62fbc461 /src/compiler/scala
parent5e2dd3850dd6da531b4e9ba7075081aae65a1502 (diff)
downloadscala-40f8fa94026d482f8318481bb64ae0245a39acbc.tar.gz
scala-40f8fa94026d482f8318481bb64ae0245a39acbc.tar.bz2
scala-40f8fa94026d482f8318481bb64ae0245a39acbc.zip
removed deprecated warning, updated svn props, ...
removed deprecated warning, updated svn props, cleaned up code
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala1
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala10
-rw-r--r--src/compiler/scala/tools/nsc/CompilerCommand.scala34
-rw-r--r--src/compiler/scala/tools/nsc/IdeSupport.scala34
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala8
-rw-r--r--src/compiler/scala/tools/nsc/PhaseAssembly.scala149
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala178
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala20
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/JLineReader.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala4
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala6
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala11
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala4
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala7
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala12
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala3
-rw-r--r--src/compiler/scala/tools/nsc/util/FreshNameCreator.scala60
20 files changed, 304 insertions, 253 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index ea2c466be4..b38ac01c8a 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -69,7 +69,7 @@ trait CompilationUnits { self: Global =>
override def toString() = source.toString()
- def clear() = {
+ def clear() {
fresh = null
body = null
depends.clear
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 8b4767018c..dd3133acdb 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -48,7 +48,6 @@ class StandardCompileServer extends SocketServer {
var reporter: ConsoleReporter = _
-
/** Create a new compiler instance */
def newGlobal(settings: Settings, reporter: Reporter) =
new Global(settings, reporter) {
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index f5fe702e7a..c22181eabf 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -251,15 +251,15 @@ class CompileSocket {
}
def getPassword(port: Int): String = {
- val ff=portFile(port)
+ val ff = portFile(port)
val f = new BufferedReader(new FileReader(ff))
// allow some time for the server to start up
- var retry=50
- while (ff.length()==0 && retry>0) {
+ var retry = 50
+ while (ff.length() == 0 && retry > 0) {
Thread.sleep(100)
- retry-=1
+ retry -= 1
}
- if (ff.length()==0) {
+ if (ff.length() == 0) {
ff.delete()
fatal("Unable to establish connection to server.")
}
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala
index c5c7f84434..7896f4e270 100644
--- a/src/compiler/scala/tools/nsc/CompilerCommand.scala
+++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala
@@ -77,33 +77,33 @@ class CompilerCommand(
// start; an informative message of some sort
// should be printed instead.
// (note: do not add "files.isEmpty" do this list)
- val stopSettings=List[(()=>Boolean,
- (Global)=>String)](
- (()=> settings.help.value, compiler =>
- usageMsg + compiler.pluginOptionsHelp
+ val stopSettings = List[(() => Boolean, (Global) => String)](
+ (() => settings.help.value,
+ compiler => usageMsg + compiler.pluginOptionsHelp
),
- (()=> settings.Xhelp.value, compiler =>
- xusageMsg
+ (() => settings.Xhelp.value,
+ compiler => xusageMsg
),
- (()=> settings.Yhelp.value, compiler =>
- yusageMsg
+ (() => settings.Yhelp.value,
+ compiler => yusageMsg
),
- (()=> settings.showPlugins.value, compiler =>
- compiler.pluginDescriptions
+ (() => settings.showPlugins.value,
+ compiler => compiler.pluginDescriptions
),
- (()=> settings.showPhases.value, compiler =>
- compiler.phaseDescriptions
+ (() => settings.showPhases.value,
+ compiler => compiler.phaseDescriptions
)
)
- def shouldStopWithInfo = stopSettings.exists({pair => (pair._1)()})
- def getInfoMessage(compiler:Global) =
- stopSettings.find({pair => (pair._1)()}) match {
- case Some((test,getMessage)) => getMessage(compiler)
+ def shouldStopWithInfo: Boolean =
+ stopSettings.exists(pair => (pair._1)())
+
+ def getInfoMessage(compiler: Global): String =
+ stopSettings.find(pair => (pair._1)()) match {
+ case Some((test, getMessage)) => getMessage(compiler)
case None => ""
}
-
/** Whether the command was processed okay */
var ok = true
diff --git a/src/compiler/scala/tools/nsc/IdeSupport.scala b/src/compiler/scala/tools/nsc/IdeSupport.scala
index 91e7ea47a1..ab1580e124 100644
--- a/src/compiler/scala/tools/nsc/IdeSupport.scala
+++ b/src/compiler/scala/tools/nsc/IdeSupport.scala
@@ -1,12 +1,21 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2009 LAMP/EPFL
+ * @author Martin Odersky
+ */
+// $Id$
+
package scala.tools.nsc
+
import scala.tools.nsc.io._
+
trait IdeSupport extends Global with symtab.IdeSupport {
/** to do no dependency tracking */
- protected def normalCompile[T](f : => T) : T = f
- override def unpickleIDEHook : (( => Type) => Type) = f => normalCompile(f)
+ protected def normalCompile[T](f: => T): T = f
+ override def unpickleIDEHook: (( => Type) => Type) = f => normalCompile(f)
+
class IdeRun extends Run {
- override def compiles(sym : Symbol) : Boolean = false // throw new Error
- override def compileLate(file : AbstractFile) = {
+ override def compiles(sym: Symbol): Boolean = false // throw new Error
+ override def compileLate(file: AbstractFile) = {
reloadSource(file)
normalCompile(super.compileLate(file))
}
@@ -14,29 +23,32 @@ trait IdeSupport extends Global with symtab.IdeSupport {
name == "superaccessors" || super.stopPhase(name)
}
-
// load a source file without us caring about adapt.
- def loadSource(file : AbstractFile) : Option[CompilationUnit] = {
+ def loadSource(file: AbstractFile): Option[CompilationUnit] = {
val run = new IdeRun
reloadSource(file)
val source = getSourceFile(file)
try {
normalCompile(run.compileSources(source :: Nil))
- run.units.find(unit => unit.source == source)
+ run.units.find(_.source == source)
} catch {
case e =>
logError("error in presentation normal compile ", e)
None
}
}
+
object loaders1 extends {
- val global : IdeSupport.this.type = IdeSupport.this
+ val global: IdeSupport.this.type = IdeSupport.this
} with scala.tools.nsc.symtab.SymbolLoaders {
import global._
- protected override def completeClassfile(root : global.Symbol, loader : ClassfileLoader)(f : => Unit) : Unit =
+ protected override def completeClassfile(root: global.Symbol, loader: ClassfileLoader)(f: => Unit) {
global.normalCompile(f)
- override def computeDepends(from : PackageLoader) : global.PackageScopeDependMap = IdeSupport.this.computeDepends(from.asInstanceOf[IdeSupport.this.loaders.PackageLoader])
+ }
+ override def computeDepends(from: PackageLoader): global.PackageScopeDependMap =
+ IdeSupport.this.computeDepends(from.asInstanceOf[IdeSupport.this.loaders.PackageLoader])
}
- def computeDepends(from : loaders.PackageLoader) : PackageScopeDependMap = null
+
+ def computeDepends(from: loaders.PackageLoader): PackageScopeDependMap = null
override lazy val loaders = loaders1
}
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index a41198a97a..df14417565 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -94,7 +94,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
/** Be quiet. Do not print out the results of each
* submitted command unless an exception is thrown. */
- def beQuiet = { printResults = false }
+ def beQuiet { printResults = false }
/** Temporarily be quiet */
def beQuietDuring[T](operation: => T): T = {
@@ -111,7 +111,9 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
lazy val isettings = new InterpreterSettings
object reporter extends ConsoleReporter(settings, null, out) {
- override def printMessage(msg: String) { out.print(clean(msg) + "\n"); out.flush() }
+ override def printMessage(msg: String) {
+ out.print(clean(msg) + "\n"); out.flush()
+ }
}
/** Instantiate a compiler. Subclasses can override this to
@@ -934,4 +936,4 @@ object Interpreter {
}
res.toString
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
index 1b5306eb0e..f2abe0ca21 100644
--- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala
+++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
@@ -1,21 +1,14 @@
-/* __ *\
-** ________ ___ / / ___ Scala Compiler **
-** / __/ __// _ | / / / _ | (c) 2008-2009 , LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-/**
- *
+/* NSC -- new Scala compiler
+ * Copyright 2007-2009 LAMP/EPFL
* @author Anders Bach Nielsen
* @version 1.0
- * $Id$
*/
+// $Id$
package scala.tools.nsc
-import scala.collection.mutable.{HashSet,HashMap}
-import java.io.{BufferedWriter,FileWriter}
+import scala.collection.mutable.{HashSet, HashMap}
+import java.io.{BufferedWriter, FileWriter}
/**
* PhaseAssembly
@@ -40,7 +33,7 @@ trait PhaseAssembly { self: Global =>
* Simple node with name and object ref for the phase object,
* also sets of in and out going dependencies
*/
- class Node(name:String) {
+ class Node(name: String) {
val phasename = name
var phaseobj: Option[List[SubComponent]] = None
val after = new HashSet[Edge]()
@@ -50,7 +43,7 @@ trait PhaseAssembly { self: Global =>
def allPhaseNames(): String = phaseobj match {
case None => phasename
- case Some(lst) => lst.map(sc => sc.phaseName).reduceLeft( (x,y) => x + "," + y)
+ case Some(lst) => lst.map(_.phaseName).reduceLeft(_+","+_)
}
}
@@ -60,8 +53,8 @@ trait PhaseAssembly { self: Global =>
/* Given a phase object, get the node for this phase object. If the
* node object does not exist, then create it.
*/
- def getNodeByPhase(phs : SubComponent) : Node = {
- var node : Node = getNodeByPhase(phs.phaseName)
+ def getNodeByPhase(phs: SubComponent): Node = {
+ var node: Node = getNodeByPhase(phs.phaseName)
node.phaseobj match {
case None =>
node.phaseobj = Some(List[SubComponent](phs))
@@ -73,7 +66,7 @@ trait PhaseAssembly { self: Global =>
/* Given the name of a phase object, get the node for that name. If the
* node object does not exits, then create it.
*/
- def getNodeByPhase(name : String) : Node = {
+ def getNodeByPhase(name: String): Node = {
nodes.get(name).getOrElse {
val node = new Node(name)
nodes += (name -> node)
@@ -108,46 +101,48 @@ trait PhaseAssembly { self: Global =>
/* Given the entire graph, collect the phase objects at each level, where the phase
* names are sorted alphabetical at each level, into the compiler phase list
*/
- def compilerPhaseList() : List[SubComponent] = {
- var chain : List[SubComponent] = Nil
+ def compilerPhaseList(): List[SubComponent] = {
+ var chain: List[SubComponent] = Nil
var lvl = 1
- var nds = nodes.values.filter(n => (n.level == lvl)).toList
+ var nds = nodes.values.filter(_.level == lvl).toList
while(nds.size > 0) {
nds = nds.sort((n1,n2) => (n1.phasename compareTo n2.phasename) < 0)
- for( n <- nds ) {
+ for (n <- nds) {
chain = chain ::: n.phaseobj.get
}
- lvl = lvl + 1
- nds = nodes.values.filter(n => (n.level == lvl)).toList
+ lvl += 1
+ nds = nodes.values.filter(_.level == lvl).toList
}
- return chain
+ chain
}
/* Test if there are cycles in the graph, assign levels to the nodes
* and collapse hard links into nodes
*/
- def collapseHardLinksAndLevels(node : Node, lvl: Int) : Unit = {
+ def collapseHardLinksAndLevels(node: Node, lvl: Int) {
if (node.visited) {
- throw new FatalError("Cycle in compiler phase dependencies detected, phase " + node.phasename + " reacted twice!")
+ throw new FatalError(
+ "Cycle in compiler phase dependencies detected, phase " +
+ node.phasename + " reacted twice!")
}
if (node.level < lvl) node.level = lvl
- var hls = Nil ++ node.before.filter( e => e.hard )
- while( hls.size > 0 ) {
- for( hl <- hls ) {
+ var hls = Nil ++ node.before.filter(_.hard)
+ while (hls.size > 0) {
+ for (hl <- hls) {
node.phaseobj = Some(node.phaseobj.get ++ hl.frm.phaseobj.get)
node.before = hl.frm.before
nodes -= hl.frm.phasename
edges -= hl
- for( edge <- node.before ) edge.to = node
+ for (edge <- node.before) edge.to = node
}
- hls = Nil ++ node.before.filter( e => e.hard )
+ hls = Nil ++ node.before.filter(_.hard)
}
node.visited = true
- for( edge <- node.before ) {
+ for (edge <- node.before) {
collapseHardLinksAndLevels( edge.frm, lvl + 1)
}
@@ -158,20 +153,20 @@ trait PhaseAssembly { self: Global =>
* need to check that its the only dependency. If not, then we will promote the
* other dependencies down
*/
- def validateAndEnforceHardlinks() : Unit = {
- var hardlinks = edges.filter(e => e.hard)
- for(hl <- hardlinks) {
+ def validateAndEnforceHardlinks() {
+ var hardlinks = edges.filter(_.hard)
+ for (hl <- hardlinks) {
if (hl.frm.after.size > 1) {
throw new FatalError("phase " + hl.frm.phasename + " want to run right after " + hl.to.phasename + ", but some phase has declared to run before " + hl.frm.phasename + ". Re-run with -Xgenerate-phase-graph <filename> to better see the problem.")
}
}
var rerun = true
- while(rerun) {
+ while (rerun) {
rerun = false
- hardlinks = edges.filter(e => e.hard)
- for(hl <- hardlinks) {
- var sanity = Nil ++ hl.to.before.filter(e => e.hard)
+ hardlinks = edges.filter(_.hard)
+ for (hl <- hardlinks) {
+ var sanity = Nil ++ hl.to.before.filter(_.hard)
if (sanity.length == 0) {
throw new FatalError("There is no runs right after dependency, where there should be one! This is not supposed to happen!")
} else if (sanity.length > 1) {
@@ -191,7 +186,9 @@ trait PhaseAssembly { self: Global =>
sanity foreach (edge => hl.to.before += edge)
for (edge <- promote) {
rerun = true
- informProgress("promote the dependency of " + edge.frm.phasename + ": " + edge.to.phasename + " => " + hl.frm.phasename)
+ informProgress(
+ "promote the dependency of " + edge.frm.phasename +
+ ": " + edge.to.phasename + " => " + hl.frm.phasename)
edge.to = hl.frm
hl.frm.before += edge
}
@@ -200,20 +197,22 @@ trait PhaseAssembly { self: Global =>
}
}
- /* Remove all nodes in the given graph, that have no phase object
- * Make sure to clean up all edges when removing the node object
- * Inform with warnings, if an external phase has a dependency on something that is dropped.
+ /** Remove all nodes in the given graph, that have no phase object
+ * Make sure to clean up all edges when removing the node object
+ * <code>Inform</code> with warnings, if an external phase has a
+ * dependency on something that is dropped.
*/
- def removeDanglingNodes() : Unit = {
- var dnodes = nodes.values.filter(n => n.phaseobj.isEmpty )
- for(node <- dnodes) {
- informProgress("dropping dependency on node with no phase object: " + node.phasename)
+ def removeDanglingNodes() {
+ var dnodes = nodes.values.filter(_.phaseobj.isEmpty)
+ for (node <- dnodes) {
+ val msg = "dropping dependency on node with no phase object: "+node.phasename
+ informProgress(msg)
nodes -= node.phasename
- for(edge <- node.before) {
+ for (edge <- node.before) {
edges -= edge
edge.frm.after -= edge
edge.frm.phaseobj match {
- case Some(lsc) => if (! lsc.head.internal) warning("dropping dependency on node with no phase object: " + node.phasename)
+ case Some(lsc) => if (! lsc.head.internal) warning(msg)
case _ =>
}
}
@@ -222,71 +221,73 @@ trait PhaseAssembly { self: Global =>
}
-
/* Method called from computePhaseDescriptors in class Global
*/
- def buildCompilerFromPhasesSet() : List[SubComponent] = {
+ def buildCompilerFromPhasesSet(): List[SubComponent] = {
// Add all phases in the set to the graph
val graph = phasesSetToDepGraph(phasesSet)
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "1.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "1.dot")
// Remove nodes without phaseobj
graph.removeDanglingNodes()
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "2.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "2.dot")
// Validate and Enforce hardlinks / runsRightAfter and promote nodes down the tree
graph.validateAndEnforceHardlinks()
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "3.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "3.dot")
// test for cycles, assign levels and collapse hard links into nodes
graph.collapseHardLinksAndLevels(graph.getNodeByPhase("parser"), 1)
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "4.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "4.dot")
// assemble the compiler
- return graph.compilerPhaseList()
+ graph.compilerPhaseList()
}
-
- /* Given the phases set, will build a dependency graph from the phases set
- * Using the aux. method of the DependencyGraph to create nodes and egdes
+ /** Given the phases set, will build a dependency graph from the phases set
+ * Using the aux. method of the DependencyGraph to create nodes and egdes.
*/
- private def phasesSetToDepGraph(phsSet : HashSet[SubComponent]) : DependencyGraph = {
+ private def phasesSetToDepGraph(phsSet: HashSet[SubComponent]): DependencyGraph = {
val graph = new DependencyGraph()
- for(phs <- phsSet) {
+ for (phs <- phsSet) {
var fromnode = graph.getNodeByPhase(phs)
phs.runsRightAfter match {
case None =>
- for(phsname <- phs.runsAfter) {
- if (! (phsname == "terminal")) {
- var tonode = graph.getNodeByPhase(phsname)
+ for (phsname <- phs.runsAfter) {
+ if (phsname != "terminal") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(fromnode, tonode)
} else {
error("[phase assembly, after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
}
}
- for(phsname <- phs.runsBefore) {
- if (! (phsname == "parser")) {
- var tonode = graph.getNodeByPhase(phsname)
+ for (phsname <- phs.runsBefore) {
+ if (phsname != "parser") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(tonode, fromnode)
} else {
error("[phase assembly, before dependency on parser phase not allowed: " + phsname + " => "+ fromnode.phasename + "]")
}
}
case Some(phsname) =>
- if (! (phsname == "terminal")) {
- var tonode = graph.getNodeByPhase(phsname)
+ if (phsname != "terminal") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.hardConnectNodes(fromnode, tonode)
} else {
error("[phase assembly, right after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
@@ -300,12 +301,12 @@ trait PhaseAssembly { self: Global =>
* file showing its structure.
* Plug-in supplied phases are marked as green nodes and hard links are marked as blue edges.
*/
- private def graphToDotFile(graph : DependencyGraph, filename : String) : Unit = {
- var sbuf = new StringBuffer()
+ private def graphToDotFile(graph: DependencyGraph, filename: String) {
+ var sbuf = new StringBuilder
var extnodes = new HashSet[graph.Node]()
var fatnodes = new HashSet[graph.Node]()
sbuf.append("digraph G {\n")
- for(edge <- graph.edges) {
+ for (edge <- graph.edges) {
sbuf.append("\"" + edge.frm.allPhaseNames + "(" + edge.frm.level + ")" + "\"->\"" + edge.to.allPhaseNames + "(" + edge.to.level + ")" + "\"")
if (! edge.frm.phaseobj.get.first.internal) {
extnodes += edge.frm
@@ -318,10 +319,10 @@ trait PhaseAssembly { self: Global =>
sbuf.append(" [color=\"#000000\"]\n")
}
}
- for(node <- extnodes) {
+ for (node <- extnodes) {
sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#00ff00\"]\n")
}
- for(node <- fatnodes) {
+ for (node <- fatnodes) {
sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#0000ff\"]\n")
}
sbuf.append("}\n")
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 35627c1c13..ed8a5d1a35 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -58,19 +58,28 @@ trait Parsers extends NewScanners with MarkupParsers {
import global.posAssigner.atPos
case class OpInfo(operand: Tree, operator: Name, pos: Int)
+
/** ...
*
* @author Sean McDirmid
*/
class UnitParser(val unit: global.CompilationUnit) extends Parser {
val in = new UnitScanner(unit)
- def freshName(pos : Position, prefix : String) = unit.fresh.newName(pos, prefix)
- implicit def i2p(offset : Int) : Position = new OffsetPosition(unit.source,offset)
- def warning(pos : Int, msg : String) : Unit = unit.warning(pos, msg)
- def incompleteInputError(msg: String) : Unit =
+
+ def freshName(pos: Position, prefix: String): Name =
+ unit.fresh.newName(pos, prefix)
+
+ implicit def i2p(offset: Int): Position = new OffsetPosition(unit.source,offset)
+
+ def warning(pos: Int, msg: String) { unit.warning(pos, msg) }
+
+ def incompleteInputError(msg: String) {
unit.incompleteInputError(unit.source.asInstanceOf[BatchSourceFile].content.length - 1, msg)
- def deprecationWarning(pos : Int, msg : String) : Unit = unit.deprecationWarning(pos, msg)
- def syntaxError(pos: Int, msg: String) : Unit = unit.error(pos, msg)
+ }
+ def deprecationWarning(pos: Int, msg: String) {
+ unit.deprecationWarning(pos, msg)
+ }
+ def syntaxError(pos: Int, msg: String) { unit.error(pos, msg) }
/** the markup parser */
def xmlp = {
@@ -108,11 +117,11 @@ trait Parsers extends NewScanners with MarkupParsers {
val in: ParserScanner
//val unit : CompilationUnit
//import in.ScanPosition
- protected def freshName(pos : Position, prefix: String): Name
+ protected def freshName(pos: Position, prefix: String): Name
protected def posToReport: Int = in.currentPos
- protected implicit def i2p(offset : Int) : Position
- //private implicit def p2i(pos : Position) = pos.offset.get
+ protected implicit def i2p(offset: Int): Position
+ //private implicit def p2i(pos: Position) = pos.offset.get
private def inToken = in.token
private def inSkipToken = in.skipToken
@@ -121,10 +130,10 @@ trait Parsers extends NewScanners with MarkupParsers {
private def inNextTokenCode : Int = in.nextTokenCode
private def inName = in.name
private def charVal = in.charVal
- private def intVal(isNegated : Boolean) = in.intVal(isNegated).asInstanceOf[Int]
- private def longVal(isNegated : Boolean) = in.intVal(isNegated)
- private def floatVal(isNegated : Boolean) = in.floatVal(isNegated).asInstanceOf[Float]
- private def doubleVal(isNegated : Boolean) = in.floatVal(isNegated)
+ private def intVal(isNegated: Boolean) = in.intVal(isNegated).asInstanceOf[Int]
+ private def longVal(isNegated: Boolean) = in.intVal(isNegated)
+ private def floatVal(isNegated: Boolean) = in.floatVal(isNegated).asInstanceOf[Float]
+ private def doubleVal(isNegated: Boolean) = in.floatVal(isNegated)
private def stringVal = in.stringVal
/** whether a non-continuable syntax error has been seen */
@@ -133,11 +142,11 @@ trait Parsers extends NewScanners with MarkupParsers {
object treeBuilder extends TreeBuilder {
val global: Parsers.this.global.type = Parsers.this.global
- def freshName(pos : Position, prefix: String): Name = Parser.this.freshName(pos, prefix)
+ def freshName(pos : Position, prefix: String): Name =
+ Parser.this.freshName(pos, prefix)
}
import treeBuilder._
-
/** The implicit view parameters of the surrounding class */
var implicitClassViews: List[Tree] = Nil
@@ -149,7 +158,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/* -------- PLACEHOLDERS ------------------------------------------- */
+/* --------------- PLACEHOLDERS ------------------------------------------- */
/** The implicit parameters introduced by `_' in the current expression.
* Parameters appear in reverse order
@@ -199,7 +208,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/* -------- ERROR HANDLING ------------------------------------------- */
+/* ------------- ERROR HANDLING ------------------------------------------- */
protected def skip() {
var nparens = 0
@@ -228,14 +237,16 @@ trait Parsers extends NewScanners with MarkupParsers {
inNextToken
}
}
- def warning(pos : Int, msg : String) : Unit
- def incompleteInputError(msg: String) : Unit
- def deprecationWarning(pos : Int, msg : String) : Unit
- private def syntaxError(pos : Position, msg : String, skipIt : Boolean) : Unit = pos.offset match {
- case None => syntaxError(msg,skipIt)
- case Some(offset) => syntaxError(offset, msg, skipIt)
+ def warning(pos: Int, msg: String): Unit
+ def incompleteInputError(msg: String): Unit
+ def deprecationWarning(pos: Int, msg: String): Unit
+ private def syntaxError(pos: Position, msg: String, skipIt: Boolean) {
+ pos.offset match {
+ case None => syntaxError(msg,skipIt)
+ case Some(offset) => syntaxError(offset, msg, skipIt)
+ }
}
- def syntaxError(pos: Int, msg: String) : Unit
+ def syntaxError(pos: Int, msg: String): Unit
def syntaxError(msg: String, skipIt: Boolean) {
syntaxError(inCurrentPos, msg, skipIt)
}
@@ -249,8 +260,8 @@ trait Parsers extends NewScanners with MarkupParsers {
if (skipIt)
skip()
}
- def warning(msg: String) : Unit = warning(inCurrentPos, msg)
+ def warning(msg: String) { warning(inCurrentPos, msg) }
def syntaxErrorOrIncomplete(msg: String, skipIt: Boolean) {
val inToken = this.inToken
@@ -298,7 +309,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == token) inNextToken
pos
}
- def surround[T](open : Int, close : Int)(f : => T, orElse : T) : T = {
+ def surround[T](open: Int, close: Int)(f: => T, orElse: T): T = {
val wasOpened = inToken == open
accept(open)
if (wasOpened) {
@@ -308,27 +319,26 @@ trait Parsers extends NewScanners with MarkupParsers {
} else orElse
}
-
/** semi = nl {nl} | `;'
* nl = `\n' // where allowed
*/
- def acceptStatSep() : Boolean = {
+ def acceptStatSep(): Boolean =
if (inToken == NEWLINE || inToken == NEWLINES) { inNextToken; true }
else {
val ret = inToken == SEMI
accept(SEMI)
ret
}
- }
def errorTypeTree = TypeTree().setType(ErrorType).setPos((inCurrentPos))
def errorTermTree = Literal(Constant(null)).setPos((inCurrentPos))
def errorPatternTree = Ident(nme.WILDCARD).setPos((inCurrentPos))
-/* -------- TOKEN CLASSES ------------------------------------------- */
+/* -------------- TOKEN CLASSES ------------------------------------------- */
def isModifier: Boolean = inToken match {
- case ABSTRACT | FINAL | SEALED | PRIVATE | PROTECTED | OVERRIDE | IMPLICIT | LAZY => true
+ case ABSTRACT | FINAL | SEALED | PRIVATE |
+ PROTECTED | OVERRIDE | IMPLICIT | LAZY => true
case _ => false
}
@@ -361,7 +371,8 @@ trait Parsers extends NewScanners with MarkupParsers {
def isExprIntro: Boolean = isExprIntroToken(inToken)
def isTypeIntroToken(token: Int): Boolean = token match {
- case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER | USCORE | LPAREN | AT => true
+ case IDENTIFIER | BACKQUOTED_IDENT | THIS |
+ SUPER | USCORE | LPAREN | AT => true
case _ => false
}
@@ -373,7 +384,7 @@ trait Parsers extends NewScanners with MarkupParsers {
def isStatSep: Boolean = isStatSep(inToken)
-/* -------- COMMENT AND ATTRIBUTE COLLECTION ------------------------------------------- */
+/* --------- COMMENT AND ATTRIBUTE COLLECTION ----------------------------- */
/** Join the comment associated with a definition
*/
@@ -383,7 +394,7 @@ trait Parsers extends NewScanners with MarkupParsers {
else trees
}
-/* -------- TREE CONSTRUCTION ------------------------------------------- */
+/* ---------- TREE CONSTRUCTION ------------------------------------------- */
/** Convert tree to formal parameter list
*/
@@ -447,7 +458,7 @@ trait Parsers extends NewScanners with MarkupParsers {
Function(List(makeSyntheticParam(pname)), insertParam(tree))
}
-/* -------- OPERAND/OPERATOR STACK ------------------------------------------- */
+/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
var opstack: List[OpInfo] = Nil
@@ -483,7 +494,8 @@ trait Parsers extends NewScanners with MarkupParsers {
syntaxError(
pos, "left- and right-associative operators with same precedence may not be mixed", false)
- def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree, prec: Int, leftAssoc: Boolean): Tree = {
+ def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree,
+ prec: Int, leftAssoc: Boolean): Tree = {
var top = top0
if (opstack != base && precedence(opstack.head.operator) == prec)
checkAssoc(opstack.head.pos, opstack.head.operator, leftAssoc)
@@ -500,7 +512,6 @@ trait Parsers extends NewScanners with MarkupParsers {
/* -------- IDENTIFIERS AND LITERALS ------------------------------------------- */
-
def ident(): Name =
if (inToken == IDENTIFIER || inToken == BACKQUOTED_IDENT) {
val name = inName.encode
@@ -511,10 +522,9 @@ trait Parsers extends NewScanners with MarkupParsers {
nme.ERROR
}
- def selector(t: Tree) =
+ def selector(t: Tree): Tree =
atPos(inCurrentPos)(Select(t, ident()))
-
/** Path ::= StableId
* | [Ident `.'] this
* AnnotType ::= Path [`.' type]
@@ -576,15 +586,15 @@ trait Parsers extends NewScanners with MarkupParsers {
/** MixinQualifier ::= `[' Id `]'
*/
- def mixinQualifierOpt(pos : Position): (Name,Position) =
+ def mixinQualifierOpt(pos: Position): (Name, Position) =
if (inToken == LBRACKET) {
inNextToken
val pos = inCurrentPos
val name = ident().toTypeName
accept(RBRACKET)
- (name,pos)
+ (name, pos)
} else {
- (nme.EMPTY.toTypeName,pos)
+ (nme.EMPTY.toTypeName, pos)
}
/** StableId ::= Id
@@ -611,15 +621,15 @@ trait Parsers extends NewScanners with MarkupParsers {
def litToTree() = atPos(inCurrentPos) {
Literal(
inToken match {
- case CHARLIT => Constant(charVal)
- case INTLIT => Constant(intVal(isNegated))
- case LONGLIT => Constant(longVal(isNegated))
- case FLOATLIT =>Constant(floatVal(isNegated))
+ case CHARLIT => Constant(charVal)
+ case INTLIT => Constant(intVal(isNegated))
+ case LONGLIT => Constant(longVal(isNegated))
+ case FLOATLIT => Constant(floatVal(isNegated))
case DOUBLELIT => Constant(doubleVal(isNegated))
case STRINGLIT | SYMBOLLIT => Constant(stringVal)
- case TRUE => Constant(true)
- case FALSE => Constant(false)
- case NULL => Constant(null)
+ case TRUE => Constant(true)
+ case FALSE => Constant(false)
+ case NULL => Constant(null)
case _ =>
syntaxErrorOrIncomplete("illegal literal", true)
null
@@ -658,7 +668,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == NEWLINE && p(inNextTokenCode)) newLineOpt()
}
-/* -------- TYPES ------------------------------------------- */
+/* ------------- TYPES ---------------------------------------------------- */
/** TypedOpt ::= [`:' Type]
*/
@@ -722,7 +732,9 @@ trait Parsers extends NewScanners with MarkupParsers {
} else {
val ts = types(isPattern, false, true)
accept(RPAREN)
- if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(ts, typ(isPattern)) }
+ if (inToken == ARROW) atPos(inSkipToken) {
+ makeFunctionTypeTree(ts, typ(isPattern))
+ }
else {
for (t <- ts) t match {
case AppliedTypeTree(Select(_, n), _)
@@ -745,7 +757,8 @@ trait Parsers extends NewScanners with MarkupParsers {
val whereClauses = refinement()
for (wc <- whereClauses) {
wc match {
- case TypeDef(_, _, _, TypeBoundsTree(_, _)) | ValDef(_, _, _, EmptyTree) | EmptyTree =>
+ case TypeDef(_, _, _, TypeBoundsTree(_, _)) |
+ ValDef(_, _, _, EmptyTree) | EmptyTree =>
;
case _ =>
syntaxError(wc.pos, "not a legal existential clause", false)
@@ -762,7 +775,7 @@ trait Parsers extends NewScanners with MarkupParsers {
infixTypeRest(inCurrentPos, infixTypeFirst(isPattern), isPattern, mode)
}
- def infixTypeFirst(isPattern: Boolean) =
+ def infixTypeFirst(isPattern: Boolean): Tree =
if (inToken == LBRACE) scalaAnyRefConstr else annotType(isPattern)
def infixTypeRest(pos: Int, t0: Tree, isPattern: Boolean, mode: InfixMode.Value): Tree = {
@@ -909,7 +922,7 @@ trait Parsers extends NewScanners with MarkupParsers {
typ()
}
-/* -------- EXPRESSIONS ------------------------------------------- */
+/* ----------- EXPRESSIONS ------------------------------------------------ */
/** EqualsExpr ::= `=' Expr
*/
@@ -1232,10 +1245,13 @@ trait Parsers extends NewScanners with MarkupParsers {
// again, position should be on idetifier, not (
var pos = if (t.pos == NoPosition) i2p(inCurrentPos) else t.pos
simpleExprRest(atPos(pos) {
- // look for anonymous function application like (f _)(x) and translate to (f _).apply(x), bug #460
+ // look for anonymous function application like (f _)(x) and
+ // translate to (f _).apply(x), bug #460
val sel = t match {
- case Parens(List(Typed(_, _: Function))) => Select(stripParens(t), nme.apply)
- case _ => stripParens(t)
+ case Parens(List(Typed(_, _: Function))) =>
+ Select(stripParens(t), nme.apply)
+ case _ =>
+ stripParens(t)
}
Apply(sel, argumentExprs())
}, true)
@@ -1446,7 +1462,7 @@ trait Parsers extends NewScanners with MarkupParsers {
stripParens(reduceStack(false, base, top, 0, true))
}
- def xmlLiteralPattern() : Tree
+ def xmlLiteralPattern(): Tree
/** SimplePattern ::= varid
* | `_'
@@ -1491,14 +1507,16 @@ trait Parsers extends NewScanners with MarkupParsers {
} else t
case USCORE =>
atPos(inSkipToken) { Ident(nme.WILDCARD) }
- case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL =>
+ case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT |
+ STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL =>
literal(true, false)
case LPAREN =>
val pos = inSkipToken
val ps = if (inToken == RPAREN) List() else patterns(false)
accept(RPAREN)
Parens(ps) setPos (pos)
- case XMLSTART => xmlLiteralPattern()
+ case XMLSTART =>
+ xmlLiteralPattern()
case _ =>
syntaxErrorOrIncomplete("illegal start of simple pattern", true)
errorPatternTree
@@ -1529,7 +1547,7 @@ trait Parsers extends NewScanners with MarkupParsers {
/** AccessQualifier ::= "[" (Id | this) "]"
*/
- def accessQualifierOpt(mods: Modifiers) = {
+ def accessQualifierOpt(mods: Modifiers): Modifiers = {
var result = mods
if (inToken == LBRACKET) {
inNextToken
@@ -1930,7 +1948,7 @@ trait Parsers extends NewScanners with MarkupParsers {
* | type [nl] TypeDcl
*/
def defOrDcl(mods: Modifiers): List[Tree] = {
- if ((mods.hasFlag(Flags.LAZY)) && in.token != VAL)
+ if ((mods hasFlag Flags.LAZY) && in.token != VAL)
syntaxError("lazy not allowed here. Only vals can be lazy", false)
inToken match {
case VAL =>
@@ -2098,7 +2116,8 @@ trait Parsers extends NewScanners with MarkupParsers {
* | ConstrBlock
*/
def constrExpr(vparamss: List[List[ValDef]]): Tree =
- if (inToken == LBRACE) constrBlock(vparamss) else Block(List(selfInvocation(vparamss)), Literal(()))
+ if (inToken == LBRACE) constrBlock(vparamss)
+ else Block(List(selfInvocation(vparamss)), Literal(()))
/** SelfInvocation ::= this ArgumentExprs {ArgumentExprs}
*/
@@ -2110,8 +2129,8 @@ trait Parsers extends NewScanners with MarkupParsers {
t = Apply(t, argumentExprs())
newLineOptWhenFollowedBy(LBRACE)
}
- if (!implicitClassViews.isEmpty) t = Apply(t, vparamss.last.map(vd => Ident(vd.name)))
- t
+ if (implicitClassViews.isEmpty) t
+ else Apply(t, vparamss.last.map(vp => Ident(vp.name)))
}
/** ConstrBlock ::= `{' SelfInvocation {semi BlockStat} `}'
@@ -2136,9 +2155,9 @@ trait Parsers extends NewScanners with MarkupParsers {
// @M! a type alias as well as an abstract type may declare type parameters
val tparams = inToken match {
case LBRACKET =>
- typeParamClauseOpt(name, null)
+ typeParamClauseOpt(name, null)
case _ =>
- Nil
+ Nil
}
inToken match {
@@ -2206,8 +2225,16 @@ trait Parsers extends NewScanners with MarkupParsers {
if (mods.hasFlag(Flags.TRAIT)) (Modifiers(Flags.TRAIT), List())
else (accessModifierOpt(), paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE)))
val thistpe = requiresTypeOpt()
- var mods1 = if (mods.hasFlag( Flags.TRAIT )) if (inToken == SUBTYPE) mods | Flags.DEFERRED else mods
- else if (inToken == SUBTYPE) { syntaxError("classes are not allowed to be virtual", false); mods } else mods
+ var mods1 =
+ if (mods hasFlag Flags.TRAIT)
+ if (inToken == SUBTYPE) mods | Flags.DEFERRED
+ else mods
+ else if (inToken == SUBTYPE) {
+ syntaxError("classes are not allowed to be virtual", false)
+ mods
+ }
+ else
+ mods
var template = templateOpt(mods1, name, constrMods withAnnotations constrAnnots, vparamss)
if (!thistpe.isEmpty) {
if (template.self.isEmpty) {
@@ -2288,14 +2315,15 @@ trait Parsers extends NewScanners with MarkupParsers {
}
}
- def isInterface(mods: Modifiers, body: List[Tree]) =
- (mods.hasFlag(Flags.TRAIT) && (body forall treeInfo.isInterfaceMember))
+ def isInterface(mods: Modifiers, body: List[Tree]): Boolean =
+ (mods hasFlag Flags.TRAIT) && (body forall treeInfo.isInterfaceMember)
/** ClassTemplateOpt ::= 'extends' ClassTemplate | [['extends'] TemplateBody]
* TraitTemplateOpt ::= TraitExtends TraitTemplate | [['extends'] TemplateBody] | '<:' TemplateBody
* TraitExtends ::= 'extends' | `<:'
*/
- def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]]): Template = {
+ def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers,
+ vparamss: List[List[ValDef]]): Template = {
val pos = inCurrentPos;
val (parents0, argss, self, body) =
if (inToken == EXTENDS || settings.Xexperimental.value && (mods hasFlag Flags.TRAIT) && inToken == SUBTYPE) {
@@ -2328,7 +2356,7 @@ trait Parsers extends NewScanners with MarkupParsers {
/** TemplateBody ::= [nl] `{' TemplateStatSeq `}'
* @param isPre specifies whether in early initializer (true) or not (false)
*/
- def templateBody(isPre : Boolean) = {
+ def templateBody(isPre: Boolean) = {
accept(LBRACE)
val result @ (self, stats) = templateStatSeq(isPre)
accept(RBRACE)
@@ -2568,7 +2596,9 @@ trait Parsers extends NewScanners with MarkupParsers {
ts ++= topStatSeq()
}
val stats = ts.toList
- val usePos = if (stats.isEmpty || stats.head.pos == NoPosition) i2p(pos) else stats.head.pos
+ val usePos =
+ if (stats.isEmpty || stats.head.pos == NoPosition) i2p(pos)
+ else stats.head.pos
atPos(usePos) { stats match {
case List(stat @ PackageDef(_, _)) => stat
case _ => makePackaging(Ident(nme.EMPTY_PACKAGE_NAME), stats)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 4f24681a88..a2e114afca 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -71,7 +71,7 @@ trait Scanners {
def floatVal(negated: Boolean): Double
def intVal: Long = intVal(false)
def floatVal: Double = floatVal(false)
- //def token2string(token : Int) : String = configuration.token2string(token)
+ //def token2string(token: Int): String = configuration.token2string(token)
/** return recent scala doc, if any */
def flushDoc: String
}
@@ -152,14 +152,11 @@ trait Scanners {
enterKeyword(nme.ATkw, AT)
// Build keyword array
- key = new Array[Byte](maxKey + 1)
- for (i <- 0 to maxKey)
- key(i) = IDENTIFIER
- for (j <- 0 until tokenCount)
- if (tokenName(j) ne null)
- key(tokenName(j).start) = j.asInstanceOf[Byte]
-
+ key = Array.make(maxKey + 1, IDENTIFIER)
+ for (j <- 0 until tokenCount if tokenName(j) ne null)
+ key(tokenName(j).start) = j.toByte
}
+
//Token representation -----------------------------------------------------
/** Convert name to token */
@@ -1028,9 +1025,12 @@ trait Scanners {
/** ...
*/
class UnitScanner(unit: CompilationUnit) extends Scanner {
- val in = new CharArrayReader(unit.source.asInstanceOf[BatchSourceFile].content, !settings.nouescape.value, syntaxError)
+ val in = new CharArrayReader(
+ unit.source.asInstanceOf[BatchSourceFile].content,
+ !settings.nouescape.value, syntaxError
+ )
def warning(pos: Int, msg: String) = unit.warning(pos, msg)
- def error (pos: Int, msg: String) = unit. error(pos, msg)
+ def error (pos: Int, msg: String) = unit.error(pos, msg)
def incompleteInputError(pos: Int, msg: String) = unit.incompleteInputError(pos, msg)
def deprecationWarning(pos: Int, msg: String) = unit.deprecationWarning(pos, msg)
implicit def p2g(pos: Position): Int = pos.offset.getOrElse(-1)
diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
index 40e1ce596f..bb1d049677 100644
--- a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
@@ -1,8 +1,10 @@
/* NSC -- new Scala compiler
* Copyright 2005-2009 LAMP/EPFL
*/
-// $Id$
+// $Id: $
+
package scala.tools.nsc.interpreter
+
import scala.tools.nsc.io.AbstractFile
/**
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
index 8375328017..0e66a8b06a 100644
--- a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
@@ -4,8 +4,8 @@
*/
// $Id$
-
package scala.tools.nsc.interpreter
+
import java.io.File
import jline.{ History, ConsoleReader, ArgumentCompletor }
diff --git a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
index 38dfdbfb92..1bd5f217c1 100644
--- a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
@@ -5,8 +5,8 @@
// $Id$
package scala.tools.nsc.interpreter
-import java.io.{BufferedReader, PrintWriter}
+import java.io.{BufferedReader, PrintWriter}
/** Reads using standard JDK API */
class SimpleReader(
@@ -16,7 +16,7 @@ class SimpleReader(
extends InteractiveReader {
def this() = this(Console.in, new PrintWriter(Console.out), true)
- def readOneLine(prompt: String) = {
+ def readOneLine(prompt: String): String = {
if (interactive) {
out.print(prompt)
out.flush()
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 4ebc83daa2..bce4876c41 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -81,7 +81,7 @@ object Plugin {
val jar = new JarFile(jarfile)
try {
val ent = jar.getEntry("scalac-plugin.xml")
- if(ent == null) return None
+ if (ent == null) return None
val inBytes = jar.getInputStream(ent)
val packXML = XML.load(inBytes)
@@ -92,7 +92,7 @@ object Plugin {
jar.close()
}
} catch {
- case _:ZipException => None
+ case _: ZipException => None
}
}
@@ -132,7 +132,7 @@ object Plugin {
dir <- dirs if dir.isDirectory
entries = dir.listFiles
if entries ne null
- entry <- entries.toList.sort((f1, f2) => f1.getName <= f2.getName)
+ entry <- entries.toList.sort(_.getName <= _.getName)
if entry.toString.toLowerCase endsWith ".jar"
pdesc <- loadDescription(entry)
if !(ignoring contains pdesc.name)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index cd457dfec1..812bfd7ce8 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -20,7 +20,8 @@ trait Plugins { self: Global =>
/** Load a rough list of the plugins. For speed, it
* does not instantiate a compiler run. Therefore it cannot
* test for same-named phases or other problems that are
- * filtered from the final list of plugins. */
+ * filtered from the final list of plugins.
+ */
protected def loadRoughPluginsList(): List[Plugin] = {
val jars = settings.plugin.value.map(new File(_))
val dirs =
@@ -41,7 +42,6 @@ trait Plugins { self: Global =>
roughPluginsListCache.get
}
-
/** Load all available plugins. Skips plugins that
* either have the same name as another one, or which
* define a phase name that another one does.
@@ -117,7 +117,6 @@ trait Plugins { self: Global =>
plugs
}
-
private var pluginsCache: Option[List[Plugin]] = None
def plugins: List[Plugin] = {
@@ -126,7 +125,6 @@ trait Plugins { self: Global =>
pluginsCache.get
}
-
/** A description of all the plugins that are loaded */
def pluginDescriptions: String = {
val messages =
@@ -140,10 +138,7 @@ trait Plugins { self: Global =>
* @see phasesSet
*/
protected def computePluginPhases() {
-
- var plugPhases = plugins.flatMap(_.components)
-
- // Add all phases supplied by plugins to the phasesSet
+ val plugPhases = plugins.flatMap(_.components)
for (pPhase <- plugPhases) {
phasesSet += pPhase
}
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index 4c62a8435d..d6f94e8626 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -16,7 +16,7 @@ import scala.tools.nsc.util.Position
abstract class AbstractReporter extends Reporter {
private val positions = new HashMap[Position, Severity]
- override def reset = {
+ override def reset {
super.reset
positions.clear
}
@@ -28,7 +28,7 @@ abstract class AbstractReporter extends Reporter {
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean) {
severity match {
- case INFO =>
+ case INFO =>
if (force || settings.verbose.value) display(pos, msg, severity)
case WARNING =>
val hidden = testAndLog(pos, severity)
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 3dbdfc85f1..c12e32a026 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -22,7 +22,7 @@ abstract class Reporter {
val WARNING = new Severity(1)
val ERROR = new Severity(2)
- def reset: Unit = {
+ def reset {
INFO.count = 0
ERROR.count = 0
WARNING.count = 0
@@ -41,9 +41,9 @@ abstract class Reporter {
def setSource(source: SourceFile) { this.source = source }
def getSource: SourceFile = source
- def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO, force)
- def warning(pos: Position, msg: String ): Unit = info0(pos, msg, WARNING, false)
- def error(pos: Position, msg: String ): Unit = info0(pos, msg, ERROR, false)
+ def info(pos: Position, msg: String, force: Boolean) { info0(pos, msg, INFO, force) }
+ def warning(pos: Position, msg: String ) { info0(pos, msg, WARNING, false) }
+ def error(pos: Position, msg: String ) { info0(pos, msg, ERROR, false) }
/** An error that could possibly be fixed if the unit were longer.
* This is used only when the interpreter tries
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
index 08f7493b75..3563c69646 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
@@ -38,22 +38,21 @@ class AbstractFileReader(val file: AbstractFile) {
@throws(classOf[IndexOutOfBoundsException])
def nextByte: Byte = {
val b = buf(bp)
- bp = bp + 1
+ bp += 1
b
}
/** read some bytes
*/
def nextBytes(len: Int): Array[Byte] = {
- bp = bp + len
+ bp += len
buf.subArray(bp - len, bp)
}
/** read a character
*/
- def nextChar: Char = {
+ def nextChar: Char =
(((nextByte & 0xff) << 8) + (nextByte & 0xff)).toChar
- }
/** read an integer
*/
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index b40547d9d9..24ba34c572 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -66,11 +66,9 @@ abstract class ICodeReader extends ClassfileParser {
/** If we're parsing a scala module, the owner of members is always
* the module symbol.
*/
- override def getOwner(jflags: Int): Symbol = {
- if (isScalaModule) {
- this.staticModule
- } else super.getOwner(jflags)
- }
+ override def getOwner(jflags: Int): Symbol =
+ if (isScalaModule) this.staticModule
+ else super.getOwner(jflags)
override def parseClass() {
this.instanceCode = new IClass(clazz)
@@ -634,6 +632,7 @@ abstract class ICodeReader extends ClassfileParser {
def isBox(m: Symbol): Boolean =
(m.owner == definitions.BoxesRunTimeClass.moduleClass
&& m.name.startsWith("boxTo"))
+
def isUnbox(m: Symbol): Boolean =
(m.owner == definitions.BoxesRunTimeClass.moduleClass
&& m.name.startsWith("unboxTo"))
@@ -643,7 +642,8 @@ abstract class ICodeReader extends ClassfileParser {
*/
def getCode(flags: Int): IClass =
if (isScalaModule) staticCode
- else if ((flags & JAVA_ACC_STATIC) != 0) staticCode else instanceCode
+ else if ((flags & JAVA_ACC_STATIC) != 0) staticCode
+ else instanceCode
class LinearCode {
var instrs: ListBuffer[(Int, Instruction)] = new ListBuffer
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index cf2b194489..52fbc7b83c 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -621,7 +621,8 @@ abstract class CleanUp extends Transform {
case MethodType(paramTypes, resType) =>
assert(params.length == paramTypes.length)
atPos(ad.pos)(localTyper.typed {
- val sym = currentOwner.newValue(ad.pos, newTermName(unit.fresh.newName("qual"))) setInfo qual0.tpe
+ val t1 = newTermName(unit.fresh.newName(ad.pos, "qual"))
+ val sym = currentOwner.newValue(ad.pos, t1) setInfo qual0.tpe
qual = gen.mkAttributedRef(sym)
Block(
List(ValDef(sym, qual0)),
diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
index e0070e5827..a25d73a08a 100644
--- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
+++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
@@ -9,36 +9,46 @@ package scala.tools.nsc.util
import scala.collection.mutable.HashMap
trait FreshNameCreator {
- /** do not call before after type checking ends. Use newName(Position,String) instead. */
- @deprecated def newName(prefix : String) : String
- /** do not call before after type checking ends. Use newName(Position) instead. */
- @deprecated def newName() : String
- def newName(pos : util.Position, prefix : String) : String
- def newName(pos : util.Position) : String
+
+ /** do not call before after type checking ends.
+ * Use <code>newName(Position, String)</code> instead.
+ */
+ @deprecated def newName(prefix: String): String
+
+ /** do not call before after type checking ends.
+ * Use newName(Position) instead.
+ */
+ @deprecated def newName(): String
+
+ def newName(pos: util.Position, prefix: String): String
+ def newName(pos: util.Position): String
}
+
object FreshNameCreator {
+
class Default extends FreshNameCreator {
- protected var counter = 0
- protected val counters = new HashMap[String, Int]
+ protected var counter = 0
+ protected val counters = new HashMap[String, Int]
- /**
- * Create a fresh name with the given prefix. It is guaranteed
- * that the returned name has never been returned by a previous
- * call to this function (provided the prefix does not end in a digit).
- */
- def newName(prefix: String): String = {
- val safePrefix = prefix.replace('<', '$').replace('>', '$')
- val count = counters.getOrElse(safePrefix, 0) + 1
- counters(safePrefix) = count
- safePrefix + count
- }
- def newName(pos : util.Position, prefix : String) = newName(prefix)
- def newName(pos : util.Position) = newName()
+ /**
+ * Create a fresh name with the given prefix. It is guaranteed
+ * that the returned name has never been returned by a previous
+ * call to this function (provided the prefix does not end in a digit).
+ */
+ def newName(prefix: String): String = {
+ val safePrefix = prefix.replace('<', '$').replace('>', '$')
+ val count = counters.getOrElse(safePrefix, 0) + 1
+ counters(safePrefix) = count
+ safePrefix + count
+ }
+ def newName(pos: util.Position, prefix: String) = newName(prefix)
+ def newName(pos: util.Position) = newName()
- def newName(): String = {
- counter = counter + 1
- "$" + counter + "$"
+ def newName(): String = {
+ counter += 1
+ "$" + counter + "$"
+ }
}
-}
+
}