Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] [HEAD] more updates for parser to handle _Bool

Updates to handle _Bool

Core:
 - modified  CompleteParseASTFactory.getParameterTypeInfo
                 CompleteParseASTFactory.createReference 
                 CompleteParseASTFactory.usualArithmeticConversions
                 CompleteParseASTFactory.getTypeKind
                 Parser.typeId
                 TypeFilter.shouldAccept
                 TypeInfo.equals
Core.tests:
- Added CompleteParseASTTest.testCBoolAsParameter

tested on windows & linux

-Andrew

Index: parser/ChangeLog-parser
===================================================================
retrieving revision 1.30
diff -u -r1.30 ChangeLog-parser
--- parser/ChangeLog-parser	27 Jan 2004 02:36:23 -0000	1.30
+++ parser/ChangeLog-parser	27 Jan 2004 18:37:58 -0000
@@ -1,3 +1,13 @@
+2004-01-27 Andrew Niefer
+	Updates to handle _Bool
+	 - modified  CompleteParseASTFactory.getParameterTypeInfo
+				 CompleteParseASTFactory.createReference 
+				 CompleteParseASTFactory.usualArithmeticConversions
+				 CompleteParseASTFactory.getTypeKind
+				 Parser.typeId
+				 TypeFilter.shouldAccept
+				 TypeInfo.equals
+
 2004-01-26 John Camelon
 	Added traceLogs into Scanner.  
 	Fixed Bug 46402 : expression evaluation error on branch not taken
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
retrieving revision 1.139
diff -u -r1.139 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java	27 Jan 2004 01:21:18 -0000	1.139
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java	27 Jan 2004 18:38:03 -0000
@@ -4078,7 +4078,13 @@
 						consume();
 						break;
 
-                        
+					case IToken.t__Bool :
+						if( encounteredType ) break simpleMods;
+						encounteredType = true;                    
+						kind = IASTSimpleTypeSpecifier.Type._BOOL;
+						consume();
+						break;
+						
                     default :
                         break simpleMods;
                 }
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
retrieving revision 1.69
diff -u -r1.69 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java	22 Jan 2004 16:08:35 -0000	1.69
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java	27 Jan 2004 18:38:05 -0000
@@ -699,7 +699,8 @@
 				( symbol.getType() == TypeInfo.t_int )   ||
 				( symbol.getType() == TypeInfo.t_float )||
 				( symbol.getType() == TypeInfo.t_double ) ||    
-				( symbol.getType() == TypeInfo.t_void )  )
+				( symbol.getType() == TypeInfo.t_void ) ||
+				( symbol.getType() == TypeInfo.t__Bool) )
 			
 		{
 			if( symbol.getContainingSymbol().getType() == TypeInfo.t_class || 
@@ -977,8 +978,8 @@
 			rhs = rhs.getTypeSymbol().getTypeInfo();  
 		}
 		
-		if( !lhs.isType(TypeInfo.t_bool, TypeInfo.t_enumerator ) && 
-			!rhs.isType(TypeInfo.t_bool, TypeInfo.t_enumerator ) ) 
+		if( !lhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) && 
+			!rhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) ) 
 		{
 			throw new ASTSemanticException(); 
 		}
@@ -1751,6 +1752,9 @@
 				type.setType(TypeInfo.t_wchar_t);
 			else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
 				type.setType(TypeInfo.t_type);
+			else if( kind == IASTSimpleTypeSpecifier.Type._BOOL ){
+				type.setType( TypeInfo.t__Bool );
+			}
 			else
 				throw new ASTSemanticException(); 
 		}
@@ -2728,6 +2732,8 @@
 		 IASTSimpleTypeSpecifier.Type type = id.getKind();
 		 if( type == IASTSimpleTypeSpecifier.Type.BOOL )
 			 return TypeInfo.t_bool;
+		 else if( type == IASTSimpleTypeSpecifier.Type._BOOL )
+		     return TypeInfo.t__Bool;
 		 else if( type == IASTSimpleTypeSpecifier.Type.CHAR )
 			 return TypeInfo.t_char;
 		 else if( type == IASTSimpleTypeSpecifier.Type.DOUBLE )
Index: parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java
===================================================================
retrieving revision 1.5
diff -u -r1.5 TypeFilter.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java	15 Jan 2004 18:06:14 -0000	1.5
+++ parser/org/eclipse/cdt/internal/core/parser/pst/TypeFilter.java	27 Jan 2004 18:38:06 -0000
@@ -74,7 +74,7 @@
 				return false;
 			}
 		} 
-		else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t_bool, TypeInfo.t_void ) )
+		else if ( typeInfo.isType( TypeInfo.t_type ) || typeInfo.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
 		{
 			if( ( acceptedKinds.contains( LookupKind.VARIABLES ) 	   && !symbolIsMember && !symbolIsLocal ) ||
 				( acceptedKinds.contains( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal )  ||
Index: parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java
===================================================================
retrieving revision 1.9
diff -u -r1.9 TypeInfo.java
--- parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java	27 Jan 2004 02:36:23 -0000	1.9
+++ parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfo.java	27 Jan 2004 18:38:06 -0000
@@ -479,8 +479,8 @@
 			result &= _typeDeclaration.equals( type._typeDeclaration );
 		} else {
 			if( _typeDeclaration != null && type._typeDeclaration != null   &&
-				_typeDeclaration.isType( TypeInfo.t_bool, TypeInfo.t_void ) &&
-				type._typeDeclaration.isType( TypeInfo.t_bool, TypeInfo.t_void ) )
+				_typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) &&
+				type._typeDeclaration.isType( TypeInfo.t__Bool, TypeInfo.t_void ) )
 			{
 				//if typeDeclaration is a basic type, then only need the types the same
 				result &= ( _typeDeclaration.getType() == type._typeDeclaration.getType() );		
Index: ChangeLog
===================================================================
retrieving revision 1.173
diff -u -r1.173 ChangeLog
--- ChangeLog	27 Jan 2004 02:36:30 -0000	1.173
+++ ChangeLog	27 Jan 2004 18:43:53 -0000
@@ -1,3 +1,6 @@
+2004-01-27 Andrew Niefer
+	Added CompleteParseASTTest.testCBoolAsParameter
+	
 2004-01-26 John Camelon
 	Updated clients to use new Scanner logging service.
 	Added ScannerTestCase.testBug46402().  
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
retrieving revision 1.50
diff -u -r1.50 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java	17 Jan 2004 00:18:07 -0000	1.50
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java	27 Jan 2004 18:43:56 -0000
@@ -986,6 +986,25 @@
 		assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type._BOOL );
 	}
 	
+	public void testCBoolAsParameter() throws Exception
+	{
+		Iterator i = parse( "void f( _Bool b ) {} " +
+							"_Bool g( _Bool b ) {} " +
+							"void main(){" +
+							"   _Bool b;  " +
+							"   f(b);" +
+							"	f( g( (_Bool) 1 )  );" +
+							"}", 
+							true, ParserLanguage.C ).getDeclarations();
+		
+		IASTFunction f = (IASTFunction) i.next();
+		IASTFunction g = (IASTFunction) i.next();
+		IASTFunction main = (IASTFunction) i.next();
+		IASTVariable b = (IASTVariable) getDeclarations( main ).next();
+		
+		assertAllReferences( 4, createTaskList( new Task( f, 2 ), new Task( b ), new Task( g ) ) );
+	}
+	
 	public void testBug44510() throws Exception
 	{
 		Iterator i = parse( "int initialize(); " +

Back to the top