void WriteCallableDefinitionHeader(string keyword, CallableDefinition node) { WriteAttributes(node.Attributes, true); WriteModifiers(node); WriteKeyword(keyword); IExplicitMember em = node as IExplicitMember; if (null != em) { Visit(em.ExplicitInfo); } Write(node.Name); if (node.GenericParameters.Count > 0) { WriteGenericParameterList(node.GenericParameters); } WriteParameterList(node.Parameters); WriteTypeReference(node.ReturnType); if (node.ReturnTypeAttributes.Count > 0) { Write(" "); WriteAttributes(node.ReturnTypeAttributes, false); } }
bool CheckExplicitMemberValidity(IExplicitMember member) { var node = (Node)member; var explicitMember = (IMember)GetEntity(node); var declaringType = explicitMember.DeclaringType; if (!declaringType.IsClass) { Error(CompilerErrorFactory.InvalidTypeForExplicitMember(node, declaringType)); return(false); } var targetInterface = GetType(member.ExplicitInfo.InterfaceType); if (!targetInterface.IsInterface) { Error(CompilerErrorFactory.InvalidInterfaceForInterfaceMember(node, member.ExplicitInfo.InterfaceType.Name)); return(false); } if (!declaringType.IsSubclassOf(targetInterface)) { Error(CompilerErrorFactory.InterfaceImplForInvalidInterface(node, targetInterface.Name, ((TypeMember)node).Name)); return(false); } return(true); }
private void BindAllParameters() { Method entryPoint = ContextAnnotations.GetEntryPoint(Context); foreach (INodeWithParameters node in _parameters) { var member = (TypeMember)node; if (member.ContainsAnnotation(PrivateMemberNeverUsed)) { continue; } NameResolutionService.EnterNamespace((INamespace)TypeSystemServices.GetEntity(member.DeclaringType)); CodeBuilder.BindParameterDeclarations(member.IsStatic, node); if (!member.IsVisible && !member.IsSynthetic) { IExplicitMember explicitMember = member as IExplicitMember; if (null != explicitMember && null != explicitMember.ExplicitInfo) { continue; } if (member == entryPoint) //private Main is fine { continue; } member.Annotate(PrivateMemberNeverUsed, null); } } }
bool AreDifferentInterfaceMembers(IExplicitMember lhs, IExplicitMember rhs) { if (lhs.ExplicitInfo == null && rhs.ExplicitInfo == null) { return(false); } return(lhs.ExplicitInfo == null || rhs.ExplicitInfo == null || lhs.ExplicitInfo.InterfaceType.Entity != rhs.ExplicitInfo.InterfaceType.Entity); }
void AssertValidInterfaceImplementation(TypeMember node, IMember baseMember) { if (!baseMember.DeclaringType.IsInterface) { return; } IExplicitMember explicitNode = node as IExplicitMember; if (null != explicitNode && null != explicitNode.ExplicitInfo) { return; //node is an explicit interface impl } if (node.Visibility != TypeMemberModifiers.Public) { Errors.Add(CompilerErrorFactory.InterfaceImplementationMustBePublicOrExplicit(node, baseMember)); } }
void CheckExplicitImpl(IExplicitMember member) { ExplicitMemberInfo ei = member.ExplicitInfo; if (null == ei) { return; } TypeMember node = (TypeMember)member; if (TypeMemberModifiers.None != node.Modifiers) { Error( CompilerErrorFactory.ExplicitImplMustNotHaveModifiers( node, ei.InterfaceType.Name, node.Name)); } }
void CheckExplicitMemberValidity(IExplicitMember node) { IMember explicitMember = (IMember)GetEntity((Node)node); if (explicitMember.DeclaringType.IsClass) { IType targetInterface = GetType(node.ExplicitInfo.InterfaceType); if (!targetInterface.IsInterface) { Error(CompilerErrorFactory.InvalidInterfaceForInterfaceMember((Node)node, node.ExplicitInfo.InterfaceType.Name)); } if (!explicitMember.DeclaringType.IsSubclassOf(targetInterface)) { Error(CompilerErrorFactory.InterfaceImplForInvalidInterface((Node)node, targetInterface.Name, ((TypeMember)node).Name)); } } else { // TODO: Only class ITM's can do explicit interface methods } }
bool AreDifferentInterfaceMembers(IExplicitMember lhs, IExplicitMember rhs) { if (lhs.ExplicitInfo == null && rhs.ExplicitInfo == null) { return false; } if ( lhs.ExplicitInfo != null && rhs.ExplicitInfo != null && lhs.ExplicitInfo.InterfaceType.Entity == rhs.ExplicitInfo.InterfaceType.Entity ) { return false; } return true; }
bool AreDifferentInterfaceMembers(IExplicitMember lhs, IExplicitMember rhs) { if (lhs.ExplicitInfo == null && rhs.ExplicitInfo == null) return false; return lhs.ExplicitInfo == null || rhs.ExplicitInfo == null || lhs.ExplicitInfo.InterfaceType.Entity != rhs.ExplicitInfo.InterfaceType.Entity; }