// For non-interface types public ClassDecl( Identifier idName, TypeSig [] arSuper, // super class & implemented interfaces MethodDecl [] alMethods, PropertyDecl[] alProperties, FieldDecl[] alFields, EventDecl [] alEvents, TypeDeclBase[] alNestedTypes, Modifiers mods, bool fIsClass // true for class, false for struct ) { Debug.Assert(idName != null); Debug.Assert(alMethods != null); Debug.Assert(alFields != null); Debug.Assert(alProperties != null); Debug.Assert(alEvents != null); m_strName = idName.Text; m_arSuper = (arSuper == null) ? new TypeSig[0] : arSuper; m_alNestedTypes = (alNestedTypes == null) ? m_sEmptyTypeList : alNestedTypes; m_alMethods = alMethods; m_alProperties = alProperties; m_alFields = alFields; m_alEvents = alEvents; // @todo - this is wrong m_filerange = idName.Location; if (!fIsClass) // structs are implicitly sealed. mods.SetSealed(); m_mods = mods; m_genre = fIsClass ? TypeEntry.Genre.cClass : TypeEntry.Genre.cStruct; }
public DelegateDecl( Identifier idName, TypeSig tRetType, ParamVarDecl[] arParams, Modifiers mods ) { Debug.Assert(idName != null); Debug.Assert(tRetType != null); Debug.Assert(arParams != null); m_idName = idName; m_tRetType = tRetType; m_arParams = arParams; m_mods = mods; // Implied sealed m_mods.SetSealed(); }
//----------------------------------------------------------------------------- // Parse Member attributes and return the bit flag // // ** rules ** // MemberAttr -> <any subset of {public, static, etc } > //----------------------------------------------------------------------------- protected Modifiers ParseModifiers() { AST.Modifiers mods = new Modifiers(); while(true) { Token t = m_lexer.PeekNextToken(); switch(t.TokenType) { case Token.Type.cAttrPublic: mods.SetPublic(); break; case Token.Type.cAttrProtected: mods.SetProtected(); break; case Token.Type.cAttrPrivate: mods.SetPrivate(); break; case Token.Type.cAttrStatic: mods.SetStatic(); break; case Token.Type.cAttrAbstract: mods.SetAbstract(); break; case Token.Type.cAttrVirtual: mods.SetVirtual(); break; case Token.Type.cAttrOverride: mods.SetOverride(); break; case Token.Type.cAttrInternal: mods.SetInternal(); break; case Token.Type.cAttrReadOnly: mods.SetReadOnly(); break; case Token.Type.cNew: mods.SetNew(); break; case Token.Type.cAttrSealed: mods.SetSealed(); break; // Return once we encounter something that's not a modifier default: { return mods; } } ConsumeNextToken(); } // We exit once we find a token that's not a modifier (or we find a duplicate modifier) }