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
  // implements the interface method
  public Environment createClassifierContext(Environment parent, Type context) {

    Environment result = createEnvironment(parent);

    Variable self = parent.getOCLFactory().createVariable();
    self.setName(Environment.SELF_VARIABLE_NAME);
    self.setType(context);

    //        result.addElement(self.getName(), self, true);
    result.setSelfVariable(self);

    return result;
  }
 @Override
 public BasicContinuation<?> execute() {
   ObjectTemplateExp pivotElement = PivotUtil.getPivot(ObjectTemplateExp.class, csElement);
   if (pivotElement != null) {
     org.eclipse.ocl.examples.pivot.Class type =
         PivotUtil.getPivot(org.eclipse.ocl.examples.pivot.Class.class, csElement.getType());
     pivotElement.setReferredClass(type);
     pivotElement.setType(type);
     Variable variable = pivotElement.getBindsTo();
     if (variable != null) {
       variable.setType(type);
     }
   }
   return null;
 }
 @Override
 public BasicContinuation<?> execute() {
   CollectionTemplateExp pivotElement =
       PivotUtil.getPivot(CollectionTemplateExp.class, csElement);
   if (pivotElement != null) {
     CollectionType type = PivotUtil.getPivot(CollectionType.class, csElement.getType());
     pivotElement.setReferredCollectionType(type);
     pivotElement.setType(type);
     Variable variable = pivotElement.getBindsTo();
     if (variable != null) {
       variable.setType(type);
     }
   }
   return null;
 }
Ejemplo n.º 5
0
 // implements the interface method
 public Environment createOperationContext(Environment parent, Operation operation) {
   Environment result = createEnvironment(parent);
   if (result instanceof AbstractEnvironment) {
     ((AbstractEnvironment) result).setContextOperation(operation);
   }
   OCLFactory oclFactory = parent.getOCLFactory();
   for (Parameter next : operation.getOwnedParameters()) {
     // ensure that we use the OCL primitive types wherever possible
     Variable var = oclFactory.createVariable();
     var.setName(next.getName());
     var.setType(next.getType());
     var.setRepresentedParameter(next);
     result.addElement(var.getName(), var, true);
   }
   return result;
 }