예제 #1
0
        public override IList <PdbConstant> GetConstants(ModuleDef module, GenericParamContext gpContext)
        {
            if (scope is not ISymUnmanagedScope2 scope2)
            {
                return(Array2.Empty <PdbConstant>());
            }
            scope2.GetConstants(0, out uint numCs, null);
            if (numCs == 0)
            {
                return(Array2.Empty <PdbConstant>());
            }
            var unCs = new ISymUnmanagedConstant[numCs];

            scope2.GetConstants((uint)unCs.Length, out numCs, unCs);
            var nss = new PdbConstant[numCs];

            for (uint i = 0; i < numCs; i++)
            {
                var unc  = unCs[i];
                var name = GetName(unc);
                unc.GetValue(out object value);
                var     sigBytes = GetSignatureBytes(unc);
                TypeSig signature;
                if (sigBytes.Length == 0)
                {
                    signature = null;
                }
                else
                {
                    signature = SignatureReader.ReadTypeSig(module, module.CorLibTypes, sigBytes, gpContext);
                }
                nss[i] = new PdbConstant(name, signature, value);
            }
            return(nss);
        }
예제 #2
0
        public override IList <PdbConstant> GetConstants(ModuleDef module, GenericParamContext gpContext)
        {
            if (constants == null)
            {
                return(Array2.Empty <PdbConstant>());
            }
            var res = new PdbConstant[constants.Count];

            for (int i = 0; i < res.Length; i++)
            {
                var     info = constants[i];
                TypeSig signature;
                var     saSig    = module.ResolveToken(info.SignatureToken, gpContext) as StandAloneSig;
                var     fieldSig = saSig == null ? null : saSig.Signature as FieldSig;
                if (fieldSig == null)
                {
                    Debug.Fail("Constant without a signature");
                    signature = null;
                }
                else
                {
                    signature = fieldSig.Type;
                }
                res[i] = new PdbConstant(info.Name, signature, info.Value);
            }
            return(res);
        }
예제 #3
0
        public PdbConstant[] GetConstants(ModuleDefMD module, GenericParamContext gpContext)
        {
            var scope2 = scope as ISymUnmanagedScope2;

            if (scope2 == null)
            {
                return(emptySymbolConstants);
            }
            uint numCs;

            scope2.GetConstants(0, out numCs, null);
            if (numCs == 0)
            {
                return(emptySymbolConstants);
            }
            var unCs = new ISymUnmanagedConstant[numCs];

            scope2.GetConstants((uint)unCs.Length, out numCs, unCs);
            var nss = new PdbConstant[numCs];

            for (uint i = 0; i < numCs; i++)
            {
                var    unc  = unCs[i];
                var    name = GetName(unc);
                object value;
                unc.GetValue(out value);
                var     sigBytes = GetSignatureBytes(unc);
                TypeSig signature;
                if (sigBytes.Length == 0)
                {
                    signature = null;
                }
                else
                {
                    signature = SignatureReader.ReadTypeSig(module, module.CorLibTypes, sigBytes, gpContext);
                }
                nss[i] = new PdbConstant(name, signature, value);
            }
            return(nss);
        }
예제 #4
0
        public override IList <PdbConstant> GetConstants(ModuleDef module, GenericParamContext gpContext)
        {
            if (constantList >= constantListEnd)
            {
                return(emptyPdbConstants);
            }
            Debug.Assert(constantsMetaData != null);

            var res = new PdbConstant[constantListEnd - constantList];
            int w   = 0;

            for (int i = 0; i < res.Length; i++)
            {
                uint rid = constantList + (uint)i;
                uint nameOffset;
                uint signature = constantsMetaData.TablesStream.ReadLocalConstantRow2(rid, out nameOffset);
                var  name      = constantsMetaData.StringsStream.Read(nameOffset);
                using (var stream = constantsMetaData.BlobStream.CreateStream(signature)) {
                    var     localConstantSigBlobReader = new LocalConstantSigBlobReader(module, stream, gpContext);
                    TypeSig type;
                    object  value;
                    bool    b = localConstantSigBlobReader.Read(out type, out value);
                    Debug.Assert(b);
                    if (b)
                    {
                        var pdbConstant = new PdbConstant(name, type, value);
                        int token       = new MDToken(Table.LocalConstant, rid).ToInt32();
                        owner.GetCustomDebugInfos(token, gpContext, pdbConstant.CustomDebugInfos);
                        res[w++] = pdbConstant;
                    }
                    Debug.Assert(stream.Position == stream.Length);
                }
            }
            if (res.Length != w)
            {
                Array.Resize(ref res, w);
            }
            return(res);
        }
예제 #5
0
        public override IList <PdbConstant> GetConstants(ModuleDef module, GenericParamContext gpContext)
        {
            if (constantRidList.Count == 0)
            {
                return(Array2.Empty <PdbConstant>());
            }
            Debug.Assert(constantsMetadata is not null);

            var res = new PdbConstant[constantRidList.Count];
            int w   = 0;

            for (int i = 0; i < res.Length; i++)
            {
                uint rid = constantRidList[i];
                bool b   = constantsMetadata.TablesStream.TryReadLocalConstantRow(rid, out var row);
                Debug.Assert(b);
                var name = constantsMetadata.StringsStream.Read(row.Name);
                if (!constantsMetadata.BlobStream.TryCreateReader(row.Signature, out var reader))
                {
                    continue;
                }
                var localConstantSigBlobReader = new LocalConstantSigBlobReader(module, ref reader, gpContext);
                b = localConstantSigBlobReader.Read(out var type, out object value);
                Debug.Assert(b);
                if (b)
                {
                    var pdbConstant = new PdbConstant(name, type, value);
                    int token       = new MDToken(Table.LocalConstant, rid).ToInt32();
                    owner.GetCustomDebugInfos(token, gpContext, pdbConstant.CustomDebugInfos);
                    res[w++] = pdbConstant;
                }
            }
            if (res.Length != w)
            {
                Array.Resize(ref res, w);
            }
            return(res);
        }
예제 #6
0
 /// <summary>
 /// Add a constant to the list of constants available within this scope.
 /// </summary>
 /// <param name="constant">Constant to add to this scope</param>
 public void AddConstant(PdbConstant pdbConstant)
 {
     _constants.Add(pdbConstant);
 }
예제 #7
0
 internal PdbLocalConstant(PdbConstant pdbConstant, IMetadataHost host, IMethodDefinition methodDefinition)
 {
     this.pdbConstant      = pdbConstant;
     this.host             = host;
     this.methodDefinition = methodDefinition;
 }
 internal PdbLocalConstant(PdbConstant pdbConstant, IMetadataHost host, IMethodDefinition methodDefinition)
 {
     this.pdbConstant = pdbConstant;
     this.host = host;
     this.methodDefinition = methodDefinition;
 }
예제 #9
0
 internal Constant(PdbConstant constant)
 {
     this.Name  = constant.name;
     this.Value = constant.value;
     this.Token = (int)constant.token;
 }