mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'origin/bug_299911'
This commit is contained in:
commit
e39899ec23
118 changed files with 3611 additions and 2359 deletions
|
@ -188,7 +188,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
* Checks whether specified type (class or typedef to the class) is an abstract class.
|
||||
* If it is, reports violations on each pure virtual method
|
||||
*/
|
||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode) {
|
||||
IType unwindedType = CxxAstUtils.unwindTypedef(typeToCheck);
|
||||
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
|
||||
return;
|
||||
|
@ -196,7 +196,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||
if (pureVirtualMethods == null) {
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType, problemNode);
|
||||
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
|||
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.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
|
||||
/**
|
||||
|
@ -46,8 +47,8 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
ast.accept(new OnEachClass());
|
||||
}
|
||||
|
||||
private static ICPPMethod getDestructor(ICPPClassType classType) {
|
||||
for (ICPPMethod method : classType.getDeclaredMethods()) {
|
||||
private static ICPPMethod getDestructor(ICPPClassType classType, IASTNode point) {
|
||||
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
|
||||
if (method.isDestructor()) {
|
||||
return method;
|
||||
}
|
||||
|
@ -55,18 +56,18 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasVirtualDestructor(ICPPClassType classType) {
|
||||
private static boolean hasVirtualDestructor(ICPPClassType classType, IASTNode point) {
|
||||
checkedClassTypes.add(classType);
|
||||
ICPPMethod destructor = getDestructor(classType);
|
||||
ICPPMethod destructor = getDestructor(classType, point);
|
||||
if (destructor != null && destructor.isVirtual()) {
|
||||
return true;
|
||||
}
|
||||
ICPPBase[] bases = classType.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(classType, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseClass = base.getBaseClass();
|
||||
if (baseClass instanceof ICPPClassType) {
|
||||
ICPPClassType cppClassType = (ICPPClassType) baseClass;
|
||||
if (!checkedClassTypes.contains(cppClassType) && hasVirtualDestructor(cppClassType)) {
|
||||
if (!checkedClassTypes.contains(cppClassType) && hasVirtualDestructor(cppClassType, point)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +90,13 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPClassType classType = (ICPPClassType) binding;
|
||||
boolean hasVirtualDestructor = hasVirtualDestructor(classType);
|
||||
boolean hasVirtualDestructor = hasVirtualDestructor(classType, className);
|
||||
checkedClassTypes.clear();
|
||||
if (hasVirtualDestructor) {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPMethod virtualMethod = null;
|
||||
for (ICPPMethod method : classType.getAllDeclaredMethods()) {
|
||||
for (ICPPMethod method : ClassTypeHelper.getAllDeclaredMethods(classType, className)) {
|
||||
if (!method.isDestructor() && method.isVirtual()) {
|
||||
virtualMethod = method;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
if (virtualMethod == null) {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPMethod destructor = getDestructor(classType);
|
||||
ICPPMethod destructor = getDestructor(classType, className);
|
||||
if (destructor != null &&
|
||||
destructor.getVisibility() != ICPPASTVisibilityLabel.v_public &&
|
||||
classType.getFriends().length == 0) {
|
||||
|
|
|
@ -5747,7 +5747,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
// g<C>(0); // The N member of C is not a non-type
|
||||
// h<D>(0); // The TT member of D is not a template
|
||||
// }
|
||||
public void _test14_8_2s8d() throws Exception {
|
||||
public void test14_8_2s8d() throws Exception {
|
||||
final String content= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
|
||||
bh.assertProblem("f<A>", 0);
|
||||
|
|
|
@ -6252,20 +6252,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse(ClassTypeHelper.isOverrider(m5, m2));
|
||||
assertTrue(ClassTypeHelper.isOverrider(m4, m2));
|
||||
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m1);
|
||||
ors= ClassTypeHelper.findOverridden(m1, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m2);
|
||||
ors= ClassTypeHelper.findOverridden(m2, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m1);
|
||||
ors= ClassTypeHelper.findOverridden(m3);
|
||||
ors= ClassTypeHelper.findOverridden(m3, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m4);
|
||||
ors= ClassTypeHelper.findOverridden(m4, null);
|
||||
assertEquals(2, ors.length);
|
||||
assertSame(ors[0], m2);
|
||||
assertSame(ors[1], m1);
|
||||
ors= ClassTypeHelper.findOverridden(m5);
|
||||
ors= ClassTypeHelper.findOverridden(m5, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m1);
|
||||
}
|
||||
|
@ -8732,14 +8732,14 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse(ClassTypeHelper.isOverrider(m3, m0));
|
||||
assertFalse(ClassTypeHelper.isOverrider(m3, m1));
|
||||
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m1);
|
||||
ors= ClassTypeHelper.findOverridden(m1, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m2);
|
||||
ors= ClassTypeHelper.findOverridden(m2, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m0);
|
||||
ors= ClassTypeHelper.findOverridden(m3);
|
||||
ors= ClassTypeHelper.findOverridden(m3, null);
|
||||
assertEquals(0, ors.length);
|
||||
}
|
||||
|
||||
|
@ -9288,7 +9288,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
// auto f2 (); // missing late return type.
|
||||
public void testBug332114a() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
IBinding b= bh.assertNonProblem("f2", 0);
|
||||
// Must not throw a NPE
|
||||
IndexCPPSignatureUtil.getSignature(b);
|
||||
|
@ -9546,7 +9546,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
public void testRecursiveClassInheritance_Bug357256() throws Exception {
|
||||
BindingAssertionHelper bh= getAssertionHelper();
|
||||
ICPPClassType c= bh.assertNonProblem("A", 1);
|
||||
assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c).length);
|
||||
assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c, null).length);
|
||||
}
|
||||
|
||||
// template <typename T> struct CT1 {};
|
||||
|
@ -9713,7 +9713,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// g( nullptr ); // error
|
||||
// }
|
||||
public void testNullptr_327298b() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
bh.assertProblem("checkNullPtr(1)", 12);
|
||||
bh.assertProblem("checklvalue(nullptr)", 11);
|
||||
bh.assertProblem("g( nullptr )", 1);
|
||||
|
@ -9727,7 +9727,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testNullptr_327298c() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
IFunction f= bh.assertNonProblem("f( nullptr )", 1);
|
||||
assertEquals("void (char *)", ASTTypeUtil.getType(f.getType()));
|
||||
f= bh.assertNonProblem("f( 0 )", 1);
|
||||
|
@ -9736,7 +9736,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
// void foo(struct S s);
|
||||
public void testParameterForwardDeclaration_379511() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
ICPPClassType struct= bh.assertNonProblem("S", 1, ICPPClassType.class);
|
||||
IName[] declarations= bh.getTranslationUnit().getDeclarations(struct);
|
||||
assertEquals(1, declarations.length);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -90,7 +90,7 @@ public class SemanticsTests extends AST2BaseTest {
|
|||
// Test getDeclaredConversionOperators()
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
ICPPClassType c= ba.assertNonProblem("X {", 1, ICPPClassType.class);
|
||||
ICPPMethod[] cops= SemanticUtil.getDeclaredConversionOperators(c);
|
||||
ICPPMethod[] cops= SemanticUtil.getDeclaredConversionOperators(c, null);
|
||||
assertEquals(2, cops.length);
|
||||
Set actual= new HashSet();
|
||||
actual.add(cops[0].getName()); actual.add(cops[1].getName());
|
||||
|
|
|
@ -55,8 +55,10 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
|||
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -226,10 +228,10 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
assertInstance(b1, ICPPInstanceCache.class);
|
||||
|
||||
ICPPInstanceCache ct= (ICPPInstanceCache) b1;
|
||||
ICPPSpecialization inst= ct.getInstance(new ICPPTemplateArgument[]{new CPPTemplateArgument((IType)b0)});
|
||||
ICPPSpecialization inst= ct.getInstance(new ICPPTemplateArgument[]{new CPPTemplateTypeArgument((IType)b0)});
|
||||
assertInstance(inst, ICPPClassType.class);
|
||||
ICPPClassType c2t= (ICPPClassType) inst;
|
||||
ICPPBase[] bases= c2t.getBases();
|
||||
ICPPBase[] bases= ClassTypeHelper.getBases(c2t, null);
|
||||
assertEquals(1, bases.length);
|
||||
assertInstance(bases[0].getBaseClass(), ICPPClassType.class);
|
||||
}
|
||||
|
@ -998,74 +1000,74 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// class template instance
|
||||
ct= getBindingFromASTName("CT<int>", 7);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class template instance
|
||||
ct= getBindingFromASTName("CT<char>", 8);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// class specialization
|
||||
ct= getBindingFromASTName("C spec", 1);
|
||||
assertInstance(ct, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "C"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"C", "C"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "C"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"C", "C"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "C"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// class template specialization
|
||||
ct= getBindingFromASTName("CT<int> spect", 2);
|
||||
assertInstance(ct, ICPPClassTemplate.class, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class specialization
|
||||
ct= getBindingFromASTName("C espec", 1);
|
||||
assertInstance(ct, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "C", "C"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"C", "C", "C"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "C", "C"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "C", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"C", "C", "C"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "C", "C"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class template specialization
|
||||
ct= getBindingFromASTName("CT<int> espect", 7);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
}
|
||||
|
||||
// void func(const int* x) {}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -56,14 +57,14 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
|||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
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.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for exercising resolution of template bindings against IIndex
|
||||
*/
|
||||
|
@ -629,23 +630,23 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b2, ICPPClassType.class);
|
||||
assertInstance(b2, ICPPTemplateInstance.class);
|
||||
ICPPClassType ct2= (ICPPClassType) b2;
|
||||
ICPPBase[] bss2= ct2.getBases();
|
||||
ICPPBase[] bss2= ClassTypeHelper.getBases(ct2, null);
|
||||
assertEquals(1, bss2.length);
|
||||
assertInstance(bss2[0].getBaseClass(), ICPPClassType.class);
|
||||
ICPPClassType ct2b= (ICPPClassType) bss2[0].getBaseClass();
|
||||
assertInstance(ct2b, ICPPTemplateInstance.class);
|
||||
|
||||
|
||||
IBinding b0= getBindingFromASTName("B<int>", 6);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPBase[] bss= ct.getBases();
|
||||
ICPPBase[] bss= ClassTypeHelper.getBases(ct, null);
|
||||
assertEquals(1, bss.length);
|
||||
assertInstance(bss[0].getBaseClass(), ICPPClassType.class);
|
||||
|
||||
|
||||
IBinding b1= getBindingFromASTName("B<long>", 7);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
ICPPClassType ct1= (ICPPClassType) b1;
|
||||
ICPPBase[] bss1= ct1.getBases();
|
||||
ICPPBase[] bss1= ClassTypeHelper.getBases(ct1, null);
|
||||
assertEquals(1, bss1.length);
|
||||
assertInstance(bss1[0].getBaseClass(), ICPPClassType.class);
|
||||
}
|
||||
|
@ -672,13 +673,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b0= getBindingFromASTName("A<B> ab", 4);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
assertInstance(b0, ICPPSpecialization.class);
|
||||
|
||||
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPMethod[] dms= ct.getDeclaredMethods();
|
||||
ICPPMethod[] dms= ClassTypeHelper.getDeclaredMethods(ct, null);
|
||||
assertEquals(2, dms.length);
|
||||
|
||||
// if the specialization was used, we have 2 fields.
|
||||
ICPPField[] fs= ct.getDeclaredFields();
|
||||
ICPPField[] fs= ClassTypeHelper.getDeclaredFields(ct, null);
|
||||
assertEquals(2, fs.length);
|
||||
|
||||
ICPPMethod foo= dms[0].getName().equals("foo") ? dms[0] : dms[1];
|
||||
|
@ -1556,8 +1557,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments(), name);
|
||||
assertSame(inst, inst2);
|
||||
|
||||
IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateArgument(new CPPBasicType(Kind.eChar, 0))}, name);
|
||||
IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateArgument(new CPPBasicType(Kind.eChar, 0))}, name);
|
||||
IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name);
|
||||
IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name);
|
||||
assertSame(charInst1, charInst2);
|
||||
}
|
||||
|
||||
|
@ -1574,7 +1575,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(m, ICPPSpecialization.class);
|
||||
ICPPClassType ct= m.getClassOwner();
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
ICPPMethod[] ms= ct.getDeclaredMethods();
|
||||
ICPPMethod[] ms= ClassTypeHelper.getDeclaredMethods(ct, null);
|
||||
assertEquals(1, ms.length);
|
||||
assertEquals(m, ms[0]);
|
||||
}
|
||||
|
@ -1849,16 +1850,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
methods= ct.getMethods();
|
||||
assertEquals(14, methods.length);
|
||||
|
||||
ICPPBase[] bases = ct.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(ct, null);
|
||||
assertEquals(1, bases.length);
|
||||
|
||||
IField field = ct.findField("bfield");
|
||||
assertNotNull(field);
|
||||
|
||||
IField[] fields = ct.getFields();
|
||||
IField[] fields = ClassTypeHelper.getFields(ct, null);
|
||||
assertEquals(2, fields.length);
|
||||
|
||||
IBinding[] friends = ct.getFriends();
|
||||
IBinding[] friends = ClassTypeHelper.getFriends(ct, null);
|
||||
assertEquals(0, friends.length); // not yet supported
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -34,6 +35,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
@ -237,9 +239,10 @@ public class CPPClassTemplateTests extends PDOMTestBase {
|
|||
ICPPVariable var= (ICPPVariable) bs[0];
|
||||
assertInstance(var.getType(), ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) var.getType();
|
||||
assertEquals(1, ct.getFields().length);
|
||||
assertInstance(ct.getFields()[0].getType(), IPointerType.class);
|
||||
IPointerType pt= (IPointerType) ct.getFields()[0].getType();
|
||||
IField[] fields = ClassTypeHelper.getFields(ct, null);
|
||||
assertEquals(1, fields.length);
|
||||
assertInstance(fields[0].getType(), IPointerType.class);
|
||||
IPointerType pt= (IPointerType) fields[0].getType();
|
||||
assertInstance(pt.getType(), IFunctionType.class);
|
||||
IFunctionType ft= (IFunctionType) pt.getType();
|
||||
assertInstance(ft.getReturnType(), ICPPClassType.class);
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
|
||||
/**
|
||||
* Models a value of a variable, enumerator or expression.
|
||||
*
|
||||
|
@ -19,27 +22,33 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
public interface IValue {
|
||||
/**
|
||||
* Returns the value as a number, or <code>null</code> if this is not possible.
|
||||
* Returns the value as a number, or {@code null} if it is not possible.
|
||||
*/
|
||||
Long numericalValue();
|
||||
|
||||
|
||||
/**
|
||||
* Returns an internal representation of the expression that builds up
|
||||
* the value. It is suitable for instantiating dependent values but may not be
|
||||
* used for the purpose of displaying values.
|
||||
* Returns the evaluation object if this value is dependent, or {@code null} otherwise.
|
||||
* If {@link #numericalValue()} returns {@code null}, {@link #getEvaluation()} returns
|
||||
* not {@code null} and vice versa.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
char[] getInternalExpression();
|
||||
|
||||
ICPPEvaluation getEvaluation();
|
||||
|
||||
/**
|
||||
* A value may be dependent on template parameters, in which case a list
|
||||
* of unknown bindings is maintained for later instantiation.
|
||||
*/
|
||||
IBinding[] getUnknownBindings();
|
||||
|
||||
/**
|
||||
* Returns a signature containing both the internal representation and
|
||||
* the unknown bindings. The representation is sufficient to distinguish values
|
||||
* for the purpose of instantiation, it may not be used to display the value.
|
||||
* Returns a signature uniquely identifying the value. Two values with identical
|
||||
* signatures are guaranteed to be equal.
|
||||
*/
|
||||
char[] getSignature();
|
||||
|
||||
/**
|
||||
* @deprecated Returns an empty character array.
|
||||
*/
|
||||
@Deprecated
|
||||
char[] getInternalExpression();
|
||||
|
||||
/**
|
||||
* @deprecated Returns an empty array.
|
||||
*/
|
||||
@Deprecated
|
||||
IBinding[] getUnknownBindings();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTInitializerClause, ICPPASTPackExpandable {
|
||||
|
||||
@Override
|
||||
ICPPASTInitializerList copy();
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 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
|
||||
* Copyright (c) 2004, 2010 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:
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for class scopes.
|
||||
*
|
||||
|
@ -20,17 +19,15 @@ package org.eclipse.cdt.core.dom.ast.cpp;
|
|||
*/
|
||||
public interface ICPPClassScope extends ICPPScope {
|
||||
/**
|
||||
* Get the binding for the class this scope is associated with
|
||||
*
|
||||
* Returns the binding for the class this scope is associated with.
|
||||
*/
|
||||
ICPPClassType getClassType();
|
||||
|
||||
/**
|
||||
* Returns an array of methods that were implicitly added to this class
|
||||
* scope. These methods may or may not have been explicitly declared in the
|
||||
* code. The methods that will be implicitly declared are: the default
|
||||
* scope. These methods may or may not have been explicitly declared in
|
||||
* the code. The methods that will be implicitly declared are: the default
|
||||
* constructor, copy constructor, copy assignment operator, and destructor
|
||||
*
|
||||
*/
|
||||
public ICPPMethod[] getImplicitMethods();
|
||||
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2012 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
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
||||
/**
|
||||
* Specializations of all sorts of class types.
|
||||
|
@ -21,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassType {
|
||||
|
||||
@Override
|
||||
ICPPClassType getSpecializedBinding();
|
||||
|
||||
|
@ -37,4 +38,67 @@ public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassTy
|
|||
* @since 5.5
|
||||
*/
|
||||
IBinding specializeMember(IBinding binding, IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getBases()} but a accepts a starting point for template
|
||||
* instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPBase[] getBases(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getConstructors()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPConstructor[] getConstructors(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getDeclaredFields()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPField[] getDeclaredFields(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPMethod[] getMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getAllDeclaredMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPMethod[] getAllDeclaredMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getDeclaredMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPMethod[] getDeclaredMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getFriends()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
IBinding[] getFriends(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getFriends()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
IField[] getFields(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getNestedClasses()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPClassType[] getNestedClasses(IASTNode point);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
||||
/**
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
|
|
|
@ -25,10 +25,8 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
|
|||
public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
|
||||
|
||||
/**
|
||||
* Returns a list of base class relationships. The list is empty if there
|
||||
* Returns an array of base class relationships. The returned array is empty if there
|
||||
* are none.
|
||||
*
|
||||
* @return List of ICPPBase
|
||||
*/
|
||||
public ICPPBase[] getBases();
|
||||
|
||||
|
@ -88,18 +86,17 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
|
|||
* Returns an array of ICPPConstructor objects representing the constructors
|
||||
* for this class. This list includes both declared and implicit
|
||||
* constructors.
|
||||
*
|
||||
*/
|
||||
public ICPPConstructor[] getConstructors();
|
||||
|
||||
/**
|
||||
* return an array of bindings for those classes/functions declared as
|
||||
* Returns an array of bindings for those classes/functions declared as
|
||||
* friends of this class.
|
||||
*/
|
||||
public IBinding[] getFriends();
|
||||
|
||||
/**
|
||||
* return an array of nested classes/structures
|
||||
* Returns an array of nested classes/structures
|
||||
*/
|
||||
public ICPPClassType[] getNestedClasses();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 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.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* Specialization of a method.
|
||||
* @since 5.5
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPMethodSpecialization extends ICPPSpecialization, ICPPMethod {
|
||||
/**
|
||||
* Similar to {@link ICPPFunction#getExceptionSpecification()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
IType[] getExceptionSpecification(IASTNode point);
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
|
@ -19,11 +19,10 @@ import java.util.Map;
|
|||
*/
|
||||
public interface IScannerInfo {
|
||||
/**
|
||||
* Returns a <code>Map</code> containing all the defined preprocessor
|
||||
* symbols and their values.
|
||||
* Returns a {@link Map} containing all the defined preprocessor symbols and their values.
|
||||
* Symbols defined without values have an empty string for a value. For
|
||||
* example,-Dsymbol=value would have a map entry (symbol,value). A symbol
|
||||
* defined as -Dsymbol= would have a map entry of (symbol,"").
|
||||
* example, -Dsymbol=value would have a map entry (symbol, value). A symbol
|
||||
* defined as -Dsymbol= would have a map entry of (symbol, "").
|
||||
*/
|
||||
public Map<String, String> getDefinedSymbols();
|
||||
|
||||
|
@ -41,9 +40,10 @@ public interface IScannerInfo {
|
|||
* <br> E.g.: /System/Library/Frameworks/__framework__.framework/Headers/__header__,
|
||||
* /System/Library/Frameworks/__framework__.framework/PrivateHeaders/__header__
|
||||
* would handle the framework search for '/System/Library/Frameworks'
|
||||
* <br> The variables are handled only, if a search path element makes use of both of the variables.
|
||||
* The __framework__ variable will receive the first segment of the include, the __header__ variable
|
||||
* the rest. Such a search path element is not used for directives with a single segment (e.g. 'header.h')
|
||||
* <br> The variables are handled only, if a search path element makes use of both of
|
||||
* the variables. The __framework__ variable will receive the first segment of the include,
|
||||
* the __header__ variable the rest. Such a search path element is not used for directives
|
||||
* with a single segment (e.g. 'header.h')
|
||||
*/
|
||||
public String[] getIncludePaths();
|
||||
}
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
|
|
@ -329,7 +329,7 @@ public class CharArrayUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Find an array of chars in an array of arrays of chars.
|
||||
* Finds an array of chars in an array of arrays of chars.
|
||||
* @return offset where the array was found or <code>-1</code>
|
||||
*/
|
||||
public static int indexOf(final char[] searchFor, final char[][] searchIn) {
|
||||
|
@ -340,4 +340,15 @@ public class CharArrayUtils {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link StringBuilder} to a character array.
|
||||
* @since 5.5
|
||||
*/
|
||||
public static char[] extractChars(StringBuilder buf) {
|
||||
final int len = buf.length();
|
||||
char[] result= new char[len];
|
||||
buf.getChars(0, len, result, 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 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.core.parser.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Automatically growing integer array.
|
||||
*
|
||||
* @since 5.5
|
||||
*/
|
||||
public class IntArray {
|
||||
private static final int INITIAL_CAPACITY = 10;
|
||||
private static final int[] EMPTY_ARRAY = {};
|
||||
|
||||
private int[] buffer = EMPTY_ARRAY;
|
||||
private int size;
|
||||
|
||||
public IntArray() {
|
||||
}
|
||||
|
||||
public IntArray(int initialCapacity) {
|
||||
this.buffer = new int[initialCapacity];
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
public void add(int value) {
|
||||
grow(size + 1);
|
||||
buffer[size++] = value;
|
||||
}
|
||||
|
||||
public void add(int index, int value) {
|
||||
checkBounds(index);
|
||||
grow(size + 1);
|
||||
System.arraycopy(buffer, index, buffer, index + 1, size - index);
|
||||
buffer[index] = value;
|
||||
size++;
|
||||
}
|
||||
|
||||
public void addAll(IntArray other) {
|
||||
grow(size + other.size());
|
||||
System.arraycopy(other.buffer, 0, buffer, size, other.size);
|
||||
size += other.size;
|
||||
return;
|
||||
}
|
||||
|
||||
public void addAll(int[] array) {
|
||||
grow(size + array.length);
|
||||
System.arraycopy(array, 0, buffer, size, array.length);
|
||||
size += array.length;
|
||||
return;
|
||||
}
|
||||
|
||||
public int remove(int index) {
|
||||
checkBounds(index);
|
||||
int old = buffer[index];
|
||||
int n = size - index - 1;
|
||||
if (n > 0) {
|
||||
System.arraycopy(buffer, index + 1, buffer, index, n);
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
||||
public void remove(int from, int to) {
|
||||
checkBounds(from);
|
||||
checkBounds(to);
|
||||
System.arraycopy(buffer, to, buffer, from, size - to);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public int get(int index) {
|
||||
checkRange(index);
|
||||
return buffer[index];
|
||||
}
|
||||
|
||||
public int set(int index, int value) {
|
||||
checkBounds(index);
|
||||
int old = buffer[index];
|
||||
buffer[index] = value;
|
||||
return old;
|
||||
}
|
||||
|
||||
public int[] toArray() {
|
||||
return size == 0 ? EMPTY_ARRAY : Arrays.copyOf(buffer, size);
|
||||
}
|
||||
|
||||
public void trimToSize() {
|
||||
if (size == 0) {
|
||||
buffer = EMPTY_ARRAY;
|
||||
} else if (size < buffer.length) {
|
||||
buffer = Arrays.copyOf(buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
public void ensureCapacity(int minCapacity) {
|
||||
if (minCapacity > 0) {
|
||||
grow(minCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
private void grow(int minCapacity) {
|
||||
if (minCapacity < 0) // Overflow
|
||||
throw new OutOfMemoryError();
|
||||
|
||||
int capacity = buffer.length;
|
||||
if (minCapacity > capacity) {
|
||||
int newCapacity = capacity == 0 ? INITIAL_CAPACITY : capacity + (capacity >> 1);
|
||||
// newCapacity may be negative due to overflow.
|
||||
if (newCapacity < minCapacity)
|
||||
newCapacity = minCapacity;
|
||||
// newCapacity is guaranteed to be non negative.
|
||||
try {
|
||||
buffer = Arrays.copyOf(buffer, newCapacity);
|
||||
} catch (OutOfMemoryError e) {
|
||||
// Try again it case we were too aggressive in reserving capacity.
|
||||
buffer = Arrays.copyOf(buffer, minCapacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBounds(int index) {
|
||||
if (index < 0) {
|
||||
throw new IndexOutOfBoundsException("Negative index: " + index); //$NON-NLS-1$
|
||||
}
|
||||
checkRange(index);
|
||||
}
|
||||
|
||||
private void checkRange(int index) {
|
||||
if (index >= size) {
|
||||
throw new IndexOutOfBoundsException("Index: " + index + ", size: " + size); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ public class Linkage implements ILinkage {
|
|||
}
|
||||
|
||||
public static String getLinkageName(int linkageID) throws CoreException {
|
||||
switch(linkageID) {
|
||||
switch (linkageID) {
|
||||
case NO_LINKAGE_ID: return NO_LINKAGE_NAME;
|
||||
case C_LINKAGE_ID: return C_LINKAGE_NAME;
|
||||
case CPP_LINKAGE_ID: return CPP_LINKAGE_NAME;
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -61,6 +62,7 @@ public interface ITypeMarshalBuffer {
|
|||
IValue unmarshalValue() throws CoreException;
|
||||
IBinding unmarshalBinding() throws CoreException;
|
||||
ISerializableEvaluation unmarshalEvaluation() throws CoreException;
|
||||
ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException;
|
||||
int getByte() throws CoreException;
|
||||
int getShort() throws CoreException;
|
||||
int getInt() throws CoreException;
|
||||
|
@ -71,6 +73,7 @@ public interface ITypeMarshalBuffer {
|
|||
void marshalValue(IValue value) throws CoreException;
|
||||
void marshalBinding(IBinding binding) throws CoreException;
|
||||
void marshalEvaluation(ISerializableEvaluation eval, boolean includeValue) throws CoreException;
|
||||
void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException;
|
||||
void putByte(byte data);
|
||||
void putShort(short data);
|
||||
void putInt(int data);
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
@ -48,6 +49,8 @@ public class SizeofCalculator {
|
|||
}
|
||||
}
|
||||
|
||||
private static final SizeofCalculator defaultInstance = new SizeofCalculator();
|
||||
|
||||
private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1);
|
||||
|
||||
public final SizeAndAlignment size_2;
|
||||
|
@ -67,6 +70,15 @@ public class SizeofCalculator {
|
|||
public final SizeAndAlignment sizeof_long_double;
|
||||
public final SizeAndAlignment sizeof_complex_long_double;
|
||||
|
||||
/**
|
||||
* Returns the default instance of sizeof calculator. The default instance is not aware
|
||||
* of the parser configuration and can only calculate sizes that are the same across all
|
||||
* C/C++ implementations.
|
||||
*/
|
||||
public static SizeofCalculator getDefault() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public SizeofCalculator(IASTTranslationUnit ast) {
|
||||
int maxAlignment = 32;
|
||||
Map<String, String> sizeofMacros = new HashMap<String, String>();
|
||||
|
@ -102,6 +114,25 @@ public class SizeofCalculator {
|
|||
sizeof_complex_long_double = getSizeOfPair(sizeof_long_double);
|
||||
}
|
||||
|
||||
private SizeofCalculator() {
|
||||
size_2 = new SizeAndAlignment(2, 2);
|
||||
size_4 = new SizeAndAlignment(4, 4);
|
||||
size_8 = new SizeAndAlignment(8, 8);
|
||||
sizeof_pointer = null;
|
||||
sizeof_int = null;
|
||||
sizeof_long = null;
|
||||
sizeof_long_long = null;
|
||||
sizeof_short = null;
|
||||
sizeof_bool = null;
|
||||
sizeof_wchar_t = null;
|
||||
sizeof_float = null;
|
||||
sizeof_complex_float = null;
|
||||
sizeof_double = null;
|
||||
sizeof_complex_double = null;
|
||||
sizeof_long_double = null;
|
||||
sizeof_complex_long_double = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates size and alignment for the given type.
|
||||
* @param type the type to get size and alignment for.
|
||||
|
@ -109,7 +140,9 @@ public class SizeofCalculator {
|
|||
*/
|
||||
public SizeAndAlignment sizeAndAlignment(IType type) {
|
||||
type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF);
|
||||
|
||||
if (type instanceof IFunctionType) {
|
||||
return sizeAndAlignment(((IFunctionType) type).getReturnType());
|
||||
}
|
||||
if (type instanceof IBasicType) {
|
||||
return sizeAndAlignment((IBasicType) type);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Devin Steffler (IBM Corporation) - initial API and implementation
|
||||
* Devin Steffler (IBM Corporation) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -157,7 +157,6 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte= ITypeMarshalBuffer.ARRAY_TYPE;
|
||||
|
@ -174,14 +173,13 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||
}
|
||||
|
||||
|
||||
val= getSize();
|
||||
if (val != null) {
|
||||
firstByte |= ITypeMarshalBuffer.FLAG2;
|
||||
Long num= val.numericalValue();
|
||||
if (num != null) {
|
||||
long l= num;
|
||||
if (l>=0 && l <= Short.MAX_VALUE) {
|
||||
if (l >= 0 && l <= Short.MAX_VALUE) {
|
||||
nval= (short) l;
|
||||
firstByte |= ITypeMarshalBuffer.FLAG3;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 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
|
||||
|
@ -10,9 +10,11 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
|
@ -124,19 +126,19 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
public ICPPBase[] getBases(IASTNode point) {
|
||||
if (fBases == null) {
|
||||
ICPPBase[] result = null;
|
||||
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(specialClass.getSpecializedBinding(), point);
|
||||
if (bases.length == 0) {
|
||||
fBases= bases;
|
||||
} else {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap();
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding origClass = base.getBaseClass();
|
||||
if (origClass instanceof ICPPTemplateParameter && ((ICPPTemplateParameter) origClass).isParameterPack()) {
|
||||
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[]{new CPPParameterPackType((IType) origClass)}, tpmap, -1, specialClass, point);
|
||||
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[] { new CPPParameterPackType((IType) origClass) },
|
||||
tpmap, -1, specialClass, point);
|
||||
if (specClasses.length == 1 && specClasses[0] instanceof ICPPParameterPackType) {
|
||||
result= ArrayUtil.append(ICPPBase.class, result, base);
|
||||
} else {
|
||||
|
@ -182,15 +184,19 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
ICPPField[] fields= specialClass.getSpecializedBinding().getDeclaredFields();
|
||||
public ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
ICPPField[] fields= ClassTypeHelper.getDeclaredFields(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(fields, point);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getImplicitMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods(IASTNode point) {
|
||||
ICPPClassScope origClassScope= (ICPPClassScope) specialClass.getSpecializedBinding().getCompositeScope();
|
||||
if (origClassScope == null) {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
|
@ -208,30 +214,31 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
// mstodo need to pass the point of instantiation
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
ICPPConstructor[] ctors= specialClass.getSpecializedBinding().getConstructors();
|
||||
return specializeMembers(ctors, point);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
ICPPMethod[] bindings = specialClass.getSpecializedBinding().getDeclaredMethods();
|
||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
ICPPConstructor[] ctors= ClassTypeHelper.getConstructors(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(ctors, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
ICPPMethod[] bindings = ClassTypeHelper.getDeclaredMethods(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(bindings, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
ICPPClassType[] bindings = specialClass.getSpecializedBinding().getNestedClasses();
|
||||
public ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
ICPPClassType[] bindings = ClassTypeHelper.getNestedClasses(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(bindings, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IBinding[] friends = specialClass.getSpecializedBinding().getFriends();
|
||||
public IBinding[] getFriends(IASTNode point) {
|
||||
IBinding[] friends = ClassTypeHelper.getFriends(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(friends, point);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
/**
|
||||
* For example in the constructor definition <br>
|
||||
|
@ -174,7 +175,7 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
|
|||
IBinding method= fdef.getDeclarator().getName().resolveBinding();
|
||||
if (method instanceof ICPPMethod) {
|
||||
ICPPClassType cls= ((ICPPMethod) method).getClassOwner();
|
||||
for (ICPPBase base : cls.getBases()) {
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(cls, fdef)) {
|
||||
result.put(base.getBaseClassSpecifierName().getSimpleID());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CPPASTFieldReference extends ASTNode
|
|||
private boolean isDeref;
|
||||
private IASTImplicitName[] implicitNames;
|
||||
private ICPPEvaluation fEvaluation;
|
||||
|
||||
|
||||
public CPPASTFieldReference() {
|
||||
}
|
||||
|
||||
|
@ -74,11 +74,7 @@ public class CPPASTFieldReference extends ASTNode
|
|||
copy.setFieldOwner(owner == null ? null : owner.copy(style));
|
||||
copy.isTemplate = isTemplate;
|
||||
copy.isDeref = isDeref;
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -282,7 +278,7 @@ public class CPPASTFieldReference extends ASTNode
|
|||
if (n instanceof ICPPASTTemplateId) {
|
||||
args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
|
||||
}
|
||||
return new EvalID(ownerEval, qualifier, name.getSimpleID(), false, qualifier != null, args);
|
||||
return new EvalID(ownerEval, qualifier, name.getSimpleID(), false, true, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
@ -40,6 +43,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
public class CPPASTFunctionCallExpression extends ASTNode
|
||||
implements ICPPASTFunctionCallExpression, IASTAmbiguityParent {
|
||||
|
@ -163,7 +167,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
}
|
||||
} else {
|
||||
n1.computeOperatorOffsets(functionName, true);
|
||||
n2.computeOperatorOffsets(fArguments[fArguments.length-1], true);
|
||||
n2.computeOperatorOffsets(fArguments[fArguments.length - 1], true);
|
||||
}
|
||||
|
||||
implicitNames = new IASTImplicitName[] { n1, n2 };
|
||||
|
@ -219,8 +223,6 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IASTExpression getParameterExpression() {
|
||||
|
@ -269,7 +271,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
ICPPClassType cls= (ICPPClassType) t;
|
||||
LookupData data= CPPSemantics.createLookupData(((IASTIdExpression) functionName).getName());
|
||||
try {
|
||||
IBinding b= CPPSemantics.resolveFunction(data, cls.getConstructors(), true);
|
||||
IBinding b= CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors(cls, data.getLookupPoint()), true);
|
||||
if (b instanceof ICPPFunction)
|
||||
return (ICPPFunction) b;
|
||||
} catch (DOMException e) {
|
||||
|
@ -296,10 +298,10 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
if (conversion != null)
|
||||
return conversion;
|
||||
|
||||
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length+1];
|
||||
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length + 1];
|
||||
args[0]= functionName.getEvaluation();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
args[i]= ((ICPPASTExpression) fArguments[i-1]).getEvaluation();
|
||||
args[i]= ((ICPPASTExpression) fArguments[i - 1]).getEvaluation();
|
||||
}
|
||||
return new EvalFunctionCall(args);
|
||||
}
|
||||
|
@ -318,7 +320,6 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IType getExpressionType() {
|
||||
|
|
|
@ -271,14 +271,14 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
|
||||
|
||||
if (namesPos > 0) {
|
||||
IBinding binding = names[namesPos-1].resolveBinding();
|
||||
IBinding binding = names[namesPos - 1].resolveBinding();
|
||||
if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType classType = (ICPPClassType) binding;
|
||||
final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;
|
||||
List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
|
||||
if (isDeclaration && nameMatches(classType.getNameCharArray(),
|
||||
n.getLookupKey(), isPrefix)) {
|
||||
ICPPConstructor[] constructors = classType.getConstructors();
|
||||
ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(classType, n);
|
||||
for (int i = 0; i < constructors.length; i++) {
|
||||
if (!constructors[i].isImplicit()) {
|
||||
filtered.add(constructors[i]);
|
||||
|
@ -303,7 +303,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
while(scope != null) {
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
ICPPClassType classType = ((ICPPClassScope) scope).getClassType();
|
||||
if (SemanticUtil.calculateInheritanceDepth(classType, baseClass) >= 0) {
|
||||
if (SemanticUtil.calculateInheritanceDepth(classType, baseClass, this) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -40,8 +40,8 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent;
|
|||
* C++-specific implementation of a translation-unit.
|
||||
*/
|
||||
public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPASTTranslationUnit, IASTAmbiguityParent {
|
||||
private CPPNamespaceScope fScope = null;
|
||||
private ICPPNamespace fBinding = null;
|
||||
private CPPNamespaceScope fScope;
|
||||
private ICPPNamespace fBinding;
|
||||
private final CPPScopeMapper fScopeMapper= new CPPScopeMapper(this);
|
||||
|
||||
public CPPASTTranslationUnit() {
|
||||
|
|
|
@ -211,7 +211,7 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
|||
int modifiers= 0;
|
||||
int kind;
|
||||
if (dense) {
|
||||
kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
|
||||
kind= (firstByte & (ITypeMarshalBuffer.FLAG4 - 1)) / ITypeMarshalBuffer.FLAG1;
|
||||
} else {
|
||||
kind= buffer.getByte();
|
||||
modifiers= buffer.getByte();
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
|
@ -122,61 +123,103 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getBases(this);
|
||||
|
||||
return scope.getBases();
|
||||
return scope.getBases(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getDeclaredFields(this);
|
||||
|
||||
return scope.getDeclaredFields();
|
||||
return scope.getDeclaredFields(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getDeclaredMethods(this);
|
||||
|
||||
return scope.getDeclaredMethods();
|
||||
return scope.getDeclaredMethods(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getConstructors(this);
|
||||
|
||||
return scope.getConstructors();
|
||||
return scope.getConstructors(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getFriends(this);
|
||||
|
||||
return scope.getFriends();
|
||||
return scope.getFriends(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||
if (scope == null)
|
||||
return ClassTypeHelper.getNestedClasses(this);
|
||||
|
||||
return scope.getNestedClasses();
|
||||
return scope.getNestedClasses(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -186,12 +229,24 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -226,7 +281,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
if (getDefinition() != null)
|
||||
return null;
|
||||
|
||||
//implicit specialization: must specialize bindings in scope
|
||||
// Implicit specialization: must specialize bindings in scope.
|
||||
if (specScope == null) {
|
||||
specScope = new CPPClassSpecializationScope(this);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
|
|||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,12 +169,12 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -30,8 +30,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
*/
|
||||
public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClassSpecialization
|
||||
implements ICPPClassTemplatePartialSpecializationSpecialization, ICPPInternalClassTemplate {
|
||||
|
||||
private ObjectMap instances = null;
|
||||
private ObjectMap instances;
|
||||
private ICPPDeferredClassInstance fDeferredInstance;
|
||||
private final ICPPClassTemplate fClassTemplate;
|
||||
private final ICPPTemplateArgument[] fArguments;
|
||||
|
@ -70,7 +69,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
|
|||
public synchronized ICPPTemplateInstance[] getAllInstances() {
|
||||
if (instances != null) {
|
||||
ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()];
|
||||
for (int i=0; i < instances.size(); i++) {
|
||||
for (int i= 0; i < instances.size(); i++) {
|
||||
result[i]= (ICPPTemplateInstance) instances.getAt(i);
|
||||
}
|
||||
return result;
|
||||
|
@ -142,7 +141,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
|
|||
|
||||
@Override
|
||||
public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException {
|
||||
// no default arguments for partial specializations
|
||||
// No default arguments for partial specializations
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
@Override
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
||||
if (fPartialSpecs == null) {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IASTNode point= null; // Instantiation of dependent expressions may not work.
|
||||
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
|
||||
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
|
||||
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
|
||||
|
|
|
@ -309,7 +309,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
|||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -319,12 +319,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
* Binding for a specialization of a field.
|
||||
*/
|
||||
public class CPPFieldSpecialization extends CPPSpecialization implements ICPPField {
|
||||
private IType type = null;
|
||||
private IValue value= null;
|
||||
private final IType type;
|
||||
private final IValue value;
|
||||
|
||||
public CPPFieldSpecialization(IBinding orig, ICPPClassType owner, ICPPTemplateParameterMap tpmap,
|
||||
IType type, IValue value) {
|
||||
|
@ -36,7 +36,7 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
private ICPPField getField() {
|
||||
return (ICPPField) getSpecializedBinding();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return getField().getVisibility();
|
||||
|
@ -46,7 +46,7 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
public ICPPClassType getClassOwner() {
|
||||
return getField().getClassOwner();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return type;
|
||||
|
|
|
@ -194,6 +194,6 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -20,20 +21,27 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethodSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* The specialization of a method in the context of a class-specialization.
|
||||
*/
|
||||
public class CPPMethodSpecialization extends CPPFunctionSpecialization implements ICPPMethod {
|
||||
public class CPPMethodSpecialization extends CPPFunctionSpecialization implements ICPPMethodSpecialization {
|
||||
|
||||
public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpec ) {
|
||||
super(orig, owner, argMap, type, exceptionSpec );
|
||||
public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap,
|
||||
ICPPFunctionType type, IType[] exceptionSpec) {
|
||||
super(orig, owner, argMap, type, exceptionSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod getSpecializedBinding() {
|
||||
return (ICPPMethod) super.getSpecializedBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.isVirtual();
|
||||
IASTNode definition = getDefinition();
|
||||
|
@ -58,7 +66,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.getVisibility();
|
||||
return 0;
|
||||
|
@ -80,17 +88,17 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
|
||||
@Override
|
||||
public boolean isExplicit() {
|
||||
return ((ICPPMethod) getSpecializedBinding()).isExplicit();
|
||||
return getSpecializedBinding().isExplicit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImplicit() {
|
||||
return ((ICPPMethod) getSpecializedBinding()).isImplicit();
|
||||
return getSpecializedBinding().isImplicit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPureVirtual() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.isPureVirtual();
|
||||
|
||||
|
@ -98,9 +106,9 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
public IType[] getExceptionSpecification(IASTNode point) {
|
||||
if (isImplicit()) {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, point);
|
||||
}
|
||||
return super.getExceptionSpecification();
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
|||
@Override
|
||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||
IBinding[] result = getBindingsInAST(lookup);
|
||||
final IASTTranslationUnit tu = lookup.getLookupPoint().getTranslationUnit();
|
||||
final IASTTranslationUnit tu = lookup.getTranslationUnit();
|
||||
if (tu != null) {
|
||||
IIndex index = tu.getIndex();
|
||||
if (index != null) {
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 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
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of non-type template argument, used by AST and index.
|
||||
*/
|
||||
public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
|
||||
private final ICPPEvaluation fEvaluation;
|
||||
|
||||
public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation) {
|
||||
Assert.isNotNull(evaluation);
|
||||
fEvaluation= evaluation;
|
||||
}
|
||||
|
||||
public CPPTemplateNonTypeArgument(IValue value, IType type) {
|
||||
fEvaluation = new EvalFixed(type, PRVALUE, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTypeValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNonTypeValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getTypeValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getNonTypeValue() {
|
||||
return fEvaluation.getValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getTypeOfNonTypeValue() {
|
||||
return fEvaluation.getTypeOrFunctionSet(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackExpansion() {
|
||||
return fEvaluation.getTypeOrFunctionSet(null) instanceof ICPPParameterPackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument getExpansionPattern() {
|
||||
IType type = fEvaluation.getTypeOrFunctionSet(null);
|
||||
if (type instanceof ICPPParameterPackType) {
|
||||
IType t= ((ICPPParameterPackType) type).getType();
|
||||
if (t != null) {
|
||||
ICPPEvaluation evaluation;
|
||||
if (fEvaluation instanceof EvalFixed) {
|
||||
EvalFixed fixed = (EvalFixed) fEvaluation;
|
||||
evaluation = new EvalFixed(t, fixed.getValueCategory(), fixed.getValue());
|
||||
} else {
|
||||
evaluation = new EvalTypeId(t, fEvaluation);
|
||||
}
|
||||
return new CPPTemplateNonTypeArgument(evaluation);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameValue(ICPPTemplateArgument arg) {
|
||||
return getNonTypeValue().equals(arg.getNonTypeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getNonTypeValue().toString();
|
||||
}
|
||||
|
||||
public ICPPEvaluation getEvaluation() {
|
||||
return fEvaluation;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 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
|
||||
|
@ -32,10 +32,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
/**
|
||||
* Binding for a non-type template parameter.
|
||||
*/
|
||||
public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateNonTypeParameter {
|
||||
|
||||
private IType type = null;
|
||||
public class CPPTemplateNonTypeParameter extends CPPTemplateParameter
|
||||
implements ICPPTemplateNonTypeParameter {
|
||||
private IType type;
|
||||
|
||||
public CPPTemplateNonTypeParameter(IASTName name) {
|
||||
super(name);
|
||||
|
@ -80,9 +79,9 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
d= (IASTExpression) dc;
|
||||
} else if (dc instanceof ICPPASTInitializerList) {
|
||||
ICPPASTInitializerList list= (ICPPASTInitializerList) dc;
|
||||
switch(list.getSize()) {
|
||||
switch (list.getSize()) {
|
||||
case 0:
|
||||
return new CPPTemplateArgument(Value.create(0), getType());
|
||||
return new CPPTemplateNonTypeArgument(Value.create(0), getType());
|
||||
case 1:
|
||||
dc= list.getClauses()[0];
|
||||
if (dc instanceof IASTExpression) {
|
||||
|
@ -96,7 +95,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
|
||||
IValue val= Value.create(d, Value.MAX_RECURSION_DEPTH);
|
||||
IType t= getType();
|
||||
return new CPPTemplateArgument(val, t);
|
||||
return new CPPTemplateNonTypeArgument(val, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,26 +122,32 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
public boolean isStatic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getInitialValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
|
|
|
@ -131,7 +131,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
if (d == null)
|
||||
return null;
|
||||
|
||||
return new CPPTemplateArgument(d);
|
||||
return new CPPTemplateTypeArgument(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2012 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -17,47 +18,39 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
|||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of template arguments, used by ast and index.
|
||||
* Implementation of type template arguments, used by AST and index.
|
||||
*/
|
||||
public class CPPTemplateArgument implements ICPPTemplateArgument {
|
||||
public class CPPTemplateTypeArgument implements ICPPTemplateArgument {
|
||||
private final IType fType;
|
||||
private final IValue fValue;
|
||||
|
||||
public CPPTemplateArgument(IValue value, IType type) {
|
||||
Assert.isNotNull(value);
|
||||
fType= type;
|
||||
fValue= value;
|
||||
}
|
||||
|
||||
public CPPTemplateArgument(IType type) {
|
||||
public CPPTemplateTypeArgument(IType type) {
|
||||
Assert.isNotNull(type);
|
||||
fType= type;
|
||||
fValue= null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTypeValue() {
|
||||
return fValue == null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNonTypeValue() {
|
||||
return fValue != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getTypeValue() {
|
||||
return isTypeValue() ? fType : null;
|
||||
return fType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getNonTypeValue() {
|
||||
return fValue;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getTypeOfNonTypeValue() {
|
||||
return isNonTypeValue() ? fType : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,10 +63,7 @@ public class CPPTemplateArgument implements ICPPTemplateArgument {
|
|||
if (fType instanceof ICPPParameterPackType) {
|
||||
IType t= ((ICPPParameterPackType) fType).getType();
|
||||
if (t != null) {
|
||||
if (fValue != null) {
|
||||
return new CPPTemplateArgument(fValue, t);
|
||||
}
|
||||
return new CPPTemplateArgument(t);
|
||||
return new CPPTemplateTypeArgument(t);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -81,16 +71,11 @@ public class CPPTemplateArgument implements ICPPTemplateArgument {
|
|||
|
||||
@Override
|
||||
public boolean isSameValue(ICPPTemplateArgument arg) {
|
||||
if (fValue != null) {
|
||||
return fValue.equals(arg.getNonTypeValue());
|
||||
}
|
||||
return fType.isSameType(arg.getTypeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (fValue != null)
|
||||
return fValue.toString();
|
||||
return fType.toString();
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
if (t == null)
|
||||
return null;
|
||||
|
||||
return new CPPTemplateArgument(t);
|
||||
return new CPPTemplateTypeArgument(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding, IInternalVariable {
|
||||
private IASTName fDefinition = null;
|
||||
private IASTName fDeclarations[] = null;
|
||||
private IType fType = null;
|
||||
private IASTName fDefinition;
|
||||
private IASTName fDeclarations[];
|
||||
private IType fType;
|
||||
private boolean fAllResolved;
|
||||
|
||||
public CPPVariable(IASTName name) {
|
||||
|
@ -59,10 +59,11 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
|||
name = ns[ns.length - 1];
|
||||
}
|
||||
|
||||
if (isDef)
|
||||
if (isDef) {
|
||||
fDefinition = name;
|
||||
else
|
||||
} else {
|
||||
fDeclarations = new IASTName[] { name };
|
||||
}
|
||||
|
||||
// built-in variables supply a null
|
||||
if (name != null) {
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
|||
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.ICPPClassSpecialization;
|
||||
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.ICPPField;
|
||||
|
@ -101,14 +102,14 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : members) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||
if (declSpec.isFriend()) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
|
||||
if (declSpec instanceof ICPPASTElaboratedTypeSpecifier && dtors.length == 0) {
|
||||
resultSet.put(((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding());
|
||||
resultSet.put(((ICPPASTElaboratedTypeSpecifier) declSpec).getName().resolveBinding());
|
||||
} else {
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
if (dtor == null) break;
|
||||
|
@ -118,9 +119,9 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof IASTFunctionDefinition) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) decl).getDeclSpecifier();
|
||||
if (declSpec.isFriend()) {
|
||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
||||
IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator();
|
||||
dtor= ASTQueries.findInnermostDeclarator(dtor);
|
||||
resultSet.put(dtor.getName().resolveBinding());
|
||||
}
|
||||
|
@ -144,7 +145,7 @@ public class ClassTypeHelper {
|
|||
if (type.isSameType(classType)) {
|
||||
return true;
|
||||
}
|
||||
for (IBinding friend : classType.getFriends()) {
|
||||
for (IBinding friend : getFriends(classType, null)) {
|
||||
if (friend instanceof ICPPClassType && type.isSameType((IType) friend)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ public class ClassTypeHelper {
|
|||
} else if (binding instanceof ICPPFunction) {
|
||||
type = ((ICPPFunction) binding).getType();
|
||||
char[] name = binding.getNameCharArray();
|
||||
for (IBinding friend : classType.getFriends()) {
|
||||
for (IBinding friend : getFriends(classType, null)) {
|
||||
if (friend instanceof ICPPFunction &&
|
||||
CharArrayUtils.equals(name, friend.getNameCharArray()) &&
|
||||
SemanticUtil.isSameOwner(binding.getOwner(), friend.getOwner()) &&
|
||||
|
@ -217,17 +218,17 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
binding = ASTQueries.findInnermostDeclarator(dtor).getName().resolveBinding();
|
||||
if (binding instanceof ICPPField)
|
||||
result = ArrayUtil.append(ICPPField.class, result, (ICPPField) binding);
|
||||
}
|
||||
} else if (decl instanceof ICPPASTUsingDeclaration) {
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
||||
IASTName n = ((ICPPASTUsingDeclaration) decl).getName();
|
||||
binding = n.resolveBinding();
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
IBinding[] bs = ((ICPPUsingDeclaration) binding).getDelegates();
|
||||
for (IBinding element : bs) {
|
||||
if (element instanceof ICPPField)
|
||||
result = ArrayUtil.append(ICPPField.class, result, (ICPPField) element);
|
||||
|
@ -240,27 +241,63 @@ public class ClassTypeHelper {
|
|||
return ArrayUtil.trim(ICPPField.class, result);
|
||||
}
|
||||
|
||||
public static ICPPBase[] getBases(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getBases(point);
|
||||
return classType.getBases();
|
||||
}
|
||||
|
||||
public static ICPPConstructor[] getConstructors(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getConstructors(point);
|
||||
return classType.getConstructors();
|
||||
}
|
||||
|
||||
public static ICPPField[] getDeclaredFields(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredFields(point);
|
||||
return classType.getDeclaredFields();
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getDeclaredMethods(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredMethods(point);
|
||||
return classType.getDeclaredMethods();
|
||||
}
|
||||
|
||||
public static IBinding[] getFriends(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getFriends(point);
|
||||
return classType.getFriends();
|
||||
}
|
||||
|
||||
public static ICPPClassType[] getNestedClasses(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getNestedClasses(point);
|
||||
return classType.getNestedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all direct and indirect base classes.
|
||||
* @param classType a class
|
||||
* @return An array of visible base classes in arbitrary order.
|
||||
*/
|
||||
public static ICPPClassType[] getAllBases(ICPPClassType classType) {
|
||||
public static ICPPClassType[] getAllBases(ICPPClassType classType, IASTNode point) {
|
||||
HashSet<ICPPClassType> result= new HashSet<ICPPClassType>();
|
||||
result.add(classType);
|
||||
getAllBases(classType, result);
|
||||
getAllBases(classType, result, point);
|
||||
result.remove(classType);
|
||||
return result.toArray(new ICPPClassType[result.size()]);
|
||||
}
|
||||
|
||||
private static void getAllBases(ICPPClassType classType, HashSet<ICPPClassType> result) {
|
||||
ICPPBase[] bases= classType.getBases();
|
||||
private static void getAllBases(ICPPClassType classType, HashSet<ICPPClassType> result, IASTNode point) {
|
||||
ICPPBase[] bases= ClassTypeHelper.getBases(classType, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b= base.getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
final ICPPClassType baseClass = (ICPPClassType) b;
|
||||
if (result.add(baseClass)) {
|
||||
getAllBases(baseClass, result);
|
||||
getAllBases(baseClass, result, point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -287,25 +324,22 @@ public class ClassTypeHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct) {
|
||||
ICPPMethod[] methods= ct.getDeclaredMethods();
|
||||
ICPPClassType[] bases= getAllBases(ct);
|
||||
public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct, IASTNode point) {
|
||||
ICPPMethod[] methods= getDeclaredMethods(ct, point);
|
||||
ICPPClassType[] bases= getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
methods = ArrayUtil.addAll(ICPPMethod.class, methods, base.getDeclaredMethods());
|
||||
methods = ArrayUtil.addAll(ICPPMethod.class, methods, getDeclaredMethods(base, point));
|
||||
}
|
||||
return ArrayUtil.trim(ICPPMethod.class, methods);
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getMethods(ICPPClassType ct) {
|
||||
ObjectSet<ICPPMethod> set = getOwnMethods(ct);
|
||||
public static ICPPMethod[] getMethods(ICPPClassType ct, IASTNode point) {
|
||||
ObjectSet<ICPPMethod> set = getOwnMethods(ct, point);
|
||||
|
||||
ICPPClassType[] bases= getAllBases(ct);
|
||||
ICPPClassType[] bases= getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
set.addAll(base.getDeclaredMethods());
|
||||
final IScope compositeScope = base.getCompositeScope();
|
||||
if (compositeScope instanceof ICPPClassScope) {
|
||||
set.addAll(((ICPPClassScope) compositeScope).getImplicitMethods());
|
||||
}
|
||||
set.addAll(getDeclaredMethods(base, point));
|
||||
set.addAll(getImplicitMethods(base, point));
|
||||
}
|
||||
return set.keyArray(ICPPMethod.class);
|
||||
}
|
||||
|
@ -314,16 +348,23 @@ public class ClassTypeHelper {
|
|||
* Returns methods either declared by the given class or generated by the compiler. Does not
|
||||
* include methods declared in base classes.
|
||||
*/
|
||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType, IASTNode point) {
|
||||
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
||||
set.addAll(classType.getDeclaredMethods());
|
||||
IScope scope = classType.getCompositeScope();
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
set.addAll(((ICPPClassScope) scope).getImplicitMethods());
|
||||
}
|
||||
set.addAll(ClassTypeHelper.getDeclaredMethods(classType, point));
|
||||
set.addAll(getImplicitMethods(classType, point));
|
||||
return set;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getImplicitMethods(ICPPClassType classType, IASTNode point) {
|
||||
IScope scope = classType.getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getImplicitMethods(point);
|
||||
} else if (scope instanceof ICPPClassScope) {
|
||||
return ((ICPPClassScope) scope).getImplicitMethods();
|
||||
}
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getDeclaredMethods(ICPPInternalClassTypeMixinHost host) {
|
||||
if (host.getDefinition() == null) {
|
||||
host.checkForDefinition();
|
||||
|
@ -341,9 +382,9 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration)decl;
|
||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl;
|
||||
if (!((ICPPASTDeclSpecifier) sdecl.getDeclSpecifier()).isFriend()) {
|
||||
IASTDeclarator[] dtors = sdecl.getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
|
@ -353,7 +394,7 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof IASTFunctionDefinition) {
|
||||
final IASTFunctionDefinition fdef = (IASTFunctionDefinition)decl;
|
||||
final IASTFunctionDefinition fdef = (IASTFunctionDefinition) decl;
|
||||
if (!((ICPPASTDeclSpecifier) fdef.getDeclSpecifier()).isFriend()) {
|
||||
IASTDeclarator dtor = fdef.getDeclarator();
|
||||
dtor = ASTQueries.findInnermostDeclarator(dtor);
|
||||
|
@ -363,10 +404,10 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof ICPPASTUsingDeclaration) {
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
||||
IASTName n = ((ICPPASTUsingDeclaration) decl).getName();
|
||||
binding = n.resolveBinding();
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
IBinding[] bs = ((ICPPUsingDeclaration) binding).getDelegates();
|
||||
for (IBinding element : bs) {
|
||||
if (element instanceof ICPPMethod)
|
||||
result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) element);
|
||||
|
@ -407,15 +448,15 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
IBinding binding = null;
|
||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
||||
binding = ((ICPPASTCompositeTypeSpecifier) declSpec).getName().resolveBinding();
|
||||
} else if (declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
||||
((IASTSimpleDeclaration)decl).getDeclarators().length == 0) {
|
||||
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
||||
((IASTSimpleDeclaration) decl).getDeclarators().length == 0) {
|
||||
binding = ((ICPPASTElaboratedTypeSpecifier) declSpec).getName().resolveBinding();
|
||||
}
|
||||
if (binding instanceof ICPPClassType)
|
||||
result = ArrayUtil.append(ICPPClassType.class, result, (ICPPClassType) binding);
|
||||
|
@ -424,11 +465,11 @@ public class ClassTypeHelper {
|
|||
return ArrayUtil.trim(ICPPClassType.class, result);
|
||||
}
|
||||
|
||||
public static IField[] getFields(ICPPClassType ct) {
|
||||
IField[] fields = ct.getDeclaredFields();
|
||||
ICPPClassType[] bases = getAllBases(ct);
|
||||
public static IField[] getFields(ICPPClassType ct, IASTNode point) {
|
||||
IField[] fields = getDeclaredFields(ct, point);
|
||||
ICPPClassType[] bases = getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
fields = ArrayUtil.addAll(IField.class, fields, base.getDeclaredFields());
|
||||
fields = ArrayUtil.addAll(IField.class, fields, getDeclaredFields(base, point));
|
||||
}
|
||||
return ArrayUtil.trim(IField.class, fields);
|
||||
}
|
||||
|
@ -464,7 +505,8 @@ public class ClassTypeHelper {
|
|||
final ICPPClassType mcl= m.getClassOwner();
|
||||
if (mcl != null) {
|
||||
final ICPPFunctionType mft= m.getType();
|
||||
ICPPMethod[] allMethods= mcl.getMethods();
|
||||
IASTNode point = null; // Instantiation of dependent expressions may not work
|
||||
ICPPMethod[] allMethods= ClassTypeHelper.getMethods(mcl, point);
|
||||
for (ICPPMethod method : allMethods) {
|
||||
if (CharArrayUtils.equals(mname, method.getNameCharArray()) && functionTypesAllowOverride(mft, method.getType())) {
|
||||
if (method.isVirtual()) {
|
||||
|
@ -520,7 +562,7 @@ public class ClassTypeHelper {
|
|||
if (sourceClass == null || targetClass == null)
|
||||
return false;
|
||||
|
||||
ICPPClassType[] bases= getAllBases(sourceClass);
|
||||
ICPPClassType[] bases= getAllBases(sourceClass, null);
|
||||
for (ICPPClassType base : bases) {
|
||||
if (base.isSameType(targetClass))
|
||||
return true;
|
||||
|
@ -532,7 +574,7 @@ public class ClassTypeHelper {
|
|||
/**
|
||||
* Returns all methods that are overridden by the given {@code method}.
|
||||
*/
|
||||
public static ICPPMethod[] findOverridden(ICPPMethod method) {
|
||||
public static ICPPMethod[] findOverridden(ICPPMethod method, IASTNode point) {
|
||||
if (method instanceof ICPPConstructor)
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
|
||||
|
@ -546,7 +588,7 @@ public class ClassTypeHelper {
|
|||
final ICPPFunctionType mft= method.getType();
|
||||
|
||||
virtualInClass.put(mcl, method.isVirtual());
|
||||
ICPPBase[] bases= mcl.getBases();
|
||||
ICPPBase[] bases= getBases(mcl, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b= base.getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
|
@ -681,10 +723,10 @@ public class ClassTypeHelper {
|
|||
/**
|
||||
* For implicit methods the exception specification is inherited, search it
|
||||
*/
|
||||
public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod) {
|
||||
public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod, IASTNode point) {
|
||||
// See 15.4.13
|
||||
ICPPClassType owner= implicitMethod.getClassOwner();
|
||||
if (owner == null || owner.getBases().length == 0)
|
||||
if (owner == null || ClassTypeHelper.getBases(owner, point).length == 0)
|
||||
return null;
|
||||
|
||||
// we use a list as types aren't comparable, and can have duplicates (15.4.6)
|
||||
|
@ -693,7 +735,7 @@ public class ClassTypeHelper {
|
|||
return null;
|
||||
|
||||
List<IType> inheritedTypeids = new ArrayList<IType>();
|
||||
ICPPClassType[] bases= getAllBases(owner);
|
||||
ICPPClassType[] bases= getAllBases(owner, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
if (!(base instanceof ICPPDeferredClassInstance)) {
|
||||
ICPPMethod baseMethod= getMethodInClass(base, kind);
|
||||
|
@ -792,10 +834,10 @@ public class ClassTypeHelper {
|
|||
* no private or protected non-static data members (Clause 11),
|
||||
* no base classes (Clause 10), and no virtual functions (10.3).
|
||||
*/
|
||||
public static boolean isAggregateClass(ICPPClassType classTarget) {
|
||||
if (classTarget.getBases().length > 0)
|
||||
public static boolean isAggregateClass(ICPPClassType classTarget, IASTNode point) {
|
||||
if (ClassTypeHelper.getBases(classTarget, point).length > 0)
|
||||
return false;
|
||||
ICPPMethod[] methods = classTarget.getDeclaredMethods();
|
||||
ICPPMethod[] methods = ClassTypeHelper.getDeclaredMethods(classTarget, point);
|
||||
for (ICPPMethod m : methods) {
|
||||
if (m instanceof ICPPConstructor)
|
||||
return false;
|
||||
|
@ -803,7 +845,7 @@ public class ClassTypeHelper {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
ICPPField[] fields = classTarget.getDeclaredFields();
|
||||
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classTarget, point);
|
||||
for (ICPPField field : fields) {
|
||||
if (!(field.getVisibility() == ICPPMember.v_public || field.isStatic())) {
|
||||
return false;
|
||||
|
@ -837,7 +879,7 @@ public class ClassTypeHelper {
|
|||
if (base.isVirtual())
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -889,7 +931,7 @@ public class ClassTypeHelper {
|
|||
if (!ctor.isImplicit() && ctor.getParameters().length == 0)
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialDefaultConstructor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -925,7 +967,7 @@ public class ClassTypeHelper {
|
|||
if (method.isDestructor())
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialDestructor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -952,7 +994,7 @@ public class ClassTypeHelper {
|
|||
public static boolean isPolymorphic(ICPPClassType classTarget) {
|
||||
if (hasDeclaredVirtualMethod(classTarget))
|
||||
return true;
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (hasDeclaredVirtualMethod(baseClass))
|
||||
return true;
|
||||
}
|
||||
|
@ -976,9 +1018,9 @@ public class ClassTypeHelper {
|
|||
* but doesn't take into account base classes and methods dependent on unspecified
|
||||
* template parameters.
|
||||
*/
|
||||
public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType) {
|
||||
public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType, IASTNode point) {
|
||||
Map<String, List<ICPPMethod>> result= collectPureVirtualMethods(classType,
|
||||
new HashMap<ICPPClassType, Map<String, List<ICPPMethod>>>());
|
||||
new HashMap<ICPPClassType, Map<String, List<ICPPMethod>>>(), point);
|
||||
|
||||
int resultArraySize = 0;
|
||||
for (List<ICPPMethod> methods : result.values()) {
|
||||
|
@ -995,7 +1037,7 @@ public class ClassTypeHelper {
|
|||
}
|
||||
|
||||
private static Map<String, List<ICPPMethod>> collectPureVirtualMethods(ICPPClassType classType,
|
||||
Map<ICPPClassType, Map<String, List<ICPPMethod>>> cache) {
|
||||
Map<ICPPClassType, Map<String, List<ICPPMethod>>> cache, IASTNode point) {
|
||||
Map<String, List<ICPPMethod>> result = cache.get(classType);
|
||||
if (result != null)
|
||||
return result;
|
||||
|
@ -1005,10 +1047,10 @@ public class ClassTypeHelper {
|
|||
|
||||
// Look at the pure virtual methods of the base classes
|
||||
Set<IBinding> handledBaseClasses= new HashSet<IBinding>();
|
||||
for (ICPPBase base : classType.getBases()) {
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(classType, point)) {
|
||||
final IBinding baseClass = base.getBaseClass();
|
||||
if (baseClass instanceof ICPPClassType && handledBaseClasses.add(baseClass)) {
|
||||
Map<String, List<ICPPMethod>> pureVirtuals = collectPureVirtualMethods((ICPPClassType) baseClass, cache);
|
||||
Map<String, List<ICPPMethod>> pureVirtuals = collectPureVirtualMethods((ICPPClassType) baseClass, cache, point);
|
||||
// Merge derived pure virtual methods
|
||||
for (String key : pureVirtuals.keySet()) {
|
||||
List<ICPPMethod> list = result.get(key);
|
||||
|
@ -1021,8 +1063,8 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove overridden pure-virtual methods and add in new pure virutals.
|
||||
final ObjectSet<ICPPMethod> methods = getOwnMethods(classType);
|
||||
// Remove overridden pure-virtual methods and add in new pure virtuals.
|
||||
final ObjectSet<ICPPMethod> methods = getOwnMethods(classType, point);
|
||||
for (ICPPMethod method : methods) {
|
||||
String key= getMethodNameForOverrideKey(method);
|
||||
List<ICPPMethod> list = result.get(key);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,20 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2012 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
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
||||
|
@ -39,25 +42,37 @@ public interface ICPPClassSpecializationScope extends ICPPClassScope {
|
|||
/**
|
||||
* Computes the bases via the original class.
|
||||
*/
|
||||
ICPPBase[] getBases();
|
||||
ICPPBase[] getBases(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassScope#getConstructors()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
*/
|
||||
ICPPConstructor[] getConstructors(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassScope#getImplicitMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
*/
|
||||
ICPPMethod[] getImplicitMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Computes the methods via the original class.
|
||||
*/
|
||||
ICPPMethod[] getDeclaredMethods();
|
||||
ICPPMethod[] getDeclaredMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Computes the fields via the original class.
|
||||
*/
|
||||
ICPPField[] getDeclaredFields();
|
||||
ICPPField[] getDeclaredFields(IASTNode point);
|
||||
|
||||
/**
|
||||
* Computes the friends via the original class.
|
||||
*/
|
||||
IBinding[] getFriends();
|
||||
IBinding[] getFriends(IASTNode point);
|
||||
|
||||
/**
|
||||
* Computes the nested classes via the original class.
|
||||
*/
|
||||
ICPPClassType[] getNestedClasses();
|
||||
ICPPClassType[] getNestedClasses(IASTNode point);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
* Interface for deferred class template instances.
|
||||
*/
|
||||
public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPTemplateInstance {
|
||||
|
||||
/**
|
||||
* Returns the class template for the deferred instantiation.
|
||||
*/
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
|
||||
/**
|
||||
|
@ -59,4 +61,25 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
* signatures are guaranteed to produce the same results.
|
||||
*/
|
||||
char[] getSignature();
|
||||
|
||||
/**
|
||||
* Instantiates the evaluation with the provided template parameter map and pack offset.
|
||||
* The context is used to replace templates with their specialization, where appropriate.
|
||||
* @return a fully or partially instantiated evaluation, or the original evaluation
|
||||
*/
|
||||
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point);
|
||||
|
||||
/**
|
||||
* Determines size of the template parameter pack.
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
int determinePackSize(ICPPTemplateParameterMap tpMap);
|
||||
|
||||
/**
|
||||
* Checks if the evaluation references a template parameter either directly or though nested
|
||||
* evaluations.
|
||||
*/
|
||||
boolean referencesTemplateParameter();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -20,5 +20,4 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
* @since 5.0
|
||||
*/
|
||||
public interface ICPPUnknownClassType extends ICPPUnknownBinding, ICPPUnknownType, ICPPClassType {
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -16,5 +16,4 @@ 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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class AccessContext {
|
|||
return isAccessible(bindingVisibility, accessLevel);
|
||||
}
|
||||
|
||||
ICPPBase[] bases = derivedClass.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(derivedClass, name);
|
||||
if (bases != null) {
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseBinding = base.getBaseClass();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
@ -181,8 +182,7 @@ class BaseClassLookup {
|
|||
// base-classes
|
||||
ICPPClassType baseClass= result.getClassType();
|
||||
if (baseClass != null) {
|
||||
ICPPBase[] grandBases= null;
|
||||
grandBases= baseClass.getBases();
|
||||
ICPPBase[] grandBases= ClassTypeHelper.getBases(baseClass, data.getLookupPoint());
|
||||
if (grandBases != null && grandBases.length > 0) {
|
||||
HashSet<IBinding> grandBaseBindings= null;
|
||||
BitSet selectedBases= null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2010, 2012 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
|
||||
|
@ -10,7 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -67,6 +70,7 @@ class BuiltinOperators {
|
|||
|
||||
private final OverloadableOperator fOperator;
|
||||
private final boolean fUnary;
|
||||
private final IASTNode fPoint;
|
||||
private IType fType1;
|
||||
private IType fType2;
|
||||
private IType[][] fClassConversionTypes= { null, null };
|
||||
|
@ -80,7 +84,8 @@ class BuiltinOperators {
|
|||
Object[] globCandidates) {
|
||||
fFileScope= point.getTranslationUnit().getScope();
|
||||
fOperator= operator;
|
||||
fUnary= args.length<2;
|
||||
fPoint = point;
|
||||
fUnary= args.length < 2;
|
||||
fGlobalCandidates= globCandidates;
|
||||
if (args.length > 0) {
|
||||
IType type= args[0].getTypeOrFunctionSet(point);
|
||||
|
@ -95,7 +100,6 @@ class BuiltinOperators {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private ICPPFunction[] create() {
|
||||
switch (fOperator) {
|
||||
case ARROW:
|
||||
|
@ -231,8 +235,6 @@ class BuiltinOperators {
|
|||
return fResult.toArray(new ICPPFunction[fResult.size()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 13.6-3, 13.6-4, 13.6-5
|
||||
private void opIncOrDec() {
|
||||
IType[] types= getClassConversionTypes(FIRST);
|
||||
|
@ -355,7 +357,7 @@ class BuiltinOperators {
|
|||
IType t2= SemanticUtil.getNestedType(memPtr.getMemberOfClass(), TDEF);
|
||||
if (t2 instanceof ICPPClassType) {
|
||||
ICPPClassType c2= (ICPPClassType) t2;
|
||||
if (SemanticUtil.calculateInheritanceDepth(c1, c2) >= 0) {
|
||||
if (SemanticUtil.calculateInheritanceDepth(c1, c2, fPoint) >= 0) {
|
||||
IType cvt= SemanticUtil.getNestedType(memPtr.getType(), TDEF);
|
||||
IType rt= new CPPReferenceType(
|
||||
SemanticUtil.addQualifiers(cvt, cv1.isConst(), cv1.isVolatile(), cv1.isRestrict()), false);
|
||||
|
@ -424,7 +426,6 @@ class BuiltinOperators {
|
|||
return p1;
|
||||
}
|
||||
|
||||
|
||||
// 13.6-13, 13.6.14
|
||||
private void pointerArithmetic(boolean useRef, boolean isDiff) {
|
||||
IType[] types= getClassConversionTypes(FIRST);
|
||||
|
@ -665,7 +666,7 @@ class BuiltinOperators {
|
|||
if (type instanceof ICPPClassType) {
|
||||
fIsClass[idx]= true;
|
||||
try {
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) type);
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators((ICPPClassType) type, fPoint);
|
||||
result= new IType[ops.length];
|
||||
int j= -1;
|
||||
for (ICPPMethod op : ops) {
|
||||
|
|
|
@ -12,14 +12,27 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
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.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||
|
@ -27,11 +40,8 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
private static class SignatureBuilder implements ITypeMarshalBuffer {
|
||||
private static final byte NULL_TYPE= 0;
|
||||
private static final byte UNSTORABLE_TYPE= (byte) -1;
|
||||
private static final char[] HEX_DIGITS =
|
||||
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
private final StringBuilder fBuffer;
|
||||
private boolean hexMode;
|
||||
|
||||
/**
|
||||
* Constructor for input buffer.
|
||||
|
@ -45,6 +55,10 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
return fBuffer.toString();
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
return CharArrayUtils.extractChars(fBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalBinding(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ISerializableType) {
|
||||
|
@ -53,12 +67,17 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
appendSeparator();
|
||||
IBinding owner= binding.getOwner();
|
||||
if (owner instanceof IType) {
|
||||
ASTTypeUtil.appendType((IType) owner, true, fBuffer);
|
||||
fBuffer.append("::"); //$NON-NLS-1$
|
||||
if (binding instanceof ICPPBinding) {
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
|
||||
fBuffer.append(param.isParameterPack() ? '*' : '#');
|
||||
fBuffer.append(param.getParameterID());
|
||||
} else {
|
||||
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
|
||||
}
|
||||
} else {
|
||||
fBuffer.append(binding.getNameCharArray());
|
||||
}
|
||||
fBuffer.append(binding.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,49 +114,37 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void putByte(byte b) {
|
||||
appendHexDigit(b >> 4);
|
||||
appendHexDigit(b);
|
||||
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
|
||||
if (arg instanceof CPPTemplateNonTypeArgument) {
|
||||
putByte(VALUE);
|
||||
((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true);
|
||||
} else {
|
||||
marshalType(arg.getTypeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putByte(byte value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putShort(short value) {
|
||||
appendHexDigit(value >> 12);
|
||||
appendHexDigit(value >> 8);
|
||||
appendHexDigit(value >> 4);
|
||||
appendHexDigit(value);
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInt(int value) {
|
||||
appendHexDigit(value >> 28);
|
||||
appendHexDigit(value >> 24);
|
||||
appendHexDigit(value >> 20);
|
||||
appendHexDigit(value >> 16);
|
||||
appendHexDigit(value >> 12);
|
||||
appendHexDigit(value >> 8);
|
||||
appendHexDigit(value >> 4);
|
||||
appendHexDigit(value);
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLong(long value) {
|
||||
appendHexDigit((int) (value >> 60));
|
||||
appendHexDigit((int) (value >> 56));
|
||||
appendHexDigit((int) (value >> 52));
|
||||
appendHexDigit((int) (value >> 48));
|
||||
appendHexDigit((int) (value >> 44));
|
||||
appendHexDigit((int) (value >> 40));
|
||||
appendHexDigit((int) (value >> 36));
|
||||
appendHexDigit((int) (value >> 32));
|
||||
appendHexDigit((int) (value >> 28));
|
||||
appendHexDigit((int) (value >> 24));
|
||||
appendHexDigit((int) (value >> 20));
|
||||
appendHexDigit((int) (value >> 16));
|
||||
appendHexDigit((int) (value >> 12));
|
||||
appendHexDigit((int) (value >> 8));
|
||||
appendHexDigit((int) (value >> 4));
|
||||
appendHexDigit((int) value);
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,19 +155,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
}
|
||||
|
||||
private void appendHexDigit(int val) {
|
||||
if (hexMode) {
|
||||
appendSeparator();
|
||||
fBuffer.append("0x"); //$NON-NLS-1$
|
||||
hexMode = true;
|
||||
}
|
||||
fBuffer.append(HEX_DIGITS[val & 0xF]);
|
||||
}
|
||||
|
||||
private void appendSeparator() {
|
||||
if (fBuffer.length() != 0)
|
||||
fBuffer.append(' ');
|
||||
hexMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,6 +180,11 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getByte() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -214,6 +216,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
}
|
||||
|
||||
CPPEvaluation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getSignature() {
|
||||
SignatureBuilder buf = new SignatureBuilder();
|
||||
|
@ -223,6 +228,33 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
CCorePlugin.log(e);
|
||||
return new char[] { '?' };
|
||||
}
|
||||
return buf.toString().toCharArray();
|
||||
return buf.getSignature();
|
||||
}
|
||||
|
||||
protected static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
try {
|
||||
return CPPTemplates.resolveUnknown(unknown, tpMap, packOffset, within, point);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return unknown;
|
||||
}
|
||||
|
||||
protected static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
try {
|
||||
return CPPTemplates.instantiateArguments(args, tpMap, packOffset, within, point);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
protected static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) {
|
||||
SizeofCalculator calc = point == null ?
|
||||
SizeofCalculator.getDefault() :
|
||||
((ASTTranslationUnit) point.getTranslationUnit()).getSizeofCalculator();
|
||||
return calc.sizeAndAlignment(type);
|
||||
}
|
||||
}
|
|
@ -203,6 +203,7 @@ 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.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -244,7 +245,7 @@ public class CPPSemantics {
|
|||
public static int traceIndent= 0;
|
||||
|
||||
// special return value for costForFunctionCall
|
||||
private static final FunctionCost CONTAINS_DEPENDENT_TYPES = new FunctionCost(null, 0);
|
||||
private static final FunctionCost CONTAINS_DEPENDENT_TYPES = new FunctionCost(null, 0, null);
|
||||
|
||||
static protected IBinding resolveBinding(IASTName name) {
|
||||
if (traceBindingResolution) {
|
||||
|
@ -257,11 +258,11 @@ public class CPPSemantics {
|
|||
((CPPASTNameBase) name).incResolutionDepth();
|
||||
}
|
||||
|
||||
// 1: get some context info off of the name to figure out what kind of lookup we want
|
||||
// 1: Get some context info off of the name to figure out what kind of lookup we want
|
||||
LookupData data = createLookupData(name);
|
||||
|
||||
try {
|
||||
// 2: lookup
|
||||
// 2: Lookup
|
||||
lookup(data, null);
|
||||
|
||||
// Perform argument dependent lookup
|
||||
|
@ -274,14 +275,14 @@ public class CPPSemantics {
|
|||
if (data.problem != null)
|
||||
return data.problem;
|
||||
|
||||
// 3: resolve ambiguities
|
||||
// 3: Resolve ambiguities
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = resolveAmbiguities(data);
|
||||
} catch (DOMException e) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
// 4: post processing
|
||||
// 4: Post processing
|
||||
binding = postResolution(binding, data);
|
||||
if (traceBindingResolution) {
|
||||
traceIndent--;
|
||||
|
@ -306,6 +307,8 @@ public class CPPSemantics {
|
|||
if (lookupName == null)
|
||||
return binding;
|
||||
|
||||
IASTNode lookupPoint = data.getLookupPoint();
|
||||
|
||||
if (binding == null && data.checkClassContainingFriend()) {
|
||||
// 3.4.1-10 if we don't find a name used in a friend declaration in the member declaration's class
|
||||
// we should look in the class granting friendship
|
||||
|
@ -403,7 +406,7 @@ public class CPPSemantics {
|
|||
if (data.getTranslationUnit() != null) {
|
||||
ICPPASTTemplateId id = (ICPPASTTemplateId) lookupName;
|
||||
ICPPTemplateArgument[] args = CPPTemplates.createTemplateArgumentArray(id);
|
||||
IBinding inst= CPPTemplates.instantiate((ICPPClassTemplate) cls, args, data.getLookupPoint());
|
||||
IBinding inst= CPPTemplates.instantiate((ICPPClassTemplate) cls, args, lookupPoint);
|
||||
if (inst instanceof ICPPClassType) {
|
||||
cls= (ICPPClassType) inst;
|
||||
}
|
||||
|
@ -412,7 +415,7 @@ public class CPPSemantics {
|
|||
if (cls instanceof ICPPUnknownBinding) {
|
||||
binding= new CPPUnknownConstructor(cls);
|
||||
} else {
|
||||
binding= CPPSemantics.resolveFunction(data, cls.getConstructors(), true);
|
||||
binding= CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors(cls, lookupPoint), true);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
|
@ -712,7 +715,7 @@ public class CPPSemantics {
|
|||
}
|
||||
if (t instanceof ICPPClassType && !(t instanceof ICPPClassTemplate)) {
|
||||
ICPPClassType ct= (ICPPClassType) t;
|
||||
ICPPBase[] bases = ct.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(ct, tu);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b = base.getBaseClass();
|
||||
if (b instanceof IType)
|
||||
|
@ -723,7 +726,7 @@ public class CPPSemantics {
|
|||
// (excluding template template parameters);
|
||||
// * ... owners of which any template template arguments are members;
|
||||
if (ct instanceof ICPPTemplateInstance) {
|
||||
for (IBinding friend : ct.getFriends()) {
|
||||
for (IBinding friend : ClassTypeHelper.getFriends(ct, tu)) {
|
||||
if (friend instanceof ICPPFunction) {
|
||||
friendFns.add((ICPPFunction) friend);
|
||||
}
|
||||
|
@ -2413,7 +2416,7 @@ public class CPPSemantics {
|
|||
potentialCosts.add(fnCost);
|
||||
continue;
|
||||
}
|
||||
int cmp= fnCost.compareTo(tu, bestFnCost, lookupPoint);
|
||||
int cmp= fnCost.compareTo(tu, bestFnCost);
|
||||
if (cmp < 0) {
|
||||
bestFnCost= fnCost;
|
||||
ambiguousFunctions= null;
|
||||
|
@ -2425,7 +2428,7 @@ public class CPPSemantics {
|
|||
if (potentialCosts != null) {
|
||||
for (FunctionCost fnCost : potentialCosts) {
|
||||
if (!fnCost.mustBeWorse(bestFnCost) && fnCost.performUDC(lookupPoint)) {
|
||||
int cmp= fnCost.compareTo(tu, bestFnCost, lookupPoint);
|
||||
int cmp= fnCost.compareTo(tu, bestFnCost);
|
||||
if (cmp < 0) {
|
||||
bestFnCost= fnCost;
|
||||
ambiguousFunctions= null;
|
||||
|
@ -2630,9 +2633,9 @@ public class CPPSemantics {
|
|||
final int sourceLen= argTypes.length - skipArg;
|
||||
final FunctionCost result;
|
||||
if (implicitParameterType == null) {
|
||||
result= new FunctionCost(fn, sourceLen);
|
||||
result= new FunctionCost(fn, sourceLen, data.getLookupPoint());
|
||||
} else {
|
||||
result= new FunctionCost(fn, sourceLen + 1);
|
||||
result= new FunctionCost(fn, sourceLen + 1, data.getLookupPoint());
|
||||
|
||||
ValueCategory sourceIsLValue= LVALUE;
|
||||
if (impliedObjectType == null) {
|
||||
|
@ -2656,7 +2659,7 @@ public class CPPSemantics {
|
|||
if (CPPTemplates.isDependentType(implicitParameterType) || CPPTemplates.isDependentType(impliedObjectType)) {
|
||||
IType s= getNestedType(impliedObjectType, TDEF|REF|CVTYPE);
|
||||
IType t= getNestedType(implicitParameterType, TDEF|REF|CVTYPE);
|
||||
if (SemanticUtil.calculateInheritanceDepth(s, t) >= 0)
|
||||
if (SemanticUtil.calculateInheritanceDepth(s, t, data.getLookupPoint()) >= 0)
|
||||
return null;
|
||||
|
||||
return CONTAINS_DEPENDENT_TYPES;
|
||||
|
@ -2671,7 +2674,7 @@ public class CPPSemantics {
|
|||
|
||||
final UDCMode udc = allowUDC ? UDCMode.DEFER : UDCMode.FORBIDDEN;
|
||||
for (int j = 0; j < sourceLen; j++) {
|
||||
final IType argType= SemanticUtil.getNestedType(argTypes[j+skipArg], TDEF | REF);
|
||||
final IType argType= SemanticUtil.getNestedType(argTypes[j + skipArg], TDEF | REF);
|
||||
if (argType == null)
|
||||
return null;
|
||||
|
||||
|
@ -2815,7 +2818,7 @@ public class CPPSemantics {
|
|||
LookupData data= new LookupData(name);
|
||||
data.setFunctionArguments(false, init.getArguments());
|
||||
try {
|
||||
IBinding ctor = CPPSemantics.resolveFunction(data, ((ICPPClassType) targetType).getConstructors(), true);
|
||||
IBinding ctor = CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors((ICPPClassType) targetType, name), true);
|
||||
if (ctor instanceof ICPPConstructor) {
|
||||
int i= 0;
|
||||
for (IASTNode arg : init.getArguments()) {
|
||||
|
@ -3086,7 +3089,7 @@ public class CPPSemantics {
|
|||
ValueCategory isLValue= evaluation.getValueCategory(name);
|
||||
if (sourceType != null) {
|
||||
Cost c;
|
||||
if (calculateInheritanceDepth(sourceType, classType) >= 0) {
|
||||
if (calculateInheritanceDepth(sourceType, classType, name) >= 0) {
|
||||
c = Conversions.copyInitializationOfClass(isLValue, sourceType, classType, false, name);
|
||||
} else {
|
||||
c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, name);
|
||||
|
@ -3122,13 +3125,13 @@ public class CPPSemantics {
|
|||
LookupData data = new LookupData(astName);
|
||||
data.setFunctionArguments(false, arguments);
|
||||
data.qualified = true;
|
||||
data.foundItems = classType.getConstructors();
|
||||
data.foundItems = ClassTypeHelper.getConstructors(classType, name);
|
||||
binding = resolveAmbiguities(data);
|
||||
if (binding instanceof ICPPConstructor)
|
||||
return (ICPPConstructor) binding;
|
||||
} else if (initializer == null) {
|
||||
// Default initialization
|
||||
ICPPConstructor[] ctors = classType.getConstructors();
|
||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name);
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
if (ctor.getRequiredArgumentCount() == 0)
|
||||
return ctor;
|
||||
|
@ -3342,7 +3345,7 @@ public class CPPSemantics {
|
|||
if (callToObjectOfClassType != null) {
|
||||
try {
|
||||
// 13.3.1.1.2 call to object of class type
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType);
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType, point);
|
||||
for (ICPPMethod op : ops) {
|
||||
if (op.isExplicit())
|
||||
continue;
|
||||
|
@ -3652,9 +3655,10 @@ public class CPPSemantics {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected static IBinding resolveUnknownName(IScope scope, ICPPUnknownBinding unknown) {
|
||||
protected static IBinding resolveUnknownName(IScope scope, ICPPUnknownBinding unknown, IASTNode point) {
|
||||
final IASTName unknownName = unknown.getUnknownName();
|
||||
LookupData data = new LookupData(unknownName);
|
||||
LookupData data = unknownName.getTranslationUnit() != null ?
|
||||
new LookupData(unknownName) : new LookupData(unknownName.getSimpleID(), null, point);
|
||||
data.setIgnorePointOfDeclaration(true);
|
||||
data.typesOnly= unknown instanceof IType;
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
|
@ -124,11 +123,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethodTemplateSpecializat
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
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.CPPUnknownBinding;
|
||||
|
@ -138,6 +138,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclarationSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate;
|
||||
|
@ -153,9 +154,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMod
|
|||
* type instantiation.
|
||||
*/
|
||||
public class CPPTemplates {
|
||||
private static final int PACK_SIZE_DEFER = -1;
|
||||
private static final int PACK_SIZE_FAIL = -2;
|
||||
private static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
|
||||
static final int PACK_SIZE_DEFER = -1;
|
||||
static final int PACK_SIZE_FAIL = -2;
|
||||
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
|
||||
private static final ICPPFunction[] NO_FUNCTIONS = {};
|
||||
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
||||
|
||||
|
@ -225,7 +226,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
if (isPack) {
|
||||
int packOffset= numParams - 1;
|
||||
int packOffset= numParams-1;
|
||||
int packSize= numArgs - packOffset;
|
||||
ICPPTemplateArgument[] pack= new ICPPTemplateArgument[packSize];
|
||||
System.arraycopy(arguments, packOffset, pack, 0, packSize);
|
||||
|
@ -402,7 +403,7 @@ public class CPPTemplates {
|
|||
for (int i = 0; i < arguments.length; i++) {
|
||||
ICPPTemplateArgument arg = arguments[i];
|
||||
if (arg.isPackExpansion()) {
|
||||
if (i != arguments.length - 1) {
|
||||
if (i != arguments.length-1) {
|
||||
return arguments;
|
||||
}
|
||||
havePackExpansion= true;
|
||||
|
@ -421,10 +422,10 @@ public class CPPTemplates {
|
|||
|
||||
// More arguments allowed if we have a parameter pack.
|
||||
if (tparCount < argCount) {
|
||||
if (tpars[tparCount - 1].isParameterPack())
|
||||
if (tpars[tparCount-1].isParameterPack())
|
||||
return arguments;
|
||||
|
||||
if (havePackExpansion && tparCount + 1 == argCount)
|
||||
if (havePackExpansion && tparCount+1 == argCount)
|
||||
return arguments;
|
||||
return null;
|
||||
}
|
||||
|
@ -434,7 +435,7 @@ public class CPPTemplates {
|
|||
return arguments;
|
||||
|
||||
// Fewer arguments are allowed with default arguments
|
||||
if (tpars[tparCount - 1].isParameterPack())
|
||||
if (tpars[tparCount-1].isParameterPack())
|
||||
tparCount--;
|
||||
|
||||
if (tparCount == argCount)
|
||||
|
@ -492,11 +493,11 @@ public class CPPTemplates {
|
|||
if (tp.isParameterPack()) {
|
||||
t= new CPPParameterPackType(t);
|
||||
}
|
||||
args[i] = new CPPTemplateArgument(t);
|
||||
args[i] = new CPPTemplateTypeArgument(t);
|
||||
} else if (tp instanceof ICPPTemplateNonTypeParameter) {
|
||||
// Non-type template parameter pack already has type 'ICPPParameterPackType'
|
||||
final ICPPTemplateNonTypeParameter nttp = (ICPPTemplateNonTypeParameter) tp;
|
||||
args[i] = new CPPTemplateArgument(Value.create(nttp), nttp.getType());
|
||||
args[i] = new CPPTemplateNonTypeArgument(Value.create(nttp), nttp.getType());
|
||||
} else {
|
||||
assert false;
|
||||
}
|
||||
|
@ -795,12 +796,13 @@ public class CPPTemplates {
|
|||
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
|
||||
|
||||
if (decl instanceof ICPPFunctionTemplate) {
|
||||
if (decl instanceof ICPPConstructor)
|
||||
if (decl instanceof ICPPConstructor) {
|
||||
spec = new CPPConstructorTemplateSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
|
||||
else if (decl instanceof ICPPMethod)
|
||||
} else if (decl instanceof ICPPMethod) {
|
||||
spec = new CPPMethodTemplateSpecialization((ICPPMethod) decl, owner, tpMap, type, exceptionSpecs);
|
||||
else
|
||||
} else {
|
||||
spec = new CPPFunctionTemplateSpecialization((ICPPFunctionTemplate) decl, owner, tpMap, type, exceptionSpecs);
|
||||
}
|
||||
} else if (decl instanceof ICPPConstructor) {
|
||||
spec = new CPPConstructorSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
|
||||
} else if (decl instanceof ICPPMethod) {
|
||||
|
@ -862,43 +864,20 @@ public class CPPTemplates {
|
|||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
if (value == null)
|
||||
return null;
|
||||
IBinding[] unknowns= value.getUnknownBindings();
|
||||
IBinding[] resolvedUnknowns= null;
|
||||
if (unknowns.length != 0) {
|
||||
for (int i = 0; i < unknowns.length; i++) {
|
||||
IBinding unknown= unknowns[i];
|
||||
IBinding resolved= unknown;
|
||||
if (unknown instanceof ICPPUnknownBinding) {
|
||||
try {
|
||||
resolved= resolveUnknown((ICPPUnknownBinding) unknown, tpMap, packOffset, within, point);
|
||||
} catch (DOMException e) {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
}
|
||||
if (resolvedUnknowns != null) {
|
||||
resolvedUnknowns[i]= resolved;
|
||||
} else if (resolved != unknown) {
|
||||
resolvedUnknowns= new IBinding[unknowns.length];
|
||||
System.arraycopy(unknowns, 0, resolvedUnknowns, 0, i);
|
||||
resolvedUnknowns[i]= resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resolvedUnknowns != null)
|
||||
return Value.reevaluate(value, packOffset, resolvedUnknowns, tpMap, maxdepth);
|
||||
|
||||
if (Value.referencesTemplateParameter(value))
|
||||
return Value.reevaluate(value, packOffset, unknowns, tpMap, maxdepth);
|
||||
|
||||
return value;
|
||||
ICPPEvaluation evaluation = value.getEvaluation();
|
||||
if (evaluation == null)
|
||||
return value;
|
||||
ICPPEvaluation instantiated = evaluation.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (instantiated == evaluation)
|
||||
return value;
|
||||
return instantiated.getValue(point);
|
||||
}
|
||||
|
||||
public static boolean containsParameterPack(IType type) {
|
||||
return determinePackSize(type, CPPTemplateParameterMap.EMPTY) == PACK_SIZE_DEFER;
|
||||
}
|
||||
|
||||
private static int determinePackSize(IType type, ICPPTemplateParameterMap tpMap) {
|
||||
static int determinePackSize(IType type, ICPPTemplateParameterMap tpMap) {
|
||||
if (type instanceof ICPPFunctionType) {
|
||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||
final IType rt = ft.getReturnType();
|
||||
|
@ -907,7 +886,7 @@ public class CPPTemplates {
|
|||
return r;
|
||||
IType[] ps = ft.getParameterTypes();
|
||||
for (IType pt : ps) {
|
||||
r= combine(r, determinePackSize(pt, tpMap));
|
||||
r= combinePackSize(r, determinePackSize(pt, tpMap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -915,37 +894,17 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
if (type instanceof ICPPTemplateParameter) {
|
||||
final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type;
|
||||
if (tpar.isParameterPack()) {
|
||||
ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar);
|
||||
if (args != null)
|
||||
return args.length;
|
||||
return PACK_SIZE_DEFER;
|
||||
}
|
||||
return PACK_SIZE_NOT_FOUND;
|
||||
return determinePackSize((ICPPTemplateParameter) type, tpMap);
|
||||
}
|
||||
|
||||
int r= PACK_SIZE_NOT_FOUND;
|
||||
if (type instanceof ICPPUnknownBinding) {
|
||||
if (type instanceof ICPPDeferredClassInstance) {
|
||||
ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) type;
|
||||
ICPPTemplateArgument[] args = dcl.getTemplateArguments();
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
r= combine(r, determinePackSize(arg, tpMap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
IBinding binding= ((ICPPUnknownBinding) type).getOwner();
|
||||
if (binding instanceof IType)
|
||||
r= combine(r, determinePackSize((IType) binding, tpMap));
|
||||
|
||||
return r;
|
||||
return determinePackSize((ICPPUnknownBinding) type, tpMap);
|
||||
}
|
||||
|
||||
if (type instanceof ICPPParameterPackType)
|
||||
return PACK_SIZE_NOT_FOUND;
|
||||
|
||||
int r= PACK_SIZE_NOT_FOUND;
|
||||
if (type instanceof IArrayType) {
|
||||
IArrayType at= (IArrayType) type;
|
||||
IValue asize= at.getSize();
|
||||
|
@ -956,12 +915,54 @@ public class CPPTemplates {
|
|||
|
||||
if (type instanceof ITypeContainer) {
|
||||
final ITypeContainer typeContainer = (ITypeContainer) type;
|
||||
r= combine(r, determinePackSize(typeContainer.getType(), tpMap));
|
||||
r= combinePackSize(r, determinePackSize(typeContainer.getType(), tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static int combine(int ps1, int ps2) {
|
||||
static int determinePackSize(ICPPTemplateParameter tpar, ICPPTemplateParameterMap tpMap) {
|
||||
if (tpar.isParameterPack()) {
|
||||
ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar);
|
||||
if (args != null)
|
||||
return args.length;
|
||||
return PACK_SIZE_DEFER;
|
||||
}
|
||||
return PACK_SIZE_NOT_FOUND;
|
||||
}
|
||||
|
||||
static int determinePackSize(ICPPUnknownBinding binding, ICPPTemplateParameterMap tpMap) {
|
||||
int r= PACK_SIZE_NOT_FOUND;
|
||||
if (binding instanceof ICPPDeferredClassInstance) {
|
||||
ICPPDeferredClassInstance dcl= (ICPPDeferredClassInstance) binding;
|
||||
ICPPTemplateArgument[] args = dcl.getTemplateArguments();
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
r= combinePackSize(r, determinePackSize(arg, tpMap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
IBinding ownerBinding= binding.getOwner();
|
||||
if (ownerBinding instanceof IType)
|
||||
r= combinePackSize(r, determinePackSize((IType) ownerBinding, tpMap));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int determinePackSize(IValue value, ICPPTemplateParameterMap tpMap) {
|
||||
ICPPEvaluation eval = value.getEvaluation();
|
||||
if (eval == null)
|
||||
return PACK_SIZE_NOT_FOUND;
|
||||
|
||||
return ((CPPEvaluation) eval).determinePackSize(tpMap);
|
||||
}
|
||||
|
||||
static int determinePackSize(ICPPTemplateArgument arg, ICPPTemplateParameterMap tpMap) {
|
||||
if (arg.isTypeValue())
|
||||
return determinePackSize(arg.getTypeValue(), tpMap);
|
||||
return determinePackSize(arg.getNonTypeValue(), tpMap);
|
||||
}
|
||||
|
||||
static int combinePackSize(int ps1, int ps2) {
|
||||
if (ps1 < 0 || ps2 == PACK_SIZE_NOT_FOUND)
|
||||
return ps1;
|
||||
if (ps2 < 0 || ps1 == PACK_SIZE_NOT_FOUND)
|
||||
|
@ -971,35 +972,6 @@ public class CPPTemplates {
|
|||
return ps1;
|
||||
}
|
||||
|
||||
private static int determinePackSize(IValue value, ICPPTemplateParameterMap tpMap) {
|
||||
int r= PACK_SIZE_NOT_FOUND;
|
||||
IBinding[] unknown= value.getUnknownBindings();
|
||||
for (IBinding binding : unknown) {
|
||||
if (binding instanceof IType) {
|
||||
r= combine(r, determinePackSize((IType) binding, tpMap));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
int[] tpars= Value.getParameterPackReferences(value);
|
||||
for (int parID : tpars) {
|
||||
ICPPTemplateArgument[] args= tpMap.getPackExpansion(parID);
|
||||
if (args != null) {
|
||||
r= combine(r, args.length);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
return PACK_SIZE_DEFER;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static int determinePackSize(ICPPTemplateArgument arg, ICPPTemplateParameterMap tpMap) {
|
||||
if (arg.isTypeValue())
|
||||
return determinePackSize(arg.getTypeValue(), tpMap);
|
||||
return determinePackSize(arg.getNonTypeValue(), tpMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates types contained in an array.
|
||||
* @param types an array of types
|
||||
|
@ -1025,7 +997,7 @@ public class CPPTemplates {
|
|||
} else if (packSize == PACK_SIZE_DEFER) {
|
||||
newType= origType;
|
||||
} else {
|
||||
IType[] newResult= new IType[result.length + packSize - 1];
|
||||
IType[] newResult= new IType[result.length+packSize-1];
|
||||
System.arraycopy(result, 0, newResult, 0, j);
|
||||
result= newResult;
|
||||
for (int k= 0; k < packSize; k++) {
|
||||
|
@ -1113,14 +1085,14 @@ public class CPPTemplates {
|
|||
final IType instType= instantiateType(origType, tpMap, packOffset, within, point);
|
||||
if (origType == instType && origValue == instValue)
|
||||
return arg;
|
||||
return new CPPTemplateArgument(instValue, instType);
|
||||
return new CPPTemplateNonTypeArgument(instValue, instType);
|
||||
}
|
||||
|
||||
final IType orig= arg.getTypeValue();
|
||||
final IType inst= instantiateType(orig, tpMap, packOffset, within, point);
|
||||
if (orig == inst)
|
||||
return arg;
|
||||
return new CPPTemplateArgument(inst);
|
||||
return new CPPTemplateTypeArgument(inst);
|
||||
}
|
||||
|
||||
private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig, ICPPTemplateParameterMap tpMap,
|
||||
|
@ -1287,6 +1259,13 @@ public class CPPTemplates {
|
|||
return typeContainer;
|
||||
}
|
||||
|
||||
if (type instanceof TypeOfDependentExpression) {
|
||||
ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
|
||||
ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
|
||||
if (instantiated != eval)
|
||||
return instantiated.getTypeOrFunctionSet(point);
|
||||
}
|
||||
|
||||
return type;
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
|
@ -1294,11 +1273,11 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given name corresponds to a template declaration and returns the ast node for it.
|
||||
* This works for the name of a template-definition and also for a name needed to qualify a member
|
||||
* definition:
|
||||
* Checks whether a given name corresponds to a template declaration and returns the AST node
|
||||
* for it. This works for the name of a template-definition and also for a name needed to
|
||||
* qualify a member definition:
|
||||
* <pre>
|
||||
* template <typename T> void MyTemplate<T>::member() {}
|
||||
* template <typename T> void MyTemplate<T>::member() {}
|
||||
* </pre>
|
||||
* @param name a name for which the corresponding template declaration is searched for.
|
||||
* @return the template declaration or <code>null</code> if <code>name</code> does not
|
||||
|
@ -1396,7 +1375,7 @@ public class CPPTemplates {
|
|||
int depIDCount= 0;
|
||||
IASTName owner= null;
|
||||
final IASTName[] ns= qname.getNames();
|
||||
for (int i = 0; i < ns.length - 1; i++) {
|
||||
for (int i = 0; i < ns.length-1; i++) {
|
||||
IASTName n= ns[i];
|
||||
if (n instanceof ICPPASTTemplateId) {
|
||||
if (depIDCount > 0 || usesTemplateParameter((ICPPASTTemplateId) n, tparnames)) {
|
||||
|
@ -1439,17 +1418,17 @@ public class CPPTemplates {
|
|||
b= b.getOwner();
|
||||
}
|
||||
if (depIDCount > 0) {
|
||||
nestingLevel += depIDCount;
|
||||
nestingLevel+= depIDCount;
|
||||
} else if (consumesTDecl < tdeclCount && !lastIsTemplate) {
|
||||
nestingLevel++;
|
||||
lastIsTemplate= true;
|
||||
}
|
||||
} else {
|
||||
nestingLevel += depIDCount;
|
||||
nestingLevel+= depIDCount;
|
||||
node= outerMostTDecl.getParent();
|
||||
while (node != null) {
|
||||
if (node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||
nestingLevel += ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1;
|
||||
nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1;
|
||||
break;
|
||||
}
|
||||
node= node.getParent();
|
||||
|
@ -1462,7 +1441,7 @@ public class CPPTemplates {
|
|||
node= outerMostTDecl.getParent();
|
||||
while (node != null) {
|
||||
if (node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||
nestingLevel += ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1;
|
||||
nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1;
|
||||
break;
|
||||
}
|
||||
node= node.getParent();
|
||||
|
@ -1471,7 +1450,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
node= innerMostTDecl;
|
||||
while (node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||
while(node instanceof ICPPASTInternalTemplateDeclaration) {
|
||||
if (--nestingLevel < 0)
|
||||
nestingLevel= 0;
|
||||
tdecl= (ICPPASTInternalTemplateDeclaration) node;
|
||||
|
@ -1501,7 +1480,7 @@ public class CPPTemplates {
|
|||
|
||||
private static CharArraySet collectTemplateParameterNames(ICPPASTTemplateDeclaration tdecl) {
|
||||
CharArraySet set= new CharArraySet(4);
|
||||
while (true) {
|
||||
while(true) {
|
||||
ICPPASTTemplateParameter[] pars = tdecl.getTemplateParameters();
|
||||
for (ICPPASTTemplateParameter par : pars) {
|
||||
IASTName name= CPPTemplates.getTemplateParameterName(par);
|
||||
|
@ -1521,7 +1500,7 @@ public class CPPTemplates {
|
|||
private static boolean usesTemplateParameter(final ICPPASTTemplateId id, final CharArraySet names) {
|
||||
final boolean[] result= {false};
|
||||
ASTVisitor v= new ASTVisitor(false) {
|
||||
{ shouldVisitNames= true; shouldVisitAmbiguousNodes= true; }
|
||||
{ shouldVisitNames= true; shouldVisitAmbiguousNodes=true;}
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (name instanceof ICPPASTTemplateId)
|
||||
|
@ -1613,7 +1592,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
private static ICPPASTInternalTemplateDeclaration getDirectlyEnclosingTemplateDeclaration(
|
||||
ICPPASTInternalTemplateDeclaration tdecl) {
|
||||
ICPPASTInternalTemplateDeclaration tdecl ) {
|
||||
final IASTNode parent= tdecl.getParent();
|
||||
if (parent instanceof ICPPASTInternalTemplateDeclaration)
|
||||
return (ICPPASTInternalTemplateDeclaration) parent;
|
||||
|
@ -1643,10 +1622,11 @@ public class CPPTemplates {
|
|||
name = dtor.getName();
|
||||
} else if (simple.getDeclarators().length == 0) {
|
||||
IASTDeclSpecifier spec = simple.getDeclSpecifier();
|
||||
if (spec instanceof ICPPASTCompositeTypeSpecifier)
|
||||
if (spec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
name = ((ICPPASTCompositeTypeSpecifier) spec).getName();
|
||||
else if (spec instanceof ICPPASTElaboratedTypeSpecifier)
|
||||
} else if (spec instanceof ICPPASTElaboratedTypeSpecifier) {
|
||||
name = ((ICPPASTElaboratedTypeSpecifier) spec).getName();
|
||||
}
|
||||
}
|
||||
} else if (nestedDecl instanceof IASTFunctionDefinition) {
|
||||
IASTDeclarator declarator = ((IASTFunctionDefinition) nestedDecl).getDeclarator();
|
||||
|
@ -1662,11 +1642,10 @@ public class CPPTemplates {
|
|||
if (currDecl == templateDecl) {
|
||||
return ns[j];
|
||||
}
|
||||
if (currDecl instanceof ICPPASTTemplateDeclaration) {
|
||||
currDecl = ((ICPPASTTemplateDeclaration) currDecl).getDeclaration();
|
||||
} else {
|
||||
if (!(currDecl instanceof ICPPASTTemplateDeclaration)) {
|
||||
return null;
|
||||
}
|
||||
currDecl = ((ICPPASTTemplateDeclaration) currDecl).getDeclaration();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1701,16 +1680,12 @@ public class CPPTemplates {
|
|||
for (int i = 0; i < args.length; i++) {
|
||||
IASTNode arg= args[i];
|
||||
if (arg instanceof IASTTypeId) {
|
||||
result[i]= new CPPTemplateArgument(CPPVisitor.createType((IASTTypeId) arg));
|
||||
result[i]= new CPPTemplateTypeArgument(CPPVisitor.createType((IASTTypeId) arg));
|
||||
} else if (arg instanceof IASTExpression) {
|
||||
IASTExpression expr= (IASTExpression) arg;
|
||||
IType type= expr.getExpressionType();
|
||||
IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
|
||||
result[i]= new CPPTemplateArgument(value, type);
|
||||
} else if (arg instanceof ICPPASTAmbiguousTemplateArgument) {
|
||||
throw new IllegalArgumentException(id.getRawSignature()
|
||||
+ " contains an ambiguous template argument at position " + i + " in " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ id.getContainingFilename());
|
||||
result[i]= new CPPTemplateNonTypeArgument(value, type);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -1922,7 +1897,7 @@ public class CPPTemplates {
|
|||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(argLen);
|
||||
for (int i = 0; i < argLen; i++) {
|
||||
final ICPPTemplateParameter tpar = tpars[i];
|
||||
final CPPTemplateArgument arg = uniqueArg(tpar);
|
||||
final ICPPTemplateArgument arg = uniqueArg(tpar);
|
||||
args[i]= arg;
|
||||
if (tpar.isParameterPack()) {
|
||||
map.put(tpar, new ICPPTemplateArgument[] {arg});
|
||||
|
@ -1938,12 +1913,12 @@ public class CPPTemplates {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static CPPTemplateArgument uniqueArg(final ICPPTemplateParameter tpar) throws DOMException {
|
||||
final CPPTemplateArgument arg;
|
||||
private static ICPPTemplateArgument uniqueArg(final ICPPTemplateParameter tpar) throws DOMException {
|
||||
final ICPPTemplateArgument arg;
|
||||
if (tpar instanceof ICPPTemplateNonTypeParameter) {
|
||||
arg = new CPPTemplateArgument(Value.unique(), ((ICPPTemplateNonTypeParameter) tpar).getType());
|
||||
arg = new CPPTemplateNonTypeArgument(Value.unique(), ((ICPPTemplateNonTypeParameter) tpar).getType());
|
||||
} else {
|
||||
arg = new CPPTemplateArgument(new UniqueType(tpar.isParameterPack()));
|
||||
arg = new CPPTemplateTypeArgument(new UniqueType(tpar.isParameterPack()));
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
@ -1998,7 +1973,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
private static IType[] concat(final IType t, IType[] types) {
|
||||
IType[] result= new IType[types.length + 1];
|
||||
IType[] result= new IType[types.length+1];
|
||||
result[0]= t;
|
||||
System.arraycopy(types, 0, result, 1, types.length);
|
||||
return result;
|
||||
|
@ -2108,7 +2083,7 @@ public class CPPTemplates {
|
|||
final CPPTemplateParameterMap transferMap= new CPPTemplateParameterMap(tpars1Len);
|
||||
for (int i = 0; i < tpars1Len; i++) {
|
||||
final ICPPTemplateParameter param = tpars1[i];
|
||||
final CPPTemplateArgument arg = uniqueArg(param);
|
||||
final ICPPTemplateArgument arg = uniqueArg(param);
|
||||
args[i]= arg;
|
||||
transferMap.put(param, arg);
|
||||
}
|
||||
|
@ -2207,7 +2182,7 @@ public class CPPTemplates {
|
|||
pType= instantiateType(pType, map, -1, null, point);
|
||||
}
|
||||
if (argType instanceof ICPPUnknownType || argType instanceof ISemanticProblem || isNonTypeArgumentConvertible(pType, argType, point)) {
|
||||
return new CPPTemplateArgument(arg.getNonTypeValue(), pType);
|
||||
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
|
||||
}
|
||||
return null;
|
||||
|
||||
|
@ -2255,9 +2230,8 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
if (!matchTemplateTemplateParameters(((ICPPTemplateTemplateParameter) pp).getTemplateParameters(),
|
||||
((ICPPTemplateTemplateParameter) ap).getTemplateParameters())) {
|
||||
((ICPPTemplateTemplateParameter) ap).getTemplateParameters()) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pp.isParameterPack())
|
||||
|
@ -2395,7 +2369,7 @@ public class CPPTemplates {
|
|||
|
||||
public static boolean containsDependentArg(ObjectMap tpMap) {
|
||||
for (Object arg : tpMap.valueArray()) {
|
||||
if (isDependentType((IType)arg))
|
||||
if (isDependentType((IType) arg))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2429,9 +2403,9 @@ public class CPPTemplates {
|
|||
}
|
||||
} else if (!t.equals(owner)) {
|
||||
if (unknown instanceof ICPPUnknownClassType) {
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding)t, unknown.getNameCharArray());
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
} else if (unknown instanceof IFunction) {
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding)t, unknown.getNameCharArray());
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
} else {
|
||||
result= new CPPUnknownBinding((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
}
|
||||
|
@ -2439,7 +2413,7 @@ public class CPPTemplates {
|
|||
} else if (t instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType) t).getCompositeScope();
|
||||
if (s != null) {
|
||||
result= CPPSemantics.resolveUnknownName(s, unknown);
|
||||
result= CPPSemantics.resolveUnknownName(s, unknown, point);
|
||||
if (unknown instanceof ICPPUnknownClassInstance && result instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(
|
||||
((ICPPUnknownClassInstance) unknown).getArguments(), tpMap, packOffset, within, point);
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -157,6 +161,7 @@ import org.eclipse.cdt.core.parser.util.AttributeUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
|
||||
|
@ -191,8 +196,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
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.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
|
@ -2029,7 +2034,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) }, initClause);
|
||||
new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(type) }, initClause);
|
||||
if (type instanceof IProblemBinding) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||
}
|
||||
|
@ -2058,7 +2063,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
type = t;
|
||||
if (initClause instanceof ICPPASTInitializerList) {
|
||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) }, initClause);
|
||||
new ICPPTemplateArgument[] { new CPPTemplateTypeArgument(type) }, initClause);
|
||||
}
|
||||
return decorateType(type, declSpec, declarator);
|
||||
}
|
||||
|
@ -2236,7 +2241,10 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
|
||||
private static IType getStdType(final IASTNode node, char[] name) {
|
||||
IBinding[] std= node.getTranslationUnit().getScope().find(STD);
|
||||
if (node == null)
|
||||
return null;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) node.getTranslationUnit();
|
||||
IBinding[] std= ast.getScope().find(STD);
|
||||
for (IBinding binding : std) {
|
||||
if (binding instanceof ICPPNamespace) {
|
||||
final ICPPNamespaceScope scope = ((ICPPNamespace) binding).getNamespaceScope();
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the possible cv-qualification of a type.
|
||||
*/
|
||||
|
@ -23,16 +22,19 @@ public enum CVQualifier {
|
|||
private static final int R = 4;
|
||||
|
||||
final private int fQualifiers;
|
||||
|
||||
private CVQualifier(int qualifiers) {
|
||||
fQualifiers= qualifiers;
|
||||
}
|
||||
|
||||
|
||||
public boolean isConst() {
|
||||
return (fQualifiers & C) != 0;
|
||||
}
|
||||
|
||||
public boolean isVolatile() {
|
||||
return (fQualifiers & V) != 0;
|
||||
}
|
||||
|
||||
public boolean isRestrict() {
|
||||
return (fQualifiers & R) != 0;
|
||||
}
|
||||
|
@ -54,7 +56,7 @@ public enum CVQualifier {
|
|||
}
|
||||
|
||||
private CVQualifier fromQualifier(final int q) {
|
||||
switch(q) {
|
||||
switch (q) {
|
||||
case C|V|R: return CONST_VOLATILE_RESTRICT;
|
||||
case V|R: return VOLATILE_RESTRICT;
|
||||
case C|R: return CONST_RESTRICT;
|
||||
|
@ -65,7 +67,7 @@ public enum CVQualifier {
|
|||
case 0: default: return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [3.9.3-4] Implements cv-qualification (partial) comparison. There is a (partial)
|
||||
* ordering on cv-qualifiers, so that a type can be said to be more
|
||||
|
@ -83,12 +85,12 @@ public enum CVQualifier {
|
|||
* </ul>
|
||||
*/
|
||||
public int partialComparison(CVQualifier cv2) {
|
||||
// same qualifications
|
||||
// Same qualifications.
|
||||
if (this == cv2)
|
||||
return 0;
|
||||
|
||||
if (!isAtLeastAsQualifiedAs(cv2))
|
||||
return -1;
|
||||
return fQualifiers-cv2.fQualifiers;
|
||||
return fQualifiers - cv2.fQualifiers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2012 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 - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -75,8 +75,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.ReferenceBind
|
|||
* Routines for calculating the cost of conversions.
|
||||
*/
|
||||
public class Conversions {
|
||||
public enum UDCMode {ALLOWED, FORBIDDEN, DEFER}
|
||||
public enum Context {ORDINARY, IMPLICIT_OBJECT, FIRST_PARAM_OF_DIRECT_COPY_CTOR, REQUIRE_DIRECT_BINDING}
|
||||
public enum UDCMode { ALLOWED, FORBIDDEN, DEFER }
|
||||
public enum Context { ORDINARY, IMPLICIT_OBJECT, FIRST_PARAM_OF_DIRECT_COPY_CTOR, REQUIRE_DIRECT_BINDING }
|
||||
|
||||
private static final char[] INITIALIZER_LIST_NAME = "initializer_list".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] STD_NAME = "std".toCharArray(); //$NON-NLS-1$
|
||||
|
@ -135,7 +135,7 @@ public class Conversions {
|
|||
// [for overload resolution bit-fields are treated the same, error if selected as best match]
|
||||
if (valueCat == LVALUE) {
|
||||
// ... and "cv1 T1" is reference-compatible with "cv2 T2"
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject);
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject, point);
|
||||
if (cost != null) {
|
||||
cost.setReferenceBinding(refBindingType);
|
||||
return cost;
|
||||
|
@ -145,7 +145,7 @@ public class Conversions {
|
|||
// implicitly converted to an lvalue of type 'cv3 T3', where 'cv1 T1' is reference-compatible with
|
||||
// 'cv3 T3' (this conversion is selected by enumerating the applicable conversion functions (13.3.1.6)
|
||||
// and choosing the best one through overload resolution (13.3)),
|
||||
if (T2 instanceof ICPPClassType && udc != UDCMode.FORBIDDEN && isReferenceRelated(T1, T2) < 0) {
|
||||
if (T2 instanceof ICPPClassType && udc != UDCMode.FORBIDDEN && isReferenceRelated(T1, T2, point) < 0) {
|
||||
Cost cost= initializationByConversionForDirectReference(cv1T1, cv2T2, (ICPPClassType) T2, true, ctx, point);
|
||||
if (cost != null) {
|
||||
cost.setReferenceBinding(refBindingType);
|
||||
|
@ -195,7 +195,7 @@ public class Conversions {
|
|||
// ... the initializer expression is an rvalue and 'cv1 T1' is reference-compatible with 'cv2 T2'
|
||||
// ..., then the reference is bound to the initializer expression rvalue in the first case
|
||||
if (valueCat.isRValue()) {
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject);
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject, point);
|
||||
if (cost != null) {
|
||||
// [13.3.3.1.4-1] direct binding has either identity or conversion rank.
|
||||
if (cost.getInheritanceDistance() > 0) {
|
||||
|
@ -212,7 +212,7 @@ public class Conversions {
|
|||
// resolution (13.3)), then the reference is bound to the initializer expression rvalue in the
|
||||
// first case and to the object that is the result of the conversion in the second case (or,
|
||||
// in either case, to the appropriate base class sub-object of the object).
|
||||
if (udc != UDCMode.FORBIDDEN && isReferenceRelated(T1, T2) < 0) {
|
||||
if (udc != UDCMode.FORBIDDEN && isReferenceRelated(T1, T2, point) < 0) {
|
||||
Cost cost= initializationByConversionForDirectReference(cv1T1, cv2T2, (ICPPClassType) T2, false, ctx, point);
|
||||
if (cost != null) {
|
||||
cost.setReferenceBinding(refBindingType);
|
||||
|
@ -225,7 +225,7 @@ public class Conversions {
|
|||
// reference-compatible with 'cv2 T2' the reference is bound to the object represented by the
|
||||
// rvalue (see 3.10).
|
||||
if (T2 instanceof IArrayType && valueCat.isRValue()) {
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject);
|
||||
Cost cost= isReferenceCompatible(cv1T1, cv2T2, isImpliedObject, point);
|
||||
if (cost != null) {
|
||||
cost.setReferenceBinding(refBindingType);
|
||||
return cost;
|
||||
|
@ -239,7 +239,7 @@ public class Conversions {
|
|||
|
||||
// 13.3.3.1.7 no temporary object when converting the implicit object parameter
|
||||
if (!isImpliedObject && ctx != Context.REQUIRE_DIRECT_BINDING) {
|
||||
if (isReferenceRelated(T1, T2) < 0 || compareQualifications(cv1T1, cv2T2) >= 0) {
|
||||
if (isReferenceRelated(T1, T2, point) < 0 || compareQualifications(cv1T1, cv2T2) >= 0) {
|
||||
Cost cost= nonReferenceConversion(valueCat, cv2T2, T1, udc, point);
|
||||
if (cost.converts()) {
|
||||
cost.setReferenceBinding(refBindingType);
|
||||
|
@ -260,7 +260,7 @@ public class Conversions {
|
|||
*/
|
||||
private static Cost initializationByConversionForDirectReference(final IType cv1T1, final IType cv2T2, final ICPPClassType T2, boolean needLValue, Context ctx, IASTNode point)
|
||||
throws DOMException {
|
||||
ICPPMethod[] fcns= SemanticUtil.getConversionOperators(T2);
|
||||
ICPPMethod[] fcns= SemanticUtil.getConversionOperators(T2, point);
|
||||
Cost operatorCost= null;
|
||||
FunctionCost bestUdcCost= null;
|
||||
boolean ambiguousConversionOperator= false;
|
||||
|
@ -276,14 +276,14 @@ public class Conversions {
|
|||
final boolean isLValueRef= t instanceof ICPPReferenceType && !((ICPPReferenceType) t).isRValueReference();
|
||||
if (isLValueRef == needLValue) { // require an lvalue or rvalue
|
||||
IType implicitParameterType= CPPSemantics.getImplicitParameterType(op);
|
||||
Cost udcCost= isReferenceCompatible(getNestedType(implicitParameterType, TDEF | REF), cv2T2, true); // expression type to implicit object type
|
||||
Cost udcCost= isReferenceCompatible(getNestedType(implicitParameterType, TDEF | REF), cv2T2, true, point); // expression type to implicit object type
|
||||
if (udcCost != null) {
|
||||
// Make sure top-level cv-qualifiers are compared
|
||||
udcCost.setReferenceBinding(ReferenceBinding.LVALUE_REF);
|
||||
FunctionCost udcFuncCost= new FunctionCost(op, udcCost);
|
||||
int cmp= udcFuncCost.compareTo(null, bestUdcCost, point);
|
||||
FunctionCost udcFuncCost= new FunctionCost(op, udcCost, point);
|
||||
int cmp= udcFuncCost.compareTo(null, bestUdcCost);
|
||||
if (cmp <= 0) {
|
||||
Cost cost= isReferenceCompatible(cv1T1, getNestedType(t, TDEF | REF), false); // converted to target
|
||||
Cost cost= isReferenceCompatible(cv1T1, getNestedType(t, TDEF | REF), false, point); // converted to target
|
||||
if (cost != null) {
|
||||
bestUdcCost= udcFuncCost;
|
||||
ambiguousConversionOperator= cmp == 0;
|
||||
|
@ -315,7 +315,7 @@ public class Conversions {
|
|||
if (uqTarget instanceof ICPPClassType) {
|
||||
if (uqSource instanceof ICPPClassType) {
|
||||
// 13.3.3.1-6 Conceptual derived to base conversion
|
||||
int depth= calculateInheritanceDepth(uqSource, uqTarget);
|
||||
int depth= calculateInheritanceDepth(uqSource, uqTarget, point);
|
||||
if (depth >= 0) {
|
||||
if (depth == 0) {
|
||||
return new Cost(source, target, Rank.IDENTITY);
|
||||
|
@ -338,7 +338,7 @@ public class Conversions {
|
|||
return initializationByConversion(valueCat, source, (ICPPClassType) uqSource, target, udc == UDCMode.DEFER, point);
|
||||
}
|
||||
|
||||
return checkStandardConversionSequence(uqSource, target);
|
||||
return checkStandardConversionSequence(uqSource, target, point);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +371,7 @@ public class Conversions {
|
|||
return Cost.NO_CONVERSION;
|
||||
|
||||
ICPPClassType classTarget= (ICPPClassType) noCVTarget;
|
||||
if (ClassTypeHelper.isAggregateClass(classTarget)) {
|
||||
if (ClassTypeHelper.isAggregateClass(classTarget, point)) {
|
||||
Cost cost= new Cost(arg.getTypeOrFunctionSet(point), target, Rank.IDENTITY);
|
||||
cost.setUserDefinedConversion(null);
|
||||
return cost;
|
||||
|
@ -439,7 +439,7 @@ public class Conversions {
|
|||
* Note this is not a symmetric relation.
|
||||
* @return inheritance distance, or -1, if <code>cv1t1</code> is not reference-related to <code>cv2t2</code>
|
||||
*/
|
||||
private static final int isReferenceRelated(IType cv1Target, IType cv2Source) {
|
||||
private static final int isReferenceRelated(IType cv1Target, IType cv2Source, IASTNode point) {
|
||||
IType t= SemanticUtil.getNestedType(cv1Target, TDEF | REF);
|
||||
IType s= SemanticUtil.getNestedType(cv2Source, TDEF | REF);
|
||||
|
||||
|
@ -474,7 +474,7 @@ public class Conversions {
|
|||
s= SemanticUtil.getNestedType(((IQualifierType) s).getType(), TDEF | REF);
|
||||
|
||||
if (t instanceof ICPPClassType && s instanceof ICPPClassType) {
|
||||
return SemanticUtil.calculateInheritanceDepth(s, t);
|
||||
return SemanticUtil.calculateInheritanceDepth(s, t, point);
|
||||
}
|
||||
}
|
||||
if (t == s || (t != null && s != null && t.isSameType(s))) {
|
||||
|
@ -490,8 +490,8 @@ public class Conversions {
|
|||
* @return The cost for converting or <code>null</code> if <code>cv1t1</code> is not
|
||||
* reference-compatible with <code>cv2t2</code>
|
||||
*/
|
||||
private static final Cost isReferenceCompatible(IType cv1Target, IType cv2Source, boolean isImpliedObject) {
|
||||
int inheritanceDist= isReferenceRelated(cv1Target, cv2Source);
|
||||
private static final Cost isReferenceCompatible(IType cv1Target, IType cv2Source, boolean isImpliedObject, IASTNode point) {
|
||||
int inheritanceDist= isReferenceRelated(cv1Target, cv2Source, point);
|
||||
if (inheritanceDist < 0)
|
||||
return null;
|
||||
final int cmp= compareQualifications(cv1Target, cv2Source);
|
||||
|
@ -515,7 +515,7 @@ public class Conversions {
|
|||
* [4] Standard Conversions
|
||||
* Computes the cost of using the standard conversion sequence from source to target.
|
||||
*/
|
||||
private static final Cost checkStandardConversionSequence(IType source, IType target) {
|
||||
private static final Cost checkStandardConversionSequence(IType source, IType target, IASTNode point) {
|
||||
final Cost cost= new Cost(source, target, Rank.IDENTITY);
|
||||
if (lvalue_to_rvalue(cost))
|
||||
return cost;
|
||||
|
@ -523,7 +523,7 @@ public class Conversions {
|
|||
if (promotion(cost))
|
||||
return cost;
|
||||
|
||||
if (conversion(cost))
|
||||
if (conversion(cost, point))
|
||||
return cost;
|
||||
|
||||
if (qualificationConversion(cost))
|
||||
|
@ -546,7 +546,7 @@ public class Conversions {
|
|||
ICPPConstructor usedCtor= null;
|
||||
Cost bestCost= null;
|
||||
boolean hasInitListConstructor= false;
|
||||
final ICPPConstructor[] constructors = t.getConstructors();
|
||||
final ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(t, point);
|
||||
ICPPConstructor[] ctors= constructors;
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
final int minArgCount = ctor.getRequiredArgumentCount();
|
||||
|
@ -630,7 +630,8 @@ public class Conversions {
|
|||
/**
|
||||
* 13.3.1.4 Copy-initialization of class by user-defined conversion [over.match.copy]
|
||||
*/
|
||||
static final Cost copyInitializationOfClass(ValueCategory valueCat, IType source, ICPPClassType t, boolean deferUDC, IASTNode point) throws DOMException {
|
||||
static final Cost copyInitializationOfClass(ValueCategory valueCat, IType source, ICPPClassType t,
|
||||
boolean deferUDC, IASTNode point) throws DOMException {
|
||||
if (deferUDC) {
|
||||
Cost c= new Cost(source, t, Rank.USER_DEFINED_CONVERSION);
|
||||
c.setDeferredUDC(DeferredUDC.COPY_INIT_OF_CLASS);
|
||||
|
@ -639,7 +640,7 @@ public class Conversions {
|
|||
|
||||
FunctionCost cost1= null;
|
||||
Cost cost2= null;
|
||||
ICPPFunction[] ctors= t.getConstructors();
|
||||
ICPPFunction[] ctors= ClassTypeHelper.getConstructors(t, point);
|
||||
ctors = CPPTemplates.instantiateForFunctionCall(ctors, null,
|
||||
Collections.singletonList(source), Collections.singletonList(valueCat), false, point);
|
||||
|
||||
|
@ -657,7 +658,7 @@ public class Conversions {
|
|||
FunctionCost c1;
|
||||
if (ptypes.length == 0) {
|
||||
if (ctor.takesVarArgs()) {
|
||||
c1= new FunctionCost(ctor, new Cost(source, null, Rank.ELLIPSIS_CONVERSION));
|
||||
c1= new FunctionCost(ctor, new Cost(source, null, Rank.ELLIPSIS_CONVERSION), point);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -669,9 +670,9 @@ public class Conversions {
|
|||
if (ctor.getRequiredArgumentCount() > 1)
|
||||
continue;
|
||||
|
||||
c1= new FunctionCost(ctor, checkImplicitConversionSequence(ptype, source, valueCat, UDCMode.FORBIDDEN, Context.ORDINARY, point));
|
||||
c1= new FunctionCost(ctor, checkImplicitConversionSequence(ptype, source, valueCat, UDCMode.FORBIDDEN, Context.ORDINARY, point), point);
|
||||
}
|
||||
int cmp= c1.compareTo(null, cost1, point);
|
||||
int cmp= c1.compareTo(null, cost1);
|
||||
if (cmp <= 0) {
|
||||
cost1= c1;
|
||||
cost2= new Cost(t, t, Rank.IDENTITY);
|
||||
|
@ -685,7 +686,7 @@ public class Conversions {
|
|||
|
||||
final IType uqSource= getNestedType(source, TDEF | REF | CVTYPE);
|
||||
if (uqSource instanceof ICPPClassType) {
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource);
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators((ICPPClassType) uqSource, point);
|
||||
ops= CPPTemplates.instantiateConversionTemplates(ops, t, point);
|
||||
for (final ICPPFunction f : ops) {
|
||||
if (f instanceof ICPPMethod && !(f instanceof IProblemBinding)) {
|
||||
|
@ -694,15 +695,15 @@ public class Conversions {
|
|||
continue;
|
||||
final IType returnType = op.getType().getReturnType();
|
||||
final IType uqReturnType= getNestedType(returnType, REF | TDEF | CVTYPE);
|
||||
final int dist = SemanticUtil.calculateInheritanceDepth(uqReturnType, t);
|
||||
final int dist = SemanticUtil.calculateInheritanceDepth(uqReturnType, t, point);
|
||||
if (dist >= 0) {
|
||||
IType implicitType= CPPSemantics.getImplicitParameterType(op);
|
||||
final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true);
|
||||
final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true, point);
|
||||
if (udcCost != null) {
|
||||
// Make sure top-level cv-qualifiers are compared
|
||||
udcCost.setReferenceBinding(ReferenceBinding.LVALUE_REF);
|
||||
FunctionCost c1= new FunctionCost(op, udcCost);
|
||||
int cmp= c1.compareTo(null, cost1, point);
|
||||
FunctionCost c1= new FunctionCost(op, udcCost, point);
|
||||
int cmp= c1.compareTo(null, cost1);
|
||||
if (cmp <= 0) {
|
||||
cost1= c1;
|
||||
cost2= new Cost(t, t, Rank.IDENTITY);
|
||||
|
@ -735,7 +736,7 @@ public class Conversions {
|
|||
c.setDeferredUDC(DeferredUDC.INIT_BY_CONVERSION);
|
||||
return c;
|
||||
}
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators(uqSource);
|
||||
ICPPFunction[] ops = SemanticUtil.getConversionOperators(uqSource, point);
|
||||
ops= CPPTemplates.instantiateConversionTemplates(ops, target, point);
|
||||
FunctionCost cost1= null;
|
||||
Cost cost2= null;
|
||||
|
@ -753,12 +754,12 @@ public class Conversions {
|
|||
if (isExplicitConversion && c2.getRank() != Rank.IDENTITY)
|
||||
continue;
|
||||
IType implicitType= CPPSemantics.getImplicitParameterType(op);
|
||||
final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true);
|
||||
final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true, point);
|
||||
if (udcCost != null) {
|
||||
// Make sure top-level cv-qualifiers are compared
|
||||
udcCost.setReferenceBinding(ReferenceBinding.LVALUE_REF);
|
||||
FunctionCost c1= new FunctionCost(op, udcCost);
|
||||
int cmp= c1.compareTo(null, cost1, point);
|
||||
FunctionCost c1= new FunctionCost(op, udcCost, point);
|
||||
int cmp= c1.compareTo(null, cost1);
|
||||
if (cmp <= 0) {
|
||||
cost1= c1;
|
||||
cost2= c2;
|
||||
|
@ -1014,7 +1015,7 @@ public class Conversions {
|
|||
* [4.10] Pointer conversions
|
||||
* [4.11] Pointer to member conversions
|
||||
*/
|
||||
private static final boolean conversion(Cost cost){
|
||||
private static final boolean conversion(Cost cost, IASTNode point) {
|
||||
final IType s = cost.source;
|
||||
final IType t = cost.target;
|
||||
|
||||
|
@ -1085,7 +1086,7 @@ public class Conversions {
|
|||
// to an rvalue of type "pointer to cv B", where B is a base class of D.
|
||||
IType srcPtrTgt= getNestedType(srcPtr.getType(), TDEF | CVTYPE | REF);
|
||||
if (tgtPtrTgt instanceof ICPPClassType && srcPtrTgt instanceof ICPPClassType) {
|
||||
int depth= SemanticUtil.calculateInheritanceDepth(srcPtrTgt, tgtPtrTgt);
|
||||
int depth= SemanticUtil.calculateInheritanceDepth(srcPtrTgt, tgtPtrTgt, point);
|
||||
if (depth == -1) {
|
||||
cost.setRank(Rank.NO_MATCH);
|
||||
return true;
|
||||
|
@ -1108,7 +1109,7 @@ public class Conversions {
|
|||
IType tt = tpm.getType();
|
||||
if (st != null && tt != null && st.isSameType(tt)) {
|
||||
int depth = SemanticUtil.calculateInheritanceDepth(tpm.getMemberOfClass(),
|
||||
spm.getMemberOfClass());
|
||||
spm.getMemberOfClass(), point);
|
||||
if (depth == -1) {
|
||||
cost.setRank(Rank.NO_MATCH);
|
||||
return true;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -114,7 +114,6 @@ public class Cost {
|
|||
public void setRank(Rank rank) {
|
||||
fRank= rank;
|
||||
}
|
||||
|
||||
|
||||
public ReferenceBinding getReferenceBinding() {
|
||||
return fReferenceBinding;
|
||||
|
@ -123,7 +122,6 @@ public class Cost {
|
|||
public void setReferenceBinding(ReferenceBinding binding) {
|
||||
fReferenceBinding= binding;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAmbiguousUDC() {
|
||||
return fAmbiguousUDC;
|
||||
|
@ -303,7 +301,7 @@ public class Cost {
|
|||
public void setSelectedFunction(ICPPFunction function) {
|
||||
fSelectedFunction= function;
|
||||
}
|
||||
|
||||
|
||||
public ICPPFunction getSelectedFunction() {
|
||||
return fSelectedFunction;
|
||||
}
|
||||
|
|
|
@ -7,28 +7,55 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_assign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_binaryAndAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_binaryOrAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_binaryXorAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_divideAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_equals;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_greaterEqual;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_greaterThan;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_lessEqual;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_lessThan;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_logicalAnd;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_logicalOr;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_minus;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_minusAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_moduloAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_multiplyAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_notequals;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_plus;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_plusAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_pmarrow;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_pmdot;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_shiftLeftAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTBinaryExpression.op_shiftRightAssign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueTypeWithResolvedTypedefs;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -102,7 +129,43 @@ public class EvalBinary extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (getOverload(point) != null) {
|
||||
// TODO(sprigogin): Simulate execution of a function call.
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
IValue v1 = fArg1.getValue(point);
|
||||
if (v1 == Value.UNKNOWN)
|
||||
return Value.UNKNOWN;
|
||||
IValue v2 = fArg2.getValue(point);
|
||||
if (v2 == Value.UNKNOWN)
|
||||
return Value.UNKNOWN;
|
||||
|
||||
switch (fOperator) {
|
||||
case op_equals:
|
||||
if (v1.equals(v2))
|
||||
return Value.create(1);
|
||||
break;
|
||||
case op_notequals:
|
||||
if (v1.equals(v2))
|
||||
return Value.create(0);
|
||||
break;
|
||||
}
|
||||
|
||||
Long num1 = v1.numericalValue();
|
||||
if (num1 != null) {
|
||||
if (num1 == 0) {
|
||||
if (fOperator == op_logicalAnd)
|
||||
return v1;
|
||||
} else if (fOperator == op_logicalOr) {
|
||||
return v1;
|
||||
}
|
||||
Long num2 = v2.numericalValue();
|
||||
if (num2 != null) {
|
||||
return Value.evaluateBinaryExpression(fOperator, num1, num2);
|
||||
}
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,25 +192,25 @@ public class EvalBinary extends CPPEvaluation {
|
|||
|
||||
switch (fOperator) {
|
||||
case op_arrayAccess:
|
||||
case IASTBinaryExpression.op_assign:
|
||||
case IASTBinaryExpression.op_binaryAndAssign:
|
||||
case IASTBinaryExpression.op_binaryOrAssign:
|
||||
case IASTBinaryExpression.op_binaryXorAssign:
|
||||
case IASTBinaryExpression.op_divideAssign:
|
||||
case IASTBinaryExpression.op_minusAssign:
|
||||
case IASTBinaryExpression.op_moduloAssign:
|
||||
case IASTBinaryExpression.op_multiplyAssign:
|
||||
case IASTBinaryExpression.op_plusAssign:
|
||||
case IASTBinaryExpression.op_shiftLeftAssign:
|
||||
case IASTBinaryExpression.op_shiftRightAssign:
|
||||
case op_assign:
|
||||
case op_binaryAndAssign:
|
||||
case op_binaryOrAssign:
|
||||
case op_binaryXorAssign:
|
||||
case op_divideAssign:
|
||||
case op_minusAssign:
|
||||
case op_moduloAssign:
|
||||
case op_multiplyAssign:
|
||||
case op_plusAssign:
|
||||
case op_shiftLeftAssign:
|
||||
case op_shiftRightAssign:
|
||||
return LVALUE;
|
||||
|
||||
case IASTBinaryExpression.op_pmdot:
|
||||
case op_pmdot:
|
||||
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
|
||||
return fArg1.getValueCategory(point);
|
||||
break;
|
||||
|
||||
case IASTBinaryExpression.op_pmarrow:
|
||||
case op_pmarrow:
|
||||
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
|
||||
return LVALUE;
|
||||
break;
|
||||
|
@ -215,17 +278,17 @@ public class EvalBinary extends CPPEvaluation {
|
|||
}
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
|
||||
case IASTBinaryExpression.op_lessEqual:
|
||||
case IASTBinaryExpression.op_lessThan:
|
||||
case IASTBinaryExpression.op_greaterEqual:
|
||||
case IASTBinaryExpression.op_greaterThan:
|
||||
case IASTBinaryExpression.op_logicalAnd:
|
||||
case IASTBinaryExpression.op_logicalOr:
|
||||
case IASTBinaryExpression.op_equals:
|
||||
case IASTBinaryExpression.op_notequals:
|
||||
case op_lessEqual:
|
||||
case op_lessThan:
|
||||
case op_greaterEqual:
|
||||
case op_greaterThan:
|
||||
case op_logicalAnd:
|
||||
case op_logicalOr:
|
||||
case op_equals:
|
||||
case op_notequals:
|
||||
return CPPBasicType.BOOLEAN;
|
||||
|
||||
case IASTBinaryExpression.op_plus:
|
||||
case op_plus:
|
||||
if (type1 instanceof IPointerType) {
|
||||
return ExpressionTypes.restoreTypedefs(type1, originalType1);
|
||||
}
|
||||
|
@ -234,7 +297,7 @@ public class EvalBinary extends CPPEvaluation {
|
|||
}
|
||||
break;
|
||||
|
||||
case IASTBinaryExpression.op_minus:
|
||||
case op_minus:
|
||||
if (type1 instanceof IPointerType) {
|
||||
if (type2 instanceof IPointerType) {
|
||||
return CPPVisitor.getPointerDiffType(point);
|
||||
|
@ -243,13 +306,13 @@ public class EvalBinary extends CPPEvaluation {
|
|||
}
|
||||
break;
|
||||
|
||||
case ICPPASTBinaryExpression.op_pmarrow:
|
||||
case ICPPASTBinaryExpression.op_pmdot:
|
||||
case op_pmarrow:
|
||||
case op_pmdot:
|
||||
if (type2 instanceof ICPPPointerToMemberType) {
|
||||
IType t= ((ICPPPointerToMemberType) type2).getType();
|
||||
if (t instanceof ICPPFunctionType)
|
||||
return t;
|
||||
if (fOperator == ICPPASTBinaryExpression.op_pmdot && fArg1.getValueCategory(point) == PRVALUE) {
|
||||
if (fOperator == op_pmdot && fArg1.getValueCategory(point) == PRVALUE) {
|
||||
return prvalueType(t);
|
||||
}
|
||||
return glvalueType(t);
|
||||
|
@ -273,4 +336,24 @@ public class EvalBinary extends CPPEvaluation {
|
|||
ICPPEvaluation arg2= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
return new EvalBinary(op, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation arg1 = fArg1.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPEvaluation arg2 = fArg2.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (arg1 == fArg1 && arg2 == fArg2)
|
||||
return this;
|
||||
return new EvalBinary(fOperator, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.combinePackSize(fArg1.determinePackSize(tpMap), fArg2.determinePackSize(tpMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fArg1.referencesTemplateParameter() || fArg2.referencesTemplateParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -18,11 +19,16 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -74,7 +80,16 @@ public class EvalBinaryTypeId extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
|
||||
switch (fOperator) {
|
||||
case __is_base_of:
|
||||
if (!(fType1 instanceof ICPPClassType) || !(fType1 instanceof ICPPClassType))
|
||||
return Value.UNKNOWN;
|
||||
return Value.create(ClassTypeHelper.isSubclass((ICPPClassType) fType2, (ICPPClassType) fType1));
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,4 +125,25 @@ public class EvalBinaryTypeId extends CPPEvaluation {
|
|||
IType arg2= buffer.unmarshalType();
|
||||
return new EvalBinaryTypeId(Operator.values()[op], arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType type1 = CPPTemplates.instantiateType(fType1, tpMap, packOffset, within, point);
|
||||
IType type2 = CPPTemplates.instantiateType(fType2, tpMap, packOffset, within, point);
|
||||
if (type1 == fType1 && type2 == fType2)
|
||||
return this;
|
||||
return new EvalBinaryTypeId(fOperator, type1, type2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.combinePackSize(CPPTemplates.determinePackSize(fType1, tpMap),
|
||||
CPPTemplates.determinePackSize(fType2, tpMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -22,11 +23,21 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -40,7 +51,6 @@ public class EvalBinding extends CPPEvaluation {
|
|||
private boolean fIsTypeDependent;
|
||||
private boolean fCheckedIsTypeDependent;
|
||||
|
||||
|
||||
public EvalBinding(IBinding binding, IType type) {
|
||||
fBinding= binding;
|
||||
fType= type;
|
||||
|
@ -75,20 +85,19 @@ public class EvalBinding extends CPPEvaluation {
|
|||
}
|
||||
|
||||
private boolean computeIsTypeDependent() {
|
||||
if (fBinding instanceof ICPPUnknownBinding)
|
||||
return true;
|
||||
|
||||
IType t= null;
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
if (fFixedType) {
|
||||
t = fType;
|
||||
} else if (fBinding instanceof IEnumerator) {
|
||||
t= ((IEnumerator) fBinding).getType();
|
||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
t= ((ICPPTemplateNonTypeParameter) fBinding).getType();
|
||||
} else if (fBinding instanceof IVariable) {
|
||||
t = ((IVariable) fBinding).getType();
|
||||
} else if (fBinding instanceof IFunction) {
|
||||
t= ((IFunction) fBinding).getType();
|
||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
||||
return true;
|
||||
} else if (fBinding instanceof IFunction) {
|
||||
t= ((IFunction) fBinding).getType();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -114,12 +123,12 @@ public class EvalBinding extends CPPEvaluation {
|
|||
if (fBinding instanceof IVariable) {
|
||||
return Value.isDependentValue(((IVariable) fBinding).getInitialValue());
|
||||
}
|
||||
if (fBinding instanceof IFunction) {
|
||||
return false;
|
||||
}
|
||||
if (fBinding instanceof ICPPUnknownBinding) {
|
||||
return true;
|
||||
}
|
||||
if (fBinding instanceof IFunction) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -151,14 +160,28 @@ public class EvalBinding extends CPPEvaluation {
|
|||
final IFunctionType type = ((IFunction) fBinding).getType();
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return new TypeOfDependentExpression(this);
|
||||
return SemanticUtil.mapToAST(type, point);
|
||||
return SemanticUtil.mapToAST(type, point);
|
||||
}
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
|
||||
IValue value= null;
|
||||
if (fBinding instanceof IInternalVariable) {
|
||||
value= ((IInternalVariable) fBinding).getInitialValue(Value.MAX_RECURSION_DEPTH);
|
||||
} else if (fBinding instanceof IVariable) {
|
||||
value= ((IVariable) fBinding).getInitialValue();
|
||||
} else if (fBinding instanceof IEnumerator) {
|
||||
value= ((IEnumerator) fBinding).getValue();
|
||||
}
|
||||
if (value == null)
|
||||
value = Value.UNKNOWN;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +207,75 @@ public class EvalBinding extends CPPEvaluation {
|
|||
IType type= buffer.unmarshalType();
|
||||
return new EvalBinding(binding, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IBinding binding = fBinding;
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
IEnumerator enumerator = (IEnumerator) binding;
|
||||
IType originalType = enumerator.getType();
|
||||
IType type = CPPTemplates.instantiateType(originalType, tpMap, packOffset, within, point);
|
||||
IValue originalValue = enumerator.getValue();
|
||||
IValue value = CPPTemplates.instantiateValue(originalValue, tpMap, packOffset, within, maxdepth, point);
|
||||
// TODO(sprigogin): Not sure if following condition is correct.
|
||||
if (type != originalType || value != originalValue)
|
||||
return new EvalFixed(type, ValueCategory.PRVALUE, value);
|
||||
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) fBinding);
|
||||
if (argument != null) {
|
||||
IValue value = argument.getNonTypeValue();
|
||||
return new EvalFixed(null, ValueCategory.PRVALUE, value);
|
||||
}
|
||||
// TODO(sprigogin): Do we need something similar for pack expansion?
|
||||
} else if (fBinding instanceof ICPPUnknownBinding) {
|
||||
binding = resolveUnknown((ICPPUnknownBinding) fBinding, tpMap, packOffset, within, point);
|
||||
} else if (fBinding instanceof ICPPMethod) {
|
||||
IBinding owner = fBinding.getOwner();
|
||||
if (owner instanceof ICPPClassTemplate) {
|
||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
||||
tpMap, packOffset, within, point);
|
||||
}
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
binding = CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
||||
fBinding, point);
|
||||
}
|
||||
}
|
||||
if (binding == fBinding)
|
||||
return this;
|
||||
return new EvalBinding(binding, getFixedType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
if (fBinding instanceof IEnumerator) {
|
||||
return CPPTemplates.determinePackSize(((IEnumerator) fBinding).getValue(), tpMap);
|
||||
}
|
||||
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
return CPPTemplates.determinePackSize((ICPPTemplateNonTypeParameter) fBinding, tpMap);
|
||||
}
|
||||
if (fBinding instanceof ICPPUnknownBinding) {
|
||||
return CPPTemplates.determinePackSize((ICPPUnknownBinding) fBinding, tpMap);
|
||||
}
|
||||
|
||||
IBinding binding = fBinding;
|
||||
if (fBinding instanceof ICPPSpecialization) {
|
||||
binding = ((ICPPSpecialization) fBinding).getSpecializedBinding();
|
||||
}
|
||||
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
if (binding instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateParameter[] parameters = ((ICPPTemplateDefinition) binding).getTemplateParameters();
|
||||
for (ICPPTemplateParameter param : parameters) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(param, tpMap));
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fBinding instanceof ICPPTemplateParameter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -18,7 +19,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -123,12 +126,18 @@ public class EvalComma extends CPPEvaluation {
|
|||
return typeFromFunctionCall(last);
|
||||
}
|
||||
}
|
||||
return fArguments[fArguments.length-1].getTypeOrFunctionSet(point);
|
||||
return fArguments[fArguments.length - 1].getTypeOrFunctionSet(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
ICPPFunction[] overloads = getOverloads(point);
|
||||
if (overloads.length > 0) {
|
||||
// TODO(sprigogin): Simulate execution of a function call.
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
return fArguments[fArguments.length - 1].getValue(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,7 +149,7 @@ public class EvalComma extends CPPEvaluation {
|
|||
return valueCategoryFromFunctionCall(last);
|
||||
}
|
||||
}
|
||||
return fArguments[fArguments.length-1].getValueCategory(point);
|
||||
return fArguments[fArguments.length - 1].getValueCategory(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,4 +169,41 @@ public class EvalComma extends CPPEvaluation {
|
|||
}
|
||||
return new EvalComma(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
if (args == fArguments)
|
||||
return this;
|
||||
return new EvalComma(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
r = CPPTemplates.combinePackSize(r, arg.determinePackSize(tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
if (arg.referencesTemplateParameter())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -16,14 +17,16 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Performs evaluation of an expression.
|
||||
* Performs evaluation of a compound statement expression. Most but not all methods
|
||||
* delegate to the evaluation of the last expression in the compound one.
|
||||
*/
|
||||
public class EvalCompound extends CPPEvaluation {
|
||||
private final ICPPEvaluation fDelegate;
|
||||
|
@ -63,7 +66,7 @@ public class EvalCompound extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
return fDelegate.getValue(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,4 +84,23 @@ public class EvalCompound extends CPPEvaluation {
|
|||
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
return new EvalCompound(arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation delegate = fDelegate.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (delegate == fDelegate)
|
||||
return this;
|
||||
return new EvalCompound(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return fDelegate.determinePackSize(tpMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fDelegate.referencesTemplateParameter();
|
||||
}
|
||||
}
|
|
@ -7,13 +7,17 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
|
@ -23,8 +27,10 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -49,13 +55,12 @@ public class EvalConditional extends CPPEvaluation {
|
|||
private IType fType;
|
||||
private ICPPFunction fOverload;
|
||||
|
||||
|
||||
public EvalConditional(ICPPEvaluation arg1, ICPPEvaluation arg2, ICPPEvaluation arg3,
|
||||
public EvalConditional(ICPPEvaluation condition, ICPPEvaluation positive, ICPPEvaluation negative,
|
||||
boolean positiveThrows, boolean negativeThrows) {
|
||||
// Gnu-extension: Empty positive expression is replaced by condition.
|
||||
fCondition= arg1;
|
||||
fPositive= arg2;
|
||||
fNegative= arg3;
|
||||
fCondition= condition;
|
||||
fPositive= positive;
|
||||
fNegative= negative;
|
||||
fPositiveThrows= positiveThrows;
|
||||
fNegativeThrows= negativeThrows;
|
||||
}
|
||||
|
@ -103,7 +108,18 @@ public class EvalConditional extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
IValue condValue = fCondition.getValue(point);
|
||||
if (condValue == Value.UNKNOWN)
|
||||
return Value.UNKNOWN;
|
||||
Long cond = condValue.numericalValue();
|
||||
if (cond != null) {
|
||||
if (cond.longValue() != 0) {
|
||||
return fPositive == null ? condValue : fPositive.getValue(point);
|
||||
} else {
|
||||
return fNegative.getValue(point);
|
||||
}
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -252,7 +268,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
}
|
||||
// Both are class types and one derives from the other
|
||||
if (uqt1 instanceof ICPPClassType && uqt2 instanceof ICPPClassType) {
|
||||
int dist= SemanticUtil.calculateInheritanceDepth(uqt1, uqt2);
|
||||
int dist= SemanticUtil.calculateInheritanceDepth(uqt1, uqt2, point);
|
||||
if (dist >= 0) {
|
||||
CVQualifier cv1 = SemanticUtil.getCVQualifier(t1);
|
||||
CVQualifier cv2 = SemanticUtil.getCVQualifier(t2);
|
||||
|
@ -263,7 +279,7 @@ public class EvalConditional extends CPPEvaluation {
|
|||
}
|
||||
return Cost.NO_CONVERSION;
|
||||
}
|
||||
if (SemanticUtil.calculateInheritanceDepth(uqt2, uqt1) >= 0)
|
||||
if (SemanticUtil.calculateInheritanceDepth(uqt2, uqt1, point) >= 0)
|
||||
return Cost.NO_CONVERSION;
|
||||
}
|
||||
// Unrelated class types or just one class:
|
||||
|
@ -307,4 +323,32 @@ public class EvalConditional extends CPPEvaluation {
|
|||
ICPPEvaluation neg= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
return new EvalConditional(cond, pos, neg, pth, nth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation condition = fCondition.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPEvaluation positive = fPositive == null ?
|
||||
null : fPositive.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPEvaluation negative = fNegative.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (condition == fCondition && positive == fPositive && negative == fNegative)
|
||||
return this;
|
||||
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fCondition.determinePackSize(tpMap);
|
||||
r = CPPTemplates.combinePackSize(r, fNegative.determinePackSize(tpMap));
|
||||
if (fPositive != null)
|
||||
r = CPPTemplates.combinePackSize(r, fPositive.determinePackSize(tpMap));
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fCondition.referencesTemplateParameter() ||
|
||||
(fPositive != null && fPositive.referencesTemplateParameter()) ||
|
||||
fNegative.referencesTemplateParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -18,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -145,4 +148,24 @@ public class EvalFixed extends CPPEvaluation {
|
|||
value= readValue ? buffer.unmarshalValue() : Value.UNKNOWN;
|
||||
return new EvalFixed(type, cat, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType type = CPPTemplates.instantiateType(fType, tpMap, packOffset, within, point);
|
||||
IValue value = CPPTemplates.instantiateValue(fValue, tpMap, packOffset, within, maxdepth, point);
|
||||
if (type == fType && value == fValue)
|
||||
return this;
|
||||
return new EvalFixed(type, fValueCategory, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fValue, tpMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -17,6 +18,8 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
|||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
|
@ -24,8 +27,10 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -45,6 +50,10 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
fArguments= args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arguments of the function call. The first argument is the function name, the rest
|
||||
* are arguments passed to the function.
|
||||
*/
|
||||
public ICPPEvaluation[] getArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
@ -132,7 +141,8 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
// TODO(sprigogin): Simulate execution of a function call if the value is not dependent.
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,6 +177,48 @@ public class EvalFunctionCall extends CPPEvaluation {
|
|||
for (int i = 0; i < args.length; i++) {
|
||||
args[i]= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
}
|
||||
return new EvalComma(args);
|
||||
return new EvalFunctionCall(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
if (args == fArguments)
|
||||
return this;
|
||||
|
||||
if (args[0] instanceof EvalFunctionSet && getOverload(point) == null) {
|
||||
// Resolve the function using the parameters of the function call.
|
||||
args[0] = ((EvalFunctionSet) args[0]).resolveFunction(Arrays.copyOfRange(args, 1, args.length), point);
|
||||
}
|
||||
return new EvalFunctionCall(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
r = CPPTemplates.combinePackSize(r, arg.determinePackSize(tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
if (arg.referencesTemplateParameter())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,20 +7,29 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -106,7 +115,10 @@ public class EvalFunctionSet extends CPPEvaluation {
|
|||
buffer.marshalBinding(binding);
|
||||
}
|
||||
if (args != null) {
|
||||
// mstodo marshall arguments
|
||||
buffer.putShort((short) args.length);
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
buffer.marshalTemplateArgument(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,8 +131,80 @@ public class EvalFunctionSet extends CPPEvaluation {
|
|||
}
|
||||
ICPPTemplateArgument[] args= null;
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
|
||||
// mstodo marshall arguments
|
||||
int len= buffer.getShort();
|
||||
args = new ICPPTemplateArgument[len];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i]= buffer.unmarshalTemplateArgument();
|
||||
}
|
||||
}
|
||||
return new EvalFunctionSet(new CPPFunctionSet(bindings, args, null), addressOf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
||||
ICPPTemplateArgument[] arguments = originalArguments;
|
||||
arguments = instantiateArguments(originalArguments, tpMap, packOffset, within, point);
|
||||
|
||||
IBinding originalOwner = fFunctionSet.getOwner();
|
||||
IBinding owner = originalOwner;
|
||||
if (originalOwner instanceof ICPPUnknownBinding) {
|
||||
owner = resolveUnknown((ICPPUnknownBinding) owner, tpMap, packOffset, within, point);
|
||||
} else if (owner instanceof IType) {
|
||||
IType type = CPPTemplates.instantiateType((IType) owner, tpMap, packOffset, within, point);
|
||||
if (type instanceof IBinding)
|
||||
owner = (IBinding) type;
|
||||
}
|
||||
ICPPFunction[] originalFunctions = fFunctionSet.getBindings();
|
||||
ICPPFunction[] functions = originalFunctions;
|
||||
if (owner instanceof ICPPClassSpecialization && owner != originalOwner) {
|
||||
functions = new ICPPFunction[originalFunctions.length];
|
||||
for (int i = 0; i < originalFunctions.length; i++) {
|
||||
functions[i] = (ICPPFunction) CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
||||
originalFunctions[i], point);
|
||||
}
|
||||
}
|
||||
if (Arrays.equals(arguments, originalArguments) && functions == originalFunctions)
|
||||
return this;
|
||||
return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to resolve the function using the parameters of a function call.
|
||||
*
|
||||
* @param args the arguments of a function call
|
||||
* @param point the name lookup context
|
||||
* @return the resolved or the original evaluation depending on whether function resolution
|
||||
* succeeded or not
|
||||
*/
|
||||
public ICPPEvaluation resolveFunction(ICPPEvaluation[] args, IASTNode point) {
|
||||
ICPPFunction[] functions = fFunctionSet.getBindings();
|
||||
LookupData data = new LookupData(functions[0].getNameCharArray(),
|
||||
fFunctionSet.getTemplateArguments(), point);
|
||||
data.setFunctionArguments(false, args);
|
||||
try {
|
||||
IBinding binding = CPPSemantics.resolveFunction(data, functions, true);
|
||||
if (binding instanceof ICPPFunction && !(binding instanceof ICPPUnknownBinding))
|
||||
return new EvalBinding(binding, null);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
ICPPTemplateArgument[] templateArguments = fFunctionSet.getTemplateArguments();
|
||||
for (ICPPTemplateArgument arg : templateArguments) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
|
@ -30,12 +32,17 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
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.ICPPClassSpecialization;
|
||||
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.ICPPEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -51,7 +58,8 @@ public class EvalID extends CPPEvaluation {
|
|||
private final boolean fQualified;
|
||||
private final ICPPTemplateArgument[] fTemplateArgs;
|
||||
|
||||
public EvalID(ICPPEvaluation fieldOwner, IBinding nameOwner, char[] simpleID, boolean addressOf, boolean qualified, ICPPTemplateArgument[] templateArgs) {
|
||||
public EvalID(ICPPEvaluation fieldOwner, IBinding nameOwner, char[] simpleID, boolean addressOf,
|
||||
boolean qualified, ICPPTemplateArgument[] templateArgs) {
|
||||
fFieldOwner= fieldOwner;
|
||||
fName= simpleID;
|
||||
fNameOwner= nameOwner;
|
||||
|
@ -60,6 +68,9 @@ public class EvalID extends CPPEvaluation {
|
|||
fTemplateArgs= templateArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field owner expression, or {@code null}.
|
||||
*/
|
||||
public ICPPEvaluation getFieldOwner() {
|
||||
return fFieldOwner;
|
||||
}
|
||||
|
@ -80,6 +91,9 @@ public class EvalID extends CPPEvaluation {
|
|||
return fQualified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the template arguments, or {@code null} if there are no template arguments.
|
||||
*/
|
||||
public ICPPTemplateArgument[] getTemplateArgs() {
|
||||
return fTemplateArgs;
|
||||
}
|
||||
|
@ -111,7 +125,17 @@ public class EvalID extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
// Name lookup is not needed here because it was already done in the "instantiate" method.
|
||||
// IBinding nameOwner = fNameOwner;
|
||||
// if (nameOwner == null && fFieldOwner != null)
|
||||
// nameOwner = (IBinding) fFieldOwner.getTypeOrFunctionSet(point);
|
||||
//
|
||||
// if (nameOwner instanceof ICPPClassType) {
|
||||
// ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, fTemplateArgs, point);
|
||||
// if (eval != null)
|
||||
// return eval.getValue(point);
|
||||
// }
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,7 +158,10 @@ public class EvalID extends CPPEvaluation {
|
|||
buffer.putCharArray(fName);
|
||||
buffer.marshalBinding(fNameOwner);
|
||||
if (fTemplateArgs != null) {
|
||||
// mstodo marshall arguments
|
||||
buffer.putShort((short) fTemplateArgs.length);
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
buffer.marshalTemplateArgument(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +173,11 @@ public class EvalID extends CPPEvaluation {
|
|||
IBinding nameOwner= buffer.unmarshalBinding();
|
||||
ICPPTemplateArgument[] args= null;
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
|
||||
// mstodo marshall arguments
|
||||
int len= buffer.getShort();
|
||||
args = new ICPPTemplateArgument[len];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i]= buffer.unmarshalTemplateArgument();
|
||||
}
|
||||
}
|
||||
return new EvalID(fieldOwner, nameOwner, name, addressOf, qualified, args);
|
||||
}
|
||||
|
@ -242,4 +273,79 @@ public class EvalID extends CPPEvaluation {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTemplateArgument[] templateArgs = fTemplateArgs;
|
||||
if (templateArgs != null) {
|
||||
templateArgs = instantiateArguments(templateArgs, tpMap, packOffset, within, point);
|
||||
}
|
||||
|
||||
ICPPEvaluation fieldOwner = fFieldOwner;
|
||||
if (fieldOwner != null) {
|
||||
fieldOwner = fieldOwner.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
}
|
||||
|
||||
IBinding nameOwner = fNameOwner;
|
||||
if (nameOwner instanceof ICPPClassTemplate) {
|
||||
nameOwner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner),
|
||||
tpMap, packOffset, within, point);
|
||||
} else if (nameOwner instanceof IType) {
|
||||
IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point);
|
||||
if (type instanceof IBinding)
|
||||
nameOwner = (IBinding) type;
|
||||
}
|
||||
|
||||
if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)
|
||||
return this;
|
||||
|
||||
if (templateArgs == fTemplateArgs && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
|
||||
return this;
|
||||
|
||||
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, templateArgs, point);
|
||||
if (eval != null)
|
||||
return eval;
|
||||
|
||||
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
||||
}
|
||||
|
||||
private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs,
|
||||
IASTNode point) {
|
||||
LookupData data = new LookupData(fName, templateArgs, point);
|
||||
data.qualified = fQualified;
|
||||
try {
|
||||
CPPSemantics.lookup(data, nameOwner.getCompositeScope());
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
IBinding[] bindings = data.getFoundBindings();
|
||||
if (bindings.length > 1 && bindings[0] instanceof ICPPFunction) {
|
||||
ICPPFunction[] functions = new ICPPFunction[bindings.length];
|
||||
System.arraycopy(bindings, 0, functions, 0, bindings.length);
|
||||
return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf);
|
||||
}
|
||||
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
||||
if (binding instanceof IEnumerator) {
|
||||
return new EvalBinding(binding, null);
|
||||
} else if (binding instanceof ICPPMember) {
|
||||
return new EvalMemberAccess(nameOwner, ValueCategory.PRVALUE, binding, false);
|
||||
} else if (binding instanceof CPPFunctionSet) {
|
||||
return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fFieldOwner.determinePackSize(tpMap);
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fFieldOwner.referencesTemplateParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -16,6 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -71,7 +74,9 @@ public class EvalInitList extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Is this correct?
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,6 +99,43 @@ public class EvalInitList extends CPPEvaluation {
|
|||
for (int i = 0; i < args.length; i++) {
|
||||
args[i]= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
}
|
||||
return new EvalComma(args);
|
||||
return new EvalInitList(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] clauses = fClauses;
|
||||
for (int i = 0; i < fClauses.length; i++) {
|
||||
ICPPEvaluation clause = fClauses[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (clause != fClauses[i]) {
|
||||
if (clauses == fClauses) {
|
||||
clauses = new ICPPEvaluation[fClauses.length];
|
||||
System.arraycopy(fClauses, 0, clauses, 0, fClauses.length);
|
||||
}
|
||||
clauses[i] = clause;
|
||||
}
|
||||
}
|
||||
if (clauses == fClauses)
|
||||
return this;
|
||||
return new EvalInitList(clauses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPEvaluation arg : fClauses) {
|
||||
r = CPPTemplates.combinePackSize(r, arg.determinePackSize(tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
for (ICPPEvaluation clause : fClauses) {
|
||||
if (clause.referencesTemplateParameter())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -7,14 +7,21 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueTypeWithResolvedTypedefs;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -29,10 +36,12 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
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.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -245,7 +254,16 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (fMember instanceof IEnumerator) {
|
||||
return ((IEnumerator) fMember).getValue();
|
||||
}
|
||||
if (fMember instanceof IVariable) {
|
||||
return ((IVariable) fMember).getInitialValue();
|
||||
}
|
||||
if (fMember instanceof IFunction) {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,4 +319,28 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
IBinding member= buffer.unmarshalBinding();
|
||||
return new EvalMemberAccess(ownerType, ownerValueCat, member, isDeref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType ownerType = CPPTemplates.instantiateType(fOwnerType, tpMap, packOffset, within, point);
|
||||
if (ownerType == fOwnerType)
|
||||
return this;
|
||||
|
||||
IBinding member = fMember;
|
||||
if (ownerType instanceof ICPPClassSpecialization) {
|
||||
member = CPPTemplates.createSpecialization((ICPPClassSpecialization) ownerType, fMember, point);
|
||||
}
|
||||
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fOwnerType, tpMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -17,6 +18,9 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -70,7 +74,20 @@ public class EvalTypeId extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
if (fArguments == null)
|
||||
return Value.UNKNOWN;
|
||||
|
||||
if (isTypeDependent())
|
||||
return Value.create(this);
|
||||
if (fOutputType instanceof ICPPClassType) {
|
||||
// TODO(sprigogin): Simulate execution of a ctor call.
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
if (fArguments.length == 1)
|
||||
return fArguments[0].getValue(point);
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,4 +142,42 @@ public class EvalTypeId extends CPPEvaluation {
|
|||
}
|
||||
return new EvalTypeId(type, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (arg != fArguments[i]) {
|
||||
if (args == fArguments) {
|
||||
args = new ICPPEvaluation[fArguments.length];
|
||||
System.arraycopy(fArguments, 0, args, 0, fArguments.length);
|
||||
}
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
|
||||
if (args == fArguments && type == fInputType)
|
||||
return this;
|
||||
return new EvalTypeId(type, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = CPPTemplates.determinePackSize(fInputType, tpMap);
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
r = CPPTemplates.combinePackSize(r, arg.determinePackSize(tpMap));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
for (ICPPEvaluation arg : fArguments) {
|
||||
if (arg.referencesTemplateParameter())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,28 +7,48 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_alignOf;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_amper;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_minus;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_not;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_plus;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_postFixDecr;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_postFixIncr;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_prefixDecr;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_prefixIncr;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_sizeof;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_sizeofParameterPack;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_star;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_throw;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_tilde;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.op_typeid;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueTypeWithResolvedTypedefs;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
|
@ -90,7 +110,7 @@ public class EvalUnary extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public boolean isValueDependent() {
|
||||
switch(fOperator) {
|
||||
switch (fOperator) {
|
||||
case op_alignOf:
|
||||
case op_sizeof:
|
||||
case op_sizeofParameterPack:
|
||||
|
@ -124,7 +144,7 @@ public class EvalUnary extends CPPEvaluation {
|
|||
return null;
|
||||
|
||||
ICPPEvaluation[] args;
|
||||
if (fOperator == IASTUnaryExpression.op_postFixDecr || fOperator == IASTUnaryExpression.op_postFixIncr) {
|
||||
if (fOperator == op_postFixDecr || fOperator == op_postFixIncr) {
|
||||
args = new ICPPEvaluation[] { fArgument, ZERO_EVAL };
|
||||
} else {
|
||||
args = new ICPPEvaluation[] { fArgument };
|
||||
|
@ -185,7 +205,37 @@ public class EvalUnary extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
|
||||
if (getOverload(point) != null) {
|
||||
// TODO(sprigogin): Simulate execution of a function call.
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
switch (fOperator) {
|
||||
case op_sizeof: {
|
||||
SizeAndAlignment info = getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
|
||||
return info == null ? Value.UNKNOWN : Value.create(info.size);
|
||||
}
|
||||
case op_alignOf: {
|
||||
SizeAndAlignment info = getSizeAndAlignment(fArgument.getTypeOrFunctionSet(point), point);
|
||||
return info == null ? Value.UNKNOWN : Value.create(info.alignment);
|
||||
}
|
||||
case op_sizeofParameterPack:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_typeid:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_throw:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
}
|
||||
|
||||
IValue val = fArgument.getValue(point);
|
||||
Long num = val.numericalValue();
|
||||
if (num != null) {
|
||||
return Value.evaluateUnaryExpression(fOperator, num);
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -217,4 +267,23 @@ public class EvalUnary extends CPPEvaluation {
|
|||
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
|
||||
return new EvalUnary(op, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation argument = fArgument.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (argument == fArgument)
|
||||
return this;
|
||||
return new EvalUnary(fOperator, argument);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return fArgument.determinePackSize(tpMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fArgument.referencesTemplateParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,22 +7,46 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.*;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_alignof;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_nothrow_constructor;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_nothrow_copy;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_assign;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_constructor;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_copy;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_trivial_destructor;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_has_virtual_destructor;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_abstract;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_class;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_empty;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_enum;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_pod;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_polymorphic;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_union;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeid;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeof;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class EvalUnaryTypeID extends CPPEvaluation {
|
||||
|
@ -127,7 +151,52 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public IValue getValue(IASTNode point) {
|
||||
return Value.create(this, point);
|
||||
if (isValueDependent())
|
||||
return Value.create(this);
|
||||
|
||||
switch (fOperator) {
|
||||
case op_sizeof: {
|
||||
SizeAndAlignment info = getSizeAndAlignment(fOrigType, point);
|
||||
return info == null ? Value.UNKNOWN : Value.create(info.size);
|
||||
}
|
||||
case op_alignof: {
|
||||
SizeAndAlignment info = getSizeAndAlignment(fOrigType, point);
|
||||
return info == null ? Value.UNKNOWN : Value.create(info.alignment);
|
||||
}
|
||||
case op_typeid:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_nothrow_copy:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_nothrow_constructor:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_trivial_assign:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_trivial_constructor:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_trivial_copy:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_trivial_destructor:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_has_virtual_destructor:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_abstract:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_class:
|
||||
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() != ICompositeType.k_union);
|
||||
case op_is_empty:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_enum:
|
||||
return Value.create(fOrigType instanceof IEnumeration);
|
||||
case op_is_pod:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_polymorphic:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
case op_is_union:
|
||||
return Value.create(fOrigType instanceof ICompositeType && ((ICompositeType) fOrigType).getKey() == ICompositeType.k_union);
|
||||
case op_typeof:
|
||||
return Value.UNKNOWN; // TODO(sprigogin): Implement
|
||||
}
|
||||
return Value.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,7 +208,7 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
|
||||
buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID);
|
||||
buffer.putByte((byte) fOperator);
|
||||
buffer.marshalType(fType);
|
||||
buffer.marshalType(fOrigType);
|
||||
}
|
||||
|
||||
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
|
@ -147,4 +216,23 @@ public class EvalUnaryTypeID extends CPPEvaluation {
|
|||
IType arg= buffer.unmarshalType();
|
||||
return new EvalUnaryTypeID(op, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType type = CPPTemplates.instantiateType(fOrigType, tpMap, packOffset, within, point);
|
||||
if (type == fOrigType)
|
||||
return this;
|
||||
return new EvalUnaryTypeID(fOperator, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
return CPPTemplates.determinePackSize(fOrigType, tpMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,18 +40,21 @@ class FunctionCost {
|
|||
private final ICPPFunction fFunction;
|
||||
private final Cost[] fCosts;
|
||||
private final ValueCategory[] fValueCategories;
|
||||
private final IASTNode fPoint;
|
||||
private boolean fIsDirectCopyCtor;
|
||||
|
||||
public FunctionCost(ICPPFunction fn, int paramCount) {
|
||||
public FunctionCost(ICPPFunction fn, int paramCount, IASTNode point) {
|
||||
fFunction= fn;
|
||||
fCosts= new Cost[paramCount];
|
||||
fValueCategories= new ValueCategory[paramCount];
|
||||
fPoint = point;
|
||||
}
|
||||
|
||||
public FunctionCost(ICPPFunction fn, Cost cost) {
|
||||
public FunctionCost(ICPPFunction fn, Cost cost, IASTNode point) {
|
||||
fFunction= fn;
|
||||
fCosts= new Cost[] {cost};
|
||||
fValueCategories= null; // no udc will be performed
|
||||
fPoint = point;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
|
@ -127,9 +130,8 @@ class FunctionCost {
|
|||
|
||||
/**
|
||||
* Compares this function call cost to another one.
|
||||
* @param point
|
||||
*/
|
||||
public int compareTo(IASTTranslationUnit tu, FunctionCost other, IASTNode point) throws DOMException {
|
||||
public int compareTo(IASTTranslationUnit tu, FunctionCost other) throws DOMException {
|
||||
if (other == null)
|
||||
return -1;
|
||||
|
||||
|
@ -169,7 +171,7 @@ class FunctionCost {
|
|||
haveBetter = true;
|
||||
} else if (isTemplate && otherIsTemplate) {
|
||||
TypeSelection ts= SemanticUtil.isConversionOperator(f1) ? RETURN_TYPE : PARAMETERS;
|
||||
int order = CPPTemplates.orderFunctionTemplates(otherAsTemplate, asTemplate, ts, point);
|
||||
int order = CPPTemplates.orderFunctionTemplates(otherAsTemplate, asTemplate, ts, fPoint);
|
||||
if (order < 0) {
|
||||
haveBetter= true;
|
||||
} else if (order > 0) {
|
||||
|
@ -215,10 +217,10 @@ class FunctionCost {
|
|||
if (!parameterTypesMatch(ft1, ft2))
|
||||
return 0;
|
||||
|
||||
int diff= SemanticUtil.calculateInheritanceDepth(o2, o1);
|
||||
int diff= SemanticUtil.calculateInheritanceDepth(o2, o1, fPoint);
|
||||
if (diff >= 0)
|
||||
return diff;
|
||||
return -SemanticUtil.calculateInheritanceDepth(o1, o2);
|
||||
return -SemanticUtil.calculateInheritanceDepth(o1, o2, fPoint);
|
||||
}
|
||||
|
||||
private boolean parameterTypesMatch(final ICPPFunctionType ft1, final ICPPFunctionType ft2) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2012 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
|
||||
|
@ -62,7 +62,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
|
||||
|
@ -100,12 +101,12 @@ public class SemanticUtil {
|
|||
* @param clazz
|
||||
* @return an array of conversion operators.
|
||||
*/
|
||||
public static final ICPPMethod[] getDeclaredConversionOperators(ICPPClassType clazz) throws DOMException {
|
||||
public static final ICPPMethod[] getDeclaredConversionOperators(ICPPClassType clazz, IASTNode point) throws DOMException {
|
||||
ICPPMethod[] methods= ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
if (clazz instanceof ICPPDeferredClassInstance) {
|
||||
clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getTemplateDefinition();
|
||||
}
|
||||
ICPPMethod[] decs= clazz.getDeclaredMethods();
|
||||
ICPPMethod[] decs= ClassTypeHelper.getDeclaredMethods(clazz, point);
|
||||
if (decs != null) {
|
||||
for (ICPPMethod method : decs) {
|
||||
if (isConversionOperator(method)) {
|
||||
|
@ -123,11 +124,11 @@ public class SemanticUtil {
|
|||
* @param clazz
|
||||
* @return an array of conversion operators.
|
||||
*/
|
||||
public static ICPPMethod[] getConversionOperators(ICPPClassType clazz) throws DOMException {
|
||||
public static ICPPMethod[] getConversionOperators(ICPPClassType clazz, IASTNode point) throws DOMException {
|
||||
ICPPMethod[] methods= ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
ObjectSet<ICPPClassType> ancestry= inheritanceClosure(clazz);
|
||||
ObjectSet<ICPPClassType> ancestry= inheritanceClosure(clazz, point);
|
||||
for (int i = 0; i < ancestry.size(); i++) {
|
||||
methods= ArrayUtil.addAll(methods, getDeclaredConversionOperators(ancestry.keyAt(i)));
|
||||
methods= ArrayUtil.addAll(methods, getDeclaredConversionOperators(ancestry.keyAt(i), point));
|
||||
}
|
||||
return methods;
|
||||
}
|
||||
|
@ -137,7 +138,7 @@ public class SemanticUtil {
|
|||
* @return the root and all its ancestor classes
|
||||
* @throws DOMException
|
||||
*/
|
||||
public static ObjectSet<ICPPClassType> inheritanceClosure(ICPPClassType root) throws DOMException {
|
||||
public static ObjectSet<ICPPClassType> inheritanceClosure(ICPPClassType root, IASTNode point) throws DOMException {
|
||||
ObjectSet<ICPPClassType> done= new ObjectSet<ICPPClassType>(2);
|
||||
ObjectSet<ICPPClassType> current= new ObjectSet<ICPPClassType>(2);
|
||||
current.put(root);
|
||||
|
@ -148,8 +149,8 @@ public class SemanticUtil {
|
|||
for (int i = 0; i < current.size(); i++) {
|
||||
ICPPClassType clazz= current.keyAt(i);
|
||||
done.put(clazz);
|
||||
|
||||
for (ICPPBase base : clazz.getBases()) {
|
||||
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(clazz, point)) {
|
||||
IBinding binding= base.getBaseClass();
|
||||
if (binding instanceof ICPPClassType && !(binding instanceof IProblemBinding)) {
|
||||
ICPPClassType ct= (ICPPClassType) binding;
|
||||
|
@ -165,7 +166,7 @@ public class SemanticUtil {
|
|||
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param method
|
||||
* @return true if the specified method is a conversion operator
|
||||
|
@ -511,7 +512,7 @@ public class SemanticUtil {
|
|||
final IType type= arg.getTypeValue();
|
||||
final IType newType= getSimplifiedType(type);
|
||||
if (newType != type) {
|
||||
return new CPPTemplateArgument(newType);
|
||||
return new CPPTemplateTypeArgument(newType);
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
|
@ -622,11 +623,11 @@ public class SemanticUtil {
|
|||
* @return the number of edges in the inheritance graph, or -1 if the specified classes have
|
||||
* no inheritance relation
|
||||
*/
|
||||
public static final int calculateInheritanceDepth(IType type, IType baseClass) {
|
||||
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), type, baseClass);
|
||||
public static final int calculateInheritanceDepth(IType type, IType baseClass, IASTNode point) {
|
||||
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), type, baseClass, point);
|
||||
}
|
||||
|
||||
private static final int calculateInheritanceDepth(int maxdepth, Set<Object> hashSet, IType type, IType baseClass) {
|
||||
private static final int calculateInheritanceDepth(int maxdepth, Set<Object> hashSet, IType type, IType baseClass, IASTNode point) {
|
||||
if (type == baseClass || type.isSameType(baseClass)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -637,7 +638,7 @@ public class SemanticUtil {
|
|||
clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getSpecializedBinding();
|
||||
}
|
||||
|
||||
for (ICPPBase cppBase : clazz.getBases()) {
|
||||
for (ICPPBase cppBase : ClassTypeHelper.getBases(clazz, point)) {
|
||||
IBinding base= cppBase.getBaseClass();
|
||||
if (base instanceof IType && hashSet.add(base)) {
|
||||
IType tbase= (IType) base;
|
||||
|
@ -648,7 +649,7 @@ public class SemanticUtil {
|
|||
}
|
||||
|
||||
if (tbase instanceof ICPPClassType) {
|
||||
int n= calculateInheritanceDepth(maxdepth - 1, hashSet, tbase, baseClass);
|
||||
int n= calculateInheritanceDepth(maxdepth - 1, hashSet, tbase, baseClass, point);
|
||||
if (n > 0)
|
||||
return n + 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2012 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -60,8 +61,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
||||
|
@ -70,9 +73,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
|||
*/
|
||||
public class TemplateArgumentDeduction {
|
||||
/**
|
||||
* Deduce arguments for a template function from the template id + the template function parameters.
|
||||
* Deduce arguments for a template function from the template id and the template function
|
||||
* parameters.
|
||||
* 14.8.2.1
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
|
||||
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue,
|
||||
|
@ -235,7 +238,7 @@ public class TemplateArgumentDeduction {
|
|||
ICPPTemplateInstance pInst = (ICPPTemplateInstance) pcheck;
|
||||
ICPPClassTemplate pTemplate= getPrimaryTemplate(pInst);
|
||||
if (pTemplate != null) {
|
||||
ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate);
|
||||
ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate, point);
|
||||
if (aInst != null && aInst != argcheck) {
|
||||
par= pcheck;
|
||||
arg= aInst;
|
||||
|
@ -290,7 +293,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduce arguments for a user defined conversion template
|
||||
* 14.8.2.3
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForConversion(ICPPFunctionTemplate template,
|
||||
IType conversionType, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
||||
|
@ -325,7 +327,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduce arguments for a function declaration
|
||||
* 14.8.2.6
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForDeclaration(ICPPFunctionTemplate template,
|
||||
ICPPTemplateArgument[] args, ICPPFunctionType ftype, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
||||
|
@ -360,7 +361,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduces the mapping for the template parameters from the function parameters,
|
||||
* returns <code>false</code> if there is no mapping.
|
||||
* @param point
|
||||
*/
|
||||
static int deduceForPartialOrdering(ICPPTemplateParameter[] tmplPars, IType[] fnPars, IType[] fnArgs, IASTNode point) {
|
||||
try {
|
||||
|
@ -423,7 +423,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Adds the explicit arguments to the map.
|
||||
* @param point
|
||||
*/
|
||||
private static boolean addExplicitArguments(final ICPPTemplateParameter[] tmplParams,
|
||||
ICPPTemplateArgument[] tmplArgs, CPPTemplateParameterMap map, IASTNode point) {
|
||||
|
@ -481,13 +480,14 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
|
||||
/**
|
||||
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A.
|
||||
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of
|
||||
* the deduced A.
|
||||
*/
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate) throws DOMException {
|
||||
return findBaseInstance(a, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>());
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, IASTNode point) throws DOMException {
|
||||
return findBaseInstance(a, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), point);
|
||||
}
|
||||
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth, HashSet<Object> handled) throws DOMException {
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth, HashSet<Object> handled, IASTNode point) throws DOMException {
|
||||
if (a instanceof ICPPTemplateInstance) {
|
||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance) a;
|
||||
ICPPClassTemplate tmpl= getPrimaryTemplate(inst);
|
||||
|
@ -495,10 +495,10 @@ public class TemplateArgumentDeduction {
|
|||
return a;
|
||||
}
|
||||
if (maxdepth-- > 0) {
|
||||
for (ICPPBase cppBase : a.getBases()) {
|
||||
for (ICPPBase cppBase : ClassTypeHelper.getBases(a, point)) {
|
||||
IBinding base= cppBase.getBaseClass();
|
||||
if (base instanceof ICPPClassType && handled.add(base)) {
|
||||
final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth, handled);
|
||||
final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth, handled, point);
|
||||
if (inst != null)
|
||||
return inst;
|
||||
}
|
||||
|
@ -546,7 +546,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Deduces the template parameter mapping from pairs of template arguments.
|
||||
* @param point
|
||||
*/
|
||||
public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars,
|
||||
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
||||
|
@ -639,7 +638,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Deduces the template parameter mapping from one pair of template arguments.
|
||||
* @param point
|
||||
*/
|
||||
private boolean fromTemplateArgument(ICPPTemplateArgument p, ICPPTemplateArgument a, IASTNode point) throws DOMException {
|
||||
if (p.isNonTypeValue() != a.isNonTypeValue())
|
||||
|
@ -723,7 +721,7 @@ public class TemplateArgumentDeduction {
|
|||
if (parID >= 0) {
|
||||
ICPPTemplateArgument old= fDeducedArgs.getArgument(parID, fPackOffset);
|
||||
if (old == null) {
|
||||
if (!deduce(parID, new CPPTemplateArgument(as, new CPPBasicType(ICPPBasicType.Kind.eInt, 0)))) {
|
||||
if (!deduce(parID, new CPPTemplateNonTypeArgument(as, new CPPBasicType(ICPPBasicType.Kind.eInt, 0)))) {
|
||||
return false;
|
||||
}
|
||||
} else if (!as.equals(old.getNonTypeValue())) {
|
||||
|
@ -764,7 +762,7 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
if (a == null)
|
||||
return false;
|
||||
return deduce(((ICPPTemplateParameter)p).getParameterID(), new CPPTemplateArgument(a));
|
||||
return deduce(((ICPPTemplateParameter)p).getParameterID(), new CPPTemplateTypeArgument(a));
|
||||
} else if (p instanceof ICPPTemplateInstance) {
|
||||
if (!(a instanceof ICPPTemplateInstance))
|
||||
return false;
|
||||
|
@ -792,7 +790,7 @@ public class TemplateArgumentDeduction {
|
|||
if (current != null) {
|
||||
if (current.isNonTypeValue() || !current.getTypeValue().isSameType(aTemplate))
|
||||
return false;
|
||||
} else if (!deduce(tparId, new CPPTemplateArgument(aTemplate))) {
|
||||
} else if (!deduce(tparId, new CPPTemplateTypeArgument(aTemplate))) {
|
||||
return false;
|
||||
}
|
||||
} else if (!aTemplate.isSameType(pTemplate)) {
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -18,5 +17,4 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
* @since 4.0
|
||||
*/
|
||||
public interface IIndexType extends IType {
|
||||
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
throw new CompositingNotImplementedError();
|
||||
}
|
||||
|
||||
private ICPPEvaluation getCompositeEvaluation(ICPPEvaluation eval) {
|
||||
public ICPPEvaluation getCompositeEvaluation(ICPPEvaluation eval) {
|
||||
if (eval == null)
|
||||
return null;
|
||||
if (eval instanceof EvalBinary) {
|
||||
|
@ -425,16 +425,13 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
public IValue getCompositeValue(IValue v) {
|
||||
if (v == null)
|
||||
return null;
|
||||
|
||||
IBinding[] b= v.getUnknownBindings();
|
||||
if (b.length == 0)
|
||||
|
||||
ICPPEvaluation eval = v.getEvaluation();
|
||||
if (eval == null)
|
||||
return v;
|
||||
|
||||
ICPPUnknownBinding[] b2= new ICPPUnknownBinding[b.length];
|
||||
for (int i = 0; i < b2.length; i++) {
|
||||
b2[i]= (ICPPUnknownBinding) getCompositeBinding((IIndexFragmentBinding) b[i]);
|
||||
}
|
||||
return Value.fromInternalRepresentation(v.getInternalExpression(), b2);
|
||||
|
||||
eval = getCompositeEvaluation(eval);
|
||||
return Value.fromInternalRepresentation(eval);
|
||||
}
|
||||
|
||||
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -43,8 +43,8 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
|
|||
public ICPPMethod[] getImplicitMethods() {
|
||||
ICPPClassScope rscope = (ICPPClassScope) ((ICPPClassType)rbinding).getCompositeScope();
|
||||
ICPPMethod[] result = rscope.getImplicitMethods();
|
||||
for(int i=0; i<result.length; i++) {
|
||||
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -53,15 +53,15 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
|
|||
public ICPPConstructor[] getConstructors() {
|
||||
ICPPClassScope rscope = (ICPPClassScope) ((ICPPClassType)rbinding).getCompositeScope();
|
||||
ICPPConstructor[] result = rscope.getConstructors();
|
||||
for(int i=0; i<result.length; i++) {
|
||||
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
IBinding binding = ((ICPPClassType)rbinding).getCompositeScope().getBinding(name, resolve, fileSet);
|
||||
IBinding binding = ((ICPPClassType) rbinding).getCompositeScope().getBinding(name, resolve, fileSet);
|
||||
return processUncertainBinding(binding);
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,13 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
|
|||
|
||||
@Override
|
||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||
IBinding[] bindings = ((ICPPClassType)rbinding).getCompositeScope().getBindings(lookup);
|
||||
IBinding[] bindings = ((ICPPClassType) rbinding).getCompositeScope().getBindings(lookup);
|
||||
return processUncertainBindings(bindings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] find(String name) {
|
||||
IBinding[] preresult = ((ICPPClassType)rbinding).getCompositeScope().find(name);
|
||||
IBinding[] preresult = ((ICPPClassType) rbinding).getCompositeScope().find(name);
|
||||
return processUncertainBindings(preresult);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2012 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)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
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.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -29,6 +32,7 @@ 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.cpp.CPPClassSpecialization.RecursionResolvingBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
|
@ -37,11 +41,9 @@ import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPClassSpecialization extends CompositeCPPClassType implements ICPPClassSpecialization {
|
||||
|
||||
private ObjectMap specializationMap= null;
|
||||
private ObjectMap specializationMap;
|
||||
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
|
||||
|
||||
|
||||
public CompositeCPPClassSpecialization(ICompositesFactory cf, ICPPClassType rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
@ -80,11 +82,11 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
specializationMap= (ObjectMap) cached;
|
||||
} else {
|
||||
final ObjectMap newMap= new ObjectMap(2);
|
||||
// in any fragment explicit specializations may be defined.
|
||||
// In any fragment explicit specializations may be defined.
|
||||
IIndexFragmentBinding[] frags= cf.findEquivalentBindings(rbinding);
|
||||
for (IIndexFragmentBinding fb : frags) {
|
||||
if (fb instanceof ICPPClassType) {
|
||||
final ICPPClassType[] nested = ((ICPPClassType)fb).getNestedClasses();
|
||||
final ICPPClassType[] nested = ClassTypeHelper.getNestedClasses((ICPPClassType) fb, point);
|
||||
if (nested.length > 0) {
|
||||
for (ICPPClassType ct : nested) {
|
||||
if (ct instanceof ICPPClassSpecialization &&
|
||||
|
@ -130,56 +132,131 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
|
||||
@Override
|
||||
public final ICPPBase[] getBases() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPBase[] getBases(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getBases();
|
||||
return ((ICPPClassSpecializationScope) scope).getBases(point);
|
||||
}
|
||||
return super.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases((ICPPClassType) rbinding, point);
|
||||
return wrapBases(bases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPConstructor[] getConstructors() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getConstructors();
|
||||
return ((ICPPClassSpecializationScope) scope).getConstructors(point);
|
||||
}
|
||||
return super.getConstructors();
|
||||
ICPPConstructor[] result = ClassTypeHelper.getConstructors((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getDeclaredMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods();
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods(point);
|
||||
}
|
||||
return super.getDeclaredMethods();
|
||||
ICPPMethod[] result = ClassTypeHelper.getDeclaredMethods((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPField[] getDeclaredFields() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields();
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields(point);
|
||||
}
|
||||
return super.getDeclaredFields();
|
||||
ICPPField[] result = ClassTypeHelper.getDeclaredFields((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBinding[] getFriends() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBinding[] getFriends(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getFriends();
|
||||
return ((ICPPClassSpecializationScope) scope).getFriends(point);
|
||||
}
|
||||
return super.getFriends();
|
||||
IBinding[] result = ClassTypeHelper.getFriends((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPClassType[] getNestedClasses() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses();
|
||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses(point);
|
||||
}
|
||||
return super.getNestedClasses();
|
||||
ICPPClassType[] result = ClassTypeHelper.getNestedClasses((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,11 +8,14 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
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.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
|
@ -67,8 +70,14 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getImplicitMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getImplicitMethods();
|
||||
return fDelegate.getImplicitMethods(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,37 +106,43 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
createDelegate();
|
||||
return fDelegate.getConstructors();
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getDeclaredMethods();
|
||||
return fDelegate.getConstructors(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
public ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getBases();
|
||||
return fDelegate.getDeclaredMethods(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
public ICPPBase[] getBases(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getDeclaredFields();
|
||||
return fDelegate.getBases(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
public ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getFriends();
|
||||
return fDelegate.getDeclaredFields(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
public IBinding[] getFriends(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getNestedClasses();
|
||||
return fDelegate.getFriends(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
createDelegate();
|
||||
return fDelegate.getNestedClasses(point);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2012 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)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
@ -42,8 +45,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
private class CPPBaseDelegate implements ICPPBase {
|
||||
|
@ -65,7 +68,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
if (baseClass != null) {
|
||||
return baseClass;
|
||||
} else {
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding)base.getBaseClass());
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding) base.getBaseClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,68 +104,48 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
final ICPPBase[] preresult = ((ICPPClassType) rbinding).getBases();
|
||||
ICPPBase[] result = new ICPPBase[preresult.length];
|
||||
for (int i= 0; i < preresult.length; i++) {
|
||||
result[i] = new CPPBaseDelegate(preresult[i]);
|
||||
}
|
||||
return result;
|
||||
ICPPBase[] bases = ((ICPPClassType) rbinding).getBases();
|
||||
return wrapBases(bases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
ICPPConstructor[] result = ((ICPPClassType) rbinding).getConstructors();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
ICPPField[] result = ((ICPPClassType) rbinding).getDeclaredFields();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
ICPPMethod[] result = ((ICPPClassType) rbinding).getDeclaredMethods();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
IBinding[] preResult = ((ICPPClassType) rbinding).getFriends();
|
||||
IBinding[] result = new IBinding[preResult.length];
|
||||
for (int i= 0; i < preResult.length; i++) {
|
||||
result[i] = cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(preResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +167,21 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
public boolean isAnonymous() {
|
||||
return ((ICPPClassType) rbinding).isAnonymous();
|
||||
}
|
||||
|
||||
protected ICPPBase[] wrapBases(final ICPPBase[] bases) {
|
||||
ICPPBase[] result = new ICPPBase[bases.length];
|
||||
for (int i= 0; i < bases.length; i++) {
|
||||
result[i] = new CPPBaseDelegate(bases[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends IBinding> T[] wrapBindings(T[] bindings) {
|
||||
T[] result = Arrays.copyOf(bindings, bindings.length);
|
||||
for (int i= 0; i < bindings.length; i++) {
|
||||
result[i] = (T) cf.getCompositeBinding((IIndexFragmentBinding) bindings[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2011 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2012 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
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -16,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
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.IValue;
|
||||
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.ICPPTemplateArgument;
|
||||
|
@ -26,15 +26,18 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
/**
|
||||
* For implementation re-use in the absence of multiple inheritance
|
||||
* For implementation re-use in the absence of multiple inheritance.
|
||||
*/
|
||||
public class TemplateInstanceUtil {
|
||||
|
||||
public static ICPPTemplateParameterMap getTemplateParameterMap(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
ICPPTemplateParameterMap preresult= rbinding.getTemplateParameterMap();
|
||||
Integer[] keys= preresult.getAllParameterPositions();
|
||||
|
@ -50,8 +53,8 @@ public class TemplateInstanceUtil {
|
|||
result.put(key, convert(cf, pack));
|
||||
}
|
||||
}
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -90,22 +93,18 @@ public class TemplateInstanceUtil {
|
|||
}
|
||||
|
||||
static ICPPTemplateArgument convert(ICompositesFactory cf, ICPPTemplateArgument arg) throws DOMException {
|
||||
if (arg == null)
|
||||
return null;
|
||||
if (arg.isNonTypeValue()) {
|
||||
final IType t= arg.getTypeOfNonTypeValue();
|
||||
final IType t2= cf.getCompositeType(t);
|
||||
final IValue v= arg.getNonTypeValue();
|
||||
final IValue v2= cf.getCompositeValue(v);
|
||||
if (t != t2 || v != v2) {
|
||||
return new CPPTemplateArgument(v2, t2);
|
||||
if (arg instanceof CPPTemplateTypeArgument) {
|
||||
final IType typeValue = arg.getTypeValue();
|
||||
IType t= cf.getCompositeType(typeValue);
|
||||
if (t != typeValue) {
|
||||
return new CPPTemplateTypeArgument(t);
|
||||
}
|
||||
} else if (arg instanceof CPPTemplateNonTypeArgument) {
|
||||
ICPPEvaluation eval = ((CPPTemplateNonTypeArgument) arg).getEvaluation();
|
||||
ICPPEvaluation eval2 = ((CPPCompositesFactory) cf).getCompositeEvaluation(eval);
|
||||
if (eval2 != eval) {
|
||||
return new CPPTemplateNonTypeArgument(eval2);
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
final IType typeValue = arg.getTypeValue();
|
||||
IType t= cf.getCompositeType(typeValue);
|
||||
if (t != typeValue) {
|
||||
return new CPPTemplateArgument(t);
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
@ -113,8 +112,8 @@ public class TemplateInstanceUtil {
|
|||
@Deprecated
|
||||
public static ObjectMap getArgumentMap(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
ICPPSpecialization specn= (ICPPSpecialization) rbinding;
|
||||
IBinding specd= ((CPPCompositesFactory)cf).findOneBinding(specn.getSpecializedBinding());
|
||||
if(specd == null)
|
||||
IBinding specd= ((CPPCompositesFactory) cf).findOneBinding(specn.getSpecializedBinding());
|
||||
if (specd == null)
|
||||
specd= specn.getSpecializedBinding();
|
||||
|
||||
ObjectMap preresult= specn.getArgumentMap();
|
||||
|
@ -122,14 +121,13 @@ public class TemplateInstanceUtil {
|
|||
Object[] keys= preresult.keyArray();
|
||||
Object[] keysToAdapt= keys;
|
||||
|
||||
if(specd instanceof ICPPTemplateDefinition) {
|
||||
keysToAdapt= ((ICPPTemplateDefinition)specd).getTemplateParameters();
|
||||
if (specd instanceof ICPPTemplateDefinition) {
|
||||
keysToAdapt= ((ICPPTemplateDefinition) specd).getTemplateParameters();
|
||||
}
|
||||
for(int i = 0; i < keys.length && i < keysToAdapt.length; i++) {
|
||||
for (int i= 0; i < keys.length && i < keysToAdapt.length; i++) {
|
||||
IType type= (IType) preresult.get(keys[i]);
|
||||
result.put(
|
||||
cf.getCompositeBinding((IIndexFragmentBinding)keysToAdapt[i]),
|
||||
cf.getCompositeType(type));
|
||||
cf.getCompositeBinding((IIndexFragmentBinding) keysToAdapt[i]), cf.getCompositeType(type));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -144,15 +142,15 @@ public class TemplateInstanceUtil {
|
|||
public static IType[] getArguments(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization rbinding) {
|
||||
try {
|
||||
return getArguments(cf, rbinding.getArguments());
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static IType[] getArguments(ICompositesFactory cf, IType[] result) {
|
||||
for(int i=0; i<result.length; i++) {
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = cf.getCompositeType(result[i]);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2012 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.db;
|
||||
|
||||
|
@ -16,11 +17,15 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -93,7 +98,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
|
||||
byte firstByte= fBuffer[fPos];
|
||||
if (firstByte == BINDING_TYPE) {
|
||||
fPos+= 2;
|
||||
fPos += 2;
|
||||
long rec= getRecordPointer();
|
||||
return (IBinding) fLinkage.getNode(rec);
|
||||
} else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) {
|
||||
|
@ -182,6 +187,27 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
return Value.unmarshal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
|
||||
if (arg instanceof CPPTemplateNonTypeArgument) {
|
||||
putByte(VALUE);
|
||||
((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true);
|
||||
} else {
|
||||
marshalType(arg.getTypeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
|
||||
int firstByte= getByte();
|
||||
if (firstByte == VALUE) {
|
||||
return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation());
|
||||
} else {
|
||||
fPos--;
|
||||
return new CPPTemplateTypeArgument(unmarshalType());
|
||||
}
|
||||
}
|
||||
|
||||
private void request(int i) {
|
||||
if (fBuffer == null) {
|
||||
if (i <= Database.TYPE_SIZE) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -15,7 +15,8 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -36,17 +37,18 @@ public class PDOMCPPArgumentList {
|
|||
public static long putArguments(PDOMNode parent, ICPPTemplateArgument[] templateArguments) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getDB();
|
||||
final short len= (short) Math.min(templateArguments.length, (Database.MAX_MALLOC_SIZE-2)/NODE_SIZE);
|
||||
final long block= db.malloc(2+NODE_SIZE*len);
|
||||
final short len= (short) Math.min(templateArguments.length, (Database.MAX_MALLOC_SIZE - 2) / NODE_SIZE);
|
||||
final long block= db.malloc(2 + NODE_SIZE * len);
|
||||
long p= block;
|
||||
|
||||
db.putShort(p, len); p+=2;
|
||||
for (int i=0; i<len; i++, p+=NODE_SIZE) {
|
||||
db.putShort(p, len);
|
||||
p += 2;
|
||||
for (int i= 0; i < len; i++, p += NODE_SIZE) {
|
||||
final ICPPTemplateArgument arg = templateArguments[i];
|
||||
final boolean isNonType= arg.isNonTypeValue();
|
||||
if (isNonType) {
|
||||
linkage.storeType(p, arg.getTypeOfNonTypeValue());
|
||||
linkage.storeValue(p+VALUE_OFFSET, arg.getNonTypeValue());
|
||||
linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue());
|
||||
} else {
|
||||
linkage.storeType(p, arg.getTypeValue());
|
||||
}
|
||||
|
@ -54,7 +56,6 @@ public class PDOMCPPArgumentList {
|
|||
return block;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restores an array of template arguments from the database.
|
||||
*/
|
||||
|
@ -63,11 +64,11 @@ public class PDOMCPPArgumentList {
|
|||
final Database db= linkage.getDB();
|
||||
final short len= db.getShort(record);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/NODE_SIZE);
|
||||
long p= record+2;
|
||||
for (int i=0; i<len; i++) {
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE - 2) / NODE_SIZE);
|
||||
long p= record + 2;
|
||||
for (int i= 0; i < len; i++) {
|
||||
linkage.storeType(p, null);
|
||||
linkage.storeValue(p+VALUE_OFFSET, null);
|
||||
linkage.storeValue(p + VALUE_OFFSET, null);
|
||||
p+= NODE_SIZE;
|
||||
}
|
||||
db.free(record);
|
||||
|
@ -81,25 +82,25 @@ public class PDOMCPPArgumentList {
|
|||
final Database db= linkage.getDB();
|
||||
final short len= db.getShort(rec);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/NODE_SIZE);
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE - 2) / NODE_SIZE);
|
||||
if (len == 0) {
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
|
||||
rec+=2;
|
||||
rec += 2;
|
||||
ICPPTemplateArgument[] result= new ICPPTemplateArgument[len];
|
||||
for (int i=0; i<len; i++) {
|
||||
for (int i= 0; i < len; i++) {
|
||||
IType type= linkage.loadType(rec);
|
||||
if (type == null) {
|
||||
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
IValue val= linkage.loadValue(rec+VALUE_OFFSET);
|
||||
IValue val= linkage.loadValue(rec + VALUE_OFFSET);
|
||||
if (val != null) {
|
||||
result[i]= new CPPTemplateArgument(val, type);
|
||||
result[i]= new CPPTemplateNonTypeArgument(val, type);
|
||||
} else {
|
||||
result[i]= new CPPTemplateArgument(type);
|
||||
result[i]= new CPPTemplateTypeArgument(type);
|
||||
}
|
||||
rec+= NODE_SIZE;
|
||||
rec += NODE_SIZE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2011 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2012 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -54,18 +55,17 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||
ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType {
|
||||
private static final int FIRST_BASE = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int MEMBER_LIST = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
|
||||
private static final int FIRSTBASE = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPClassSpecialization record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
|
||||
|
||||
|
||||
private volatile ICPPClassScope fScope;
|
||||
private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache
|
||||
private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache
|
||||
private final ThreadLocal<Set<IBinding>> fInProgress= new ThreadLocal<Set<IBinding>>();
|
||||
|
||||
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
|
||||
|
@ -76,7 +76,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
public PDOMCPPClassSpecialization(PDOMLinkage linkage, long bindingRecord) {
|
||||
super(linkage, bindingRecord);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
|
@ -91,14 +91,14 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
public ICPPClassType getSpecializedBinding() {
|
||||
return (ICPPClassType) super.getSpecializedBinding();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBinding specializeMember(IBinding original) {
|
||||
return specializeMember(original, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding specializeMember(IBinding original, IASTNode point) {
|
||||
public IBinding specializeMember(IBinding original, IASTNode point) {
|
||||
if (specializationMap == null) {
|
||||
final Long key= record+PDOMCPPLinkage.CACHE_INSTANCE_SCOPE;
|
||||
Object cached= getPDOM().getCachedResult(key);
|
||||
|
@ -124,14 +124,14 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
Set<IBinding> set;
|
||||
synchronized (specializationMap) {
|
||||
IBinding result= (IBinding) specializationMap.get(original);
|
||||
if (result != null)
|
||||
if (result != null)
|
||||
return result;
|
||||
set= fInProgress.get();
|
||||
if (set == null) {
|
||||
set= new HashSet<IBinding>();
|
||||
fInProgress.set(set);
|
||||
}
|
||||
if (!set.add(original))
|
||||
}
|
||||
if (!set.add(original))
|
||||
return new RecursionResolvingBinding(null, null);
|
||||
}
|
||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
||||
|
@ -154,7 +154,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
if (hasOwnScope()) {
|
||||
fScope= new PDOMCPPClassScope(this);
|
||||
return fScope;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
fScope= new PDOMCPPClassSpecializationScope(this);
|
||||
|
@ -167,22 +167,22 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
}
|
||||
|
||||
public PDOMCPPBase getFirstBase() throws CoreException {
|
||||
long rec = getDB().getRecPtr(record + FIRSTBASE);
|
||||
long rec = getDB().getRecPtr(record + FIRST_BASE);
|
||||
return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null;
|
||||
}
|
||||
|
||||
private void setFirstBase(PDOMCPPBase base) throws CoreException {
|
||||
long rec = base != null ? base.getRecord() : 0;
|
||||
getDB().putRecPtr(record + FIRSTBASE, rec);
|
||||
getDB().putRecPtr(record + FIRST_BASE, rec);
|
||||
}
|
||||
|
||||
|
||||
public void addBase(PDOMCPPBase base) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
PDOMCPPBase firstBase = getFirstBase();
|
||||
base.setNextBase(firstBase);
|
||||
setFirstBase(base);
|
||||
}
|
||||
|
||||
|
||||
public void removeBase(PDOMName pdomName) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
PDOMCPPBase base= getFirstBase();
|
||||
|
@ -205,25 +205,31 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
base.delete();
|
||||
}
|
||||
}
|
||||
|
||||
// implementation of class type
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getBases();
|
||||
}
|
||||
|
||||
// this is an explicit specialization
|
||||
return ((ICPPClassSpecializationScope) scope).getBases(point);
|
||||
}
|
||||
|
||||
// This is an explicit specialization
|
||||
Long key= record + PDOMCPPLinkage.CACHE_BASES;
|
||||
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);
|
||||
if (bases != null)
|
||||
if (bases != null)
|
||||
return bases;
|
||||
|
||||
try {
|
||||
List<PDOMCPPBase> list = new ArrayList<PDOMCPPBase>();
|
||||
for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase())
|
||||
for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase()) {
|
||||
list.add(base);
|
||||
}
|
||||
Collections.reverse(list);
|
||||
bases = list.toArray(new ICPPBase[list.size()]);
|
||||
getPDOM().putCachedResult(key, bases);
|
||||
|
@ -233,12 +239,18 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
}
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getConstructors();
|
||||
return ((ICPPClassSpecializationScope) scope).getConstructors(point);
|
||||
}
|
||||
try {
|
||||
PDOMClassUtil.ConstructorCollector visitor= new PDOMClassUtil.ConstructorCollector();
|
||||
|
@ -252,9 +264,15 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods();
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods(point);
|
||||
}
|
||||
try {
|
||||
PDOMClassUtil.MethodCollector methods = new PDOMClassUtil.MethodCollector(false);
|
||||
|
@ -268,10 +286,16 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields();
|
||||
}
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields(point);
|
||||
}
|
||||
try {
|
||||
PDOMClassUtil.FieldCollector visitor = new PDOMClassUtil.FieldCollector();
|
||||
PDOMCPPClassScope.acceptViaCache(this, visitor, false);
|
||||
|
@ -281,13 +305,19 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
IScope scope= getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses();
|
||||
}
|
||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses(point);
|
||||
}
|
||||
try {
|
||||
PDOMClassUtil.NestedClassCollector visitor = new PDOMClassUtil.NestedClassCollector();
|
||||
PDOMCPPClassScope.acceptViaCache(this, visitor, false);
|
||||
|
@ -300,25 +330,49 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
// not yet supported.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends(IASTNode point) {
|
||||
// Not yet supported.
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
public ICPPMethod[] getMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField findField(String name) {
|
||||
return ClassTypeHelper.findField(this, name);
|
||||
|
@ -350,7 +404,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
return CPPClassSpecialization.isSameClassSpecialization(this, (ICPPClassSpecialization) type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
|
@ -362,13 +416,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBER_LIST);
|
||||
list.addMember(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptUncached(IPDOMVisitor visitor) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBER_LIST);
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
|
@ -376,7 +430,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
PDOMCPPClassScope.acceptViaCache(this, visitor, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
|
|
|
@ -158,7 +158,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IASTNode point= null; // Instantiation of dependent expressions may not work.
|
||||
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
|
||||
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
|
||||
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
|
||||
|
|
|
@ -351,17 +351,17 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
|
@ -63,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
|
@ -77,6 +82,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
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.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
|
@ -114,11 +120,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Container for c++-entities.
|
||||
*/
|
||||
|
@ -252,7 +253,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
||||
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding);
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +300,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (pdomBinding != null) {
|
||||
getPDOM().putCachedResult(inputBinding, pdomBinding);
|
||||
if (inputBinding instanceof CPPClosureType) {
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding);
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
|
@ -490,17 +491,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
|
||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding, IASTNode point) throws CoreException {
|
||||
try {
|
||||
final long fileLocalRec= type.getLocalToFileRec();
|
||||
IScope scope = binding.getCompositeScope();
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
List<ICPPMethod> old= new ArrayList<ICPPMethod>();
|
||||
if (type instanceof ICPPClassType) {
|
||||
IScope oldScope = ((ICPPClassType)type).getCompositeScope();
|
||||
if (oldScope instanceof ICPPClassScope) {
|
||||
old.addAll(Arrays.asList(((ICPPClassScope) oldScope).getImplicitMethods()));
|
||||
}
|
||||
ArrayUtil.addAll(old, ClassTypeHelper.getImplicitMethods((ICPPClassType) type, point));
|
||||
}
|
||||
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
||||
for (ICPPMethod method : implicit) {
|
||||
|
@ -1109,5 +1107,4 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an evaluation, first byte=" + firstByte)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue