Ejemplo n.º 1
0
 protected Map<TemplateParameter, ParameterableElement> getIterationBindings(
     Iteration candidateIteration) {
   Type sourceType = this.sourceType;
   if (!(sourceType instanceof CollectionType)
       && (candidateIteration.getOwningType() instanceof CollectionType)) {
     sourceType = metaModelManager.getCollectionType("Set", sourceType); // Implicit oclAsSet()
   }
   if (!(sourceType instanceof CollectionType)) { // May be InvalidType
     return null;
   }
   HashMap<TemplateParameter, ParameterableElement> bindings =
       new HashMap<TemplateParameter, ParameterableElement>();
   bindings.put(
       candidateIteration.getOwningType().getOwnedTemplateSignature().getOwnedParameter().get(0),
       ((CollectionType) sourceType).getElementType());
   PivotUtil.getAllTemplateParameterSubstitutions(bindings, sourceType);
   TemplateSignature templateSignature = candidateIteration.getOwnedTemplateSignature();
   if (templateSignature != null) {
     List<TemplateParameter> templateParameters = templateSignature.getOwnedParameter();
     int accIndex = 0;
     for (NavigatingArgCS csArgument : csArguments) {
       if (csArgument.getRole() == NavigationRole.ACCUMULATOR) {
         if (accIndex < templateParameters.size()) {
           Variable argument = PivotUtil.getPivot(Variable.class, csArgument);
           Type argumentType = argument.getType();
           TemplateParameter accParameter = templateParameters.get(accIndex);
           bindings.put(accParameter, argumentType);
         }
         accIndex++;
       }
     }
   }
   return bindings;
 }
Ejemplo n.º 2
0
 protected OclExpression getExpressionArgument(int index) {
   int expIndex = 0;
   for (NavigatingArgCS csNavigatingArg : csArguments) {
     if (csNavigatingArg.getRole() == NavigationRole.EXPRESSION) {
       if (expIndex == index) {
         return PivotUtil.getPivot(OclExpression.class, csNavigatingArg);
       }
       expIndex++;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 public OperationFilter(
     MetaModelManager metaModelManager, Type sourceType, InvocationExpCS csNavigatingExp) {
   super(metaModelManager, sourceType);
   int accumulators = 0;
   int iterators = 0;
   int expressions = 0;
   this.csArguments = csNavigatingExp.getArgument();
   for (NavigatingArgCS csNavigatingArg : csArguments) {
     if (csNavigatingArg.getRole() == NavigationRole.ITERATOR) {
       iterators++;
     } else if (csNavigatingArg.getRole() == NavigationRole.ACCUMULATOR) {
       accumulators++;
     } else if (csNavigatingArg.getRole() == NavigationRole.EXPRESSION) {
       expressions++;
     }
   }
   this.iterators = iterators;
   this.accumulators = accumulators;
   this.expressions = expressions;
 }