public static DefaultResolvedMethod CreateFromMultipleParts(IUnresolvedMethod[] parts, ITypeResolveContext firstPartParentContext, bool isExtensionMethod)
        {
            DefaultResolvedMethod method = new DefaultResolvedMethod(parts[0], firstPartParentContext, isExtensionMethod);

            method.parts = parts;
            return(method);
        }
示例#2
0
        public static DefaultResolvedMethod CreateFromMultipleParts(IUnresolvedMethod[] parts, ITypeResolveContext[] contexts, bool isExtensionMethod)
        {
            DefaultResolvedMethod method = new DefaultResolvedMethod(parts[0], contexts[0], isExtensionMethod);

            method.parts = parts;
            if (parts.Length > 1)
            {
                var attrs = new ListOfLists <IAttribute>();
                for (int i = 0; i < parts.Length; i++)
                {
                    attrs.AddList(parts[i].Attributes.CreateResolvedAttributes(contexts[i]));
                }
                method.Attributes = attrs;
            }
            return(method);
        }
 public IEnumerable <IMethod> GetConstructors(Predicate <IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers)
 {
     if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
     {
         if (this.HasDefaultConstructorConstraint || this.HasValueTypeConstraint)
         {
             if (filter == null || filter(DefaultUnresolvedMethod.DummyConstructor))
             {
                 return(new [] { DefaultResolvedMethod.GetDummyConstructor(compilation, this) });
             }
         }
         return(EmptyList <IMethod> .Instance);
     }
     else
     {
         return(GetMembersHelper.GetConstructors(this, filter, options));
     }
 }
示例#4
0
 public MemberList(List <ITypeResolveContext> contextPerMember, List <IUnresolvedMember> unresolvedNonPartialMembers, List <PartialMethodInfo> partialMethodInfos)
 {
     this.NonPartialMemberCount = unresolvedNonPartialMembers.Count;
     this.contextPerMember      = contextPerMember.ToArray();
     this.unresolvedMembers     = unresolvedNonPartialMembers.ToArray();
     if (partialMethodInfos == null)
     {
         this.resolvedMembers = new IMember[unresolvedNonPartialMembers.Count];
     }
     else
     {
         this.resolvedMembers = new IMember[unresolvedNonPartialMembers.Count + partialMethodInfos.Count];
         for (int i = 0; i < partialMethodInfos.Count; i++)
         {
             var info        = partialMethodInfos[i];
             int memberIndex = NonPartialMemberCount + i;
             resolvedMembers[memberIndex] = DefaultResolvedMethod.CreateFromMultipleParts(
                 info.Parts.ToArray(), info.Contexts.ToArray(), false);
         }
     }
 }
		public static IMethod CreateTypeCheckMethod(IType type, ICompilation compilation) {
			IMethod method = new DefaultResolvedMethod(new DefaultUnresolvedMethod(type.GetDefinition().Parts[0], "IsInstanceOfType"), compilation.TypeResolveContext.WithCurrentTypeDefinition(type.GetDefinition()));
			if (type is ParameterizedType)
				method = new SpecializedMethod(method, new TypeParameterSubstitution(classTypeArguments: ((ParameterizedType)type).TypeArguments, methodTypeArguments: null));
			return method;
		}
		public static DefaultResolvedMethod CreateFromMultipleParts(IUnresolvedMethod[] parts, ITypeResolveContext firstPartParentContext, bool isExtensionMethod)
		{
			DefaultResolvedMethod method = new DefaultResolvedMethod(parts[0], firstPartParentContext, isExtensionMethod);
			method.parts = parts;
			return method;
		}
示例#7
0
 protected IMethod GenerateDefaultConstructor(ITypeDefinition ce)
 {
     var compilerGeneratedCtor = ce.GetConstructors(true, false).FirstOrDefault(t => t.GetDeclarationBody() == null); //TODO: where is this phantom ctor coming from??? (dan-el)
     if (compilerGeneratedCtor == null)
     {
         var cePart = ce.Parts.First();
         var me2 = new DefaultUnresolvedMethod(cePart, ".ctor");
         me2.SymbolKind = SymbolKind.Constructor;
         me2.IsSynthetic = true;
         me2.UnresolvedFile = cePart.UnresolvedFile;
         var x = new DefaultResolvedMethod(me2, Compiler.Project.Compilation.TypeResolveContext.WithCurrentTypeDefinition(ce));
         compilerGeneratedCtor = x;
     }
     return compilerGeneratedCtor;
 }
		public static IMethod CreateDummyMethodForFieldInitialization(IMember member, ICompilation compilation) {
			var unresolved = new DefaultUnresolvedMethod(member.DeclaringTypeDefinition.Parts[0], "initialization for " + member.Name) {
				Parameters = { new DefaultUnresolvedParameter(member.ReturnType.ToTypeReference(), "value") },
				IsStatic = member.IsStatic,
			};
			IMethod method = new DefaultResolvedMethod(unresolved, compilation.TypeResolveContext.WithCurrentTypeDefinition(member.DeclaringTypeDefinition));
			if (member.DeclaringType is ParameterizedType)
				method = new SpecializedMethod(method, new TypeParameterSubstitution(classTypeArguments: ((ParameterizedType)member.DeclaringType).TypeArguments, methodTypeArguments: null));
			return method;
		}