mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
0f13c1b8f1
commit
372f3ef066
34 changed files with 498 additions and 536 deletions
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bnicolle
|
* @author bnicolle
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class IStructureTests extends IntegratedCModelTest {
|
public class IStructureTests extends IntegratedCModelTest {
|
||||||
/**
|
/**
|
||||||
|
@ -56,29 +55,29 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
* containing all its public members named "test*"
|
* containing all its public members named "test*"
|
||||||
*/
|
*/
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite( IStructureTests.class.getName() );
|
TestSuite suite= new TestSuite(IStructureTests.class.getName());
|
||||||
|
|
||||||
// TODO check C-only behaviour using C_NATURE vs CC_NATURE
|
// TODO check C-only behaviour using C_NATURE vs CC_NATURE
|
||||||
|
|
||||||
// Interface tests:
|
// Interface tests:
|
||||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
|
suite.addTest(new IStructureTests("testGetChildrenOfTypeStruct"));
|
||||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
suite.addTest(new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testGetFields"));
|
suite.addTest(new IStructureTests("testGetFields"));
|
||||||
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetFieldsHack"));
|
//Bug# 38985: solved. suite.addTest(new IStructureTests("testGetFieldsHack"));
|
||||||
suite.addTest( new IStructureTests("testGetField"));
|
suite.addTest(new IStructureTests("testGetField"));
|
||||||
suite.addTest( new IStructureTests("testGetMethods")); // C++ only
|
suite.addTest(new IStructureTests("testGetMethods")); // C++ only
|
||||||
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
|
//Bug# 38985: solved. suite.addTest(new IStructureTests("testGetMethodsHack")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testGetMethod")); // C++ only
|
suite.addTest(new IStructureTests("testGetMethod")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testIsStruct"));
|
suite.addTest(new IStructureTests("testIsStruct"));
|
||||||
suite.addTest( new IStructureTests("testIsClass")); // C++ only
|
suite.addTest(new IStructureTests("testIsClass")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testIsUnion"));
|
suite.addTest(new IStructureTests("testIsUnion"));
|
||||||
suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
|
suite.addTest(new IStructureTests("testIsAbstract")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
|
suite.addTest(new IStructureTests("testGetBaseTypes")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
|
suite.addTest(new IStructureTests("testGetAccessControl")); // C++ only
|
||||||
|
|
||||||
// Language Specification tests:
|
// Language Specification tests:
|
||||||
suite.addTest( new IStructureTests("testAnonymousStructObject"));
|
suite.addTest(new IStructureTests("testAnonymousStructObject"));
|
||||||
suite.addTest( new IStructureTests("testInnerStruct"));
|
suite.addTest(new IStructureTests("testInnerStruct"));
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
@ -92,9 +91,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"testStruct8"
|
"testStruct8"
|
||||||
};
|
};
|
||||||
assertEquals(myExpectedStructs.length,arrayStructs.size());
|
assertEquals(myExpectedStructs.length,arrayStructs.size());
|
||||||
for(int i=0; i<myExpectedStructs.length; i++) {
|
for (int i= 0; i < myExpectedStructs.length; i++) {
|
||||||
IStructure myIStruct = (IStructure) arrayStructs.get(i);
|
IStructure myIStruct = (IStructure) arrayStructs.get(i);
|
||||||
assertNotNull( "Failed on "+i, myIStruct);
|
assertNotNull("Failed on " + i, myIStruct);
|
||||||
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
|
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,11 +102,11 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
||||||
String[] myExpectedClasses = {
|
String[] myExpectedClasses = {
|
||||||
"testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
|
"testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
|
||||||
"testClass5", "testClass6"};
|
"testClass5", "testClass6" };
|
||||||
assertEquals(myExpectedClasses.length,arrayClasses.size());
|
assertEquals(myExpectedClasses.length,arrayClasses.size());
|
||||||
for(int i=0; i<myExpectedClasses.length; i++) {
|
for (int i= 0; i < myExpectedClasses.length; i++) {
|
||||||
IStructure myIStruct = (IStructure) arrayClasses.get(i);
|
IStructure myIStruct = (IStructure) arrayClasses.get(i);
|
||||||
assertNotNull( "Failed on "+i, myIStruct);
|
assertNotNull("Failed on " + i, myIStruct);
|
||||||
assertEquals(myExpectedClasses[i], myIStruct.getElementName());
|
assertEquals(myExpectedClasses[i], myIStruct.getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +121,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"m_field4","m_field5","m_field6",
|
"m_field4","m_field5","m_field6",
|
||||||
};
|
};
|
||||||
assertEquals(myExpectedFields.length, myArrayIField.length);
|
assertEquals(myExpectedFields.length, myArrayIField.length);
|
||||||
for(int i=0; i<myArrayIField.length; i++) {
|
for (int i= 0; i < myArrayIField.length; i++) {
|
||||||
assertNotNull( "Failed on "+i, myArrayIField[i]);
|
assertNotNull("Failed on " + i, myArrayIField[i]);
|
||||||
assertEquals("Failed on "+i,
|
assertEquals("Failed on " + i,
|
||||||
myExpectedFields[i], myArrayIField[i].getElementName());
|
myExpectedFields[i], myArrayIField[i].getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,10 +139,10 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
};
|
};
|
||||||
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
||||||
assertEquals(myExpectedFields.length, myArrayIField.size());
|
assertEquals(myExpectedFields.length, myArrayIField.size());
|
||||||
for(int i=0; i<myArrayIField.size(); i++) {
|
for (int i= 0; i < myArrayIField.size(); i++) {
|
||||||
IField myIField = (IField) myArrayIField.get(i);
|
IField myIField = (IField) myArrayIField.get(i);
|
||||||
assertNotNull( "Failed on "+i, myIField );
|
assertNotNull("Failed on " + i, myIField);
|
||||||
assertEquals("Failed on "+i,
|
assertEquals("Failed on " + i,
|
||||||
myExpectedFields[i], myIField.getElementName());
|
myExpectedFields[i], myIField.getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,17 +154,17 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"m_field1","m_field2","m_field3",
|
"m_field1","m_field2","m_field3",
|
||||||
"m_field4","m_field5","m_field6",
|
"m_field4","m_field5","m_field6",
|
||||||
};
|
};
|
||||||
for(int i=0; i<myExpectedFields.length; i++) {
|
for (int i= 0; i < myExpectedFields.length; i++) {
|
||||||
IField myIField = myIStruct.getField( myExpectedFields[i] );
|
IField myIField = myIStruct.getField(myExpectedFields[i]);
|
||||||
assertNotNull( "Failed on "+i, myIField);
|
assertNotNull("Failed on " + i, myIField);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myUnexpectedFields = {
|
String[] myUnexpectedFields = {
|
||||||
"m_field7","m_field8","m_field9",
|
"m_field7","m_field8","m_field9",
|
||||||
};
|
};
|
||||||
for(int i=0; i<myUnexpectedFields.length; i++) {
|
for (int i= 0; i < myUnexpectedFields.length; i++) {
|
||||||
IField myIField = myIStruct.getField( myUnexpectedFields[i] );
|
IField myIField = myIStruct.getField(myUnexpectedFields[i]);
|
||||||
assertNull( "Failed on "+i, myIField);
|
assertNull("Failed on " + i, myIField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void testGetMethods() throws CModelException {
|
public void testGetMethods() throws CModelException {
|
||||||
|
@ -177,9 +176,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
};
|
};
|
||||||
assertEquals(myExpectedMethods.length, myArrayIMethod.length);
|
assertEquals(myExpectedMethods.length, myArrayIMethod.length);
|
||||||
for(int i=0; i<myArrayIMethod.length; i++) {
|
for (int i= 0; i < myArrayIMethod.length; i++) {
|
||||||
assertNotNull( "Failed on "+i, myArrayIMethod[i]);
|
assertNotNull("Failed on " + i, myArrayIMethod[i]);
|
||||||
assertEquals("Failed on "+i,
|
assertEquals("Failed on " + i,
|
||||||
myExpectedMethods[i], myArrayIMethod[i].getElementName());
|
myExpectedMethods[i], myArrayIMethod[i].getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,15 +188,15 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) );
|
myArrayIMethod.addAll(myIStruct.getChildrenOfType(ICElement.C_METHOD));
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
};
|
};
|
||||||
assertEquals(myExpectedMethods.length, myArrayIMethod.size());
|
assertEquals(myExpectedMethods.length, myArrayIMethod.size());
|
||||||
for(int i=0; i<myArrayIMethod.size(); i++) {
|
for (int i= 0; i < myArrayIMethod.size(); i++) {
|
||||||
IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i);
|
IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i);
|
||||||
assertNotNull( "Failed on "+i, myIMethod);
|
assertNotNull("Failed on " + i, myIMethod);
|
||||||
assertEquals("Failed on "+i,
|
assertEquals("Failed on " + i,
|
||||||
myExpectedMethods[i], myIMethod.getElementName());
|
myExpectedMethods[i], myIMethod.getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,17 +207,17 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
};
|
};
|
||||||
for(int i=0; i<myExpectedMethods.length; i++) {
|
for (int i= 0; i < myExpectedMethods.length; i++) {
|
||||||
IMethodDeclaration myIMethod = myIStruct.getMethod( myExpectedMethods[i] );
|
IMethodDeclaration myIMethod = myIStruct.getMethod(myExpectedMethods[i]);
|
||||||
assertNotNull( "Failed on "+i, myIMethod);
|
assertNotNull("Failed on " + i, myIMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myUnexpectedMethods = {
|
String[] myUnexpectedMethods = {
|
||||||
"method7","method8","method9",
|
"method7","method8","method9",
|
||||||
};
|
};
|
||||||
for(int i=0; i<myUnexpectedMethods.length; i++) {
|
for (int i= 0; i < myUnexpectedMethods.length; i++) {
|
||||||
IMethodDeclaration myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] );
|
IMethodDeclaration myIMethod = myIStruct.getMethod(myUnexpectedMethods[i]);
|
||||||
assertNull( "Failed on "+i, myIMethod);
|
assertNull("Failed on " + i, myIMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,23 +228,22 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementUnion = tu.getElement("testUnion1");
|
myElementUnion = tu.getElement("testUnion1");
|
||||||
myElementNonUnion = tu.getElement("testStruct1");
|
myElementNonUnion = tu.getElement("testStruct1");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElementUnion);
|
||||||
{
|
assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElementUnion );
|
|
||||||
assertTrue( myElementUnion.getElementType()==ICElement.C_UNION );
|
|
||||||
IStructure myStructUnion = (IStructure) myElementUnion;
|
IStructure myStructUnion = (IStructure) myElementUnion;
|
||||||
assertNotNull( myStructUnion );
|
assertNotNull(myStructUnion);
|
||||||
assertTrue( myStructUnion.isUnion() );
|
assertTrue(myStructUnion.isUnion());
|
||||||
|
|
||||||
assertNotNull( myElementNonUnion );
|
assertNotNull(myElementNonUnion);
|
||||||
assertTrue( myElementNonUnion.getElementType()!=ICElement.C_UNION );
|
assertTrue(myElementNonUnion.getElementType() != ICElement.C_UNION);
|
||||||
IStructure myStructNonUnion = (IStructure) myElementNonUnion;
|
IStructure myStructNonUnion = (IStructure) myElementNonUnion;
|
||||||
assertNotNull( myStructNonUnion );
|
assertNotNull(myStructNonUnion);
|
||||||
assertFalse( myStructNonUnion.isUnion() );
|
assertFalse(myStructNonUnion.isUnion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsStruct() throws CModelException {
|
public void testIsStruct() throws CModelException {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement myElementStruct = null;
|
ICElement myElementStruct = null;
|
||||||
|
@ -253,22 +251,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementStruct = tu.getElement("testStruct1");
|
myElementStruct = tu.getElement("testStruct1");
|
||||||
myElementNonStruct = tu.getElement("testClass1");
|
myElementNonStruct = tu.getElement("testClass1");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElementStruct);
|
||||||
{
|
assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElementStruct );
|
|
||||||
assertTrue( myElementStruct.getElementType()==ICElement.C_STRUCT );
|
|
||||||
IStructure myStructStruct = (IStructure) myElementStruct;
|
IStructure myStructStruct = (IStructure) myElementStruct;
|
||||||
assertNotNull( myStructStruct );
|
assertNotNull(myStructStruct);
|
||||||
assertTrue( myStructStruct.isStruct() );
|
assertTrue(myStructStruct.isStruct());
|
||||||
|
|
||||||
assertNotNull( myElementNonStruct );
|
assertNotNull(myElementNonStruct);
|
||||||
assertTrue( myElementNonStruct.getElementType()!=ICElement.C_STRUCT );
|
assertTrue(myElementNonStruct.getElementType() != ICElement.C_STRUCT);
|
||||||
IStructure myStructNonStruct = (IStructure) myElementNonStruct;
|
IStructure myStructNonStruct = (IStructure) myElementNonStruct;
|
||||||
assertNotNull( myStructNonStruct );
|
assertNotNull(myStructNonStruct);
|
||||||
assertFalse( myStructNonStruct.isStruct() );
|
assertFalse(myStructNonStruct.isStruct());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsClass() throws CModelException {
|
public void testIsClass() throws CModelException {
|
||||||
|
@ -278,22 +274,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementClass = tu.getElement("testClass1");
|
myElementClass = tu.getElement("testClass1");
|
||||||
myElementNonClass = tu.getElement("testStruct1");
|
myElementNonClass = tu.getElement("testStruct1");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElementClass);
|
||||||
{
|
assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElementClass );
|
|
||||||
assertTrue( myElementClass.getElementType()==ICElement.C_CLASS );
|
|
||||||
IStructure myStructClass = (IStructure) myElementClass;
|
IStructure myStructClass = (IStructure) myElementClass;
|
||||||
assertNotNull( myStructClass );
|
assertNotNull(myStructClass);
|
||||||
assertTrue( myStructClass.isClass() );
|
assertTrue(myStructClass.isClass());
|
||||||
|
|
||||||
assertNotNull( myElementNonClass );
|
assertNotNull(myElementNonClass);
|
||||||
assertTrue( myElementNonClass.getElementType()!=ICElement.C_CLASS );
|
assertTrue(myElementNonClass.getElementType() != ICElement.C_CLASS);
|
||||||
IStructure myStructNonClass = (IStructure) myElementNonClass;
|
IStructure myStructNonClass = (IStructure) myElementNonClass;
|
||||||
assertNotNull( myStructNonClass );
|
assertNotNull(myStructNonClass);
|
||||||
assertFalse( myStructNonClass.isClass() );
|
assertFalse(myStructNonClass.isClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsAbstract() throws CModelException {
|
public void testIsAbstract() throws CModelException {
|
||||||
|
@ -303,22 +297,20 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
try {
|
try {
|
||||||
myElementAbstract = tu.getElement("testClass4Abstract");
|
myElementAbstract = tu.getElement("testClass4Abstract");
|
||||||
myElementNonAbstract = tu.getElement("testClass1");
|
myElementNonAbstract = tu.getElement("testClass1");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElementAbstract);
|
||||||
{
|
assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElementAbstract );
|
|
||||||
assertTrue( myElementAbstract.getElementType()==ICElement.C_CLASS );
|
|
||||||
IStructure myStructAbstract = (IStructure) myElementAbstract;
|
IStructure myStructAbstract = (IStructure) myElementAbstract;
|
||||||
assertNotNull( myStructAbstract );
|
assertNotNull(myStructAbstract);
|
||||||
assertTrue( myStructAbstract.isAbstract() );
|
assertTrue(myStructAbstract.isAbstract());
|
||||||
|
|
||||||
assertNotNull( myElementNonAbstract );
|
assertNotNull(myElementNonAbstract);
|
||||||
assertTrue( myElementNonAbstract.getElementType() == ICElement.C_CLASS );
|
assertTrue(myElementNonAbstract.getElementType() == ICElement.C_CLASS);
|
||||||
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
||||||
assertNotNull( myStructNonAbstract );
|
assertNotNull(myStructNonAbstract);
|
||||||
assertFalse( myStructNonAbstract.isAbstract() );
|
assertFalse(myStructNonAbstract.isAbstract());
|
||||||
}
|
}
|
||||||
|
|
||||||
// IInheritance
|
// IInheritance
|
||||||
|
@ -328,23 +320,21 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
String[] myBaseTypes = null;
|
String[] myBaseTypes = null;
|
||||||
try {
|
try {
|
||||||
myElementDerived = tu.getElement("testClass5"); // throws
|
myElementDerived = tu.getElement("testClass5"); // throws
|
||||||
assertNotNull( myElementDerived );
|
assertNotNull(myElementDerived);
|
||||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
|
||||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||||
assertNotNull( myStructDerived );
|
assertNotNull(myStructDerived);
|
||||||
myBaseTypes = myStructDerived.getSuperClassesNames();
|
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myExpectedBaseTypes = {
|
String[] myExpectedBaseTypes = {
|
||||||
"testClass1","testClass3","testClass4Abstract"
|
"testClass1", "testClass3","testClass4Abstract"
|
||||||
};
|
};
|
||||||
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
|
assertEquals(myExpectedBaseTypes.length, myBaseTypes.length);
|
||||||
for(int i=0; i<myBaseTypes.length; i++) {
|
for (int i= 0; i < myBaseTypes.length; i++) {
|
||||||
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i] );
|
assertEquals("Failed on " + i, myExpectedBaseTypes[i], myBaseTypes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,10 +345,10 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
String[] myBaseTypes = null;
|
String[] myBaseTypes = null;
|
||||||
try {
|
try {
|
||||||
myElementDerived = tu.getElement("testClass5"); // throws
|
myElementDerived = tu.getElement("testClass5"); // throws
|
||||||
assertNotNull( myElementDerived );
|
assertNotNull(myElementDerived);
|
||||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
|
||||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||||
assertNotNull( myStructDerived );
|
assertNotNull(myStructDerived);
|
||||||
myBaseTypes = myStructDerived.getSuperClassesNames();
|
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||||
|
|
||||||
ASTAccessVisibility[] myExpectedAccessControl = {
|
ASTAccessVisibility[] myExpectedAccessControl = {
|
||||||
|
@ -367,15 +357,13 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ASTAccessVisibility.PROTECTED,
|
ASTAccessVisibility.PROTECTED,
|
||||||
ASTAccessVisibility.PRIVATE
|
ASTAccessVisibility.PRIVATE
|
||||||
};
|
};
|
||||||
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
|
assertEquals(myExpectedAccessControl.length, myBaseTypes.length);
|
||||||
for(int i=0; i<myBaseTypes.length; i++) {
|
for (int i= 0; i < myBaseTypes.length; i++) {
|
||||||
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
|
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
|
||||||
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl );
|
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
|
||||||
}
|
}
|
||||||
}
|
} catch (CModelException e) {
|
||||||
catch( CModelException c )
|
assertNotNull("CModelException thrown", e);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,13 +387,11 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ICElement myElement = null;
|
ICElement myElement = null;
|
||||||
try {
|
try {
|
||||||
myElement = tu.getElement("testAnonymousStructObject1");
|
myElement = tu.getElement("testAnonymousStructObject1");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElement);
|
||||||
{
|
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElement );
|
|
||||||
assertEquals( ICElement.C_VARIABLE, myElement.getElementType() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInnerStruct() throws CModelException {
|
public void testInnerStruct() throws CModelException {
|
||||||
|
@ -413,24 +399,22 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ICElement myElement = null;
|
ICElement myElement = null;
|
||||||
try {
|
try {
|
||||||
myElement = tu.getElement("testStruct8");
|
myElement = tu.getElement("testStruct8");
|
||||||
|
} catch (CModelException e) {
|
||||||
|
assertNotNull("CModelException thrown", e);
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
assertNotNull(myElement);
|
||||||
{
|
|
||||||
assertNotNull("CModelException thrown",c);
|
|
||||||
}
|
|
||||||
assertNotNull( myElement );
|
|
||||||
IStructure myIStruct = (IStructure) myElement;
|
IStructure myIStruct = (IStructure) myElement;
|
||||||
assertNotNull( myIStruct );
|
assertNotNull(myIStruct);
|
||||||
|
|
||||||
String[] myExpectedInnerStructs = {
|
String[] myExpectedInnerStructs = {
|
||||||
"testStruct9Inner", "testStruct10Inner"
|
"testStruct9Inner", "testStruct10Inner"
|
||||||
};
|
};
|
||||||
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() );
|
assertEquals(myExpectedInnerStructs.length, myInnerStructs.size());
|
||||||
for(int i=0; i<myExpectedInnerStructs.length; i++) {
|
for (int i= 0; i < myExpectedInnerStructs.length; i++) {
|
||||||
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
||||||
assertNotNull( "Failed on "+i, myInnerStruct );
|
assertNotNull("Failed on " + i, myInnerStruct);
|
||||||
assertEquals( "Failed on "+i, myExpectedInnerStructs[i], myInnerStruct.getElementName() );
|
assertEquals("Failed on " + i, myExpectedInnerStructs[i], myInnerStruct.getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Jun 3, 2003
|
|
||||||
* by bnicolle
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -33,18 +29,13 @@ import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bnicolle
|
* @author bnicolle
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class IntegratedCModelTest extends BaseTestCase {
|
public abstract class IntegratedCModelTest extends BaseTestCase {
|
||||||
|
|
||||||
private ICProject fCProject;
|
private ICProject fCProject;
|
||||||
private IFile sourceFile;
|
private IFile sourceFile;
|
||||||
private NullProgressMonitor monitor;
|
private NullProgressMonitor monitor;
|
||||||
private boolean structuralParse = false;
|
private boolean structuralParse = false;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public IntegratedCModelTest() {
|
public IntegratedCModelTest() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -113,5 +104,4 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
|
||||||
public void setStructuralParse(boolean structuralParse) {
|
public void setStructuralParse(boolean structuralParse) {
|
||||||
this.structuralParse = structuralParse;
|
this.structuralParse = structuralParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class BaseTestCase extends TestCase {
|
||||||
try {
|
try {
|
||||||
super.runBare();
|
super.runBare();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
testThrowable=e;
|
testThrowable= e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusLog.size() != fExpectedLoggedNonOK) {
|
if (statusLog.size() != fExpectedLoggedNonOK) {
|
||||||
|
@ -168,7 +168,7 @@ public class BaseTestCase extends TestCase {
|
||||||
msg.append("non-OK status objects in log differs from actual (" + statusLog.size() + ").\n");
|
msg.append("non-OK status objects in log differs from actual (" + statusLog.size() + ").\n");
|
||||||
Throwable cause= null;
|
Throwable cause= null;
|
||||||
if (!statusLog.isEmpty()) {
|
if (!statusLog.isEmpty()) {
|
||||||
synchronized(statusLog) {
|
synchronized (statusLog) {
|
||||||
for (IStatus status : statusLog) {
|
for (IStatus status : statusLog) {
|
||||||
IStatus[] ss= {status};
|
IStatus[] ss= {status};
|
||||||
ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
|
ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
|
||||||
|
|
|
@ -22,51 +22,51 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
*/
|
*/
|
||||||
public interface ICPPFunction extends IFunction, ICPPBinding {
|
public interface ICPPFunction extends IFunction, ICPPBinding {
|
||||||
/**
|
/**
|
||||||
* Does this function have the mutable storage class specifier
|
* Does this function have the mutable storage class specifier
|
||||||
*/
|
*/
|
||||||
public boolean isMutable();
|
public boolean isMutable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this an inline function
|
* Is this an inline function
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isInline();
|
public boolean isInline();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this function is declared as extern "C".
|
* Returns whether this function is declared as extern "C".
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public boolean isExternC();
|
public boolean isExternC();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the exception specification for this function or <code>null</code> if there
|
* Returns the exception specification for this function or <code>null</code> if there
|
||||||
* is no exception specification.
|
* is no exception specification.
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public IType[] getExceptionSpecification();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
@Override
|
public IType[] getExceptionSpecification();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public ICPPFunctionType getType();
|
public ICPPFunctionType getType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICPPParameter[] getParameters();
|
public ICPPParameter[] getParameters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
|
||||||
*/
|
|
||||||
public int getRequiredArgumentCount();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
public boolean hasParameterPack();
|
public int getRequiredArgumentCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public boolean hasParameterPack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this is a function with a deleted function definition.
|
* Returns whether this is a function with a deleted function definition.
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.util;
|
package org.eclipse.cdt.core.parser.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,9 +43,7 @@ public class ObjectMap extends ObjectTable<Object> {
|
||||||
@Override
|
@Override
|
||||||
final public void clear() {
|
final public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
for(int i = 0; i < valueTable.length; i++) {
|
Arrays.fill(valueTable, null);
|
||||||
valueTable[i] = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -417,8 +417,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
||||||
copy.fForContentAssist = fForContentAssist;
|
copy.fForContentAssist = fForContentAssist;
|
||||||
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
|
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
|
||||||
|
|
||||||
for (IASTDeclaration declaration : getDeclarations())
|
for (IASTDeclaration declaration : getDeclarations()) {
|
||||||
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
|
}
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
if (image.length > 1 && image[0] == 'L')
|
if (image.length > 1 && image[0] == 'L')
|
||||||
return Value.create(ExpressionEvaluator.getChar(image, 2));
|
return Value.create(ExpressionEvaluator.getChar(image, 2));
|
||||||
return Value.create(ExpressionEvaluator.getChar(image, 1));
|
return Value.create(ExpressionEvaluator.getChar(image, 1));
|
||||||
} catch (EvalException e1) {
|
} catch (EvalException e) {
|
||||||
return Value.UNKNOWN;
|
return Value.UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
private IValue createIntValue() {
|
private IValue createIntValue() {
|
||||||
try {
|
try {
|
||||||
return Value.create(ExpressionEvaluator.getNumber(getValue()));
|
return Value.create(ExpressionEvaluator.getNumber(getValue()));
|
||||||
} catch (EvalException e1) {
|
} catch (EvalException e) {
|
||||||
return Value.UNKNOWN;
|
return Value.UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,4 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor {
|
||||||
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
|
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
|
||||||
super(declarator);
|
super(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM) - Initial API and implementation
|
* Andrew Niefer (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||||
private final ICPPTemplateArgument[] fArguments;
|
private final ICPPTemplateArgument[] fArguments;
|
||||||
|
|
||||||
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, argMap, type, exceptionSpecs);
|
super(orig, owner, argMap, type, exceptionSpecs);
|
||||||
fArguments = args;
|
fArguments = args;
|
||||||
}
|
}
|
||||||
|
@ -73,11 +74,11 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){
|
if ((obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)) {
|
||||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj;
|
final ICPPTemplateInstance inst = (ICPPTemplateInstance) obj;
|
||||||
ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType();
|
ICPPFunctionType ct1= ((ICPPFunction) getSpecializedBinding()).getType();
|
||||||
ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType();
|
ICPPFunctionType ct2= ((ICPPFunction) inst.getTemplateDefinition()).getType();
|
||||||
if(!ct1.isSameType(ct2))
|
if (!ct1.isSameType(ct2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return CPPTemplates.haveSameArguments(this, inst);
|
return CPPTemplates.haveSameArguments(this, inst);
|
||||||
|
|
|
@ -183,10 +183,10 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
||||||
|
|
||||||
protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) {
|
protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) {
|
||||||
if (decl instanceof IASTSimpleDeclaration) {
|
if (decl instanceof IASTSimpleDeclaration) {
|
||||||
return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||||
}
|
}
|
||||||
if (decl instanceof IASTFunctionDefinition) {
|
if (decl instanceof IASTFunctionDefinition) {
|
||||||
return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) decl).getDeclSpecifier();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM) - Initial API and implementation
|
* Andrew Niefer (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
*/
|
*/
|
||||||
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||||
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
||||||
|
private ObjectMap instances;
|
||||||
private ObjectMap instances = null;
|
|
||||||
|
|
||||||
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(original, owner, argumentMap, type, exceptionSpecs);
|
super(original, owner, argumentMap, type, exceptionSpecs);
|
||||||
|
|
|
@ -23,16 +23,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
*/
|
*/
|
||||||
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
||||||
|
|
||||||
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap,
|
||||||
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getVisibility() {
|
public int getVisibility() {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).getVisibility();
|
return ((ICPPMethod) getTemplateDefinition()).getVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,20 +38,14 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
||||||
return (ICPPClassType) getOwner();
|
return (ICPPClassType) getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVirtual() {
|
public boolean isVirtual() {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).isVirtual();
|
return ((ICPPMethod) getTemplateDefinition()).isVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPureVirtual() {
|
public boolean isPureVirtual() {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).isPureVirtual();
|
return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,9 +53,6 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
||||||
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
|
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDestructor() {
|
public boolean isDestructor() {
|
||||||
char[] name = getNameCharArray();
|
char[] name = getNameCharArray();
|
||||||
|
@ -80,11 +69,11 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOverride() {
|
public boolean isOverride() {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).isOverride();
|
return ((ICPPMethod) getTemplateDefinition()).isOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinal() {
|
public boolean isFinal() {
|
||||||
return ((ICPPMethod)getTemplateDefinition()).isFinal();
|
return ((ICPPMethod) getTemplateDefinition()).isFinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
|
|
@ -3041,8 +3041,10 @@ public class CPPSemantics {
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
ICPPEvaluation[] args = {
|
||||||
((ICPPASTExpression) expr.getOperand()).getEvaluation()};
|
new EvalFixed(type, LVALUE, Value.UNKNOWN),
|
||||||
|
((ICPPASTExpression) expr.getOperand()).getEvaluation()
|
||||||
|
};
|
||||||
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
if (isTypeDependent())
|
if (isTypeDependent())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
|
IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
|
||||||
if (t instanceof ICPPClassType) {
|
if (t instanceof ICPPClassType) {
|
||||||
return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS);
|
return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS);
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,8 @@ public class EvalFunctionCall extends CPPEvaluation {
|
||||||
if (overload != null)
|
if (overload != null)
|
||||||
return ExpressionTypes.typeFromFunctionCall(overload);
|
return ExpressionTypes.typeFromFunctionCall(overload);
|
||||||
|
|
||||||
|
|
||||||
final ICPPEvaluation arg0 = fArguments[0];
|
final ICPPEvaluation arg0 = fArguments[0];
|
||||||
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
|
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
|
||||||
if (t instanceof ICPPClassType) {
|
if (t instanceof ICPPClassType) {
|
||||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,9 @@ public class EvalMemberAccess extends CPPEvaluation {
|
||||||
* examine for type information.
|
* examine for type information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ICPPEvaluation[] args= {new EvalFixed(type, LVALUE, Value.UNKNOWN)};
|
ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
|
||||||
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType,
|
||||||
|
OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
||||||
if (op == null)
|
if (op == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
@ -24,28 +24,28 @@ class CompositeCParameter extends CompositeCBinding implements IParameter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
IType rtype = ((IParameter)rbinding).getType();
|
IType rtype = ((IParameter) rbinding).getType();
|
||||||
return cf.getCompositeType(rtype);
|
return cf.getCompositeType(rtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return ((IParameter)rbinding).isAuto();
|
return ((IParameter) rbinding).isAuto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return ((IParameter)rbinding).isExtern();
|
return ((IParameter) rbinding).isExtern();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return ((IParameter)rbinding).isRegister();
|
return ((IParameter) rbinding).isRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return ((IParameter)rbinding).isStatic();
|
return ((IParameter) rbinding).isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||||
|
|
||||||
|
@ -24,18 +24,18 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
IType rtype = ((IVariable)rbinding).getType();
|
IType rtype = ((IVariable) rbinding).getType();
|
||||||
return cf.getCompositeType(rtype);
|
return cf.getCompositeType(rtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return ((IVariable)rbinding).isAuto();
|
return ((IVariable) rbinding).isAuto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return ((IVariable)rbinding).isExtern();
|
return ((IVariable) rbinding).isExtern();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,11 +45,11 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return ((IVariable)rbinding).isStatic();
|
return ((IVariable) rbinding).isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return ((IVariable)rbinding).getInitialValue();
|
return ((IVariable) rbinding).getInitialValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
|
@ -25,42 +25,42 @@ class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return ((ICPPVariable)rbinding).isMutable();
|
return ((ICPPVariable) rbinding).isMutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExternC() {
|
public boolean isExternC() {
|
||||||
return ((ICPPVariable)rbinding).isExternC();
|
return ((ICPPVariable) rbinding).isExternC();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
IType rtype = ((ICPPVariable)rbinding).getType();
|
IType rtype = ((ICPPVariable) rbinding).getType();
|
||||||
return cf.getCompositeType(rtype);
|
return cf.getCompositeType(rtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return ((ICPPVariable)rbinding).isAuto();
|
return ((ICPPVariable) rbinding).isAuto();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return ((ICPPVariable)rbinding).isExtern();
|
return ((ICPPVariable) rbinding).isExtern();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return ((ICPPVariable)rbinding).isRegister();
|
return ((ICPPVariable) rbinding).isRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return ((ICPPVariable)rbinding).isStatic();
|
return ((ICPPVariable) rbinding).isStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return ((ICPPVariable)rbinding).getInitialValue();
|
return ((ICPPVariable) rbinding).getInitialValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial implementation
|
* IBM Corporation - initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
@ -73,9 +73,9 @@ public class ExpressionEvaluator {
|
||||||
if (LA() == IToken.tQUESTION) {
|
if (LA() == IToken.tQUESTION) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = expression();
|
long r2 = expression();
|
||||||
if (LA() == IToken.tCOLON)
|
if (LA() == IToken.tCOLON) {
|
||||||
consume();
|
consume();
|
||||||
else {
|
} else {
|
||||||
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
|
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
|
||||||
}
|
}
|
||||||
long r3 = conditionalExpression();
|
long r3 = conditionalExpression();
|
||||||
|
@ -139,11 +139,12 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
|
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = relationalExpression();
|
long r2 = relationalExpression();
|
||||||
if (t == IToken.tEQUAL)
|
if (t == IToken.tEQUAL) {
|
||||||
r1 = (r1 == r2) ? 1 : 0;
|
r1 = (r1 == r2) ? 1 : 0;
|
||||||
else
|
} else {
|
||||||
// t == tNOTEQUAL
|
// t == tNOTEQUAL
|
||||||
r1 = (r1 != r2) ? 1 : 0;
|
r1 = (r1 != r2) ? 1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
@ -179,11 +180,12 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
|
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = additiveExpression();
|
long r2 = additiveExpression();
|
||||||
if (t == IToken.tSHIFTL)
|
if (t == IToken.tSHIFTL) {
|
||||||
r1 = r1 << r2;
|
r1 = r1 << r2;
|
||||||
else
|
} else {
|
||||||
// t == tSHIFTR
|
// t == tSHIFTR
|
||||||
r1 = r1 >> r2;
|
r1 = r1 >> r2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
@ -193,11 +195,12 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
|
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = multiplicativeExpression();
|
long r2 = multiplicativeExpression();
|
||||||
if (t == IToken.tPLUS)
|
if (t == IToken.tPLUS) {
|
||||||
r1 = r1 + r2;
|
r1 = r1 + r2;
|
||||||
else
|
} else {
|
||||||
// t == tMINUS
|
// t == tMINUS
|
||||||
r1 = r1 - r2;
|
r1 = r1 - r2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
@ -207,13 +210,14 @@ public class ExpressionEvaluator {
|
||||||
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
|
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
|
||||||
consume();
|
consume();
|
||||||
long r2 = unaryExpression();
|
long r2 = unaryExpression();
|
||||||
if (t == IToken.tSTAR)
|
if (t == IToken.tSTAR) {
|
||||||
r1 = r1 * r2;
|
r1 = r1 * r2;
|
||||||
else if (r2 != 0) {
|
} else if (r2 != 0) {
|
||||||
if (t == IToken.tDIV)
|
if (t == IToken.tDIV) {
|
||||||
r1 = r1 / r2;
|
r1 = r1 / r2;
|
||||||
else
|
} else {
|
||||||
r1 = r1 % r2; //tMOD
|
r1 = r1 % r2; //tMOD
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
|
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
|
||||||
}
|
}
|
||||||
|
@ -328,7 +332,7 @@ public class ExpressionEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
long getValue(Token t) throws EvalException {
|
long getValue(Token t) throws EvalException {
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tCHAR:
|
case IToken.tCHAR:
|
||||||
return getChar(t.getCharImage(), 1);
|
return getChar(t.getCharImage(), 1);
|
||||||
case IToken.tLCHAR:
|
case IToken.tLCHAR:
|
||||||
|
@ -386,7 +390,7 @@ public class ExpressionEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getChar(char[] tokenImage, int i) throws EvalException {
|
public static long getChar(char[] tokenImage, int i) throws EvalException {
|
||||||
if (i>=tokenImage.length) {
|
if (i >= tokenImage.length) {
|
||||||
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
|
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
|
||||||
}
|
}
|
||||||
final char c= tokenImage[i];
|
final char c= tokenImage[i];
|
||||||
|
@ -398,7 +402,7 @@ public class ExpressionEvaluator {
|
||||||
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
|
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
|
||||||
}
|
}
|
||||||
final char d= tokenImage[i];
|
final char d= tokenImage[i];
|
||||||
switch(d) {
|
switch (d) {
|
||||||
case '\\': case '"': case '\'':
|
case '\\': case '"': case '\'':
|
||||||
return d;
|
return d;
|
||||||
case 'a': return 7;
|
case 'a': return 7;
|
||||||
|
@ -433,7 +437,7 @@ public class ExpressionEvaluator {
|
||||||
result= result*base + digit;
|
result= result*base + digit;
|
||||||
}
|
}
|
||||||
for (; i < to; i++) {
|
for (; i < to; i++) {
|
||||||
switch(tokenImage[i]) {
|
switch (tokenImage[i]) {
|
||||||
case 'u' : case 'l': case 'U': case 'L':
|
case 'u' : case 'l': case 'U': case 'L':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -444,13 +448,13 @@ public class ExpressionEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getDigit(char c) {
|
private static int getDigit(char c) {
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
||||||
return c-'0';
|
return c - '0';
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||||
return c-'a' + 10;
|
return c - 'a' + 10;
|
||||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||||
return c-'A'+10;
|
return c - 'A' + 10;
|
||||||
}
|
}
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (QNX) - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a function parameter in the index.
|
* Binding for a function parameter in the index.
|
||||||
*/
|
*/
|
||||||
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
|
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
|
||||||
|
|
||||||
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
||||||
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
|
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
|
@ -75,13 +74,13 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
byte flag = 1<<PDOMCAnnotation.AUTO_OFFSET;
|
byte flag = 1 << PDOMCAnnotation.AUTO_OFFSET;
|
||||||
return hasFlag(flag, true);
|
return hasFlag(flag, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
byte flag = 1<<PDOMCAnnotation.REGISTER_OFFSET;
|
byte flag = 1 << PDOMCAnnotation.REGISTER_OFFSET;
|
||||||
return hasFlag(flag, false);
|
return hasFlag(flag, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +137,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
return getNodeType();
|
return getNodeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
PDOMCParameter p= this;
|
PDOMCParameter p= this;
|
||||||
|
@ -193,7 +191,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Result of instantiating a class template.
|
* Result of instantiating a class template.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
|
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
|
||||||
|
|
||||||
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,22 +42,20 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
private static final short ANNOT_IS_DELETED = 9;
|
private static final short ANNOT_IS_DELETED = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of total number of function parameters (relative to the
|
* Offset of total number of function parameters (relative to the beginning of the record).
|
||||||
* beginning of the record).
|
|
||||||
*/
|
*/
|
||||||
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
|
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of pointer to the first parameter of this function (relative to
|
* Offset of pointer to the first parameter of this function (relative to the beginning of the record).
|
||||||
* the beginning of the record).
|
|
||||||
*/
|
*/
|
||||||
private static final int FIRST_PARAM = NUM_PARAMS + 4;
|
private static final int FIRST_PARAM = NUM_PARAMS + 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of pointer to the function type record of this function (relative to
|
* Offset of pointer to the function type record of this function (relative to the beginning of the
|
||||||
* the beginning of the record).
|
* record).
|
||||||
*/
|
*/
|
||||||
protected static final int FUNCTION_TYPE= FIRST_PARAM + Database.PTR_SIZE;
|
protected static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset of hash of parameter information to allow fast comparison
|
* Offset of hash of parameter information to allow fast comparison
|
||||||
|
@ -82,11 +80,12 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4;
|
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4;
|
||||||
|
|
||||||
private short fAnnotation= -1;
|
private short fAnnotation = -1;
|
||||||
private int fRequiredArgCount= -1;
|
private int fRequiredArgCount = -1;
|
||||||
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
|
||||||
|
|
||||||
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
|
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function,
|
||||||
|
boolean setTypes) throws CoreException, DOMException {
|
||||||
super(linkage, parent, function.getNameCharArray());
|
super(linkage, parent, function.getNameCharArray());
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
||||||
|
@ -99,7 +98,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
}
|
}
|
||||||
|
|
||||||
private short getAnnotation(ICPPFunction function) {
|
private short getAnnotation(ICPPFunction function) {
|
||||||
int annot= PDOMCPPAnnotation.encodeAnnotation(function) & 0xff;
|
int annot = PDOMCPPAnnotation.encodeAnnotation(function) & 0xff;
|
||||||
if (function.hasParameterPack()) {
|
if (function.hasParameterPack()) {
|
||||||
annot |= (1 << ANNOT_PARAMETER_PACK);
|
annot |= (1 << ANNOT_PARAMETER_PACK);
|
||||||
}
|
}
|
||||||
|
@ -122,39 +121,39 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
@Override
|
@Override
|
||||||
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
if (newBinding instanceof ICPPFunction) {
|
if (newBinding instanceof ICPPFunction) {
|
||||||
ICPPFunction func= (ICPPFunction) newBinding;
|
ICPPFunction func = (ICPPFunction) newBinding;
|
||||||
ICPPFunctionType newType;
|
ICPPFunctionType newType;
|
||||||
ICPPParameter[] newParams;
|
ICPPParameter[] newParams;
|
||||||
short newAnnotation;
|
short newAnnotation;
|
||||||
int newBindingRequiredArgCount;
|
int newBindingRequiredArgCount;
|
||||||
newType= func.getType();
|
newType = func.getType();
|
||||||
newParams = func.getParameters();
|
newParams = func.getParameters();
|
||||||
newAnnotation = getAnnotation(func);
|
newAnnotation = getAnnotation(func);
|
||||||
newBindingRequiredArgCount= func.getRequiredArgumentCount();
|
newBindingRequiredArgCount = func.getRequiredArgumentCount();
|
||||||
|
|
||||||
fType= null;
|
fType = null;
|
||||||
linkage.storeType(record + FUNCTION_TYPE, newType);
|
linkage.storeType(record + FUNCTION_TYPE, newType);
|
||||||
|
|
||||||
PDOMCPPParameter oldParams= getFirstParameter(null);
|
PDOMCPPParameter oldParams = getFirstParameter(null);
|
||||||
int requiredCount;
|
int requiredCount;
|
||||||
if (oldParams != null && hasDeclaration()) {
|
if (oldParams != null && hasDeclaration()) {
|
||||||
int parCount= 0;
|
int parCount = 0;
|
||||||
requiredCount= 0;
|
requiredCount = 0;
|
||||||
for (ICPPParameter newPar : newParams) {
|
for (ICPPParameter newPar : newParams) {
|
||||||
parCount++;
|
parCount++;
|
||||||
if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue())
|
if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue())
|
||||||
requiredCount= parCount;
|
requiredCount = parCount;
|
||||||
oldParams.update(newPar);
|
oldParams.update(newPar);
|
||||||
long next= oldParams.getNextPtr();
|
long next = oldParams.getNextPtr();
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
break;
|
break;
|
||||||
oldParams= new PDOMCPPParameter(linkage, next, null);
|
oldParams = new PDOMCPPParameter(linkage, next, null);
|
||||||
}
|
}
|
||||||
if (parCount < newBindingRequiredArgCount) {
|
if (parCount < newBindingRequiredArgCount) {
|
||||||
requiredCount= newBindingRequiredArgCount;
|
requiredCount = newBindingRequiredArgCount;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requiredCount= newBindingRequiredArgCount;
|
requiredCount = newBindingRequiredArgCount;
|
||||||
setParameters(newParams);
|
setParameters(newParams);
|
||||||
if (oldParams != null) {
|
if (oldParams != null) {
|
||||||
oldParams.delete(linkage);
|
oldParams.delete(linkage);
|
||||||
|
@ -162,9 +161,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
}
|
}
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
db.putShort(record + ANNOTATION, newAnnotation);
|
db.putShort(record + ANNOTATION, newAnnotation);
|
||||||
fAnnotation= newAnnotation;
|
fAnnotation = newAnnotation;
|
||||||
db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
|
db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
|
||||||
fRequiredArgCount= requiredCount;
|
fRequiredArgCount = requiredCount;
|
||||||
|
|
||||||
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
|
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
|
||||||
storeExceptionSpec(extractExceptionSpec(func));
|
storeExceptionSpec(extractExceptionSpec(func));
|
||||||
|
@ -175,7 +174,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
|
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
|
||||||
long typelist= PDOMCPPTypeList.putTypes(this, exceptionSpec);
|
long typelist = PDOMCPPTypeList.putTypes(this, exceptionSpec);
|
||||||
getDB().putRecPtr(record + EXCEPTION_SPEC, typelist);
|
getDB().putRecPtr(record + EXCEPTION_SPEC, typelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,27 +182,27 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
IType[] exceptionSpec;
|
IType[] exceptionSpec;
|
||||||
if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isImplicit()) {
|
if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isImplicit()) {
|
||||||
// Don't store the exception specification, compute it on demand.
|
// Don't store the exception specification, compute it on demand.
|
||||||
exceptionSpec= null;
|
exceptionSpec = null;
|
||||||
} else {
|
} else {
|
||||||
exceptionSpec= binding.getExceptionSpecification();
|
exceptionSpec = binding.getExceptionSpecification();
|
||||||
}
|
}
|
||||||
return exceptionSpec;
|
return exceptionSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setParameters(ICPPParameter[] params) throws CoreException {
|
private void setParameters(ICPPParameter[] params) throws CoreException {
|
||||||
final PDOMLinkage linkage = getLinkage();
|
final PDOMLinkage linkage = getLinkage();
|
||||||
final Database db= getDB();
|
final Database db = getDB();
|
||||||
db.putInt(record + NUM_PARAMS, params.length);
|
db.putInt(record + NUM_PARAMS, params.length);
|
||||||
db.putRecPtr(record + FIRST_PARAM, 0);
|
db.putRecPtr(record + FIRST_PARAM, 0);
|
||||||
PDOMCPPParameter next= null;
|
PDOMCPPParameter next = null;
|
||||||
for (int i= params.length; --i >= 0;) {
|
for (int i = params.length; --i >= 0;) {
|
||||||
next= new PDOMCPPParameter(linkage, this, params[i], next);
|
next = new PDOMCPPParameter(linkage, this, params[i], next);
|
||||||
}
|
}
|
||||||
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
|
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setType(ICPPFunctionType ft) throws CoreException {
|
private void setType(ICPPFunctionType ft) throws CoreException {
|
||||||
fType= null;
|
fType = null;
|
||||||
getLinkage().storeType(record + FUNCTION_TYPE, ft);
|
getLinkage().storeType(record + FUNCTION_TYPE, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,9 +243,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
public int getRequiredArgumentCount() {
|
public int getRequiredArgumentCount() {
|
||||||
if (fRequiredArgCount == -1) {
|
if (fRequiredArgCount == -1) {
|
||||||
try {
|
try {
|
||||||
fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT);
|
fRequiredArgCount = getDB().getInt(record + REQUIRED_ARG_COUNT);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fRequiredArgCount= 0;
|
fRequiredArgCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fRequiredArgCount;
|
return fRequiredArgCount;
|
||||||
|
@ -255,9 +254,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
final protected short getAnnotation() {
|
final protected short getAnnotation() {
|
||||||
if (fAnnotation == -1) {
|
if (fAnnotation == -1) {
|
||||||
try {
|
try {
|
||||||
fAnnotation= getDB().getShort(record + ANNOTATION);
|
fAnnotation = getDB().getShort(record + ANNOTATION);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
fAnnotation= 0;
|
fAnnotation = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fAnnotation;
|
return fAnnotation;
|
||||||
|
@ -281,20 +280,20 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
@Override
|
@Override
|
||||||
public ICPPParameter[] getParameters() {
|
public ICPPParameter[] getParameters() {
|
||||||
try {
|
try {
|
||||||
PDOMLinkage linkage= getLinkage();
|
PDOMLinkage linkage = getLinkage();
|
||||||
Database db= getDB();
|
Database db = getDB();
|
||||||
ICPPFunctionType ft = getType();
|
ICPPFunctionType ft = getType();
|
||||||
IType[] ptypes= ft == null ? IType.EMPTY_TYPE_ARRAY : ft.getParameterTypes();
|
IType[] ptypes = ft == null ? IType.EMPTY_TYPE_ARRAY : ft.getParameterTypes();
|
||||||
|
|
||||||
int n = db.getInt(record + NUM_PARAMS);
|
int n = db.getInt(record + NUM_PARAMS);
|
||||||
ICPPParameter[] result = new ICPPParameter[n];
|
ICPPParameter[] result = new ICPPParameter[n];
|
||||||
|
|
||||||
long next = db.getRecPtr(record + FIRST_PARAM);
|
long next = db.getRecPtr(record + FIRST_PARAM);
|
||||||
for (int i = 0; i < n && next != 0; i++) {
|
for (int i = 0; i < n && next != 0; i++) {
|
||||||
IType type= i<ptypes.length ? ptypes[i] : null;
|
IType type = i < ptypes.length ? ptypes[i] : null;
|
||||||
final PDOMCPPParameter par = new PDOMCPPParameter(linkage, next, type);
|
final PDOMCPPParameter par = new PDOMCPPParameter(linkage, next, type);
|
||||||
next= par.getNextPtr();
|
next = par.getNextPtr();
|
||||||
result[i]= par;
|
result[i] = par;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -307,10 +306,10 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
public final ICPPFunctionType getType() {
|
public final ICPPFunctionType getType() {
|
||||||
if (fType == null) {
|
if (fType == null) {
|
||||||
try {
|
try {
|
||||||
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
fType = (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
fType = new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fType;
|
return fType;
|
||||||
|
@ -371,13 +370,13 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
||||||
|
|
||||||
protected static int compareSignatures(IPDOMOverloader a, Object b) {
|
protected static int compareSignatures(IPDOMOverloader a, Object b) {
|
||||||
if (b instanceof IPDOMOverloader) {
|
if (b instanceof IPDOMOverloader) {
|
||||||
IPDOMOverloader bb= (IPDOMOverloader) b;
|
IPDOMOverloader bb = (IPDOMOverloader) b;
|
||||||
try {
|
try {
|
||||||
int mySM = a.getSignatureHash();
|
int mySM = a.getSignatureHash();
|
||||||
int otherSM = bb.getSignatureHash();
|
int otherSM = bb.getSignatureHash();
|
||||||
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert false;
|
assert false;
|
||||||
|
|
|
@ -86,7 +86,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
getLinkage().storeType(record + FUNCTION_TYPE, astFt);
|
getLinkage().storeType(record + FUNCTION_TYPE, astFt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding();
|
ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization) astFunction).getSpecializedBinding();
|
||||||
ICPPParameter[] origAstParams= origAstFunc.getParameters();
|
ICPPParameter[] origAstParams= origAstFunc.getParameters();
|
||||||
if (origAstParams.length == 0) {
|
if (origAstParams.length == 0) {
|
||||||
db.putInt(record + NUM_PARAMS, 0);
|
db.putInt(record + NUM_PARAMS, 0);
|
||||||
|
@ -98,14 +98,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
db.putRecPtr(record + FIRST_PARAM, 0);
|
db.putRecPtr(record + FIRST_PARAM, 0);
|
||||||
PDOMCPPParameter origPar= null;
|
PDOMCPPParameter origPar= null;
|
||||||
PDOMCPPParameterSpecialization next= null;
|
PDOMCPPParameterSpecialization next= null;
|
||||||
for (int i= length-1; i >= 0; --i) {
|
for (int i= length; --i >= 0;) {
|
||||||
// There may be fewer or less original parameters, because of parameter packs.
|
// There may be fewer or less original parameters, because of parameter packs.
|
||||||
if (i < origAstParams.length - 1) {
|
if (i < origAstParams.length - 1) {
|
||||||
// Normal case
|
// Normal case
|
||||||
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
|
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
|
||||||
} else if (origPar == null) {
|
} else if (origPar == null) {
|
||||||
// Use last parameter
|
// Use last parameter
|
||||||
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null);
|
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length - 1], null);
|
||||||
}
|
}
|
||||||
next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
|
next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
|
||||||
}
|
}
|
||||||
|
@ -205,8 +205,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
if (fType == null) {
|
if (fType == null) {
|
||||||
try {
|
try {
|
||||||
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
||||||
@Override
|
@Override
|
||||||
public int pdomCompareTo(PDOMBinding other) {
|
public int pdomCompareTo(PDOMBinding other) {
|
||||||
int cmp= super.pdomCompareTo(other);
|
int cmp= super.pdomCompareTo(other);
|
||||||
return cmp==0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp;
|
return cmp == 0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (QNX) - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a parameter of a c++ function in the index.
|
* Binding for a parameter of a c++ function in the index.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
|
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
|
||||||
|
|
||||||
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
|
||||||
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
|
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
|
||||||
private static final int FLAGS = ANNOTATIONS + 1;
|
private static final int FLAGS = ANNOTATIONS + 1;
|
||||||
|
@ -48,6 +47,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
|
||||||
private static final byte FLAG_DEFAULT_VALUE = 0x1;
|
private static final byte FLAG_DEFAULT_VALUE = 0x1;
|
||||||
|
|
||||||
private final IType fType;
|
private final IType fType;
|
||||||
|
|
||||||
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
|
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
|
||||||
super(linkage, record);
|
super(linkage, record);
|
||||||
fType= type;
|
fType= type;
|
||||||
|
@ -125,7 +125,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
// ISO/IEC 14882:2003 7.1.1.2
|
// ISO/IEC 14882:2003 7.1.1.2
|
||||||
byte flag = 1<<PDOMCAnnotation.AUTO_OFFSET;
|
byte flag = 1 << PDOMCAnnotation.AUTO_OFFSET;
|
||||||
return hasFlag(flag, true, ANNOTATIONS);
|
return hasFlag(flag, true, ANNOTATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
// ISO/IEC 14882:2003 7.1.1.2
|
// ISO/IEC 14882:2003 7.1.1.2
|
||||||
byte flag = 1<<PDOMCAnnotation.REGISTER_OFFSET;
|
byte flag = 1 << PDOMCAnnotation.REGISTER_OFFSET;
|
||||||
return hasFlag(flag, true, ANNOTATIONS);
|
return hasFlag(flag, true, ANNOTATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
|
||||||
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
|
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
|
||||||
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
|
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
|
||||||
super(linkage, parent, (ICPPSpecialization) astParam, original);
|
super(linkage, parent, (ICPPSpecialization) astParam, original);
|
||||||
fType= null; // this constructor is used for adding parameters to the database, only.
|
fType= null; // This constructor is used for adding parameters to the database, only.
|
||||||
|
|
||||||
Database db = getDB();
|
Database db = getDB();
|
||||||
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
|
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
|
||||||
|
@ -79,7 +79,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
|
||||||
if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) {
|
if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) {
|
||||||
IParameter[] pars= ((ICPPFunction) parent).getParameters();
|
IParameter[] pars= ((ICPPFunction) parent).getParameters();
|
||||||
int parPos= -1;
|
int parPos= -1;
|
||||||
for (parPos= 0; parPos<pars.length; parPos++) {
|
for (parPos= 0; parPos < pars.length; parPos++) {
|
||||||
IParameter par= pars[parPos];
|
IParameter par= pars[parPos];
|
||||||
if (equals(par)) {
|
if (equals(par)) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (QNX) - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Binding for a c++ variable in the index, serves as a base class for fields.
|
* Binding for a c++ variable in the index, serves as a base class for fields.
|
||||||
*/
|
*/
|
||||||
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||||
|
|
||||||
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
|
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
|
||||||
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
||||||
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte
|
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte
|
||||||
|
|
Loading…
Add table
Reference in a new issue