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
use std::collections::BTreeSet;
use id_arena::Arena;
use crate::core;
#[allow(dead_code)]
pub struct Module {
target_triple: Option<core::target_triple::TargetTriple>,
target_datalayout: Option<core::target_datalayout::TargetDataLayout>,
function_arena: Arena<core::function::Function>,
functions: BTreeSet<core::function::FunctionId>,
}
impl Module {
pub fn new_function(
&mut self,
func_name: &str,
ret_type: core::function::ReturnType,
) -> core::function::FunctionId {
let func_id = self
.function_arena
.alloc(core::function::Function::new(func_name, ret_type));
assert!(self.functions.insert(func_id));
func_id
}
}
impl Default for Module {
fn default() -> Self {
Self {
target_triple: None,
target_datalayout: None,
function_arena: Arena::new(),
functions: BTreeSet::new(),
}
}
}