AstType ConvertToType (Mono.CSharp.Expression typeName) { if (typeName is TypeExpression) { var typeExpr = (Mono.CSharp.TypeExpression)typeName; return new PrimitiveType (typeExpr.GetSignatureForError (), Convert (typeExpr.Location)); } if (typeName is Mono.CSharp.QualifiedAliasMember) { var qam = (Mono.CSharp.QualifiedAliasMember)typeName; // TODO: Overwork the return type model - atm we don't have a good representation // for qualified alias members. return new SimpleType (qam.Name, Convert (qam.Location)); } if (typeName is MemberAccess) { MemberAccess ma = (MemberAccess)typeName; var memberType = new MonoDevelop.CSharp.Ast.MemberType (); memberType.AddChild (ConvertToType (ma.LeftExpression), MonoDevelop.CSharp.Ast.MemberType.TargetRole); memberType.MemberName = ma.Name; AddTypeArguments (ma, memberType); return memberType; } if (typeName is SimpleName) { var sn = (SimpleName)typeName; var result = new SimpleType (sn.Name, Convert (sn.Location)); AddTypeArguments (sn, result); return result; } if (typeName is ComposedCast) { var cc = (ComposedCast)typeName; var baseType = ConvertToType (cc.Left); var result = new ComposedType () { BaseType = baseType }; if (cc.Spec.IsNullable) { result.HasNullableSpecifier = true; } else if (cc.Spec.IsPointer) { result.PointerRank++; } else { var location = LocationsBag.GetLocations (cc.Spec); var spec = new ArraySpecifier () { Dimensions = cc.Spec.Dimension - 1 }; spec.AddChild (new CSharpTokenNode (Convert (cc.Spec.Location), 1), FieldDeclaration.Roles.LBracket); if (location != null) spec.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.RBracket); result.ArraySpecifiers = new ArraySpecifier[] { spec }; } return result; } System.Console.WriteLine ("Error while converting :" + typeName + " - unknown type name"); System.Console.WriteLine (Environment.StackTrace); return new SimpleType ("unknown"); }
public override object Visit (QualifiedAliasMember qualifiedAliasMember) { var result = new MonoDevelop.CSharp.Ast.MemberType (); result.Target = new SimpleType (qualifiedAliasMember.alias); result.IsDoubleColon = true; result.AddChild (new Identifier (qualifiedAliasMember.Name, Convert (qualifiedAliasMember.Location)), MemberReferenceExpression.Roles.Identifier); return new TypeReferenceExpression () { Type = result }; }
AstType ConvertImport (MemberName memberName) { if (memberName.Left != null) { // left.name var t = new MonoDevelop.CSharp.Ast.MemberType(); t.IsDoubleColon = memberName.IsDoubleColon; t.AddChild (ConvertImport (memberName.Left), MonoDevelop.CSharp.Ast.MemberType.TargetRole); t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), MonoDevelop.CSharp.Ast.MemberType.Roles.Identifier); return t; } else { SimpleType t = new SimpleType(); t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier); // TODO type arguments return t; } }
public virtual S VisitMemberType(MemberType memberType, T data) { return(VisitChildren(memberType, data)); }