[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_ainit.tc,1.3,1.4 c_builtin.tc,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/cscc/c c_ainit.tc,1.3,1.4 c_builtin.tc,1.6,1.7 c_defs.tc,1.22,1.23 |
Date: |
Fri, 27 Jun 2003 02:19:57 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/cscc/c
In directory subversions:/tmp/cvs-serv17830/cscc/c
Modified Files:
c_ainit.tc c_builtin.tc c_defs.tc
Log Message:
Initialization of arrays containing strings (e.g. char[] x = "abc").
Index: c_ainit.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_ainit.tc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** c_ainit.tc 27 Jun 2003 02:04:47 -0000 1.3
--- c_ainit.tc 27 Jun 2003 06:19:54 -0000 1.4
***************
*** 19,22 ****
--- 19,24 ----
*/
+ %output "c_semantics.c"
+
%{
***************
*** 223,226 ****
--- 225,229 ----
return CSemValueError;
}
+ node->type = CSemGetType(value1);
/* Determine the type of assignment based on the r-value */
***************
*** 270,273 ****
--- 273,325 ----
}
+ %output "c_nodes.c"
+
+ %{
+
+ /*
+ * Write an initializer into memory at a specific pointer location,
+ * where the pointer is on the stack.
+ */
+ static void WriteInitializer(ILGenInfo *info, ILType *type, ILNode *node)
+ {
+ ILUInt32 size;
+
+ if(yyisa(node, ILNode_CString))
+ {
+ /* Write the contents of a string to a location */
+ if(CTypeIsArray(type))
+ {
+ /* Populate an array by copying a string into it */
+ ILNode_GenValue(node, info);
+ size = CTypeGetNumElems(type);
+ if(size > (((ILNode_CString *)node)->len + 1))
+ {
+ size = ((ILNode_CString *)node)->len + 1;
+ }
+ ILGenUInt32(info, size);
+ ILGenAdjust(info, 1);
+ ILGenByteInsn(info, IL_OP_PREFIX +
IL_PREFIX_OP_UNALIGNED, 1);
+ ILGenSimple(info, IL_OP_PREFIX + IL_PREFIX_OP_CPBLK);
+ ILGenAdjust(info, -3);
+ }
+ else
+ {
+ /* Store the string directly as a pointer */
+ ILNode_GenValue(node, info);
+ ILGenSimple(info, IL_OP_STIND_I);
+ ILGenAdjust(info, -2);
+ }
+ }
+ else
+ {
+ /* Write the contents of an array or structure to a location */
+ /* TODO */
+ ILGenSimple(info, IL_OP_POP);
+ ILGenAdjust(info, -1);
+ }
+ }
+
+ %}
+
/*
* Generate discard code for an array assignment statement.
***************
*** 275,279 ****
ILNode_GenDiscard(ILNode_CAssignArray)
{
! /* TODO */
}
JavaGenDiscard(ILNode_CAssignArray)
--- 327,335 ----
ILNode_GenDiscard(ILNode_CAssignArray)
{
! /* Get the address of the array */
! CGenAddress(info, node->expr1);
!
! /* Write the initializer value into the array */
! WriteInitializer(info, node->type, node->expr2);
}
JavaGenDiscard(ILNode_CAssignArray)
Index: c_builtin.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_builtin.tc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** c_builtin.tc 20 Sep 2002 01:05:53 -0000 1.6
--- c_builtin.tc 27 Jun 2003 06:19:54 -0000 1.7
***************
*** 19,22 ****
--- 19,24 ----
*/
+ %output "c_semantics.c"
+
%{
Index: c_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_defs.tc,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** c_defs.tc 27 Jun 2003 02:04:47 -0000 1.22
--- c_defs.tc 27 Jun 2003 06:19:54 -0000 1.23
***************
*** 408,411 ****
--- 408,412 ----
ILNode *expr1;
ILNode *expr2;
+ %nocreate ILType *type = {0};
}
%node ILNode_CAssignStruct ILNode_Statement =
***************
*** 413,416 ****
--- 414,418 ----
ILNode *expr1;
ILNode *expr2;
+ %nocreate ILType *type = {0};
}
%node ILNode_CToCSharpString ILNode_UnaryExpression
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/cscc/c c_ainit.tc,1.3,1.4 c_builtin.tc,1.6,1.7 c_defs.tc,1.22,1.23,
Rhys Weatherley <address@hidden> <=