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)
}
}
*/
-class CodeGenerator {
+class CodeGenerator(indexBindings: IndexBindings) {
def apply(assignment: Assignment) {
//val declarations = collectDeclarations(assignment)
//for(declaration <- declarations) code append declaration+"\n"
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
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 = {