]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Don't use wrappers to bind indices.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 16 Apr 2012 23:28:28 +0000 (00:28 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 16 Apr 2012 23:28:28 +0000 (00:28 +0100)
src/ofc/generators/Onetep.scala
src/ofc/generators/onetep/CodeGenerator.scala
src/ofc/generators/onetep/TreeBuilder.scala

index 61b5ba36016e3cee6998b92aea7b1912b97e3a61..e7f10f3f9f1d8f153f22b27222184e865784866b 100644 (file)
@@ -86,7 +86,7 @@ class Onetep extends Generator {
   def buildDefinition(definition : parser.Definition) {
     val builder = new TreeBuilder(dictionary)
     val assignment = builder(definition.term, definition.expr)
-    val codeGenerator = new CodeGenerator()
+    val codeGenerator = new CodeGenerator(builder.getIndexBindings)
     codeGenerator(assignment)
   }
 
index 17c15a305d1e8550d658d7552a8e5597bbb914fe..0bfb8861dae31b247a946ed0aafef44eac740d9d 100644 (file)
@@ -28,7 +28,7 @@ class NameManager {
 }
 */
 
-class CodeGenerator {
+class CodeGenerator(indexBindings: IndexBindings) {
   def apply(assignment: Assignment) {
     //val declarations = collectDeclarations(assignment)
     //for(declaration <- declarations) code append declaration+"\n"
@@ -61,6 +61,19 @@ class CodeGenerator {
 
     for(operand <- space.getOperands) {
       val opStatement = buildStatement(operand)
+
+      for(discreteIndex <- operand.getDiscreteIndices; if indexBindings.contains(discreteIndex)) {
+        //TODO: store the symbol!
+        val symbol = new NamedUnboundVarSymbol[IntType](discreteIndex.getName)
+        val newData = opStatement.addPredicate(symbol |==| discreteIndex.getValue)
+      }
+
+      for(spatialIndex <- operand.getSpatialIndices; if indexBindings.contains(spatialIndex)) {
+        //TODO: store the symbol!
+        val symbol = new NamedUnboundVarSymbol[IntType](spatialIndex.getName)
+        opStatement.addPredicate(symbol |==| spatialIndex.getValue)
+      }
+
       result.merge(opStatement)
     }
     result
index bc863f3e618ae8b993fbb61fc33fedef0d7b9db5..4d4723bd02c2d87f91bec43a025c18dec1ff7109 100644 (file)
@@ -63,10 +63,13 @@ class TreeBuilder(dictionary : Dictionary) {
     for(i <- indices zip dataSpace.getDiscreteIndices)
       indexBindings.add(i._1, i._2)
 
+    /*
     dataSpace match {
       case (dataSpace: DataSpace) => new DataSpaceIndexBinding(dataSpace)
       case iterationSpace => new IterationSpaceIndexBinding(iterationSpace)
     }
+    */
+    dataSpace
   }
 
   private def buildIndex(term: parser.Expression) : BindingIndex = {