本文整理汇总了C#中Mosa.Compiler.Metadata.Token类的典型用法代码示例。如果您正苦于以下问题:C# Token类的具体用法?C# Token怎么用?C# Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Token类属于Mosa.Compiler.Metadata命名空间,在下文中一共展示了Token类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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;
}
示例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;
}
示例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;
}
示例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>();
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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)
);
}
}
示例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)
);
}
}
示例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)
);
}
}
示例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)
);
}
}