PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Runtime/Microsoft.Scripting/Runtime/DynamicStackFrame.cs

#
C# | 67 lines | 42 code | 8 blank | 17 comment | 1 complexity | d3be9c204196407c7dd193d61c11e383 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Reflection;
  17. namespace Microsoft.Scripting.Runtime {
  18. /// <summary>
  19. /// Helper for storing information about stack frames.
  20. /// </summary>
  21. [Serializable]
  22. public class DynamicStackFrame {
  23. private string _funcName;
  24. private string _filename;
  25. private int _lineNo;
  26. private MethodBase _method;
  27. public DynamicStackFrame(MethodBase method, string funcName, string filename, int line) {
  28. _funcName = funcName;
  29. _filename = filename;
  30. _lineNo = line;
  31. _method = method;
  32. }
  33. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  34. public MethodBase GetMethod() {
  35. return _method;
  36. }
  37. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  38. public string GetMethodName() {
  39. return _funcName;
  40. }
  41. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  42. public string GetFileName() {
  43. return _filename;
  44. }
  45. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  46. public int GetFileLineNumber() {
  47. return _lineNo;
  48. }
  49. public override string ToString() {
  50. return string.Format(
  51. "{0} in {1}:{2}, {3}",
  52. _funcName ?? "<function unknown>",
  53. _filename ?? "<filename unknown>",
  54. _lineNo,
  55. (_method != null ? _method.ToString() : "<method unknown>")
  56. );
  57. }
  58. }
  59. }