示例#1
0
        public static CallGraph ProcessCallGraph(string text)
        {
            var processor = new CallGraphProcessor();

            using var reader = new StringReader(text);
            string?line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.Length == 0)
                {
                    continue;
                }

                processor.ProcessLine(line);
            }

            return(processor.CallGraph);
        }
示例#2
0
        public static SampleFile Parse(Stream stream)
        {
            using var streamReader = new StreamReader(stream);

            Processor processor = new NullProcessor();
            string    line;

            // TODO: PERF: Maybe use Read into an array instead of strings.
            while ((line = streamReader.ReadLine()) != null)
            {
                // If the line has no leading whitespace, it's a header
                if (line.Length == 0)
                {
                    continue;
                }

                if (line[0] != ' ')
                {
                    switch (line)
                    {
                    case Headers.CallGraph:
                        processor = new CallGraphProcessor();
                        break;

                    case Headers.TotalNumbersInStack:
                        // TODO: Implement this
                        processor = new NullProcessor();
                        break;
                    }

                    continue;
                }

                // We have a line starting with 4 whitespace chars, it's part of the processor's job to parse it.
                processor.ProcessLine(line.AsSpan(4));
            }

            return(new SampleFile());
        }