diff options
Diffstat (limited to 'src/yellow/mod.rs')
-rw-r--r-- | src/yellow/mod.rs | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/yellow/mod.rs b/src/yellow/mod.rs deleted file mode 100644 index ff3bb221b..000000000 --- a/src/yellow/mod.rs +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | mod builder; | ||
2 | mod green; | ||
3 | mod red; | ||
4 | mod syntax; | ||
5 | |||
6 | use std::{ | ||
7 | ops::Deref, | ||
8 | sync::Arc, | ||
9 | ptr, | ||
10 | }; | ||
11 | pub use self::syntax::{SyntaxNode, SyntaxNodeRef, SyntaxError}; | ||
12 | pub(crate) use self::{ | ||
13 | builder::GreenBuilder, | ||
14 | green::GreenNode, | ||
15 | red::RedNode, | ||
16 | }; | ||
17 | |||
18 | pub trait TreeRoot: Deref<Target=SyntaxRoot> + Clone + Send + Sync {} | ||
19 | |||
20 | #[derive(Debug)] | ||
21 | pub struct SyntaxRoot { | ||
22 | red: RedNode, | ||
23 | pub(crate) errors: Vec<SyntaxError>, | ||
24 | } | ||
25 | |||
26 | impl TreeRoot for Arc<SyntaxRoot> {} | ||
27 | |||
28 | impl<'a> TreeRoot for &'a SyntaxRoot {} | ||
29 | |||
30 | impl SyntaxRoot { | ||
31 | pub(crate) fn new(green: GreenNode, errors: Vec<SyntaxError>) -> SyntaxRoot { | ||
32 | SyntaxRoot { | ||
33 | red: RedNode::new_root(green), | ||
34 | errors, | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | |||
39 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
40 | pub(crate) struct RedPtr(ptr::NonNull<RedNode>); | ||
41 | |||
42 | unsafe impl Send for RedPtr {} | ||
43 | |||
44 | unsafe impl Sync for RedPtr {} | ||
45 | |||
46 | impl RedPtr { | ||
47 | fn new(red: &RedNode) -> RedPtr { | ||
48 | RedPtr(red.into()) | ||
49 | } | ||
50 | |||
51 | unsafe fn get<'a>(self, _root: &'a impl TreeRoot) -> &'a RedNode { | ||
52 | &*self.0.as_ptr() | ||
53 | } | ||
54 | } | ||
55 | |||
56 | #[test] | ||
57 | fn assert_send_sync() { | ||
58 | fn f<T: Send + Sync>() {} | ||
59 | f::<GreenNode>(); | ||
60 | f::<RedNode>(); | ||
61 | f::<SyntaxNode>(); | ||
62 | } | ||