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_decls.tc,1.25,1.26


From: Jonathan Springer <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_decls.tc,1.25,1.26
Date: Sat, 16 Nov 2002 20:05:00 -0500

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

Modified Files:
        cs_decls.tc 
Log Message:


Class constructors extracted to guarantee textual order of execution.


Index: cs_decls.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_decls.tc,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -r1.25 -r1.26
*** cs_decls.tc 16 Nov 2002 08:11:42 -0000      1.25
--- cs_decls.tc 17 Nov 2002 01:04:57 -0000      1.26
***************
*** 33,38 ****
--- 33,60 ----
  }
  
+ /*  Since we can't (shouldn't?) inherit list from multiple types, this
+  *  operation will iterate over a list of declarations adding to the 
+  *  compound constructor */
+ static void CSListGatherStaticCtor(ILNode_List *node, ILNode_List *ctor)
+ {
+       ILNode_ListIter iter;
+       ILNode_Declaration *curr;
+ 
+       if (yyisa(node, ILNode_List) || node == 0)
+       {
+               /* Iterate through the body gathering up the necessary 
constructors */
+               ILNode_ListIter_Init(&iter, node);
+               while ((curr = (ILNode_Declaration 
*)ILNode_ListIter_Next(&iter)))
+               {
+                       ILNode_Declaration_GatherStaticCtor(curr, ctor);
+               }
+       }
+ }
+ 
  %}
  
+ %operation void ILNode_Declaration_GatherStaticCtor
+               ([ILNode_Declaration *node], ILNode_List *ctor) = {0};
+ 
  /*
   * Perform semantic analysis for class definitions.
***************
*** 117,121 ****
                                                           
&(node->initCtorsMethod));
                }
!               if(node->staticCtors)
                {
                        /* Create a method for the static constructors and
--- 139,159 ----
                                                           
&(node->initCtorsMethod));
                }
! 
!               /*  Create static constructor method if necessary  */
!               if (!node->staticCtors)
!               {
!                       node->staticCtors = ILNode_List_create();
!               }
! 
!               ILNode_Declaration_GatherStaticCtor
!                                                               (   
(ILNode_Declaration *)node->body, 
!                                                                       
(ILNode_List *)node->staticCtors);
! 
!               if (ILNode_List_Length(node->staticCtors) == 0)
!               {
!                       /*  There were no static constructors after all  */
!                       node->staticCtors = 0;
!               }
!               else
                {
                        /* Create a method for the static constructors and
***************
*** 192,195 ****
--- 230,242 ----
  }
  
+ ILNode_Declaration_GatherStaticCtor(ILNode_ClassDefn),
+ ILNode_Declaration_GatherStaticCtor(ILNode_ScopeChange)
+ {
+       if (node->body) 
+       {
+               CSListGatherStaticCtor((ILNode_List *)node->body, ctor);
+       }
+ }
+ 
  /*
   * Perform semantic analysis for declaration scope changes.
***************
*** 471,485 ****
  }
  
- void CSAddStaticCtor(ILGenInfo *info, ILNode *stmt)
- {
-       ILNode_ClassDefn *defn = (ILNode_ClassDefn *)(info->currentClass);
-       if(defn && stmt)
-       {
-               stmt = ILNode_NewScope_create(stmt);
-               defn->staticCtors =
-                       ILNode_Compound_CreateFrom(defn->staticCtors, stmt);
-       }
- }
- 
  void CSAddInitCtor(ILGenInfo *info, ILNode *stmt)
  {
--- 518,521 ----
***************
*** 582,585 ****
--- 618,630 ----
  }
  
+ ILNode_Declaration_GatherStaticCtor(ILNode_FieldDeclaration)
+ {
+       if (node->fieldDeclarators) 
+       {
+               return CSListGatherStaticCtor
+                                                       ((ILNode_List 
*)node->fieldDeclarators, ctor);
+       }
+ }
+ 
  ILNode_SemAnalysis(ILNode_FieldDeclarator)
  {
***************
*** 688,692 ****
  
        /* Add a statement to the static constructor to initialize the field */
!       CSAddStaticCtor(info, ILNode_Assign_create(node->name, 
node->initializer));
  
  done:
--- 733,740 ----
  
        /* Add a statement to the static constructor to initialize the field */
!       /*      CSAddStaticCtor(info,  
!                        ILNode_Assign_create(node->name, node->initializer)); 
*/
!       node->staticCtor = ILNode_NewScope_create
!                                               
(ILNode_Assign_create(node->name, node->initializer));
  
  done:
***************
*** 696,699 ****
--- 744,752 ----
  }
  
+ ILNode_Declaration_GatherStaticCtor(ILNode_FieldDeclarator)
+ {
+       ILNode_List_Add(ctor, node->staticCtor);
+ }
+ 
  ILNode_SemAnalysis(ILNode_EventDeclaration)
  {
***************
*** 1170,1173 ****
--- 1223,1242 ----
        /* Nothing to do here */
        return CSSemValueDefault;
+ }
+ 
+ ILNode_Declaration_GatherStaticCtor(ILNode_EventDeclaration),
+ ILNode_Declaration_GatherStaticCtor(ILNode_EventDeclarator),
+ ILNode_Declaration_GatherStaticCtor(ILNode_MethodDeclaration),
+ ILNode_Declaration_GatherStaticCtor(ILNode_PropertyDeclaration),
+ ILNode_Declaration_GatherStaticCtor(ILNode_EnumMemberDeclaration),
+ ILNode_Declaration_GatherStaticCtor(ILNode_DelegateMemberDeclaration),
+ ILNode_Declaration_GatherStaticCtor(ILNode_FormalParameter),
+ ILNode_Declaration_GatherStaticCtor(ILNode_AttributeTree),
+ ILNode_Declaration_GatherStaticCtor(ILNode_AttributeSection),
+ ILNode_Declaration_GatherStaticCtor(ILNode_Attribute),
+ ILNode_Declaration_GatherStaticCtor(ILNode_AttrArgs),
+ ILNode_Declaration_GatherStaticCtor(ILNode_NamedArg)
+ {
+       return;
  }
  





reply via email to

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