Пример #1
0
        /// <summary>
        /// Returns zero or more namespace scopes into which the namespace type containing the given method body has been nested.
        /// These scopes determine how simple names are looked up inside the method body. There is a separate scope for each dotted
        /// component in the namespace type name. For istance namespace type x.y.z will have two namespace scopes, the first is for the x and the second
        /// is for the y.
        /// </summary>
        public virtual IEnumerable <INamespaceScope> GetNamespaceScopes(IMethodBody methodBody)
        {
            var ilGeneratorMethodBody = methodBody as ILGeneratorMethodBody;

            if (ilGeneratorMethodBody == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <INamespaceScope>());
            }
            return(ilGeneratorMethodBody.GetNamespaceScopes());
        }
Пример #2
0
        /// <summary>
        /// Returns zero or more local variable definitions that are local to the given scope.
        /// </summary>
        public virtual IEnumerable <ILocalDefinition> GetVariablesInScope(ILocalScope scope)
        {
            var ilGeneratorScope = scope as ILGeneratorScope;

            if (ilGeneratorScope == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <ILocalDefinition>());
            }
            return(ilGeneratorScope.Locals);
        }
Пример #3
0
        /// <summary>
        /// Returns zero or more lexical scopes into which the CLR IL operations in the given method body is organized.
        /// </summary>
        public IEnumerable <ILocalScope> GetLocalScopes(IMethodBody methodBody)
        {
            PdbFunction /*?*/ pdbFunction = this.GetPdbFunctionFor(methodBody);

            if (pdbFunction == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <ILocalScope>());
            }
            List <ILocalScope> scopes = new List <ILocalScope>();

            this.FillInScopesAndSubScopes(methodBody, pdbFunction.scopes, scopes);
            return(scopes.AsReadOnly());
        }
Пример #4
0
        /// <summary>
        /// Return zero or more locations in primary source documents that correspond to the definition of the given local.
        /// </summary>
        public IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition)
        {
            ISourceLocationProvider /*?*/ provider = this.GetProvider(localDefinition);

            if (provider == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <IPrimarySourceLocation>());
            }
            else
            {
                return(provider.GetPrimarySourceLocationsForDefinitionOf(localDefinition));
            }
        }
Пример #5
0
        /// <summary>
        /// Returns zero or more local variable definitions that are local to the given scope.
        /// </summary>
        public IEnumerable <ILocalDefinition> GetVariablesInScope(ILocalScope scope)
        {
            ILocalScopeProvider /*?*/ provider = this.GetProvider(scope.MethodDefinition);

            if (provider == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <ILocalDefinition>());
            }
            else
            {
                return(provider.GetVariablesInScope(scope));
            }
        }
Пример #6
0
        /// <summary>
        /// Returns zero or more namespace scopes into which the namespace type containing the given method body has been nested.
        /// These scopes determine how simple names are looked up inside the method body. There is a separate scope for each dotted
        /// component in the namespace type name. For istance namespace type x.y.z will have two namespace scopes, the first is for the x and the second
        /// is for the y.
        /// </summary>
        public IEnumerable <INamespaceScope> GetNamespaceScopes(IMethodBody methodBody)
        {
            ILocalScopeProvider /*?*/ provider = this.GetProvider(methodBody.MethodDefinition);

            if (provider == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <INamespaceScope>());
            }
            else
            {
                return(provider.GetNamespaceScopes(methodBody));
            }
        }
Пример #7
0
        /// <summary>
        /// Allocates an object that is the metadata (IL) level represetation of the body of a method or of a property/event accessor.
        /// </summary>
        /// <param name="generator">An object that provides a way to construct the information needed by a method body. Construction should
        /// be completed by the time the generator is passed to this constructor. The generator is not referenced by the resulting method body.</param>
        /// <param name="localsAreZeroed">True if the locals are initialized by zeroeing the stack upon method entry.</param>
        /// <param name="maxStack">The maximum number of elements on the evaluation stack during the execution of the method.</param>
        public ILGeneratorMethodBody(ILGenerator generator, bool localsAreZeroed, ushort maxStack)
        {
            this.localsAreZeroed = localsAreZeroed;
            this.operationExceptionInformation = generator.GetOperationExceptionInformation();
            this.operations         = generator.GetOperations();
            this.privateHelperTypes = IteratorHelper.GetEmptyEnumerable <ITypeDefinition>();
            this.generatorScopes    = generator.GetLocalScopes();
            List <ILocalDefinition> locals = new List <ILocalDefinition>();

            foreach (var localScope in this.generatorScopes)
            {
                locals.AddRange(localScope.Locals);
            }
            this.localVariables = locals.AsReadOnly();
            this.maxStack       = maxStack;
        }
Пример #8
0
        /// <summary>
        /// Returns zero or more namespace scopes into which the namespace type containing the given method body has been nested.
        /// These scopes determine how simple names are looked up inside the method body. There is a separate scope for each dotted
        /// component in the namespace type name. For istance namespace type x.y.z will have two namespace scopes, the first is for the x and the second
        /// is for the y.
        /// </summary>
        public IEnumerable <INamespaceScope> GetNamespaceScopes(IMethodBody methodBody)
        {
            PdbFunction /*?*/ pdbFunction = this.GetPdbFunctionFor(methodBody);

            if (pdbFunction != null && pdbFunction.usingCounts != null)
            {
                if (pdbFunction.namespaceScopes != null)
                {
                    return(pdbFunction.namespaceScopes);
                }
                foreach (PdbScope pdbScope in pdbFunction.scopes)
                {
                    return(pdbFunction.namespaceScopes = this.GetNamespaceScopes(pdbFunction.usingCounts, pdbScope).AsReadOnly());
                }
            }
            return(IteratorHelper.GetEmptyEnumerable <INamespaceScope>());
        }
Пример #9
0
        /// <summary>
        /// Returns zero or more local (block) scopes, each defining an IL range in which an iterator local is defined.
        /// The scopes are returned by the MoveNext method of the object returned by the iterator method.
        /// The index of the scope corresponds to the index of the local. Specifically local scope i corresponds
        /// to the local stored in field &lt;localName&gt;x_i of the class used to store the local values in between
        /// calls to MoveNext.
        /// </summary>
        public IEnumerable <ILocalScope> GetIteratorScopes(IMethodBody methodBody)
        {
            PdbFunction /*?*/ pdbFunction = this.GetPdbFunctionFor(methodBody);

            if (pdbFunction == null || pdbFunction.iteratorScopes == null)
            {
                return(IteratorHelper.GetEmptyEnumerable <ILocalScope>());
            }
            foreach (var i in pdbFunction.iteratorScopes)
            {
                PdbIteratorScope pis = i as PdbIteratorScope;
                if (pis != null)
                {
                    pis.MethodDefinition = methodBody.MethodDefinition;
                }
            }
            return(pdbFunction.iteratorScopes.AsReadOnly());
        }
Пример #10
0
        /// <summary>
        /// Return zero or more locations in primary source documents that correspond to the definition of the given local.
        /// </summary>
        public IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition)
        {
            PdbFunction /*?*/ pdbFunction = this.GetPdbFunctionFor(localDefinition);

            if (pdbFunction != null)
            {
                uint index = 0;
                foreach (ILocation location in localDefinition.Locations)
                {
                    MethodBodyLocation /*?*/ mbLocation = location as MethodBodyLocation;
                    if (mbLocation != null)
                    {
                        index = mbLocation.Offset;
                        break;
                    }
                }
                PdbSlot /*?*/ slot = this.GetSlotFor(pdbFunction.scopes, index);
                if (slot != null && (slot.flags & 0x4) == 0)
                {
                    return(IteratorHelper.GetSingletonEnumerable <IPrimarySourceLocation>(new LocalNameSourceLocation(slot.name)));
                }
            }
            return(IteratorHelper.GetEmptyEnumerable <IPrimarySourceLocation>());
        }
Пример #11
0
 public IEnumerable <ITypeDefinitionMember> GetMatchingMembersNamed(IName name, bool ignoreCase, Function <ITypeDefinitionMember, bool> predicate)
 {
     return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>());
 }
Пример #12
0
 /// <summary>
 /// Return zero or more locations in primary source documents that correspond to the definition of the given local.
 /// </summary>
 public virtual IEnumerable <IPrimarySourceLocation> GetPrimarySourceLocationsForDefinitionOf(ILocalDefinition localDefinition)
 {
     return(IteratorHelper.GetEmptyEnumerable <IPrimarySourceLocation>());
 }
Пример #13
0
 /// <summary>
 /// Returns zero or more local constant definitions that are local to the given scope.
 /// </summary>
 public virtual IEnumerable <ILocalDefinition> GetConstantsInScope(ILocalScope scope)
 {
     return(IteratorHelper.GetEmptyEnumerable <ILocalDefinition>());
 }
Пример #14
0
 public IEnumerable <INamedTypeDefinition> GetAllTypes()
 {
     return(IteratorHelper.GetEmptyEnumerable <INamedTypeDefinition>());
 }
Пример #15
0
 public IEnumerable <ITypeDefinitionMember> GetMatchingMembers(Function <ITypeDefinitionMember, bool> predicate)
 {
     return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>());
 }
Пример #16
0
 /// <summary>
 /// Returns zero or more local (block) scopes, each defining an IL range in which an iterator local is defined.
 /// The scopes are returned by the MoveNext method of the object returned by the iterator method.
 /// The index of the scope corresponds to the index of the local. Specifically local scope i corresponds
 /// to the local stored in field &lt;localName&gt;x_i of the class used to store the local values in between
 /// calls to MoveNext.
 /// </summary>
 public virtual IEnumerable <ILocalScope> GetIteratorScopes(IMethodBody methodBody)
 {
     return(IteratorHelper.GetEmptyEnumerable <ILocalScope>());
 }
Пример #17
0
 public IEnumerable <ITypeDefinitionMember> GetMembersNamed(IName name, bool ignoreCase)
 {
     return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>());
 }
Пример #18
0
 public IEnumerable <string> GetStrings()
 {
     return(IteratorHelper.GetEmptyEnumerable <string>());
 }