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