예제 #1
0
        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);
        }
예제 #2
0
 /// <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,
 };
예제 #3
0
파일: ProjectSaver.cs 프로젝트: heruix/reko
        /// <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);
        }
예제 #4
0
파일: ProjectLoader.cs 프로젝트: ntzwq/reko
 public Project VisitProject_v4(Project_v4 sProject) { return outer.LoadProject(filename, sProject); }
예제 #5
0
파일: ProjectSaver.cs 프로젝트: heruix/reko
        public void Save(Project_v4 sProject, XmlWriter xw)
        {
            var ser = SerializedLibrary.CreateSerializer_v4(typeof(Project_v4));

            ser.Serialize(xw, sProject);
        }
예제 #6
0
 /// <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)));
 }
예제 #7
0
 public Project VisitProject_v4(Project_v4 sProject) => outer.LoadProject(filename, sProject);
예제 #8
0
파일: ProjectSaver.cs 프로젝트: Godzil/reko
        public void Save(Project_v4 sProject, TextWriter sw)
        {
            var ser = SerializedLibrary.CreateSerializer_v4(typeof(Project_v4));

            ser.Serialize(sw, sProject);
        }