public Int32[] Calculate(String source) { SyntaxTree tree = CSharpSyntaxTree.ParseText(source); RoslynCompilationChecker.CheckErrors(tree); MethodDeclarationSyntax method = tree.GetRoot().DescendantNodes().OfType <MethodDeclarationSyntax>().First(decl => decl.Identifier.Text == "Evaluate"); VariableStateCalculatorWalker walker = new VariableStateCalculatorWalker(); walker.Visit(method.Body); return(walker.FrameStack.Peek().States.Select(state => state.AssignmentValue).OrderBy(value => value).ToArray()); }
public Int32[] Calculate(String source) { SyntaxTree tree = CSharpSyntaxTree.ParseText(source); RoslynCompilationChecker.CheckErrors(tree); MethodDeclarationSyntax method = tree.GetRoot().DescendantNodes().OfType <MethodDeclarationSyntax>().First(decl => decl.Identifier.Text == "Evaluate"); Stack <ExecutionFrame> frameStack = new Stack <ExecutionFrame>(); frameStack.Push(new ExecutionFrame()); ProcessBlock(method.Body, frameStack); return(frameStack.Peek().States.Select(state => state.AssignmentValue).OrderBy(value => value).ToArray()); }