diff options
author | David MacIver <david.maciver@gmail.com> | 2008-10-28 01:24:04 +0000 |
---|---|---|
committer | David MacIver <david.maciver@gmail.com> | 2008-10-28 01:24:04 +0000 |
commit | 1db99a43092b73d9a00544ee6f6ba95dd710e6d4 (patch) | |
tree | 4803d5e8492f1fd7856e5f93263151b749eafc56 /src | |
parent | d5763d58d993be554b5f19ab9b13992f903e3ad3 (diff) | |
download | scala-1db99a43092b73d9a00544ee6f6ba95dd710e6d4.tar.gz scala-1db99a43092b73d9a00544ee6f6ba95dd710e6d4.tar.bz2 scala-1db99a43092b73d9a00544ee6f6ba95dd710e6d4.zip |
Tidying up the control flow in applyRule.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 1461cd7098..c094422533 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -1104,32 +1104,29 @@ trait ParallelMatching { case Nil => ErrorRule() case Row(pats, subst, g, bx)::xs => - var px = 0; var rpats = pats; var bnd = subst; var temps = temp; while((bnd ne null) && (rpats ne Nil)) { + var bnd = subst; + var px = 0; var rpats = pats; var bnd = subst; var temps = temp; while(rpats ne Nil){ val (vs,p) = strip(rpats.head); - if (!isDefaultPattern(p)) { /*break*/ bnd = null; } else { + if (!isDefaultPattern(p)) { + // Row( _ ... _ p_1i ... p_1n g_m b_m ) :: rows + // cut out column px that contains the non-default pattern + val column = rpats.head :: (row.tail map { case Row(pats,_,_,_) => pats(px) }) + val restTemp = temp.take(px) ::: temp.drop(px+1) + val restRows = row map { r => r.replace(r.pat.take(px) ::: r.pat.drop(px+1)) } + val mr = MixtureRule(temps.head, column, rep.make(restTemp, restRows)) + DBG("\n---\nmixture rule is = " + mr.getClass.toString) + return mr + } else { bnd = bnd.add(vs,temps.head) rpats = rpats.tail temps = temps.tail px += 1 // pattern index } } - /* Row( _ ... _ g_1 b_1 ) :: rows it's all default patterns - */ - if (bnd ne null) { // all default patterns - val rest = if (g eq EmptyTree) null else rep.make(temp, xs) - DBG("\n---\nmixture rule is = VariableRule") - return VariableRule (bnd, g, rest, bx) - } - - /* Row( _ ... _ p_1i ... p_1n g_m b_m ) :: rows - */ - // cut out column px that contains the non-default pattern - val column = rpats.head :: (row.tail map { case Row(pats,_,_,_) => pats(px) }) - val restTemp = temp.take(px) ::: temp.drop(px+1) - val restRows = row map { r => r.replace(r.pat.take(px) ::: r.pat.drop(px+1)) } - val mr = MixtureRule(temps.head, column, rep.make(restTemp, restRows)) - DBG("\n---\nmixture rule is = " + mr.getClass.toString) - mr + //Row( _ ... _ g_1 b_1 ) :: rows it's all default patterns + val rest = if (g eq EmptyTree) null else rep.make(temp, xs) + DBG("\n---\nmixture rule is = VariableRule") + VariableRule (bnd, g, rest, bx) } // a fancy toString method for debugging @@ -1146,8 +1143,8 @@ trait ParallelMatching { sb.append('\n') } sb.toString - } /* def toString */ - } /* class Rep */ + } + } /** creates initial clause matrix */ |