[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog codegen/cg_decls.tc codegen/cg_g...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog codegen/cg_decls.tc codegen/cg_g... |
Date: |
Thu, 20 Sep 2007 20:04:18 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 07/09/20 20:04:18
Modified files:
. : ChangeLog
codegen : cg_decls.tc cg_gen.h cg_nodemap.c cg_nodemap.h
cg_nodes.tc
cscc : cs_main.c
cscc/c : c_lvalue.tc
cscc/csharp : cs_decls.tc cs_defs.tc cs_gather.c cs_grammar.y
cs_internal.h cs_lookup.c cs_lvalue.tc
cs_types.tc Makefile.am
cscc/java : java_decls.tc java_gather.c java_grammar.y
cscc/vb : vb_grammar.y
csdoc : il2doc.c
dumpasm : dump_class.c dump_type.c dump_utils.c
include : il_dumpasm.h
image : class.c
Added files:
cscc/csharp : cs_lookup_member.c cs_lookup_member.h
Log message:
Add support for declaring generic types and methods.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3497&r2=1.3498
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_decls.tc?cvsroot=dotgnu-pnet&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_gen.h?cvsroot=dotgnu-pnet&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_nodemap.c?cvsroot=dotgnu-pnet&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_nodemap.h?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnet/codegen/cg_nodes.tc?cvsroot=dotgnu-pnet&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/cs_main.c?cvsroot=dotgnu-pnet&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/c/c_lvalue.tc?cvsroot=dotgnu-pnet&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_decls.tc?cvsroot=dotgnu-pnet&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_defs.tc?cvsroot=dotgnu-pnet&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_gather.c?cvsroot=dotgnu-pnet&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_grammar.y?cvsroot=dotgnu-pnet&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_internal.h?cvsroot=dotgnu-pnet&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lookup.c?cvsroot=dotgnu-pnet&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lvalue.tc?cvsroot=dotgnu-pnet&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_types.tc?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/Makefile.am?cvsroot=dotgnu-pnet&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lookup_member.c?cvsroot=dotgnu-pnet&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lookup_member.h?cvsroot=dotgnu-pnet&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/java/java_decls.tc?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/java/java_gather.c?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/java/java_grammar.y?cvsroot=dotgnu-pnet&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/vb/vb_grammar.y?cvsroot=dotgnu-pnet&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/pnet/csdoc/il2doc.c?cvsroot=dotgnu-pnet&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/pnet/dumpasm/dump_class.c?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnet/dumpasm/dump_type.c?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnet/dumpasm/dump_utils.c?cvsroot=dotgnu-pnet&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_dumpasm.h?cvsroot=dotgnu-pnet&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pnet/image/class.c?cvsroot=dotgnu-pnet&r1=1.39&r2=1.40
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3497
retrieving revision 1.3498
diff -u -b -r1.3497 -r1.3498
--- ChangeLog 14 Sep 2007 09:37:29 -0000 1.3497
+++ ChangeLog 20 Sep 2007 20:04:15 -0000 1.3498
@@ -1,57 +1,166 @@
+2007-09-20 Klaus Treichel <address@hidden>
+
+ * codegen/cg_decls.c: Use ILDasmDumpGenericParams to dump the generic
+ parameters instead of implementing it here too. Compile it conditional
+ if IL_VERSION_MAJOR > 1.
+
+ * codegen/cg_gen.h: Include the currentTypeFormals and
currentMethodFormals
+ only if IL_VERSION_MAJOR > 1.
+
+ * codegen/cg_nodemap.c: Access the typeFormals in the genInfo only if
+ IL_VERSION_MAJOR > 1.
+
+ * codegen/cg_nodemap.h: Include the currentTypeFormals and
+ currentMethodFormals in the ILGenItemContext only if IL_VERSION_MAJOR >
1.
+
+ * codegen/cg_nodes.tc: Add the ILNode_GenericTypeParameter and
+ ILNode_GenericTypeParameters node types. Add the typeFormals to the
+ ILNode_MethodDeclaration.
+
+ * cscc/cs_main.c: Initialize the memory pool for the member resolution
+ on start and destroy it on exit.
+
+ * cscc/c/c_lvalue.tc: Add dummy SemAnalysis for the new
+ ILNode_GenericTypeParameter and ILNode_GenericTypeParameters node types.
+
+ * cscc/csharp/cs_decls.tc: Save and restore the current formals only if
+ IL_VERSION_MAJOR > 1. Pass the new argument typeFormals as 0 to
+ ILNode_MethodDeclaration_create.
+
+ * cscc/csharp/cs_defs.tc: Add numArgs and rename actuals to
typeArguments
+ in the definition of ILNode_GenericReference. Add the new node type
+ ILNode_GenericConstraint.
+
+ * cscc/csharp/cs_gather.c: Add support for creating generic type
parameters
+ for classes and methods. Add the arity suffix for clscompliant generic
+ classes. Pass the methodTypeFormals if needed to
+ ILNode_MethodDeclaration_create. Handle renaming of overridden generic
type
+ parameters in nested parent classes.
+
+ * cscc/csharp/cs_grammar.y: Pass the new typeFormals argument to
+ ILMethodDeclaration_create. Redo the whole part of generic type
+ declaration to be ECMA 334 version 4 compliant.
+
+ * cscc/csharp/cs_internal.h: Include <il_profile.h> to check for
+ IL_VERSION_MAJOR. Include the new header file cs_lookup_member.h.
+ Add numActuals to the arguments of CSInsertGenericReference.
+
+ * cscc/csharp/cs_lookup.c: Move the member lookup to the new file
+ cs_lookop_member.c and include this file. Fix the resolution of generic
+ type parameters and generic method parameters.
+
+ * cscc/csharp/cs_lookup_member.c, cscc/csharp/cs_lookup_member.h: Add
+ those new files.
+
+ * cscc/csharp/cs_lvalue.tc: Add dummy SemAnalysis for the new node types
+ ILNode_GenericTypeParameter, ILNode_GenericTypeParameters and
+ ILNode_GenericConstraint.
+
+ * cscc/csharp/cs_types.c: Fix the handling of typeActuals so that they
+ compile now. A major change is needed here too.
+
+ cscc/csharp/Makefile.am: handle the new source files cs_lookup_member.c
+ and cs_lookup_member.h.
+
+ * cscc/java/java_decls.tc, cscc/java/java_gather.c,
+ cscc/java/java_grammar.y, cscc/vb/vb_grammar.y: Pass the new argument
+ typeFormals as 0 to ILNode_MethodDeclaration_create.
+
+ * csdoc/il2doc.c, dumpasm/dump_class.c, dumpasm/dump_type.c,
+ dumpasm/dump_utils.c, include/il_dumpasm.h: Rename
ILAsmDumpGenericParams
+ to ILDasmDumpGenericParams.
+
+ * image/class.c: Fix returning of 0 in ILClassNextMember.
+
2007-09-14 Heiko Weiss <address@hidden>
-* engine/jitc.c: enabling jit optimizing locals by default.
+
+ * engine/jitc.c: enabling jit optimizing locals by default.
2007-09-11 Ivan de Jesus Deras Tabora <address@hidden>
+
* engine/cvm.h: Define the new cvm opcode COP_PREFIX_CALL_VIRTGEN to
call a instance of a virtual generic method.
+
* engine/cvm_call.c Implementing the new opcode COP_PREFIX_CALL_VIRTGEN.
+
* engine/cvmc.c Added a new include il_program.h
- * engine/cvmc_call.c CVMCoder_CallVirtual now handle virtual generic
method instances.
- * engine/layout.c LayoutClass now handles classes that inherits or
implements generic
- classes or interfaces.
- * engine/lib_type.c NameOutputClassName now handles generic instance
classes.
+
+ * engine/cvmc_call.c CVMCoder_CallVirtual now handle virtual generic
+ method instances.
+
+ * engine/layout.c LayoutClass now handles classes that inherits or
+ implements generic classes or interfaces.
+
+ * engine/lib_type.c NameOutputClassName now handles generic instance
+ classes.
+
* engine/verify.c Handling of generic local variables in methods.
+
* engine/verify_call.c GetMethodToken handles generic method references.
+
* engine/verify_obj.c GetFieldToken now handles generic field
references.
+
* engine/verify_ptr.c GetClassToken now handles generic class
references.
+
* image/class.c Set the class name when creating a wrapper.
- * image/generic.c Split of the code into two different files:
generic_member.c for
- functions related to generic class members and generic_class.c for
functions related to
- generic classes.
- * image/generic_member.c New file for functions related to generic
member classes.
+
+ * image/generic.c Split of the code into two different files:
+ generic_member.c for functions related to generic class members and
+ generic_class.c for functions related to generic classes.
+
+ * image/generic_member.c New file for functions related to generic
+ member classes.
+
* image/generic_class.c New file for functions related to generic
classes.
+
* image/member.c ILMemberAccessible now handles generic members.
+
* image/meta_types.c ILGetEnumType now handles generic enum types.
- * image/program.h Added a new define for the initial size of the method
vtable.
- Added two new structures ILMethodVTableItem and ILMethodVTable to
support dynamic
- vtables for virtual generic methods.
+
+ * image/program.h Added a new define for the initial size of the method
+ vtable. Added two new structures ILMethodVTableItem and ILMethodVTable
+ to support dynamic vtables for virtual generic methods.
Added a new member to the ILMethod struct to support vtables in methods.
Added a new struct ILMethodInstance that represent a method instance.
+
* include/il_program.h Added a new typedef for ILMethodInstance.
ILClassInstantiate now receive the method type arguments as parameter.
- Added function prototypes for the following functions:
ILClassGetTypeArguments,
- ILClassGetGenericDef, ILClassExpand, ILClassIsExpanded,
ILClassResolveToInstance,
- ILClassLookupMethodInstance, ILMemberResolveToInstance,
ILMethodSpecToMethod,
+ Added function prototypes for the following functions:
+ ILClassGetTypeArguments, ILClassGetGenericDef, ILClassExpand,
+ ILClassIsExpanded, ILClassResolveToInstance,
ILClassLookupMethodInstance,
+ ILMemberResolveToInstance, ILMethodSpecToMethod,
ILMethodSetVirtualAncestor, ILMethodGetInstance, ILMethodAddInstance,
ILMethodGetClassTypeArguments, ILMethodGetMethodTypeArguments.
- Added the following macros ILMember_IsGenericInstance,
ILMethod_IsVirtualGeneric,
- ILClass_IsGenericInstance
- * image/Makefile.am added new source files generic_member.c and
generic_class.c
+ Added the following macros ILMember_IsGenericInstance,
+ ILMethod_IsVirtualGeneric, ILClass_IsGenericInstance
+
+ * image/Makefile.am added new source files generic_member.c and
+ generic_class.c
+
2007-09-11 Ivan de Jesus Deras Tabora <address@hidden>
+
* engine/cvm_stack.c Fixed CVM documentation for COP_PREFIX_REPL_WORD_N.
- * engine/verify_call.c Constrained callvirt for value types should be
handled as
- a normal call (non virtual).
- * engine/verify_obj.c Fixed INITOBJ CIL opcode to be ECMA compliant.
Now it can
- be applied to ref types.
- * engine/verify_ptr.c Fixed IL_OP_LDELEM for value types. Also added a
missing break
- when handling LDSFLDA.
- * image/generic.c _ILTypeToSyntheticInstantiation now receive an extra
parameters, the
- method type parameters.
- * image/image.h _ILTypeToSyntheticInstantiation now receive an extra
parameters, the
- method type parameters.
- * image/meta_types.c ILTypeToName now handle BYREF types and Method
Type Parameters.
- * image/synthetic.c _ILTypeToSyntheticInstantiation now receive an
extra parameters, the
- method type parameters.
+
+ * engine/verify_call.c Constrained callvirt for value types should be
+ handled as a normal call (non virtual).
+
+ * engine/verify_obj.c Fixed INITOBJ CIL opcode to be ECMA compliant.
+ Now it can be applied to ref types.
+
+ * engine/verify_ptr.c Fixed IL_OP_LDELEM for value types. Also added a
+ missing break when handling LDSFLDA.
+
+ * image/generic.c _ILTypeToSyntheticInstantiation now receive an extra
+ parameters, the method type parameters.
+
+ * image/image.h _ILTypeToSyntheticInstantiation now receive an extra
+ parameters, the method type parameters.
+
+ * image/meta_types.c ILTypeToName now handle BYREF types and Method Type
+ Parameters.
+
+ * image/synthetic.c _ILTypeToSyntheticInstantiation now receive an extra
+ parameters, the method type parameters.
2007-09-10 Klaus Treichel <address@hidden>
@@ -1986,7 +2095,7 @@
* engine/jitc.c, engine/jitc_call.c: Call internal fuctions now directly
for normal calls and ctors.
-2006-03-19 Rainer Gr��linger <address@hidden>
+2006-03-19 Rainer GröÃlinger <address@hidden>
* libgc/Makefile.am, libgc/Makefile.direct, libgc/Makefile.in,
libgc/allchblk.c, libgc/alloc.c, libgc/configure, libgc/configure.in,
@@ -2957,12 +3066,12 @@
* csant/csant_dir.c: Prevent prepending of pathname if filename starts
with
a drive specification on windows in CSAntDirCombine.
-2005-08-03 Rainer Gr��linger <address@hidden>
+2005-08-03 Rainer GröÃlinger <address@hidden>
* libffi/include/Makefile.am, libffi/include/Makefile.in: ffitarget.h is
installed in $(includedir)/pnet now. (applied by Klaus Treichel)
-2005-08-02 Rainer Gr��linger <address@hidden>
+2005-08-02 Rainer GröÃlinger <address@hidden>
* doc/cvmdoc.py: replace module regex by re. (applied by Klaus Treichel)
@@ -2970,7 +3079,7 @@
* ilalink/link_main.c: Add missing newline to error message.
-2005-08-01 Rainer Gr��linger <address@hidden>
+2005-08-01 Rainer GröÃlinger <address@hidden>
* doc/pnetasm.texi: remove incorrect @. (applied by Klaus Treichel)
Index: codegen/cg_decls.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_decls.tc,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- codegen/cg_decls.tc 5 May 2007 15:56:41 -0000 1.57
+++ codegen/cg_decls.tc 20 Sep 2007 20:04:15 -0000 1.58
@@ -22,6 +22,7 @@
*/
#include <codegen/cg_nodes.h>
+#include <il_profile.h>
#include "il_dumpasm.h"
/*
@@ -168,26 +169,12 @@
ILDumpIdentifier(info->asmOutput, ILClass_Name(classInfo), 0,
IL_DUMP_QUOTE_NAMES);
+ #if IL_VERSION_MAJOR > 1
/* Output the generic parameters, if any */
- if(ILGenericParGetNumParams(ILToProgramItem(classInfo)) > 0)
- {
- ILUInt32 number = 0;
- ILGenericPar *genPar;
- putc('<', info->asmOutput);
- while((genPar = ILGenericParGetFromOwner
- (ILToProgramItem(classInfo), number))
!= 0)
- {
- if(number > 0)
- {
- fputs(", ", info->asmOutput);
- }
- /* TODO: generic type constraints */
- ILDumpIdentifier(info->asmOutput,
ILGenericPar_Name(genPar),
- 0,
IL_DUMP_QUOTE_NAMES);
- ++number;
- }
- putc('>', info->asmOutput);
- }
+ ILDAsmDumpGenericParams(info->image, info->asmOutput,
+
ILToProgramItem(classInfo),
+
IL_DUMP_QUOTE_NAMES);
+ #endif /* IL_VERSION_MAJOR > 1 */
/* Output the name of the parent class */
if(ILClass_ParentRef(classInfo) != 0)
@@ -799,7 +786,11 @@
}
ILDumpMethodType(outstream, info->image,
ILMethod_Signature(method),
+#if IL_VERSION_MAJOR > 1
+ IL_DUMP_QUOTE_NAMES |
IL_DUMP_GENERIC_PARAMS, 0,
+#else /* IL_VERSION_MAJOR == 1 */
IL_DUMP_QUOTE_NAMES, 0,
+#endif /* IL_VERSION_MAJOR == 1 */
ILMethod_Name(method), method);
putc(' ', outstream);
ILDumpFlags(outstream, ILMethod_ImplAttrs(method),
Index: codegen/cg_gen.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_gen.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- codegen/cg_gen.h 24 May 2007 13:51:14 -0000 1.48
+++ codegen/cg_gen.h 20 Sep 2007 20:04:15 -0000 1.49
@@ -21,6 +21,8 @@
#ifndef _CODEGEN_CG_GEN_H
#define _CODEGEN_CG_GEN_H
+#include "il_profile.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -146,8 +148,10 @@
ILArrayInit *arrayInit; /* Array initialization
information */
ILHashTable *itemHash; /* Hash program items
to nodes */
ILVarUsageTable *varUsage; /* Variable usage table
*/
+#if IL_VERSION_MAJOR > 1
ILNode *currentTypeFormals; /* Current generic type formals
*/
ILNode *currentMethodFormals; /* Current generic method
formals */
+#endif /* IL_VERSION_MAJOR > 1 */
ILLabel gotoPtrLabel; /* Label for "goto *"
operations */
};
Index: codegen/cg_nodemap.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_nodemap.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- codegen/cg_nodemap.c 5 Jul 2003 05:03:58 -0000 1.5
+++ codegen/cg_nodemap.c 20 Sep 2007 20:04:15 -0000 1.6
@@ -192,8 +192,10 @@
context->currentScope = info->currentScope;
context->currentClass = info->currentClass;
context->currentNamespace = info->currentNamespace;
+#if IL_VERSION_MAJOR > 1
context->currentTypeFormals = info->currentTypeFormals;
context->currentMethodFormals = info->currentMethodFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
context->overflowInsns = info->overflowInsns;
context->overflowChanged = info->overflowChanged;
@@ -238,14 +240,18 @@
{
info->currentScope = globalScope;
}
+ #if IL_VERSION_MAJOR > 1
info->currentTypeFormals = classNode->typeFormals;
info->currentMethodFormals = 0;
+ #endif /* IL_VERSION_MAJOR > 1 */
}
else
{
info->currentScope = globalScope;
+ #if IL_VERSION_MAJOR > 1
info->currentTypeFormals = 0;
info->currentMethodFormals = 0;
+ #endif /* IL_VERSION_MAJOR > 1 */
}
info->overflowInsns = info->overflowGlobal;
info->overflowChanged = 0;
@@ -259,8 +265,10 @@
info->currentScope = context->currentScope;
info->currentClass = context->currentClass;
info->currentNamespace = context->currentNamespace;
+#if IL_VERSION_MAJOR > 1
info->currentTypeFormals = context->currentTypeFormals;
info->currentMethodFormals = context->currentMethodFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
info->overflowInsns = context->overflowInsns;
info->overflowChanged = context->overflowChanged;
}
Index: codegen/cg_nodemap.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_nodemap.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- codegen/cg_nodemap.h 5 Jul 2003 05:03:58 -0000 1.4
+++ codegen/cg_nodemap.h 20 Sep 2007 20:04:15 -0000 1.5
@@ -33,8 +33,10 @@
ILScope *currentScope;
ILNode *currentClass;
ILNode *currentNamespace;
+#if IL_VERSION_MAJOR > 1
ILNode *currentTypeFormals;
ILNode *currentMethodFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
int overflowInsns;
int overflowChanged;
Index: codegen/cg_nodes.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_nodes.tc,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- codegen/cg_nodes.tc 24 May 2007 13:51:14 -0000 1.88
+++ codegen/cg_nodes.tc 20 Sep 2007 20:04:15 -0000 1.89
@@ -600,6 +600,18 @@
int baseAccess;
%nocreate long saveStack = {0};
}
+%node ILNode_GenericTypeParameter ILNode_Dummy =
+{
+ ILUInt32 num;
+ const char *name;
+ ILUInt32 constraint;
+ ILNode_List *typeConstraints;
+}
+%node ILNode_GenericTypeParameters ILNode_Dummy =
+{
+ ILUInt32 numTypeParams;
+ ILNode_List *typeParams;
+}
%output "cg_ainit.c"
@@ -877,6 +889,7 @@
ILUInt32 modifiers;
ILNode *type;
ILNode *name;
+ ILNode *typeFormals;
ILNode *params;
ILNode *body;
%nocreate ILMethod *methodInfo = {0};
Index: cscc/cs_main.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/cs_main.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- cscc/cs_main.c 1 Jun 2007 11:08:51 -0000 1.24
+++ cscc/cs_main.c 20 Sep 2007 20:04:16 -0000 1.25
@@ -87,12 +87,13 @@
{
CSNoHideBySig = 0;
}
+ CSMemberInfoInit();
return 1;
}
void CCPluginShutdown(int status)
{
- /* Nothing to do here */
+ CSMemberInfoDestroy();
}
int CCPluginParse(void)
Index: cscc/c/c_lvalue.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/c/c_lvalue.tc,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- cscc/c/c_lvalue.tc 21 Jun 2004 15:21:15 -0000 1.24
+++ cscc/c/c_lvalue.tc 20 Sep 2007 20:04:16 -0000 1.25
@@ -28,6 +28,16 @@
return CSemValueError;
}
+/*
+ * Perform semantic analysis for generic parameters.
+ */
+ILNode_CSemAnalysis(ILNode_GenericTypeParameter),
+ILNode_CSemAnalysis(ILNode_GenericTypeParameters)
+{
+ /* This is not used in C */
+ return CSemValueError;
+}
+
%{
/*
Index: cscc/csharp/cs_decls.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_decls.tc,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- cscc/csharp/cs_decls.tc 5 May 2007 15:56:41 -0000 1.42
+++ cscc/csharp/cs_decls.tc 20 Sep 2007 20:04:16 -0000 1.43
@@ -114,7 +114,9 @@
ILNode *savedNamespace;
ILNode *savedMethod;
ILNode *staticCtorList=NULL;
+#if IL_VERSION_MAJOR > 1
ILNode *savedTypeFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
ILNode_ListIter iter;
ILNode *staticCtor;
int hadStaticCtorsBefore;
@@ -184,11 +186,15 @@
savedClass = info->currentClass;
savedNamespace = info->currentNamespace;
savedMethod = info->currentMethod;
+ #if IL_VERSION_MAJOR > 1
savedTypeFormals = info->currentTypeFormals;
+ #endif /* IL_VERSION_MAJOR > 1 */
info->currentClass = (ILNode *)node;
info->currentNamespace = node->namespaceNode;
info->currentMethod = NULL;
+ #if IL_VERSION_MAJOR > 1
info->currentTypeFormals = node->typeFormals;
+ #endif /* IL_VERSION_MAJOR > 1 */
value = ILNode_SemAnalysis(node->body, info, &(node->body));
if(node->initCtorsMethod)
{
@@ -248,6 +254,7 @@
IL_META_METHODDEF_RT_SPECIAL_NAME,
0 /* void */,
ILQualIdentSimple(ILInternString(".cctor", 6).string),
+ 0 /* no type formals */,
0 /* no parameters */,
ILNode_NewScope_create(node->staticCtors));
methodInfo = ILMethodCreate(node->classInfo, 0,
".cctor",
@@ -274,7 +281,9 @@
info->currentClass = savedClass;
info->currentNamespace = savedNamespace;
info->currentMethod = savedMethod;
+ #if IL_VERSION_MAJOR > 1
info->currentTypeFormals = savedTypeFormals;
+ #endif /* IL_VERSION_MAJOR > 1 */
}
else
{
@@ -632,6 +641,7 @@
IL_META_METHODDEF_HIDE_BY_SIG,
0 /* void */,
ILQualIdentSimple(ILInternString(".init", 5).string),
+ 0 /* no type formals */,
0 /* no parameters */,
ILNode_NewScope_create(bodyList));
methodInfo = ILMethodCreate(defn->classInfo, 0, ".init",
Index: cscc/csharp/cs_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_defs.tc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- cscc/csharp/cs_defs.tc 24 May 2007 13:51:15 -0000 1.17
+++ cscc/csharp/cs_defs.tc 20 Sep 2007 20:04:16 -0000 1.18
@@ -95,7 +95,14 @@
%node ILNode_GenericReference ILNode_Dummy =
{
ILNode *type;
- ILNode *actuals;
+ ILUInt32 numArgs;
+ ILNode *typeArguments;
+}
+%node ILNode_GenericConstraint ILNode_Dummy =
+{
+ const char *name;
+ ILUInt32 constraint;
+ ILNode_List *typeConstraints;
}
/*
Index: cscc/csharp/cs_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_gather.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- cscc/csharp/cs_gather.c 5 May 2007 15:56:41 -0000 1.53
+++ cscc/csharp/cs_gather.c 20 Sep 2007 20:04:16 -0000 1.54
@@ -118,6 +118,238 @@
return result;
}
+#if IL_VERSION_MAJOR > 1
+/*
+ * Add the generic type contraints to the generic type parameter.
+ */
+static void AddGenericConstraints(ILGenInfo *info,
+ ILGenericPar
*genPar,
+ ILNode_List
*constraints)
+{
+ if(constraints)
+ {
+ ILUInt32 first = 1;
+ ILNode_ListIter iter;
+ ILNode *constraint;
+
+ ILNode_ListIter_Init(&iter, (ILNode *)constraints);
+ while((constraint = ILNode_ListIter_Next(&iter)) != 0)
+ {
+ ILType *constraintType;
+
+ constraintType = CSSemType(constraint, info,
&constraint);
+ if(constraintType)
+ {
+ ILClass *constraintClass =
ILType_ToClass(constraintType);
+
+ if(first)
+ {
+
if(!ILClass_IsInterface(constraintClass))
+ {
+ if(ILGenericParGetFlags(genPar)
& (IL_META_GENPARAM_CLASS_CONST |
+
IL_META_GENPARAM_VALUETYPE_CONST))
+ {
+
CCErrorOnLine(yygetfilename(constraint), yygetlinenum(constraint),
+
"either class or valuetype or a non interface class can be supplied");
+ }
+ }
+ first = 0;
+ }
+ else
+ {
+
if(!ILClass_IsInterface(constraintClass))
+ {
+
CCErrorOnLine(yygetfilename(constraint), yygetlinenum(constraint),
+ "only
one non interface class can be supplied");
+ }
+ }
+
+ constraintClass = ILClassImport(info->image,
constraintClass);
+
+ if(!ILGenericParAddConstraint(genPar, 0,
+
ILToProgramItem(constraintClass)))
+ {
+ CCOutOfMemory();
+ }
+ }
+ }
+ }
+}
+
+/*
+ * Add the given generic parameters to the program item.
+ */
+static void AddTypeFormals(ILGenInfo *info,
+ ILProgramItem *owner,
+ ILNode *typeFormals)
+{
+ if(owner && typeFormals)
+ {
+ ILNode_ListIter iter;
+ ILNode_GenericTypeParameter *genParam;
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams = (ILNode_GenericTypeParameters *)typeFormals;
+ ILNode_ListIter_Init(&iter, genParams->typeParams);
+ while((genParam =
+ (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
+ {
+ ILGenericPar *genPar = ILGenericParCreate(info->image,
0,
+
owner, genParam->num);
+ if(!genPar)
+ {
+ CCOutOfMemory();
+ }
+ if(!ILGenericParSetName(genPar, genParam->name))
+ {
+ CCOutOfMemory();
+ }
+ ILGenericParSetFlags(genPar, IL_MAX_UINT32,
genParam->constraint);
+ AddGenericConstraints(info, genPar,
genParam->typeConstraints);
+ }
+ }
+}
+
+static void _AddTypeFormalWithCheck(ILGenInfo *info,
+
ILProgramItem *owner,
+
ILNode_GenericTypeParameter *genParam,
+
ILUInt32 offset,
+
ILUInt32 *overridden)
+{
+ ILUInt32 current;
+ ILGenericPar *genPar;
+
+ genPar = ILGenericParCreate(info->image, 0, owner, genParam->num +
offset);
+ if(!genPar)
+ {
+ CCOutOfMemory();
+ }
+ if(!ILGenericParSetName(genPar, genParam->name))
+ {
+ CCOutOfMemory();
+ }
+ ILGenericParSetFlags(genPar, IL_MAX_UINT32, genParam->constraint);
+
+ /* Check for duplicate names */
+ for(current = 0; current < offset; current++)
+ {
+ ILGenericPar *genParCheck = ILGenericParGetFromOwner(owner,
current);
+
+ if(genParCheck)
+ {
+ if(!strcmp(ILGenericParGetName(genParCheck),
genParam->name))
+ {
+ char buffer[31];
+
+ sprintf(buffer, "<_P%i>", *overridden);
+ if(!ILGenericParSetName(genParCheck, buffer))
+ {
+ CCOutOfMemory();
+ }
+ (*overridden)++;
+ }
+ }
+ }
+ AddGenericConstraints(info, genPar, genParam->typeConstraints);
+}
+
+static void _AddTypeFormalsToClassInner(ILGenInfo *info,
+
ILNode_ClassDefn *defn,
+
ILProgramItem *owner,
+
ILUInt32 *offset,
+
ILUInt32 *overridden)
+{
+ if(defn->nestedParent)
+ {
+ /* Add the deneric parameters of the nested parents first. */
+ _AddTypeFormalsToClassInner(info, defn->nestedParent,
+ owner,
offset, overridden);
+ }
+ if(defn->typeFormals)
+ {
+ ILNode_ListIter iter;
+ ILNode_GenericTypeParameter *genParam;
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams = (ILNode_GenericTypeParameters *)(defn->typeFormals);
+ ILNode_ListIter_Init(&iter, genParams->typeParams);
+ while((genParam =
+ (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
+ {
+ _AddTypeFormalWithCheck(info, owner, genParam,
+
*offset, overridden);
+ }
+ *offset += genParams->numTypeParams;
+ }
+}
+
+/*
+ * Add the generic parameters to a class.
+ * Handle the generic parameters consistent with the ECMA specs.
+ */
+static void AddTypeFormalsToClass(ILGenInfo *info,
+
ILNode_ClassDefn *defn)
+{
+ ILUInt32 overridden = 0;
+ ILUInt32 offset = 0;
+
+ if(defn->nestedParent)
+ {
+ _AddTypeFormalsToClassInner(info, defn->nestedParent,
+
ILToProgramItem(defn->classInfo),
+
&offset, &overridden);
+ }
+ if(defn->typeFormals)
+ {
+ ILNode_ListIter iter;
+ ILNode_GenericTypeParameter *genParam;
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams = (ILNode_GenericTypeParameters *)(defn->typeFormals);
+ ILNode_ListIter_Init(&iter, genParams->typeParams);
+ while((genParam =
+ (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
+ {
+ _AddTypeFormalWithCheck(info,
ILToProgramItem(defn->classInfo),
+
genParam, offset, &overridden);
+
+ /* Adjust the generic parameter number */
+ genParam->num += offset;
+ }
+ }
+}
+
+static void AddGenericParametersToClass(ILGenInfo *info, ILNode *classDefn)
+{
+ if(yyisa(classDefn, ILNode_ClassDefn))
+ {
+ ILNode *savedNamespace;
+ ILNode *savedClass;
+ ILNode_ClassDefn *defn = (ILNode_ClassDefn *)classDefn;
+
+ if(!(defn->classInfo) ||
+ (defn->classInfo == (ILClass *)1) ||
+ (defn->classInfo == (ILClass *)2))
+ {
+ return;
+ }
+
+ /* Set the namespace and class to use for resolving type names
*/
+ savedNamespace = info->currentNamespace;
+ info->currentNamespace = defn->namespaceNode;
+ savedClass = info->currentClass;
+ info->currentClass = classDefn;
+
+ /* Add the generic type parameters to the class */
+ AddTypeFormalsToClass(info, defn);
+
+ /* Restore the previous values. */
+ info->currentClass = savedClass;
+ info->currentNamespace = savedNamespace;
+ }
+}
+#endif /* IL_VERSION_MAJOR > 1 */
+
/*
* Create the program structure for a type and all of its base types.
* Returns the new end of the top-level type list.
@@ -140,12 +372,12 @@
ILNode_ClassDefn *defn;
ILNode *savedNamespace;
ILNode *savedClass;
+#if IL_VERSION_MAJOR > 1
ILNode *savedTypeFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
ILProgramItem *nestedScope;
ILNode *node;
ILNode_ListIter iter;
- ILUInt32 formalNum;
- ILGenericPar *genPar;
ILClass *underlying;
/* Get the name and namespace for the type, for error reporting */
@@ -204,8 +436,10 @@
info->currentNamespace = defn->namespaceNode;
savedClass = info->currentClass;
info->currentClass = (ILNode *)(defn->nestedParent);
+#if IL_VERSION_MAJOR > 1
savedTypeFormals = info->currentTypeFormals;
info->currentTypeFormals = defn->typeFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
/* Create all of the base classes */
numBases = CountBaseClasses(defn->baseClass);
@@ -335,7 +569,9 @@
/* Restore the namespace, class, and type formals */
info->currentNamespace = savedNamespace;
info->currentClass = savedClass;
+#if IL_VERSION_MAJOR > 1
info->currentTypeFormals = savedTypeFormals;
+#endif /* IL_VERSION_MAJOR > 1 */
/* Output an error if attempting to inherit from a sealed class */
if(parent)
@@ -385,24 +621,6 @@
}
}
- /* Add the type formals to the class definition */
- ILNode_ListIter_Init(&iter, defn->typeFormals);
- formalNum = 0;
- while((node = ILNode_ListIter_Next(&iter)) != 0)
- {
- genPar = ILGenericParCreate
- (info->image, 0, ILToProgramItem(classInfo), formalNum);
- if(!genPar)
- {
- CCOutOfMemory();
- }
- if(!ILGenericParSetName(genPar, ILQualIdentName(node, 0)))
- {
- CCOutOfMemory();
- }
- ++formalNum;
- }
-
/* Clean up */
if(baseList)
{
@@ -955,6 +1173,14 @@
ILClass *interface;
ILMember *interfaceMember;
ILClass *class1, *class2;
+#if IL_VERSION_MAJOR > 1
+ ILNode *savedMethod;
+
+ /* Save the current method context. */
+ savedMethod = info->currentMethod;
+ /* and set the method context for generic type parameter resolution */
+ info->currentMethod = (ILNode *)method;
+#endif /* IL_VERSION_MAJOR > 1 */
/* Get the name of the method, and the interface member (if any) */
interface = 0;
@@ -1155,6 +1381,25 @@
ILMethodSetCallConv(methodInfo, ILType_CallConv(signature));
}
+#if IL_VERSION_MAJOR > 1
+ /* Set the number of generic parameters in the method signature */
+ /* and mark the method as "generic" if generic type parameters are */
+ /* present */
+ if(method->typeFormals)
+ {
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams = (ILNode_GenericTypeParameters
*)(method->typeFormals);
+ ILTypeSetCallConv(signature, ILType_CallConv(signature) |
+
IL_META_CALLCONV_GENERIC);
+ ILType_SetNumGen(signature, genParams->numTypeParams);
+ ILMethodSetCallConv(methodInfo, ILType_CallConv(signature));
+
+ AddTypeFormals(info, ILToProgramItem(methodInfo),
+ method->typeFormals);
+ }
+#endif /* IL_VERSION_MAJOR > 1 */
+
/* Set the signature for the method */
ILMemberSetSignature((ILMember *)methodInfo, signature);
@@ -1315,6 +1560,10 @@
ReportUnnecessaryNew(method->name, name);
}
}
+#if IL_VERSION_MAJOR > 1
+ /* Restore the previous method context */
+ info->currentMethod = savedMethod;
+#endif /* IL_VERSION_MAJOR > 1 */
}
/*
@@ -2098,7 +2347,7 @@
IL_META_METHODDEF_HIDE_BY_SIG,
member->returnType,
ILQualIdentSimple(ILInternString("Invoke", -1).string),
- member->params, 0);
+ 0, member->params, 0);
yysetfilename((ILNode*)decl,yygetfilename(member));
yysetlinenum((ILNode*)decl, yygetlinenum(member));
@@ -2131,6 +2380,7 @@
IL_META_METHODDEF_COMPILER_CONTROLLED,
ILNode_SystemType_create("IAsyncResult"),
ILQualIdentSimple(ILInternString("BeginInvoke",
-1).string),
+ 0,
(ILNode*)params,
0);
@@ -2164,6 +2414,7 @@
IL_META_METHODDEF_COMPILER_CONTROLLED,
member->returnType,
ILQualIdentSimple(ILInternString("EndInvoke",
-1).string),
+ 0,
(ILNode*)params,
0);
@@ -2436,6 +2687,24 @@
aliasScope=((ILNode_Namespace*)(defn->namespaceNode))->localScope;
+ #if IL_VERSION_MAJOR > 1
+ if(defn->typeFormals)
+ {
+ /* Adjust the type name to be CLSCompliant. */
+ ILUInt32 numTypeParams;
+
+ numTypeParams = ((ILNode_GenericTypeParameters
*)(defn->typeFormals))->numTypeParams;
+ if(numTypeParams > 0)
+ {
+ char buffer[261];
+
+ sprintf(buffer, "%s`%i", name,
numTypeParams);
+ name = ILInternString(buffer,
-1).string;
+ defn->name = name;
+ }
+ }
+ #endif /* IL_VERSION_MAJOR > 1 */
+
error = ILScopeDeclareType(parentScope, child,
name, namespace, &scope,
&origDefn,aliasScope);
@@ -2539,6 +2808,34 @@
CreateType(info, globalScope, list, systemObject, child);
}
+#if IL_VERSION_MAJOR > 1
+ /* Add the generic type parameters to each class */
+ ILNode_ListIter_Init(&iterator, list);
+ while((child = ILNode_ListIter_Next(&iterator)) != 0)
+ {
+ if(yykind(child) == yykindof(ILNode_ClassDefn))
+ {
+ AddGenericParametersToClass(info, child);
+
+ /* process the nested classes */
+ if(((ILNode_ClassDefn*)child)->nestedClasses)
+ {
+ ILNode_ListIter iterator2;
+
+ ILNode_ListIter_Init(&iterator2,
+
((ILNode_ClassDefn*)child)->nestedClasses);
+ while((child =
ILNode_ListIter_Next(&iterator2)) != 0)
+ {
+ if(yykind(child) ==
yykindof(ILNode_ClassDefn))
+ {
+
AddGenericParametersToClass(info, child);
+ }
+ }
+ }
+ }
+ }
+#endif /* IL_VERSION_MAJOR > 1 */
+
/* Create the class members within each type */
ILNode_ListIter_Init(&iterator, list);
while((child = ILNode_ListIter_Next(&iterator)) != 0)
Index: cscc/csharp/cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- cscc/csharp/cs_grammar.y 24 May 2007 13:51:15 -0000 1.79
+++ cscc/csharp/cs_grammar.y 20 Sep 2007 20:04:16 -0000 1.80
@@ -290,6 +290,7 @@
return classNameCtorDefined[classNameStackSize - 1];
}
+#if IL_VERSION_MAJOR > 1
/*
* Get the modifiers of the current class.
*/
@@ -297,6 +298,7 @@
{
return classNameModifiers[classNameStackSize - 1];
}
+#endif /* IL_VERSION_MAJOR > 1 */
/*
* Determine if an identifier is identical to
@@ -475,7 +477,7 @@
decl = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
(0, property->modifiers,
property->type,
- name, property->params, 0);
+ name, 0, property->params, 0);
property->getAccessor = (ILNode *)decl;
}
else
@@ -507,7 +509,7 @@
/* Abstract interface definition */
decl = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
- (0, property->modifiers, 0,
name, params, 0);
+ (0, property->modifiers, 0,
name, 0, params, 0);
property->setAccessor = (ILNode *)decl;
}
else
@@ -554,7 +556,7 @@
/* Field-based event that needs a pre-defined body */
method = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
- (0, event->modifiers, 0, name,
addParams, 0);
+ (0, event->modifiers, 0, name, 0,
addParams, 0);
method->body = ILNode_NewScope_create
(ILNode_AssignAdd_create
(ILNode_Add_create(eventName,
@@ -567,7 +569,7 @@
/* Abstract interface definition */
method = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
- (0, event->modifiers, 0, name,
addParams, 0);
+ (0, event->modifiers, 0, name, 0,
addParams, 0);
decl->addAccessor = (ILNode *)method;
}
else
@@ -588,7 +590,7 @@
/* Field-based event that needs a pre-defined body */
method = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
- (0, event->modifiers, 0, name,
removeParams, 0);
+ (0, event->modifiers, 0, name, 0,
removeParams, 0);
method->body = ILNode_NewScope_create
(ILNode_AssignSub_create
(ILNode_Sub_create(eventName,
@@ -601,7 +603,7 @@
/* Abstract interface definition */
method = (ILNode_MethodDeclaration *)
ILNode_MethodDeclaration_create
- (0, event->modifiers, 0, name,
removeParams, 0);
+ (0, event->modifiers, 0, name, 0,
removeParams, 0);
decl->removeAccessor = (ILNode *)method;
}
else
@@ -647,6 +649,97 @@
}
}
+#if IL_VERSION_MAJOR > 1
+/*
+ * Check if the generic constraints have a matching generic type
+ * and move the constraint data to that type.
+ */
+static void MergeGenericConstraints(ILNode_GenericTypeParameters
*genericTypeParameters,
+
ILNode_List *constraints)
+{
+ ILNode_ListIter iter;
+ ILNode_GenericConstraint *constraint;
+ ILNode_GenericTypeParameter *parameter;
+
+ ILNode_ListIter_Init(&iter, constraints);
+ while((constraint = (ILNode_GenericConstraint
*)ILNode_ListIter_Next(&iter)) != 0)
+ {
+ ILNode_ListIter iter2;
+
+ ILNode_ListIter_Init(&iter2, genericTypeParameters->typeParams);
+ while((parameter = (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter2)) != 0)
+ {
+ if(!strcmp(constraint->name, parameter->name))
+ {
+ parameter->constraint = constraint->constraint;
+ parameter->typeConstraints =
constraint->typeConstraints;
+ break;
+ }
+ }
+ if(!parameter)
+ {
+ /* If we get here a parameter with the name in the
constraint could not be found. */
+ CCErrorOnLine(yygetfilename(constraint),
yygetlinenum(constraint),
+ "`%s' is no generic
parameter",
+ constraint->name);
+ }
+ }
+}
+
+/*
+ * Convert type arguments to type parameters and check if each argument is an
identifier.
+ */
+static ILNode_GenericTypeParameters *TypeActualsToTypeFormals(ILNode
*typeArguments)
+{
+
+ ILNode_ListIter iter;
+ ILNode *node;
+ ILNode* list = 0;
+ ILUInt32 count = 0;
+
+ ILNode_ListIter_Init(&iter, typeArguments);
+ while((node = ILNode_ListIter_Next(&iter)) != 0)
+ {
+ if(yyisa(node, ILNode_Identifier))
+ {
+ /* Check for duplicates in the list */
+ const char *name = ILQualIdentName(node, 0);
+ ILNode_ListIter iter2;
+ ILNode_GenericTypeParameter *genParam;
+
+ ILNode_ListIter_Init(&iter2, list);
+ while((genParam = (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter2)) != 0)
+ {
+ if(!strcmp(genParam->name, name))
+ {
+ CCErrorOnLine(yygetfilename(node),
yygetlinenum(node),
+ "`%s'
declared multiple times in generic parameters",
+ name);
+ break;
+ }
+ }
+
+ /* Add the generic parameter to the list */
+ list = MakeList(list,
+ (ILNode
*)ILNode_GenericTypeParameter_create(count,
+
name,
+
0, 0));
+ count++;
+ }
+ else
+ {
+ CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
+ "expected an identifier and
not a type");
+ }
+ }
+ if(count > 0)
+ {
+ return (ILNode_GenericTypeParameters
*)ILNode_GenericTypeParameters_create(count, (ILNode_List *)list);
+ }
+ return 0;
+}
+#endif /* IL_VERSION_MAJOR > 1 */
+
%}
/*
@@ -715,6 +808,36 @@
} target;
int partial;
+ ILNode_List *nodeList;
+ struct
+ {
+ ILUInt32 count;
+ ILNode_List *list;
+ } countList;
+ ILNode_GenericTypeParameters *genericTypeParameters;
+ struct
+ {
+ ILUInt32 constraint;
+ ILNode_List *typeConstraints;
+ } constraint;
+ struct
+ {
+ ILNode *attributes;
+ ILUInt32 modifiers;
+ ILUInt32 partial;
+ ILNode *identifier;
+ ILNode *classBase;
+ ILNode_GenericTypeParameters *typeFormals;
+ } classHeader;
+ struct
+ {
+ ILNode *attributes;
+ ILUInt32 modifiers;
+ ILNode *type;
+ ILNode *identifier;
+ ILNode_List *args;
+ ILNode_GenericTypeParameters *typeFormals;
+ } memberHeader;
}
/*
@@ -966,12 +1089,21 @@
%type <node> RankSpecifiers RankSpecifierList
%type <node> OptArrayInitializer ArrayInitializer
%type <node> OptVariableInitializerList VariableInitializerList
-%type <node> TypeActuals TypeFormals TypeFormalList
+%type <countList> TypeActuals
+%type <genericTypeParameters> TypeFormals
+%type <countList> TypeFormalList
+%type <mask> PrimaryConstraint ConstructorConstraint
+%type <nodeList> SecondaryConstraints
+%type <constraint> TypeParameterConstraints
+%type <node> TypeParameterConstraintsClause
+%type <nodeList> TypeParameterConstraintsClauses
+%type <classHeader> ClassHeader InterfaceHeader StructHeader
+%type <memberHeader> MethodHeader DelegateHeader InterfaceMethodHeader
%type <indexer> IndexerDeclarator
%type <catchinfo> CatchNameInfo
%type <target> AttributeTarget
-%expect 28
+%expect 34
%start CompilationUnit
%%
@@ -1140,10 +1272,10 @@
QualifiedIdentifierPart
: Identifier { $$ =
$1; }
| Identifier '<' TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
| Identifier GENERIC_LT TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
;
@@ -1317,10 +1449,10 @@
MakeUnary(PtrType, $1);
}
| Type '<' TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
| Type GENERIC_LT TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
;
@@ -1341,16 +1473,22 @@
MakeUnary(PtrType, $1);
}
| NonExpressionType '<' TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
| NonExpressionType GENERIC_LT TypeActuals '>' {
- MakeBinary(GenericReference, $1, $3);
+ MakeTernary(GenericReference, $1, $3.count,
(ILNode *)$3.list);
}
;
TypeActuals
- : Type { $$ = $1; }
- | TypeActuals ',' Type { MakeBinary(TypeActuals, $1, $3); }
+ : Type {
+ $$.count = 1;
+ $$.list = (ILNode_List *)MakeList(0, $1);
+ }
+ | TypeActuals ',' Type {
+ $$.count = $1.count + 1;
+ $$.list = (ILNode_List *)MakeList((ILNode
*)($1.list), $3);
+ }
;
/*
@@ -1363,11 +1501,11 @@
MakeBinary(LocalVariableType, $1, $2);
}
| PrimaryExpression '<' TypeActuals '>' TypeSuffixes {
- ILNode *type =
ILNode_GenericReference_create($1, $3);
+ ILNode *type =
ILNode_GenericReference_create($1, $3.count, (ILNode *)$3.list);
MakeBinary(LocalVariableType, type, $5);
}
| PrimaryExpression GENERIC_LT TypeActuals '>' TypeSuffixes {
- ILNode *type =
ILNode_GenericReference_create($1, $3);
+ ILNode *type =
ILNode_GenericReference_create($1, $3.count, (ILNode *)$3.list);
MakeBinary(LocalVariableType, type, $5);
}
| BuiltinType TypeSuffixes {
@@ -1789,33 +1927,36 @@
}
;
+/*
+ * TODO: This needs a rework after the type stuff is done.
+ */
GenericReference
: RelationalExpression GENERIC_LT ShiftExpression '>' {
- $$ = CSInsertGenericReference($1, $3);
+ $$ = CSInsertGenericReference($1, 1,
MakeList(0, $3));
}
| RelationalExpression GENERIC_LT ShiftExpression TypeSuffixList '>'
{
$$ = CSInsertGenericReference
- ($1,
ILNode_LocalVariableType_create($3, $4));
+ ($1, 1, MakeList(0,
ILNode_LocalVariableType_create($3, $4)));
}
| RelationalExpression GENERIC_LT ShiftExpression ',' TypeActuals '>'
{
$$ = CSInsertGenericReference
- ($1, ILNode_TypeActuals_create($3, $5));
+ ($1, $5.count + 1, MakeList(MakeList(0,
$3), (ILNode *)($5.list)));
}
| RelationalExpression GENERIC_LT ShiftExpression TypeSuffixList ','
TypeActuals '>' {
$$ = CSInsertGenericReference
- ($1, CSInsertTypeActuals
-
(ILNode_LocalVariableType_create($3, $4), $6));
+ ($1, $6.count + 1, CSInsertTypeActuals
+
(ILNode_LocalVariableType_create($3, $4), (ILNode *)($6.list)));
}
| RelationalExpression GENERIC_LT BuiltinType TypeSuffixes '>' {
$$ = CSInsertGenericReference
- ($1,
ILNode_LocalVariableType_create($3, $4));
+ ($1, 1, MakeList(0,
ILNode_LocalVariableType_create($3, $4)));
}
| RelationalExpression GENERIC_LT BuiltinType TypeSuffixes ','
TypeActuals '>' {
$$ = CSInsertGenericReference
- ($1, CSInsertTypeActuals
-
(ILNode_LocalVariableType_create($3, $4), $6));
+ ($1, $6.count + 1, CSInsertTypeActuals
+
(ILNode_LocalVariableType_create($3, $4), (ILNode *)($6.list)));
}
;
@@ -2695,48 +2836,77 @@
/*
* Class declarations.
*/
+ClassHeader
+ : OptAttributes OptModifiers OptPartial CLASS Identifier ClassBase
{
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $6;
+ $$.typeFormals = 0;
+ }
+ | OptAttributes OptModifiers OptPartial CLASS Identifier TypeFormals
+ ClassBase TypeParameterConstraintsClauses {
+#if IL_VERSION_MAJOR > 1
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = $6;
+ MergeGenericConstraints($6, $8);
+#else /* IL_VERSION_MAJOR == 1 */
+ CCErrorOnLine(yygetfilename($5),
yygetlinenum($5),
+ "generics are not
supported in this version");
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = 0;
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
ClassDeclaration
- : OptAttributes OptModifiers OptPartial CLASS Identifier TypeFormals
- ClassBase Constraints {
+ : ClassHeader {
/* Enter a new nesting level */
++NestingLevel;
#if IL_VERSION_MAJOR > 1
/* ECMA 334 Version 4: 17.1.1.3 */
- if($2 & CS_MODIFIER_STATIC)
+ if($1.modifiers & CS_MODIFIER_STATIC)
{
- if($2 & CS_MODIFIER_SEALED)
+ if($1.modifiers & CS_MODIFIER_SEALED)
{
CCError(_("static classes must
not be sealed"));
}
- if($2 & CS_MODIFIER_ABSTRACT)
+ if($1.modifiers & CS_MODIFIER_ABSTRACT)
{
CCError(_("static classes must
not be abstract"));
}
- if($7 != 0)
+ if($1.classBase != 0)
{
CCError(_("static classes must
not have a base class specification"));
}
/* Static classes are implecitely
sealed. */
/* ECMA 335 Version 4: 10.1.4 states
they should be abstract too. */
- $2 |= (CS_MODIFIER_SEALED |
CS_MODIFIER_ABSTRACT);
+ $1.modifiers |= (CS_MODIFIER_SEALED |
CS_MODIFIER_ABSTRACT);
}
#endif /* IL_VERSION_MAJOR > 1 */
/* Push the identifier onto the class name
stack */
- ClassNamePush($5, $2);
+ ClassNamePush($1.identifier, $1.modifiers);
}
ClassBody OptSemiColon {
- ILNode *classBody = ($10).body;
+ ILNode *classBody = ($3).body;
/* Validate the modifiers */
ILUInt32 attrs =
#if IL_VERSION_MAJOR > 1
- CSModifiersToTypeAttrs($5, $2 &
~CS_MODIFIER_STATIC,
+ CSModifiersToTypeAttrs($1.identifier,
$1.modifiers & ~CS_MODIFIER_STATIC,
(NestingLevel > 1));
#else /* IL_VERSION_MAJOR == 1 */
- CSModifiersToTypeAttrs($5, $2,
(NestingLevel > 1));
+ CSModifiersToTypeAttrs($1.identifier,
$1.modifiers, (NestingLevel > 1));
#endif /* IL_VERSION_MAJOR == 1 */
/* Exit the current nesting level */
@@ -2745,7 +2915,7 @@
/* Determine if we need to add a default
constructor */
#if IL_VERSION_MAJOR > 1
/* Don't add the default constructor for static
classes. */
- if((($2 & CS_MODIFIER_STATIC) == 0) &&
+ if((($1.modifiers & CS_MODIFIER_STATIC) == 0)
&&
!ClassNameIsCtorDefined())
#else /* IL_VERSION_MAJOR == 1 */
if(!ClassNameIsCtorDefined())
@@ -2763,7 +2933,7 @@
(ILNode_BaseInit_create(), 0)));
ILNode *ctor =
ILNode_MethodDeclaration_create
(0,
CSModifiersToConstructorAttrs(cname, ctorMods),
- 0 /* "void" */, cname,
+ 0 /* "void" */, cname, 0,
ILNode_Empty_create(), body);
if(!classBody)
{
@@ -2775,16 +2945,16 @@
/* Create the class definition */
InitGlobalNamespace();
$$ = ILNode_ClassDefn_create
- ($1,
/* OptAttributes */
+ ($1.attributes,
/* OptAttributes */
attrs,
/* OptModifiers */
- ILQualIdentName($5,
0),/* Identifier */
+
ILQualIdentName($1.identifier, 0),/* Identifier */
CurrNamespace.string,
/* Namespace */
(ILNode
*)CurrNamespaceNode,
- $6,
/* TypeFormals */
- $7,
/* ClassBase */
+ (ILNode
*)$1.typeFormals, /* TypeFormals */
+ $1.classBase,
/* ClassBase */
classBody,
- ($10).staticCtors);
- CloneLine($$, $5);
+ ($3).staticCtors);
+ CloneLine($$, $1.identifier);
/* Pop the class name stack */
ClassNamePop();
@@ -2795,53 +2965,102 @@
;
TypeFormals
- : /* empty */ { $$ = 0; }
- | '<' TypeFormalList '>' { $$ = $2; }
- | GENERIC_LT TypeFormalList '>' { $$ = $2; }
+ : '<' TypeFormalList '>' {
+ $$ = (ILNode_GenericTypeParameters *)
+
ILNode_GenericTypeParameters_create($2.count, $2.list);
+ }
+ | GENERIC_LT TypeFormalList '>' {
+ $$ = (ILNode_GenericTypeParameters *)
+
ILNode_GenericTypeParameters_create($2.count, $2.list);
+ }
;
TypeFormalList
: Identifier {
- $$ = ILNode_List_create();
- ILNode_List_Add($$, $1);
+ $$.count = 1;
+ $$.list = (ILNode_List *)MakeList(0,
+ (ILNode
*)ILNode_GenericTypeParameter_create(0,
+
ILQualIdentName($1, 0),
+
0, 0));
}
| TypeFormalList ',' Identifier {
/* Check for duplicates in the list */
+ const char *name = ILQualIdentName($3, 0);
ILNode_ListIter iter;
- ILNode *node;
- ILNode_ListIter_Init(&iter, $1);
- while((node = ILNode_ListIter_Next(&iter)) != 0)
+ ILNode_GenericTypeParameter *node;
+ ILNode_ListIter_Init(&iter, $1.list);
+ while((node = (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
{
- if(!strcmp(ILQualIdentName(node, 0),
- ILQualIdentName($3,
0)))
+ if(!strcmp(node->name, name))
{
CCErrorOnLine(yygetfilename($3), yygetlinenum($3),
"`%s' declared multiple times
in generic parameters",
- ILQualIdentName($3, 0));
+ name);
break;
}
}
- /* Add the identifier to the list */
- ILNode_List_Add($1, $3);
- $$ = $1;
+ /* Add the generic parameter to the list */
+ $$.list = (ILNode_List *)MakeList((ILNode
*)($1.list),
+ (ILNode
*)ILNode_GenericTypeParameter_create($1.count,
+
name,
+
0, 0));
+ $$.count = $1.count + 1;
}
;
-/* TODO: generic parameter constraints */
-Constraints
- : /* empty */
- | WHERE ConstraintList
+TypeParameterConstraintsClauses
+ : /* EMPTY */ { $$ = 0; }
+ | TypeParameterConstraintsClause { $$ = (ILNode_List
*)MakeList(0, $1); }
+ | TypeParameterConstraintsClauses TypeParameterConstraintsClause
{
+ $$ = (ILNode_List
*)MakeList((ILNode *)$1, $2);
+ }
+ ;
+
+TypeParameterConstraintsClause
+ : WHERE Identifier ':' TypeParameterConstraints {
+ $$ =
ILNode_GenericConstraint_create
+
(ILQualIdentName($2, 0),
+ $4.constraint,
+
$4.typeConstraints);
+ }
+ ;
+
+TypeParameterConstraints
+ : PrimaryConstraint { $$.constraint
= $1; $$.typeConstraints = 0; }
+ | SecondaryConstraints { $$.constraint = 0;
$$.typeConstraints = $1; }
+ | ConstructorConstraint { $$.constraint = $1;
$$.typeConstraints = 0; }
+ | PrimaryConstraint ',' SecondaryConstraints {
+ $$.constraint = $1;
+ $$.typeConstraints = $3;
+ }
+ | PrimaryConstraint ',' ConstructorConstraint {
+ $$.constraint = ($1 | $3);
+ $$.typeConstraints = 0;
+ }
+ | SecondaryConstraints ',' ConstructorConstraint {
+ $$.constraint = $3;
+ $$.typeConstraints = $1;
+ }
+ | PrimaryConstraint ',' SecondaryConstraints ',' ConstructorConstraint
{
+ $$.constraint = ($1 | $5);
+ $$.typeConstraints = $3;
+ }
+
+ ;
+
+SecondaryConstraints
+ : Type { $$ =
(ILNode_List *)MakeList(0, $1); }
+ | SecondaryConstraints ',' Type { $$ = (ILNode_List *)MakeList((ILNode
*)$1, $3); }
;
-ConstraintList
- : Constraint
- | ConstraintList ',' Constraint
+PrimaryConstraint
+ : CLASS { $$ =
IL_META_GENPARAM_CLASS_CONST; }
+ | STRUCT { $$ =
IL_META_GENPARAM_VALUETYPE_CONST; }
;
-Constraint
- : Identifier ':' Type { /* TODO */ }
- | Identifier ':' NEW '(' ')' { /* TODO */ }
+ConstructorConstraint
+ : NEW '(' ')' { $$ =
IL_META_GENPARAM_CTOR_CONST; }
;
ModuleDeclaration
@@ -3019,33 +3238,82 @@
/*
* Methods.
*/
+MethodHeader
+ : OptAttributes OptModifiers Type QualifiedIdentifier
+ '(' OptFormalParameterList ')'
TypeParameterConstraintsClauses {
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $3;
+ $$.args = (ILNode_List *)$6;
+#if IL_VERSION_MAJOR > 1
+ if(yyisa($4, ILNode_Identifier))
+ {
+ $$.identifier = $4;
+ $$.typeFormals = 0;
+ if($8 != 0)
+ {
+
CCErrorOnLine(yygetfilename($8), yygetlinenum($8),
+ "constraints
are not allowed without generic parameters");
+ }
+ }
+ else if(yyisa($4, ILNode_GenericReference))
+ {
+ $$.identifier =
((ILNode_GenericReference *)$4)->type;
+
+ $$.typeFormals =
TypeActualsToTypeFormals(((ILNode_GenericReference *)$4)->typeArguments);
+
+ if($$.typeFormals != 0)
+ {
+
MergeGenericConstraints($$.typeFormals, $8);
+ }
+ }
+ else
+ {
+ $$.identifier = $4;
+ $$.typeFormals = 0;
+ }
+#else /* IL_VERSION_MAJOR == 1 */
+ $$.identifier = $4;
+ $$.typeFormals = 0;
+ if($8 != 0)
+ {
+ CCErrorOnLine(yygetfilename($8),
yygetlinenum($8),
+ "generics are
not supported in this version");
+ }
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
MethodDeclaration
- : OptAttributes OptModifiers Type QualifiedIdentifier
- '(' OptFormalParameterList ')' MethodBody {
- ILUInt32 attrs = CSModifiersToMethodAttrs($3,
$2);
- if($2 & CS_MODIFIER_PRIVATE && yyisa($4,
ILNode_QualIdent))
+ : MethodHeader MethodBody {
+ ILUInt32 attrs =
CSModifiersToMethodAttrs($1.type, $1.modifiers);
+ if($1.modifiers & CS_MODIFIER_PRIVATE &&
yyisa($1.identifier, ILNode_QualIdent))
{
// NOTE: clean this up later
- CCErrorOnLine(yygetfilename($3),
yygetlinenum($3),
+ CCErrorOnLine(yygetfilename($1.type),
yygetlinenum($1.type),
"`private' cannot be used in
this context");
}
#if IL_VERSION_MAJOR > 1
if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
{
- if(!($2 & CS_MODIFIER_STATIC))
+ if(!($1.modifiers & CS_MODIFIER_STATIC))
{
CCError(_("only static methods
are allowed in static classes"));
}
- if($2 & CS_MODIFIER_PROTECTED)
+ if($1.modifiers & CS_MODIFIER_PROTECTED)
{
CCError(_("no protected or
protected internal methods are allowed in static classes"));
}
}
#endif /* IL_VERSION_MAJOR > 1 */
$$ = ILNode_MethodDeclaration_create
- ($1, attrs, $3, $4, $6, $8);
- CloneLine($$, $4);
+ ($1.attributes,
+ attrs,
+ $1.type,
+ $1.identifier,
+ (ILNode *)$1.typeFormals,
+ (ILNode *)$1.args,
+ $2);
+ CloneLine($$, $1.type);
}
;
@@ -3158,7 +3426,7 @@
GetAccessorDeclaration
: OptAttributes GET AccessorBody {
$$ = ILNode_MethodDeclaration_create
- ($1, 0, 0, 0, 0, $3);
+ ($1, 0, 0, 0, 0, 0, $3);
#ifdef YYBISON
yysetlinenum($$, @2.first_line);
#endif
@@ -3173,7 +3441,7 @@
SetAccessorDeclaration
: OptAttributes SET AccessorBody {
$$ = ILNode_MethodDeclaration_create
- ($1, 0, 0, 0, 0, $3);
+ ($1, 0, 0, 0, 0, 0, $3);
#ifdef YYBISON
yysetlinenum($$, @2.first_line);
#endif
@@ -3280,7 +3548,7 @@
AddAccessorDeclaration
: OptAttributes ADD AccessorBody {
$$ = ILNode_MethodDeclaration_create
- ($1, 0, 0, 0, 0, $3);
+ ($1, 0, 0, 0, 0, 0, $3);
#ifdef YYBISION
yysetlinenum($$, @2.first_line);
#endif
@@ -3290,7 +3558,7 @@
RemoveAccessorDeclaration
: OptAttributes REMOVE AccessorBody {
$$ = ILNode_MethodDeclaration_create
- ($1, 0, 0, 0, 0, $3);
+ ($1, 0, 0, 0, 0, 0, $3);
#ifdef YYBISION
yysetlinenum($$, @2.first_line);
#endif
@@ -3381,7 +3649,6 @@
/*
* Operators.
*/
-
OperatorDeclaration
: NormalOperatorDeclaration { $$ = $1; }
| ConversionOperatorDeclaration { $$ = $1; }
@@ -3389,12 +3656,10 @@
NormalOperatorDeclaration
: OptAttributes OptModifiers Type OPERATOR OverloadableOperator
- TypeFormals '(' Type Identifier ')' Block {
+ '(' Type Identifier ')' Block {
ILUInt32 attrs;
ILNode *params;
- /* TODO: generic parameters */
-
/* Validate the name of the unary operator */
if($5.unary == 0)
{
@@ -3415,22 +3680,20 @@
/* Build the formal parameter list */
params = ILNode_List_create();
ILNode_List_Add(params,
- ILNode_FormalParameter_create(0,
ILParamMod_empty, $8, $9));
+ ILNode_FormalParameter_create(0,
ILParamMod_empty, $7, $8));
/* Create a method definition for the operator
*/
$$ = ILNode_MethodDeclaration_create
($1, attrs, $3,
ILQualIdentSimple(ILInternString($5.unary, -1).string),
- params, $11);
+ 0, params, $10);
CloneLine($$, $3);
}
| OptAttributes OptModifiers Type OPERATOR OverloadableOperator
- TypeFormals '(' Type Identifier ',' Type Identifier ')'
Block {
+ '(' Type Identifier ',' Type Identifier ')' Block
{
ILUInt32 attrs;
ILNode *params;
- /* TODO: generic parameters */
-
/* Validate the name of the binary operator */
if($5.binary == 0)
{
@@ -3452,17 +3715,17 @@
params = ILNode_List_create();
ILNode_List_Add(params,
ILNode_FormalParameter_create
- (0, ILParamMod_empty, $8, $9));
+ (0, ILParamMod_empty, $7, $8));
ILNode_List_Add(params,
ILNode_FormalParameter_create
- (0, ILParamMod_empty, $11,
$12));
+ (0, ILParamMod_empty, $10,
$11));
/* Create a method definition for the operator
*/
$$ = ILNode_MethodDeclaration_create
($1, attrs, $3,
ILQualIdentSimple
(ILInternString($5.binary, -1).string),
- params, $14);
+ 0, params, $13);
CloneLine($$, $3);
}
;
@@ -3493,51 +3756,47 @@
;
ConversionOperatorDeclaration
- : OptAttributes OptModifiers IMPLICIT OPERATOR TypeFormals Type
+ : OptAttributes OptModifiers IMPLICIT OPERATOR Type
'(' Type Identifier ')' Block {
ILUInt32 attrs;
ILNode *params;
- /* TODO: generic parameters */
-
/* Get the operator attributes */
- attrs = CSModifiersToOperatorAttrs($6, $2);
+ attrs = CSModifiersToOperatorAttrs($5, $2);
/* Build the formal parameter list */
params = ILNode_List_create();
ILNode_List_Add(params,
- ILNode_FormalParameter_create(0,
ILParamMod_empty, $8, $9));
+ ILNode_FormalParameter_create(0,
ILParamMod_empty, $7, $8));
/* Create a method definition for the operator
*/
$$ = ILNode_MethodDeclaration_create
- ($1, attrs, $6,
+ ($1, attrs, $5,
ILQualIdentSimple
(ILInternString("op_Implicit", -1).string),
- params, $11);
- CloneLine($$, $6);
+ 0, params, $10);
+ CloneLine($$, $5);
}
- | OptAttributes OptModifiers EXPLICIT OPERATOR TypeFormals Type
+ | OptAttributes OptModifiers EXPLICIT OPERATOR Type
'(' Type Identifier ')' Block {
ILUInt32 attrs;
ILNode *params;
- /* TODO: generic parameters */
-
/* Get the operator attributes */
- attrs = CSModifiersToOperatorAttrs($6, $2);
+ attrs = CSModifiersToOperatorAttrs($5, $2);
/* Build the formal parameter list */
params = ILNode_List_create();
ILNode_List_Add(params,
- ILNode_FormalParameter_create(0,
ILParamMod_empty, $8, $9));
+ ILNode_FormalParameter_create(0,
ILParamMod_empty, $7, $8));
/* Create a method definition for the operator
*/
$$ = ILNode_MethodDeclaration_create
- ($1, attrs, $6,
+ ($1, attrs, $5,
ILQualIdentSimple
(ILInternString("op_Explicit", -1).string),
- params, $11);
- CloneLine($$, $6);
+ 0, params, $10);
+ CloneLine($$, $5);
}
;
@@ -3622,7 +3881,7 @@
else
{
$$.body =
ILNode_MethodDeclaration_create
- ($1, attrs, 0 /* "void" */,
cname, $5, body);
+ ($1, attrs, 0 /* "void" */,
cname, 0, $5, body);
CloneLine($$.body, $3);
$$.staticCtors = 0;
}
@@ -3703,7 +3962,7 @@
($1, attrs, 0 /* void
*/,
ILQualIdentSimple
(ILInternString("Finalize", -1).string),
- 0, body);
+ 0, 0, body);
CloneLine($$, $4);
}
;
@@ -3711,22 +3970,52 @@
/*
* Structs.
*/
+StructHeader
+ : OptAttributes OptModifiers OptPartial STRUCT Identifier
StructInterfaces {
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $6;
+ $$.typeFormals = 0;
+ }
+ | OptAttributes OptModifiers OptPartial STRUCT Identifier TypeFormals
+ StructInterfaces TypeParameterConstraintsClauses {
+#if IL_VERSION_MAJOR > 1
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = $6;
+ MergeGenericConstraints($6, $8);
+#else /* IL_VERSION_MAJOR == 1 */
+ CCErrorOnLine(yygetfilename($5),
yygetlinenum($5),
+ "generics are not
supported in this version");
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = 0;
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
StructDeclaration
- : OptAttributes OptModifiers OptPartial STRUCT Identifier TypeFormals
- StructInterfaces Constraints {
+ : StructHeader {
/* Enter a new nesting level */
++NestingLevel;
/* Push the identifier onto the class name
stack */
- ClassNamePush($5, $2);
+ ClassNamePush($1.identifier, $1.modifiers);
}
StructBody OptSemiColon {
ILNode *baseList;
ILUInt32 attrs;
/* Validate the modifiers */
- attrs = CSModifiersToTypeAttrs($5, $2,
(NestingLevel > 1));
+ attrs = CSModifiersToTypeAttrs($1.identifier,
$1.modifiers,
+
(NestingLevel > 1));
/* Add extra attributes that structs need */
attrs |= IL_META_TYPEDEF_LAYOUT_SEQUENTIAL |
@@ -3738,24 +4027,24 @@
/* Make sure that we have "ValueType" in the
base list */
baseList = MakeSystemType("ValueType");
- if($7 != 0)
+ if($1.classBase != 0)
{
- baseList = ILNode_ArgList_create($7,
baseList);
+ baseList =
ILNode_ArgList_create($1.classBase, baseList);
}
/* Create the class definition */
InitGlobalNamespace();
$$ = ILNode_ClassDefn_create
- ($1,
/* OptAttributes */
+ ($1.attributes,
/* OptAttributes */
attrs,
/* OptModifiers */
- ILQualIdentName($5,
0),/* Identifier */
+
ILQualIdentName($1.identifier, 0),/* Identifier */
CurrNamespace.string,
/* Namespace */
(ILNode
*)CurrNamespaceNode,
- $6,
/* TypeFormals */
+ (ILNode
*)$1.typeFormals, /* TypeFormals */
baseList,
/* ClassBase */
- ($10).body,
/* StructBody */
- ($10).staticCtors);
/* StaticCtors */
- CloneLine($$, $5);
+ ($3).body,
/* StructBody */
+ ($3).staticCtors);
/* StaticCtors */
+ CloneLine($$, $1.identifier);
/* Pop the class name stack */
ClassNamePop();
@@ -3785,20 +4074,50 @@
/*
* Interfaces.
*/
+InterfaceHeader
+ : OptAttributes OptModifiers OptPartial INTERFACE Identifier
InterfaceBase {
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $6;
+ $$.typeFormals = 0;
+ }
+ | OptAttributes OptModifiers OptPartial INTERFACE Identifier TypeFormals
+ InterfaceBase TypeParameterConstraintsClauses {
+#if IL_VERSION_MAJOR > 1
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = $6;
+ MergeGenericConstraints($6, $8);
+#else /* IL_VERSION_MAJOR == 1 */
+ CCErrorOnLine(yygetfilename($5),
yygetlinenum($5),
+ "generics are not
supported in this version");
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.partial = $3;
+ $$.identifier = $5;
+ $$.classBase = $7;
+ $$.typeFormals = 0;
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
InterfaceDeclaration
- : OptAttributes OptModifiers OptPartial INTERFACE Identifier TypeFormals
- InterfaceBase Constraints {
+ : InterfaceHeader {
/* Increase the nesting level */
++NestingLevel;
/* Push the identifier onto the class name
stack */
- ClassNamePush($5, $2);
+ ClassNamePush($1.identifier, $1.modifiers);
}
InterfaceBody OptSemiColon {
/* Validate the modifiers */
ILUInt32 attrs =
- CSModifiersToTypeAttrs($5, $2,
(NestingLevel > 1));
+ CSModifiersToTypeAttrs($1.identifier,
$1.modifiers,
+
(NestingLevel > 1));
/* Add extra attributes that interfaces need */
attrs |= IL_META_TYPEDEF_INTERFACE |
@@ -3810,16 +4129,16 @@
/* Create the interface definition */
InitGlobalNamespace();
$$ = ILNode_ClassDefn_create
- ($1,
/* OptAttributes */
+ ($1.attributes,
/* OptAttributes */
attrs,
/* OptModifiers */
- ILQualIdentName($5,
0),/* Identifier */
+
ILQualIdentName($1.identifier, 0),/* Identifier */
CurrNamespace.string,
/* Namespace */
(ILNode
*)CurrNamespaceNode,
- $6,
/* TypeFormals */
- $7,
/* ClassBase */
- $10,
/* InterfaceBody */
+ (ILNode
*)$1.typeFormals, /* TypeFormals */
+ $1.classBase,
/* ClassBase */
+ $3,
/* InterfaceBody */
0);
/* StaticCtors */
- CloneLine($$, $5);
+ CloneLine($$, $1.identifier);
/* Pop the class name stack */
ClassNamePop();
@@ -3869,17 +4188,54 @@
| InterfaceIndexerDeclaration { $$ = $1;}
;
+InterfaceMethodHeader
+ : OptAttributes OptNew Type Identifier '(' OptFormalParameterList ')' {
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $3;
+ $$.identifier = $4;
+ $$.args = (ILNode_List *)$6;
+ $$.typeFormals = 0;
+ }
+ | OptAttributes OptNew Type Identifier TypeFormals
+ '(' OptFormalParameterList ')'
TypeParameterConstraintsClauses {
+#if IL_VERSION_MAJOR > 1
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $3;
+ $$.identifier = $4;
+ $$.args = (ILNode_List *)$7;
+ $$.typeFormals = $5;
+ MergeGenericConstraints($5, $9);
+#else /* IL_VERSION_MAJOR == 1 */
+ CCErrorOnLine(yygetfilename($5),
yygetlinenum($5),
+ "generics are not
supported in this version");
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $3;
+ $$.identifier = $4;
+ $$.args = (ILNode_List *)$7;
+ $$.typeFormals = 0;
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
+
InterfaceMethodDeclaration
- : OptAttributes OptNew Type Identifier '(' OptFormalParameterList ')'
';' {
- ILUInt32 attrs = ($2 ? CS_SPECIALATTR_NEW : 0) |
+ : InterfaceMethodHeader ';' {
+ ILUInt32 attrs = ($1.modifiers ?
CS_SPECIALATTR_NEW : 0) |
IL_META_METHODDEF_PUBLIC |
IL_META_METHODDEF_VIRTUAL |
IL_META_METHODDEF_ABSTRACT |
IL_META_METHODDEF_HIDE_BY_SIG |
IL_META_METHODDEF_NEW_SLOT;
$$ = ILNode_MethodDeclaration_create
- ($1, attrs, $3, $4, $6, 0);
- CloneLine($$, $4);
+ ($1.attributes,
+ attrs,
+ $1.type,
+ $1.identifier,
+ (ILNode *)$1.typeFormals,
+ (ILNode *)$1.args,
+ 0);
+ CloneLine($$, $1.identifier);
}
;
@@ -4100,16 +4456,47 @@
/*
* Delegates.
*/
+DelegateHeader
+ : OptAttributes OptModifiers DELEGATE Type Identifier
+ '(' OptFormalParameterList ')' {
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $4;
+ $$.identifier = $5;
+ $$.args = (ILNode_List *)$7;
+ $$.typeFormals = 0;
+ }
+ | OptAttributes OptModifiers DELEGATE Type Identifier TypeFormals
+ '(' OptFormalParameterList ')'
TypeParameterConstraintsClauses {
+#if IL_VERSION_MAJOR > 1
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $4;
+ $$.identifier = $5;
+ $$.args = (ILNode_List *)$8;
+ $$.typeFormals = $6;
+ MergeGenericConstraints($6, $10);
+#else /* IL_VERSION_MAJOR == 1 */
+ CCErrorOnLine(yygetfilename($5),
yygetlinenum($5),
+ "generics are not
supported in this version");
+ $$.attributes = $1;
+ $$.modifiers = $2;
+ $$.type = $4;
+ $$.identifier = $5;
+ $$.args = (ILNode_List *)$8;
+ $$.typeFormals = 0;
+#endif /* IL_VERSION_MAJOR == 1 */
+ }
DelegateDeclaration
- : OptAttributes OptModifiers DELEGATE Type Identifier TypeFormals
- '(' OptFormalParameterList ')' ';' {
+ : DelegateHeader ';' {
ILNode *baseList;
ILNode *bodyList;
ILUInt32 attrs;
/* Validate the modifiers */
- attrs = CSModifiersToDelegateAttrs($5, $2,
(NestingLevel > 0));
+ attrs =
CSModifiersToDelegateAttrs($1.identifier, $1.modifiers,
+
(NestingLevel > 0));
/* Make sure that we have "MulticastDelegate"
in the base list */
@@ -4118,21 +4505,22 @@
/* Construct the body of the delegate class */
bodyList = ILNode_List_create();
ILNode_List_Add(bodyList,
-
ILNode_DelegateMemberDeclaration_create($4, $8));
+
ILNode_DelegateMemberDeclaration_create($1.type,
+
(ILNode *)$1.args));
/* Create the class definition */
InitGlobalNamespace();
$$ = ILNode_ClassDefn_create
- ($1,
/* OptAttributes */
+ ($1.attributes,
/* OptAttributes */
attrs,
/* OptModifiers */
- ILQualIdentName($5,
0),/* Identifier */
+
ILQualIdentName($1.identifier, 0),/* Identifier */
CurrNamespace.string,
/* Namespace */
(ILNode
*)CurrNamespaceNode,
- $6,
/* TypeFormals */
+ (ILNode
*)$1.typeFormals, /* TypeFormals */
baseList,
/* ClassBase */
bodyList,
/* Body */
0);
/* StaticCtors */
- CloneLine($$, $5);
+ CloneLine($$, $1.identifier);
/* We have declarations at the top-most level
of the file */
HaveDecls = 1;
Index: cscc/csharp/cs_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_internal.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- cscc/csharp/cs_internal.h 5 May 2007 15:56:41 -0000 1.23
+++ cscc/csharp/cs_internal.h 20 Sep 2007 20:04:16 -0000 1.24
@@ -21,8 +21,10 @@
#ifndef _CSCC_CS_INTERNAL_H
#define _CSCC_CS_INTERNAL_H
+#include <il_profile.h>
#include <cscc/csharp/cs_defs.h>
#include <cscc/common/cc_main.h>
+#include <cscc/csharp/cs_lookup_member.h>
#ifdef __cplusplus
extern "C" {
@@ -273,7 +275,8 @@
* Insert generic type actuals into an expression node at
* the right-most position.
*/
-ILNode *CSInsertGenericReference(ILNode *mainNode, ILNode *actuals);
+ILNode *CSInsertGenericReference(ILNode *mainNode, ILUInt32 numActuals,
+ ILNode
*actuals);
/*
* Insert a type at the beginning of a type actuals list.
Index: cscc/csharp/cs_lookup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lookup.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- cscc/csharp/cs_lookup.c 1 Jun 2007 11:08:51 -0000 1.36
+++ cscc/csharp/cs_lookup.c 20 Sep 2007 20:04:16 -0000 1.37
@@ -20,178 +20,13 @@
#include "cs_internal.h"
+#include "cs_lookup_member.c"
+
#ifdef __cplusplus
extern "C" {
#endif
/*
- * Extra member kinds.
- */
-#define CS_MEMBERKIND_TYPE 20
-#define CS_MEMBERKIND_TYPE_NODE 21
-#define CS_MEMBERKIND_NAMESPACE 22
-
-/*
- * A list of members that results from a lookup on a type.
- */
-typedef struct _tagCSMemberInfo CSMemberInfo;
-struct _tagCSMemberInfo
-{
- ILProgramItem *member;
- ILClass *owner;
- short kind;
- short form;
- CSMemberInfo *next;
-};
-#define CS_MEMBER_LOOKUP_MAX 4
-typedef struct _tagCSMemberLookupInfo CSMemberLookupInfo;
-struct _tagCSMemberLookupInfo
-{
- int num;
- CSMemberInfo *members;
- CSMemberInfo *lastMember;
-
-};
-
-/*
- * Iterator control structure for CSMemberLookupInfo.
- */
-typedef struct
-{
- CSMemberLookupInfo *info;
- CSMemberInfo *current;
- CSMemberInfo *last;
-
-} CSMemberLookupIter;
-
-/*
- * Initialize a member results set.
- */
-static void InitMembers(CSMemberLookupInfo *results)
-{
- results->num = 0;
- results->members = 0;
- results->lastMember = 0;
-}
-
-/*
- * Add a member to a results set.
- */
-static void AddMember(CSMemberLookupInfo *results,
- ILProgramItem *member, ILClass *owner,
- int kind)
-{
- CSMemberInfo *info;
-
- /* Check to make sure that the member isn't already in the list.
- This can happen when the same member is located along different
- paths in an interface inheritance hierarchy */
- info = results->members;
- while(info != 0)
- {
- if(info->member == member)
- {
- return;
- }
- info = info->next;
- }
-
- /* Add the new member to the list */
- info = (CSMemberInfo *)ILMalloc(sizeof(CSMemberInfo));
- if(!info)
- {
- CCOutOfMemory();
- }
- info->member = member;
- info->owner = owner;
- info->kind = kind;
- info->form = 0;
- info->next = 0;
- if(results->lastMember)
- {
- results->lastMember->next = info;
- }
- else
- {
- results->members = info;
- }
- results->lastMember = info;
- ++(results->num);
-}
-
-/*
- * Free the contents of a member lookup results list.
- */
-static void FreeMembers(CSMemberLookupInfo *results)
-{
- CSMemberInfo *info, *next;
- info = results->members;
- while(info != 0)
- {
- next = info->next;
- ILFree(info);
- info = next;
- }
- results->num = 0;
- results->members = 0;
- results->lastMember = 0;
-}
-
-/*
- * Initialize a member iterator.
- */
-static void MemberIterInit(CSMemberLookupIter *iter,
- CSMemberLookupInfo *results)
-{
- iter->info = results;
- iter->current = 0;
- iter->last = 0;
-}
-
-/*
- * Get the next item from a member iterator.
- */
-static CSMemberInfo *MemberIterNext(CSMemberLookupIter *iter)
-{
- if(iter->current)
- {
- iter->last = iter->current;
- iter->current = iter->current->next;
- }
- else
- {
- iter->current = iter->info->members;
- iter->last = 0;
- }
- return iter->current;
-}
-
-/*
- * Remove the current item from a member iterator.
- */
-static void MemberIterRemove(CSMemberLookupIter *iter)
-{
- if(iter->current == iter->info->lastMember)
- {
- iter->info->lastMember = iter->last;
- }
- if(iter->last)
- {
- iter->last->next = iter->current->next;
- ILFree(iter->current);
- iter->current = iter->last;
- }
- else
- {
- iter->info->members = iter->current->next;
- ILFree(iter->current);
- iter->current = 0;
- iter->last = 0;
- }
- --(iter->info->num);
-}
-
-/*
* Get the method underlying a member, for permission and access checks.
* Returns NULL if there is no underlying method.
*/
@@ -523,7 +358,7 @@
/* Remove "testMember" from the
method group */
tempMember = testMember->next;
prevMember->next = tempMember;
- ILFree(testMember);
+ CSMemberInfoFree(testMember);
testMember = tempMember;
--(results->num);
continue;
@@ -1051,10 +886,15 @@
{
if(genInfo->currentMethod)
{
- return ILMethod_Owner
- (((ILNode_MethodDeclaration
*)(genInfo->currentMethod))->methodInfo);
+ ILNode_MethodDeclaration *method;
+
+ method = (ILNode_MethodDeclaration *)(genInfo->currentMethod);
+ if(method->methodInfo)
+ {
+ return ILMethod_Owner(method->methodInfo);
+ }
}
- else if(genInfo->currentClass &&
+ if(genInfo->currentClass &&
((ILNode_ClassDefn *)(genInfo->currentClass))->classInfo)
{
return ((ILNode_ClassDefn *)(genInfo->currentClass))->classInfo;
@@ -1249,39 +1089,66 @@
ILNode_ClassDefn *nestedParent;
ILNode *child;
ILNode_ListIter iter;
- int formalNum;
ILType *formalType;
CSSemValue value;
ILMethod *caller;
int switchToStatics;
ILNode *aliasNode;
- /* If we are within type gathering, then search the nesting
- parents for a nested type that matches our requirements */
- if(genInfo->typeGather)
+#if IL_VERSION_MAJOR > 1
+ /* Scan the method type formals for a match */
+ if(genInfo->currentMethod)
{
- nestedParent = (ILNode_ClassDefn *)(genInfo->currentClass);
- while(nestedParent != 0)
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams =
+ (ILNode_GenericTypeParameters *)
+ ((ILNode_MethodDeclaration
*)(genInfo->currentMethod))->typeFormals;
+ if(genParams && (genParams->numTypeParams > 0))
{
- child = FindNestedClass(0, nestedParent, name);
- if(child)
+ ILNode_GenericTypeParameter *genParam;
+
+ ILNode_ListIter_Init(&iter, genParams->typeParams);
+ while((genParam = (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
{
- CSSemSetTypeNode(value, child);
+ if(!strcmp(genParam->name, name))
+ {
+ formalType = ILTypeCreateVarNum
+ (genInfo->context,
IL_TYPE_COMPLEX_MVAR, genParam->num);
+ if(!formalType)
+ {
+ CCOutOfMemory();
+ }
+ CSSemSetType(value, formalType);
return value;
}
- nestedParent = nestedParent->nestedParent;
+ }
}
}
- /* Scan the method formals for a match */
- ILNode_ListIter_Init(&iter, genInfo->currentMethodFormals);
- formalNum = 0;
- while((child = ILNode_ListIter_Next(&iter)) != 0)
+ if(genInfo->currentClass)
{
- if(!strcmp(ILQualIdentName(child, 0), name))
+ ILNode_ClassDefn *defn = (ILNode_ClassDefn
*)(genInfo->currentClass);
+
+ while(defn)
+ {
+ ILNode_GenericTypeParameters *genParams;
+
+ genParams =
+ (ILNode_GenericTypeParameters
*)(defn->typeFormals);
+
+ if(genParams)
+ {
+ /* Scan the type formals for a match */
+ ILNode_GenericTypeParameter *genParam;
+
+ ILNode_ListIter_Init(&iter,
genParams->typeParams);
+ while((genParam = (ILNode_GenericTypeParameter
*)ILNode_ListIter_Next(&iter)) != 0)
+ {
+ if(!strcmp(genParam->name, name))
{
formalType = ILTypeCreateVarNum
- (genInfo->context, IL_TYPE_COMPLEX_MVAR,
formalNum);
+ (genInfo->context,
IL_TYPE_COMPLEX_VAR, genParam->num);
if(!formalType)
{
CCOutOfMemory();
@@ -1289,7 +1156,28 @@
CSSemSetType(value, formalType);
return value;
}
- ++formalNum;
+ }
+ }
+ defn = defn->nestedParent;
+ }
+ }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+ /* If we are within type gathering, then search the nesting
+ parents for a nested type that matches our requirements */
+ if(genInfo->typeGather)
+ {
+ nestedParent = (ILNode_ClassDefn *)(genInfo->currentClass);
+ while(nestedParent != 0)
+ {
+ child = FindNestedClass(0, nestedParent, name);
+ if(child)
+ {
+ CSSemSetTypeNode(value, child);
+ return value;
+ }
+ nestedParent = nestedParent->nestedParent;
+ }
}
/* Find the type to start looking at and the scope to use for accesses
*/
@@ -1343,25 +1231,6 @@
/* Clear the results buffer */
InitMembers(&results);
- /* Scan the type formals for a match */
- ILNode_ListIter_Init(&iter, genInfo->currentTypeFormals);
- formalNum = 0;
- while((child = ILNode_ListIter_Next(&iter)) != 0)
- {
- if(!strcmp(ILQualIdentName(child, 0), name))
- {
- formalType = ILTypeCreateVarNum
- (genInfo->context, IL_TYPE_COMPLEX_VAR,
formalNum);
- if(!formalType)
- {
- CCOutOfMemory();
- }
- CSSemSetType(value, formalType);
- return value;
- }
- ++formalNum;
- }
-
/* Scan all namespaces that enclose the current context */
namespace = (ILNode_Namespace *)(genInfo->currentNamespace);
while(namespace != 0 && !(results.num))
@@ -1815,94 +1684,6 @@
return value;
}
-void *CSCreateMethodGroup(ILMethod *method)
-{
- CSMemberLookupInfo results;
-
- /* Clear the results buffer */
- InitMembers(&results);
-
- /* Add the method as a group member */
- AddMember(&results, ILToProgramItem(method),
- ILMethod_Owner(method), IL_META_MEMBERKIND_METHOD);
-
- /* Return the group to the caller */
- return results.members;
-}
-
-ILProgramItem *CSGetGroupMember(void *group, unsigned long n)
-{
- CSMemberInfo *member = (CSMemberInfo *)group;
- while(member != 0)
- {
- if(n <= 0)
- {
- return (ILProgramItem *)(member->member);
- }
- --n;
- member = member->next;
- }
- return 0;
-}
-
-void *CSRemoveGroupMember(void *group, unsigned long n)
-{
- CSMemberInfo *member = (CSMemberInfo *)group;
- CSMemberInfo *last = 0;
- while(member != 0)
- {
- if(n <= 0)
- {
- if(last)
- {
- last->next = member->next;
- ILFree(member);
- return group;
- }
- else
- {
- last = member->next;
- ILFree(member);
- return (void *)last;
- }
- }
- --n;
- last = member;
- member = member->next;
- }
- return group;
-}
-
-void CSSetGroupMemberForm(void *group, unsigned long n, int form)
-{
- CSMemberInfo *member = (CSMemberInfo *)group;
- while(member != 0)
- {
- if(n <= 0)
- {
- member->form = (short)form;
- return;
- }
- --n;
- member = member->next;
- }
-}
-
-int CSGetGroupMemberForm(void *group, unsigned long n)
-{
- CSMemberInfo *member = (CSMemberInfo *)group;
- while(member != 0)
- {
- if(n <= 0)
- {
- return member->form;
- }
- --n;
- member = member->next;
- }
- return 0;
-}
-
#ifdef __cplusplus
};
#endif
Index: cscc/csharp/cs_lvalue.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lvalue.tc,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- cscc/csharp/cs_lvalue.tc 1 Jun 2007 11:08:52 -0000 1.62
+++ cscc/csharp/cs_lvalue.tc 20 Sep 2007 20:04:17 -0000 1.63
@@ -1175,6 +1175,18 @@
}
/*
+ * Perform semantic analysis for generic parameters.
+ */
+ILNode_SemAnalysis(ILNode_GenericTypeParameter),
+ILNode_SemAnalysis(ILNode_GenericTypeParameters),
+ILNode_SemAnalysis(ILNode_GenericConstraint)
+{
+ /* This should never be called because they are handled
+ during type gathering */
+ return CSSemValueDefault;
+}
+
+/*
* Perform semantic analysis for local and argument variables.
*/
ILNode_SemAnalysis(ILNode_LocalVar),
Index: cscc/csharp/cs_types.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_types.tc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- cscc/csharp/cs_types.tc 30 May 2003 04:34:12 -0000 1.10
+++ cscc/csharp/cs_types.tc 20 Sep 2007 20:04:17 -0000 1.11
@@ -333,7 +333,7 @@
if(!CSSemIsType(value))
{
CCErrorOnLine(yygetfilename(actuals),
yygetlinenum(actuals),
- "type name expected in generic
type parameter");
+ "type name expected in generic
type argument");
CSSemSetType(value, ILType_Int32);
}
if(!ILTypeAddWithParam(info->context, withType,
CSSemGetType(value)))
@@ -353,8 +353,6 @@
CSSemValue value;
ILClass *classInfo;
ILUInt32 numFormals;
- ILUInt32 numActuals;
- ILNode *actuals;
ILType *withType;
/* Perform semantic analysis on the main part of the type */
@@ -370,23 +368,15 @@
classInfo = ILClassResolve(ILTypeToClass(info, CSSemGetType(value)));
numFormals = ILGenericParGetNumParams(ILToProgramItem(classInfo));
- /* Count the number of actual parameters that we were given */
- numActuals = 1;
- actuals = node->actuals;
- while(yyisa(actuals, ILNode_TypeActuals))
- {
- ++numActuals;
- actuals = ((ILNode_TypeActuals *)actuals)->left;
- }
-
/* Check the counts for consistency */
- if(numFormals != numActuals)
+ /* TODO: This check is not correct for nested types. */
+ if(numFormals != node->numArgs)
{
CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
"incorrect number of generic
parameters supplied to "
"`%s'; was %d but should be %d",
CSTypeToName(CSSemGetType(value)),
- (int)numActuals, (int)numFormals);
+ (int)node->numArgs, (int)numFormals);
}
/* Build the "with" type and return it */
@@ -395,7 +385,7 @@
{
CCOutOfMemory();
}
- SemWithType(info, withType, node->actuals, &(node->actuals));
+ SemWithType(info, withType, node->typeArguments,
&(node->typeArguments));
CSSemSetType(value, withType);
return value;
}
@@ -425,10 +415,10 @@
}
}
-ILNode *CSInsertGenericReference(ILNode *mainNode, ILNode *actuals)
+ILNode *CSInsertGenericReference(ILNode *mainNode, ILUInt32 numActuals, ILNode
*actuals)
{
ILNode **parent = FindGenericInsertPosition(mainNode, &mainNode);
- *parent = ILNode_GenericReference_create(*parent, actuals);
+ *parent = ILNode_GenericReference_create(*parent, numActuals, actuals);
return mainNode;
}
Index: cscc/csharp/Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cscc/csharp/Makefile.am 6 Feb 2007 20:54:52 -0000 1.11
+++ cscc/csharp/Makefile.am 20 Sep 2007 20:04:17 -0000 1.12
@@ -37,13 +37,16 @@
TREECC_OUTPUT = $(TREECC_SRCOUT) $(TREECC_UNUSED_SRCOUT) cs_defs.h
-EXTRA_DIST = $(TREECC_INPUTS)
+CS_LOOKUP_INPUTS = cs_lookup_member.c
+
+EXTRA_DIST = $(TREECC_INPUTS) $(CS_LOOKUP_INPUTS)
libILCSharp_a_SOURCES = cs_attrs.c \
cs_gather.c \
cs_grammar.y \
cs_internal.h \
cs_lookup.c \
+ cs_lookup_member.h \
cs_modifiers.c \
cs_rename.h \
cs_scanner.l \
Index: cscc/java/java_decls.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/java/java_decls.tc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- cscc/java/java_decls.tc 5 May 2007 15:56:42 -0000 1.2
+++ cscc/java/java_decls.tc 20 Sep 2007 20:04:17 -0000 1.3
@@ -172,6 +172,7 @@
IL_META_METHODDEF_RT_SPECIAL_NAME,
0 /* void */,
ILQualIdentSimple(ILInternString(".cctor", 6).string),
+ 0 /* no type formals */,
0 /* no parameters */,
ILNode_NewScope_create(node->staticCtors));
methodInfo = ILMethodCreate(node->classInfo, 0,
".cctor",
@@ -620,6 +621,7 @@
IL_META_METHODDEF_HIDE_BY_SIG,
0 /* void */,
ILQualIdentSimple(ILInternString(".init", 5).string),
+ 0 /* no type formals */,
0 /* no parameters */,
ILNode_NewScope_create(bodyList));
methodInfo = ILMethodCreate(defn->classInfo, 0, ".init",
Index: cscc/java/java_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/java/java_gather.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- cscc/java/java_gather.c 5 May 2007 15:56:42 -0000 1.2
+++ cscc/java/java_gather.c 20 Sep 2007 20:04:17 -0000 1.3
@@ -1144,6 +1144,7 @@
IL_META_METHODDEF_HIDE_BY_SIG,
0,
ILQualIdentSimple("Main"),
+
0,
list,
helperBody);
}
Index: cscc/java/java_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/java/java_grammar.y,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- cscc/java/java_grammar.y 24 May 2007 13:51:15 -0000 1.6
+++ cscc/java/java_grammar.y 20 Sep 2007 20:04:17 -0000 1.7
@@ -999,7 +999,7 @@
(ILNode_BaseInit_create(), 0)));
ILNode *ctor = ILNode_MethodDeclaration_create
(0,
JavaModifiersToConstructorAttrs(cname, ctorMods),
- 0 /* "void" */, cname,
+ 0 /* "void" */, cname, 0,
ILNode_Empty_create(), body);
if(!classBody)
{
@@ -1143,6 +1143,7 @@
attrs, /* modifiers */
0, /* "void" */
cname, /* name */
+
0, /* typeFormals */
$3, /* params */
$5); /* body */
CloneLine($$, $2);
@@ -1168,6 +1169,7 @@
attrs, /* modifiers */
$2, /* retval */
cname, /* name */
+
0, /* typeFormals */
$4, /* params */
$6); /* body */
CloneLine($$, $2);
@@ -1270,7 +1272,7 @@
ILUInt32 attrs =JavaModifiersToMethodAttrs($3,$1);
attrs = attrs | IL_META_METHODDEF_ABSTRACT;
$$ = ILNode_MethodDeclaration_create
- (NULL, attrs, $2, $3, $4, 0);
+ (NULL, attrs, $2, $3, 0, $4, 0);
CloneLine($$, $3);
}
| ModifiersOpt error Identifier FormalParameters ';' {
Index: cscc/vb/vb_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/vb/vb_grammar.y,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- cscc/vb/vb_grammar.y 24 May 2007 13:51:15 -0000 1.5
+++ cscc/vb/vb_grammar.y 20 Sep 2007 20:04:17 -0000 1.6
@@ -1351,7 +1351,7 @@
(ILNode_BaseInit_create(), 0)));
ILNode *ctor =
ILNode_MethodDeclaration_create
(0,
VBModifiersToConstructorAttrs(cname, ctorMods, 0),
- 0 /* "void" */, cname,
+ 0 /* "void" */, cname, 0,
ILNode_Empty_create(), body);
if(!classBody)
{
@@ -1425,7 +1425,7 @@
(ILNode_BaseInit_create(), 0)));
ILNode *ctor =
ILNode_MethodDeclaration_create
(0,
VBModifiersToConstructorAttrs(cname, ctorMods, 0),
- 0 /* "void" */, cname,
+ 0 /* "void" */, cname, 0,
ILNode_Empty_create(), body);
if(!classBody)
{
@@ -1577,7 +1577,7 @@
$$ = ILNode_MethodDeclaration_create
($1, attrs,
ILNode_PrimitiveType_create
(IL_META_ELEMTYPE_VOID),
- $4, $5, $8);
+ $4, 0, $5, $8);
CloneLine($$, $4);
/* TODO: HandlesOrImplements clause */
}
@@ -1599,7 +1599,7 @@
funcattrs = CombineAttributes
($1, ILAttrTargetType_Return, $6.attrs);
$$ = ILNode_MethodDeclaration_create
- (funcattrs, attrs, $6.type, $4,
$5, $9);
+ (funcattrs, attrs, $6.type, $4,
0, $5, $9);
CloneLine($$, $4);
/* TODO: HandlesOrImplements clause */
}
@@ -1621,7 +1621,7 @@
$$ = ILNode_MethodDeclaration_create
($1, attrs,
ILNode_PrimitiveType_create
(IL_META_ELEMTYPE_VOID),
- $6, $9, 0);
+ $6, 0, $9, 0);
CloneLine($$, $6);
/* TODO: PInvoke information */
}
@@ -1639,7 +1639,7 @@
funcattrs = CombineAttributes
($1, ILAttrTargetType_Return,
$10.attrs);
$$ = ILNode_MethodDeclaration_create
- (funcattrs, attrs, $10.type,
$6, $9, 0);
+ (funcattrs, attrs, $10.type,
$6, 0, $9, 0);
CloneLine($$, $6);
/* TODO: PInvoke information */
}
@@ -1802,7 +1802,7 @@
else
{
$$.body =
ILNode_MethodDeclaration_create
- ($1, attrs, 0 /* "void" */,
cname, $5, body);
+ ($1, attrs, 0 /* "void" */,
cname, 0, $5, body);
CloneLine($$.body, $5);
$$.staticCtors = 0;
}
Index: csdoc/il2doc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/csdoc/il2doc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- csdoc/il2doc.c 1 Jul 2007 14:15:15 -0000 1.5
+++ csdoc/il2doc.c 20 Sep 2007 20:04:17 -0000 1.6
@@ -743,7 +743,7 @@
/* Dump the generic method parameters if necessary */
if(dumpGenerics && methodInfo)
{
- ILAsmDumpGenericParams(image, stream,
+ ILDAsmDumpGenericParams(image, stream,
ILToProgramItem(methodInfo), flags);
}
else if(withTypes)
Index: dumpasm/dump_class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/dumpasm/dump_class.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- dumpasm/dump_class.c 13 Aug 2007 17:53:48 -0000 1.4
+++ dumpasm/dump_class.c 20 Sep 2007 20:04:17 -0000 1.5
@@ -407,7 +407,7 @@
}
/* Dump the generic parameters, if any are present */
- ILAsmDumpGenericParams(image, outstream,
+ ILDAsmDumpGenericParams(image, outstream,
ILToProgramItem(info),
flags);
}
Index: dumpasm/dump_type.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/dumpasm/dump_type.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- dumpasm/dump_type.c 1 Jul 2007 14:15:16 -0000 1.16
+++ dumpasm/dump_type.c 20 Sep 2007 20:04:17 -0000 1.17
@@ -728,7 +728,7 @@
/* Dump the generic method parameters if necessary */
if(dumpGenerics && methodInfo)
{
- ILAsmDumpGenericParams(image, stream,
+ ILDAsmDumpGenericParams(image, stream,
ILToProgramItem(methodInfo), flags);
}
else if(withTypes)
Index: dumpasm/dump_utils.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/dumpasm/dump_utils.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- dumpasm/dump_utils.c 1 Jul 2007 14:15:16 -0000 1.2
+++ dumpasm/dump_utils.c 20 Sep 2007 20:04:17 -0000 1.3
@@ -186,7 +186,7 @@
}
}
-void ILAsmDumpGenericParams(ILImage *image, FILE *outstream,
+void ILDAsmDumpGenericParams(ILImage *image, FILE *outstream,
ILProgramItem *item,
int flags)
{
ILUInt32 genericNum, genParFlags;
Index: include/il_dumpasm.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_dumpasm.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- include/il_dumpasm.h 1 Jul 2007 14:15:17 -0000 1.12
+++ include/il_dumpasm.h 20 Sep 2007 20:04:17 -0000 1.13
@@ -216,7 +216,7 @@
/*
* Dump the generic parameters of a generic class or method.
*/
-void ILAsmDumpGenericParams(ILImage *image, FILE *outstream,
+void ILDAsmDumpGenericParams(ILImage *image, FILE *outstream,
ILProgramItem *item,
int flags);
/*
Index: image/class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/class.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- image/class.c 14 Sep 2007 00:55:43 -0000 1.39
+++ image/class.c 20 Sep 2007 20:04:18 -0000 1.40
@@ -1378,10 +1378,7 @@
return info->firstMember;
}
}
- else
- {
return 0;
- }
}
ILMember *ILClassNextMemberByKind(ILClass *info, ILMember *last, int kind)
Index: cscc/csharp/cs_lookup_member.c
===================================================================
RCS file: cscc/csharp/cs_lookup_member.c
diff -N cscc/csharp/cs_lookup_member.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cscc/csharp/cs_lookup_member.c 20 Sep 2007 20:04:16 -0000 1.1
@@ -0,0 +1,299 @@
+/*
+ * cs_lookup_member.c - Member lookup routines.
+ *
+ * Copyright (C) 2007 Southern Storm Software, Pty Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static ILMemPool _MemberInfoPool;
+
+struct _tagCSMemberInfo
+{
+ ILProgramItem *member;
+ ILClass *owner;
+ short kind;
+ short form;
+ CSMemberInfo *next;
+};
+
+struct _tagCSMemberLookupInfo
+{
+ int num;
+ CSMemberInfo *members;
+ CSMemberInfo *lastMember;
+};
+
+/*
+ * Iterator control structure for CSMemberLookupInfo.
+ */
+typedef struct
+{
+ CSMemberLookupInfo *info;
+ CSMemberInfo *current;
+ CSMemberInfo *last;
+
+} CSMemberLookupIter;
+
+/*
+ * Initialize a member results set.
+ */
+static void InitMembers(CSMemberLookupInfo *results)
+{
+ results->num = 0;
+ results->members = 0;
+ results->lastMember = 0;
+}
+
+/*
+ * Add a member to a results set.
+ */
+static void AddMember(CSMemberLookupInfo *results,
+ ILProgramItem *member, ILClass *owner,
+ int kind)
+{
+ CSMemberInfo *info;
+
+ /* Check to make sure that the member isn't already in the list.
+ This can happen when the same member is located along different
+ paths in an interface inheritance hierarchy */
+ info = results->members;
+ while(info != 0)
+ {
+ if(info->member == member)
+ {
+ return;
+ }
+ info = info->next;
+ }
+
+ /* Add the new member to the list */
+ info = (CSMemberInfo *)ILMemPoolAllocItem(&_MemberInfoPool);
+ if(!info)
+ {
+ CCOutOfMemory();
+ }
+ info->member = member;
+ info->owner = owner;
+ info->kind = kind;
+ info->form = 0;
+ info->next = 0;
+ if(results->lastMember)
+ {
+ results->lastMember->next = info;
+ }
+ else
+ {
+ results->members = info;
+ }
+ results->lastMember = info;
+ ++(results->num);
+}
+
+/*
+ * Free the contents of a member lookup results list.
+ */
+static void FreeMembers(CSMemberLookupInfo *results)
+{
+ CSMemberInfo *info, *next;
+ info = results->members;
+ while(info != 0)
+ {
+ next = info->next;
+ ILMemPoolFree(&_MemberInfoPool, info);
+ info = next;
+ }
+ results->num = 0;
+ results->members = 0;
+ results->lastMember = 0;
+}
+
+/*
+ * Initialize a member iterator.
+ */
+static void MemberIterInit(CSMemberLookupIter *iter,
+ CSMemberLookupInfo *results)
+{
+ iter->info = results;
+ iter->current = 0;
+ iter->last = 0;
+}
+
+/*
+ * Get the next item from a member iterator.
+ */
+static CSMemberInfo *MemberIterNext(CSMemberLookupIter *iter)
+{
+ if(iter->current)
+ {
+ iter->last = iter->current;
+ iter->current = iter->current->next;
+ }
+ else
+ {
+ iter->current = iter->info->members;
+ iter->last = 0;
+ }
+ return iter->current;
+}
+
+/*
+ * Remove the current item from a member iterator.
+ */
+static void MemberIterRemove(CSMemberLookupIter *iter)
+{
+ if(iter->current == iter->info->lastMember)
+ {
+ iter->info->lastMember = iter->last;
+ }
+ if(iter->last)
+ {
+ iter->last->next = iter->current->next;
+ ILMemPoolFree(&_MemberInfoPool, iter->current);
+ iter->current = iter->last;
+ }
+ else
+ {
+ iter->info->members = iter->current->next;
+ ILMemPoolFree(&_MemberInfoPool, iter->current);
+ iter->current = 0;
+ iter->last = 0;
+ }
+ --(iter->info->num);
+}
+
+/*
+ * Initialize the member lookup pool.
+ */
+void CSMemberInfoInit()
+{
+ ILMemPoolInit(&_MemberInfoPool, sizeof(CSMemberInfo), 10);
+}
+
+/*
+ * Destroy the member lookup pool.
+ */
+void CSMemberInfoDestroy()
+{
+ ILMemPoolDestroy(&_MemberInfoPool);
+}
+
+/*
+ * Free a member info item.
+ */
+void CSMemberInfoFree(CSMemberInfo *item)
+{
+ if(item)
+ {
+ ILMemPoolFree(&_MemberInfoPool, item);
+ }
+}
+
+void *CSCreateMethodGroup(ILMethod *method)
+{
+ CSMemberLookupInfo results;
+
+ /* Clear the results buffer */
+ InitMembers(&results);
+
+ /* Add the method as a group member */
+ AddMember(&results, ILToProgramItem(method),
+ ILMethod_Owner(method), IL_META_MEMBERKIND_METHOD);
+
+ /* Return the group to the caller */
+ return results.members;
+}
+
+ILProgramItem *CSGetGroupMember(void *group, unsigned long n)
+{
+ CSMemberInfo *member = (CSMemberInfo *)group;
+ while(member != 0)
+ {
+ if(n <= 0)
+ {
+ return (ILProgramItem *)(member->member);
+ }
+ --n;
+ member = member->next;
+ }
+ return 0;
+}
+
+void *CSRemoveGroupMember(void *group, unsigned long n)
+{
+ CSMemberInfo *member = (CSMemberInfo *)group;
+ CSMemberInfo *last = 0;
+ while(member != 0)
+ {
+ if(n <= 0)
+ {
+ if(last)
+ {
+ last->next = member->next;
+ ILMemPoolFree(&_MemberInfoPool, member);
+ return group;
+ }
+ else
+ {
+ last = member->next;
+ ILMemPoolFree(&_MemberInfoPool, member);
+ return (void *)last;
+ }
+ }
+ --n;
+ last = member;
+ member = member->next;
+ }
+ return group;
+}
+
+void CSSetGroupMemberForm(void *group, unsigned long n, int form)
+{
+ CSMemberInfo *member = (CSMemberInfo *)group;
+ while(member != 0)
+ {
+ if(n <= 0)
+ {
+ member->form = (short)form;
+ return;
+ }
+ --n;
+ member = member->next;
+ }
+}
+
+int CSGetGroupMemberForm(void *group, unsigned long n)
+{
+ CSMemberInfo *member = (CSMemberInfo *)group;
+ while(member != 0)
+ {
+ if(n <= 0)
+ {
+ return member->form;
+ }
+ --n;
+ member = member->next;
+ }
+ return 0;
+}
+
+#ifdef __cplusplus
+};
+#endif
Index: cscc/csharp/cs_lookup_member.h
===================================================================
RCS file: cscc/csharp/cs_lookup_member.h
diff -N cscc/csharp/cs_lookup_member.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cscc/csharp/cs_lookup_member.h 20 Sep 2007 20:04:16 -0000 1.1
@@ -0,0 +1,91 @@
+/*
+ * cs_lookup_member.h - Header file for member lookup routines.
+ *
+ * Copyright (C) 2007 Southern Storm Software, Pty Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _CSCC_CS_MEMBER_LOOKUP_H
+#define _CSCC_CS_MEMBER_LOOKUP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Extra member kinds.
+ */
+#define CS_MEMBERKIND_TYPE 20
+#define CS_MEMBERKIND_TYPE_NODE 21
+#define CS_MEMBERKIND_NAMESPACE 22
+
+/*
+ * A list of members that results from a lookup on a type.
+ */
+typedef struct _tagCSMemberLookupInfo CSMemberLookupInfo;
+
+/*
+ * A member that results from a member lookup.
+ */
+typedef struct _tagCSMemberInfo CSMemberInfo;
+
+/*
+ * Initialize the member lookup pool.
+ */
+void CSMemberInfoInit();
+
+/*
+ * Destroy the member lookup pool.
+ */
+void CSMemberInfoDestroy();
+
+/*
+ * Free a member info item.
+ */
+void CSMemberInfoFree(CSMemberInfo *item);
+
+/*
+ * Create a method group that contains a single method.
+ */
+void *CSCreateMethodGroup(ILMethod *method);
+
+/*
+ * Get the n'th member from a method or indexer group.
+ * Returns NULL at the end of the group.
+ */
+ILProgramItem *CSGetGroupMember(void *group, unsigned long n);
+
+/*
+ * Remove the n'th member from a method group.
+ * Returns the new group.
+ */
+void *CSRemoveGroupMember(void *group, unsigned long n);
+
+/*
+ * Set the candidate form for the n'th member of a method group.
+ */
+void CSSetGroupMemberForm(void *group, unsigned long n, int form);
+
+/*
+ * Get the candidate form for the n'th member of a method group.
+ */
+int CSGetGroupMemberForm(void *group, unsigned long n);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* _CSCC_CS_MEMBER_LOOKUP_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog codegen/cg_decls.tc codegen/cg_g...,
Klaus Treichel <=