1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
Updated AST to better represent pointers to functions/methods.
	Implemented typedef declaration/x-ref infrastructure.  

TESTS
	Updated QuickParseASTTests for pointer to function updates.
	Updated CompleteParseASTTests for typedef work.
This commit is contained in:
John Camelon 2003-07-30 01:31:14 +00:00
parent 3d7a522e3e
commit 57c348fffa
27 changed files with 382 additions and 614 deletions

View file

@ -1,3 +1,7 @@
2003-07-29 John Camelon
Updated QuickParseASTTests for pointer to function updates.
Updated CompleteParseASTTests for typedef work.
2003-07-28 Victor Mozgin 2003-07-28 Victor Mozgin
Moved testBug39546() from ASTFailedTests.java to QuickParseASTTests.java. Moved testBug39546() from ASTFailedTests.java to QuickParseASTTests.java.

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTDeclaration; import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.tests.BaseASTTest; import org.eclipse.cdt.core.parser.tests.BaseASTTest;
@ -323,7 +322,7 @@ public class ASTFailedTests extends BaseASTTest
{ {
try try
{ {
IASTPointerToFunction p2f = (IASTPointerToFunction)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));"); IASTDeclaration d = assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));");
fail( "We should not reach this point"); fail( "We should not reach this point");
} }
catch( ClassCastException cce ) catch( ClassCastException cce )

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.parser.ScannerInfo;
@ -120,6 +121,12 @@ public class BaseASTTest extends TestCase
assertEquals( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).getType(), type ); assertEquals( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).getType(), type );
} }
protected void assertSimpleType(IASTTypedefDeclaration variable, IASTSimpleTypeSpecifier.Type type)
{
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclarator().getTypeSpecifier()).getType(), type );
}
protected void assertSimpleType(IASTVariable variable, IASTSimpleTypeSpecifier.Type type) protected void assertSimpleType(IASTVariable variable, IASTSimpleTypeSpecifier.Type type)
{ {
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), type ); assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), type );

View file

@ -48,8 +48,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
@ -380,20 +378,6 @@ public class CompleteParseASTTest extends TestCase
this.compilationUnit = popScope(); this.compilationUnit = popScope();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
*/
public void acceptPointerToFunction(IASTPointerToFunction function)
{
getCurrentScope().addDeclaration(function);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
*/
public void acceptPointerToMethod(IASTPointerToMethod method)
{
getCurrentScope().addDeclaration(method); }
private Stack scopes = new Stack(); private Stack scopes = new Stack();
@ -796,11 +780,26 @@ public class CompleteParseASTTest extends TestCase
assertEquals( callback.getReferences().size(), 2 ); assertEquals( callback.getReferences().size(), 2 );
} }
// public void testSimpleTypedef() throws Exception public void testSimpleTypedef() throws Exception
// { {
// IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)parse( "typedef int myInt;").getDeclarations().next(); Iterator iter = parse( "typedef int myInt;\n myInt var;").getDeclarations();
// assertEquals( typedef.getName(), "myInt"); IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)iter.next();
// } assertEquals( typedef.getName(), "myInt");
assertEquals( ((IASTSimpleTypeSpecifier)typedef.getAbstractDeclarator().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT );
IASTVariable v = (IASTVariable)iter.next();
assertEquals( v.getName(), "var");
assertEquals( callback.getReferences().size(), 1 );
}
public void testComplexTypedef() throws Exception
{
Iterator declarations = parse( "class A{ }; typedef A ** A_DOUBLEPTR;").getDeclarations();
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)declarations.next();
assertEquals( ((IASTSimpleTypeSpecifier)typedef.getAbstractDeclarator().getTypeSpecifier()).getTypeSpecifier(), classA );
assertEquals( callback.getReferences().size(), 1 );
}
protected void assertQualifiedName(String [] fromAST, String [] theTruth) protected void assertQualifiedName(String [] fromAST, String [] theTruth)
{ {

View file

@ -35,8 +35,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMacro;
import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
@ -433,6 +431,7 @@ public class QuickParseASTTests extends BaseASTTest
parse("typedef void (boo) ( void ); "); parse("typedef void (boo) ( void ); ");
parse("typedef void boo (void); "); parse("typedef void boo (void); ");
} }
public void testBug36769B() throws Exception { public void testBug36769B() throws Exception {
parse("class X { operator int(); } \n"); parse("class X { operator int(); } \n");
parse("class X { operator int*(); } \n"); parse("class X { operator int*(); } \n");
@ -1495,24 +1494,22 @@ public class QuickParseASTTests extends BaseASTTest
code.write( "static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n"); code.write( "static void * (* const orig_malloc_hook)(const char *file, int line, size_t size);\n");
Iterator declarations = parse( code.toString() ).getDeclarations(); Iterator declarations = parse( code.toString() ).getDeclarations();
IASTPointerToFunction p2f = (IASTPointerToFunction)declarations.next(); IASTVariable p2f = (IASTVariable)declarations.next();
assertSimpleReturnType( p2f, IASTSimpleTypeSpecifier.Type.VOID ); assertSimpleType( p2f, IASTSimpleTypeSpecifier.Type.VOID );
assertEquals( p2f.getName(), "name"); assertEquals( p2f.getName(), "name" );
assertEquals( p2f.getPointerOperator(), ASTPointerOperator.POINTER); Iterator parameters = p2f.getAbstractDeclaration().getParameters();
Iterator parameters = p2f.getParameters();
IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.next(); IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.next();
assertFalse( parameters.hasNext() ); assertFalse( parameters.hasNext() );
assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.VOID ); assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.VOID );
assertEquals( parm.getName(), "" ); assertEquals( parm.getName(), "" );
p2f = (IASTPointerToFunction)declarations.next(); p2f = (IASTVariable)declarations.next();
assertSimpleReturnType( p2f, IASTSimpleTypeSpecifier.Type.VOID ); assertSimpleType( p2f, IASTSimpleTypeSpecifier.Type.VOID );
assertTrue( p2f.isStatic() ); assertTrue( p2f.isStatic() );
Iterator rtPo = p2f.getReturnType().getPointerOperators(); Iterator rtPo = p2f.getAbstractDeclaration().getPointerOperators();
assertEquals( rtPo.next(), ASTPointerOperator.POINTER ); assertEquals( rtPo.next(), ASTPointerOperator.POINTER );
assertFalse( rtPo.hasNext() ); assertFalse( rtPo.hasNext() );
assertEquals( p2f.getPointerOperator(), ASTPointerOperator.CONST_POINTER); parameters = p2f.getAbstractDeclaration().getParameters();
parameters = p2f.getParameters();
parm = (IASTParameterDeclaration)parameters.next(); parm = (IASTParameterDeclaration)parameters.next();
assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.CHAR ); assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.CHAR );
assertEquals( parm.getName(), "file" ); assertEquals( parm.getName(), "file" );
@ -1529,13 +1526,12 @@ public class QuickParseASTTests extends BaseASTTest
public void testBug36600() throws Exception public void testBug36600() throws Exception
{ {
IASTPointerToFunction p2f = (IASTPointerToFunction)parse( "enum mad_flow (*input_func)(void *, struct mad_stream *);").getDeclarations().next(); IASTVariable p2f = (IASTVariable)parse( "enum mad_flow (*input_func)(void *, struct mad_stream *);").getDeclarations().next();
IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier)p2f.getReturnType().getTypeSpecifier(); IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier)p2f.getAbstractDeclaration().getTypeSpecifier();
assertEquals( elab.getName(), "mad_flow"); assertEquals( elab.getName(), "mad_flow");
assertEquals( elab.getClassKind(), ASTClassKind.ENUM ); assertEquals( elab.getClassKind(), ASTClassKind.ENUM );
assertEquals( p2f.getPointerOperator(), ASTPointerOperator.POINTER );
assertEquals( p2f.getName(), "input_func"); assertEquals( p2f.getName(), "input_func");
Iterator parms = p2f.getParameters(); Iterator parms = p2f.getAbstractDeclaration().getParameters();
IASTParameterDeclaration parm = (IASTParameterDeclaration)parms.next(); IASTParameterDeclaration parm = (IASTParameterDeclaration)parms.next();
assertEquals( parm.getName(), "" ); assertEquals( parm.getName(), "" );
assertEquals( parm.getPointerOperators().next(), ASTPointerOperator.POINTER); assertEquals( parm.getPointerOperators().next(), ASTPointerOperator.POINTER);
@ -1635,11 +1631,11 @@ public class QuickParseASTTests extends BaseASTTest
public void testPointersToMemberFunctions() throws Exception public void testPointersToMemberFunctions() throws Exception
{ {
IASTPointerToMethod p2m = (IASTPointerToMethod)parse("void (A::*name)(void);").getDeclarations().next(); IASTVariable p2m = (IASTVariable)parse("void (A::*name)(void);").getDeclarations().next();
assertSimpleReturnType( p2m, IASTSimpleTypeSpecifier.Type.VOID ); assertSimpleType( p2m, IASTSimpleTypeSpecifier.Type.VOID );
assertEquals( p2m.getName(), "A::name"); assertEquals( p2m.getName(), "A::name");
assertEquals( p2m.getPointerOperator(), ASTPointerOperator.POINTER); assertEquals( p2m.getAbstractDeclaration().getPointerToFunctionOperator(), ASTPointerOperator.POINTER);
Iterator parameters = p2m.getParameters(); Iterator parameters = p2m.getAbstractDeclaration().getParameters();
IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.next(); IASTParameterDeclaration parm = (IASTParameterDeclaration)parameters.next();
assertFalse( parameters.hasNext() ); assertFalse( parameters.hasNext() );
assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.VOID ); assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.VOID );
@ -1721,4 +1717,38 @@ public class QuickParseASTTests extends BaseASTTest
parse("signed char c = (signed char) 0xffffffff;"); parse("signed char c = (signed char) 0xffffffff;");
assertTrue( quickParseCallback.getCompilationUnit().getDeclarations().hasNext() ); assertTrue( quickParseCallback.getCompilationUnit().getDeclarations().hasNext() );
} }
public void testIndirectDeclarators() throws Exception
{
IASTVariable v = (IASTVariable)parse( "void (*x)( int );").getDeclarations().next();
assertEquals( v.getName(), "x");
assertSimpleType( v, IASTSimpleTypeSpecifier.Type.VOID );
assertParameterSimpleType( (IASTParameterDeclaration)v.getAbstractDeclaration().getParameters().next(), IASTSimpleTypeSpecifier.Type.INT );
assertEquals( v.getAbstractDeclaration().getPointerToFunctionOperator(), ASTPointerOperator.POINTER );
v = (IASTVariable)parse( "const int * (* const something)( const int * const * const );").getDeclarations().next();
assertEquals( v.getName(), "something");
assertEquals( v.getAbstractDeclaration().getPointerToFunctionOperator(), ASTPointerOperator.CONST_POINTER);
assertTrue( v.getAbstractDeclaration().isConst() );
assertSimpleType( v, IASTSimpleTypeSpecifier.Type.INT );
assertEquals( v.getAbstractDeclaration().getPointerOperators().next(), ASTPointerOperator.POINTER );
IASTParameterDeclaration parm = (IASTParameterDeclaration)v.getAbstractDeclaration().getParameters().next();
assertParameterSimpleType( parm, IASTSimpleTypeSpecifier.Type.INT );
Iterator pointerOps = parm.getPointerOperators();
assertEquals( pointerOps.next(), ASTPointerOperator.CONST_POINTER );
assertEquals( pointerOps.next(), ASTPointerOperator.CONST_POINTER );
assertFalse( pointerOps.hasNext() );
IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)parse( "typedef void (*life)(int);").getDeclarations().next();
assertEquals( typedef.getName(), "life");
assertSimpleType( typedef, IASTSimpleTypeSpecifier.Type.VOID );
assertParameterSimpleType( (IASTParameterDeclaration)typedef.getAbstractDeclarator().getParameters().next(), IASTSimpleTypeSpecifier.Type.INT );
IASTFunction f = (IASTFunction)parse( "void (f)(void);").getDeclarations().next();
assertEquals( f.getName(), "f");
typedef = (IASTTypedefDeclaration)parse( "typedef void (life)(int);").getDeclarations().next();
assertEquals( typedef.getName(), "life");
}
} }

View file

@ -28,8 +28,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
@ -892,22 +890,11 @@ public class DOMBuilder implements ISourceElementRequestor
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
*/
public void acceptPointerToFunction(IASTPointerToFunction function)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
*/ */
public void acceptPointerToMethod(IASTPointerToMethod method)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)
*/ */

View file

@ -318,7 +318,7 @@ public class Util {
} else if (existingExternalFiles.contains(externalFile)) { } else if (existingExternalFiles.contains(externalFile)) {
return externalFile; return externalFile;
} else { } else {
//TODO: BOG do we need to add something here? //TODO: BOG do we need to add something here? ANSWER YES!
/* /*
if (JavaModelManager.ZIP_ACCESS_VERBOSE) { if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
System.out.println("(" + Thread.currentThread() + ") [JavaModel.getTarget(...)] Checking existence of " + path.toString()); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println("(" + Thread.currentThread() + ") [JavaModel.getTarget(...)] Checking existence of " + path.toString()); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -35,8 +35,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization; import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
@ -351,20 +349,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
*/
public void acceptPointerToFunction(IASTPointerToFunction function) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
*/
public void acceptPointerToMethod(IASTPointerToMethod method) {
// TODO Auto-generated method stub
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)
*/ */

View file

@ -1,3 +1,7 @@
2003-07-29 John Camelon
Updated AST to better represent pointers to functions/methods.
Implemented typedef declaration/x-ref infrastructure.
2003-07-29 Victor Mozgin 2003-07-29 Victor Mozgin
Fixed PR 39546 : Parser fails on 'signed' casts. Fixed PR 39546 : Parser fails on 'signed' casts.

View file

@ -28,8 +28,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization; import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
@ -95,13 +93,5 @@ public interface ISourceElementRequestor {
public void exitInclusion( IASTInclusion inclusion ); public void exitInclusion( IASTInclusion inclusion );
public void exitCompilationUnit( IASTCompilationUnit compilationUnit ); public void exitCompilationUnit( IASTCompilationUnit compilationUnit );
/**
* @param function
*/
public void acceptPointerToFunction(IASTPointerToFunction function);
/**
* @param method
*/
public void acceptPointerToMethod(IASTPointerToMethod method);
} }

View file

@ -21,6 +21,7 @@ public interface IASTAbstractDeclaration extends IASTTypeSpecifierOwner
public boolean isConst(); public boolean isConst();
public Iterator getPointerOperators(); public Iterator getPointerOperators();
public Iterator getArrayModifiers(); public Iterator getArrayModifiers();
public Iterator getParameters();
public ASTPointerOperator getPointerToFunctionOperator();
} }

View file

@ -139,7 +139,7 @@ public interface IASTFactory
boolean isConst, boolean isConst,
IASTTypeSpecifier typeSpecifier, IASTTypeSpecifier typeSpecifier,
List pointerOperators, List pointerOperators,
List arrayModifiers); List arrayModifiers, List parameters, ASTPointerOperator pointerOperator);
public IASTMethod createMethod( public IASTMethod createMethod(
IASTScope scope, IASTScope scope,
String name, String name,
@ -166,7 +166,7 @@ public interface IASTFactory
public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, ASTAccessVisibility visibility) throws ASTSemanticException; public IASTField createField( IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, ASTAccessVisibility visibility) throws ASTSemanticException;
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause ); public IASTParameterDeclaration createParameterDeclaration( boolean isConst, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause );
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset ); public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset );
@ -176,42 +176,8 @@ public interface IASTFactory
public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset); public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset);
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset ); public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset ) throws ASTSemanticException;
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset); public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
public IASTPointerToFunction createPointerToFunction(
IASTScope scope,
String name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator);
public IASTPointerToMethod createPointerToMethod(
IASTScope scope,
String name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isConstructor,
boolean isDestructor,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility, ASTPointerOperator pointerOperator);
} }

View file

@ -1,20 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
/**
* @author jcamelon
*
*/
public interface IASTPointerToFunction extends IASTFunction, IASTPointerOperatorOwner
{
}

View file

@ -1,20 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
/**
* @author jcamelon
*
*/
public interface IASTPointerToMethod extends IASTMethod, IASTPointerOperatorOwner
{
}

View file

@ -14,19 +14,16 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException; import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTDeclaration; import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTField; import org.eclipse.cdt.core.parser.ast.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.core.parser.ast.IASTFunction;
import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplate; import org.eclipse.cdt.core.parser.ast.IASTTemplate;
@ -318,63 +315,113 @@ public class DeclarationWrapper implements IDeclaratorOwner
boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null ); boolean hasInnerDeclarator = ( declarator.getOwnedDeclarator() != null );
if( hasInnerDeclarator ) if( hasInnerDeclarator )
{ return createIndirectDeclaration( declarator );
ITokenDuple innerPointerName = declarator.getOwnedDeclarator().getPointerOperatorNameDuple();
if( innerPointerName != null && innerPointerName.getLastToken().getType() == IToken.tCOLONCOLON )
return createP2MethodASTNode(declarator);
else
return createP2FunctionASTNode( declarator );
}
if (isTypedef()) if (isTypedef())
return createTypedef(declarator); return createTypedef(declarator, false);
if (isWithinClass ) if (isWithinClass )
{ {
if( isFunction) if( isFunction)
return createMethodASTNode(declarator); return createMethodASTNode(declarator, false);
else else
return createFieldASTNode(declarator); return createFieldASTNode(declarator, false );
} }
else else
{ {
if (isFunction) if (isFunction)
return createFunctionASTNode(declarator); return createFunctionASTNode(declarator, false);
else else
return createVariableASTNode(declarator); return createVariableASTNode(declarator, false);
} }
} }
/** /**
* @param declarator * @param declarator
* @return * @return
*/ */
private IASTTypedefDeclaration createTypedef(Declarator declarator) private IASTDeclaration createIndirectDeclaration(Declarator declarator) throws ASTSemanticException
{
if( declarator.getOwnedDeclarator().getOwnedDeclarator() == null )
{
Declarator d = declarator.getOwnedDeclarator();
Iterator i = d.getPtrOps().iterator();
if( !i.hasNext() )
{
boolean isWithinClass = scope instanceof IASTClassSpecifier;
boolean isFunction = (declarator.getParameters().size() != 0);
if (isTypedef())
return createTypedef(declarator, true);
if (isWithinClass )
{
if( isFunction)
return createMethodASTNode(declarator, true);
else
return createFieldASTNode(declarator, true );
}
else
{
if (isFunction)
return createFunctionASTNode(declarator, true);
else
return createVariableASTNode(declarator, true);
}
}
List convertedParms = createParameterList( declarator.getParameters() );
IASTAbstractDeclaration abs = astFactory.createAbstractDeclaration(
constt, getTypeSpecifier(), declarator.getPtrOps(), declarator.getArrayModifiers(), convertedParms,
(ASTPointerOperator)i.next() );
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
if( typedef )
return astFactory.createTypedef(
scope,
name,
abs, getStartingOffset(), d.getNameStartOffset() );
else
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), d.getNameStartOffset() );
}
else
{
throw new ASTSemanticException();
}
}
/**
* @param declarator
* @return
*/
private IASTTypedefDeclaration createTypedef(Declarator declarator, boolean nested ) throws ASTSemanticException
{ {
return astFactory.createTypedef( return astFactory.createTypedef(
scope, scope,
declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers()), startingOffset, declarator.getNameStartOffset()); declarator.getArrayModifiers(), null, null), startingOffset, declarator.getNameStartOffset());
} }
/** /**
* @param declarator * @param declarator
* @return * @return
*/ */
private IASTMethod createMethodASTNode(Declarator declarator) throws ASTSemanticException private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{ {
return astFactory return astFactory
.createMethod( .createMethod(
scope, scope,
declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
createParameterList(declarator.getParameters()), createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers()), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(), declarator.getExceptionSpecification(),
inline, inline,
friend, friend,
@ -396,17 +443,17 @@ public class DeclarationWrapper implements IDeclaratorOwner
* @param declarator * @param declarator
* @return * @return
*/ */
private IASTFunction createFunctionASTNode(Declarator declarator) throws ASTSemanticException private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{ {
return astFactory.createFunction( return astFactory.createFunction(
scope, scope,
declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
createParameterList(declarator.getParameters()), createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration( astFactory.createAbstractDeclaration(
constt, constt,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers()), declarator.getArrayModifiers(), null, null),
declarator.getExceptionSpecification(), declarator.getExceptionSpecification(),
inline, inline,
friend, friend,
@ -419,11 +466,11 @@ public class DeclarationWrapper implements IDeclaratorOwner
* @param declarator * @param declarator
* @return * @return
*/ */
private IASTField createFieldASTNode(Declarator declarator) throws ASTSemanticException private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{ {
return astFactory.createField( return astFactory.createField(
scope, scope,
declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
auto, auto,
declarator.getInitializerClause(), declarator.getInitializerClause(),
declarator.getBitFieldExpression(), declarator.getBitFieldExpression(),
@ -431,7 +478,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
constt, constt,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers()), declarator.getArrayModifiers(), null, null),
mutable, mutable,
extern, extern,
register, register,
@ -457,10 +504,10 @@ public class DeclarationWrapper implements IDeclaratorOwner
wrapper.getTypeSpecifier(), wrapper.getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers(), declarator.getArrayModifiers(),
declarator.getName() == null null,
? "" null, declarator.getName() == null
: declarator.getName(), ? ""
declarator.getInitializerClause())); : declarator.getName(), declarator.getInitializerClause()));
} }
} }
return result; return result;
@ -469,11 +516,11 @@ public class DeclarationWrapper implements IDeclaratorOwner
* @param declarator * @param declarator
* @return * @return
*/ */
private IASTVariable createVariableASTNode(Declarator declarator) throws ASTSemanticException private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException
{ {
return astFactory.createVariable( return astFactory.createVariable(
scope, scope,
declarator.getName(), nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
isAuto(), isAuto(),
declarator.getInitializerClause(), declarator.getInitializerClause(),
declarator.getBitFieldExpression(), declarator.getBitFieldExpression(),
@ -481,7 +528,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
constt, constt,
getTypeSpecifier(), getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers()), declarator.getArrayModifiers(), null, null),
mutable, mutable,
extern, extern,
register, register,
@ -490,67 +537,6 @@ public class DeclarationWrapper implements IDeclaratorOwner
declarator.getNameStartOffset()); declarator.getNameStartOffset());
} }
/**
* @param declarator
* @return
*/
private IASTPointerToMethod createP2MethodASTNode(Declarator declarator)
{
return astFactory
.createPointerToMethod(
scope,
declarator.getOwnedDeclarator().getPointerOperatorNameDuple().toString().trim() +
declarator.getOwnedDeclarator().getName().trim(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
getTypeSpecifier(),
declarator.getPtrOps(),
declarator.getArrayModifiers()),
declarator.getExceptionSpecification(),
inline,
friend,
staticc,
startingOffset,
declarator.getOwnedDeclarator().getNameStartOffset(),
templateDeclaration,
declarator.isConst(),
declarator.isVolatile(),
false,
// isConstructor
false, // isDestructor
virtual,
explicit,
declarator.isPureVirtual(),
((scope instanceof IASTClassSpecifier )? ((IASTClassSpecifier)scope).getCurrentVisibilityMode() : ASTAccessVisibility.PUBLIC )
, (ASTPointerOperator)declarator.getOwnedDeclarator().getPtrOps().get(0));
}
/**
* @param declarator
* @return
*/
private IASTPointerToFunction createP2FunctionASTNode(Declarator declarator)
{
return astFactory.createPointerToFunction(
scope,
declarator.getOwnedDeclarator().getName(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
getTypeSpecifier(),
declarator.getPtrOps(),
declarator.getArrayModifiers()),
declarator.getExceptionSpecification(),
inline,
friend,
staticc,
startingOffset,
declarator.getOwnedDeclarator().getNameStartOffset(),
templateDeclaration, (ASTPointerOperator)declarator.getOwnedDeclarator().getPtrOps().get(0));
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IDeclaratorOwner#getDeclarationWrapper() * @see org.eclipse.cdt.internal.core.parser.IDeclaratorOwner#getDeclarationWrapper()
*/ */

View file

@ -20,8 +20,6 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTMethodReference; import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation; import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization; import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
@ -333,23 +331,8 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTPointerToFunction)
*/
public void acceptPointerToFunction(IASTPointerToFunction function)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTPointerToMethod)
*/
public void acceptPointerToMethod(IASTPointerToMethod method)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference) * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)

View file

@ -595,10 +595,10 @@ public class Parser implements IParser
wrapper.getTypeSpecifier(), wrapper.getTypeSpecifier(),
declarator.getPtrOps(), declarator.getPtrOps(),
declarator.getArrayModifiers(), declarator.getArrayModifiers(),
declarator.getName() == null null,
? "" null, declarator.getName() == null
: declarator.getName(), ? ""
declarator.getInitializerClause()), : declarator.getName(), declarator.getInitializerClause()),
null)); null));
} }
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
@ -22,22 +23,26 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
*/ */
public class ASTAbstractDeclaration implements IASTAbstractDeclaration public class ASTAbstractDeclaration implements IASTAbstractDeclaration
{ {
private final boolean isConst; private final List parms;
private final boolean isConst;
private final IASTTypeSpecifier typeSpecifier; private final IASTTypeSpecifier typeSpecifier;
private final List pointerOperators; private final List pointerOperators;
private final List arrayModifiers; private final List arrayModifiers;
private final ASTPointerOperator pointerOperator;
/** /**
* @param isConst * @param isConst
* @param typeSpecifier * @param typeSpecifier
* @param pointerOperators * @param pointerOperators
* @param arrayModifiers * @param arrayModifiers
*/ */
public ASTAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers) public ASTAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp )
{ {
this.isConst = isConst; this.isConst = isConst;
this.typeSpecifier = typeSpecifier; this.typeSpecifier = typeSpecifier;
this.pointerOperators = pointerOperators; this.pointerOperators = pointerOperators;
this.arrayModifiers = arrayModifiers; this.arrayModifiers = arrayModifiers;
this.parms = parameters;
this.pointerOperator = pointerOp;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst() * @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst()
@ -67,4 +72,18 @@ public class ASTAbstractDeclaration implements IASTAbstractDeclaration
{ {
return arrayModifiers.iterator(); return arrayModifiers.iterator();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getParameters()
*/
public Iterator getParameters()
{
return parms.iterator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerToFunctionOperator()
*/
public ASTPointerOperator getPointerToFunctionOperator()
{
return pointerOperator;
}
} }

View file

@ -10,9 +10,9 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast; package org.eclipse.cdt.internal.core.parser.ast;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
@ -21,12 +21,9 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
* @author jcamelon * @author jcamelon
* *
*/ */
public class ASTParameterDeclaration implements IASTParameterDeclaration public class ASTParameterDeclaration extends ASTAbstractDeclaration implements IASTParameterDeclaration
{ {
private final boolean isConst;
private final IASTTypeSpecifier typeSpecifier;
private final List pointerOperators;
private final List arrayModifiers;
private final String parameterName; private final String parameterName;
private final IASTInitializerClause initializerClause; private final IASTInitializerClause initializerClause;
/** /**
@ -37,12 +34,9 @@ public class ASTParameterDeclaration implements IASTParameterDeclaration
* @param parameterName * @param parameterName
* @param initializerClause * @param initializerClause
*/ */
public ASTParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause) public ASTParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
{ {
this.isConst = isConst; super( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp );
this.typeSpecifier = typeSpecifier;
this.pointerOperators = pointerOperators;
this.arrayModifiers = arrayModifiers;
this.parameterName = parameterName; this.parameterName = parameterName;
this.initializerClause = initializerClause; this.initializerClause = initializerClause;
} }
@ -60,32 +54,4 @@ public class ASTParameterDeclaration implements IASTParameterDeclaration
{ {
return initializerClause; return initializerClause;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#isConst()
*/
public boolean isConst()
{
return isConst;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getTypeSpecifier()
*/
public IASTTypeSpecifier getTypeSpecifier()
{
return typeSpecifier;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getPointerOperators()
*/
public Iterator getPointerOperators()
{
return pointerOperators.iterator();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration#getArrayModifiers()
*/
public Iterator getArrayModifiers()
{
return arrayModifiers.iterator();
}
} }

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.ast.IASTInclusion;
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause; import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
@ -48,14 +49,14 @@ public class BaseASTFactory {
return inclusion; return inclusion;
} }
public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers) public IASTAbstractDeclaration createAbstractDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOperator)
{ {
return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers ); return new ASTAbstractDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOperator );
} }
public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, String parameterName, IASTInitializerClause initializerClause) public IASTParameterDeclaration createParameterDeclaration(boolean isConst, IASTTypeSpecifier typeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause)
{ {
return new ASTParameterDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameterName, initializerClause ); return new ASTParameterDeclaration( isConst, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOp, parameterName, initializerClause );
} }

View file

@ -10,121 +10,137 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.complete; package org.eclipse.cdt.internal.core.parser.ast.complete;
import java.util.List;
import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
/** /**
* @author jcamelon * @author jcamelon
* *
*/ */
public class ASTTypedef implements IASTTypedefDeclaration public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration
{ {
private final IASTAbstractDeclaration mapping;
private NamedOffsets offsets = new NamedOffsets();
private final ASTQualifiedNamedElement qualifiedName;
private final ASTReferenceStore referenceStore;
/** /**
* * @param newSymbol
* @param mapping
* @param startingOffset
* @param nameOffset
* @param references
*/ */
public ASTTypedef() public ASTTypedef(ISymbol newSymbol, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset, List references)
{ {
super(); super( newSymbol );
// TODO Auto-generated constructor stub this.mapping = mapping;
this.referenceStore = new ASTReferenceStore( references );
this.qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), newSymbol.getName());
setStartingOffset(startingOffset);
setNameOffset(nameOffset);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName() * @see org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration#getName()
*/ */
public String getName() public String getName()
{ {
// TODO Auto-generated method stub return getSymbol().getName();
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration#getAbstractDeclarator() * @see org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration#getAbstractDeclarator()
*/ */
public IASTAbstractDeclaration getAbstractDeclarator() public IASTAbstractDeclaration getAbstractDeclarator()
{ {
// TODO Auto-generated method stub return mapping;
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
*/
public int getNameOffset()
{
// TODO Auto-generated method stub
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
*/
public void setNameOffset(int o)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
*/
public String[] getFullyQualifiedName()
{
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope()
*/
public IASTScope getOwnerScope()
{
// TODO Auto-generated method stub
return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor) * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/ */
public void acceptElement(ISourceElementRequestor requestor) public void acceptElement(ISourceElementRequestor requestor)
{ {
// TODO Auto-generated method stub requestor.acceptTypedefDeclaration(this);
referenceStore.processReferences(requestor);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor) * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/ */
public void enterScope(ISourceElementRequestor requestor) public void enterScope(ISourceElementRequestor requestor)
{ {
// TODO Auto-generated method stub
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor) * @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/ */
public void exitScope(ISourceElementRequestor requestor) public void exitScope(ISourceElementRequestor requestor)
{ {
// TODO Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getNameOffset()
*/
public int getNameOffset()
{
return offsets.getNameOffset();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
*/
public void setNameOffset(int o)
{
offsets.setNameOffset(o);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
*/ */
public void setStartingOffset(int o) public void setStartingOffset(int o)
{ {
// TODO Auto-generated method stub offsets.setStartingOffset(o);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
*/ */
public void setEndingOffset(int o) public void setEndingOffset(int o)
{ {
// TODO Auto-generated method stub offsets.setEndingOffset(o);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset() * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getStartingOffset()
*/ */
public int getStartingOffset() public int getStartingOffset()
{ {
// TODO Auto-generated method stub return offsets.getStartingOffset();
return 0;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset() * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getEndingOffset()
*/ */
public int getEndingOffset() public int getEndingOffset()
{ {
// TODO Auto-generated method stub return offsets.getEndingOffset();
return 0;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName()
*/
public String[] getFullyQualifiedName()
{
return qualifiedName.getFullyQualifiedName();
}
} }

View file

@ -0,0 +1,62 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.complete;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
/**
* @author jcamelon
*
*/
public class ASTTypedefReference
extends ASTReference
implements IASTTypedefReference
{
private final IASTTypedefDeclaration referencedItem;
/**
* @param offset
* @param name
*/
public ASTTypedefReference(int offset, String name, IASTTypedefDeclaration referencedItem )
{
super(offset, name);
this.referencedItem = referencedItem;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
*/
public ISourceElementCallbackDelegate getReferencedElement()
{
return referencedItem;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/
public void acceptElement(ISourceElementRequestor requestor)
{
requestor.acceptTypedefReference(this);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/
public void enterScope(ISourceElementRequestor requestor)
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
*/
public void exitScope(ISourceElementRequestor requestor)
{
}
}

View file

@ -38,8 +38,6 @@ import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
@ -432,6 +430,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
return new ASTClassReference( offset, string, (IASTClassSpecifier)symbol.getASTExtension().getPrimaryDeclaration() ); return new ASTClassReference( offset, string, (IASTClassSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
} }
else if( symbol.getTypeInfo().checkBit( TypeInfo.isTypedef ))
{
return new ASTTypedefReference( offset, string, (IASTTypedefDeclaration)symbol.getASTExtension().getPrimaryDeclaration());
}
else if( symbol.getType() == TypeInfo.t_enumeration ) else if( symbol.getType() == TypeInfo.t_enumeration )
return new ASTEnumerationReference( offset, string, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() ); return new ASTEnumerationReference( offset, string, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
else if( symbol.getType() == TypeInfo.t_function ) else if( symbol.getType() == TypeInfo.t_function )
@ -1137,10 +1139,36 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
String name, String name,
IASTAbstractDeclaration mapping, IASTAbstractDeclaration mapping,
int startingOffset, int startingOffset,
int nameOffset) int nameOffset) throws ASTSemanticException
{ {
// TODO Auto-generated method stub IContainerSymbol containerSymbol = scopeToSymbol(scope);
return new ASTTypedef(); ISymbol newSymbol = pst.newSymbol( name, TypeInfo.t_type);
newSymbol.getTypeInfo().setBit( true,TypeInfo.isTypedef );
List references = new ArrayList();
if( mapping.getTypeSpecifier() instanceof ASTSimpleTypeSpecifier )
{
references.addAll( ((ASTSimpleTypeSpecifier)mapping.getTypeSpecifier()).getReferences() );
}
try
{
containerSymbol.addSymbol( newSymbol );
}
catch (ParserSymbolTableException e)
{
throw new ASTSemanticException();
}
ASTTypedef d = new ASTTypedef( newSymbol, mapping, startingOffset, nameOffset, references );
try
{
attachSymbolExtension(newSymbol, d );
}
catch (ExtensionException e1)
{
throw new ASTSemanticException();
}
return d;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, org.eclipse.cdt.core.parser.ast.IASTTemplate, int, int) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, org.eclipse.cdt.core.parser.ast.IASTTemplate, int, int)
@ -1154,54 +1182,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
return new ASTAbstractTypeSpecifierDeclaration( scopeToSymbol(scope), typeSpecifier, template, startingOffset, endingOffset); return new ASTAbstractTypeSpecifierDeclaration( scopeToSymbol(scope), typeSpecifier, template, startingOffset, endingOffset);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
*/
public IASTPointerToFunction createPointerToFunction(
IASTScope scope,
String name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate,
ASTPointerOperator pointerOperator)
{
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, org.eclipse.cdt.core.parser.ast.ASTPointerOperator)
*/
public IASTPointerToMethod createPointerToMethod(
IASTScope scope,
String name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
boolean isFriend,
boolean isStatic,
int startOffset,
int nameOffset,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
boolean isConstructor,
boolean isDestructor,
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
ASTAccessVisibility visibility,
ASTPointerOperator pointerOperator)
{
// TODO Auto-generated method stub
return null;
}
protected ParserSymbolTable pst = new ParserSymbolTable(); protected ParserSymbolTable pst = new ParserSymbolTable();
} }

View file

@ -1,72 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.quick;
import java.util.List;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
/**
* @author jcamelon
*
*/
public class ASTPointerToFunction
extends ASTFunction
implements IASTPointerToFunction
{
private final ASTPointerOperator pointerOperator;
/**
* @param scope
* @param name
* @param parameters
* @param returnType
* @param exception
* @param isInline
* @param isFriend
* @param isStatic
* @param startOffset
* @param nameOffset
* @param ownerTemplate
*/
public ASTPointerToFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator)
{
super(
scope,
name,
parameters,
returnType,
exception,
isInline,
isFriend,
isStatic,
startOffset,
nameOffset,
ownerTemplate);
this.pointerOperator = pointerOperator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTPointerOperatorOwner#getPointerOperator()
*/
public ASTPointerOperator getPointerOperator()
{
return pointerOperator;
}
}

View file

@ -1,87 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.quick;
import java.util.List;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
/**
* @author jcamelon
*
*/
public class ASTPointerToMethod
extends ASTMethod
implements IASTPointerToMethod
{
private final ASTPointerOperator pointerOperator;
/**
* @param scope
* @param name
* @param parameters
* @param returnType
* @param exception
* @param isInline
* @param isFriend
* @param isStatic
* @param startOffset
* @param nameOffset
* @param ownerTemplate
* @param isConst
* @param isVolatile
* @param isConstructor
* @param isDestructor
* @param isVirtual
* @param isExplicit
* @param isPureVirtual
* @param visibility
*/
public ASTPointerToMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, ASTPointerOperator pointerOperator)
{
super(
scope,
name,
parameters,
returnType,
exception,
isInline,
isFriend,
isStatic,
startOffset,
nameOffset,
ownerTemplate,
isConst,
isVolatile,
isConstructor,
isDestructor,
isVirtual,
isExplicit,
isPureVirtual,
visibility);
this.pointerOperator = pointerOperator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTPointerOperatorOwner#getPointerOperator()
*/
public ASTPointerOperator getPointerOperator()
{
return pointerOperator;
}
}

View file

@ -15,7 +15,6 @@ import java.util.List;
import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.ASTClassKind;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException; import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
@ -37,8 +36,6 @@ import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTMethod;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTTemplate; import org.eclipse.cdt.core.parser.ast.IASTTemplate;
@ -288,19 +285,5 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
return new ASTAbstractTypeSpecifierDeclaration( scope, typeSpecifier, template, startingOffset, endingOffset ); return new ASTAbstractTypeSpecifierDeclaration( scope, typeSpecifier, template, startingOffset, endingOffset );
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate)
*/
public IASTPointerToFunction createPointerToFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, ASTPointerOperator pointerOperator)
{
return new ASTPointerToFunction( scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, pointerOperator);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createPointerToMethod(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplate, boolean, boolean, boolean, boolean, boolean, boolean, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
*/
public IASTPointerToMethod createPointerToMethod(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isConstructor, boolean isDestructor, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, ASTPointerOperator pointerOperator)
{
return new ASTPointerToMethod(scope, name, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate, isConst, isVolatile, isConstructor, isDestructor, isVirtual, isExplicit, isPureVirtual, visibility, pointerOperator);
}
} }

View file

@ -75,8 +75,6 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) { } public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef) { }
public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {} public void acceptAbstractTypeSpecDeclaration(IASTAbstractTypeSpecifierDeclaration abstractDeclaration) {}
public void acceptPointerToFunction(IASTPointerToFunction function) {}
public void acceptPointerToMethod(IASTPointerToMethod method) { }
public void acceptTypedefReference( IASTTypedefReference reference ) { } public void acceptTypedefReference( IASTTypedefReference reference ) { }
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) { } public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) { }