本文整理汇总了C#中INameTable类的典型用法代码示例。如果您正苦于以下问题:C# INameTable类的具体用法?C# INameTable怎么用?C# INameTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
INameTable类属于命名空间,在下文中一共展示了INameTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FirstStatementIsIteratorCreation
private static IMethodBody/*?*/ FirstStatementIsIteratorCreation(IMetadataHost host, ISourceMethodBody possibleIterator, INameTable nameTable, IStatement statement) {
ICreateObjectInstance createObjectInstance = GetICreateObjectInstance(statement);
if (createObjectInstance == null) {
// If the first statement in the method body is not the creation of iterator closure, return a dummy.
// Possible corner case not handled: a local is used to hold the constant value for the initial state of the closure.
return null;
}
ITypeReference closureType/*?*/ = createObjectInstance.MethodToCall.ContainingType;
ITypeReference unspecializedClosureType = ContractHelper.Unspecialized(closureType);
if (!AttributeHelper.Contains(unspecializedClosureType.Attributes, host.PlatformType.SystemRuntimeCompilerServicesCompilerGeneratedAttribute))
return null;
INestedTypeReference closureTypeAsNestedTypeReference = unspecializedClosureType as INestedTypeReference;
if (closureTypeAsNestedTypeReference == null) return null;
ITypeReference unspecializedClosureContainingType = ContractHelper.Unspecialized(closureTypeAsNestedTypeReference.ContainingType);
if (closureType != null && TypeHelper.TypesAreEquivalent(possibleIterator.MethodDefinition.ContainingTypeDefinition, unspecializedClosureContainingType)) {
IName MoveNextName = nameTable.GetNameFor("MoveNext");
foreach (ITypeDefinitionMember member in closureType.ResolvedType.GetMembersNamed(MoveNextName, false)) {
IMethodDefinition moveNext = member as IMethodDefinition;
if (moveNext != null) {
ISpecializedMethodDefinition moveNextGeneric = moveNext as ISpecializedMethodDefinition;
if (moveNextGeneric != null)
moveNext = moveNextGeneric.UnspecializedVersion.ResolvedMethod;
return moveNext.Body;
}
}
}
return null;
}
示例2: HostEnvironment
public HostEnvironment(INameTable table, IEnumerable<String> assemblyPaths, IEnumerable<String> referencedAssemblies)
: base(table, new InternFactory(), 4, assemblyPaths, true)
{
_peReader = new PeReader(this);
_assemblyPaths = assemblyPaths;
_referencedAssemblies = referencedAssemblies;
}
示例3: MetadataHostEnvironment
/// <summary>
/// Allocates an object that provides an abstraction over the application hosting compilers based on this framework.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
/// <param name="pointerSize">The size of a pointer on the runtime that is the target of the metadata units to be loaded
/// into this metadta host. This parameter only matters if the host application wants to work out what the exact layout
/// of a struct will be on the target runtime. The framework uses this value in methods such as TypeHelper.SizeOfType and
/// TypeHelper.TypeAlignment. If the host application does not care about the pointer size it can provide 0 as the value
/// of this parameter. In that case, the first reference to IMetadataHost.PointerSize will probe the list of loaded assemblies
/// to find an assembly that either requires 32 bit pointers or 64 bit pointers. If no such assembly is found, the default is 32 bit pointers.
/// </param>
/// <param name="factory">The intern factory to use when generating keys. When comparing two or more assemblies using
/// TypeHelper, MemberHelper, etc. it is necessary to make the hosts use the same intern factory.</param>
protected MetadataHostEnvironment(INameTable nameTable, IInternFactory factory, byte pointerSize)
//^ requires pointerSize == 0 || pointerSize == 4 || pointerSize == 8;
{
this.nameTable = nameTable;
this.internFactory = factory;
this.pointerSize = pointerSize;
}
示例4: MetadataHostEnvironment
/// <summary>
/// Allocates an object that provides an abstraction over the application hosting compilers based on this framework.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
/// <param name="factory">
/// The intern factory to use when generating keys. When comparing two or more assemblies using
/// TypeHelper, MemberHelper, etc. it is necessary to make the hosts use the same intern factory.
/// </param>
/// <param name="pointerSize">The size of a pointer on the runtime that is the target of the metadata units to be loaded
/// into this metadta host. This parameter only matters if the host application wants to work out what the exact layout
/// of a struct will be on the target runtime. The framework uses this value in methods such as TypeHelper.SizeOfType and
/// TypeHelper.TypeAlignment. If the host application does not care about the pointer size it can provide 0 as the value
/// of this parameter. In that case, the first reference to IMetadataHost.PointerSize will probe the list of loaded assemblies
/// to find an assembly that either requires 32 bit pointers or 64 bit pointers. If no such assembly is found, the default is 32 bit pointers.
/// </param>
/// <param name="searchPaths">
/// A collection of strings that are interpreted as valid paths which are used to search for units.
/// </param>
/// <param name="searchInGAC">
/// Whether the GAC (Global Assembly Cache) should be searched when resolving references.
/// </param>
protected MetadataHostEnvironment(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string> searchPaths, bool searchInGAC)
//^ requires pointerSize == 0 || pointerSize == 4 || pointerSize == 8;
{
this.nameTable = nameTable;
this.internFactory = factory;
this.pointerSize = pointerSize;
this.libPaths = searchPaths == null ? new List<string>(0) : new List<string>(searchPaths);
this.SearchInGAC = searchInGAC;
}
示例5: MetadataHostEnvironment
/// <summary>
/// Allocates an object that provides an abstraction over the application hosting compilers based on this framework.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
/// <param name="factory">
/// The intern factory to use when generating keys. When comparing two or more assemblies using
/// TypeHelper, MemberHelper, etc. it is necessary to make the hosts use the same intern factory.
/// </param>
/// <param name="pointerSize">The size of a pointer on the runtime that is the target of the metadata units to be loaded
/// into this metadta host. This parameter only matters if the host application wants to work out what the exact layout
/// of a struct will be on the target runtime. The framework uses this value in methods such as TypeHelper.SizeOfType and
/// TypeHelper.TypeAlignment. If the host application does not care about the pointer size it can provide 0 as the value
/// of this parameter. In that case, the first reference to IMetadataHost.PointerSize will probe the list of loaded assemblies
/// to find an assembly that either requires 32 bit pointers or 64 bit pointers. If no such assembly is found, the default is 32 bit pointers.
/// </param>
/// <param name="searchPaths">
/// A collection of strings that are interpreted as valid paths which are used to search for units. May be null.
/// </param>
/// <param name="searchInGAC">
/// Whether the GAC (Global Assembly Cache) should be searched when resolving references.
/// </param>
protected MetadataHostEnvironment(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string>/*?*/ searchPaths, bool searchInGAC) {
Contract.Requires(nameTable != null);
Contract.Requires(factory != null);
Contract.Requires(pointerSize == 0 || pointerSize == 4 || pointerSize == 8);
this.nameTable = nameTable;
this.internFactory = factory;
this.pointerSize = pointerSize;
this.libPaths = searchPaths == null ? new List<string>(0) : new List<string>(searchPaths);
this.SearchInGAC = searchInGAC;
}
示例6: Parse
public static AssemblyIdentity Parse(INameTable nameTable, string formattedName)
{
var name = new System.Reflection.AssemblyName(formattedName);
return new AssemblyIdentity(nameTable.GetNameFor(name.Name),
name.CultureName,
name.Version,
name.GetPublicKeyToken(),
#if COREFX
"");
#else
name.CodeBase);
#endif
}
示例7: Inherited
/// <summary>
/// Specifies whether this attribute applies to derived types and/or overridden methods.
/// This information is obtained from an attribute on the attribute type definition.
/// </summary>
public static bool Inherited(ITypeDefinition attributeType, INameTable nameTable) {
foreach (ICustomAttribute ca in attributeType.Attributes) {
if (!TypeHelper.TypesAreEquivalent(ca.Type, attributeType.PlatformType.SystemAttributeUsageAttribute))
continue;
foreach (IMetadataNamedArgument namedArgument in ca.NamedArguments) {
if (namedArgument.ArgumentName.UniqueKey == nameTable.AllowMultiple.UniqueKey) {
IMetadataConstant/*?*/ compileTimeConst = namedArgument.ArgumentValue as IMetadataConstant;
if (compileTimeConst == null || compileTimeConst.Value == null || !(compileTimeConst.Value is bool))
continue;
//^ assume false; //Unboxing cast might fail
return (bool)compileTimeConst.Value;
}
}
}
return false;
}
示例8: NamespaceTypeName
internal NamespaceTypeName(INameTable nameTable, NamespaceName/*?*/ namespaceName, IName name) {
this.NamespaceName = namespaceName;
this.Name = name;
string nameStr = null;
TypeCache.SplitMangledTypeName(name.Value, out nameStr, out this.genericParameterCount);
if (this.genericParameterCount > 0)
this.unmanagledTypeName = nameTable.GetNameFor(nameStr);
else
this.unmanagledTypeName = name;
}
示例9: NamespaceName
internal NamespaceName(INameTable nameTable, NamespaceName/*?*/ parentNamespaceName, IName name) {
this.ParentNamespaceName = parentNamespaceName;
this.Name = name;
if (parentNamespaceName == null)
this.FullyQualifiedName = name;
else
this.FullyQualifiedName = nameTable.GetNameFor(parentNamespaceName.FullyQualifiedName.Value + "." + name);
}
示例10: MetadataReaderHost
/// <summary>
/// Allocates an object that provides an abstraction over the application hosting compilers based on this framework.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
/// <param name="factory">The intern factory to use when generating keys. When comparing two or more assemblies using
/// TypeHelper, MemberHelper, etc. it is necessary to make the hosts use the same intern factory.</param>
/// /// <param name="pointerSize">The size of a pointer on the runtime that is the target of the metadata units to be loaded
/// into this metadta host. This parameter only matters if the host application wants to work out what the exact layout
/// of a struct will be on the target runtime. The framework uses this value in methods such as TypeHelper.SizeOfType and
/// TypeHelper.TypeAlignment. If the host application does not care about the pointer size it can provide 0 as the value
/// of this parameter. In that case, the first reference to IMetadataHost.PointerSize will probe the list of loaded assemblies
/// to find an assembly that either requires 32 bit pointers or 64 bit pointers. If no such assembly is found, the default is 32 bit pointers.
/// </param>
protected MetadataReaderHost(INameTable nameTable, IInternFactory factory, byte pointerSize)
: base(nameTable, factory, pointerSize)
//^ requires pointerSize == 0 || pointerSize == 4 || pointerSize == 8;
{
}
示例11: NestedTypeName
internal NestedTypeName(INameTable nameTable, NominalTypeName containingTypeName, IName mangledName) {
this.ContainingTypeName = containingTypeName;
this.Name = mangledName;
string nameStr = null;
TypeCache.SplitMangledTypeName(mangledName.Value, out nameStr, out this.genericParameterCount);
this.unmangledTypeName = nameTable.GetNameFor(nameStr);
}
示例12: DefaultHost
/// <summary>
/// Allocates a simple host environment using default settings inherited from MetadataReaderHost and that
/// uses PeReader as its metadata reader.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
public DefaultHost(INameTable nameTable)
: base(nameTable) {
this.peReader = new PeReader(this);
}
示例13: AssertAssumeAdderVisitor
/// <summary>
/// Allocates a visitor that traverses a code model and generates explicit assert and assume statements based on implicit checks and assumptions
/// that are present in the object model. For example, any array index expression implicitly asserts that the array index is within bounds.
/// The purpose of this visitor is to produce an object model that can be checked by a static checker, without requiring the static checker to
/// have special cases for all of the implicit assertions and assumes in the code.
/// </summary>
/// <param name="nameTable">A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.</param>
/// <param name="insertAssumeFalseAtLine"></param>
public AssertAssumeAdderVisitor(INameTable nameTable, uint? insertAssumeFalseAtLine)
: base()
{
this.nameTable = nameTable;
this.insertAssumeFalseAtLine = insertAssumeFalseAtLine;
}
示例14: DefaultHost
/// <summary>
/// Allocates a simple host environment using default settings inherited from MetadataReaderHost and that
/// uses PeReader as its metadata reader.
/// </summary>
/// <param name="nameTable">
/// A collection of IName instances that represent names that are commonly used during compilation.
/// This is a provided as a parameter to the host environment in order to allow more than one host
/// environment to co-exist while agreeing on how to map strings to IName instances.
/// </param>
public DefaultHost(INameTable nameTable)
: base(nameTable, new InternFactory(), 0, null, false)
{
this.peReader = new PeReader(this);
}
示例15: InstructionParser
internal InstructionParser(SourceMethodBody sourceMethodBody) {
Contract.Requires(sourceMethodBody != null);
this.sourceMethodBody = sourceMethodBody;
this.host = sourceMethodBody.host; Contract.Assume(this.host != null);
this.ilMethodBody = sourceMethodBody.ilMethodBody; Contract.Assume(this.ilMethodBody != null);
this.MethodDefinition = sourceMethodBody.MethodDefinition;
this.nameTable = sourceMethodBody.nameTable; Contract.Assume(this.nameTable != null);
this.sourceLocationProvider = sourceMethodBody.sourceLocationProvider;
this.localScopeProvider = sourceMethodBody.localScopeProvider;
this.options = sourceMethodBody.options;
this.platformType = sourceMethodBody.platformType; Contract.Assume(this.platformType != null);
this.numberOfAssignmentsToLocal = sourceMethodBody.numberOfAssignmentsToLocal; Contract.Assume(this.numberOfAssignmentsToLocal != null);
this.numberOfReferencesToLocal = sourceMethodBody.numberOfReferencesToLocal; Contract.Assume(this.numberOfReferencesToLocal != null);
this.gotosThatTarget = sourceMethodBody.gotosThatTarget; Contract.Assume(this.gotosThatTarget != null);
this.cdfg = sourceMethodBody.cdfg; Contract.Assume(this.cdfg != null);
this.bindingsThatMakeALastUseOfALocalVersion = sourceMethodBody.bindingsThatMakeALastUseOfALocalVersion; Contract.Assume(this.bindingsThatMakeALastUseOfALocalVersion != null);
if (this.localScopeProvider != null) {
var syncInfo = this.localScopeProvider.GetSynchronizationInformation(sourceMethodBody);
if (syncInfo != null) {
var syncPointFor = this.synchronizatonPointLocationFor = new Hashtable<SynchronizationPointLocation>();
IDocument doc = Dummy.Document;
foreach (var loc in this.MethodDefinition.Locations) { doc = loc.Document; break; }
foreach (var syncPoint in syncInfo.SynchronizationPoints) {
Contract.Assume(syncPoint != null);
var syncLoc = new SynchronizationPointLocation(doc, syncPoint);
syncPointFor[syncPoint.SynchronizeOffset] = syncLoc;
if (syncPoint.ContinuationMethod == null)
syncPointFor[syncPoint.ContinuationOffset] = syncLoc;
}
}
}
}