bool ReadChildAssemblies(GlobalContainer Global) { var RetValue = true; var Count = ReadLEB128_Int(); ChildAssemblies = new Assembly[Count]; for (var i = 0; i < Count; i++) { var Name = ReadLEB128_String(); var Random = Reader.ReadInt32(); ReadLEB128_Int(); var Assembly = Global.GetLoadedAssembly(Name); if (Assembly == null) { var Path = new AssemblyPath(Name, true); Assembly = Global.LoadAssembly(Path); } if (Assembly == null || Random != Assembly.Random) { RetValue = false; continue; } ChildAssemblies[i] = Assembly; } return(RetValue); }
public Assembly LoadAssembly(AssemblyPath AssemblyPath) { string ZinniaLib; if (AssemblyPath.BuiltIn) { var Name = AssemblyPath.Name; var Dir = ZinniaBuilder.GetDirectory(ZinniaDirectory.Libraries); if (Dir == null || !Directory.Exists(Dir = Path.Combine(Dir, Name))) { State.Messages.Add(MessageId.AssemblyNotFound, new CodeString(Name)); return(null); } ZinniaLib = Path.Combine(Dir, Name + ".zlib"); if (!File.Exists(ZinniaLib)) { State.Messages.Add(MessageId.FileDoesntExists, new CodeString(ZinniaLib)); return(null); } var Arc = Path.Combine(Dir, Name + ".a"); if (!File.Exists(Arc)) { State.Messages.Add(MessageId.FileDoesntExists, new CodeString(Arc)); return(null); } if (State.Builder != null) { State.Builder.Archives.Add(Arc); } var Additional = Path.Combine(Dir, Name + ".link.txt"); if (File.Exists(Additional)) { var RetValue = true; foreach (var Line in File.ReadAllLines(Additional)) { var NewLine = State.Builder.GetFilePath(Line, Dir); if (!File.Exists(NewLine)) { State.Messages.Add(MessageId.FileDoesntExists, new CodeString(Line)); RetValue = false; } var Ext = Path.GetExtension(NewLine); if (Ext == ".o" || Ext == ".obj") { State.Builder.ObjectFiles.Add(NewLine); } else if (Ext == ".a") { State.Builder.Archives.Add(NewLine); } else { State.Messages.Add(MessageId.CantLoadFile, new CodeString(NewLine)); return(null); } } if (!RetValue) { return(null); } } } else { ZinniaLib = AssemblyPath.Name; } #if !DEBUG try { #endif var Stream = File.OpenRead(ZinniaLib); var ADL = new AssemblyDescLoader(); var Ret = ADL.LoadAssemblyDesc(this, Stream); if (Ret == null) { State.Messages.Add(MessageId.CantLoadFile, new CodeString(ZinniaLib)); } return(Ret); #if !DEBUG } catch (Exception) { State.Messages.Add(MessageId.CantLoadFile, new CodeString(ZinniaLib)); return(null); } #endif }