コード例 #1
0
        bool CheckInheritedPropertyImpl(IProperty impl, IProperty target)
        {
            if (impl.Type == target.Type)
            {
                if (TypeSystemServices.CheckOverrideSignature(impl.GetParameters(), target.GetParameters()))
                {
                    if (HasGetter(target))
                    {
                        if (!HasGetter(impl))
                        {
                            return(false);
                        }
                    }
                    if (HasSetter(target))
                    {
                        if (!HasSetter(impl))
                        {
                            return(false);
                        }
                    }

                    /* Unnecessary?
                     * if(impl.IsPublic != target.IsPublic ||
                     * impl.IsProtected != target.IsProtected ||
                     * impl.IsPrivate != target.IsPrivate)
                     * {
                     *      return false;
                     * }*/
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        void ResolveClassAbstractProperty(ClassDefinition node,
                                          TypeReference baseTypeRef,
                                          IProperty entity)
        {
            foreach (TypeMember member in node.Members)
            {
                if (entity.Name != member.Name ||
                    NodeType.Property != member.NodeType ||
                    !IsCorrectExplicitMemberImplOrNoExplicitMemberAtAll(member, entity) ||
                    !TypeSystemServices.CheckOverrideSignature(entity.GetParameters(), GetPropertyEntity(member).GetParameters()))
                {
                    continue;
                }

                Property p = (Property)member;
                ProcessPropertyAccessor(p, p.Getter, entity.GetGetMethod());
                ProcessPropertyAccessor(p, p.Setter, entity.GetSetMethod());
                if (null == p.Type)
                {
                    p.Type = CodeBuilder.CreateTypeReference(entity.Type);
                }
                else
                {
                    if (entity.Type != p.Type.Entity)
                    {
                        Error(CompilerErrorFactory.ConflictWithInheritedMember(p, p.FullName, entity.FullName));
                    }
                }
                return;
            }

            node.Members.Add(CreateAbstractProperty(baseTypeRef, entity));
            AbstractMemberNotImplemented(node, baseTypeRef, entity);
        }
コード例 #3
0
        private bool ResolveAsImplementationOf(IProperty baseProperty, Property property)
        {
            if (!TypeSystemServices.CheckOverrideSignature(GetEntity(property).GetParameters(), baseProperty.GetParameters()))
            {
                return(false);
            }

            ProcessPropertyImplementation(property, baseProperty);
            AssertValidPropertyImplementation(property, baseProperty);
            return(true);
        }
コード例 #4
0
 bool CheckInheritedMethodImpl(IMethod impl, IMethod target)
 {
     if (TypeSystemServices.CheckOverrideSignature(impl, target))
     {
         if (impl.ReturnType == target.ReturnType)
         {
             return(true);
         }
         //TODO: Oh snap! No reusable error messages for this!
         //Errors(CompilerErrorFactory.ConflictWithInheritedMember());
     }
     return(false);
 }
コード例 #5
0
        void ResolveAbstractMethod(ClassDefinition node,
                                   TypeReference baseTypeRef,
                                   IMethod entity)
        {
            if (entity.IsSpecialName)
            {
                return;
            }

            foreach (TypeMember member in node.Members)
            {
                if (entity.Name == member.Name &&
                    NodeType.Method == member.NodeType &&
                    IsCorrectExplicitMemberImplOrNoExplicitMemberAtAll(member, entity))
                {
                    Method method = (Method)member;
                    if (TypeSystemServices.CheckOverrideSignature(GetEntity(method), entity))
                    {
                        if (IsUnknown(method.ReturnType))
                        {
                            method.ReturnType = CodeBuilder.CreateTypeReference(entity.ReturnType);
                        }
                        else
                        {
                            if (entity.ReturnType != method.ReturnType.Entity)
                            {
                                Error(CompilerErrorFactory.ConflictWithInheritedMember(method, method.FullName, entity.FullName));
                            }
                        }

                        if (null != method.ExplicitInfo)
                        {
                            method.ExplicitInfo.Entity = entity;
                        }

                        if (!method.IsOverride && !method.IsVirtual)
                        {
                            method.Modifiers |= TypeMemberModifiers.Virtual;
                        }

                        _context.TraceInfo("{0}: Method {1} implements {2}", method.LexicalInfo, method, entity);
                        return;
                    }
                }
            }

            node.Members.Add(CodeBuilder.CreateAbstractMethod(baseTypeRef.LexicalInfo, entity));
            AbstractMemberNotImplemented(node, baseTypeRef, entity);
        }
コード例 #6
0
        private bool ResolveAsImplementationOf(IMethod baseMethod, Method method)
        {
            if (!TypeSystemServices.CheckOverrideSignature(GetEntity(method), baseMethod))
            {
                return(false);
            }

            ProcessMethodImplementation(method, baseMethod);

            if (!method.IsOverride && !method.IsVirtual)
            {
                method.Modifiers |= TypeMemberModifiers.Virtual;
            }

            AssertValidInterfaceImplementation(method, baseMethod);
            TraceImplements(method, baseMethod);
            return(true);
        }
コード例 #7
0
        bool CheckInheritedPropertyImpl(IProperty impl, IProperty target)
        {
            if (!TypeSystemServices.CheckOverrideSignature(impl.GetParameters(), target.GetParameters()))
            {
                return(false);
            }

            if (HasGetter(target) && !HasGetter(impl))
            {
                return(false);
            }
            if (HasSetter(target) && !HasSetter(impl))
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        void ResolveAbstractMethod(ClassDefinition node,
                                   TypeReference baseTypeRef,
                                   IMethod entity)
        {
            if (entity.IsSpecialName)
            {
                return;
            }

            foreach (TypeMember member in node.Members)
            {
                if (entity.Name == member.Name &&
                    NodeType.Method == member.NodeType &&
                    IsCorrectExplicitMemberImplOrNoExplicitMemberAtAll(member, entity))
                {
                    Method method = (Method)member;
                    if (TypeSystemServices.CheckOverrideSignature(GetEntity(method), entity))
                    {
                        if (IsUnknown(method.ReturnType))
                        {
                            method.ReturnType = CodeBuilder.CreateTypeReference(entity.ReturnType);
                        }
                        else
                        {
                            if (entity.ReturnType != method.ReturnType.Entity)
                            {
                                Error(CompilerErrorFactory.ConflictWithInheritedMember(method, method.FullName, entity.FullName));
                            }
                        }

                        if (null != method.ExplicitInfo)
                        {
                            method.ExplicitInfo.Entity = entity;
                        }

                        if (!method.IsOverride && !method.IsVirtual)
                        {
                            method.Modifiers |= TypeMemberModifiers.Virtual;
                        }

                        _context.TraceInfo("{0}: Method {1} implements {2}", method.LexicalInfo, method, entity);
                        return;
                    }
                }
            }
            foreach (SimpleTypeReference parent in node.BaseTypes)
            {
                if (_classDefinitionList.Contains(parent.Name))
                {
                    depth++;
                    ResolveAbstractMethod(_classDefinitionList[parent.Name] as ClassDefinition, baseTypeRef, entity);
                    depth--;
                }
            }
            if (CheckInheritsInterfaceImplementation(node, entity))
            {
                return;
            }
            if (depth == 0)
            {
                if (!AbstractMemberNotImplemented(node, baseTypeRef, entity))
                {
                    //BEHAVIOR < 0.7.7: no stub, mark class as abstract
                    node.Members.Add(CodeBuilder.CreateAbstractMethod(baseTypeRef.LexicalInfo, entity));
                }
            }
        }
コード例 #9
0
 bool CheckInheritedMethodImpl(IMethod impl, IMethod baseMethod)
 {
     return(TypeSystemServices.CheckOverrideSignature(impl, baseMethod));
 }