private static TypeSpec TranslateTypeSpec(OS.TypeSpec t, Text Text, Dictionary <Object, TextRange> InnerPositions, Dictionary <Object, TextRange> Positions) { if (t.OnTypeRef) { var r = TypeSpec.CreateTypeRef((TypeRef)(t.TypeRef.VersionedName())); if (InnerPositions.ContainsKey(t)) { Positions.Add(r, InnerPositions[t]); } return(r); } else if (t.OnGenericTypeSpec && t.GenericTypeSpec.TypeSpec.OnTypeRef && t.GenericTypeSpec.TypeSpec.TypeRef.NameMatches("Optional") && t.GenericTypeSpec.ParameterValues.Count == 1) { var Parameter = t.GenericTypeSpec.ParameterValues.Single(); var InnerType = TranslateTypeSpec(Parameter, Text, InnerPositions, Positions); if (InnerType.OnTypeRef) { var r = TypeSpec.CreateOptional(InnerType.TypeRef); if (InnerPositions.ContainsKey(t)) { Positions.Add(r, InnerPositions[t]); } return(r); } } else if (t.OnGenericTypeSpec && t.GenericTypeSpec.TypeSpec.OnTypeRef && t.GenericTypeSpec.TypeSpec.TypeRef.NameMatches("List") && t.GenericTypeSpec.ParameterValues.Count == 1) { var Parameter = t.GenericTypeSpec.ParameterValues.Single(); if (Parameter.OnTypeRef && Parameter.TypeRef.NameMatches("Byte")) { var r = TypeSpec.CreateTypeRef((TypeRef)("Binary")); if (InnerPositions.ContainsKey(t)) { Positions.Add(r, InnerPositions[t]); } return(r); } else { var InnerType = TranslateTypeSpec(Parameter, Text, InnerPositions, Positions); if (InnerType.OnTypeRef) { var r = TypeSpec.CreateList(InnerType.TypeRef); if (InnerPositions.ContainsKey(t)) { Positions.Add(r, InnerPositions[t]); } return(r); } } } var oRange = InnerPositions.ContainsKey(t) ? InnerPositions[t] : TreeFormat.Optional <TextRange> .Empty; var FileRange = new FileTextRange { Text = Text, Range = oRange }; throw new InvalidEvaluationException("InvalidTypeSpec", FileRange, t); }
public String GetTypeString(OS.TypeSpec Type) { return(InnerWriter.GetTypeString(Type)); }