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_function.c,1.19,1.20 c_grammar


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/c c_function.c,1.19,1.20 c_grammar.y,1.46,1.47
Date: Tue, 24 Jun 2003 21:27:18 -0400

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

Modified Files:
        c_function.c c_grammar.y 
Log Message:


Implement global initializer flushing in the C compiler.


Index: c_function.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_function.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** c_function.c        28 Dec 2002 17:17:02 -0000      1.19
--- c_function.c        25 Jun 2003 01:27:16 -0000      1.20
***************
*** 35,38 ****
--- 35,39 ----
  static ILMethod *currMethod = 0;
  static ILType *localVarSig = 0;
+ static int initNumber = 0;
  
  /*
***************
*** 319,322 ****
--- 320,332 ----
                                             IL_META_METHODDEF_SPECIAL_NAME);
        }
+       if(CAttrPresent(decl.attrs, ".init", ".init"))
+       {
+               /* This is a "normal" initializer, generated by the compiler */
+               AddInitOrFini(info, ILToProgramItem(method),
+                                         "InitializerAttribute", 
"InitializerOrderAttribute", 0);
+               ILMemberSetAttrs((ILMember *)method,
+                                            IL_META_METHODDEF_SPECIAL_NAME,
+                                            IL_META_METHODDEF_SPECIAL_NAME);
+       }
        if(CAttrPresent(decl.attrs, "destructor", "__destructor__"))
        {
***************
*** 582,586 ****
  void CFunctionFlushInits(ILGenInfo *info, ILNode *list)
  {
!       /* TODO */
  }
  
--- 592,631 ----
  void CFunctionFlushInits(ILGenInfo *info, ILNode *list)
  {
!       CDeclSpec spec;
!       CDeclarator decl;
!       char buf[64];
!       char *name;
!       ILMethod *method;
!       ILNode *attributes;
!       ILScope *scope;
! 
!       /* Set the return type, which is "void" */
!       CDeclSpecSetType(spec, ILType_Void);
!       spec.specifiers = C_SPEC_STATIC;
! 
!       /* Build the initializer name */
!       sprintf(buf, ".init-%d", initNumber);
!       ++initNumber;
!       name = ILInternString(buf, -1).string;
! 
!       /* Build the attribute list, containing just ".init" */
!       attributes = ILNode_List_create();
!       ILNode_List_Add(attributes, ILNode_CAttribute_create(".init", 0));
! 
!       /* Build a prototype for the initializer */
!       CDeclSetName(decl, name, ILQualIdentSimple(name));
!       decl = CDeclCreatePrototype(info, decl, 0, attributes);
! 
!       /* Create the method header for the initializer */
!       method = CFunctionCreate
!               (info, name, list, spec, decl, ILNode_List_create());
! 
!       /* Wrap the function body in a new scope */
!       scope = ILScopeCreate(info, CGlobalScope);
!       list = ILNode_NewScope_create(list);
!       ((ILNode_NewScope *)list)->scope = scope;
! 
!       /* Output the initializer */
!       CFunctionOutput(info, method, list);
  }
  

Index: c_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_grammar.y,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** c_grammar.y 16 Apr 2003 01:54:45 -0000      1.46
--- c_grammar.y 25 Jun 2003 01:27:16 -0000      1.47
***************
*** 291,296 ****
  }
  
- #if 0
- 
  /*
   * Add a global initializer statement to the pending list.
--- 291,294 ----
***************
*** 303,307 ****
        stmt = ILNode_CGlobalVar_create(name, type, CTypeDecay(&CCCodeGen, 
type));
        CGenCloneLine(stmt, node);
!       stmt = ILNode_Assign_create(stmt, init);
  
        /* Add the statement to the pending list */
--- 301,313 ----
        stmt = ILNode_CGlobalVar_create(name, type, CTypeDecay(&CCCodeGen, 
type));
        CGenCloneLine(stmt, node);
!       if(CTypeIsArray(type))
!       {
!               stmt = ILNode_CAssignArray_create(stmt, init);
!       }
!       else
!       {
!               stmt = ILNode_Assign_create(stmt, init);
!       }
!       CGenCloneLine(stmt, init);
  
        /* Add the statement to the pending list */
***************
*** 313,318 ****
  }
  
- #endif
- 
  /*
   * Report a redeclaration error.
--- 319,322 ----
***************
*** 718,722 ****
                }
  
!               /* TODO: process initializers */
        }
        else
--- 722,730 ----
                }
  
!               /* Process the initializer */
!               if(init)
!               {
!                       AddInitializer(decl.name, decl.node, type, init);
!               }
        }
        else





reply via email to

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