1use super::common::*;
2use super::function::{DwarfDirective, SectionDirective};
3use super::variable::ModuleVariableDirective;
4use crate::Spanned;
5use crate::parser::Span;
6use crate::r#type::{AliasFunctionDirective, EntryFunctionDirective, FuncFunctionDirective};
7
8#[derive(Debug, Clone, PartialEq, Spanned, Default)]
10pub struct Module {
11 pub directives: Vec<ModuleDirective>,
12 pub span: Span,
13}
14
15#[derive(Debug, Clone, PartialEq, Spanned)]
17pub enum ModuleDirective {
18 ModuleVariable {
19 linkage: Option<DataLinkage>,
20 directive: ModuleVariableDirective,
21 span: Span,
22 },
23 EntryFunction {
24 linkage: Option<CodeLinkage>,
25 directive: EntryFunctionDirective,
26 span: Span,
27 },
28 FuncFunction {
29 linkage: Option<CodeLinkage>,
30 directive: FuncFunctionDirective,
31 span: Span,
32 },
33 AliasFunction {
34 directive: AliasFunctionDirective,
35 span: Span,
36 },
37 ModuleInfo {
38 directive: ModuleInfoDirectiveKind,
39 span: Span,
40 },
41 Debug {
42 directive: ModuleDebugDirective,
43 span: Span,
44 },
45}
46
47#[derive(Debug, Clone, PartialEq, Spanned)]
49pub enum ModuleInfoDirectiveKind {
50 Version {
51 directive: VersionDirective,
52 span: Span,
53 },
54 Target {
55 directive: TargetDirective,
56 span: Span,
57 },
58 AddressSize {
59 directive: AddressSizeDirective,
60 span: Span,
61 },
62}
63
64#[derive(Debug, Clone, PartialEq, Spanned)]
74pub struct VersionDirective {
75 pub major: u32,
76 pub minor: u32,
77 pub span: Span,
78}
79
80#[derive(Debug, Clone, PartialEq, Spanned)]
110pub struct TargetDirective {
111 pub entries: Vec<TargetString>,
112 pub span: Span,
113}
114
115#[derive(Debug, Clone, PartialEq, Spanned)]
124pub struct AddressSizeDirective {
125 pub size: AddressSize,
126 pub span: Span,
127}
128
129#[derive(Debug, Clone, PartialEq, Spanned)]
131pub enum ModuleDebugDirective {
132 File {
133 directive: FileDirective,
134 span: Span,
135 },
136 Section {
137 directive: SectionDirective,
138 span: Span,
139 },
140 Dwarf {
141 directive: DwarfDirective,
142 span: Span,
143 },
144}
145
146#[derive(Debug, Clone, PartialEq, Spanned)]
156pub struct FileDirective {
157 pub index: u32,
158 pub path: String,
159 pub timestamp: Option<u64>,
160 pub file_size: Option<u64>,
161 pub span: Span,
162}
163
164#[derive(Debug, Clone, PartialEq, Spanned)]
166pub enum TargetString {
167 Sm120a { span: Span },
168 Sm120f { span: Span },
169 Sm120 { span: Span },
170 Sm121a { span: Span },
171 Sm121f { span: Span },
172 Sm121 { span: Span },
173 Sm110a { span: Span },
174 Sm110f { span: Span },
175 Sm110 { span: Span },
176 Sm100a { span: Span },
177 Sm100f { span: Span },
178 Sm100 { span: Span },
179 Sm101a { span: Span },
180 Sm101f { span: Span },
181 Sm101 { span: Span },
182 Sm103a { span: Span },
183 Sm103f { span: Span },
184 Sm103 { span: Span },
185 Sm90a { span: Span },
186 Sm90 { span: Span },
187 Sm80 { span: Span },
188 Sm86 { span: Span },
189 Sm87 { span: Span },
190 Sm88 { span: Span },
191 Sm89 { span: Span },
192 Sm70 { span: Span },
193 Sm72 { span: Span },
194 Sm75 { span: Span },
195 Sm60 { span: Span },
196 Sm61 { span: Span },
197 Sm62 { span: Span },
198 Sm50 { span: Span },
199 Sm52 { span: Span },
200 Sm53 { span: Span },
201 Sm30 { span: Span },
202 Sm32 { span: Span },
203 Sm35 { span: Span },
204 Sm37 { span: Span },
205 Sm20 { span: Span },
206 Sm10 { span: Span },
207 Sm11 { span: Span },
208 Sm12 { span: Span },
209 Sm13 { span: Span },
210 TexmodeUnified { span: Span },
211 TexmodeIndependent { span: Span },
212 Debug { span: Span },
213 MapF64ToF32 { span: Span },
214}
215
216#[derive(Debug, Clone, PartialEq, Spanned)]
218pub enum AddressSize {
219 Size32 { span: Span },
220 Size64 { span: Span },
221}