Ejemplo n.º 1
0
        public override void RewriteChildren(NamespaceTypeDefinition namespaceTypeDefinition)
        {
            string  typeName       = Util.FullyQualifiedTypeNameFromType(namespaceTypeDefinition);
            Element currentElement = null;

            // Unlike all other types that visited from either a namespace or a parent,
            // the module type is visited from the containing module
            if (_systemTypes.Contains(typeName))
            {
                currentElement = new SpecialTrimType(typeName);
                _trimElements.Push(currentElement);
            }

            this.RewriteChildren((NamedTypeDefinition)namespaceTypeDefinition);
            //namespaceTypeDefinition.ContainingUnitNamespace = this.GetCurrentNamespace();

            if (!_systemTypes.Contains(typeName))
            {
                TypeElement type = _currentTrimAssembly.GetTypeElement(typeName);
                MutateType(namespaceTypeDefinition, type);
            }
            if (currentElement != null)
            {
                _trimElements.Pop();
            }
        }
Ejemplo n.º 2
0
        public override List <INamespaceMember> Rewrite(List <INamespaceMember> namespaceMembers)
        {
            List <INamespaceMember> newList = new List <INamespaceMember>();

            if (namespaceMembers == null)
            {
                return(newList);
            }
            foreach (INamespaceMember member in namespaceMembers)
            {
                Element currentElement = null;

                MemberTypes memberType = Util.GetMemberTypeFromMember(member);

                if (memberType == MemberTypes.Type)
                {
                    INamedTypeDefinition typeDef = member as INamedTypeDefinition;
                    string typeName = Util.FullyQualifiedTypeNameFromType(typeDef);
                    currentElement = _currentTrimAssembly.GetTypeElement(typeName);
                    // special case for the module class. In mscorlib we don't have any global functions, etc.
                    // TODO: process its members too.
                    if (currentElement == null && IsSpecialType(typeName))
                    {
                        currentElement = new SpecialTrimType(typeName);
                        if (!_systemTypes.Contains(typeName))
                        {
                            _systemTypes.Add(typeName);
                        }
                    }
                }
                else
                {
                    currentElement = new SpecialTrimMember(null, member.Name.Value, null, memberType);
                }

                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    // Visit(INamespaceMember) will create the Mutable copy
                    INamespaceMember newMember = this.Rewrite(member);
                    newList.Add(newMember);

                    _trimElements.Pop();
                }
            }

            return(newList);
        }
Ejemplo n.º 3
0
        public override List <INestedTypeDefinition> Rewrite(List <INestedTypeDefinition> nestedTypeDefinitions)
        {
            List <INestedTypeDefinition> newList = new List <INestedTypeDefinition>();

            bool inParentSpecialType = CurrentTrimElement is SpecialTrimType;

            if (nestedTypeDefinitions == null)
            {
                return(newList);
            }
            foreach (INestedTypeDefinition nestedType in nestedTypeDefinitions)
            {
                string  typeName       = Util.FullyQualifiedTypeNameFromType(nestedType);
                Element currentElement = null;

                if (inParentSpecialType)
                {
                    currentElement = new SpecialTrimType(typeName);
                }
                else
                {
                    currentElement = _currentTrimAssembly.GetTypeElement(typeName);
                }

                // special case for the module class. In mscorlib we don't have any global functions, etc.
                // TODO: process its members too.
                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    // Need to create the Mutable copy here
                    INestedTypeDefinition newType = Rewrite(nestedType);
                    newList.Add(newType);
                    MutateType(newType, currentElement);
                    _trimElements.Pop();
                }
            }

            return(newList);
        }
Ejemplo n.º 4
0
        public override List<INestedTypeDefinition> Rewrite(List<INestedTypeDefinition> nestedTypeDefinitions)
        {
            List<INestedTypeDefinition> newList = new List<INestedTypeDefinition>();

            bool inParentSpecialType = CurrentTrimElement is SpecialTrimType;

            if (nestedTypeDefinitions == null)
            {
                return newList;
            }
            foreach (INestedTypeDefinition nestedType in nestedTypeDefinitions)
            {
                string typeName = Util.FullyQualifiedTypeNameFromType(nestedType);
                Element currentElement = null;

                if (inParentSpecialType)
                {
                    currentElement = new SpecialTrimType(typeName);
                }
                else
                {
                    currentElement = _currentTrimAssembly.GetTypeElement(typeName);
                }

                // special case for the module class. In mscorlib we don't have any global functions, etc.
                // TODO: process its members too.
                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    // Need to create the Mutable copy here
                    INestedTypeDefinition newType = Rewrite(nestedType);
                    newList.Add(newType);
                    MutateType(newType, currentElement);
                    _trimElements.Pop();
                }
            }

            return newList;
        }
Ejemplo n.º 5
0
        public override List<INamespaceMember> Rewrite(List<INamespaceMember> namespaceMembers)
        {
            List<INamespaceMember> newList = new List<INamespaceMember>();

            if (namespaceMembers == null)
            {
                return newList;
            }
            foreach (INamespaceMember member in namespaceMembers)
            {
                Element currentElement = null;

                MemberTypes memberType = Util.GetMemberTypeFromMember(member);

                if (memberType == MemberTypes.Type)
                {
                    INamedTypeDefinition typeDef = member as INamedTypeDefinition;
                    string typeName = Util.FullyQualifiedTypeNameFromType(typeDef);
                    currentElement = _currentTrimAssembly.GetTypeElement(typeName);
                    // special case for the module class. In mscorlib we don't have any global functions, etc.
                    // TODO: process its members too.
                    if (currentElement == null && IsSpecialType(typeName))
                    {
                        currentElement = new SpecialTrimType(typeName);
                        if (!_systemTypes.Contains(typeName))
                        {
                            _systemTypes.Add(typeName);
                        }
                    }
                }
                else
                {
                    currentElement = new SpecialTrimMember(null, member.Name.Value, null, memberType);
                }

                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    // Visit(INamespaceMember) will create the Mutable copy
                    INamespaceMember newMember = this.Rewrite(member);
                    newList.Add(newMember);

                    _trimElements.Pop();
                }
            }

            return newList;
        }
Ejemplo n.º 6
0
        public override void RewriteChildren(NamespaceTypeDefinition namespaceTypeDefinition)
        {
            string typeName = Util.FullyQualifiedTypeNameFromType(namespaceTypeDefinition);
            Element currentElement = null;

            // Unlike all other types that visited from either a namespace or a parent, 
            // the module type is visited from the containing module
            if (_systemTypes.Contains(typeName))
            {
                currentElement = new SpecialTrimType(typeName);
                _trimElements.Push(currentElement);
            }

            this.RewriteChildren((NamedTypeDefinition)namespaceTypeDefinition);
            //namespaceTypeDefinition.ContainingUnitNamespace = this.GetCurrentNamespace();

            if (!_systemTypes.Contains(typeName))
            {
                TypeElement type = _currentTrimAssembly.GetTypeElement(typeName);
                MutateType(namespaceTypeDefinition, type);
            }
            if (currentElement != null)
            {
                _trimElements.Pop();
            }
        }