benjamin.schwertfeger@gmail.com 14 лет назад
Родитель
Сommit
b8c29b1aa8
13 измененных файлов с 6012 добавлено и 0 удалено
  1. 1149 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java
  2. 897 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java
  3. 279 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java
  4. 593 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java
  5. 821 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java
  6. 751 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java
  7. 169 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecExtensions.java
  8. 245 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SgraphExtensions.java
  9. 251 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java
  10. 402 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java
  11. 40 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java
  12. 308 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java
  13. 107 0
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/TraceExtensions.java

Разница между файлами не показана из-за своего большого размера
+ 1149 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java


+ 897 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java

@@ -0,0 +1,897 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.Check;
+import org.yakindu.sct.model.sexec.CheckRef;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.HistoryEntry;
+import org.yakindu.sct.model.sexec.If;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+
+@SuppressWarnings("all")
+public class FlowOptimizer {
+  
+  private boolean _inlineReactions;
+  
+  public boolean inlineReactions(final boolean b) {
+    boolean __inlineReactions = this._inlineReactions = b;
+    return __inlineReactions;
+  }
+  
+  private boolean _inlineEntryActions;
+  
+  public boolean inlineEntryActions(final boolean b) {
+    boolean __inlineEntryActions = this._inlineEntryActions = b;
+    return __inlineEntryActions;
+  }
+  
+  private boolean _inlineExitActions;
+  
+  public boolean inlineExitActions(final boolean b) {
+    boolean __inlineExitActions = this._inlineExitActions = b;
+    return __inlineExitActions;
+  }
+  
+  private boolean _inlineEnterSequences;
+  
+  public boolean inlineEnterSequences(final boolean b) {
+    boolean __inlineEnterSequences = this._inlineEnterSequences = b;
+    return __inlineEnterSequences;
+  }
+  
+  private boolean _inlineEnterRegion;
+  
+  public boolean inlineEnterRegion(final boolean b) {
+    boolean __inlineEnterRegion = this._inlineEnterRegion = b;
+    return __inlineEnterRegion;
+  }
+  
+  private boolean _inlineExitRegion;
+  
+  public boolean inlineExitRegion(final boolean b) {
+    boolean __inlineExitRegion = this._inlineExitRegion = b;
+    return __inlineExitRegion;
+  }
+  
+  private boolean _inlineExitSequences;
+  
+  public boolean inlineExitSequences(final boolean b) {
+    boolean __inlineExitSequences = this._inlineExitSequences = b;
+    return __inlineExitSequences;
+  }
+  
+  private boolean _inlineChoices;
+  
+  public boolean inlineChoices(final boolean b) {
+    boolean __inlineChoices = this._inlineChoices = b;
+    return __inlineChoices;
+  }
+  
+  private boolean _inlineEntries;
+  
+  public boolean inlineEntries(final boolean b) {
+    boolean __inlineEntries = this._inlineEntries = b;
+    return __inlineEntries;
+  }
+  
+  public ExecutionFlow transform(final ExecutionFlow flow) {
+    ExecutionFlow _xblockexpression = null;
+    {
+      this.replaceTrueIfs(flow);
+      if (this._inlineReactions) {
+        {
+          this.inlineReactionChecks(flow);
+          this.inlineReactionEffects(flow);
+        }
+      }
+      if (this._inlineEntryActions) {
+        EList<ExecutionState> _states = flow.getStates();
+        final Function1<ExecutionState,Step> _function = new Function1<ExecutionState,Step>() {
+            public Step apply(final ExecutionState state) {
+              Step _entryAction = state.getEntryAction();
+              Step _inline = FlowOptimizer.this.inline(_entryAction);
+              return _inline;
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states, _function);
+      }
+      if (this._inlineExitActions) {
+        EList<ExecutionState> _states_1 = flow.getStates();
+        final Function1<ExecutionState,Step> _function_1 = new Function1<ExecutionState,Step>() {
+            public Step apply(final ExecutionState state_1) {
+              Step _exitAction = state_1.getExitAction();
+              Step _inline_1 = FlowOptimizer.this.inline(_exitAction);
+              return _inline_1;
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_1, _function_1);
+      }
+      if (this._inlineEnterSequences) {
+        EList<ExecutionState> _states_2 = flow.getStates();
+        final Function1<ExecutionState,Step> _function_2 = new Function1<ExecutionState,Step>() {
+            public Step apply(final ExecutionState state_2) {
+              Sequence _enterSequence = state_2.getEnterSequence();
+              Step _inline_2 = FlowOptimizer.this.inline(_enterSequence);
+              return _inline_2;
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_2, _function_2);
+      }
+      if (this._inlineExitSequences) {
+        EList<ExecutionState> _states_3 = flow.getStates();
+        final Function1<ExecutionState,Step> _function_3 = new Function1<ExecutionState,Step>() {
+            public Step apply(final ExecutionState state_3) {
+              Sequence _exitSequence = state_3.getExitSequence();
+              Step _inline_3 = FlowOptimizer.this.inline(_exitSequence);
+              return _inline_3;
+            }
+          };
+        IterableExtensions.<ExecutionState>forEach(_states_3, _function_3);
+      }
+      if (this._inlineExitRegion) {
+        Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(flow);
+        Iterable<ExecutionRegion> _filter = IterableExtensions.<ExecutionRegion>filter(_allContentsIterable, org.yakindu.sct.model.sexec.ExecutionRegion.class);
+        final Function1<ExecutionRegion,Step> _function_4 = new Function1<ExecutionRegion,Step>() {
+            public Step apply(final ExecutionRegion region) {
+              Sequence _exitSequence_1 = region.getExitSequence();
+              Step _inline_4 = FlowOptimizer.this.inline(_exitSequence_1);
+              return _inline_4;
+            }
+          };
+        IterableExtensions.<ExecutionRegion>forEach(_filter, _function_4);
+      }
+      if (this._inlineEnterRegion) {
+        Iterable<EObject> _allContentsIterable_1 = EObjectExtensions.allContentsIterable(flow);
+        Iterable<ExecutionRegion> _filter_1 = IterableExtensions.<ExecutionRegion>filter(_allContentsIterable_1, org.yakindu.sct.model.sexec.ExecutionRegion.class);
+        final Function1<ExecutionRegion,Step> _function_5 = new Function1<ExecutionRegion,Step>() {
+            public Step apply(final ExecutionRegion region_1) {
+              Sequence _enterSequence_1 = region_1.getEnterSequence();
+              Step _inline_5 = FlowOptimizer.this.inline(_enterSequence_1);
+              return _inline_5;
+            }
+          };
+        IterableExtensions.<ExecutionRegion>forEach(_filter_1, _function_5);
+      }
+      if (this._inlineChoices) {
+        {
+          EList<ExecutionNode> _nodes = flow.getNodes();
+          Iterable<ExecutionChoice> _filter_2 = IterableExtensions.<ExecutionChoice>filter(_nodes, org.yakindu.sct.model.sexec.ExecutionChoice.class);
+          final Function1<ExecutionChoice,ExecutionChoice> _function_6 = new Function1<ExecutionChoice,ExecutionChoice>() {
+              public ExecutionChoice apply(final ExecutionChoice node) {
+                ExecutionChoice _xblockexpression_1 = null;
+                {
+                  EList<Reaction> _reactions = node.getReactions();
+                  final Function1<Reaction,Step> _function_7 = new Function1<Reaction,Step>() {
+                      public Step apply(final Reaction r) {
+                        Step _xblockexpression_2 = null;
+                        {
+                          Check _check = r.getCheck();
+                          FlowOptimizer.this.inline(_check);
+                          Step _effect = r.getEffect();
+                          Step _inline_6 = FlowOptimizer.this.inline(_effect);
+                          _xblockexpression_2 = (_inline_6);
+                        }
+                        return _xblockexpression_2;
+                      }
+                    };
+                  IterableExtensions.<Reaction>forEach(_reactions, _function_7);
+                  _xblockexpression_1 = (node);
+                }
+                return _xblockexpression_1;
+              }
+            };
+          IterableExtensions.<ExecutionChoice>forEach(_filter_2, _function_6);
+          EList<ExecutionNode> _nodes_1 = flow.getNodes();
+          Iterable<ExecutionChoice> _filter_3 = IterableExtensions.<ExecutionChoice>filter(_nodes_1, org.yakindu.sct.model.sexec.ExecutionChoice.class);
+          final Function1<ExecutionChoice,Step> _function_8 = new Function1<ExecutionChoice,Step>() {
+              public Step apply(final ExecutionChoice node_1) {
+                Sequence _reactSequence = node_1.getReactSequence();
+                Step _inline_7 = FlowOptimizer.this.inline(_reactSequence);
+                return _inline_7;
+              }
+            };
+          IterableExtensions.<ExecutionChoice>forEach(_filter_3, _function_8);
+        }
+      }
+      if (this._inlineEntries) {
+        {
+          EList<ExecutionNode> _nodes_2 = flow.getNodes();
+          Iterable<ExecutionEntry> _filter_4 = IterableExtensions.<ExecutionEntry>filter(_nodes_2, org.yakindu.sct.model.sexec.ExecutionEntry.class);
+          final Function1<ExecutionEntry,ExecutionEntry> _function_9 = new Function1<ExecutionEntry,ExecutionEntry>() {
+              public ExecutionEntry apply(final ExecutionEntry node_2) {
+                ExecutionEntry _xblockexpression_3 = null;
+                {
+                  EList<Reaction> _reactions_1 = node_2.getReactions();
+                  final Function1<Reaction,Step> _function_10 = new Function1<Reaction,Step>() {
+                      public Step apply(final Reaction r_1) {
+                        Step _xblockexpression_4 = null;
+                        {
+                          Check _check_1 = r_1.getCheck();
+                          FlowOptimizer.this.inline(_check_1);
+                          Step _effect_1 = r_1.getEffect();
+                          Step _inline_8 = FlowOptimizer.this.inline(_effect_1);
+                          _xblockexpression_4 = (_inline_8);
+                        }
+                        return _xblockexpression_4;
+                      }
+                    };
+                  IterableExtensions.<Reaction>forEach(_reactions_1, _function_10);
+                  _xblockexpression_3 = (node_2);
+                }
+                return _xblockexpression_3;
+              }
+            };
+          IterableExtensions.<ExecutionEntry>forEach(_filter_4, _function_9);
+          EList<ExecutionNode> _nodes_3 = flow.getNodes();
+          Iterable<ExecutionEntry> _filter_5 = IterableExtensions.<ExecutionEntry>filter(_nodes_3, org.yakindu.sct.model.sexec.ExecutionEntry.class);
+          final Function1<ExecutionEntry,Step> _function_11 = new Function1<ExecutionEntry,Step>() {
+              public Step apply(final ExecutionEntry node_3) {
+                Sequence _reactSequence_1 = node_3.getReactSequence();
+                Step _inline_9 = FlowOptimizer.this.inline(_reactSequence_1);
+                return _inline_9;
+              }
+            };
+          IterableExtensions.<ExecutionEntry>forEach(_filter_5, _function_11);
+        }
+      }
+      _xblockexpression = (flow);
+    }
+    return _xblockexpression;
+  }
+  
+  public void replaceTrueIfs(final ExecutionFlow flow) {
+    Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(flow);
+    Iterable<If> _filter = IterableExtensions.<If>filter(_allContentsIterable, org.yakindu.sct.model.sexec.If.class);
+    final Function1<If,Boolean> _function = new Function1<If,Boolean>() {
+        public Boolean apply(final If i) {
+          Check _check = i.getCheck();
+          boolean _alwaysTrue = FlowOptimizer.this.alwaysTrue(_check);
+          return ((Boolean)_alwaysTrue);
+        }
+      };
+    Iterable<If> _filter_1 = IterableExtensions.<If>filter(_filter, _function);
+    final Function1<If,Step> _function_1 = new Function1<If,Step>() {
+        public Step apply(final If i_1) {
+          Step _thenStep = i_1.getThenStep();
+          Step _substituteBy = FlowOptimizer.this.substituteBy(i_1, _thenStep);
+          return _substituteBy;
+        }
+      };
+    IterableExtensions.<If>forEach(_filter_1, _function_1);
+  }
+  
+  public Step substituteBy(final Step orig, final Step substitute) {
+    EObject _eContainer = orig.eContainer();
+    Step _substitute = this.substitute(_eContainer, orig, substitute);
+    return _substitute;
+  }
+  
+  protected Step _substitute(final Object parent, final Step orig, final Step subst) {
+    return null;
+  }
+  
+  protected Step _substitute(final Sequence parent, final Step orig, final Step subst) {
+    Step _xifexpression = null;
+    EList<Step> _steps = parent.getSteps();
+    boolean _contains = _steps.contains(orig);
+    if (_contains) {
+      EList<Step> _steps_1 = parent.getSteps();
+      EList<Step> _steps_2 = parent.getSteps();
+      int _indexOf = _steps_2.indexOf(orig);
+      Step _set = _steps_1.set(_indexOf, subst);
+      _xifexpression = _set;
+    }
+    return _xifexpression;
+  }
+  
+  protected Step _substitute(final If parent, final Step orig, final Step subst) {
+    Step _xblockexpression = null;
+    {
+      Step _thenStep = parent.getThenStep();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_thenStep, orig);
+      if (_operator_equals) {
+        parent.setThenStep(subst);
+      } else {
+        Step _elseStep = parent.getElseStep();
+        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_elseStep, orig);
+        if (_operator_equals_1) {
+          parent.setElseStep(subst);
+        }
+      }
+      _xblockexpression = (subst);
+    }
+    return _xblockexpression;
+  }
+  
+  public boolean alwaysTrue(final Check check) {
+    {
+      boolean _operator_and = false;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(check, null);
+      if (!_operator_notEquals) {
+        _operator_and = false;
+      } else {
+        Statement _condition = check.getCondition();
+        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_condition instanceof org.yakindu.sct.model.stext.stext.PrimitiveValueExpression));
+      }
+      if (_operator_and) {
+        {
+          Statement _condition_1 = check.getCondition();
+          final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
+          boolean _operator_and_1 = false;
+          Literal _value = pve.getValue();
+          if (!(_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral)) {
+            _operator_and_1 = false;
+          } else {
+            Literal _value_1 = pve.getValue();
+            boolean _isValue = ((BoolLiteral) _value_1).isValue();
+            _operator_and_1 = BooleanExtensions.operator_and((_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral), _isValue);
+          }
+          return _operator_and_1;
+        }
+      }
+      return false;
+    }
+  }
+  
+  protected boolean _empty(final Step step) {
+    return false;
+  }
+  
+  protected boolean _empty(final Sequence seq) {
+    EList<Step> _steps = seq.getSteps();
+    int _size = _steps.size();
+    boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)0));
+    return _operator_equals;
+  }
+  
+  public void inlineReactionChecks(final ExecutionFlow flow) {
+    EList<ExecutionState> _states = flow.getStates();
+    final Function1<ExecutionState,ExecutionState> _function = new Function1<ExecutionState,ExecutionState>() {
+        public ExecutionState apply(final ExecutionState state) {
+          ExecutionState _inlineReactionChecks = FlowOptimizer.this.inlineReactionChecks(state);
+          return _inlineReactionChecks;
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states, _function);
+  }
+  
+  public ExecutionState inlineReactionChecks(final ExecutionState state) {
+    ExecutionState _xblockexpression = null;
+    {
+      EList<Reaction> _reactions = state.getReactions();
+      final Function1<Reaction,Check> _function = new Function1<Reaction,Check>() {
+          public Check apply(final Reaction r) {
+            Check _check = r.getCheck();
+            return _check;
+          }
+        };
+      List<Check> _map = ListExtensions.<Reaction, Check>map(_reactions, _function);
+      List<Check> _list = IterableExtensions.<Check>toList(_map);
+      final List<Check> checks = _list;
+      final Function1<Check,Check> _function_1 = new Function1<Check,Check>() {
+          public Check apply(final Check c) {
+            Check _inline = FlowOptimizer.this.inline(c);
+            return _inline;
+          }
+        };
+      IterableExtensions.<Check>forEach(checks, _function_1);
+      _xblockexpression = (state);
+    }
+    return _xblockexpression;
+  }
+  
+  public Check inline(final Check c) {
+    Check _xblockexpression = null;
+    {
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(c, null);
+      if (_operator_notEquals) {
+        {
+          ArrayList<CheckRef> _arrayList = new ArrayList<CheckRef>();
+          final List<CheckRef> cRefs = _arrayList;
+          EList<CheckRef> _refs = c.getRefs();
+          cRefs.addAll(_refs);
+          for (final CheckRef ref : cRefs) {
+            {
+              Check _copy = EcoreUtil.<Check>copy(c);
+              final Check clone = _copy;
+              EObject _eContainer = ref.eContainer();
+              this.substitute(_eContainer, ref, clone);
+              ref.setCheck(null);
+            }
+          }
+        }
+      }
+      _xblockexpression = (c);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _substitute(final EObject owner, final Check pre, final Check post) {
+    return null;
+  }
+  
+  protected Step _substitute(final If owner, final Check pre, final Check post) {
+    Check _xblockexpression = null;
+    {
+      Check _check = owner.getCheck();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_check, pre);
+      if (_operator_equals) {
+        owner.setCheck(post);
+      }
+      _xblockexpression = (post);
+    }
+    return _xblockexpression;
+  }
+  
+  public void inlineReactionEffects(final ExecutionFlow flow) {
+    EList<ExecutionState> _states = flow.getStates();
+    final Function1<ExecutionState,ExecutionState> _function = new Function1<ExecutionState,ExecutionState>() {
+        public ExecutionState apply(final ExecutionState state) {
+          ExecutionState _inlineReactionEffects = FlowOptimizer.this.inlineReactionEffects(state);
+          return _inlineReactionEffects;
+        }
+      };
+    IterableExtensions.<ExecutionState>forEach(_states, _function);
+  }
+  
+  public ExecutionState inlineReactionEffects(final ExecutionState state) {
+    ExecutionState _xblockexpression = null;
+    {
+      EList<Reaction> _reactions = state.getReactions();
+      final Function1<Reaction,Step> _function = new Function1<Reaction,Step>() {
+          public Step apply(final Reaction r) {
+            Step _effect = r.getEffect();
+            return _effect;
+          }
+        };
+      List<Step> _map = ListExtensions.<Reaction, Step>map(_reactions, _function);
+      List<Step> _list = IterableExtensions.<Step>toList(_map);
+      final List<Step> effects = _list;
+      final Function1<Step,Step> _function_1 = new Function1<Step,Step>() {
+          public Step apply(final Step e) {
+            Step _inline = FlowOptimizer.this.inline(e);
+            return _inline;
+          }
+        };
+      IterableExtensions.<Step>forEach(effects, _function_1);
+      _xblockexpression = (state);
+    }
+    return _xblockexpression;
+  }
+  
+  public void inlineEntryAndExitActions(final ExecutionFlow flow) {
+    {
+      EList<ExecutionState> _states = flow.getStates();
+      final Function1<ExecutionState,Step> _function = new Function1<ExecutionState,Step>() {
+          public Step apply(final ExecutionState state) {
+            Step _entryAction = state.getEntryAction();
+            Step _inline = FlowOptimizer.this.inline(_entryAction);
+            return _inline;
+          }
+        };
+      IterableExtensions.<ExecutionState>forEach(_states, _function);
+      EList<ExecutionState> _states_1 = flow.getStates();
+      final Function1<ExecutionState,Step> _function_1 = new Function1<ExecutionState,Step>() {
+          public Step apply(final ExecutionState state_1) {
+            Step _exitAction = state_1.getExitAction();
+            Step _inline_1 = FlowOptimizer.this.inline(_exitAction);
+            return _inline_1;
+          }
+        };
+      IterableExtensions.<ExecutionState>forEach(_states_1, _function_1);
+    }
+  }
+  
+  public Step inline(final Step step) {
+    Step _xblockexpression = null;
+    {
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(step, null);
+      if (_operator_notEquals) {
+        {
+          ArrayList<Call> _arrayList = new ArrayList<Call>();
+          final List<Call> calls = _arrayList;
+          EList<Call> _caller = step.getCaller();
+          calls.addAll(_caller);
+          for (final Call caller : calls) {
+            {
+              Step _stepCopy = this.stepCopy(step);
+              final Step clone = _stepCopy;
+              EObject _eContainer = caller.eContainer();
+              boolean _substituteCall = this.substituteCall(_eContainer, caller, clone);
+              if (_substituteCall) {
+                caller.setStep(null);
+              } else {
+                String _operator_plus = StringExtensions.operator_plus("Did not substitute \'", step);
+                String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "\' call from \'");
+                EObject _eContainer_1 = caller.eContainer();
+                String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _eContainer_1);
+                String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "\'.");
+                System.out.println(_operator_plus_3);
+              }
+            }
+          }
+        }
+      }
+      _xblockexpression = (step);
+    }
+    return _xblockexpression;
+  }
+  
+  protected boolean _substituteCall(final EObject owner, final Call pre, final Step post) {
+    return false;
+  }
+  
+  protected boolean _substituteCall(final StateCase owner, final Call pre, final Step post) {
+    {
+      Step _step = owner.getStep();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_step, pre);
+      if (_operator_equals) {
+        {
+          owner.setStep(post);
+          return true;
+        }
+      }
+      return false;
+    }
+  }
+  
+  protected boolean _substituteCall(final HistoryEntry owner, final Call pre, final Step post) {
+    {
+      Step _initialStep = owner.getInitialStep();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_initialStep, pre);
+      if (_operator_equals) {
+        {
+          owner.setInitialStep(post);
+          return true;
+        }
+      }
+      Step _historyStep = owner.getHistoryStep();
+      boolean _operator_equals_1 = ObjectExtensions.operator_equals(_historyStep, pre);
+      if (_operator_equals_1) {
+        {
+          owner.setHistoryStep(post);
+          return true;
+        }
+      }
+      return false;
+    }
+  }
+  
+  protected boolean _substituteCall(final Sequence owner, final Call call, final Step step) {
+    {
+      EList<Step> _steps = owner.getSteps();
+      boolean _contains = _steps.contains(call);
+      if (_contains) {
+        {
+          EList<Step> _steps_1 = owner.getSteps();
+          EList<Step> _steps_2 = owner.getSteps();
+          int _indexOf = _steps_2.indexOf(call);
+          _steps_1.set(_indexOf, step);
+          return true;
+        }
+      }
+      return false;
+    }
+  }
+  
+  protected boolean _substituteCall(final If owner, final Call call, final Step step) {
+    {
+      Step _thenStep = owner.getThenStep();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_thenStep, call);
+      if (_operator_equals) {
+        {
+          owner.setThenStep(step);
+          return true;
+        }
+      } else {
+        Step _elseStep = owner.getElseStep();
+        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_elseStep, call);
+        if (_operator_equals_1) {
+          {
+            owner.setElseStep(step);
+            return true;
+          }
+        }
+      }
+      return false;
+    }
+  }
+  
+  protected Step _stepCopy(final Step step) {
+    Step _copy = EcoreUtil.<Step>copy(step);
+    return _copy;
+  }
+  
+  protected Step _stepCopy(final Sequence seq) {
+    Sequence _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Sequence _createSequence = _sexecFactory.createSequence();
+      final Sequence _copy = _createSequence;
+      String _name = seq.getName();
+      _copy.setName(_name);
+      String _comment = seq.getComment();
+      _copy.setComment(_comment);
+      EList<Step> _steps = _copy.getSteps();
+      EList<Step> _steps_1 = seq.getSteps();
+      final Function1<Step,Step> _function = new Function1<Step,Step>() {
+          public Step apply(final Step s) {
+            Step _stepCopy = FlowOptimizer.this.stepCopy(s);
+            return _stepCopy;
+          }
+        };
+      List<Step> _map = ListExtensions.<Step, Step>map(_steps_1, _function);
+      _steps.addAll(_map);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final If _if) {
+    If _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      If _createIf = _sexecFactory.createIf();
+      final If _copy = _createIf;
+      String _name = _if.getName();
+      _copy.setName(_name);
+      String _comment = _if.getComment();
+      _copy.setComment(_comment);
+      Check _check = _if.getCheck();
+      Step _stepCopy = this.stepCopy(_check);
+      _copy.setCheck(((Check) _stepCopy));
+      Step _xifexpression = null;
+      Step _thenStep = _if.getThenStep();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_thenStep, null);
+      if (_operator_notEquals) {
+        Step _thenStep_1 = _if.getThenStep();
+        Step _stepCopy_1 = this.stepCopy(_thenStep_1);
+        _xifexpression = _stepCopy_1;
+      } else {
+        _xifexpression = null;
+      }
+      _copy.setThenStep(_xifexpression);
+      Step _xifexpression_1 = null;
+      Step _elseStep = _if.getElseStep();
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_elseStep, null);
+      if (_operator_notEquals_1) {
+        Step _elseStep_1 = _if.getElseStep();
+        Step _stepCopy_2 = this.stepCopy(_elseStep_1);
+        _xifexpression_1 = _stepCopy_2;
+      } else {
+        _xifexpression_1 = null;
+      }
+      _copy.setElseStep(_xifexpression_1);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final Call call) {
+    Call _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Call _createCall = _sexecFactory.createCall();
+      final Call _copy = _createCall;
+      String _name = call.getName();
+      _copy.setName(_name);
+      String _comment = call.getComment();
+      _copy.setComment(_comment);
+      Step _step = call.getStep();
+      _copy.setStep(_step);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final CheckRef cref) {
+    CheckRef _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      CheckRef _createCheckRef = _sexecFactory.createCheckRef();
+      final CheckRef _copy = _createCheckRef;
+      String _name = cref.getName();
+      _copy.setName(_name);
+      String _comment = cref.getComment();
+      _copy.setComment(_comment);
+      Check _check = cref.getCheck();
+      _copy.setCheck(_check);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final HistoryEntry cref) {
+    HistoryEntry _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      HistoryEntry _createHistoryEntry = _sexecFactory.createHistoryEntry();
+      final HistoryEntry _copy = _createHistoryEntry;
+      String _name = cref.getName();
+      _copy.setName(_name);
+      String _comment = cref.getComment();
+      _copy.setComment(_comment);
+      boolean _isDeep = cref.isDeep();
+      _copy.setDeep(_isDeep);
+      ExecutionRegion _region = cref.getRegion();
+      _copy.setRegion(_region);
+      Step _initialStep = cref.getInitialStep();
+      Step _stepCopy = this.stepCopy(_initialStep);
+      _copy.setInitialStep(_stepCopy);
+      Step _historyStep = cref.getHistoryStep();
+      Step _stepCopy_1 = this.stepCopy(_historyStep);
+      _copy.setHistoryStep(_stepCopy_1);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Step _stepCopy(final StateSwitch _switch) {
+    StateSwitch _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      StateSwitch _createStateSwitch = _sexecFactory.createStateSwitch();
+      final StateSwitch _copy = _createStateSwitch;
+      String _name = _switch.getName();
+      _copy.setName(_name);
+      String _comment = _switch.getComment();
+      _copy.setComment(_comment);
+      int _stateConfigurationIdx = _switch.getStateConfigurationIdx();
+      _copy.setStateConfigurationIdx(_stateConfigurationIdx);
+      EList<StateCase> _cases = _copy.getCases();
+      EList<StateCase> _cases_1 = _switch.getCases();
+      final Function1<StateCase,StateCase> _function = new Function1<StateCase,StateCase>() {
+          public StateCase apply(final StateCase c) {
+            StateCase _stepCopy = FlowOptimizer.this.stepCopy(c);
+            return _stepCopy;
+          }
+        };
+      List<StateCase> _map = ListExtensions.<StateCase, StateCase>map(_cases_1, _function);
+      _cases.addAll(_map);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  public StateCase stepCopy(final StateCase _case) {
+    StateCase _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      StateCase _createStateCase = _sexecFactory.createStateCase();
+      final StateCase _copy = _createStateCase;
+      ExecutionState _state = _case.getState();
+      _copy.setState(_state);
+      Step _step = _case.getStep();
+      Step _stepCopy = this.stepCopy(_step);
+      _copy.setStep(_stepCopy);
+      _xblockexpression = (_copy);
+    }
+    return _xblockexpression;
+  }
+  
+  public SexecFactory sexecFactory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public SGraphFactory sgraphFactory() {
+    return SGraphFactory.eINSTANCE;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Step substitute(final Object owner, final Step pre, final Step post) {
+    if ((owner instanceof If)
+         && (pre instanceof Check)
+         && (post instanceof Check)) {
+      return _substitute((If)owner, (Check)pre, (Check)post);
+    } else if ((owner instanceof If)
+         && (pre instanceof Step)
+         && (post instanceof Step)) {
+      return _substitute((If)owner, (Step)pre, (Step)post);
+    } else if ((owner instanceof Sequence)
+         && (pre instanceof Step)
+         && (post instanceof Step)) {
+      return _substitute((Sequence)owner, (Step)pre, (Step)post);
+    } else if ((owner instanceof EObject)
+         && (pre instanceof Check)
+         && (post instanceof Check)) {
+      return _substitute((EObject)owner, (Check)pre, (Check)post);
+    } else if ((owner instanceof Object)
+         && (pre instanceof Step)
+         && (post instanceof Step)) {
+      return _substitute((Object)owner, (Step)pre, (Step)post);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(owner, pre, post).toString());
+    }
+  }
+  
+  public boolean empty(final Step seq) {
+    if ((seq instanceof Sequence)) {
+      return _empty((Sequence)seq);
+    } else if ((seq instanceof Step)) {
+      return _empty((Step)seq);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(seq).toString());
+    }
+  }
+  
+  public boolean substituteCall(final EObject owner, final Call pre, final Step post) {
+    if ((owner instanceof HistoryEntry)
+         && (pre instanceof Call)
+         && (post instanceof Step)) {
+      return _substituteCall((HistoryEntry)owner, (Call)pre, (Step)post);
+    } else if ((owner instanceof If)
+         && (pre instanceof Call)
+         && (post instanceof Step)) {
+      return _substituteCall((If)owner, (Call)pre, (Step)post);
+    } else if ((owner instanceof Sequence)
+         && (pre instanceof Call)
+         && (post instanceof Step)) {
+      return _substituteCall((Sequence)owner, (Call)pre, (Step)post);
+    } else if ((owner instanceof StateCase)
+         && (pre instanceof Call)
+         && (post instanceof Step)) {
+      return _substituteCall((StateCase)owner, (Call)pre, (Step)post);
+    } else if ((owner instanceof EObject)
+         && (pre instanceof Call)
+         && (post instanceof Step)) {
+      return _substituteCall((EObject)owner, (Call)pre, (Step)post);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(owner, pre, post).toString());
+    }
+  }
+  
+  public Step stepCopy(final Step cref) {
+    if ((cref instanceof CheckRef)) {
+      return _stepCopy((CheckRef)cref);
+    } else if ((cref instanceof Call)) {
+      return _stepCopy((Call)cref);
+    } else if ((cref instanceof HistoryEntry)) {
+      return _stepCopy((HistoryEntry)cref);
+    } else if ((cref instanceof If)) {
+      return _stepCopy((If)cref);
+    } else if ((cref instanceof Sequence)) {
+      return _stepCopy((Sequence)cref);
+    } else if ((cref instanceof StateSwitch)) {
+      return _stepCopy((StateSwitch)cref);
+    } else if ((cref instanceof Step)) {
+      return _stepCopy((Step)cref);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(cref).toString());
+    }
+  }
+}

+ 279 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java

@@ -0,0 +1,279 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.InputOutput;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.types.Feature;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.BehaviorMapping;
+import org.yakindu.sct.model.sexec.transformation.ReactionBuilder;
+import org.yakindu.sct.model.sexec.transformation.SequenceBuilder;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StateVectorBuilder;
+import org.yakindu.sct.model.sexec.transformation.StructureMapping;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class ModelSequencer {
+  
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StructureMapping structureMapping;
+  
+  @Inject
+  private BehaviorMapping behaviorMapping;
+  
+  @Inject
+  private ReactionBuilder reactBuilder;
+  
+  @Inject
+  private SequenceBuilder seqBuilder;
+  
+  @Inject
+  private StateVectorBuilder svBuilder;
+  
+  public ExecutionFlow transform(final Statechart sc) {
+    {
+      ExecutionFlow _create = this.mapping.create(sc);
+      final ExecutionFlow ef = _create;
+      this.structureMapping.mapScopes(sc, ef);
+      this.structureMapping.mapRegularStates(sc, ef);
+      this.structureMapping.mapRegions(sc, ef);
+      this.structureMapping.mapPseudoStates(sc, ef);
+      this.structureMapping.mapTimeEvents(sc, ef);
+      this.svBuilder.defineStateVector(ef, sc);
+      this.svBuilder.defineHistoryVector(ef, sc);
+      this.behaviorMapping.mapEntryActions(sc, ef);
+      this.behaviorMapping.mapExitActions(sc, ef);
+      this.seqBuilder.defineStateEnterSequences(ef, sc);
+      this.seqBuilder.defineStateExitSequences(ef, sc);
+      this.seqBuilder.defineDeepEnterSequences(ef, sc);
+      this.seqBuilder.defineShallowEnterSequences(ef, sc);
+      this.seqBuilder.defineStatechartEnterSequence(ef, sc);
+      this.seqBuilder.defineStatechartExitSequence(ef, sc);
+      this.behaviorMapping.mapTransitions(sc, ef);
+      this.behaviorMapping.mapLocalReactions(sc, ef);
+      this.behaviorMapping.mapChoiceTransitions(sc, ef);
+      this.reactBuilder.defineEntryReactions(sc, ef);
+      this.reactBuilder.defineRegularStateReactions(ef, sc);
+      this.reactBuilder.definePseudoStateReactions(ef, sc);
+      this.reactBuilder.defineStatechartReaction(ef, sc);
+      this.retargetDeclRefs(ef);
+      return ef;
+    }
+  }
+  
+  public void retargetDeclRefs(final ExecutionFlow flow) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(flow);
+      final List<EObject> allContent = _eAllContentsAsList;
+      final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
+          public Boolean apply(final EObject e) {
+            boolean _operator_or = false;
+            boolean _operator_or_1 = false;
+            if ((e instanceof org.yakindu.sct.model.stext.stext.EventDefinition)) {
+              _operator_or_1 = true;
+            } else {
+              _operator_or_1 = BooleanExtensions.operator_or((e instanceof org.yakindu.sct.model.stext.stext.EventDefinition), (e instanceof org.yakindu.sct.model.stext.stext.VariableDefinition));
+            }
+            if (_operator_or_1) {
+              _operator_or = true;
+            } else {
+              _operator_or = BooleanExtensions.operator_or(_operator_or_1, (e instanceof org.yakindu.sct.model.stext.stext.OperationDefinition));
+            }
+            return ((Boolean)_operator_or);
+          }
+        };
+      Iterable<EObject> _filter = IterableExtensions.<EObject>filter(allContent, _function);
+      Set<EObject> _set = IterableExtensions.<EObject>toSet(_filter);
+      final Set<EObject> declared = _set;
+      Iterable<ElementReferenceExpression> _filter_1 = IterableExtensions.<ElementReferenceExpression>filter(allContent, org.yakindu.sct.model.stext.stext.ElementReferenceExpression.class);
+      final Function1<ElementReferenceExpression,Object> _function_1 = new Function1<ElementReferenceExpression,Object>() {
+          public Object apply(final ElementReferenceExpression ere) {
+            Object _retarget = ModelSequencer.this.retarget(ere, declared);
+            return _retarget;
+          }
+        };
+      IterableExtensions.<ElementReferenceExpression>forEach(_filter_1, _function_1);
+      Iterable<FeatureCall> _filter_2 = IterableExtensions.<FeatureCall>filter(allContent, org.yakindu.sct.model.stext.stext.FeatureCall.class);
+      final Function1<FeatureCall,Object> _function_2 = new Function1<FeatureCall,Object>() {
+          public Object apply(final FeatureCall call) {
+            Object _retarget_1 = ModelSequencer.this.retarget(call, declared);
+            return _retarget_1;
+          }
+        };
+      IterableExtensions.<FeatureCall>forEach(_filter_2, _function_2);
+    }
+  }
+  
+  public Object retarget(final ElementReferenceExpression ere, final Collection<EObject> declared) {
+    Object _xifexpression = null;
+    boolean _operator_and = false;
+    EObject _reference = ere.getReference();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_reference, null);
+    if (!_operator_notEquals) {
+      _operator_and = false;
+    } else {
+      EObject _reference_1 = ere.getReference();
+      boolean _contains = declared.contains(_reference_1);
+      boolean _operator_not = BooleanExtensions.operator_not(_contains);
+      _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_not);
+    }
+    if (_operator_and) {
+      Object _xblockexpression = null;
+      {
+        EObject _reference_2 = ere.getReference();
+        Declaration _replaced = this.replaced(_reference_2);
+        final Declaration r = _replaced;
+        Object _xifexpression_1 = null;
+        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(r, null);
+        if (_operator_notEquals_1) {
+          ere.setReference(r);
+        }
+        _xblockexpression = (_xifexpression_1);
+      }
+      _xifexpression = _xblockexpression;
+    }
+    return _xifexpression;
+  }
+  
+  public Object retarget(final FeatureCall call, final Collection<EObject> declared) {
+    Object _xifexpression = null;
+    boolean _operator_and = false;
+    EObject _feature = call.getFeature();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_feature, null);
+    if (!_operator_notEquals) {
+      _operator_and = false;
+    } else {
+      EObject _feature_1 = call.getFeature();
+      boolean _contains = declared.contains(_feature_1);
+      boolean _operator_not = BooleanExtensions.operator_not(_contains);
+      _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_not);
+    }
+    if (_operator_and) {
+      Object _xblockexpression = null;
+      {
+        EObject _feature_2 = call.getFeature();
+        Declaration _replaced = this.replaced(_feature_2);
+        final Declaration r = _replaced;
+        Object _xifexpression_1 = null;
+        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(r, null);
+        if (_operator_notEquals_1) {
+          call.setFeature(((Feature) r));
+        }
+        _xblockexpression = (_xifexpression_1);
+      }
+      _xifexpression = _xblockexpression;
+    }
+    return _xifexpression;
+  }
+  
+  protected Declaration _replaced(final EObject ne) {
+    Declaration _xblockexpression = null;
+    {
+      try {
+        {
+          Comparable<? extends Object> _xifexpression = null;
+          boolean _operator_equals = ObjectExtensions.operator_equals(ne, null);
+          if (_operator_equals) {
+            _xifexpression = "null";
+          } else {
+            QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(ne);
+            _xifexpression = _fullyQualifiedName;
+          }
+          String _operator_plus = StringExtensions.operator_plus("Replace with unknown eObject called: ", _xifexpression);
+          InputOutput.<String>println(_operator_plus);
+          Log _log = LogFactory.getLog(org.yakindu.sct.model.sexec.transformation.ModelSequencer.class);
+          Comparable<? extends Object> _xifexpression_1 = null;
+          boolean _operator_equals_1 = ObjectExtensions.operator_equals(ne, null);
+          if (_operator_equals_1) {
+            _xifexpression_1 = "null";
+          } else {
+            QualifiedName _fullyQualifiedName_1 = this.qfnProvider.getFullyQualifiedName(ne);
+            _xifexpression_1 = _fullyQualifiedName_1;
+          }
+          String _operator_plus_1 = StringExtensions.operator_plus("Replace with unknown NamedElement called: ", _xifexpression_1);
+          _log.error(_operator_plus_1);
+        }
+      } catch (final LogConfigurationException e) { 
+        {
+          e.printStackTrace();
+          Comparable<? extends Object> _xifexpression_2 = null;
+          boolean _operator_equals_2 = ObjectExtensions.operator_equals(ne, null);
+          if (_operator_equals_2) {
+            _xifexpression_2 = "null";
+          } else {
+            QualifiedName _fullyQualifiedName_2 = this.qfnProvider.getFullyQualifiedName(ne);
+            _xifexpression_2 = _fullyQualifiedName_2;
+          }
+          String _operator_plus_2 = StringExtensions.operator_plus("Replace with unknown NamedElement called: ", _xifexpression_2);
+          InputOutput.<String>println(_operator_plus_2);
+        }
+      }
+      _xblockexpression = (null);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Declaration _replaced(final VariableDefinition vd) {
+    VariableDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final OperationDefinition vd) {
+    OperationDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final EventDefinition ed) {
+    EventDefinition _create = this.mapping.create(ed);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final TimeEvent ed) {
+    return ed;
+  }
+  
+  public Declaration replaced(final EObject ed) {
+    if ((ed instanceof TimeEvent)) {
+      return _replaced((TimeEvent)ed);
+    } else if ((ed instanceof EventDefinition)) {
+      return _replaced((EventDefinition)ed);
+    } else if ((ed instanceof OperationDefinition)) {
+      return _replaced((OperationDefinition)ed);
+    } else if ((ed instanceof VariableDefinition)) {
+      return _replaced((VariableDefinition)ed);
+    } else if ((ed instanceof EObject)) {
+      return _replaced((EObject)ed);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(ed).toString());
+    }
+  }
+}

+ 593 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java

@@ -0,0 +1,593 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.Check;
+import org.yakindu.sct.model.sexec.CheckRef;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.HistoryEntry;
+import org.yakindu.sct.model.sexec.If;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.ReactionFired;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TraceNodeExecuted;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sexec.transformation.TraceExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+
+@SuppressWarnings("all")
+public class ReactionBuilder {
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StatechartExtensions sct;
+  
+  @Inject
+  private TraceExtensions trace;
+  
+  public ExecutionFlow defineStatechartReaction(final ExecutionFlow flow, final Statechart sc) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence sequence = _createSequence;
+      sequence.setName("react");
+      String _name = sc.getName();
+      String _operator_plus = StringExtensions.operator_plus("The reactions of statechart ", _name);
+      sequence.setComment(_operator_plus);
+      List<RegularState> _allRegularStates = this.sct.allRegularStates(sc);
+      final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+          public Boolean apply(final RegularState s) {
+            boolean _isLeaf = ReactionBuilder.this.sgraph.isLeaf(s);
+            return ((Boolean)_isLeaf);
+          }
+        };
+      Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_allRegularStates, _function);
+      final Iterable<RegularState> leafStates = _filter;
+      SexecFactory _factory_1 = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory_1.createStateSwitch();
+      final StateSwitch sSwitch = _createStateSwitch;
+      EList<Step> _steps = sequence.getSteps();
+      CollectionExtensions.<Step>operator_add(_steps, sSwitch);
+      final Function1<RegularState,ExecutionState> _function_1 = new Function1<RegularState,ExecutionState>() {
+          public ExecutionState apply(final RegularState s_1) {
+            ExecutionState _create = ReactionBuilder.this.mapping.create(s_1);
+            return _create;
+          }
+        };
+      Iterable<ExecutionState> _map = IterableExtensions.<RegularState, ExecutionState>map(leafStates, _function_1);
+      for (final ExecutionState leaf : _map) {
+        {
+          SexecFactory _factory_2 = this.sexec.factory();
+          StateCase _createStateCase = _factory_2.createStateCase();
+          final StateCase sCase = _createStateCase;
+          sCase.setState(leaf);
+          Sequence _reactSequence = leaf.getReactSequence();
+          Call _newCall = this.mapping.newCall(_reactSequence);
+          sCase.setStep(_newCall);
+          EList<StateCase> _cases = sSwitch.getCases();
+          CollectionExtensions.<StateCase>operator_add(_cases, sCase);
+        }
+      }
+      flow.setReactSequence(sequence);
+      return flow;
+    }
+  }
+  
+  public ExecutionFlow defineRegularStateReactions(final ExecutionFlow flow, final Statechart sc) {
+    {
+      List<RegularState> _allRegularStates = this.sct.allRegularStates(sc);
+      final List<RegularState> states = _allRegularStates;
+      Iterable<State> _filter = IterableExtensions.<State>filter(states, org.yakindu.sct.model.sgraph.State.class);
+      final Function1<State,Boolean> _function = new Function1<State,Boolean>() {
+          public Boolean apply(final State s) {
+            boolean _isSimple = s.isSimple();
+            return ((Boolean)_isSimple);
+          }
+        };
+      Iterable<State> _filter_1 = IterableExtensions.<State>filter(_filter, _function);
+      final Function1<State,Sequence> _function_1 = new Function1<State,Sequence>() {
+          public Sequence apply(final State s_1) {
+            Sequence _defineCycle = ReactionBuilder.this.defineCycle(s_1);
+            return _defineCycle;
+          }
+        };
+      IterableExtensions.<State>forEach(_filter_1, _function_1);
+      Iterable<FinalState> _filter_2 = IterableExtensions.<FinalState>filter(states, org.yakindu.sct.model.sgraph.FinalState.class);
+      final Function1<FinalState,Sequence> _function_2 = new Function1<FinalState,Sequence>() {
+          public Sequence apply(final FinalState s_2) {
+            Sequence _defineCycle_1 = ReactionBuilder.this.defineCycle(s_2);
+            return _defineCycle_1;
+          }
+        };
+      IterableExtensions.<FinalState>forEach(_filter_2, _function_2);
+      return flow;
+    }
+  }
+  
+  public void definePseudoStateReactions(final ExecutionFlow flow, final Statechart sc) {
+    Iterable<Choice> _allChoices = this.sct.allChoices(sc);
+    final Function1<Choice,Sequence> _function = new Function1<Choice,Sequence>() {
+        public Sequence apply(final Choice choice) {
+          Sequence _defineReaction = ReactionBuilder.this.defineReaction(choice);
+          return _defineReaction;
+        }
+      };
+    IterableExtensions.<Choice>forEach(_allChoices, _function);
+  }
+  
+  public Sequence defineReaction(final Choice choice) {
+    {
+      ExecutionChoice _create = this.mapping.create(choice);
+      final ExecutionChoice execChoice = _create;
+      EList<Reaction> _reactions = execChoice.getReactions();
+      final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+          public Boolean apply(final Reaction r) {
+            Check _check = r.getCheck();
+            boolean _alwaysTrue = ReactionBuilder.this.alwaysTrue(_check);
+            return ((Boolean)_alwaysTrue);
+          }
+        };
+      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
+      Reaction _head = IterableExtensions.<Reaction>head(_list);
+      final Reaction _default_ = _head;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_default_, null);
+      if (_operator_notEquals) {
+        EList<Reaction> _reactions_1 = execChoice.getReactions();
+        EList<Reaction> _reactions_2 = execChoice.getReactions();
+        int _size = _reactions_2.size();
+        int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
+        _reactions_1.move(_operator_minus, _default_);
+      }
+      Sequence _createReactionSequence = this.createReactionSequence(execChoice, null);
+      final Sequence stateReaction = _createReactionSequence;
+      Sequence _reactSequence = execChoice.getReactSequence();
+      EList<Step> _steps = _reactSequence.getSteps();
+      EList<Step> _steps_1 = stateReaction.getSteps();
+      _steps.addAll(_steps_1);
+      Sequence _reactSequence_1 = execChoice.getReactSequence();
+      _reactSequence_1.setName("react");
+      Sequence _reactSequence_2 = execChoice.getReactSequence();
+      String _name = choice.getName();
+      String _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
+      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
+      _reactSequence_2.setComment(_operator_plus_1);
+      boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+      if (_isAddTraceSteps) {
+        Sequence _reactSequence_3 = execChoice.getReactSequence();
+        EList<Step> _steps_2 = _reactSequence_3.getSteps();
+        ExecutionChoice _create_1 = this.mapping.create(choice);
+        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(_create_1);
+        _steps_2.add(0, _newTraceNodeExecuted);
+      }
+      Sequence _reactSequence_4 = execChoice.getReactSequence();
+      return _reactSequence_4;
+    }
+  }
+  
+  public boolean alwaysTrue(final Check check) {
+    {
+      boolean _operator_and = false;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(check, null);
+      if (!_operator_notEquals) {
+        _operator_and = false;
+      } else {
+        Statement _condition = check.getCondition();
+        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, (_condition instanceof org.yakindu.sct.model.stext.stext.PrimitiveValueExpression));
+      }
+      if (_operator_and) {
+        {
+          Statement _condition_1 = check.getCondition();
+          final PrimitiveValueExpression pve = ((PrimitiveValueExpression) _condition_1);
+          boolean _operator_and_1 = false;
+          Literal _value = pve.getValue();
+          if (!(_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral)) {
+            _operator_and_1 = false;
+          } else {
+            Literal _value_1 = pve.getValue();
+            boolean _isValue = ((BoolLiteral) _value_1).isValue();
+            _operator_and_1 = BooleanExtensions.operator_and((_value instanceof org.yakindu.sct.model.stext.stext.BoolLiteral), _isValue);
+          }
+          return _operator_and_1;
+        }
+      }
+      return false;
+    }
+  }
+  
+  public Sequence defineCycle(final RegularState state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState execState = _create;
+      List<RegularState> _parentStates = this.sgraph.parentStates(state);
+      final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+          public ExecutionState apply(final RegularState p) {
+            ExecutionState _create_1 = ReactionBuilder.this.mapping.create(p);
+            return ((ExecutionState) _create_1);
+          }
+        };
+      List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(_parentStates, _function);
+      final Function1<ExecutionState,Boolean> _function_1 = new Function1<ExecutionState,Boolean>() {
+          public Boolean apply(final ExecutionState p_1) {
+            StateVector _stateVector = p_1.getStateVector();
+            int _offset = _stateVector.getOffset();
+            StateVector _stateVector_1 = execState.getStateVector();
+            int _offset_1 = _stateVector_1.getOffset();
+            boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset), ((Integer)_offset_1));
+            return ((Boolean)_operator_equals);
+          }
+        };
+      Iterable<ExecutionState> _filter = IterableExtensions.<ExecutionState>filter(_map, _function_1);
+      final Iterable<ExecutionState> parents = _filter;
+      Iterable<ExecutionNode> _xifexpression = null;
+      EObject _rootContainer = EcoreUtil.getRootContainer(execState);
+      StateVector _stateVector_2 = ((ExecutionFlow) _rootContainer).getStateVector();
+      int _offset_2 = _stateVector_2.getOffset();
+      StateVector _stateVector_3 = execState.getStateVector();
+      int _offset_3 = _stateVector_3.getOffset();
+      boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_offset_2), ((Integer)_offset_3));
+      if (_operator_equals_1) {
+        final Function1<ExecutionState,ExecutionNode> _function_2 = new Function1<ExecutionState,ExecutionNode>() {
+            public ExecutionNode apply(final ExecutionState p_2) {
+              return ((ExecutionNode) p_2);
+            }
+          };
+        Iterable<ExecutionNode> _map_1 = IterableExtensions.<ExecutionState, ExecutionNode>map(parents, _function_2);
+        EObject _rootContainer_1 = EcoreUtil.getRootContainer(execState);
+        HashSet<ExecutionNode> _newHashSet = CollectionLiterals.<ExecutionNode>newHashSet(((ExecutionNode) _rootContainer_1));
+        Iterable<ExecutionNode> _concat = Iterables.<ExecutionNode>concat(_map_1, _newHashSet);
+        _xifexpression = _concat;
+      } else {
+        final Function1<ExecutionState,ExecutionNode> _function_3 = new Function1<ExecutionState,ExecutionNode>() {
+            public ExecutionNode apply(final ExecutionState p_3) {
+              return ((ExecutionNode) p_3);
+            }
+          };
+        Iterable<ExecutionNode> _map_2 = IterableExtensions.<ExecutionState, ExecutionNode>map(parents, _function_3);
+        _xifexpression = _map_2;
+      }
+      final Iterable<ExecutionNode> parentNodes = _xifexpression;
+      final Function2<Sequence,ExecutionNode,Sequence> _function_4 = new Function2<Sequence,ExecutionNode,Sequence>() {
+          public Sequence apply(final Sequence r , final ExecutionNode s) {
+            Sequence _createReactionSequence = ReactionBuilder.this.createReactionSequence(s, r);
+            return _createReactionSequence;
+          }
+        };
+      Sequence _fold = IterableExtensions.<ExecutionNode, Sequence>fold(parentNodes, null, _function_4);
+      execState.setReactSequence(_fold);
+      Sequence _reactSequence = execState.getReactSequence();
+      _reactSequence.setName("react");
+      Sequence _reactSequence_1 = execState.getReactSequence();
+      String _name = state.getName();
+      String _operator_plus = StringExtensions.operator_plus("The reactions of state ", _name);
+      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
+      _reactSequence_1.setComment(_operator_plus_1);
+      Sequence _reactSequence_2 = execState.getReactSequence();
+      return _reactSequence_2;
+    }
+  }
+  
+  public Sequence createReactionSequence(final ExecutionNode state, final Step localStep) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence cycle = _createSequence;
+      cycle.setName("react");
+      EList<Reaction> _reactions = state.getReactions();
+      final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+          public Boolean apply(final Reaction r) {
+            boolean _isTransition = r.isTransition();
+            boolean _operator_not = BooleanExtensions.operator_not(_isTransition);
+            return ((Boolean)_operator_not);
+          }
+        };
+      Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_reactions, _function);
+      List<Reaction> _list = IterableExtensions.<Reaction>toList(_filter);
+      final List<Reaction> localReactions = _list;
+      SexecFactory _factory_1 = this.sexec.factory();
+      Sequence _createSequence_1 = _factory_1.createSequence();
+      Sequence localSteps = _createSequence_1;
+      EList<Step> _steps = localSteps.getSteps();
+      final Function1<Reaction,If> _function_1 = new Function1<Reaction,If>() {
+          public If apply(final Reaction lr) {
+            If _xblockexpression = null;
+            {
+              SexecFactory _factory_2 = ReactionBuilder.this.sexec.factory();
+              If _createIf = _factory_2.createIf();
+              If ifStep = _createIf;
+              Check _check = lr.getCheck();
+              CheckRef _newRef = ReactionBuilder.this.mapping.newRef(_check);
+              ifStep.setCheck(_newRef);
+              Step _effect = lr.getEffect();
+              Call _newCall = ReactionBuilder.this.mapping.newCall(_effect);
+              ifStep.setThenStep(_newCall);
+              _xblockexpression = (ifStep);
+            }
+            return _xblockexpression;
+          }
+        };
+      List<If> _map = ListExtensions.<Reaction, If>map(localReactions, _function_1);
+      _steps.addAll(_map);
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(localStep, null);
+      if (_operator_notEquals) {
+        EList<Step> _steps_1 = localSteps.getSteps();
+        CollectionExtensions.<Step>operator_add(_steps_1, localStep);
+      }
+      EList<Step> _steps_2 = localSteps.getSteps();
+      boolean _isEmpty = _steps_2.isEmpty();
+      if (_isEmpty) {
+        localSteps = null;
+      }
+      EList<Reaction> _reactions_1 = state.getReactions();
+      final Function1<Reaction,Boolean> _function_2 = new Function1<Reaction,Boolean>() {
+          public Boolean apply(final Reaction r_1) {
+            boolean _isTransition_1 = r_1.isTransition();
+            return ((Boolean)_isTransition_1);
+          }
+        };
+      Iterable<Reaction> _filter_1 = IterableExtensions.<Reaction>filter(_reactions_1, _function_2);
+      List<Reaction> _list_1 = IterableExtensions.<Reaction>toList(_filter_1);
+      final List<Reaction> transitionReactions = _list_1;
+      Iterable<Reaction> _reverseView = ListExtensions.<Reaction>reverseView(transitionReactions);
+      final Function2<Step,Reaction,Step> _function_3 = new Function2<Step,Reaction,Step>() {
+          public Step apply(final Step s , final Reaction reaction) {
+            Step _xblockexpression_1 = null;
+            {
+              SexecFactory _factory_3 = ReactionBuilder.this.sexec.factory();
+              If _createIf_1 = _factory_3.createIf();
+              If ifStep_1 = _createIf_1;
+              Check _check_1 = reaction.getCheck();
+              CheckRef _newRef_1 = ReactionBuilder.this.mapping.newRef(_check_1);
+              ifStep_1.setCheck(_newRef_1);
+              Step _effect_1 = reaction.getEffect();
+              Call _newCall_1 = ReactionBuilder.this.mapping.newCall(_effect_1);
+              ifStep_1.setThenStep(_newCall_1);
+              ifStep_1.setElseStep(s);
+              _xblockexpression_1 = (((Step) ifStep_1));
+            }
+            return _xblockexpression_1;
+          }
+        };
+      Step _fold = IterableExtensions.<Reaction, Step>fold(_reverseView, ((Step) localSteps), _function_3);
+      final Step transitionStep = _fold;
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(transitionStep, null);
+      if (_operator_notEquals_1) {
+        EList<Step> _steps_3 = cycle.getSteps();
+        _steps_3.add(transitionStep);
+      } else {
+        boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(localSteps, null);
+        if (_operator_notEquals_2) {
+          EList<Step> _steps_4 = cycle.getSteps();
+          _steps_4.add(localSteps);
+        }
+      }
+      return cycle;
+    }
+  }
+  
+  public ExecutionFlow defineEntryReactions(final Statechart statechart, final ExecutionFlow r) {
+    {
+      Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
+      final Function1<Entry,Boolean> _function = new Function1<Entry,Boolean>() {
+          public Boolean apply(final Entry e) {
+            Boolean _defineReaction = ReactionBuilder.this.defineReaction(e);
+            return _defineReaction;
+          }
+        };
+      IterableExtensions.<Entry>forEach(_allEntries, _function);
+      return r;
+    }
+  }
+  
+  public Boolean defineReaction(final Entry e) {
+    Boolean _xblockexpression = null;
+    {
+      ExecutionEntry _create = this.mapping.create(e);
+      final ExecutionEntry execEntry = _create;
+      Sequence _reactSequence = execEntry.getReactSequence();
+      final Sequence seq = _reactSequence;
+      State _target = this.sgraph.target(e);
+      ExecutionState _create_1 = this.mapping.create(_target);
+      final ExecutionState target = _create_1;
+      boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+      if (_isAddTraceSteps) {
+        EList<Step> _steps = seq.getSteps();
+        TraceNodeExecuted _newTraceNodeExecuted = this.trace.newTraceNodeExecuted(execEntry);
+        _steps.add(0, _newTraceNodeExecuted);
+      }
+      Boolean _xifexpression = null;
+      EntryKind _kind = e.getKind();
+      boolean _operator_equals = ObjectExtensions.operator_equals(_kind, EntryKind.INITIAL);
+      if (_operator_equals) {
+        Boolean _xifexpression_1 = null;
+        boolean _operator_and = false;
+        boolean _operator_notEquals = ObjectExtensions.operator_notEquals(target, null);
+        if (!_operator_notEquals) {
+          _operator_and = false;
+        } else {
+          Sequence _enterSequence = target.getEnterSequence();
+          boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+          _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+        }
+        if (_operator_and) {
+          boolean _xblockexpression_1 = false;
+          {
+            boolean _isAddTraceSteps_1 = this.trace.isAddTraceSteps();
+            if (_isAddTraceSteps_1) {
+              EList<Step> _steps_1 = seq.getSteps();
+              EList<Transition> _outgoingTransitions = e.getOutgoingTransitions();
+              Transition _get = _outgoingTransitions.get(0);
+              Reaction _create_2 = this.mapping.create(_get);
+              ReactionFired _newTraceReactionFired = this.trace.newTraceReactionFired(_create_2);
+              CollectionExtensions.<Step>operator_add(_steps_1, _newTraceReactionFired);
+            }
+            EList<Step> _steps_2 = seq.getSteps();
+            Sequence _enterSequence_1 = target.getEnterSequence();
+            Call _newCall = this.mapping.newCall(_enterSequence_1);
+            boolean _operator_add = CollectionExtensions.<Step>operator_add(_steps_2, _newCall);
+            _xblockexpression_1 = (_operator_add);
+          }
+          _xifexpression_1 = _xblockexpression_1;
+        }
+        _xifexpression = _xifexpression_1;
+      } else {
+        boolean _xifexpression_2 = false;
+        EntryKind _kind_1 = e.getKind();
+        boolean _operator_equals_1 = ObjectExtensions.operator_equals(_kind_1, EntryKind.SHALLOW_HISTORY);
+        if (_operator_equals_1) {
+          boolean _xblockexpression_2 = false;
+          {
+            SexecFactory _factory = this.sexec.factory();
+            HistoryEntry _createHistoryEntry = _factory.createHistoryEntry();
+            final HistoryEntry entryStep = _createHistoryEntry;
+            entryStep.setName("HistoryEntry");
+            entryStep.setComment("Enter the region with shallow history");
+            entryStep.setDeep(false);
+            EObject _eContainer = e.eContainer();
+            ExecutionRegion _create_3 = this.mapping.create(((Region) _eContainer));
+            entryStep.setRegion(_create_3);
+            boolean _operator_and_1 = false;
+            boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(target, null);
+            if (!_operator_notEquals_2) {
+              _operator_and_1 = false;
+            } else {
+              Sequence _enterSequence_2 = target.getEnterSequence();
+              boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(_enterSequence_2, null);
+              _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_2, _operator_notEquals_3);
+            }
+            if (_operator_and_1) {
+              {
+                boolean _isAddTraceSteps_2 = this.trace.isAddTraceSteps();
+                if (_isAddTraceSteps_2) {
+                  EList<Step> _steps_3 = seq.getSteps();
+                  EList<Transition> _outgoingTransitions_1 = e.getOutgoingTransitions();
+                  Transition _get_1 = _outgoingTransitions_1.get(0);
+                  Reaction _create_4 = this.mapping.create(_get_1);
+                  ReactionFired _newTraceReactionFired_1 = this.trace.newTraceReactionFired(_create_4);
+                  CollectionExtensions.<Step>operator_add(_steps_3, _newTraceReactionFired_1);
+                }
+                Sequence _enterSequence_3 = target.getEnterSequence();
+                Call _newCall_1 = this.mapping.newCall(_enterSequence_3);
+                entryStep.setInitialStep(_newCall_1);
+              }
+            }
+            EObject _eContainer_1 = e.eContainer();
+            ExecutionRegion _create_5 = this.mapping.create(((Region) _eContainer_1));
+            Sequence _shallowEnterSequence = _create_5.getShallowEnterSequence();
+            Call _newCall_2 = this.mapping.newCall(_shallowEnterSequence);
+            entryStep.setHistoryStep(_newCall_2);
+            EList<Step> _steps_4 = seq.getSteps();
+            boolean _operator_add_1 = CollectionExtensions.<Step>operator_add(_steps_4, entryStep);
+            _xblockexpression_2 = (_operator_add_1);
+          }
+          _xifexpression_2 = _xblockexpression_2;
+        } else {
+          Boolean _xifexpression_3 = null;
+          EntryKind _kind_2 = e.getKind();
+          boolean _operator_equals_2 = ObjectExtensions.operator_equals(_kind_2, EntryKind.DEEP_HISTORY);
+          if (_operator_equals_2) {
+            boolean _xblockexpression_3 = false;
+            {
+              SexecFactory _factory_1 = this.sexec.factory();
+              HistoryEntry _createHistoryEntry_1 = _factory_1.createHistoryEntry();
+              final HistoryEntry entryStep_1 = _createHistoryEntry_1;
+              entryStep_1.setName("HistoryEntry");
+              entryStep_1.setComment("Enter the region with deep history");
+              EObject _eContainer_2 = e.eContainer();
+              ExecutionRegion _create_6 = this.mapping.create(((Region) _eContainer_2));
+              entryStep_1.setRegion(_create_6);
+              entryStep_1.setDeep(true);
+              boolean _operator_and_2 = false;
+              boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(target, null);
+              if (!_operator_notEquals_4) {
+                _operator_and_2 = false;
+              } else {
+                Sequence _enterSequence_4 = target.getEnterSequence();
+                boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(_enterSequence_4, null);
+                _operator_and_2 = BooleanExtensions.operator_and(_operator_notEquals_4, _operator_notEquals_5);
+              }
+              if (_operator_and_2) {
+                {
+                  boolean _isAddTraceSteps_3 = this.trace.isAddTraceSteps();
+                  if (_isAddTraceSteps_3) {
+                    EList<Step> _steps_5 = seq.getSteps();
+                    EList<Transition> _outgoingTransitions_2 = e.getOutgoingTransitions();
+                    Transition _get_2 = _outgoingTransitions_2.get(0);
+                    Reaction _create_7 = this.mapping.create(_get_2);
+                    ReactionFired _newTraceReactionFired_2 = this.trace.newTraceReactionFired(_create_7);
+                    CollectionExtensions.<Step>operator_add(_steps_5, _newTraceReactionFired_2);
+                  }
+                  Sequence _enterSequence_5 = target.getEnterSequence();
+                  Call _newCall_3 = this.mapping.newCall(_enterSequence_5);
+                  entryStep_1.setInitialStep(_newCall_3);
+                }
+              }
+              EObject _eContainer_3 = e.eContainer();
+              ExecutionRegion _create_8 = this.mapping.create(((Region) _eContainer_3));
+              Sequence _deepEnterSequence = _create_8.getDeepEnterSequence();
+              Call _newCall_4 = this.mapping.newCall(_deepEnterSequence);
+              entryStep_1.setHistoryStep(_newCall_4);
+              EList<Step> _steps_6 = seq.getSteps();
+              boolean _operator_add_2 = CollectionExtensions.<Step>operator_add(_steps_6, entryStep_1);
+              _xblockexpression_3 = (_operator_add_2);
+            }
+            _xifexpression_3 = _xblockexpression_3;
+          }
+          _xifexpression_2 = _xifexpression_3;
+        }
+        _xifexpression = _xifexpression_2;
+      }
+      _xblockexpression = (_xifexpression);
+    }
+    return _xblockexpression;
+  }
+}

+ 821 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java

@@ -0,0 +1,821 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.EnterState;
+import org.yakindu.sct.model.sexec.Execution;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExitState;
+import org.yakindu.sct.model.sexec.SaveHistory;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateSwitch;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TraceStateEntered;
+import org.yakindu.sct.model.sexec.TraceStateExited;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StextExtensions;
+import org.yakindu.sct.model.sexec.transformation.TraceExtensions;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Variable;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.AssignmentExpression;
+import org.yakindu.sct.model.stext.stext.AssignmentOperator;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class SequenceBuilder {
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StextExtensions stext;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private TraceExtensions trace;
+  
+  @Inject
+  @Named("ADD_TRACES")
+  private boolean _addTraceSteps;
+  
+  public void defineDeepEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineDeepEnterSequence(r);
+    }
+  }
+  
+  public void defineDeepEnterSequence(final State s) {
+    EList<Region> _regions = s.getRegions();
+    for (final Region r : _regions) {
+      this.defineDeepEnterSequence(r);
+    }
+  }
+  
+  public void defineDeepEnterSequence(final Region r) {
+    {
+      EList<Vertex> _vertices = r.getVertices();
+      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
+      for (final State s : _filter) {
+        this.defineDeepEnterSequence(s);
+      }
+      boolean _requireDeepHistory = this.sgraph.requireDeepHistory(r);
+      boolean _operator_not = BooleanExtensions.operator_not(_requireDeepHistory);
+      if (_operator_not) {
+        return;
+      }
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("deepEnterSequence");
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("deep enterSequence with history in child ", _name);
+      seq.setComment(_operator_plus);
+      EList<Step> _steps = seq.getSteps();
+      StateSwitch _defineDeepHistorySwitch = this.defineDeepHistorySwitch(r);
+      CollectionExtensions.<Step>operator_add(_steps, _defineDeepHistorySwitch);
+      execRegion.setDeepEnterSequence(seq);
+    }
+  }
+  
+  public StateSwitch defineDeepHistorySwitch(final Region r) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory.createStateSwitch();
+      final StateSwitch sSwitch = _createStateSwitch;
+      StateVector _stateVector = execRegion.getStateVector();
+      int _offset = _stateVector.getOffset();
+      sSwitch.setStateConfigurationIdx(_offset);
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Handle deep history entry of ", _name);
+      sSwitch.setComment(_operator_plus);
+      sSwitch.setHistoryRegion(execRegion);
+      EList<Vertex> _vertices = r.getVertices();
+      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
+      for (final State child : _filter) {
+        ArrayList<RegularState> _newArrayList = CollectionLiterals.<RegularState>newArrayList();
+        List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(child, _newArrayList);
+        final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+            public Boolean apply(final RegularState c) {
+              ExecutionState _create_1 = SequenceBuilder.this.mapping.create(c);
+              StateVector _stateVector_1 = _create_1.getStateVector();
+              int _offset_1 = _stateVector_1.getOffset();
+              int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+              boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
+              return ((Boolean)_operator_equals);
+            }
+          };
+        Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+        for (final RegularState childLeaf : _filter_1) {
+          {
+            ExecutionState _create_2 = this.mapping.create(child);
+            final ExecutionState execChild = _create_2;
+            SexecFactory _factory_1 = this.sexec.factory();
+            Sequence _createSequence = _factory_1.createSequence();
+            final Sequence seq = _createSequence;
+            seq.setName("enterSequence");
+            String _name_1 = child.getName();
+            String _operator_plus_1 = StringExtensions.operator_plus("enterSequence with history in child ", _name_1);
+            String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " for leaf ");
+            String _name_2 = childLeaf.getName();
+            String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, _name_2);
+            seq.setComment(_operator_plus_3);
+            boolean _isLeaf = execChild.isLeaf();
+            if (_isLeaf) {
+              EList<Step> _steps = seq.getSteps();
+              Sequence _enterSequence = execChild.getEnterSequence();
+              Call _newCall = this.mapping.newCall(_enterSequence);
+              CollectionExtensions.<Step>operator_add(_steps, _newCall);
+            } else {
+              {
+                Step _entryAction = execChild.getEntryAction();
+                boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+                if (_operator_notEquals) {
+                  EList<Step> _steps_1 = seq.getSteps();
+                  Step _entryAction_1 = execChild.getEntryAction();
+                  Call _newCall_1 = this.mapping.newCall(_entryAction_1);
+                  CollectionExtensions.<Step>operator_add(_steps_1, _newCall_1);
+                }
+                boolean _isAddTraceSteps = this.trace.isAddTraceSteps();
+                if (_isAddTraceSteps) {
+                  EList<Step> _steps_2 = seq.getSteps();
+                  TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execChild);
+                  CollectionExtensions.<Step>operator_add(_steps_2, _newTraceStateEntered);
+                }
+                EList<Region> _regions = child.getRegions();
+                for (final Region childRegion : _regions) {
+                  EList<Step> _steps_3 = seq.getSteps();
+                  ExecutionRegion _create_3 = this.mapping.create(childRegion);
+                  Sequence _deepEnterSequence = _create_3.getDeepEnterSequence();
+                  Call _newCall_2 = this.mapping.newCall(_deepEnterSequence);
+                  CollectionExtensions.<Step>operator_add(_steps_3, _newCall_2);
+                }
+              }
+            }
+            EList<StateCase> _cases = sSwitch.getCases();
+            ExecutionState _create_4 = this.mapping.create(childLeaf);
+            StateCase _newCase = this.sexec.newCase(_create_4, seq);
+            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+          }
+        }
+      }
+      return sSwitch;
+    }
+  }
+  
+  public void defineShallowEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(sc);
+    Iterable<Region> _filter = IterableExtensions.<Region>filter(_allContentsIterable, org.yakindu.sct.model.sgraph.Region.class);
+    for (final Region r : _filter) {
+      boolean _requireShallowHistory = this.sgraph.requireShallowHistory(r);
+      if (_requireShallowHistory) {
+        {
+          ExecutionRegion _create = this.mapping.create(r);
+          final ExecutionRegion execRegion = _create;
+          SexecFactory _factory = this.sexec.factory();
+          Sequence _createSequence = _factory.createSequence();
+          final Sequence seq = _createSequence;
+          seq.setName("shallowEnterSequence");
+          String _name = r.getName();
+          String _operator_plus = StringExtensions.operator_plus("shallow enterSequence with history in child ", _name);
+          seq.setComment(_operator_plus);
+          EList<Step> _steps = seq.getSteps();
+          StateSwitch _defineShallowHistorySwitch = this.defineShallowHistorySwitch(r);
+          CollectionExtensions.<Step>operator_add(_steps, _defineShallowHistorySwitch);
+          execRegion.setShallowEnterSequence(seq);
+        }
+      }
+    }
+  }
+  
+  public StateSwitch defineShallowHistorySwitch(final Region r) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory.createStateSwitch();
+      final StateSwitch sSwitch = _createStateSwitch;
+      StateVector _stateVector = execRegion.getStateVector();
+      int _offset = _stateVector.getOffset();
+      sSwitch.setStateConfigurationIdx(_offset);
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Handle shallow history entry of ", _name);
+      sSwitch.setComment(_operator_plus);
+      ExecutionRegion _create_1 = this.mapping.create(r);
+      sSwitch.setHistoryRegion(_create_1);
+      EList<Vertex> _vertices = r.getVertices();
+      Iterable<State> _filter = IterableExtensions.<State>filter(_vertices, org.yakindu.sct.model.sgraph.State.class);
+      for (final State child : _filter) {
+        {
+          ExecutionState _create_2 = this.mapping.create(child);
+          final ExecutionState execChild = _create_2;
+          ArrayList<RegularState> _newArrayList = CollectionLiterals.<RegularState>newArrayList();
+          List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(child, _newArrayList);
+          final Function1<RegularState,Boolean> _function = new Function1<RegularState,Boolean>() {
+              public Boolean apply(final RegularState c) {
+                ExecutionState _create_3 = SequenceBuilder.this.mapping.create(c);
+                StateVector _stateVector_1 = _create_3.getStateVector();
+                int _offset_1 = _stateVector_1.getOffset();
+                int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+                boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_offset_1), ((Integer)_stateConfigurationIdx));
+                return ((Boolean)_operator_equals);
+              }
+            };
+          Iterable<RegularState> _filter_1 = IterableExtensions.<RegularState>filter(_collectLeafStates, _function);
+          for (final RegularState childLeaf : _filter_1) {
+            EList<StateCase> _cases = sSwitch.getCases();
+            ExecutionState _create_4 = this.mapping.create(childLeaf);
+            Sequence _enterSequence = execChild.getEnterSequence();
+            Call _newCall = this.mapping.newCall(_enterSequence);
+            StateCase _newCase = this.sexec.newCase(_create_4, _newCall);
+            CollectionExtensions.<StateCase>operator_add(_cases, _newCase);
+          }
+        }
+      }
+      return sSwitch;
+    }
+  }
+  
+  public void defineStateEnterSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineStateEnterSequence(r);
+    }
+  }
+  
+  protected void _defineStateEnterSequence(final Region r) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execState = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("enterSequence");
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default enter sequence for region ", _name);
+      seq.setComment(_operator_plus);
+      EList<Vertex> _vertices = r.getVertices();
+      for (final Vertex s : _vertices) {
+        this.defineStateEnterSequence(s);
+      }
+      Entry _entry = this.sgraph.entry(r);
+      ExecutionEntry _create_1 = this.mapping==null?(ExecutionEntry)null:this.mapping.create(_entry);
+      final ExecutionEntry entryNode = _create_1;
+      boolean _operator_and = false;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(entryNode, null);
+      if (!_operator_notEquals) {
+        _operator_and = false;
+      } else {
+        Sequence _reactSequence = entryNode.getReactSequence();
+        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_reactSequence, null);
+        _operator_and = BooleanExtensions.operator_and(_operator_notEquals, _operator_notEquals_1);
+      }
+      if (_operator_and) {
+        EList<Step> _steps = seq.getSteps();
+        Sequence _reactSequence_1 = entryNode.getReactSequence();
+        Call _newCall = this.mapping.newCall(_reactSequence_1);
+        _steps.add(_newCall);
+      }
+      execState.setEnterSequence(seq);
+    }
+  }
+  
+  protected void _defineStateEnterSequence(final Vertex v) {
+  }
+  
+  protected void _defineStateEnterSequence(final FinalState state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState execState = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("enterSequence");
+      String _name = state.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default enter sequence for state ", _name);
+      seq.setComment(_operator_plus);
+      Step _entryAction = execState.getEntryAction();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+      if (_operator_notEquals) {
+        EList<Step> _steps = seq.getSteps();
+        Step _entryAction_1 = execState.getEntryAction();
+        Call _newCall = this.mapping.newCall(_entryAction_1);
+        _steps.add(_newCall);
+      }
+      if (this._addTraceSteps) {
+        EList<Step> _steps_1 = seq.getSteps();
+        TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execState);
+        CollectionExtensions.<Step>operator_add(_steps_1, _newTraceStateEntered);
+      }
+      EList<Step> _steps_2 = seq.getSteps();
+      EnterState _newEnterStateStep = this.sexec.newEnterStateStep(execState);
+      CollectionExtensions.<Step>operator_add(_steps_2, _newEnterStateStep);
+      execState.setEnterSequence(seq);
+    }
+  }
+  
+  protected void _defineStateEnterSequence(final State state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState execState = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("enterSequence");
+      String _name = state.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default enter sequence for state ", _name);
+      seq.setComment(_operator_plus);
+      Step _entryAction = execState.getEntryAction();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_entryAction, null);
+      if (_operator_notEquals) {
+        EList<Step> _steps = seq.getSteps();
+        Step _entryAction_1 = execState.getEntryAction();
+        Call _newCall = this.mapping.newCall(_entryAction_1);
+        _steps.add(_newCall);
+      }
+      if (this._addTraceSteps) {
+        EList<Step> _steps_1 = seq.getSteps();
+        TraceStateEntered _newTraceStateEntered = this.trace.newTraceStateEntered(execState);
+        CollectionExtensions.<Step>operator_add(_steps_1, _newTraceStateEntered);
+      }
+      boolean _isLeaf = execState.isLeaf();
+      if (_isLeaf) {
+        EList<Step> _steps_2 = seq.getSteps();
+        EnterState _newEnterStateStep = this.sexec.newEnterStateStep(execState);
+        CollectionExtensions.<Step>operator_add(_steps_2, _newEnterStateStep);
+      } else {
+        EList<Region> _regions = state.getRegions();
+        for (final Region r : _regions) {
+          {
+            this.defineStateEnterSequence(r);
+            ExecutionRegion _create_1 = this.mapping.create(r);
+            final ExecutionRegion execRegion = _create_1;
+            Sequence _enterSequence = execRegion.getEnterSequence();
+            boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+            if (_operator_notEquals_1) {
+              EList<Step> _steps_3 = seq.getSteps();
+              Sequence _enterSequence_1 = execRegion.getEnterSequence();
+              Call _newCall_1 = this.mapping.newCall(_enterSequence_1);
+              _steps_3.add(_newCall_1);
+            }
+          }
+        }
+      }
+      execState.setEnterSequence(seq);
+    }
+  }
+  
+  public void defineStateExitSequences(final ExecutionFlow flow, final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      this.defineStateExitSequence(r);
+    }
+  }
+  
+  protected void _defineStateExitSequence(final Region r) {
+    {
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion execRegion = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("exitSequence");
+      String _name = r.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default exit sequence for region ", _name);
+      seq.setComment(_operator_plus);
+      EList<Vertex> _vertices = r.getVertices();
+      for (final Vertex s : _vertices) {
+        this.defineStateExitSequence(s);
+      }
+      StateVector _historyVector = execRegion.getHistoryVector();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_historyVector, null);
+      if (_operator_notEquals) {
+        EList<Step> _steps = seq.getSteps();
+        SaveHistory _newSaveHistory = this.sexec.newSaveHistory(execRegion);
+        CollectionExtensions.<Step>operator_add(_steps, _newSaveHistory);
+      }
+      ArrayList<RegularState> _arrayList = new ArrayList<RegularState>();
+      List<RegularState> _collectLeafStates = this.sgraph.collectLeafStates(r, _arrayList);
+      final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+          public ExecutionState apply(final RegularState rs) {
+            ExecutionState _create_1 = SequenceBuilder.this.mapping.create(rs);
+            return _create_1;
+          }
+        };
+      List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(_collectLeafStates, _function);
+      final Iterable<ExecutionState> leafStates = _map;
+      StateVector _stateVector = execRegion.getStateVector();
+      final StateVector sVector = _stateVector;
+      int _offset = sVector.getOffset();
+      int _offset_1 = sVector.getOffset();
+      int _size = sVector.getSize();
+      int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)_offset_1), ((Integer)_size));
+      int _operator_minus = IntegerExtensions.operator_minus(((Integer)_operator_plus_1), ((Integer)1));
+      Iterable<Integer> _operator_upTo = IntegerExtensions.operator_upTo(((Integer)_offset), ((Integer)_operator_minus));
+      for (final Integer i : _operator_upTo) {
+        {
+          StateSwitch _defineExitSwitch = this.defineExitSwitch(execRegion, leafStates, i);
+          final StateSwitch sSwitch = _defineExitSwitch;
+          EList<Step> _steps_1 = seq.getSteps();
+          _steps_1.add(sSwitch);
+        }
+      }
+      execRegion.setExitSequence(seq);
+    }
+  }
+  
+  protected void _defineStateExitSequence(final Vertex v) {
+  }
+  
+  protected void _defineStateExitSequence(final FinalState s) {
+    {
+      ExecutionState _create = this.mapping.create(s);
+      final ExecutionState execState = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("exitSequence");
+      seq.setComment("Default exit sequence for final state.");
+      EList<Step> _steps = seq.getSteps();
+      ExitState _newExitStateStep = this.sexec.newExitStateStep(execState);
+      CollectionExtensions.<Step>operator_add(_steps, _newExitStateStep);
+      if (this._addTraceSteps) {
+        EList<Step> _steps_1 = seq.getSteps();
+        TraceStateExited _newTraceStateExited = this.trace.newTraceStateExited(execState);
+        CollectionExtensions.<Step>operator_add(_steps_1, _newTraceStateExited);
+      }
+      execState.setExitSequence(seq);
+    }
+  }
+  
+  protected void _defineStateExitSequence(final State state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState execState = _create;
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence seq = _createSequence;
+      seq.setName("exitSequence");
+      String _name = state.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default exit sequence for state ", _name);
+      seq.setComment(_operator_plus);
+      boolean _isLeaf = execState.isLeaf();
+      if (_isLeaf) {
+        EList<Step> _steps = seq.getSteps();
+        ExitState _newExitStateStep = this.sexec.newExitStateStep(execState);
+        CollectionExtensions.<Step>operator_add(_steps, _newExitStateStep);
+      } else {
+        EList<Region> _regions = state.getRegions();
+        for (final Region r : _regions) {
+          {
+            this.defineStateExitSequence(r);
+            ExecutionRegion _create_1 = this.mapping.create(r);
+            final ExecutionRegion execRegion = _create_1;
+            Sequence _exitSequence = execRegion.getExitSequence();
+            boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
+            if (_operator_notEquals) {
+              EList<Step> _steps_1 = seq.getSteps();
+              Sequence _exitSequence_1 = execRegion.getExitSequence();
+              Call _newCall = this.mapping.newCall(_exitSequence_1);
+              _steps_1.add(_newCall);
+            }
+          }
+        }
+      }
+      Step _exitAction = execState.getExitAction();
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_exitAction, null);
+      if (_operator_notEquals_1) {
+        EList<Step> _steps_2 = seq.getSteps();
+        Step _exitAction_1 = execState.getExitAction();
+        Call _newCall_1 = this.mapping.newCall(_exitAction_1);
+        _steps_2.add(_newCall_1);
+      }
+      if (this._addTraceSteps) {
+        EList<Step> _steps_3 = seq.getSteps();
+        TraceStateExited _newTraceStateExited = this.trace.newTraceStateExited(execState);
+        CollectionExtensions.<Step>operator_add(_steps_3, _newTraceStateExited);
+      }
+      execState.setExitSequence(seq);
+    }
+  }
+  
+  public StateSwitch defineExitSwitch(final ExecutionRegion region, final Iterable<ExecutionState> leafStates, final int pos) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      StateSwitch _createStateSwitch = _factory.createStateSwitch();
+      StateSwitch sSwitch = _createStateSwitch;
+      sSwitch.setStateConfigurationIdx(pos);
+      String _name = region.getName();
+      String _operator_plus = StringExtensions.operator_plus("Handle exit of all possible states (of ", _name);
+      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ") at position ");
+      int _stateConfigurationIdx = sSwitch.getStateConfigurationIdx();
+      String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ((Integer)_stateConfigurationIdx));
+      String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "...");
+      sSwitch.setComment(_operator_plus_3);
+      final Function1<ExecutionState,Boolean> _function = new Function1<ExecutionState,Boolean>() {
+          public Boolean apply(final ExecutionState rs) {
+            boolean _operator_and = false;
+            StateVector _stateVector = rs.getStateVector();
+            int _size = _stateVector.getSize();
+            boolean _operator_equals = ObjectExtensions.operator_equals(((Integer)_size), ((Integer)1));
+            if (!_operator_equals) {
+              _operator_and = false;
+            } else {
+              StateVector _stateVector_1 = rs.getStateVector();
+              int _offset = _stateVector_1.getOffset();
+              boolean _operator_equals_1 = ObjectExtensions.operator_equals(((Integer)_offset), ((Integer)pos));
+              _operator_and = BooleanExtensions.operator_and(_operator_equals, _operator_equals_1);
+            }
+            return ((Boolean)_operator_and);
+          }
+        };
+      Iterable<ExecutionState> _filter = IterableExtensions.<ExecutionState>filter(leafStates, _function);
+      final Iterable<ExecutionState> posStates = _filter;
+      for (final ExecutionState s : posStates) {
+        {
+          SexecFactory _factory_1 = this.sexec.factory();
+          Sequence _createSequence = _factory_1.createSequence();
+          final Sequence caseSeq = _createSequence;
+          ArrayList<ExecutionScope> _parentScopes = this.sexec.parentScopes(s);
+          final ArrayList<ExecutionScope> exitScopes = _parentScopes;
+          ArrayList<ExecutionScope> _parentScopes_1 = this.sexec.parentScopes(region);
+          exitScopes.removeAll(_parentScopes_1);
+          exitScopes.remove(s);
+          final Function2<Sequence,ExecutionScope,Sequence> _function_1 = new Function2<Sequence,ExecutionScope,Sequence>() {
+              public Sequence apply(final Sequence cs , final ExecutionScope exitScope) {
+                Sequence _xblockexpression = null;
+                {
+                  boolean _operator_and_1 = false;
+                  if (!(exitScope instanceof org.yakindu.sct.model.sexec.ExecutionRegion)) {
+                    _operator_and_1 = false;
+                  } else {
+                    StateVector _historyVector = ((ExecutionRegion) exitScope).getHistoryVector();
+                    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_historyVector, null);
+                    _operator_and_1 = BooleanExtensions.operator_and((exitScope instanceof org.yakindu.sct.model.sexec.ExecutionRegion), _operator_notEquals);
+                  }
+                  if (_operator_and_1) {
+                    {
+                      final ExecutionRegion execRegion = ((ExecutionRegion) exitScope);
+                      EList<Step> _steps = cs.getSteps();
+                      SaveHistory _newSaveHistory = SequenceBuilder.this.sexec.newSaveHistory(execRegion);
+                      CollectionExtensions.<Step>operator_add(_steps, _newSaveHistory);
+                    }
+                  }
+                  _xblockexpression = (cs);
+                }
+                return _xblockexpression;
+              }
+            };
+          IterableExtensions.<ExecutionScope, Sequence>fold(exitScopes, caseSeq, _function_1);
+          Sequence _exitSequence = s.getExitSequence();
+          boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_exitSequence, null);
+          if (_operator_notEquals_1) {
+            EList<Step> _steps_1 = caseSeq.getSteps();
+            Sequence _exitSequence_1 = s.getExitSequence();
+            Call _newCall = this.mapping.newCall(_exitSequence_1);
+            CollectionExtensions.<Step>operator_add(_steps_1, _newCall);
+          }
+          final Function2<Sequence,ExecutionScope,Sequence> _function_2 = new Function2<Sequence,ExecutionScope,Sequence>() {
+              public Sequence apply(final Sequence cs_1 , final ExecutionScope exitScope_1) {
+                Sequence _xblockexpression_1 = null;
+                {
+                  boolean _operator_and_2 = false;
+                  if (!(exitScope_1 instanceof org.yakindu.sct.model.sexec.ExecutionState)) {
+                    _operator_and_2 = false;
+                  } else {
+                    StateVector _stateVector_2 = s.getStateVector();
+                    int _last = SequenceBuilder.this.sexec.last(_stateVector_2);
+                    StateVector _stateVector_3 = exitScope_1.getStateVector();
+                    int _last_1 = SequenceBuilder.this.sexec.last(_stateVector_3);
+                    boolean _operator_equals_2 = ObjectExtensions.operator_equals(((Integer)_last), ((Integer)_last_1));
+                    _operator_and_2 = BooleanExtensions.operator_and((exitScope_1 instanceof org.yakindu.sct.model.sexec.ExecutionState), _operator_equals_2);
+                  }
+                  if (_operator_and_2) {
+                    {
+                      final ExecutionState execState = ((ExecutionState) exitScope_1);
+                      Step _exitAction = execState.getExitAction();
+                      boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_exitAction, null);
+                      if (_operator_notEquals_2) {
+                        EList<Step> _steps_2 = cs_1.getSteps();
+                        Step _exitAction_1 = execState.getExitAction();
+                        Call _newCall_1 = SequenceBuilder.this.mapping.newCall(_exitAction_1);
+                        _steps_2.add(_newCall_1);
+                      }
+                      if (SequenceBuilder.this._addTraceSteps) {
+                        EList<Step> _steps_3 = cs_1.getSteps();
+                        TraceStateExited _newTraceStateExited = SequenceBuilder.this.trace.newTraceStateExited(execState);
+                        _steps_3.add(_newTraceStateExited);
+                      }
+                    }
+                  }
+                  _xblockexpression_1 = (cs_1);
+                }
+                return _xblockexpression_1;
+              }
+            };
+          IterableExtensions.<ExecutionScope, Sequence>fold(exitScopes, caseSeq, _function_2);
+          EList<Step> _steps_4 = caseSeq.getSteps();
+          boolean _isEmpty = _steps_4.isEmpty();
+          boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+          if (_operator_not) {
+            EList<StateCase> _cases = sSwitch.getCases();
+            StateCase _newCase = this.sexec.newCase(s, caseSeq);
+            _cases.add(_newCase);
+          }
+        }
+      }
+      return sSwitch;
+    }
+  }
+  
+  public Sequence defineStatechartExitSequence(final ExecutionFlow flow, final Statechart sc) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence exitSequence = _createSequence;
+      exitSequence.setName("exit");
+      String _name = sc.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default exit sequence for statechart ", _name);
+      exitSequence.setComment(_operator_plus);
+      EList<Region> _regions = sc.getRegions();
+      for (final Region r : _regions) {
+        {
+          ExecutionRegion _create = this.mapping.create(r);
+          final ExecutionRegion execRegion = _create;
+          Sequence _exitSequence = execRegion.getExitSequence();
+          boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_exitSequence, null);
+          if (_operator_notEquals) {
+            EList<Step> _steps = exitSequence.getSteps();
+            Sequence _exitSequence_1 = execRegion.getExitSequence();
+            Call _newCall = this.mapping.newCall(_exitSequence_1);
+            _steps.add(_newCall);
+          }
+        }
+      }
+      Step _exitAction = flow.getExitAction();
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_exitAction, null);
+      if (_operator_notEquals_1) {
+        EList<Step> _steps_1 = exitSequence.getSteps();
+        Step _exitAction_1 = flow.getExitAction();
+        Call _newCall_1 = this.mapping.newCall(_exitAction_1);
+        _steps_1.add(_newCall_1);
+      }
+      flow.setExitSequence(exitSequence);
+      return exitSequence;
+    }
+  }
+  
+  public Sequence defineStatechartEnterSequence(final ExecutionFlow flow, final Statechart sc) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Sequence _createSequence = _factory.createSequence();
+      final Sequence enterSequence = _createSequence;
+      enterSequence.setName("enter");
+      String _name = sc.getName();
+      String _operator_plus = StringExtensions.operator_plus("Default enter sequence for statechart ", _name);
+      enterSequence.setComment(_operator_plus);
+      EList<Scope> _scopes = sc.getScopes();
+      final Function1<Scope,EList<Variable>> _function = new Function1<Scope,EList<Variable>>() {
+          public EList<Variable> apply(final Scope s) {
+            EList<Variable> _variables = s.getVariables();
+            return _variables;
+          }
+        };
+      List<EList<Variable>> _map = ListExtensions.<Scope, EList<Variable>>map(_scopes, _function);
+      Iterable<Variable> _flatten = IterableExtensions.<Variable>flatten(_map);
+      Iterable<VariableDefinition> _filter = IterableExtensions.<VariableDefinition>filter(_flatten, org.yakindu.sct.model.stext.stext.VariableDefinition.class);
+      for (final VariableDefinition vd : _filter) {
+        Expression _initialValue = vd.getInitialValue();
+        boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_initialValue, null);
+        if (_operator_notEquals) {
+          EList<Step> _steps = enterSequence.getSteps();
+          Execution _createInitialization = this.createInitialization(vd);
+          _steps.add(_createInitialization);
+        }
+      }
+      Step _entryAction = flow.getEntryAction();
+      boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(_entryAction, null);
+      if (_operator_notEquals_1) {
+        EList<Step> _steps_1 = enterSequence.getSteps();
+        Step _entryAction_1 = flow.getEntryAction();
+        Call _newCall = this.mapping.newCall(_entryAction_1);
+        _steps_1.add(_newCall);
+      }
+      EList<Region> _regions = sc.getRegions();
+      for (final Region r : _regions) {
+        {
+          ExecutionRegion _create = this.mapping.create(r);
+          final ExecutionRegion execRegion = _create;
+          Sequence _enterSequence = execRegion.getEnterSequence();
+          boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(_enterSequence, null);
+          if (_operator_notEquals_2) {
+            EList<Step> _steps_2 = enterSequence.getSteps();
+            Sequence _enterSequence_1 = execRegion.getEnterSequence();
+            Call _newCall_1 = this.mapping.newCall(_enterSequence_1);
+            _steps_2.add(_newCall_1);
+          }
+        }
+      }
+      flow.setEnterSequence(enterSequence);
+      return enterSequence;
+    }
+  }
+  
+  public Execution createInitialization(final VariableDefinition vd) {
+    {
+      SexecFactory _factory = this.sexec.factory();
+      Execution _createExecution = _factory.createExecution();
+      final Execution execution = _createExecution;
+      StextFactory _factory_1 = this.stext.factory();
+      AssignmentExpression _createAssignmentExpression = _factory_1.createAssignmentExpression();
+      final AssignmentExpression assignment = _createAssignmentExpression;
+      StextFactory _factory_2 = this.stext.factory();
+      ElementReferenceExpression _createElementReferenceExpression = _factory_2.createElementReferenceExpression();
+      final ElementReferenceExpression reference = _createElementReferenceExpression;
+      reference.setReference(vd);
+      assignment.setVarRef(reference);
+      assignment.setOperator(AssignmentOperator.ASSIGN);
+      Expression _initialValue = vd.getInitialValue();
+      Expression _copy = EcoreUtil.<Expression>copy(_initialValue);
+      assignment.setExpression(_copy);
+      execution.setStatement(assignment);
+      return execution;
+    }
+  }
+  
+  public void defineStateEnterSequence(final NamedElement state) {
+    if ((state instanceof FinalState)) {
+      _defineStateEnterSequence((FinalState)state);
+    } else if ((state instanceof State)) {
+      _defineStateEnterSequence((State)state);
+    } else if ((state instanceof Region)) {
+      _defineStateEnterSequence((Region)state);
+    } else if ((state instanceof Vertex)) {
+      _defineStateEnterSequence((Vertex)state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(state).toString());
+    }
+  }
+  
+  public void defineStateExitSequence(final NamedElement s) {
+    if ((s instanceof FinalState)) {
+      _defineStateExitSequence((FinalState)s);
+    } else if ((s instanceof State)) {
+      _defineStateExitSequence((State)s);
+    } else if ((s instanceof Region)) {
+      _defineStateExitSequence((Region)s);
+    } else if ((s instanceof Vertex)) {
+      _defineStateExitSequence((Vertex)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(s).toString());
+    }
+  }
+}

+ 751 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java

@@ -0,0 +1,751 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.util.Strings;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sexec.Call;
+import org.yakindu.sct.model.sexec.Check;
+import org.yakindu.sct.model.sexec.CheckRef;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ScheduleTimeEvent;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.UnscheduleTimeEvent;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sexec.transformation.StextExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Statement;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.AlwaysEvent;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.DefaultEvent;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.EventSpec;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.InterfaceScope;
+import org.yakindu.sct.model.stext.stext.InternalScope;
+import org.yakindu.sct.model.stext.stext.LocalReaction;
+import org.yakindu.sct.model.stext.stext.OnCycleEvent;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.RegularEventSpec;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.TimeEventType;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+@Singleton
+public class SexecElementMapping {
+  
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private StatechartExtensions sce;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  @Inject
+  private StextExtensions stext;
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  private final HashMap<ArrayList<?>,ExecutionFlow> _createCache_create = new HashMap<ArrayList<?>,ExecutionFlow>();
+  
+  public ExecutionFlow create(final Statechart statechart) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(statechart);
+    final ExecutionFlow r;
+    synchronized (_createCache_create) {
+      if (_createCache_create.containsKey(_cacheKey)) {
+        return _createCache_create.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionFlow _createExecutionFlow = _sexecFactory.createExecutionFlow();
+      r = _createExecutionFlow;
+      _createCache_create.put(_cacheKey, r);
+    }
+    {
+      String _name = statechart.getName();
+      r.setName(_name);
+      r.setSourceElement(statechart);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,InterfaceScope> _createCache_create_1 = new HashMap<ArrayList<?>,InterfaceScope>();
+  
+  protected Scope _create(final InterfaceScope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    final InterfaceScope r;
+    synchronized (_createCache_create_1) {
+      if (_createCache_create_1.containsKey(_cacheKey)) {
+        return _createCache_create_1.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InterfaceScope _createInterfaceScope = _stextFactory.createInterfaceScope();
+      r = _createInterfaceScope;
+      _createCache_create_1.put(_cacheKey, r);
+    }
+    String _name = scope.getName();
+    r.setName(_name);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,InternalScope> _createCache_create_2 = new HashMap<ArrayList<?>,InternalScope>();
+  
+  protected Scope _create(final Scope scope) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(scope);
+    final InternalScope r;
+    synchronized (_createCache_create_2) {
+      if (_createCache_create_2.containsKey(_cacheKey)) {
+        return _createCache_create_2.get(_cacheKey);
+      }
+      StextFactory _stextFactory = this.stextFactory();
+      InternalScope _createInternalScope = _stextFactory.createInternalScope();
+      r = _createInternalScope;
+      _createCache_create_2.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,Scope> _createCache_timeEventScope = new HashMap<ArrayList<?>,Scope>();
+  
+  public Scope timeEventScope(final ExecutionFlow flow) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(flow);
+    final Scope r;
+    synchronized (_createCache_timeEventScope) {
+      if (_createCache_timeEventScope.containsKey(_cacheKey)) {
+        return _createCache_timeEventScope.get(_cacheKey);
+      }
+      SGraphFactory _factory = this.sgraph.factory();
+      Scope _createScope = _factory.createScope();
+      r = _createScope;
+      _createCache_timeEventScope.put(_cacheKey, r);
+    }
+    EList<Scope> _scopes = flow.getScopes();
+    _scopes.add(r);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,EventDefinition> _createCache_create_3 = new HashMap<ArrayList<?>,EventDefinition>();
+  
+  public EventDefinition create(final EventDefinition event) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(event);
+    final EventDefinition r;
+    synchronized (_createCache_create_3) {
+      if (_createCache_create_3.containsKey(_cacheKey)) {
+        return _createCache_create_3.get(_cacheKey);
+      }
+      EventDefinition _copy = EcoreUtil.<EventDefinition>copy(event);
+      r = _copy;
+      _createCache_create_3.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,VariableDefinition> _createCache_create_4 = new HashMap<ArrayList<?>,VariableDefinition>();
+  
+  public VariableDefinition create(final VariableDefinition v) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
+    final VariableDefinition r;
+    synchronized (_createCache_create_4) {
+      if (_createCache_create_4.containsKey(_cacheKey)) {
+        return _createCache_create_4.get(_cacheKey);
+      }
+      VariableDefinition _copy = EcoreUtil.<VariableDefinition>copy(v);
+      r = _copy;
+      _createCache_create_4.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,OperationDefinition> _createCache_create_5 = new HashMap<ArrayList<?>,OperationDefinition>();
+  
+  public OperationDefinition create(final OperationDefinition v) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(v);
+    final OperationDefinition r;
+    synchronized (_createCache_create_5) {
+      if (_createCache_create_5.containsKey(_cacheKey)) {
+        return _createCache_create_5.get(_cacheKey);
+      }
+      OperationDefinition _copy = EcoreUtil.<OperationDefinition>copy(v);
+      r = _copy;
+      _createCache_create_5.put(_cacheKey, r);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,ExecutionState> _createCache_create_6 = new HashMap<ArrayList<?>,ExecutionState>();
+  
+  public ExecutionState create(final RegularState state) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(state);
+    final ExecutionState r;
+    synchronized (_createCache_create_6) {
+      if (_createCache_create_6.containsKey(_cacheKey)) {
+        return _createCache_create_6.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionState _createExecutionState = _sexecFactory.createExecutionState();
+      r = _createExecutionState;
+      _createCache_create_6.put(_cacheKey, r);
+    }
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(state, null);
+    if (_operator_notEquals) {
+      {
+        Region _parentRegion = state.getParentRegion();
+        EList<Vertex> _vertices = _parentRegion.getVertices();
+        Iterable<FinalState> _filter = IterableExtensions.<FinalState>filter(_vertices, org.yakindu.sct.model.sgraph.FinalState.class);
+        List<FinalState> _list = IterableExtensions.<FinalState>toList(_filter);
+        int _indexOf = _list.indexOf(state);
+        final int n = _indexOf;
+        String _xifexpression = null;
+        if ((state instanceof org.yakindu.sct.model.sgraph.FinalState)) {
+          String _operator_plus = StringExtensions.operator_plus("_final_", ((Integer)n));
+          _xifexpression = _operator_plus;
+        } else {
+          String _name = state.getName();
+          _xifexpression = _name;
+        }
+        r.setSimpleName(_xifexpression);
+        QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(state);
+        String _string = _fullyQualifiedName.toString();
+        String _replaceAll = _string.replaceAll(" ", "");
+        r.setName(_replaceAll);
+        r.setSourceElement(state);
+      }
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,ExecutionChoice> _createCache_create_7 = new HashMap<ArrayList<?>,ExecutionChoice>();
+  
+  public ExecutionChoice create(final Choice choice) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(choice);
+    final ExecutionChoice r;
+    synchronized (_createCache_create_7) {
+      if (_createCache_create_7.containsKey(_cacheKey)) {
+        return _createCache_create_7.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionChoice _createExecutionChoice = _sexecFactory.createExecutionChoice();
+      r = _createExecutionChoice;
+      _createCache_create_7.put(_cacheKey, r);
+    }
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(choice, null);
+    if (_operator_notEquals) {
+      {
+        Region _parentRegion = choice.getParentRegion();
+        EList<Vertex> _vertices = _parentRegion.getVertices();
+        Iterable<Choice> _filter = IterableExtensions.<Choice>filter(_vertices, org.yakindu.sct.model.sgraph.Choice.class);
+        List<Choice> _list = IterableExtensions.<Choice>toList(_filter);
+        int _indexOf = _list.indexOf(choice);
+        final int n = _indexOf;
+        String _operator_plus = StringExtensions.operator_plus("_choice", ((Integer)n));
+        String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_");
+        r.setSimpleName(_operator_plus_1);
+        QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(choice);
+        String _string = _fullyQualifiedName.toString();
+        String _replaceAll = _string.replaceAll(" ", "");
+        r.setName(_replaceAll);
+        r.setSourceElement(choice);
+        SexecFactory _sexecFactory_1 = this.sexecFactory();
+        Sequence _createSequence = _sexecFactory_1.createSequence();
+        r.setReactSequence(_createSequence);
+      }
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,ExecutionEntry> _createCache_create_8 = new HashMap<ArrayList<?>,ExecutionEntry>();
+  
+  public ExecutionEntry create(final Entry entry) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(entry);
+    final ExecutionEntry r;
+    synchronized (_createCache_create_8) {
+      if (_createCache_create_8.containsKey(_cacheKey)) {
+        return _createCache_create_8.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionEntry _createExecutionEntry = _sexecFactory.createExecutionEntry();
+      r = _createExecutionEntry;
+      _createCache_create_8.put(_cacheKey, r);
+    }
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(entry, null);
+    if (_operator_notEquals) {
+      {
+        EObject _eContainer = entry.eContainer();
+        final Region region = ((Region) _eContainer);
+        String _name = region.getName();
+        String _firstUpper = StringExtensions.toFirstUpper(_name);
+        final String regionName = _firstUpper;
+        String _xifexpression = null;
+        EObject _eContainer_1 = region.eContainer();
+        if ((_eContainer_1 instanceof org.yakindu.sct.model.sgraph.State)) {
+          EObject _eContainer_2 = region.eContainer();
+          String _name_1 = ((State) _eContainer_2).getName();
+          String _firstUpper_1 = StringExtensions.toFirstUpper(_name_1);
+          _xifexpression = _firstUpper_1;
+        }
+        final String stateName = _xifexpression;
+        String _xifexpression_1 = null;
+        String _name_2 = entry.getName();
+        boolean _isEmpty = _name_2==null?false:_name_2.isEmpty();
+        boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
+        if (_operator_not) {
+          String _name_3 = entry.getName();
+          _xifexpression_1 = _name_3;
+        } else {
+          _xifexpression_1 = "_entry_Default";
+        }
+        final String entryName = _xifexpression_1;
+        String _xifexpression_2 = null;
+        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(regionName, null);
+        if (_operator_notEquals_1) {
+          _xifexpression_2 = regionName;
+        } else {
+          _xifexpression_2 = "";
+        }
+        String _operator_plus = StringExtensions.operator_plus(_xifexpression_2, "_");
+        String _xifexpression_3 = null;
+        boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(stateName, null);
+        if (_operator_notEquals_2) {
+          _xifexpression_3 = stateName;
+        } else {
+          _xifexpression_3 = "";
+        }
+        String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _xifexpression_3);
+        String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "_");
+        String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, entryName);
+        r.setSimpleName(_operator_plus_3);
+        QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(entry);
+        String _string = _fullyQualifiedName.toString();
+        String _replaceAll = _string.replaceAll(" ", "");
+        r.setName(_replaceAll);
+        r.setSourceElement(entry);
+        SexecFactory _factory = this.sexec.factory();
+        Sequence _createSequence = _factory.createSequence();
+        final Sequence seq = _createSequence;
+        seq.setName("react");
+        String _switchResult = null;
+        EntryKind _kind = entry.getKind();
+        final EntryKind __valOfSwitchOver = _kind;
+        boolean matched = false;
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.INITIAL)) {
+            matched=true;
+            _switchResult = "initial ";
+          }
+        }
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.DEEP_HISTORY)) {
+            matched=true;
+            _switchResult = "deep history ";
+          }
+        }
+        if (!matched) {
+          if (org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_equals(__valOfSwitchOver,EntryKind.SHALLOW_HISTORY)) {
+            matched=true;
+            _switchResult = "shallow history ";
+          }
+        }
+        if (!matched) {
+          _switchResult = "";
+        }
+        String _operator_plus_4 = StringExtensions.operator_plus("Default react sequence for ", _switchResult);
+        String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, "entry ");
+        String _name_4 = entry.getName();
+        String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, _name_4);
+        seq.setComment(_operator_plus_6);
+        r.setReactSequence(seq);
+      }
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,ExecutionRegion> _createCache_create_9 = new HashMap<ArrayList<?>,ExecutionRegion>();
+  
+  public ExecutionRegion create(final Region region) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(region);
+    final ExecutionRegion r;
+    synchronized (_createCache_create_9) {
+      if (_createCache_create_9.containsKey(_cacheKey)) {
+        return _createCache_create_9.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ExecutionRegion _createExecutionRegion = _sexecFactory.createExecutionRegion();
+      r = _createExecutionRegion;
+      _createCache_create_9.put(_cacheKey, r);
+    }
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(region, null);
+    if (_operator_notEquals) {
+      {
+        String _name = region.getName();
+        boolean _isEmpty = Strings.isEmpty(_name);
+        if (_isEmpty) {
+          {
+            EObject _eContainer = region.eContainer();
+            final CompositeElement container = ((CompositeElement) _eContainer);
+            EList<Region> _regions = container.getRegions();
+            int _indexOf = _regions.indexOf(region);
+            final int index = _indexOf;
+            String _operator_plus = StringExtensions.operator_plus("region", ((Integer)index));
+            r.setName(_operator_plus);
+          }
+        } else {
+          String _name_1 = region.getName();
+          r.setName(_name_1);
+        }
+        r.setSourceElement(region);
+      }
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,Check> _createCache_createCheck = new HashMap<ArrayList<?>,Check>();
+  
+  public Check createCheck(final ReactionTrigger tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    final Check r;
+    synchronized (_createCache_createCheck) {
+      if (_createCache_createCheck.containsKey(_cacheKey)) {
+        return _createCache_createCheck.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Check _createCheck = _sexecFactory.createCheck();
+      r = _createCheck;
+      _createCache_createCheck.put(_cacheKey, r);
+    }
+    Reaction _reaction = this.sce.reaction(tr);
+    String _id = this.sce.id(_reaction);
+    r.setName(_id);
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction> _createCache_create_10 = new HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction>();
+  
+  public org.yakindu.sct.model.sexec.Reaction create(final Transition tr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tr);
+    final org.yakindu.sct.model.sexec.Reaction r;
+    synchronized (_createCache_create_10) {
+      if (_createCache_create_10.containsKey(_cacheKey)) {
+        return _createCache_create_10.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      org.yakindu.sct.model.sexec.Reaction _createReaction = _sexecFactory.createReaction();
+      r = _createReaction;
+      _createCache_create_10.put(_cacheKey, r);
+    }
+    {
+      String _id = this.sce.id(tr);
+      r.setName(_id);
+      r.setTransition(true);
+      r.setSourceElement(tr);
+    }
+    return r;
+  }
+  
+  private final HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction> _createCache_create_11 = new HashMap<ArrayList<?>,org.yakindu.sct.model.sexec.Reaction>();
+  
+  public org.yakindu.sct.model.sexec.Reaction create(final LocalReaction lr) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(lr);
+    final org.yakindu.sct.model.sexec.Reaction r;
+    synchronized (_createCache_create_11) {
+      if (_createCache_create_11.containsKey(_cacheKey)) {
+        return _createCache_create_11.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      org.yakindu.sct.model.sexec.Reaction _createReaction = _sexecFactory.createReaction();
+      r = _createReaction;
+      _createCache_create_11.put(_cacheKey, r);
+    }
+    {
+      String _id = this.sce.id(lr);
+      r.setName(_id);
+      r.setTransition(false);
+    }
+    return r;
+  }
+  
+  public CheckRef newRef(final Check check) {
+    CheckRef _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      CheckRef _createCheckRef = _sexecFactory.createCheckRef();
+      final CheckRef r = _createCheckRef;
+      r.setCheck(check);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public Call newCall(final Step step) {
+    Call _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      Call _createCall = _sexecFactory.createCall();
+      final Call r = _createCall;
+      r.setStep(step);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public ScheduleTimeEvent newScheduleTimeEvent(final TimeEvent te, final Statement timeValue) {
+    ScheduleTimeEvent _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      ScheduleTimeEvent _createScheduleTimeEvent = _sexecFactory.createScheduleTimeEvent();
+      final ScheduleTimeEvent r = _createScheduleTimeEvent;
+      r.setTimeEvent(te);
+      r.setTimeValue(timeValue);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  public UnscheduleTimeEvent newUnscheduleTimeEvent(final TimeEvent te) {
+    UnscheduleTimeEvent _xblockexpression = null;
+    {
+      SexecFactory _sexecFactory = this.sexecFactory();
+      UnscheduleTimeEvent _createUnscheduleTimeEvent = _sexecFactory.createUnscheduleTimeEvent();
+      final UnscheduleTimeEvent r = _createUnscheduleTimeEvent;
+      r.setTimeEvent(te);
+      _xblockexpression = (r);
+    }
+    return _xblockexpression;
+  }
+  
+  private final HashMap<ArrayList<?>,TimeEvent> _createCache_createDerivedEvent = new HashMap<ArrayList<?>,TimeEvent>();
+  
+  public TimeEvent createDerivedEvent(final TimeEventSpec tes) {
+    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(tes);
+    final TimeEvent r;
+    synchronized (_createCache_createDerivedEvent) {
+      if (_createCache_createDerivedEvent.containsKey(_cacheKey)) {
+        return _createCache_createDerivedEvent.get(_cacheKey);
+      }
+      SexecFactory _sexecFactory = this.sexecFactory();
+      TimeEvent _createTimeEvent = _sexecFactory.createTimeEvent();
+      r = _createTimeEvent;
+      _createCache_createDerivedEvent.put(_cacheKey, r);
+    }
+    TimeEventType _type = tes.getType();
+    boolean _operator_equals = ObjectExtensions.operator_equals(_type, TimeEventType.EVERY);
+    r.setPeriodic(_operator_equals);
+    return r;
+  }
+  
+  protected Expression _raised(final EventSpec e) {
+    return null;
+  }
+  
+  protected Expression _raised(final RegularEventSpec e) {
+    {
+      StextFactory _factory = this.stext.factory();
+      ElementReferenceExpression _createElementReferenceExpression = _factory.createElementReferenceExpression();
+      final ElementReferenceExpression r = _createElementReferenceExpression;
+      EObject _eContainer = e.eContainer();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(e, _eContainer);
+      r.setReference(_resolveRegularEventSpec);
+      return r;
+    }
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final Object o, final Object context) {
+    return null;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final RegularEventSpec re, final Object context) {
+    NamedElement _xifexpression = null;
+    Expression _event = re.getEvent();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_event, null);
+    if (_operator_notEquals) {
+      Expression _event_1 = re.getEvent();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_event_1, re);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final FeatureCall fc, final Object context) {
+    NamedElement _xifexpression = null;
+    EObject _feature = fc.getFeature();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_feature, null);
+    if (_operator_notEquals) {
+      EObject _feature_1 = fc.getFeature();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_feature_1, fc);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final ElementReferenceExpression ter, final Object context) {
+    NamedElement _xifexpression = null;
+    EObject _reference = ter.getReference();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_reference, null);
+    if (_operator_notEquals) {
+      EObject _reference_1 = ter.getReference();
+      NamedElement _resolveRegularEventSpec = this.resolveRegularEventSpec(_reference_1, ter);
+      _xifexpression = _resolveRegularEventSpec;
+    }
+    return _xifexpression;
+  }
+  
+  protected NamedElement _resolveRegularEventSpec(final EventDefinition ed, final Object context) {
+    EventDefinition _create = this.create(ed);
+    return _create;
+  }
+  
+  protected Expression _raised(final TimeEventSpec e) {
+    {
+      StextFactory _factory = this.stext.factory();
+      ElementReferenceExpression _createElementReferenceExpression = _factory.createElementReferenceExpression();
+      final ElementReferenceExpression r = _createElementReferenceExpression;
+      TimeEvent _createDerivedEvent = this.createDerivedEvent(e);
+      r.setReference(_createDerivedEvent);
+      return r;
+    }
+  }
+  
+  protected Expression _raised(final OnCycleEvent e) {
+    {
+      StextFactory _factory = this.stext.factory();
+      PrimitiveValueExpression _createPrimitiveValueExpression = _factory.createPrimitiveValueExpression();
+      final PrimitiveValueExpression r = _createPrimitiveValueExpression;
+      StextFactory _factory_1 = this.stext.factory();
+      BoolLiteral _createBoolLiteral = _factory_1.createBoolLiteral();
+      final BoolLiteral boolLit = _createBoolLiteral;
+      boolLit.setValue(true);
+      r.setValue(boolLit);
+      return r;
+    }
+  }
+  
+  protected Expression _raised(final AlwaysEvent e) {
+    {
+      StextFactory _factory = this.stext.factory();
+      PrimitiveValueExpression _createPrimitiveValueExpression = _factory.createPrimitiveValueExpression();
+      final PrimitiveValueExpression r = _createPrimitiveValueExpression;
+      StextFactory _factory_1 = this.stext.factory();
+      BoolLiteral _createBoolLiteral = _factory_1.createBoolLiteral();
+      final BoolLiteral boolLit = _createBoolLiteral;
+      boolLit.setValue(true);
+      r.setValue(boolLit);
+      return r;
+    }
+  }
+  
+  protected Expression _raised(final DefaultEvent e) {
+    {
+      StextFactory _factory = this.stext.factory();
+      PrimitiveValueExpression _createPrimitiveValueExpression = _factory.createPrimitiveValueExpression();
+      final PrimitiveValueExpression r = _createPrimitiveValueExpression;
+      StextFactory _factory_1 = this.stext.factory();
+      BoolLiteral _createBoolLiteral = _factory_1.createBoolLiteral();
+      final BoolLiteral boolLit = _createBoolLiteral;
+      boolLit.setValue(true);
+      r.setValue(boolLit);
+      return r;
+    }
+  }
+  
+  public SexecFactory sexecFactory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Scope create(final Scope scope) {
+    if ((scope instanceof InterfaceScope)) {
+      return _create((InterfaceScope)scope);
+    } else if ((scope instanceof Scope)) {
+      return _create((Scope)scope);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(scope).toString());
+    }
+  }
+  
+  public Expression raised(final EventSpec e) {
+    if ((e instanceof AlwaysEvent)) {
+      return _raised((AlwaysEvent)e);
+    } else if ((e instanceof DefaultEvent)) {
+      return _raised((DefaultEvent)e);
+    } else if ((e instanceof OnCycleEvent)) {
+      return _raised((OnCycleEvent)e);
+    } else if ((e instanceof RegularEventSpec)) {
+      return _raised((RegularEventSpec)e);
+    } else if ((e instanceof TimeEventSpec)) {
+      return _raised((TimeEventSpec)e);
+    } else if ((e instanceof EventSpec)) {
+      return _raised((EventSpec)e);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(e).toString());
+    }
+  }
+  
+  public NamedElement resolveRegularEventSpec(final Object ed, final Object context) {
+    if ((ed instanceof EventDefinition)
+         && (context instanceof Object)) {
+      return _resolveRegularEventSpec((EventDefinition)ed, (Object)context);
+    } else if ((ed instanceof ElementReferenceExpression)
+         && (context instanceof Object)) {
+      return _resolveRegularEventSpec((ElementReferenceExpression)ed, (Object)context);
+    } else if ((ed instanceof FeatureCall)
+         && (context instanceof Object)) {
+      return _resolveRegularEventSpec((FeatureCall)ed, (Object)context);
+    } else if ((ed instanceof RegularEventSpec)
+         && (context instanceof Object)) {
+      return _resolveRegularEventSpec((RegularEventSpec)ed, (Object)context);
+    } else if ((ed instanceof Object)
+         && (context instanceof Object)) {
+      return _resolveRegularEventSpec((Object)ed, (Object)context);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(ed, context).toString());
+    }
+  }
+}

+ 169 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecExtensions.java

@@ -0,0 +1,169 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.yakindu.sct.model.sexec.EnterState;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExitState;
+import org.yakindu.sct.model.sexec.SaveHistory;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateCase;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.Step;
+
+@SuppressWarnings("all")
+public class SexecExtensions {
+  
+  public SexecFactory factory() {
+    return SexecFactory.eINSTANCE;
+  }
+  
+  public EnterState newEnterStateStep(final ExecutionState s) {
+    {
+      EnterState ess = null;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(s, null);
+      if (_operator_notEquals) {
+        {
+          SexecFactory _factory = this.factory();
+          EnterState _createEnterState = _factory.createEnterState();
+          ess = _createEnterState;
+          ess.setState(s);
+        }
+      }
+      return ess;
+    }
+  }
+  
+  public ExitState newExitStateStep(final ExecutionState s) {
+    {
+      ExitState ess = null;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(s, null);
+      if (_operator_notEquals) {
+        {
+          SexecFactory _factory = this.factory();
+          ExitState _createExitState = _factory.createExitState();
+          ess = _createExitState;
+          ess.setState(s);
+        }
+      }
+      return ess;
+    }
+  }
+  
+  public StateCase newCase(final ExecutionState it, final Step step) {
+    {
+      SexecFactory _factory = this.factory();
+      StateCase _createStateCase = _factory.createStateCase();
+      final StateCase sCase = _createStateCase;
+      sCase.setState(it);
+      sCase.setStep(step);
+      return sCase;
+    }
+  }
+  
+  public SaveHistory newSaveHistory(final ExecutionRegion r) {
+    {
+      SexecFactory _factory = this.factory();
+      SaveHistory _createSaveHistory = _factory.createSaveHistory();
+      final SaveHistory save = _createSaveHistory;
+      save.setRegion(r);
+      return save;
+    }
+  }
+  
+  protected List<ExecutionState> _collectLeafStates(final ExecutionState state, final List<ExecutionState> leafStates) {
+    {
+      boolean _isLeaf = state.isLeaf();
+      if (_isLeaf) {
+        CollectionExtensions.<ExecutionState>operator_add(leafStates, state);
+      } else {
+        EList<ExecutionScope> _subScopes = state.getSubScopes();
+        for (final ExecutionScope r : _subScopes) {
+          this.collectLeafStates(r, leafStates);
+        }
+      }
+      return leafStates;
+    }
+  }
+  
+  protected List<ExecutionState> _collectLeafStates(final ExecutionRegion region, final List<ExecutionState> leafStates) {
+    {
+      EList<ExecutionScope> _subScopes = region.getSubScopes();
+      for (final ExecutionScope r : _subScopes) {
+        this.collectLeafStates(r, leafStates);
+      }
+      return leafStates;
+    }
+  }
+  
+  public int last(final StateVector sv) {
+    int _offset = sv.getOffset();
+    int _size = sv.getSize();
+    int _operator_plus = IntegerExtensions.operator_plus(((Integer)_offset), ((Integer)_size));
+    int _operator_minus = IntegerExtensions.operator_minus(((Integer)_operator_plus), ((Integer)1));
+    return _operator_minus;
+  }
+  
+  public int first(final StateVector sv) {
+    int _offset = sv.getOffset();
+    return _offset;
+  }
+  
+  public ArrayList<ExecutionScope> parentScopes(final ExecutionScope scope) {
+    {
+      ArrayList<ExecutionScope> _newArrayList = CollectionLiterals.<ExecutionScope>newArrayList();
+      final ArrayList<ExecutionScope> parents = _newArrayList;
+      ExecutionScope s = scope;
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(s, null);
+      Boolean _xwhileexpression = _operator_notEquals;
+      while (_xwhileexpression) {
+        {
+          parents.add(s);
+          ExecutionScope _superScope = s.getSuperScope();
+          s = _superScope;
+        }
+        boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(s, null);
+        _xwhileexpression = _operator_notEquals_1;
+      }
+      return parents;
+    }
+  }
+  
+  public List<ExecutionState> collectLeafScopes(final ExecutionScope scope, final List<ExecutionState> leafs) {
+    {
+      EList<ExecutionScope> _subScopes = scope.getSubScopes();
+      boolean _isEmpty = _subScopes.isEmpty();
+      if (_isEmpty) {
+        if ((scope instanceof org.yakindu.sct.model.sexec.ExecutionState)) {
+          leafs.add(((ExecutionState) scope));
+        }
+      } else {
+        EList<ExecutionScope> _subScopes_1 = scope.getSubScopes();
+        for (final ExecutionScope s : _subScopes_1) {
+          this.collectLeafScopes(s, leafs);
+        }
+      }
+      return leafs;
+    }
+  }
+  
+  public List<ExecutionState> collectLeafStates(final ExecutionScope region, final List<ExecutionState> leafStates) {
+    if ((region instanceof ExecutionRegion)
+         && (leafStates instanceof List)) {
+      return _collectLeafStates((ExecutionRegion)region, (List<ExecutionState>)leafStates);
+    } else if ((region instanceof ExecutionState)
+         && (leafStates instanceof List)) {
+      return _collectLeafStates((ExecutionState)region, (List<ExecutionState>)leafStates);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(region, leafStates).toString());
+    }
+  }
+}

+ 245 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SgraphExtensions.java

@@ -0,0 +1,245 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.SGraphFactory;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class SgraphExtensions {
+  
+  public SGraphFactory factory() {
+    return SGraphFactory.eINSTANCE;
+  }
+  
+  protected boolean _isLeaf(final RegularState s) {
+    return false;
+  }
+  
+  protected boolean _isLeaf(final FinalState s) {
+    return true;
+  }
+  
+  protected boolean _isLeaf(final State s) {
+    boolean _isSimple = s.isSimple();
+    return _isSimple;
+  }
+  
+  public List<RegularState> parentStates(final RegularState s) {
+    List<EObject> _containers = this.containers(s);
+    Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_containers, org.yakindu.sct.model.sgraph.RegularState.class);
+    List<RegularState> _list = IterableExtensions.<RegularState>toList(_filter);
+    return _list;
+  }
+  
+  public List<RegularState> parentStates(final Region s) {
+    List<EObject> _containers = this.containers(s);
+    Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_containers, org.yakindu.sct.model.sgraph.RegularState.class);
+    List<RegularState> _list = IterableExtensions.<RegularState>toList(_filter);
+    return _list;
+  }
+  
+  public List<EObject> containers(final EObject obj) {
+    {
+      ArrayList<EObject> _arrayList = new ArrayList<EObject>();
+      final ArrayList<EObject> containerList = _arrayList;
+      this.collectContainers(obj, containerList);
+      return containerList;
+    }
+  }
+  
+  public void collectContainers(final EObject obj, final List<EObject> containerList) {
+    {
+      CollectionExtensions.<EObject>operator_add(containerList, obj);
+      EObject _eContainer = obj==null?(EObject)null:obj.eContainer();
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_eContainer, null);
+      if (_operator_notEquals) {
+        EObject _eContainer_1 = obj.eContainer();
+        this.collectContainers(_eContainer_1, containerList);
+      }
+    }
+  }
+  
+  public Iterable<Entry> collectEntries(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_vertices, org.yakindu.sct.model.sgraph.Entry.class);
+    return _filter;
+  }
+  
+  public Entry entry(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function1<Vertex,Boolean> _function = new Function1<Vertex,Boolean>() {
+        public Boolean apply(final Vertex v) {
+          boolean _operator_and = false;
+          if (!(v instanceof org.yakindu.sct.model.sgraph.Entry)) {
+            _operator_and = false;
+          } else {
+            boolean _operator_or = false;
+            boolean _operator_or_1 = false;
+            String _name = v.getName();
+            boolean _operator_equals = ObjectExtensions.operator_equals(_name, null);
+            if (_operator_equals) {
+              _operator_or_1 = true;
+            } else {
+              String _name_1 = v.getName();
+              boolean _equals = "".equals(_name_1);
+              _operator_or_1 = BooleanExtensions.operator_or(_operator_equals, _equals);
+            }
+            if (_operator_or_1) {
+              _operator_or = true;
+            } else {
+              String _name_2 = v.getName();
+              boolean _operator_equals_1 = ObjectExtensions.operator_equals(_name_2, "default");
+              _operator_or = BooleanExtensions.operator_or(_operator_or_1, _operator_equals_1);
+            }
+            _operator_and = BooleanExtensions.operator_and((v instanceof org.yakindu.sct.model.sgraph.Entry), _operator_or);
+          }
+          return ((Boolean)_operator_and);
+        }
+      };
+    Vertex _findFirst = IterableExtensions.<Vertex>findFirst(_vertices, _function);
+    return ((Entry) _findFirst);
+  }
+  
+  public State target(final Entry entry) {
+    State _xifexpression = null;
+    EList<Transition> _outgoingTransitions = entry==null?(EList<Transition>)null:entry.getOutgoingTransitions();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_outgoingTransitions, null);
+    if (_operator_notEquals) {
+      State _xifexpression_1 = null;
+      EList<Transition> _outgoingTransitions_1 = entry.getOutgoingTransitions();
+      int _size = _outgoingTransitions_1.size();
+      boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+      if (_operator_greaterThan) {
+        State _xblockexpression = null;
+        {
+          EList<Transition> _outgoingTransitions_2 = entry.getOutgoingTransitions();
+          Transition _get = _outgoingTransitions_2.get(0);
+          Vertex _target = _get.getTarget();
+          final Vertex target = _target;
+          State _xifexpression_2 = null;
+          if ((target instanceof org.yakindu.sct.model.sgraph.State)) {
+            _xifexpression_2 = ((State) target);
+          }
+          _xblockexpression = (_xifexpression_2);
+        }
+        _xifexpression_1 = _xblockexpression;
+      }
+      _xifexpression = _xifexpression_1;
+    }
+    return _xifexpression;
+  }
+  
+  public List<RegularState> collectLeafStates(final RegularState state, final List<RegularState> leafStates) {
+    {
+      boolean _isLeaf = this.isLeaf(state);
+      if (_isLeaf) {
+        CollectionExtensions.<RegularState>operator_add(leafStates, state);
+      } else {
+        if ((state instanceof org.yakindu.sct.model.sgraph.State)) {
+          {
+            final State s = ((State) state);
+            EList<Region> _regions = s.getRegions();
+            for (final Region r : _regions) {
+              EList<Vertex> _vertices = r.getVertices();
+              for (final Vertex v : _vertices) {
+                if ((v instanceof org.yakindu.sct.model.sgraph.RegularState)) {
+                  this.collectLeafStates(((RegularState) v), leafStates);
+                }
+              }
+            }
+          }
+        }
+      }
+      return leafStates;
+    }
+  }
+  
+  public List<RegularState> collectLeafStates(final Region region, final List<RegularState> leafStates) {
+    {
+      EList<Vertex> _vertices = region.getVertices();
+      for (final Vertex v : _vertices) {
+        if ((v instanceof org.yakindu.sct.model.sgraph.RegularState)) {
+          this.collectLeafStates(((RegularState) v), leafStates);
+        }
+      }
+      return leafStates;
+    }
+  }
+  
+  public boolean requireDeepHistory(final Region r) {
+    List<EObject> _containers = this.containers(r);
+    Iterable<Region> _filter = IterableExtensions.<Region>filter(_containers, org.yakindu.sct.model.sgraph.Region.class);
+    final Function1<Region,Boolean> _function = new Function1<Region,Boolean>() {
+        public Boolean apply(final Region p) {
+          EList<Vertex> _vertices = p.getVertices();
+          Iterable<Entry> _filter_1 = IterableExtensions.<Entry>filter(_vertices, org.yakindu.sct.model.sgraph.Entry.class);
+          final Function1<Entry,Boolean> _function_1 = new Function1<Entry,Boolean>() {
+              public Boolean apply(final Entry v) {
+                EntryKind _kind = v.getKind();
+                boolean _operator_equals = ObjectExtensions.operator_equals(_kind, EntryKind.DEEP_HISTORY);
+                return ((Boolean)_operator_equals);
+              }
+            };
+          boolean _exists = IterableExtensions.<Entry>exists(_filter_1, _function_1);
+          return ((Boolean)_exists);
+        }
+      };
+    boolean _exists_1 = IterableExtensions.<Region>exists(_filter, _function);
+    return _exists_1;
+  }
+  
+  public boolean requireShallowHistory(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_vertices, org.yakindu.sct.model.sgraph.Entry.class);
+    final Function1<Entry,Boolean> _function = new Function1<Entry,Boolean>() {
+        public Boolean apply(final Entry v) {
+          EntryKind _kind = v.getKind();
+          boolean _operator_equals = ObjectExtensions.operator_equals(_kind, EntryKind.SHALLOW_HISTORY);
+          return ((Boolean)_operator_equals);
+        }
+      };
+    boolean _exists = IterableExtensions.<Entry>exists(_filter, _function);
+    return _exists;
+  }
+  
+  public boolean requireHistory(final Region r) {
+    boolean _operator_or = false;
+    boolean _requireDeepHistory = this.requireDeepHistory(r);
+    if (_requireDeepHistory) {
+      _operator_or = true;
+    } else {
+      boolean _requireShallowHistory = this.requireShallowHistory(r);
+      _operator_or = BooleanExtensions.operator_or(_requireDeepHistory, _requireShallowHistory);
+    }
+    return _operator_or;
+  }
+  
+  public boolean isLeaf(final RegularState s) {
+    if ((s instanceof FinalState)) {
+      return _isLeaf((FinalState)s);
+    } else if ((s instanceof State)) {
+      return _isLeaf((State)s);
+    } else if ((s instanceof RegularState)) {
+      return _isLeaf((RegularState)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(s).toString());
+    }
+  }
+}

+ 251 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java

@@ -0,0 +1,251 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class StateVectorBuilder {
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sc;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  public Object defineHistoryVector(final ExecutionFlow flow, final Statechart sc) {
+    Object _xblockexpression = null;
+    {
+      int _operator_minus = IntegerExtensions.operator_minus(1);
+      int offset = _operator_minus;
+      Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(sc);
+      Iterable<Region> _filter = IterableExtensions.<Region>filter(_allContentsIterable, org.yakindu.sct.model.sgraph.Region.class);
+      for (final Region r : _filter) {
+        boolean _requireHistory = this.sgraph.requireHistory(r);
+        if (_requireHistory) {
+          {
+            int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+            offset = _operator_plus;
+            ExecutionRegion _create = this.mapping.create(r);
+            final ExecutionRegion er = _create;
+            SexecFactory _factory = this.sexec.factory();
+            StateVector _createStateVector = _factory.createStateVector();
+            er.setHistoryVector(_createStateVector);
+            StateVector _historyVector = er.getHistoryVector();
+            _historyVector.setOffset(offset);
+            StateVector _historyVector_1 = er.getHistoryVector();
+            _historyVector_1.setSize(1);
+          }
+        }
+      }
+      Object _xifexpression = null;
+      int _operator_minus_1 = IntegerExtensions.operator_minus(1);
+      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(((Integer)offset), ((Integer)_operator_minus_1));
+      if (_operator_notEquals) {
+        {
+          SexecFactory _factory_1 = this.sexec.factory();
+          StateVector _createStateVector_1 = _factory_1.createStateVector();
+          flow.setHistoryVector(_createStateVector_1);
+          StateVector _historyVector_2 = flow.getHistoryVector();
+          _historyVector_2.setOffset(0);
+          StateVector _historyVector_3 = flow.getHistoryVector();
+          int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)1));
+          _historyVector_3.setSize(_operator_plus_1);
+        }
+      }
+      _xblockexpression = (_xifexpression);
+    }
+    return _xblockexpression;
+  }
+  
+  public void defineStateVector(final ExecutionFlow flow, final Statechart sc) {
+    {
+      int offset = 0;
+      EList<Region> _regions = sc.getRegions();
+      for (final Region r : _regions) {
+        int _defineStateVectors = this.defineStateVectors(r, offset);
+        int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_defineStateVectors));
+        offset = _operator_plus;
+      }
+      SexecFactory _factory = this.sexec.factory();
+      StateVector _createStateVector = _factory.createStateVector();
+      flow.setStateVector(_createStateVector);
+      StateVector _stateVector = flow.getStateVector();
+      _stateVector.setOffset(0);
+      StateVector _stateVector_1 = flow.getStateVector();
+      _stateVector_1.setSize(offset);
+    }
+  }
+  
+  public int defineStateVectors(final Statechart sc, final int offset) {
+    EList<Region> _regions = sc.getRegions();
+    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+        public Integer apply(final Integer o , final Region r) {
+          int _maxOrthogonality = StateVectorBuilder.this.sc.maxOrthogonality(r);
+          int _operator_plus = IntegerExtensions.operator_plus(((Integer)_maxOrthogonality), o);
+          return ((Integer)_operator_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, ((Integer)0), _function);
+    return _fold;
+  }
+  
+  public int defineStateVectors(final Region r, final int offset) {
+    {
+      EList<Vertex> _vertices = r.getVertices();
+      final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
+          public Integer apply(final Integer s , final Vertex v) {
+            int _xblockexpression = (int) 0;
+            {
+              int _defineStateVectors = StateVectorBuilder.this.defineStateVectors(v, ((Integer)offset));
+              final int mo = _defineStateVectors;
+              int _xifexpression = (int) 0;
+              boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)mo), s);
+              if (_operator_greaterThan) {
+                _xifexpression = mo;
+              } else {
+                _xifexpression = s;
+              }
+              _xblockexpression = (_xifexpression);
+            }
+            return ((Integer)_xblockexpression);
+          }
+        };
+      Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, ((Integer)0), _function);
+      final Integer maxOrthogonality = _fold;
+      ExecutionRegion _create = this.mapping.create(r);
+      final ExecutionRegion er = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateVector _createStateVector = _factory.createStateVector();
+      er.setStateVector(_createStateVector);
+      StateVector _stateVector = er.getStateVector();
+      _stateVector.setOffset(offset);
+      StateVector _stateVector_1 = er.getStateVector();
+      _stateVector_1.setSize(maxOrthogonality);
+      return maxOrthogonality;
+    }
+  }
+  
+  protected int _defineStateVectors(final Vertex v, final int offset) {
+    return 0;
+  }
+  
+  protected int _defineStateVectors(final State s, final int offset) {
+    {
+      int maxOrthogonality = 0;
+      EList<Region> _regions = s.getRegions();
+      int _size = _regions.size();
+      boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+      if (_operator_greaterThan) {
+        EList<Region> _regions_1 = s.getRegions();
+        for (final Region r : _regions_1) {
+          int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)maxOrthogonality));
+          int _defineStateVectors = this.defineStateVectors(r, _operator_plus);
+          int _operator_plus_1 = IntegerExtensions.operator_plus(((Integer)maxOrthogonality), ((Integer)_defineStateVectors));
+          maxOrthogonality = _operator_plus_1;
+        }
+      } else {
+        maxOrthogonality = 1;
+      }
+      ExecutionState _create = this.mapping.create(s);
+      final ExecutionState es = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateVector _createStateVector = _factory.createStateVector();
+      es.setStateVector(_createStateVector);
+      StateVector _stateVector = es.getStateVector();
+      _stateVector.setOffset(offset);
+      StateVector _stateVector_1 = es.getStateVector();
+      _stateVector_1.setSize(maxOrthogonality);
+      return maxOrthogonality;
+    }
+  }
+  
+  protected int _defineStateVectors(final FinalState s, final int offset) {
+    {
+      ExecutionState _create = this.mapping.create(s);
+      final ExecutionState es = _create;
+      SexecFactory _factory = this.sexec.factory();
+      StateVector _createStateVector = _factory.createStateVector();
+      es.setStateVector(_createStateVector);
+      StateVector _stateVector = es.getStateVector();
+      _stateVector.setOffset(offset);
+      StateVector _stateVector_1 = es.getStateVector();
+      _stateVector_1.setSize(1);
+      return 1;
+    }
+  }
+  
+  protected StateVector _stateVector(final Vertex v) {
+    return null;
+  }
+  
+  protected StateVector _stateVector(final RegularState s) {
+    ExecutionState _create = this.mapping.create(s);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  protected StateVector _stateVector(final Choice choice) {
+    Region _parentRegion = choice.getParentRegion();
+    ExecutionRegion _create = this.mapping.create(_parentRegion);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  public int defineStateVectors(final Vertex s, final Integer offset) {
+    if ((s instanceof FinalState)
+         && (offset instanceof Integer)) {
+      return _defineStateVectors((FinalState)s, (Integer)offset);
+    } else if ((s instanceof State)
+         && (offset instanceof Integer)) {
+      return _defineStateVectors((State)s, (Integer)offset);
+    } else if ((s instanceof Vertex)
+         && (offset instanceof Integer)) {
+      return _defineStateVectors((Vertex)s, (Integer)offset);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(s, offset).toString());
+    }
+  }
+  
+  public StateVector stateVector(final Vertex choice) {
+    if ((choice instanceof Choice)) {
+      return _stateVector((Choice)choice);
+    } else if ((choice instanceof RegularState)) {
+      return _stateVector((RegularState)choice);
+    } else if ((choice instanceof Vertex)) {
+      return _stateVector((Vertex)choice);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(choice).toString());
+    }
+  }
+}

+ 402 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java

@@ -0,0 +1,402 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.ReactiveElement;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Trigger;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EventSpec;
+import org.yakindu.sct.model.stext.stext.LocalReaction;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+
+@SuppressWarnings("all")
+public class StatechartExtensions {
+  
+  public int maxOrthogonality(final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+        public Integer apply(final Integer o , final Region r) {
+          int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+          int _operator_plus = IntegerExtensions.operator_plus(((Integer)_maxOrthogonality), o);
+          return ((Integer)_operator_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, ((Integer)0), _function);
+    return _fold;
+  }
+  
+  public int maxOrthogonality(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
+        public Integer apply(final Integer s , final Vertex v) {
+          int _xblockexpression = (int) 0;
+          {
+            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(v);
+            final int mo = _maxOrthogonality;
+            int _xifexpression = (int) 0;
+            boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)mo), s);
+            if (_operator_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return ((Integer)_xblockexpression);
+        }
+      };
+    Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, ((Integer)0), _function);
+    return _fold;
+  }
+  
+  protected int _maxOrthogonality(final Vertex v) {
+    return 0;
+  }
+  
+  protected int _maxOrthogonality(final State s) {
+    Integer _xifexpression = null;
+    EList<Region> _regions = s.getRegions();
+    int _size = _regions.size();
+    boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)_size), ((Integer)0));
+    if (_operator_greaterThan) {
+      EList<Region> _regions_1 = s.getRegions();
+      final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+          public Integer apply(final Integer o , final Region r) {
+            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+            int _operator_plus = IntegerExtensions.operator_plus(((Integer)_maxOrthogonality), o);
+            return ((Integer)_operator_plus);
+          }
+        };
+      Integer _fold = IterableExtensions.<Region, Integer>fold(_regions_1, ((Integer)0), _function);
+      _xifexpression = _fold;
+    } else {
+      _xifexpression = 1;
+    }
+    return _xifexpression;
+  }
+  
+  public Reaction reaction(final Trigger tr) {
+    EObject _eContainer = tr.eContainer();
+    return ((Reaction) _eContainer);
+  }
+  
+  public Statechart statechart(final State state) {
+    Region _parentRegion = state.getParentRegion();
+    Statechart _statechart = this.statechart(_parentRegion);
+    return _statechart;
+  }
+  
+  public Statechart statechart(final Region region) {
+    Statechart _xifexpression = null;
+    EObject _eContainer = region.eContainer();
+    if ((_eContainer instanceof org.yakindu.sct.model.sgraph.Statechart)) {
+      EObject _eContainer_1 = region.eContainer();
+      _xifexpression = ((Statechart) _eContainer_1);
+    } else {
+      EObject _eContainer_2 = region.eContainer();
+      Statechart _statechart = this.statechart(((State) _eContainer_2));
+      _xifexpression = _statechart;
+    }
+    return _xifexpression;
+  }
+  
+  public List<TimeEventSpec> timeEventSpecs(final Statechart state) {
+    {
+      ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+      ArrayList<TimeEventSpec> tesList = _arrayList;
+      EList<Reaction> _localReactions = state.getLocalReactions();
+      final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+          public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s , final Reaction r) {
+            ArrayList<TimeEventSpec> _xblockexpression = null;
+            {
+              List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+              Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, org.yakindu.sct.model.stext.stext.TimeEventSpec.class);
+              final Function1<TimeEventSpec,Boolean> _function_1 = new Function1<TimeEventSpec,Boolean>() {
+                  public Boolean apply(final TimeEventSpec tes) {
+                    boolean _add = s.add(tes);
+                    return ((Boolean)_add);
+                  }
+                };
+              IterableExtensions.<TimeEventSpec>forEach(_filter, _function_1);
+              _xblockexpression = (s);
+            }
+            return _xblockexpression;
+          }
+        };
+      IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
+      return tesList;
+    }
+  }
+  
+  public List<TimeEventSpec> timeEventSpecs(final State state) {
+    {
+      ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+      ArrayList<TimeEventSpec> tesList = _arrayList;
+      EList<Transition> _outgoingTransitions = state.getOutgoingTransitions();
+      final Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>>() {
+          public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s , final Transition r) {
+            ArrayList<TimeEventSpec> _xblockexpression = null;
+            {
+              List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+              Iterable<TimeEventSpec> _filter = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList, org.yakindu.sct.model.stext.stext.TimeEventSpec.class);
+              final Function1<TimeEventSpec,Boolean> _function_1 = new Function1<TimeEventSpec,Boolean>() {
+                  public Boolean apply(final TimeEventSpec tes) {
+                    boolean _add = s.add(tes);
+                    return ((Boolean)_add);
+                  }
+                };
+              IterableExtensions.<TimeEventSpec>forEach(_filter, _function_1);
+              _xblockexpression = (s);
+            }
+            return _xblockexpression;
+          }
+        };
+      IterableExtensions.<Transition, ArrayList<TimeEventSpec>>fold(_outgoingTransitions, tesList, _function);
+      EList<Reaction> _localReactions = state.getLocalReactions();
+      final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function_2 = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+          public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s_1 , final Reaction r_1) {
+            ArrayList<TimeEventSpec> _xblockexpression_1 = null;
+            {
+              List<EObject> _eAllContentsAsList_1 = EcoreUtil2.eAllContentsAsList(r_1);
+              Iterable<TimeEventSpec> _filter_1 = IterableExtensions.<TimeEventSpec>filter(_eAllContentsAsList_1, org.yakindu.sct.model.stext.stext.TimeEventSpec.class);
+              final Function1<TimeEventSpec,Boolean> _function_3 = new Function1<TimeEventSpec,Boolean>() {
+                  public Boolean apply(final TimeEventSpec tes_1) {
+                    boolean _add_1 = s_1.add(tes_1);
+                    return ((Boolean)_add_1);
+                  }
+                };
+              IterableExtensions.<TimeEventSpec>forEach(_filter_1, _function_3);
+              _xblockexpression_1 = (s_1);
+            }
+            return _xblockexpression_1;
+          }
+        };
+      IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function_2);
+      return tesList;
+    }
+  }
+  
+  protected ReactiveElement _reactiveElement(final Reaction r) {
+    Scope _scope = this.scope(r);
+    ReactiveElement _reactiveElement = this.reactiveElement(_scope);
+    return _reactiveElement;
+  }
+  
+  protected ReactiveElement _reactiveElement(final Transition tr) {
+    State _xifexpression = null;
+    Vertex _source = tr.getSource();
+    if ((_source instanceof org.yakindu.sct.model.sgraph.State)) {
+      _xifexpression = ((State) tr);
+    } else {
+      _xifexpression = null;
+    }
+    return _xifexpression;
+  }
+  
+  public Scope scope(final Reaction r) {
+    Scope _xifexpression = null;
+    EObject _eContainer = r.eContainer();
+    if ((_eContainer instanceof org.yakindu.sct.model.sgraph.Scope)) {
+      EObject _eContainer_1 = r.eContainer();
+      _xifexpression = ((Scope) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public ReactiveElement reactiveElement(final Scope s) {
+    ReactiveElement _xifexpression = null;
+    EObject _eContainer = s.eContainer();
+    if ((_eContainer instanceof org.yakindu.sct.model.sgraph.ReactiveElement)) {
+      EObject _eContainer_1 = s.eContainer();
+      _xifexpression = ((ReactiveElement) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public List<RegularState> allRegularStates(final Statechart sc) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
+      List<EObject> content = _eAllContentsAsList;
+      Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(content, org.yakindu.sct.model.sgraph.RegularState.class);
+      final Iterable<RegularState> allStates = _filter;
+      List<RegularState> _list = IterableExtensions.<RegularState>toList(allStates);
+      return _list;
+    }
+  }
+  
+  public List<Region> allRegions(final Statechart sc) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
+      List<EObject> content = _eAllContentsAsList;
+      Iterable<Region> _filter = IterableExtensions.<Region>filter(content, org.yakindu.sct.model.sgraph.Region.class);
+      final Iterable<Region> allRegions = _filter;
+      List<Region> _list = IterableExtensions.<Region>toList(allRegions);
+      return _list;
+    }
+  }
+  
+  public Iterable<Choice> allChoices(final Statechart sc) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(sc);
+      List<EObject> content = _eAllContentsAsList;
+      Iterable<Choice> _filter = IterableExtensions.<Choice>filter(content, org.yakindu.sct.model.sgraph.Choice.class);
+      final Iterable<Choice> allChoices = _filter;
+      return allChoices;
+    }
+  }
+  
+  public Iterable<Entry> allEntries(final Statechart sc) {
+    Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(sc);
+    Iterable<Entry> _filter = IterableExtensions.<Entry>filter(_allContentsIterable, org.yakindu.sct.model.sgraph.Entry.class);
+    return _filter;
+  }
+  
+  public List<LocalReaction> entryReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function_1 = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return ((Boolean)(t instanceof org.yakindu.sct.model.stext.stext.EntryEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function_1);
+          return ((Boolean)_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_2 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_2);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  public List<LocalReaction> exitReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function_1 = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return ((Boolean)(t instanceof org.yakindu.sct.model.stext.stext.ExitEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function_1);
+          return ((Boolean)_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_2 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_2);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  protected String _id(final Object obj) {
+    return null;
+  }
+  
+  protected String _id(final Transition t) {
+    Comparable<? extends Object> _xifexpression = null;
+    Vertex _source = t.getSource();
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_source, null);
+    if (_operator_notEquals) {
+      Vertex _source_1 = t.getSource();
+      EList<Transition> _outgoingTransitions = _source_1.getOutgoingTransitions();
+      int _indexOf = _outgoingTransitions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _operator_plus = StringExtensions.operator_plus("tr", _xifexpression);
+    return _operator_plus;
+  }
+  
+  protected String _id(final LocalReaction t) {
+    Comparable<? extends Object> _xifexpression = null;
+    ReactiveElement _reactiveElement = this.reactiveElement(t);
+    boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_reactiveElement, null);
+    if (_operator_notEquals) {
+      ReactiveElement _reactiveElement_1 = this.reactiveElement(t);
+      EList<Reaction> _localReactions = _reactiveElement_1.getLocalReactions();
+      int _indexOf = _localReactions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _operator_plus = StringExtensions.operator_plus("lr", _xifexpression);
+    return _operator_plus;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public int maxOrthogonality(final Vertex s) {
+    if ((s instanceof State)) {
+      return _maxOrthogonality((State)s);
+    } else if ((s instanceof Vertex)) {
+      return _maxOrthogonality((Vertex)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(s).toString());
+    }
+  }
+  
+  public ReactiveElement reactiveElement(final Reaction tr) {
+    if ((tr instanceof Transition)) {
+      return _reactiveElement((Transition)tr);
+    } else if ((tr instanceof Reaction)) {
+      return _reactiveElement((Reaction)tr);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(tr).toString());
+    }
+  }
+  
+  public String id(final Object t) {
+    if ((t instanceof LocalReaction)) {
+      return _id((LocalReaction)t);
+    } else if ((t instanceof Transition)) {
+      return _id((Transition)t);
+    } else if ((t instanceof Object)) {
+      return _id((Object)t);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(t).toString());
+    }
+  }
+}

+ 40 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java

@@ -0,0 +1,40 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+
+@SuppressWarnings("all")
+public class StextExtensions {
+  
+  public StextFactory factory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Expression or(final Expression left, final Expression right) {
+    LogicalOrExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      LogicalOrExpression _createLogicalOrExpression = _factory.createLogicalOrExpression();
+      final LogicalOrExpression or = _createLogicalOrExpression;
+      or.setLeftOperand(left);
+      or.setRightOperand(right);
+      _xblockexpression = (or);
+    }
+    return _xblockexpression;
+  }
+  
+  public Expression and(final Expression left, final Expression right) {
+    LogicalAndExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      LogicalAndExpression _createLogicalAndExpression = _factory.createLogicalAndExpression();
+      final LogicalAndExpression or = _createLogicalAndExpression;
+      or.setLeftOperand(left);
+      or.setRightOperand(right);
+      _xblockexpression = (or);
+    }
+    return _xblockexpression;
+  }
+}

+ 308 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java

@@ -0,0 +1,308 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.CollectionExtensions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class StructureMapping {
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sct;
+  
+  public ExecutionFlow mapScopes(final Statechart sc, final ExecutionFlow flow) {
+    ExecutionFlow _xblockexpression = null;
+    {
+      EList<Scope> _scopes = flow.getScopes();
+      EList<Scope> _scopes_1 = sc.getScopes();
+      final Function1<Scope,Scope> _function = new Function1<Scope,Scope>() {
+          public Scope apply(final Scope scope) {
+            Scope _map = StructureMapping.this.map(scope);
+            return _map;
+          }
+        };
+      List<Scope> _map_1 = ListExtensions.<Scope, Scope>map(_scopes_1, _function);
+      _scopes.addAll(_map_1);
+      _xblockexpression = (flow);
+    }
+    return _xblockexpression;
+  }
+  
+  public Scope map(final Scope scope) {
+    {
+      Scope _create = this.mapping.create(scope);
+      final Scope _scope = _create;
+      EList<Declaration> _declarations = _scope.getDeclarations();
+      EList<Declaration> _declarations_1 = scope.getDeclarations();
+      final Function1<Declaration,Declaration> _function = new Function1<Declaration,Declaration>() {
+          public Declaration apply(final Declaration decl) {
+            Declaration _map = StructureMapping.this.map(decl);
+            return _map;
+          }
+        };
+      List<Declaration> _map_1 = ListExtensions.<Declaration, Declaration>map(_declarations_1, _function);
+      final Function1<Declaration,Boolean> _function_1 = new Function1<Declaration,Boolean>() {
+          public Boolean apply(final Declaration e) {
+            boolean _operator_notEquals = ObjectExtensions.operator_notEquals(e, null);
+            return ((Boolean)_operator_notEquals);
+          }
+        };
+      Iterable<Declaration> _filter = IterableExtensions.<Declaration>filter(_map_1, _function_1);
+      CollectionExtensions.<Declaration>addAll(_declarations, _filter);
+      return _scope;
+    }
+  }
+  
+  protected Declaration _map(final Declaration decl) {
+    return null;
+  }
+  
+  protected Declaration _map(final EventDefinition e) {
+    {
+      EventDefinition _create = this.mapping.create(e);
+      final EventDefinition _e = _create;
+      return _e;
+    }
+  }
+  
+  protected Declaration _map(final VariableDefinition v) {
+    {
+      VariableDefinition _create = this.mapping.create(v);
+      final VariableDefinition _v = _create;
+      return _v;
+    }
+  }
+  
+  protected Declaration _map(final OperationDefinition v) {
+    {
+      OperationDefinition _create = this.mapping.create(v);
+      final OperationDefinition _v = _create;
+      return _v;
+    }
+  }
+  
+  public ExecutionFlow mapRegularStates(final Statechart statechart, final ExecutionFlow r) {
+    {
+      List<RegularState> _allRegularStates = this.sct.allRegularStates(statechart);
+      final List<RegularState> allStates = _allRegularStates;
+      EList<ExecutionState> _states = r.getStates();
+      final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+          public ExecutionState apply(final RegularState s) {
+            ExecutionState _mapState = StructureMapping.this.mapState(s);
+            return _mapState;
+          }
+        };
+      List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(allStates, _function);
+      _states.addAll(_map);
+      return r;
+    }
+  }
+  
+  protected ExecutionState _mapState(final FinalState state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState _state = _create;
+      _state.setLeaf(true);
+      _state.setEntryAction(null);
+      _state.setExitAction(null);
+      return _state;
+    }
+  }
+  
+  protected ExecutionState _mapState(final State state) {
+    {
+      ExecutionState _create = this.mapping.create(state);
+      final ExecutionState _state = _create;
+      boolean _isSimple = state.isSimple();
+      _state.setLeaf(_isSimple);
+      return _state;
+    }
+  }
+  
+  protected ExecutionState _mapState(final RegularState state) {
+    return null;
+  }
+  
+  public ExecutionFlow mapRegions(final Statechart statechart, final ExecutionFlow flow) {
+    {
+      List<Region> _allRegions = this.sct.allRegions(statechart);
+      final List<Region> allRegions = _allRegions;
+      EList<ExecutionRegion> _regions = flow.getRegions();
+      final Function1<Region,ExecutionRegion> _function = new Function1<Region,ExecutionRegion>() {
+          public ExecutionRegion apply(final Region r) {
+            ExecutionRegion _mapRegion = StructureMapping.this.mapRegion(r);
+            return _mapRegion;
+          }
+        };
+      List<ExecutionRegion> _map = ListExtensions.<Region, ExecutionRegion>map(allRegions, _function);
+      _regions.addAll(_map);
+      return flow;
+    }
+  }
+  
+  public ExecutionRegion mapRegion(final Region region) {
+    {
+      ExecutionRegion _create = this.mapping.create(region);
+      final ExecutionRegion _region = _create;
+      CompositeElement _composite = region.getComposite();
+      if ((_composite instanceof org.yakindu.sct.model.sgraph.Statechart)) {
+        CompositeElement _composite_1 = region.getComposite();
+        ExecutionFlow _create_1 = this.mapping.create(((Statechart) _composite_1));
+        _region.setSuperScope(_create_1);
+      } else {
+        CompositeElement _composite_2 = region.getComposite();
+        ExecutionState _create_2 = this.mapping.create(((State) _composite_2));
+        _region.setSuperScope(_create_2);
+      }
+      EList<ExecutionScope> _subScopes = _region.getSubScopes();
+      EList<Vertex> _vertices = region.getVertices();
+      Iterable<RegularState> _filter = IterableExtensions.<RegularState>filter(_vertices, org.yakindu.sct.model.sgraph.RegularState.class);
+      final Function1<RegularState,ExecutionScope> _function = new Function1<RegularState,ExecutionScope>() {
+          public ExecutionScope apply(final RegularState v) {
+            ExecutionState _create_3 = StructureMapping.this.mapping.create(v);
+            return ((ExecutionScope) _create_3);
+          }
+        };
+      Iterable<ExecutionScope> _map = IterableExtensions.<RegularState, ExecutionScope>map(_filter, _function);
+      CollectionExtensions.<ExecutionScope>addAll(_subScopes, _map);
+      return _region;
+    }
+  }
+  
+  public ExecutionFlow mapPseudoStates(final Statechart statechart, final ExecutionFlow r) {
+    {
+      EList<ExecutionNode> _nodes = r.getNodes();
+      Iterable<Choice> _allChoices = this.sct.allChoices(statechart);
+      final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
+          public ExecutionChoice apply(final Choice choice) {
+            ExecutionChoice _create = StructureMapping.this.mapping.create(choice);
+            return _create;
+          }
+        };
+      Iterable<ExecutionChoice> _map = IterableExtensions.<Choice, ExecutionChoice>map(_allChoices, _function);
+      CollectionExtensions.<ExecutionNode>addAll(_nodes, _map);
+      EList<ExecutionNode> _nodes_1 = r.getNodes();
+      Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
+      final Function1<Entry,ExecutionEntry> _function_1 = new Function1<Entry,ExecutionEntry>() {
+          public ExecutionEntry apply(final Entry entry) {
+            ExecutionEntry _create_1 = StructureMapping.this.mapping.create(entry);
+            return _create_1;
+          }
+        };
+      Iterable<ExecutionEntry> _map_1 = IterableExtensions.<Entry, ExecutionEntry>map(_allEntries, _function_1);
+      CollectionExtensions.<ExecutionNode>addAll(_nodes_1, _map_1);
+      return r;
+    }
+  }
+  
+  public ExecutionFlow mapTimeEvents(final Statechart statechart, final ExecutionFlow r) {
+    {
+      List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(statechart);
+      List<EObject> content = _eAllContentsAsList;
+      Iterable<State> _filter = IterableExtensions.<State>filter(content, org.yakindu.sct.model.sgraph.State.class);
+      final Iterable<State> allStates = _filter;
+      final Function1<State,ArrayList<TimeEvent>> _function = new Function1<State,ArrayList<TimeEvent>>() {
+          public ArrayList<TimeEvent> apply(final State s) {
+            ArrayList<TimeEvent> _mapTimeEventSpecs = StructureMapping.this.mapTimeEventSpecs(s);
+            return _mapTimeEventSpecs;
+          }
+        };
+      IterableExtensions.<State>forEach(allStates, _function);
+      return r;
+    }
+  }
+  
+  public ArrayList<TimeEvent> mapTimeEventSpecs(final State state) {
+    ArrayList<TimeEvent> _xblockexpression = null;
+    {
+      List<TimeEventSpec> _timeEventSpecs = this.sct.timeEventSpecs(state);
+      final List<TimeEventSpec> timeEventSpecs = _timeEventSpecs;
+      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
+      final ArrayList<TimeEvent> result = _arrayList;
+      for (final TimeEventSpec tes : timeEventSpecs) {
+        {
+          TimeEvent _createDerivedEvent = this.mapping.createDerivedEvent(tes);
+          final TimeEvent timeEvent = _createDerivedEvent;
+          String _name = state.getName();
+          String _operator_plus = StringExtensions.operator_plus(_name, "_time_event_");
+          int _indexOf = timeEventSpecs.indexOf(tes);
+          String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ((Integer)_indexOf));
+          timeEvent.setName(_operator_plus_1);
+          Statechart _statechart = this.sct.statechart(state);
+          ExecutionFlow _create = this.mapping.create(_statechart);
+          Scope _timeEventScope = this.mapping.timeEventScope(_create);
+          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
+          _declarations.add(timeEvent);
+          result.add(timeEvent);
+        }
+      }
+      _xblockexpression = (result);
+    }
+    return _xblockexpression;
+  }
+  
+  public Declaration map(final Declaration e) {
+    if ((e instanceof EventDefinition)) {
+      return _map((EventDefinition)e);
+    } else if ((e instanceof OperationDefinition)) {
+      return _map((OperationDefinition)e);
+    } else if ((e instanceof VariableDefinition)) {
+      return _map((VariableDefinition)e);
+    } else if ((e instanceof Declaration)) {
+      return _map((Declaration)e);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(e).toString());
+    }
+  }
+  
+  public ExecutionState mapState(final RegularState state) {
+    if ((state instanceof FinalState)) {
+      return _mapState((FinalState)state);
+    } else if ((state instanceof State)) {
+      return _mapState((State)state);
+    } else if ((state instanceof RegularState)) {
+      return _mapState((RegularState)state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        java.util.Arrays.<Object>asList(state).toString());
+    }
+  }
+}

+ 107 - 0
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/TraceExtensions.java

@@ -0,0 +1,107 @@
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import org.eclipse.emf.common.util.EList;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.Reaction;
+import org.yakindu.sct.model.sexec.ReactionFired;
+import org.yakindu.sct.model.sexec.Sequence;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.Step;
+import org.yakindu.sct.model.sexec.TraceNodeExecuted;
+import org.yakindu.sct.model.sexec.TraceStateEntered;
+import org.yakindu.sct.model.sexec.TraceStateExited;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sgraph.RegularState;
+
+@SuppressWarnings("all")
+public class TraceExtensions {
+  
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  @Named("ADD_TRACES")
+  private boolean _addTraceSteps;
+  
+  public boolean isAddTraceSteps() {
+    return this._addTraceSteps;
+  }
+  
+  public ReactionFired newTraceReactionFired(final Reaction r) {
+    ReactionFired _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      ReactionFired _createReactionFired = _factory.createReactionFired();
+      final ReactionFired rf = _createReactionFired;
+      rf.setReaction(r);
+      _xblockexpression = (rf);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceNodeExecuted newTraceNodeExecuted(final ExecutionNode node) {
+    TraceNodeExecuted _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      TraceNodeExecuted _createTraceNodeExecuted = _factory.createTraceNodeExecuted();
+      final TraceNodeExecuted t = _createTraceNodeExecuted;
+      t.setNode(node);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceStateEntered newTraceStateEntered(final ExecutionState state) {
+    TraceStateEntered _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      TraceStateEntered _createTraceStateEntered = _factory.createTraceStateEntered();
+      final TraceStateEntered t = _createTraceStateEntered;
+      t.setState(state);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public TraceStateExited newTraceStateExited(final ExecutionState state) {
+    TraceStateExited _xblockexpression = null;
+    {
+      SexecFactory _factory = this.sexec.factory();
+      TraceStateExited _createTraceStateExited = _factory.createTraceStateExited();
+      final TraceStateExited t = _createTraceStateExited;
+      t.setState(state);
+      _xblockexpression = (t);
+    }
+    return _xblockexpression;
+  }
+  
+  public Boolean traceStateExited(final Sequence seq, final ExecutionState state) {
+    Boolean _xifexpression = null;
+    boolean _isAddTraceSteps = this.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      EList<Step> _steps = seq.getSteps();
+      TraceStateExited _newTraceStateExited = this.newTraceStateExited(state);
+      boolean _add = _steps.add(_newTraceStateExited);
+      _xifexpression = _add;
+    }
+    return _xifexpression;
+  }
+  
+  public Boolean traceStateExited(final Sequence seq, final RegularState state) {
+    Boolean _xifexpression = null;
+    boolean _isAddTraceSteps = this.isAddTraceSteps();
+    if (_isAddTraceSteps) {
+      ExecutionState _create = this.mapping.create(state);
+      Boolean _traceStateExited = this.traceStateExited(seq, _create);
+      _xifexpression = _traceStateExited;
+    }
+    return _xifexpression;
+  }
+}