forked from cea-hpc/NabLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove possibility to create variables using unicode caracters (greek alphabet, sum, prod and sqrt). Generated code and LaTeX view are unchanged or equivalent. Bug: cea-hpc#98 Signed-off-by: Vincent BLAIN <vincent.blain@obeosoft.com>
- Loading branch information
1 parent
09091bc
commit 646694e
Showing
50 changed files
with
383 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 72 additions & 72 deletions
144
plugins/fr.cea.nabla.ir/src/fr/cea/nabla/ir/generator/python/JobContentProvider.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,83 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 CEA | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* Contributors: see AUTHORS file | ||
*******************************************************************************/ | ||
package fr.cea.nabla.ir.generator.python | ||
|
||
import fr.cea.nabla.ir.IrUtils | ||
import fr.cea.nabla.ir.generator.Utils | ||
import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob | ||
import fr.cea.nabla.ir.ir.IrRoot | ||
import fr.cea.nabla.ir.ir.Job | ||
import fr.cea.nabla.ir.ir.Variable | ||
|
||
import static extension fr.cea.nabla.ir.JobCallerExtensions.* | ||
import static extension fr.cea.nabla.ir.generator.python.ExpressionContentProvider.* | ||
import static extension fr.cea.nabla.ir.generator.python.InstructionContentProvider.* | ||
|
||
/******************************************************************************* | ||
* Copyright (c) 2022 CEA | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* Contributors: see AUTHORS file | ||
*******************************************************************************/ | ||
package fr.cea.nabla.ir.generator.python | ||
|
||
import fr.cea.nabla.ir.IrUtils | ||
import fr.cea.nabla.ir.generator.Utils | ||
import fr.cea.nabla.ir.ir.ExecuteTimeLoopJob | ||
import fr.cea.nabla.ir.ir.IrRoot | ||
import fr.cea.nabla.ir.ir.Job | ||
import fr.cea.nabla.ir.ir.Variable | ||
|
||
import static extension fr.cea.nabla.ir.JobCallerExtensions.* | ||
import static extension fr.cea.nabla.ir.generator.python.ExpressionContentProvider.* | ||
import static extension fr.cea.nabla.ir.generator.python.InstructionContentProvider.* | ||
|
||
class JobContentProvider | ||
{ | ||
static def getContent(Job it) | ||
''' | ||
""" | ||
Job «Utils.getCodeName(it)» called @«at» in «Utils.getCodeName(caller)» method. | ||
In variables: «FOR v : inVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» | ||
Out variables: «FOR v : outVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» | ||
""" | ||
''' | ||
""" | ||
Job «Utils.getCodeName(it)» called @«at» in «Utils.getCodeName(caller)» method. | ||
In variables: «FOR v : inVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» | ||
Out variables: «FOR v : outVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR» | ||
""" | ||
def _«Utils.getCodeName(it)»(self): | ||
«innerContent» | ||
''' | ||
|
||
private static def dispatch CharSequence getInnerContent(Job it) | ||
''' | ||
''' | ||
«instruction.innerContent» | ||
''' | ||
|
||
private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) | ||
''' | ||
«val itVar = Utils.getCodeName(iterationCounter)» | ||
«val irRoot = IrUtils.getContainerOfType(it, IrRoot)» | ||
«val tn = Utils.getCodeName(irRoot.currentTimeVariable)» | ||
«val deltat = Utils.getCodeName(irRoot.timeStepVariable)» | ||
«val ppInfo = irRoot.postProcessing» | ||
self.«itVar» = 0 | ||
«IF irRoot.currentTimeVariable.needDefinition»self.«tn» = 0.0«ENDIF» | ||
«IF irRoot.timeStepVariable.needDefinition»self.«deltat» = 0.0«ENDIF» | ||
continueLoop = True | ||
while continueLoop: | ||
self.«itVar» += 1 | ||
«IF caller.main» | ||
print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - deltat: %5.5f\n" % (self.«itVar», self.«tn», self.«deltat»)) | ||
«IF ppInfo !== null» | ||
if (self.«Utils.getCodeName(ppInfo.periodReference)» >= self.«Utils.getCodeName(ppInfo.lastDumpVariable)» + self.«Utils.getCodeName(ppInfo.periodValue)»): | ||
self.__dumpVariables(self.«itVar») | ||
«ENDIF» | ||
«ELSE» | ||
print("Start iteration «iterationCounter.name»: %5d\n" % (self.«itVar»)) | ||
«ENDIF» | ||
|
||
«FOR j : calls» | ||
«PythonGeneratorUtils.getCallName(j)»() # @«j.at» | ||
«ENDFOR» | ||
|
||
# Evaluate loop condition with variables at time n | ||
continueLoop = («whileCondition.content») | ||
|
||
«instruction.innerContent» | ||
«IF caller.main» | ||
|
||
print("FINAL TIME: %5.5f - deltat: %5.5f\n" % (self.«tn», self.«deltat»)) | ||
«IF ppInfo !== null»self.__dumpVariables(self.«itVar»+1);«ENDIF» | ||
«ENDIF» | ||
''' | ||
private static def needDefinition(Variable v) | ||
{ | ||
!v.option && v.defaultValue === null | ||
} | ||
|
||
private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it) | ||
''' | ||
«val itVar = Utils.getCodeName(iterationCounter)» | ||
«val irRoot = IrUtils.getContainerOfType(it, IrRoot)» | ||
«val tn = Utils.getCodeName(irRoot.currentTimeVariable)» | ||
«val delta_t = Utils.getCodeName(irRoot.timeStepVariable)» | ||
«val ppInfo = irRoot.postProcessing» | ||
self.«itVar» = 0 | ||
«IF irRoot.currentTimeVariable.needDefinition»self.«tn» = 0.0«ENDIF» | ||
«IF irRoot.timeStepVariable.needDefinition»self.«delta_t» = 0.0«ENDIF» | ||
continueLoop = True | ||
while continueLoop: | ||
self.«itVar» += 1 | ||
«IF caller.main» | ||
print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - delta_t: %5.5f\n" % (self.«itVar», self.«tn», self.«delta_t»)) | ||
«IF ppInfo !== null» | ||
if (self.«Utils.getCodeName(ppInfo.periodReference)» >= self.«Utils.getCodeName(ppInfo.lastDumpVariable)» + self.«Utils.getCodeName(ppInfo.periodValue)»): | ||
self.__dumpVariables(self.«itVar») | ||
«ENDIF» | ||
«ELSE» | ||
print("Start iteration «iterationCounter.name»: %5d\n" % (self.«itVar»)) | ||
«ENDIF» | ||
|
||
«FOR j : calls» | ||
«PythonGeneratorUtils.getCallName(j)»() # @«j.at» | ||
«ENDFOR» | ||
|
||
# Evaluate loop condition with variables at time n | ||
continueLoop = («whileCondition.content») | ||
|
||
«instruction.innerContent» | ||
«IF caller.main» | ||
|
||
print("FINAL TIME: %5.5f - delta_t: %5.5f\n" % (self.«tn», self.«delta_t»)) | ||
«IF ppInfo !== null»self.__dumpVariables(self.«itVar»+1);«ENDIF» | ||
«ENDIF» | ||
''' | ||
private static def needDefinition(Variable v) | ||
{ | ||
!v.option && v.defaultValue === null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.