1use std::hash::Hash;
2use std::sync::Arc;
3
4use indexmap::IndexMap;
5use serde::{Deserialize, Serialize};
6
7use crate::symbol::Name;
8use crate::Type;
9
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15pub struct FnParam {
16 pub name: Name,
17 pub ty: Option<crate::compact::SimpleType>,
20 #[serde(default)]
25 pub out_ty: Option<crate::compact::SimpleType>,
26 pub default: Option<crate::compact::SimpleType>,
28 pub is_variadic: bool,
29 pub is_byref: bool,
30 pub is_optional: bool,
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
38pub enum Variance {
39 #[default]
41 Invariant,
42 Covariant,
44 Contravariant,
46}
47
48#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
53pub struct TemplateParam {
54 pub name: Name,
55 pub bound: Option<Type>,
56 pub variance: Variance,
57}
58
59#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
64pub enum ArrayKey {
65 String(Arc<str>),
66 Int(i64),
67}
68
69impl PartialOrd for ArrayKey {
70 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
71 Some(self.cmp(other))
72 }
73}
74
75impl Ord for ArrayKey {
76 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
77 match (self, other) {
78 (ArrayKey::Int(a), ArrayKey::Int(b)) => a.cmp(b),
79 (ArrayKey::String(a), ArrayKey::String(b)) => a.cmp(b),
80 (ArrayKey::Int(_), ArrayKey::String(_)) => std::cmp::Ordering::Less,
82 (ArrayKey::String(_), ArrayKey::Int(_)) => std::cmp::Ordering::Greater,
83 }
84 }
85}
86
87#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
88pub struct KeyedProperty {
89 pub ty: Type,
90 pub optional: bool,
91}
92
93type KeyedMap = IndexMap<ArrayKey, KeyedProperty, rustc_hash::FxBuildHasher>;
94
95#[derive(Default, Serialize, Deserialize)]
99pub struct KeyedProperties {
100 map: KeyedMap,
101 pub remainder: Option<Type>,
103 #[serde(skip)]
104 hash: std::sync::OnceLock<u64>,
105}
106
107impl KeyedProperties {
108 pub fn with_capacity_and_hasher(n: usize, hasher: rustc_hash::FxBuildHasher) -> Self {
109 KeyedMap::with_capacity_and_hasher(n, hasher).into()
110 }
111
112 pub fn map_types(&self, mut f: impl FnMut(&Type) -> Type) -> KeyedProperties {
114 let mut out: KeyedProperties = self
115 .map
116 .iter()
117 .map(|(k, p)| {
118 let property = KeyedProperty {
119 ty: f(&p.ty),
120 optional: p.optional,
121 };
122 (k.clone(), property)
123 })
124 .collect();
125 out.remainder = self.remainder.as_ref().map(f);
126 out
127 }
128
129 pub fn entries_hash(&self) -> u64 {
131 *self.hash.get_or_init(|| {
132 let entries = self.map.iter().fold(0u64, |combined, (k, v)| {
133 let mut entry_hasher = rustc_hash::FxHasher::default();
134 k.hash(&mut entry_hasher);
135 v.hash(&mut entry_hasher);
136 combined.wrapping_add(std::hash::Hasher::finish(&entry_hasher))
137 });
138 match &self.remainder {
139 None => entries,
140 Some(rest) => {
141 let mut hasher = rustc_hash::FxHasher::default();
142 rest.hash(&mut hasher);
143 entries ^ std::hash::Hasher::finish(&hasher)
144 }
145 }
146 })
147 }
148}
149
150impl From<KeyedMap> for KeyedProperties {
151 fn from(map: KeyedMap) -> Self {
152 KeyedProperties {
153 map,
154 remainder: None,
155 hash: std::sync::OnceLock::new(),
156 }
157 }
158}
159
160impl Clone for KeyedProperties {
161 fn clone(&self) -> Self {
162 KeyedProperties {
163 map: self.map.clone(),
164 remainder: self.remainder.clone(),
165 hash: self.hash.clone(),
166 }
167 }
168}
169
170impl std::fmt::Debug for KeyedProperties {
171 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
172 self.map.fmt(f)
173 }
174}
175
176impl PartialEq for KeyedProperties {
177 fn eq(&self, other: &Self) -> bool {
178 if let (Some(a), Some(b)) = (self.hash.get(), other.hash.get()) {
180 if a != b {
181 return false;
182 }
183 }
184 self.map == other.map && self.remainder == other.remainder
185 }
186}
187
188impl Eq for KeyedProperties {}
189
190impl std::ops::Deref for KeyedProperties {
191 type Target = KeyedMap;
192 fn deref(&self) -> &KeyedMap {
193 &self.map
194 }
195}
196
197impl std::ops::DerefMut for KeyedProperties {
198 fn deref_mut(&mut self) -> &mut KeyedMap {
199 self.hash = std::sync::OnceLock::new();
200 &mut self.map
201 }
202}
203
204impl FromIterator<(ArrayKey, KeyedProperty)> for KeyedProperties {
205 fn from_iter<I: IntoIterator<Item = (ArrayKey, KeyedProperty)>>(iter: I) -> Self {
206 KeyedMap::from_iter(iter).into()
207 }
208}
209
210impl Extend<(ArrayKey, KeyedProperty)> for KeyedProperties {
211 fn extend<I: IntoIterator<Item = (ArrayKey, KeyedProperty)>>(&mut self, iter: I) {
212 std::ops::DerefMut::deref_mut(self).extend(iter);
213 }
214}
215
216impl IntoIterator for KeyedProperties {
217 type Item = (ArrayKey, KeyedProperty);
218 type IntoIter = indexmap::map::IntoIter<ArrayKey, KeyedProperty>;
219 fn into_iter(self) -> Self::IntoIter {
220 self.map.into_iter()
221 }
222}
223
224impl<'a> IntoIterator for &'a KeyedProperties {
225 type Item = (&'a ArrayKey, &'a KeyedProperty);
226 type IntoIter = indexmap::map::Iter<'a, ArrayKey, KeyedProperty>;
227 fn into_iter(self) -> Self::IntoIter {
228 self.map.iter()
229 }
230}
231
232impl<'a> IntoIterator for &'a mut KeyedProperties {
233 type Item = (&'a ArrayKey, &'a mut KeyedProperty);
234 type IntoIter = indexmap::map::IterMut<'a, ArrayKey, KeyedProperty>;
235 fn into_iter(self) -> Self::IntoIter {
236 std::ops::DerefMut::deref_mut(self).iter_mut()
237 }
238}
239
240#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
246pub struct ClosureData {
247 pub params: Box<[FnParam]>,
248 pub return_type: Type,
249 pub this_type: Option<Type>,
250 pub is_pure: bool,
252 pub is_static: bool,
254 #[serde(default)]
256 pub rejects_surplus_args: bool,
257 #[serde(default)]
259 pub is_impure: bool,
260}
261
262#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
264pub struct ConditionalData {
265 pub param_name: Option<Name>,
268 pub subject: Type,
269 pub if_true: Type,
270 pub if_false: Type,
271}
272
273#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
275pub enum PropertyFilter {
276 All,
277 Public,
278 Protected,
279 Private,
280}
281
282#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
284pub enum IntRefinement {
285 Literal,
287 MaskOf(Name),
289}
290
291#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
293pub enum StringRefinement {
294 Lowercase,
295 Uppercase,
296 Literal,
298 DecimalInt,
300 NonDecimalInt,
301}
302
303impl StringRefinement {
304 pub fn accepts(self, s: &str) -> bool {
305 match self {
306 StringRefinement::Lowercase => !s.bytes().any(|b| b.is_ascii_uppercase()),
307 StringRefinement::Uppercase => !s.bytes().any(|b| b.is_ascii_lowercase()),
308 StringRefinement::Literal => true,
309 StringRefinement::DecimalInt => is_decimal_int(s),
310 StringRefinement::NonDecimalInt => !is_decimal_int(s),
311 }
312 }
313}
314
315fn is_decimal_int(s: &str) -> bool {
316 s.parse::<i64>().is_ok_and(|n| n.to_string() == s)
317}
318
319#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
324pub enum Atomic {
325 TString,
328 TLiteralString(Arc<str>),
330 TCallableString,
332 TClassString(Option<Name>),
334 TNonEmptyString,
336 TNonFalsyString,
338 TNumericString,
340 TRefinedString {
342 refinement: StringRefinement,
343 non_empty: bool,
344 },
345
346 TInt,
348 TLiteralInt(i64),
350 TIntRange { min: Option<i64>, max: Option<i64> },
352 TPositiveInt,
354 TNegativeInt,
356 TNonNegativeInt,
358 TRefinedInt(IntRefinement),
360
361 TFloat,
363 TIntegralFloat,
367 TLiteralFloat(i64, i64), TBool,
372 TTrue,
374 TFalse,
376
377 TNull,
379
380 TVoid,
383 TNever,
385 TMixed,
387 TScalar,
389 TNumeric,
391
392 TObject,
395 TNamedObject {
397 fqcn: Name,
398 type_params: Arc<[Type]>,
400 },
401 TStaticObject { fqcn: Name },
403 TSelf { fqcn: Name },
405 TParent { fqcn: Name },
407
408 TCallable {
411 params: Option<Box<Vec<FnParam>>>,
415 return_type: Option<Box<Type>>,
416 is_pure: bool,
418 },
419 TClosure { data: Box<ClosureData> },
422
423 TArray { key: Box<Type>, value: Box<Type> },
426 TList { value: Box<Type> },
428 TNonEmptyArray { key: Box<Type>, value: Box<Type> },
430 TNonEmptyList { value: Box<Type> },
432 TKeyedArray {
434 properties: Arc<KeyedProperties>,
436 is_open: bool,
438 is_list: bool,
440 },
441
442 TTemplateParam {
445 name: Name,
446 as_type: Box<Type>,
447 defining_entity: Name,
449 },
450 TKeyOf { target: Box<Type> },
452 TValueOf { target: Box<Type> },
454 TConditional { data: Box<ConditionalData> },
457
458 TInterfaceString(Option<Name>),
461 TEnumString,
463 TTraitString,
465
466 TLiteralEnumCase { enum_fqcn: Name, case_name: Name },
469
470 TIntersection { parts: Arc<[Type]> },
473
474 TObjectShape { properties: Arc<KeyedProperties> },
476
477 TResource,
479 TClosedResource,
481
482 TPropertiesOf { class: Name, filter: PropertyFilter },
484}
485
486impl Atomic {
487 pub fn can_be_falsy(&self) -> bool {
489 match self {
490 Atomic::TNull
491 | Atomic::TFalse
492 | Atomic::TBool
493 | Atomic::TNever
494 | Atomic::TLiteralInt(0)
495 | Atomic::TLiteralFloat(0, 0)
496 | Atomic::TInt
497 | Atomic::TRefinedInt(_)
498 | Atomic::TFloat
499 | Atomic::TNumeric
500 | Atomic::TScalar
501 | Atomic::TMixed
502 | Atomic::TString
503 | Atomic::TNonEmptyString | Atomic::TNumericString | Atomic::TRefinedString { .. }
506 | Atomic::TKeyOf { .. }
507 | Atomic::TValueOf { .. }
508 | Atomic::TArray { .. }
509 | Atomic::TList { .. } => true,
510 Atomic::TLiteralString(s) => s.as_ref().is_empty() || s.as_ref() == "0",
514
515 Atomic::TKeyedArray { properties, .. } => properties.values().all(|p| p.optional),
516
517 Atomic::TIntRange { min, max } => {
519 min.is_none_or(|lo| lo <= 0) && max.is_none_or(|hi| hi >= 0)
520 }
521 Atomic::TNonNegativeInt => true,
523
524 _ => false,
525 }
526 }
527
528 pub fn is_deferred(&self) -> bool {
530 matches!(
531 self,
532 Atomic::TTemplateParam { .. } | Atomic::TKeyOf { .. } | Atomic::TValueOf { .. }
533 )
534 }
535
536 pub fn can_be_truthy(&self) -> bool {
538 match self {
539 Atomic::TNever
540 | Atomic::TVoid
541 | Atomic::TNull
542 | Atomic::TFalse
543 | Atomic::TLiteralInt(0)
544 | Atomic::TLiteralFloat(0, 0) => false,
545 Atomic::TLiteralString(s) if s.as_ref() == "" || s.as_ref() == "0" => false,
546 Atomic::TIntRange {
548 min: Some(0),
549 max: Some(0),
550 } => false,
551 Atomic::TKeyedArray {
553 properties,
554 is_open,
555 ..
556 } if !is_open && properties.is_empty() => false,
557 _ => true,
558 }
559 }
560
561 pub fn is_numeric(&self) -> bool {
563 matches!(
564 self,
565 Atomic::TInt
566 | Atomic::TLiteralInt(_)
567 | Atomic::TIntRange { .. }
568 | Atomic::TPositiveInt
569 | Atomic::TNegativeInt
570 | Atomic::TNonNegativeInt
571 | Atomic::TRefinedInt(_)
572 | Atomic::TFloat
573 | Atomic::TIntegralFloat
574 | Atomic::TLiteralFloat(..)
575 | Atomic::TNumeric
576 | Atomic::TNumericString
577 )
578 }
579
580 pub fn is_int(&self) -> bool {
582 matches!(
583 self,
584 Atomic::TInt
585 | Atomic::TLiteralInt(_)
586 | Atomic::TIntRange { .. }
587 | Atomic::TPositiveInt
588 | Atomic::TNegativeInt
589 | Atomic::TNonNegativeInt
590 | Atomic::TRefinedInt(_)
591 )
592 }
593
594 pub fn is_string(&self) -> bool {
596 matches!(
597 self,
598 Atomic::TString
599 | Atomic::TLiteralString(_)
600 | Atomic::TCallableString
601 | Atomic::TClassString(_)
602 | Atomic::TNonEmptyString
603 | Atomic::TNonFalsyString
604 | Atomic::TRefinedString { .. }
605 | Atomic::TNumericString
606 | Atomic::TInterfaceString(_)
607 | Atomic::TEnumString
608 | Atomic::TTraitString
609 )
610 }
611
612 pub fn is_array(&self) -> bool {
614 matches!(
615 self,
616 Atomic::TArray { .. }
617 | Atomic::TList { .. }
618 | Atomic::TNonEmptyArray { .. }
619 | Atomic::TNonEmptyList { .. }
620 | Atomic::TKeyedArray { .. }
621 )
622 }
623
624 pub fn is_object(&self) -> bool {
626 matches!(
627 self,
628 Atomic::TObject
629 | Atomic::TObjectShape { .. }
630 | Atomic::TNamedObject { .. }
631 | Atomic::TStaticObject { .. }
632 | Atomic::TSelf { .. }
633 | Atomic::TParent { .. }
634 | Atomic::TIntersection { .. }
635 )
636 }
637
638 pub fn is_definitely_non_object(&self) -> bool {
643 matches!(
644 self,
645 Atomic::TString
646 | Atomic::TLiteralString(_)
647 | Atomic::TCallableString
648 | Atomic::TClassString(_)
649 | Atomic::TNonEmptyString
650 | Atomic::TNonFalsyString
651 | Atomic::TRefinedString { .. }
652 | Atomic::TNumericString
653 | Atomic::TInterfaceString(_)
654 | Atomic::TEnumString
655 | Atomic::TTraitString
656 | Atomic::TInt
657 | Atomic::TLiteralInt(_)
658 | Atomic::TIntRange { .. }
659 | Atomic::TPositiveInt
660 | Atomic::TNegativeInt
661 | Atomic::TNonNegativeInt
662 | Atomic::TRefinedInt(_)
663 | Atomic::TFloat
664 | Atomic::TIntegralFloat
665 | Atomic::TLiteralFloat(..)
666 | Atomic::TBool
667 | Atomic::TTrue
668 | Atomic::TFalse
669 | Atomic::TNull
670 | Atomic::TVoid
671 | Atomic::TArray { .. }
672 | Atomic::TList { .. }
673 | Atomic::TNonEmptyArray { .. }
674 | Atomic::TNonEmptyList { .. }
675 | Atomic::TKeyedArray { .. }
676 | Atomic::TScalar
677 | Atomic::TNumeric
678 )
679 }
680
681 pub fn is_callable(&self) -> bool {
686 matches!(
687 self,
688 Atomic::TCallable { .. } | Atomic::TClosure { .. } | Atomic::TCallableString
689 )
690 }
691
692 pub fn named_object_fqcn(&self) -> Option<&str> {
694 match self {
695 Atomic::TNamedObject { fqcn, .. }
696 | Atomic::TStaticObject { fqcn }
697 | Atomic::TSelf { fqcn }
698 | Atomic::TParent { fqcn } => Some(fqcn.as_ref()),
699 _ => None,
700 }
701 }
702
703 pub fn type_name(&self) -> &'static str {
705 match self {
706 Atomic::TString
707 | Atomic::TLiteralString(_)
708 | Atomic::TNonEmptyString
709 | Atomic::TNonFalsyString
710 | Atomic::TRefinedString { .. }
711 | Atomic::TNumericString => "string",
712 Atomic::TCallableString => "callable-string",
713 Atomic::TClassString(_) => "class-string",
714 Atomic::TInt
715 | Atomic::TLiteralInt(_)
716 | Atomic::TIntRange { .. }
717 | Atomic::TRefinedInt(_) => "int",
718 Atomic::TPositiveInt => "positive-int",
719 Atomic::TNegativeInt => "negative-int",
720 Atomic::TNonNegativeInt => "non-negative-int",
721 Atomic::TFloat | Atomic::TIntegralFloat | Atomic::TLiteralFloat(..) => "float",
722 Atomic::TBool => "bool",
723 Atomic::TTrue => "true",
724 Atomic::TFalse => "false",
725 Atomic::TNull => "null",
726 Atomic::TVoid => "void",
727 Atomic::TNever => "never",
728 Atomic::TMixed => "mixed",
729 Atomic::TScalar => "scalar",
730 Atomic::TNumeric => "numeric",
731 Atomic::TObject => "object",
732 Atomic::TResource | Atomic::TClosedResource => "resource",
733 Atomic::TPropertiesOf { .. } => "array",
734 Atomic::TNamedObject { .. } => "object",
735 Atomic::TStaticObject { .. } => "static",
736 Atomic::TSelf { .. } => "self",
737 Atomic::TParent { .. } => "parent",
738 Atomic::TCallable { .. } => "callable",
739 Atomic::TClosure { .. } => "Closure",
740 Atomic::TArray { .. } => "array",
741 Atomic::TList { .. } => "list",
742 Atomic::TNonEmptyArray { .. } => "non-empty-array",
743 Atomic::TNonEmptyList { .. } => "non-empty-list",
744 Atomic::TKeyedArray { .. } => "array",
745 Atomic::TTemplateParam { .. } => "template-param",
746 Atomic::TKeyOf { .. } => "key-of",
747 Atomic::TValueOf { .. } => "value-of",
748 Atomic::TConditional { .. } => "conditional-type",
749 Atomic::TInterfaceString(_) => "interface-string",
750 Atomic::TEnumString => "enum-string",
751 Atomic::TTraitString => "trait-string",
752 Atomic::TLiteralEnumCase { .. } => "enum-case",
753 Atomic::TIntersection { .. } => "intersection",
754 Atomic::TObjectShape { .. } => "object",
755 }
756 }
757}
758
759impl Hash for FnParam {
764 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
765 self.name.hash(state);
766 self.ty.hash(state);
767 self.out_ty.hash(state);
768 self.default.hash(state);
769 self.is_variadic.hash(state);
770 self.is_byref.hash(state);
771 self.is_optional.hash(state);
772 }
773}
774
775#[allow(non_camel_case_types, clippy::enum_variant_names)]
777#[repr(u8)]
778enum AtomicTag {
779 TString = 0,
780 TLiteralString,
781 TCallableString,
782 TClassString,
783 TNonEmptyString,
784 TNonFalsyString,
785 TNumericString,
786 TRefinedString,
787 TInt,
788 TLiteralInt,
789 TIntRange,
790 TPositiveInt,
791 TNegativeInt,
792 TNonNegativeInt,
793 TRefinedInt,
794 TFloat,
795 TIntegralFloat,
796 TLiteralFloat,
797 TBool,
798 TTrue,
799 TFalse,
800 TNull,
801 TVoid,
802 TNever,
803 TMixed,
804 TScalar,
805 TNumeric,
806 TObject,
807 TNamedObject,
808 TStaticObject,
809 TSelf,
810 TParent,
811 TCallable,
812 TClosure,
813 TArray,
814 TList,
815 TNonEmptyArray,
816 TNonEmptyList,
817 TKeyedArray,
818 TTemplateParam,
819 TKeyOf,
820 TValueOf,
821 TConditional,
822 TInterfaceString,
823 TEnumString,
824 TTraitString,
825 TLiteralEnumCase,
826 TIntersection,
827 TObjectShape,
828 TResource,
829 TClosedResource,
830 TPropertiesOf,
831}
832
833impl Hash for Atomic {
834 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
835 use AtomicTag as T;
836 match self {
837 Atomic::TString => (T::TString as u8).hash(state),
839 Atomic::TCallableString => (T::TCallableString as u8).hash(state),
840 Atomic::TNonEmptyString => (T::TNonEmptyString as u8).hash(state),
841 Atomic::TNonFalsyString => (T::TNonFalsyString as u8).hash(state),
842 Atomic::TNumericString => (T::TNumericString as u8).hash(state),
843 Atomic::TRefinedString {
844 refinement,
845 non_empty,
846 } => {
847 (T::TRefinedString as u8).hash(state);
848 refinement.hash(state);
849 non_empty.hash(state);
850 }
851 Atomic::TInt => (T::TInt as u8).hash(state),
852 Atomic::TPositiveInt => (T::TPositiveInt as u8).hash(state),
853 Atomic::TNegativeInt => (T::TNegativeInt as u8).hash(state),
854 Atomic::TNonNegativeInt => (T::TNonNegativeInt as u8).hash(state),
855 Atomic::TRefinedInt(refinement) => {
856 (T::TRefinedInt as u8).hash(state);
857 refinement.hash(state);
858 }
859 Atomic::TFloat => (T::TFloat as u8).hash(state),
860 Atomic::TIntegralFloat => (T::TIntegralFloat as u8).hash(state),
861 Atomic::TBool => (T::TBool as u8).hash(state),
862 Atomic::TTrue => (T::TTrue as u8).hash(state),
863 Atomic::TFalse => (T::TFalse as u8).hash(state),
864 Atomic::TNull => (T::TNull as u8).hash(state),
865 Atomic::TVoid => (T::TVoid as u8).hash(state),
866 Atomic::TNever => (T::TNever as u8).hash(state),
867 Atomic::TMixed => (T::TMixed as u8).hash(state),
868 Atomic::TScalar => (T::TScalar as u8).hash(state),
869 Atomic::TNumeric => (T::TNumeric as u8).hash(state),
870 Atomic::TObject => (T::TObject as u8).hash(state),
871 Atomic::TEnumString => (T::TEnumString as u8).hash(state),
872 Atomic::TTraitString => (T::TTraitString as u8).hash(state),
873 Atomic::TResource => (T::TResource as u8).hash(state),
874 Atomic::TClosedResource => (T::TClosedResource as u8).hash(state),
875 Atomic::TPropertiesOf { class, filter } => {
876 (T::TPropertiesOf as u8).hash(state);
877 class.hash(state);
878 filter.hash(state);
879 }
880
881 Atomic::TLiteralString(s) => {
883 (T::TLiteralString as u8).hash(state);
884 s.hash(state);
885 }
886 Atomic::TClassString(opt) => {
887 (T::TClassString as u8).hash(state);
888 opt.hash(state);
889 }
890 Atomic::TInterfaceString(opt) => {
891 (T::TInterfaceString as u8).hash(state);
892 opt.hash(state);
893 }
894 Atomic::TLiteralInt(n) => {
895 (T::TLiteralInt as u8).hash(state);
896 n.hash(state);
897 }
898 Atomic::TIntRange { min, max } => {
899 (T::TIntRange as u8).hash(state);
900 min.hash(state);
901 max.hash(state);
902 }
903 Atomic::TLiteralFloat(int_bits, frac_bits) => {
904 (T::TLiteralFloat as u8).hash(state);
905 int_bits.hash(state);
906 frac_bits.hash(state);
907 }
908 Atomic::TNamedObject { fqcn, type_params } => {
909 (T::TNamedObject as u8).hash(state);
910 fqcn.hash(state);
911 type_params.hash(state);
912 }
913 Atomic::TStaticObject { fqcn } => {
914 (T::TStaticObject as u8).hash(state);
915 fqcn.hash(state);
916 }
917 Atomic::TSelf { fqcn } => {
918 (T::TSelf as u8).hash(state);
919 fqcn.hash(state);
920 }
921 Atomic::TParent { fqcn } => {
922 (T::TParent as u8).hash(state);
923 fqcn.hash(state);
924 }
925 Atomic::TCallable {
926 params,
927 return_type,
928 is_pure,
929 } => {
930 (T::TCallable as u8).hash(state);
931 params.hash(state);
932 return_type.hash(state);
933 is_pure.hash(state);
934 }
935 Atomic::TClosure { data } => {
936 (T::TClosure as u8).hash(state);
937 data.hash(state);
938 }
939 Atomic::TArray { key, value } => {
940 (T::TArray as u8).hash(state);
941 key.hash(state);
942 value.hash(state);
943 }
944 Atomic::TList { value } => {
945 (T::TList as u8).hash(state);
946 value.hash(state);
947 }
948 Atomic::TNonEmptyArray { key, value } => {
949 (T::TNonEmptyArray as u8).hash(state);
950 key.hash(state);
951 value.hash(state);
952 }
953 Atomic::TNonEmptyList { value } => {
954 (T::TNonEmptyList as u8).hash(state);
955 value.hash(state);
956 }
957 Atomic::TObjectShape { properties } => {
958 (T::TObjectShape as u8).hash(state);
959 properties.entries_hash().hash(state);
960 properties.len().hash(state);
961 }
962 Atomic::TKeyedArray {
963 properties,
964 is_open,
965 is_list,
966 } => {
967 (T::TKeyedArray as u8).hash(state);
968 properties.entries_hash().hash(state);
969 properties.len().hash(state);
970 is_open.hash(state);
971 is_list.hash(state);
972 }
973 Atomic::TTemplateParam {
974 name,
975 as_type,
976 defining_entity,
977 } => {
978 (T::TTemplateParam as u8).hash(state);
979 name.hash(state);
980 as_type.hash(state);
981 defining_entity.hash(state);
982 }
983 Atomic::TKeyOf { target } => {
984 (T::TKeyOf as u8).hash(state);
985 target.hash(state);
986 }
987 Atomic::TValueOf { target } => {
988 (T::TValueOf as u8).hash(state);
989 target.hash(state);
990 }
991 Atomic::TConditional { data } => {
992 (T::TConditional as u8).hash(state);
993 data.hash(state);
994 }
995 Atomic::TLiteralEnumCase {
996 enum_fqcn,
997 case_name,
998 } => {
999 (T::TLiteralEnumCase as u8).hash(state);
1000 enum_fqcn.hash(state);
1001 case_name.hash(state);
1002 }
1003 Atomic::TIntersection { parts } => {
1004 (T::TIntersection as u8).hash(state);
1005 parts.hash(state);
1006 }
1007 }
1008 }
1009}