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/csharp cs_grammar.y,1.29,1.30


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y,1.29,1.30
Date: Sun, 03 Nov 2002 04:25:20 -0500

Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv26131/cscc/csharp

Modified Files:
        cs_grammar.y 
Log Message:
IndexerName hack


Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** cs_grammar.y        19 Oct 2002 21:49:17 -0000      1.29
--- cs_grammar.y        3 Nov 2002 09:25:15 -0000       1.30
***************
*** 317,320 ****
--- 317,364 ----
  }
  
+ /* A hack to rename the indexer during parsing , damn the C# designers,
+  * they had to make the variable names resolved later using an attribute
+  * public int <name>[int posn] would have been a cleaner design 
+  */
+ static ILNode *GetIndexerName(ILGenInfo *info,ILNode_AttributeTree *attrTree)
+ {
+       ILNode_ListIter iter;
+       ILNode_ListIter iter2;
+       ILNode *temp;
+       ILNode *attr;
+       ILNode_List *args;
+       ILEvalValue evalValue;
+       if(attrTree && attrTree->sections)
+       {
+               ILNode_ListIter_Init(&iter, attrTree->sections);
+               while((temp = ILNode_ListIter_Next(&iter))!=0)
+               {       
+                       if(!temp || 
!((ILNode_AttributeSection*)temp)->attrs)continue;
+                       ILNode_ListIter_Init(&iter2, 
+                               ((ILNode_AttributeSection*)(temp))->attrs);
+                       while((attr = ILNode_ListIter_Next(&iter2))!=0)
+                       {
+                               
if(!strcmp(ILQualIdentName(((ILNode_Attribute*)attr)->name,0)
+                                                       ,"IndexerName"))
+                               {
+                                       args=(ILNode_List*)((ILNode_AttrArgs*)
+                                               
(((ILNode_Attribute*)attr)->args))->positionalArgs;     
+                                       if(yyisa(args->item1, ILNode_ToConst))
+                                       {
+                                               
ILNode_EvalConst(args->item1,info,&evalValue);
+                                               
if(evalValue.valueType==ILMachineType_String)
+                                               {
+                                                       return 
ILQualIdentSimple(ILInternString(
+                                                                               
evalValue.un.strValue.str
+                                                                               
,evalValue.un.strValue.len).string);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       /* THE BIG ELSE */
+       return ILQualIdentSimple(ILInternString("Item", 4).string);
+ }
  /*
   * Adjust the name of a property to include a "get_" or "set_" prefix.
***************
*** 2850,2856 ****
        : OptAttributes OptModifiers IndexerDeclarator
                        StartAccessorBlock AccessorBlock                {
                                ILUInt32 attrs = 
CSModifiersToPropertyAttrs($3.type, $2);
                                $$ = ILNode_PropertyDeclaration_create($1,
!                                                                  attrs, 
$3.type, $3.ident, $3.params,
                                                                   $5.item1, 
$5.item2,
                                                                   (($5.item1 ? 
1 : 0) |
--- 2894,2901 ----
        : OptAttributes OptModifiers IndexerDeclarator
                        StartAccessorBlock AccessorBlock                {
+                               ILNode* 
name=GetIndexerName(NULL,(ILNode_AttributeTree*)$1);
                                ILUInt32 attrs = 
CSModifiersToPropertyAttrs($3.type, $2);
                                $$ = ILNode_PropertyDeclaration_create($1,
!                                                                  attrs, 
$3.type, name, $3.params,
                                                                   $5.item1, 
$5.item2,
                                                                   (($5.item1 ? 
1 : 0) |
***************
*** 3421,3426 ****
                                                                 
IL_META_METHODDEF_SPECIAL_NAME |
                                                                 
IL_META_METHODDEF_NEW_SLOT;
!                               ILNode *name = ILQualIdentSimple
!                                                                       
(ILInternString("Item", 4).string);
                                $$ = ILNode_PropertyDeclaration_create
                                                                ($1, attrs, $3, 
name, $5, 0, 0, $7);
--- 3466,3470 ----
                                                                 
IL_META_METHODDEF_SPECIAL_NAME |
                                                                 
IL_META_METHODDEF_NEW_SLOT;
!                               ILNode* 
name=GetIndexerName(NULL,(ILNode_AttributeTree*)$1);
                                $$ = ILNode_PropertyDeclaration_create
                                                                ($1, attrs, $3, 
name, $5, 0, 0, $7);





reply via email to

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