private bool ValidateName(Core.Name name, Diagnostics.Span span) { int duplicateIndex; if (this.session.TryGetDecl(name, out duplicateIndex)) { var duplicateSpan = this.structWorkData.Find(st => st.name.Compare(name))?.declNode.name.GetSpan() ?? this.functWorkData.Find(st => st.name.Compare(name))?.declNode.name.GetSpan() ?? new Diagnostics.Span(); this.session.AddMessage( Diagnostics.MessageKind.Error, Diagnostics.MessageCode.DuplicateDeclaration, "duplicate declaration of '" + name.GetString() + "'", span); this.session.AddInnerMessageToLast( Diagnostics.MessageKind.Info, Diagnostics.MessageCode.DuplicateDeclaration, "first declaration here", duplicateSpan); return(false); } return(true); }
private string MangleName(Core.Name name) { return(name.GetString().Replace("::", "_")); }