public override PLanguageType VisitNamedTupleType(PParser.NamedTupleTypeContext context) { HashSet <string> names = new HashSet <string>(); PParser.IdenTypeContext[] namedTupleFields = context.idenTypeList().idenType(); if (context.idenTypeList().idenType().Length > 8) { throw handler.TupleSizeMoreThanEight(context); } NamedTupleEntry[] fields = new NamedTupleEntry[namedTupleFields.Length]; for (int i = 0; i < namedTupleFields.Length; i++) { PParser.IdenTypeContext field = namedTupleFields[i]; string fieldName = field.name.GetText(); if (names.Contains(fieldName)) { throw handler.DuplicateNamedTupleEntry(field.name, fieldName); } names.Add(fieldName); fields[i] = new NamedTupleEntry { Name = fieldName, FieldNo = i, Type = Visit(field.type()) }; } return(new NamedTupleType(fields)); }
public override PLanguageType VisitNamedTupleType(PParser.NamedTupleTypeContext context) { var names = new HashSet <string>(); var namedTupleFields = context.idenTypeList().idenType(); var fields = new NamedTupleEntry[namedTupleFields.Length]; for (var i = 0; i < namedTupleFields.Length; i++) { PParser.IdenTypeContext field = namedTupleFields[i]; string fieldName = field.name.GetText(); if (names.Contains(fieldName)) { throw handler.DuplicateNamedTupleEntry(field.name, fieldName); } names.Add(fieldName); fields[i] = new NamedTupleEntry { Name = fieldName, Type = Visit(field.type()) }; } return(new NamedTupleType(fields)); }
public override object VisitNamedTupleType(PParser.NamedTupleTypeContext context) { return(null); }