From: Francis Russell Date: Thu, 2 Feb 2012 19:44:18 +0000 (+0000) Subject: More work on fixing loop hierarchy. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=bdf1ae4d277e1b1184c48fd40c59d1bd860f98c2;p=francis%2Fofc.git More work on fixing loop hierarchy. --- diff --git a/src/ofc/generators/onetep/LoopTree.scala b/src/ofc/generators/onetep/LoopTree.scala index 3d34043..c711a5a 100644 --- a/src/ofc/generators/onetep/LoopTree.scala +++ b/src/ofc/generators/onetep/LoopTree.scala @@ -16,7 +16,6 @@ object LoopTree { val indices = space.getIndices val localSortedIndices = sortedIndices filter (indices.contains(_)) base.addIterationSpace(localSortedIndices, space) - println(localSortedIndices.toString + " -> "+space) } println(base) @@ -48,13 +47,17 @@ case class LoopTree private(localIndex: Option[Index]) { private def getEndLoop(index: Index) : LoopTree = { def newTree = { val tree = new LoopTree(Some(index)); subItems += Right(tree); tree} - if (subItems.isEmpty) - newTree - else - subItems.last match { - case Right(tree) => if (tree.getLocalIndex == Some(index)) tree else newTree - case _ => newTree - } + var destination : Option[LoopTree]= None + for(item <- subItems) + item match { + case Right(tree) => if (tree.getLocalIndex == Some(index)) destination = Some(tree) + case _ => + } + + destination match { + case Some(tree) => tree + case None => newTree + } } private def getLocalIndex = localIndex