public static string TypeVariantToString(TypeVariant variant) { var pair = TypeVariantMapping.FirstOrDefault(x => x.Value == variant); if (string.IsNullOrEmpty(pair.Key)) throw new ArgumentException("Type variant is not supported in Visual Basic."); return pair.Key; }
public static IType TypeMap(Func <int, TypeVar, IType> onVar, int c, IType t) { IType Walk(int c, IType t) { return(t switch { TypeVar v => onVar(c, v), TypeId i => i, TypeString ts => ts, TypeUnit u => u, TypeRecord r => new TypeRecord(r.Variants.Select(p => (p.Item1, Walk(c, p.Item2)))), TypeFloat f => f, TypeBool b => b, TypeNat n => n, TypeArrow a => new TypeArrow(Walk(c, a.From), Walk(c, a.To)), TypeVariant tv => new TypeVariant(tv.Variants.Select(p => (p.Item1, Walk(c, p.Item2)))), _ => throw new InvalidOperationException() }); }
/// <summary> /// Construct a single group - a list of cell types and variants. Only accessible via static ctor /// </summary> private GroupTypeVariant(string libPath, string groupName) { // Store the group name this.groupName = groupName; // Store the list of cell type names in this group string groupPath = libPath + "\\" + groupName; // cell types are subdirectories inside the group directory string[] types = Directory.GetDirectories(groupPath); // get the list of subdirectories (cell types) for (int p = 0; p < types.Length; p++) // remove everything except the subfolder name { types[p] = Path.GetFileName(types[p]); } Array.Sort(types); // Create an array of CellType instances, holding the names of the variants cellType = new TypeVariant[types.Length]; for (int t = 0; t < cellType.Length; t++) { cellType[t] = new TypeVariant(groupPath, types[t]); // create each TypeVariant object and let it enumberate the variants } }
private static RppGenericParameterVariance GetVariance(TypeVariant variant) { switch (variant) { case TypeVariant.Invariant: return RppGenericParameterVariance.Invariant; case TypeVariant.Covariant: return RppGenericParameterVariance.Covariant; case TypeVariant.Contravariant: return RppGenericParameterVariance.Contravariant; default: throw new ArgumentOutOfRangeException(nameof(variant), variant, null); } }
public static string TypeVariantToString(TypeVariant typeVariant) { string modifierString; if (!TypeVariantMapping.TryGetValue(typeVariant, out modifierString)) throw new ArgumentException("Type variant does not exist in the Visual Basic language."); return modifierString; }
public RppVariantTypeParam([NotNull] string name, TypeVariant variant, [CanBeNull] RTypeName constraintTypeName) : base(name) { Variant = variant; _constraint = constraintTypeName; }