1#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub enum FieldKind {
7 StructField,
9 Namespace,
11 ArrayListLen,
13 StringLen,
15 MapSetSize,
17 MathConstant(String),
19 NumberConstant(String),
21 SymbolWellKnown(String),
23 TypedArrayProp {
27 prop: String,
28 type_suffix: Option<String>,
29 },
30 Private,
32 PointerDeref,
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
38pub enum IndexKind {
39 ArrayListItem,
41 SliceIndex,
43}
44
45#[derive(Debug, Clone, PartialEq, Eq, Hash)]
47pub enum ComputedKeyKind {
48 StructField,
50 MapGet,
52 JsAnyGetByKey,
54 ArrayListItem,
56 CompileError(String),
58}
59
60#[derive(Debug, Clone, PartialEq, Eq, Hash)]
62pub enum CallKind {
63 Direct,
65 Method { object_type: MethodObjectKind },
67 Closure,
69}
70
71#[derive(Debug, Clone, PartialEq, Eq, Hash)]
73pub enum MethodObjectKind {
74 ArrayList,
75 String,
76 Map,
77 Set,
78 Date,
79 Class(String),
81 JsAny,
82 Unknown,
83}
84
85#[derive(Debug, Clone, PartialEq, Eq, Hash)]
87pub enum NewConstructor {
88 Map,
89 Set,
90 Date(DateConstructorKind),
91 RegExp,
92 TypedArray(TypedArrayKind),
93 Class(String),
95 Error(String),
97 Unsupported(String),
99}
100
101#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
103pub enum DateConstructorKind {
104 Now,
106 FromMillis,
108 FromString,
110 FromComponents,
112}
113
114#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
116pub enum TypedArrayKind {
117 Int8Array,
118 Uint8Array,
119 Uint8ClampedArray,
120 Int16Array,
121 Uint16Array,
122 Int32Array,
123 Uint32Array,
124 Float32Array,
125 Float64Array,
126 BigInt64Array,
127 BigUint64Array,
128}
129
130#[cfg(test)]
131mod tests {
132 use super::*;
133
134 #[test]
135 fn test_field_kind_variants() {
136 let kinds = [
137 FieldKind::StructField,
138 FieldKind::ArrayListLen,
139 FieldKind::StringLen,
140 FieldKind::MapSetSize,
141 FieldKind::MathConstant("pi".to_string()),
142 FieldKind::NumberConstant("floatMax".to_string()),
143 FieldKind::SymbolWellKnown("iterator".to_string()),
144 FieldKind::TypedArrayProp {
145 prop: "buffer".to_string(),
146 type_suffix: None,
147 },
148 ];
149 assert_eq!(kinds.len(), 8);
150 }
151
152 #[test]
153 fn test_call_kind() {
154 let direct = CallKind::Direct;
155 let method = CallKind::Method {
156 object_type: MethodObjectKind::ArrayList,
157 };
158 let closure = CallKind::Closure;
159 assert_ne!(direct, method);
160 assert_ne!(method, closure);
161 }
162
163 #[test]
164 fn test_new_constructor() {
165 let date_now = NewConstructor::Date(DateConstructorKind::Now);
166 let class = NewConstructor::Class("Foo".to_string());
167 assert!(matches!(
168 date_now,
169 NewConstructor::Date(DateConstructorKind::Now)
170 ));
171 assert!(matches!(class, NewConstructor::Class(_)));
172 }
173
174 #[test]
175 fn test_typed_array_kinds() {
176 let all = [
177 TypedArrayKind::Int8Array,
178 TypedArrayKind::Uint8Array,
179 TypedArrayKind::Uint8ClampedArray,
180 TypedArrayKind::Int16Array,
181 TypedArrayKind::Uint16Array,
182 TypedArrayKind::Int32Array,
183 TypedArrayKind::Uint32Array,
184 TypedArrayKind::Float32Array,
185 TypedArrayKind::Float64Array,
186 TypedArrayKind::BigInt64Array,
187 TypedArrayKind::BigUint64Array,
188 ];
189 assert_eq!(all.len(), 11);
190 }
191}