Exemple #1
0
        public void AcceptSection(WasmSection section)
        {
            var reader = new WasmReader(section.Payload);

            switch (section.Code)
            {
            case WasmSectionCode.Type:
                TypeSections.Add(reader.ReadTypeSection());
                break;

            case WasmSectionCode.Import:
                ImportSections.Add(reader.ReadImportSection());
                break;

            case WasmSectionCode.Function:
                FunctionSections.Add(reader.ReadFunctionSection());
                break;

            case WasmSectionCode.Table:
                TableSections.Add(reader.ReadTableSection());
                break;

            case WasmSectionCode.Memory:
                MemorySections.Add(reader.ReadMemorySection());
                break;

            case WasmSectionCode.Global:
                GlobalSections.Add(reader.ReadGlobalSection());
                break;

            case WasmSectionCode.Export:
                ExportSections.Add(reader.ReadExportSection());
                break;

            case WasmSectionCode.Start:
                StartSections.Add(reader.ReadStartSection());
                break;

            case WasmSectionCode.Element:
                ElementSections.Add(reader.ReadElementSection());
                break;

            case WasmSectionCode.Code:
                CodeSections.Add(reader.ReadCodeSection());
                break;

            case WasmSectionCode.Data:
                DataSections.Add(reader.ReadDataSection());
                break;

            default:
                CustomSections.Add(section);
                break;
            }
        }
Exemple #2
0
 private SolutionSection GetGlobalSection(string name, string type, bool createIfNotExist)
 {
     SolutionSection section;
     if ((section = GlobalSections.FirstOrDefault(x => x.Name == name && x.Type == type)) == null && createIfNotExist)
     {
         section = new SolutionSection()
         {
             Name = name,
             Type = type,
             SectionType = "Global",
         };
         GlobalSections.Add(section);
     }
     return section;
 }
Exemple #3
0
        void Parse(string slnFile)
        {
            this.Name = System.IO.Path.GetFileName(slnFile);
            this.Path = slnFile;
            bool    isParsingProject = false;
            bool    isParsingGlobal  = false;
            var     lines            = File.ReadAllLines(slnFile);
            Project currentProject   = null;

            GlobalSection currentGlobalSection = null;

            foreach (var line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                if (IsComment(line))
                {
                    continue;
                }

                if (isParsingGlobal)
                {
                    if (line.TrimStart().StartsWith("GlobalSection"))
                    {
                        currentGlobalSection = GlobalSection.Parse(line);
                    }
                    else if (line.TrimStart().StartsWith("EndGlobalSection"))
                    {
                        GlobalSections.Add(currentGlobalSection.SectionType, currentGlobalSection);
                        currentGlobalSection = null;
                    }
                    else if (line == "EndGlobal")
                    {
                        isParsingGlobal = false;
                    }
                    else
                    {
                        currentGlobalSection.AddSubLine(line);
                    }
                }
                else if (isParsingProject)
                {
                    if (line.StartsWith("EndProject"))
                    {
                        isParsingProject = false;
                        this.Projects.Add(currentProject);
                    }
                    else
                    {
                        currentProject.AddSubItem(line);
                    }
                }
                else
                {
                    if (line.StartsWith("VisualStudioVersion = "))
                    {
                        this.VisualStudioVersion = Version.Parse(line.Substring("VisualStudioVersion = ".Length));
                    }
                    if (line.StartsWith("MinimumVisualStudioVersion ="))
                    {
                        this.MinimumVisualStudioVersion = Version.Parse(line.Substring("MinimumVisualStudioVersion =".Length));
                    }

                    if (line.StartsWith("Project("))
                    {
                        isParsingProject = true;
                        currentProject   = Project.Parse(line, Name);
                    }

                    if (line.Trim() == "Global")
                    {
                        isParsingGlobal = true;
                    }
                }
            }


            foreach (var p in Projects)
            {
                ProjectsById[p.ProjectGuid] = p;
            }

            if (GlobalSections.TryGetValue("NestedProjects", out var section))
            {
                foreach (var subItem in section.SubItems)
                {
                    var guids  = subItem.Split("=");
                    var child  = Guid.Parse(guids[0].Trim());
                    var parent = Guid.Parse(guids[1].Trim());
                    ProjectsById[child].ParentGuid = parent;
                    ProjectsById[parent].ChildProjectGuids.Add(child);
                }
            }
            else
            {
                GlobalSections.Add("NestProjects", new GlobalSection {
                    Location = "preSolution", SectionType = "NestedProjects"
                });
            }

            this.SolutionGuid = GetSolutionGuid();
        }