• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Metadata.Token类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mosa.Compiler.Metadata.Token的典型用法代码示例。如果您正苦于以下问题:C# Token类的具体用法?C# Token怎么用?C# Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Token类属于Mosa.Compiler.Metadata命名空间,在下文中一共展示了Token类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CilGenericType

        /// <summary>
        /// Initializes a new instance of the <see cref="CilGenericType"/> class.
        /// </summary>
        /// <param name="typeModule">The type module.</param>
        /// <param name="token">The token.</param>
        /// <param name="baseGenericType">Type of the base generic.</param>
        /// <param name="genericTypeInstanceSignature">The generic type instance signature.</param>
        public CilGenericType(ITypeModule typeModule, Token token, RuntimeType baseGenericType, GenericInstSigType genericTypeInstanceSignature)
            : base(baseGenericType.Module, token, baseGenericType.BaseType)
        {
            Debug.Assert(baseGenericType is CilRuntimeType);

            this.signature = genericTypeInstanceSignature;
            this.baseGenericType = baseGenericType as CilRuntimeType;
            this.InstantiationModule = typeModule;
            base.Attributes = baseGenericType.Attributes;
            base.Namespace = baseGenericType.Namespace;

            if (this.baseGenericType.IsNested)
            {
                // TODO: find generic type

                ;
            }

            // TODO: if this is a nested types, add enclosing type(s) into genericArguments first
            this.genericArguments = signature.GenericArguments;

            base.Name = GetName(typeModule);

            ResolveMethods();
            ResolveFields();

            this.containsOpenGenericArguments = CheckContainsOpenGenericParameters();
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:35,代码来源:CilGenericType.cs


示例2: RuntimeAttribute

 /// <summary>
 /// Initializes a new instance of the <see cref="RuntimeAttribute"/> class.
 /// </summary>
 /// <param name="typeModule">The type module.</param>
 /// <param name="ctor">The ctor.</param>
 /// <param name="ctorMethod">The ctor method.</param>
 /// <param name="blobIndex">Index of the blob.</param>
 public RuntimeAttribute(ITypeModule typeModule, Token ctor, RuntimeMethod ctorMethod, HeapIndexToken blobIndex)
 {
     this.typeModule = typeModule;
     this.ctorMethod = ctorMethod;
     this.ctor = ctor;
     this.blobIndex = blobIndex;
 }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:14,代码来源:RuntimeAttribute.cs


示例3: CilRuntimeField

 /// <summary>
 /// Initializes a new instance of the <see cref="CilRuntimeField"/> class.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="name">The name.</param>
 /// <param name="signature">The signature.</param>
 /// <param name="token">The token.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="rva">The rva.</param>
 /// <param name="declaringType">Type of the declaring.</param>
 /// <param name="attributes">The attributes.</param>
 public CilRuntimeField(ITypeModule module, string name, FieldSignature signature, Token token, uint offset, uint rva, RuntimeType declaringType, FieldAttributes attributes)
     : base(module, token, declaringType)
 {
     this.Name = name;
     this.Signature = signature;
     base.Attributes = attributes;
     base.RVA = rva;
 }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:19,代码来源:CilRuntimeField.cs


示例4: VerificationEntry

 public VerificationEntry(string assembly, VerificationType type, string section, string error, string description, Token token)
 {
     this.Assembly = assembly;
     this.Type = type;
     this.Section = section;
     this.Rule = error;
     this.Description = description;
     this.Location = token;
 }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:9,代码来源:VerificationEntry.cs


示例5: CilRuntimeMethod

        /// <summary>
        /// Initializes a new instance of the <see cref="CilRuntimeMethod"/> class.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="name">The name.</param>
        /// <param name="signature">The signature.</param>
        /// <param name="token">The token.</param>
        /// <param name="declaringType">Type of the declaring.</param>
        /// <param name="methodAttributes">The method attributes.</param>
        /// <param name="methodImplAttributes">The method impl attributes.</param>
        /// <param name="rva">The rva.</param>
        public CilRuntimeMethod(ITypeModule module, string name, MethodSignature signature, Token token, RuntimeType declaringType, MethodAttributes methodAttributes, MethodImplAttributes methodImplAttributes, uint rva)
            : base(module, token, declaringType)
        {
            base.Attributes = methodAttributes;
            base.ImplAttributes = methodImplAttributes;
            base.Rva = rva;
            this.Name = name;
            this.Signature = signature;

            this.Parameters = new List<RuntimeParameter>();
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:22,代码来源:CilRuntimeMethod.cs


示例6: Run

        protected override void Run()
        {
            int rows = metadata.GetRowCount(TableType.Assembly);

            if (rows == 0)
                return;

            // 1. The Assembly table shall contain zero or one row
            if (rows > 1)
            {
                AddSpecificationError("22.2-1", "The Assembly table shall contain zero or one row", "Multiple rows found");
            }

            Token token = new Token(TableType.Assembly, 1);
            AssemblyRow row = metadata.ReadAssemblyRow(token);

            // 2. HashAlgId shall be one of the specified values
            // Note: Microsoft treats this as a WARNING rather than an error
            if (!IsValidHashAlgID((int)row.HashAlgId))
            {
                AddSpecificationError("22.2-2", "HashAlgId shall be one of the specified values", "Invalid Hash Algorithm ID", token);
            }

            // 4. Flags shall have only those values set that are specified
            if (!IsAssemblyFlags((int)row.Flags))
            {
                AddSpecificationError("22.2-4", "Flags shall have only those values set that are specified", "Invalid Hash Algorithm ID", token);
            }

            // 6. Name shall index a non-empty string in the String heap
            switch (CheckName(row.Name))
            {
                case 0: break;
                case 1: AddSpecificationError("22.2-6", "Name shall index a non-empty string, in the String heap", "Empty name", token); break;
                case 2: AddSpecificationError("22.2-6", "Name shall index a non-empty string, in the String heap", "Invalid index", token); break;
                case 3: AddSpecificationError("22.2-6", "Name shall index a non-empty string, in the String heap", "Empty name", token); break;
            }

            // 9. If Culture is non-null, it shall index a single string from the list specified
            switch (CheckCulture(row.Culture))
            {
                case 0: break;
                case 1: AddSpecificationError("22.2-9", "If Culture is non-null, it shall index a single string from the list specified", "Invalid or Missing Culture", token); break;
            }
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:45,代码来源:Assembly.cs


示例7: CilRuntimeType

        /// <summary>
        /// Initializes a new instance of the <see cref="CilRuntimeType"/> class.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="name">The name.</param>
        /// <param name="typeNamespace">The type namespace.</param>
        /// <param name="packing">The packing.</param>
        /// <param name="size">The size.</param>
        /// <param name="token">The token.</param>
        /// <param name="baseType">Type of the base.</param>
        /// <param name="enclosingType">Type of the enclosing.</param>
        /// <param name="attributes">The attributes.</param>
        /// <param name="baseToken">The base token.</param>
        public CilRuntimeType(ITypeModule module, string name, string typeNamespace, int packing, int size, Token token, RuntimeType baseType, RuntimeType enclosingType, TypeAttributes attributes, Token baseToken)
            : base(module, token, baseType)
        {
            this.baseTypeToken = baseToken;
            this.enclosingType = enclosingType;

            base.Attributes = attributes;
            base.Pack = packing;
            base.LayoutSize = size;
            base.Name = name;
            base.Namespace = typeNamespace;

            if (IsNested)
            {
                Debug.Assert(enclosingType != null);
                this.Namespace = enclosingType.Namespace + "." + enclosingType.Name;
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:31,代码来源:CilRuntimeType.cs


示例8: UpdateTree

        protected void UpdateTree()
        {
            treeView.BeginUpdate();
            treeView.Nodes.Clear();

            //Cycle through all metadata tables
            foreach (TableType table in Enum.GetValues(typeof(TableType)))
            {
                if (table == TableType.Module)
                    continue;

                int count = metadataModule.Metadata.GetRowCount(table);

                if (count == 0)
                    continue;

                TreeNode tableNode = new TreeNode("[" + table.FormatToString() + "] " + table.ToString() + " (" + count.ToString() + ")");
                treeView.Nodes.Add(tableNode);

                //Cycle through all metadata rows
                for (int rowid = 1; rowid <= count; rowid++)
                {
                    Token token = new Token(table, rowid);

                    TableRow row = Resolver.GetTableRow(metadataModule, token);

                    if (row == null)
                        continue;

                    TreeNode rowNode = new TreeNode(token.FormatToString() + " - " + row.Name);
                    tableNode.Nodes.Add(rowNode);

                    foreach (KeyValuePair<string, string> data in row.GetValues())
                    {
                        TreeNode rowValueNode = new TreeNode(data.Key + ": " + data.Value);
                        rowNode.Nodes.Add(rowValueNode);
                    }
                }
            }

            treeView.EndUpdate();
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:42,代码来源:Main.cs


示例9: foreach

        /// <summary>
        /// Runs the specified compiler.
        /// </summary>
        void IMethodCompilerStage.Run()
        {
            // Handler Code
            foreach (ExceptionHandlingClause clause in methodCompiler.ExceptionClauseHeader.Clauses)
            {
                if (clause.ExceptionHandler == ExceptionHandlerType.Exception)
                {
                    var typeToken = new Token(clause.ClassToken);

                    RuntimeType type = methodCompiler.Method.Module.GetType(typeToken);

                    var block = FindBlock(clause.HandlerOffset);

                    var context = new Context(instructionSet, block).InsertBefore();

                    SigType sigType = new ClassSigType(typeToken);
                    Operand exceptionObject = methodCompiler.CreateTemporary(sigType);

                    context.SetInstruction(IR.Instruction.ExceptionPrologueInstruction, exceptionObject);
                }
            }
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:25,代码来源:ExceptionPrologueStage.cs


示例10: GetTableRow

        public static TableRow GetTableRow(IMetadataProvider metadata, Token token)
        {
            switch (token.Table)
            {
                case TableType.File: return new FileRowExt(metadata, metadata.ReadFileRow(token));
                case TableType.TypeDef: return new TypeDefRowExt(metadata, metadata.ReadTypeDefRow(token));
                case TableType.TypeSpec: return new TypeSpecRowExt(metadata, metadata.ReadTypeSpecRow(token));
                case TableType.TypeRef: return new TypeRefRowExt(metadata, metadata.ReadTypeRefRow(token));
                case TableType.Field: return new FieldRowExt(metadata, metadata.ReadFieldRow(token));
                case TableType.MethodDef: return new MethodDefRowExt(metadata, metadata.ReadMethodDefRow(token));
                case TableType.ImplMap: return new ImplMapRowExt(metadata, metadata.ReadImplMapRow(token));
                case TableType.MemberRef: return new MemberRefRowExt(metadata, metadata.ReadMemberRefRow(token));
                case TableType.InterfaceImpl: return new InterfaceImplRowExt(metadata, metadata.ReadInterfaceImplRow(token));
                case TableType.CustomAttribute: return new CustomAttributeRowExt(metadata, metadata.ReadCustomAttributeRow(token));
                case TableType.Assembly: return new AssemblyRowExt(metadata, metadata.ReadAssemblyRow(token));
                case TableType.AssemblyRef: return new AssemblyRefRowExt(metadata, metadata.ReadAssemblyRefRow(token));
                case TableType.GenericParam: return new GenericParamRowExt(metadata, metadata.ReadGenericParamRow(token));
                case TableType.Param: return new ParamRowExt(metadata, metadata.ReadParamRow(token));

                default: return null;
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:22,代码来源:Resolver.cs


示例11: GetTableRow

 public static TableRow GetTableRow(IMetadataModule metadataModule, Token token)
 {
     switch (token.Table)
     {
         case TableType.File: return new FileRowExt(metadataModule, metadataModule.Metadata.ReadFileRow(token));
         case TableType.TypeDef: return new TypeDefRowExt(metadataModule, metadataModule.Metadata.ReadTypeDefRow(token));
         case TableType.TypeSpec: return new TypeSpecRowExt(metadataModule, metadataModule.Metadata.ReadTypeSpecRow(token));
         case TableType.TypeRef: return new TypeRefRowExt(metadataModule, metadataModule.Metadata.ReadTypeRefRow(token));
         case TableType.Field: return new FieldRowExt(metadataModule, metadataModule.Metadata.ReadFieldRow(token));
         case TableType.MethodDef: return new MethodDefRowExt(metadataModule, metadataModule.Metadata.ReadMethodDefRow(token));
         case TableType.ImplMap: return new ImplMapRowExt(metadataModule, metadataModule.Metadata.ReadImplMapRow(token));
         case TableType.MemberRef: return new MemberRefRowExt(metadataModule, metadataModule.Metadata.ReadMemberRefRow(token));
         case TableType.InterfaceImpl: return new InterfaceImplRowExt(metadataModule, metadataModule.Metadata.ReadInterfaceImplRow(token));
         case TableType.CustomAttribute: return new CustomAttributeRowExt(metadataModule, metadataModule.Metadata.ReadCustomAttributeRow(token));
         case TableType.Assembly: return new AssemblyRowExt(metadataModule, metadataModule.Metadata.ReadAssemblyRow(token));
         case TableType.AssemblyRef: return new AssemblyRefRowExt(metadataModule, metadataModule.Metadata.ReadAssemblyRefRow(token));
         case TableType.GenericParam: return new GenericParamRowExt(metadataModule, metadataModule.Metadata.ReadGenericParamRow(token));
         case TableType.Param: return new ParamRowExt(metadataModule, metadataModule.Metadata.ReadParamRow(token));
         case TableType.StandAloneSig: return new StandAloneSigExt(metadataModule, metadataModule.Metadata.ReadStandAloneSigRow(token));
         case TableType.MethodSpec: return new MethodSpecExt(metadataModule, metadataModule.Metadata.ReadMethodSpecRow(token));
         case TableType.NestedClass: return new NestedClassExt(metadataModule, metadataModule.Metadata.ReadNestedClassRow(token));
         default: return null;
     }
 }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:24,代码来源:Resolver.cs


示例12: ReadPropertyRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public PropertyRow ReadPropertyRow(Token token)
        {
            if (token.Table != TableType.Property)
                throw new ArgumentException("Invalid token type for PropertyRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new PropertyRow(
                    (PropertyAttributes)reader.ReadUInt16(),
                    ReadHeapToken(reader, IndexType.StringHeap),
                    ReadHeapToken(reader, IndexType.BlobHeap)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:19,代码来源:TableHeap.cs


示例13: ReadPropertyMapRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public PropertyMapRow ReadPropertyMapRow(Token token)
        {
            if (token.Table != TableType.PropertyMap)
                throw new ArgumentException("Invalid token type for PropertyMapRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new PropertyMapRow(
                    ReadIndexValue(reader, TableType.TypeDef),
                    ReadIndexValue(reader, TableType.Property)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:18,代码来源:TableHeap.cs


示例14: ReadParamRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public ParamRow ReadParamRow(Token token)
        {
            if (token.Table != TableType.Param)
                throw new ArgumentException("Invalid token type for ParamRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new ParamRow(
                    (ParameterAttributes)reader.ReadUInt16(),
                    reader.ReadInt16(),
                    ReadHeapToken(reader, IndexType.StringHeap)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:19,代码来源:TableHeap.cs


示例15: ReadNestedClassRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public NestedClassRow ReadNestedClassRow(Token token)
        {
            if (token.Table != TableType.NestedClass)
                throw new ArgumentException("Invalid token type for NestedClassRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new NestedClassRow(
                    ReadIndexValue(reader, TableType.TypeDef),
                    ReadIndexValue(reader, TableType.TypeDef)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:18,代码来源:TableHeap.cs


示例16:

 /// <summary>
 /// Retrieves the runtime type for a given metadata token.
 /// </summary>
 /// <param name="token">The token of the type to load. This can represent a typeref, typedef or typespec token.</param>
 /// <returns>The runtime type of the specified token.</returns>
 RuntimeType ITypeModule.GetType(Token token)
 {
     return null;
 }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:9,代码来源:InternalTypeModule.cs


示例17: foreach

 /// <summary>
 /// Retrieves the method definition identified by the given token in the scope.
 /// </summary>
 /// <param name="token">The token of the method to retrieve.</param>
 /// <returns></returns>
 RuntimeMethod ITypeModule.GetMethod(Token token)
 {
     foreach (var method in methods)
         if (method.Token == token)
             return method;
     return null;
 }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:12,代码来源:InternalTypeModule.cs


示例18: ReadTypeRefRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public TypeRefRow ReadTypeRefRow(Token token)
        {
            if (token.Table != TableType.TypeRef)
                throw new ArgumentException("Invalid token type for TypeRefRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new TypeRefRow(
                    ReadMetadataToken(reader, IndexType.ResolutionScope),
                    ReadHeapToken(reader, IndexType.StringHeap),
                    ReadHeapToken(reader, IndexType.StringHeap)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:19,代码来源:TableHeap.cs


示例19: ReadStandAloneSigRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public StandAloneSigRow ReadStandAloneSigRow(Token token)
        {
            if (token.Table != TableType.StandAloneSig)
                throw new ArgumentException("Invalid token type for StandAloneSigRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new StandAloneSigRow(
                    ReadHeapToken(reader, IndexType.BlobHeap)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:17,代码来源:TableHeap.cs


示例20: ReadTypeDefRow

        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        public TypeDefRow ReadTypeDefRow(Token token)
        {
            if (token.Table != TableType.TypeDef)
                throw new ArgumentException("Invalid token type for TypeDefRow.", @"token");

            using (var reader = CreateReaderForToken(token))
            {
                return new TypeDefRow(
                    (TypeAttributes)reader.ReadUInt32(),
                    ReadHeapToken(reader, IndexType.StringHeap),
                    ReadHeapToken(reader, IndexType.StringHeap),
                    ReadMetadataToken(reader, IndexType.TypeDefOrRef),
                    ReadIndexValue(reader, TableType.Field),
                    ReadIndexValue(reader, TableType.MethodDef)
                );
            }
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:22,代码来源:TableHeap.cs



注:本文中的Mosa.Compiler.Metadata.Token类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Signatures.SigType类代码示例发布时间:2022-05-26
下一篇:
C# RegisterAllocator.SlotIndex类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap