protected internal virtual TypeSyntax CreateType(ITypeInfo type) { // // Ez ne a switch-ben legyen mert az AddType()-ot nem akarjuk hivni int[]-re v int*-ra // // TODO: FIXME: itt "type.RefType > RefType.None"-ra kene vizsgalni // if (type.ElementType is not null && type is not IArrayTypeInfo) { TypeSyntax result = CreateType(type.ElementType !); if (type.RefType == RefType.Pointer) { result = PointerType(result); } return(result); } AddType(type); return(type switch { _ when type.IsVoid => PredefinedType ( Token(SyntaxKind.VoidKeyword) ), _ when type.IsNested => type .GetParentTypes() .Append(type) .Select(GetQualifiedName) .Qualify(), _ when type is IArrayTypeInfo array => ArrayType ( elementType: CreateType(array.ElementType !) ) .WithRankSpecifiers ( rankSpecifiers: SingletonList ( node: ArrayRankSpecifier ( sizes: array .Rank .Times(OmittedArraySizeExpression) .ToSyntaxList(arSize => (ExpressionSyntax)arSize) ) ) ), _ => GetQualifiedName(type) });
protected TypeSyntax ResolveType(ITypeInfo type) { // // Ez ne a switch-ben legyen mert az AddType()-ot nem akarjuk hivni int[]-re v int*-ra // // TODO: FIXME: itt "type.RefType > RefType.None"-ra kene vizsgalni // if (type.ElementType is not null && type is not IArrayTypeInfo) { TypeSyntax result = ResolveType(type.ElementType); if (type.RefType is RefType.Pointer) { result = PointerType(result); } return(result); } if (type.IsVoid) { return(PredefinedType ( Token(SyntaxKind.VoidKeyword) )); } if (type.IsNested) { return(GetParts().Qualify()); IEnumerable <NameSyntax> GetParts() { foreach (ITypeInfo parent in type.GetParentTypes()) { yield return(GetQualifiedName(parent)); } yield return(GetQualifiedName(type)); } } if (type is IArrayTypeInfo array) { return(ArrayType ( elementType: ResolveType(array.ElementType !) ) .WithRankSpecifiers ( rankSpecifiers: SingletonList ( node: ArrayRankSpecifier ( sizes: array .Rank .Times(OmittedArraySizeExpression) .ToSyntaxList(arSize => (ExpressionSyntax)arSize) ) ) )); } return(GetQualifiedName(type)); }