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
110
#![doc(html_root_url = "https://docs.rs/gluon_base/0.9.4")] #![allow(unknown_lints)]
#[macro_use]
extern crate collect_mac;
extern crate itertools;
#[macro_use]
extern crate log;
extern crate pretty;
#[macro_use]
extern crate quick_error;
extern crate either;
extern crate smallvec;
extern crate stable_deref_trait;
extern crate codespan;
extern crate codespan_reporting;
extern crate ordered_float;
#[cfg(feature = "serde_derive")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "serde_derive_state")]
#[macro_use]
extern crate serde_derive_state;
#[cfg(feature = "serde")]
extern crate serde_state as serde;
macro_rules! type_cache {
($name: ident ($($args: ident),*) ($($arg: ident : $arg_type: ty),*) { $typ: ty, $inner_type: ident } $( $id: ident )+) => {
#[derive(Debug, Clone)]
pub struct $name<$($args),*> {
$(pub $arg : $arg_type,)*
$(pub $id : $typ,)+
_marker: ::std::marker::PhantomData<( $($args),* )>,
}
impl<$($args),*> Default for $name<$($args),*>
where $typ: From<$inner_type<$($args,)*>> + Clone,
{
fn default() -> Self {
$name::new()
}
}
impl<$($args),*> $name<$($args),*>
where $typ: From<$inner_type<$($args,)*>> + Clone,
{
pub fn new() -> Self {
$name {
$($arg: <$arg_type>::default(),)*
$(
$id : $inner_type::$id(),
)+
_marker: ::std::marker::PhantomData,
}
}
$(
pub fn $id(&self) -> $typ {
self.$id.clone()
}
)+
}
}
}
macro_rules! chain {
($alloc: expr; $first: expr, $($rest: expr),+) => {{
let mut doc = ::pretty::DocBuilder($alloc, $first.into());
$(
doc = doc.append($rest);
)*
doc
}}
}
#[macro_use]
pub mod macros;
pub mod ast;
pub mod error;
pub mod fixed;
pub mod fnv;
pub mod kind;
pub mod merge;
pub mod metadata;
pub mod pos;
pub mod resolve;
pub mod scoped_map;
#[cfg(feature = "serde")]
pub mod serialization;
pub mod source;
pub mod symbol;
pub mod types;
pub fn filename_to_module(filename: &str) -> String {
use std::path::Path;
let filename = filename.trim_right_matches('/');
let path = Path::new(filename);
let name = path.extension().map_or(filename, |ext| {
ext.to_str()
.map(|ext| &filename[..filename.len() - ext.len() - 1])
.unwrap_or(filename)
});
name.replace(|c: char| c == '/' || c == '\\', ".")
}