]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Add index binding operators to expression tree.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 9 Apr 2012 17:06:49 +0000 (18:06 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 9 Apr 2012 17:19:29 +0000 (18:19 +0100)
src/ofc/generators/onetep/DataSpaceIndexBinding.scala [new file with mode: 0644]
src/ofc/generators/onetep/IterationSpaceIndexBinding.scala [new file with mode: 0644]
src/ofc/generators/onetep/TreeBuilder.scala

diff --git a/src/ofc/generators/onetep/DataSpaceIndexBinding.scala b/src/ofc/generators/onetep/DataSpaceIndexBinding.scala
new file mode 100644 (file)
index 0000000..ce74c84
--- /dev/null
@@ -0,0 +1,9 @@
+package ofc.generators.onetep
+import ofc.codegen.NullStatement
+
+class DataSpaceIndexBinding(operand: DataSpace) extends DataSpace {
+  def getSpatialIndices = operand.getSpatialIndices
+  def getDiscreteIndices = Nil
+  def getDataValue = operand.getDataValue
+  def getSuffixFragment = operand.getSuffixFragment
+}
diff --git a/src/ofc/generators/onetep/IterationSpaceIndexBinding.scala b/src/ofc/generators/onetep/IterationSpaceIndexBinding.scala
new file mode 100644 (file)
index 0000000..c4a5857
--- /dev/null
@@ -0,0 +1,11 @@
+package ofc.generators.onetep
+import ofc.codegen.NullStatement
+
+class IterationSpaceIndexBinding(operand: IterationSpace) extends IterationSpace {
+  def getOperands = operand.getOperands
+  def getSpatialIndices = operand.getSpatialIndices
+  def getDiscreteIndices = Nil
+  def getDataValue = operand.getDataValue
+  def getReaderFragment = operand.getReaderFragment
+  def getSuffixFragment = operand.getSuffixFragment
+}
index f5d49833dd7fd8a3413e745d3bc5463507ca6831..8e4a2708d803d6f7351ee4d8e7c0513581446351 100644 (file)
@@ -73,7 +73,10 @@ class TreeBuilder(dictionary : Dictionary) {
     for(i <- indices zip dataSpace.getDiscreteIndices)
       indexBindings.add(i._1, i._2)
 
-    dataSpace
+    dataSpace match {
+      case (dataSpace: DataSpace) => new DataSpaceIndexBinding(dataSpace)
+      case iterationSpace => new IterationSpaceIndexBinding(iterationSpace)
+    }
   }
 
   def buildExpression(term: parser.Expression) : IterationSpace = {