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 crate::arenas::{Alloc, AllocOwned};
use crate::ty2::access::*;
use crate::ty2::enums::*;
use crate::ty2::floats::*;
use crate::ty2::ints::*;
use crate::ty2::physical::*;
use crate::ty2::prelude::*;
use crate::ty2::types::NullType;
make_arenas!(
pub struct TypeArena<'t> {
integer_basetype: IntegerBasetype,
integer_subtype: IntegerSubtype<'t>,
floating_basetype: FloatingBasetype,
floating_subtype: FloatingSubtype<'t>,
enum_basetype: EnumBasetype,
enum_subtype: EnumSubtype<'t>,
physical_basetype: PhysicalBasetype,
physical_subtype: PhysicalSubtype<'t>,
access: AccessType<'t>,
}
);
impl<'t> AllocOwned<'t, 't, Type> for TypeArena<'t> {
fn alloc_owned(&'t self, value: OwnedType<'t>) -> &'t Type {
match value {
OwnedType::IntegerBasetype(t) => self.alloc(t),
OwnedType::IntegerSubtype(t) => self.alloc(t),
OwnedType::FloatingBasetype(t) => self.alloc(t),
OwnedType::FloatingSubtype(t) => self.alloc(t),
OwnedType::EnumBasetype(t) => self.alloc(t),
OwnedType::EnumSubtype(t) => self.alloc(t),
OwnedType::PhysicalBasetype(t) => self.alloc(t),
OwnedType::PhysicalSubtype(t) => self.alloc(t),
OwnedType::Access(t) => self.alloc(t),
OwnedType::Null => &NullType,
OwnedType::UniversalInteger => &UniversalIntegerType,
OwnedType::UniversalReal => &UniversalRealType,
}
}
}