// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System.Collections.Generic; using Debugger; using Debugger.MetaData; using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.CSharp; namespace ILSpy.Debugger.Models.TreeModel { public class StackFrameNode: TreeNode { StackFrame stackFrame; public StackFrame StackFrame { get { return stackFrame; } } public StackFrameNode(StackFrame stackFrame) { this.stackFrame = stackFrame; this.Name = stackFrame.MethodInfo.Name; this.ChildNodes = LazyGetChildNodes(); } IEnumerable LazyGetChildNodes() { foreach(DebugParameterInfo par in stackFrame.MethodInfo.GetParameters()) { string imageName; var image = ExpressionNode.GetImageForParameter(out imageName); var expression = new ExpressionNode(image, par.Name, par.GetExpression()); expression.ImageName = imageName; yield return expression; } foreach(DebugLocalVariableInfo locVar in stackFrame.MethodInfo.GetLocalVariables(this.StackFrame.IP)) { string imageName; var image = ExpressionNode.GetImageForLocalVariable(out imageName); var expression = new ExpressionNode(image, locVar.Name, locVar.GetExpression()); expression.ImageName = imageName; yield return expression; } if (stackFrame.Thread.CurrentException != null) { yield return new ExpressionNode(null, "__exception", new IdentifierExpression("__exception")); } } } }