public static void Process(string pInputPath) { sModule = Decompiler.GetCodeModelFromMetadataModel(Host, Host.LoadUnitFrom(pInputPath) as IModule, null); sPlatformType = Module.PlatformType; sRuntimeAssembly = (IAssembly)PlatformType.SystemRuntimeTypeHandle.ContainingUnitNamespace.Unit.ResolvedUnit; EnlistRuntimeTypes(); EnlistRuntimeMethods(); sEntryMethod = GetOrCreateMethod(Module.EntryPoint); int checkedTypes = 0; while (sTypes.Count != checkedTypes || sPendingMethods.Count > 0) { // STARTED: Process IStatements/IExpressions into HLInstructionBlocks/HLInstructions while (sPendingMethods.Count > 0) { sPendingMethods.Dequeue().Process(); } // STARTED: Build virtual map for each type and include any missing override methods // starting at the top the chain (Object) and working down to the given type, then process // pending methods and repeat until no methods or types are added, as each new method may // add new types and methods checkedTypes = sTypes.Count; foreach (HLType type in sTypes.Values.ToList()) { type.MapVirtualMethods(); } } // NOTE: After this point, do not GetOrCreate types and methods // DONE: Build virtual table and virtual index lookup from the complete virtual maps foreach (HLType type in sTypes.Values) { type.BuildVirtualTable(); } // DONE: Determine HLType Calculated and Variable sizes // DONE: Layout Non-Static HLField offsets foreach (HLType type in sTypes.Values) { type.LayoutFields(); } // NOTE: After this point, conversion to LL begins // DONE: Convert HLTypes to LLTypes BuildGCAllocate(); BuildGCRoot(); BuildVTableHandleLookup(); BuildVTableFunctionLookup(); BuildDelegateLookup(); BuildDelegateInstance(); BuildGlobals(); foreach (HLMethod method in sMethods.Values.ToList()) { method.BuildFunction(); } HLStringTable stringTable = new HLStringTable(); // STARTED: Build constant global runtime type handles BuildRuntimeTypeHandles(); // STARTED: Build constant global runtime type data BuildRuntimeTypeData(stringTable); // STARTED: Build constant global runtime method data BuildRuntimeMethodData(stringTable); // STARTED: Build constant global runtime data string table BuildRuntimeDataStringTable(stringTable); // STARTED: Convert HLInstructions to LLInstructions foreach (HLMethod method in sMethods.Values) { method.Transform(); } using (StreamWriter writer = new StreamWriter(Path.ChangeExtension(pInputPath, ".ll"))) { LLModule.Dump(writer); } }