public override void EnterClassvarModifiers([NotNull] XSharpParser.ClassvarModifiersContext context) { var tokens = context._Tokens; this._currentVarVisibility = decodeVisibility(tokens); this._currentVarStatic = isStatic(tokens); }
//classvarModifiers : (Tokens+=(INSTANCE| STATIC | CONST | INITONLY | PRIVATE | HIDDEN | PROTECTED | PUBLIC // | EXPORT | INTERNAL | VOLATILE | UNSAFE | FIXED) )+ public MemberAttributes decodeClassVarModifiers([NotNull] XSharpParser.ClassvarModifiersContext context) { var visibility = MemberAttributes.Public; var modifiers = (MemberAttributes)0; foreach (var token in context._Tokens) { switch (token.Type) { case XSharpLexer.INTERNAL: if (visibility == MemberAttributes.Family) { visibility = MemberAttributes.FamilyOrAssembly; } else { visibility = MemberAttributes.Assembly; } break; case XSharpLexer.HIDDEN: case XSharpLexer.PRIVATE: visibility = MemberAttributes.Private; break; case XSharpLexer.PUBLIC: case XSharpLexer.EXPORT: visibility = MemberAttributes.Public; break; case XSharpLexer.PROTECTED: if (visibility == MemberAttributes.Assembly) { visibility = MemberAttributes.FamilyOrAssembly; } else { visibility = MemberAttributes.Family; } break; case XSharpLexer.CONST: modifiers |= MemberAttributes.Const; break; case XSharpLexer.STATIC: modifiers |= MemberAttributes.Static; break; case XSharpLexer.INITONLY: case XSharpLexer.VOLATILE: case XSharpLexer.INSTANCE: case XSharpLexer.UNSAFE: case XSharpLexer.FIXED: break; } } return(visibility | modifiers); }
public override void EnterClassvarModifiers([NotNull] XSharpParser.ClassvarModifiersContext context) { this.classVarModifiers = MemberAttributes.Public; // ITerminalNode[] visibility; // visibility = context.INTERNAL(); if (visibility.Length > 0) { this.classVarModifiers = MemberAttributes.Assembly; } // visibility = context.HIDDEN(); if (visibility.Length > 0) { this.classVarModifiers = MemberAttributes.Private; } // visibility = context.PRIVATE(); if (visibility.Length > 0) { this.classVarModifiers = MemberAttributes.Private; } // visibility = context.PROTECTED(); if (visibility.Length > 0) { visibility = context.INTERNAL(); if (visibility.Length > 0) { this.classVarModifiers = MemberAttributes.FamilyOrAssembly; } else { this.classVarModifiers = MemberAttributes.Family; } } // visibility = context.EXPORT(); if (visibility.Length > 0) { this.classVarModifiers = MemberAttributes.Public; } // if (context.CONST().Length > 0) { this.classVarModifiers |= MemberAttributes.Const; } if (context.STATIC().Length > 0) { this.classVarModifiers |= MemberAttributes.Static; } }