Example #1
0
 protected static void _privk3_getAllChildren(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final AbstractState vertex,
     final ArrayList<AbstractState> children) {
   if ((vertex instanceof State)) {
     EList<Region> _ownedRegions = ((State) vertex).getOwnedRegions();
     boolean _notEquals = (!Objects.equal(_ownedRegions, null));
     if (_notEquals) {
       EList<Region> _ownedRegions_1 = ((State) vertex).getOwnedRegions();
       final Consumer<Region> _function =
           (Region _region) -> {
             EList<AbstractState> _subvertex = _region.getSubvertex();
             children.addAll(_subvertex);
             EList<AbstractState> _subvertex_1 = _region.getSubvertex();
             final Consumer<AbstractState> _function_1 =
                 (AbstractState _vertex) -> {
                   RegionAspect.getAllChildren(_self, _vertex, children);
                 };
             _subvertex_1.forEach(_function_1);
           };
       _ownedRegions_1.forEach(_function);
     }
   }
 }
Example #2
0
 protected static void _privk3_step(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final Hashtable<String, Object> context,
     final EList<String> events) {
   boolean allJunctionsAttended = false;
   while ((!allJunctionsAttended)) {
     {
       ArrayList<AbstractState> currentState =
           RegionAspect.getCurrentState(_self, context, events);
       ArrayList<Transition> currentTransitions = new ArrayList<Transition>();
       ArrayList<AbstractState> attendedStates = new ArrayList<AbstractState>();
       ArrayList<AbstractState> newStates = new ArrayList<AbstractState>();
       EList<Transition> activeTransitions = new BasicEList<Transition>();
       for (final AbstractState _state : currentState) {
         EList<Transition> _activeTransitions =
             RegionAspect.getActiveTransitions(_self, _state, events);
         activeTransitions.addAll(_activeTransitions);
       }
       for (final Transition transition : activeTransitions) {
         {
           RegionAspect.findOldActiveStates(_self, attendedStates, transition, context);
           RegionAspect.findNewActiveTransitions(_self, currentTransitions, transition, context);
           RegionAspect.findNewActiveStates(
               _self, newStates, transition, currentTransitions, context);
         }
       }
       for (final AbstractState _attendedState : attendedStates) {
         if ((_attendedState instanceof State)) {
           StateAspect.exitState(((State) _attendedState), context);
         }
       }
       RegionAspect.removeStatesFromContext(_self, context, attendedStates);
       RegionAspect.addStatesToContext(_self, context, newStates);
       final Consumer<Transition> _function =
           (Transition transition_1) -> {
             TransitionAspect.evalTransition(transition_1, context);
           };
       activeTransitions.forEach(_function);
       final Consumer<Transition> _function_1 =
           (Transition transition_1) -> {
             boolean _alreadyFired = TransitionAspect.alreadyFired(transition_1, context);
             boolean _not = (!_alreadyFired);
             if (_not) {
               TransitionAspect.evalTransition(transition_1, context);
             }
           };
       currentTransitions.forEach(_function_1);
       final Consumer<AbstractState> _function_2 =
           (AbstractState state) -> {
             EList<Transition> _outgoing = state.getOutgoing();
             final Consumer<Transition> _function_3 =
                 (Transition transition_1) -> {
                   TransitionAspect.resetFired(transition_1);
                 };
             _outgoing.forEach(_function_3);
           };
       newStates.forEach(_function_2);
       final ArrayList<AbstractState> currentConditionalState = new ArrayList<AbstractState>();
       Set<String> _keySet = context.keySet();
       Iterator<String> _it = _keySet.iterator();
       while (_it.hasNext()) {
         {
           String _key = _it.next();
           Object _value = context.get(_key);
           boolean _startsWith = _key.startsWith("currentState");
           if (_startsWith) {
             final Consumer<AbstractState> _function_3 =
                 (AbstractState _vertex) -> {
                   currentConditionalState.add(_vertex);
                 };
             ((ArrayList<AbstractState>) _value).forEach(_function_3);
           }
         }
       }
       String _name = _self.getName();
       String _plus = ("currentState-" + _name);
       Object _get = context.get(_plus);
       currentState = ((ArrayList<AbstractState>) _get);
       final Function1<AbstractState, Boolean> _function_3 =
           (AbstractState _vertex) -> {
             EList<Transition> _outgoing = _vertex.getOutgoing();
             final Function1<Transition, Boolean> _function_4 =
                 (Transition _outgoing_1) -> {
                   boolean _and = false;
                   AbstractState _target = _outgoing_1.getTarget();
                   if (!(_target instanceof Pseudostate)) {
                     _and = false;
                   } else {
                     AbstractState _target_1 = _outgoing_1.getTarget();
                     _and = (_target_1 instanceof Junction);
                   }
                   return Boolean.valueOf(_and);
                 };
             return Boolean.valueOf(IterableExtensions.<Transition>exists(_outgoing, _function_4));
           };
       boolean _exists = IterableExtensions.<AbstractState>exists(currentState, _function_3);
       boolean _not = (!_exists);
       allJunctionsAttended = _not;
     }
   }
 }
 @Check
 public void checkEnumExtendsDuplicates(final MobaDataType datatype) {
   final MobaDataType superType = datatype.getSuperType();
   boolean _or = false;
   boolean _isEnum = datatype.isEnum();
   boolean _not = (!_isEnum);
   if (_not) {
     _or = true;
   } else {
     boolean _equals = Objects.equal(superType, null);
     _or = _equals;
   }
   if (_or) {
     return;
   }
   final HashSet<String> names = CollectionLiterals.<String>newHashSet();
   final HashSet<String> literals = CollectionLiterals.<String>newHashSet();
   final HashSet<Integer> values = CollectionLiterals.<Integer>newHashSet();
   MobaEnum _enumAST = superType.getEnumAST();
   List<MobaEnumLiteral> _allLiterals = _enumAST.getAllLiterals();
   final Consumer<MobaEnumLiteral> _function =
       (MobaEnumLiteral it) -> {
         String _name = it.getName();
         names.add(_name);
         String _literal = it.getLiteral();
         literals.add(_literal);
         int _value = it.getValue();
         values.add(Integer.valueOf(_value));
       };
   _allLiterals.forEach(_function);
   MobaEnum _enumAST_1 = datatype.getEnumAST();
   EList<MobaEnumLiteral> _literals = _enumAST_1.getLiterals();
   final Consumer<MobaEnumLiteral> _function_1 =
       (MobaEnumLiteral it) -> {
         String _name = it.getName();
         boolean _contains = names.contains(_name);
         if (_contains) {
           StringConcatenation _builder = new StringConcatenation();
           _builder.append("Duplicate name \"");
           String _name_1 = it.getName();
           _builder.append(_name_1, "");
           _builder.append(".\" Check super type.");
           this.error(
               _builder.toString(), datatype, MobaPackage.Literals.MOBA_DATA_TYPE__ENUM_AST);
         }
         String _literal = it.getLiteral();
         boolean _contains_1 = literals.contains(_literal);
         if (_contains_1) {
           StringConcatenation _builder_1 = new StringConcatenation();
           _builder_1.append("Duplicate literal \"");
           String _literal_1 = it.getLiteral();
           _builder_1.append(_literal_1, "");
           _builder_1.append(".\" Check super type.");
           this.error(
               _builder_1.toString(), datatype, MobaPackage.Literals.MOBA_DATA_TYPE__ENUM_AST);
         }
         int _value = it.getValue();
         boolean _contains_2 = values.contains(Integer.valueOf(_value));
         if (_contains_2) {
           StringConcatenation _builder_2 = new StringConcatenation();
           _builder_2.append("You are redefinging enum literal with value\"");
           int _value_1 = it.getValue();
           _builder_2.append(_value_1, "");
           _builder_2.append(".\" Check super type.");
           this.warning(
               _builder_2.toString(), datatype, MobaPackage.Literals.MOBA_DATA_TYPE__ENUM_AST);
         }
       };
   _literals.forEach(_function_1);
 }