summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-03-07 16:40:25 -0800
committerJames Iry <jamesiry@gmail.com>2013-03-07 16:40:25 -0800
commit04eac5c4362d7af74302e73272a1a7406968e0ba (patch)
treef83cc4ca998ad39c687e75073aecd8fbb535c951
parentb50a0d811f0fb99ccbc295741e66bab348b3f99e (diff)
downloadscala-04eac5c4362d7af74302e73272a1a7406968e0ba.tar.gz
scala-04eac5c4362d7af74302e73272a1a7406968e0ba.tar.bz2
scala-04eac5c4362d7af74302e73272a1a7406968e0ba.zip
SI-7006 Cleanup from code review
Minor cleanup from review of https://github.com/scala/scala/pull/2185 * Changed several instances of |= to ||= for better clarity (and bonus savings!) * Documented the return of two methods that compute the reachability of follow-on blocks.
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 468e2cfd35..4f2d248672 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -990,11 +990,11 @@ abstract class GenICode extends SubComponent {
}
caseCtx = genLoad(body, tmpCtx, generatedType)
- afterCtxReachable |= !caseCtx.bb.ignore
+ afterCtxReachable ||= !caseCtx.bb.ignore
// close the block unless it's already been closed by the body, which closes the block if it ends in a jump (which is emitted to have alternatives share their body)
caseCtx.bb.closeWith(JUMP(afterCtx.bb) setPos caze.pos)
}
- afterCtxReachable |= (default == afterCtx)
+ afterCtxReachable ||= (default == afterCtx)
ctx1.bb.emitOnly(
SWITCH(tags.reverse map (x => List(x)), (default :: targets).reverse) setPos tree.pos
)
@@ -1357,6 +1357,14 @@ abstract class GenICode extends SubComponent {
thenCtx: Context,
elseCtx: Context): Boolean =
{
+ /**
+ * Generate the de-sugared comparison mechanism that will underly an '=='
+ *
+ * @param l left-hand side of the '=='
+ * @param r right-hand side of the '=='
+ * @param code the comparison operator to use
+ * @return true if either branch can continue normally to a follow on block, false otherwise
+ */
def genComparisonOp(l: Tree, r: Tree, code: Int): Boolean = {
val op: TestOp = code match {
case scalaPrimitives.LT => LT
@@ -1455,6 +1463,7 @@ abstract class GenICode extends SubComponent {
* @param ctx current context
* @param thenCtx target context if the comparison yields true
* @param elseCtx target context if the comparison yields false
+ * @return true if either branch can continue normally to a follow on block, false otherwise
*/
def genEqEqPrimitive(l: Tree, r: Tree, ctx: Context)(thenCtx: Context, elseCtx: Context): Boolean = {
def getTempLocal = ctx.method.lookupLocal(nme.EQEQ_LOCAL_VAR) getOrElse {
@@ -2047,7 +2056,7 @@ abstract class GenICode extends SubComponent {
exhStartCtx.addFinalizer(finalizer, finalizerCtx)
loadException(exhStartCtx, exh, tree.pos)
val exhEndCtx = handler(exhStartCtx)
- normalExitReachable |= !exhEndCtx.bb.ignore
+ normalExitReachable ||= !exhEndCtx.bb.ignore
exhEndCtx.bb.closeWith(JUMP(normalExitCtx.bb))
outerCtx.endHandler()
}
@@ -2062,7 +2071,7 @@ abstract class GenICode extends SubComponent {
outerCtx.bb.closeWith(JUMP(bodyCtx.bb))
- normalExitReachable |= !bodyEndCtx.bb.ignore
+ normalExitReachable ||= !bodyEndCtx.bb.ignore
normalExitCtx.bb killUnless normalExitReachable
bodyEndCtx.bb.closeWith(JUMP(normalExitCtx.bb))