-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.rs
More file actions
114 lines (102 loc) · 3.44 KB
/
Copy pathcore.rs
File metadata and controls
114 lines (102 loc) · 3.44 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
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
111
112
113
114
use crate::diagnostics::diagnose::Diagnose;
use crate::diagnostics::kinds::DiagnosticKind;
use crate::diagnostics::reporter::Reporter;
use crate::parser::ModuleConfiguration;
use crate::{analyser::index_identifier::IdentifierIndex, reader::Meta};
use tucana::shared::{
DefinitionDataType, FlowType, FunctionDefinition, ModuleConfigurationDefinition,
RuntimeFlowType, RuntimeFunctionDefinition,
};
#[derive(Clone)]
pub struct AnalysableDataType {
pub original_definition: Meta,
pub definition_data_type: DefinitionDataType,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableFlowType {
pub original_definition: Meta,
pub flow_type: FlowType,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableFunction {
pub original_definition: Meta,
pub function: RuntimeFunctionDefinition,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableRuntimeFlowType {
pub original_definition: Meta,
pub runtime_flow_type: RuntimeFlowType,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableFunctionDefinition {
pub original_definition: Meta,
pub function_definition: FunctionDefinition,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableModuleConfigurationDefinition {
pub original_definition: Meta,
pub module_configuration_definition: ModuleConfigurationDefinition,
pub id: i16,
}
#[derive(Clone)]
pub struct AnalysableModuleDefinition {
pub original_definition: Meta,
pub module_definition: ModuleConfiguration,
pub id: i16,
}
pub struct Analyser {
pub reporter: Reporter,
pub(crate) index: IdentifierIndex,
pub data_types: Vec<AnalysableDataType>,
pub flow_types: Vec<AnalysableFlowType>,
pub functions: Vec<AnalysableFunction>,
pub runtime_flow_types: Vec<AnalysableRuntimeFlowType>,
pub function_definitions: Vec<AnalysableFunctionDefinition>,
pub module_configuration_definitions: Vec<AnalysableModuleConfigurationDefinition>,
pub module_definitions: Vec<AnalysableModuleDefinition>,
}
impl Analyser {
pub fn new(path: &str) -> Self {
super::loader::load_from_path(path)
}
pub fn report(&mut self, will_exit: bool, with_warning: bool) {
// Run analysis passes
for dt in self.data_types.clone() {
self.analyse_data_type(&dt);
}
for ft in self.flow_types.clone() {
self.analyse_flow_type(&ft);
}
for f in self.functions.clone() {
self.analyse_runtime_function(&f);
}
for rft in self.runtime_flow_types.clone() {
self.analyse_runtime_flow_type(&rft);
}
for f in self.function_definitions.clone() {
self.analyse_function_definition(&f);
}
for config in self.module_configuration_definitions.clone() {
self.analyse_module_configuration_definition(&config);
}
for module in self.module_definitions.clone() {
self.analyse_module_definition(&module);
}
self.reporter.print(will_exit, true, with_warning);
}
pub fn data_type_identifier_exists(&self, identifier: &str, except_id: Option<i16>) -> bool {
self.index.has_data_type(identifier, except_id)
}
pub fn null_field(&mut self, name: String, adt: &AnalysableDataType) {
self.reporter.add(Diagnose::new(
adt.definition_data_type.identifier.clone(),
adt.original_definition.clone(),
DiagnosticKind::NullField { field_name: name },
));
}
}