diff --git a/source/Cosmos.sln b/source/Cosmos.sln index d75d804ff..10a1e3586 100644 --- a/source/Cosmos.sln +++ b/source/Cosmos.sln @@ -92,7 +92,7 @@ Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Docs", "..\Docs", "{67E7DEF Release.AspNetCompiler.ForceOverwrite = "true" Release.AspNetCompiler.FixedNames = "false" Release.AspNetCompiler.Debug = "False" - VWDPort = "6345" + VWDPort = "26549" EndProjectSection EndProject Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Playground.Kudzu.Breakpoints", "..\source2\Users\Kudzu\Breakpoints\Playground.Kudzu.Breakpoints.Cosmos", "{3EEE2ABA-87B3-4DD7-B6C5-BEF23D411136}" diff --git a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs index 0e6b81286..6de830567 100644 --- a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs +++ b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs @@ -207,6 +207,12 @@ namespace Cosmos.Build.MSBuild { // These are the references of our boot project. We dont actually ever load the boot // project asm. Instead the references will contain plugs, and the kernel. We load // them then find the entry point in the kernel. + // + // Plugs and refs in this list will be loaded absolute (or as proj refs) only. Asm resolution + // will not be tried on them, but will on ASMs they reference. + // + // TODO - Update to use Load for Reflection only, but note that this wont load references + // and we have to do it manually (Probably better for us anyways) Type xKernelType = null; foreach (var xRef in References) { diff --git a/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs b/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs index 45f0ed1cd..363887056 100644 --- a/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs +++ b/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs @@ -206,6 +206,11 @@ namespace Cosmos.Debug.Common { BulkInsert("Methods", mMethods, 2500, aFlush); } + public void AddAssemblies(IList aAssemblies) { + // GUIDs by caller on AssemblyFiles, see caller to see why. + BulkInsert("AssemblyFiles", aAssemblies, 0, true); + } + public void WriteSymbols(IList aSymbols, bool aFlush = false) { foreach (var x in aSymbols) { x.ID = Guid.NewGuid(); diff --git a/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs b/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs index d6029443e..f57287919 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/AppAssembler.cs @@ -16,6 +16,10 @@ namespace Cosmos.IL2CPU { public DebugInfo DebugInfo { get; set; } protected System.IO.TextWriter mLog; + // Quick look up of assemblies so we dont have to go to the database and compare + // by fullname. + public Dictionary Assemblies = new Dictionary(); + protected Cosmos.Assembler.Assembler mAssembler; protected AppAssembler(Cosmos.Assembler.Assembler assembler) { mAssembler = assembler; diff --git a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs index 59c77f2c6..f39d00d91 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/ILScanner.cs @@ -57,6 +57,11 @@ namespace Cosmos.IL2CPU { protected ILReader mReader; protected AppAssembler mAsmblr; + // List of asssemblies found during scan. We cannot use the list of loaded + // assemblies because the loaded list includes compilers, etc, and also possibly + // other unused assemblies. So instead we collect a list of assemblies as we scan. + protected List mUsedAssemblies = new List(); + protected OurHashSet mItems = new OurHashSet(); protected List mItemsList = new List(); // Contains items to be scanned, both types and methods @@ -295,12 +300,20 @@ namespace Cosmos.IL2CPU { // scanner and assembler as needed. // // -SQL Inserts are slow when done individually. - // -Assemblies can only be uniquely identified by their names. + // -Assemblies can only be uniquely identified by their names or instance. ie there is no Token for example. // -Assembly table must be written before dependent items like Method // can be written. - // Because of this, we scan in a loop all at once instead of noticing - // assemblies as we use them. - //mAsmblr.DebugInfo + var xAssemblies = new List(); + foreach (var xAsm in mUsedAssemblies) { + var xRow = new Cosmos.Debug.Common.AssemblyFile() { + ID = Guid.NewGuid(), + Pathname = xAsm.Location + }; + xAssemblies.Add(xRow); + + mAsmblr.Assemblies.Add(xAsm, xRow.ID); + } + mAsmblr.DebugInfo.AddAssemblies(xAssemblies); // Time to assemble foreach (var xItem in mItems) { @@ -816,7 +829,14 @@ namespace Cosmos.IL2CPU { if (xItem.Item is MethodBase) { ScanMethod((MethodBase)xItem.Item, false, xItem.SourceItem); } else if (xItem.Item is Type) { - ScanType((Type)xItem.Item); + var xType = (Type)xItem.Item; + ScanType(xType); + + // Methods and fields cant exist without types, so we only update + // mUsedAssemblies in type branch. + if (!mUsedAssemblies.Contains(xType.Assembly)) { + mUsedAssemblies.Add(xType.Assembly); + } } else if (xItem.Item is FieldInfo) { // todo: static fields need more processing? } else { @@ -843,14 +863,6 @@ namespace Cosmos.IL2CPU { xList.Add(xLogItem); } - /// - /// - /// - /// - /// - /// The target method to be plugged - /// - /// protected MethodBase ResolvePlug(Type aTargetType, List aImpls, MethodBase aMethod, Type[] aParamTypes) { //TODO: This method is "reversed" from old - remember that when porting MethodBase xResult = null;