Repository navigation
Expand file tree
/
Copy pathsnapshot.rs
More file actions
76 lines (65 loc) · 2.04 KB
/
Copy pathsnapshot.rs
File metadata and controls
76 lines (65 loc) · 2.04 KB
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
//! Editor-safe semantic facts from either strict or recovering checking.
use std::sync::Arc;
use crate::{
CheckedProgram, CompilerContext, RecoveredCheck,
ast::{EnumDecl, Program},
effects::OperationAnalysis,
hir::TypedProgram,
semantic::SemanticModel,
syntax::SourceDocument,
};
#[derive(Debug, Clone)]
pub enum SemanticSnapshot {
Checked(Arc<CheckedProgram>),
Recovered(Arc<RecoveredCheck>),
}
impl SemanticSnapshot {
pub fn context(&self) -> CompilerContext {
match self {
Self::Checked(program) => program.context(),
Self::Recovered(program) => program.context(),
}
}
pub fn semantics(&self) -> &SemanticModel {
match self {
Self::Checked(program) => program.semantics(),
Self::Recovered(program) => program.semantics(),
}
}
pub fn syntax(&self) -> &Program {
match self {
Self::Checked(program) => program.syntax(),
Self::Recovered(program) => program.syntax(),
}
}
pub fn source_document(&self) -> &SourceDocument {
match self {
Self::Checked(program) => program.source_document(),
Self::Recovered(program) => program.source_document(),
}
}
pub fn enum_types(&self) -> &[EnumDecl] {
match self {
Self::Checked(program) => program.enum_types(),
Self::Recovered(program) => program.enum_types(),
}
}
pub fn typed_hir(&self) -> Option<&TypedProgram> {
match self {
Self::Checked(program) => Some(program.typed_hir()),
Self::Recovered(_) => None,
}
}
pub fn effects(&self) -> Option<&OperationAnalysis> {
match self {
Self::Checked(program) => Some(program.effects()),
Self::Recovered(program) => program.effects(),
}
}
pub fn checked(&self) -> Option<&CheckedProgram> {
match self {
Self::Checked(program) => Some(program),
Self::Recovered(_) => None,
}
}
}