summaryrefslogtreecommitdiff
path: root/BCT
diff options
context:
space:
mode:
authorGravatar mikebarnett <unknown>2009-11-17 19:38:01 +0000
committerGravatar mikebarnett <unknown>2009-11-17 19:38:01 +0000
commitd64c97865ea76d67e0c9a0590a9a3b26bba10c9e (patch)
treebcb0e962ac921263b5312ddfc2681e140f54497f /BCT
parent0035ce0a95f5a481704d84374f58af92408b7e3a (diff)
Update use of CCI's API for decompiling the IL model to the Code Model.
Diffstat (limited to 'BCT')
-rw-r--r--BCT/BCT.sln12
-rw-r--r--BCT/BytecodeTranslator/Program.cs46
2 files changed, 13 insertions, 45 deletions
diff --git a/BCT/BCT.sln b/BCT/BCT.sln
index 1d957640..fd82e94f 100644
--- a/BCT/BCT.sln
+++ b/BCT/BCT.sln
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeModel", "..\..\CCICodeP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MutableCodeModel", "..\..\CCICodePlex\Ast\Sources\MutableCodeModel\MutableCodeModel.csproj", "{319E150C-8F33-49E7-81CA-30F02F9BA90A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeModelToIL", "..\..\CCICodePlex\Ast\Sources\CodeModelToIL\CodeModelToIL.csproj", "{CEB76EA1-A168-49B0-A410-2C4195FEE86F}"
+EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 9
@@ -180,6 +182,16 @@ Global
{319E150C-8F33-49E7-81CA-30F02F9BA90A}.NightlyRelease|Any CPU.Build.0 = NightlyRelease|Any CPU
{319E150C-8F33-49E7-81CA-30F02F9BA90A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{319E150C-8F33-49E7-81CA-30F02F9BA90A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.CompilerOnly|Any CPU.ActiveCfg = CompilerOnly|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.CompilerOnly|Any CPU.Build.0 = CompilerOnly|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.NightlyDebug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.NightlyDebug|Any CPU.Build.0 = Debug|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.NightlyRelease|Any CPU.ActiveCfg = Release|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.NightlyRelease|Any CPU.Build.0 = Release|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CEB76EA1-A168-49B0-A410-2C4195FEE86F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/BCT/BytecodeTranslator/Program.cs b/BCT/BytecodeTranslator/Program.cs
index cd9f11f2..2e58b07f 100644
--- a/BCT/BytecodeTranslator/Program.cs
+++ b/BCT/BytecodeTranslator/Program.cs
@@ -88,7 +88,7 @@ namespace BytecodeTranslator {
}
ContractProvider contractProvider = new ContractProvider(new ContractMethods(host), module);
- module = ConvertMetadataModelToCodeModel(host, module, pdbReader, contractProvider);
+ module = Decompiler.GetCodeAndContractModelFromMetadataModel(host, module, pdbReader, contractProvider);
//SourceToILConverterProvider sourceToILProvider =
// delegate(IMetadataHost host2, ISourceLocationProvider/*?*/ sourceLocationProvider, IContractProvider/*?*/ contractProvider2)
@@ -132,50 +132,6 @@ namespace BytecodeTranslator {
return name.Substring(0, i);
}
- /// <summary>
- /// Takes a module which is presumably a metadata model (either immutable or mutable) and returns
- /// the "same" module which is now a code model module.
- ///
- /// Currently there is no way to lazily convert a module from the metadata model to the code model.
- /// Therefore, this method works eagerly by visiting the entire <paramref name="module"/>.
- /// </summary>
- /// <param name="host">
- /// The host that was used to load the module.
- /// </param>
- /// <param name="module">
- /// The module which is to be converted.
- /// </param>
- /// <param name="pdbReader">
- /// A PDB reader that is used by ILToCodeModel during the conversion.
- /// </param>
- /// <param name="contractProvider">
- /// A contract provider that is used by ILToCodeModel during the conversion. As part of the conversion, the
- /// contract provider will become populated with any contracts found during decompilation.
- /// </param>
- /// <returns>
- /// A module that is at the code model level.
- /// </returns>
- public static IModule ConvertMetadataModelToCodeModel(IMetadataHost host, IModule module, PdbReader/*?*/ pdbReader, ContractProvider contractProvider) {
-
- SourceMethodBodyProvider ilToSourceProvider =
- delegate(IMethodBody methodBody) {
- return new Microsoft.Cci.ILToCodeModel.SourceMethodBody(methodBody, host, contractProvider, pdbReader);
- };
-
- IAssembly/*?*/ assembly;
-
- #region Just run the code and contract mutator which extracts all contracts to their containing methods
- CodeAndContractMutator ccm = new CodeAndContractMutator(host, true, ilToSourceProvider, null, pdbReader, contractProvider);
-
- assembly = module as IAssembly;
- if (assembly != null)
- module = ccm.Visit(ccm.GetMutableCopy(assembly));
- else
- module = ccm.Visit(ccm.GetMutableCopy(module));
- #endregion Just run the code and contract mutator which extracts all contracts to their containing methods
-
- return module;
- }
}