public Project LoadProject(string filename, Project_v4 sp) { var cfgSvc = Services.RequireService <IConfigurationService>(); this.arch = cfgSvc.GetArchitecture(sp.ArchitectureName !); if (arch == null) { throw new ApplicationException( string.Format("Unknown architecture '{0}' in project file.", sp.ArchitectureName ?? "(null)")); } var env = cfgSvc.GetEnvironment(sp.PlatformName !); if (env == null) { throw new ApplicationException( string.Format("Unknown operating environment '{0}' in project file.", sp.PlatformName ?? "(null)")); } this.platform = env.Load(Services, arch); this.project.LoadedMetadata = this.platform.CreateMetadata(); var typelibs = sp.Inputs.OfType <MetadataFile_v3>().Select(m => VisitMetadataFile(filename, m)); var programs = sp.Inputs.OfType <DecompilerInput_v4>().Select(s => VisitInputFile(filename, s)); sp.Inputs.OfType <AssemblerFile_v3>().Select(s => VisitAssemblerFile(s)); project.MetadataFiles.AddRange(typelibs); project.Programs.AddRange(programs); return(this.project); }
/// <summary> /// Migrate Project_v4 to Project_v5. /// </summary> public static Project_v5 MigrateProject(Project_v4 v4) => new Project_v5() { ArchitectureName = v4.ArchitectureName, PlatformName = v4.PlatformName, InputFiles = v4.InputFiles.Select(i => MigrateDecompilerInput(i)).ToList(), MetadataFiles = v4.MetadataFiles, AssemblerFiles = v4.AssemblerFiles, };
/// <summary> /// Given a <see cref="Project"/> serializes it into a <see cref="Project_v4"/>. /// </summary> /// <param name="projectAbsPath"></param> /// <param name="project"></param> /// <returns></returns> public Project_v4 Serialize(string projectAbsPath, Project project) { var inputs = new List <ProjectFile_v3>(); inputs.AddRange(project.Programs.Select(p => VisitProgram(projectAbsPath, p))); inputs.AddRange(project.MetadataFiles.Select(m => VisitMetadataFile(projectAbsPath, m))); var sp = new Project_v4 { // ".Single()" because there can be only one Architecture and Platform, realistically. ArchitectureName = project.Programs.Select(p => p.Architecture.Name).Distinct().SingleOrDefault(), PlatformName = project.Programs.Select(p => p.Platform.Name).Distinct().SingleOrDefault(), Inputs = inputs }; return(sp); }
public Project VisitProject_v4(Project_v4 sProject) { return outer.LoadProject(filename, sProject); }
public void Save(Project_v4 sProject, XmlWriter xw) { var ser = SerializedLibrary.CreateSerializer_v4(typeof(Project_v4)); ser.Serialize(xw, sProject); }
/// <summary> /// Loads a Project object from its serialized representation. First loads the /// common architecture and platform then metadata, and finally any programs. /// </summary> /// <param name="sp"></param> /// <returns></returns> public Project LoadProject(string filename, Project_v4 sp) { return(LoadProject(filename, ProjectVersionMigrator.MigrateProject(sp))); }
public Project VisitProject_v4(Project_v4 sProject) => outer.LoadProject(filename, sProject);
public void Save(Project_v4 sProject, TextWriter sw) { var ser = SerializedLibrary.CreateSerializer_v4(typeof(Project_v4)); ser.Serialize(sw, sProject); }