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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-10 14:19:12 -07:00
parent 595db0a239
commit e726c3d217
22 changed files with 377 additions and 431 deletions

View file

@ -27,7 +27,6 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* C functions. * C functions.
*/ */
public class CFunctionTests extends PDOMTestBase { public class CFunctionTests extends PDOMTestBase {
protected ICProject project; protected ICProject project;
protected PDOM pdom; protected PDOM pdom;
@ -81,7 +80,7 @@ public class CFunctionTests extends PDOMTestBase {
IFunction f= (IFunction) bindings[0]; IFunction f= (IFunction) bindings[0];
IParameter[] params= f.getParameters(); IParameter[] params= f.getParameters();
assertEquals(3, params.length); assertEquals(3, params.length);
assertNull(params[0].getType()); // its a problem binding in the DOM assertNull(params[0].getType()); // It's a problem binding in the DOM
assertTrue(params[1].getType() instanceof ICBasicType); assertTrue(params[1].getType() instanceof ICBasicType);
assertTrue(params[2].getType() instanceof ICBasicType); assertTrue(params[2].getType() instanceof ICBasicType);
} }

View file

@ -31,14 +31,12 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* Tests for verifying whether the PDOM correctly stores information about * Tests for verifying whether the PDOM correctly stores information about
* C++ non-member functions. * C++ non-member functions.
*/ */
public class CPPFunctionTests extends PDOMTestBase { public class CPPFunctionTests extends PDOMTestBase {
protected ICProject project; protected ICProject project;
protected PDOM pdom; protected PDOM pdom;
@ -58,13 +56,14 @@ public class CPPFunctionTests extends PDOMTestBase {
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
pdom.releaseReadLock(); pdom.releaseReadLock();
if (project != null) { if (project != null) {
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor()); project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, npm());
} }
} }
public void testPointerToFunctionType() throws Exception { public void testPointerToFunctionType() throws Exception {
assertDeclarationCount(pdom, "int2intPtr", 1); assertDeclarationCount(pdom, "int2intPtr", 1);
IIndexFragmentBinding[] b= pdom.findBindings(new char[][] {"int2intPtr".toCharArray()}, IndexFilter.ALL, npm()); IIndexFragmentBinding[] b=
pdom.findBindings(new char[][] { "int2intPtr".toCharArray() }, IndexFilter.ALL, npm());
assertEquals(1, b.length); assertEquals(1, b.length);
assertInstance(b[0], ICPPVariable.class); assertInstance(b[0], ICPPVariable.class);
ICPPVariable v= (ICPPVariable) b[0]; ICPPVariable v= (ICPPVariable) b[0];
@ -103,11 +102,11 @@ public class CPPFunctionTests extends PDOMTestBase {
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
ICPPFunction function = (ICPPFunction) bindings[0]; ICPPFunction function = (ICPPFunction) bindings[0];
IParameter[] parameters = function.getParameters(); IParameter[] parameters = function.getParameters();
assertEquals(IBasicType.t_int, ((ICPPBasicType) parameters[0].getType()).getType()); assertEquals(IBasicType.Kind.eInt, ((ICPPBasicType) parameters[0].getType()).getKind());
assertEquals("p1", parameters[0].getName()); assertEquals("p1", parameters[0].getName());
assertEquals(IBasicType.t_char, ((ICPPBasicType) parameters[1].getType()).getType()); assertEquals(IBasicType.Kind.eChar, ((ICPPBasicType) parameters[1].getType()).getKind());
assertEquals("p2", parameters[1].getName()); assertEquals("p2", parameters[1].getName());
assertEquals(IBasicType.t_float, ((ICPPBasicType) parameters[2].getType()).getType()); assertEquals(IBasicType.Kind.eFloat, ((ICPPBasicType) parameters[2].getType()).getKind());
assertEquals("p3", parameters[2].getName()); assertEquals("p3", parameters[2].getName());
} }
@ -127,7 +126,7 @@ public class CPPFunctionTests extends PDOMTestBase {
} }
public void testStaticCPPFunction() throws Exception { public void testStaticCPPFunction() throws Exception {
// static elements cannot be found on global scope, see bug 161216 // Static elements cannot be found in global scope, see bug 161216
IBinding[] bindings = findUnqualifiedName(pdom, "staticCPPFunction"); IBinding[] bindings = findUnqualifiedName(pdom, "staticCPPFunction");
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).isStatic()); assertTrue(((ICPPFunction) bindings[0]).isStatic());

View file

@ -55,7 +55,6 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation;
* @author Doug Schaefer * @author Doug Schaefer
*/ */
public class PDOMTestBase extends BaseTestCase { public class PDOMTestBase extends BaseTestCase {
protected static final IProgressMonitor PROGRESS = new NullProgressMonitor(); protected static final IProgressMonitor PROGRESS = new NullProgressMonitor();
static IPath rootPath = new Path("resources/pdomtests"); static IPath rootPath = new Path("resources/pdomtests");
private String projectName= null; private String projectName= null;
@ -100,7 +99,7 @@ public class PDOMTestBase extends BaseTestCase {
mj.join(); mj.join();
// Index the project // Index the project
CCorePlugin.getIndexManager().setIndexerId(cprojects[0], IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().setIndexerId(cprojects[0], IPDOMManager.ID_FAST_INDEXER);
// wait until the indexer is done // Wait until the indexer is done
try { try {
waitForIndexer(cprojects[0]); waitForIndexer(cprojects[0]);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -210,8 +209,6 @@ public class PDOMTestBase extends BaseTestCase {
assertEquals(visibility, member.getVisibility()); assertEquals(visibility, member.getVisibility());
} }
public static final void assertFunctionRefCount(PDOM pdom, Class[] args, IBinding[] bindingPool, int refCount) throws CoreException { public static final void assertFunctionRefCount(PDOM pdom, Class[] args, IBinding[] bindingPool, int refCount) throws CoreException {
IBinding[] bindings = findIFunctions(args, bindingPool); IBinding[] bindings = findIFunctions(args, bindingPool);
assertEquals(1, bindings.length); assertEquals(1, bindings.length);

View file

@ -45,9 +45,9 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
public class BaseTestCase extends TestCase { public class BaseTestCase extends TestCase {
private boolean fExpectFailure= false; private boolean fExpectFailure;
private int fBugnumber= 0; private int fBugNumber;
private int fExpectedLoggedNonOK= 0; private int fExpectedLoggedNonOK;
public BaseTestCase() { public BaseTestCase() {
super(); super();
@ -213,8 +213,8 @@ public class BaseTestCase extends TestCase {
} }
} else if (r.errorCount() == 0 && r.failureCount() == 0) { } else if (r.errorCount() == 0 && r.failureCount() == 0) {
String err = "Unexpected success of " + getName(); String err = "Unexpected success of " + getName();
if (fBugnumber > 0) { if (fBugNumber > 0) {
err += ", bug #" + fBugnumber; err += ", bug #" + fBugNumber;
} }
result.addFailure(this, new AssertionFailedError(err)); result.addFailure(this, new AssertionFailedError(err));
} }
@ -222,9 +222,9 @@ public class BaseTestCase extends TestCase {
result.endTest(this); result.endTest(this);
} }
public void setExpectFailure(int bugnumber) { public void setExpectFailure(int bugNumber) {
fExpectFailure= true; fExpectFailure= true;
fBugnumber= bugnumber; fBugNumber= bugNumber;
} }
/** /**

View file

@ -11,13 +11,12 @@
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* An implicit name generated on demand. * An AST node that may have implicit names.
* @since 5.1 * @since 5.1
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTImplicitNameOwner extends IASTNode { public interface IASTImplicitNameOwner extends IASTNode {
public static final ASTNodeProperty IMPLICIT_NAME = public static final ASTNodeProperty IMPLICIT_NAME =
new ASTNodeProperty("ICPPASTImplicitNameOwner.IMPLICIT_NAME"); //$NON-NLS-1$ new ASTNodeProperty("ICPPASTImplicitNameOwner.IMPLICIT_NAME"); //$NON-NLS-1$

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* This represents a function in the program. A function is also a scope * This represents a function in the program. A function is also a scope
* for other bindings. * for other bindings.
@ -19,19 +18,18 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IFunction extends IBinding { public interface IFunction extends IBinding {
/** /**
* Returns the formal parameters of the function. * Returns the formal parameters of the function.
*/ */
public IParameter[] getParameters(); public IParameter[] getParameters();
/** /**
* Get the function scope * Returns the function scope
*/ */
public IScope getFunctionScope(); public IScope getFunctionScope();
/** /**
* Get the IFunctionType for this function * Returns the IFunctionType for this function
*/ */
public IFunctionType getType(); public IFunctionType getType();

View file

@ -21,14 +21,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
*/ */
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();

View file

@ -12,13 +12,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.util; package org.eclipse.cdt.core.parser.util;
import java.util.Arrays;
/** /**
* A static utility class for char arrays * A static utility class for char arrays
* @author dschaefe * @author dschaefe
*
*/ */
public class CharArrayUtils { public class CharArrayUtils {
public static final char[] EMPTY = new char[0]; public static final char[] EMPTY = {};
private CharArrayUtils() {} private CharArrayUtils() {}
@ -26,8 +27,9 @@ public class CharArrayUtils {
int h = 0; int h = 0;
int end = start + length; int end = start + length;
for (int curr = start; curr < end; ++curr) for (int curr = start; curr < end; ++curr) {
h += (h << 3) + str[curr]; h += (h << 3) + str[curr];
}
return h; return h;
} }
@ -37,17 +39,7 @@ public class CharArrayUtils {
} }
public static final boolean equals(char[] str1, char[] str2) { public static final boolean equals(char[] str1, char[] str2) {
if (str1 == str2) return Arrays.equals(str1, str2);
return true;
if (str1.length != str2.length)
return false;
for (int i = 0; i < str1.length; ++i)
if (str1[i] != str2[i])
return false;
return true;
} }
public static final boolean equals(char[][] strarr1, char[][] strarr2) { public static final boolean equals(char[][] strarr1, char[][] strarr2) {
@ -55,7 +47,7 @@ public class CharArrayUtils {
return false; return false;
} }
for (int i = 0; i < strarr2.length; i++) { for (int i = 0; i < strarr2.length; i++) {
if (!equals(strarr1[i], strarr2[i])) { if (!Arrays.equals(strarr1[i], strarr2[i])) {
return false; return false;
} }
} }
@ -93,9 +85,10 @@ public class CharArrayUtils {
return false; return false;
if (str1 == str2 && start1 == 0) if (str1 == str2 && start1 == 0)
return true; return true;
for (int i = 0; i < length1; ++i) for (int i = 0; i < length1; ++i) {
if (str1[start1++] != str2[i]) if (str1[start1++] != str2[i])
return false; return false;
}
return true; return true;
} }
@ -107,10 +100,10 @@ public class CharArrayUtils {
if (length1 != str2.length || str1.length < start1 + length1) if (length1 != str2.length || str1.length < start1 + length1)
return false; return false;
for (int i = 0; i < length1; ++i) for (int i = 0; i < length1; ++i) {
if (Character.toLowerCase(str1[start1++]) != Character.toLowerCase(str2[i])) if (Character.toLowerCase(str1[start1++]) != Character.toLowerCase(str2[i]))
return false; return false;
}
return true; return true;
} }
@ -137,11 +130,7 @@ public class CharArrayUtils {
return result; return result;
} }
public static final char[] replace( public static final char[] replace(char[] array, char[] toBeReplaced, char[] replacementChars) {
char[] array,
char[] toBeReplaced,
char[] replacementChars) {
int max = array.length; int max = array.length;
int replacedLength = toBeReplaced.length; int replacedLength = toBeReplaced.length;
int replacementLength = replacementChars.length; int replacementLength = replacementChars.length;
@ -150,7 +139,6 @@ public class CharArrayUtils {
int occurrenceCount = 0; int occurrenceCount = 0;
if (!equals(toBeReplaced, replacementChars)) { if (!equals(toBeReplaced, replacementChars)) {
next: for (int i = 0; i < max; i++) { next: for (int i = 0; i < max; i++) {
int j = 0; int j = 0;
while (j < replacedLength) { while (j < replacedLength) {
@ -160,11 +148,7 @@ public class CharArrayUtils {
continue next; continue next;
} }
if (occurrenceCount == starts.length) { if (occurrenceCount == starts.length) {
System.arraycopy( System.arraycopy(starts, 0, starts = new int[occurrenceCount * 2], 0,
starts,
0,
starts = new int[occurrenceCount * 2],
0,
occurrenceCount); occurrenceCount);
} }
starts[occurrenceCount++] = i; starts[occurrenceCount++] = i;
@ -172,9 +156,7 @@ public class CharArrayUtils {
} }
if (occurrenceCount == 0) if (occurrenceCount == 0)
return array; return array;
char[] result = char[] result = new char[max + occurrenceCount * (replacementLength - replacedLength)];
new char[max
+ occurrenceCount * (replacementLength - replacedLength)];
int inStart = 0, outStart = 0; int inStart = 0, outStart = 0;
for (int i = 0; i < occurrenceCount; i++) { for (int i = 0; i < occurrenceCount; i++) {
int offset = starts[i] - inStart; int offset = starts[i] - inStart;
@ -225,9 +207,10 @@ public class CharArrayUtils {
} }
public static final int indexOf(char toBeFound, char[] array) { public static final int indexOf(char toBeFound, char[] array) {
for (int i = 0; i < array.length; i++) for (int i = 0; i < array.length; i++) {
if (toBeFound == array[i]) if (toBeFound == array[i])
return i; return i;
}
return -1; return -1;
} }
@ -235,9 +218,10 @@ public class CharArrayUtils {
if (start < 0 || start > buffer.length || end > buffer.length) if (start < 0 || start > buffer.length || end > buffer.length)
return -1; return -1;
for (int i = start; i < end; i++) for (int i = start; i < end; i++) {
if (toBeFound == buffer[i]) if (toBeFound == buffer[i])
return i; return i;
}
return -1; return -1;
} }
@ -250,8 +234,9 @@ public class CharArrayUtils {
if (toBeFound[j] == array[i]) { if (toBeFound[j] == array[i]) {
if (++j == toBeFound.length) if (++j == toBeFound.length)
return i - j + 1; return i - j + 1;
} else {
j = 0;
} }
else j = 0;
} }
return -1; return -1;
} }
@ -262,7 +247,9 @@ public class CharArrayUtils {
if (toBeFound[j] == array[i]) { if (toBeFound[j] == array[i]) {
if (--j == -1) if (--j == -1)
return i; return i;
} else j = toBeFound.length - 1; } else {
j = toBeFound.length - 1;
}
} }
return -1; return -1;
} }

View file

@ -27,8 +27,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
public class CExternalFunction extends CFunction implements ICExternalBinding { public class CExternalFunction extends CFunction implements ICExternalBinding {
private static final IType VOID_TYPE = new CBasicType(Kind.eVoid, 0); private static final IType VOID_TYPE = new CBasicType(Kind.eVoid, 0);
private IASTName name = null; private IASTName name;
private IASTTranslationUnit tu = null; private IASTTranslationUnit tu;
public CExternalFunction(IASTTranslationUnit tu, IASTName name) { public CExternalFunction(IASTTranslationUnit tu, IASTName name) {
super(null); super(null);
@ -36,7 +36,6 @@ public class CExternalFunction extends CFunction implements ICExternalBinding {
this.tu = tu; this.tu = tu;
} }
@Override @Override
public IFunctionType getType() { public IFunctionType getType() {
if (type == null) { if (type == null) {

View file

@ -41,7 +41,7 @@ import org.eclipse.core.runtime.PlatformObject;
* Represents a function. * Represents a function.
*/ */
public class CFunction extends PlatformObject implements IFunction, ICInternalFunction { public class CFunction extends PlatformObject implements IFunction, ICInternalFunction {
private IASTDeclarator[] declarators = null; private IASTDeclarator[] declarators;
private IASTFunctionDeclarator definition; private IASTFunctionDeclarator definition;
private static final int FULLY_RESOLVED = 1; private static final int FULLY_RESOLVED = 1;
@ -69,10 +69,11 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
@Override @Override
public IASTDeclarator getPhysicalNode() { public IASTDeclarator getPhysicalNode() {
if (definition != null) if (definition != null) {
return definition; return definition;
else if (declarators != null && declarators.length > 0) } else if (declarators != null && declarators.length > 0) {
return declarators[0]; return declarators[0];
}
return null; return null;
} }
@ -88,10 +89,11 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
} }
protected IASTTranslationUnit getTranslationUnit() { protected IASTTranslationUnit getTranslationUnit() {
if( definition != null ) if (definition != null) {
return definition.getTranslationUnit(); return definition.getTranslationUnit();
else if( declarators != null ) } else if (declarators != null) {
return declarators[0].getTranslationUnit(); return declarators[0].getTranslationUnit();
}
return null; return null;
} }
@ -145,8 +147,8 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
result[i] = (IParameter) decl.getName().resolveBinding(); result[i] = (IParameter) decl.getName().resolveBinding();
} else { } else {
result[i] = new CParameter.CParameterProblem(names[i], result[i] = new CParameter.CParameterProblem(names[i],
IProblemBinding.SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND, names[i] IProblemBinding.SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND,
.toCharArray()); names[i].toCharArray());
} }
} }
} }
@ -162,9 +164,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return CBuiltinParameter.createParameterList(getType()); return CBuiltinParameter.createParameterList(getType());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override @Override
public String getName() { public String getName() {
return getASTName().toString(); return getASTName().toString();
@ -179,9 +178,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return ASTQueries.findInnermostDeclarator(getPhysicalNode()).getName(); return ASTQueries.findInnermostDeclarator(getPhysicalNode()).getName();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
@Override @Override
public IScope getScope() { public IScope getScope() {
IASTDeclarator dtor = getPhysicalNode(); IASTDeclarator dtor = getPhysicalNode();
@ -190,9 +186,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IFunction#getFunctionScope()
*/
@Override @Override
public IScope getFunctionScope() { public IScope getFunctionScope() {
if (definition != null) { if (definition != null) {
@ -302,8 +295,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return binding; return binding;
} }
protected void updateParameterBindings(IASTFunctionDeclarator fdtor) { protected void updateParameterBindings(IASTFunctionDeclarator fdtor) {
IParameter [] params = getParameters(); IParameter [] params = getParameters();
if (fdtor instanceof IASTStandardFunctionDeclarator) { if (fdtor instanceof IASTStandardFunctionDeclarator) {
@ -334,9 +325,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IFunction#isStatic()
*/
@Override @Override
public boolean isStatic() { public boolean isStatic() {
return isStatic(true); return isStatic(true);
@ -372,15 +360,15 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
} }
} }
if( ds != null && ++i < ds.length ) if (ds != null && ++i < ds.length) {
dtor = ds[i]; dtor = ds[i];
else } else {
break; break;
}
} while (dtor != null); } while (dtor != null);
return false; return false;
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return isExtern(true); return isExtern(true);
@ -393,7 +381,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return hasStorageClass(IASTDeclSpecifier.sc_extern); return hasStorageClass(IASTDeclSpecifier.sc_extern);
} }
@Override @Override
public boolean isAuto() { public boolean isAuto() {
if ((bits & FULLY_RESOLVED) == 0) { if ((bits & FULLY_RESOLVED) == 0) {
@ -402,7 +389,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return hasStorageClass(IASTDeclSpecifier.sc_auto); return hasStorageClass(IASTDeclSpecifier.sc_auto);
} }
@Override @Override
public boolean isRegister() { public boolean isRegister() {
if ((bits & FULLY_RESOLVED) == 0) { if ((bits & FULLY_RESOLVED) == 0) {
@ -411,7 +397,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
return hasStorageClass(IASTDeclSpecifier.sc_register); return hasStorageClass(IASTDeclSpecifier.sc_register);
} }
@Override @Override
public boolean isInline() { public boolean isInline() {
if ((bits & FULLY_RESOLVED) == 0) { if ((bits & FULLY_RESOLVED) == 0) {
@ -423,28 +408,30 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
do { do {
if (dtor != null) { if (dtor != null) {
IASTNode parent = dtor.getParent(); IASTNode parent = dtor.getParent();
while( !(parent instanceof IASTDeclaration) ) while (!(parent instanceof IASTDeclaration)) {
parent = parent.getParent(); parent = parent.getParent();
}
IASTDeclSpecifier declSpec = null; IASTDeclSpecifier declSpec = null;
if (parent instanceof IASTSimpleDeclaration) { if (parent instanceof IASTSimpleDeclaration) {
declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier(); declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
} else if( parent instanceof IASTFunctionDefinition ) } else if (parent instanceof IASTFunctionDefinition) {
declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier(); declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier();
}
if (declSpec != null && declSpec.isInline()) if (declSpec != null && declSpec.isInline())
return true; return true;
} }
if( ds != null && ++i < ds.length ) if (ds != null && ++i < ds.length) {
dtor = ds[i]; dtor = ds[i];
else } else {
break; break;
}
} while (dtor != null); } while (dtor != null);
return false; return false;
} }
@Override @Override
public boolean takesVarArgs() { public boolean takesVarArgs() {
if ((bits & FULLY_RESOLVED) == 0) { if ((bits & FULLY_RESOLVED) == 0) {
@ -469,11 +456,12 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
@Override @Override
public void setFullyResolved(boolean resolved) { public void setFullyResolved(boolean resolved) {
if( resolved ) if (resolved) {
bits |= FULLY_RESOLVED; bits |= FULLY_RESOLVED;
else } else {
bits &= ~FULLY_RESOLVED; bits &= ~FULLY_RESOLVED;
} }
}
@Override @Override
public ILinkage getLinkage() { public ILinkage getLinkage() {

View file

@ -57,10 +57,9 @@ import org.eclipse.core.runtime.PlatformObject;
* Binding for c++ function * Binding for c++ function
*/ */
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction { public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
protected IASTDeclarator[] declarations; protected IASTDeclarator[] declarations;
protected ICPPASTFunctionDeclarator definition; protected ICPPASTFunctionDeclarator definition;
protected ICPPFunctionType type = null; protected ICPPFunctionType type;
private static final int FULLY_RESOLVED = 1; private static final int FULLY_RESOLVED = 1;
private static final int RESOLUTION_IN_PROGRESS = 1 << 1; private static final int RESOLUTION_IN_PROGRESS = 1 << 1;

View file

@ -40,9 +40,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
* also used as base class for function instances. * also used as base class for function instances.
*/ */
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction { public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
private ICPPFunctionType type = null; private ICPPFunctionType type;
private ICPPParameter[] fParams = null; private ICPPParameter[] fParams;
private IType[] specializedExceptionSpec = null; private IType[] specializedExceptionSpec;
private final ICPPClassSpecialization fContext; private final ICPPClassSpecialization fContext;
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap) { public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap) {
@ -156,6 +156,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
public boolean isStatic() { public boolean isStatic() {
return isStatic(true); return isStatic(true);
} }
@Override @Override
public boolean isStatic(boolean resolveAll) { public boolean isStatic(boolean resolveAll) {
//TODO resolveAll //TODO resolveAll

View file

@ -45,8 +45,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/ */
public class CPPFunctionTemplate extends CPPTemplateDefinition public class CPPFunctionTemplate extends CPPTemplateDefinition
implements ICPPFunctionTemplate, ICPPInternalFunction { implements ICPPFunctionTemplate, ICPPInternalFunction {
protected ICPPFunctionType type;
protected ICPPFunctionType type = null;
public CPPFunctionTemplate(IASTName name) { public CPPFunctionTemplate(IASTName name) {
super(name); super(name);
@ -171,10 +170,11 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
return true; return true;
} }
} }
if (ns != null && ++i < ns.length) if (ns != null && ++i < ns.length) {
name = (IASTName) ns[i]; name = (IASTName) ns[i];
else } else {
break; break;
}
} while (name != null); } while (name != null);
return false; return false;
} }
@ -284,10 +284,11 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
if (declSpec != null && declSpec.isInline()) if (declSpec != null && declSpec.isInline())
return true; return true;
} }
if (ns != null && ++i < ns.length) if (ns != null && ++i < ns.length) {
name = (IASTName) ns[i]; name = (IASTName) ns[i];
else } else {
break; break;
}
} while (name != null); } while (name != null);
return false; return false;
} }
@ -338,7 +339,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
} }
private IASTDeclarator getDeclaratorByName(IASTNode node) { private IASTDeclarator getDeclaratorByName(IASTNode node) {
// skip qualified names and nested declarators. // Skip qualified names and nested declarators.
while (node != null) { while (node != null) {
node= node.getParent(); node= node.getParent();
if (node instanceof IASTDeclarator) { if (node instanceof IASTDeclarator) {

View file

@ -108,9 +108,7 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
@Override @Override
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(); return getName() + " " + ASTTypeUtil.getParameterTypeString(getType()); //$NON-NLS-1$
result.append(getName()+" "+ASTTypeUtil.getParameterTypeString(getType())); //$NON-NLS-1$
return result.toString();
} }
@Override @Override

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* 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;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
@ -24,7 +23,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
* (const, volatile). * (const, volatile).
*/ */
public class PDOMCAnnotation { public class PDOMCAnnotation {
// Storage class specifiers and function annotations // Storage class specifiers and function annotations
public static final int AUTO_OFFSET = 0; public static final int AUTO_OFFSET = 0;
public static final int EXTERN_OFFSET = 1; public static final int EXTERN_OFFSET = 1;

View file

@ -11,7 +11,6 @@
* 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;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -32,30 +31,25 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*
*/ */
class PDOMCFunction extends PDOMBinding implements IFunction { class PDOMCFunction extends PDOMBinding implements IFunction {
/** /**
* 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).
*/ */
public static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE; public static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE;
/** /**
* 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).
*/ */
public static final int FIRST_PARAM = NUM_PARAMS + 4; public static final int FIRST_PARAM = NUM_PARAMS + 4;
/** /**
* Offset for the type of this function (relative to * Offset for the type of this function (relative to the beginning of the record).
* the beginning of the record).
*/ */
private static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE; private static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
/** /**
* Offset of annotation information (relative to the beginning of the * Offset of annotation information (relative to the beginning of the record).
* record).
*/ */
private static final int ANNOTATIONS = FUNCTION_TYPE + Database.TYPE_SIZE; // byte private static final int ANNOTATIONS = FUNCTION_TYPE + Database.TYPE_SIZE; // byte

View file

@ -37,7 +37,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for c++ functions in the index. * Binding for c++ functions in the index.
*/ */
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader { class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader {
private static final short ANNOT_PARAMETER_PACK = 8; private static final short ANNOT_PARAMETER_PACK = 8;
private static final short ANNOT_IS_DELETED = 9; private static final short ANNOT_IS_DELETED = 9;
@ -70,8 +69,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
protected static final int EXCEPTION_SPEC = SIGNATURE_HASH + 4; // int protected static final int EXCEPTION_SPEC = SIGNATURE_HASH + 4; // int
/** /**
* Offset of annotation information (relative to the beginning of the * Offset of annotation information (relative to the beginning of the record).
* record).
*/ */
private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
@ -183,7 +181,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
IType[] extractExceptionSpec(ICPPFunction binding) { IType[] extractExceptionSpec(ICPPFunction binding) {
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();
@ -197,7 +195,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
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-1; i >= 0; --i) { 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());
@ -241,7 +239,6 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET); return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
} }
@Override @Override
public int getRequiredArgumentCount() { public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) { if (fRequiredArgCount == -1) {

View file

@ -35,20 +35,18 @@ import org.eclipse.core.runtime.CoreException;
*/ */
class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICPPFunction { class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICPPFunction {
/** /**
* 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 = PDOMCPPSpecialization.RECORD_SIZE; private static final int NUM_PARAMS = PDOMCPPSpecialization.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
* the beginning of the record). * of the record).
*/ */
private static final int FIRST_PARAM = NUM_PARAMS + 4; private static final int FIRST_PARAM = NUM_PARAMS + 4;
/** /**
* Offset for type of this function (relative to * Offset for type of this function (relative to the beginning of the record).
* the beginning of the record).
*/ */
private static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE; private static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
@ -58,19 +56,18 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
protected static final int EXCEPTION_SPEC = FUNCTION_TYPE + Database.TYPE_SIZE; // int protected static final int EXCEPTION_SPEC = FUNCTION_TYPE + Database.TYPE_SIZE; // int
/** /**
* Offset of annotation information (relative to the beginning of the * Offset of annotation information (relative to the beginning of the record).
* record).
*/ */
protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short
private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2; private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2;
/** /**
* The size in bytes of a PDOMCPPFunction record in the database. * The size in bytes of a PDOMCPPFunction record in the database.
*/ */
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4; protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4;
private static final short ANNOT_PARAMETER_PACK = 8; private static final short ANNOT_PARAMETER_PACK = 8;
private static final short ANNOT_IS_DELETED = 9; private static final short ANNOT_IS_DELETED = 9;
@ -118,12 +115,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount()); db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount());
long typelist= 0; long typelist= 0;
if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) { if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) {
// don't store the exception specification, computed it on demand. // Don't store the exception specification, it is computed on demand.
} else { } else {
typelist = PDOMCPPTypeList.putTypes(this, astFunction.getExceptionSpecification()); typelist = PDOMCPPTypeList.putTypes(this, astFunction.getExceptionSpecification());
} }
db.putRecPtr(record + EXCEPTION_SPEC, typelist); db.putRecPtr(record + EXCEPTION_SPEC, typelist);
} }
private short getAnnotation(ICPPFunction astFunction) { private short getAnnotation(ICPPFunction astFunction) {
@ -191,7 +187,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
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 PDOMCPPParameterSpecialization par = new PDOMCPPParameterSpecialization(linkage, next, type); final PDOMCPPParameterSpecialization par =
new PDOMCPPParameterSpecialization(linkage, next, type);
next= par.getNextPtr(); next= par.getNextPtr();
result[i]= par; result[i]= par;
} }
@ -247,7 +244,6 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
return getBit(readAnnotation(), PDOMCAnnotation.VARARGS_OFFSET); return getBit(readAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
} }
@Override @Override
public int getRequiredArgumentCount() { public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) { if (fRequiredArgCount == -1) {

View file

@ -24,7 +24,6 @@ import org.eclipse.core.runtime.PlatformObject;
@SuppressWarnings("restriction") @SuppressWarnings("restriction")
public class C99Function extends PlatformObject implements IC99Binding, IFunction, ITypeable { public class C99Function extends PlatformObject implements IC99Binding, IFunction, ITypeable {
private String name; private String name;
private IFunctionType type; private IFunctionType type;
private List<IParameter> parameters = new ArrayList<IParameter>(); private List<IParameter> parameters = new ArrayList<IParameter>();
@ -42,7 +41,6 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio
// the scope that represents the body of the function // the scope that represents the body of the function
private IScope bodyScope; private IScope bodyScope;
public C99Function() { public C99Function() {
} }
@ -55,7 +53,6 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio
this.type = type; this.type = type;
} }
public IParameter[] getParameters() { public IParameter[] getParameters() {
return parameters.toArray(new IParameter[parameters.size()]); return parameters.toArray(new IParameter[parameters.size()]);
} }