dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 05eb1cc85637a8c48bf942442f407d2a985fddef
Date: Thu, 30 Jul 2009 19:00:57 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  05eb1cc85637a8c48bf942442f407d2a985fddef (commit)
      from  afb8696bbb49ebc188949cda7a0950d63d70e1b5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=05eb1cc85637a8c48bf942442f407d2a985fddef

commit 05eb1cc85637a8c48bf942442f407d2a985fddef
Author: Klaus Treichel <address@hidden>
Date:   Thu Jul 30 20:58:21 2009 +0200

    Store C# modifiers in the nodes instead of the attribute flags.
    Move lots of the semantic analysis logig from cs_grammar.y to cs_gather.c.

diff --git a/ChangeLog b/ChangeLog
index 9583d9b..bcc902d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,86 @@
+2009-07-30  Klaus Treichel  <address@hidden>
+
+       * cscc/csharp/cs_cast.tc (CSCastMethod): Use CS_MODIGIER_STATIC instead
+       of IL_META_METHODDEF_STATIC with the modifiers now.
+
+       * cscc/csharp/cs_decls.tc (AppendStaticCtor): Guard the initialization
+       with a SemGuard node if required.
+       (CheckStaticCtor): Add helper function to check for multiple static
+       constructors.
+       (CreateStaticCtorMethod): Move logic from
+       ILNode_SemAnalysis(ILNode_ClassDefn) to this helper function.
+       (HandleStaticCtor): Move logic from ILNode_SemAnalysis(ILNode_ClassDefn)
+       to this new helper function.
+       (CSAddInitCtor): Perform semantic analysis on the initialization
+       statement in the context of the class node where it is defined here.
+
+       * cscc/csharp/cs_gather.c (CloneLine): New helper function
+       (GetMemberVisibilityFromModifiers): likewise
+       (PrefixName): likewise
+       (GetImplicitParent): likewise.
+       (CollectBaseClasses): Move collecting the base classes and implemented
+       interfaces from AddBaseClases to this separate function.
+       (AddBaseClasses): see CollectBaseClasses.
+       (GetTypeAttrs): Add helper function for determining the correct type
+       attributes for an ILNode_ClassDefn (Logic moved from cs_grammar.y to 
here).
+       (CreateNestedTypes): Add helper function.
+       (AddTypeToList): likewise.
+       (AddDefaultCtor): Logic moved from cs_grammar.y to here.
+       (CreateType): Move handling of implicit parent classes from cs_grammar.y
+       to here. Use the new small helper functions CreateNestedTypec,
+       AddTypeToList) instead of having the logic inlined.
+       Creation of the default constructor moved to here.
+       (GetFieldAttrs): Add helper function for determining the correct field
+       attributes for an ILNode_FieldDeclaration (Logic moved from cs_grammar.y
+       to here).
+       (CreateField): Move check for static classes from cs_grammar.y to here.
+       (GetMethodAttrs): Add helper function for determining the correct method
+       attributes for an ILNode_MethodDeclaration (Logic moved from 
cs_grammar.y
+       to here).
+       (CreateMethod): Move check for static classes from cs_grammar.y to here.
+       (CreateProperty): Move check for static classes from cs_grammar.y to
+       here.
+       (GetEventAccessorModifiers): Add helper function for determining the
+       correct attributes for an event accessor.
+       (CreateEventDeclMethods): Moved to from cs_grammar.y to here.
+       (CreateEventMethods): likewise
+       (CreateEventDecl): Move check for static classes from cs_grammar.y to
+       here.
+       General: Use the new CS_MODIFIER_* flags instead of the metadata
+       attribute flags with the node modifiers members.
+       Pass the ClassDefn node to the Create* functions indtead of the 
classInfo.
+
+       * cscc/csharp/cs_grammar.y (GetAccessorAttrs): Rename to
+       GetAccessorModifiers to reflect the new purpose to return the accessor
+       modifiers instead of the attributes.
+       (CreatePropertyMethods): Rename attrs to modifiers and GetAccessorAttrs
+       and store the modigfiers in the ILNode_MethodDeclarations.
+       (CreateEventDeclMethods): Moved to cs_gather.c
+       (CreateEventMethods): likewise
+       (parser): Move the checks for static classes to the corresponding 
Create*
+       functions in cs_gather.c.
+       Move the modifier to attribute conversions to cs_gather.c and store the
+       C# modifiers in the modifiers member of the nodes instead.
+       Move the default constructor creation to cs_gather.c
+       Move adding the implicit base classes to cs_gather.c
+
+       * cscc/csharp/cs_internal.h: Add additional CS_MODIFIER_ flags used
+       during type gathering and semantic analysis.
+       (CSProcessAttrsForClass): Add prototype.
+
+       * cscc/csharp/cs_invoke.tc
+       (ILNode_SemAnalysis(ILNode_InvokationExpression),
+       DelegateCreationSem): likewise
+
+       * cscc/csharp/cs_lvalue.tc (CheckForInstanceAccess,
+       (ILNode_SemAnalysis(ILNode_This), ILNode_SemAnalysis(ILNode_Identifier),
+       ILNode_SemAnalysis(ILNode_BaseAccess),
+       ILNode_SemAnalysis(ILNode_BaseElement)): likewise
+
+       * cscc/csharp/cs_modifiers.c: Omit the CS_SPECIALATTR_* flags from the
+       returned attribute flags because the modifiers member holds the 
modifiers
+       from the source now instead of the type/member attributes.
+
 2009-07-25  Klaus Treichel  <address@hidden>
 
        * codegen/jv_misc.tc: Add operations JavaGenDiscard for  ILNode_AsIs
diff --git a/cscc/csharp/cs_cast.tc b/cscc/csharp/cs_cast.tc
index e9d2384..b460875 100644
--- a/cscc/csharp/cs_cast.tc
+++ b/cscc/csharp/cs_cast.tc
@@ -484,7 +484,7 @@ int CSCastMethod(ILGenInfo *info, ILNode *node, ILNode 
**parent,
 
                                caller = (ILNode_MethodDeclaration 
*)(info->currentMethod);
                                if(!caller || 
-                                       (caller->modifiers & 
IL_META_METHODDEF_STATIC) != 0)
+                                       (caller->modifiers & 
CS_MODIFIER_STATIC) != 0)
                                {
                                        /* Attempt to call an instance method 
using "this"
                                           from within a static method */
diff --git a/cscc/csharp/cs_decls.tc b/cscc/csharp/cs_decls.tc
index a64ded8..f71736a 100644
--- a/cscc/csharp/cs_decls.tc
+++ b/cscc/csharp/cs_decls.tc
@@ -82,19 +82,178 @@ static void CSListGatherStaticCtor(ILNode_List *node, 
ILNode_List *ctor)
  * the user specified static ctors after the ones from field decl
  */
 static void AppendStaticCtor(ILNode_List *collectedList, 
-                                                        ILNode_List *oldList)
+                                                        ILNode_List *oldList, 
int withSemGuard)
 {
-       ILNode_ListIter iter;
-       ILNode *curr;
-
-       if(!oldList)return;
+       if(!oldList)
+       {
+               return;
+       }
 
        if (yyisa(oldList, ILNode_List))
        {
-               ILNode_ListIter_Init(&iter,oldList);
+               ILNode_ListIter iter;
+               ILNode *curr;
+
+               ILNode_ListIter_Init(&iter, oldList);
                while((curr = ILNode_ListIter_Next(&iter)))
                {
-                       ILNode_List_Add(collectedList,curr);
+                       if(withSemGuard)
+                       {
+                               curr = ILNode_SemGuard_create(curr, 
CSSemValueDefault);
+                       }
+                       ILNode_List_Add(collectedList, curr);
+               }
+       }
+}
+
+/*
+ * Check for multiple explicit static constructors.
+ */
+static void CheckStaticCtor(ILNode *staticCtors, int hasStaticCtor)
+{
+       ILNode_ListIter iter;
+       ILNode *staticCtor;
+
+       ILNode_ListIter_Init(&iter, staticCtors);
+       if(!hasStaticCtor)
+       {
+               /* skip the first one */
+               if(!ILNode_ListIter_Next(&iter))
+               {
+                       return;
+               }
+       }
+       while((staticCtor = ILNode_ListIter_Next(&iter)) != NULL)
+       {
+               CCErrorOnLine(yygetfilename(staticCtor),
+                                         yygetlinenum(staticCtor),
+                                         "Cannot have more than one static 
constructor");
+       }
+}
+
+/*
+ * Create the static constructor method.
+ */
+static ILNode *CreateStaticCtorMethod(ILGenInfo *info, ILClass *classInfo)
+{
+       ILMethod *methodInfo;
+       ILType *signature;
+       ILNode *ctorMethod;
+
+       ctorMethod = ILNode_MethodDeclaration_create(0,
+                                                                               
                 CS_MODIFIER_STATIC |
+                                                                               
                 CS_MODIFIER_METHOD_CONSTRUCTOR,
+                                                                               
                 0 /* void */,
+                                                                               
                 ILQualIdentSimple(ILInternString(".cctor", 6).string),
+                                                                               
                 0 /* no type formals */,
+                                                                               
                 0 /* no parameters */,
+                                                                               
                 0 /* no body */);
+       methodInfo = ILMethodCreate(classInfo, 0, ".cctor",
+                                                               
IL_META_METHODDEF_PRIVATE |
+                                                               
IL_META_METHODDEF_STATIC |
+                                                               
IL_META_METHODDEF_HIDE_BY_SIG |
+                                                               
IL_META_METHODDEF_SPECIAL_NAME |
+                                                               
IL_META_METHODDEF_RT_SPECIAL_NAME);
+       if(!methodInfo)
+       {
+               CCOutOfMemory();
+       }
+       signature = ILTypeCreateMethod(info->context, ILType_Void);
+       if(!signature)
+       {
+               CCOutOfMemory();
+       }
+       ILMemberSetSignature((ILMember *)methodInfo, signature);
+       ((ILNode_MethodDeclaration *)(ctorMethod))->methodInfo = methodInfo;
+
+       return ctorMethod;
+}
+
+/*
+ * Handle static field declarations and constructors.
+ */
+static void HandleStaticCtor(ILGenInfo *info, ILNode_ClassDefn *node)
+{
+       ILNode *staticCtor;
+       ILNode_ClassDefn *ctorDefn;
+       ILNode *staticInitList;
+       ILNode *staticCtorsMethod;
+
+       /* First check if there is an explicit static constructor */
+       staticCtor = 0;
+       ctorDefn = 0;
+       staticCtorsMethod = 0;
+       if(node->staticCtors)
+       {
+               CheckStaticCtor(node->staticCtors, 0);
+               staticCtor = node->staticCtors;
+               ctorDefn = node;
+       }
+
+       /* Now collect the static fields with initialization */
+       staticInitList = ILNode_List_create();
+       ILNode_Declaration_GatherStaticCtor((ILNode_Declaration *)node->body,
+                                                                               
(ILNode_List *)staticInitList);
+
+       /* append the explicit static constructors to the end of the 
+          gathered list */
+       AppendStaticCtor((ILNode_List*)staticInitList,
+                                         (ILNode_List*)staticCtor, 0);
+
+       if(ILNode_List_Length(staticInitList) == 0)
+       {
+               /*  There were no static constructors after all  */
+               node->staticCtors = 0;
+       }
+       else
+       {
+               /* Create a method for the static constructors and
+                  then perform semantic analysis on its contents */
+               ILNode *savedClass;
+               ILNode *savedNamespace;
+               ILNode *savedMethod;
+
+               if(staticCtorsMethod == 0)
+               {
+                       staticCtorsMethod = CreateStaticCtorMethod(info, 
node->classInfo);
+               }
+               ((ILNode_MethodDeclaration *)staticCtorsMethod)->body =
+                                                                       
ILNode_NewScope_create(staticInitList);
+               node->staticCtorsMethod = staticCtorsMethod;
+
+               /*
+                * Perform semantic analysis on the cctor in the context of the
+                * explicit static constructor declaration.
+                */
+               if(!ctorDefn)
+               {
+                       ctorDefn = node;
+               }
+               savedClass = info->currentClass;
+               savedNamespace = info->currentNamespace;
+               savedMethod = info->currentMethod;
+               info->currentClass = (ILNode *)ctorDefn;
+               info->currentNamespace = ctorDefn->namespaceNode;
+               info->currentMethod = NULL;
+
+               ILNode_SemAnalysis(node->staticCtorsMethod, info,
+                                                  &(node->staticCtorsMethod));
+
+               info->currentClass = savedClass;
+               info->currentNamespace = savedNamespace;
+               info->currentMethod = savedMethod;
+
+               if(!staticCtor)
+               {
+                       /* The class contains static initializers for fields, 
but no
+                          explicit static constructor.  Add the 
"beforefieldinit"
+                          flag to the set of modifiers */
+                       if(node->classInfo)
+                       {
+                               ILClassSetAttrs(node->classInfo,
+                                                               
IL_META_TYPEDEF_BEFORE_FIELD_INIT,
+                                                               
IL_META_TYPEDEF_BEFORE_FIELD_INIT);
+                       }
                }
        }
 }
@@ -113,10 +272,6 @@ ILNode_SemAnalysis(ILNode_ClassDefn)
        ILNode *savedClass;
        ILNode *savedNamespace;
        ILNode *savedMethod;
-       ILNode *staticCtorList=NULL;
-       ILNode_ListIter iter;
-       ILNode *staticCtor;
-       int hadStaticCtorsBefore;
        int target;
 
        /* Determine if we have already visited this node */
@@ -190,8 +345,7 @@ ILNode_SemAnalysis(ILNode_ClassDefn)
 #endif /* IL_VERSION_MAJOR > 1 */
 
        /* Perform semantic analysis on the node */
-       hadStaticCtorsBefore = (node->staticCtors != 0);
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeEnter(info, (ILNode *)node, "unsafe class declaration");
        }
@@ -211,84 +365,13 @@ ILNode_SemAnalysis(ILNode_ClassDefn)
                                                           
&(node->initCtorsMethod));
                }
 
-               /*  save the explicit static constructors before gathering  */
-               if (node->staticCtors)
-               {
-                       if(ILNode_List_Length(node->staticCtors)>1)
-                       {
-                               ILNode_ListIter_Init(&iter, node->staticCtors);
-                               ILNode_ListIter_Next(&iter); /* skip the first 
*/
-                               
while((staticCtor=ILNode_ListIter_Next(&iter))!=NULL)
-                               {
-                                       CCErrorOnLine(yygetfilename(staticCtor),
-                                                                       
yygetlinenum(staticCtor), 
-                                                                       "Cannot 
have more than one static "
-                                                                       
"constructor");
-                               }
-                       }
-                       staticCtorList=node->staticCtors;
-               }
-
-               node->staticCtors=ILNode_List_create();
+               /* Create the static constructor */
+               HandleStaticCtor(info, node);
 
-               ILNode_Declaration_GatherStaticCtor
-                                                               (   
(ILNode_Declaration *)node->body, 
-                                                                       
(ILNode_List *)node->staticCtors);
-
-               /* append the explicit static constructors to the end of the 
-                  gathered list */
-               AppendStaticCtor((ILNode_List*)node->staticCtors,
-                                                 (ILNode_List*) 
staticCtorList);
-
-               staticCtorList=NULL; /* do not use it again or segfault :-) */
-
-               if (ILNode_List_Length(node->staticCtors) == 0)
-               {
-                       /*  There were no static constructors after all  */
-                       node->staticCtors = 0;
-               }
-               else
-               {
-                       /* Create a method for the static constructors and
-                          then perform semantic analysis on its contents */
-                       ILMethod *methodInfo;
-                       ILType *signature;
-                       node->staticCtorsMethod =
-                               ILNode_MethodDeclaration_create
-                                       (0, IL_META_METHODDEF_PRIVATE |
-                                               IL_META_METHODDEF_STATIC |
-                                               IL_META_METHODDEF_HIDE_BY_SIG |
-                                               IL_META_METHODDEF_SPECIAL_NAME |
-                                               
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",
-                                                                               
IL_META_METHODDEF_PRIVATE |
-                                                                               
IL_META_METHODDEF_STATIC |
-                                                                               
IL_META_METHODDEF_HIDE_BY_SIG |
-                                                                               
IL_META_METHODDEF_SPECIAL_NAME |
-                                                                               
IL_META_METHODDEF_RT_SPECIAL_NAME);
-                       if(!methodInfo)
-                       {
-                               CCOutOfMemory();
-                       }
-                       signature = ILTypeCreateMethod(info->context, 
ILType_Void);
-                       if(!signature)
-                       {
-                               CCOutOfMemory();
-                       }
-                       ILMemberSetSignature((ILMember *)methodInfo, signature);
-                       ((ILNode_MethodDeclaration *)(node->staticCtorsMethod))
-                                       ->methodInfo = methodInfo;
-                       ILNode_SemAnalysis(node->staticCtorsMethod, info,
-                                                          
&(node->staticCtorsMethod));
-               }
                info->currentClass = savedClass;
                info->currentNamespace = savedNamespace;
                info->currentMethod = savedMethod;
+
        }
        else
        {
@@ -300,23 +383,10 @@ ILNode_SemAnalysis(ILNode_ClassDefn)
                ILGenImplementsAllInterfaces(info, (ILNode *)node, 
node->classInfo,
                                                                         
InterfaceErrorFunc, InterfaceProxyFunc);
        }
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeLeave(info);
        }
-       if(!hadStaticCtorsBefore && node->staticCtors)
-       {
-               /* The class contains static initializers for fields, but no
-                  explicit static constructor.  Add the "beforefieldinit"
-                  flag to the set of modifiers */
-               node->modifiers |= IL_META_TYPEDEF_BEFORE_FIELD_INIT;
-               if(node->classInfo)
-               {
-                       ILClassSetAttrs(node->classInfo,
-                                                       
IL_META_TYPEDEF_BEFORE_FIELD_INIT,
-                                                       
IL_META_TYPEDEF_BEFORE_FIELD_INIT);
-               }
-       }
 
        /* We have finished processing this node */
        node->visited = ILVisitMode_Done;
@@ -630,6 +700,9 @@ void CSAddInitCtor(ILGenInfo *info, ILNode *stmt)
        ILNode *bodyList;
        if(defn && stmt)
        {
+               CSSemValue value;
+               ILNode *savedMethod;
+
                /* Construct the method declaration for ".init" if necessary.
                   Note: the ".init" method is a pseudo method to collect up
                   all non-static field initializers.  It isn't output into
@@ -642,8 +715,8 @@ void CSAddInitCtor(ILGenInfo *info, ILNode *stmt)
                        bodyList = ILNode_Compound_create();
                        defn->initCtorsMethod =
                                ILNode_MethodDeclaration_create
-                                       (0, IL_META_METHODDEF_PRIVATE |
-                                               IL_META_METHODDEF_HIDE_BY_SIG,
+                                       (0, CS_MODIFIER_PRIVATE |
+                                               CS_MODIFIER_METHOD_CONSTRUCTOR,
                                         0 /* void */,
                                         
ILQualIdentSimple(ILInternString(".init", 5).string),
                                         0 /* no type formals */,
@@ -674,6 +747,20 @@ void CSAddInitCtor(ILGenInfo *info, ILNode *stmt)
                        bodyList = ((ILNode_NewScope *)bodyList)->stmt;
                }
 
+               /* Perform semantic analysis on the statement */
+               /*
+                * FIXME: Allow statements to be semanalyzed without having a
+                * current method.
+                * We are using ine .init method for now.
+                */
+               savedMethod = info->currentMethod;
+               info->currentMethod = defn->initCtorsMethod;
+               value = ILNode_SemAnalysis(stmt, info, &stmt);
+               info->currentMethod =  savedMethod;
+
+               /* Guard the statement from further semantic analysis */
+               stmt = ILNode_SemGuard_create(stmt, value);
+
                /* Wrap the statement in a scope and add it to the body */
                ILNode_List_Add(bodyList, ILNode_NewScope_create(stmt));
        }
@@ -690,9 +777,9 @@ ILNode_SemAnalysis(ILNode_FieldDeclaration)
        ILNode *decl;
 
        /* Enter an unsafe context for the field if necessary */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
-               if((node->modifiers & IL_META_FIELDDEF_LITERAL) != 0)
+               if((node->modifiers & CS_MODIFIER_FIELD_CONST) != 0)
                {
                        CCUnsafeEnter(info, (ILNode *)node, "unsafe constant 
declaration");
                }
@@ -716,7 +803,7 @@ ILNode_SemAnalysis(ILNode_FieldDeclaration)
        }
 
        /* Leave the unsafe context for the field */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeLeave(info);
        }
@@ -776,9 +863,10 @@ ILNode_SemAnalysis(ILNode_FieldDeclarator)
        info->currentMethod=NULL;
 
        /* Non-static fields are initialized differently */
-       if(node->owner && (node->owner->modifiers & IL_META_FIELDDEF_STATIC) == 
0)
+       if(node->owner &&
+          (node->owner->modifiers & (CS_MODIFIER_STATIC | 
CS_MODIFIER_FIELD_CONST)) == 0)
        {
-               /* non-static field initializers are not allowed in structs */  
 
+               /* non-static field initializers are not allowed in structs */
                if(ILClassIsValueType(((ILNode_ClassDefn 
*)info->currentClass)->classInfo))
                {
                        if (node->initializer != NULL)
@@ -799,7 +887,7 @@ ILNode_SemAnalysis(ILNode_FieldDeclarator)
        }
 
        /* If this is a constant, then evaluate the value */
-       if(node->owner && (node->owner->modifiers & IL_META_FIELDDEF_LITERAL) 
!= 0)
+       if(node->owner && (node->owner->modifiers & CS_MODIFIER_FIELD_CONST) != 
0)
        {
                /* Perform semantic analysis on the initializer value */
                value = ILNode_SemAnalysis(node->initializer, info,
@@ -860,10 +948,6 @@ ILNode_SemAnalysis(ILNode_FieldDeclarator)
                node->initializer = ILNode_SemGuard_create(node->initializer, 
value);
        }
 
-       /* Add a statement to the static constructor to initialize the field */
-       /*      CSAddStaticCtor(info,  
-                        ILNode_Assign_create(node->name, node->initializer)); 
*/
-
        initializer=ILNode_Assign_create(node->name, node->initializer);
        yysetfilename(initializer,yygetfilename(node));
        yysetlinenum(initializer,yygetlinenum(node));
@@ -887,7 +971,7 @@ ILNode_SemAnalysis(ILNode_EventDeclaration)
        CSSemValue value = CSSemValueDefault;
 
        /* Enter an unsafe context for the event field if necessary */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeEnter(info, (ILNode *)node, "unsafe event declaration");
        }
@@ -903,7 +987,7 @@ ILNode_SemAnalysis(ILNode_EventDeclaration)
                                           &(node->eventDeclarators));
 
        /* Leave the unsafe context for the event field */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeLeave(info);
        }
@@ -1004,7 +1088,7 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
        info->currentMethod = (ILNode *)node;
 
        /* Enter an unsafe context for the method if necessary */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeEnter(info, (ILNode *)node, "unsafe method 
declaration");
        }
@@ -1031,7 +1115,7 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
        }
 
        /* Declare the parameters into the method's local variable scope */
-       if((node->modifiers & IL_META_METHODDEF_STATIC) == 0)
+       if((node->modifiers & CS_MODIFIER_STATIC) == 0)
        {
                /* Non-static parameters start at argument 1 */
                argNum = 1;
@@ -1078,11 +1162,13 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
        }
 
        /* If the method is abstract, then the class must be too */
-       if((node->modifiers & IL_META_METHODDEF_ABSTRACT) != 0)
+       if((node->modifiers & CS_MODIFIER_ABSTRACT) != 0)
        {
                if(info->currentClass &&
-                  (((ILNode_ClassDefn *)(info->currentClass))->modifiers &
-                                       IL_META_TYPEDEF_ABSTRACT) == 0)
+                  ((((ILNode_ClassDefn *)(info->currentClass))->modifiers &
+                                       CS_MODIFIER_ABSTRACT) == 0) &&
+                       ((((ILNode_ClassDefn *)(info->currentClass))->modifiers 
&
+                                       CS_MODIFIER_TYPE_MASK) != 
CS_MODIFIER_TYPE_INTERFACE))
                {
                        CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                  "`abstract' used on a member in a 
non-abstract class");
@@ -1105,12 +1191,12 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
                                node->body = ILNode_Empty_create();
                        }
                }
-               if((node->modifiers & IL_META_METHODDEF_ABSTRACT) != 0)
+               if((node->modifiers & CS_MODIFIER_ABSTRACT) != 0)
                {
                        CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                                  "`abstract' cannot be used 
with a method body");
                }
-               if((node->modifiers & CS_SPECIALATTR_EXTERN) != 0)
+               if((node->modifiers & CS_MODIFIER_EXTERN) != 0)
                {
                        CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                                  "`extern' cannot be used with 
a method body");
@@ -1120,8 +1206,9 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
                ILNode_SemAnalysis(node->body, info, &(node->body));
                info->currentScope = savedScope;
        }
-       else if((node->modifiers & CS_SPECIALATTR_EXTERN) == 0 &&
-                       (node->modifiers & IL_META_METHODDEF_ABSTRACT) == 0)
+       else if(((node->modifiers & (CS_MODIFIER_EXTERN | 
CS_MODIFIER_ABSTRACT)) == 0) &&
+                       ((node->modifiers & CS_MODIFIER_METHOD_TYPE_MASK) != 
CS_MODIFIER_METHOD_INTERFACE) &&
+                       ((node->modifiers & CS_MODIFIER_METHOD_TYPE_MASK) != 
CS_MODIFIER_METHOD_INTERFACE_ACCESSOR))
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                          "method with no body requires `abstract' or 
`extern'");
@@ -1147,18 +1234,18 @@ ILNode_SemAnalysis(ILNode_MethodDeclaration)
           within the "<Module>" class, then suppress code generation.
           Such methods are imported from a foreign C module, and
           should not be generated from the C# application */
-       if((node->modifiers & CS_SPECIALATTR_EXTERN) != 0)
+       if((node->modifiers & CS_MODIFIER_EXTERN) != 0)
        {
                if(info->currentClass &&
                   !strcmp(((ILNode_ClassDefn *)(info->currentClass))->name,
-                                  "<Module>"))
+                                  "<Module>"))
                {
                        node->suppressCodeGen = 1;
                }
        }
 
        /* Leave the unsafe context for the method */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeLeave(info);
        }
@@ -1193,7 +1280,7 @@ ILNode_SemAnalysis(ILNode_PropertyDeclaration)
                                   node->attributes, 
IL_ATTRIBUTE_TARGET_PROPERTY);
 
        /* Enter an unsafe context for the property if necessary */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeEnter(info, (ILNode *)node, "unsafe property 
declaration");
        }
@@ -1215,7 +1302,7 @@ ILNode_SemAnalysis(ILNode_PropertyDeclaration)
        }
 
        /* Leave the unsafe context for the property */
-       if((node->modifiers & CS_SPECIALATTR_UNSAFE) != 0)
+       if((node->modifiers & CS_MODIFIER_UNSAFE) != 0)
        {
                CCUnsafeLeave(info);
        }
diff --git a/cscc/csharp/cs_gather.c b/cscc/csharp/cs_gather.c
index eeab572..6493df3 100644
--- a/cscc/csharp/cs_gather.c
+++ b/cscc/csharp/cs_gather.c
@@ -45,6 +45,15 @@ semantic analysis.
 */
 
 /*
+ * Clone the filename/linenum information from one node to another.
+ */
+static void CloneLine(ILNode *dest, ILNode *src)
+{
+       yysetfilename(dest, yygetfilename(src));
+       yysetlinenum(dest, yygetlinenum(src));
+}
+
+/*
  * Count the number of classes in a base class list.
  */
 static int CountBaseClasses(ILNode *node)
@@ -82,6 +91,79 @@ static ILClass *NodeToClass(ILNode *node)
 #define NodeToProgramItem(node)        ILToProgramItem(NodeToClass(node))
 
 /*
+ * Get the member visibility for the modifiers.
+ */
+static ILUInt32 GetMemberVisibilityFromModifiers(ILUInt32 modifiers)
+{
+       switch(modifiers & CS_MODIFIER_ACCESS_MASK)
+       {
+               case CS_MODIFIER_PUBLIC:
+               {
+                       return IL_META_METHODDEF_PUBLIC;
+               }
+               break;
+
+               case CS_MODIFIER_PRIVATE:
+               {
+                       return IL_META_METHODDEF_PRIVATE;
+               }
+               break;
+
+               case CS_MODIFIER_PROTECTED:
+               {
+                       return IL_META_METHODDEF_FAMILY;
+               }
+               break;
+
+               case CS_MODIFIER_INTERNAL:
+               {
+                       return IL_META_METHODDEF_ASSEM;
+               }
+               break;
+
+               case (CS_MODIFIER_PROTECTED | CS_MODIFIER_INTERNAL):
+               {
+                       return IL_META_METHODDEF_FAM_OR_ASSEM;
+               }
+               break;
+       }
+       return IL_META_METHODDEF_PRIVATE;
+}
+
+/*
+ * Adjust the name of a property to include a "get_" or "set_" prefix.
+ */
+static ILNode *PrefixName(ILNode *name, char *prefix)
+{
+       ILNode *node;
+       if(yykind(name) == yykindof(ILNode_Identifier))
+       {
+               /* Simple name: just add the prefix */
+               node = ILQualIdentSimple
+                                       (ILInternAppendedString
+                                               (ILInternString(prefix, 
strlen(prefix)),
+                                                
ILInternString(ILQualIdentName(name, 0), -1)).string);
+               CloneLine(node, name);
+               return node;
+       }
+       else if(yykind(name) == yykindof(ILNode_QualIdent))
+       {
+               /* Qualified name: add the prefix to the second component */
+               node = ILNode_QualIdent_create(((ILNode_QualIdent *)name)->left,
+                                       (ILInternAppendedString
+                                               (ILInternString(prefix, 
strlen(prefix)),
+                                                
ILInternString(((ILNode_QualIdent *)name)->name, -1)).string));
+               CloneLine(node, name);
+               return node;
+       }
+       else
+       {
+               /* Shouldn't happen */
+               return name;
+       }
+}
+
+/*
  * Get the full and basic names from a method/property/event name.
  */
 static const char *GetFullAndBasicNames(ILNode *name, const char **basicName)
@@ -365,6 +447,31 @@ static void AddGenericParametersToClass(ILGenInfo *info, 
ILNode *classDefn)
 }
 #endif /* IL_VERSION_MAJOR > 1 */
 
+static ILNode *GetImplicitParent(ILNode_ClassDefn *defn)
+{
+       switch(defn->modifiers & CS_MODIFIER_TYPE_MASK)
+       {
+               case CS_MODIFIER_TYPE_STRUCT:
+               {
+                       return 
ILNode_GlobalNamespace_create(ILNode_SystemType_create("ValueType"));
+               }
+               break;
+
+               case CS_MODIFIER_TYPE_ENUM:
+               {
+                       return 
ILNode_GlobalNamespace_create(ILNode_SystemType_create("Enum"));
+               }
+               break;
+
+               case CS_MODIFIER_TYPE_DELEGATE:
+               {
+                       return 
ILNode_GlobalNamespace_create(ILNode_SystemType_create("MulticastDelegate"));
+               }
+               break;
+       }
+       return 0;
+}
+
 static void AddObjectParent(ILGenInfo *info,
                                                        ILNode_ClassDefn 
*classNode,
                                                        ILClass *classInfo,
@@ -419,184 +526,230 @@ static void AddObjectParent(ILGenInfo *info,
        }
 }
 
-static void AddBaseClasses(ILGenInfo *info,
-                                                  ILNode_ClassDefn *classNode,
-                                                  ILNode *systemObjectName)
+/*
+ * Collect the base classes for one class definition.
+ * The implement list must be large enough to hold all implemented
+ * interfaces of this class definition.
+ */
+static void CollectBaseClasses(ILGenInfo *info,
+                                                          ILNode_ClassDefn 
*defn,
+                                                          ILProgramItem 
**parent,
+                                                          ILProgramItem 
**implementList,
+                                                          ILUInt32 
*numImplements,
+                                                          int baseClassAllowed)
 {
+       int errorReported;
+       ILUInt32 currentBase;
+       ILUInt32 currentImpl;
        ILNode *savedNamespace;
        ILNode *savedClass;
-       ILClass *classInfo = classNode->classInfo;
+       ILNode *baseNode;
+       ILNode *baseNodeList;
+
+       *parent = 0;
+       errorReported = 0;
 
        /* Set the namespace and class to use for resolving type names */
        savedNamespace = info->currentNamespace;
-       info->currentNamespace = classNode->namespaceNode;
        savedClass = info->currentClass;
-       info->currentClass = (ILNode *)classNode;
+       info->currentNamespace = defn->namespaceNode;
+       info->currentClass = (ILNode *)defn;
 
-       if(classInfo && (classInfo != (ILClass *)1) &&
-                                       (classInfo != (ILClass *)2))
+       currentImpl = 0;
+       baseNodeList = defn->baseClass;
+       for(currentBase = 0; currentBase < *numImplements; ++currentBase)
        {
-               ILProgramItem *parent = 0;
-               int numBases = CountBaseClasses(classNode->baseClass);
+               ILNode *baseTypeNode;
+               ILProgramItem *baseItem;
 
-               if(numBases > 0)
+               /* Get the name of the class to be inherited or implemented */
+               if(yykind(baseNodeList) == yykindof(ILNode_ArgList))
                {
-                       if(!strcmp(ILClass_Name(classInfo), "<Module>"))
-                       {
-                               CCErrorOnLine(yygetfilename(classNode), 
yygetlinenum(classNode),
-                                                         "Modules must not 
have any base type specifications");
-                               numBases = 0;
-                       }
+                       baseNode = ((ILNode_ArgList *)baseNodeList)->expr2;
+                       baseNodeList = ((ILNode_ArgList *)baseNodeList)->expr1;
+               }
+               else
+               {
+                       baseNode = baseNodeList;
                }
 
-               if(numBases > 0)
+               baseItem = 0;
+               /* Look in the scope for the base class */
+               if(CSSemBaseType(baseNode, info, &baseNode,
+                                                &baseTypeNode, &baseItem))
                {
-                       int base;
-                       ILNode *baseNode;
-                       ILNode *baseNodeList;
-                       int errorReported = 0;
-                       ILProgramItem *baseList[numBases];
+                       /* All class nodes should have a valid classinfo at
+                          this point. */
+                       if(baseItem == 0)
+                       {
+                               baseItem = NodeToProgramItem(baseTypeNode);
 
-                       ILMemZero(baseList, numBases * sizeof(ILClass *));
+                               if(baseItem == 0)
+                               {
+                                       /* This is not a valid base class 
specification */
+                                       CCErrorOnLine(yygetfilename(baseNode), 
yygetlinenum(baseNode),
+                                                                 "invalid base 
type");
+                               }
+                       }
 
-                       baseNodeList = classNode->baseClass;
-                       for(base = 0; base < numBases; ++base)
+                       if(baseItem)
                        {
-                               ILNode *baseTypeNode;
+                               ILClass *underlying;
 
-                               /* Get the name of the class to be inherited or 
implemented */
-                               if(yykind(baseNodeList) == 
yykindof(ILNode_ArgList))
+                               underlying = 
ILProgramItemToUnderlyingClass(baseItem);
+                               if(underlying)
                                {
-                                       baseNode = ((ILNode_ArgList 
*)baseNodeList)->expr2;
-                                       baseNodeList = ((ILNode_ArgList 
*)baseNodeList)->expr1;
+                                       underlying = ILClassResolve(underlying);
                                }
-                               else
+                               if(!underlying)
                                {
-                                       baseNode = baseNodeList;
+                                       CCOutOfMemory();
                                }
-
-                               /* Look in the scope for the base class */
-                               if(CSSemBaseType(baseNode, info, &baseNode,
-                                                                &baseTypeNode, 
&(baseList[base])))
+                               if(currentBase == 0)
                                {
-                                       /* All class nodes should have a valid 
classinfo at
-                                          this point. */
-                                       if(baseList[base] == 0)
+                                       /* Handle the first item in the base 
list */
+                                       if(!ILClass_IsInterface(underlying))
                                        {
-                                               baseList[base] = 
NodeToProgramItem(baseTypeNode);
-
-                                               if(baseList[base] == 0)
+                                               if(baseClassAllowed)
                                                {
-                                                       /* This is not a valid 
base class specification */
-                                                       
CCErrorOnLine(yygetfilename(baseNode), yygetlinenum(baseNode),
-                                                                               
  "invalid base type");
+                                                       *parent = baseItem;
                                                }
-                                       }
-
-                                       if(baseList[base])
-                                       {
-                                               ILClass *underlying;
-
-                                               underlying = 
ILProgramItemToUnderlyingClass(baseList[base]);
-                                               if(underlying)
-                                               {
-                                                       underlying = 
ILClassResolve(underlying);
-                                               }
-                                               if(!underlying)
+                                               else
                                                {
-                                                       CCOutOfMemory();
+                                                       
CCErrorOnLine(yygetfilename(baseNode),
+                                                                               
  yygetlinenum(baseNode),
+                                                                               
  "base class not allowed in this scope");
+
                                                }
-                                               if(base == 0)
+                                       }
+                                       else
+                                       {
+                                               /* First base in the list is an 
interface */
+                                               implementList[currentImpl++] = 
baseItem;
+                                       }
+                               }
+                               else
+                               {
+                                       if(!ILClass_IsInterface(underlying))
+                                       {
+                                               /*
+                                                * Non interface class found 
later in the base list.
+                                                */
+                                               if(!parent)
                                                {
-                                                       /* Handle the first 
item in the base list */
-                                                       
if(!ILClass_IsInterface(underlying))
+                                                       
CCErrorOnLine(yygetfilename(defn),
+                                                                               
  yygetlinenum(defn),
+                                                         "base class must be 
the first class in the base list");
+                                                       if(baseClassAllowed)
                                                        {
-                                                               
if(ILClass_IsInterface(classInfo))
-                                                               {
-                                                                       /*
-                                                                        * 
Interfaces must not have non interface
-                                                                        * 
classes in the base list.
-                                                                        */
-                                                                       
CCErrorOnLine(yygetfilename(classNode),
-                                                                               
                  yygetlinenum(classNode),
-                                                                       
"interface inherits from non-interface class");
-                                                                       
errorReported = 1;
-                                                               }
-                                                               else
-                                                               {
-                                                                       
if(ILClass_IsSealed(underlying))
-                                                                       {
-                                                                               
CCErrorOnLine(yygetfilename(classNode),
-                                                                               
                          yygetlinenum(classNode),
-                                                                         
"inheriting from a sealed parent class");
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               
ILClassSetParent(classInfo, baseList[base]);
-                                                                       }
-                                                               }
-                                                               parent = 
baseList[base];
-                                                               baseList[base] 
= 0;
-                                                       }
-                                                       else
-                                                       {
-                                                               /* First base 
in the list is an interface */
-                                                               
if(!ILClass_IsInterface(classInfo))
-                                                               {
-                                                                       /* We 
have to add the System.Object parent */
-                                                                       
AddObjectParent(info, classNode,
-                                                                               
                        classInfo,
-                                                                               
                        systemObjectName);
-                                                               }
+                                                               *parent = 
baseItem;
                                                        }
                                                }
                                                else
                                                {
-                                                       
if(!ILClass_IsInterface(underlying))
+                                                       if(!errorReported)
                                                        {
-                                                               /*
-                                                                * Non 
interface class found later in the base list.
-                                                                */
-                                                               
if(ILClass_IsInterface(classInfo))
-                                                               {
-                                                                       
if(!errorReported)
-                                                                       {
-                                                                               
CCErrorOnLine(yygetfilename(classNode),
-                                                                               
                          yygetlinenum(classNode),
-                                                                         
"interface inherits from non-interface classes");
-                                                                               
errorReported = 1;
-                                                                       }
-                                                               }
-                                                               else
-                                                               {
-                                                                       
if(!parent)
-                                                                       {
-                                                                               
CCErrorOnLine(yygetfilename(classNode),
-                                                                               
                          yygetlinenum(classNode),
-                                                                               
  "base class must be the first class in the base list");
-                                                                               
parent = baseList[base];
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               
if(!errorReported)
-                                                                               
{
-                                                                               
        CCErrorOnLine(yygetfilename(classNode),
-                                                                               
                                  yygetlinenum(classNode),
-                                                                               
  "class inherits from two or more non-interface classes");
-                                                                               
        errorReported = 1;
-                                                                               
}
-                                                                       }
-                                                               }
-                                                               baseList[base] 
= 0;
+                                                               
CCErrorOnLine(yygetfilename(defn),
+                                                                               
          yygetlinenum(defn),
+                                                               "more than one 
non-interface classes in the base class list");
+                                                               errorReported = 
1;
                                                        }
                                                }
                                        }
+                                       else
+                                       {
+                                               implementList[currentImpl++] = 
baseItem;
+                                       }
+                               }
+                       }
+               }
+               else
+               {
+                       /* This is not a valid base class specification */
+                       CCErrorOnLine(yygetfilename(baseNode), 
yygetlinenum(baseNode),
+                                                 "invalid base type");
+               }
+       }
+
+       /* Restore the namespace, class */
+       info->currentNamespace = savedNamespace;
+       info->currentClass = savedClass;
+
+       *numImplements = currentImpl;
+}
+
+static void AddBaseClasses(ILGenInfo *info,
+                                                  ILNode_ClassDefn *classNode,
+                                                  ILNode *systemObjectName)
+{
+       ILClass *classInfo = classNode->classInfo;
+
+       if(classInfo && (classInfo != (ILClass *)1) &&
+                                       (classInfo != (ILClass *)2))
+       {
+               int baseClassAllowed;
+               ILProgramItem *parent = 0;
+               ILUInt32 numBases = CountBaseClasses(classNode->baseClass);
+
+               /* Only classes can have an explicit  base class */
+               baseClassAllowed = ((classNode->modifiers & 
CS_MODIFIER_TYPE_MASK) ==
+                                                  CS_MODIFIER_TYPE_CLASS);
+               if(numBases > 0)
+               {
+                       if(!strcmp(ILClass_Name(classInfo), "<Module>"))
+                       {
+                               CCErrorOnLine(yygetfilename(classNode), 
yygetlinenum(classNode),
+                                                         "Modules must not 
have any base type specifications");
+                               numBases = 0;
+                       }
+               }
+
+               if(numBases > 0)
+               {
+                       int base;
+                       ILProgramItem *baseList[numBases];
+
+                       ILMemZero(baseList, numBases * sizeof(ILClass *));
+
+                       numBases = CountBaseClasses(classNode->baseClass);
+                       if(numBases > 0)
+                       {
+                               CollectBaseClasses(info, classNode, &parent, 
baseList,
+                                                                  &numBases, 
baseClassAllowed);
+                       }
+
+                       if(parent)
+                       {
+                               if(ILClass_IsInterface(classInfo))
+                               {
+                                       CCErrorOnLine(yygetfilename(classNode),
+                                                                 
yygetlinenum(classNode),
+                                       "interface inherits from non-interface 
class");
                                }
                                else
                                {
-                                       /* This is not a valid base class 
specification */
-                                       CCErrorOnLine(yygetfilename(baseNode), 
yygetlinenum(baseNode),
-                                                                 "invalid base 
type");
+                                       ILClass *underlying;
+
+                                       underlying = 
ILProgramItemToUnderlyingClass(parent);
+                                       if(underlying)
+                                       {
+                                               underlying = 
ILClassResolve(underlying);
+                                       }
+                                       if(!underlying)
+                                       {
+                                               CCOutOfMemory();
+                                       }
+                                       if(ILClass_IsSealed(underlying))
+                                       {
+                                               
CCErrorOnLine(yygetfilename(classNode),
+                                                                         
yygetlinenum(classNode),
+                                         "inheriting from a sealed parent 
class");
+                                       }
+                                       else
+                                       {
+                                               /* Set the parent of the class 
*/
+                                               ILClassSetParent(classInfo, 
parent);
+                                       }
                                }
                        }
 
@@ -612,14 +765,11 @@ static void AddBaseClasses(ILGenInfo *info,
                                }
                        }
                }
-               else
+
+               if(!parent && baseClassAllowed)
                {
-                       if(!ILClass_IsInterface(classInfo) && 
-                          (strcmp(ILClass_Name(classInfo), "<Module>") != 0))
-                       {
-                               /* We have to add the System.Object parent */
-                               AddObjectParent(info, classNode, classInfo, 
systemObjectName);
-                       }
+                       /* We have to add the System.Object parent */
+                       AddObjectParent(info, classNode, classInfo, 
systemObjectName);
                }
        }
        else
@@ -628,10 +778,6 @@ static void AddBaseClasses(ILGenInfo *info,
                                          "class not completely layed out");
        }
 
-       /* Restore the namespace, class, and type formals */
-       info->currentNamespace = savedNamespace;
-       info->currentClass = savedClass;
-
        /* Now process the nested classes */
        if(classNode->nestedClasses)
        {
@@ -651,6 +797,216 @@ static void AddBaseClasses(ILGenInfo *info,
        }
 }
 
+static ILUInt32 GetTypeAttrs(ILGenInfo *info, ILNode_ClassDefn *defn)
+{
+       ILUInt32 attrs;
+
+       /* Validate the modifiers */
+       if((defn->modifiers & CS_MODIFIER_TYPE_MASK) == 
CS_MODIFIER_TYPE_DELEGATE)
+       {
+               attrs = CSModifiersToDelegateAttrs((ILNode *)defn,
+                                                                               
   defn->modifiers & CS_MODIFIER_MASK,
+                                                                               
   (defn->nestedParent != 0));
+
+               /*
+                * Delegates should not be serializable by default but cscc 
behaved
+                * like this.
+                */
+               attrs |= IL_META_TYPEDEF_SERIALIZABLE;
+               attrs |= IL_META_TYPEDEF_SEALED;
+       }
+       else
+       {
+               attrs = CSModifiersToTypeAttrs((ILNode *)defn,
+                                                                          
defn->modifiers & CS_MODIFIER_MASK,
+                                                                          
(defn->nestedParent != 0));
+
+               /*
+                * Add type specific flags to the attributes.
+                */
+               switch(defn->modifiers & CS_MODIFIER_TYPE_MASK)
+               {
+                       case CS_MODIFIER_TYPE_STRUCT:
+                       {
+                               /*
+                                * NOTE: Default sequential layout is not in 
the ECMA specs.
+                                * But it's the way we and MS layout structs by 
default.
+                                */
+                               attrs |= IL_META_TYPEDEF_LAYOUT_SEQUENTIAL;
+
+                               /*
+                                * Structs should not be serializable by 
default but cscc behaved
+                                * like this.
+                                */
+                               attrs |= IL_META_TYPEDEF_SERIALIZABLE;
+
+                               attrs |= IL_META_TYPEDEF_SEALED;
+                       }
+                       break;
+
+                       case CS_MODIFIER_TYPE_INTERFACE:
+                       {
+                               attrs |= (IL_META_TYPEDEF_INTERFACE | 
IL_META_TYPEDEF_ABSTRACT);
+                       }
+                       break;
+
+                       case CS_MODIFIER_TYPE_ENUM:
+                       {
+                               /*
+                                * Enums should not be serializable by default 
but cscc behaved
+                                * like this.
+                                */
+                               attrs |= IL_META_TYPEDEF_SERIALIZABLE;
+                               attrs |= IL_META_TYPEDEF_SEALED;
+                       }
+                       break;
+               }
+
+#if IL_VERSION_MAJOR > 1
+               /* Process the "static" modifier */
+               if((defn->modifiers & CS_MODIFIER_STATIC) != 0)
+               {
+                       if((defn->modifiers & CS_MODIFIER_TYPE_MASK) ==  
CS_MODIFIER_TYPE_CLASS)
+                       {
+                               if(defn->modifiers & CS_MODIFIER_SEALED)
+                               {
+                                       CCErrorOnLine(yygetfilename(defn), 
yygetlinenum(defn),
+                                                                 "static 
classes must not be sealed");
+                               }
+                               if(defn->modifiers & CS_MODIFIER_ABSTRACT)
+                               {
+                                       CCErrorOnLine(yygetfilename(defn), 
yygetlinenum(defn),
+                                                                 "static 
classes must not be abstract");
+                               }
+                               /* Static classes are sealed and abstract */
+                               attrs |= (IL_META_TYPEDEF_SEALED | 
IL_META_TYPEDEF_ABSTRACT);
+                       }
+                       else
+                       {
+                               CCErrorOnLine(yygetfilename(defn), 
yygetlinenum(defn),
+                                         "`static' modifier is not permitted 
on non classes");
+                       }
+               }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+       }
+
+       return attrs;
+}
+
+/*
+ * Forward declaration
+ */
+static void CreateType(ILGenInfo *info, ILScope *globalScope,
+                                          ILNode_List *list, ILNode 
*systemObjectName,
+                                          ILNode *type);
+
+/*
+ * Create the nested types of a type
+ */
+static void CreateNestedTypes(ILGenInfo *info, ILScope *globalScope,
+                                                         ILNode_List *list, 
ILNode *systemObjectName,
+                                                         ILNode_ClassDefn 
*nestedParent)
+{
+       ILNode *node;
+       ILNode_ListIter iter;
+
+       node = nestedParent->body;
+       if(node && yyisa(node, ILNode_ScopeChange))
+       {
+               node = ((ILNode_ScopeChange *)node)->body;
+       }
+       ILNode_ListIter_Init(&iter, node);
+       while((node = ILNode_ListIter_Next(&iter)) != 0)
+       {
+               if(yyisa(node, ILNode_ClassDefn))
+               {
+                       CreateType(info, globalScope, list, systemObjectName, 
node);
+               }
+       }
+}
+
+static void AddTypeToList(ILNode_List *list, ILNode_ClassDefn *defn)
+{
+       ILNode *type;
+
+       type = (ILNode *)defn;
+       if(!(defn->nestedParent))
+       {
+               ILNode_List_Add(list, type);
+       }
+       else
+       {
+               if(!defn->nestedParent->nestedClasses)
+               {
+                       defn->nestedParent->nestedClasses = 
ILNode_List_create();
+               }
+               ILNode_List_Add(defn->nestedParent->nestedClasses, type);
+       }
+}
+
+static void AddDefaultCtor(ILNode_ClassDefn *defn)
+{
+       /* Determine if we need to add a default constructor */
+#if IL_VERSION_MAJOR > 1
+       /* Don't add the default constructor for static classes. */
+       if(((defn->modifiers & (CS_MODIFIER_STATIC | CS_MODIFIER_CTOR_DEFINED)) 
== 0) &&
+          ((defn->modifiers & CS_MODIFIER_TYPE_MASK) == 
CS_MODIFIER_TYPE_CLASS))
+#else  /* IL_VERSION_MAJOR == 1 */
+       if(((defn->modifiers & CS_MODIFIER_CTOR_DEFINED) == 0) &&
+          ((defn->modifiers & CS_MODIFIER_TYPE_MASK) == 
CS_MODIFIER_TYPE_CLASS))
+#endif /* IL_VERSION_MAJOR == 1 */
+       {
+               ILUInt32 ctorMods;
+               ILNode *empty;
+               ILNode *cname;
+               ILNode *nonstaticInit;
+               ILNode *baseInit;
+               ILNode *invokation;
+               ILNode *compound;
+               ILNode *ctor;
+               ILNode *body;
+               ILNode *node;
+
+               ctorMods = (((defn->modifiers & CS_MODIFIER_ABSTRACT) != 0)
+                                                       ? CS_MODIFIER_PROTECTED 
: CS_MODIFIER_PUBLIC);
+               ctorMods |= CS_MODIFIER_METHOD_CONSTRUCTOR;
+               cname = ILQualIdentSimple(ILInternString(".ctor", 5).string);
+               empty = ILNode_Empty_create();
+               nonstaticInit = ILNode_NonStaticInit_create();
+               baseInit = ILNode_BaseInit_create();
+               invokation = ILNode_InvocationExpression_create(baseInit, 0);
+               compound = ILNode_Compound_CreateFrom(nonstaticInit, 
invokation);
+               body = ILNode_NewScope_create(compound);
+               ctor = ILNode_MethodDeclaration_create(0, ctorMods, 0, cname, 0,
+                                                                               
           empty, body);
+
+               node = defn->body;
+               if(!node)
+               {
+                       node = ILNode_List_create();
+                       ILNode_List_Add(node, ctor);
+                       /* TODO: Create a scope change here */
+                       defn->body = node;
+               }
+               else
+               {
+                       if(node && yyisa(node, ILNode_ScopeChange))
+                       {
+                               if(!((ILNode_ScopeChange *)node)->body)
+                               {
+                                       /*
+                                        * A empty class declaration so create 
the member list now
+                                        */
+                                       ((ILNode_ScopeChange *)node)->body = 
ILNode_List_create();
+                               }
+                               node = ((ILNode_ScopeChange *)node)->body;
+                       }
+                       ILNode_List_Add(node, ctor);
+               }
+       }
+}
+
 /*
  * Create the program structure for a type and all of its base types.
  * Returns the new end of the top-level type list.
@@ -665,13 +1021,12 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
        ILNode *baseNode;
        ILNode *baseTypeNode;
        ILProgramItem *parent;
+       ILProgramItem *implicitParent;
        ILClass *classInfo;
        ILNode_ClassDefn *defn;
        ILNode *savedNamespace;
        ILNode *savedClass;
        ILProgramItem *nestedScope;
-       ILNode *node;
-       ILNode_ListIter iter;
 
        /* Get the name and namespace for the type, for error reporting */
        defn = (ILNode_ClassDefn *)type;
@@ -705,9 +1060,9 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
                 * since we'll be coming back to this very same class by
                 * defn->nestedParent as it's nested child or the forward
                 * edge , let's skip this loop,by returning here */
-               if(defn->nestedParent->classInfo==0)
+               if(defn->nestedParent->classInfo == 0)
                {
-                       defn->classInfo=0;
+                       defn->classInfo = 0;
                        CreateType(info, globalScope, list,
                                   systemObjectName, (ILNode 
*)(defn->nestedParent));
                        return; 
@@ -724,12 +1079,50 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
                nestedScope = ILClassGlobalScope(info->image);
        }
 
+       /* Set the default accessibility if none was specified */
+       if((defn->modifiers & CS_MODIFIER_ACCESS_MASK) == 0)
+       {
+               defn->modifiers |= (defn->nestedParent ? CS_MODIFIER_PRIVATE :
+                                                                               
                 CS_MODIFIER_INTERNAL);
+       }
+
        /* Set the namespace and class to use for resolving type names */
        savedNamespace = info->currentNamespace;
        info->currentNamespace = defn->namespaceNode;
        savedClass = info->currentClass;
        info->currentClass = (ILNode *)defn;
 
+
+       /*
+        * Handle the implicit parents.
+        * They are known to be no interfaces and not generic.
+        */
+       implicitParent = 0;
+       if((baseNode = GetImplicitParent(defn)) != 0)
+       {
+               if(CSSemBaseType(baseNode, info, &baseNode,
+                                                &baseTypeNode, 
&implicitParent))
+               {
+                       if(implicitParent == 0)
+                       {
+                               implicitParent = 
NodeToProgramItem(baseTypeNode);
+                               if(implicitParent == 0)
+                               {
+                                       CreateType(info, globalScope, list,
+                                                          systemObjectName, 
baseTypeNode);
+                                       implicitParent = 
NodeToProgramItem(baseTypeNode);
+                               }
+                       }
+               }
+       }
+
+       /* Test for interfaces, or find "System.Object" if no parent yet */
+       /*
+        * NOTE: This done too to make sure that all base classes and interfaces
+        * are created before any class that inherits from the class or 
implamants
+        * an interface. Otherwise members for implemented interface methods are
+        * not created virtual sealed.
+        */
        parent = 0;
        baseNodeList = defn->baseClass;
        while(baseNodeList)
@@ -794,8 +1187,8 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
                }
        }
 
-       /* Test for interfaces, or find "System.Object" if no parent yet */
-       if(!parent && (defn->modifiers & IL_META_TYPEDEF_INTERFACE) == 0)
+       if(!parent &&
+          ((defn->modifiers & CS_MODIFIER_TYPE_MASK) == 
CS_MODIFIER_TYPE_CLASS))
        {
                /* Compiling something else that inherits "System.Object" */
                /* Use the builtin library's "System.Object" as parent class */
@@ -805,11 +1198,14 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
 
                if(!objectClass)
                {
+                       ILNode_Namespace *namespaceNode;
+
                        /* Change to the global namespace to resolve 
"System.Object" */
-                       while(((ILNode_Namespace 
*)(info->currentNamespace))->enclosing != 0)
+                       namespaceNode = (ILNode_Namespace 
*)(info->currentNamespace);
+                       while(namespaceNode->enclosing != 0)
                        {
-                               info->currentNamespace = (ILNode *)
-                                       ((ILNode_Namespace 
*)(info->currentNamespace))->enclosing;
+                               namespaceNode = namespaceNode->enclosing;
+                               info->currentNamespace = (ILNode 
*)namespaceNode;
                        }
 
                        if(CSSemBaseType(systemObjectName, info, 
&systemObjectName,
@@ -833,14 +1229,20 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
        }
 
        /* Create the class information block */
-       if(strcmp(name, "<Module>") != 0)
+       if((defn->modifiers & CS_MODIFIER_TYPE_MASK) != CS_MODIFIER_TYPE_MODULE)
        {
-               classInfo = ILClassCreate(nestedScope, 0, name, namespace, 0);
+               ILUInt32 attrs;
+
+               attrs = GetTypeAttrs(info, defn);
+               classInfo = ILClassCreate(nestedScope, 0, name, namespace, 
implicitParent);
                if(!classInfo)
                {
                        CCOutOfMemory();
                }
-               ILClassSetAttrs(classInfo, ~0, defn->modifiers);
+               ILClassSetAttrs(classInfo, ~0, attrs);
+
+               /* Add the default ctor to the class if needed */
+               AddDefaultCtor(defn);
        }
        else
        {
@@ -857,33 +1259,10 @@ static void CreateType(ILGenInfo *info, ILScope 
*globalScope,
        ILSetProgramItemMapping(info, (ILNode *)defn);
 
        /* Process the nested types */
-       node = defn->body;
-       if(node && yyisa(node, ILNode_ScopeChange))
-       {
-               node = ((ILNode_ScopeChange *)node)->body;
-       }
-       ILNode_ListIter_Init(&iter, node);
-       while((node = ILNode_ListIter_Next(&iter)) != 0)
-       {
-               if(yyisa(node, ILNode_ClassDefn))
-               {
-                       CreateType(info, globalScope, list, systemObjectName, 
node);
-               }
-       }
+       CreateNestedTypes(info, globalScope, list, systemObjectName, defn);
 
        /* Add the type to the new top-level list in create order */
-       if(!(defn->nestedParent))
-       {
-               ILNode_List_Add(list, type);
-       }
-       else
-       {
-               if(!defn->nestedParent->nestedClasses)
-               {
-                       defn->nestedParent->nestedClasses = 
ILNode_List_create();
-               }
-               ILNode_List_Add(defn->nestedParent->nestedClasses, type);
-       }
+       AddTypeToList(list, defn);
 }
 
 /*
@@ -1035,7 +1414,7 @@ static void ReportDuplicates(ILNode *node, ILMember 
*newMember,
                                          "declaration of `%s' conflicts with 
an existing member",
                                          name);
        }
-       else if((modifiers & CS_SPECIALATTR_NEW) == 0)
+       else if((modifiers & CS_MODIFIER_NEW) == 0)
        {
                /* The duplicate is in a parent class, and "new" wasn't 
specified */
                CCWarningOnLine(yygetfilename(node), yygetlinenum(node),
@@ -1054,10 +1433,37 @@ static void ReportUnnecessaryNew(ILNode *node, const 
char *name)
                                        name);
 }
 
+static ILUInt32 GetFieldAttrs(ILNode_FieldDeclaration *field)
+{
+       ILUInt32 attrs;
+
+       if((field->modifiers & CS_MODIFIER_FIELD_CONST) != 0)
+       {
+               attrs = CSModifiersToConstAttrs(field->type,
+                                                                               
field->modifiers & CS_MODIFIER_MASK);
+       }
+       else
+       {
+               attrs = CSModifiersToFieldAttrs(field->type,
+                                                                               
field->modifiers & CS_MODIFIER_MASK);
+
+               if((field->modifiers & CS_MODIFIER_FIELD_SPECIAL_NAME) != 0)
+               {
+                       attrs |= IL_META_FIELDDEF_SPECIAL_NAME;
+               }
+               if((field->modifiers & CS_MODIFIER_FIELD_RT_SPECIAL_NAME) != 0)
+               {
+                       attrs |= IL_META_FIELDDEF_RT_SPECIAL_NAME;
+               }
+       }
+
+       return attrs;
+}
+
 /*
  * Create a field definition.
  */
-static void CreateField(ILGenInfo *info, ILClass *classInfo,
+static void CreateField(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                ILNode_FieldDeclaration *field)
 {
        ILNode_ListIter iterator;
@@ -1067,12 +1473,58 @@ static void CreateField(ILGenInfo *info, ILClass 
*classInfo,
        ILType *tempType;
        ILType *modifier;
        ILMember *member;
+       ILClass *classInfo;
+       ILUInt32 fieldAttrs;
+
+#if IL_VERSION_MAJOR > 1
+       if((classNode->modifiers & CS_MODIFIER_STATIC) != 0)
+       {
+               /* Constants are static by default */
+               if((field->modifiers & CS_MODIFIER_FIELD_CONST) == 0)
+               {
+                       /* Only static fields or constants are allowed */
+                       if((field->modifiers & CS_MODIFIER_STATIC) == 0)
+                       {
+                               CCErrorOnLine(yygetfilename(field), 
yygetlinenum(field),
+                                                 "only static fields are 
allowed in static classes");
+                       }
+                       switch(field->modifiers & CS_MODIFIER_ACCESS_MASK)
+                       {
+                               case CS_MODIFIER_PROTECTED:
+                               {
+                                       CCErrorOnLine(yygetfilename(field), 
yygetlinenum(field),
+                                               "no protected fields are 
allowed in static classes");
+                               }
+                               break;
+
+                               case (CS_MODIFIER_PROTECTED | 
CS_MODIFIER_INTERNAL):
+                               {
+                                       CCErrorOnLine(yygetfilename(field), 
yygetlinenum(field),
+                                       "no protected internal fields are 
allowed in static classes");
+                               }
+                               break;
+                       }
+               }
+       }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+       /* Set the default accessibility if none was specified */
+       if((field->modifiers & CS_MODIFIER_ACCESS_MASK) == 0)
+       {
+               field->modifiers |= CS_MODIFIER_PRIVATE;
+       }
+
+       /* Get the field meadata flags */
+       fieldAttrs = GetFieldAttrs(field);
+
+       /* Get the class information block */
+       classInfo = classNode->classInfo;
 
        /* Get the field's type */
        tempType = CSSemType(field->type, info, &(field->type));
 
        /* Add the "volatile" modifier if necessary */
-       if((field->modifiers & CS_SPECIALATTR_VOLATILE) != 0)
+       if((field->modifiers & CS_MODIFIER_VOLATILE) != 0)
        {
                modifier = ILFindNonSystemType(info, "IsVolatile",
                                                                           
"System.Runtime.CompilerServices");
@@ -1104,8 +1556,7 @@ static void CreateField(ILGenInfo *info, ILClass 
*classInfo,
                member = FindMemberByName(classInfo, name, classInfo, 0);
 
                /* Create the field information block */
-               fieldInfo = ILFieldCreate(classInfo, 0, name,
-                                                                 
(field->modifiers & 0xFFFF));
+               fieldInfo = ILFieldCreate(classInfo, 0, name, fieldAttrs & 
0xFFFF);
                if(!fieldInfo)
                {
                        CCOutOfMemory();
@@ -1120,7 +1571,7 @@ static void CreateField(ILGenInfo *info, ILClass 
*classInfo,
                        ReportDuplicates(decl->name, (ILMember *)fieldInfo,
                                                         member, classInfo, 
field->modifiers, name);
                }
-               else if((field->modifiers & CS_SPECIALATTR_NEW) != 0)
+               else if((field->modifiers & CS_MODIFIER_NEW) != 0)
                {
                        ReportUnnecessaryNew(decl->name, name);
                }
@@ -1266,9 +1717,7 @@ static ILMember *FindInterfaceDecl(ILNode *node, ILClass 
*classInfo,
                /* Set the correct attributes on the explicit implementation */
                newAttrs &= ~(IL_META_METHODDEF_MEMBER_ACCESS_MASK |
                                          IL_META_METHODDEF_STATIC |
-                                         IL_META_METHODDEF_ABSTRACT |
-                                         CS_SPECIALATTR_NEW |
-                                         CS_SPECIALATTR_OVERRIDE);
+                                         IL_META_METHODDEF_ABSTRACT);
                newAttrs |= IL_META_METHODDEF_PRIVATE |
                                        IL_META_METHODDEF_FINAL |
                                        IL_META_METHODDEF_VIRTUAL |
@@ -1402,14 +1851,91 @@ static int IsRealFinalizer(ILClass *classInfo)
        return 0;
 }
 
+static ILUInt32 GetMethodAttrs(ILNode_MethodDeclaration *method)
+{
+       ILUInt32 attrs;
+
+       switch(method->modifiers & CS_MODIFIER_METHOD_TYPE_MASK)
+       {
+               case CS_MODIFIER_METHOD_NORMAL:
+               {
+                       attrs = CSModifiersToMethodAttrs((ILNode *)method,
+                                                                               
         method->modifiers);
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_CONSTRUCTOR:
+               {
+                       attrs = CSModifiersToConstructorAttrs((ILNode *)method,
+                                                                               
                  method->modifiers);
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_DESTRUCTOR:
+               {
+                       attrs = CSModifiersToDestructorAttrs((ILNode *)method,
+                                                                               
                 method->modifiers);
+
+                       /* Add the override modifier by default */
+                       method->modifiers |= CS_MODIFIER_OVERRIDE;
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_OPERATOR:
+               {
+                       attrs = CSModifiersToOperatorAttrs((ILNode *)method,
+                                                                               
           method->modifiers);
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_INTERFACE:
+               {
+                       attrs = IL_META_METHODDEF_PUBLIC |
+                                       IL_META_METHODDEF_VIRTUAL |
+                                       IL_META_METHODDEF_ABSTRACT |
+                                       IL_META_METHODDEF_HIDE_BY_SIG |
+                                       IL_META_METHODDEF_NEW_SLOT;
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_INTERFACE_ACCESSOR:
+               {
+                       attrs =  IL_META_METHODDEF_PUBLIC |
+                                        IL_META_METHODDEF_VIRTUAL |
+                                        IL_META_METHODDEF_ABSTRACT |
+                                        IL_META_METHODDEF_HIDE_BY_SIG |
+                                        IL_META_METHODDEF_SPECIAL_NAME |
+                                        IL_META_METHODDEF_NEW_SLOT;
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_EVENT_ACCESSOR:
+               {
+                       attrs = CSModifiersToEventAttrs((ILNode *)method,
+                                                                               
        method->modifiers);
+               }
+               break;
+
+               case CS_MODIFIER_METHOD_PROPERTY_ACCESSOR:
+               {
+                       attrs = CSModifiersToPropertyAttrs((ILNode *)method,
+                                                                               
           method->modifiers);
+               }
+               break;
+       }
+
+       return attrs;
+}
+
 /*
  * Create a method definition.
  */
-static void CreateMethod(ILGenInfo *info, ILClass *classInfo,
+static void CreateMethod(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                 ILNode_MethodDeclaration 
*method)
 {
        const char *name;
        const char *basicName;
+       ILUInt32 attrs;
        ILUInt32 thisAccess;
        ILUInt32 baseAccess;
        ILType *tempType;
@@ -1425,14 +1951,57 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
        ILClass *interface;
        ILMember *interfaceMember;
        ILClass *class1, *class2;
+       ILClass *classInfo;
 #if IL_VERSION_MAJOR > 1
        ILNode *savedMethod;
 
+       if((classNode->modifiers & CS_MODIFIER_STATIC) != 0)
+       {
+               /* Only static methods are allowed */
+               if((method->modifiers & CS_MODIFIER_STATIC) == 0)
+               {
+                       CCErrorOnLine(yygetfilename(method), 
yygetlinenum(method),
+                                       "only static methods are allowed in 
static classes");
+               }
+               switch(method->modifiers & CS_MODIFIER_ACCESS_MASK)
+               {
+                       case CS_MODIFIER_PROTECTED:
+                       {
+                               CCErrorOnLine(yygetfilename(method), 
yygetlinenum(method),
+                                       "no protected methods are allowed in 
static classes");
+                       }
+                       break;
+
+                       case (CS_MODIFIER_PROTECTED | CS_MODIFIER_INTERNAL):
+                       {
+                               CCErrorOnLine(yygetfilename(method), 
yygetlinenum(method),
+                               "no protected internal methods are allowed in 
static classes");
+                       }
+                       break;
+               }
+               switch(method->modifiers & CS_MODIFIER_METHOD_TYPE_MASK)
+               {
+                       case CS_MODIFIER_METHOD_OPERATOR:
+                       {
+                               CCErrorOnLine(yygetfilename(method), 
yygetlinenum(method),
+                                                               "no operators 
are allowed in static classes");
+                       }
+                       break;
+               }
+       }
+
        /* 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 */
+
+#endif /* IL_VERSION_MAJOR > 1 */
+
+       /* Get the method flags */
+       attrs = GetMethodAttrs(method);
+
+       /* Get the class information block */
+       classInfo = classNode->classInfo;
 
        /* Get the name of the method, and the interface member (if any) */
        interface = 0;
@@ -1507,8 +2076,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
        /* Create the method information block */
        if(!methodInfo)
        {
-               methodInfo = ILMethodCreate(classInfo, 0, name,
-                                                                       
(method->modifiers & 0xFFFF));
+               methodInfo = ILMethodCreate(classInfo, 0, name, (attrs & 
0xFFFF));
                if(!methodInfo)
                {
                        CCOutOfMemory();
@@ -1524,9 +2092,9 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
        if(!strcmp(name, "Finalize") &&
           (method->params == 0 || yyisa(method->params, ILNode_Empty)) &&
           tempType == ILType_Void &&
-          (method->modifiers & CS_SPECIALATTR_DESTRUCTOR) == 0)
+          (method->modifiers & CS_MODIFIER_METHOD_TYPE_MASK) != 
CS_MODIFIER_METHOD_DESTRUCTOR)
        {
-               if((method->modifiers & CS_SPECIALATTR_OVERRIDE) != 0)
+               if((method->modifiers & CS_MODIFIER_OVERRIDE) != 0)
                {
                        if(IsRealFinalizer(classInfo))
                        {
@@ -1537,7 +2105,8 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
                }
                else if(!ILTypeIsObjectClass(ILType_FromClass(classInfo)))
                {
-                       method->modifiers |= CS_SPECIALATTR_NEW;
+                       method->modifiers |= CS_MODIFIER_NEW;
+                       attrs |= IL_META_METHODDEF_NEW_SLOT;
                }
        }
 
@@ -1547,7 +2116,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
        {
                CCOutOfMemory();
        }
-       if((method->modifiers & IL_META_METHODDEF_STATIC) == 0)
+       if((method->modifiers & CS_MODIFIER_STATIC) == 0)
        {
                ILTypeSetCallConv(signature, IL_META_CALLCONV_HASTHIS);
                ILMethodSetCallConv(methodInfo, IL_META_CALLCONV_HASTHIS);
@@ -1662,7 +2231,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
        /* Process interface overrides */
        if(!ILClass_IsInterface(classInfo))
        {
-               paramNum = method->modifiers;
+               paramNum = attrs;
                interfaceMember = FindInterfaceDecl
                        ((ILNode *)method, classInfo, interface,
                         basicName, signature, IL_META_MEMBERKIND_METHOD,
@@ -1698,7 +2267,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
            strncmp(ILMethod_Name(methodInfo), "set_", 4) != 0))
        {
                /* If "override" is supplied, then look for its "virtual" */
-               if((method->modifiers & CS_SPECIALATTR_OVERRIDE) != 0)
+               if((method->modifiers & CS_MODIFIER_OVERRIDE) != 0)
                {
                        if(!ILMemberGetBase((ILMember *)methodInfo))
                        {
@@ -1747,9 +2316,9 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
                                }
 
                                /* Check for the correct form of virtual method 
overrides */
-                               if((method->modifiers & 
CS_SPECIALATTR_OVERRIDE) == 0)
+                               if((method->modifiers & CS_MODIFIER_OVERRIDE) 
== 0)
                                {
-                                       if((method->modifiers & 
CS_SPECIALATTR_NEW) == 0)
+                                       if((method->modifiers & 
CS_MODIFIER_NEW) == 0)
                                        {
                                                /* Report absent new keyword 
warning. */
                                                ReportDuplicates(method->name, 
(ILMember *)methodInfo,
@@ -1757,7 +2326,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
                                                                                
 method->modifiers, name);
 
                                                /* Add new slot modifier. */
-                                               method->modifiers |= 
CS_SPECIALATTR_NEW;
+                                               method->modifiers |= 
CS_MODIFIER_NEW;
                                        }
 
                                        /* Set the method to use a new vtable 
slot. */
@@ -1768,13 +2337,13 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
                                else
                                {
                                        /* Get the access modifiers for this 
and the base methods */
-                                       thisAccess = (method->modifiers &
-                                                   
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
+                                       thisAccess = (attrs &
+                                                                 
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
                                        baseAccess = (ILMember_Attrs(member) &
-                                                   
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
+                                                                 
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
 
                                        /* Check for legal modifiers for 
overrides */
-                                       if((method->modifiers & 
CS_SPECIALATTR_OVERRIDE) != 0 &&
+                                       if((method->modifiers & 
CS_MODIFIER_OVERRIDE) != 0 &&
                                           (thisAccess != baseAccess) &&
                                           ((ILProgramItem_Image(member) ==
                                             ILProgramItem_Image(methodInfo)) ||
@@ -1807,7 +2376,7 @@ static void CreateMethod(ILGenInfo *info, ILClass 
*classInfo,
                                                                 member, 
classInfo, method->modifiers, name);
                        }
                }
-               else if((method->modifiers & CS_SPECIALATTR_NEW) != 0)
+               else if((method->modifiers & CS_MODIFIER_NEW) != 0)
                {
                        ReportUnnecessaryNew(method->name, name);
                }
@@ -1920,7 +2489,7 @@ static int EventIsVirtual(ILEvent *event)
 /*
  * Create a property definition.
  */
-static void CreateProperty(ILGenInfo *info, ILClass *classInfo,
+static void CreateProperty(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                   ILNode_PropertyDeclaration 
*property,
                                                   const char 
**defaultMemberName)
 {
@@ -1940,16 +2509,48 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
        int interfaceOverride;
        ILMethod *baseMethod;
        ILClass *class1, *class2;
+       ILClass *classInfo;
+
+#if IL_VERSION_MAJOR > 1
+       if((classNode->modifiers & CS_MODIFIER_STATIC) != 0)
+       {
+               /* Only static methods are allowed */
+               if((property->modifiers & CS_MODIFIER_STATIC) == 0)
+               {
+                       CCErrorOnLine(yygetfilename(property), 
yygetlinenum(property),
+                                       "only static properties are allowed in 
static classes");
+               }
+               switch(property->modifiers & CS_MODIFIER_ACCESS_MASK)
+               {
+                       case CS_MODIFIER_PROTECTED:
+                       {
+                               CCErrorOnLine(yygetfilename(property), 
yygetlinenum(property),
+                                       "no protected properties are allowed in 
static classes");
+                       }
+                       break;
+
+                       case (CS_MODIFIER_PROTECTED | CS_MODIFIER_INTERNAL):
+                       {
+                               CCErrorOnLine(yygetfilename(property), 
yygetlinenum(property),
+                               "no protected internal properties are allowed 
in static classes");
+                       }
+                       break;
+               }
+       }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+       /* Get the class information block */
+       classInfo = classNode->classInfo;
 
        /* Create the get and set methods */
        if(property->getAccessor)
        {
-               CreateMethod(info, classInfo,
+               CreateMethod(info, classNode,
                                     (ILNode_MethodDeclaration 
*)(property->getAccessor));
        }
        if(property->setAccessor)
        {
-               CreateMethod(info, classInfo,
+               CreateMethod(info, classNode,
                                     (ILNode_MethodDeclaration 
*)(property->setAccessor));
        }
 
@@ -2026,8 +2627,8 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
 
                /* Return the name of this indexer for use in the
                   "DefaultMember" attribute on the containing class */
-               if((property->modifiers & IL_META_METHODDEF_MEMBER_ACCESS_MASK)
-                               != IL_META_METHODDEF_PRIVATE)
+               if((property->modifiers & CS_MODIFIER_ACCESS_MASK)
+                               != CS_MODIFIER_PRIVATE)
                {
                        *defaultMemberName = basicName;
                }
@@ -2072,7 +2673,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                                         name, (ILMember *)propertyInfo, 
property->name);
 
        /* If "override" is supplied, then look for its "virtual" */
-       if((property->modifiers & CS_SPECIALATTR_OVERRIDE) != 0)
+       if((property->modifiers & CS_MODIFIER_OVERRIDE) != 0)
        {
                if(!ILMemberGetBase((ILMember *)propertyInfo))
                {
@@ -2090,7 +2691,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
        {
                if(ILMember_IsProperty(member) &&
                   PropertyIsVirtual((ILProperty *)member) &&
-                  (property->modifiers & CS_SPECIALATTR_NEW) == 0)
+                  (property->modifiers & CS_MODIFIER_NEW) == 0)
                {
                        if(ILMember_Owner(member) == classInfo)
                        {
@@ -2100,7 +2701,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                        }
 
                        /* Check for the correct form of virtual method 
overrides */
-                       if((property->modifiers & CS_SPECIALATTR_OVERRIDE) == 0)
+                       if((property->modifiers & CS_MODIFIER_OVERRIDE) == 0)
                        {
                                /* Report absent new keyword warning. */
                                ReportDuplicates(property->name, (ILMember 
*)propertyInfo,
@@ -2108,13 +2709,13 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                                                                 
property->modifiers, name);
 
                                /* Add new slot modifier for property. */
-                               property->modifiers |= CS_SPECIALATTR_NEW;
+                               property->modifiers |= CS_MODIFIER_NEW;
 
                                /* Set the getter to use a new vtable slot. */
                                if(property->getAccessor)
                                {
                                        ((ILNode_MethodDeclaration 
*)property->getAccessor)
-                                               ->modifiers |= 
CS_SPECIALATTR_NEW;
+                                               ->modifiers |= CS_MODIFIER_NEW;
                                        ILMemberSetAttrs((ILMember 
*)(ILProperty_Getter(propertyInfo)),
                                                                         
IL_META_METHODDEF_VTABLE_LAYOUT_MASK,
                                                                         
IL_META_METHODDEF_NEW_SLOT);
@@ -2124,7 +2725,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                                if(property->setAccessor)
                                {
                                        ((ILNode_MethodDeclaration 
*)property->setAccessor)
-                                               ->modifiers |= 
CS_SPECIALATTR_NEW;
+                                               ->modifiers |= CS_MODIFIER_NEW;
                                        ILMemberSetAttrs((ILMember 
*)(ILProperty_Setter(propertyInfo)),
                                                                         
IL_META_METHODDEF_VTABLE_LAYOUT_MASK,
                                                                         
IL_META_METHODDEF_NEW_SLOT);
@@ -2133,8 +2734,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                        else
                        {
                                /* Get the access modifiers for this property */
-                               thisAccess = (property->modifiers &
-                                             
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
+                               thisAccess = 
GetMemberVisibilityFromModifiers(property->modifiers);
 
                                /* Get a base getter or setter */
                                baseMethod = ILProperty_Getter((ILProperty 
*)member);
@@ -2148,7 +2748,7 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                                              
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
 
                                /* Check for legal modifiers for overrides */
-                               if((property->modifiers & 
CS_SPECIALATTR_OVERRIDE) != 0 &&
+                               if((property->modifiers & CS_MODIFIER_OVERRIDE) 
!= 0 &&
                                   (thisAccess != baseAccess) &&
                                   ((ILProgramItem_Image(member) ==
                                     ILProgramItem_Image(propertyInfo)) ||
@@ -2179,16 +2779,171 @@ static void CreateProperty(ILGenInfo *info, ILClass 
*classInfo,
                                                         member, classInfo, 
property->modifiers, name);
                }
        }
-       else if((property->modifiers & CS_SPECIALATTR_NEW) != 0)
+       else if((property->modifiers & CS_MODIFIER_NEW) != 0)
        {
                ReportUnnecessaryNew(property->name, name);
        }
 }
 
+static ILUInt32 GetEventAccessorModifiers(ILNode_EventDeclaration *event)
+{
+       ILUInt32 modifiers;
+
+       /* Validate the modifiers */
+       if((event->modifiers & CS_MODIFIER_EVENT_INTERFACE) != 0)
+       {
+               modifiers = (event->modifiers & CS_MODIFIER_MASK) | 
CS_MODIFIER_METHOD_INTERFACE;
+       }
+       else
+       {
+               modifiers = (event->modifiers & CS_MODIFIER_MASK) | 
CS_MODIFIER_METHOD_EVENT_ACCESSOR;
+       }
+
+       return modifiers;
+}
+
+/*
+ * Create the methods needed by an event declarator.
+ */
+static void CreateEventDeclMethods(ILNode_EventDeclaration *event,
+                                                                  
ILNode_EventDeclarator *decl,
+                                                                  ILUInt32 
accessorModifiers)
+{
+       ILNode_MethodDeclaration *method;
+       ILNode *eventName;
+       ILNode *name;
+       ILNode *param;
+       ILNode *addParams;
+       ILNode *removeParams;
+
+       /* Get the name of the event */
+       eventName = ((ILNode_FieldDeclarator *)(decl->fieldDeclarator))->name;
+
+       /* Create the parameter information for the "add" and "remove" methods 
*/
+       addParams = ILNode_List_create();
+       param = ILNode_FormalParameter_create(0, ILParamMod_empty, event->type,
+                               ILQualIdentSimple(ILInternString("value", 
5).string));
+       CloneLine(param, (ILNode *)decl);
+       ILNode_List_Add(addParams, param);
+
+       removeParams = ILNode_List_create();
+       param = ILNode_FormalParameter_create(0, ILParamMod_empty, event->type,
+                               ILQualIdentSimple(ILInternString("value", 
5).string));
+       CloneLine(param, (ILNode *)decl);
+       ILNode_List_Add(removeParams, param);
+
+       /* Create the "add" method */
+       name = PrefixName(eventName, "add_");
+       method = (ILNode_MethodDeclaration *)(decl->addAccessor);
+       if(!method && event->needFields)
+       {
+               /* Field-based event that needs a pre-defined body */
+               method = (ILNode_MethodDeclaration *)
+                       ILNode_MethodDeclaration_create
+                                       (0, accessorModifiers, 0, name, 0, 
addParams, 0);
+               method->body = ILNode_NewScope_create
+                                                       (ILNode_AssignAdd_create
+                                                               
(ILNode_Add_create(eventName, 
+                                                                       
ILQualIdentSimple
+                                                                               
(ILInternString("value", 5).string))));
+               decl->addAccessor = (ILNode *)method;
+       }
+       else if(!method)
+       {
+               /* Abstract interface definition */
+               method = (ILNode_MethodDeclaration *)
+                       ILNode_MethodDeclaration_create
+                                       (0, accessorModifiers, 0, name, 0, 
addParams, 0);
+               decl->addAccessor = (ILNode *)method;
+       }
+       else
+       {
+               /* Regular class definition */
+               method->modifiers = accessorModifiers;
+               method->type = 0;
+               method->name = name;
+               method->params = addParams;
+       }
+
+       /* Create the "remove" method */
+       name = PrefixName(eventName, "remove_");
+       method = (ILNode_MethodDeclaration *)(decl->removeAccessor);
+       if(!method && event->needFields)
+       {
+               /* Field-based event that needs a pre-defined body */
+               method = (ILNode_MethodDeclaration *)
+                       ILNode_MethodDeclaration_create
+                                       (0, accessorModifiers, 0, name, 0, 
removeParams, 0);
+               method->body = ILNode_NewScope_create
+                                                       (ILNode_AssignSub_create
+                                                               
(ILNode_Sub_create(eventName, 
+                                                                       
ILQualIdentSimple
+                                                                               
(ILInternString("value", 5).string))));
+               decl->removeAccessor = (ILNode *)method;
+       }
+       else if(!method)
+       {
+               /* Abstract interface definition */
+               method = (ILNode_MethodDeclaration *)
+                       ILNode_MethodDeclaration_create
+                                       (0, accessorModifiers, 0, name, 0, 
removeParams, 0);
+               decl->removeAccessor = (ILNode *)method;
+       }
+       else
+       {
+               /* Regular class definition */
+               method->modifiers = accessorModifiers;
+               method->type = 0;
+               method->name = name;
+               method->params = removeParams;
+       }
+}
+
+/*
+ * Create the methods needed by an event definition.
+ */
+static void CreateEventMethods(ILNode_EventDeclaration *event)
+{
+       ILNode_ListIter iter;
+       ILNode *decl;
+       ILUInt32 accessorModifiers;
+
+       accessorModifiers = GetEventAccessorModifiers(event);
+
+       if(yyisa(event->eventDeclarators, ILNode_EventDeclarator))
+       {
+               ILNode_EventDeclarator *eventDeclarator;
+
+               eventDeclarator = (ILNode_EventDeclarator 
*)(event->eventDeclarators);
+
+               /* A single declarator indicates a property-style event */
+               event->needFields = 0;
+
+               /* Create the methods for the event declarator */
+               CreateEventDeclMethods(event, eventDeclarator, 
accessorModifiers);
+       }
+       else
+       {
+               /* A list of declarators indicates a field-style event */
+               event->needFields =
+                       ((event->modifiers & (CS_MODIFIER_ABSTRACT | 
CS_MODIFIER_EVENT_INTERFACE)) == 0);
+
+               /* Scan the list and create the methods that we require */
+               ILNode_ListIter_Init(&iter, event->eventDeclarators);
+               while((decl = ILNode_ListIter_Next(&iter)) != 0)
+               {
+                       ILNode_EventDeclarator *eventDeclarator;
+
+                       eventDeclarator = (ILNode_EventDeclarator *)decl;
+                       CreateEventDeclMethods(event, eventDeclarator, 
accessorModifiers);
+               }
+       }
+}
+
 /*
  * Create an event definition from a specific declarator.
  */
-static void CreateEventDecl(ILGenInfo *info, ILClass *classInfo,
+static void CreateEventDecl(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                    ILNode_EventDeclaration 
*event,
                                                        ILType *eventType,
                                                        ILNode_EventDeclarator 
*eventDecl)
@@ -2204,6 +2959,41 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
        int interfaceOverride;
        ILMethod *baseMethod;
        ILClass *class1, *class2;
+       ILClass *classInfo;
+
+#if IL_VERSION_MAJOR > 1
+       if((classNode->modifiers & CS_MODIFIER_STATIC) != 0)
+       {
+               /* Only static fields or constants are allowed */
+               if((event->modifiers & CS_MODIFIER_STATIC) == 0)
+               {
+                       CCErrorOnLine(yygetfilename(event), yygetlinenum(event),
+                                                 "only static events are 
allowed in static classes");
+               }
+               switch(event->modifiers & CS_MODIFIER_ACCESS_MASK)
+               {
+                       case CS_MODIFIER_PROTECTED:
+                       {
+                               CCErrorOnLine(yygetfilename(event), 
yygetlinenum(event),
+                                       "no protected events are allowed in 
static classes");
+                       }
+                       break;
+
+                       case (CS_MODIFIER_PROTECTED | CS_MODIFIER_INTERNAL):
+                       {
+                               CCErrorOnLine(yygetfilename(event), 
yygetlinenum(event),
+                                       "no protected internal events are 
allowed in static classes");
+                       }
+                       break;
+               }
+       }
+#endif /* IL_VERSION_MAJOR > 1 */
+
+       /* Create the event accessor methods */
+       CreateEventMethods(event);
+
+       /* Get the class information block */
+       classInfo = classNode->classInfo;
 
        /* Set the back link for use by code generation */
        eventDecl->backLink = event;
@@ -2211,12 +3001,12 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
        /* Create the add and remove methods */
        if(eventDecl->addAccessor)
        {
-               CreateMethod(info, classInfo,
+               CreateMethod(info, classNode,
                                     (ILNode_MethodDeclaration 
*)(eventDecl->addAccessor));
        }
        if(eventDecl->removeAccessor)
        {
-               CreateMethod(info, classInfo,
+               CreateMethod(info, classNode,
                                     (ILNode_MethodDeclaration 
*)(eventDecl->removeAccessor));
        }
 
@@ -2311,7 +3101,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                                         name, (ILMember *)eventInfo, 
eventName);
 
        /* If "override" is supplied, then look for its "virtual" */
-       if((event->modifiers & CS_SPECIALATTR_OVERRIDE) != 0)
+       if((event->modifiers & CS_MODIFIER_OVERRIDE) != 0)
        {
                if(!ILMemberGetBase((ILMember *)eventInfo))
                {
@@ -2326,7 +3116,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
        {
                if(ILMember_IsEvent(member) &&
                   EventIsVirtual((ILEvent *)member) &&
-                  (event->modifiers & IL_META_METHODDEF_NEW_SLOT) == 0)
+                  (event->modifiers & CS_MODIFIER_NEW) == 0)
                {
                        if(ILMember_Owner(member) == classInfo)
                        {
@@ -2336,7 +3126,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                        }
 
                        /* Check for the correct form of virtual method 
overrides */
-                       if((event->modifiers & CS_SPECIALATTR_OVERRIDE) == 0)
+                       if((event->modifiers & CS_MODIFIER_OVERRIDE) == 0)
                        {
                                /* Report absent new keyword warning. */
                                ReportDuplicates(eventName, (ILMember 
*)eventInfo,
@@ -2344,13 +3134,13 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                                                                 
event->modifiers, name);
 
                                /* Add new slot modifier for event. */
-                               event->modifiers |= CS_SPECIALATTR_NEW;
+                               event->modifiers |= CS_MODIFIER_NEW;
 
                                /* Set the adder to use a new vtable slot. */
                                if(eventDecl->addAccessor)
                                {
                                        ((ILNode_MethodDeclaration 
*)eventDecl->addAccessor)
-                                               ->modifiers |= 
CS_SPECIALATTR_NEW;
+                                               ->modifiers |= CS_MODIFIER_NEW;
                                        ILMemberSetAttrs((ILMember 
*)(ILEvent_AddOn(eventInfo)),
                                                                         
IL_META_METHODDEF_VTABLE_LAYOUT_MASK,
                                                                         
IL_META_METHODDEF_NEW_SLOT);
@@ -2360,7 +3150,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                                if(eventDecl->removeAccessor)
                                {
                                        ((ILNode_MethodDeclaration 
*)eventDecl->removeAccessor)
-                                               ->modifiers |= 
CS_SPECIALATTR_NEW;
+                                               ->modifiers |= CS_MODIFIER_NEW;
                                        ILMemberSetAttrs((ILMember 
*)(ILEvent_RemoveOn(eventInfo)),
                                                                         
IL_META_METHODDEF_VTABLE_LAYOUT_MASK,
                                                                         
IL_META_METHODDEF_NEW_SLOT);
@@ -2369,8 +3159,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                        else
                        {
                                /* Get the access modifiers for this event */
-                               thisAccess = (event->modifiers &
-                                             
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
+                               thisAccess = 
GetMemberVisibilityFromModifiers(event->modifiers);
 
                                /* Get a base adder or remover */
                                baseMethod = ILEvent_AddOn((ILEvent *)member);
@@ -2384,7 +3173,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                                              
IL_META_METHODDEF_MEMBER_ACCESS_MASK);
 
                                /* Check for legal modifiers for overrides */
-                               if((event->modifiers & CS_SPECIALATTR_OVERRIDE) 
!= 0 &&
+                               if((event->modifiers & CS_MODIFIER_OVERRIDE) != 
0 &&
                                   (thisAccess != baseAccess) &&
                                   ((ILProgramItem_Image(member) ==
                                     ILProgramItem_Image(eventInfo)) ||
@@ -2415,7 +3204,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
                                                         member, classInfo, 
event->modifiers, name);
                }
        }
-       else if((event->modifiers & CS_SPECIALATTR_NEW) != 0)
+       else if((event->modifiers & CS_MODIFIER_NEW) != 0)
        {
                ReportUnnecessaryNew(eventName, name);
        }
@@ -2426,7 +3215,7 @@ static void CreateEventDecl(ILGenInfo *info, ILClass 
*classInfo,
        {
                ILUInt32 attrs = IL_META_FIELDDEF_PRIVATE;
                ILField *field;
-               if((event->modifiers & IL_META_METHODDEF_STATIC) != 0)
+               if((event->modifiers & CS_MODIFIER_STATIC) != 0)
                {
                        attrs |= IL_META_FIELDDEF_STATIC;
                }
@@ -2468,7 +3257,7 @@ static int FuzzyIsDelegate(ILType *type)
 /*
  * Create an event definition.
  */
-static void CreateEvent(ILGenInfo *info, ILClass *classInfo,
+static void CreateEvent(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                ILNode_EventDeclaration *event)
 {
        ILNode_ListIter iter;
@@ -2487,7 +3276,7 @@ static void CreateEvent(ILGenInfo *info, ILClass 
*classInfo,
        if(yyisa(event->eventDeclarators, ILNode_EventDeclarator))
        {
                /* Create the methods for the event declarator */
-               CreateEventDecl(info, classInfo, event, eventType,
+               CreateEventDecl(info, classNode, event, eventType,
                                            (ILNode_EventDeclarator 
*)(event->eventDeclarators));
        }
        else
@@ -2496,7 +3285,7 @@ static void CreateEvent(ILGenInfo *info, ILClass 
*classInfo,
                ILNode_ListIter_Init(&iter, event->eventDeclarators);
                while((decl = ILNode_ListIter_Next(&iter)) != 0)
                {
-                       CreateEventDecl(info, classInfo, event, eventType,
+                       CreateEventDecl(info, classNode, event, eventType,
                                                        (ILNode_EventDeclarator 
*)decl);
                }
        }
@@ -2534,9 +3323,8 @@ static void AppendParameters(ILNode *from,ILNode_List 
*to,int onlyPtrs)
                                                                                
        ILNode_FormalParameter_create(NULL,
                                                                                
                        node->pmod,node->type,
                                                                                
                        node->name);
-                       yysetfilename((ILNode*)param,yygetfilename(node));
-                       yysetlinenum((ILNode*)param, yygetlinenum(node));
-                       ILNode_List_Add(to,param);
+                       CloneLine((ILNode *)param, (ILNode *)node);
+                       ILNode_List_Add(to, param);
                }
        }
 }
@@ -2544,13 +3332,17 @@ static void AppendParameters(ILNode *from,ILNode_List 
*to,int onlyPtrs)
 /*
  * Create a delegate member definition.
  */
-static void CreateDelegateMember(ILGenInfo *info, ILClass *classInfo,
+static void CreateDelegateMember(ILGenInfo *info, ILNode_ClassDefn *classNode,
                                                                 
ILNode_DelegateMemberDeclaration *member)
 {
        ILMethod *method;
        ILType *signature;
        ILNode_MethodDeclaration *decl;
        ILNode_List *params;
+       ILClass *classInfo;
+
+       /* Get the class information block */
+       classInfo = classNode->classInfo;
 
        /* Create the delegate constructor */
        method = ILMethodCreate(classInfo, 0, ".ctor",
@@ -2593,18 +3385,16 @@ static void CreateDelegateMember(ILGenInfo *info, 
ILClass *classInfo,
 
        /* Create the "Invoke" method */
        decl = (ILNode_MethodDeclaration *)ILNode_MethodDeclaration_create
-               (0, IL_META_METHODDEF_PUBLIC |
-                       IL_META_METHODDEF_VIRTUAL |
-                       IL_META_METHODDEF_NEW_SLOT |
-                       IL_META_METHODDEF_HIDE_BY_SIG,
+               (0, CS_MODIFIER_PUBLIC |
+                       CS_MODIFIER_VIRTUAL |
+                       CS_MODIFIER_METHOD_HIDE_BY_SIG,
                 member->returnType,
                 ILQualIdentSimple(ILInternString("Invoke", -1).string),
                 0, member->params, 0);
        
-       yysetfilename((ILNode*)decl,yygetfilename(member));
-       yysetlinenum((ILNode*)decl, yygetlinenum(member));
+       CloneLine((ILNode *)decl, (ILNode *)member);
 
-       CreateMethod(info, classInfo, decl);
+       CreateMethod(info, classNode, decl);
        method = member->invokeMethod = decl->methodInfo;
        if(method)
        {
@@ -2625,21 +3415,19 @@ static void CreateDelegateMember(ILGenInfo *info, 
ILClass *classInfo,
        /* Create the "BeginInvoke" method */
        decl = (ILNode_MethodDeclaration*) ILNode_MethodDeclaration_create
                        (0,
-                       IL_META_METHODDEF_PUBLIC |
-                       IL_META_METHODDEF_VIRTUAL |
-                       IL_META_METHODDEF_NEW_SLOT |
-                       IL_META_METHODDEF_HIDE_BY_SIG |
-                       IL_META_METHODDEF_COMPILER_CONTROLLED,
+                       CS_MODIFIER_PUBLIC |
+                       CS_MODIFIER_VIRTUAL |
+                       CS_MODIFIER_METHOD_HIDE_BY_SIG |
+                       CS_MODIFIER_METHOD_COMPILER_CONTROLED,
                        ILNode_SystemType_create("IAsyncResult"),
                        ILQualIdentSimple(ILInternString("BeginInvoke", 
-1).string),
                        0,
                        (ILNode*)params,
                        0);
 
-       yysetfilename((ILNode*)decl,yygetfilename(member));
-       yysetlinenum((ILNode*)decl, yygetlinenum(member));
+       CloneLine((ILNode *)decl, (ILNode *)member);
 
-       CreateMethod(info, classInfo, decl);
+       CreateMethod(info, classNode, decl);
        method = member->beginInvokeMethod = decl->methodInfo;
        if(method)
        {
@@ -2659,21 +3447,18 @@ static void CreateDelegateMember(ILGenInfo *info, 
ILClass *classInfo,
        /* Create the "EndInvoke" method */
        decl = (ILNode_MethodDeclaration*) ILNode_MethodDeclaration_create
                        (0,
-                       IL_META_METHODDEF_PUBLIC |
-                       IL_META_METHODDEF_VIRTUAL |
-                       IL_META_METHODDEF_NEW_SLOT |
-                       IL_META_METHODDEF_HIDE_BY_SIG |
-                       IL_META_METHODDEF_COMPILER_CONTROLLED,
+                       CS_MODIFIER_PUBLIC |
+                       CS_MODIFIER_VIRTUAL |
+                       CS_MODIFIER_METHOD_HIDE_BY_SIG |
+                       CS_MODIFIER_METHOD_COMPILER_CONTROLED,
                        member->returnType,
                        ILQualIdentSimple(ILInternString("EndInvoke", 
-1).string),
                        0,
                        (ILNode*)params,
                        0);
-       
-       yysetfilename((ILNode*)decl,yygetfilename(member));
-       yysetlinenum((ILNode*)decl, yygetlinenum(member));
+       CloneLine((ILNode *)decl, (ILNode *)member);
 
-       CreateMethod(info, classInfo, decl);
+       CreateMethod(info, classNode, decl);
        method = member->endInvokeMethod = decl->methodInfo;
        if(method)
        {
@@ -2782,7 +3567,7 @@ static void FixNonInterfaceMethods(ILClass *classInfo)
  * Create the members of a class node.
  */
 static void CreateMembers(ILGenInfo *info, ILScope *globalScope,
-                                                 ILNode *classNode)
+                                                 ILNode_ClassDefn *classNode)
 {
        ILClass *classInfo;
        ILNode *body;
@@ -2795,7 +3580,7 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
        const char *defaultMemberName;
 
        /* Get the class information block, and bail out if not defined */
-       classInfo = ((ILNode_ClassDefn *)classNode)->classInfo;
+       classInfo = classNode->classInfo;
        if(!classInfo || classInfo == ((ILClass *)1) ||
           classInfo == ((ILClass *)2))
        {
@@ -2803,7 +3588,7 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
        }
 
        /* Get the class body and the scope it is declared within */
-       body = ((ILNode_ClassDefn *)classNode)->body;
+       body = classNode->body;
        if(body && yykind(body) == yykindof(ILNode_ScopeChange))
        {
                scope = ((ILNode_ScopeChange *)body)->scope;
@@ -2818,9 +3603,9 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
        savedScope = info->currentScope;
        info->currentScope = scope;
        savedClass = info->currentClass;
-       info->currentClass = classNode;
+       info->currentClass = (ILNode *)classNode;
        savedNamespace = info->currentNamespace;
-       info->currentNamespace = ((ILNode_ClassDefn *)classNode)->namespaceNode;
+       info->currentNamespace = classNode->namespaceNode;
 
        /* Iterate over the member definitions in the class body */
        defaultMemberName = 0;
@@ -2829,11 +3614,11 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
        {
                if(yykind(member) == yykindof(ILNode_FieldDeclaration))
                {
-                       CreateField(info, classInfo, (ILNode_FieldDeclaration 
*)member);
+                       CreateField(info, classNode, (ILNode_FieldDeclaration 
*)member);
                }
                else if(yykind(member) == yykindof(ILNode_MethodDeclaration))
                {
-                       CreateMethod(info, classInfo,
+                       CreateMethod(info, classNode,
                                                 (ILNode_MethodDeclaration 
*)member);
                }
                else if(yykind(member) == 
yykindof(ILNode_EnumMemberDeclaration))
@@ -2843,18 +3628,18 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
                }
                else if(yykind(member) == yykindof(ILNode_PropertyDeclaration))
                {
-                       CreateProperty(info, classInfo,
+                       CreateProperty(info, classNode,
                                                   (ILNode_PropertyDeclaration 
*)member,
                                                   &defaultMemberName);
                }
                else if(yykind(member) == yykindof(ILNode_EventDeclaration))
                {
-                       CreateEvent(info, classInfo,
+                       CreateEvent(info, classNode,
                                                (ILNode_EventDeclaration 
*)member);
                }
                else if(yykind(member) == 
yykindof(ILNode_DelegateMemberDeclaration))
                {
-                       CreateDelegateMember(info, classInfo,
+                       CreateDelegateMember(info, classNode,
                                                                 
(ILNode_DelegateMemberDeclaration *)member);
                }
                else if(yykind(member) == yykindof(ILNode_ClassDefn))
@@ -2871,14 +3656,14 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
 
        /* process the nested classes in the order of creation , rather than
         * occurrence in source */
-       if(((ILNode_ClassDefn*)classNode)->nestedClasses)
+       if(classNode->nestedClasses)
        {
-               ILNode_ListIter_Init(&iterator, 
((ILNode_ClassDefn*)classNode)->nestedClasses);
+               ILNode_ListIter_Init(&iterator, classNode->nestedClasses);
                while((member = ILNode_ListIter_Next(&iterator)) != 0)
                {
                        if(yykind(member) == yykindof(ILNode_ClassDefn))
                        {
-                               CreateMembers(info, globalScope, member);
+                               CreateMembers(info, globalScope, 
(ILNode_ClassDefn *)member);
                        }
                }
        }
@@ -2886,14 +3671,14 @@ static void CreateMembers(ILGenInfo *info, ILScope 
*globalScope,
        /* Add the "DefaultMember" attribute to the class if necessary */
        if(defaultMemberName)
        {
-               ((ILNode_ClassDefn *)classNode)->defaultMemberName = 
defaultMemberName;
+               classNode->defaultMemberName = defaultMemberName;
        }
 
        /* If the class is not abstract then make sure that all abstract
           methods in ancestor classes have been implemented here */
        if(!ILClass_IsAbstract(classInfo))
        {
-               CheckAbstractOverrides(info, classInfo, classNode);
+               CheckAbstractOverrides(info, classInfo, (ILNode *)classNode);
        }
 
        /* Fix up "public final virtual" methods that we thought we
@@ -2915,19 +3700,20 @@ static void DeclareTypes(ILGenInfo *info, ILScope 
*parentScope,
 {
        ILNode_ListIter iterator;
        ILNode *child;
-       ILNode_ClassDefn *defn;
-       ILScope *scope;
-       ILScope *aliasScope;
-       ILNode *origDefn;
-       const char *name;
-       const char *namespace;
-       int error;
 
        ILNode_ListIter_Init(&iterator, tree);
        while((child = ILNode_ListIter_Next(&iterator)) != 0)
        {
                if(yykind(child) == yykindof(ILNode_ClassDefn))
                {
+                       ILNode_ClassDefn *defn;
+                       ILScope *scope;
+                       ILScope *aliasScope;
+                       ILNode *origDefn;
+                       const char *name;
+                       const char *namespace;
+                       int error;
+
                        defn = (ILNode_ClassDefn *)child;
                        defn->nestedParent = nestedParent;
                        name = defn->name;
@@ -2958,8 +3744,8 @@ static void DeclareTypes(ILGenInfo *info, ILScope 
*parentScope,
                #endif  /* IL_VERSION_MAJOR > 1 */
 
                        error = ILScopeDeclareType(parentScope, child,
-                                                                          
name, namespace, &scope,
-                                                                          
&origDefn,aliasScope);
+                                                                          
name, namespace, &scope,
+                                                                          
&origDefn, aliasScope);
 
                        if(error != IL_SCOPE_ERROR_OK)
                        {
@@ -3083,7 +3869,7 @@ ILNode *CSTypeGather(ILGenInfo *info, ILScope 
*globalScope, ILNode *tree)
        ILNode_ListIter_Init(&iterator, list);
        while((child = ILNode_ListIter_Next(&iterator)) != 0)
        {
-               CreateMembers(info, globalScope, child);
+               CreateMembers(info, globalScope, (ILNode_ClassDefn *)child);
        }
 
        /* Return the new top-level list to the caller */
diff --git a/cscc/csharp/cs_grammar.y b/cscc/csharp/cs_grammar.y
index 906773d..c574dc3 100644
--- a/cscc/csharp/cs_grammar.y
+++ b/cscc/csharp/cs_grammar.y
@@ -309,7 +309,7 @@ static int ClassNameSame(ILNode *name)
 {
        return (strcmp(((ILNode_Identifier *)name)->name,
           ((ILNode_Identifier *)(classNameStack[classNameStackSize - 
1]))->name)
-                               == 0);
+                               == 0);
 }
 
 /*
@@ -579,71 +579,78 @@ static ILNode *GetIndexerName(ILGenInfo 
*info,ILNode_AttributeTree *attrTree,
 #define CS_PROPERTY_ACCESSOR_MODIFIERS \
                (CS_MODIFIER_PRIVATE | CS_MODIFIER_PROTECTED | 
CS_MODIFIER_INTERNAL)
 
-static ILUInt32 GetAccessorAttrs(ILUInt32 propertyAttrs,
-                                                                ILUInt32 
accessorAttrs,
-                                                                const char 
*filename,
-                                                                long linenum)
+static ILUInt32 GetAccessorModifiers(ILUInt32 propertyModifiers,
+                                                                        
ILUInt32 accessorModifiers,
+                                                                        const 
char *filename,
+                                                                        long 
linenum)
 {
-       ILUInt32 attrs;
+       ILUInt32 modifiers;
 
-       if(accessorAttrs == 0)
+       if(accessorModifiers == 0)
        {
-               return propertyAttrs;
+               if((propertyModifiers & CS_MODIFIER_PROPERTY_INTERFACE) != 0)
+               {
+                       return propertyModifiers | 
CS_MODIFIER_METHOD_INTERFACE_ACCESSOR;
+               }
+               else
+               {
+                       return propertyModifiers | 
CS_MODIFIER_METHOD_PROPERTY_ACCESSOR;
+               }
        }
-       if((accessorAttrs & ~CS_PROPERTY_ACCESSOR_MODIFIERS) != 0)
+       if((accessorModifiers & ~CS_PROPERTY_ACCESSOR_MODIFIERS) != 0)
        {
                CCErrorOnLine(filename, linenum,
                                          "Invalid modifier used for accessor");
-               return propertyAttrs;
+               return propertyModifiers;
        }
-       if((accessorAttrs & CS_MODIFIER_PRIVATE) != 0)
+       if((accessorModifiers & CS_MODIFIER_PRIVATE) != 0)
        {
-               if((accessorAttrs & CS_MODIFIER_PROTECTED) != 0)
+               if((accessorModifiers & CS_MODIFIER_PROTECTED) != 0)
                {
                        CCErrorOnLine(filename, linenum,
                                                  "cannot use both `private' 
and `protected'");
                }
-               if((accessorAttrs & CS_MODIFIER_INTERNAL) != 0)
+               if((accessorModifiers & CS_MODIFIER_INTERNAL) != 0)
                {
                        CCErrorOnLine(filename, linenum,
                                                  "cannot use both `private' 
and `internal'");
                }
-               attrs = IL_META_METHODDEF_PRIVATE;
+               modifiers = CS_MODIFIER_PRIVATE;
        }
        else
        {
-               attrs = 0;
+               modifiers = 0;
 
-               if((accessorAttrs & CS_MODIFIER_PROTECTED) != 0)
+               if((accessorModifiers & CS_MODIFIER_PROTECTED) != 0)
                {
-                       if((accessorAttrs & CS_MODIFIER_INTERNAL) != 0)
+                       if((accessorModifiers & CS_MODIFIER_INTERNAL) != 0)
                        {
-                               attrs = IL_META_METHODDEF_FAM_OR_ASSEM;
+                               modifiers = (CS_MODIFIER_PROTECTED | 
CS_MODIFIER_INTERNAL);
                        }
                        else
                        {
-                               attrs = IL_META_METHODDEF_FAMILY;
+                               modifiers = CS_MODIFIER_PROTECTED;
                        }
                }
                else
                {
-                       attrs = IL_META_METHODDEF_ASSEM;
+                       modifiers = CS_MODIFIER_INTERNAL;
                }
        }
        /* Now validate the visibility */
-       switch(propertyAttrs & IL_META_FIELDDEF_FIELD_ACCESS_MASK)
+       switch(propertyModifiers & CS_MODIFIER_ACCESS_MASK)
        {
-               case IL_META_FIELDDEF_PUBLIC:
+               case CS_MODIFIER_PUBLIC:
                {
-                       /* OK every accessor modifier is allowed */             
        
+                       /* OK every accessor modifier is allowed */
                }
                break;
 
-               case IL_META_FIELDDEF_FAM_OR_ASSEM:
+               case (CS_MODIFIER_PROTECTED | CS_MODIFIER_INTERNAL):
                {
-                       if((attrs == IL_META_METHODDEF_ASSEM) ||
-                          (attrs == IL_META_METHODDEF_FAMILY) ||
-                          (attrs == IL_META_METHODDEF_PRIVATE))
+                       if((modifiers == CS_MODIFIER_INTERNAL) ||
+                          (modifiers == CS_MODIFIER_PROTECTED) ||
+                          (modifiers == CS_MODIFIER_PRIVATE))
                        {
                                /* OK */
                        }
@@ -655,10 +662,10 @@ static ILUInt32 GetAccessorAttrs(ILUInt32 propertyAttrs,
                }
                break;
 
-               case IL_META_FIELDDEF_FAMILY:
-               case IL_META_FIELDDEF_ASSEMBLY:
+               case CS_MODIFIER_PROTECTED:
+               case CS_MODIFIER_INTERNAL:
                {
-                       if(attrs != IL_META_METHODDEF_PRIVATE)
+                       if(modifiers != CS_MODIFIER_PRIVATE)
                        {
                                CCErrorOnLine(filename, linenum,
                                                "only `private' is allowed in 
this context");
@@ -672,8 +679,8 @@ static ILUInt32 GetAccessorAttrs(ILUInt32 propertyAttrs,
                                                "no modifiers are allowed in 
this context");
                }
        }
-       attrs |= (propertyAttrs & ~IL_META_FIELDDEF_FIELD_ACCESS_MASK);
-       return attrs;
+       modifiers |= CS_MODIFIER_METHOD_PROPERTY_ACCESSOR;
+       return modifiers;
 }
 
 /*
@@ -724,17 +731,17 @@ static void 
CreatePropertyMethods(ILNode_PropertyDeclaration *property,
        /* Create the "get" method */
        if(accessors->getAccessor.present != 0)
        {
-               ILUInt32 attrs;
+               ILUInt32 modifiers;
 
                name = AdjustPropertyName(property->name, "get_");
-               attrs = GetAccessorAttrs(property->modifiers,
-                                                                
accessors->getAccessor.modifiers,
-                                                                
accessors->getAccessor.filename,
-                                                                
accessors->getAccessor.linenum);
+               modifiers = GetAccessorModifiers(property->modifiers,
+                                                                               
 accessors->getAccessor.modifiers,
+                                                                               
 accessors->getAccessor.filename,
+                                                                               
 accessors->getAccessor.linenum);
                decl = (ILNode_MethodDeclaration *)
                                ILNode_MethodDeclaration_create
                                                
(accessors->getAccessor.attributes,
-                                                attrs, property->type,
+                                                modifiers, property->type,
                                                 name, 0, property->params,
                                                 accessors->getAccessor.body);
                yysetfilename(decl, accessors->getAccessor.filename);
@@ -745,13 +752,13 @@ static void 
CreatePropertyMethods(ILNode_PropertyDeclaration *property,
        /* Create the "set" method */
        if(accessors->setAccessor.present != 0)
        {
-               ILUInt32 attrs;
+               ILUInt32 modifiers;
 
                name = AdjustPropertyName(property->name, "set_");
-               attrs = GetAccessorAttrs(property->modifiers,
-                                                                
accessors->setAccessor.modifiers,
-                                                                
accessors->setAccessor.filename,
-                                                                
accessors->setAccessor.linenum);
+               modifiers = GetAccessorModifiers(property->modifiers,
+                                                                               
 accessors->setAccessor.modifiers,
+                                                                               
 accessors->setAccessor.filename,
+                                                                               
 accessors->setAccessor.linenum);
                params = ILNode_List_create();
                ILNode_ListIter_Init(&iter, property->params);
                while((temp = ILNode_ListIter_Next(&iter)) != 0)
@@ -764,7 +771,7 @@ static void 
CreatePropertyMethods(ILNode_PropertyDeclaration *property,
                decl = (ILNode_MethodDeclaration *)
                        ILNode_MethodDeclaration_create
                                        (accessors->setAccessor.attributes,
-                                        attrs, 0, name, 0, params,
+                                        modifiers, 0, name, 0, params,
                                         accessors->setAccessor.body);
                yysetfilename(decl, accessors->setAccessor.filename);
                yysetlinenum(decl, accessors->setAccessor.linenum);
@@ -772,132 +779,6 @@ static void 
CreatePropertyMethods(ILNode_PropertyDeclaration *property,
        }
 }
 
-/*
- * Create the methods needed by an event declarator.
- */
-static void CreateEventDeclMethods(ILNode_EventDeclaration *event,
-                                                                  
ILNode_EventDeclarator *decl)
-{
-       ILNode_MethodDeclaration *method;
-       ILNode *eventName;
-       ILNode *name;
-       ILNode *addParams;
-       ILNode *removeParams;
-
-       /* Get the name of the event */
-       eventName = ((ILNode_FieldDeclarator *)(decl->fieldDeclarator))->name;
-
-       /* Create the parameter information for the "add" and "remove" methods 
*/
-       addParams = ILNode_List_create();
-       ILNode_List_Add(addParams,
-               ILNode_FormalParameter_create(0, ILParamMod_empty, event->type,
-                               ILQualIdentSimple(ILInternString("value", 
5).string)));
-       removeParams = ILNode_List_create();
-       ILNode_List_Add(removeParams,
-               ILNode_FormalParameter_create(0, ILParamMod_empty, event->type,
-                               ILQualIdentSimple(ILInternString("value", 
5).string)));
-
-       /* Create the "add" method */
-       name = AdjustPropertyName(eventName, "add_");
-       method = (ILNode_MethodDeclaration *)(decl->addAccessor);
-       if(!method && event->needFields)
-       {
-               /* Field-based event that needs a pre-defined body */
-               method = (ILNode_MethodDeclaration *)
-                       ILNode_MethodDeclaration_create
-                                       (0, event->modifiers, 0, name, 0, 
addParams, 0);
-               method->body = ILNode_NewScope_create
-                                                       (ILNode_AssignAdd_create
-                                                               
(ILNode_Add_create(eventName, 
-                                                                       
ILQualIdentSimple
-                                                                               
(ILInternString("value", 5).string))));
-               decl->addAccessor = (ILNode *)method;
-       }
-       else if(!method)
-       {
-               /* Abstract interface definition */
-               method = (ILNode_MethodDeclaration *)
-                       ILNode_MethodDeclaration_create
-                                       (0, event->modifiers, 0, name, 0, 
addParams, 0);
-               decl->addAccessor = (ILNode *)method;
-       }
-       else
-       {
-               /* Regular class definition */
-               method->modifiers = event->modifiers;
-               method->type = 0;
-               method->name = name;
-               method->params = addParams;
-       }
-       method->modifiers |= IL_META_METHODDEF_SPECIAL_NAME;
-
-       /* Create the "remove" method */
-       name = AdjustPropertyName(eventName, "remove_");
-       method = (ILNode_MethodDeclaration *)(decl->removeAccessor);
-       if(!method && event->needFields)
-       {
-               /* Field-based event that needs a pre-defined body */
-               method = (ILNode_MethodDeclaration *)
-                       ILNode_MethodDeclaration_create
-                                       (0, event->modifiers, 0, name, 0, 
removeParams, 0);
-               method->body = ILNode_NewScope_create
-                                                       (ILNode_AssignSub_create
-                                                               
(ILNode_Sub_create(eventName, 
-                                                                       
ILQualIdentSimple
-                                                                               
(ILInternString("value", 5).string))));
-               decl->removeAccessor = (ILNode *)method;
-       }
-       else if(!method)
-       {
-               /* Abstract interface definition */
-               method = (ILNode_MethodDeclaration *)
-                       ILNode_MethodDeclaration_create
-                                       (0, event->modifiers, 0, name, 0, 
removeParams, 0);
-               decl->removeAccessor = (ILNode *)method;
-       }
-       else
-       {
-               /* Regular class definition */
-               method->modifiers = event->modifiers;
-               method->type = 0;
-               method->name = name;
-               method->params = removeParams;
-       }
-       method->modifiers |= IL_META_METHODDEF_SPECIAL_NAME;
-}
-
-/*
- * Create the methods needed by an event definition.
- */
-static void CreateEventMethods(ILNode_EventDeclaration *event)
-{
-       ILNode_ListIter iter;
-       ILNode *decl;
-
-       if(yyisa(event->eventDeclarators, ILNode_EventDeclarator))
-       {
-               /* A single declarator indicates a property-style event */
-               event->needFields = 0;
-
-               /* Create the methods for the event declarator */
-               CreateEventDeclMethods
-                       (event, (ILNode_EventDeclarator 
*)(event->eventDeclarators));
-       }
-       else
-       {
-               /* A list of declarators indicates a field-style event */
-               event->needFields =
-                       ((event->modifiers & IL_META_METHODDEF_ABSTRACT) == 0);
-
-               /* Scan the list and create the methods that we require */
-               ILNode_ListIter_Init(&iter, event->eventDeclarators);
-               while((decl = ILNode_ListIter_Next(&iter)) != 0)
-               {
-                       CreateEventDeclMethods(event, (ILNode_EventDeclarator 
*)decl);
-               }
-       }
-}
-
 #if IL_VERSION_MAJOR > 1
 /*
  * Check if the generic constraints have a matching generic type
@@ -3367,81 +3248,27 @@ ClassDeclaration
                                /* Enter a new nesting level */
                                ++NestingLevel;
 
-                       #if IL_VERSION_MAJOR > 1
-                               /* ECMA 334 Version 4: 17.1.1.3 */
-                               if($1.modifiers & CS_MODIFIER_STATIC)
-                               {
-                                       if($1.modifiers & CS_MODIFIER_SEALED)
-                                       {
-                                               CCError(_("static classes must 
not be sealed"));
-                                       }
-                                       if($1.modifiers & CS_MODIFIER_ABSTRACT)
-                                       {
-                                               CCError(_("static classes must 
not be abstract"));
-                                       }
-                                       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. */
-                                       $1.modifiers |= (CS_MODIFIER_SEALED | 
CS_MODIFIER_ABSTRACT);
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
-
                                /* Push the identifier onto the class name 
stack */
                                ClassNamePush($1.identifier, $1.modifiers);
                        }
                        ClassBody OptSemiColon  {
                                ILNode *classBody = ($3).body;
-
-                               /* Validate the modifiers */
-                               ILUInt32 attrs =
-                       #if IL_VERSION_MAJOR > 1
-                                       CSModifiersToTypeAttrs($1.identifier, 
$1.modifiers & ~CS_MODIFIER_STATIC,
-                                                                               
   (NestingLevel > 1));
-                       #else   /* IL_VERSION_MAJOR == 1 */
-                                       CSModifiersToTypeAttrs($1.identifier, 
$1.modifiers, (NestingLevel > 1));
-                       #endif  /* IL_VERSION_MAJOR == 1 */
+                               ILUInt32 modifiers = $1.modifiers;
 
                                /* Exit the current nesting level */
                                --NestingLevel;
 
                                /* Determine if we need to add a default 
constructor */
-                       #if IL_VERSION_MAJOR > 1
-                               /* Don't add the default constructor for static 
classes. */
-                               if((($1.modifiers & CS_MODIFIER_STATIC) == 0) 
&& 
-                                  !ClassNameIsCtorDefined())
-                       #else   /* IL_VERSION_MAJOR == 1 */
-                               if(!ClassNameIsCtorDefined())
-                       #endif  /* IL_VERSION_MAJOR == 1 */
+                               if(ClassNameIsCtorDefined())
                                {
-                                       ILUInt32 ctorMods =
-                                               (((attrs & 
IL_META_TYPEDEF_ABSTRACT) != 0)
-                                                       ? CS_MODIFIER_PROTECTED 
: CS_MODIFIER_PUBLIC);
-                                       ILNode *cname = ILQualIdentSimple
-                                                       
(ILInternString(".ctor", 5).string);
-                                       ILNode *body = ILNode_NewScope_create
-                                                       
(ILNode_Compound_CreateFrom
-                                                               
(ILNode_NonStaticInit_create(),
-                                                                
ILNode_InvocationExpression_create
-                                                                       
(ILNode_BaseInit_create(), 0)));
-                                       ILNode *ctor = 
ILNode_MethodDeclaration_create
-                                                 (0, 
CSModifiersToConstructorAttrs(cname, ctorMods),
-                                                  0 /* "void" */, cname, 0,
-                                                  ILNode_Empty_create(), body);
-                                       if(!classBody)
-                                       {
-                                               classBody = 
ILNode_List_create();
-                                       }
-                                       ILNode_List_Add(classBody, ctor);
+                                       modifiers |= CS_MODIFIER_CTOR_DEFINED;
                                }
 
                                /* Create the class definition */
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
                                                        ($1.attributes,         
        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                        modifiers | 
CS_MODIFIER_TYPE_CLASS,
                                                         
ILQualIdentName($1.identifier, 0),/* Identifier */
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
@@ -3611,7 +3438,7 @@ ModuleDeclaration
                                ILNode *classBody = ($3).body;
 
                                /* Get the default modifiers */
-                               ILUInt32 attrs = IL_META_TYPEDEF_PUBLIC;
+                               ILUInt32 modifiers = CS_MODIFIER_PUBLIC;
 
                                /* Exit the current nesting level */
                                --NestingLevel;
@@ -3620,7 +3447,7 @@ ModuleDeclaration
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
                                                        (0,                     
                        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                        modifiers | 
CS_MODIFIER_TYPE_MODULE,
                                                         
ILInternString("<Module>", -1).string,
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
@@ -3761,8 +3588,9 @@ GenericMethodHeaderStart
 
 ConstantDeclaration
        : OptAttributesAndModifiers CONST Type ConstantDeclarators ';' {
-                               ILUInt32 attrs = CSModifiersToConstAttrs($3, 
$1.modifiers);
-                               $$ = 
ILNode_FieldDeclaration_create($1.attributes, attrs, $3, $4);
+                               $$ = 
ILNode_FieldDeclaration_create($1.attributes,
+                                                                               
                        $1.modifiers | CS_MODIFIER_FIELD_CONST,
+                                                                               
                        $3, $4);
                        }
        ;
 
@@ -3789,21 +3617,9 @@ ConstantDeclarator
 
 FieldDeclaration
        : MemberHeaderStart FieldDeclarators ';'        {
-                               ILUInt32 attrs = 
CSModifiersToFieldAttrs($1.type, $1.modifiers);
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       if(!($1.modifiers & CS_MODIFIER_STATIC))
-                                       {
-                                               CCError(_("only static fields 
are allowed in static classes"));
-                                       }
-                                       if($1.modifiers & CS_MODIFIER_PROTECTED)
-                                       {
-                                               CCError(_("no protected or 
protected internal fields are allowed in static classes"));
-                                       }
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
-                               $$ = 
ILNode_FieldDeclaration_create($1.attributes, attrs, $1.type, $2);
+                               $$ = 
ILNode_FieldDeclaration_create($1.attributes,
+                                                                               
                        $1.modifiers,
+                                                                               
                        $1.type, $2);
                        }
        ;
 
@@ -3860,29 +3676,15 @@ MethodHeader
 
 MethodDeclaration
        : 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($1.type), 
yygetlinenum($1.type),
                                                "`private' cannot be used in 
this context");
                                }
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       if(!($1.modifiers & CS_MODIFIER_STATIC))
-                                       {
-                                               CCError(_("only static methods 
are allowed in static classes"));
-                                       }
-                                       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.attributes,
-                                                attrs,
+                                                $1.modifiers,
                                                 $1.type,
                                                 $1.identifier,
                                                 (ILNode *)$1.typeFormals,
@@ -3936,25 +3738,9 @@ ParameterModifier
 PropertyDeclaration
        : NonGenericMethodAndPropertyHeaderStart
                        StartAccessorBlock AccessorBlock        {
-                               ILUInt32 attrs;
-
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       if(!($1.modifiers & CS_MODIFIER_STATIC))
-                                       {
-                                               CCError(_("only static 
properties are allowed in static classes"));
-                                       }
-                                       if($1.modifiers & CS_MODIFIER_PROTECTED)
-                                       {
-                                               CCError(_("no protected or 
protected internal properties are allowed in static classes"));
-                                       }
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
                                /* Create the property declaration */
-                               attrs = CSModifiersToPropertyAttrs($1.type, 
$1.modifiers);
                                $$ = 
ILNode_PropertyDeclaration_create($1.attributes,
-                                                                  attrs, 
$1.type, $1.identifier, 0, 0, 0,
+                                                                  
$1.modifiers, $1.type, $1.identifier, 0, 0, 0,
                                                                   
(($3.getAccessor.present ? 1 : 0) |
                                                                    
($3.setAccessor.present ? 2 : 0)));
                                CloneLine($$, $1.identifier);
@@ -4073,22 +3859,8 @@ EventDeclaration
 
 EventFieldDeclaration
        : OptAttributesAndModifiers EVENT Type EventDeclarators ';'     {
-                               ILUInt32 attrs = CSModifiersToEventAttrs($3, 
$1.modifiers);
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       if(!($1.modifiers & CS_MODIFIER_STATIC))
-                                       {
-                                               CCError(_("only static events 
are allowed in static classes"));
-                                       }
-                                       if($1.modifiers & CS_MODIFIER_PROTECTED)
-                                       {
-                                               CCError(_("no protected or 
protected internal events are allowed in static classes"));
-                                       }
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
-                               $$ = 
ILNode_EventDeclaration_create($1.attributes, attrs, $3, $4);
-                               CreateEventMethods((ILNode_EventDeclaration 
*)($$));
+                               $$ = 
ILNode_EventDeclaration_create($1.attributes, $1.modifiers, $3, $4);
+                               CloneLine($$, $3);
                        }
        ;
 
@@ -4106,26 +3878,32 @@ EventDeclarators
 
 EventDeclarator
        : Identifier                                                    {
-                               $$ = ILNode_EventDeclarator_create
-                                               
(ILNode_FieldDeclarator_create($1, 0), 0, 0);
+                               ILNode *field;
+
+                               field = ILNode_FieldDeclarator_create($1, 0);
+                               $$ = ILNode_EventDeclarator_create(field, 0, 0);
                        }
        | Identifier '=' VariableInitializer    {
-                               $$ = ILNode_EventDeclarator_create
-                                               
(ILNode_FieldDeclarator_create($1, $3), 0, 0);
+                               ILNode *field;
+
+                               field = ILNode_FieldDeclarator_create($1, $3);
+                               $$ = ILNode_EventDeclarator_create(field, 0, 0);
                        }
        ;
 
 EventPropertyDeclaration
        : OptAttributesAndModifiers EVENT Type QualifiedIdentifier
                        StartAccessorBlock EventAccessorBlock   {
-                               ILUInt32 attrs = CSModifiersToEventAttrs($3, 
$1.modifiers);
-                               $$ = ILNode_EventDeclaration_create
-                                       ($1.attributes, attrs, $3, 
-                                               ILNode_EventDeclarator_create
-                                                       
(ILNode_FieldDeclarator_create($4, 0),
-                                                        $6.item1, $6.item2));
-                               CloneLine($$, $4);
-                               CreateEventMethods((ILNode_EventDeclaration 
*)($$));
+                               ILNode *fieldDeclarator;
+                               ILNode *eventDeclarator;
+
+                               fieldDeclarator = 
ILNode_FieldDeclarator_create($4, 0);
+                               eventDeclarator = 
ILNode_EventDeclarator_create(fieldDeclarator,
+                                                                               
                                                $6.item1,
+                                                                               
                                                $6.item2);
+                               $$ = 
ILNode_EventDeclaration_create($1.attributes,
+                                                                               
                        $1.modifiers, $3,
+                                                                               
                        eventDeclarator);
                        }
        ;
 
@@ -4183,7 +3961,6 @@ IndexerDeclaration
                        StartAccessorBlock AccessorBlock                {
                                ILNode* 
name=GetIndexerName(&CCCodeGen,(ILNode_AttributeTree*)$1.attributes,
                                                        $2.ident);
-                               ILUInt32 attrs = 
CSModifiersToPropertyAttrs($1.type, $1.modifiers);
 
                        #if IL_VERSION_MAJOR > 1
                                if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
@@ -4200,7 +3977,7 @@ IndexerDeclaration
                        #endif  /* IL_VERSION_MAJOR > 1 */
 
                                $$ = 
ILNode_PropertyDeclaration_create($1.attributes,
-                                                                  attrs, 
$1.type, name, $2.params,
+                                                                  
$1.modifiers, $1.type, name, $2.params,
                                                                   0, 0,
                                                                   
(($4.getAccessor.present ? 1 : 0) |
                                                                    
($4.setAccessor.present ? 2 : 0)));
@@ -4264,7 +4041,6 @@ OperatorDeclaration
 NormalOperatorDeclaration
        : MemberHeaderStart OPERATOR OverloadableOperator
                        '(' Type Identifier ')' Block {
-                               ILUInt32 attrs;
                                ILNode *params;
 
                                /* Validate the name of the unary operator */
@@ -4274,16 +4050,6 @@ NormalOperatorDeclaration
                                        $3.unary = $3.binary;
                                }
 
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       CCError(_("no operators are allowed in 
static classes"));
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
-
-                               /* Get the operator attributes */
-                               attrs = CSModifiersToOperatorAttrs($1.type, 
$1.modifiers);
-
                                /* Build the formal parameter list */
                                params = ILNode_List_create();
                                ILNode_List_Add(params,
@@ -4291,14 +4057,14 @@ NormalOperatorDeclaration
 
                                /* Create a method definition for the operator 
*/
                                $$ = ILNode_MethodDeclaration_create
-                                               ($1.attributes, attrs, $1.type,
+                                               ($1.attributes,
+                                                $1.modifiers | 
CS_MODIFIER_METHOD_OPERATOR, $1.type,
                                                 
ILQualIdentSimple(ILInternString($3.unary, -1).string),
                                                 0, params, $8);
                                CloneLine($$, $1.type);
                        }
        | MemberHeaderStart OPERATOR OverloadableOperator
                        '(' Type Identifier ',' Type Identifier ')' Block       
{
-                               ILUInt32 attrs;
                                ILNode *params;
 
                                /* Validate the name of the binary operator */
@@ -4308,16 +4074,6 @@ NormalOperatorDeclaration
                                        $3.binary = $3.unary;
                                }
 
-                       #if IL_VERSION_MAJOR > 1
-                               if(ClassNameGetModifiers() & CS_MODIFIER_STATIC)
-                               {
-                                       CCError(_("no operators are allowed in 
static classes"));
-                               }
-                       #endif  /* IL_VERSION_MAJOR > 1 */
-
-                               /* Get the operator attributes */
-                               attrs = CSModifiersToOperatorAttrs($1.type, 
$1.modifiers);
-
                                /* Build the formal parameter list */
                                params = ILNode_List_create();
                                ILNode_List_Add(params,
@@ -4329,7 +4085,8 @@ NormalOperatorDeclaration
 
                                /* Create a method definition for the operator 
*/
                                $$ = ILNode_MethodDeclaration_create
-                                               ($1.attributes, attrs, $1.type,
+                                               ($1.attributes,
+                                                $1.modifiers | 
CS_MODIFIER_METHOD_OPERATOR, $1.type,
                                                 ILQualIdentSimple
                                                        
(ILInternString($3.binary, -1).string),
                                                 0, params, $11);
@@ -4365,12 +4122,8 @@ OverloadableOperator
 ConversionOperatorDeclaration
        : OptAttributesAndModifiers IMPLICIT OPERATOR Type
                        '(' Type Identifier ')' Block   {
-                               ILUInt32 attrs;
                                ILNode *params;
 
-                               /* Get the operator attributes */
-                               attrs = CSModifiersToOperatorAttrs($4, 
$1.modifiers);
-
                                /* Build the formal parameter list */
                                params = ILNode_List_create();
                                ILNode_List_Add(params,
@@ -4378,7 +4131,8 @@ ConversionOperatorDeclaration
 
                                /* Create a method definition for the operator 
*/
                                $$ = ILNode_MethodDeclaration_create
-                                               ($1.attributes, attrs, $4,
+                                               ($1.attributes,
+                                                $1.modifiers | 
CS_MODIFIER_METHOD_OPERATOR, $4,
                                                 ILQualIdentSimple
                                                        
(ILInternString("op_Implicit", -1).string),
                                                 0, params, $9);
@@ -4386,12 +4140,8 @@ ConversionOperatorDeclaration
                        }
        | OptAttributesAndModifiers EXPLICIT OPERATOR Type
                        '(' Type Identifier ')' Block   {
-                               ILUInt32 attrs;
                                ILNode *params;
 
-                               /* Get the operator attributes */
-                               attrs = CSModifiersToOperatorAttrs($4, 
$1.modifiers);
-
                                /* Build the formal parameter list */
                                params = ILNode_List_create();
                                ILNode_List_Add(params,
@@ -4399,7 +4149,8 @@ ConversionOperatorDeclaration
 
                                /* Create a method definition for the operator 
*/
                                $$ = ILNode_MethodDeclaration_create
-                                               ($1.attributes, attrs, $4,
+                                               ($1.attributes,
+                                                $1.modifiers | 
CS_MODIFIER_METHOD_OPERATOR, $4,
                                                 ILQualIdentSimple
                                                        
(ILInternString("op_Explicit", -1).string),
                                                 0, params, $9);
@@ -4414,7 +4165,6 @@ ConversionOperatorDeclaration
 ConstructorDeclaration
        : OptAttributesAndModifiers Identifier
                        '(' OptFormalParameterList ')' ConstructorInitializer 
MethodBody {
-                               ILUInt32 attrs = 
CSModifiersToConstructorAttrs($2, $1.modifiers);
                                ILNode *ctorName;
                                ILNode *cname;
                                ILNode *initializer = $6;
@@ -4430,7 +4180,7 @@ ConstructorDeclaration
                                }
                        #endif  /* IL_VERSION_MAJOR > 1 */
 
-                               if((attrs & IL_META_METHODDEF_STATIC) != 0)
+                               if(($1.modifiers & CS_MODIFIER_STATIC) != 0)
                                {
                                        cname = ILQualIdentSimple
                                                                
(ILInternString(".cctor", 6).string);
@@ -4456,7 +4206,7 @@ ConstructorDeclaration
                                                ILNode_Compound_CreateFrom
                                                        (initializer, 
((ILNode_NewScope *)body)->stmt);
                                }
-                               else if($7 || (attrs & CS_SPECIALATTR_EXTERN) 
== 0)
+                               else if($7 || ($1.modifiers & 
CS_MODIFIER_EXTERN) == 0)
                                {
                                        /* Non-scoped body: create a new scoped 
body */
                                        body = ILNode_NewScope_create
@@ -4469,7 +4219,7 @@ ConstructorDeclaration
                                        /* Extern constructor with an empty 
body */
                                        body = 0;
                                }
-                               if((attrs & IL_META_METHODDEF_STATIC) != 0)
+                               if(($1.modifiers & CS_MODIFIER_STATIC) != 0)
                                {
                                        if(!yyisa($4,ILNode_Empty))
                                        {
@@ -4482,7 +4232,8 @@ ConstructorDeclaration
                                else
                                {
                                        $$.body = 
ILNode_MethodDeclaration_create
-                                                 ($1.attributes, attrs, 0 /* 
"void" */, cname, 0, $4, body);
+                                                 ($1.attributes, $1.modifiers 
| CS_MODIFIER_METHOD_CONSTRUCTOR,
+                                                  0 /* "void" */, cname, 0, 
$4, body);
                                        CloneLine($$.body, $2);
                                        $$.staticCtors = 0;
                                }
@@ -4509,7 +4260,6 @@ ConstructorInitializer
 
 DestructorDeclaration
        : OptAttributesAndModifiers '~' Identifier '(' ')' Block                
{
-                               ILUInt32 attrs;
                                ILNode *dtorName;
                                ILNode *name;
                                ILNode *body;
@@ -4533,9 +4283,6 @@ DestructorDeclaration
                                                "destructor name does not match 
class name");
                                }
 
-                               /* Build the list of attributes needed on 
"Finalize" */
-                               attrs = CSModifiersToDestructorAttrs($3, 
$1.modifiers);
-
                                /* Build the name of the "Finalize" method */
                                name = 
ILQualIdentSimple(ILInternString("Finalize", -1).string);
 
@@ -4553,7 +4300,9 @@ DestructorDeclaration
 
                                /* Construct the finalizer declaration */
                                $$ = ILNode_MethodDeclaration_create
-                                                       ($1.attributes, attrs, 
0 /* void */,
+                                                       ($1.attributes,
+                                                        $1.modifiers | 
CS_MODIFIER_METHOD_DESTRUCTOR,
+                                                        0 /* void */,
                                                         ILQualIdentSimple
                                                                
(ILInternString("Finalize", -1).string),
                                                         0, 0, body);
@@ -4604,38 +4353,19 @@ StructDeclaration
                                ClassNamePush($1.identifier, $1.modifiers);
                        }
                        StructBody OptSemiColon {
-                               ILNode *baseList;
-                               ILUInt32 attrs;
-
-                               /* Validate the modifiers */
-                               attrs = CSModifiersToTypeAttrs($1.identifier, 
$1.modifiers,
-                                                                               
           (NestingLevel > 1));
-
-                               /* Add extra attributes that structs need */
-                               attrs |= IL_META_TYPEDEF_LAYOUT_SEQUENTIAL |
-                                                IL_META_TYPEDEF_SERIALIZABLE |
-                                                IL_META_TYPEDEF_SEALED;
-
                                /* Exit the current nesting level */
                                --NestingLevel;
 
-                               /* Make sure that we have "ValueType" in the 
base list */
-                               baseList = MakeSystemType("ValueType");
-                               if($1.classBase != 0)
-                               {
-                                       baseList = 
ILNode_ArgList_create($1.classBase, baseList);
-                               }
-
                                /* Create the class definition */
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
                                                        ($1.attributes,         
        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                        $1.modifiers | 
CS_MODIFIER_TYPE_STRUCT,
                                                         
ILQualIdentName($1.identifier, 0),/* Identifier */
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
                                                         (ILNode 
*)$1.typeFormals, /* TypeFormals */
-                                                        baseList,              
                /* ClassBase */
+                                                        ($1).classBase,        
        /* ClassBase */
                                                         ($3).body,             
                /* StructBody */
                                                         ($3).staticCtors);     
        /* StaticCtors */
                                CloneLine($$, $1.identifier);
@@ -4708,15 +4438,6 @@ InterfaceDeclaration
                                ClassNamePush($1.identifier, $1.modifiers);
                        }
                        InterfaceBody OptSemiColon      {
-                               /* Validate the modifiers */
-                               ILUInt32 attrs =
-                                       CSModifiersToTypeAttrs($1.identifier, 
$1.modifiers,
-                                                                               
   (NestingLevel > 1));
-
-                               /* Add extra attributes that interfaces need */
-                               attrs |= IL_META_TYPEDEF_INTERFACE |
-                                                IL_META_TYPEDEF_ABSTRACT;
-
                                /* Exit from the current nesting level */
                                --NestingLevel;
 
@@ -4724,7 +4445,7 @@ InterfaceDeclaration
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
                                                        ($1.attributes,         
        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                        $1.modifiers | 
CS_MODIFIER_TYPE_INTERFACE,
                                                         
ILQualIdentName($1.identifier, 0),/* Identifier */
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
@@ -4815,15 +4536,9 @@ InterfaceMethodHeader
 
 InterfaceMethodDeclaration
        : 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.attributes,
-                                                attrs,
+                                                $1.modifiers | 
CS_MODIFIER_METHOD_INTERFACE,
                                                 $1.type,
                                                 $1.identifier,
                                                 (ILNode *)$1.typeFormals,
@@ -4835,21 +4550,16 @@ InterfaceMethodDeclaration
 
 OptNew
        : /* empty */   { $$ = 0; }
-       | NEW                   { $$ = 1; }
+       | NEW                   { $$ = CS_MODIFIER_NEW; }
        ;
 
 InterfacePropertyDeclaration
        : OptAttributes OptNew Type Identifier
                        StartInterfaceAccessorBody InterfaceAccessorBody        
{
-                               ILUInt32 attrs = ($2 ? 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_SPECIAL_NAME |
-                                                                
IL_META_METHODDEF_NEW_SLOT;
                                $$ = ILNode_PropertyDeclaration_create
-                                                               ($1, attrs, $3, 
$4, 0, 0, 0,
+                                                               ($1,
+                                                                $2 | 
CS_MODIFIER_PROPERTY_INTERFACE,
+                                                                $3, $4, 0, 0, 
0,
                                                                 
(($6.getAccessor.present ? 1 : 0) |
                                                                  
($6.setAccessor.present ? 2 : 0)));
                                CloneLine($$, $4);
@@ -4969,34 +4679,24 @@ InterfaceAccessors
 
 InterfaceEventDeclaration
        : OptAttributes OptNew EVENT Type Identifier ';'                {
-                               ILUInt32 attrs = ($2 ? 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;
+                               ILUInt32 modifiers;
+
+                               modifiers = $2 | CS_MODIFIER_EVENT_INTERFACE;
                                $$ = ILNode_EventDeclaration_create
-                                                       ($1, attrs, $4,
+                                                       ($1, modifiers, $4,
                                                         
ILNode_EventDeclarator_create
                                                                
(ILNode_FieldDeclarator_create($5, 0), 0, 0));
-                               CreateEventMethods((ILNode_EventDeclaration 
*)($$));
                        }
        ;
 
 InterfaceIndexerDeclaration
        : OptAttributes OptNew Type THIS FormalIndexParameters
                        StartInterfaceAccessorBody InterfaceAccessorBody        
{
-                               ILUInt32 attrs = ($2 ? 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_SPECIAL_NAME |
-                                                                
IL_META_METHODDEF_NEW_SLOT;
+                               ILUInt32 modifiers = $2 | 
CS_MODIFIER_PROPERTY_INTERFACE;
                                ILNode* 
name=GetIndexerName(&CCCodeGen,(ILNode_AttributeTree*)$1,
                                                                
ILQualIdentSimple(NULL));
                                $$ = ILNode_PropertyDeclaration_create
-                                                               ($1, attrs, $3, 
name, $5, 0, 0,
+                                                               ($1, modifiers, 
$3, name, $5, 0, 0,
                                                                 
(($7.getAccessor.present ? 1 : 0) |
                                                                  
($7.setAccessor.present ? 2 : 0)));
                                CloneLine($$, $3);
@@ -5019,24 +4719,12 @@ EnumDeclaration
                                ClassNamePush($3, $1.modifiers);
                        }
                        EnumBody OptSemiColon   {
-                               ILNode *baseList;
                                ILNode *bodyList;
                                ILNode *fieldDecl;
-                               ILUInt32 attrs;
-
-                               /* Validate the modifiers */
-                               attrs = CSModifiersToTypeAttrs($3, 
$1.modifiers, (NestingLevel > 1));
-
-                               /* Add extra attributes that enums need */
-                               attrs |= IL_META_TYPEDEF_SERIALIZABLE |
-                                                IL_META_TYPEDEF_SEALED;
 
                                /* Exit the current nesting level */
                                --NestingLevel;
 
-                               /* Make sure that we have "Enum" in the base 
list */
-                               baseList = MakeSystemType("Enum");
-
                                /* Add an instance field called "value__" to 
the body,
                                   which is used to hold the enumerated value */
                                bodyList = $6;
@@ -5051,20 +4739,20 @@ EnumDeclaration
                                MakeBinary(FieldDeclarator, $1.attributes, 0);
                                ILNode_List_Add(bodyList,
                                        ILNode_FieldDeclaration_create
-                                               (0, IL_META_FIELDDEF_PUBLIC |
-                                                       
IL_META_FIELDDEF_SPECIAL_NAME |
-                                                       
IL_META_FIELDDEF_RT_SPECIAL_NAME, $4, fieldDecl));
+                                               (0, CS_MODIFIER_PUBLIC |
+                                                       
CS_MODIFIER_FIELD_SPECIAL_NAME |
+                                                       
CS_MODIFIER_FIELD_RT_SPECIAL_NAME, $4, fieldDecl));
 
                                /* Create the class definition */
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
-                                                       ($1.attributes,         
                        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                       ($1.attributes,         
        /* OptAttributes */
+                                                        $1.modifiers | 
CS_MODIFIER_TYPE_ENUM,
                                                         ILQualIdentName($3, 
0),/* Identifier */
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
                                                         0,                     
                        /* TypeFormals */
-                                                        baseList,              
                /* ClassBase */
+                                                        0,                     
                        /* ClassBase */
                                                         bodyList,              
                /* EnumBody */
                                                         0);                    
                /* StaticCtors */
                                CloneLine($$, $3);
@@ -5171,17 +4859,7 @@ DelegateHeader
 
 DelegateDeclaration
        : DelegateHeader ';'    {
-                               ILNode *baseList;
                                ILNode *bodyList;
-                               ILUInt32 attrs;
-
-                               /* Validate the modifiers */
-                               attrs = 
CSModifiersToDelegateAttrs($1.identifier, $1.modifiers,
-                                                                               
                   (NestingLevel > 0));
-
-                               /* Make sure that we have "MulticastDelegate"
-                                  in the base list */
-                               baseList = MakeSystemType("MulticastDelegate");
 
                                /* Construct the body of the delegate class */
                                bodyList = ILNode_List_create();
@@ -5193,12 +4871,12 @@ DelegateDeclaration
                                InitGlobalNamespace();
                                $$ = ILNode_ClassDefn_create
                                                        ($1.attributes,         
        /* OptAttributes */
-                                                        attrs,                 
                /* OptModifiers */
+                                                        $1.modifiers | 
CS_MODIFIER_TYPE_DELEGATE,
                                                         
ILQualIdentName($1.identifier, 0),/* Identifier */
                                                         CurrNamespace.string,  
/* Namespace */
                                                         (ILNode 
*)CurrNamespaceNode,
                                                         (ILNode 
*)$1.typeFormals, /* TypeFormals */
-                                                        baseList,              
                /* ClassBase */
+                                                        0,                     
                        /* ClassBase */
                                                         bodyList,              
                /* Body */
                                                         0);                    
                /* StaticCtors */
                                CloneLine($$, $1.identifier);
diff --git a/cscc/csharp/cs_internal.h b/cscc/csharp/cs_internal.h
index 4fb1427..f9e61ed 100644
--- a/cscc/csharp/cs_internal.h
+++ b/cscc/csharp/cs_internal.h
@@ -104,6 +104,52 @@ struct PropertyAccessors
 #define        CS_MODIFIER_EXTERN                      (1<<11)
 #define        CS_MODIFIER_UNSAFE                      (1<<12)
 #define        CS_MODIFIER_VOLATILE            (1<<13)
+#define        CS_MODIFIER_MASK                        (0x0000FFFF)
+
+/* Type specific modifier flags */
+/* Set if an instance  constructor is defined for the class */
+#define        CS_MODIFIER_CTOR_DEFINED        0x00010000
+#define CS_MODIFIER_TYPE_CLASS         0x00100000
+#define CS_MODIFIER_TYPE_STRUCT                0x00200000
+#define CS_MODIFIER_TYPE_INTERFACE     0x00300000
+#define CS_MODIFIER_TYPE_ENUM          0x00400000
+#define CS_MODIFIER_TYPE_DELEGATE      0x00500000
+#define CS_MODIFIER_TYPE_MODULE                0x00600000
+#define CS_MODIFIER_TYPE_MASK          0x00700000
+
+/* Event specific modifier flags */
+/* Set for interface events */
+#define        CS_MODIFIER_EVENT_INTERFACE                             
0x00010000
+
+/*
+ * Field specific modifier flags
+ */
+#define        CS_MODIFIER_FIELD_CONST                                 
0x00010000
+#define        CS_MODIFIER_FIELD_SPECIAL_NAME                  0x00020000
+#define        CS_MODIFIER_FIELD_RT_SPECIAL_NAME               0x00040000
+
+/*
+ * Property specific modifier flags
+ */
+#define        CS_MODIFIER_PROPERTY_INTERFACE                  0x00010000
+
+/*
+ * Method specific modifier flags
+ */
+#define        CS_MODIFIER_METHOD_SPECIAL_NAME                 0x00010000
+#define        CS_MODIFIER_METHOD_RT_SPECIAL_NAME              0x00020000
+#define        CS_MODIFIER_METHOD_COMPILER_CONTROLED   0x00040000
+#define        CS_MODIFIER_METHOD_HIDE_BY_SIG                  0x00080000
+#define        CS_MODIFIER_METHOD_NORMAL                               
0x00000000
+#define        CS_MODIFIER_METHOD_CONSTRUCTOR                  0x00100000
+#define        CS_MODIFIER_METHOD_DESTRUCTOR                   0x00200000
+#define        CS_MODIFIER_METHOD_OPERATOR                             
0x00300000
+#define        CS_MODIFIER_METHOD_INTERFACE                    0x00400000
+#define        CS_MODIFIER_METHOD_INTERFACE_ACCESSOR   0x00500000
+#define        CS_MODIFIER_METHOD_EVENT_ACCESSOR               0x00600000
+#define        CS_MODIFIER_METHOD_PROPERTY_ACCESSOR    0x00700000
+#define        CS_MODIFIER_METHOD_TYPE_MASK                    0x00700000
+
 
 /*
  * Special attribute flags.
@@ -294,6 +340,12 @@ void CSProcessAttrs(ILGenInfo *info, ILProgramItem *item,
                                        ILNode *attributes, int target);
 
 /*
+ * Process the attributes on a type definition.
+ */
+void CSProcessAttrsForClass(ILGenInfo *info, ILNode_ClassDefn *defn,
+                                                       int mainTarget);
+
+/*
  * Process the attributes on a method parameter.
  */
 void CSProcessAttrsForParam(ILGenInfo *info, ILMethod *method,
diff --git a/cscc/csharp/cs_invoke.tc b/cscc/csharp/cs_invoke.tc
index fd28110..c348002 100644
--- a/cscc/csharp/cs_invoke.tc
+++ b/cscc/csharp/cs_invoke.tc
@@ -121,7 +121,7 @@ ILNode_SemAnalysis(ILNode_VarArgList)
        method = (decl ? decl->methodInfo : 0);
        if(!method ||
           (ILMethodGetCallConv(method) & IL_META_CALLCONV_MASK)
-                       != IL_META_CALLCONV_VARARG)
+                       != IL_META_CALLCONV_VARARG)
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                          "`__arglist' must be used inside a 
vararg method");
@@ -572,7 +572,7 @@ ILNode_SemAnalysis(ILNode_InvocationExpression)
                    yyisa(((ILNode_MarkType *)(node->thisExpr))->expr, 
ILNode_This)))
                {
                        caller = (ILNode_MethodDeclaration 
*)(info->currentMethod);
-                       if(!caller || (caller->modifiers & 
IL_META_METHODDEF_STATIC) != 0)
+                       if(!caller || (caller->modifiers & CS_MODIFIER_STATIC) 
!= 0)
                        {
                                /* Attempt to call an instance method using 
"this"
                                   from within a static method */
@@ -687,7 +687,7 @@ CSSemValue DelegateCreationSem(ILGenInfo *info, ILNode 
*node,
                        {
                                caller = (ILNode_MethodDeclaration 
*)(info->currentMethod);
                                if(!caller || 
-                                       (caller->modifiers & 
IL_META_METHODDEF_STATIC) != 0)
+                                       (caller->modifiers & 
CS_MODIFIER_STATIC) != 0)
                                {
                                        /* Attempt to call an instance method 
using "this"
                                           from within a static method */
diff --git a/cscc/csharp/cs_lvalue.tc b/cscc/csharp/cs_lvalue.tc
index 3201f0f..6ae4046 100644
--- a/cscc/csharp/cs_lvalue.tc
+++ b/cscc/csharp/cs_lvalue.tc
@@ -28,7 +28,7 @@ static void CheckForInstanceAccess(ILGenInfo *info, ILNode 
*node)
 {
        ILNode_MethodDeclaration *caller;
        caller = (ILNode_MethodDeclaration *)(info->currentMethod);
-       if(!caller || (caller->modifiers & IL_META_METHODDEF_STATIC) != 0)
+       if(!caller || (caller->modifiers & CS_MODIFIER_STATIC) != 0)
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                          "cannot access instance members in 
static methods");
@@ -50,7 +50,7 @@ ILNode_SemAnalysis(ILNode_This)
        method = (ILNode_MethodDeclaration *)(info->currentMethod);
 
        /* If the method is static, then we cannot use "this" */
-       if((method->modifiers & IL_META_METHODDEF_STATIC) != 0)
+       if((method->modifiers & CS_MODIFIER_STATIC) != 0)
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                          "cannot use `this' in static 
methods");
@@ -908,7 +908,7 @@ ILNode_SemAnalysis(ILNode_Identifier)
                {
                        /* Argument reference */
                        index &= ~CS_LOCAL_IS_ARG;
-                       if((method->modifiers & IL_META_METHODDEF_STATIC) == 0)
+                       if((method->modifiers & CS_MODIFIER_STATIC) == 0)
                        {
                                paramMod = 
ILGenGetParamInfo(method->methodInfo, 0,
                                                                                
         index, &type);
@@ -935,7 +935,7 @@ ILNode_SemAnalysis(ILNode_Identifier)
                        else if(paramMod == ILParamMod_params)
                        {
                                /* Use the array form of the parameter inside 
the method */
-                               if((method->modifiers & 
IL_META_METHODDEF_STATIC) == 0)
+                               if((method->modifiers & CS_MODIFIER_STATIC) == 
0)
                                {
                                        type = ILTypeGetParam
                                                
(ILMethod_Signature(method->methodInfo), index);
@@ -1528,7 +1528,7 @@ ILNode_SemAnalysis(ILNode_BaseAccess)
 
        /* Bail out if "base" is used within a static method */
        caller = (ILNode_MethodDeclaration *)(info->currentMethod);
-       if(!caller || (caller->modifiers & IL_META_METHODDEF_STATIC) != 0)
+       if(!caller || (caller->modifiers & CS_MODIFIER_STATIC) != 0)
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                          "cannot use base reference in a static method");
@@ -1583,7 +1583,7 @@ ILNode_SemAnalysis(ILNode_BaseElement)
        
        /* Bail out if "base" is used within a static method */
        caller = (ILNode_MethodDeclaration *)(info->currentMethod);
-       if(!caller || (caller->modifiers & IL_META_METHODDEF_STATIC) != 0)
+       if(!caller || (caller->modifiers & CS_MODIFIER_STATIC) != 0)
        {
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                          "cannot use base reference in a static method");
diff --git a/cscc/csharp/cs_modifiers.c b/cscc/csharp/cs_modifiers.c
index 8a741d3..aeb2a85 100644
--- a/cscc/csharp/cs_modifiers.c
+++ b/cscc/csharp/cs_modifiers.c
@@ -27,6 +27,19 @@ extern       "C" {
 int CSNoHideBySig = 0;
 
 /*
+ * Define invalid modifiers
+ */
+#if IL_VERSION_MAJOR > 1
+#define INVALID_CLASS_MODIFIERS \
+       (CS_MODIFIER_READONLY | CS_MODIFIER_VIRTUAL | CS_MODIFIER_OVERRIDE | \
+       CS_MODIFIER_EXTERN | CS_MODIFIER_VOLATILE)
+#else /* IL_VERSION_MAJOR == 1 */
+#define INVALID_CLASS_MODIFIERS \
+       (CS_MODIFIER_STATIC | CS_MODIFIER_READONLY | CS_MODIFIER_VIRTUAL | \
+       CS_MODIFIER_OVERRIDE | CS_MODIFIER_EXTERN | CS_MODIFIER_VOLATILE)
+#endif /* IL_VERSION_MAJOR == 1 */
+
+/*
  * Report errors for each modifier in a mask.
  */
 static void ModifierError(char *filename, long linenum,
@@ -225,12 +238,6 @@ ILUInt32 CSModifiersToTypeAttrs(ILNode *node, ILUInt32 
modifiers, int isNested)
                {
                        attrs = IL_META_TYPEDEF_NESTED_PRIVATE;
                }
-
-               /* Process the "new" modifier */
-               if((modifiers & CS_MODIFIER_NEW) != 0)
-               {
-                       attrs |= CS_SPECIALATTR_NEW;
-               }
        }
 
        /* Process "sealed", "abstract", and "unsafe" modifiers */
@@ -242,16 +249,10 @@ ILUInt32 CSModifiersToTypeAttrs(ILNode *node, ILUInt32 
modifiers, int isNested)
        {
                attrs |= IL_META_TYPEDEF_ABSTRACT;
        }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
 
        /* Report errors for any remaining modifiers */
        BadModifiers(node,
-                                modifiers & (CS_MODIFIER_STATIC | 
CS_MODIFIER_READONLY |
-                                                         CS_MODIFIER_VIRTUAL | 
CS_MODIFIER_OVERRIDE |
-                                                         CS_MODIFIER_EXTERN | 
CS_MODIFIER_VOLATILE));
+                                modifiers & INVALID_CLASS_MODIFIERS);
 
        /* We have the attributes we wanted now */
        return attrs;
@@ -378,18 +379,6 @@ ILUInt32 CSModifiersToDelegateAttrs(ILNode *node, ILUInt32 
modifiers,
                {
                        attrs = IL_META_TYPEDEF_NESTED_PRIVATE;
                }
-
-               /* Process the "new" modifier */
-               if((modifiers & CS_MODIFIER_NEW) != 0)
-               {
-                       attrs |= CS_SPECIALATTR_NEW;
-               }
-       }
-
-       /* Process the "unsafe" modifier */
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
        }
 
        /* Report errors for any remaining modifiers */
@@ -472,12 +461,6 @@ ILUInt32 CSModifiersToConstAttrs(ILNode *node, ILUInt32 
modifiers)
        /* Process the common attributes */
        attrs = ValidateAccess(node, modifiers);
 
-       /* Process the "new" modifier */
-       if((modifiers & CS_MODIFIER_NEW) != 0)
-       {
-               attrs |= CS_SPECIALATTR_NEW;
-       }
-
        /* Add the "literal" and "static" attributes */
        attrs |= IL_META_FIELDDEF_LITERAL | IL_META_FIELDDEF_STATIC;
 
@@ -509,18 +492,6 @@ ILUInt32 CSModifiersToFieldAttrs(ILNode *node, ILUInt32 
modifiers)
        {
                attrs |= IL_META_FIELDDEF_INIT_ONLY;
        }
-       if((modifiers & CS_MODIFIER_NEW) != 0)
-       {
-               attrs |= CS_SPECIALATTR_NEW;
-       }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
-       if((modifiers & CS_MODIFIER_VOLATILE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_VOLATILE;
-       }
 
        /* Report errors for the remaining modifiers */
        BadModifiers(node,
@@ -576,11 +547,6 @@ static ILUInt32 ValidateCalling(ILNode *node, ILUInt32 
modifiers,
                {
                        CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                                  "cannot use both `override' 
and `new'");
-                       attrs |= CS_SPECIALATTR_OVERRIDE;
-               }
-               else
-               {
-                       attrs |= CS_SPECIALATTR_OVERRIDE;
                }
                if((modifiers & CS_MODIFIER_VIRTUAL) != 0)
                {
@@ -609,7 +575,7 @@ static ILUInt32 ValidateCalling(ILNode *node, ILUInt32 
modifiers,
        }
        else if((modifiers & CS_MODIFIER_OVERRIDE) != 0)
        {
-               attrs |= IL_META_METHODDEF_VIRTUAL | CS_SPECIALATTR_OVERRIDE;
+               attrs |= IL_META_METHODDEF_VIRTUAL;
                if((modifiers & CS_MODIFIER_NEW) != 0)
                {
                        CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
@@ -661,17 +627,21 @@ ILUInt32 CSModifiersToMethodAttrs(ILNode *node, ILUInt32 
modifiers)
        attrs |= ValidateCalling(node, modifiers, attrs);
 
        /* Process the other method modifiers */
-       if((modifiers & CS_MODIFIER_NEW) != 0)
+       if((modifiers & CS_MODIFIER_METHOD_SPECIAL_NAME) != 0)
        {
-               attrs |= CS_SPECIALATTR_NEW;
+               attrs |= IL_META_METHODDEF_SPECIAL_NAME;
        }
-       if((modifiers & CS_MODIFIER_EXTERN) != 0)
+       if((modifiers & CS_MODIFIER_METHOD_RT_SPECIAL_NAME) != 0)
        {
-               attrs |= CS_SPECIALATTR_EXTERN;
+               attrs |= IL_META_METHODDEF_RT_SPECIAL_NAME;
        }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
+       if((modifiers & CS_MODIFIER_METHOD_COMPILER_CONTROLED) != 0)
        {
-               attrs |= CS_SPECIALATTR_UNSAFE;
+               attrs |= IL_META_METHODDEF_COMPILER_CONTROLLED;
+       }
+       if((modifiers & CS_MODIFIER_METHOD_HIDE_BY_SIG) != 0)
+       {
+               attrs |= IL_META_METHODDEF_HIDE_BY_SIG;
        }
 
        /* Report errors for the remaining modifiers */
@@ -691,16 +661,6 @@ ILUInt32 CSModifiersToEventAttrs(ILNode *node, ILUInt32 
modifiers)
        /* Process the calling convention attributes */
        attrs |= ValidateCalling(node, modifiers, attrs);
 
-       /* Process the other property modifiers */
-       if((modifiers & CS_MODIFIER_NEW) != 0)
-       {
-               attrs |= CS_SPECIALATTR_NEW;
-       }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
-
        /* Events always need the "specialname" attribute */
        attrs |= IL_META_METHODDEF_SPECIAL_NAME;
 
@@ -721,20 +681,6 @@ ILUInt32 CSModifiersToPropertyAttrs(ILNode *node, ILUInt32 
modifiers)
        /* Process the calling convention attributes */
        attrs |= ValidateCalling(node, modifiers, attrs);
 
-       /* Process the other property modifiers */
-       if((modifiers & CS_MODIFIER_NEW) != 0)
-       {
-               attrs |= CS_SPECIALATTR_NEW;
-       }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
-       if((modifiers & CS_MODIFIER_EXTERN) != 0)
-       {
-               attrs |= CS_SPECIALATTR_EXTERN;
-       }
-
        /* Properties always need the "specialname" attribute */
        attrs |= IL_META_METHODDEF_SPECIAL_NAME;
 
@@ -758,10 +704,7 @@ ILUInt32 CSModifiersToOperatorAttrs(ILNode *node, ILUInt32 
modifiers)
                CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
                                          "operators must have `static' 
access");
        }
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
+
        BadModifiers(node,
                                 modifiers & ~(CS_MODIFIER_PUBLIC | 
CS_MODIFIER_STATIC |
                                                           CS_MODIFIER_UNSAFE));
@@ -777,10 +720,7 @@ ILUInt32 CSModifiersToConstructorAttrs(ILNode *node, 
ILUInt32 modifiers)
        if((modifiers & CS_MODIFIER_STATIC) == 0)
        {
                attrs = ValidateAccess(node, modifiers);
-               if((modifiers & CS_MODIFIER_EXTERN) != 0)
-               {
-                       attrs |= CS_SPECIALATTR_EXTERN;
-               }
+
                BadModifiers(node,
                                         modifiers & ~(CS_MODIFIER_PUBLIC |
                                                                   
CS_MODIFIER_PRIVATE |
@@ -796,12 +736,6 @@ ILUInt32 CSModifiersToConstructorAttrs(ILNode *node, 
ILUInt32 modifiers)
                attrs = IL_META_METHODDEF_PRIVATE | IL_META_METHODDEF_STATIC;
        }
 
-       /* Process the "unsafe" modifier */
-       if((modifiers & CS_MODIFIER_UNSAFE) != 0)
-       {
-               attrs |= CS_SPECIALATTR_UNSAFE;
-       }
-
        /* Add the "hidebysig" and "*specialname" attributes always */
        attrs |= IL_META_METHODDEF_HIDE_BY_SIG |
                         IL_META_METHODDEF_SPECIAL_NAME |
@@ -816,19 +750,10 @@ ILUInt32 CSModifiersToDestructorAttrs(ILNode *node, 
ILUInt32 modifiers)
        ILUInt32 attrs=0;
        
        BadModifiers(node,
-                                       modifiers & ~(CS_MODIFIER_EXTERN |
-                                                             
CS_MODIFIER_UNSAFE));
+                                modifiers & ~(CS_MODIFIER_EXTERN |
+                                                          CS_MODIFIER_UNSAFE));
 
-       /* Process the "unsafe" modifier */
-       if(modifiers == CS_MODIFIER_UNSAFE)
-       {
-               attrs = CS_SPECIALATTR_UNSAFE;
-       }
-       else if(modifiers == CS_MODIFIER_EXTERN)
-       {
-               attrs = CS_SPECIALATTR_EXTERN;
-       }
-       else if((modifiers & (CS_SPECIALATTR_EXTERN | 
CS_SPECIALATTR_EXTERN))!=0)
+       if((modifiers & (CS_MODIFIER_EXTERN | CS_MODIFIER_EXTERN)) != 0)
        {
                CCWarningOnLine(yygetfilename(node),yygetlinenum(node),
                                                        "'extern' and 'unsafe' 
modifiers used together");
@@ -837,9 +762,7 @@ ILUInt32 CSModifiersToDestructorAttrs(ILNode *node, 
ILUInt32 modifiers)
        /* Add the "hidebysig" and "*specialname" attributes always */
        attrs |= IL_META_METHODDEF_FAMILY |
                         IL_META_METHODDEF_HIDE_BY_SIG |
-                        IL_META_METHODDEF_VIRTUAL |
-                        CS_SPECIALATTR_OVERRIDE |
-                        CS_SPECIALATTR_DESTRUCTOR;
+                        IL_META_METHODDEF_VIRTUAL;
 
        /* Done */
        return attrs;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                  |   83 +++
 cscc/csharp/cs_cast.tc     |    2 +-
 cscc/csharp/cs_decls.tc    |  345 +++++++----
 cscc/csharp/cs_gather.c    | 1380 ++++++++++++++++++++++++++++++++++----------
 cscc/csharp/cs_grammar.y   |  570 ++++--------------
 cscc/csharp/cs_internal.h  |   52 ++
 cscc/csharp/cs_invoke.tc   |    6 +-
 cscc/csharp/cs_lvalue.tc   |   12 +-
 cscc/csharp/cs_modifiers.c |  139 +----
 9 files changed, 1599 insertions(+), 990 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]