Просмотр исходного кода

- Fixed recursive errors in destructability test

- Fixed some more storage tag issues
- Added methods with storage tag requirements
Stan Hebben 6 лет назад
Родитель
Сommit
b64fee8856
34 измененных файлов: 191 добавлений и 44 удалений
  1. 17
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  2. 15
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  3. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java
  4. 5
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java
  5. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java
  6. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java
  7. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  8. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  9. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java
  10. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java
  11. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java
  12. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/InvalidTypeID.java
  13. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java
  14. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ModifiedTypeID.java
  15. 8
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java
  16. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java
  17. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java
  18. 3
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java
  19. 5
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  20. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  21. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageType.java
  22. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageType.java
  23. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/InvalidStorageTag.java
  24. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageType.java
  25. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageType.java
  26. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageType.java
  27. 19
    5
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunctionHeader.java
  28. 6
    3
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java
  29. 2
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionBracket.java
  30. 2
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionCast.java
  31. 4
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionString.java
  32. 2
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java
  33. 3
    10
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java
  34. 6
    0
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/ValidationUtils.java

+ 17
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java Просмотреть файл

@@ -18,6 +18,7 @@ import org.openzen.zenscript.codemodel.scope.TypeScope;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
20 20
 import org.openzen.zenscript.codemodel.type.TypeID;
21
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
21 22
 
22 23
 /**
23 24
  *
@@ -28,6 +29,7 @@ public class FunctionHeader {
28 29
 	private StoredType returnType;
29 30
 	public final FunctionParameter[] parameters;
30 31
 	public final StoredType thrownType;
32
+	public final StorageTag storage;
31 33
 	
32 34
 	public final int minParameters;
33 35
 	public final int maxParameters;
@@ -41,6 +43,7 @@ public class FunctionHeader {
41 43
 		this.returnType = returnType;
42 44
 		this.parameters = FunctionParameter.NONE;
43 45
 		this.thrownType = null;
46
+		this.storage = null;
44 47
 		
45 48
 		minParameters = 0;
46 49
 		maxParameters = 0;
@@ -59,6 +62,7 @@ public class FunctionHeader {
59 62
 		this.returnType = returnType;
60 63
 		this.parameters = new FunctionParameter[parameterTypes.length];
61 64
 		this.thrownType = null;
65
+		this.storage = null;
62 66
 		
63 67
 		for (int i = 0; i < parameterTypes.length; i++)
64 68
 			parameters[i] = new FunctionParameter(parameterTypes[i], null);
@@ -80,6 +84,7 @@ public class FunctionHeader {
80 84
 		this.returnType = returnType;
81 85
 		this.parameters = parameters;
82 86
 		this.thrownType = null;
87
+		this.storage = null;
83 88
 		
84 89
 		minParameters = getMinParameters(parameters);
85 90
 		maxParameters = getMaxParameters(parameters);
@@ -90,7 +95,7 @@ public class FunctionHeader {
90 95
 		this(returnType.stored, parameters);
91 96
 	}
92 97
 	
93
-	public FunctionHeader(TypeParameter[] typeParameters, StoredType returnType, StoredType thrownType, FunctionParameter... parameters) {
98
+	public FunctionHeader(TypeParameter[] typeParameters, StoredType returnType, StoredType thrownType, StorageTag storage, FunctionParameter... parameters) {
94 99
 		if (returnType == null)
95 100
 			throw new NullPointerException();
96 101
 		if (typeParameters == null)
@@ -100,6 +105,7 @@ public class FunctionHeader {
100 105
 		this.returnType = returnType;
101 106
 		this.parameters = parameters;
102 107
 		this.thrownType = thrownType;
108
+		this.storage = storage;
103 109
 		
104 110
 		minParameters = getMinParameters(parameters);
105 111
 		maxParameters = getMaxParameters(parameters);
@@ -134,7 +140,7 @@ public class FunctionHeader {
134 140
 		FunctionParameter[] normalizedParameters = new FunctionParameter[parameters.length];
135 141
 		for (int i = 0; i < normalizedParameters.length; i++)
136 142
 			normalizedParameters[i] = parameters[i].normalized(registry);
137
-		return new FunctionHeader(typeParameters, returnType.getNormalized(), thrownType == null ? null : thrownType.getNormalized(), normalizedParameters);
143
+		return new FunctionHeader(typeParameters, returnType.getNormalized(), thrownType == null ? null : thrownType.getNormalized(), storage, normalizedParameters);
138 144
 	}
139 145
 	
140 146
 	public int getNumberOfTypeParameters() {
@@ -150,7 +156,7 @@ public class FunctionHeader {
150 156
 	}
151 157
 	
152 158
 	public FunctionHeader withReturnType(StoredType returnType) {
153
-		return new FunctionHeader(typeParameters, returnType, thrownType, parameters);
159
+		return new FunctionHeader(typeParameters, returnType, thrownType, storage, parameters);
154 160
 	}
155 161
 	
156 162
 	public FunctionHeader inferFromOverride(GlobalTypeRegistry registry, FunctionHeader overridden) {
@@ -172,7 +178,11 @@ public class FunctionHeader {
172 178
 			}
173 179
 		}
174 180
 		
175
-		return new FunctionHeader(resultTypeParameters, resultReturnType, resultThrownType, resultParameters);
181
+		StorageTag resultStorage = this.storage;
182
+		if (resultStorage == null)
183
+			resultStorage = overridden.storage;
184
+		
185
+		return new FunctionHeader(resultTypeParameters, resultReturnType, resultThrownType, resultStorage, resultParameters);
176 186
 	}
177 187
 	
178 188
 	public boolean matchesExactly(CallArguments arguments, TypeScope scope) {
@@ -382,7 +392,7 @@ public class FunctionHeader {
382 392
 		for (int i = 0; i < parameters.length; i++) {
383 393
 			parameters[i] = this.parameters[i].withGenericArguments(mapper);
384 394
 		}
385
-		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.instance(mapper), parameters);
395
+		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.instance(mapper), storage, parameters);
386 396
 	}
387 397
 	
388 398
 	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, TypeID[] arguments, GenericMapper typeParameterMapping) {
@@ -399,7 +409,7 @@ public class FunctionHeader {
399 409
 		for (int i = 0; i < parameters.length; i++) {
400 410
 			parameters[i] = this.parameters[i].withGenericArguments(mapper);
401 411
 		}
402
-		return new FunctionHeader(TypeParameter.NONE, returnType, thrownType == null ? null : thrownType.instance(mapper), parameters);
412
+		return new FunctionHeader(TypeParameter.NONE, returnType, thrownType == null ? null : thrownType.instance(mapper), storage, parameters);
403 413
 	}
404 414
 	
405 415
 	public FunctionHeader forTypeParameterInference() {
@@ -411,7 +421,7 @@ public class FunctionHeader {
411 421
 		for (int i = 0; i < lambdaHeader.parameters.length; i++)
412 422
 			parameters[i] = new FunctionParameter(this.parameters[i].type, lambdaHeader.parameters[i].name);
413 423
 		
414
-		return new FunctionHeader(typeParameters, returnType, thrownType, parameters);
424
+		return new FunctionHeader(typeParameters, returnType, thrownType, storage, parameters);
415 425
 	}
416 426
 	
417 427
 	public FunctionParameter getVariadicParameter() {

+ 15
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel;
7 7
 
8 8
 import java.util.ArrayList;
9
+import java.util.HashSet;
9 10
 import java.util.List;
11
+import java.util.Set;
10 12
 import org.openzen.zencode.shared.CodePosition;
11 13
 import org.openzen.zencode.shared.Taggable;
12 14
 import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
@@ -113,18 +115,30 @@ public abstract class HighLevelDefinition extends Taggable {
113 115
 	}
114 116
 	
115 117
 	public boolean isDestructible() {
118
+		Set<HighLevelDefinition> scanning = new HashSet<>();
119
+		return isDestructible(scanning);
120
+	}
121
+	
122
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
123
+		if (scanning.contains(this))
124
+			return false;
125
+		
126
+		scanning.add(this);
127
+		
116 128
 		boolean isDestructible = false;
117 129
 		for (IDefinitionMember member : members) {
118 130
 			if (member instanceof DestructorMember)
119 131
 				isDestructible = true;
120 132
 			if (member instanceof FieldMember) {
121 133
 				FieldMember field = (FieldMember)member;
122
-				if (!field.type.isDefinition(this) && field.type.isDestructible())
134
+				if (field.type.isDestructible(scanning))
123 135
 					isDestructible = true;
124 136
 			}
125 137
 			if ((member instanceof ImplementationMember) && ((ImplementationMember)member).type.isDestructible())
126 138
 				isDestructible = true;
127 139
 		}
140
+		
141
+		scanning.remove(this);
128 142
 		return isDestructible;
129 143
 	}
130 144
 	

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java Просмотреть файл

@@ -38,7 +38,7 @@ public class ConstructorMember extends FunctionalMember {
38 38
 				position,
39 39
 				definition,
40 40
 				modifiers,
41
-				new FunctionHeader(header.typeParameters, BasicTypeID.VOID.stored, header.thrownType, header.parameters),
41
+				new FunctionHeader(header.typeParameters, BasicTypeID.VOID.stored, header.thrownType, header.storage, header.parameters),
42 42
 				builtin);
43 43
 	}
44 44
 	

+ 5
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java Просмотреть файл

@@ -32,10 +32,14 @@ public class FunctionScope extends StatementScope {
32 32
 	private final BaseScope outer;
33 33
 	private final FunctionHeader header;
34 34
 	private final GenericMapper typeParameterMap;
35
+	private final StoredType thisType;
35 36
 	
36 37
 	public FunctionScope(BaseScope outer, FunctionHeader header) {
37 38
 		this.outer = outer;
38 39
 		this.header = header;
40
+		this.thisType = outer.getThisType() == null || header.storage == null ? outer.getThisType() : outer.getThisType().type.stored(header.storage);
41
+		if (header.storage != null)
42
+			System.out.println("Storage is " + header.storage);
39 43
 		
40 44
 		if (outer.getLocalTypeParameters() == null)
41 45
 			throw new NullPointerException();
@@ -105,7 +109,7 @@ public class FunctionScope extends StatementScope {
105 109
 
106 110
 	@Override
107 111
 	public StoredType getThisType() {
108
-		return outer.getThisType();
112
+		return thisType;
109 113
 	}
110 114
 
111 115
 	@Override

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 13
 
12 14
 /**
@@ -63,6 +65,11 @@ public class ArrayTypeID implements TypeID {
63 65
 		return elementType.type.isDestructible();
64 66
 	}
65 67
 	
68
+	@Override
69
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
70
+		return elementType.type.isDestructible(scanning);
71
+	}
72
+	
66 73
 	@Override
67 74
 	public ArrayTypeID instanceUnstored(GenericMapper mapper) {
68 75
 		return mapper.registry.getArray(elementType.instance(mapper), dimension);

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 13
 
12 14
 /**
@@ -65,6 +67,11 @@ public class AssocTypeID implements TypeID {
65 67
 		return keyType.isDestructible() || valueType.isDestructible();
66 68
 	}
67 69
 	
70
+	@Override
71
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
72
+		return keyType.isDestructible(scanning) || valueType.isDestructible(scanning);
73
+	}
74
+	
68 75
 	@Override
69 76
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
70 77
 		return keyType.hasInferenceBlockingTypeParameters(parameters) || valueType.hasInferenceBlockingTypeParameters(parameters);

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java Просмотреть файл

@@ -7,7 +7,9 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Collections;
9 9
 import java.util.List;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 14
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
13 15
 
@@ -83,6 +85,11 @@ public enum BasicTypeID implements TypeID {
83 85
 	public boolean isDestructible() {
84 86
 		return false;
85 87
 	}
88
+	
89
+	@Override
90
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
91
+		return false;
92
+	}
86 93
 
87 94
 	@Override
88 95
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java Просмотреть файл

@@ -10,6 +10,7 @@ import java.util.HashMap;
10 10
 import java.util.List;
11 11
 import java.util.Map;
12 12
 import java.util.Objects;
13
+import java.util.Set;
13 14
 import org.openzen.zenscript.codemodel.GenericMapper;
14 15
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15 16
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
@@ -187,6 +188,11 @@ public class DefinitionTypeID implements TypeID {
187 188
 		return definition.isDestructible();
188 189
 	}
189 190
 	
191
+	@Override
192
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
193
+		return definition.isDestructible(scanning);
194
+	}
195
+	
190 196
 	@Override
191 197
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
192 198
 		if (hasTypeParameters()) {

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java Просмотреть файл

@@ -7,9 +7,11 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Arrays;
9 9
 import java.util.List;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
11 12
 import org.openzen.zenscript.codemodel.FunctionParameter;
12 13
 import org.openzen.zenscript.codemodel.GenericMapper;
14
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 15
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 16
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
15 17
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
@@ -63,6 +65,11 @@ public class FunctionTypeID implements TypeID {
63 65
 	public boolean isDestructible() {
64 66
 		return false;
65 67
 	}
68
+	
69
+	@Override
70
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
71
+		return false;
72
+	}
66 73
 
67 74
 	@Override
68 75
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java Просмотреть файл

@@ -7,7 +7,9 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9 9
 import java.util.Objects;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 14
 
13 15
 /**
@@ -56,6 +58,11 @@ public class GenericMapTypeID implements TypeID {
56 58
 		return value.isDestructible();
57 59
 	}
58 60
 	
61
+	@Override
62
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
63
+		return value.isDestructible(scanning);
64
+	}
65
+	
59 66
 	@Override
60 67
 	public TypeID instanceUnstored(GenericMapper mapper) {
61 68
 		return mapper.registry.getGenericMap(value.instance(mapper), key);

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 13
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
12 14
 
@@ -60,6 +62,11 @@ public class GenericTypeID implements TypeID {
60 62
 		return false; // TODO: actually depends on the type..?
61 63
 	}
62 64
 	
65
+	@Override
66
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
67
+		return false; // TODO: actually depends on the type..?
68
+	}
69
+	
63 70
 	@Override
64 71
 	public boolean isGeneric() {
65 72
 		return true;

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/InvalidTypeID.java Просмотреть файл

@@ -6,9 +6,11 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zencode.shared.CodePosition;
10 11
 import org.openzen.zencode.shared.CompileExceptionCode;
11 12
 import org.openzen.zenscript.codemodel.GenericMapper;
13
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 15
 
14 16
 /**
@@ -50,6 +52,11 @@ public class InvalidTypeID implements TypeID {
50 52
 	public boolean isDestructible() {
51 53
 		return false;
52 54
 	}
55
+	
56
+	@Override
57
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
58
+		return false;
59
+	}
53 60
 
54 61
 	@Override
55 62
 	public TypeID getNormalizedUnstored() {

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java Просмотреть файл

@@ -7,7 +7,9 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Arrays;
9 9
 import java.util.List;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 14
 
13 15
 /**
@@ -69,6 +71,11 @@ public class IteratorTypeID implements TypeID {
69 71
 		return false;
70 72
 	}
71 73
 	
74
+	@Override
75
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
76
+		return false;
77
+	}
78
+	
72 79
 	@Override
73 80
 	public TypeID instanceUnstored(GenericMapper mapper) {
74 81
 		StoredType[] instanced = mapper.map(iteratorTypes);

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ModifiedTypeID.java Просмотреть файл

@@ -7,7 +7,9 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9 9
 import java.util.Objects;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 14
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
13 15
 
@@ -73,6 +75,11 @@ public class ModifiedTypeID implements TypeID {
73 75
 		return baseType.isDestructible();
74 76
 	}
75 77
 	
78
+	@Override
79
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
80
+		return baseType.isDestructible(scanning);
81
+	}
82
+	
76 83
 	@Override
77 84
 	public TypeID withoutOptional() {
78 85
 		return without(MODIFIER_OPTIONAL);

+ 8
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 13
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
12 14
 
@@ -66,7 +68,12 @@ public class RangeTypeID implements TypeID {
66 68
 	
67 69
 	@Override
68 70
 	public boolean isDestructible() {
69
-		return false;
71
+		return baseType.isDestructible();
72
+	}
73
+	
74
+	@Override
75
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
76
+		return baseType.isDestructible(scanning);
70 77
 	}
71 78
 
72 79
 	@Override

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java Просмотреть файл

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Map;
9 9
 import java.util.Objects;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
@@ -46,6 +47,10 @@ public class StoredType {
46 47
 		return type.isDestructible() && storage.isDestructible();
47 48
 	}
48 49
 	
50
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
51
+		return type.isDestructible(scanning) && storage.isDestructible();
52
+	}
53
+	
49 54
 	public boolean hasDefaultValue() {
50 55
 		return type.hasDefaultValue();
51 56
 	}

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java Просмотреть файл

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Set;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 13
 import org.openzen.zenscript.codemodel.type.storage.AnyStorageTag;
12 14
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
@@ -53,6 +55,11 @@ public class StringTypeID implements TypeID {
53 55
 	public boolean isDestructible() {
54 56
 		return false;
55 57
 	}
58
+	
59
+	@Override
60
+	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
61
+		return false;
62
+	}
56 63
 
57 64
 	@Override
58 65
 	public TypeID instanceUnstored(GenericMapper mapper) {

+ 3
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java Просмотреть файл

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.List;
9 9
 import java.util.Map;
10
+import java.util.Set;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
@@ -31,6 +32,8 @@ public interface TypeID {
31 32
 	
32 33
 	boolean isDestructible();
33 34
 	
35
+	boolean isDestructible(Set<HighLevelDefinition> scanning);
36
+	
34 37
 	boolean hasDefaultValue();
35 38
 	
36 39
 	boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters);

+ 5
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java Просмотреть файл

@@ -291,6 +291,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
291 291
 					new TypeParameter[] { mappedConstructorParameter },
292 292
 					VOID.stored,
293 293
 					null,
294
+					null,
294 295
 					new FunctionParameter(registry.getArray(registry.getGeneric(mappedConstructorParameter).stored(BorrowStorageTag.INVOCATION), dimension).stored(BorrowStorageTag.INVOCATION), "original"),
295 296
 					new FunctionParameter(registry.getFunction(mappedConstructorHeaderWithoutIndex).stored(BorrowStorageTag.INVOCATION), "projection"));
296 297
 			members.addConstructor(new ConstructorMember(
@@ -313,6 +314,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
313 314
 					new TypeParameter[] { mappedConstructorParameter },
314 315
 					VOID.stored,
315 316
 					null,
317
+					null,
316 318
 					new FunctionParameter(registry.getArray(registry.getGeneric(mappedConstructorParameter).stored(BorrowStorageTag.INVOCATION), dimension).stored(BorrowStorageTag.INVOCATION), "original"),
317 319
 					new FunctionParameter(registry.getFunction(mappedConstructorHeaderWithIndex).stored(BorrowStorageTag.INVOCATION), "projection"));
318 320
 			constructor(definition, ARRAY_CONSTRUCTOR_PROJECTED_INDEXED, mappedConstructorFunctionWithIndex);
@@ -388,9 +390,9 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
388 390
 		Map<TypeParameter, TypeID> parameterFilled = Collections.singletonMap(map.key, registry.getGeneric(functionParameter));
389 391
 		StoredType valueType = map.value.instance(new GenericMapper(registry, parameterFilled));
390 392
 		
391
-		FunctionHeader getOptionalHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, registry.getOptional(valueType.type).stored(valueType.storage), null, new FunctionParameter[0]);
392
-		FunctionHeader putHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, VOID.stored, null, new FunctionParameter(valueType));
393
-		FunctionHeader containsHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BOOL.stored, null, new FunctionParameter[0]);
393
+		FunctionHeader getOptionalHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, registry.getOptional(valueType.type).stored(valueType.storage), null, null, new FunctionParameter[0]);
394
+		FunctionHeader putHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, VOID.stored, null, null, new FunctionParameter(valueType));
395
+		FunctionHeader containsHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BOOL.stored, null, null, new FunctionParameter[0]);
394 396
 		
395 397
 		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
396 398
 		constructor(builtin, GENERICMAP_CONSTRUCTOR);

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java Просмотреть файл

@@ -492,8 +492,8 @@ public final class TypeMembers {
492 492
 				return castEquivalent(position, caster.member.cast(position, value, implicit), toType);
493 493
 		}
494 494
 		for (TypeMember<ImplementationMemberRef> implementation : implementations) {
495
-			if (implementation.member.implementsType.equals(toType))
496
-				return new InterfaceCastExpression(position, value, toType);
495
+			if (implementation.member.implementsType.equals(toType.type))
496
+				return castEquivalent(position, new InterfaceCastExpression(position, value, toType.type.stored(type.storage)), toType);
497 497
 		}
498 498
 		if (extendsType(toType.type))
499 499
 			return new SupertypeCastExpression(position, value, toType);

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageType.java Просмотреть файл

@@ -25,7 +25,7 @@ public class AnyStorageType implements StorageType {
25 25
 
26 26
 	@Override
27 27
 	public StorageTag instance(CodePosition position, String[] arguments) {
28
-		if (arguments != null)
28
+		if (arguments.length > 0)
29 29
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "any storage type doesn't take arguments");
30 30
 		
31 31
 		return AnyStorageTag.INSTANCE;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageType.java Просмотреть файл

@@ -24,7 +24,7 @@ public class BorrowStorageType implements StorageType {
24 24
 
25 25
 	@Override
26 26
 	public StorageTag instance(CodePosition position, String[] arguments) {
27
-		if (arguments != null) {
27
+		if (arguments.length > 0) {
28 28
 			if (arguments.length == 1 && arguments[0].equals("this"))
29 29
 				return BorrowStorageTag.THIS;
30 30
 			

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/InvalidStorageTag.java Просмотреть файл

@@ -42,4 +42,9 @@ public class InvalidStorageTag implements StorageTag {
42 42
 	public boolean isDestructible() {
43 43
 		return false;
44 44
 	}
45
+	
46
+	@Override
47
+	public String toString() {
48
+		return "invalid";
49
+	}
45 50
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageType.java Просмотреть файл

@@ -24,7 +24,7 @@ public class SharedStorageType implements StorageType {
24 24
 
25 25
 	@Override
26 26
 	public StorageTag instance(CodePosition position, String[] arguments) {
27
-		if (arguments != null)
27
+		if (arguments.length > 0)
28 28
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "shared storage type doesn't take arguments");
29 29
 		
30 30
 		return SharedStorageTag.INSTANCE;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageType.java Просмотреть файл

@@ -24,7 +24,7 @@ public class StaticStorageType implements StorageType {
24 24
 
25 25
 	@Override
26 26
 	public StorageTag instance(CodePosition position, String[] arguments) {
27
-		if (arguments != null)
27
+		if (arguments.length > 0)
28 28
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "static storage type doesn't take arguments");
29 29
 		
30 30
 		return StaticStorageTag.INSTANCE;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageType.java Просмотреть файл

@@ -24,7 +24,7 @@ public class UniqueStorageType implements StorageType {
24 24
 
25 25
 	@Override
26 26
 	public StorageTag instance(CodePosition position, String[] arguments) {
27
-		if (arguments != null)
27
+		if (arguments.length > 0)
28 28
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "unique storage type doesn't take arguments");
29 29
 		
30 30
 		return UniqueStorageTag.INSTANCE;

+ 19
- 5
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunctionHeader.java Просмотреть файл

@@ -8,12 +8,14 @@ package org.openzen.zenscript.parser.definitions;
8 8
 import java.util.ArrayList;
9 9
 import java.util.Collections;
10 10
 import java.util.List;
11
+import org.openzen.zencode.shared.CodePosition;
11 12
 import org.openzen.zenscript.codemodel.FunctionHeader;
12 13
 import org.openzen.zenscript.codemodel.FunctionParameter;
13 14
 import org.openzen.zenscript.codemodel.context.LocalTypeResolutionContext;
14 15
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
15 16
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
16 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17 19
 import org.openzen.zenscript.lexer.ParseException;
18 20
 import org.openzen.zenscript.lexer.ZSToken;
19 21
 import org.openzen.zenscript.lexer.ZSTokenParser;
@@ -22,6 +24,7 @@ import static org.openzen.zenscript.lexer.ZSTokenType.*;
22 24
 import org.openzen.zenscript.parser.ParsedAnnotation;
23 25
 import org.openzen.zenscript.parser.expression.ParsedExpression;
24 26
 import org.openzen.zenscript.parser.type.IParsedType;
27
+import org.openzen.zenscript.parser.type.ParsedStorageTag;
25 28
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
26 29
 
27 30
 /**
@@ -30,6 +33,10 @@ import org.openzen.zenscript.parser.type.ParsedTypeBasic;
30 33
  */
31 34
 public class ParsedFunctionHeader {
32 35
 	public static ParsedFunctionHeader parse(ZSTokenParser tokens) throws ParseException {
36
+		CodePosition position = tokens.getPosition();
37
+		
38
+		ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
39
+		
33 40
 		List<ParsedTypeParameter> genericParameters = null;
34 41
 		if (tokens.optional(ZSTokenType.T_LESS) != null) {
35 42
 			genericParameters = new ArrayList<>();
@@ -71,26 +78,32 @@ public class ParsedFunctionHeader {
71 78
 			thrownType = IParsedType.parse(tokens);
72 79
 		}
73 80
 		
74
-		return new ParsedFunctionHeader(genericParameters, parameters, returnType, thrownType);
81
+		return new ParsedFunctionHeader(position, genericParameters, parameters, returnType, thrownType, storage);
75 82
 	}
76 83
 	
84
+	public final CodePosition position;
77 85
 	public final List<ParsedTypeParameter> genericParameters;
78 86
 	public final List<ParsedFunctionParameter> parameters;
79 87
 	public final IParsedType returnType;
80 88
 	public final IParsedType thrownType;
89
+	public final ParsedStorageTag storage;
81 90
 	
82
-	public ParsedFunctionHeader(List<ParsedFunctionParameter> parameters, IParsedType returnType, IParsedType thrownType) {
91
+	public ParsedFunctionHeader(CodePosition position, List<ParsedFunctionParameter> parameters, IParsedType returnType) {
92
+		this.position = position;
83 93
 		this.genericParameters = Collections.emptyList();
84 94
 		this.parameters = parameters;
85 95
 		this.returnType = returnType;
86
-		this.thrownType = thrownType;
96
+		this.thrownType = null;
97
+		this.storage = ParsedStorageTag.NULL;
87 98
 	}
88 99
 	
89
-	public ParsedFunctionHeader(List<ParsedTypeParameter> genericParameters, List<ParsedFunctionParameter> parameters, IParsedType returnType, IParsedType thrownType) {
100
+	public ParsedFunctionHeader(CodePosition position, List<ParsedTypeParameter> genericParameters, List<ParsedFunctionParameter> parameters, IParsedType returnType, IParsedType thrownType, ParsedStorageTag storage) {
101
+		this.position = position;
90 102
 		this.genericParameters = genericParameters;
91 103
 		this.parameters = parameters;
92 104
 		this.returnType = returnType;
93 105
 		this.thrownType = thrownType;
106
+		this.storage = storage;
94 107
 	}
95 108
 	
96 109
 	public FunctionHeader compile(TypeResolutionContext context) {
@@ -103,6 +116,7 @@ public class ParsedFunctionHeader {
103 116
 		for (int i = 0; i < parameters.length; i++)
104 117
 			parameters[i] = this.parameters.get(i).compile(localContext);
105 118
 		
106
-		return new FunctionHeader(genericParameters, returnType, thrownType == null ? null : thrownType.compile(context), parameters);
119
+		StorageTag storage = this.storage.resolve(position, context);
120
+		return new FunctionHeader(genericParameters, returnType, thrownType == null ? null : thrownType.compile(context), storage, parameters);
107 121
 	}
108 122
 }

+ 6
- 3
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java Просмотреть файл

@@ -434,12 +434,15 @@ public abstract class ParsedExpression {
434 434
 						position,
435 435
 						parser.next().content);
436 436
 			case T_STRING_SQ:
437
-			case T_STRING_DQ:
437
+			case T_STRING_DQ: {
438
+				String quoted = parser.next().content;
438 439
 				return new ParsedExpressionString(
439 440
 						position,
440
-						StringExpansion.unescape(parser.next().content).orElse(error -> {
441
+						StringExpansion.unescape(quoted).orElse(error -> {
441 442
 							return "INVALID_STRING";
442
-						}));
443
+						}),
444
+						quoted.charAt(0) == '\'');
445
+			}
443 446
 			case T_IDENTIFIER: {
444 447
 				String name = parser.next().content;
445 448
 				List<IParsedType> genericParameters = IParsedType.parseTypeArguments(parser);

+ 2
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionBracket.java Просмотреть файл

@@ -15,6 +15,7 @@ import org.openzen.zenscript.codemodel.scope.ExpressionScope;
15 15
 import org.openzen.zenscript.lexer.ParseException;
16 16
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
17 17
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
18
+import org.openzen.zenscript.parser.type.ParsedStorageTag;
18 19
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
19 20
 
20 21
 /**
@@ -45,7 +46,7 @@ public class ParsedExpressionBracket extends ParsedExpression {
45 46
 		for (ParsedExpression expression : expressions)
46 47
 			parameters.add(expression.toLambdaParameter());
47 48
 		
48
-		return new ParsedFunctionHeader(parameters, ParsedTypeBasic.UNDETERMINED, null);
49
+		return new ParsedFunctionHeader(position, parameters, ParsedTypeBasic.UNDETERMINED);
49 50
 	}
50 51
 
51 52
 	@Override

+ 2
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionCast.java Просмотреть файл

@@ -16,6 +16,7 @@ import org.openzen.zenscript.parser.ParsedAnnotation;
16 16
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
17 17
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
18 18
 import org.openzen.zenscript.parser.type.IParsedType;
19
+import org.openzen.zenscript.parser.type.ParsedStorageTag;
19 20
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
20 21
 
21 22
 /**
@@ -52,7 +53,7 @@ public class ParsedExpressionCast extends ParsedExpression {
52 53
 		if (header.returnType != ParsedTypeBasic.UNDETERMINED)
53 54
 			throw new ParseException(position, "Lambda parameter already has a return type");
54 55
 		
55
-		return new ParsedFunctionHeader(header.genericParameters, header.parameters, type, null);
56
+		return new ParsedFunctionHeader(position, header.genericParameters, header.parameters, type, null, ParsedStorageTag.NULL);
56 57
 	}
57 58
 	
58 59
 	@Override

+ 4
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionString.java Просмотреть файл

@@ -25,16 +25,18 @@ import org.openzen.zenscript.codemodel.type.StringTypeID;
25 25
  */
26 26
 public class ParsedExpressionString extends ParsedExpression {
27 27
 	public final String value;
28
+	public final boolean singleQuote;
28 29
 	
29
-	public ParsedExpressionString(CodePosition position, String value) {
30
+	public ParsedExpressionString(CodePosition position, String value, boolean singleQuote) {
30 31
 		super(position);
31 32
 		
32 33
 		this.value = value;
34
+		this.singleQuote = singleQuote;
33 35
 	}
34 36
 
35 37
 	@Override
36 38
 	public IPartialExpression compile(ExpressionScope scope) {
37
-		if (value.length() == 1 && scope.hints.contains(BasicTypeID.CHAR.stored))
39
+		if (value.length() == 1 && (singleQuote || scope.hints.contains(BasicTypeID.CHAR.stored)))
38 40
 			return new ConstantCharExpression(position, value.charAt(0));
39 41
 		
40 42
 		return new ConstantStringExpression(position, value);

+ 2
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java Просмотреть файл

@@ -30,6 +30,7 @@ import org.openzen.zenscript.parser.ParsedAnnotation;
30 30
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
31 31
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
32 32
 import org.openzen.zenscript.parser.type.IParsedType;
33
+import org.openzen.zenscript.parser.type.ParsedStorageTag;
33 34
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
34 35
 
35 36
 /**
@@ -105,7 +106,7 @@ public class ParsedExpressionVariable extends ParsedExpression {
105 106
 	
106 107
 	@Override
107 108
 	public ParsedFunctionHeader toLambdaHeader() {
108
-		return new ParsedFunctionHeader(Collections.singletonList(toLambdaParameter()), ParsedTypeBasic.UNDETERMINED, null);
109
+		return new ParsedFunctionHeader(position, Collections.singletonList(toLambdaParameter()), ParsedTypeBasic.UNDETERMINED);
109 110
 	}
110 111
 	
111 112
 	@Override

+ 3
- 10
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java Просмотреть файл

@@ -27,16 +27,9 @@ public class ParsedStorageTag {
27 27
 			return NULL;
28 28
 		
29 29
 		String name = parser.required(ZSTokenType.T_IDENTIFIER, "identifier expected").content;
30
-		List<String> arguments = null;
31
-		if (parser.optional(ZSTokenType.T_BROPEN) != null) {
32
-			arguments = new ArrayList<>();
33
-			if (parser.optional(ZSTokenType.T_BRCLOSE) == null) {
34
-				do {
35
-					arguments.add(parser.required(ZSTokenType.T_IDENTIFIER, "identifier expected").content);
36
-				} while (parser.optional(ZSTokenType.T_COMMA) == null);
37
-				parser.required(ZSTokenType.T_BRCLOSE, ") expected");
38
-			}
39
-		}
30
+		List<String> arguments = new ArrayList<>();
31
+		while (parser.optional(ZSTokenType.T_COLON) != null)
32
+			arguments.add(parser.next().content);
40 33
 		
41 34
 		return new ParsedStorageTag(name, arguments.toArray(new String[arguments.size()]));
42 35
 	}

+ 6
- 0
Validator/src/main/java/org/openzen/zenscript/validator/visitors/ValidationUtils.java Просмотреть файл

@@ -28,6 +28,7 @@ import static org.openzen.zenscript.validator.ValidationLogEntry.Code.*;
28 28
 import org.openzen.zenscript.validator.Validator;
29 29
 import org.openzen.zenscript.validator.analysis.ExpressionScope;
30 30
 import org.openzen.zenscript.codemodel.type.TypeID;
31
+import org.openzen.zenscript.codemodel.type.storage.InvalidStorageTag;
31 32
 
32 33
 /**
33 34
  *
@@ -53,6 +54,11 @@ public class ValidationUtils {
53 54
 		TypeValidator typeValidator = new TypeValidator(target, position);
54 55
 		typeValidator.validate(header.getReturnType());
55 56
 		
57
+		if (header.storage instanceof InvalidStorageTag) {
58
+			InvalidStorageTag invalid = (InvalidStorageTag)header.storage;
59
+			target.logError(INVALID_TYPE, invalid.position, invalid.message);
60
+		}
61
+		
56 62
 		Set<String> parameterNames = new HashSet<>();
57 63
 		int i = 0;
58 64
 		for (FunctionParameter parameter : header.parameters) {

Загрузка…
Отмена
Сохранить