mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Fixed Bug 39542 : Parser fails on 'struct' parameter types Fixed Bug 39549 : Designated initializers are not supported (ANSI C99) Fixed Bug 39551 : Complex and imaginary numbers are not supported (ANSI C99) TESTS Moved testBug39542() from ASTFailedTests to QuickParseASTTests. Moved testBug39549() from ASTFailedTests to QuickParseASTTests. Added testCDesignatedInitializers() to CompleteParseASTTests. Moved testBug39551A() from ASTFailedTests to QuickParseASTTests. Moved testBug39551B() from ASTFailedTests to QuickParseASTTests. Added testCBool() to QuickParseASTTests. Added testBug39551A(), testBug39551B() and testCBool to CompleteParseTests.
This commit is contained in:
parent
303306e897
commit
5be9f16c62
33 changed files with 889 additions and 184 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2003-10-24 John Camelon
|
||||||
|
Moved testBug39542() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
Moved testBug39549() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
Added testCDesignatedInitializers() to CompleteParseASTTests.
|
||||||
|
Moved testBug39551A() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
Moved testBug39551B() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
Added testCBool() to QuickParseASTTests.
|
||||||
|
Added testBug39551A(), testBug39551B() and testCBool to CompleteParseTests.
|
||||||
|
|
||||||
2003-10-22 Hoda Amer
|
2003-10-22 Hoda Amer
|
||||||
Added offset checking in CModelElementsTest
|
Added offset checking in CModelElementsTest
|
||||||
|
|
||||||
|
|
|
@ -36,30 +36,6 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
assertCodeFailsParse("FUNCTION_MACRO( 1, a )\n int i;");
|
assertCodeFailsParse("FUNCTION_MACRO( 1, a )\n int i;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testBug39542() throws Exception
|
|
||||||
{
|
|
||||||
assertCodeFailsParse("void f(int a, struct {int b[a];} c) {}");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Here starts C99-specific section
|
|
||||||
public void testBug39549() throws Exception
|
|
||||||
{
|
|
||||||
assertCodeFailsParse("struct X x = { .b = 40, .z = {} };");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug39551A() throws Exception
|
|
||||||
{
|
|
||||||
IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);").getDeclarations().next();
|
|
||||||
assertEquals( function.getName(), "conjf");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug39551B() throws Exception
|
|
||||||
{
|
|
||||||
IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;").getDeclarations().next();
|
|
||||||
assertEquals( variable.getName(), "id");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug39554() throws Exception
|
public void testBug39554() throws Exception
|
||||||
{
|
{
|
||||||
assertCodeFailsParse("_Pragma(\"foobar\")");
|
assertCodeFailsParse("_Pragma(\"foobar\")");
|
||||||
|
|
|
@ -72,11 +72,16 @@ public class BaseASTTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
protected IASTDeclaration assertSoleDeclaration( String code ) throws ParserException
|
||||||
|
{
|
||||||
|
return assertSoleDeclaration( code, ParserLanguage.CPP );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTDeclaration assertSoleDeclaration( String code, ParserLanguage language ) throws ParserException
|
||||||
{
|
{
|
||||||
Iterator declarationIter = null;
|
Iterator declarationIter = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
declarationIter = parse(code).getDeclarations();
|
declarationIter = parse(code, true, true, language).getDeclarations();
|
||||||
}
|
}
|
||||||
catch (ASTNotImplementedException e1)
|
catch (ASTNotImplementedException e1)
|
||||||
{
|
{
|
||||||
|
@ -90,10 +95,15 @@ public class BaseASTTest extends TestCase
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertCodeFailsParse(String code) {
|
public void assertCodeFailsParse( String code )
|
||||||
|
{
|
||||||
|
assertCodeFailsParse( code, true, true, ParserLanguage.CPP );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void assertCodeFailsParse(String code, boolean quick, boolean throwOnError, ParserLanguage CPP ) {
|
||||||
boolean testPassed = false;
|
boolean testPassed = false;
|
||||||
try {
|
try {
|
||||||
parse(code);
|
parse(code, quick, throwOnError, CPP );
|
||||||
testPassed = true;
|
testPassed = true;
|
||||||
fail( "We should not reach this point");
|
fail( "We should not reach this point");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
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.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
@ -916,4 +917,58 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( constructor.getName(), "B" );
|
assertEquals( constructor.getName(), "B" );
|
||||||
assertTrue( constructor.previouslyDeclared() );
|
assertTrue( constructor.previouslyDeclared() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCDesignatedInitializers() throws Exception
|
||||||
|
{
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append( "struct Inner { int a,b,c; };");
|
||||||
|
buffer.append( "struct A { int x; int y[]; struct Inner innerArray[]; int z []; };");
|
||||||
|
buffer.append( "struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
|
||||||
|
Iterator i = parse( buffer.toString(), true, ParserLanguage.C ).getDeclarations();
|
||||||
|
IASTClassSpecifier Inner = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
Iterator members = getDeclarations(Inner);
|
||||||
|
IASTField a = (IASTField)members.next();
|
||||||
|
IASTField b = (IASTField)members.next();
|
||||||
|
IASTField c = (IASTField)members.next();
|
||||||
|
assertFalse( members.hasNext());
|
||||||
|
IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
members = getDeclarations( A );
|
||||||
|
IASTField x = (IASTField)members.next();
|
||||||
|
IASTField y = (IASTField)members.next();
|
||||||
|
IASTField innerArray = (IASTField)members.next();
|
||||||
|
IASTField z = (IASTField)members.next();
|
||||||
|
assertFalse( members.hasNext() );
|
||||||
|
IASTVariable myA = (IASTVariable)i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertAllReferences( 12, createTaskList( new Task( A ),
|
||||||
|
new Task( x ),
|
||||||
|
new Task( y, 2 ),
|
||||||
|
new Task( Inner ),
|
||||||
|
new Task( innerArray, 3),
|
||||||
|
new Task( a ),
|
||||||
|
new Task( b ),
|
||||||
|
new Task( c ),
|
||||||
|
new Task( z ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39551A() throws Exception
|
||||||
|
{
|
||||||
|
IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C).getDeclarations().next();
|
||||||
|
assertEquals( function.getName(), "conjf");
|
||||||
|
assertTrue( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).isComplex() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39551B() throws Exception
|
||||||
|
{
|
||||||
|
IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C).getDeclarations().next();
|
||||||
|
assertEquals( variable.getName(), "id");
|
||||||
|
assertTrue( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCBool() throws Exception
|
||||||
|
{
|
||||||
|
IASTVariable variable = (IASTVariable)parse( "_Bool x;", true, ParserLanguage.C ).getDeclarations().next();
|
||||||
|
assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type._BOOL );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,14 +669,20 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
|
|
||||||
protected IASTScope parse( String code ) throws ParserException
|
protected IASTScope parse( String code ) throws ParserException
|
||||||
{
|
{
|
||||||
return parse( code, true );
|
return parse( code, true, ParserLanguage.CPP );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException
|
protected IASTScope parse( String code, boolean throwOnError ) throws ParserException
|
||||||
|
{
|
||||||
|
return parse( code, throwOnError, ParserLanguage.CPP );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTScope parse(String code, boolean throwOnError, ParserLanguage language) throws ParserException
|
||||||
{
|
{
|
||||||
callback = new FullParseCallback();
|
callback = new FullParseCallback();
|
||||||
IParser parser = ParserFactory.createParser(
|
IParser parser = ParserFactory.createParser(
|
||||||
ParserFactory.createScanner( new StringReader( code ), "test-code", new ScannerInfo(),
|
ParserFactory.createScanner( new StringReader( code ), "test-code", new ScannerInfo(),
|
||||||
ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback ), callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP
|
ParserMode.COMPLETE_PARSE, language, callback ), callback, ParserMode.COMPLETE_PARSE, language
|
||||||
);
|
);
|
||||||
if( ! parser.parse() && throwOnError ) throw new ParserException( "FAILURE");
|
if( ! parser.parse() && throwOnError ) throw new ParserException( "FAILURE");
|
||||||
return callback.getCompilationUnit();
|
return callback.getCompilationUnit();
|
||||||
|
@ -836,6 +842,27 @@ public class CompleteParseBaseTest extends TestCase
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List createTaskList(Task task, Task task2, Task task3, Task task4, Task task5, Task task6, Task task7)
|
||||||
|
{
|
||||||
|
List result = createTaskList( task, task2, task3, task4, task5, task6 );
|
||||||
|
result.add( task7 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List createTaskList(Task task, Task task2, Task task3, Task task4, Task task5, Task task6, Task task7, Task task8 )
|
||||||
|
{
|
||||||
|
List result = createTaskList( task, task2, task3, task4, task5, task6, task7 );
|
||||||
|
result.add( task8 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List createTaskList(Task task, Task task2, Task task3, Task task4, Task task5, Task task6, Task task7, Task task8, Task task9 )
|
||||||
|
{
|
||||||
|
List result = createTaskList( task, task2, task3, task4, task5, task6, task7, task8 );
|
||||||
|
result.add( task9 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean qualifiedNamesEquals( String [] fromAST, String [] theTruth)
|
public boolean qualifiedNamesEquals( String [] fromAST, String [] theTruth)
|
||||||
{
|
{
|
||||||
if( fromAST == null || theTruth == null ) return false;
|
if( fromAST == null || theTruth == null ) return false;
|
||||||
|
|
|
@ -1975,5 +1975,37 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
parse("template<class E> class X { inline X<E>(int); };");
|
parse("template<class E> class X { inline X<E>(int); };");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug39542() throws Exception
|
||||||
|
{
|
||||||
|
parse("void f(int a, struct {int b[a];} c) {}");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Here starts C99-specific section
|
||||||
|
public void testBug39549() throws Exception
|
||||||
|
{
|
||||||
|
parse("struct X x = { .b = 40, .z = { sizeof(X), 42 }, .t[3] = 2, .t.f[3].x = A * B };", true, true, ParserLanguage.C);
|
||||||
|
// with trailing commas
|
||||||
|
parse("struct X x = { .b = 40, .z = { sizeof(X), 42,}, .t[3] = 2, .t.f[3].x = A * B ,};", true, true, ParserLanguage.C);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39551A() throws Exception
|
||||||
|
{
|
||||||
|
IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);", true, true, ParserLanguage.C).getDeclarations().next();
|
||||||
|
assertEquals( function.getName(), "conjf");
|
||||||
|
assertTrue( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).isComplex() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39551B() throws Exception
|
||||||
|
{
|
||||||
|
IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;", true, true, ParserLanguage.C).getDeclarations().next();
|
||||||
|
assertEquals( variable.getName(), "id");
|
||||||
|
assertTrue( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCBool() throws Exception
|
||||||
|
{
|
||||||
|
IASTVariable variable = (IASTVariable)assertSoleDeclaration( "_Bool x;", ParserLanguage.C );
|
||||||
|
assertSimpleType( variable, IASTSimpleTypeSpecifier.Type._BOOL );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-10-22 John Camelon
|
||||||
|
Fixed Bug 39542 : Parser fails on 'struct' parameter types
|
||||||
|
Fixed Bug 39549 : Designated initializers are not supported (ANSI C99)
|
||||||
|
Fixed Bug 39551 : Complex and imaginary numbers are not supported (ANSI C99)
|
||||||
|
|
||||||
2003-10-21 John Camelon
|
2003-10-21 John Camelon
|
||||||
Fixed Bug 40007 : Parser reports success when it fails
|
Fixed Bug 40007 : Parser reports success when it fails
|
||||||
Fixed Bug 44305 : Scanner/preprocessor fails on conditionals using hexidecimal
|
Fixed Bug 44305 : Scanner/preprocessor fails on conditionals using hexidecimal
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser;
|
package org.eclipse.cdt.core.parser;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.Enum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IASTDesignator
|
||||||
|
{
|
||||||
|
public static class DesignatorKind extends Enum
|
||||||
|
{
|
||||||
|
public static final DesignatorKind FIELD = new DesignatorKind( 0 );
|
||||||
|
public static final DesignatorKind SUBSCRIPT = new DesignatorKind( 1 );
|
||||||
|
/**
|
||||||
|
* @param enumValue
|
||||||
|
*/
|
||||||
|
protected DesignatorKind(int enumValue)
|
||||||
|
{
|
||||||
|
super(enumValue);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DesignatorKind getKind();
|
||||||
|
public IASTExpression arraySubscriptExpression();
|
||||||
|
public String fieldName();
|
||||||
|
public int fieldOffset();
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
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.IASTClassSpecifier.ClassNameType;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
|
@ -24,32 +25,32 @@ public interface IASTFactory
|
||||||
String name,
|
String name,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
int nameEndOffset, int endingOffset) throws Exception;
|
int nameEndOffset, int endingOffset) ;
|
||||||
public IASTInclusion createInclusion(
|
public IASTInclusion createInclusion(
|
||||||
String name,
|
String name,
|
||||||
String fileName,
|
String fileName,
|
||||||
boolean local,
|
boolean local,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
int nameEndOffset, int endingOffset) throws Exception;
|
int nameEndOffset, int endingOffset) ;
|
||||||
public IASTUsingDirective createUsingDirective(
|
public IASTUsingDirective createUsingDirective(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
ITokenDuple duple, int startingOffset, int endingOffset)
|
ITokenDuple duple, int startingOffset, int endingOffset)
|
||||||
throws ASTSemanticException, Exception;
|
throws ASTSemanticException;
|
||||||
public IASTUsingDeclaration createUsingDeclaration(
|
public IASTUsingDeclaration createUsingDeclaration(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
boolean isTypeName,
|
boolean isTypeName,
|
||||||
ITokenDuple name, int startingOffset, int endingOffset) throws ASTSemanticException, Exception;
|
ITokenDuple name, int startingOffset, int endingOffset) throws ASTSemanticException;
|
||||||
public IASTASMDefinition createASMDefinition(
|
public IASTASMDefinition createASMDefinition(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String assembly,
|
String assembly,
|
||||||
int first,
|
int first,
|
||||||
int last)throws Exception;
|
int last);
|
||||||
public IASTNamespaceDefinition createNamespaceDefinition(
|
public IASTNamespaceDefinition createNamespaceDefinition(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String identifier,
|
String identifier,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
|
int nameOffset, int nameEndOffset) throws ASTSemanticException;
|
||||||
|
|
||||||
public IASTNamespaceAlias createNamespaceAlias(
|
public IASTNamespaceAlias createNamespaceAlias(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
|
@ -57,12 +58,12 @@ public interface IASTFactory
|
||||||
ITokenDuple alias,
|
ITokenDuple alias,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
int nameEndOffset, int endOffset ) throws ASTSemanticException, Exception;
|
int nameEndOffset, int endOffset ) throws ASTSemanticException;
|
||||||
|
|
||||||
public IASTCompilationUnit createCompilationUnit() throws Exception;
|
public IASTCompilationUnit createCompilationUnit() ;
|
||||||
public IASTLinkageSpecification createLinkageSpecification(
|
public IASTLinkageSpecification createLinkageSpecification(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String spec, int startingOffset) throws Exception;
|
String spec, int startingOffset) ;
|
||||||
public IASTClassSpecifier createClassSpecifier(
|
public IASTClassSpecifier createClassSpecifier(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
ITokenDuple name,
|
ITokenDuple name,
|
||||||
|
@ -70,7 +71,7 @@ public interface IASTFactory
|
||||||
ClassNameType type,
|
ClassNameType type,
|
||||||
ASTAccessVisibility access,
|
ASTAccessVisibility access,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
|
int nameOffset, int nameEndOffset) throws ASTSemanticException;
|
||||||
/**
|
/**
|
||||||
* @param astClassSpec
|
* @param astClassSpec
|
||||||
* @param isVirtual
|
* @param isVirtual
|
||||||
|
@ -81,21 +82,21 @@ public interface IASTFactory
|
||||||
IASTClassSpecifier astClassSpec,
|
IASTClassSpecifier astClassSpec,
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
ITokenDuple parentClassName) throws ASTSemanticException, Exception;
|
ITokenDuple parentClassName) throws ASTSemanticException;
|
||||||
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
|
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
ASTClassKind elaboratedClassKind,
|
ASTClassKind elaboratedClassKind,
|
||||||
ITokenDuple typeName,
|
ITokenDuple typeName,
|
||||||
int startingOffset, int endOffset, boolean isForewardDecl) throws ASTSemanticException, Exception;
|
int startingOffset, int endOffset, boolean isForewardDecl) throws ASTSemanticException;
|
||||||
public IASTEnumerationSpecifier createEnumerationSpecifier(
|
public IASTEnumerationSpecifier createEnumerationSpecifier(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
String name,
|
||||||
int startingOffset, int nameOffset, int nameEndOffset) throws ASTSemanticException, Exception;
|
int startingOffset, int nameOffset, int nameEndOffset) throws ASTSemanticException;
|
||||||
public void addEnumerator(
|
public void addEnumerator(
|
||||||
IASTEnumerationSpecifier enumeration,
|
IASTEnumerationSpecifier enumeration,
|
||||||
String string,
|
String string,
|
||||||
int startingOffset,
|
int startingOffset,
|
||||||
int nameOffset, int nameEndOffset, int endingOffset, IASTExpression initialValue)throws ASTSemanticException, Exception;
|
int nameOffset, int nameEndOffset, int endingOffset, IASTExpression initialValue)throws ASTSemanticException;
|
||||||
public IASTExpression createExpression(
|
public IASTExpression createExpression(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTExpression.Kind kind,
|
IASTExpression.Kind kind,
|
||||||
|
@ -103,17 +104,17 @@ public interface IASTFactory
|
||||||
IASTExpression rhs,
|
IASTExpression rhs,
|
||||||
IASTExpression thirdExpression,
|
IASTExpression thirdExpression,
|
||||||
IASTTypeId typeId,
|
IASTTypeId typeId,
|
||||||
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException, Exception;
|
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException;
|
||||||
public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(List newPlacementExpressions,List newTypeIdExpressions,List newInitializerExpressions)throws Exception;
|
public IASTExpression.IASTNewExpressionDescriptor createNewDescriptor(List newPlacementExpressions,List newTypeIdExpressions,List newInitializerExpressions);
|
||||||
public IASTInitializerClause createInitializerClause(
|
public IASTInitializerClause createInitializerClause(
|
||||||
|
IASTScope scope,
|
||||||
IASTInitializerClause.Kind kind,
|
IASTInitializerClause.Kind kind,
|
||||||
IASTExpression assignmentExpression,
|
IASTExpression assignmentExpression, List initializerClauses, List designators) ;
|
||||||
List initializerClauses) throws Exception;
|
public IASTExceptionSpecification createExceptionSpecification(IASTScope scope, List typeIds) throws ASTSemanticException;
|
||||||
public IASTExceptionSpecification createExceptionSpecification(IASTScope scope, List typeIds) throws ASTSemanticException, Exception;
|
|
||||||
/**
|
/**
|
||||||
* @param exp
|
* @param exp
|
||||||
*/
|
*/
|
||||||
public IASTArrayModifier createArrayModifier(IASTExpression exp) throws Exception;
|
public IASTArrayModifier createArrayModifier(IASTExpression exp) ;
|
||||||
/**
|
/**
|
||||||
* @param duple
|
* @param duple
|
||||||
* @param expressionList
|
* @param expressionList
|
||||||
|
@ -121,7 +122,7 @@ public interface IASTFactory
|
||||||
*/
|
*/
|
||||||
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
|
public IASTConstructorMemberInitializer createConstructorMemberInitializer(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException, Exception;
|
ITokenDuple duple, IASTExpression expressionList) throws ASTSemanticException;
|
||||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
|
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
IASTSimpleTypeSpecifier.Type kind,
|
IASTSimpleTypeSpecifier.Type kind,
|
||||||
|
@ -129,7 +130,7 @@ public interface IASTFactory
|
||||||
boolean isShort,
|
boolean isShort,
|
||||||
boolean isLong,
|
boolean isLong,
|
||||||
boolean isSigned,
|
boolean isSigned,
|
||||||
boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
|
boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary) throws ASTSemanticException;
|
||||||
public IASTFunction createFunction(
|
public IASTFunction createFunction(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
ITokenDuple name,
|
ITokenDuple name,
|
||||||
|
@ -147,12 +148,12 @@ public interface IASTFactory
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual, List constructorChain, boolean isDefinition, boolean hasFunctionTryBlock ) throws ASTSemanticException, Exception;
|
boolean isPureVirtual, List constructorChain, boolean isDefinition, boolean hasFunctionTryBlock ) throws ASTSemanticException;
|
||||||
public IASTAbstractDeclaration createAbstractDeclaration(
|
public IASTAbstractDeclaration createAbstractDeclaration(
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
IASTTypeSpecifier typeSpecifier,
|
IASTTypeSpecifier typeSpecifier,
|
||||||
List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOperator)throws Exception;
|
List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOperator);
|
||||||
public IASTMethod createMethod(
|
public IASTMethod createMethod(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
String name,
|
||||||
|
@ -170,28 +171,30 @@ public interface IASTFactory
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
boolean isExplicit,
|
boolean isExplicit,
|
||||||
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition, boolean hasFunctionTryBlock) throws ASTSemanticException, Exception;
|
boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition, boolean hasFunctionTryBlock) throws ASTSemanticException;
|
||||||
|
|
||||||
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
|
public IASTVariable createVariable(IASTScope scope, String name, boolean isAuto, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression,
|
||||||
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression ) throws ASTSemanticException, Exception;
|
IASTAbstractDeclaration abstractDeclaration, boolean isMutable, boolean isExtern, boolean isRegister, boolean isStatic, int startingOffset, int nameOffset, int nameEndOffset, IASTExpression constructorExpression ) 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, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException, Exception;
|
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, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException;
|
||||||
|
|
||||||
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset ) throws Exception;
|
public IASTDesignator createDesignator( IASTDesignator.DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier );
|
||||||
|
|
||||||
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset ) throws Exception;
|
public IASTParameterDeclaration createParameterDeclaration( boolean isConst, boolean isVolatile, IASTTypeSpecifier getTypeSpecifier, List pointerOperators, List arrayModifiers, List parameters, ASTPointerOperator pointerOp, String parameterName, IASTInitializerClause initializerClause, int startingOffset, int nameOffset, int nameEndOffset, int endingOffset ) ;
|
||||||
|
|
||||||
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ) throws Exception;
|
public IASTTemplateDeclaration createTemplateDeclaration( IASTScope scope, List templateParameters, boolean exported, int startingOffset ) ;
|
||||||
|
|
||||||
public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset)throws Exception;
|
public IASTTemplateParameter createTemplateParameter( IASTTemplateParameter.ParamKind kind, String identifier, String defaultValue, IASTParameterDeclaration parameter, List parms ) ;
|
||||||
|
|
||||||
public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset)throws Exception;
|
public IASTTemplateInstantiation createTemplateInstantiation(IASTScope scope, int startingOffset);
|
||||||
|
|
||||||
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset, int nameEndOffset ) throws ASTSemanticException, Exception;
|
public IASTTemplateSpecialization createTemplateSpecialization(IASTScope scope, int startingOffset);
|
||||||
|
|
||||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset)throws Exception;
|
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset, int nameEndOffset ) throws ASTSemanticException;
|
||||||
|
|
||||||
public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion ) throws Exception;
|
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int endingOffset);
|
||||||
|
|
||||||
|
public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion ) ;
|
||||||
|
|
||||||
static final String DOUBLE_COLON = "::";
|
static final String DOUBLE_COLON = "::";
|
||||||
static final String TELTA = "~";
|
static final String TELTA = "~";
|
||||||
|
@ -199,14 +202,14 @@ public interface IASTFactory
|
||||||
* @param scope
|
* @param scope
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IASTCodeScope createNewCodeBlock(IASTScope scope)throws Exception;
|
public IASTCodeScope createNewCodeBlock(IASTScope scope);
|
||||||
|
|
||||||
public IASTTypeId createTypeId( IASTScope scope, IASTSimpleTypeSpecifier.Type kind, boolean isConst, boolean isVolatile, boolean isShort,
|
public IASTTypeId createTypeId( IASTScope scope, IASTSimpleTypeSpecifier.Type kind, boolean isConst, boolean isVolatile, boolean isShort,
|
||||||
boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods ) throws ASTSemanticException, Exception;
|
boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, ITokenDuple name, List pointerOps, List arrayMods ) throws ASTSemanticException;
|
||||||
/**
|
/**
|
||||||
* @param astClassSpecifier
|
* @param astClassSpecifier
|
||||||
*/
|
*/
|
||||||
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier) throws Exception;
|
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,6 +25,8 @@ public interface IASTInitializerClause extends ISourceElementCallbackDelegate{
|
||||||
public static final Kind ASSIGNMENT_EXPRESSION = new Kind( 1 );
|
public static final Kind ASSIGNMENT_EXPRESSION = new Kind( 1 );
|
||||||
public static final Kind INITIALIZER_LIST = new Kind( 2 );
|
public static final Kind INITIALIZER_LIST = new Kind( 2 );
|
||||||
public static final Kind EMPTY = new Kind( 3 );
|
public static final Kind EMPTY = new Kind( 3 );
|
||||||
|
public static final Kind DESIGNATED_INITIALIZER_LIST = new Kind( 4 );
|
||||||
|
public static final Kind DESIGNATED_ASSIGNMENT_EXPRESSION = new Kind( 5 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
|
@ -37,5 +39,9 @@ public interface IASTInitializerClause extends ISourceElementCallbackDelegate{
|
||||||
public Kind getKind();
|
public Kind getKind();
|
||||||
public Iterator getInitializers();
|
public Iterator getInitializers();
|
||||||
public IASTExpression getAssigmentExpression();
|
public IASTExpression getAssigmentExpression();
|
||||||
|
public Iterator getDesignators();
|
||||||
|
|
||||||
|
public void setOwnerVariableDeclaration( IASTVariable declaration );
|
||||||
|
public IASTVariable getOwnerVariableDeclaration();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
||||||
public static final Type VOID = new Type( 7 );
|
public static final Type VOID = new Type( 7 );
|
||||||
public static final Type CLASS_OR_TYPENAME = new Type( 8 );
|
public static final Type CLASS_OR_TYPENAME = new Type( 8 );
|
||||||
public static final Type TEMPLATE = new Type( 9 );
|
public static final Type TEMPLATE = new Type( 9 );
|
||||||
|
public static final Type _BOOL = new Type( 10 );
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
*/
|
*/
|
||||||
|
@ -49,6 +49,8 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
||||||
public boolean isSigned();
|
public boolean isSigned();
|
||||||
public boolean isUnsigned();
|
public boolean isUnsigned();
|
||||||
public boolean isTypename();
|
public boolean isTypename();
|
||||||
|
public boolean isComplex();
|
||||||
|
public boolean isImaginary();
|
||||||
|
|
||||||
public IASTTypeSpecifier getTypeSpecifier() throws ASTNotImplementedException;
|
public IASTTypeSpecifier getTypeSpecifier() throws ASTNotImplementedException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
*/
|
*/
|
||||||
public class DeclarationWrapper implements IDeclaratorOwner
|
public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
|
private boolean imaginary, complex;
|
||||||
private boolean restrict;
|
private boolean restrict;
|
||||||
private int endOffset;
|
private int endOffset;
|
||||||
private ITokenDuple name;
|
private ITokenDuple name;
|
||||||
|
@ -773,5 +774,35 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
return restrict;
|
return restrict;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
public void setImaginary(boolean b)
|
||||||
|
{
|
||||||
|
imaginary = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isComplex()
|
||||||
|
{
|
||||||
|
return complex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isImaginary()
|
||||||
|
{
|
||||||
|
return imaginary;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
public void setComplex(boolean b)
|
||||||
|
{
|
||||||
|
complex = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
@ -72,6 +73,7 @@ import org.eclipse.cdt.internal.core.model.Util;
|
||||||
*/
|
*/
|
||||||
public class Parser implements IParser
|
public class Parser implements IParser
|
||||||
{
|
{
|
||||||
|
private static final List EMPTY_LIST = new ArrayList();
|
||||||
private static int DEFAULT_OFFSET = -1;
|
private static int DEFAULT_OFFSET = -1;
|
||||||
// sentinel initial value for offsets
|
// sentinel initial value for offsets
|
||||||
private int firstErrorOffset = DEFAULT_OFFSET;
|
private int firstErrorOffset = DEFAULT_OFFSET;
|
||||||
|
@ -943,7 +945,7 @@ public class Parser implements IParser
|
||||||
sdw.isShort(),
|
sdw.isShort(),
|
||||||
sdw.isLong(),
|
sdw.isLong(),
|
||||||
sdw.isSigned(),
|
sdw.isSigned(),
|
||||||
sdw.isUnsigned(), sdw.isTypeNamed()));
|
sdw.isUnsigned(), sdw.isTypeNamed(), sdw.isComplex(), sdw.isImaginary()));
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
|
@ -1182,7 +1184,7 @@ public class Parser implements IParser
|
||||||
sdw.isShort(),
|
sdw.isShort(),
|
||||||
sdw.isLong(),
|
sdw.isLong(),
|
||||||
sdw.isSigned(),
|
sdw.isSigned(),
|
||||||
sdw.isUnsigned(), sdw.isTypeNamed()));
|
sdw.isUnsigned(), sdw.isTypeNamed(), sdw.isComplex(), sdw.isImaginary()));
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
{
|
{
|
||||||
|
@ -1455,6 +1457,20 @@ public class Parser implements IParser
|
||||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||||
sdw.setLong(true);
|
sdw.setLong(true);
|
||||||
break;
|
break;
|
||||||
|
case IToken.t__Complex :
|
||||||
|
consume( IToken.t__Complex );
|
||||||
|
if (typeNameBegin == null)
|
||||||
|
typeNameBegin = LA(1);
|
||||||
|
typeNameEnd = LA(1);
|
||||||
|
sdw.setComplex( true );
|
||||||
|
break;
|
||||||
|
case IToken.t__Imaginary :
|
||||||
|
consume( IToken.t__Imaginary );
|
||||||
|
if (typeNameBegin == null)
|
||||||
|
typeNameBegin = LA(1);
|
||||||
|
typeNameEnd = LA(1);
|
||||||
|
sdw.setImaginary( true );
|
||||||
|
break;
|
||||||
case IToken.t_char :
|
case IToken.t_char :
|
||||||
if (typeNameBegin == null)
|
if (typeNameBegin == null)
|
||||||
typeNameBegin = LA(1);
|
typeNameBegin = LA(1);
|
||||||
|
@ -1477,6 +1493,13 @@ public class Parser implements IParser
|
||||||
callbackSimpleDeclToken(flags);
|
callbackSimpleDeclToken(flags);
|
||||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.BOOL);
|
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.BOOL);
|
||||||
break;
|
break;
|
||||||
|
case IToken.t__Bool:
|
||||||
|
if (typeNameBegin == null)
|
||||||
|
typeNameBegin = LA(1);
|
||||||
|
typeNameEnd = LA(1);
|
||||||
|
callbackSimpleDeclToken(flags);
|
||||||
|
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type._BOOL);
|
||||||
|
break;
|
||||||
case IToken.t_int :
|
case IToken.t_int :
|
||||||
if (typeNameBegin == null)
|
if (typeNameBegin == null)
|
||||||
typeNameBegin = LA(1);
|
typeNameBegin = LA(1);
|
||||||
|
@ -1523,10 +1546,8 @@ public class Parser implements IParser
|
||||||
break;
|
break;
|
||||||
case IToken.tCOLONCOLON :
|
case IToken.tCOLONCOLON :
|
||||||
consume(IToken.tCOLONCOLON);
|
consume(IToken.tCOLONCOLON);
|
||||||
// handle nested later:
|
|
||||||
case IToken.tIDENTIFIER :
|
case IToken.tIDENTIFIER :
|
||||||
// TODO - Kludgy way to handle constructors/destructors
|
// TODO - Kludgy way to handle constructors/destructors
|
||||||
// handle nested later:
|
|
||||||
if (flags.haveEncounteredRawType())
|
if (flags.haveEncounteredRawType())
|
||||||
{
|
{
|
||||||
if (typeNameBegin != null)
|
if (typeNameBegin != null)
|
||||||
|
@ -1564,8 +1585,6 @@ public class Parser implements IParser
|
||||||
case IToken.t_class :
|
case IToken.t_class :
|
||||||
case IToken.t_struct :
|
case IToken.t_struct :
|
||||||
case IToken.t_union :
|
case IToken.t_union :
|
||||||
if (!parm )
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
classSpecifier(sdw);
|
classSpecifier(sdw);
|
||||||
|
@ -1578,16 +1597,7 @@ public class Parser implements IParser
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elaboratedTypeSpecifier(sdw);
|
|
||||||
flags.setEncounteredTypename(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IToken.t_enum :
|
case IToken.t_enum :
|
||||||
if (!parm )
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
enumSpecifier(sdw);
|
enumSpecifier(sdw);
|
||||||
|
@ -1601,13 +1611,6 @@ public class Parser implements IParser
|
||||||
flags.setEncounteredTypename(true);
|
flags.setEncounteredTypename(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elaboratedTypeSpecifier(sdw);
|
|
||||||
flags.setEncounteredTypename(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default :
|
default :
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
|
@ -1883,11 +1886,22 @@ public class Parser implements IParser
|
||||||
throws Backtrack
|
throws Backtrack
|
||||||
{
|
{
|
||||||
Declarator d = declarator(sdw, sdw.getScope(), strategy );
|
Declarator d = declarator(sdw, sdw.getScope(), strategy );
|
||||||
// handle = initializerClause
|
if( language == ParserLanguage.CPP )
|
||||||
|
optionalCPPInitializer(d);
|
||||||
|
else if( language == ParserLanguage.C )
|
||||||
|
optionalCInitializer(d);
|
||||||
|
sdw.addDeclarator(d);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void optionalCPPInitializer(Declarator d)
|
||||||
|
throws EndOfFile, Backtrack
|
||||||
|
{
|
||||||
|
// handle initializer
|
||||||
if (LT(1) == IToken.tASSIGN)
|
if (LT(1) == IToken.tASSIGN)
|
||||||
{
|
{
|
||||||
consume(IToken.tASSIGN);
|
consume(IToken.tASSIGN);
|
||||||
d.setInitializerClause(initializerClause(sdw.getScope()));
|
d.setInitializerClause(initializerClause(d.getDeclarationWrapper().getScope()));
|
||||||
}
|
}
|
||||||
else if (LT(1) == IToken.tLPAREN )
|
else if (LT(1) == IToken.tLPAREN )
|
||||||
{
|
{
|
||||||
|
@ -1897,7 +1911,7 @@ public class Parser implements IParser
|
||||||
{
|
{
|
||||||
consume(IToken.tLPAREN); // EAT IT!
|
consume(IToken.tLPAREN); // EAT IT!
|
||||||
IASTExpression astExpression = null;
|
IASTExpression astExpression = null;
|
||||||
astExpression = expression(sdw.getScope());
|
astExpression = expression(d.getDeclarationWrapper().getScope());
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
d.setConstructorExpression(astExpression);
|
d.setConstructorExpression(astExpression);
|
||||||
} catch( Backtrack bt )
|
} catch( Backtrack bt )
|
||||||
|
@ -1906,8 +1920,85 @@ public class Parser implements IParser
|
||||||
throw bt;
|
throw bt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sdw.addDeclarator(d);
|
}
|
||||||
return d;
|
|
||||||
|
protected void optionalCInitializer( Declarator d ) throws Backtrack
|
||||||
|
{
|
||||||
|
if( LT(1) == IToken.tASSIGN )
|
||||||
|
{
|
||||||
|
consume( IToken.tASSIGN );
|
||||||
|
d.setInitializerClause( cInitializerClause(d.getDeclarationWrapper().getScope(), EMPTY_LIST ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param scope
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTInitializerClause cInitializerClause(
|
||||||
|
IASTScope scope,
|
||||||
|
List designators)
|
||||||
|
throws Backtrack
|
||||||
|
{
|
||||||
|
if (LT(1) == IToken.tLBRACE)
|
||||||
|
{
|
||||||
|
consume(IToken.tLBRACE);
|
||||||
|
List initializerList = new ArrayList();
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
// required at least one initializer list
|
||||||
|
// get designator list
|
||||||
|
List newDesignators = designatorList(scope);
|
||||||
|
if( newDesignators.size() != 0 )
|
||||||
|
consume( IToken.tASSIGN );
|
||||||
|
IASTInitializerClause initializer =
|
||||||
|
cInitializerClause(scope, newDesignators );
|
||||||
|
initializerList.add(initializer);
|
||||||
|
// can end with just a '}'
|
||||||
|
if (LT(1) == IToken.tRBRACE)
|
||||||
|
break;
|
||||||
|
// can end with ", }"
|
||||||
|
if (LT(1) == IToken.tCOMMA)
|
||||||
|
consume(IToken.tCOMMA);
|
||||||
|
if (LT(1) == IToken.tRBRACE)
|
||||||
|
break;
|
||||||
|
// otherwise, its another initializer in the list
|
||||||
|
}
|
||||||
|
// consume the closing brace
|
||||||
|
consume(IToken.tRBRACE);
|
||||||
|
return astFactory.createInitializerClause(
|
||||||
|
scope,
|
||||||
|
(
|
||||||
|
( designators.size() == 0 ) ?
|
||||||
|
IASTInitializerClause.Kind.INITIALIZER_LIST :
|
||||||
|
IASTInitializerClause.Kind.DESIGNATED_INITIALIZER_LIST ),
|
||||||
|
null, initializerList, designators );
|
||||||
|
}
|
||||||
|
// if we get this far, it means that we have not yet succeeded
|
||||||
|
// try this now instead
|
||||||
|
// assignmentExpression
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IASTExpression assignmentExpression = assignmentExpression(scope);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return astFactory.createInitializerClause(
|
||||||
|
scope,
|
||||||
|
(
|
||||||
|
( designators.size() == 0 ) ?
|
||||||
|
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION :
|
||||||
|
IASTInitializerClause.Kind.DESIGNATED_ASSIGNMENT_EXPRESSION ),
|
||||||
|
assignmentExpression, null, designators );
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Backtrack b)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
throw backtrack;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1924,16 +2015,17 @@ public class Parser implements IParser
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createInitializerClause(
|
return astFactory.createInitializerClause(
|
||||||
|
scope,
|
||||||
IASTInitializerClause.Kind.EMPTY,
|
IASTInitializerClause.Kind.EMPTY,
|
||||||
null,
|
null, null, EMPTY_LIST );
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise it is a list of initializers
|
|
||||||
|
// otherwise it is a list of initializer clauses
|
||||||
List initializerClauses = new ArrayList();
|
List initializerClauses = new ArrayList();
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -1947,17 +2039,19 @@ public class Parser implements IParser
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createInitializerClause(
|
return astFactory.createInitializerClause(
|
||||||
|
scope,
|
||||||
IASTInitializerClause.Kind.INITIALIZER_LIST,
|
IASTInitializerClause.Kind.INITIALIZER_LIST,
|
||||||
null,
|
null, initializerClauses, EMPTY_LIST );
|
||||||
initializerClauses);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we get this far, it means that we did not
|
||||||
// try this now instead
|
// try this now instead
|
||||||
// assignmentExpression || { initializerList , } || { }
|
// assignmentExpression
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression assignmentExpression =
|
IASTExpression assignmentExpression =
|
||||||
|
@ -1966,9 +2060,9 @@ public class Parser implements IParser
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return astFactory.createInitializerClause(
|
return astFactory.createInitializerClause(
|
||||||
|
scope,
|
||||||
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION,
|
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION,
|
||||||
assignmentExpression,
|
assignmentExpression, null, EMPTY_LIST );
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1981,6 +2075,43 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List designatorList(IASTScope scope) throws EndOfFile, Backtrack
|
||||||
|
{
|
||||||
|
List designatorList = new ArrayList();
|
||||||
|
// designated initializers for C
|
||||||
|
|
||||||
|
if( LT(1) == IToken.tDOT || LT(1) == IToken.tLBRACKET )
|
||||||
|
{
|
||||||
|
|
||||||
|
while( LT(1) == IToken.tDOT || LT(1) == IToken.tLBRACKET )
|
||||||
|
{
|
||||||
|
IToken id = null;
|
||||||
|
IASTExpression constantExpression = null;
|
||||||
|
IASTDesignator.DesignatorKind kind = null;
|
||||||
|
|
||||||
|
if( LT(1) == IToken.tDOT )
|
||||||
|
{
|
||||||
|
consume( IToken.tDOT );
|
||||||
|
id = identifier();
|
||||||
|
kind = IASTDesignator.DesignatorKind.FIELD;
|
||||||
|
}
|
||||||
|
else if( LT(1) == IToken.tLBRACKET )
|
||||||
|
{
|
||||||
|
consume( IToken.tLBRACKET );
|
||||||
|
constantExpression = expression( scope );
|
||||||
|
consume( IToken.tRBRACKET );
|
||||||
|
kind = IASTDesignator.DesignatorKind.SUBSCRIPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTDesignator d =
|
||||||
|
astFactory.createDesignator( kind, constantExpression, id );
|
||||||
|
designatorList.add( d );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return designatorList;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Parse a declarator, as according to the ANSI C++ specification.
|
* Parse a declarator, as according to the ANSI C++ specification.
|
||||||
*
|
*
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITranslationOptions;
|
import org.eclipse.cdt.core.parser.ITranslationOptions;
|
||||||
import org.eclipse.cdt.core.parser.ITranslationResult;
|
import org.eclipse.cdt.core.parser.ITranslationResult;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
|
import org.eclipse.cdt.core.parser.ast.ExpressionEvaluationException;
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTDesignator implements IASTDesignator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param constantExpression
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public ASTDesignator(DesignatorKind kind, IASTExpression constantExpression, String fieldName, int fieldOffset )
|
||||||
|
{
|
||||||
|
this.fieldName = fieldName;
|
||||||
|
this.constantExpression = constantExpression;
|
||||||
|
this.kind = kind;
|
||||||
|
this.fieldOffset = fieldOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int fieldOffset;
|
||||||
|
private final String fieldName;
|
||||||
|
private final IASTExpression constantExpression;
|
||||||
|
private final DesignatorKind kind;
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTDesignator#getKind()
|
||||||
|
*/
|
||||||
|
public DesignatorKind getKind()
|
||||||
|
{
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTDesignator#arraySubscriptExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression arraySubscriptExpression()
|
||||||
|
{
|
||||||
|
return constantExpression;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTDesignator#fieldName()
|
||||||
|
*/
|
||||||
|
public String fieldName()
|
||||||
|
{
|
||||||
|
return fieldName;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
if( constantExpression != null )
|
||||||
|
constantExpression.acceptElement(requestor);
|
||||||
|
}
|
||||||
|
/* (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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTDesignator#fieldOffset()
|
||||||
|
*/
|
||||||
|
public int fieldOffset()
|
||||||
|
{
|
||||||
|
return fieldOffset;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,14 +12,16 @@ package org.eclipse.cdt.internal.core.parser.ast;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
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.IASTArrayModifier;
|
import org.eclipse.cdt.core.parser.ast.IASTArrayModifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
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.IASTMacro;
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,15 +51,17 @@ public class BaseASTFactory {
|
||||||
return new ASTAbstractDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOperator );
|
return new ASTAbstractDeclaration( isConst, isVolatile, typeSpecifier, pointerOperators, arrayModifiers, parameters, pointerOperator );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTInitializerClause createInitializerClause(IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses)
|
|
||||||
{
|
|
||||||
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses );
|
|
||||||
}
|
|
||||||
|
|
||||||
public IASTArrayModifier createArrayModifier(IASTExpression exp)
|
public IASTArrayModifier createArrayModifier(IASTExpression exp)
|
||||||
{
|
{
|
||||||
return new ASTArrayModifier( exp );
|
return new ASTArrayModifier( exp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTDesignator createDesignator(DesignatorKind kind, IASTExpression constantExpression, IToken fieldIdentifier)
|
||||||
|
{
|
||||||
|
return new ASTDesignator( kind, constantExpression,
|
||||||
|
fieldIdentifier == null ? "" : fieldIdentifier.getImage(),
|
||||||
|
fieldIdentifier == null ? -1 : fieldIdentifier.getOffset() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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 java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTInitializerClause implements IASTInitializerClause
|
||||||
|
{
|
||||||
|
private List references = new ArrayList();
|
||||||
|
private IASTVariable ownerDeclaration = null;
|
||||||
|
private final IASTInitializerClause.Kind kind;
|
||||||
|
private final IASTExpression assignmentExpression;
|
||||||
|
private final List initializerClauses;
|
||||||
|
private final List designators;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param assignmentExpression
|
||||||
|
* @param initializerClauses
|
||||||
|
* @param designators
|
||||||
|
*/
|
||||||
|
public ASTInitializerClause(Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators)
|
||||||
|
{
|
||||||
|
this.kind = kind;
|
||||||
|
this.assignmentExpression = assignmentExpression;
|
||||||
|
this.initializerClauses = initializerClauses;
|
||||||
|
this.designators = designators;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getKind()
|
||||||
|
*/
|
||||||
|
public Kind getKind() {
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getInitializerList()
|
||||||
|
*/
|
||||||
|
public Iterator getInitializers() {
|
||||||
|
if( initializerClauses == null )
|
||||||
|
return new EmptyIterator();
|
||||||
|
return initializerClauses.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getAssigmentExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getAssigmentExpression() {
|
||||||
|
return assignmentExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
Iterator i = getInitializers();
|
||||||
|
while( i.hasNext() )
|
||||||
|
((IASTInitializerClause)i.next()).acceptElement(requestor);
|
||||||
|
|
||||||
|
if( assignmentExpression != null )
|
||||||
|
assignmentExpression.acceptElement( requestor );
|
||||||
|
|
||||||
|
ASTReferenceStore store = new ASTReferenceStore( getReferences() );
|
||||||
|
store.processReferences(requestor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getDesignators()
|
||||||
|
*/
|
||||||
|
public Iterator getDesignators()
|
||||||
|
{
|
||||||
|
return designators.iterator();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#setOwnerDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public void setOwnerVariableDeclaration(IASTVariable declaration)
|
||||||
|
{
|
||||||
|
ownerDeclaration = declaration;
|
||||||
|
Iterator subInitializers = getInitializers();
|
||||||
|
while( subInitializers.hasNext() )
|
||||||
|
((IASTInitializerClause)subInitializers.next()).setOwnerVariableDeclaration(declaration);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getOwnerDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTVariable getOwnerVariableDeclaration()
|
||||||
|
{
|
||||||
|
return ownerDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getReferences()
|
||||||
|
{
|
||||||
|
return references;
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,6 +63,8 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
return IASTSimpleTypeSpecifier.Type.VOID;
|
return IASTSimpleTypeSpecifier.Type.VOID;
|
||||||
if( symbol.getType() == TypeInfo.t_wchar_t)
|
if( symbol.getType() == TypeInfo.t_wchar_t)
|
||||||
return IASTSimpleTypeSpecifier.Type.WCHAR_T;
|
return IASTSimpleTypeSpecifier.Type.WCHAR_T;
|
||||||
|
if( symbol.getType() == TypeInfo.t__Bool )
|
||||||
|
return IASTSimpleTypeSpecifier.Type._BOOL;
|
||||||
|
|
||||||
return IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
|
return IASTSimpleTypeSpecifier.Type.UNSPECIFIED;
|
||||||
|
|
||||||
|
@ -130,4 +132,20 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
return (IASTTypeSpecifier)getSymbol().getTypeSymbol().getASTExtension().getPrimaryDeclaration();
|
return (IASTTypeSpecifier)getSymbol().getTypeSymbol().getASTExtension().getPrimaryDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isComplex()
|
||||||
|
*/
|
||||||
|
public boolean isComplex()
|
||||||
|
{
|
||||||
|
return symbol.getTypeInfo().checkBit( TypeInfo.isComplex );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isImaginary()
|
||||||
|
*/
|
||||||
|
public boolean isImaginary()
|
||||||
|
{
|
||||||
|
return symbol.getTypeInfo().checkBit( TypeInfo.isImaginary );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTDesignator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
@ -90,6 +91,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private final static List SUBSCRIPT;
|
||||||
|
static
|
||||||
|
{
|
||||||
|
SUBSCRIPT = new ArrayList();
|
||||||
|
SUBSCRIPT.add( TypeInfo.OperatorExpression.subscript );
|
||||||
|
}
|
||||||
|
|
||||||
public CompleteParseASTFactory( ParserLanguage language )
|
public CompleteParseASTFactory( ParserLanguage language )
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
@ -1333,42 +1341,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
boolean isShort,
|
boolean isShort,
|
||||||
boolean isLong,
|
boolean isLong,
|
||||||
boolean isSigned,
|
boolean isSigned,
|
||||||
boolean isUnsigned, boolean isTypename) throws ASTSemanticException
|
boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
TypeInfo.eType type = null;
|
TypeInfo.eType type = null;
|
||||||
|
|
||||||
if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
||||||
{
|
|
||||||
type = TypeInfo.t_type;
|
type = TypeInfo.t_type;
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
|
else if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
|
||||||
{
|
|
||||||
type = TypeInfo.t_bool;
|
type = TypeInfo.t_bool;
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
||||||
{
|
|
||||||
type = TypeInfo.t_char;
|
type = TypeInfo.t_char;
|
||||||
}
|
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE ||kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
|
||||||
{
|
|
||||||
type = TypeInfo.t_double;
|
type = TypeInfo.t_double;
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
|
||||||
{
|
|
||||||
type = TypeInfo.t_double;
|
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.INT )
|
else if( kind == IASTSimpleTypeSpecifier.Type.INT )
|
||||||
{
|
|
||||||
type = TypeInfo.t_int;
|
type = TypeInfo.t_int;
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
|
else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
|
||||||
{
|
|
||||||
type = TypeInfo.t_void;
|
type = TypeInfo.t_void;
|
||||||
}
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T)
|
else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T)
|
||||||
{
|
|
||||||
type = TypeInfo.t_wchar_t;
|
type = TypeInfo.t_wchar_t;
|
||||||
}
|
else if( kind == IASTSimpleTypeSpecifier.Type._BOOL )
|
||||||
|
type = TypeInfo.t__Bool;
|
||||||
|
|
||||||
List references = new ArrayList();
|
List references = new ArrayList();
|
||||||
ISymbol s = pst.newSymbol( "", type );
|
ISymbol s = pst.newSymbol( "", type );
|
||||||
|
@ -1405,10 +1397,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
s.setTypeSymbol( typeSymbol );
|
s.setTypeSymbol( typeSymbol );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s.getTypeInfo().setBit( isLong, TypeInfo.isLong );
|
s.getTypeInfo().setBit( isLong, TypeInfo.isLong );
|
||||||
s.getTypeInfo().setBit( isShort, TypeInfo.isShort);
|
s.getTypeInfo().setBit( isShort, TypeInfo.isShort);
|
||||||
s.getTypeInfo().setBit( isUnsigned, TypeInfo.isUnsigned );
|
s.getTypeInfo().setBit( isUnsigned, TypeInfo.isUnsigned );
|
||||||
|
s.getTypeInfo().setBit( isComplex, TypeInfo.isComplex );
|
||||||
|
s.getTypeInfo().setBit( isImaginary, TypeInfo.isImaginary );
|
||||||
|
|
||||||
return new ASTSimpleTypeSpecifier( s, false, typeName.toString(), references );
|
return new ASTSimpleTypeSpecifier( s, false, typeName.toString(), references );
|
||||||
|
|
||||||
|
@ -1441,7 +1434,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||||
|
|
||||||
// check if this is a method in a body file
|
// check if this is a method in a body file
|
||||||
Iterator tokenizer = name.iterator();
|
|
||||||
if(name.length() > 1){
|
if(name.length() > 1){
|
||||||
IContainerSymbol parentScope = (IContainerSymbol)
|
IContainerSymbol parentScope = (IContainerSymbol)
|
||||||
lookupQualifiedName(
|
lookupQualifiedName(
|
||||||
|
@ -1898,7 +1890,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
String fieldName = oneToken;
|
String fieldName = oneToken;
|
||||||
String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
|
|
||||||
|
|
||||||
int numOfTokens = 1;
|
int numOfTokens = 1;
|
||||||
int offset = nameOffset;
|
int offset = nameOffset;
|
||||||
|
@ -1968,6 +1959,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, nameEndOffset, references, constructorExpression, previouslyDeclared );
|
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, nameEndOffset, references, constructorExpression, previouslyDeclared );
|
||||||
|
if( variable.getInitializerClause() != null )
|
||||||
|
{
|
||||||
|
variable.getInitializerClause().setOwnerVariableDeclaration(variable);
|
||||||
|
addDesignatorReferences( (ASTInitializerClause)variable.getInitializerClause() );
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
attachSymbolExtension(newSymbol, variable );
|
attachSymbolExtension(newSymbol, variable );
|
||||||
|
@ -1978,6 +1975,72 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
return variable;
|
return variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param clause
|
||||||
|
*/
|
||||||
|
protected void addDesignatorReferences( ASTInitializerClause clause )
|
||||||
|
{
|
||||||
|
if( clause.getKind() == IASTInitializerClause.Kind.DESIGNATED_INITIALIZER_LIST ||
|
||||||
|
clause.getKind() == IASTInitializerClause.Kind.DESIGNATED_ASSIGNMENT_EXPRESSION )
|
||||||
|
{
|
||||||
|
ISymbol variableSymbol = ((ASTVariable)clause.getOwnerVariableDeclaration()).getSymbol();
|
||||||
|
ISymbol currentSymbol = variableSymbol.getTypeSymbol();
|
||||||
|
|
||||||
|
TypeInfo currentTypeInfo = new TypeInfo( currentSymbol.getTypeInfo() );
|
||||||
|
Iterator designators = clause.getDesignators();
|
||||||
|
while( designators.hasNext() )
|
||||||
|
{
|
||||||
|
IASTDesignator designator = (IASTDesignator)designators.next();
|
||||||
|
if( designator.getKind() == IASTDesignator.DesignatorKind.FIELD )
|
||||||
|
{
|
||||||
|
ISymbol lookup = null;
|
||||||
|
if( ! ( currentSymbol instanceof IContainerSymbol ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lookup = ((IContainerSymbol)currentSymbol).lookup( designator.fieldName() );
|
||||||
|
}
|
||||||
|
catch (ParserSymbolTableException e){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lookup == null || lookup.getContainingSymbol() != currentSymbol )
|
||||||
|
break;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clause.getReferences().add( createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e1)
|
||||||
|
{
|
||||||
|
// error
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have found the correct field
|
||||||
|
currentTypeInfo = new TypeInfo( lookup.getTypeInfo() );
|
||||||
|
if( lookup.getTypeInfo() == null )
|
||||||
|
break;
|
||||||
|
currentSymbol = lookup.getTypeSymbol();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if( designator.getKind() == IASTDesignator.DesignatorKind.SUBSCRIPT )
|
||||||
|
currentTypeInfo.applyOperatorExpressions( SUBSCRIPT );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( clause.getKind() == IASTInitializerClause.Kind.DESIGNATED_INITIALIZER_LIST ||
|
||||||
|
clause.getKind() == IASTInitializerClause.Kind.INITIALIZER_LIST )
|
||||||
|
{
|
||||||
|
Iterator subInitializers = clause.getInitializers();
|
||||||
|
while( subInitializers.hasNext() )
|
||||||
|
addDesignatorReferences( (ASTInitializerClause)subInitializers.next() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void setVariableTypeInfoBits(
|
protected void setVariableTypeInfoBits(
|
||||||
boolean isAuto,
|
boolean isAuto,
|
||||||
IASTAbstractDeclaration abstractDeclaration,
|
IASTAbstractDeclaration abstractDeclaration,
|
||||||
|
@ -2016,8 +2079,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier )
|
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier )
|
||||||
{
|
{
|
||||||
|
ASTElaboratedTypeSpecifier elab = ((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier());
|
||||||
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
|
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
|
||||||
symbolToBeCloned.setTypeSymbol(((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol());
|
symbolToBeCloned.setTypeSymbol(elab.getSymbol());
|
||||||
|
references.add( createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
|
||||||
}
|
}
|
||||||
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
||||||
newSymbol.setName( name );
|
newSymbol.setName( name );
|
||||||
|
@ -2464,4 +2529,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
// do nothing, this is best effort
|
// do nothing, this is best effort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTInitializerClause createInitializerClause(IASTScope scope, IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators)
|
||||||
|
{
|
||||||
|
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses, designators );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -16,6 +16,8 @@ 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.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -25,15 +27,18 @@ public class ASTInitializerClause implements IASTInitializerClause {
|
||||||
private final IASTInitializerClause.Kind kind;
|
private final IASTInitializerClause.Kind kind;
|
||||||
private final IASTExpression assignmentExpression;
|
private final IASTExpression assignmentExpression;
|
||||||
private final List initializerClauses;
|
private final List initializerClauses;
|
||||||
|
private final List designators;
|
||||||
|
private IASTVariable ownerDeclaration = null;
|
||||||
/**
|
/**
|
||||||
* @param kind
|
* @param kind
|
||||||
* @param assignmentExpression
|
* @param assignmentExpression
|
||||||
* @param initializerClauses
|
* @param initializerClauses
|
||||||
*/
|
*/
|
||||||
public ASTInitializerClause(Kind kind, IASTExpression assignmentExpression, List initializerClauses) {
|
public ASTInitializerClause(Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators ) {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.assignmentExpression = assignmentExpression;
|
this.assignmentExpression = assignmentExpression;
|
||||||
this.initializerClauses = initializerClauses;
|
this.initializerClauses = initializerClauses;
|
||||||
|
this.designators = designators;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -64,14 +69,6 @@ public class ASTInitializerClause implements IASTInitializerClause {
|
||||||
*/
|
*/
|
||||||
public void acceptElement(ISourceElementRequestor requestor)
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
Iterator i = getInitializers();
|
|
||||||
while( i.hasNext() )
|
|
||||||
{
|
|
||||||
IASTInitializerClause initializerClause = (IASTInitializerClause)i.next();
|
|
||||||
initializerClause.acceptElement(requestor);
|
|
||||||
}
|
|
||||||
if( assignmentExpression != null )
|
|
||||||
assignmentExpression.acceptElement( requestor );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -88,4 +85,28 @@ public class ASTInitializerClause implements IASTInitializerClause {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getDesignators()
|
||||||
|
*/
|
||||||
|
public Iterator getDesignators()
|
||||||
|
{
|
||||||
|
return designators.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#setOwnerDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public void setOwnerVariableDeclaration(IASTVariable declaration)
|
||||||
|
{
|
||||||
|
ownerDeclaration = declaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTInitializerClause#getOwnerDeclaration()
|
||||||
|
*/
|
||||||
|
public IASTVariable getOwnerVariableDeclaration()
|
||||||
|
{
|
||||||
|
return ownerDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.*;
|
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.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.*;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
*/
|
*/
|
||||||
public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
{
|
{
|
||||||
|
private final boolean imaginary;
|
||||||
|
private final boolean complex;
|
||||||
private final boolean isTypename;
|
private final boolean isTypename;
|
||||||
private final Type kind;
|
private final Type kind;
|
||||||
private final String typeName;
|
private final String typeName;
|
||||||
|
@ -40,12 +42,13 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
nameMap.put( Type.INT, "int");
|
nameMap.put( Type.INT, "int");
|
||||||
nameMap.put( Type.VOID, "void" );
|
nameMap.put( Type.VOID, "void" );
|
||||||
nameMap.put( Type.WCHAR_T, "wchar_t" );
|
nameMap.put( Type.WCHAR_T, "wchar_t" );
|
||||||
|
nameMap.put( Type._BOOL, "_Bool");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param kind
|
* @param kind
|
||||||
* @param typeName
|
* @param typeName
|
||||||
*/
|
*/
|
||||||
public ASTSimpleTypeSpecifier(Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename)
|
public ASTSimpleTypeSpecifier(Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary )
|
||||||
{
|
{
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.isLong = isLong;
|
this.isLong = isLong;
|
||||||
|
@ -53,7 +56,8 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
this.isSigned = isSigned;
|
this.isSigned = isSigned;
|
||||||
this.isUnsigned = isUnsigned;
|
this.isUnsigned = isUnsigned;
|
||||||
this.isTypename = isTypename;
|
this.isTypename = isTypename;
|
||||||
|
this.complex = isComplex;
|
||||||
|
this.imaginary = isImaginary;
|
||||||
|
|
||||||
StringBuffer type = new StringBuffer();
|
StringBuffer type = new StringBuffer();
|
||||||
if( this.kind == IASTSimpleTypeSpecifier.Type.CHAR || this.kind == IASTSimpleTypeSpecifier.Type.WCHAR_T )
|
if( this.kind == IASTSimpleTypeSpecifier.Type.CHAR || this.kind == IASTSimpleTypeSpecifier.Type.WCHAR_T )
|
||||||
|
@ -62,7 +66,7 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
type.append("unsigned ");
|
type.append("unsigned ");
|
||||||
type.append( (String)nameMap.get( this.kind ));
|
type.append( (String)nameMap.get( this.kind ));
|
||||||
}
|
}
|
||||||
else if( this.kind == Type.BOOL || this.kind == Type.FLOAT || this.kind == Type.VOID )
|
else if( this.kind == Type.BOOL || this.kind == Type.VOID || this.kind == Type._BOOL )
|
||||||
{
|
{
|
||||||
type.append( (String) nameMap.get( this.kind ));
|
type.append( (String) nameMap.get( this.kind ));
|
||||||
}
|
}
|
||||||
|
@ -76,11 +80,23 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
type.append("long ");
|
type.append("long ");
|
||||||
type.append( (String)nameMap.get( this.kind ));
|
type.append( (String)nameMap.get( this.kind ));
|
||||||
}
|
}
|
||||||
|
else if( this.kind == Type.FLOAT )
|
||||||
|
{
|
||||||
|
type.append( (String)nameMap.get( this.kind ));
|
||||||
|
if( isComplex() )
|
||||||
|
type.append( "_Complex" );
|
||||||
|
else if( isImaginary() )
|
||||||
|
type.append( "_Imaginary" );
|
||||||
|
}
|
||||||
else if( this.kind == Type.DOUBLE )
|
else if( this.kind == Type.DOUBLE )
|
||||||
{
|
{
|
||||||
if (isLong())
|
if (isLong())
|
||||||
type.append("long ");
|
type.append("long ");
|
||||||
type.append( (String)nameMap.get( this.kind ));
|
type.append( (String)nameMap.get( this.kind ));
|
||||||
|
if( isComplex() )
|
||||||
|
type.append( "_Complex" );
|
||||||
|
else if( isImaginary() )
|
||||||
|
type.append( "_Imaginary" );
|
||||||
}
|
}
|
||||||
else if( this.kind == Type.CLASS_OR_TYPENAME || this.kind == Type.TEMPLATE )
|
else if( this.kind == Type.CLASS_OR_TYPENAME || this.kind == Type.TEMPLATE )
|
||||||
{
|
{
|
||||||
|
@ -160,4 +176,20 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||||
{
|
{
|
||||||
throw new ASTNotImplementedException();
|
throw new ASTNotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isComplex()
|
||||||
|
*/
|
||||||
|
public boolean isComplex()
|
||||||
|
{
|
||||||
|
return complex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#isImaginary()
|
||||||
|
*/
|
||||||
|
public boolean isImaginary()
|
||||||
|
{
|
||||||
|
return imaginary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ 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.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.*;
|
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.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.parser.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.*;
|
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.ast.NamedOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +58,8 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
||||||
setStartingOffset(startingOffset);
|
setStartingOffset(startingOffset);
|
||||||
setNameOffset(nameOffset);
|
setNameOffset(nameOffset);
|
||||||
setNameEndOffset( nameEndOffset );
|
setNameEndOffset( nameEndOffset );
|
||||||
|
if( initializerClause != null )
|
||||||
|
initializerClause.setOwnerVariableDeclaration(this);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isAuto()
|
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isAuto()
|
||||||
|
|
|
@ -176,9 +176,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType, org.eclipse.cdt.core.parser.ITokenDuple)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType, org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
*/
|
*/
|
||||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(IASTScope scope, Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename )
|
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(IASTScope scope, Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary )
|
||||||
{
|
{
|
||||||
return new ASTSimpleTypeSpecifier( kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename );
|
return new ASTSimpleTypeSpecifier( kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename, isComplex, isImaginary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -210,7 +210,8 @@ public class QuickParseASTFactory extends BaseASTFactory implements 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, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
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, int nameEndOffset, IASTExpression constructorExpression, ASTAccessVisibility visibility)
|
||||||
{
|
{
|
||||||
return new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, nameEndOffset, constructorExpression, visibility);
|
final ASTField field = new ASTField(scope, name, isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern, isRegister, isStatic, startingOffset, nameOffset, nameEndOffset, constructorExpression, visibility);
|
||||||
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -309,4 +310,10 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier)
|
public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTInitializerClause createInitializerClause(IASTScope scope, IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators)
|
||||||
|
{
|
||||||
|
return new ASTInitializerClause( kind, assignmentExpression, initializerClauses, designators );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.pst;
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,6 +87,8 @@ public class TypeInfo {
|
||||||
public static final int isShort = 0x40000;
|
public static final int isShort = 0x40000;
|
||||||
public static final int isLong = 0x80000;
|
public static final int isLong = 0x80000;
|
||||||
public static final int isForward = 0x100000;
|
public static final int isForward = 0x100000;
|
||||||
|
public static final int isComplex = 0x200000;
|
||||||
|
public static final int isImaginary= 0x400000;
|
||||||
|
|
||||||
// Types (maximum type is typeMask
|
// Types (maximum type is typeMask
|
||||||
// Note that these should be considered ordered and if you change
|
// Note that these should be considered ordered and if you change
|
||||||
|
@ -113,6 +115,7 @@ public class TypeInfo {
|
||||||
public static final TypeInfo.eType t_template = new TypeInfo.eType( 18 );
|
public static final TypeInfo.eType t_template = new TypeInfo.eType( 18 );
|
||||||
public static final TypeInfo.eType t_asm = new TypeInfo.eType( 19 );
|
public static final TypeInfo.eType t_asm = new TypeInfo.eType( 19 );
|
||||||
public static final TypeInfo.eType t_linkage = new TypeInfo.eType( 20 );
|
public static final TypeInfo.eType t_linkage = new TypeInfo.eType( 20 );
|
||||||
|
public static final TypeInfo.eType t__Bool = new TypeInfo.eType( 21 );
|
||||||
//public static final eType t_templateParameter = new eType( 18 );
|
//public static final eType t_templateParameter = new eType( 18 );
|
||||||
|
|
||||||
public static class eType implements Comparable{
|
public static class eType implements Comparable{
|
||||||
|
|
|
@ -24,7 +24,6 @@ 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.IASTTemplateParameter;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.ASTArrayModifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a utility class to help convert AST elements to Strings.
|
* This is a utility class to help convert AST elements to Strings.
|
||||||
|
@ -172,7 +171,7 @@ public class ASTUtil {
|
||||||
StringBuffer arrayString = new StringBuffer();
|
StringBuffer arrayString = new StringBuffer();
|
||||||
Iterator i = declaration.getArrayModifiers();
|
Iterator i = declaration.getArrayModifiers();
|
||||||
while (i.hasNext()){
|
while (i.hasNext()){
|
||||||
ASTArrayModifier q = (ASTArrayModifier) i.next();
|
i.next();
|
||||||
arrayString.append("[]");
|
arrayString.append("[]");
|
||||||
}
|
}
|
||||||
return arrayString.toString();
|
return arrayString.toString();
|
||||||
|
|
Loading…
Add table
Reference in a new issue