void InitializeScopes(CodeFile[] CodeFiles) { if (string.IsNullOrEmpty(AssemblyName)) { throw new InvalidOperationException("Assembly hasn't been set up"); } if (CodeOut == null || LibOut == null) { throw new InvalidOperationException("Output streams haven't been set up"); } var Random = new Random(); var Assembly = new Assembly(this, AssemblyName); Assembly.Random = Random.Next(); GlobalContainer = new GlobalContainer(this); GlobalContainer.OutputAssembly = Assembly; for (var i = 0; i < CodeFiles.Length; i++) { var AssemblyScope = new AssemblyScope(GlobalContainer, Assembly, CodeFiles[i]); GlobalContainer.GlobalNamespace.AddScope(AssemblyScope); GlobalContainer.Children.Add(AssemblyScope); } GlobalContainer.GlobalNamespaceScope = new AssemblyScope(GlobalContainer, Assembly); GlobalContainer.GlobalNamespace.AddScope(GlobalContainer.GlobalNamespaceScope); GlobalContainer.Children.Add(GlobalContainer.GlobalNamespaceScope); }
public Assembly LoadAssemblyDesc(GlobalContainer Global, Stream Stream) { this.Global = Global; this.State = Global.State; Reader = new BinaryReader(Stream); BeginningPos = Stream.Position; var IdListPtr = Reader.ReadInt64() + BeginningPos; var Name = ReadLEB128_String(); var DescName = ReadLEB128_String(); var Index = Global.LoadedAssemblies.Count; CurrentAssembly = new Assembly(State, Name, DescName, Index); CurrentAssembly.Random = Reader.ReadInt32(); Global.LoadedAssemblies.Add(CurrentAssembly); ReadLEB128_Int(); var Scope = new AssemblyScope(Global, CurrentAssembly); Global.GlobalNamespace.AddScope(Scope); Global.Children.Add(Scope); if (!ReadChildAssemblies(Global)) { return(null); } var ContentPos = Stream.Position; Stream.Seek(IdListPtr, SeekOrigin.Begin); ReadIdRefs(); Stream.Seek(ContentPos, SeekOrigin.Begin); ReadIdList(Scope, Global.GlobalNamespace); Dereference(); UpdateIds(); return(CurrentAssembly); }