/// <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; }
/// <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; }
/// <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; }
/// <summary> /// /// </summary> /// <param name="securityAttribute"></param> /// <param name="internFactory"></param> public void Copy(ISecurityAttribute securityAttribute, IInternFactory internFactory) { this.action = securityAttribute.Action; if (IteratorHelper.EnumerableIsNotEmpty(securityAttribute.Attributes)) { this.attributes = new List <ICustomAttribute>(securityAttribute.Attributes); } else { this.attributes = null; } }
/// <summary> /// /// </summary> /// <param name="resourceReference"></param> /// <param name="internFactory"></param> public void Copy(IResourceReference resourceReference, IInternFactory internFactory) { if (IteratorHelper.EnumerableIsNotEmpty(resourceReference.Attributes)) { this.attributes = new List <ICustomAttribute>(resourceReference.Attributes); } else { this.attributes = null; } this.definingAssembly = resourceReference.DefiningAssembly; this.isPublic = resourceReference.IsPublic; this.name = resourceReference.Name; this.resource = resourceReference.Resource; }
/// <summary> /// /// </summary> /// <param name="assembly"></param> /// <param name="internFactory"></param> public void Copy(IAssembly assembly, IInternFactory internFactory) { ((ICopyFrom <IModule>) this).Copy(assembly, internFactory); this.assemblyAttributes = new List <ICustomAttribute>(assembly.AssemblyAttributes); this.culture = assembly.Culture; this.exportedTypes = new List <IAliasForType>(assembly.ExportedTypes); this.flags = assembly.Flags; this.files = new List <IFileReference>(assembly.Files); this.memberModules = new List <IModule>(assembly.MemberModules); this.moduleName = assembly.ModuleName; this.publicKey = assembly.PublicKey; this.resources = new List <IResourceReference>(assembly.Resources); this.securityAttributes = new List <ISecurityAttribute>(assembly.SecurityAttributes); this.version = assembly.Version; }
/// <summary> /// /// </summary> /// <param name="resource"></param> /// <param name="internFactory"></param> public void Copy(IResource resource, IInternFactory internFactory) { this.attributes = new List <ICustomAttribute>(resource.Attributes); this.data = new List <byte>(resource.Data); this.definingAssembly = resource.DefiningAssembly; if (resource.IsInExternalFile) { this.externalFile = resource.ExternalFile; } else { this.externalFile = Dummy.FileReference; } this.isInExternalFile = resource.IsInExternalFile; this.isPublic = resource.IsPublic; this.name = resource.Name; }
/// <summary> /// Makes a shallow copy of an expression that creates an array instance in metadata. Only for use in custom attributes. /// </summary> /// <param name="createArray"></param> /// <param name="internFactory"></param> public void Copy(IMetadataCreateArray createArray, IInternFactory internFactory) { ((ICopyFrom <IMetadataExpression>) this).Copy(createArray, internFactory); this.elementType = createArray.ElementType; if (!IteratorHelper.EnumerableIsEmpty(createArray.Initializers)) { this.initializers = new List <IMetadataExpression>(createArray.Initializers); } if (!IteratorHelper.EnumerableIsEmpty(createArray.LowerBounds)) { this.lowerBounds = new List <int>(createArray.LowerBounds); } this.rank = createArray.Rank; if (!IteratorHelper.EnumerableIsEmpty(createArray.Sizes)) { this.sizes = new List <ulong>(createArray.Sizes); } }
/// <summary> /// /// </summary> /// <param name="unitNamespaceReference"></param> /// <param name="internFactory"></param> public virtual void Copy(IUnitNamespaceReference unitNamespaceReference, IInternFactory internFactory) { if (IteratorHelper.EnumerableIsNotEmpty(unitNamespaceReference.Attributes)) { this.attributes = new List <ICustomAttribute>(unitNamespaceReference.Attributes); } else { this.attributes = null; } if (IteratorHelper.EnumerableIsNotEmpty(unitNamespaceReference.Locations)) { this.locations = new List <ILocation>(unitNamespaceReference.Locations); } else { this.locations = null; } }
/// <summary> /// /// </summary> /// <param name="customAttribute"></param> /// <param name="internFactory"></param> public void Copy(ICustomAttribute customAttribute, IInternFactory internFactory) { if (IteratorHelper.EnumerableIsNotEmpty(customAttribute.Arguments)) { this.arguments = new List <IMetadataExpression>(customAttribute.Arguments); } else { this.arguments = null; } this.constructor = customAttribute.Constructor; if (customAttribute.NumberOfNamedArguments > 0) { this.namedArguments = new List <IMetadataNamedArgument>(customAttribute.NamedArguments); } else { this.namedArguments = null; } }
/// <summary> /// /// </summary> /// <param name="module"></param> /// <param name="internFactory"></param> public void Copy(IModule module, IInternFactory internFactory) { ((ICopyFrom <IUnit>) this).Copy(module, internFactory); this.strings = new List <string>(module.GetStrings()); this.allTypes = new List <INamedTypeDefinition>(module.GetAllTypes()); this.assemblyReferences = new List <IAssemblyReference>(module.AssemblyReferences); this.baseAddress = module.BaseAddress; this.containingAssembly = module.ContainingAssembly; this.dllCharacteristics = module.DllCharacteristics; if (module.Kind == ModuleKind.ConsoleApplication || module.Kind == ModuleKind.WindowsApplication) { this.entryPoint = module.EntryPoint; } else { this.entryPoint = Dummy.MethodReference; } this.fileAlignment = module.FileAlignment; this.ilOnly = module.ILOnly; this.kind = module.Kind; this.linkerMajorVersion = module.LinkerMajorVersion; this.linkerMinorVersion = module.LinkerMinorVersion; this.metadataFormatMajorVersion = module.MetadataFormatMajorVersion; this.metadataFormatMinorVersion = module.MetadataFormatMinorVersion; this.moduleAttributes = new List <ICustomAttribute>(module.ModuleAttributes); this.moduleReferences = new List <IModuleReference>(module.ModuleReferences); this.persistentIdentifier = Guid.NewGuid(); this.requiresAmdInstructionSet = module.RequiresAmdInstructionSet; this.requires32bits = module.Requires32bits; this.requires64bits = module.Requires64bits; this.sizeOfHeapCommit = module.SizeOfHeapCommit; this.sizeOfHeapReserve = module.SizeOfHeapReserve; this.sizeOfStackCommit = module.SizeOfStackCommit; this.sizeOfStackReserve = module.SizeOfStackReserve; this.strings = new List <string>(module.GetStrings()); this.targetRuntimeVersion = module.TargetRuntimeVersion; this.trackDebugData = module.TrackDebugData; this.usePublicKeyTokensForAssemblyReferences = module.UsePublicKeyTokensForAssemblyReferences; this.win32Resources = new List <IWin32Resource>(module.Win32Resources); }
/// <summary> /// /// </summary> /// <param name="unitNamespace"></param> /// <param name="internFactory"></param> public virtual void Copy(IUnitNamespace unitNamespace, IInternFactory internFactory) { if (IteratorHelper.EnumerableIsNotEmpty(unitNamespace.Attributes)) { this.attributes = new List <ICustomAttribute>(unitNamespace.Attributes); } else { this.attributes = null; } if (IteratorHelper.EnumerableIsNotEmpty(unitNamespace.Locations)) { this.locations = new List <ILocation>(unitNamespace.Locations); } else { this.locations = null; } this.members = new List <INamespaceMember>(unitNamespace.Members); this.name = unitNamespace.Name; this.unit = unitNamespace.Unit; }
public CachingInternFactory() { m_factory = new InternFactory(); m_objects = new Dictionary <uint, object>(); }
/// <summary> /// /// </summary> /// <param name="rootUnitNamespaceReference"></param> /// <param name="internFactory"></param> public void Copy(IRootUnitNamespaceReference rootUnitNamespaceReference, IInternFactory internFactory) { ((ICopyFrom <IUnitNamespaceReference>) this).Copy(rootUnitNamespaceReference, internFactory); this.unit = rootUnitNamespaceReference.Unit; }
/// <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 SourceEditHostEnvironment(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string> searchPaths, bool searchInGAC) : base(nameTable, factory, pointerSize, searchPaths, searchInGAC) //^ requires pointerSize == 0 || pointerSize == 4 || pointerSize == 8; { }
/// <summary> /// Makes a shallow copy of an expression that results in a System.Type instance. /// </summary> /// <param name="typeOf"></param> /// <param name="internFactory"></param> public void Copy(IMetadataTypeOf typeOf, IInternFactory internFactory) { ((ICopyFrom <IMetadataExpression>) this).Copy(typeOf, internFactory); this.typeToGet = typeOf.TypeToGet; }
/// <summary> /// /// </summary> /// <param name="unitNamespaceReference"></param> /// <param name="internFactory"></param> public virtual void Copy(IUnitNamespaceReference unitNamespaceReference, IInternFactory internFactory) { this.attributes = new List <ICustomAttribute>(unitNamespaceReference.Attributes); this.locations = new List <ILocation>(unitNamespaceReference.Locations); }
/// <summary> /// /// </summary> /// <param name="metadataExpression"></param> /// <param name="internFactory"></param> public void Copy(IMetadataExpression metadataExpression, IInternFactory internFactory) { this.locations = new List <ILocation>(metadataExpression.Locations); this.type = metadataExpression.Type; }
public HostEnvironment(IInternFactory internFactory) : this(new NameTable(), internFactory) { }
/// <summary> /// /// </summary> /// <param name="customAttribute"></param> /// <param name="internFactory"></param> public void Copy(ICustomAttribute customAttribute, IInternFactory internFactory) { this.arguments = new List <IMetadataExpression>(customAttribute.Arguments); this.constructor = customAttribute.Constructor; this.namedArguments = new List <IMetadataNamedArgument>(customAttribute.NamedArguments); }
/// <summary> /// /// </summary> /// <param name="marshallingInformation"></param> /// <param name="internFactory"></param> public void Copy(IMarshallingInformation marshallingInformation, IInternFactory internFactory) { if (marshallingInformation.UnmanagedType == UnmanagedType.CustomMarshaler) { this.customMarshaller = marshallingInformation.CustomMarshaller; } else { this.customMarshaller = Dummy.TypeReference; } if (marshallingInformation.UnmanagedType == UnmanagedType.CustomMarshaler) { this.customMarshallerRuntimeArgument = marshallingInformation.CustomMarshallerRuntimeArgument; } else { this.customMarshallerRuntimeArgument = ""; } if (marshallingInformation.UnmanagedType == UnmanagedType.LPArray) { this.elementSize = marshallingInformation.ElementSize; } else { this.elementSize = 0; } if (marshallingInformation.UnmanagedType == UnmanagedType.LPArray && marshallingInformation.ParamIndex != null) { this.elementSizeMultiplier = marshallingInformation.ElementSizeMultiplier; } else { this.elementSizeMultiplier = 0; } if (marshallingInformation.UnmanagedType == UnmanagedType.ByValArray || marshallingInformation.UnmanagedType == UnmanagedType.LPArray) { this.elementType = marshallingInformation.ElementType; } else { this.elementType = (UnmanagedType)0; } if (marshallingInformation.UnmanagedType == UnmanagedType.Interface) { this.iidParameterIndex = marshallingInformation.IidParameterIndex; } else { this.iidParameterIndex = 0; } if (marshallingInformation.UnmanagedType == UnmanagedType.ByValArray || marshallingInformation.UnmanagedType == UnmanagedType.ByValTStr || marshallingInformation.UnmanagedType == UnmanagedType.LPArray) { this.numberOfElements = marshallingInformation.NumberOfElements; } else { this.numberOfElements = 0; } if (marshallingInformation.UnmanagedType == UnmanagedType.LPArray) { this.paramIndex = marshallingInformation.ParamIndex; } else { this.paramIndex = 0; } if (marshallingInformation.UnmanagedType == UnmanagedType.SafeArray) { this.safeArrayElementSubType = marshallingInformation.SafeArrayElementSubtype; } else { this.safeArrayElementSubType = (VarEnum)0; } if (marshallingInformation.UnmanagedType == UnmanagedType.SafeArray && (marshallingInformation.SafeArrayElementSubtype == VarEnum.VT_DISPATCH || marshallingInformation.SafeArrayElementSubtype == VarEnum.VT_UNKNOWN || marshallingInformation.SafeArrayElementSubtype == VarEnum.VT_RECORD)) { this.safeArrayElementUserDefinedSubType = marshallingInformation.SafeArrayElementUserDefinedSubtype; } else { this.safeArrayElementUserDefinedSubType = Dummy.TypeReference; } this.unmanagedType = marshallingInformation.UnmanagedType; }
/// <summary> /// /// </summary> /// <param name="securityAttribute"></param> /// <param name="internFactory"></param> public void Copy(ISecurityAttribute securityAttribute, IInternFactory internFactory) { this.action = securityAttribute.Action; this.attributes = new List <ICustomAttribute>(securityAttribute.Attributes); }
public CachingInternFactory() { m_factory = new InternFactory(); m_objects = new Dictionary<uint, object>(); }
public void Cleanup() { m_factory = null; m_objects = null; }
/// <summary> /// A base class for an object provided by the application hosting the metadata reader. The object allows the host application /// to control how assembly references are unified, where files are found, how Windows Runtime types and methods are projected to CLR types and methods /// and so on. The object also controls the lifetime of things such as memory mapped files and blocks of unmanaged memory. Be sure to call Dispose on the object when /// it is no longer needed and the associated locks and/or memory must be released immediately. /// </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> /// <param name="projectToCLRTypes">True if the host should project references to certain Windows Runtime types and methods /// to corresponding CLR types and methods, in order to emulate the runtime behavior of the CLR.</param> protected WindowsRuntimeMetadataReaderHost(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string> searchPaths, bool searchInGAC, bool projectToCLRTypes) : base(nameTable, factory, pointerSize, searchPaths, searchInGAC) { Contract.Requires(pointerSize == 0 || pointerSize == 4 || pointerSize == 8); this.projectToCLRTypes = projectToCLRTypes; this.AllowMultiple = nameTable.GetNameFor("AllowMultiple"); this.AllowMultipleAttribute = nameTable.GetNameFor("AllowMultipleAttribute"); this.Animation = nameTable.GetNameFor("Animation"); this.Collections = nameTable.GetNameFor("Collections"); this.Controls = nameTable.GetNameFor("Controls"); this.Data = nameTable.GetNameFor("Data"); this.Foundation = nameTable.GetNameFor("Foundation"); this.HResult = nameTable.GetNameFor("HResult"); this.IBindableIterable = nameTable.GetNameFor("IBindableIterable"); this.IBindableVector = nameTable.GetNameFor("IBindableVector"); this.IClosable = nameTable.GetNameFor("IClosable"); this.IIterable = nameTable.GetNameFor("IIterable"); this.IKeyValuePair = nameTable.GetNameFor("IKeyValuePair"); this.IMap = nameTable.GetNameFor("IMap"); this.IMapView = nameTable.GetNameFor("IMapView"); this.INotifyCollectionChanged = nameTable.GetNameFor("INotifyCollectionChanged"); this.INotifyPropertyChanged = nameTable.GetNameFor("INotifyPropertyChanged"); this.Input = nameTable.GetNameFor("Input"); this.Interop = nameTable.GetNameFor("Interop"); this.IReference = nameTable.GetNameFor("IReference"); this.IVector = nameTable.GetNameFor("IVector"); this.IVectorView = nameTable.GetNameFor("IVectorView"); this.Media = nameTable.GetNameFor("Media"); this.Media3D = nameTable.GetNameFor("Media3D"); this.Metadata = nameTable.GetNameFor("Metadata"); this.NotifyCollectionChangedAction = nameTable.GetNameFor("NotifyCollectionChangedAction"); this.NotifyCollectionChangedEventArgs = nameTable.GetNameFor("NotifyCollectionChangedEventArgs"); this.NotifyCollectionChangedEventHandler = nameTable.GetNameFor("NotifyCollectionChangedEventHandler"); this.Primitives = nameTable.GetNameFor("Primitives"); this.PropertyChangedEventArgs = nameTable.GetNameFor("PropertyChangedEventArgs"); this.PropertyChangedEventHandler = nameTable.GetNameFor("PropertyChangedEventHandler"); this.TypeName = nameTable.GetNameFor("TypeName"); this.UI = nameTable.GetNameFor("UI"); this.Windows = nameTable.GetNameFor("Windows"); this.Xaml = nameTable.GetNameFor("Xaml"); }
//^ requires pointerSize == 0 || pointerSize == 4 || pointerSize == 8; /// <summary> /// Allocates an object that provides an abstraction over the application hosting compilers based on this framework. /// Remember to call the Dispose method when the resulting object is no longer needed. /// </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 MetadataReaderHost(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string> searchPaths, bool searchInGAC) : base(nameTable, factory, pointerSize, searchPaths, searchInGAC) { }
public VccFunctionPointerType(NameDeclaration name, ISignature signature, IInternFactory internFactory) : base(signature, internFactory) { this.name = name; }
/// <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; { }
/// <summary> /// /// </summary> /// <param name="operationExceptionInformation"></param> /// <param name="internFactory"></param> public void Copy(IOperationExceptionInformation operationExceptionInformation, IInternFactory internFactory) { this.exceptionType = operationExceptionInformation.ExceptionType; this.filterDecisionStartOffset = operationExceptionInformation.FilterDecisionStartOffset; this.handlerEndOffset = operationExceptionInformation.HandlerEndOffset; this.handlerKind = operationExceptionInformation.HandlerKind; this.handlerStartOffset = operationExceptionInformation.HandlerStartOffset; this.tryEndOffset = operationExceptionInformation.TryEndOffset; this.tryStartOffset = operationExceptionInformation.TryStartOffset; }
public HostEnvironment(INameTable nameTable, IInternFactory internFactory) : base(nameTable, internFactory, 0, null, false) { _reader = new PeReader(this); _unresolvedIdentities = new HashSet <UnresolvedReference <IUnit, AssemblyIdentity> >(); }
public VccFunctionPointerType(NameDeclaration name, CallingConvention callingConvention, bool returnValueIsByRef, ITypeReference type, IEnumerable<ICustomModifier> returnValueCustomModifiers, IEnumerable<IParameterTypeInformation> parameters, IEnumerable<IParameterTypeInformation> extraArgumentTypes, IInternFactory internFactory) : base(callingConvention, returnValueIsByRef, type, returnValueCustomModifiers, parameters, extraArgumentTypes, internFactory) { this.name = name; }
/// <summary> /// Allocates an object that provides an abstraction over the application hosting compilers based on this framework. /// Remember to call the Dispose method when the resulting object is no longer needed. /// </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 MetadataReaderHost(INameTable nameTable, IInternFactory factory, byte pointerSize, IEnumerable<string> searchPaths, bool searchInGAC) : base(nameTable, factory, pointerSize, searchPaths, searchInGAC) { Contract.Requires(pointerSize == 0 || pointerSize == 4 || pointerSize == 8); }
public static void SetupInternFactory(IInternFactory ifactory) { internFactory = ifactory; }
/// <summary> /// An expression that does not change its value at runtime and can be evaluated at compile time. /// </summary> /// <param name="metadataConstant">A template from which to construct a shallow copy.</param> /// <param name="internFactory">The intern factory to use for computing the interned identity (if applicable) of this mutable object.</param> public void Copy(IMetadataConstant metadataConstant, IInternFactory internFactory) { ((ICopyFrom <IMetadataExpression>) this).Copy(metadataConstant, internFactory); this.value = metadataConstant.Value; }
/// <summary> /// /// </summary> /// <param name="unitReference"></param> /// <param name="internFactory"></param> public void Copy(IUnitReference unitReference, IInternFactory internFactory) { this.attributes = new List <ICustomAttribute>(unitReference.Attributes); this.locations = new List <ILocation>(unitReference.Locations); this.name = unitReference.Name; }
internal SimpleHostEnvironment(INameTable nameTable, IInternFactory internFactory, bool preserveILLocations) : base(nameTable, internFactory, 0, null, false) { this.preserveILLocations = preserveILLocations; this.peReader = new PeReader(this); }
public VccFunctionPointerType(NameDeclaration name, CallingConvention callingConvention, bool returnValueIsByRef, ITypeReference type, IEnumerable <ICustomModifier> returnValueCustomModifiers, IEnumerable <IParameterTypeInformation> parameters, IEnumerable <IParameterTypeInformation> extraArgumentTypes, IInternFactory internFactory) : base(callingConvention, returnValueIsByRef, type, returnValueCustomModifiers, parameters, extraArgumentTypes, internFactory) { this.name = name; }
/// <summary> /// /// </summary> /// <param name="rootUnitNamespace"></param> /// <param name="internFactory"></param> public void Copy(IRootUnitNamespace rootUnitNamespace, IInternFactory internFactory) { ((ICopyFrom <IUnitNamespace>) this).Copy(rootUnitNamespace, internFactory); }
public static IArrayTypeReference MakeArrayType(this ITypeReference elementType, IInternFactory internFactory) { return(Vector45.GetVector(elementType, internFactory)); }
/// <summary> /// /// </summary> /// <param name="nestedUnitNamespace"></param> /// <param name="internFactory"></param> public void Copy(INestedUnitNamespace nestedUnitNamespace, IInternFactory internFactory) { ((ICopyFrom <IUnitNamespace>) this).Copy(nestedUnitNamespace, internFactory); this.containingUnitNamespace = nestedUnitNamespace.ContainingUnitNamespace; }
public void Cleanup() { m_factory = null; m_objects = null; }
public VccFunctionPointerType(NameDeclaration name, ISignature signature, IInternFactory internFactory) : base(signature, internFactory) { this.name = name; }
/*^ #pragma warning disable 2666, 2669, 2677, 2674 ^*/ internal PEFileToObjectModel( PeReader peReader, PEFileReader peFileReader, ModuleIdentity moduleIdentity, Assembly/*?*/ containingAssembly, byte pointerSize ) //^ requires peFileReader.IsAssembly ==> moduleIdentity.ContainingAssembly != null; //^ requires peFileReader.IsAssembly ==> containingAssembly == null; //^ requires !(moduleIdentity.Location != null && moduleIdentity.Location.Length != 0); { this.pointerSize = pointerSize; this.document = new MetadataObjectDocument(this); this.ModuleReader = peReader; this.PEFileReader = peFileReader; this.NameTable = peReader.metadataReaderHost.NameTable; this.InternFactory = peReader.metadataReaderHost.InternFactory; this.StringIndexToNameTable = new Hashtable<IName>(); this.StringIndexToUnmangledNameTable = new Hashtable<IName>(); this.typeCache = new TypeCache(this); uint moduleNameOffset = peFileReader.ModuleTable.GetName(1); IName moduleName = this.GetNameFromOffset(moduleNameOffset); AssemblyIdentity/*?*/ assemblyIdentity = moduleIdentity as AssemblyIdentity; if (peFileReader.IsAssembly) { //^ assert assemblyIdentity != null; AssemblyRow assemblyRow = peFileReader.AssemblyTable[1]; IName assemblyName = this.GetNameFromOffset(assemblyRow.Name); byte[] publicKeyArray = TypeCache.EmptyByteArray; if (assemblyRow.PublicKey != 0) { publicKeyArray = peFileReader.BlobStream[assemblyRow.PublicKey]; } uint internedModuleId = (uint)peReader.metadataReaderHost.InternFactory.GetAssemblyInternedKey(assemblyIdentity); Assembly assem = new Assembly(this, moduleName, peFileReader.COR20Header.COR20Flags, internedModuleId, assemblyIdentity, assemblyName, assemblyRow.Flags, publicKeyArray); this.ContainingAssembly = assem; this.Module = assem; } else { uint internedModuleId = (uint)peReader.metadataReaderHost.InternFactory.GetModuleInternedKey(moduleIdentity); this.ContainingAssembly = containingAssembly; this.Module = new Module(this, moduleName, peFileReader.COR20Header.COR20Flags, internedModuleId, moduleIdentity); } this.LoadAssemblyReferences(); this.LoadModuleReferences(); this.RootModuleNamespace = new RootNamespace(this); this.NamespaceINameHashtable = new Hashtable<Namespace>(); this.LoadNamespaces(); this.NamespaceReferenceINameHashtable = new DoubleHashtable<NamespaceReference>(); this.NamespaceTypeTokenTable = new DoubleHashtable(peFileReader.TypeDefTable.NumberOfRows + peFileReader.ExportedTypeTable.NumberOfRows); this.NestedTypeTokenTable = new DoubleHashtable(peFileReader.NestedClassTable.NumberOfRows + peFileReader.ExportedTypeTable.NumberOfRows); this.PreLoadTypeDefTableLookup(); this.ModuleTypeDefArray = new TypeBase/*?*/[peFileReader.TypeDefTable.NumberOfRows + 1]; this.ModuleTypeDefLoadState = new LoadState[peFileReader.TypeDefTable.NumberOfRows + 1]; this.RedirectedTypeDefArray = new INamedTypeReference/*?*/[peFileReader.TypeDefTable.NumberOfRows + 1]; this.ModuleTypeDefLoadState[0] = LoadState.Loaded; this.ExportedTypeArray = new ExportedTypeAliasBase/*?*/[peFileReader.ExportedTypeTable.NumberOfRows + 1]; this.ExportedTypeLoadState = new LoadState[peFileReader.ExportedTypeTable.NumberOfRows + 1]; this.ExportedTypeLoadState[0] = LoadState.Loaded; this.ModuleGenericParamArray = new GenericParameter[peFileReader.GenericParamTable.NumberOfRows + 1]; if (peFileReader.MethodSpecTable.NumberOfRows > 0) { this.ModuleMethodSpecHashtable = new DoubleHashtable<IGenericMethodInstanceReference>(peFileReader.MethodSpecTable.NumberOfRows + 1); } this.ModuleTypeRefReferenceArray = new INamedTypeReference[peFileReader.TypeRefTable.NumberOfRows + 1]; this.ModuleTypeRefReferenceLoadState = new LoadState[peFileReader.TypeRefTable.NumberOfRows + 1]; this.ModuleTypeRefReferenceLoadState[0] = LoadState.Loaded; if (peFileReader.TypeSpecTable.NumberOfRows > 0) { this.ModuleTypeSpecHashtable = new DoubleHashtable<TypeSpecReference>(peFileReader.TypeSpecTable.NumberOfRows + 1); } this.ModuleFieldArray = new FieldDefinition[peFileReader.FieldTable.NumberOfRows + 1]; this.ModuleMethodArray = new IMethodDefinition[peFileReader.MethodTable.NumberOfRows + 1]; this.ModuleEventArray = new EventDefinition[peFileReader.EventTable.NumberOfRows + 1]; this.ModulePropertyArray = new PropertyDefinition[peFileReader.PropertyTable.NumberOfRows + 1]; this.ModuleMemberReferenceArray = new MemberReference/*?*/[peFileReader.MemberRefTable.NumberOfRows + 1]; this.UnspecializedMemberReferenceArray = new MemberReference/*?*/[peFileReader.MemberRefTable.NumberOfRows + 1]; this.SpecializedFieldHashtable = new DoubleHashtable<ISpecializedFieldReference>(); this.SpecializedMethodHashtable = new DoubleHashtable<ISpecializedMethodReference>(); this.CustomAttributeArray = new ICustomAttribute/*?*/[peFileReader.CustomAttributeTable.NumberOfRows + 1]; this.DeclSecurityArray = new ISecurityAttribute/*?*/[peFileReader.DeclSecurityTable.NumberOfRows + 1]; this._Module_ = this.Create_Module_Type(); }