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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! This crate exists because of limitations with `proc-macro` crates. We need
//! to be able to test errors returned from the code generation function while
//! also being able to test the macros themselves. This might also be reused by
//! people who have new storage types.
//!
//! This is also available as a hidden reexport from the main `awint` crate if
//! the "std" feature is enabled

#![allow(clippy::needless_range_loop)]
#![allow(clippy::comparison_chain)]
#![cfg_attr(feature = "const_support", feature(const_trait_impl))]

mod cc_macro;
mod component;
mod concatenation;
mod errors;
mod lower_structs;
mod lowering;
mod misc;
mod names;
mod ranges;
mod token_stream;
mod token_tree;

pub use awint_ext::{self, awint_core};
pub use cc_macro::*;
pub use component::*;
pub use concatenation::*;
pub use errors::*;
pub use lower_structs::*;
pub use lowering::*;
pub use misc::*;
pub use names::*;
pub use ranges::*;
pub use token_stream::*;
pub use token_tree::*;
pub use triple_arena;
#[cfg(feature = "debug")]
pub use triple_arena_render;

pub fn awint_macro_cc(input: &str) -> Result<String, String> {
    let code_gen = CodeGen {
        static_width: false,
        return_type: None,
        must_use: awint_must_use,
        static_construction_fn: awint_static_construction_fn,
        lit_construction_fn: awint_unreachable_construction_fn,
        construction_fn: cc_construction_fn,
        const_wrapper: identity_const_wrapper,
        fn_names: AWINT_FN_NAMES,
    };
    cc_macro(input, code_gen, AWINT_NAMES)
}

pub fn awint_macro_inlawi(input: &str) -> Result<String, String> {
    let code_gen = CodeGen {
        static_width: true,
        return_type: Some("InlAwi"),
        must_use: awint_must_use,
        static_construction_fn: awint_static_construction_fn,
        lit_construction_fn: awint_inlawi_lit_construction_fn,
        construction_fn: inlawi_construction_fn,
        const_wrapper: identity_const_wrapper,
        fn_names: AWINT_FN_NAMES,
    };
    cc_macro(input, code_gen, AWINT_NAMES)
}

pub fn awint_macro_extawi(input: &str) -> Result<String, String> {
    let code_gen = CodeGen {
        static_width: false,
        return_type: Some("ExtAwi"),
        must_use: awint_must_use,
        static_construction_fn: awint_static_construction_fn,
        lit_construction_fn: awint_extawi_lit_construction_fn,
        construction_fn: extawi_construction_fn,
        const_wrapper: identity_const_wrapper,
        fn_names: AWINT_FN_NAMES,
    };
    cc_macro(input, code_gen, AWINT_NAMES)
}

pub fn awint_macro_awi(input: &str) -> Result<String, String> {
    let code_gen = CodeGen {
        static_width: false,
        return_type: Some("Awi"),
        must_use: awint_must_use,
        static_construction_fn: awint_static_construction_fn,
        lit_construction_fn: awint_awi_lit_construction_fn,
        construction_fn: awi_construction_fn,
        const_wrapper: identity_const_wrapper,
        fn_names: AWINT_FN_NAMES,
    };
    cc_macro(input, code_gen, AWINT_NAMES)
}

pub fn awint_macro_bits(input: &str) -> Result<String, String> {
    let code_gen = CodeGen {
        static_width: true,
        return_type: Some("&'static Bits"),
        must_use: awint_must_use,
        static_construction_fn: awint_static_construction_fn,
        lit_construction_fn: awint_bits_lit_construction_fn,
        construction_fn: inlawi_construction_fn,
        const_wrapper: awint_bits_const_wrapper,
        fn_names: AWINT_FN_NAMES,
    };
    cc_macro(input, code_gen, AWINT_NAMES)
}