Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbSymbol"/> class.
 /// </summary>
 /// <param name="module">Module that contains this symbol.</param>
 /// <param name="typeIndex">Type index of the simple build-in type.</param>
 public PdbSymbol(PdbModule module, TypeIndex typeIndex)
     : base(module)
 {
     PdbModule = module;
     Id        = typeIndex.Index;
     Initialize(typeIndex);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes data based on the <see cref="ModifierRecord"/>.
        /// </summary>
        private void Initialize(ModifierRecord record)
        {
            PdbSymbol symbol = PdbModule.GetSymbol(record.ModifiedType);

            symbol.LinkSymbols(this);
            Tag                  = symbol.Tag;
            BasicType            = symbol.BasicType;
            Offset               = symbol.Offset;
            Size                 = symbol.Size;
            IsVirtualInheritance = symbol.IsVirtualInheritance;
            IsForwardReference   = symbol.IsForwardReference;
            UniqueName           = symbol.UniqueName;
            Name                 = symbol.Name;
            if ((record.Modifiers & ModifierOptions.Unaligned) != ModifierOptions.None)
            {
                Name = "unaligned " + Name;
            }
            if ((record.Modifiers & ModifierOptions.Volatile) != ModifierOptions.None)
            {
                Name = "volatile " + Name;
            }
            if ((record.Modifiers & ModifierOptions.Const) != ModifierOptions.None)
            {
                Name = "const " + Name;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbGlobalScope"/> class.
 /// </summary>
 /// <param name="module">Module that contains this symbol.</param>
 public PdbGlobalScope(PdbModule module)
     : base(module)
 {
     Tag       = Engine.CodeTypeTag.ModuleGlobals;
     BasicType = DIA.BasicType.Void;
     Name      = string.Empty;
     Id        = uint.MaxValue;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes data based on the <see cref="VirtualBaseClassRecord"/>.
        /// </summary>
        private void Initialize(VirtualBaseClassRecord record)
        {
            Symbol symbol = PdbModule.GetSymbol(record.BaseType);

            Tag                  = Engine.CodeTypeTag.BaseClass;
            BasicType            = symbol.BasicType;
            Name                 = symbol.Name;
            Size                 = symbol.Size;
            IsVirtualInheritance = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes data based on the <see cref="BaseClassRecord"/>.
        /// </summary>
        private void Initialize(BaseClassRecord record)
        {
            Symbol symbol = PdbModule.GetSymbol(record.Type);

            Offset               = (int)record.Offset;
            Tag                  = Engine.CodeTypeTag.BaseClass;
            BasicType            = symbol.BasicType;
            Name                 = symbol.Name;
            Size                 = symbol.Size;
            IsVirtualInheritance = false;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gets the element type (if symbol is array or pointer).
 /// </summary>
 protected override Symbol GetElementType()
 {
     if (typeRecord is ArrayRecord arrayRecord)
     {
         return(PdbModule.GetSymbol(arrayRecord.ElementType));
     }
     if (typeRecord is PointerRecord pointerRecord)
     {
         return(PdbModule.GetSymbol(pointerRecord.ReferentType));
     }
     return(null);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbSymbol"/> class.
 /// </summary>
 /// <param name="module">Module that contains this symbol.</param>
 /// <param name="id">Type identifier.</param>
 /// <param name="typeRecord">Type record that represents this symbol.</param>
 public PdbSymbol(PdbModule module, uint id, TypeRecord typeRecord)
     : base(module)
 {
     PdbModule       = module;
     Id              = id;
     this.typeRecord = typeRecord;
     if (typeRecord is ClassRecord classRecord)
     {
         Initialize(classRecord);
     }
     else if (typeRecord is UnionRecord unionRecord)
     {
         Initialize(unionRecord);
     }
     else if (typeRecord is EnumRecord enumRecord)
     {
         Initialize(enumRecord);
     }
     else if (typeRecord is BaseClassRecord baseClassRecord)
     {
         Initialize(baseClassRecord);
     }
     else if (typeRecord is VirtualBaseClassRecord virtualBaseClassRecord)
     {
         Initialize(virtualBaseClassRecord);
     }
     else if (typeRecord is PointerRecord pointerRecord)
     {
         Initialize(pointerRecord);
     }
     else if (typeRecord is ProcedureRecord procedureRecord)
     {
         Initialize(procedureRecord);
     }
     else if (typeRecord is ArrayRecord arrayRecord)
     {
         Initialize(arrayRecord);
     }
     else if (typeRecord is ModifierRecord modifierRecord)
     {
         Initialize(modifierRecord);
     }
     else if (typeRecord is MemberFunctionRecord memberFunctionRecord)
     {
         Initialize(memberFunctionRecord);
     }
     else
     {
         throw new NotImplementedException($"Unexpected type record: {typeRecord.Kind}");
     }
 }
Exemplo n.º 8
0
            /// <summary>
            /// Opens the module for the specified XML module description.
            /// </summary>
            /// <param name="xmlModule">The XML module description.</param>
            public override CodeGen.SymbolProviders.Module Open(XmlModule xmlModule)
            {
                try
                {
                    if (UsePdbReaderWhenPossible && xmlModule?.SymbolsPath != null && Path.GetExtension(xmlModule.SymbolsPath).ToLower() == ".pdb")
                    {
                        PdbSymbolProvider.PdbModule pdbModule = new PdbSymbolProvider.PdbModule(xmlModule);

                        lock (pdbModules)
                        {
                            pdbModules.Add(pdbModule);
                        }
                        return(pdbModule);
                    }
                }
                catch
                {
                }
                return(base.Open(xmlModule));
            }
Exemplo n.º 9
0
        /// <summary>
        /// Gets user type base classes.
        /// </summary>
        protected override IEnumerable <Symbol> GetBaseClasses()
        {
            if (typeRecord is ClassRecord classRecord)
            {
                if (classRecord.DerivationList != TypeIndex.None)
                {
                    TypeRecord baseClasses = PdbModule.PdbFile.TpiStream[classRecord.DerivationList];

                    throw new NotImplementedException();
                }
                else if (classRecord.FieldList != TypeIndex.None)
                {
                    foreach (TypeRecord field in EnumerateFieldList(classRecord.FieldList))
                    {
                        if (field is BaseClassRecord || field is VirtualBaseClassRecord)
                        {
                            yield return(PdbModule.GetSymbol(field));
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes data based on the simple built-in type.
        /// </summary>
        private void Initialize(TypeIndex typeIndex)
        {
            Name = typeIndex.SimpleTypeName;
            Tag  = typeIndex.SimpleMode != SimpleTypeMode.Direct ? Engine.CodeTypeTag.Pointer : Engine.CodeTypeTag.BuiltinType;
            switch (typeIndex.SimpleKind)
            {
            case SimpleTypeKind.None:
                BasicType = DIA.BasicType.NoType;
                Size      = 0;
                break;

            case SimpleTypeKind.Void:
                BasicType = DIA.BasicType.Void;
                Size      = 0;
                break;

            case SimpleTypeKind.HResult:
                BasicType = DIA.BasicType.Hresult;
                Size      = 4;
                break;

            case SimpleTypeKind.UnsignedCharacter:
                BasicType = DIA.BasicType.UInt;
                Size      = 1;
                break;

            case SimpleTypeKind.NarrowCharacter:
            case SimpleTypeKind.SignedCharacter:
                BasicType = DIA.BasicType.Char;
                Size      = 1;
                break;

            case SimpleTypeKind.WideCharacter:
                BasicType = DIA.BasicType.WChar;
                Size      = 2;
                break;

            case SimpleTypeKind.Character16:
                BasicType = DIA.BasicType.Char16;
                Size      = 2;
                break;

            case SimpleTypeKind.Character32:
                BasicType = DIA.BasicType.Char32;
                Size      = 4;
                break;

            case SimpleTypeKind.SByte:
                BasicType = DIA.BasicType.Int;
                Size      = 1;
                break;

            case SimpleTypeKind.Byte:
                BasicType = DIA.BasicType.UInt;
                Size      = 1;
                break;

            case SimpleTypeKind.Int16Short:
            case SimpleTypeKind.Int16:
                BasicType = DIA.BasicType.Int;
                Size      = 2;
                break;

            case SimpleTypeKind.UInt16:
            case SimpleTypeKind.UInt16Short:
                BasicType = DIA.BasicType.UInt;
                Size      = 2;
                break;

            case SimpleTypeKind.Int32Long:
            case SimpleTypeKind.Int32:
                BasicType = DIA.BasicType.Int;
                Size      = 4;
                break;

            case SimpleTypeKind.UInt32Long:
            case SimpleTypeKind.UInt32:
                BasicType = DIA.BasicType.UInt;
                Size      = 4;
                break;

            case SimpleTypeKind.Int64Quad:
            case SimpleTypeKind.Int64:
                BasicType = DIA.BasicType.Long;
                Size      = 8;
                break;

            case SimpleTypeKind.UInt64Quad:
            case SimpleTypeKind.UInt64:
                BasicType = DIA.BasicType.ULong;
                Size      = 8;
                break;

            case SimpleTypeKind.Int128Oct:
            case SimpleTypeKind.Int128:
                BasicType = DIA.BasicType.Long;
                Size      = 16;
                break;

            case SimpleTypeKind.UInt128Oct:
            case SimpleTypeKind.UInt128:
                BasicType = DIA.BasicType.ULong;
                Size      = 16;
                break;

            case SimpleTypeKind.Float16:
                BasicType = DIA.BasicType.Float;
                Size      = 2;
                break;

            case SimpleTypeKind.Float32:
            case SimpleTypeKind.Float32PartialPrecision:
                BasicType = DIA.BasicType.Float;
                Size      = 4;
                break;

            case SimpleTypeKind.Float48:
                BasicType = DIA.BasicType.Float;
                Size      = 6;
                break;

            case SimpleTypeKind.Float64:
                BasicType = DIA.BasicType.Float;
                Size      = 8;
                break;

            case SimpleTypeKind.Float80:
                BasicType = DIA.BasicType.Float;
                Size      = 10;
                break;

            case SimpleTypeKind.Float128:
                BasicType = DIA.BasicType.Float;
                Size      = 12;
                break;

            case SimpleTypeKind.Complex16:
                BasicType = DIA.BasicType.Complex;
                Size      = 2;
                break;

            case SimpleTypeKind.Complex32:
            case SimpleTypeKind.Complex32PartialPrecision:
                BasicType = DIA.BasicType.Complex;
                Size      = 4;
                break;

            case SimpleTypeKind.Complex48:
                BasicType = DIA.BasicType.Complex;
                Size      = 6;
                break;

            case SimpleTypeKind.Complex64:
                BasicType = DIA.BasicType.Complex;
                Size      = 8;
                break;

            case SimpleTypeKind.Complex80:
                BasicType = DIA.BasicType.Complex;
                Size      = 10;
                break;

            case SimpleTypeKind.Complex128:
                BasicType = DIA.BasicType.Complex;
                Size      = 16;
                break;

            case SimpleTypeKind.Boolean8:
                BasicType = DIA.BasicType.Bool;
                Size      = 1;
                break;

            case SimpleTypeKind.Boolean16:
                BasicType = DIA.BasicType.Bool;
                Size      = 2;
                break;

            case SimpleTypeKind.Boolean32:
                BasicType = DIA.BasicType.Bool;
                Size      = 4;
                break;

            case SimpleTypeKind.Boolean64:
                BasicType = DIA.BasicType.Bool;
                Size      = 8;
                break;

            case SimpleTypeKind.Boolean128:
                BasicType = DIA.BasicType.Bool;
                Size      = 16;
                break;

            case SimpleTypeKind.NotTranslated:
                BasicType = DIA.BasicType.NoType;
                Size      = 0;
                break;

            default:
                throw new NotImplementedException($"Unexpected simple type: {typeIndex.SimpleKind}, from type index: {typeIndex}");
            }
            if (typeIndex.SimpleMode != SimpleTypeMode.Direct)
            {
                ElementType             = PdbModule.GetSymbol(new TypeIndex(typeIndex.SimpleKind));
                ElementType.PointerType = this;
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbSymbol"/> class.
 /// </summary>
 /// <param name="module">Module that contains this symbol.</param>
 protected PdbSymbol(PdbModule module)
     : base(module)
 {
     PdbModule = module;
 }