forked from IronLanguages/dlr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicStackFrame.cs
More file actions
53 lines (44 loc) · 1.87 KB
/
DynamicStackFrame.cs
File metadata and controls
53 lines (44 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
#nullable enable
using System;
using System.Reflection;
namespace Microsoft.Scripting.Runtime {
/// <summary>
/// Helper for storing information about stack frames.
/// </summary>
[Serializable]
public class DynamicStackFrame {
private readonly string? _funcName;
private readonly string? _filename;
private readonly int _lineNo;
private readonly MethodBase? _method;
public DynamicStackFrame(MethodBase? method, string? funcName, string? filename, int line) {
_funcName = funcName;
_filename = filename;
_lineNo = line;
_method = method;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public MethodBase? GetMethod() {
return _method;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public string? GetMethodName() {
return _funcName;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public string? GetFileName() {
return _filename;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public int GetFileLineNumber() {
return _lineNo;
}
public override string ToString() {
return
$"{_funcName ?? "<function unknown>"} in {_filename ?? "<filename unknown>"}:{_lineNo}, {(_method is not null ? _method.ToString() : "<method unknown>")}";
}
}
}