summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala27
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala22
2 files changed, 25 insertions, 24 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
index 6569ec29af..4ab2883126 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
@@ -10,10 +10,11 @@ package scala.tools.nsc.backend.icode.analysis
import scala.collection.mutable.{Map, HashMap}
import scala.tools.nsc.symtab.Flags.DEFERRED
-/**
- * A modified copy-propagation like analysis. It
+/** A modified copy-propagation like analysis. It
* is augmented with a record-like value which is used
* to represent closures.
+ *
+ * @author Iulian Dragos
*/
abstract class CopyPropagation {
val global: Global
@@ -33,8 +34,8 @@ abstract class CopyPropagation {
case class Record(cls: Symbol, bindings: Map[Symbol, Value]) extends Value {
override def isRecord = true
}
- case class Deref(l: Location) extends Value;
- case class Boxed(l: Location) extends Value;
+ case class Deref(l: Location) extends Value
+ case class Boxed(l: Location) extends Value
case object Unknown extends Value
object AllRecords extends Record(NoSymbol, new HashMap[Symbol, Value])
@@ -159,7 +160,7 @@ abstract class CopyPropagation {
*/
val commonPairs = a.bindings.toList intersect (b.bindings.toList)
val resBindings = new HashMap[Location, Value]
- for (val Pair(k, v) <- commonPairs)
+ for ((k, v) <- commonPairs)
resBindings += k -> v;
new State(resBindings, resStack)
}
@@ -172,7 +173,7 @@ abstract class CopyPropagation {
var method: IMethod = _
- def init(m: IMethod): Unit = {
+ def init(m: IMethod) {
this.method = m
init {
@@ -193,7 +194,7 @@ abstract class CopyPropagation {
}
}
- override def run: Unit = {
+ override def run {
forwardAnalysis(blockTransfer)
if (settings.debug.value) {
linearizer.linearize(method).foreach(b => if (b != method.code.startBlock)
@@ -293,8 +294,8 @@ abstract class CopyPropagation {
if (method.isPrimaryConstructor/* && isClosureClass(method.owner)*/) {
obj match {
case Record(_, bindings) =>
- for (val v <- out.stack.take(method.info.paramTypes.length + 1);
- v ne obj) {
+ for (v <- out.stack.take(method.info.paramTypes.length + 1)
+ if v ne obj) {
bindings ++= getBindingsForPrimaryCtor(in, method);
}
case _ => ()
@@ -397,7 +398,7 @@ abstract class CopyPropagation {
* and bindings. It is called when a new assignment destroys
* previous copy-relations.
*/
- final def cleanReferencesTo(s: copyLattice.State, target: Location): Unit = {
+ final def cleanReferencesTo(s: copyLattice.State, target: Location) {
def cleanRecord(r: Record): Record = {
r.bindings retain { (loc, value) =>
value match {
@@ -455,7 +456,7 @@ abstract class CopyPropagation {
*
* @param state ...
*/
- final def invalidateRecords(state: copyLattice.State): Unit = {
+ final def invalidateRecords(state: copyLattice.State) {
state.stack = state.stack map { v => v match {
case Record(cls, bindings) =>
Record(cls, new HashMap[Symbol, Value])
@@ -482,7 +483,7 @@ abstract class CopyPropagation {
// this relies on having the same order in paramAccessors and
// the arguments on the stack. It should be the same!
- for (val (p, i) <- paramAccessors.zipWithIndex) {
+ for ((p, i) <- paramAccessors.zipWithIndex) {
// assert(p.tpe == ctor.tpe.paramTypes(i), "In: " + ctor.fullNameString + " having: " + (paramAccessors map (_.tpe))+ " vs. " + ctor.tpe.paramTypes)
if (p.tpe == ctor.tpe.paramTypes(i))
bindings += p -> values.head;
@@ -514,7 +515,7 @@ abstract class CopyPropagation {
final override def toString(): String = {
var res = ""
- for (val b <- this.method.code.blocks.toList)
+ for (b <- this.method.code.blocks.toList)
res = (res + "\nIN(" + b.label + "):\t Bindings: " + in(b).bindings +
"\nIN(" + b.label +"):\t Stack: " + in(b).stack) + "\n";
res
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index 01167c2986..4a69746c71 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -9,7 +9,7 @@ package scala.tools.nsc.backend.icode.analysis
import scala.collection.mutable.{Map, HashMap}
-/** A data-flow analysis on types, that works on ICode.
+/** A data-flow analysis on types, that works on <code>ICode</code>.
*
* @author Iulian Dragos
*/
@@ -61,8 +61,8 @@ abstract class TypeFlowAnalysis {
/** A map which returns the bottom type for unfound elements */
class VarBinding extends HashMap[icodes.Local, icodes.TypeKind] {
override def get(l: icodes.Local) = super.get(l) match {
- case Some(t) => Some(t);
- case None => Some(typeLattice.bottom);
+ case Some(t) => Some(t)
+ case None => Some(typeLattice.bottom)
}
def this(o: VarBinding) = {
@@ -76,7 +76,7 @@ abstract class TypeFlowAnalysis {
*/
object typeFlowLattice extends CompleteLattice {
import icodes._
- type Elem = Pair[VarBinding, icodes.TypeStack]
+ type Elem = (VarBinding, icodes.TypeStack)
override val top = new Pair(new VarBinding, typeStackLattice.top) {
override def equals(that: Any) = (this eq that.asInstanceOf[AnyRef])
@@ -86,22 +86,22 @@ abstract class TypeFlowAnalysis {
}
def lub2(a: Elem, b: Elem) = {
- val Pair(env1, s1) = a
- val Pair(env2, s2) = b
+ val (env1, s1) = a
+ val (env2, s2) = b
val resultingLocals = new VarBinding
- for (val binding1 <- env1.elements) {
+ for (binding1 <- env1.elements) {
val tp2 = env2(binding1._1)
resultingLocals += binding1._1 -> typeLattice.lub2(binding1._2, tp2)
}
- for (val binding2 <- env2.elements; resultingLocals(binding2._1) eq typeLattice.bottom) {
+ for (binding2 <- env2.elements if resultingLocals(binding2._1) eq typeLattice.bottom) {
val tp1 = env1(binding2._1)
resultingLocals += binding2._1 -> typeLattice.lub2(binding2._2, tp1)
}
- Pair(resultingLocals, typeStackLattice.lub2(a._2, b._2))
+ (resultingLocals, typeStackLattice.lub2(a._2, b._2))
}
}
@@ -116,7 +116,7 @@ abstract class TypeFlowAnalysis {
var method: IMethod = _
/** Initialize the in/out maps for the analysis of the given method. */
- def init(m: icodes.IMethod): Unit = {
+ def init(m: icodes.IMethod) {
this.method = m
init {
@@ -132,7 +132,7 @@ abstract class TypeFlowAnalysis {
}
}
- def this(m: icodes.IMethod) = {
+ def this(m: icodes.IMethod) {
this()
init(m)
}