dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_grammar.y,1.49,1.50 c_types.c,


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/c c_grammar.y,1.49,1.50 c_types.c,1.32,1.33 c_types.h,1.15,1.16
Date: Thu, 26 Jun 2003 02:12:48 -0400

Update of /cvsroot/dotgnu-pnet/pnet/cscc/c
In directory subversions:/tmp/cvs-serv19944/cscc/c

Modified Files:
        c_grammar.y c_types.c c_types.h 
Log Message:


Resolve anonymous enumerated types and constants to the
underlying type because there is no way to define an
enumerated type that will work across modules otherwise.


Index: c_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_grammar.y,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** c_grammar.y 25 Jun 2003 09:59:21 -0000      1.49
--- c_grammar.y 26 Jun 2003 06:12:46 -0000      1.50
***************
*** 1912,1916 ****
  
                                /* Return the completed type to the next higher 
level */
!                               $$ = $<structInfo>3.type;
                        }
        | K_ENUM AnyIdentifier '{'      {
--- 1912,1916 ----
  
                                /* Return the completed type to the next higher 
level */
!                               $$ = CTypeResolveAnonEnum($<structInfo>3.type);
                        }
        | K_ENUM AnyIdentifier '{'      {
***************
*** 1994,1998 ****
                                                                                
 $1, currentEnumValue);
                                        CScopeAddEnumConst($1, 
ILQualIdentSimple($1),
!                                                                          
currentEnumValue, currentEnum);
                                }
                                ++currentEnumValue;
--- 1994,1999 ----
                                                                                
 $1, currentEnumValue);
                                        CScopeAddEnumConst($1, 
ILQualIdentSimple($1),
!                                                                          
currentEnumValue,
!                                                                          
CTypeResolveAnonEnum(currentEnum));
                                }
                                ++currentEnumValue;
***************
*** 2022,2026 ****
                                                                                
 $1, currentEnumValue);
                                        CScopeAddEnumConst($1, 
ILQualIdentSimple($1),
!                                                                          
currentEnumValue, currentEnum);
                                }
                                ++currentEnumValue;
--- 2023,2028 ----
                                                                                
 $1, currentEnumValue);
                                        CScopeAddEnumConst($1, 
ILQualIdentSimple($1),
!                                                                          
currentEnumValue,
!                                                                          
CTypeResolveAnonEnum(currentEnum));
                                }
                                ++currentEnumValue;

Index: c_types.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_types.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** c_types.c   26 Jun 2003 04:55:54 -0000      1.32
--- c_types.c   26 Jun 2003 06:12:46 -0000      1.33
***************
*** 725,728 ****
--- 725,740 ----
  }
  
+ ILType *CTypeResolveAnonEnum(ILType *type)
+ {
+       if(!CTypeIsAnonEnum(type))
+       {
+               return type;
+       }
+       else
+       {
+               return ILTypeGetEnumType(ILTypeStripPrefixes(type));
+       }
+ }
+ 
  ILField *CTypeDefineField(ILGenInfo *info, ILType *structType,
                                                  const char *fieldName, ILType 
*fieldType)
***************
*** 1725,1728 ****
--- 1737,1753 ----
        {
                if(!strncmp(ILClass_Name(ILType_ToValueType(type)), "enum ", 5))
+               {
+                       return 1;
+               }
+       }
+       return 0;
+ }
+ 
+ int CTypeIsAnonEnum(ILType *type)
+ {
+       type = ILTypeStripPrefixes(type);
+       if(ILType_IsValueType(type))
+       {
+               if(!strncmp(ILClass_Name(ILType_ToValueType(type)), "enum (", 
6))
                {
                        return 1;

Index: c_types.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_types.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** c_types.h   16 Feb 2003 23:52:43 -0000      1.15
--- c_types.h   26 Jun 2003 06:12:46 -0000      1.16
***************
*** 133,136 ****
--- 133,142 ----
  
  /*
+  * Resolve an anonymous enumerated type to its underlying type.
+  * Regular enumerated types are left as-is.
+  */
+ ILType *CTypeResolveAnonEnum(ILType *type);
+ 
+ /*
   * Define a new field within a "struct" or "union".  Returns NULL
   * if the type is dynamic in size.
***************
*** 212,215 ****
--- 218,226 ----
   */
  int CTypeIsEnum(ILType *type);
+ 
+ /*
+  * Determine if a C type is an anonymous enumerated type.
+  */
+ int CTypeIsAnonEnum(ILType *type);
  
  /*





reply via email to

[Prev in Thread] Current Thread [Next in Thread]