private List<IRType> getBoundedParameterTypeDescriptors(IConstructorInfo mi) {
    if (mi.getParameters().length == 0) {
      return Collections.emptyList();
    }

    if (mi instanceof IJavaConstructorInfo) {
      return IRTypeResolver.getDescriptors(
          ((IJavaConstructorInfo) mi).getJavaConstructor().getParameterTypes());
    } else if (mi instanceof IGosuConstructorInfo) {
      IReducedDynamicFunctionSymbol dfs = ((IGosuConstructorInfo) mi).getDfs();
      while (dfs instanceof ReducedParameterizedDynamicFunctionSymbol) {
        ReducedParameterizedDynamicFunctionSymbol pdfs =
            (ReducedParameterizedDynamicFunctionSymbol) dfs;
        dfs = pdfs.getBackingDfs();
      }

      List<IRType> boundedTypes = new ArrayList<IRType>(dfs.getArgs().size());
      if (IGosuClass.ProxyUtil.isProxy(dfs.getGosuClass())) {
        return getBoundedParamTypesFromProxiedClass(dfs);
      }

      for (int i = 0; i < dfs.getArgs().size(); i++) {
        boundedTypes.add(
            IRTypeResolver.getDescriptor(
                TypeLord.getDefaultParameterizedTypeWithTypeVars(dfs.getArgs().get(i).getType())));
      }
      return boundedTypes;
    } else {
      return getTypeDescriptors(mi.getParameters());
    }
  }
 @Override
 protected Object evaluate(Iterator args) {
   Object[] argArray = new Object[_ci.getParameters().length];
   if (_boundValues != null) {
     args = Arrays.asList(_boundValues).iterator();
   }
   for (int i = 0; i < argArray.length; i++) {
     argArray[i] = args.next();
   }
   return _ci.getConstructor().newInstance(argArray);
 }
  // TODO - AHK - Duplicate of method in AbstractElementTransformer
  @Override
  public IType getOwningIType() {
    IType owningType;
    if (_constructor instanceof IJavaConstructorInfo) {
      // We have to get the owner type from the method because it may be
      // different from the owning type e.g., entity aspects see ContactGosuAspect.AllAdresses
      IJavaClassConstructor m = ((IJavaConstructorInfo) _constructor).getJavaConstructor();
      if (m != null) {
        owningType = TypeSystem.get(m.getEnclosingClass());
      } else {
        owningType = _constructor.getOwnersType();
      }
    } else {
      owningType = _constructor.getOwnersType();
    }

    return owningType;
  }
 @Override
 public IFunctionType getFunctionType() {
   if (_constructor instanceof IGosuConstructorInfo
       && !IGosuClass.ProxyUtil.isProxy(_constructor.getOwnersType())) {
     return (IFunctionType) ((IGosuConstructorInfo) _constructor).getDfs().getType();
   } else {
     return null;
   }
 }
 @Override
 public IGenericTypeVariable[] getTypeVariables() {
   if (_constructor instanceof IGosuConstructorInfo
       && !IGosuClass.ProxyUtil.isProxy(_constructor.getOwnersType())) {
     return ((IGosuConstructorInfo) _constructor).getTypeVariables();
   } else {
     return null;
   }
 }
 @Override
 public List<IType> getFullArgTypes() {
   ArrayList<IType> lst = new ArrayList<IType>();
   if (_boundValues == null) {
     for (IParameterInfo pi : _ci.getParameters()) {
       lst.add(pi.getFeatureType());
     }
   }
   return lst;
 }
  private static IRType getTrueOwningType(IConstructorInfo mi) {
    if (mi instanceof IJavaConstructorInfo) {
      // We have to get the owner type from the method because it may be different from the owning
      // type e.g., entity aspects see ContactGosuAspect.AllAdresses
      IJavaClassConstructor m = ((IJavaConstructorInfo) mi).getJavaConstructor();
      if (m != null) {
        return IRTypeResolver.getDescriptor(m.getEnclosingClass());
      }
    }

    return IRTypeResolver.getDescriptor(mi.getOwnersType());
  }
Пример #8
0
  private void genConstructor(StringBuilder sb, IConstructorInfo ci) {
    if (ci.isPrivate()
        || ((ci instanceof JavaConstructorInfo) && ((JavaConstructorInfo) ci).isSynthetic())) {
      return;
    }

    sb.append("  construct(");
    IParameterInfo[] params = getGenericParameters(ci);
    for (int i = 0; i < params.length; i++) {
      IParameterInfo pi = params[i];
      sb.append(' ')
          .append("p")
          .append(i)
          .append(" : ")
          .append(pi.getFeatureType().getName())
          .append(i < params.length - 1 ? ',' : ' ');
    }
    sb.append(")\n").append("{\n").append("}\n");
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    ConstructorReference that = (ConstructorReference) o;

    if (!Arrays.equals(_boundValues, that._boundValues)) {
      return false;
    }
    if (_ci != null ? !_ci.equals(that._ci) : that._ci != null) {
      return false;
    }

    return true;
  }
Пример #10
0
 private IParameterInfo[] getGenericParameters(IConstructorInfo ci) {
   return (ci instanceof JavaConstructorInfo)
       ? ((JavaConstructorInfo) ci).getGenericParameters()
       : ci.getParameters();
 }
 public IType getRootType() {
   return _ci.getType();
 }
 @Override
 public int hashCode() {
   int result = _ci != null ? _ci.hashCode() : 0;
   result = 31 * result + (_boundValues != null ? Arrays.hashCode(_boundValues) : 0);
   return result;
 }
 @Override
 public boolean couldHaveTypeVariables() {
   return _constructor instanceof IGosuMethodInfo
       && !IGosuClass.ProxyUtil.isProxy(_constructor.getOwnersType());
 }