Examples of TForLoop


Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

    //Sometimes tObject is NOT parent of tChild! (for and if)
    ReferenceFromParent tChildParent2tChildRef = template.getParentFrom(tChild, tChildContext);
    EObject tChildParent = tChildParent2tChildRef.getParent();
    //FOR-LOOP
    if(TForLoop.isTForLoop(tChildParent)){
      TForLoop forLoop = new TForLoop(tChildParent, tChildContext, template);
      List<EObject> loopBody= template.getChildrenFrom(
          forLoop.getTElement(), forLoop.getOLReference(), tChildContext);
     
      //TODO implement the following
//      if(decisionMaker.onlyFilterOutInputElementAndDoNotDelete(tChild)){
//        throw new SynchronizingException("Handle filter out - Not yet implemented.");
//      }
      if(loopBody.size()>1){
        //Remove element when more elements are in bodyVersion
        template.removeChildFrom(
            forLoop.getTElement(), forLoop.getOLReference(), tChild, tChildContext);
       
        log.debug("Removed tChild "+Util.getFullName(tChild)+
            " from for-Loop body: " + Util.getFullName(forLoop.getTElement()));
      } else if(loopBody.size()==1){
       
       
        //Remove parameter element when only one element is in bodyVersion
        EObject inputModelElement = tChildContext.getVariableValue(forLoop.getName());
       
        parameterModelHandler.removeElement(inputModelElement,
            forLoop.getSetToBeIterated().getReferenceFromParent());
       
        log.debug("Removed parameterElement in for-Loop: " + Util.getFullName(forLoop.getTElement()) + " Element: " + Util.getFullName(inputModelElement));
       
      } else {
        log.error("BUG: For-loop has no element. This should not happend.");
      }
    } else if(TIfStatement.isTIfStatement(tChildParent)){
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

        EObject uppermostForLoop = findUpperMostForLoop(tParent, tLeft, tLeftContext);
        if(uppermostForLoop==null||!TForLoop.isTForLoop(uppermostForLoop)){
          throw new SimTLException("Didn't find uppermost for-loop ancistor?");
        }
       
        GrayPath grayPathToTLeft = findGrayPath(new TForLoop(uppermostForLoop, tLeftContext, template), tLeft, tLeftContext);
        elementsInRange.add(new NewIterationAddAllocation(grayPathToTLeft,true,tLeftContext));
      }
      return elementsInRange;
    }
    EObject commonAncistor = tParent;
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

      }
      position++;
    }
    //If tParent a for-loop, than it can also be an element within the new iteration
    if(TForLoop.isTForLoop(tParent)){
      TForLoop forLoop = new TForLoop(tParent, context, template);
      GrayPath grayPath = new GrayPath(forLoop.getTElement());
      allocateToElementInNewIteration( forLoop, leftToRight, grayPath, tiChild, context, allocations);
    }
    return addAllocationsTillCap(leftToRight, tParent, context, cap, tiChild, allocations);
  }
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

 
  private void addAllocationsToGreyElement(EObject tObject, boolean addRightToParamElem,
      EObject tiChild, IContext context,
      Vector<AddAllocation> allocations) throws SimTLException{
    if(TForLoop.isTForLoop(tObject)){
      TForLoop forLoop = new TForLoop(tObject, context, template);
      GrayPath grayPath = new GrayPath(forLoop.getTElement());
      allocateToElementInNewIteration(forLoop, addRightToParamElem, grayPath, tiChild, context, allocations);
    } else if(TIfStatement.isTIfStatement(tObject)){
      TIfStatement ifStatement = new TIfStatement(tObject, context, template);
      GrayPath grayPath = new GrayPath(ifStatement.getTElement());
      allocateToElementInIfStatement(ifStatement, addRightToParamElem,
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

        TIfStatement ifStatement = new TIfStatement(loopChild, context, template);
        grayPath.add(ifStatement.getTElement());
        allocateToElementInIfStatement(ifStatement, addRightToParamElem,
            AllocationType.FOR_NEWIT, grayPath, tiChild, context, allocations);
      } else if(TForLoop.isTForLoop(loopChild)){
        TForLoop childForLoop = new TForLoop(loopChild, context, template);
        grayPath.add(childForLoop.getTElement());
        allocateToElementInNewIteration(childForLoop,addRightToParamElem, grayPath, tiChild, context,allocations);
      } else if(TElement.isTElement(loopChild)){
        log.error("Unknown tElement");
      }
    }
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

      } else if(TIfStatement.isTIfStatement(ifChild)){
        TIfStatement childIfStatement = new TIfStatement(ifChild, context, template);
        grayPath.add(childIfStatement.getTElement());
        allocateToElementInIfStatement(childIfStatement, addRightToParamElem, allocationType, grayPath, tiChild, context, allocations);
      } else if(TForLoop.isTForLoop(ifChild)){
        TForLoop forLoop = new TForLoop(ifChild, context, template);
        grayPath.add(forLoop.getTElement());
        allocateToElementInNewIteration(forLoop, addRightToParamElem, grayPath, tiChild,context,allocations);
      } else if(TElement.isTElement(ifChild)){
        log.debug("Unknown tElement");
      }
    }
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

                tiChild
              )
            ));
       
      } else if(TForLoop.isTForLoop(tObject)){
        TForLoop forLoop = new TForLoop(tObject, context, template);
        EObject neighborInputElement = context.getVariableValue(forLoop.getName());
       
        Reference2Element pPointerToList = (Reference2Element)forLoop.getSetToBeIterated().getReferenceFromParent();
        List<EObject> parameterList = (List<EObject>)pPointerToList.getReferencedValue();
        if(parameterList.size()>0
            && (neighborInputElement==null
              ||!parameterList.contains(neighborInputElement))){
          throw new SimTLException("InputModel collection doesn't contain neighbor input element. It does contain other elements though");
         
        }
       
        Reference2Element pPointerToListElement = (Reference2Element)pPointerToList;
        EClass pClass = pPointerToListElement.getReferenceToChildren().getEReferenceType();
        //create new inputElement
        EObject pElement = pClass.getEPackage().getEFactoryInstance().create(pClass);
       
       
        if(pElement==null) throw new SimTLException("Couldn't instantiate parameter element type " + pClass.getName());
       
        //Add element to parameter model
        if(parameterList.size()>1){
          //It must be a new iteration => Existing is covered in position above
          boolean insertToRightOfParam = ((NewIterationAddAllocation)grayElementAddAllocation).isInsertToRightOfParam();
          int neighborIndex = parameterList.indexOf(neighborInputElement);
          int pIndex =
            insertToRightOfParam
              ?neighborIndex+1
              :neighborIndex;
          parameterModelHandler.addElement(pElement, pIndex, pPointerToList);
        } else {
          parameterModelHandler.addElement(pElement, Util.NO_POSITION, pPointerToList);
        }
       
        //Update context
        context = addVariableToContext(context, forLoop.getName(), pElement);
        //introduce trace link
        modelCorrespondence.add(
            new TraceLink(
              (StaticContext)context, //context is been adapted
              new TraceLinkNode(
                template,
                tChild
              ),
              new TraceLinkNode(
                instance,
                tiChild
              )
            ));
        log.debug("Added parameterElement in for-Loop: " + Util.getFullName(forLoop.getTElement()) + " Element: " + Util.getFullName(pElement));
      } else {
        log.error("Unknown TElement: " + Util.getFullName(tObject));
      }
    }
   
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

        //but leaf as child
        doNotDeleteEO = grayPath.getLeaf();
      }
      TElement tElement = null;
      if(TForLoop.isTForLoop(tElementEO)){
        tElement = new TForLoop(tElementEO, context, template);
      } else if(TIfStatement.isTIfStatement(tElementEO)){
        tElement = new TIfStatement(tElementEO, context, template);
      } else {         
        throw new SimTLException("Unknown TElement type " + Util.getFullName(tElementEO));
      }
View Full Code Here

Examples of sg.edu.nus.comp.simTL.engine.interpreter.evaluators.TForLoop

    //Placeholders are evaluated already
    if(TPlaceholder.isTPlaceholder(tObject)){
      return;
    } else if(TForLoop.isTForLoop(tObject)){
      log.debug("Evaluating loop");
      TForLoop loop = new TForLoop(tObject,currentContext,template);
      ReferenceFromParent pReferenceFromParent = loop.getSetToBeIterated().getReferenceFromParent();
      if(pReferenceFromParent instanceof Reference2Attribute){
        throw new ValidationException("For-loop references an attribute and no list of elements! " + Util.getFullName(loop.getTElement()));
      } else if(!((Reference2Element)pReferenceFromParent).getReferenceToChildren().isMany()){
        throw new ValidationException("For-loop doesn't reference a list of elements! " + Util.getFullName(loop.getTElement()));
      }
     
      List<?> parameterList = (List<?>)pReferenceFromParent.getReferencedValue();
      //FOR-LOOP
      for(Object o : parameterList){
//        if(!(o instanceof EObject)){
//          throw new ValidationException("For-loop methodCall ("+loop.getSetToBeIterated().toString()+") does not return a list of ModelElements but Attributes");
//        }
        currentContext.pushVariable(loop.getName(),(EObject)o);
        //BODY
        for(EObject tObjectChildren : template.getChildrenFrom(loop.getTElement(), loop.getOLReference(), currentContext)){
          evaluate(tObjectChildren,iObjectProxy, iRootPackage);
        }
        currentContext.pullVariable(loop.getName());
      }
    } else if(TIfStatement.isTIfStatement(tObject)){
      log.debug("Evaluating if");
      TIfStatement ifStatement = new TIfStatement(tObject,currentContext,template);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.