1#![doc = include_str!("readme.md")]
2
3pub struct ValkyrieRoot {
5 pub items: Vec<ValkyrieItem>,
6}
7
8#[derive(Clone, Debug)]
10pub enum ValkyrieItem {
11 Module(ValkyrieModule),
12 Function(ValkyrieFunction),
13 Memory(ValkyrieMemory),
14 Export(ValkyrieExport),
15 Import(ValkyrieImport),
16}
17
18#[derive(Clone, Debug)]
20pub struct ValkyrieModule {
21 pub name: Option<String>,
22 pub items: Vec<ValkyrieItem>,
23}
24
25#[derive(Clone, Debug)]
27pub struct ValkyrieFunction {
28 pub name: Option<String>,
29 pub params: Vec<ValkyrieParam>,
30 pub result: Option<ValkyrieType>,
31 pub locals: Vec<ValkyrieLocal>,
32 pub body: Vec<ValkyrieInstruction>,
33}
34
35#[derive(Clone, Debug)]
37pub struct ValkyrieParam {
38 pub name: Option<String>,
39 pub param_type: ValkyrieType,
40}
41
42#[derive(Clone, Debug)]
44pub struct ValkyrieLocal {
45 pub name: Option<String>,
46 pub local_type: ValkyrieType,
47}
48
49#[derive(Clone, Debug)]
51pub enum ValkyrieType {
52 I32,
53 I64,
54 F32,
55 F64,
56}
57
58#[derive(Clone, Debug)]
60pub struct ValkyrieMemory {
61 pub name: Option<String>,
62 pub min: u32,
63 pub max: Option<u32>,
64}
65
66#[derive(Clone, Debug)]
68pub struct ValkyrieExport {
69 pub name: String,
70 pub kind: ValkyrieExportKind,
71}
72
73#[derive(Clone, Debug)]
75pub enum ValkyrieExportKind {
76 Function(String),
77 Memory(String),
78 Global(String),
79 Table(String),
80}
81
82#[derive(Clone, Debug)]
84pub struct ValkyrieImport {
85 pub module: String,
86 pub name: String,
87 pub kind: ValkyrieImportKind,
88}
89
90#[derive(Clone, Debug)]
92pub enum ValkyrieImportKind {
93 Function(ValkyrieFunctionType),
94 Memory(ValkyrieMemoryType),
95 Global(ValkyrieGlobalType),
96 Table(ValkyrieTableType),
97}
98
99#[derive(Clone, Debug)]
101pub struct ValkyrieFunctionType {
102 pub params: Vec<ValkyrieType>,
103 pub results: Vec<ValkyrieType>,
104}
105
106#[derive(Clone, Debug)]
108pub struct ValkyrieMemoryType {
109 pub min: u32,
110 pub max: Option<u32>,
111}
112
113#[derive(Clone, Debug)]
115pub struct ValkyrieGlobalType {
116 pub value_type: ValkyrieType,
117 pub mutable: bool,
118}
119
120#[derive(Clone, Debug)]
122pub struct ValkyrieTableType {
123 pub element_type: ValkyrieType,
124 pub min: u32,
125 pub max: Option<u32>,
126}
127
128#[derive(Clone, Debug)]
130pub enum ValkyrieInstruction {
131 Simple(String),
133 WithOperand { opcode: String, operand: String },
135 Control { opcode: String, label: Option<String> },
137 Call { function: String },
139}