scilla_parser/simplified_representation/
primitives.rs1use crate::FieldList;
2
3#[derive(Debug, Clone, PartialEq)]
5pub enum SrIdentifierKind {
6 FunctionName,
7 StaticFunctionName,
8 TransitionName,
9 ProcedureName,
10 TemplateFunctionName,
11 ExternalFunctionName,
12
13 TypeName,
14 ComponentName,
15 Event,
16 Namespace,
17 BlockLabel,
18
19 ContextResource,
20
21 VirtualRegister,
23 VirtualRegisterIntermediate,
24 Memory,
25 State,
26
27 Unknown,
29}
30
31#[derive(Debug, Clone, PartialEq)]
33pub struct SrIdentifier {
34 pub unresolved: String,
35 pub resolved: Option<String>,
36 pub type_reference: Option<String>,
37 pub kind: SrIdentifierKind,
38 pub is_definition: bool,
39}
40
41#[derive(Debug, Clone)]
42pub struct AddressType {
43 pub type_name: String,
44 pub fields: FieldList,
45}
46
47#[derive(Debug, Clone)]
48pub struct SrType {
49 pub main_type: String,
50 pub sub_types: Vec<SrType>,
51 pub address_type: Option<AddressType>, }
53
54impl SrType {
55 pub fn push_sub_type(&mut self, sub_type: SrType) {
56 self.sub_types.push(sub_type);
57 }
58}
59
60impl From<SrIdentifier> for SrType {
61 fn from(value: SrIdentifier) -> Self {
62 Self {
63 main_type: value.unresolved,
64 sub_types: vec![],
65 address_type: None,
66 }
67 }
68}
69
70impl SrIdentifier {
71 pub fn new(unresolved: String, kind: SrIdentifierKind) -> Self {
72 Self {
73 unresolved,
74 resolved: None,
75 type_reference: None,
76 kind,
77 is_definition: false,
78 }
79 }
80}