1use std::{
2 path::{Path, PathBuf},
3 sync::Arc,
4};
5
6#[derive(Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub enum Linkage {
8 #[default]
9 Private,
10 Internal,
11 AvailableExternally,
12 LinkOnce,
13 Weak,
14 Common,
15 Appending,
16 ExternWeak,
17 LinkOnceOdr,
18 WeakOdr,
19 External,
20}
21
22#[derive(Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
23pub enum CConv {
24 #[default]
25 Ccc,
26 FastCc,
27 ColdCc,
28 GhCcc,
29 Cc11,
30 Anyregcc,
31 PreserveMostCc,
32 PreserveAllCc,
33 PreserveNoneCc,
34 CxxFastTlsCc,
35 TailCc,
36 SwiftCc,
37 CfGuardCheckCc,
38}
39
40#[derive(Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
41pub enum Visibility {
42 #[default]
43 Default,
44 Hidden,
45 Protected,
46}
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
49pub enum DllStorageClass {
50 Import,
51 Export,
52}
53
54#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
55pub enum ThreadLocalStorageModel {
56 LocalDynamic,
57 InitialExec,
58 LocalExec,
59}
60
61#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
62pub enum RuntimePreemption {
63 DsoPreemptable,
64 DsoLocal,
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Default)]
68pub enum Location {
69 #[default]
70 Unknown,
71 File(FileLocation),
72}
73
74impl Location {
75 pub fn unknown() -> Self {
76 Self::Unknown
77 }
78
79 pub fn file(file: &Path, line: u32, col: u32) -> Self {
80 Self::File(FileLocation::new(file, line, col))
81 }
82
83 pub fn get_line(&self) -> Option<u32> {
84 match self {
85 Location::Unknown => None,
86 Location::File(file_location) => Some(file_location.line),
87 }
88 }
89}
90
91#[derive(Debug, Clone, PartialEq, Eq)]
92pub struct FileLocation {
93 pub file: Arc<PathBuf>,
94 pub line: u32,
95 pub col: u32,
96}
97
98impl FileLocation {
99 pub fn new(file: &Path, line: u32, col: u32) -> Self {
100 Self {
101 file: file.to_path_buf().into(),
102 line,
103 col,
104 }
105 }
106}