1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +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.
*/
public class CFunctionTests extends PDOMTestBase {
protected ICProject project;
protected PDOM pdom;
@ -81,7 +80,7 @@ public class CFunctionTests extends PDOMTestBase {
IFunction f= (IFunction) bindings[0];
IParameter[] params= f.getParameters();
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[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.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
* Tests for verifying whether the PDOM correctly stores information about
* C++ non-member functions.
*/
public class CPPFunctionTests extends PDOMTestBase {
protected ICProject project;
protected PDOM pdom;
@ -58,13 +56,14 @@ public class CPPFunctionTests extends PDOMTestBase {
protected void tearDown() throws Exception {
pdom.releaseReadLock();
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 {
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);
assertInstance(b[0], ICPPVariable.class);
ICPPVariable v= (ICPPVariable) b[0];
@ -103,11 +102,11 @@ public class CPPFunctionTests extends PDOMTestBase {
assertEquals(1, bindings.length);
ICPPFunction function = (ICPPFunction) bindings[0];
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(IBasicType.t_char, ((ICPPBasicType) parameters[1].getType()).getType());
assertEquals(IBasicType.Kind.eChar, ((ICPPBasicType) parameters[1].getType()).getKind());
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());
}
@ -127,7 +126,7 @@ public class CPPFunctionTests extends PDOMTestBase {
}
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");
assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).isStatic());

View file

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

View file

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

View file

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

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* This represents a function in the program. A function is also a scope
* 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.
*/
public interface IFunction extends IBinding {
/**
* Returns the formal parameters of the function.
*/
public IParameter[] getParameters();
/**
* Get the function scope
* Returns the function scope
*/
public IScope getFunctionScope();
/**
* Get the IFunctionType for this function
* Returns the IFunctionType for this function
*/
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.
*/
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();
/**
* is this an inline function
* Is this an inline function
*/
@Override
public boolean isInline();

View file

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

View file

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

View file

@ -57,10 +57,9 @@ import org.eclipse.core.runtime.PlatformObject;
* Binding for c++ function
*/
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
protected IASTDeclarator[] declarations;
protected ICPPASTFunctionDeclarator definition;
protected ICPPFunctionType type = null;
protected ICPPFunctionType type;
private static final int FULLY_RESOLVED = 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.
*/
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
private ICPPFunctionType type = null;
private ICPPParameter[] fParams = null;
private IType[] specializedExceptionSpec = null;
private ICPPFunctionType type;
private ICPPParameter[] fParams;
private IType[] specializedExceptionSpec;
private final ICPPClassSpecialization fContext;
public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap) {
@ -156,6 +156,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
public boolean isStatic() {
return isStatic(true);
}
@Override
public boolean isStatic(boolean 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
implements ICPPFunctionTemplate, ICPPInternalFunction {
protected ICPPFunctionType type = null;
protected ICPPFunctionType type;
public CPPFunctionTemplate(IASTName name) {
super(name);
@ -171,10 +170,11 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
return true;
}
}
if (ns != null && ++i < ns.length)
if (ns != null && ++i < ns.length) {
name = (IASTName) ns[i];
else
} else {
break;
}
} while (name != null);
return false;
}
@ -284,10 +284,11 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
if (declSpec != null && declSpec.isInline())
return true;
}
if (ns != null && ++i < ns.length)
if (ns != null && ++i < ns.length) {
name = (IASTName) ns[i];
else
} else {
break;
}
} while (name != null);
return false;
}
@ -338,7 +339,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
}
private IASTDeclarator getDeclaratorByName(IASTNode node) {
// skip qualified names and nested declarators.
// Skip qualified names and nested declarators.
while (node != null) {
node= node.getParent();
if (node instanceof IASTDeclarator) {

View file

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

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -24,7 +23,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
* (const, volatile).
*/
public class PDOMCAnnotation {
// Storage class specifiers and function annotations
public static final int AUTO_OFFSET = 0;
public static final int EXTERN_OFFSET = 1;

View file

@ -11,7 +11,6 @@
* Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin;
@ -32,30 +31,25 @@ import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
*/
class PDOMCFunction extends PDOMBinding implements IFunction {
/**
* Offset of total number of function parameters (relative to the
* beginning of the record).
* Offset of total number of function parameters (relative to the beginning of the record).
*/
public static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE;
/**
* Offset of total number of function parameters (relative to the
* beginning of the record).
* Offset of total number of function parameters (relative to the beginning of the record).
*/
public static final int FIRST_PARAM = NUM_PARAMS + 4;
/**
* Offset for the type of this function (relative to
* the beginning of the record).
* Offset for the type of this function (relative to the beginning of the record).
*/
private static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
/**
* Offset of annotation information (relative to the beginning of the
* record).
* Offset of annotation information (relative to the beginning of the record).
*/
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.
*/
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader {
private static final short ANNOT_PARAMETER_PACK = 8;
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
/**
* Offset of annotation information (relative to the beginning of the
* record).
* Offset of annotation information (relative to the beginning of the record).
*/
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[] exceptionSpec;
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;
} else {
exceptionSpec= binding.getExceptionSpecification();
@ -197,7 +195,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
db.putInt(record + NUM_PARAMS, params.length);
db.putRecPtr(record + FIRST_PARAM, 0);
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);
}
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);
}
@Override
public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) {

View file

@ -35,20 +35,18 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICPPFunction {
/**
* Offset of total number of function parameters (relative to the
* beginning of the record).
* Offset of total number of function parameters (relative to the beginning of the record).
*/
private static final int NUM_PARAMS = PDOMCPPSpecialization.RECORD_SIZE;
/**
* Offset of pointer to the first parameter of this function (relative to
* the beginning of the record).
* Offset of pointer to the first parameter of this function (relative to the beginning
* of the record).
*/
private static final int FIRST_PARAM = NUM_PARAMS + 4;
/**
* Offset for type of this function (relative to
* the beginning of the record).
* Offset for type of this function (relative to the beginning of the record).
*/
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
/**
* Offset of annotation information (relative to the beginning of the
* record).
* Offset of annotation information (relative to the beginning of the record).
*/
protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short
private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2;
/**
* The size in bytes of a PDOMCPPFunction record in the database.
*/
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4;
private static final short ANNOT_PARAMETER_PACK = 8;
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());
long typelist= 0;
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 {
typelist = PDOMCPPTypeList.putTypes(this, astFunction.getExceptionSpecification());
}
db.putRecPtr(record + EXCEPTION_SPEC, typelist);
}
private short getAnnotation(ICPPFunction astFunction) {
@ -191,7 +187,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
long next = db.getRecPtr(record + FIRST_PARAM);
for (int i = 0; i < n && next != 0; i++) {
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();
result[i]= par;
}
@ -247,7 +244,6 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
return getBit(readAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
}
@Override
public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) {

View file

@ -24,7 +24,6 @@ import org.eclipse.core.runtime.PlatformObject;
@SuppressWarnings("restriction")
public class C99Function extends PlatformObject implements IC99Binding, IFunction, ITypeable {
private String name;
private IFunctionType type;
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
private IScope bodyScope;
public C99Function() {
}
@ -55,7 +53,6 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio
this.type = type;
}
public IParameter[] getParameters() {
return parameters.toArray(new IParameter[parameters.size()]);
}