it_lilo/lowerer/
mod.rs

1/*
2 * Copyright 2021 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17mod error;
18mod lower_array;
19mod lower_record;
20mod memory_writer;
21
22use crate::lowerer::memory_writer::MemoryWriter;
23use crate::traits::Allocatable;
24
25pub use error::LoError;
26pub use lower_array::array_lower_memory;
27pub use lower_array::LoweredArray;
28pub use lower_record::record_lower_memory;
29
30pub use it_memory_traits::MemoryView;
31
32pub type LoResult<T> = std::result::Result<T, error::LoError>;
33
34pub struct ILowerer<
35    'm,
36    A: Allocatable<MV, Store>,
37    MV: MemoryView<Store>,
38    Store: it_memory_traits::Store,
39> {
40    pub writer: MemoryWriter<'m, A, MV, Store>,
41}
42
43impl<'m, A: Allocatable<MV, Store>, MV: MemoryView<Store>, Store: it_memory_traits::Store>
44    ILowerer<'m, A, MV, Store>
45{
46    pub fn new(view: MV, allocatable: &'m mut A) -> LoResult<Self> {
47        let writer = MemoryWriter::new(view, allocatable)?;
48        let lowerer = Self { writer };
49
50        Ok(lowerer)
51    }
52}