[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_gather.c,1.41,1.42 cs_in
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_gather.c,1.41,1.42 cs_internal.h,1.19,1.20 cs_modifiers.c,1.6,1.7 |
Date: |
Thu, 26 Jun 2003 19:55:52 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv13431/cscc/csharp
Modified Files:
cs_gather.c cs_internal.h cs_modifiers.c
Log Message:
Report errors for "Finalize" methods that are not properly declared
as constructors (Bug #4062).
Index: cs_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_gather.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** cs_gather.c 24 May 2003 02:35:26 -0000 1.41
--- cs_gather.c 26 Jun 2003 23:55:50 -0000 1.42
***************
*** 865,868 ****
--- 865,908 ----
/*
+ * Determine if a declaration of "Finalize" will override
+ * the one in "Object" or if it is on a separate "new" slot.
+ */
+ static int IsRealFinalizer(ILClass *classInfo)
+ {
+ ILClass *parent = ILClass_Parent(classInfo);
+ ILMethod *method;
+ ILType *signature;
+ while(parent != 0)
+ {
+ if(ILTypeIsObjectClass(ILType_FromClass(parent)))
+ {
+ /* We've found the declaration in "System.Object" */
+ return 1;
+ }
+ method = 0;
+ while((method = (ILMethod *)ILClassNextMemberMatch
+ (parent, (ILMember *)method,
+ IL_META_MEMBERKIND_METHOD, "Finalize", 0)) !=
0)
+ {
+ signature = ILMethod_Signature(method);
+ if(ILTypeGetReturn(signature) == ILType_Void &&
+ ILTypeNumParams(signature) == 0)
+ {
+ if((ILMethod_Attrs(method) &
+ (IL_META_METHODDEF_NEW_SLOT |
+ IL_META_METHODDEF_VIRTUAL)) !=
+ IL_META_METHODDEF_VIRTUAL)
+ {
+ /* We've found something other than the
real "Finalize" */
+ return 0;
+ }
+ }
+ }
+ parent = ILClass_Parent(parent);
+ }
+ return 0;
+ }
+
+ /*
* Create a method definition.
*/
***************
*** 973,976 ****
--- 1013,1037 ----
/* Get the return type */
tempType = CSSemTypeVoid(method->type, info, &(method->type));
+
+ /* Special handling for "Finalize" to be consistent with the ECMA spec
*/
+ if(!strcmp(name, "Finalize") &&
+ (method->params == 0 || yyisa(method->params, ILNode_Empty)) &&
+ tempType == ILType_Void &&
+ (method->modifiers & CS_SPECIALATTR_DESTRUCTOR) == 0)
+ {
+ if((method->modifiers & CS_SPECIALATTR_OVERRIDE) != 0)
+ {
+ if(IsRealFinalizer(classInfo))
+ {
+ CCErrorOnLine(yygetfilename(method),
yygetlinenum(method),
+ "do not override
`Object.Finalize'; provide "
+ "a destructor
instead");
+ }
+ }
+ else if(!ILTypeIsObjectClass(ILType_FromClass(classInfo)))
+ {
+ method->modifiers |= CS_SPECIALATTR_NEW;
+ }
+ }
/* Create the method signature type */
Index: cs_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_internal.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** cs_internal.h 21 Jun 2003 17:33:51 -0000 1.19
--- cs_internal.h 26 Jun 2003 23:55:50 -0000 1.20
***************
*** 59,62 ****
--- 59,63 ----
#define CS_SPECIALATTR_OVERRIDE 0x01000000
#define CS_SPECIALATTR_VOLATILE 0x00800000
+ #define CS_SPECIALATTR_DESTRUCTOR 0x00400000
/*
Index: cs_modifiers.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_modifiers.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** cs_modifiers.c 14 Jun 2003 19:24:42 -0000 1.6
--- cs_modifiers.c 26 Jun 2003 23:55:50 -0000 1.7
***************
*** 834,838 ****
IL_META_METHODDEF_HIDE_BY_SIG |
IL_META_METHODDEF_VIRTUAL |
! CS_SPECIALATTR_OVERRIDE;
/* Done */
--- 834,839 ----
IL_META_METHODDEF_HIDE_BY_SIG |
IL_META_METHODDEF_VIRTUAL |
! CS_SPECIALATTR_OVERRIDE |
! CS_SPECIALATTR_DESTRUCTOR;
/* Done */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_gather.c,1.41,1.42 cs_internal.h,1.19,1.20 cs_modifiers.c,1.6,1.7,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/engine lib_thread.c,1.11,1.12 monitor.c,1.2,1.3
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel MarshalByValueComponent.cs,1.3,1.4
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/engine lib_thread.c,1.11,1.12 monitor.c,1.2,1.3
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/System/ComponentModel MarshalByValueComponent.cs,1.3,1.4
- Index(es):