From a992ec2d579b65b79d61c7c2997812deb58250cd Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 22 Sep 2010 20:24:08 +0000 Subject: A cleanup of the inliner. and still came out of the washing machine smiling. Already reviewed by a certain i. dragos so no review. --- .../nsc/backend/icode/analysis/SemiLattice.scala | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala') diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala index 10c03f4455..2b41f34967 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala @@ -5,7 +5,8 @@ package scala.tools.nsc -package backend.icode.analysis +package backend.icode +package analysis /** A complete lattice. */ @@ -16,17 +17,18 @@ trait SemiLattice { * equals method uses reference equality for top and bottom, * and structural equality for other values. */ - case class IState[V, S](val vars: V, val stack: S) { + final case class IState[V, S](vars: V, stack: S) { + override def hashCode = vars.hashCode + stack.hashCode override def equals(other: Any): Boolean = other match { - case that: IState[_, _] => - if ((this eq bottom) || (that eq bottom)) this eq that - else if ((this eq top) || (that eq top)) this eq that - else (stack == that.stack && vars == that.vars) - case _ => false + case x: IState[_, _] => + if ((this eq bottom) || (this eq top) || (x eq bottom) || (x eq top)) this eq x + else stack == x.stack && vars == x.vars + case _ => + false } } - /** Return the least upper bound of a and b */ + /** Return the least upper bound of a and b. */ def lub2(exceptional: Boolean)(a: Elem, b: Elem): Elem /** Return the top element. */ @@ -36,11 +38,8 @@ trait SemiLattice { def bottom: Elem /** Compute the least upper bound of a list of elements. */ - def lub(xs: List[Elem], exceptional: Boolean): Elem = try { - if (xs == Nil) bottom else xs reduceLeft lub2(exceptional) - } catch { - case e: LubException => - Console.println("Lub on blocks: " + xs) - throw e - } + def lub(xs: List[Elem], exceptional: Boolean): Elem = + if (xs.isEmpty) bottom + else try xs reduceLeft lub2(exceptional) + catch { case e: LubException => Console.println("Lub on blocks: " + xs) ; throw e } } -- cgit v1.2.3