Пример #1
0
 public TypeDeclaration(IdContainer Container, CodeString Name, TypeDeclType Type,
                        StructureBase[] Bases, CodeString Inner, List <Modifier> Mods)
 {
     this.Container = Container;
     this.Name      = Name;
     this.Bases     = Bases;
     this.Type      = Type;
     this.Mods      = Mods;
     this.Inner     = Inner;
 }
Пример #2
0
        void VisitTypeDeclaration(TypeDeclType typeDeclType, TypeDeclarationSyntax typeDecl)
        {
            if (TypeIsRemoved(typeDecl))
            {
                return;
            }

            VisitAttributeLists(typeDecl.AttributeLists);

            if (typeDecl.Modifiers.ContainsPartial())
            {
                partialTypes.Add(typeDecl.Identifier.Text,
                                 new FileAndTypeDecl(currentFileModel, typeDecl));
            }

            AddTypeAndNamespace(currentFileModel.semanticModel.GetDeclaredSymbol(typeDecl));

            if (typeDecl.BaseList == null)
            {
                if (typeDeclType == TypeDeclType.Class)
                {
                    AddNewType(true, "mscorlib.System", "__DotNet__Object", 0);
                }
            }
            else
            {
                if (!typeDecl.BaseList.Types.HasItems())
                {
                    throw new InvalidOperationException();
                }

                if (typeDeclType == TypeDeclType.Class)
                {
                    BaseTypeSyntax firstType       = typeDecl.BaseList.Types[0];
                    ITypeSymbol    firstTypeSymbol = currentFileModel.semanticModel.GetTypeInfo(firstType.Type).Type;
                    if (firstTypeSymbol.TypeKind != TypeKind.Class)
                    {
                        AddNewType(true, "mscorlib.System", "__DotNet__Object", 0);
                    }
                }

                foreach (BaseTypeSyntax type in typeDecl.BaseList.Types)
                {
                    TypeInfo typeInfo = currentFileModel.semanticModel.GetTypeInfo(type.Type);
                    if (typeInfo.Type == null)
                    {
                        throw new InvalidOperationException();
                    }
                    AddTypeAndNamespace(typeInfo.Type);
                }
            }

            if (CSharpToD.generateDebug)
            {
                writer.WriteLine("// Enter '{0}'", typeDecl.Identifier.Text);
                writer.Tab();
            }
            foreach (var member in typeDecl.Members)
            {
                Visit(member);
            }
            if (CSharpToD.generateDebug)
            {
                writer.Untab();
                writer.WriteLine("// Exit '{0}'", typeDecl.Identifier.Text);
            }

            if (typeDeclType == TypeDeclType.Struct)
            {
                if (typeDecl.BaseList != null)
                {
                    AddNewType(true, "mscorlib.System", "__DotNet__Object", 0);
                }
            }
        }