Пример #1
0
        AsmUnit ParseUnit()
        {
            Dictionary <string, AsmFile> files = new Dictionary <string, AsmFile>();

            AsmFile file = null;
            string  line = CurrentLine;

            while (true)
            {
                if (line.StartsWith(FileStartID))
                {
                    file = ParseFileStart(files, line);
                }
                else if (line.Contains(FunctionStartID) && (file != null))
                {
                    file.Functions.Add(ParseFunction());
                }

                if (IsEOF)
                {
                    break;
                }

                line = NextLine();
            }

            return(BuildUnit(files));
        }
Пример #2
0
        void OnCompilationSuccess(VCFile file)
        {
            OnCompilationEnd("Asm compilation successful.");

            VCProject project = file.project;

            string dir         = project.ActiveConfiguration.Evaluate(OutputAsmDir);
            string filename    = Path.ChangeExtension(file.Name, "asm");
            string solutionDir = Path.GetDirectoryName(m_dte.Solution.FullName);

            string path = Path.Combine(solutionDir, dir, filename);
            string text = File.ReadAllText(path);

            CLx64AsmParser parser  = new CLx64AsmParser();
            AsmUnit        asmUnit = parser.Parse(text);

            foreach (KeyValuePair <string, AsmFile> filePair in asmUnit.Files)
            {
                string  fileName = filePair.Key;
                AsmFile asmFile  = filePair.Value;

                if (m_asm.ContainsKey(fileName))
                {
                    UpdateFile(m_asm[fileName], asmFile);
                }
                else
                {
                    m_asm[fileName] = asmFile;
                }
            }

            m_view.OnDocumentChanged();
        }
Пример #3
0
        AsmFile ParseFileStart(Dictionary <string, AsmFile> files, string line)
        {
            string path = line.Substring(FileStartID.Length + 1).ToLower();

            if (!files.TryGetValue(path, out AsmFile builder))
            {
                builder = new AsmFile()
                {
                    Functions = new List <AsmFunction>()
                };
                files.Add(path, builder);
            }

            return(builder);
        }
Пример #4
0
        AsmUnit BuildUnit(Dictionary <string, AsmFile> files)
        {
            AsmUnit unit = new AsmUnit {
                Files = new Dictionary <string, AsmFile>()
            };

            foreach (KeyValuePair <string, AsmFile> file in files)
            {
                AsmFile builder = file.Value;
                builder.Functions.Sort();
                unit.Files[file.Key] = new AsmFile {
                    Path      = file.Key,
                    Functions = builder.Functions
                };
            }

            return(unit);
        }
Пример #5
0
 void UpdateFile(AsmFile current, AsmFile newFile)
 {
     current.Functions = newFile.Functions;
 }