From 4e7cd6768a5aa4bcb36c8aee6c77e6e9e7f69555 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Tue, 17 Apr 2012 00:28:28 +0100 Subject: [PATCH] Don't use wrappers to bind indices. --- src/ofc/generators/Onetep.scala | 2 +- src/ofc/generators/onetep/CodeGenerator.scala | 15 ++++++++++++++- src/ofc/generators/onetep/TreeBuilder.scala | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ofc/generators/Onetep.scala b/src/ofc/generators/Onetep.scala index 61b5ba3..e7f10f3 100644 --- a/src/ofc/generators/Onetep.scala +++ b/src/ofc/generators/Onetep.scala @@ -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) } diff --git a/src/ofc/generators/onetep/CodeGenerator.scala b/src/ofc/generators/onetep/CodeGenerator.scala index 17c15a3..0bfb886 100644 --- a/src/ofc/generators/onetep/CodeGenerator.scala +++ b/src/ofc/generators/onetep/CodeGenerator.scala @@ -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 diff --git a/src/ofc/generators/onetep/TreeBuilder.scala b/src/ofc/generators/onetep/TreeBuilder.scala index bc863f3..4d4723b 100644 --- a/src/ofc/generators/onetep/TreeBuilder.scala +++ b/src/ofc/generators/onetep/TreeBuilder.scala @@ -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 = { -- 2.47.3