1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 13:25:45 +02:00

For deferred class instances also defer selection of partial instantiation, bug 229218.

This commit is contained in:
Markus Schorn 2008-05-08 13:10:05 +00:00
parent 3b147b1e56
commit eb179298f4
53 changed files with 871 additions and 709 deletions

View file

@ -2314,7 +2314,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// }; // };
// //
// void main(Iter<int*>::iter_reference r); // void main(Iter<int*>::iter_reference r);
public void _testSpecializationSelection_229218() throws Exception { public void testSpecializationSelection_229218() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();
tu.accept(col); tu.accept(col);

View file

@ -1,16 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others. * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
/*
* Created on Mar 31, 2005
*/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
@ -18,6 +16,6 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
/** /**
* @author aniefer * @author aniefer
*/ */
public interface ICPPClassTemplate extends ICPPTemplateDefinition { public interface ICPPClassTemplate extends ICPPTemplateDefinition, ICPPClassType {
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException; public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException;
} }

View file

@ -1,19 +1,20 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
/** /**
* @author Doug Schaefer * Base interface for all template definitions including explicit (partial) specializations.
*/ */
public interface ICPPTemplateDefinition extends ICPPBinding { public interface ICPPTemplateDefinition extends ICPPBinding {
@ -24,4 +25,10 @@ public interface ICPPTemplateDefinition extends ICPPBinding {
* @return array of ICPPTemplateParameter * @return array of ICPPTemplateParameter
*/ */
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException; public ICPPTemplateParameter[] getTemplateParameters() throws DOMException;
/**
* Returns the scope defined by this template definition.
* @since 5.0
*/
public ICPPTemplateScope getTemplateScope() throws DOMException;
} }

View file

@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
@ -49,9 +48,9 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType {
if (cls != null) { if (cls != null) {
ICPPBase[] result = null; ICPPBase[] result = null;
ICPPBase[] bindings = cls.getBases(); ICPPBase[] bindings = cls.getBases();
for (int i = 0; i < bindings.length; i++) { for (ICPPBase binding : bindings) {
ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase) bindings[i]).clone(); ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase) binding).clone();
IBinding base = bindings[i].getBaseClass(); IBinding base = binding.getBaseClass();
if (base instanceof IType) { if (base instanceof IType) {
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap); IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
specBase = getUltimateType(specBase, false); specBase = getUltimateType(specBase, false);
@ -125,7 +124,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType {
return true; return true;
if (type instanceof ITypedef || type instanceof IIndexType) if (type instanceof ITypedef || type instanceof IIndexType)
return type.isSameType(this); return type.isSameType(this);
if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType) if (type instanceof ICPPDeferredClassInstance)
return type.isSameType(this); // the CPPDeferredClassInstance has some fuzziness return type.isSameType(this); // the CPPDeferredClassInstance has some fuzziness
if (type instanceof ICPPTemplateInstance) { if (type instanceof ICPPTemplateInstance) {

View file

@ -47,7 +47,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
this.specialization = specialization; this.specialization = specialization;
} }
private ICPPClassType getOriginalClass() { protected ICPPClassType getOriginalClass() {
return (ICPPClassType) specialization.getSpecializedBinding(); return (ICPPClassType) specialization.getSpecializedBinding();
} }
@ -88,8 +88,8 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
return null; return null;
IBinding[] specs = new IBinding[0]; IBinding[] specs = new IBinding[0];
for (int i = 0; i < bindings.length; i++) { for (IBinding binding : bindings) {
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i])); specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(binding));
} }
specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs); specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
return CPPSemantics.resolveAmbiguities(name, specs); return CPPSemantics.resolveAmbiguities(name, specs);
@ -111,8 +111,8 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null; classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null;
if (bindings != null) { if (bindings != null) {
for (int i = 0; i < bindings.length; i++) { for (IBinding binding : bindings) {
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, getInstance(bindings[i])); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, getInstance(binding));
} }
} }
@ -142,8 +142,8 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
if (bindings == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; if (bindings == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
ICPPConstructor[] specs = new ICPPConstructor[0]; ICPPConstructor[] specs = new ICPPConstructor[0];
for (int i = 0; i < bindings.length; i++) { for (ICPPConstructor binding : bindings) {
specs = (ICPPConstructor[]) ArrayUtil.append(ICPPConstructor.class, specs, getInstance(bindings[i])); specs = (ICPPConstructor[]) ArrayUtil.append(ICPPConstructor.class, specs, getInstance(binding));
} }
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs); return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
} }
@ -155,8 +155,8 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
if (bindings == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; if (bindings == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
ICPPMethod[] specs = new ICPPMethod[0]; ICPPMethod[] specs = new ICPPMethod[0];
for (int i = 0; i < bindings.length; i++) { for (ICPPMethod binding : bindings) {
specs = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, specs, getInstance(bindings[i])); specs = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, specs, getInstance(binding));
} }
return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, specs); return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, specs);
} }

View file

@ -1,22 +1,22 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others. * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
/*
* Created on May 2, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
@ -24,7 +24,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition.CPPTemplateProblem;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/** /**
@ -128,4 +131,16 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
public String toString() { public String toString() {
return getName(); return getName();
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
IScope scope= getCompositeScope().getParent();
if (scope instanceof ICPPTemplateScope) {
return (ICPPTemplateScope) scope;
}
IASTNode def= getDefinition();
if (def == null) {
def= getDeclarations()[0];
}
throw new DOMException(new CPPTemplateProblem(def, IProblemBinding.SEMANTIC_BAD_SCOPE, CharArrayUtils.EMPTY));
}
} }

View file

@ -8,21 +8,17 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
@ -33,88 +29,36 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* *
* @author aniefer * @author aniefer
*/ */
public class CPPDeferredClassInstance extends CPPInstance public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
implements ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
private IType[] fArguments;
private ObjectMap fArgmap;
private ICPPScope fUnknownScope;
public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) { public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) {
super(null, orig, argMap, arguments); super(orig);
fArgmap= argMap;
fArguments= arguments;
} }
public ICPPBase[] getBases() throws DOMException { private ICPPClassTemplate getClassTemplate() {
return ((ICPPClassType) getClassTemplate()).getBases(); return (ICPPClassTemplate) getSpecializedBinding();
}
public IField[] getFields() {
return null;
}
public IField findField(String name) {
return null;
}
public ICPPField[] getDeclaredFields() {
return null;
}
public ICPPMethod[] getMethods() {
return null;
}
public ICPPMethod[] getAllDeclaredMethods() {
return null;
}
public ICPPMethod[] getDeclaredMethods() {
return null;
}
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
public IBinding[] getFriends() {
return null;
}
public int getKey() throws DOMException {
return ((ICPPClassType) getClassTemplate()).getKey();
}
public IScope getCompositeScope() throws DOMException {
if (getArgumentMap() != null) {
return new CPPClassSpecializationScope(this);
}
return ((ICPPClassType) getClassTemplate()).getCompositeScope();
} }
@Override @Override
public Object clone() { public CPPDeferredClassInstance clone() {
return this; CPPDeferredClassInstance cloned= (CPPDeferredClassInstance) super.clone();
return cloned;
} }
public IType instantiate(ObjectMap argMap) { @Override
IType[] arguments = getArguments();
IType[] newArgs = new IType[arguments.length];
int size = arguments.length;
for (int i = 0; i < size; i++) {
newArgs[i] = CPPTemplates.instantiateType(arguments[i], argMap);
}
ICPPClassTemplate classTemplate = getClassTemplate();
if (argMap.containsKey(classTemplate)) {
classTemplate = (ICPPClassTemplate) argMap.get(classTemplate);
}
return (IType) ((ICPPInternalTemplateInstantiator) classTemplate).instantiate(newArgs);
}
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
if (type == this) if (type == this)
return true; return true;
// allow some fuzziness here. // allow some fuzziness here.
ICPPClassTemplate classTemplate = getClassTemplate(); ICPPClassTemplate classTemplate = getClassTemplate();
if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType) { if (type instanceof ICPPDeferredClassInstance) {
ICPPClassTemplate typeClass = ICPPClassTemplate typeClass =
(ICPPClassTemplate) ((ICPPDeferredTemplateInstance) type).getSpecializedBinding(); (ICPPClassTemplate) ((ICPPDeferredTemplateInstance) type).getSpecializedBinding();
return typeClass == classTemplate; return typeClass == classTemplate;
@ -127,11 +71,56 @@ public class CPPDeferredClassInstance extends CPPInstance
return false; return false;
} }
public ICPPClassType[] getNestedClasses() throws DOMException { @Override
return null; public int getKey() throws DOMException {
return getClassTemplate().getKey();
}
public IType[] getArguments() {
return fArguments;
} }
private ICPPClassTemplate getClassTemplate() { public ICPPTemplateDefinition getTemplateDefinition() {
return (ICPPClassTemplate) getSpecializedBinding(); return (ICPPTemplateDefinition) scopeBinding;
}
public ObjectMap getArgumentMap() {
return fArgmap;
}
@Override
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
IType[] arguments = getArguments();
IType[] newArgs = new IType[arguments.length];
int size = arguments.length;
for (int i = 0; i < size; i++) {
newArgs[i] = CPPTemplates.instantiateType(arguments[i], argMap);
}
ICPPClassTemplate classTemplate = getClassTemplate();
if (argMap.containsKey(classTemplate)) {
classTemplate = (ICPPClassTemplate) argMap.get(classTemplate);
}
return ((ICPPInternalTemplateInstantiator) classTemplate).instantiate(newArgs);
}
public IBinding getSpecializedBinding() {
return getTemplateDefinition();
}
@Override
public ICPPScope getUnknownScope() throws DOMException {
if (fUnknownScope != null)
return fUnknownScope;
final ICPPClassTemplate classTemplate = getClassTemplate();
if (classTemplate.getPartialSpecializations().length == 0) {
if (fArgmap == null) {
return fUnknownScope= (ICPPScope) classTemplate.getCompositeScope();
}
return fUnknownScope= new CPPClassSpecializationScope(this);
}
return super.getUnknownScope();
} }
} }

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@ -93,6 +94,9 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
public boolean takesVarArgs() throws DOMException { public boolean takesVarArgs() throws DOMException {
throw new DOMException( this ); throw new DOMException( this );
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
throw new DOMException( this );
}
} }
protected IFunctionType type = null; protected IFunctionType type = null;

View file

@ -6,18 +6,25 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition.CPPTemplateProblem;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/** /**
@ -76,4 +83,17 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) { public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
return null; return null;
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
IScope scope= getFunctionScope().getParent();
if (scope instanceof ICPPTemplateScope) {
return (ICPPTemplateScope) scope;
}
IASTNode def= getDefinition();
if (def == null) {
def= getDeclarations()[0];
}
throw new DOMException(new CPPTemplateProblem(def, IProblemBinding.SEMANTIC_BAD_SCOPE, CharArrayUtils.EMPTY));
}
} }

View file

@ -1,17 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others. * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
/*
* Created on Mar 14, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ILinkage;
@ -41,7 +38,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
@ -73,6 +72,9 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
public boolean isGloballyQualified() throws DOMException { public boolean isGloballyQualified() throws DOMException {
throw new DOMException(this); throw new DOMException(this);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
throw new DOMException(this);
}
} }
//private IASTName templateName; //private IASTName templateName;
@ -161,8 +163,8 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
public void addSpecialization(IType[] types, ICPPSpecialization spec) { public void addSpecialization(IType[] types, ICPPSpecialization spec) {
if (types == null) if (types == null)
return; return;
for (int i = 0; i < types.length; i++) { for (IType type : types) {
if (types[i] == null) if (type == null)
return; return;
} }
if (instances == null) if (instances == null)
@ -237,6 +239,15 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
return definition != null ? definition : declarations[0]; return definition != null ? definition : declarations[0];
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
final IASTName name = getTemplateName();
ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(name);
if (template != null) {
return template.getScope();
}
throw new DOMException(new CPPTemplateProblem(name, IProblemBinding.SEMANTIC_BAD_SCOPE, CharArrayUtils.EMPTY));
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
@ -290,13 +301,13 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
ICPPASTTemplateParameter[] params = template.getTemplateParameters(); ICPPASTTemplateParameter[] params = template.getTemplateParameters();
ICPPTemplateParameter p = null; ICPPTemplateParameter p = null;
ICPPTemplateParameter[] result = null; ICPPTemplateParameter[] result = null;
for (int i = 0; i < params.length; i++) { for (ICPPASTTemplateParameter param : params) {
if (params[i] instanceof ICPPASTSimpleTypeTemplateParameter) { if (param instanceof ICPPASTSimpleTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter) params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter) param).getName().resolveBinding();
} else if (params[i] instanceof ICPPASTParameterDeclaration) { } else if (param instanceof ICPPASTParameterDeclaration) {
p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration) params[i]).getDeclarator().getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration) param).getDeclarator().getName().resolveBinding();
} else if (params[i] instanceof ICPPASTTemplatedTypeTemplateParameter) { } else if (param instanceof ICPPASTTemplatedTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter) params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter) param).getName().resolveBinding();
} }
if (p != null) { if (p != null) {

View file

@ -1,17 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others. * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
/*
* Created on Mar 11, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
@ -87,8 +84,8 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
return ((ICPPClassType) binding).getCompositeScope(); return ((ICPPClassType) binding).getCompositeScope();
} else if (binding instanceof ICPPNamespace) { } else if (binding instanceof ICPPNamespace) {
return ((ICPPNamespace) binding).getNamespaceScope(); return ((ICPPNamespace) binding).getNamespaceScope();
} else if (binding instanceof ICPPInternalUnknown) { } else if (binding instanceof ICPPUnknownBinding) {
return ((ICPPInternalUnknown) binding).getUnknownScope(); return ((ICPPUnknownBinding) binding).getUnknownScope();
} else if (binding instanceof IProblemBinding) { } else if (binding instanceof IProblemBinding) {
if (binding instanceof ICPPScope) if (binding instanceof ICPPScope)
return (IScope) binding; return (IScope) binding;

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -23,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@ -31,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
@ -40,7 +43,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* @author aniefer * @author aniefer
*/ */
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPInternalUnknown { ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPUnknownBinding {
private ICPPTemplateParameter[] templateParameters = null; private ICPPTemplateParameter[] templateParameters = null;
private ObjectMap instances = null; private ObjectMap instances = null;
@ -71,13 +74,13 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
ICPPASTTemplateParameter[] params = template.getTemplateParameters(); ICPPASTTemplateParameter[] params = template.getTemplateParameters();
ICPPTemplateParameter p = null; ICPPTemplateParameter p = null;
ICPPTemplateParameter[] result = null; ICPPTemplateParameter[] result = null;
for (int i = 0; i < params.length; i++) { for (ICPPASTTemplateParameter param : params) {
if (params[i] instanceof ICPPASTSimpleTypeTemplateParameter) { if (param instanceof ICPPASTSimpleTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)param).getName().resolveBinding();
} else if (params[i] instanceof ICPPASTParameterDeclaration) { } else if (param instanceof ICPPASTParameterDeclaration) {
p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)params[i]).getDeclarator().getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)param).getDeclarator().getName().resolveBinding();
} else if (params[i] instanceof ICPPASTTemplatedTypeTemplateParameter) { } else if (param instanceof ICPPASTTemplatedTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)param).getName().resolveBinding();
} }
if (p != null) { if (p != null) {
@ -224,12 +227,23 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
instances.put(types, spec); instances.put(types, spec);
} }
public IBinding resolveUnknown(ObjectMap argMap) {
return null;
}
public ICPPClassType[] getNestedClasses() { public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY; return ICPPClassType.EMPTY_CLASS_ARRAY;
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return null;
}
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
return null;
}
public IASTName getUnknownName() {
return null;
}
public ICPPBinding getContainerBinding() {
return null;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others. * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -17,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
@ -27,7 +29,7 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
* @author aniefer * @author aniefer
*/ */
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
ICPPTemplateTypeParameter, IType, ICPPInternalUnknown { ICPPTemplateTypeParameter, IType, ICPPUnknownBinding {
private ICPPScope unknownScope; private ICPPScope unknownScope;
public CPPTemplateTypeParameter(IASTName name) { public CPPTemplateTypeParameter(IASTName name) {
@ -65,8 +67,16 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
return false; return false;
} }
public IBinding resolveUnknown(ObjectMap argMap) { public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
// Cannot do resolution here since the result is not necessarily a binding. // Cannot do resolution here since the result is not necessarily a binding.
return null; return null;
} }
public IASTName getUnknownName() {
return null;
}
public ICPPBinding getContainerBinding() {
return null;
}
} }

View file

@ -16,35 +16,34 @@ import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
/** /**
* @author aniefer * @author aniefer
*/ */
public abstract class CPPUnknownBinding extends PlatformObject public abstract class CPPUnknownBinding extends PlatformObject
implements ICPPInternalUnknown, Cloneable { implements ICPPUnknownBinding, ICPPInternalBinding, Cloneable {
private ICPPScope unknownScope; private ICPPScope unknownScope;
protected ICPPInternalUnknown scopeBinding; protected ICPPBinding scopeBinding;
protected IASTName name; protected IASTName name;
public CPPUnknownBinding(ICPPInternalUnknown scopeBinding, IASTName name) { public CPPUnknownBinding(ICPPUnknownBinding scopeBinding, IASTName name) {
super(); super();
this.name = name; this.name = name;
this.scopeBinding = scopeBinding; this.scopeBinding = scopeBinding;
} }
public CPPUnknownBinding(ICPPTemplateDefinition templateDef) {
this.name= new CPPASTName(templateDef.getNameCharArray());
this.scopeBinding= templateDef;
}
public IASTNode[] getDeclarations() { public IASTNode[] getDeclarations() {
return null; return null;
} }
@ -82,55 +81,23 @@ public abstract class CPPUnknownBinding extends PlatformObject
return name.toCharArray(); return name.toCharArray();
} }
public IScope getScope() { public IScope getScope() throws DOMException {
return scopeBinding.getUnknownScope(); if (scopeBinding instanceof ICPPUnknownBinding) {
return ((ICPPUnknownBinding) scopeBinding).getUnknownScope();
} else if (scopeBinding instanceof ICPPTemplateDefinition) {
return ((ICPPTemplateDefinition) scopeBinding).getTemplateScope();
}
assert false;
return null;
} }
public ICPPScope getUnknownScope() { public ICPPScope getUnknownScope() throws DOMException {
if (unknownScope == null) { if (unknownScope == null) {
unknownScope = new CPPUnknownScope(this, name); unknownScope = new CPPUnknownScope(this, name);
} }
return unknownScope; return unknownScope;
} }
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
IType t = null;
if (scopeBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) scopeBinding, argMap);
} else if (scopeBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) scopeBinding).resolveUnknown(argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
// If name did not come from an AST but was created just to encapsulate
// a simple identifier, we should not use getBinding method since it may
// lead to a NullPointerException.
if (name.getParent() != null) {
result = s.getBinding(name, true);
} else {
IBinding[] bindings = s.find(name.toString());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
}
} else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap);
}
}
return result;
}
protected abstract IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap);
public ILinkage getLinkage() { public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE; return Linkage.CPP_LINKAGE;
} }
@ -148,4 +115,12 @@ public abstract class CPPUnknownBinding extends PlatformObject
public String toString() { public String toString() {
return getName(); return getName();
} }
public IASTName getUnknownName() {
return name;
}
public ICPPBinding getContainerBinding() {
return scopeBinding;
}
} }

View file

@ -12,12 +12,14 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
@ -29,12 +31,16 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
* *
* @author aniefer * @author aniefer
*/ */
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUnknownClassType { public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownClassType {
public CPPUnknownClass(ICPPInternalUnknown scopeBinding, IASTName name) { public CPPUnknownClass(ICPPUnknownBinding scopeBinding, IASTName name) {
super(scopeBinding, name); super(scopeBinding, name);
} }
protected CPPUnknownClass(ICPPClassTemplate template) {
super(template);
}
public ICPPBase[] getBases() { public ICPPBase[] getBases() {
return ICPPBase.EMPTY_BASE_ARRAY; return ICPPBase.EMPTY_BASE_ARRAY;
} }
@ -71,11 +77,11 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUn
return IBinding.EMPTY_BINDING_ARRAY; return IBinding.EMPTY_BINDING_ARRAY;
} }
public int getKey() { public int getKey() throws DOMException{
return 0; return 0;
} }
public IScope getCompositeScope() { public final IScope getCompositeScope() throws DOMException {
return getUnknownScope(); return getUnknownScope();
} }
@ -87,8 +93,7 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUn
return ICPPClassType.EMPTY_CLASS_ARRAY; return ICPPClassType.EMPTY_CLASS_ARRAY;
} }
@Override public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
if (parentBinding == this.scopeBinding) { if (parentBinding == this.scopeBinding) {
return this; return this;
} }

View file

@ -11,12 +11,9 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
@ -25,10 +22,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* *
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPInternalUnknownClassInstance { public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnknownClassInstance {
private final IType[] arguments; private final IType[] arguments;
public CPPUnknownClassInstance(ICPPInternalUnknown scopeBinding, IASTName name, IType[] arguments) { public CPPUnknownClassInstance(ICPPUnknownBinding scopeBinding, IASTName name, IType[] arguments) {
super(scopeBinding, name); super(scopeBinding, name);
this.arguments = arguments; this.arguments = arguments;
} }
@ -37,24 +34,11 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPInte
return arguments; return arguments;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
@Override
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = super.resolveUnknown(argMap);
if (result instanceof ICPPSpecialization && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
result = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
}
return result;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/ */
@Override @Override
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) { public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap); IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
return new CPPUnknownClassInstance(parentBinding, name, newArgs); return new CPPUnknownClassInstance(parentBinding, name, newArgs);
} }

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -32,11 +33,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* @author aniefer * @author aniefer
*/ */
public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope { public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
private final ICPPInternalUnknown binding; private final ICPPUnknownBinding binding;
private final IASTName scopeName; private final IASTName scopeName;
private CharArrayObjectMap map; private CharArrayObjectMap map;
public CPPUnknownScope(ICPPInternalUnknown binding, IASTName name) { public CPPUnknownScope(ICPPUnknownBinding binding, IASTName name) {
super(); super();
this.scopeName = name; this.scopeName = name;
this.binding = binding; this.binding = binding;
@ -127,8 +128,8 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
IBinding[] result = null; IBinding[] result = null;
if (prefixLookup) { if (prefixLookup) {
Object[] keys = map.keyArray(); Object[] keys = map.keyArray();
for (int i = 0; i < keys.length; i++) { for (Object key2 : keys) {
char[] key = (char[]) keys[i]; char[] key = (char[]) key2;
if (CharArrayUtils.equals(key, 0, c.length, c, true)) { if (CharArrayUtils.equals(key, 0, c.length, c, true)) {
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, map.get(key)); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, map.get(key));
} }
@ -167,7 +168,7 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding() * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding()
*/ */
public ICPPInternalUnknown getScopeBinding() { public ICPPBinding getScopeBinding() {
return binding; return binding;
} }

View file

@ -1,26 +1,20 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others. * Copyright (c) 2007, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/** /**
* @author Bryan Wilkinson * Interface for deferred class template instances.
*
*/ */
public interface ICPPInternalDeferredClassInstance { public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPDeferredTemplateInstance {
/**
* instantiate the original template
*/
public IType instantiate(ObjectMap argMap);
} }

View file

@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* Created on May 3, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* @author aniefer
*/
public interface ICPPInternalUnknown extends ICPPInternalBinding {
public ICPPScope getUnknownScope();
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException;
}

View file

@ -1,31 +0,0 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
/*
* @author Sergey Prigogin
*/
public interface ICPPInternalUnknownClassType extends ICPPClassType, ICPPInternalUnknown {
/**
* Resolves unknown type to another unknown type that is a step closer to the final
* name resolution.
* @param parentBinding a new parent binding, usually a result of partial resolution
* of the original parent binding.
* @param argMap template argument map.
* @return a partially resolved, but still unknown, binding.
*/
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap);
}

View file

@ -10,11 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/** /**
* Scope corresponding to an unknown binding. * Scope corresponding to an unknown binding.
* @see ICPPInternalUnknown
* *
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
@ -23,5 +23,5 @@ public interface ICPPInternalUnknownScope extends IASTInternalScope {
/** /**
* @return Returns the binding corresponding to the scope. * @return Returns the binding corresponding to the scope.
*/ */
public abstract ICPPInternalUnknown getScopeBinding(); public abstract ICPPBinding getScopeBinding();
} }

View file

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* Represents a binding found within a template definition that cannot be resolved until
* the template gets instantiated.
*
* This interface should be made public
* @since 5.0
*/
public interface ICPPUnknownBinding extends ICPPBinding {
/**
* Returns the binding of the scope containing this binding.
* @since 5.0
*/
public ICPPBinding getContainerBinding();
/**
* Returns the scope this binding represents.
* @throws DOMException
*/
public ICPPScope getUnknownScope() throws DOMException;
/**
* Returns a the name of the unknown binding that has to be searched in the parent scope.
* The ast-node may not be rooted in an ast-tree. May be <code>null</code>.
*/
public IASTName getUnknownName();
/**
* Resolves unknown type to another unknown type that is a step closer to the final
* name resolution.
* @param parentBinding a new parent binding, usually a result of partial resolution
* of the original parent binding, or <code>null</code> for deferred template
* instantiations.
* @param argMap template argument map.
* @return a partially resolved, but still unknown, binding.
*/
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap);
}

View file

@ -12,11 +12,15 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
/* /**
* Represents a partially instantiated C++ class template, declaration of which is not yet available. * Represents a partially instantiated C++ class template, declaration of which is not yet available.
* *
* @author Sergey Prigogin * This interface should be made public.
* @since 5.0
*/ */
public interface ICPPInternalUnknownClassInstance extends ICPPInternalUnknownClassType { public interface ICPPUnknownClassInstance extends ICPPUnknownClassType {
/**
* Returns the arguments of the instantiation
*/
public IType[] getArguments(); public IType[] getArguments();
} }

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
/**
* Represents a binding for a type found in a template definition, that can be
* determined only after the template is instantiated.
*
* This interface should be made public.
* @since 5.0
*/
public interface ICPPUnknownClassType extends ICPPUnknownBinding, ICPPClassType {
}

View file

@ -137,6 +137,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDirective; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDirective;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
@ -313,6 +314,11 @@ public class CPPSemantics {
name = (IASTName) name.getParent(); name = (IASTName) name.getParent();
} }
// if the lookup in base-classes ran into a deferred instance, use the computed unknown binding.
if (binding == null && data.unknownBinding != null) {
binding= data.unknownBinding;
}
if (binding != null) { if (binding != null) {
if (name.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !(binding instanceof IType || binding instanceof ICPPConstructor)) { if (name.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !(binding instanceof IType || binding instanceof ICPPConstructor)) {
IASTNode parent = name.getParent().getParent(); IASTNode parent = name.getParent().getParent();
@ -746,18 +752,20 @@ public class CPPSemantics {
} }
private static Object lookupInParents(LookupData data, ICPPScope lookIn) throws DOMException{ private static Object lookupInParents(LookupData data, ICPPScope lookIn) throws DOMException{
ICPPBase[] bases = null; if (lookIn instanceof ICPPClassScope == false)
if (lookIn instanceof ICPPClassScope) { return null;
ICPPClassType c = ((ICPPClassScope)lookIn).getClassType();
if (c != null) final ICPPClassType classType= ((ICPPClassScope)lookIn).getClassType();
bases = c.getBases(); if (classType == null)
} return null;
final ICPPBase[] bases= classType.getBases();
if (bases == null || bases.length == 0)
return null;
Object inherited = null; Object inherited = null;
Object result = null; Object result = null;
if (bases == null || bases.length == 0)
return null;
//use data to detect circular inheritance //use data to detect circular inheritance
if (data.inheritanceChain == null) if (data.inheritanceChain == null)
@ -771,19 +779,27 @@ public class CPPSemantics {
} }
int size = bases.length; int size = bases.length;
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++) {
{
inherited = null; inherited = null;
ICPPClassType cls = null;
IBinding b = bases[i].getBaseClass(); IBinding b = bases[i].getBaseClass();
if (b instanceof ICPPClassType) if (b instanceof ICPPClassType == false)
cls = (ICPPClassType) b;
else
continue; continue;
ICPPScope parent = (ICPPScope) cls.getCompositeScope();
if (parent == null || parent instanceof CPPUnknownScope) final ICPPClassType cls= (ICPPClassType) b;
final ICPPScope parent = (ICPPScope) cls.getCompositeScope();
if (parent == null)
continue; continue;
if (parent instanceof CPPUnknownScope) {
if (data.unknownBinding == null && classType instanceof ICPPClassTemplate && data.astName != null) {
ICPPClassTemplate template= ((ICPPClassTemplate) classType);
IBinding thisType= CPPTemplates.instantiateWithinClassTemplate(template);
if (thisType instanceof ICPPUnknownBinding) {
data.unknownBinding= ((ICPPUnknownBinding) thisType).getUnknownScope().getBinding(data.astName, true);
}
}
continue;
}
if (!bases[i].isVirtual() || !data.visited.containsKey(parent)) { if (!bases[i].isVirtual() || !data.visited.containsKey(parent)) {
if (bases[i].isVirtual()) { if (bases[i].isVirtual()) {

View file

@ -55,10 +55,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
@ -80,6 +82,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet; import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
@ -108,10 +111,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplate; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplate;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
/** /**
* @author aniefer * @author aniefer
@ -733,12 +737,10 @@ public class CPPTemplates {
} else { } else {
newType = t; newType = t;
} }
} else if (type instanceof ICPPInternalDeferredClassInstance) { } else if (type instanceof ICPPUnknownBinding) {
newType = ((ICPPInternalDeferredClassInstance) type).instantiate(argMap);
} else if (type instanceof ICPPInternalUnknown) {
IBinding binding; IBinding binding;
try { try {
binding = ((ICPPInternalUnknown) type).resolveUnknown(argMap); binding = CPPTemplates.resolveUnknown((ICPPUnknownBinding) type, argMap);
} catch (DOMException e) { } catch (DOMException e) {
binding = e.getProblem(); binding = e.getProblem();
} }
@ -1325,7 +1327,7 @@ public class CPPTemplates {
} }
} }
return true; return true;
} else if (p instanceof ICPPInternalUnknown) { } else if (p instanceof ICPPUnknownBinding) {
return true; // An unknown type may match anything. return true; // An unknown type may match anything.
} else { } else {
return p.isSameType(a); return p.isSameType(a);
@ -1478,13 +1480,14 @@ public class CPPTemplates {
//to order class template specializations, we need to transform them into function templates //to order class template specializations, we need to transform them into function templates
ICPPFunctionTemplate template1 = null, template2 = null; ICPPFunctionTemplate template1 = null, template2 = null;
if (spec1 instanceof ICPPClassType) { // if (spec1 instanceof ICPPClassType) {
template1 = classTemplateSpecializationToFunctionTemplate(spec1); template1 = classTemplateSpecializationToFunctionTemplate(spec1);
template2 = classTemplateSpecializationToFunctionTemplate(spec2); template2 = classTemplateSpecializationToFunctionTemplate(spec2);
} else if (spec1 instanceof ICPPFunction) { // }
template1 = (ICPPFunctionTemplate) spec1; // else if (spec1 instanceof ICPPFunction) {
template2 = (ICPPFunctionTemplate) spec2; // template1 = (ICPPFunctionTemplate) spec1;
} // template2 = (ICPPFunctionTemplate) spec2;
// }
return orderTemplateFunctions(template1, template2); return orderTemplateFunctions(template1, template2);
} }
@ -1528,9 +1531,6 @@ public class CPPTemplates {
* arguments of the partial specialization * arguments of the partial specialization
*/ */
static private ICPPFunctionTemplate classTemplateSpecializationToFunctionTemplate(ICPPClassTemplatePartialSpecialization specialization) { static private ICPPFunctionTemplate classTemplateSpecializationToFunctionTemplate(ICPPClassTemplatePartialSpecialization specialization) {
if (!(specialization instanceof ICPPClassType))
return null;
ICPPTemplateDefinition template = specialization; ICPPTemplateDefinition template = specialization;
IType[] args = null; IType[] args = null;
try { try {
@ -1695,10 +1695,18 @@ public class CPPTemplates {
if (map.containsKey(defaultType)) { if (map.containsKey(defaultType)) {
arg = (IType) map.get(defaultType); arg = (IType) map.get(defaultType);
} }
} else if (defaultType instanceof ICPPInternalDeferredClassInstance) { } else if (defaultType instanceof ICPPUnknownBinding) {
// A default template parameter may be depend on a previously defined // A default template parameter may be depend on a previously defined
// parameter: template<typename T1, typename T2 = A<T1> > class B {}; // parameter: template<typename T1, typename T2 = A<T1> > class B {};
arg = ((ICPPInternalDeferredClassInstance) defaultType).instantiate(map); IType resolvedType= null;
try {
IBinding resolved= CPPTemplates.resolveUnknown((ICPPUnknownBinding) defaultType, map);
if (resolved instanceof IType) {
resolvedType= (IType) resolved;
}
} catch (DOMException e) {
}
arg= resolvedType == null ? defaultType : resolvedType;
} else { } else {
arg = defaultType; arg = defaultType;
} }
@ -1784,4 +1792,53 @@ public class CPPTemplates {
return new ICPPBase[0]; return new ICPPBase[0];
} }
/**
* Attempts to (partially) resolve an unknown binding with the given arguments.
*/
public static IBinding resolveUnknown(ICPPUnknownBinding unknown, ObjectMap argMap) throws DOMException {
ICPPBinding parentBinding= unknown.getContainerBinding();
IBinding result = unknown;
IType t = null;
if (parentBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) parentBinding, argMap);
} else if (parentBinding instanceof ICPPUnknownClassType) {
IBinding binding= CPPTemplates.resolveUnknown((ICPPUnknownClassType) parentBinding, argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPUnknownBinding) {
result = unknown.resolvePartially((ICPPUnknownBinding) t, argMap);
} else if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
// If name did not come from an AST but was created just to encapsulate
// a simple identifier, we should not use getBinding method since it may
// lead to a NullPointerException.
IASTName name= unknown.getUnknownName();
if (name != null) {
if (name.getParent() != null) {
result = s.getBinding(name, true);
} else {
IBinding[] bindings = s.find(name.toString());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
if (unknown instanceof ICPPUnknownClassInstance && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(((ICPPUnknownClassInstance) unknown).getArguments(), argMap);
result = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
}
}
}
}
} else if (unknown instanceof ICPPDeferredTemplateInstance) {
result= unknown.resolvePartially(null, argMap);
}
return result;
}
} }

View file

@ -177,7 +177,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerToMemberType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
/** /**
@ -924,8 +924,8 @@ public class CPPVisitor {
scope= ((ICPPClassType)binding).getCompositeScope(); scope= ((ICPPClassType)binding).getCompositeScope();
} else if (binding instanceof ICPPNamespace) { } else if (binding instanceof ICPPNamespace) {
scope= ((ICPPNamespace)binding).getNamespaceScope(); scope= ((ICPPNamespace)binding).getNamespaceScope();
} else if (binding instanceof ICPPInternalUnknown) { } else if (binding instanceof ICPPUnknownBinding) {
scope= ((ICPPInternalUnknown)binding).getUnknownScope(); scope= ((ICPPUnknownBinding)binding).getUnknownScope();
} else if (binding instanceof IProblemBinding) { } else if (binding instanceof IProblemBinding) {
if (binding instanceof ICPPScope) if (binding instanceof ICPPScope)
scope= (IScope) binding; scope= (IScope) binding;

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -95,6 +96,7 @@ class LookupData {
public boolean typesOnly = false; public boolean typesOnly = false;
public boolean considerConstructors = false; public boolean considerConstructors = false;
public IBinding unknownBinding= null;
public Object foundItems = null; public Object foundItems = null;
public Object [] functionParameters; public Object [] functionParameters;
public IASTNode [] templateArguments; public IASTNode [] templateArguments;

View file

@ -13,11 +13,10 @@
package org.eclipse.cdt.internal.core.index.composite; package org.eclipse.cdt.internal.core.index.composite;
import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
@ -71,7 +70,7 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
return new String[] {getName()}; return new String[] {getName()};
} }
public IScope getScope() throws DOMException { public IIndexScope getScope() {
return cf.getCompositeScope(rbinding.getScope()); return cf.getCompositeScope(rbinding.getScope());
} }

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -51,8 +52,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexMacroContainer; import org.eclipse.cdt.core.index.IIndexMacroContainer;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
import org.eclipse.cdt.internal.core.index.CIndex; import org.eclipse.cdt.internal.core.index.CIndex;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
@ -254,10 +255,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
result = new CompositeCPPField(this, (ICPPField) binding); result = new CompositeCPPField(this, (ICPPField) binding);
} else if (binding instanceof ICPPVariable) { } else if (binding instanceof ICPPVariable) {
result = new CompositeCPPVariable(this, (ICPPVariable) binding); result = new CompositeCPPVariable(this, (ICPPVariable) binding);
} else if (binding instanceof ICPPInternalUnknownClassInstance) { } else if (binding instanceof ICPPUnknownClassInstance) {
result = new CompositeCPPUnknownClassInstance(this, (ICPPInternalUnknownClassInstance) binding); result = new CompositeCPPUnknownClassInstance(this, (ICPPUnknownClassInstance) binding);
} else if (binding instanceof ICPPInternalUnknownClassType) { } else if (binding instanceof ICPPUnknownClassType) {
result = new CompositeCPPUnknownClassType(this, (ICPPInternalUnknownClassType) binding); result = new CompositeCPPUnknownClassType(this, (ICPPUnknownClassType) binding);
} else if (binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
ICPPClassType def = (ICPPClassType) findOneBinding(binding); ICPPClassType def = (ICPPClassType) findOneBinding(binding);
result = def == null ? null : new CompositeCPPClassType(this, def); result = def == null ? null : new CompositeCPPClassType(this, def);

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -21,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
@ -30,8 +32,8 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class CompositeCPPClassTemplate extends CompositeCPPClassType implements public class CompositeCPPClassTemplate extends CompositeCPPClassType
ICPPClassTemplate, ICPPInternalTemplateInstantiator { implements ICPPClassTemplate, ICPPInternalTemplateInstantiator {
public CompositeCPPClassTemplate(ICompositesFactory cf, ICPPClassType ct) { public CompositeCPPClassTemplate(ICompositesFactory cf, ICPPClassType ct) {
super(cf, ct); super(cf, ct);
@ -88,4 +90,8 @@ ICPPClassTemplate, ICPPInternalTemplateInstantiator {
return CPPTemplates.instantiateTemplate(this, arguments, null); return CPPTemplates.instantiateTemplate(this, arguments, null);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getCompositeScope().getParent();
}
} }

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
@ -25,7 +24,7 @@ import org.eclipse.core.runtime.CoreException;
public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader { public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
public CompositeCPPClassTemplatePartialSpecialization(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization delegate) { public CompositeCPPClassTemplatePartialSpecialization(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization delegate) {
super(cf, (ICPPClassType) delegate); super(cf, delegate);
} }
public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException { public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException {

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others. * Copyright (c) 2007, 2008 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -18,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
@ -59,4 +61,7 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInternalTempla
return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding); return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getCompositeScope().getParent();
}
} }

View file

@ -1,31 +1,39 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others. * Copyright (c) 2007, 2008 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType implements ICPPInternalDeferredClassInstance, ICPPDeferredTemplateInstance, ICPPSpecialization { public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType implements ICPPDeferredClassInstance {
private ICPPScope unknownScope;
public CompositeCPPDeferredClassInstance(ICompositesFactory cf, ICPPClassType rbinding) { public CompositeCPPDeferredClassInstance(ICompositesFactory cf, ICPPClassType rbinding) {
super(cf, rbinding); super(cf, rbinding);
@ -41,25 +49,36 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
} }
// TODO - what happens to the arguments? public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
public ICPPSpecialization deferredInstance(IType[] arguments, ObjectMap argMap) { public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
ICPPSpecialization spec= ((ICPPInternalTemplateInstantiator) rbinding).deferredInstance(argMap, arguments); public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)spec);
public IASTName getUnknownName() {
return ((ICPPUnknownClassType) rbinding).getUnknownName();
} }
// TODO - what happens to the arguments? public ICPPBinding getContainerBinding() {
public ICPPSpecialization getInstance(IType[] arguments) { ICPPBinding scopeBinding= ((ICPPUnknownClassType) rbinding).getContainerBinding();
ICPPSpecialization ins= ((ICPPInternalTemplateInstantiator)rbinding).getInstance(arguments); return (ICPPBinding) cf.getCompositeBinding((IIndexFragmentBinding)scopeBinding);
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)ins);
} }
// TODO - what happens to the arguments? public ICPPScope getUnknownScope() throws DOMException {
public IBinding instantiate(IType[] arguments) { if (unknownScope == null) {
IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments); final ICPPClassTemplate classTemplate= (ICPPClassTemplate) getTemplateDefinition();
return cf.getCompositeBinding((IIndexFragmentBinding)ins); if (classTemplate.getPartialSpecializations().length == 0) {
unknownScope= new CompositeCPPClassSpecializationScope(cf, rbinding);
}
else {
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
}
}
return unknownScope;
} }
public IType instantiate(ObjectMap argMap) { /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUnknownBinding#resolvePartially(org.eclipse.cdt.core.dom.ast.cpp.ICPPUnknownClassBinding, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
IType[] arguments = getArguments(); IType[] arguments = getArguments();
IType [] newArgs = new IType[ arguments.length ]; IType [] newArgs = new IType[ arguments.length ];
@ -68,10 +87,6 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
newArgs[i] = CPPTemplates.instantiateType( arguments[i], argMap ); newArgs[i] = CPPTemplates.instantiateType( arguments[i], argMap );
} }
return (IType) ((ICPPInternalTemplateInstantiator)getTemplateDefinition()).instantiate( newArgs ); return ((ICPPInternalTemplateInstantiator)getTemplateDefinition()).instantiate( newArgs );
} }
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
} }

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -17,12 +18,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPFunctionTemplate extends CompositeCPPFunction implements ICPPFunctionTemplate, ICPPInternalTemplateInstantiator { public class CompositeCPPFunctionTemplate extends CompositeCPPFunction
implements ICPPFunctionTemplate, ICPPInternalTemplateInstantiator {
public CompositeCPPFunctionTemplate(ICompositesFactory cf, ICPPFunction rbinding) { public CompositeCPPFunctionTemplate(ICompositesFactory cf, ICPPFunction rbinding) {
super(cf, rbinding); super(cf, rbinding);
@ -47,4 +50,8 @@ public class CompositeCPPFunctionTemplate extends CompositeCPPFunction implement
public IBinding instantiate(IType[] arguments) { public IBinding instantiate(IType[] arguments) {
return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding); return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getFunctionScope().getParent();
}
} }

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Systems and others. * Copyright (c) 2007, 2008 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -17,14 +18,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPFunctionTemplateSpecialization public class CompositeCPPFunctionTemplateSpecialization extends CompositeCPPFunctionSpecialization
extends CompositeCPPFunctionSpecialization implements ICPPFunctionTemplate, ICPPInternalTemplateInstantiator {
implements ICPPFunctionTemplate, ICPPInternalTemplateInstantiator {
public CompositeCPPFunctionTemplateSpecialization(ICompositesFactory cf, ICPPFunction ft) { public CompositeCPPFunctionTemplateSpecialization(ICompositesFactory cf, ICPPFunction ft) {
super(cf, ft); super(cf, ft);
@ -49,4 +50,8 @@ public class CompositeCPPFunctionTemplateSpecialization
public IBinding instantiate(IType[] arguments) { public IBinding instantiate(IType[] arguments) {
return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding); return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getFunctionScope().getParent();
}
} }

View file

@ -6,19 +6,15 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
@ -26,14 +22,15 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType
implements ICPPInternalUnknownClassInstance { implements ICPPUnknownClassInstance {
public CompositeCPPUnknownClassInstance(ICompositesFactory cf, public CompositeCPPUnknownClassInstance(ICompositesFactory cf,
ICPPInternalUnknownClassInstance rbinding) { ICPPUnknownClassInstance rbinding) {
super(cf, rbinding); super(cf, rbinding);
} }
public IType[] getArguments() { public IType[] getArguments() {
IType[] arguments = ((ICPPInternalUnknownClassInstance) rbinding).getArguments(); IType[] arguments = ((ICPPUnknownClassInstance) rbinding).getArguments();
try { try {
for (int i = 0; i < arguments.length; i++) { for (int i = 0; i < arguments.length; i++) {
arguments[i] = cf.getCompositeType((IIndexType) arguments[i]); arguments[i] = cf.getCompositeType((IIndexType) arguments[i]);
@ -43,17 +40,4 @@ class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType
} }
return arguments; return arguments;
} }
@Override
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = super.resolveUnknown(argMap);
if (result instanceof ICPPSpecialization && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(getArguments(), argMap);
IBinding instance = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
if (instance != null) {
result = instance;
}
}
return result;
}
} }

View file

@ -6,43 +6,38 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.runtime.CoreException;
/** /**
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
class CompositeCPPUnknownClassType extends CompositeCPPBinding class CompositeCPPUnknownClassType extends CompositeCPPBinding implements ICPPUnknownClassType, IIndexType {
implements ICPPInternalUnknownClassType, IIndexType { private ICPPScope unknownScope;
public CompositeCPPUnknownClassType(ICompositesFactory cf, ICPPInternalUnknownClassType rbinding) {
public CompositeCPPUnknownClassType(ICompositesFactory cf, ICPPUnknownClassType rbinding) {
super(cf, rbinding); super(cf, rbinding);
} }
@ -134,74 +129,21 @@ implements ICPPInternalUnknownClassType, IIndexType {
} }
public ICPPScope getUnknownScope() { public ICPPScope getUnknownScope() {
// TODO Auto-generated method stub if (unknownScope == null) {
return null; unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
}
return unknownScope;
}
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
return ((ICPPUnknownClassType) rbinding).resolvePartially(parentBinding, argMap);
} }
/* (non-Javadoc) public IASTName getUnknownName() {
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap) return ((ICPPUnknownClassType) rbinding).getUnknownName();
*/
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
IType t = null;
try {
if(rbinding instanceof PDOMBinding) {
IIndexFragmentBinding tparentBinding = (IIndexFragmentBinding) ((PDOMBinding) rbinding).getParentBinding();
IIndexBinding parentBinding= cf.getCompositeBinding(tparentBinding);
if (parentBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) parentBinding, argMap);
} else if (parentBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) parentBinding).resolveUnknown(argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
IBinding[] bindings = s.find(getName());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
} else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap);
}
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
}
return result;
} }
/* (non-Javadoc) public ICPPBinding getContainerBinding() {
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap) return ((ICPPUnknownClassType) rbinding).getContainerBinding();
*/
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
return ((ICPPInternalUnknownClassType) rbinding).resolvePartially(parentBinding, argMap);
}
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return null;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
} }
} }

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2008 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
public class CompositeCPPUnknownScope extends CPPUnknownScope implements IIndexScope {
private CompositeCPPBinding fBinding;
public CompositeCPPUnknownScope(CompositeCPPBinding binding, IASTName name) {
super((ICPPUnknownBinding) binding, name);
fBinding= binding;
}
@Override
public IIndexName getScopeName() {
return null;
}
@Override
public IIndexScope getParent() {
return fBinding.getScope();
}
@Override
public CompositeCPPBinding getScopeBinding() {
return fBinding;
}
}

View file

@ -172,6 +172,7 @@ public class PDOM extends PlatformObject implements IPDOM {
* 56 - using directives (bug 216527) * 56 - using directives (bug 216527)
* 57.0 - macro references (bug 156561) * 57.0 - macro references (bug 156561)
* 58.0 - non-type parameters (bug 207840) * 58.0 - non-type parameters (bug 207840)
* 59.0 - changed modeling of deferred class instances (bug 229218)
*/ */
public static final int LINKAGES = Database.DATA_AREA; public static final int LINKAGES = Database.DATA_AREA;

View file

@ -33,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@ -43,6 +42,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -133,7 +133,7 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
} }
if (type instanceof ITypedef) if (type instanceof ITypedef)
return ((ITypedef)type).isSameType(this); return ((ITypedef)type).isSameType(this);
if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType) if (type instanceof ICPPDeferredClassInstance)
return type.isSameType(this); //the CPPDeferredClassInstance has some fuzziness return type.isSameType(this); //the CPPDeferredClassInstance has some fuzziness
if (type instanceof ICPPTemplateInstance) { if (type instanceof ICPPTemplateInstance) {

View file

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope;
import org.eclipse.cdt.internal.core.index.IIndexScope;
/**
* @since 5.0
*/
public class PDOMCPPClassSpecializationScope extends CPPClassSpecializationScope implements IIndexScope {
private final PDOMCPPDeferredClassInstance fBinding;
public PDOMCPPClassSpecializationScope(PDOMCPPDeferredClassInstance specialization) {
super(specialization);
fBinding= specialization;
}
public IIndexBinding getScopeBinding() {
return fBinding;
}
@Override
public IIndexName getScopeName() {
return null;
}
@Override
public IIndexScope getParent() {
ICPPClassType cls = getOriginalClass();
try {
IScope scope = cls.getCompositeScope();
if (scope != null) {
scope= scope.getParent();
if (scope instanceof IIndexScope) {
return (IIndexScope) scope;
}
}
} catch (DOMException e) {
}
return null;
}
}

View file

@ -68,7 +68,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
protected static final int RECORD_SIZE = PDOMCPPClassType.RECORD_SIZE + 16; protected static final int RECORD_SIZE = PDOMCPPClassType.RECORD_SIZE + 16;
public PDOMCPPClassTemplate(PDOM pdom, PDOMNode parent, ICPPClassTemplate template) throws CoreException { public PDOMCPPClassTemplate(PDOM pdom, PDOMNode parent, ICPPClassTemplate template) throws CoreException {
super(pdom, parent, (ICPPClassType) template); super(pdom, parent, template);
} }
public PDOMCPPClassTemplate(PDOM pdom, int bindingRecord) { public PDOMCPPClassTemplate(PDOM pdom, int bindingRecord) {
@ -208,6 +208,10 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
@Override @Override
public IIndexScope getScope() { public IIndexScope getScope() {
return getTemplateScope();
}
public PDOMCPPTemplateScope getTemplateScope() {
if (scope == null) { if (scope == null) {
scope = new PDOMCPPTemplateScope(); scope = new PDOMCPPTemplateScope();
} }

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others. * Copyright (c) 2007, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -19,11 +20,11 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
@ -53,7 +54,7 @@ class PDOMCPPClassTemplateSpecialization extends
public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized) public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
throws CoreException { throws CoreException {
super(pdom, parent, (ICPPClassType) template, specialized); super(pdom, parent, template, specialized);
} }
public PDOMCPPClassTemplateSpecialization(PDOM pdom, int bindingRecord) { public PDOMCPPClassTemplateSpecialization(PDOM pdom, int bindingRecord) {
@ -170,4 +171,11 @@ class PDOMCPPClassTemplateSpecialization extends
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl()); PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
list.accept(visitor); list.accept(visitor);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getTemplateScope()
*/
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getCompositeScope().getParent();
}
} }

View file

@ -1,32 +1,38 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others. * Copyright (c) 2007, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
@ -40,8 +46,7 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Bryan Wilkinson * @author Bryan Wilkinson
*/ */
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements ICPPDeferredClassInstance, IPDOMMemberOwner, IIndexType {
ICPPClassType, IPDOMMemberOwner, IIndexType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
private static final int MEMBERLIST = PDOMCPPInstance.RECORD_SIZE + 0; private static final int MEMBERLIST = PDOMCPPInstance.RECORD_SIZE + 0;
@ -51,6 +56,8 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 4;
private ICPPScope unknownScope;
public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding instantiated) public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding instantiated)
throws CoreException { throws CoreException {
super(pdom, parent, (ICPPTemplateInstance) classType, instantiated); super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
@ -93,7 +100,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
ICPPClassTemplate classTemplate = (ICPPClassTemplate) getTemplateDefinition(); ICPPClassTemplate classTemplate = (ICPPClassTemplate) getTemplateDefinition();
//allow some fuzziness here. //allow some fuzziness here.
if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType) { if (type instanceof ICPPDeferredClassInstance) {
ICPPClassTemplate typeClass = (ICPPClassTemplate) ((ICPPDeferredTemplateInstance)type).getSpecializedBinding(); ICPPClassTemplate typeClass = (ICPPClassTemplate) ((ICPPDeferredTemplateInstance)type).getSpecializedBinding();
return typeClass == classTemplate; return typeClass == classTemplate;
} else if (type instanceof ICPPClassTemplate && classTemplate == type) { } else if (type instanceof ICPPClassTemplate && classTemplate == type) {
@ -109,16 +116,6 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
} }
/**
* @param argMap
* @return This class instance re-instantiated with resolved template arguments.
*/
public IType instantiate(ObjectMap argMap) {
IType[] arguments = getArguments();
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
return (IType) ((ICPPInternalTemplateInstantiator) getTemplateDefinition()).instantiate(newArgs);
}
public void addMember(PDOMNode member) throws CoreException { public void addMember(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl()); PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.addMember(member); list.addMember(member);
@ -156,4 +153,34 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; } public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
@Override @Override
public Object clone() {fail();return null;} public Object clone() {fail();return null;}
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
IType[] arguments = getArguments();
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
return ((ICPPInternalTemplateInstantiator) getTemplateDefinition()).instantiate(newArgs);
}
public ICPPScope getUnknownScope() throws DOMException {
if (unknownScope == null) {
final ICPPClassTemplate classTemplate= (ICPPClassTemplate) getTemplateDefinition();
if (classTemplate.getPartialSpecializations().length == 0) {
unknownScope= new PDOMCPPClassSpecializationScope(this);
} else {
unknownScope= new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
}
}
return unknownScope;
}
public IASTName getUnknownName() {
return new CPPASTName(getNameCharArray());
}
public ICPPBinding getContainerBinding() {
try {
return (ICPPBinding) getParentBinding();
} catch (CoreException e) {
return null;
}
}
} }

View file

@ -238,4 +238,8 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
public IIndexBinding getScopeBinding() { public IIndexBinding getScopeBinding() {
return this; return this;
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return this;
}
} }

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
@ -150,4 +151,8 @@ class PDOMCPPFunctionTemplateSpecialization extends
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl()); PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
list.accept(visitor); list.accept(visitor);
} }
public ICPPTemplateScope getTemplateScope() throws DOMException {
return (ICPPTemplateScope) getFunctionScope().getParent();
}
} }

View file

@ -70,10 +70,10 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -360,10 +360,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ICPPClassTemplate) { } else if (binding instanceof ICPPClassTemplate) {
pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding); pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding);
} else if (binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
if (binding instanceof ICPPInternalUnknownClassInstance) { if (binding instanceof ICPPUnknownClassInstance) {
pdomBinding= new PDOMCPPUnknownClassInstance(pdom, parent, (ICPPInternalUnknownClassInstance) binding); pdomBinding= new PDOMCPPUnknownClassInstance(pdom, parent, (ICPPUnknownClassInstance) binding);
} else if (binding instanceof ICPPInternalUnknown) { } else if (binding instanceof ICPPUnknownClassType) {
pdomBinding= new PDOMCPPUnknownClassType(pdom, parent, (ICPPInternalUnknownClassType) binding); pdomBinding= new PDOMCPPUnknownClassType(pdom, parent, (ICPPUnknownClassType) binding);
} else { } else {
pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding); pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
} }
@ -527,10 +527,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
return CPP_DEFERRED_CLASS_INSTANCE; return CPP_DEFERRED_CLASS_INSTANCE;
} }
} else if (binding instanceof ICPPInternalUnknown) { } else if (binding instanceof ICPPUnknownBinding) {
if (binding instanceof ICPPInternalUnknownClassInstance) { if (binding instanceof ICPPUnknownClassInstance) {
return CPP_UNKNOWN_CLASS_INSTANCE; return CPP_UNKNOWN_CLASS_INSTANCE;
} else if (binding instanceof ICPPInternalUnknownClassType) { } else if (binding instanceof ICPPUnknownClassType) {
return CPP_UNKNOWN_CLASS_TYPE; return CPP_UNKNOWN_CLASS_TYPE;
} }
} else if (binding instanceof ICPPTemplateInstance) { } else if (binding instanceof ICPPTemplateInstance) {

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
@ -26,7 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -39,7 +39,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Bryan Wilkinson * @author Bryan Wilkinson
*/ */
class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMemberOwner, class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMemberOwner,
ICPPTemplateNonTypeParameter, ICPPInternalUnknown, IIndexType { ICPPTemplateNonTypeParameter, ICPPUnknownBinding, IIndexType {
private static final int MEMBERLIST = PDOMCPPVariable.RECORD_SIZE + 4; private static final int MEMBERLIST = PDOMCPPVariable.RECORD_SIZE + 4;
@ -120,26 +120,19 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMe
return null; return null;
} }
public IBinding resolveUnknown(ObjectMap argMap) { fail(); return null; }
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return IASTNode.EMPTY_NODE_ARRAY;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
}
public IASTExpression getDefault() { public IASTExpression getDefault() {
return null; return null;
} }
public IASTName getUnknownName() {
return null;
}
public ICPPBinding getContainerBinding() {
return null;
}
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
return null;
}
} }

View file

@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -38,7 +38,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Bryan Wilkinson * @author Bryan Wilkinson
*/ */
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner, class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner,
ICPPTemplateTypeParameter, ICPPInternalUnknown, IIndexType { ICPPTemplateTypeParameter, ICPPUnknownBinding, IIndexType {
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0; private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4; private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
@ -144,22 +144,11 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
return null; return null;
} }
public IBinding resolveUnknown(ObjectMap argMap) { fail(); return null; } public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) { fail(); return null;}
public IASTName getUnknownName() {
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return IASTNode.EMPTY_NODE_ARRAY;
}
public IASTNode getDefinition() {
return null; return null;
} }
public ICPPBinding getContainerBinding() {
public void removeDeclaration(IASTNode node) { return null;
} }
} }

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -18,17 +19,14 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode; import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -39,8 +37,7 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICPPUnknownClassInstance {
implements ICPPInternalUnknownClassInstance {
private static final int ARGUMENTS = PDOMCPPUnknownClassType.RECORD_SIZE + 0; private static final int ARGUMENTS = PDOMCPPUnknownClassType.RECORD_SIZE + 0;
@ -50,8 +47,7 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType
// Cached values. // Cached values.
IType[] arguments; IType[] arguments;
public PDOMCPPUnknownClassInstance(PDOM pdom, PDOMNode parent, public PDOMCPPUnknownClassInstance(PDOM pdom, PDOMNode parent, ICPPUnknownClassInstance classInstance) throws CoreException {
ICPPInternalUnknownClassInstance classInstance) throws CoreException {
super(pdom, parent, classInstance); super(pdom, parent, classInstance);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl()); PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
@ -106,27 +102,8 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType
return arguments; return arguments;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
@Override @Override
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException { public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
IBinding result = super.resolveUnknown(argMap);
if (result instanceof ICPPSpecialization && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(getArguments(), argMap);
IBinding instance = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
if (instance != null) {
result = instance;
}
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
@Override
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
IType[] arguments = getArguments(); IType[] arguments = getArguments();
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap); IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
if (parentBinding instanceof PDOMNode && isChildOf((PDOMNode) parentBinding) && if (parentBinding instanceof PDOMNode && isChildOf((PDOMNode) parentBinding) &&

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -14,31 +15,27 @@ import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
@ -46,23 +43,23 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList; import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* @author Sergey Prigogin * @author Sergey Prigogin
*/ */
class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope, ICPPInternalUnknownClassType, class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope, ICPPUnknownClassType,
IPDOMMemberOwner, IIndexType, IIndexScope { IPDOMMemberOwner, IIndexType, IIndexScope {
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0; private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 0; // byte
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 8;
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12; protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8;
public PDOMCPPUnknownClassType(PDOM pdom, PDOMNode parent, ICPPInternalUnknownClassType classType) private ICPPScope unknownScope;
public PDOMCPPUnknownClassType(PDOM pdom, PDOMNode parent, ICPPUnknownClassType classType)
throws CoreException { throws CoreException {
super(pdom, parent, classType.getNameCharArray()); super(pdom, parent, classType.getNameCharArray());
@ -106,22 +103,6 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_TYPE; return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_TYPE;
} }
public PDOMCPPBase getFirstBase() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
pdom.getDB().putInt(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
PDOMCPPBase firstBase = getFirstBase();
base.setNextBase(firstBase);
setFirstBase(base);
}
@Override @Override
public void accept(IPDOMVisitor visitor) throws CoreException { public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor); super.accept(visitor);
@ -137,21 +118,17 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
return this; return this;
} }
/* (non-Javadoc) public ICPPScope getUnknownScope() {
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope() if (unknownScope == null) {
*/ unknownScope= new PDOMCPPUnknownScope(this, getUnknownName());
public ICPPScope getUnknownScope() { fail(); return null; } }
return unknownScope;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.IIndexScope#getScopeBinding()
*/
public IIndexBinding getScopeBinding() { public IIndexBinding getScopeBinding() {
return this; return this;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override @Override
public boolean isGloballyQualified() throws DOMException { public boolean isGloballyQualified() throws DOMException {
try { try {
@ -170,10 +147,6 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
addMember(member); addMember(member);
} }
public boolean isFullyCached() {
return true;
}
@Override @Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
return null; return null;
@ -200,26 +173,6 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
return true; return true;
} }
public void removeBase(PDOMName pdomName) throws CoreException {
}
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return null;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
*/ */
@ -294,57 +247,30 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
return ICPPClassType.EMPTY_CLASS_ARRAY; return ICPPClassType.EMPTY_CLASS_ARRAY;
} }
/* (non-Javadoc) public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap) {
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
try {
IIndexBinding parentBinding = getParentBinding();
IType t = null;
if (parentBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) parentBinding, argMap);
} else if (parentBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) parentBinding).resolveUnknown(argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
IBinding[] bindings = s.find(getName());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
} else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap);
}
}
} catch (CoreException e) {
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
try { try {
if (parentBinding == getParentBinding()) { if (parentBinding == getParentBinding()) {
return this; return this;
} }
} catch (CoreException e) { } catch (CoreException e) {
} }
IASTName name = new CPPASTName(getNameCharArray()); return new CPPUnknownClass(parentBinding, getUnknownName());
return new CPPUnknownClass(parentBinding, name);
} }
@Override @Override
public String toString() { public String toString() {
return ASTTypeUtil.getType(this); return ASTTypeUtil.getType(this);
} }
public IASTName getUnknownName() {
return new CPPASTName(getNameCharArray());
}
public ICPPBinding getContainerBinding() {
try {
return (ICPPBinding) getParentBinding();
} catch (CoreException e) {
return null;
}
}
} }

View file

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
/**
* @since 5.0
*/
public class PDOMCPPUnknownScope extends CPPUnknownScope implements IIndexScope {
private PDOMCPPBinding fBinding;
public PDOMCPPUnknownScope(PDOMCPPBinding binding, IASTName name) {
super((ICPPUnknownBinding) binding, name);
}
@Override
public IIndexName getScopeName() {
return null;
}
@Override
public IIndexScope getParent() {
return fBinding.getScope();
}
@Override
public PDOMCPPBinding getScopeBinding() {
return fBinding;
}
}