mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
7415f69a91
27 changed files with 396 additions and 449 deletions
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Symbian - Fix a race condition (157992)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Symbian - Fix a race condition (157992)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -223,16 +220,16 @@ public class PDOMTestBase extends BaseTestCase {
|
|||
public static IBinding[] findIFunctions(Class[] paramTypes, IBinding[] bindings) throws CoreException {
|
||||
List preresult = new ArrayList();
|
||||
for (IBinding binding : bindings) {
|
||||
if(binding instanceof IFunction) {
|
||||
if (binding instanceof IFunction) {
|
||||
IFunction function = (IFunction) binding;
|
||||
IType[] candidate = function.getType().getParameterTypes();
|
||||
boolean areEqual = candidate.length == paramTypes.length;
|
||||
for(int j=0; areEqual && j<paramTypes.length; j++) {
|
||||
if(!paramTypes[j].isAssignableFrom(candidate[j].getClass())) {
|
||||
for (int j= 0; areEqual && j < paramTypes.length; j++) {
|
||||
if (!paramTypes[j].isAssignableFrom(candidate[j].getClass())) {
|
||||
areEqual = false;
|
||||
}
|
||||
}
|
||||
if(areEqual) {
|
||||
if (areEqual) {
|
||||
preresult.add(binding);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +239,7 @@ public class PDOMTestBase extends BaseTestCase {
|
|||
|
||||
protected void assertInstance(Object o, Class c) {
|
||||
assertNotNull(o);
|
||||
assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
|
||||
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
||||
}
|
||||
|
||||
public static Pattern[] makePatternArray(String[] args) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.testplugin.util;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,18 +6,17 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Mike Kucera (IBM) - Initial API and implementation
|
||||
* Mike Kucera (IBM) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
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$
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
|
@ -16,7 +16,6 @@ package org.eclipse.cdt.core.parser;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IToken {
|
||||
|
||||
// getters
|
||||
public int getType();
|
||||
public String getImage();
|
||||
|
@ -29,7 +28,6 @@ public interface IToken {
|
|||
public void setNext(IToken t);
|
||||
public void setType(int i);
|
||||
|
||||
|
||||
// Token types
|
||||
int FIRST_RESERVED_PREPROCESSOR= -200;
|
||||
int LAST_RESERVED_PREPROCESSOR= -101;
|
||||
|
@ -39,7 +37,6 @@ public interface IToken {
|
|||
/** @since 5.2 */
|
||||
int t_PRAGMA = 5200;
|
||||
|
||||
|
||||
int tIDENTIFIER = 1;
|
||||
int tINTEGER = 2;
|
||||
int tCOLONCOLON = 3;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -89,28 +81,29 @@ public class CharArrayUtils {
|
|||
}
|
||||
|
||||
public static final boolean equals(char[] str1, int start1, int length1, char[] str2) {
|
||||
if (length1 != str2.length || str1.length < length1+start1 )
|
||||
if (length1 != str2.length || str1.length < length1 + start1)
|
||||
return false;
|
||||
if( str1 == str2 && start1 == 0 )
|
||||
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;
|
||||
}
|
||||
|
||||
public static final boolean equals(char[] str1, int start1, int length1, char[] str2, boolean ignoreCase ) {
|
||||
if( !ignoreCase )
|
||||
return equals( str1, start1, length1, str2 );
|
||||
public static final boolean equals(char[] str1, int start1, int length1, char[] str2, boolean ignoreCase) {
|
||||
if (!ignoreCase)
|
||||
return equals(str1, start1, length1, str2);
|
||||
|
||||
if (length1 != str2.length || str1.length < start1 + length1 )
|
||||
if (length1 != str2.length || str1.length < start1 + length1)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < length1; ++i)
|
||||
if( Character.toLowerCase(str1[start1++]) != Character.toLowerCase( str2[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,8 +139,7 @@ public class CharArrayUtils {
|
|||
int occurrenceCount = 0;
|
||||
|
||||
if (!equals(toBeReplaced, replacementChars)) {
|
||||
|
||||
next : for (int i = 0; i < max; i++) {
|
||||
next: for (int i = 0; i < max; i++) {
|
||||
int j = 0;
|
||||
while (j < replacedLength) {
|
||||
if (i + j == max)
|
||||
|
@ -160,21 +148,15 @@ public class CharArrayUtils {
|
|||
continue next;
|
||||
}
|
||||
if (occurrenceCount == starts.length) {
|
||||
System.arraycopy(
|
||||
starts,
|
||||
0,
|
||||
starts = new int[occurrenceCount * 2],
|
||||
0,
|
||||
occurrenceCount);
|
||||
System.arraycopy(starts, 0, starts = new int[occurrenceCount * 2], 0,
|
||||
occurrenceCount);
|
||||
}
|
||||
starts[occurrenceCount++] = i;
|
||||
}
|
||||
}
|
||||
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,44 +207,49 @@ 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;
|
||||
}
|
||||
|
||||
public static int indexOf( char toBeFound, char[] buffer, int start, int end ) {
|
||||
if( start < 0 || start > buffer.length || end > buffer.length )
|
||||
public static int indexOf(char toBeFound, char[] buffer, int start, int end) {
|
||||
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;
|
||||
}
|
||||
|
||||
public static final int indexOf( char[] toBeFound, char[] array ){
|
||||
if( toBeFound.length > array.length )
|
||||
public static final int indexOf(char[] toBeFound, char[] array) {
|
||||
if (toBeFound.length > array.length)
|
||||
return -1;
|
||||
|
||||
int j = 0;
|
||||
for( int i = 0; i < array.length; i++ ){
|
||||
if( toBeFound[j] == array[i] ){
|
||||
if( ++j == toBeFound.length )
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (toBeFound[j] == array[i]) {
|
||||
if (++j == toBeFound.length)
|
||||
return i - j + 1;
|
||||
} else {
|
||||
j = 0;
|
||||
}
|
||||
else j = 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static final int lastIndexOf(char[] toBeFound, char[] array) {
|
||||
int j = toBeFound.length - 1;
|
||||
for (int i = array.length; --i >= 0;){
|
||||
if (toBeFound[j] == array[i]){
|
||||
if( --j == -1 )
|
||||
for (int i = array.length; --i >= 0;) {
|
||||
if (toBeFound[j] == array[i]) {
|
||||
if (--j == -1)
|
||||
return i;
|
||||
} else j = toBeFound.length - 1;
|
||||
} else {
|
||||
j = toBeFound.length - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -296,11 +283,11 @@ public class CharArrayUtils {
|
|||
* @param i
|
||||
* @param charImage
|
||||
*/
|
||||
public static void overWrite( char[] buff, int i, char[] charImage ) {
|
||||
if( buff.length < i + charImage.length )
|
||||
public static void overWrite(char[] buff, int i, char[] charImage) {
|
||||
if (buff.length < i + charImage.length)
|
||||
return;
|
||||
for( int j = 0; j < charImage.length; j++ ){
|
||||
buff[ i + j ] = charImage[j];
|
||||
for (int j = 0; j < charImage.length; j++) {
|
||||
buff[i + j] = charImage[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,7 +296,7 @@ public class CharArrayUtils {
|
|||
* @return offset where the array was found or <code>-1</code>
|
||||
*/
|
||||
public static int indexOf(final char[] searchFor, final char[][] searchIn) {
|
||||
for (int i=0; i < searchIn.length; i++) {
|
||||
for (int i = 0; i < searchIn.length; i++) {
|
||||
if (equals(searchIn[i], searchFor)) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -27,16 +27,15 @@ 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 );
|
||||
public CExternalFunction(IASTTranslationUnit tu, IASTName name) {
|
||||
super(null);
|
||||
this.name = name;
|
||||
this.tu = tu;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IFunctionType getType() {
|
||||
if (type == null) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -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,19 +89,20 @@ 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;
|
||||
}
|
||||
|
||||
private void resolveAllDeclarations(){
|
||||
if( (bits & (FULLY_RESOLVED | RESOLUTION_IN_PROGRESS)) == 0 ){
|
||||
private void resolveAllDeclarations() {
|
||||
if ((bits & (FULLY_RESOLVED | RESOLUTION_IN_PROGRESS)) == 0) {
|
||||
bits |= RESOLUTION_IN_PROGRESS;
|
||||
IASTTranslationUnit tu = getTranslationUnit();
|
||||
if( tu != null ){
|
||||
CVisitor.getDeclarations( tu, this );
|
||||
if (tu != null) {
|
||||
CVisitor.getDeclarations(tu, this);
|
||||
}
|
||||
declarators = ArrayUtil.trim(IASTDeclarator.class, declarators);
|
||||
bits |= FULLY_RESOLVED;
|
||||
|
@ -113,7 +115,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
*/
|
||||
@Override
|
||||
public IParameter[] getParameters() {
|
||||
int j=-1;
|
||||
int j= -1;
|
||||
int len = declarators != null ? declarators.length : 0;
|
||||
for (IASTDeclarator dtor = definition; j < len; j++) {
|
||||
if (j >= 0) {
|
||||
|
@ -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,16 +164,13 @@ 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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNameCharArray(){
|
||||
public char[] getNameCharArray() {
|
||||
return getASTName().toCharArray();
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -224,66 +217,66 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
return null;
|
||||
}
|
||||
|
||||
public IBinding resolveParameter( IASTName paramName ){
|
||||
if( paramName.getBinding() != null )
|
||||
public IBinding resolveParameter(IASTName paramName) {
|
||||
if (paramName.getBinding() != null)
|
||||
return paramName.getBinding();
|
||||
|
||||
IBinding binding = null;
|
||||
int idx = 0;
|
||||
IASTNode parent = paramName.getParent();
|
||||
while( parent instanceof IASTDeclarator && !(parent instanceof ICASTKnRFunctionDeclarator ) )
|
||||
while (parent instanceof IASTDeclarator && !(parent instanceof ICASTKnRFunctionDeclarator))
|
||||
parent = parent.getParent();
|
||||
|
||||
ICASTKnRFunctionDeclarator fKnRDtor = null;
|
||||
IASTDeclarator knrParamDtor = null;
|
||||
if( parent instanceof IASTParameterDeclaration ){
|
||||
if (parent instanceof IASTParameterDeclaration) {
|
||||
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) parent.getParent();
|
||||
IASTParameterDeclaration [] ps = fdtor.getParameters();
|
||||
for( ; idx < ps.length; idx++ ){
|
||||
if( parent == ps[idx] )
|
||||
for (; idx < ps.length; idx++) {
|
||||
if (parent == ps[idx])
|
||||
break;
|
||||
}
|
||||
} else if( parent instanceof IASTSimpleDeclaration ){
|
||||
} else if (parent instanceof IASTSimpleDeclaration) {
|
||||
//KnR: name in declaration list
|
||||
fKnRDtor = (ICASTKnRFunctionDeclarator) parent.getParent();
|
||||
IASTName [] ps = fKnRDtor.getParameterNames();
|
||||
char [] n = paramName.toCharArray();
|
||||
for( ; idx < ps.length; idx++ ){
|
||||
if( CharArrayUtils.equals( ps[idx].toCharArray(), n ) )
|
||||
for (; idx < ps.length; idx++) {
|
||||
if (CharArrayUtils.equals(ps[idx].toCharArray(), n))
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//KnR: name in name list
|
||||
fKnRDtor = (ICASTKnRFunctionDeclarator) parent;
|
||||
IASTName [] ps = fKnRDtor.getParameterNames();
|
||||
for( ; idx < ps.length; idx++ ){
|
||||
if( ps[idx] == paramName)
|
||||
for (; idx < ps.length; idx++) {
|
||||
if (ps[idx] == paramName)
|
||||
break;
|
||||
}
|
||||
knrParamDtor = CVisitor.getKnRParameterDeclarator( fKnRDtor, paramName );
|
||||
if( knrParamDtor != null )
|
||||
knrParamDtor = CVisitor.getKnRParameterDeclarator(fKnRDtor, paramName);
|
||||
if (knrParamDtor != null)
|
||||
paramName = knrParamDtor.getName();
|
||||
}
|
||||
|
||||
//create a new binding and set it for the corresponding parameter in all known defns and decls
|
||||
binding = new CParameter( paramName );
|
||||
binding = new CParameter(paramName);
|
||||
IASTParameterDeclaration temp = null;
|
||||
if( definition != null ){
|
||||
if( definition instanceof IASTStandardFunctionDeclarator ){
|
||||
if (definition != null) {
|
||||
if (definition instanceof IASTStandardFunctionDeclarator) {
|
||||
IASTParameterDeclaration [] parameters = ((IASTStandardFunctionDeclarator)definition).getParameters();
|
||||
if( parameters.length > idx ) {
|
||||
if (parameters.length > idx) {
|
||||
temp = parameters[idx];
|
||||
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding( binding );
|
||||
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding(binding);
|
||||
}
|
||||
} else if( definition instanceof ICASTKnRFunctionDeclarator ){
|
||||
} else if (definition instanceof ICASTKnRFunctionDeclarator) {
|
||||
fKnRDtor = (ICASTKnRFunctionDeclarator) definition;
|
||||
IASTName [] parameterNames = fKnRDtor.getParameterNames();
|
||||
if( parameterNames.length > idx ) {
|
||||
if (parameterNames.length > idx) {
|
||||
IASTName n = parameterNames[idx];
|
||||
n.setBinding( binding );
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( fKnRDtor, n );
|
||||
if( dtor != null ){
|
||||
dtor.getName().setBinding( binding );
|
||||
n.setBinding(binding);
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator(fKnRDtor, n);
|
||||
if (dtor != null) {
|
||||
dtor.getName().setBinding(binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,9 +285,9 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
for (IASTDeclarator dtor : declarators) {
|
||||
if (dtor instanceof IASTStandardFunctionDeclarator) {
|
||||
IASTStandardFunctionDeclarator fdtor= (IASTStandardFunctionDeclarator) dtor;
|
||||
if( fdtor.getParameters().length > idx ){
|
||||
if (fdtor.getParameters().length > idx) {
|
||||
temp = fdtor.getParameters()[idx];
|
||||
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding( binding );
|
||||
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding(binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -302,41 +295,36 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
return binding;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void updateParameterBindings( IASTFunctionDeclarator fdtor ){
|
||||
protected void updateParameterBindings(IASTFunctionDeclarator fdtor) {
|
||||
IParameter [] params = getParameters();
|
||||
if( fdtor instanceof IASTStandardFunctionDeclarator ){
|
||||
if (fdtor instanceof IASTStandardFunctionDeclarator) {
|
||||
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
||||
if(params.length < nps.length )
|
||||
if (params.length < nps.length)
|
||||
return;
|
||||
for( int i = 0; i < nps.length; i++ ){
|
||||
for (int i = 0; i < nps.length; i++) {
|
||||
IASTName name = ASTQueries.findInnermostDeclarator(nps[i].getDeclarator()).getName();
|
||||
name.setBinding( params[i] );
|
||||
if( params[i] instanceof CParameter )
|
||||
((CParameter)params[i]).addDeclaration( name );
|
||||
name.setBinding(params[i]);
|
||||
if (params[i] instanceof CParameter)
|
||||
((CParameter)params[i]).addDeclaration(name);
|
||||
}
|
||||
} else {
|
||||
IASTName [] ns = ((ICASTKnRFunctionDeclarator)fdtor).getParameterNames();
|
||||
if( params.length > 0 && params.length != ns.length )
|
||||
if (params.length > 0 && params.length != ns.length)
|
||||
return; //problem
|
||||
|
||||
for( int i = 0; i < params.length; i++ ){
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
IASTName name = ns[i];
|
||||
name.setBinding( params[i] );
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) fdtor, name );
|
||||
if( dtor != null ){
|
||||
dtor.getName().setBinding( params[i] );
|
||||
if( params[i] instanceof CParameter )
|
||||
((CParameter)params[i]).addDeclaration( dtor.getName() );
|
||||
name.setBinding(params[i]);
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator((ICASTKnRFunctionDeclarator) fdtor, name);
|
||||
if (dtor != null) {
|
||||
dtor.getName().setBinding(params[i]);
|
||||
if (params[i] instanceof CParameter)
|
||||
((CParameter)params[i]).addDeclaration(dtor.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IFunction#isStatic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return isStatic(true);
|
||||
|
@ -344,107 +332,106 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
|
||||
@Override
|
||||
public boolean isStatic(boolean resolveAll) {
|
||||
if( resolveAll && (bits & FULLY_RESOLVED) == 0 ){
|
||||
if (resolveAll && (bits & FULLY_RESOLVED) == 0) {
|
||||
resolveAllDeclarations();
|
||||
}
|
||||
return hasStorageClass( IASTDeclSpecifier.sc_static );
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
||||
}
|
||||
|
||||
public boolean hasStorageClass( int storage){
|
||||
public boolean hasStorageClass(int storage) {
|
||||
IASTDeclarator dtor = definition;
|
||||
IASTDeclarator[] ds = declarators;
|
||||
|
||||
int i = -1;
|
||||
do{
|
||||
if( dtor != null ){
|
||||
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 ){
|
||||
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.getStorageClass() == storage ) {
|
||||
if (declSpec != null && declSpec.getStorageClass() == storage) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( ds != null && ++i < ds.length )
|
||||
if (ds != null && ++i < ds.length) {
|
||||
dtor = ds[i];
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
} while( dtor != null );
|
||||
}
|
||||
} while (dtor != null);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return isExtern(true);
|
||||
}
|
||||
|
||||
public boolean isExtern(boolean resolveAll) {
|
||||
if( resolveAll && (bits & FULLY_RESOLVED) == 0 ){
|
||||
if (resolveAll && (bits & FULLY_RESOLVED) == 0) {
|
||||
resolveAllDeclarations();
|
||||
}
|
||||
return hasStorageClass( IASTDeclSpecifier.sc_extern);
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
if( (bits & FULLY_RESOLVED) == 0 ){
|
||||
if ((bits & FULLY_RESOLVED) == 0) {
|
||||
resolveAllDeclarations();
|
||||
}
|
||||
return hasStorageClass( IASTDeclSpecifier.sc_auto);
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
if( (bits & FULLY_RESOLVED) == 0 ){
|
||||
if ((bits & FULLY_RESOLVED) == 0) {
|
||||
resolveAllDeclarations();
|
||||
}
|
||||
return hasStorageClass( IASTDeclSpecifier.sc_register);
|
||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
if( (bits & FULLY_RESOLVED) == 0 ){
|
||||
if ((bits & FULLY_RESOLVED) == 0) {
|
||||
resolveAllDeclarations();
|
||||
}
|
||||
IASTDeclarator dtor = definition;
|
||||
IASTDeclarator[] ds = declarators;
|
||||
int i = -1;
|
||||
do{
|
||||
if( dtor != null ){
|
||||
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 ){
|
||||
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() )
|
||||
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 );
|
||||
}
|
||||
} while (dtor != null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean takesVarArgs() {
|
||||
if ((bits & FULLY_RESOLVED) == 0) {
|
||||
|
@ -469,10 +456,11 @@ 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
|
||||
|
|
|
@ -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;
|
||||
|
@ -575,8 +574,8 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
|
||||
public static int getRequiredArgumentCount(ICPPParameter[] pars) {
|
||||
int result= pars.length;
|
||||
while(result > 0) {
|
||||
final ICPPParameter p = pars[result-1];
|
||||
while (result > 0) {
|
||||
final ICPPParameter p = pars[result - 1];
|
||||
if (p.hasDefaultValue() || p.isParameterPack()) {
|
||||
result--;
|
||||
} else {
|
||||
|
@ -592,6 +591,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
@Override
|
||||
public boolean hasParameterPack() {
|
||||
ICPPParameter[] pars= getParameters();
|
||||
return pars.length > 0 && pars[pars.length-1].isParameterPack();
|
||||
return pars.length > 0 && pars[pars.length - 1].isParameterPack();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -139,7 +139,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
IASTNode def = getDefinition();
|
||||
while (!(def instanceof IASTFunctionDefinition))
|
||||
def = def.getParent();
|
||||
return ((IASTFunctionDefinition)def).getDeclSpecifier().isInline();
|
||||
return ((IASTFunctionDefinition) def).getDeclSpecifier().isInline();
|
||||
}
|
||||
return getFunction().isInline();
|
||||
}
|
||||
|
@ -156,12 +156,13 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
public boolean isStatic() {
|
||||
return isStatic(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic(boolean resolveAll) {
|
||||
//TODO resolveAll
|
||||
IBinding f = getSpecializedBinding();
|
||||
if (f instanceof ICPPInternalFunction)
|
||||
return ((ICPPInternalFunction)f).isStatic(resolveAll);
|
||||
return ((ICPPInternalFunction) f).isStatic(resolveAll);
|
||||
if (f instanceof IIndexBinding && f instanceof ICPPFunction) {
|
||||
return ((ICPPFunction) f).isStatic();
|
||||
}
|
||||
|
@ -325,8 +326,8 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
IType[] types = function.getExceptionSpecification();
|
||||
if (types != null) {
|
||||
IType[] specializedTypeList = new IType[types.length];
|
||||
int j=0;
|
||||
for (int i=0; i<types.length; ++i) {
|
||||
int j= 0;
|
||||
for (int i= 0; i < types.length; ++i) {
|
||||
final IType origType = types[i];
|
||||
if (origType instanceof ICPPParameterPackType) {
|
||||
IType[] specialized= specializeTypePack((ICPPParameterPackType) origType);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -143,7 +142,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
|||
while (parent.getParent() instanceof IASTDeclarator)
|
||||
parent = parent.getParent();
|
||||
|
||||
IType t = getNestedType(CPPVisitor.createType((IASTDeclarator)parent), TDEF);
|
||||
IType t = getNestedType(CPPVisitor.createType((IASTDeclarator) parent), TDEF);
|
||||
if (t instanceof ICPPFunctionType) {
|
||||
type = (ICPPFunctionType) t;
|
||||
} else if (t instanceof ISemanticProblem){
|
||||
|
@ -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,11 +284,12 @@ 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);
|
||||
}
|
||||
} 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) {
|
||||
|
@ -375,7 +376,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
|
|||
}
|
||||
|
||||
IType[] typeIds = new IType[astTypeIds.length];
|
||||
for (int i=0; i<astTypeIds.length; ++i) {
|
||||
for (int i = 0; i < astTypeIds.length; ++i) {
|
||||
typeIds[i] = CPPVisitor.createType(astTypeIds[i]);
|
||||
}
|
||||
return typeIds;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.c;
|
||||
|
||||
|
@ -31,9 +31,9 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
|
|||
|
||||
@Override
|
||||
public IParameter[] getParameters() {
|
||||
IParameter[] preResult = ((IFunction)rbinding).getParameters();
|
||||
IParameter[] preResult = ((IFunction) rbinding).getParameters();
|
||||
IParameter[] result = new IParameter[preResult.length];
|
||||
for(int i=0; i<preResult.length; i++) {
|
||||
for (int i= 0; i < preResult.length; i++) {
|
||||
result[i] = (IParameter) cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
|
||||
}
|
||||
return result;
|
||||
|
@ -41,37 +41,37 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
|
|||
|
||||
@Override
|
||||
public IFunctionType getType() {
|
||||
IType rtype = ((IFunction)rbinding).getType();
|
||||
IType rtype = ((IFunction) rbinding).getType();
|
||||
return (IFunctionType) cf.getCompositeType(rtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return ((IFunction)rbinding).isAuto();
|
||||
return ((IFunction) rbinding).isAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return ((IFunction)rbinding).isExtern();
|
||||
return ((IFunction) rbinding).isExtern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return ((IFunction)rbinding).isInline();
|
||||
return ((IFunction) rbinding).isInline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return ((IFunction)rbinding).isRegister();
|
||||
return ((IFunction) rbinding).isRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return ((IFunction)rbinding).isStatic();
|
||||
return ((IFunction) rbinding).isStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takesVarArgs() {
|
||||
return ((IFunction)rbinding).takesVarArgs();
|
||||
return ((IFunction) rbinding).takesVarArgs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -28,17 +28,17 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
|||
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return ((ICPPFunction)rbinding).isExternC();
|
||||
return ((ICPPFunction) rbinding).isExternC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return ((ICPPFunction)rbinding).isInline();
|
||||
return ((ICPPFunction) rbinding).isInline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return ((ICPPFunction)rbinding).isMutable();
|
||||
return ((ICPPFunction) rbinding).isMutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +48,8 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
|||
|
||||
@Override
|
||||
public ICPPParameter[] getParameters() {
|
||||
ICPPParameter[] result = ((ICPPFunction)rbinding).getParameters();
|
||||
for(int i=0; i<result.length; i++) {
|
||||
ICPPParameter[] result = ((ICPPFunction) rbinding).getParameters();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPParameter) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
|
@ -57,48 +57,48 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
|
|||
|
||||
@Override
|
||||
public ICPPFunctionType getType() {
|
||||
IType rtype = ((ICPPFunction)rbinding).getType();
|
||||
IType rtype = ((ICPPFunction) rbinding).getType();
|
||||
return (ICPPFunctionType) cf.getCompositeType(rtype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return ((ICPPFunction)rbinding).isDeleted();
|
||||
return ((ICPPFunction) rbinding).isDeleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return ((ICPPFunction)rbinding).isAuto();
|
||||
return ((ICPPFunction) rbinding).isAuto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return ((ICPPFunction)rbinding).isExtern();
|
||||
return ((ICPPFunction) rbinding).isExtern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return ((ICPPFunction)rbinding).isRegister();
|
||||
return ((ICPPFunction) rbinding).isRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return ((ICPPFunction)rbinding).isStatic();
|
||||
return ((ICPPFunction) rbinding).isStatic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takesVarArgs() {
|
||||
return ((ICPPFunction)rbinding).takesVarArgs();
|
||||
return ((ICPPFunction) rbinding).takesVarArgs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredArgumentCount() {
|
||||
return ((ICPPFunction)rbinding).getRequiredArgumentCount();
|
||||
return ((ICPPFunction) rbinding).getRequiredArgumentCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameterPack() {
|
||||
return ((ICPPFunction)rbinding).hasParameterPack();
|
||||
return ((ICPPFunction) rbinding).hasParameterPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,14 +108,12 @@ 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
|
||||
public IType[] getExceptionSpecification() {
|
||||
IType[] es= ((ICPPFunction)rbinding).getExceptionSpecification();
|
||||
IType[] es= ((ICPPFunction) rbinding).getExceptionSpecification();
|
||||
if (es == null || es.length == 0)
|
||||
return es;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class Token implements IToken, Cloneable {
|
|||
|
||||
@Override
|
||||
final public int getLength() {
|
||||
return fEndOffset-fOffset;
|
||||
return fEndOffset - fOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,6 @@ public class Token implements IToken, Cloneable {
|
|||
return fNextToken;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
final public void setType(int kind) {
|
||||
fKind= kind;
|
||||
|
@ -73,8 +72,8 @@ public class Token implements IToken, Cloneable {
|
|||
}
|
||||
|
||||
public void shiftOffset(int shift) {
|
||||
fOffset+= shift;
|
||||
fEndOffset+= shift;
|
||||
fOffset += shift;
|
||||
fEndOffset += shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* 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
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -102,10 +100,10 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
private short getAnnotation(ICPPFunction function) {
|
||||
int annot= PDOMCPPAnnotation.encodeAnnotation(function) & 0xff;
|
||||
if (function.hasParameterPack()) {
|
||||
annot |= (1<<ANNOT_PARAMETER_PACK);
|
||||
annot |= (1 << ANNOT_PARAMETER_PACK);
|
||||
}
|
||||
if (function.isDeleted()) {
|
||||
annot |= (1<<ANNOT_IS_DELETED);
|
||||
annot |= (1 << ANNOT_IS_DELETED);
|
||||
}
|
||||
return (short) annot;
|
||||
}
|
||||
|
@ -134,7 +132,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
newBindingRequiredArgCount= func.getRequiredArgumentCount();
|
||||
|
||||
fType= null;
|
||||
linkage.storeType(record+FUNCTION_TYPE, newType);
|
||||
linkage.storeType(record + FUNCTION_TYPE, newType);
|
||||
|
||||
PDOMCPPParameter oldParams= getFirstParameter(null);
|
||||
int requiredCount;
|
||||
|
@ -167,7 +165,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
|
||||
fRequiredArgCount= requiredCount;
|
||||
|
||||
long oldRec = db.getRecPtr(record+EXCEPTION_SPEC);
|
||||
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
|
||||
storeExceptionSpec(extractExceptionSpec(func));
|
||||
if (oldRec != 0) {
|
||||
PDOMCPPTypeList.clearTypes(this, oldRec);
|
||||
|
@ -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());
|
||||
|
@ -205,7 +203,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
|
||||
private void setType(ICPPFunctionType ft) throws CoreException {
|
||||
fType= null;
|
||||
getLinkage().storeType(record+FUNCTION_TYPE, ft);
|
||||
getLinkage().storeType(record + FUNCTION_TYPE, ft);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +239,6 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRequiredArgumentCount() {
|
||||
if (fRequiredArgCount == -1) {
|
||||
|
@ -309,7 +306,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
public final ICPPFunctionType getType() {
|
||||
if (fType == null) {
|
||||
try {
|
||||
fType= (ICPPFunctionType) getLinkage().loadType(record+FUNCTION_TYPE);
|
||||
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
|
@ -385,7 +382,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
try {
|
||||
final long rec = getPDOM().getDB().getRecPtr(record+EXCEPTION_SPEC);
|
||||
final long rec = getPDOM().getDB().getRecPtr(record + EXCEPTION_SPEC);
|
||||
return PDOMCPPTypeList.getTypes(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -102,7 +99,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
|||
PDOMCPPParameterSpecialization next= null;
|
||||
for (int i= length-1; i >= 0; --i) {
|
||||
// There may be fewer or less original parameters, because of parameter packs.
|
||||
if (i < origAstParams.length-1) {
|
||||
if (i < origAstParams.length - 1) {
|
||||
// Normal case
|
||||
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
|
||||
} else if (origPar == null) {
|
||||
|
@ -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) {
|
||||
|
@ -132,7 +128,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
|||
annot |= (1 << ANNOT_PARAMETER_PACK);
|
||||
}
|
||||
if (astFunction.isDeleted()) {
|
||||
annot |= (1<<ANNOT_IS_DELETED);
|
||||
annot |= (1 << ANNOT_IS_DELETED);
|
||||
}
|
||||
return (short) annot;
|
||||
}
|
||||
|
@ -190,8 +186,9 @@ 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);
|
||||
IType type= i < ptypes.length ? ptypes[i] : null;
|
||||
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) {
|
||||
|
@ -291,7 +287,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
|||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
try {
|
||||
final long rec = getPDOM().getDB().getRecPtr(record+EXCEPTION_SPEC);
|
||||
final long rec = getPDOM().getDB().getRecPtr(record + EXCEPTION_SPEC);
|
||||
return PDOMCPPTypeList.getTypes(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
|
@ -58,10 +58,10 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
|||
public static final String GDB_7_2_VERSION = "7.2"; //$NON-NLS-1$
|
||||
/** @since 4.1 */
|
||||
public static final String GDB_7_2_1_VERSION = "7.2.1"; //$NON-NLS-1$
|
||||
|
||||
// Keep private until GDB 7.4 is released and we can change the constant
|
||||
// to its proper value of 7.4
|
||||
private static final String GDB_7_4_VERSION = "7.3.50"; //$NON-NLS-1$
|
||||
/** @since 4.1 */
|
||||
public static final String GDB_7_3_VERSION = "7.3"; //$NON-NLS-1$
|
||||
/** @since 4.1 */
|
||||
public static final String GDB_7_4_VERSION = "7.4"; //$NON-NLS-1$
|
||||
|
||||
private final String fVersion;
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ public class ExpressionVMProvider extends AbstractDMVMProvider
|
|||
|
||||
@Override
|
||||
public void expressionsAdded(IExpression[] expressions) {
|
||||
expressionsListChanged(ExpressionsChangedEvent.Type.ADDED, expressions, -1);
|
||||
expressionsListChanged(ExpressionsChangedEvent.Type.ADDED, expressions, DebugPlugin.getDefault().getExpressionManager().getExpressions().length - expressions.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -157,8 +157,13 @@ public class ExpressionVMProviderModelProxyStrategy extends DefaultVMModelProxyS
|
|||
case ADDED:
|
||||
// New expressions are always added one element before last.
|
||||
// Last element is the "Add new expression" element.
|
||||
// Note: Index should be calculated when the IExpressionListener.expressionsAdded
|
||||
// is called. If it's not, try to calculate it here based on parent count.
|
||||
int parentCount = parentDelta.getChildCount();
|
||||
parentDelta.addNode(element, parentCount > 1 ? parentCount - 2 : -1, IModelDelta.ADDED);
|
||||
if (elementIdx == -1 && parentCount > 1) {
|
||||
elementIdx = parentCount - 2;
|
||||
}
|
||||
parentDelta.addNode(element, elementIdx, IModelDelta.ADDED);
|
||||
break;
|
||||
case CHANGED:
|
||||
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
|
||||
|
|
|
@ -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()]);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue