From: Francis Russell Date: Mon, 9 Apr 2012 17:06:49 +0000 (+0100) Subject: Add index binding operators to expression tree. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3ad9946edefb78fc3a0b63b1173ce17a3fe52bfb;p=francis%2Fofc.git Add index binding operators to expression tree. --- diff --git a/src/ofc/generators/onetep/DataSpaceIndexBinding.scala b/src/ofc/generators/onetep/DataSpaceIndexBinding.scala new file mode 100644 index 0000000..ce74c84 --- /dev/null +++ b/src/ofc/generators/onetep/DataSpaceIndexBinding.scala @@ -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 index 0000000..c4a5857 --- /dev/null +++ b/src/ofc/generators/onetep/IterationSpaceIndexBinding.scala @@ -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 +} diff --git a/src/ofc/generators/onetep/TreeBuilder.scala b/src/ofc/generators/onetep/TreeBuilder.scala index f5d4983..8e4a270 100644 --- a/src/ofc/generators/onetep/TreeBuilder.scala +++ b/src/ofc/generators/onetep/TreeBuilder.scala @@ -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 = {