[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_cast.tc cscc/csha...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_cast.tc cscc/csha... |
Date: |
Sun, 15 Feb 2009 15:00:58 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 09/02/15 15:00:58
Modified files:
. : ChangeLog
cscc/csharp : cs_cast.tc cs_gather.c cs_grammar.y
cs_invoke.tc
Log message:
Fix declaration of base class lists do that declaration order is
preserved
and the check if the base class is the first one in the list can be
performed.
Fix output of generic instances in error messages in cscc.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3603&r2=1.3604
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_cast.tc?cvsroot=dotgnu-pnet&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_gather.c?cvsroot=dotgnu-pnet&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_grammar.y?cvsroot=dotgnu-pnet&r1=1.87&r2=1.88
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_invoke.tc?cvsroot=dotgnu-pnet&r1=1.33&r2=1.34
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3603
retrieving revision 1.3604
diff -u -b -r1.3603 -r1.3604
--- ChangeLog 8 Feb 2009 18:01:46 -0000 1.3603
+++ ChangeLog 15 Feb 2009 15:00:57 -0000 1.3604
@@ -1,3 +1,21 @@
+2009-02-15 Klaus Treichel <address@hidden>
+
+ * cscc/csharp/cs_cast.tc (CSTypeToName): Add handling of generic type
+ instances. Remove unnecessary casts to char * in calls to
ILInternString.
+
+ * cscc/csharp/cs_gather.c (AddBaseClasses): Add the parent class at the
+ earliest point possible so that value types can be distinguished from
+ reference types while semanalyzing the base class lists.
+ (FindInterfaceMatch): Instantiate generic interfaced before looking for
+ interface member implementations.
+
+ * cscc/csharp/cs_grammar.y: Make sure that the declaration order in the
+ base type list is preserved so that the checks in cs_gather.c can be
+ performed.
+
+ * cscc/csharp/cs_invoke.tc (CSItemToName): Handle members if generic
+ instances.
+
2009-02-08 Klaus Treichel <address@hidden>
* codegen/cg_interface.c (ImplementsInterface): Instantiate a generic
Index: cscc/csharp/cs_cast.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_cast.tc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- cscc/csharp/cs_cast.tc 1 Jun 2007 11:08:51 -0000 1.14
+++ cscc/csharp/cs_cast.tc 15 Feb 2009 15:00:57 -0000 1.15
@@ -123,6 +123,23 @@
%end %{
+#if IL_VERSION_MAJOR > 1
+
+/* Get the number of generic prameters for the nested patent class */
+static unsigned long NumNestedParentGenericPars(ILClass *classInfo)
+{
+ ILClass *nestedParentInfo;
+
+ nestedParentInfo = ILClass_NestedParent(classInfo);
+ if(nestedParentInfo)
+ {
+ return ILClassGetNumGenericPars(nestedParentInfo);
+ }
+ return 0;
+}
+
+#endif /* IL_VERSION_MAJOR > 1 */
+
const char *CSTypeToName(ILType *type)
{
if(ILType_IsPrimitive(type))
@@ -165,9 +182,9 @@
if(namespace)
{
finalName = ILInternStringConcat3
- (ILInternString((char
*)namespace, -1),
- ILInternString((char
*)".", 1),
- ILInternString((char
*)name, -1)).string;
+
(ILInternString(namespace, -1),
+ ILInternString(".", 1),
+ ILInternString(name,
-1)).string;
}
else
{
@@ -179,9 +196,9 @@
const char *parentName = CSTypeToName
(ILType_FromClass(ILClass_NestedParent(classInfo)));
finalName = ILInternStringConcat3
- (ILInternString((char
*)parentName, -1),
- ILInternString((char
*)".", 1),
- ILInternString((char
*)finalName, -1)).string;
+
(ILInternString(parentName, -1),
+ ILInternString(".", 1),
+
ILInternString(finalName, -1)).string;
}
return finalName;
}
@@ -192,14 +209,14 @@
if(kind == IL_TYPE_COMPLEX_BYREF)
{
return ILInternAppendedString
- (ILInternString((char
*)CSTypeToName(ILType_Ref(type)), -1),
- ILInternString((char *)" &",
2)).string;
+
(ILInternString(CSTypeToName(ILType_Ref(type)), -1),
+ ILInternString(" &", 2)).string;
}
else if(kind == IL_TYPE_COMPLEX_PTR)
{
return ILInternAppendedString
- (ILInternString((char
*)CSTypeToName(ILType_Ref(type)), -1),
- ILInternString((char *)" *",
2)).string;
+
(ILInternString(CSTypeToName(ILType_Ref(type)), -1),
+ ILInternString(" *", 2)).string;
}
else if(kind == IL_TYPE_COMPLEX_ARRAY ||
kind == IL_TYPE_COMPLEX_ARRAY_CONTINUE)
@@ -215,10 +232,10 @@
{
elemType = ILType_ElemType(elemType);
}
- str = ILInternString((char *)CSTypeToName(elemType),
-1);
- open = ILInternString((char *)"[", 1);
- close = ILInternString((char *)"]", 1);
- comma = ILInternString((char *)",", 1);
+ str = ILInternString(CSTypeToName(elemType), -1);
+ open = ILInternString("[", 1);
+ close = ILInternString("]", 1);
+ comma = ILInternString(",", 1);
str = ILInternAppendedString(str, open);
while(type != elemType)
{
@@ -239,6 +256,69 @@
}
return str.string;
}
+#if IL_VERSION_MAJOR > 1
+ else if(kind == IL_TYPE_COMPLEX_WITH)
+ {
+ unsigned long current;
+ unsigned long numGenericPars;
+ unsigned long numParentGenericPars;
+ const char *typeName;
+ const char *temp;
+ ILType *mainType;
+ ILIntString str;
+
+ mainType = ILTypeGetWithMain(type);
+ typeName = CSTypeToName(mainType);
+
+ /* Strip the part including the arity fromm the type
name */
+ temp = strchr(typeName, '`');
+ if(temp)
+ {
+ str = ILInternString(typeName, (int)(temp -
typeName));
+ }
+ else
+ {
+ /* A non generic class nested in a generic
class */
+ str = ILInternString(typeName, -1);
+ }
+ numParentGenericPars =
NumNestedParentGenericPars(ILType_ToClass(mainType));
+ numGenericPars = ILTypeNumWithParams(type);
+ if(numGenericPars > numParentGenericPars)
+ {
+ ILIntString open;
+ ILIntString close;
+ ILIntString comma;
+ ILIntString tempString;
+
+ open = ILInternString("<", 1);
+ close = ILInternString(">", 1);
+ comma = ILInternString(",", 1);
+ str = ILInternAppendedString(str, open);
+ current = numParentGenericPars + 1;
+ while(current <= numGenericPars)
+ {
+ if(current > numParentGenericPars + 1)
+ {
+ str =
ILInternAppendedString(str, comma);
+ }
+ typeName =
CSTypeToName(ILTypeGetWithParam(type, current));
+ tempString = ILInternString(typeName,
-1);
+ str = ILInternAppendedString(str,
tempString);
+ ++current;
+ }
+ str = ILInternAppendedString(str, close);
+ }
+ return str.string;
+ }
+ else if(kind == IL_TYPE_COMPLEX_VAR)
+ {
+ /* TODO */
+ }
+ else if(kind == IL_TYPE_COMPLEX_MVAR)
+ {
+ /* TODO */
+ }
+#endif /* IL_VERSION_MAJOR > 1 */
else if(kind == IL_TYPE_COMPLEX_CMOD_REQD ||
kind == IL_TYPE_COMPLEX_CMOD_OPT)
{
@@ -253,13 +333,13 @@
str = ILInternString("/* opt ", -1);
}
temp = ILInternString
- ((char *)(CSTypeToName(ILType_FromClass
-
(type->un.modifier__.info__))), -1);
+ (CSTypeToName(ILType_FromClass
+
(type->un.modifier__.info__)), -1);
str = ILInternAppendedString(str, temp);
temp = ILInternString(" */ ", -1);
str = ILInternAppendedString(str, temp);
temp = ILInternString
- ((char
*)(CSTypeToName(type->un.modifier__.type__)), -1);
+ (CSTypeToName(type->un.modifier__.type__), -1);
str = ILInternAppendedString(str, temp);
return str.string;
}
@@ -273,7 +353,7 @@
/* Convert the return type */
str = ILInternString
- ((char
*)(CSTypeToName(ILTypeGetReturnWithPrefixes(type))), -1);
+
(CSTypeToName(ILTypeGetReturnWithPrefixes(type)), -1);
/* Add the start of the parameter list */
temp = ILInternString(" * (", -1);
@@ -291,7 +371,7 @@
for(param = 1; param <= num; ++param)
{
paramType = ILTypeGetParamWithPrefixes(type,
param);
- temp = ILInternString((char
*)(CSTypeToName(paramType)), -1);
+ temp = ILInternString(CSTypeToName(paramType),
-1);
str = ILInternAppendedString(str, temp);
if(param < num)
{
Index: cscc/csharp/cs_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_gather.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- cscc/csharp/cs_gather.c 26 Nov 2008 20:15:19 -0000 1.62
+++ cscc/csharp/cs_gather.c 15 Feb 2009 15:00:57 -0000 1.63
@@ -364,6 +364,60 @@
}
#endif /* IL_VERSION_MAJOR > 1 */
+static void AddObjectParent(ILGenInfo *info,
+ ILNode_ClassDefn
*classNode,
+ ILClass *classInfo,
+ ILNode
*systemObjectName)
+{
+ ILClass *objectClass;
+ ILProgramItem *parent = 0;
+
+ objectClass = ILType_ToClass(ILFindSystemType(info, "Object"));
+ if(!objectClass)
+ {
+ ILNode *baseTypeNode = 0;
+
+ /* Compiling something else that inherits "System.Object" */
+ if(CSSemBaseType(systemObjectName, info, &systemObjectName,
+ &baseTypeNode, &parent))
+ {
+ if(!parent)
+ {
+ parent = NodeToProgramItem(baseTypeNode);
+ }
+ }
+ }
+ else
+ {
+ parent = ILToProgramItem(objectClass);
+ }
+ if(!parent)
+ {
+ CCErrorOnLine(yygetfilename(classNode), yygetlinenum(classNode),
+ "could not resolve System.Object");
+ }
+ else
+ {
+ /*
+ * Check classInfo is System.Object so we don't have to add the
+ * parent
+ */
+ if(!ILProgramItemToTypeSpec(parent) &&
+ ((objectClass = ILProgramItemToClass(parent)) != 0))
+ {
+ if(ILClassResolve(objectClass) ==
ILClassResolve(classInfo))
+ {
+ /* Compiling System.Object so don't set the
parent. */
+ parent = 0;
+ }
+ }
+ }
+ if(parent)
+ {
+ ILClassSetParent(classInfo, parent);
+ }
+}
+
static void AddBaseClasses(ILGenInfo *info,
ILNode_ClassDefn *classNode,
ILNode *systemObjectName)
@@ -386,6 +440,16 @@
if(numBases > 0)
{
+ if(!strcmp(ILClass_Name(classInfo), "<Module>"))
+ {
+ CCErrorOnLine(yygetfilename(classNode),
yygetlinenum(classNode),
+ "Modules must not
have any base type specifications");
+ numBases = 0;
+ }
+ }
+
+ if(numBases > 0)
+ {
int base;
ILNode *baseNode;
ILNode *baseNodeList;
@@ -441,111 +505,97 @@
{
CCOutOfMemory();
}
-
if(!ILClass_IsInterface(underlying))
+ if(base == 0)
{
- if(parent)
+ /* Handle the first
item in the base list */
+
if(!ILClass_IsInterface(underlying))
{
-
if(!errorReported)
+
if(ILClass_IsInterface(classInfo))
{
+ /*
+ *
Interfaces must not have non interface
+ *
classes in the base list.
+ */
CCErrorOnLine(yygetfilename(classNode),
yygetlinenum(classNode),
-
"class inherits from two or more non-interface classes");
+
"interface inherits from non-interface class");
errorReported = 1;
}
- }
else
{
- parent =
baseList[base];
- }
- baseList[base] = 0;
- }
- }
+
if(ILClass_IsSealed(underlying))
+ {
+
CCErrorOnLine(yygetfilename(classNode),
+
yygetlinenum(classNode),
+
"inheriting from a sealed parent class");
}
else
{
- /* This is not a valid base class
specification */
- CCErrorOnLine(yygetfilename(baseNode),
yygetlinenum(baseNode),
- "invalid base
type");
+
ILClassSetParent(classInfo, baseList[base]);
}
}
-
- /* Test for interfaces, or find "System.Object" if no
parent yet */
- if(ILClass_IsInterface(classInfo))
+ parent =
baseList[base];
+ baseList[base]
= 0;
+ }
+ else
{
- if(parent)
+ /* First base
in the list is an interface */
+
if(!ILClass_IsInterface(classInfo))
{
- CCErrorOnLine(yygetfilename(classNode),
yygetlinenum(classNode),
- "interface
inherits from non-interface class");
- parent = 0;
+ /* We
have to add the System.Object parent */
+
AddObjectParent(info, classNode,
+
classInfo,
+
systemObjectName);
+ }
}
}
- else if(!parent)
+ else
{
- /* Use the builtin library's "System.Object" */
- ILClass *objectClass;
-
- objectClass =
ILType_ToClass(ILFindSystemType(info, "Object"));
- if(!objectClass)
+
if(!ILClass_IsInterface(underlying))
{
- ILNode *baseTypeNode;
-
- /* Compiling something else that
inherits "System.Object" */
- if(CSSemBaseType(systemObjectName,
info, &systemObjectName,
-
&baseTypeNode, &parent))
+ /*
+ * Non
interface class found later in the base list.
+ */
+
if(ILClass_IsInterface(classInfo))
{
- if(!parent)
+
if(!errorReported)
{
- parent =
NodeToProgramItem(baseTypeNode);
- }
+
CCErrorOnLine(yygetfilename(classNode),
+
yygetlinenum(classNode),
+
"interface inherits from non-interface classes");
+
errorReported = 1;
}
}
else
{
- parent = ILToProgramItem(objectClass);
- }
if(!parent)
{
- CCErrorOnLine(yygetfilename(classNode),
yygetlinenum(classNode),
- "could not
resolve System.Object");
+
CCErrorOnLine(yygetfilename(classNode),
+
yygetlinenum(classNode),
+
"base class must be the first class in the base list");
+
parent = baseList[base];
}
else
{
- if(!ILProgramItemToTypeSpec(parent) &&
- ((objectClass =
ILProgramItemToClass(parent)) != 0))
- {
- if(ILClassResolve(objectClass)
== ILClassResolve(classInfo))
+
if(!errorReported)
{
- /* Compiling
System.Object so don't set the parent. */
- parent = 0;
- }
+
CCErrorOnLine(yygetfilename(classNode),
+
yygetlinenum(classNode),
+
"class inherits from two or more non-interface classes");
+
errorReported = 1;
}
}
}
- else
- {
- /* Output an error if attempting to inherit
from a sealed class */
- ILClass *underlying =
ILProgramItemToUnderlyingClass(parent);
- if(underlying)
- {
- underlying = ILClassResolve(underlying);
+ baseList[base]
= 0;
}
- if(!underlying)
- {
- CCOutOfMemory();
}
- if(underlying && ILClass_IsSealed(underlying))
- {
- CCErrorOnLine(yygetfilename(classNode),
yygetlinenum(classNode),
- "inheriting
from a sealed parent class");
}
}
-
- /* Set the calass parent */
- if(strcmp(ILClass_Name(classInfo), "<Module>") != 0)
- {
- if(parent && !ILClass_IsInterface(classInfo))
+ else
{
- ILClassSetParent(classInfo, parent);
+ /* This is not a valid base class
specification */
+ CCErrorOnLine(yygetfilename(baseNode),
yygetlinenum(baseNode),
+ "invalid base
type");
}
}
@@ -561,16 +611,13 @@
}
}
}
- else if(!ILClass_IsInterface(classInfo))
+ else
{
- ILClass *objectClass;
-
- /* Use the builtin library's "System.Object" as parent
class */
- objectClass = ILType_ToClass(ILFindSystemType(info,
"Object"));
-
- if(ILClassResolve(classInfo) !=
ILClassResolve(objectClass))
+ if(!ILClass_IsInterface(classInfo) &&
+ (strcmp(ILClass_Name(classInfo), "<Module>") != 0))
{
- ILClassSetParent(classInfo,
ILToProgramItem(objectClass));
+ /* We have to add the System.Object parent */
+ AddObjectParent(info, classNode, classInfo,
systemObjectName);
}
}
}
@@ -1091,7 +1138,29 @@
ILType
*signature,
int
kind)
{
- ILMember *member = 0;
+ ILMember *member;
+
+#if IL_VERSION_MAJOR > 1
+ if(ILClassNeedsExpansion(interface))
+ {
+ ILType *classType;
+ ILClass *instanceInfo;
+
+ classType = ILClass_SynType(interface);
+ instanceInfo =
ILClassInstantiate(ILProgramItem_Image(interface),
+
classType, classType, 0);
+ if(!instanceInfo)
+ {
+ return 0;
+ }
+ else
+ {
+ interface = instanceInfo;
+ }
+ }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+ member = 0;
while((member = ILClassNextMemberMatch
(interface, member, kind, name, 0)) != 0)
{
Index: cscc/csharp/cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -b -r1.87 -r1.88
--- cscc/csharp/cs_grammar.y 6 Dec 2008 19:13:37 -0000 1.87
+++ cscc/csharp/cs_grammar.y 15 Feb 2009 15:00:57 -0000 1.88
@@ -3536,7 +3536,25 @@
TypeList
: Type { $$ = $1; }
- | TypeList ',' Type { MakeBinary(ArgList, $1, $3); }
+ | TypeList ',' Type {
+ if(yykind($1) == yykindof(ILNode_ArgList))
+ {
+ /* Make sure the declaration order is
preserved */
+ ILNode_ArgList *argList;
+
+ argList = (ILNode_ArgList *)$1;
+ while(yykind(argList->expr1) ==
yykindof(ILNode_ArgList))
+ {
+ argList = (ILNode_ArgList
*)(argList->expr1);
+ }
+ argList->expr1 =
ILNode_ArgList_create($3, argList->expr1);
+ $$ = $1;
+ }
+ else
+ {
+ $$ = ILNode_ArgList_create($3, $1);
+ }
+ }
;
ClassBody
Index: cscc/csharp/cs_invoke.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_invoke.tc,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- cscc/csharp/cs_invoke.tc 18 Nov 2008 20:06:04 -0000 1.33
+++ cscc/csharp/cs_invoke.tc 15 Feb 2009 15:00:58 -0000 1.34
@@ -1939,7 +1939,10 @@
}
/* Get the type of the class that contains the method */
+ if((type = ILClassGetSynType(owner)) == 0)
+ {
type = (owner ? ILType_FromClass(owner) : 0);
+ }
/* add the "event" if it is an event */
if(kind == IL_META_MEMBERKIND_EVENT)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_cast.tc cscc/csha...,
Klaus Treichel <=