InRulesConditionSwitch.xtend 978 B

1234567891011121314151617181920212223242526272829303132
  1. package be.uantwerpen.ansymo.semanticadaptation.cg.cpp
  2. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
  3. import java.util.LinkedHashMap
  4. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CompositeOutputFunction
  5. class InRulesConditionSwitch extends InOutRulesConditionSwitch {
  6. private Boolean inOutput = false;
  7. new(String adaptationName, LinkedHashMap<String, Pair<String, Integer>> scalars) {
  8. super(adaptationName, scalars, "in_rule_");
  9. }
  10. override String caseCompositeOutputFunction(CompositeOutputFunction object) {
  11. this.inOutput = true;
  12. val returnVal = super.caseCompositeOutputFunction(object);
  13. this.inOutput = false;
  14. return returnVal;
  15. }
  16. override String caseAssignment(Assignment object) {
  17. if (inOutput) { '''
  18. setValue(«object.lvalue.owner.name»,«scalars.get(object.lvalue.owner.name+object.lvalue.ref.name).key»,«doSwitch(object.expr)»);
  19. ''';
  20. } else {
  21. super.caseAssignment(object);
  22. }
  23. }
  24. }