public override object VisitModuleFieldDecl([NotNull] SLangGrammarParser.ModuleFieldDeclContext context) { headerText.Write("extern "); base.VisitModuleFieldDecl(context); WriteLineAll(";"); return(null); }
public override object VisitModuleFieldDecl([NotNull] SLangGrammarParser.ModuleFieldDeclContext context) { VariableNameTableItem data; if (context.variableDecl() != null) { data = Visit(context.variableDecl()) as VariableNameTableItem; if (data != null) { ThrowIfReservedWord(data.Name, ModuleData.File, context.variableDecl().Start); } } else { data = Visit(context.constDecl()) as VariableNameTableItem; if (data != null) { ThrowIfReservedWord(data.Name, ModuleData.File, context.constDecl().Start); } } if (data != null && moduleItem.Fields.ContainsKey(data.Name)) { ThrowIfVariableExistsException(data.Name, ModuleData.File, data.Line, data.Column); } if (data != null) { var item = new ModuleFieldNameTableItem { AccessModifier = GetModifierByName(context.AccessModifier().GetText()), IsConstant = data.IsConstant, Column = data.Column, Line = data.Line, Name = data.Name, Type = data.Type }; if (item.Type is SlangCustomType t) { var typeOfItem = Table.FindClass(t); // если поле класса публично, а тип поля приватный, но при этом тип поля не тип класса if (item.AccessModifier == AccessModifier.Public && typeOfItem.AccessModifier == AccessModifier.Private) { ThrowLevelAccessibilityForFieldsException(context.Start, ModuleData.File, t.ToString(), item.Name); } } moduleItem.CheckCommonNamesConflicts(item.Name, item.Line, item.Column); if (context.importHead() != null) { item.Header = Visit(context.importHead()) as ImportHeader; } moduleItem.Fields[data.Name] = item; } return(base.VisitModuleFieldDecl(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="SLangGrammarParser.moduleFieldDecl"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitModuleFieldDecl([NotNull] SLangGrammarParser.ModuleFieldDeclContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="SLangGrammarParser.moduleFieldDecl"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitModuleFieldDecl([NotNull] SLangGrammarParser.ModuleFieldDeclContext context) { return(VisitChildren(context)); }