[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_decls.tc,1.34,1.35 cs_ga
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_decls.tc,1.34,1.35 cs_gather.c,1.38,1.39 |
Date: |
Tue, 25 Feb 2003 21:11:13 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv6681/cscc/csharp
Modified Files:
cs_decls.tc cs_gather.c
Log Message:
Enforce the conditions on abstract method overrides.
Index: cs_decls.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_decls.tc,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** cs_decls.tc 26 Feb 2003 00:07:25 -0000 1.34
--- cs_decls.tc 26 Feb 2003 02:11:11 -0000 1.35
***************
*** 968,971 ****
--- 968,983 ----
}
+ /* If the method is abstract, then the class must be too */
+ if((node->modifiers & IL_META_METHODDEF_ABSTRACT) != 0)
+ {
+ if(info->currentClass &&
+ (((ILNode_ClassDefn *)(info->currentClass))->modifiers &
+ IL_META_TYPEDEF_ABSTRACT) == 0)
+ {
+ CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
+ "`abstract' used on a member in a
non-abstract class");
+ }
+ }
+
/* Perform semantic analysis on the method body */
if(node->body)
Index: cs_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_gather.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** cs_gather.c 26 Feb 2003 00:07:25 -0000 1.38
--- cs_gather.c 26 Feb 2003 02:11:11 -0000 1.39
***************
*** 1859,1862 ****
--- 1859,1915 ----
/*
+ * Check abstract method overrides.
+ */
+ static void CheckAbstractOverrides(ILGenInfo *info, ILClass *classInfo,
+ ILNode *node)
+ {
+ ILClass *parent;
+ ILMethod *method;
+ ILClass *tempClass;
+ ILMethod *method2;
+
+ /* Scan up through the parents and look for all "abstract" methods */
+ parent = ILClass_Parent(classInfo);
+ while(parent != 0)
+ {
+ method = 0;
+ while((method = (ILMethod *)ILClassNextMemberByKind
+ (parent, (ILMember *)method,
IL_META_MEMBERKIND_METHOD)) != 0)
+ {
+ /* Skip non-abstract methods */
+ if(!ILMethod_IsAbstract(method))
+ {
+ continue;
+ }
+
+ /* Scan from "classInfo" to look for an override for
this method */
+ tempClass = classInfo;
+ method2 = 0;
+ while(tempClass != 0 && tempClass != parent)
+ {
+ method2 = (ILMethod *)ILClassNextMemberMatch
+ (tempClass, 0,
IL_META_MEMBERKIND_METHOD,
+ ILMethod_Name(method),
ILMethod_Signature(method));
+ if(method2 && !ILMethod_IsNewSlot(method2))
+ {
+ break;
+ }
+ tempClass = ILClass_Parent(tempClass);
+ method2 = 0;
+ }
+
+ /* If we didn't find a match, then report an error */
+ if(!method2)
+ {
+ CCErrorOnLine(yygetfilename(node),
yygetlinenum(node),
+ "no override for
abstract member `%s'",
+
CSItemToName(ILToProgramItem(method)));
+ }
+ }
+ parent = ILClass_Parent(parent);
+ }
+ }
+
+ /*
* Create the members of a class node.
*/
***************
*** 1952,1955 ****
--- 2005,2015 ----
{
((ILNode_ClassDefn *)classNode)->defaultMemberName =
defaultMemberName;
+ }
+
+ /* If the class is not abstract then make sure that all abstract
+ methods in ancestor classes have been implemented here */
+ if(!ILClass_IsAbstract(classInfo))
+ {
+ CheckAbstractOverrides(info, classInfo, classNode);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_decls.tc,1.34,1.35 cs_gather.c,1.38,1.39,
Rhys Weatherley <address@hidden> <=