/// <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()); }
/// <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); }
/// <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()); }
/// <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)); } }
/// <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)); } }
/// <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)); } }
/// <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; }
/// <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>()); }
/// <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 <localName>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()); }
/// <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>()); }
public IEnumerable <ITypeDefinitionMember> GetMatchingMembersNamed(IName name, bool ignoreCase, Function <ITypeDefinitionMember, bool> predicate) { return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>()); }
/// <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>()); }
/// <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>()); }
public IEnumerable <INamedTypeDefinition> GetAllTypes() { return(IteratorHelper.GetEmptyEnumerable <INamedTypeDefinition>()); }
public IEnumerable <ITypeDefinitionMember> GetMatchingMembers(Function <ITypeDefinitionMember, bool> predicate) { return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>()); }
/// <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 <localName>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>()); }
public IEnumerable <ITypeDefinitionMember> GetMembersNamed(IName name, bool ignoreCase) { return(IteratorHelper.GetEmptyEnumerable <ITypeDefinitionMember>()); }
public IEnumerable <string> GetStrings() { return(IteratorHelper.GetEmptyEnumerable <string>()); }