PageRenderTime 58ms CodeModel.GetById 49ms app.highlight 5ms RepoModel.GetById 2ms 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
 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
16using System;
17using System.Reflection;
18
19namespace Microsoft.Scripting.Runtime {
20    /// <summary>
21    /// Helper for storing information about stack frames.
22    /// </summary>
23    [Serializable]
24    public class DynamicStackFrame {
25        private string _funcName;
26        private string _filename;
27        private int _lineNo;
28        private MethodBase _method;
29
30        public DynamicStackFrame(MethodBase method, string funcName, string filename, int line) {
31            _funcName = funcName;
32            _filename = filename;
33            _lineNo = line;
34            _method = method;
35        }
36
37        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
38        public MethodBase GetMethod() {
39            return _method;
40        }
41
42        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
43        public string GetMethodName() {
44            return _funcName;
45        }
46
47        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
48        public string GetFileName() {
49            return _filename;
50        }
51
52        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
53        public int GetFileLineNumber() {
54            return _lineNo;
55        }
56
57        public override string ToString() {
58            return string.Format(
59                "{0} in {1}:{2}, {3}",
60                _funcName ?? "<function unknown>",
61                _filename ?? "<filename unknown>",
62                _lineNo,
63                (_method != null ? _method.ToString() : "<method unknown>")
64            );
65        }
66    }
67}