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

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

[Dotgnu-pnet-commits] CVS: pnet/codegen cg_nodes.tc, 1.81, 1.82 cg_stmt.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/codegen cg_nodes.tc, 1.81, 1.82 cg_stmt.tc, 1.37, 1.38
Date: Sun, 17 Aug 2003 19:33:20 -0400

Update of /cvsroot/dotgnu-pnet/pnet/codegen
In directory subversions:/tmp/cvs-serv6744/codegen

Modified Files:
        cg_nodes.tc cg_stmt.tc 
Log Message:


Implement "GetType" and "GenValue" for scopes and compound statements,
to support statement expressions in C (bug #4809).


Index: cg_nodes.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_nodes.tc,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -r1.81 -r1.82
*** cg_nodes.tc 25 Jun 2003 13:03:33 -0000      1.81
--- cg_nodes.tc 17 Aug 2003 23:33:17 -0000      1.82
***************
*** 999,1032 ****
  ILNode_GetType(ILNode_Statement)
  {
!       fprintf(stderr, "GetType is not implemented for node type `%s'",
!                       yykindname(node));
!       exit(1);
!       return ILMachineType_Void; /* Not reached */
  }
  ILNode_GenValue(ILNode_Statement)
  {
!       fprintf(stderr, "GenDiscard is not implemented for node type `%s'",
!                       yykindname(node));
!       exit(1);
!       return ILMachineType_Void; /* Not reached */
  }
  ILNode_GenThen(ILNode_Statement)
  {
!       fprintf(stderr, "GenThen is not implemented for node type `%s'",
!                       yykindname(node));
!       exit(1);
  }
  ILNode_GenElse(ILNode_Statement)
  {
!       fprintf(stderr, "GenElse is not implemented for node type `%s'",
!                       yykindname(node));
!       exit(1);
  }
  ILNode_EvalConst(ILNode_Statement)
  {
!       fprintf(stderr, "EvalConst is not implemented for node type `%s'",
!                       yykindname(node));
!       exit(1);
!       return 0; /* Not reached */
  }
  
--- 999,1022 ----
  ILNode_GetType(ILNode_Statement)
  {
!       return ILMachineType_Void;
  }
  ILNode_GenValue(ILNode_Statement)
  {
!       ILNode_GenDiscard(node, info);
!       return ILMachineType_Void;
  }
  ILNode_GenThen(ILNode_Statement)
  {
!       ILMachineType type = ILNode_GenValue(node, info);
!       ILNodeStackThen(info, label, type);
  }
  ILNode_GenElse(ILNode_Statement)
  {
!       ILMachineType type = ILNode_GenValue(node, info);
!       ILNodeStackElse(info, label, type);
  }
  ILNode_EvalConst(ILNode_Statement)
  {
!       return 0;
  }
  

Index: cg_stmt.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_stmt.tc,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** cg_stmt.tc  19 Jan 2003 15:01:53 -0000      1.37
--- cg_stmt.tc  17 Aug 2003 23:33:17 -0000      1.38
***************
*** 351,354 ****
--- 351,380 ----
  
  /*
+  * Get type information for compound statements used as expressions.
+  */
+ ILNode_GetType(ILNode_List)
+ {
+       ILNode_ListIter iter;
+       ILNode *last = 0;
+       ILNode *stmt;
+       ILNode_ListIter_Init(&iter, node);
+       while((stmt = ILNode_ListIter_Next(&iter)) != 0)
+       {
+               if(!yyisa(stmt, ILNode_Empty))
+               {
+                       last = stmt;
+               }
+       }
+       if(last)
+       {
+               return ILNode_GetType(last, info);
+       }
+       else
+       {
+               return ILMachineType_Void;
+       }
+ }
+ 
+ /*
   * Generate discard code for empty statements.
   */
***************
*** 383,386 ****
--- 409,438 ----
  
  /*
+  * Generate value code for compound statements used as expressions.
+  */
+ ILNode_GenValue(ILNode_Compound),
+ ILNode_GenValue(ILNode_List)
+ {
+       ILNode_ListIter iter;
+       ILNode *current;
+       ILMachineType lastType = ILMachineType_Void;
+ 
+       ILNode_ListIter_Init(&iter, node);
+       while((current = ILNode_ListIter_Next(&iter)) != 0)
+       {
+               if(!yyisa(node, ILNode_Empty))
+               {
+                       if(lastType != ILMachineType_Void)
+                       {
+                               ILGenSimple(info, IL_OP_POP);
+                               ILGenAdjust(info, -1);
+                       }
+                       lastType = ILNode_GenValue(current, info);
+               }
+       }
+       return lastType;
+ }
+ 
+ /*
   * Determine if a compound statement ends in a return statement.
   */
***************
*** 1505,1508 ****
--- 1557,1596 ----
  
  %}
+ 
+ /*
+  * Get type information for the "new scope" statement.
+  */
+ ILNode_GetType(ILNode_NewScope)
+ {
+       return ILNode_GetType(node->stmt, info);
+ }
+ 
+ /*
+  * Generate value code for the "new scope" statement.
+  */
+ ILNode_GenValue(ILNode_NewScope)
+ {
+       ILMachineType type;
+       if(info->hasGotoScopes)
+       {
+               /* Enter a new scope */
+               ++(info->scopeLevel);
+ 
+               /* Generate the code within the scope */
+               type = ILNode_GenValue(node->stmt, info);
+ 
+               /* Exit from the scope */
+               --(info->scopeLevel);
+ 
+               /* Trim goto labels that were defined within the scope */
+               TrimGotoList(info, 0);
+       }
+       else
+       {
+               /* Generate the code within the scope */
+               type = ILNode_GenValue(node->stmt, info);
+       }
+       return type;
+ }
  
  /*





reply via email to

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