summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-01-21 16:01:35 +0000
committermichelou <michelou@epfl.ch>2008-01-21 16:01:35 +0000
commite5237247c91d05fd981e5f5a50fa543ad58890ed (patch)
treee4b0b9e946698fe877ff6b4380a5618360cffc52
parent94a67b3673d466a80362035db6211e5d73e40b79 (diff)
downloadscala-e5237247c91d05fd981e5f5a50fa543ad58890ed.tar.gz
scala-e5237247c91d05fd981e5f5a50fa543ad58890ed.tar.bz2
scala-e5237247c91d05fd981e5f5a50fa543ad58890ed.zip
removed some warnings
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala37
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala42
-rw-r--r--src/compiler/scala/tools/nsc/io/PlainFile.scala8
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala6
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala4
5 files changed, 47 insertions, 50 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
index 79e1764a31..cb4411cc1f 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
@@ -1,15 +1,14 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
-// $Id: $
+// $Id$
package scala.tools.nsc.backend.icode.analysis
-import compat.StringBuilder
-import scala.collection.jcl.{HashMap, Map}
import scala.collection.immutable.{Set, ListSet, HashSet}
+import scala.collection.jcl.{HashMap, Map}
/** Compute reaching definitions. We are only interested in reaching
* definitions for local variables, since values on the stack
@@ -42,11 +41,11 @@ abstract class ReachingDefinitions {
if (bottom == a) b
else if (bottom == b) a
else {
- val locals = a.vars incl b.vars
+ val locals = a.vars ++ b.vars
val stack = if (a.stack == Nil)
b.stack
else if (b.stack == Nil) a.stack
- else List.map2(a.stack, b.stack) (_ incl _)
+ else List.map2(a.stack, b.stack) (_ ++ _)
val res = IState(locals, stack)
@@ -73,18 +72,18 @@ abstract class ReachingDefinitions {
val drops: Map[BasicBlock, Int] = new HashMap()
val outStack: Map[BasicBlock, Stack] = new HashMap()
- def init(m: IMethod): Unit = {
+ def init(m: IMethod) {
this.method = m
gen.clear; kill.clear
drops.clear; outStack.clear
- for (val b <- m.code.blocks.toList;
- val (g, k) = genAndKill(b);
- val (d, st) = dropsAndGen(b)) {
- gen += b -> g
- kill += b -> k
- drops += b -> d
- outStack += b -> st
+ for (b <- m.code.blocks.toList;
+ (g, k) = genAndKill(b);
+ (d, st) = dropsAndGen(b)) {
+ gen += Pair(b, g)
+ kill += Pair(b, k)
+ drops += Pair(b, d)
+ outStack += Pair(b, st)
}
init {
@@ -142,7 +141,7 @@ abstract class ReachingDefinitions {
(drops, stackOut)
}
- override def run: Unit = {
+ override def run {
forwardAnalysis(blockTransfer)
if (settings.debug.value) {
linearizer.linearize(method).foreach(b => if (b != method.code.startBlock)
@@ -163,7 +162,7 @@ abstract class ReachingDefinitions {
}
private def blockTransfer(b: BasicBlock, in: lattice.Elem): lattice.Elem = {
- var locals: Set[Definition] = (in.vars filter { case (l, _, _) => !kill(b)(l) }) incl gen(b)
+ var locals: Set[Definition] = (in.vars filter { case (l, _, _) => !kill(b)(l) }) ++ gen(b)
if (locals eq lattice.bottom.vars) locals = new ListSet[Definition]
IState(locals, outStack(b) ::: in.stack.drop(drops(b)))
}
@@ -186,7 +185,7 @@ abstract class ReachingDefinitions {
var prod = instr.produced
while (prod > 0) {
stack = (new collection.immutable.Set1((b, idx))) :: stack
- prod = prod - 1
+ prod -= 1
}
IState(locals, stack)
@@ -239,9 +238,9 @@ abstract class ReachingDefinitions {
findDefs(bb, idx, m, 0)
override def toString: String = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append("rdef: \n")
- for (val b <- method.code.blocks)
+ for (b <- method.code.blocks)
sb.append("rdef_entry(" + b + ")= " + in(b)).append("\nrdef_exit(" + b + ")= " + out(b))
sb.toString()
}
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index a2cae2146e..ef16a1caae 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Iulian Dragos
*/
@@ -32,8 +32,9 @@ abstract class Inliners extends SubComponent {
def name = phaseName
val inliner = new Inliner
- override def apply(c: IClass): Unit =
+ override def apply(c: IClass) {
inliner.analyzeClass(c)
+ }
}
/**
@@ -65,7 +66,7 @@ abstract class Inliners extends SubComponent {
def inline(caller: IMethod,
block: BasicBlock,
instr: Instruction,
- callee: IMethod): Unit = {
+ callee: IMethod) {
log("Inlining " + callee + " in " + caller + " at pos: " +
(try {
instr.pos.offset.get
@@ -207,17 +208,17 @@ abstract class Inliners extends SubComponent {
if (retVal ne null)
addLocal(caller, retVal);
callee.code.blocks.foreach { b =>
- inlinedBlock += b -> newBlock;
+ inlinedBlock += Pair(b, newBlock)
inlinedBlock(b).varsInScope ++= (b.varsInScope map inlinedLocals)
}
// analyse callee
- a.run;
+ a.run
// re-emit the instructions before the call
- block.open;
- block.clear;
- instrBefore.foreach(i => block.emit(i, i.pos));
+ block.open
+ block.clear
+ instrBefore.foreach(i => block.emit(i, i.pos))
// store the arguments into special locals
callee.params.reverse.foreach { param =>
@@ -227,7 +228,7 @@ abstract class Inliners extends SubComponent {
// jump to the start block of the callee
block.emit(JUMP(inlinedBlock(callee.code.startBlock)), targetPos);
- block.close;
+ block.close
// duplicate the other blocks in the callee
linearizer.linearize(callee).foreach { bb =>
@@ -251,12 +252,12 @@ abstract class Inliners extends SubComponent {
inlinedBlock(bb).emit(map(i), targetPos);
info = a.interpret(info, i);
}
- inlinedBlock(bb).close;
+ inlinedBlock(bb).close
}
instrAfter.foreach(i => afterBlock.emit(i, i.pos));
afterBlock.close;
- count = count + 1;
+ count += 1
// add exception handlers of the callee
caller.exh = (callee.exh map translateExh) ::: caller.exh;
@@ -274,8 +275,8 @@ abstract class Inliners extends SubComponent {
tfa.stat = settings.statistics.value
def analyzeMethod(m: IMethod): Unit = try {
- var retry = false;
- var count = 0;
+ var retry = false
+ var count = 0
fresh.clear
// how many times have we already inlined this method here?
val inlinedMethods: Map[Symbol, Int] = new HashMap[Symbol, Int] {
@@ -385,12 +386,13 @@ abstract class Inliners extends SubComponent {
* - synthetic private members are made public in this pass.
*/
def isSafeToInline(caller: IMethod, callee: IMethod, stack: TypeStack): Boolean = {
- var callsPrivateMember = false;
+ var callsPrivateMember = false
- if (callee.recursive) return false;
+ if (callee.recursive) return false
callsPrivate get (callee) match {
- case Some(b) => callsPrivateMember = b;
+ case Some(b) =>
+ callsPrivateMember = b
case None =>
for (b <- callee.code.blocks)
for (i <- b.toList)
@@ -420,7 +422,7 @@ abstract class Inliners extends SubComponent {
case _ => ()
}
- callsPrivate += callee -> callsPrivateMember;
+ callsPrivate += Pair(callee, callsPrivateMember)
}
if (callsPrivateMember && (caller.symbol.owner != callee.symbol.owner))
@@ -471,7 +473,7 @@ abstract class Inliners extends SubComponent {
if (callee.code.blocks.length <= SMALL_METHOD_SIZE) score = score + 1
if (caller.code.blocks.length <= SMALL_METHOD_SIZE
&& ((caller.code.blocks.length + callee.code.blocks.length) > SMALL_METHOD_SIZE)) {
- score = score - 1
+ score -= 1
if (settings.debug.value)
log("shouldInline: score decreased to " + score + " because small " + caller + " would become large")
}
@@ -481,10 +483,10 @@ abstract class Inliners extends SubComponent {
if (callee.symbol.tpe.paramTypes.exists(t => definitions.FunctionClass.contains(t.typeSymbol))) {
if (settings.debug.value)
log("increased score to: " + score)
- score = score + 2
+ score += 2
}
if (isClosureClass(callee.symbol.owner))
- score = score + 2
+ score += 2
score > 0
}
diff --git a/src/compiler/scala/tools/nsc/io/PlainFile.scala b/src/compiler/scala/tools/nsc/io/PlainFile.scala
index a8eba28f05..a489dd1694 100644
--- a/src/compiler/scala/tools/nsc/io/PlainFile.scala
+++ b/src/compiler/scala/tools/nsc/io/PlainFile.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -28,9 +28,6 @@ class PlainFile(val file: File) extends AbstractFile {
assert(file ne null)
assert(file.exists(), "non-existent file: " + file)
- //########################################################################
- // Public Methods
-
/** Returns the name of this abstract file. */
def name = file.getName()
@@ -60,7 +57,7 @@ class PlainFile(val file: File) extends AbstractFile {
assert(isDirectory, "not a directory '" + this + "'")
val names: Array[String] = file.list()
if ((names eq null) || names.length == 0) Iterator.empty
- else Iterator.fromArray(names).map { name: String => new File(file, name) }
+ else names.elements.map { name: String => new File(file, name) }
.filter(_.exists).map(file => new PlainFile(file))
}
@@ -82,5 +79,4 @@ class PlainFile(val file: File) extends AbstractFile {
else new PlainFile(child)
}
- //########################################################################
}
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 6960280986..acb78f9df3 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2002-2007 LAMP/EPFL
+ * Copyright 2002-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -40,7 +40,7 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
countElementsAsString((severity).count, label(severity))
/** Prints the message. */
- def printMessage(msg: String) = writer.println(msg)
+ def printMessage(msg: String) { writer.println(msg) }
/** Prints the message with the given position indication. */
def printMessage(posIn: Position, msg: String) {
@@ -49,7 +49,7 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
val buf = new StringBuilder(msg)
if (!pos.source.isEmpty) {
buf.insert(0, " ")
- buf.insert(0, pos.line.map(ln => ":" + pos.line.get + ":").get(":"))
+ buf.insert(0, pos.line.map(ln => ":" + pos.line.get + ":").getOrElse(":"))
}
//println(getSource.file)
pos match {
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index fca5c05586..0a4ce8713f 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -844,7 +844,7 @@ trait Definitions {
def addScalaCallerInfo(scalaCaller: Symbol, methSym: Symbol) = {
assert(Delegate_scalaCallers contains scalaCaller)
- Delegate_scalaCallerTargets += scalaCaller -> methSym
+ Delegate_scalaCallerTargets += Pair(scalaCaller, methSym)
}
}
}