C# Class Microsoft.Cci.ILToCodeModel.ClosureFieldMapper

The purpose of this traverser is to discover the mapping between fields in a closure state class and the original locals and parameters that were captured into the closure state class, so that we can substitute field accesses with local and parameter accesses during decompilation of anonymous delegates. Things are complicated by having to deal with a variety of compilers that potentially use different name mangling schemes and moreover we might not have a PDB file available and so might not know the name of a local or parameter. The bottom line is that we cannot rely on naming conventions. Generally, we rely on the source operand of the first assignment to a state field as providing the local or parameter that is being captured. However, if an anonymous delegate uses a local that is not used outside of it (or other anonymous delegates) then a compiler (such as, alas, the C# compiler) might provide a state field for the local while not actually defining a real local of inserting an assignment to capture the value of the local in the state class before constructing a closure. We therefore recurse into anonymous delegate bodies to find assignments to state fields, assume those are captured locals, and then dummy up locals for use in the decompiled method.
Inheritance: CodeTraverser
显示文件 Open project: visualmutator/visualmutator Class Usage Examples

Public Methods

Method Description
TraverseChildren ( IAddressableExpression addressableExpression ) : void
TraverseChildren ( IAssignment assignment ) : void

Private Methods

Method Description
ClosureFieldMapper ( IMetadataHost host, IMethodDefinition method, Hashtable closures, Hashtable closureFieldToLocalOrParameterMap ) : System.Diagnostics.Contracts
ObjectInvariant ( ) : void

Method Details

TraverseChildren() public method

public TraverseChildren ( IAddressableExpression addressableExpression ) : void
addressableExpression IAddressableExpression
return void

TraverseChildren() public method

public TraverseChildren ( IAssignment assignment ) : void
assignment IAssignment
return void