@Override
 public ICPPDeferredClassInstance asDeferredInstance() {
   if (fDeferredInstance == null) {
     fDeferredInstance = CPPTemplates.createDeferredInstance(this);
   }
   return fDeferredInstance;
 }
Esempio n. 2
0
  @Override
  public boolean equals(Object obj) {
    if ((obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)) {
      final ICPPTemplateInstance inst = (ICPPTemplateInstance) obj;
      ICPPFunctionType ct1 = ((ICPPFunction) getSpecializedBinding()).getType();
      ICPPFunctionType ct2 = ((ICPPFunction) inst.getTemplateDefinition()).getType();
      if (!ct1.isSameType(ct2)) return false;

      return CPPTemplates.haveSameArguments(this, inst);
    }

    return false;
  }
  @Override
  public IBinding specializeMember(IBinding original, IASTNode point) {
    if (specializationMap == null) {
      final Long key = record + PDOMCPPLinkage.CACHE_INSTANCE_SCOPE;
      Object cached = getPDOM().getCachedResult(key);
      if (cached != null) {
        specializationMap = (ObjectMap) cached;
      } else {
        final ObjectMap newMap = new ObjectMap(2);
        try {
          PDOMClassUtil.NestedClassCollector visitor = new PDOMClassUtil.NestedClassCollector();
          PDOMCPPClassScope.acceptViaCache(this, visitor, false);
          final ICPPClassType[] nested = visitor.getNestedClasses();
          for (ICPPClassType classType : nested) {
            if (classType instanceof ICPPSpecialization) {
              newMap.put(((ICPPSpecialization) classType).getSpecializedBinding(), classType);
            }
          }
        } catch (CoreException e) {
          CCorePlugin.log(e);
        }
        specializationMap = (ObjectMap) getPDOM().putCachedResult(key, newMap, false);
      }
    }
    Set<IBinding> set;
    synchronized (specializationMap) {
      IBinding result = (IBinding) specializationMap.get(original);
      if (result != null) return result;
      set = fInProgress.get();
      if (set == null) {
        set = new HashSet<IBinding>();
        fInProgress.set(set);
      }
      if (!set.add(original)) return RecursionResolvingBinding.createFor(original, point);
    }
    IBinding newSpec = CPPTemplates.createSpecialization(this, original, point);
    set.remove(original);

    synchronized (specializationMap) {
      IBinding oldSpec = (IBinding) specializationMap.put(original, newSpec);
      if (oldSpec != null) {
        specializationMap.put(original, oldSpec);
        return oldSpec;
      }
    }
    return newSpec;
  }
 @Override
 @Deprecated
 public IType[] getArguments() throws DOMException {
   return CPPTemplates.getArguments(getTemplateArguments());
 }
 @Override
 @Deprecated
 public ObjectMap getArgumentMap() {
   return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap());
 }
Esempio n. 6
0
 @Override
 @Deprecated
 public IType[] getArguments() {
   return CPPTemplates.getArguments(fArguments);
 }