mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Classification of names depending on template parameters, bug 234321.
This commit is contained in:
parent
dfb6a300d1
commit
09f94f8e51
34 changed files with 468 additions and 518 deletions
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -33,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
|
@ -3850,7 +3852,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// S a( f() ); // does not instantiate member template
|
||||
// }
|
||||
public void test12_8s3() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// void h(int());
|
||||
|
@ -4245,7 +4247,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// void* p = operator new(sizeof(int)*n);
|
||||
// }
|
||||
public void test13_5s4() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// struct B {
|
||||
|
@ -4268,7 +4270,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// // D::operator=(const D&)
|
||||
// }
|
||||
public void test13_5_3s2() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// class X {
|
||||
|
@ -4388,6 +4390,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
}
|
||||
|
||||
// template<typename T> class complex {};
|
||||
// template<class T> class Array {
|
||||
// T* v;
|
||||
// int sz;
|
||||
|
@ -4398,8 +4401,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// // ...
|
||||
// };
|
||||
// Array<int> v1(20);
|
||||
// typedef complex<double> dcomplex; // complex is a standard
|
||||
// // library template
|
||||
// typedef complex<double> dcomplex;
|
||||
// Array<dcomplex> v2(30);
|
||||
// Array<dcomplex> v3(40);
|
||||
// void bar() {
|
||||
|
@ -4407,7 +4409,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// v2[3] = v3.elem(4) = dcomplex(7,8);
|
||||
// }
|
||||
public void test14_3s1() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// template<class T> class X {
|
||||
|
@ -4513,6 +4515,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
|
||||
// void error(const char*);
|
||||
// template<class T> class Array {
|
||||
// T* v;
|
||||
// int sz;
|
||||
|
@ -4528,7 +4532,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// return v[i];
|
||||
// }
|
||||
public void test14_5_1_1s1() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// void test() {
|
||||
|
@ -4562,7 +4566,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// // ...
|
||||
// }
|
||||
public void test14_5_2s1() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4592,8 +4596,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// ip = a.operator int*(); // explicit call to template operator
|
||||
// // A::operator int*()
|
||||
// }
|
||||
public void test14_5_2s5() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
public void _test14_5_2s5() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// template<class T> class X {
|
||||
|
@ -4978,10 +4982,11 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// template<typename T> class Array {};
|
||||
// template<class T> class X : public Array<T> { };
|
||||
// template<class T> class Y : public T { };
|
||||
public void test14_6_1s3b() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
// template<class T, int i> class Y {
|
||||
|
@ -5032,6 +5037,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
}
|
||||
|
||||
// template <typename T> class B {};
|
||||
// template<class T> struct X : B<T> {
|
||||
// typename T::A* pa;
|
||||
// void f(B<T>* pb) {
|
||||
|
@ -5040,7 +5046,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// }
|
||||
// };
|
||||
public void test14_6_2s2() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
|
||||
final String code = getAboveComment();
|
||||
parse(code, ParserLanguage.CPP, true, 0);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
ICPPUnknownBinding unknown= bh.assertNonProblem("B<T>", 4);
|
||||
unknown= bh.assertNonProblem("T::A", 4);
|
||||
unknown= bh.assertNonProblem("B<T>::i", 7);
|
||||
unknown= bh.assertNonProblem("j", 1);
|
||||
}
|
||||
|
||||
// typedef double A;
|
||||
|
@ -5050,7 +5062,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// template<class T> struct X : B<T> {
|
||||
// A a; // a has type double
|
||||
// };
|
||||
public void test14_6_2s3() throws Exception { // TODO this doesn't compile via g++ ?
|
||||
public void test14_6_2s3() throws Exception {
|
||||
final String content= getAboveComment();
|
||||
IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
|
||||
|
@ -5076,7 +5088,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// };
|
||||
// Y<A> ya;
|
||||
public void test14_6_2s4() throws Exception {
|
||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||
final String content= getAboveComment();
|
||||
parse(content, ParserLanguage.CPP, true, 0);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
|
||||
IBinding b= bh.assertNonProblem("b;", 1);
|
||||
assertEquals("Y", b.getOwner().getName());
|
||||
b= bh.assertNonProblem("a = i", 1);
|
||||
assertNull(b.getOwner());
|
||||
}
|
||||
|
||||
// void g(double);
|
||||
|
|
|
@ -1596,8 +1596,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
ICPPFunction f2 = (ICPPFunction) col.getName(8).resolveBinding();
|
||||
assertTrue(f2 instanceof ICPPTemplateInstance);
|
||||
assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f);
|
||||
assertTrue(f2 instanceof ICPPUnknownBinding);
|
||||
}
|
||||
|
||||
// template < class T > class A {};
|
||||
|
@ -3414,4 +3413,72 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
assertInstance(a1, ICPPField.class);
|
||||
assertSame(a1, a2);
|
||||
}
|
||||
|
||||
// void f(int); void f(char);
|
||||
// void g(int);
|
||||
// template<typename T> void h(T);
|
||||
// template<typename T> struct A {
|
||||
// void m(int); void m(char);
|
||||
// void m() {
|
||||
// typename T::B b;
|
||||
// b.func(); b.var;
|
||||
// f(b); g(b); h(b); m(b);
|
||||
// }
|
||||
// };
|
||||
public void testUnknownReferences_Bug257186() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
bh.assertNonProblem("func();", 4, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("var;", 3, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("f(b)", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("h(b)", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("m(b)", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
IFunction g= bh.assertNonProblem("g(b)", 1);
|
||||
assertFalse(g instanceof ICPPUnknownBinding);
|
||||
}
|
||||
|
||||
// template<typename T> struct A {
|
||||
// void m() {
|
||||
// T::b.c;
|
||||
// T::b.f();
|
||||
// T::b.f().d;
|
||||
// T::f1();
|
||||
// }
|
||||
// };
|
||||
public void testTypeOfUnknownReferences_Bug257186a() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
bh.assertNonProblem("b.c", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("f();", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("f().", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("d;", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("f1();", 2, ICPPUnknownBinding.class, IFunction.class);
|
||||
}
|
||||
|
||||
// template<typename T> struct A {
|
||||
// void m() {
|
||||
// T::b->c;
|
||||
// T::b->f();
|
||||
// T::b->f()->d;
|
||||
// T::f1();
|
||||
// }
|
||||
// };
|
||||
public void testTypeOfUnknownReferences_Bug257186b() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
bh.assertNonProblem("b->c", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("c;", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("f();", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("f()->", 1, ICPPUnknownBinding.class, IFunction.class);
|
||||
bh.assertNonProblem("d;", 1, ICPPUnknownBinding.class);
|
||||
bh.assertNonProblem("f1();", 2, ICPPUnknownBinding.class, IFunction.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,16 +11,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* Interface for deferred instances. A deferred instance is not actually instantiated yet,
|
||||
* because the correct template cannot be selected until all information is available.
|
||||
*/
|
||||
public interface ICPPDeferredTemplateInstance extends ICPPTemplateInstance {
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
||||
/**
|
||||
* Returns an empty map, because template parameters cannot be mapped until
|
||||
* all of the arguments are resolved.
|
||||
* @since 5.1
|
||||
* @deprecated use {@link ICPPDeferredClassInstance} instead.
|
||||
*/
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap();
|
||||
@Deprecated
|
||||
public interface ICPPDeferredTemplateInstance extends ICPPTemplateInstance {
|
||||
}
|
||||
|
|
|
@ -111,11 +111,11 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope getUnknownScope() throws DOMException {
|
||||
public ICPPScope asScope() throws DOMException {
|
||||
if (fLookupScope != null)
|
||||
return fLookupScope;
|
||||
|
||||
return super.getUnknownScope();
|
||||
return super.asScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 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:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
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.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
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.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* The deferred function instance collects information about the instantiation until it can
|
||||
* be carried out.
|
||||
*/
|
||||
public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements ICPPFunction, ICPPInternalFunction, ICPPDeferredTemplateInstance {
|
||||
private ICPPTemplateArgument[] fArguments;
|
||||
private ICPPFunctionTemplate fFunctionTemplate;
|
||||
|
||||
private IParameter [] fParameters;
|
||||
private IFunctionType fFunctionType;
|
||||
|
||||
public CPPDeferredFunctionInstance(ICPPFunctionTemplate template, ICPPTemplateArgument[] arguments) throws DOMException {
|
||||
super(template.getOwner(), new CPPASTName(template.getNameCharArray()));
|
||||
fArguments= arguments;
|
||||
fFunctionTemplate= template;
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return fFunctionTemplate;
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return fFunctionTemplate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
if( fParameters == null ){
|
||||
IParameter [] params = ((ICPPFunction)getTemplateDefinition()).getParameters();
|
||||
fParameters = new IParameter[ params.length ];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
fParameters[i] = new CPPParameterSpecialization( (ICPPParameter)params[i], null, CPPTemplateParameterMap.EMPTY);
|
||||
}
|
||||
}
|
||||
return fParameters;
|
||||
}
|
||||
|
||||
public IScope getFunctionScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
if( fFunctionType == null ){
|
||||
IFunctionType ft = ((ICPPFunction)getTemplateDefinition()).getType();
|
||||
IType returnType = ft.getReturnType();
|
||||
returnType = CPPTemplates.instantiateType(returnType, getTemplateParameterMap(), null);
|
||||
fFunctionType = CPPVisitor.createImplicitFunctionType( returnType, getParameters(), null);
|
||||
}
|
||||
return fFunctionType;
|
||||
}
|
||||
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isStatic();
|
||||
}
|
||||
|
||||
public boolean isMutable() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isMutable();
|
||||
}
|
||||
|
||||
public boolean isInline() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isInline();
|
||||
}
|
||||
|
||||
public boolean isExternC() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isExternC();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isExtern();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isAuto();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).isRegister();
|
||||
}
|
||||
|
||||
public boolean takesVarArgs() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).takesVarArgs();
|
||||
}
|
||||
|
||||
public boolean isStatic( boolean resolveAll) {
|
||||
try {
|
||||
return ASTInternal.isStatic((IFunction) getTemplateDefinition(), resolveAll);
|
||||
} catch (DOMException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding resolveParameter(IASTParameterDeclaration param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IType[] getExceptionSpecification() throws DOMException {
|
||||
return ((ICPPFunction)getTemplateDefinition()).getExceptionSpecification();
|
||||
}
|
||||
}
|
|
@ -44,7 +44,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPUnknownBinding {
|
||||
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPUnknownBinding,
|
||||
ICPPUnknownType {
|
||||
|
||||
private ICPPTemplateParameter[] templateParameters;
|
||||
private ObjectMap instances;
|
||||
|
@ -57,7 +58,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
super(name);
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
IASTName n = null;
|
||||
IASTNode[] nodes = getDeclarations();
|
||||
|
|
|
@ -27,14 +27,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
* The standard template parameter (template<typename T> or template<class T>).
|
||||
*/
|
||||
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateTypeParameter, IType, ICPPUnknownBinding {
|
||||
ICPPTemplateTypeParameter, ICPPUnknownType, ICPPUnknownBinding {
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
public CPPTemplateTypeParameter(IASTName name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
IASTName n = null;
|
||||
IASTNode[] nodes = getDeclarations();
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
/**
|
||||
* Represents a binding that is unknown because it depends on template arguments.
|
||||
*/
|
||||
public abstract class CPPUnknownBinding extends PlatformObject
|
||||
public class CPPUnknownBinding extends PlatformObject
|
||||
implements ICPPUnknownBinding, ICPPInternalBinding, Cloneable {
|
||||
protected IBinding fOwner;
|
||||
private ICPPScope unknownScope;
|
||||
|
@ -80,7 +80,7 @@ public abstract class CPPUnknownBinding extends PlatformObject
|
|||
|
||||
public IScope getScope() throws DOMException {
|
||||
if (fOwner instanceof ICPPUnknownBinding) {
|
||||
return ((ICPPUnknownBinding) fOwner).getUnknownScope();
|
||||
return ((ICPPUnknownBinding) fOwner).asScope();
|
||||
} else if (fOwner instanceof ICPPClassType) {
|
||||
return ((ICPPClassType) fOwner).getCompositeScope();
|
||||
} else if (fOwner instanceof ICPPNamespace) {
|
||||
|
@ -91,7 +91,7 @@ public abstract class CPPUnknownBinding extends PlatformObject
|
|||
return null;
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() throws DOMException {
|
||||
public ICPPScope asScope() throws DOMException {
|
||||
if (unknownScope == null) {
|
||||
unknownScope = new CPPUnknownScope(this, name);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
@ -29,10 +28,11 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
|
||||
/**
|
||||
* Represents a C++ class, declaration of which is not yet available.
|
||||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownClassType {
|
||||
public static CPPUnknownClass createUnnamedInstance() {
|
||||
return new CPPUnknownClass(null, new CPPASTName());
|
||||
}
|
||||
|
||||
public CPPUnknownClass(IBinding binding, IASTName name) {
|
||||
super(binding, name);
|
||||
|
@ -79,7 +79,7 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla
|
|||
}
|
||||
|
||||
public final IScope getCompositeScope() throws DOMException {
|
||||
return getUnknownScope();
|
||||
return asScope();
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/*******************************************************************************
|
||||
* 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.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
|
||||
/**
|
||||
* Represents a reference to a (member) function (instance), which cannot be resolved because
|
||||
* it depends on a template parameter. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunction {
|
||||
|
||||
public static IFunction createForSample(IFunction sample, IASTName name) throws DOMException {
|
||||
return new CPPUnknownFunction(sample.getOwner(), name.getLastName());
|
||||
}
|
||||
|
||||
private IFunctionType fType;
|
||||
|
||||
public CPPUnknownFunction(IBinding owner, IASTName name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
public IType[] getExceptionSpecification() throws DOMException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isExternC() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInline() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMutable() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IScope getFunctionScope() throws DOMException {
|
||||
return asScope();
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
return IParameter.EMPTY_PARAMETER_ARRAY;
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
if (fType == null) {
|
||||
fType= new CPPUnknownFunctionType();
|
||||
}
|
||||
return fType;
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean takesVarArgs() throws DOMException {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* 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.IType;
|
||||
|
||||
/**
|
||||
* Models the type of an unknown function.
|
||||
*/
|
||||
public class CPPUnknownFunctionType extends CPPFunctionType implements ICPPUnknownType {
|
||||
CPPUnknownFunctionType() {
|
||||
super(CPPUnknownClass.createUnnamedInstance(), IType.EMPTY_TYPE_ARRAY);
|
||||
}
|
||||
}
|
|
@ -16,19 +16,21 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
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.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
||||
/**
|
||||
* Models the scope represented by an unknown binding such (e.g.: template type parameter). Used within
|
||||
|
@ -100,55 +102,68 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||
*/
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap(2);
|
||||
public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
boolean type= false;
|
||||
boolean function= false;
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
if (map.containsKey(c)) {
|
||||
return (IBinding) map.get(c);
|
||||
}
|
||||
|
||||
IBinding b;
|
||||
if (name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) {
|
||||
type= true;
|
||||
} else {
|
||||
IASTName n= name;
|
||||
IASTNode parent= name.getParent();
|
||||
if (parent instanceof ICPPASTTemplateId) {
|
||||
try {
|
||||
ICPPTemplateArgument[] arguments = CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) parent);
|
||||
b = new CPPUnknownClassInstance(binding, name, arguments);
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
n= (IASTName) parent;
|
||||
parent= n.getParent();
|
||||
}
|
||||
if (parent instanceof ICPPASTQualifiedName) {
|
||||
ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent;
|
||||
if (qname.getLastName() != n) {
|
||||
type= true;
|
||||
} else {
|
||||
b = new CPPUnknownClass(binding, name);
|
||||
parent= qname.getParent();
|
||||
}
|
||||
}
|
||||
if (!type) {
|
||||
if (parent instanceof ICPPASTNamedTypeSpecifier ||
|
||||
parent instanceof ICPPASTBaseSpecifier ||
|
||||
parent instanceof ICPPASTConstructorChainInitializer) {
|
||||
type= true;
|
||||
} else if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||
function= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
name.setBinding(b);
|
||||
map.put(c, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
|
||||
IIndexFileSet fileSet) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap(2);
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
IBinding[] o= (IBinding[]) map.get(c);
|
||||
if (o == null) {
|
||||
o= new IBinding[3];
|
||||
map.put(c, o);
|
||||
}
|
||||
|
||||
IBinding[] result = null;
|
||||
if (prefixLookup) {
|
||||
Object[] keys = map.keyArray();
|
||||
for (Object key2 : keys) {
|
||||
char[] key = (char[]) key2;
|
||||
if (CharArrayUtils.equals(key, 0, c.length, c, true)) {
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, map.get(key));
|
||||
}
|
||||
}
|
||||
int idx= type ? 0 : function ? 1 : 2;
|
||||
IBinding result= o[idx];
|
||||
if (result == null) {
|
||||
if (type) {
|
||||
result= new CPPUnknownClass(binding, name.getLastName());
|
||||
} else if (function) {
|
||||
result= new CPPUnknownFunction(binding, name.getLastName());
|
||||
} else {
|
||||
result = new IBinding[] { (IBinding) map.get(c) };
|
||||
result= new CPPUnknownBinding(binding, name.getLastName());
|
||||
}
|
||||
o[idx]= result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||
return result;
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
|
||||
if (prefixLookup)
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
|
||||
return new IBinding[] {getBinding(name, resolve, fileSet)};
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -12,15 +12,23 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* Interface for deferred class template instances.
|
||||
*/
|
||||
public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPDeferredTemplateInstance {
|
||||
public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPTemplateInstance {
|
||||
|
||||
/**
|
||||
* Returns the class template for the deferred instantiation.
|
||||
*/
|
||||
ICPPClassTemplate getClassTemplate();
|
||||
|
||||
/**
|
||||
* Returns an empty map, because template parameters cannot be mapped until
|
||||
* all of the arguments are resolved.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public interface ICPPUnknownBinding extends ICPPBinding {
|
|||
* Returns the scope this binding represents.
|
||||
* @throws DOMException
|
||||
*/
|
||||
public ICPPScope getUnknownScope() throws DOMException;
|
||||
public ICPPScope asScope() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a the name of the unknown binding that has to be searched in the parent scope.
|
||||
|
|
|
@ -19,6 +19,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
* This interface should be made public.
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ICPPUnknownClassType extends ICPPUnknownBinding, ICPPClassType {
|
||||
public interface ICPPUnknownClassType extends ICPPUnknownBinding, ICPPUnknownType, ICPPClassType {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* 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.IType;
|
||||
|
||||
/**
|
||||
* Marks types that depend on a template parameter and are thus unknown.
|
||||
*/
|
||||
public interface ICPPUnknownType extends IType {
|
||||
|
||||
}
|
|
@ -100,7 +100,6 @@ 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.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.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
|
@ -144,13 +143,16 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespace;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
||||
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.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
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.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
||||
|
@ -303,7 +305,7 @@ public class CPPSemantics {
|
|||
ICPPASTTemplateId id = (ICPPASTTemplateId) data.astName;
|
||||
ICPPTemplateArgument[] args = CPPTemplates.createTemplateArgumentArray(id);
|
||||
IBinding inst= CPPTemplates.instantiate((ICPPClassTemplate) cls, args);
|
||||
cls = inst instanceof ICPPClassType && !(inst instanceof ICPPDeferredTemplateInstance) ? (ICPPClassType)inst : cls;
|
||||
cls = inst instanceof ICPPClassType && !(inst instanceof ICPPDeferredClassInstance) ? (ICPPClassType)inst : cls;
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
|
@ -339,8 +341,12 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
// 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 && data.skippedScope != null) {
|
||||
if (data.functionParameters != null) {
|
||||
binding= new CPPUnknownFunction(data.skippedScope, name.getLastName());
|
||||
} else {
|
||||
binding= new CPPUnknownBinding(data.skippedScope, name.getLastName());
|
||||
}
|
||||
}
|
||||
|
||||
if (binding != null) {
|
||||
|
@ -737,7 +743,7 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
if (!data.usingDirectivesOnly && scope instanceof ICPPClassScope) {
|
||||
mergeResults(data, lookupInParents(data, scope), true);
|
||||
mergeResults(data, lookupInParents(data, scope, ((ICPPClassScope) scope).getClassType()), true);
|
||||
}
|
||||
|
||||
if (!data.contentAssist && (data.problem != null || data.hasResults()))
|
||||
|
@ -794,7 +800,7 @@ public class CPPSemantics {
|
|||
return (ICPPScope) parentScope;
|
||||
}
|
||||
|
||||
private static Object lookupInParents(LookupData data, ICPPScope lookIn) throws DOMException{
|
||||
private static Object lookupInParents(LookupData data, ICPPScope lookIn, ICPPClassType overallScope) throws DOMException{
|
||||
if (lookIn instanceof ICPPClassScope == false)
|
||||
return null;
|
||||
|
||||
|
@ -826,44 +832,46 @@ public class CPPSemantics {
|
|||
continue;
|
||||
|
||||
IBinding b = base.getBaseClass();
|
||||
if (b instanceof ICPPClassType == false)
|
||||
if (!(b instanceof ICPPClassType)) {
|
||||
// 14.6.2.3 scope is not examined
|
||||
if (b instanceof ICPPUnknownBinding) {
|
||||
if (data.skippedScope == null)
|
||||
data.skippedScope= overallScope;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
inherited = null;
|
||||
|
||||
final ICPPClassType cls = (ICPPClassType) b;
|
||||
if (cls instanceof ICPPUnknownBinding) {
|
||||
if (data.unknownBinding == null) {
|
||||
data.unknownBinding= cls;
|
||||
}
|
||||
final ICPPScope classScope = (ICPPScope) cls.getCompositeScope();
|
||||
if (classScope == null || classScope instanceof ICPPInternalUnknownScope) {
|
||||
// 14.6.2.3 scope is not examined
|
||||
if (data.skippedScope == null)
|
||||
data.skippedScope= overallScope;
|
||||
continue;
|
||||
}
|
||||
|
||||
final ICPPScope parent = (ICPPScope) cls.getCompositeScope();
|
||||
if (parent == null || parent instanceof CPPUnknownScope)
|
||||
continue;
|
||||
|
||||
if (!base.isVirtual() || !data.visited.containsKey(parent)) {
|
||||
if (!base.isVirtual() || !data.visited.containsKey(classScope)) {
|
||||
if (base.isVirtual()) {
|
||||
data.visited.put(parent);
|
||||
data.visited.put(classScope);
|
||||
}
|
||||
|
||||
//if the inheritanceChain already contains the parent, then that
|
||||
//is circular inheritance
|
||||
if (!data.inheritanceChain.containsKey(parent)) {
|
||||
if (!data.inheritanceChain.containsKey(classScope)) {
|
||||
//is this name define in this scope?
|
||||
if (ASTInternal.isFullyCached(parent)) {
|
||||
if (ASTInternal.isFullyCached(classScope)) {
|
||||
if (data.astName != null && !data.contentAssist) {
|
||||
inherited = parent.getBinding(data.astName, true);
|
||||
inherited = classScope.getBinding(data.astName, true);
|
||||
} else if (data.astName != null) {
|
||||
inherited = parent.getBindings(data.astName, true, data.prefixLookup);
|
||||
inherited = classScope.getBindings(data.astName, true, data.prefixLookup);
|
||||
}
|
||||
} else {
|
||||
inherited = lookupInScope(data, parent, null);
|
||||
inherited = lookupInScope(data, classScope, null);
|
||||
}
|
||||
|
||||
if (inherited == null || data.contentAssist) {
|
||||
Object temp = lookupInParents(data, parent);
|
||||
Object temp = lookupInParents(data, classScope, overallScope);
|
||||
if (inherited != null) {
|
||||
inherited = mergePrefixResults(null, inherited, true);
|
||||
inherited = mergePrefixResults((CharArrayObjectMap)inherited, (CharArrayObjectMap)temp, true);
|
||||
|
@ -1863,6 +1871,13 @@ public class CPPSemantics {
|
|||
functions[i]= null;
|
||||
continue;
|
||||
}
|
||||
if (function instanceof ICPPUnknownBinding) {
|
||||
if (def) {
|
||||
functions[i]= null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
num = function.getParameters().length;
|
||||
|
||||
// if there are m arguments in the list, all candidate functions having m parameters
|
||||
|
@ -1981,21 +1996,27 @@ public class CPPSemantics {
|
|||
// Reduce our set of candidate functions to only those who have the right number of parameters
|
||||
reduceToViable(data, fns);
|
||||
|
||||
// deferred function instances cannot be disambiguated.
|
||||
boolean deferredOnly= true;
|
||||
for (int i = 0; deferredOnly && i < fns.length; i++) {
|
||||
final IFunction f = fns[i];
|
||||
if (f != null && !(f instanceof ICPPDeferredTemplateInstance)) {
|
||||
deferredOnly= false;
|
||||
int viableCount= 0;
|
||||
IFunction firstViable= null;
|
||||
for (IFunction f : fns) {
|
||||
if (f != null) {
|
||||
if (++viableCount == 1) {
|
||||
firstViable= f;
|
||||
}
|
||||
}
|
||||
if (deferredOnly || data.forFunctionDeclaration()) {
|
||||
for (IFunction fn : fns) {
|
||||
if (fn != null) {
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
if (firstViable == null)
|
||||
return null;
|
||||
if (data.forFunctionDeclaration())
|
||||
return firstViable;
|
||||
|
||||
|
||||
final IType[] sourceParameters = getSourceParameterTypes(data.functionParameters); // the parameters the function is being called with
|
||||
if (CPPTemplates.containsDependentType(sourceParameters)) {
|
||||
if (viableCount == 1)
|
||||
return firstViable;
|
||||
|
||||
return CPPUnknownFunction.createForSample(firstViable, data.astName);
|
||||
}
|
||||
|
||||
IFunction bestFn = null; // the best function
|
||||
|
@ -2016,7 +2037,6 @@ public class CPPSemantics {
|
|||
boolean currHasAmbiguousParam = false; // currFn has an ambiguous parameter conversion (ok if not bestFn)
|
||||
boolean bestHasAmbiguousParam = false; // bestFn has an ambiguous parameter conversion (not ok, ambiguous)
|
||||
|
||||
final IType[] sourceParameters = getSourceParameterTypes(data.functionParameters); // the parameters the function is being called with
|
||||
final boolean sourceVoid = (data.functionParameters == null || data.functionParameters.length == 0);
|
||||
final IType impliedObjectType = data.getImpliedObjectArgument();
|
||||
|
||||
|
@ -2400,7 +2420,7 @@ public class CPPSemantics {
|
|||
IASTExpression owner = fieldReference.getFieldOwner();
|
||||
IType result= CPPVisitor.getExpressionType(owner);
|
||||
|
||||
if (fieldReference.isPointerDereference()) {
|
||||
if (fieldReference.isPointerDereference() && !(result instanceof ICPPUnknownType)) {
|
||||
IType type= getUltimateTypeUptoPointers(result);
|
||||
boolean needCheckClassMemberAccessOperator= true;
|
||||
if (type instanceof IPointerType) {
|
||||
|
|
|
@ -103,7 +103,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorInstance;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
|
||||
|
@ -126,6 +125,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -135,6 +135,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate;
|
|||
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.ICPPUnknownType;
|
||||
|
||||
/**
|
||||
* Collection of static methods to perform template instantiation, member specialization and
|
||||
|
@ -312,70 +313,25 @@ public class CPPTemplates {
|
|||
|
||||
private static IBinding instantiateFunctionTemplate(ICPPFunctionTemplate template, ICPPTemplateArgument[] arguments)
|
||||
throws DOMException {
|
||||
ICPPTemplateParameter[] parameters= template.getTemplateParameters();
|
||||
if (parameters == null || parameters.length == 0)
|
||||
return null;
|
||||
|
||||
final int numParams= parameters.length;
|
||||
int numArgs = arguments.length;
|
||||
|
||||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(numParams);
|
||||
ICPPTemplateParameter param = null;
|
||||
ICPPTemplateArgument arg = null;
|
||||
ICPPTemplateArgument[] actualArgs = new ICPPTemplateArgument[numParams];
|
||||
boolean argsContainDependentType = false;
|
||||
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
arg= null;
|
||||
param= parameters[i];
|
||||
|
||||
if (i < numArgs) {
|
||||
arg= arguments[i];
|
||||
} else {
|
||||
ICPPTemplateArgument defaultArg= param.getDefaultValue();
|
||||
if (defaultArg == null) {
|
||||
return null;
|
||||
}
|
||||
arg= instantiateArgument(defaultArg, map, null);
|
||||
}
|
||||
|
||||
arg= CPPTemplates.matchTemplateParameterAndArgument(param, arg, map);
|
||||
if (arg == null)
|
||||
return null;
|
||||
|
||||
if (!argIsParameter(arg, param)) {
|
||||
map.put(param, arg);
|
||||
}
|
||||
actualArgs[i] = arg;
|
||||
if (CPPTemplates.isDependentArgument(arg)) {
|
||||
argsContainDependentType = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (argsContainDependentType) {
|
||||
return deferredInstance(template, actualArgs);
|
||||
}
|
||||
|
||||
ICPPTemplateInstance instance= getInstance(template, arguments);
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
IBinding owner= template.getOwner();
|
||||
instance = CPPTemplates.createInstance(owner, template, map, actualArgs);
|
||||
addInstance(template, actualArgs, instance);
|
||||
return instance;
|
||||
final int length = arguments.length;
|
||||
ICPPTemplateParameter[] parameters= template.getTemplateParameters();
|
||||
if (parameters.length != length)
|
||||
return null;
|
||||
|
||||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
map.put(parameters[i], arguments[i]);
|
||||
}
|
||||
|
||||
private static boolean argIsParameter(ICPPTemplateArgument arg, ICPPTemplateParameter param) {
|
||||
if (param instanceof ICPPTemplateNonTypeParameter) {
|
||||
return arg.isNonTypeValue() && Value.isTemplateParameter(arg.getNonTypeValue()) == param.getParameterID();
|
||||
}
|
||||
if (param instanceof IType) {
|
||||
return arg.isTypeValue() && ((IType) param).isSameType(arg.getTypeValue());
|
||||
}
|
||||
assert false;
|
||||
return false;
|
||||
IBinding owner= template.getOwner();
|
||||
instance = CPPTemplates.createInstance(owner, template, map, arguments);
|
||||
addInstance(template, arguments, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,23 +353,15 @@ public class CPPTemplates {
|
|||
}
|
||||
}
|
||||
|
||||
private static IBinding deferredInstance(ICPPTemplateDefinition template, ICPPTemplateArgument[] arguments) throws DOMException {
|
||||
private static IBinding deferredInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments) throws DOMException {
|
||||
ICPPTemplateInstance instance= getInstance(template, arguments);
|
||||
if (instance != null)
|
||||
return instance;
|
||||
|
||||
if (template instanceof ICPPClassTemplate) {
|
||||
instance = new CPPDeferredClassInstance((ICPPClassTemplate) template, arguments);
|
||||
instance = new CPPDeferredClassInstance(template, arguments);
|
||||
addInstance(template, arguments, instance);
|
||||
return instance;
|
||||
}
|
||||
if (template instanceof ICPPFunctionTemplate) {
|
||||
instance = new CPPDeferredFunctionInstance((ICPPFunctionTemplate) template, arguments);
|
||||
addInstance(template, arguments, instance);
|
||||
return instance;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates the template for usage within its own body. May return <code>null</code>.
|
||||
|
@ -603,15 +551,19 @@ public class CPPTemplates {
|
|||
IBinding result= null;
|
||||
IASTName templateName = id.getTemplateName();
|
||||
IBinding template = templateName.resolveBinding();
|
||||
if (template instanceof ICPPUnknownClassInstance) {
|
||||
// mstodo we should not get here, rather than that an unknown class
|
||||
// should be made to an unknown class instance here
|
||||
return template;
|
||||
}
|
||||
|
||||
if (template instanceof ICPPConstructor) {
|
||||
template= template.getOwner();
|
||||
}
|
||||
|
||||
if (template instanceof ICPPUnknownClassType) {
|
||||
IBinding owner= template.getOwner();
|
||||
if (owner instanceof ICPPUnknownBinding) {
|
||||
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
||||
return new CPPUnknownClassInstance((ICPPUnknownBinding) template.getOwner(), id, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(template instanceof ICPPClassTemplate) || template instanceof ICPPClassTemplatePartialSpecialization)
|
||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE, templateName.toCharArray());
|
||||
|
||||
|
@ -698,6 +650,7 @@ public class CPPTemplates {
|
|||
if (tmplArg == null)
|
||||
return null;
|
||||
|
||||
tmplArg= SemanticUtil.getSimplifiedArgument(tmplArg);
|
||||
map.put(tmplParam, tmplArg);
|
||||
result[i]= tmplArg;
|
||||
}
|
||||
|
@ -1423,14 +1376,19 @@ public class CPPTemplates {
|
|||
return null;
|
||||
|
||||
ICPPTemplateArgument[] templateArguments = ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
if (name instanceof ICPPASTTemplateId) {
|
||||
final IType[] fnArgs= createTypeArray(functionArguments);
|
||||
try {
|
||||
if (containsDependentType(fnArgs))
|
||||
return new IFunction[] {CPPUnknownFunction.createForSample(templates.keyAt(0), name)};
|
||||
|
||||
if (name instanceof ICPPASTTemplateId) {
|
||||
templateArguments = createTemplateArgumentArray((ICPPASTTemplateId) name);
|
||||
if (hasDependentArgument(templateArguments))
|
||||
return new IFunction[] {CPPUnknownFunction.createForSample(templates.keyAt(0), name)};
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return new IFunction[0];
|
||||
}
|
||||
}
|
||||
final IType[] fnArgs= createTypeArray(functionArguments);
|
||||
|
||||
IFunction[] instances= null;
|
||||
final int size = templates.size();
|
||||
|
@ -2042,18 +2000,24 @@ public class CPPTemplates {
|
|||
return Value.isDependentValue(arg.getNonTypeValue());
|
||||
}
|
||||
|
||||
public static boolean containsDependentType(IType[] ts) {
|
||||
for (IType t : ts) {
|
||||
if (isDependentType(t))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDependentType(IType t) {
|
||||
try {
|
||||
while (true) {
|
||||
if (t instanceof ICPPTemplateParameter || t instanceof ICPPUnknownBinding)
|
||||
if (t instanceof ICPPUnknownType)
|
||||
return true;
|
||||
|
||||
if (t instanceof ICPPFunctionType) {
|
||||
final ICPPFunctionType ft = (ICPPFunctionType) t;
|
||||
IType[] types= ft.getParameterTypes();
|
||||
for (IType type : types) {
|
||||
if (isDependentType(type))
|
||||
if (containsDependentType(ft.getParameterTypes()))
|
||||
return true;
|
||||
}
|
||||
t= ft.getReturnType();
|
||||
} else if (t instanceof ICPPPointerToMemberType) {
|
||||
ICPPPointerToMemberType ptmt= (ICPPPointerToMemberType) t;
|
||||
|
@ -2132,10 +2096,8 @@ public class CPPTemplates {
|
|||
}
|
||||
if (unknown instanceof ICPPUnknownClassInstance && result instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(((ICPPUnknownClassInstance) unknown).getArguments(), tpMap, within);
|
||||
if (result instanceof ICPPClassTemplate)
|
||||
if (result instanceof ICPPClassTemplate) {
|
||||
result = instantiate((ICPPClassTemplate) result, newArgs);
|
||||
else if (result instanceof ICPPFunctionTemplate) {
|
||||
result= instantiateFunctionTemplate((ICPPFunctionTemplate) result, newArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerToMemberType;
|
||||
|
@ -946,7 +947,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else if (binding instanceof ICPPNamespace) {
|
||||
scope= ((ICPPNamespace)binding).getNamespaceScope();
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
scope= ((ICPPUnknownBinding)binding).getUnknownScope();
|
||||
scope= ((ICPPUnknownBinding)binding).asScope();
|
||||
} else if (binding instanceof IProblemBinding) {
|
||||
if (binding instanceof ICPPScope)
|
||||
scope= (IScope) binding;
|
||||
|
@ -971,6 +972,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
if (type instanceof ICPPClassType) {
|
||||
return ((ICPPClassType) type).getCompositeScope();
|
||||
} else if (type instanceof ICPPUnknownBinding) {
|
||||
return ((ICPPUnknownBinding) type).asScope();
|
||||
}
|
||||
} else if (parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement) {
|
||||
while (!(parent instanceof IASTFunctionDefinition)) {
|
||||
|
@ -1786,6 +1789,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
return ((ICPPTemplateNonTypeParameter) binding).getType();
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
return ((ICPPClassType) binding);
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
return CPPUnknownClass.createUnnamedInstance();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
|
@ -2004,6 +2009,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
return ((IFunction)binding).getType();
|
||||
else if (binding instanceof IEnumerator)
|
||||
return ((IEnumerator)binding).getType();
|
||||
else if (binding instanceof ICPPUnknownBinding)
|
||||
return CPPUnknownClass.createUnnamedInstance();
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
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.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -56,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
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.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
@ -95,7 +95,7 @@ class LookupData {
|
|||
public boolean typesOnly = false;
|
||||
public boolean considerConstructors = false;
|
||||
|
||||
public IBinding unknownBinding= null;
|
||||
public ICPPClassType skippedScope;
|
||||
public Object foundItems = null;
|
||||
public Object[] functionParameters;
|
||||
public ICPPASTTemplateId templateId;
|
||||
|
|
|
@ -38,7 +38,6 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPP_FUNCTION_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 21;
|
||||
int CPP_METHOD_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 22;
|
||||
int CPP_CONSTRUCTOR_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 23;
|
||||
int CPP_DEFERRED_FUNCTION_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 24;
|
||||
int CPP_CLASS_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 25;
|
||||
int CPP_DEFERRED_CLASS_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 26;
|
||||
int CPP_PARAMETER_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 27;
|
||||
|
|
|
@ -29,7 +29,6 @@ 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.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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
|
@ -183,14 +182,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
result = null;
|
||||
} else if (binding instanceof ICPPSpecialization) {
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredClassInstance) {
|
||||
return new CompositeCPPDeferredClassInstance(this, (ICPPDeferredClassInstance) findOneBinding(binding));
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
return new CompositeCPPDeferredFunctionInstance(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPClassInstance(this, (ICPPClassType) findOneBinding(binding));
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
|
|||
return ((ICPPDeferredClassInstance) rbinding).getUnknownName();
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() throws DOMException {
|
||||
public ICPPScope asScope() throws DOMException {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 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
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPDeferredFunctionInstance extends CompositeCPPFunction
|
||||
implements ICPPDeferredTemplateInstance {
|
||||
|
||||
public CompositeCPPDeferredFunctionInstance(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
|
@ -20,11 +20,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
||||
implements ICPPTemplateTypeParameter, ICPPUnknownBinding, IIndexType {
|
||||
implements ICPPTemplateTypeParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType {
|
||||
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
fail(); return null;
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class CompositeCPPUnknownClassType extends CompositeCPPBinding implements ICPPUn
|
|||
return ((ICPPClassType) rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -47,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
|||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
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.index.IIndexFragmentFile;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
|
||||
|
@ -251,7 +251,7 @@ abstract public class PDOMWriter {
|
|||
}
|
||||
} else if (name.isReference()) {
|
||||
if (binding instanceof ICPPTemplateParameter ||
|
||||
binding instanceof ICPPDeferredTemplateInstance ||
|
||||
binding instanceof ICPPUnknownBinding ||
|
||||
((fSkipReferences & SKIP_TYPE_REFERENCES) != 0 && isTypeReferenceBinding(binding))) {
|
||||
if (!isRequiredReference(name)) {
|
||||
na[0]= null;
|
||||
|
|
|
@ -205,7 +205,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
|||
if (parent instanceof ICPPClassType) {
|
||||
return (IIndexScope) ((ICPPClassType) parent).getCompositeScope();
|
||||
} else if (parent instanceof ICPPUnknownBinding) {
|
||||
return (IIndexScope) ((ICPPUnknownBinding) parent).getUnknownScope();
|
||||
return (IIndexScope) ((ICPPUnknownBinding) parent).asScope();
|
||||
}
|
||||
|
||||
if (parent instanceof IIndexScope) {
|
||||
|
|
|
@ -170,7 +170,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
@Override
|
||||
public Object clone() {fail();return null;}
|
||||
|
||||
public ICPPScope getUnknownScope() throws DOMException {
|
||||
public ICPPScope asScope() throws DOMException {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new PDOMCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX 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:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*
|
||||
*/
|
||||
class PDOMCPPDeferredFunctionInstance extends PDOMCPPFunctionInstance
|
||||
implements ICPPDeferredTemplateInstance {
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPDeferredFunctionInstance record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
|
||||
|
||||
public PDOMCPPDeferredFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding instantiated)
|
||||
throws CoreException {
|
||||
super(pdom, parent, function, instantiated);
|
||||
}
|
||||
|
||||
public PDOMCPPDeferredFunctionInstance(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_DEFERRED_FUNCTION_INSTANCE;
|
||||
}
|
||||
}
|
|
@ -44,7 +44,6 @@ 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.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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
|
@ -385,10 +384,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
|
||||
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special) throws CoreException {
|
||||
PDOMBinding result= null;
|
||||
if (special instanceof ICPPDeferredTemplateInstance) {
|
||||
if (special instanceof ICPPFunction && orig instanceof ICPPFunctionTemplate) {
|
||||
result= new PDOMCPPDeferredFunctionInstance(pdom, parent, (ICPPFunction) special, orig);
|
||||
} else if (special instanceof ICPPDeferredClassInstance && orig instanceof ICPPClassTemplate) {
|
||||
if (special instanceof ICPPDeferredClassInstance) {
|
||||
if (orig instanceof ICPPClassTemplate) {
|
||||
result= new PDOMCPPDeferredClassInstance(pdom, parent, (ICPPDeferredClassInstance) special, orig);
|
||||
}
|
||||
} else if (special instanceof ICPPTemplateInstance) {
|
||||
|
@ -476,14 +473,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
@Override
|
||||
public int getBindingType(IBinding binding) {
|
||||
if (binding instanceof ICPPSpecialization) {
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if (binding instanceof ICPPFunction) {
|
||||
return CPP_DEFERRED_FUNCTION_INSTANCE;
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredClassInstance) {
|
||||
return CPP_DEFERRED_CLASS_INSTANCE;
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
return CPP_CONSTRUCTOR_INSTANCE;
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
return CPP_METHOD_INSTANCE;
|
||||
|
@ -800,8 +793,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return new PDOMCPPMethodInstance(pdom, record);
|
||||
case CPP_CONSTRUCTOR_INSTANCE:
|
||||
return new PDOMCPPConstructorInstance(pdom, record);
|
||||
case CPP_DEFERRED_FUNCTION_INSTANCE:
|
||||
return new PDOMCPPDeferredFunctionInstance(pdom, record);
|
||||
case CPP_CLASS_INSTANCE:
|
||||
return new PDOMCPPClassInstance(pdom, record);
|
||||
case CPP_DEFERRED_CLASS_INSTANCE:
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.internal.core.Util;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -39,7 +40,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Binding for template type parameters in the index.
|
||||
*/
|
||||
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner,
|
||||
ICPPTemplateTypeParameter, ICPPUnknownBinding, IIndexType {
|
||||
ICPPTemplateTypeParameter, ICPPUnknownBinding, ICPPUnknownType, IIndexType {
|
||||
|
||||
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
|
@ -161,7 +162,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
public Object clone() { fail(); return null; }
|
||||
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (fUnknownScope == null) {
|
||||
fUnknownScope= new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
|
|||
return this;
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new PDOMCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
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.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
@ -43,6 +42,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
|
||||
if (element instanceof ICPPTemplateInstance) {
|
||||
StringBuffer buffer = null;
|
||||
if (element instanceof ICPPDeferredTemplateInstance) {
|
||||
if (element instanceof ICPPDeferredClassInstance) {
|
||||
buffer = new StringBuffer("Dfrd: "); //$NON-NLS-1$
|
||||
} else {
|
||||
buffer = new StringBuffer("Inst: "); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue