summaryrefslogtreecommitdiff
path: root/BCT/BytecodeTranslator/Program.cs
diff options
context:
space:
mode:
authorGravatar mikebarnett <unknown>2010-04-16 20:42:55 +0000
committerGravatar mikebarnett <unknown>2010-04-16 20:42:55 +0000
commite0476d2bed64bc99d4d068d882dafbc72599c2e0 (patch)
tree77a855ad451e0133587588dccc1c510ca0aa96ed /BCT/BytecodeTranslator/Program.cs
parent642a3e23fd847a5a173e389748ead7c2cc6a7115 (diff)
Updated to use new CCI API.
Diffstat (limited to 'BCT/BytecodeTranslator/Program.cs')
-rw-r--r--BCT/BytecodeTranslator/Program.cs58
1 files changed, 3 insertions, 55 deletions
diff --git a/BCT/BytecodeTranslator/Program.cs b/BCT/BytecodeTranslator/Program.cs
index 2e58b07f..3c2a1fa0 100644
--- a/BCT/BytecodeTranslator/Program.cs
+++ b/BCT/BytecodeTranslator/Program.cs
@@ -37,7 +37,7 @@ namespace BytecodeTranslator {
static int DoRealWork(string assemblyName) {
- var host = new PeReader.DefaultHost();
+ var host = new Microsoft.Cci.ILToCodeModel.CodeContractAwareHostEnvironment();
IModule/*?*/ module = host.LoadUnitFrom(assemblyName) as IModule;
if (module == null || module == Dummy.Module || module == Dummy.Assembly) {
@@ -45,39 +45,6 @@ namespace BytecodeTranslator {
return 1;
}
- #region Load any reference assemblies
- var fileSpec = module.Location;
- string directory;
- if (Path.IsPathRooted(fileSpec))
- directory = Path.GetDirectoryName(fileSpec);
- else
- directory = Directory.GetCurrentDirectory();
- string[] files;
- Dictionary<string, List<IAssembly>>/*?*/ referenceAssemblies = new Dictionary<string, List<IAssembly>>();
- #region Look for reference assembly dlls
- // TODO: Search a user-specified set of paths/directories, not just the one the input came from.
- files = Directory.GetFiles(directory, "*.Contracts*.dll", SearchOption.TopDirectoryOnly);
- if (files != null) {
- foreach (var file in files) {
- IAssembly/*?*/ refAssem = host.LoadUnitFrom(file) as IAssembly;
- if (refAssem == null || refAssem == Dummy.Assembly) {
- Console.WriteLine("Could not load '" + file + "' as a reference assembly.");
- continue;
- }
- var fileName = Path.GetFileNameWithoutExtension(file);
- var baseName = BCT.NameUpToFirstPeriod(fileName);
- if (referenceAssemblies.ContainsKey(baseName)) {
- referenceAssemblies[baseName].Add(refAssem);
- } else {
- List<IAssembly> a = new List<IAssembly>();
- a.Add(refAssem);
- referenceAssemblies.Add(baseName, a);
- }
- }
- }
- #endregion Look for reference assembly dlls
- #endregion Load any reference assemblies
-
IAssembly/*?*/ assembly = null;
PdbReader/*?*/ pdbReader = null;
@@ -87,30 +54,11 @@ namespace BytecodeTranslator {
pdbReader = new PdbReader(pdbStream, host);
}
- ContractProvider contractProvider = new ContractProvider(new ContractMethods(host), module);
- module = Decompiler.GetCodeAndContractModelFromMetadataModel(host, module, pdbReader, contractProvider);
-
- //SourceToILConverterProvider sourceToILProvider =
- // delegate(IMetadataHost host2, ISourceLocationProvider/*?*/ sourceLocationProvider, IContractProvider/*?*/ contractProvider2)
- // {
- // return new CodeModelToILConverter(host2, sourceLocationProvider, contractProvider2);
- // };
-
-
- List<IAssembly> oobUnits;
- List<KeyValuePair<IContractProvider, IMetadataHost>> oobProvidersAndHosts = new List<KeyValuePair<IContractProvider, IMetadataHost>>();
- if (referenceAssemblies.TryGetValue(module.Name.Value, out oobUnits)) {
- foreach (var oob in oobUnits) {
- LazyContractProvider ocp = new LazyContractProvider(host, oob, contractProvider.ContractMethods);
- oobProvidersAndHosts.Add(new KeyValuePair<IContractProvider, IMetadataHost>(ocp, host));
- }
- }
-
- AggregatingContractProvider acp = new AggregatingContractProvider(host, contractProvider, oobProvidersAndHosts);
+ module = Decompiler.GetCodeAndContractModelFromMetadataModel(host, module, pdbReader);
#region Pass 3: Translate the code model to BPL
//tmp_BPLGenerator translator = new tmp_BPLGenerator(host, acp);
- ToplevelTraverser translator = new ToplevelTraverser(acp);
+ ToplevelTraverser translator = new ToplevelTraverser(host.GetContractExtractor(module.ModuleIdentity));
assembly = module as IAssembly;
if (assembly != null)
translator.Visit(assembly);