|
@@ -0,0 +1,70 @@
|
|
1
|
+package org.openzen.zenscript.codemodel.type.member;
|
|
2
|
+
|
|
3
|
+import org.openzen.zenscript.codemodel.type.*;
|
|
4
|
+
|
|
5
|
+import java.util.Arrays;
|
|
6
|
+
|
|
7
|
+public class TagRemovingTypeVisitor implements TypeVisitor<StoredType> {
|
|
8
|
+
|
|
9
|
+ private final LocalMemberCache cache;
|
|
10
|
+
|
|
11
|
+ public TagRemovingTypeVisitor(LocalMemberCache cache) {
|
|
12
|
+
|
|
13
|
+ this.cache = cache;
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ @Override
|
|
17
|
+ public StoredType visitBasic(BasicTypeID basic) {
|
|
18
|
+ return basic.stored;
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ @Override
|
|
22
|
+ public StoredType visitString(StringTypeID string) {
|
|
23
|
+ return string.stored();
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ @Override
|
|
27
|
+ public StoredType visitArray(ArrayTypeID array) {
|
|
28
|
+ return new ArrayTypeID(cache.getRegistry(), array.elementType.type.accept(this), array.dimension).stored();
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ @Override
|
|
32
|
+ public StoredType visitAssoc(AssocTypeID assoc) {
|
|
33
|
+ return new AssocTypeID(cache.getRegistry(), assoc.keyType.type.accept(this), assoc.valueType.type.accept(this)).stored();
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ @Override
|
|
37
|
+ public StoredType visitGenericMap(GenericMapTypeID map) {
|
|
38
|
+ return new GenericMapTypeID(cache.getRegistry(), map.value.type.accept(this), map.key).stored();
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ @Override
|
|
42
|
+ public StoredType visitIterator(IteratorTypeID iterator) {
|
|
43
|
+ return new IteratorTypeID(cache.getRegistry(), Arrays.stream(iterator.iteratorTypes).map(storedType -> storedType.type).map(typeID -> typeID.accept(this)).toArray(StoredType[]::new)).stored();
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ @Override
|
|
47
|
+ public StoredType visitFunction(FunctionTypeID function) {
|
|
48
|
+ return function.stored();
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ @Override
|
|
52
|
+ public StoredType visitDefinition(DefinitionTypeID definition) {
|
|
53
|
+ return definition.stored();
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ @Override
|
|
57
|
+ public StoredType visitGeneric(GenericTypeID generic) {
|
|
58
|
+ return generic.stored();
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ @Override
|
|
62
|
+ public StoredType visitRange(RangeTypeID range) {
|
|
63
|
+ return new RangeTypeID(cache.getRegistry(), range.baseType.type.accept(this)).stored;
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ @Override
|
|
67
|
+ public StoredType visitOptional(OptionalTypeID type) {
|
|
68
|
+ return new OptionalTypeID(cache.getRegistry(), type.baseType.accept(this).type).stored();
|
|
69
|
+ }
|
|
70
|
+}
|