Browse Source

Removed TypeArgument and simplified type system a little

Stan Hebben 6 years ago
parent
commit
92234bca0e
100 changed files with 493 additions and 987 deletions
  1. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java
  2. 5
    19
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java
  3. 9
    10
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  4. 12
    14
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java
  5. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeContext.java
  6. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java
  7. 8
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java
  8. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  9. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  10. 2
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  11. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinition.java
  12. 1
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/IPartialExpression.java
  13. 3
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialGlobalExpression.java
  14. 4
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java
  15. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialPackageExpression.java
  16. 4
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  17. 3
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java
  18. 2
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialVariantOptionExpression.java
  19. 4
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java
  20. 3
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java
  21. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java
  22. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java
  23. 3
    10
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  24. 18
    23
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  25. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java
  26. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java
  27. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericName.java
  28. 5
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java
  29. 8
    26
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GlobalTypeRegistry.java
  30. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ISymbol.java
  31. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/InvalidTypeID.java
  32. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java
  33. 13
    59
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java
  34. 3
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java
  35. 56
    47
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java
  36. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java
  37. 0
    111
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeArgument.java
  38. 4
    25
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java
  39. 14
    18
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeMatcher.java
  40. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java
  41. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeSymbol.java
  42. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java
  43. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitorWithContext.java
  44. 23
    20
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  45. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java
  46. 7
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  47. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageTag.java
  48. 52
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/MutableStorageTag.java
  49. 36
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/MutableStorageType.java
  50. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageTag.java
  51. 1
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java
  52. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/ValueStorageTag.java
  53. 1
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaBoxingTypeVisitor.java
  54. 2
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  55. 2
    6
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaSyntheticTypeSignatureConverter.java
  56. 2
    5
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeDescriptorVisitor.java
  57. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeGenericVisitor.java
  58. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInfo.java
  59. 1
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInternalNameVisitor.java
  60. 2
    6
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeNameVisitor.java
  61. 1
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeUtils.java
  62. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java
  63. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java
  64. 4
    5
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java
  65. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticHelperGenerator.java
  66. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java
  67. 0
    5
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceStatementScope.java
  68. 5
    5
      ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/CodeReader.java
  69. 2
    2
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/TypeSerializer.java
  70. 5
    5
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedAnnotation.java
  71. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java
  72. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnumConstant.java
  73. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java
  74. 12
    13
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedCallArguments.java
  75. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionCoalesce.java
  76. 1
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFloat.java
  77. 2
    3
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java
  78. 1
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionIndex.java
  79. 1
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionInt.java
  80. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionMember.java
  81. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionRange.java
  82. 1
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java
  83. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryConvertExpression.java
  84. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryRethrowExpression.java
  85. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedSetter.java
  86. 9
    30
      Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java
  87. 3
    31
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java
  88. 7
    70
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java
  89. 0
    51
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedOptionalBasicType.java
  90. 33
    0
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedOptionalType.java
  91. 2
    25
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedString.java
  92. 2
    36
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeArray.java
  93. 2
    37
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeAssociative.java
  94. 0
    16
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeBasic.java
  95. 3
    28
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java
  96. 3
    34
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeRange.java
  97. 3
    3
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java
  98. 1
    1
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/ExpressionValidator.java
  99. 3
    3
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/SupertypeValidator.java
  100. 0
    0
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/TypeValidator.java

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java View File

@@ -30,7 +30,7 @@ import org.openzen.zenscript.codemodel.statement.TryCatchStatement;
30 30
 import org.openzen.zenscript.codemodel.statement.VarStatement;
31 31
 import org.openzen.zenscript.codemodel.statement.WhileStatement;
32 32
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
33
-import org.openzen.zenscript.codemodel.type.TypeArgument;
33
+import org.openzen.zenscript.codemodel.type.StoredType;
34 34
 
35 35
 /**
36 36
  *
@@ -128,7 +128,7 @@ public class FormattingUtils {
128 128
 			result.append("<");
129 129
 			
130 130
 			int index = 0;
131
-			for (TypeArgument typeArgument : arguments.typeArguments) {
131
+			for (StoredType typeArgument : arguments.typeArguments) {
132 132
 				if (index > 0)
133 133
 					result.append(", ");
134 134
 				result.append(typeFormatter.format(typeArgument));

+ 5
- 19
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
16
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
19 19
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -22,7 +22,6 @@ import org.openzen.zenscript.codemodel.type.IteratorTypeID;
22 22
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
23 23
 import org.openzen.zenscript.codemodel.type.StoredType;
24 24
 import org.openzen.zenscript.codemodel.type.StringTypeID;
25
-import org.openzen.zenscript.codemodel.type.TypeArgument;
26 25
 import org.openzen.zenscript.codemodel.type.TypeID;
27 26
 import stdlib.Chars;
28 27
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
@@ -44,12 +43,8 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
44 43
 		return type.accept(this);
45 44
 	}
46 45
 	
47
-	public String format(TypeArgument type) {
48
-		return type.storage == null ? format(type.type) : format(type.stored());
49
-	}
50
-	
51 46
 	public String format(StoredType type) {
52
-		return type.type.accept(this) + "`" + type.storage.toString();
47
+		return type.type.accept(this) + (type.getSpecifiedStorage() == null ? "" : "`" + type.getSpecifiedStorage().toString());
53 48
 	}
54 49
 
55 50
 	@Override
@@ -102,7 +97,7 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
102 97
 		result.append(importedName);
103 98
 		result.append("<");
104 99
 		int index = 0;
105
-		for (TypeArgument typeParameter : definition.typeArguments) {
100
+		for (StoredType typeParameter : definition.typeArguments) {
106 101
 			if (index > 0)
107 102
 				result.append(", ");
108 103
 			
@@ -123,17 +118,8 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
123 118
 	}
124 119
 
125 120
 	@Override
126
-	public String visitModified(ModifiedTypeID type) {
127
-		StringBuilder result = new StringBuilder();
128
-		if (type.isConst())
129
-			result.append("const ");
130
-		if (type.isImmutable())
131
-			result.append("immutable ");
132
-		result.append(type.accept(this));
133
-		if (type.isOptional())
134
-			result.append("?");
135
-		
136
-		return result.toString();
121
+	public String visitOptional(OptionalTypeID type) {
122
+		return type.accept(this) + "?";
137 123
 	}
138 124
 
139 125
 	@Override

+ 9
- 10
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

@@ -16,7 +16,6 @@ import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17 17
 import org.openzen.zenscript.codemodel.scope.TypeScope;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.TypeArgument;
20 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
21 20
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
22 21
 
@@ -232,14 +231,14 @@ public class FunctionHeader {
232 231
 		return result.toString();
233 232
 	}
234 233
 	
235
-	public TypeArgument[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<StoredType> resultHint) {
234
+	public StoredType[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<StoredType> resultHint) {
236 235
 		if (arguments.arguments.length != this.parameters.length)
237 236
 			return null;
238 237
 		
239
-		Map<TypeParameter, TypeArgument> mapping = new HashMap<>();
238
+		Map<TypeParameter, StoredType> mapping = new HashMap<>();
240 239
 		if (!resultHint.isEmpty()) {
241 240
 			for (StoredType hint : resultHint) {
242
-				Map<TypeParameter, TypeArgument> temp = returnType.inferTypeParameters(cache, hint.asArgument());
241
+				Map<TypeParameter, StoredType> temp = returnType.inferTypeParameters(cache, hint);
243 242
 				if (temp != null) {
244 243
 					mapping = temp;
245 244
 					break;
@@ -249,7 +248,7 @@ public class FunctionHeader {
249 248
 		
250 249
 		// TODO: lambda header inference
251 250
 		for (int i = 0; i < parameters.length; i++) {
252
-			Map<TypeParameter, TypeArgument> forParameter = parameters[i].type.inferTypeParameters(cache, arguments.arguments[i].type.asArgument());
251
+			Map<TypeParameter, StoredType> forParameter = parameters[i].type.inferTypeParameters(cache, arguments.arguments[i].type);
253 252
 			if (forParameter == null)
254 253
 				return null;
255 254
 			
@@ -259,7 +258,7 @@ public class FunctionHeader {
259 258
 		if (mapping.size() > typeParameters.length)
260 259
 			return null;
261 260
 		
262
-		TypeArgument[] result = new TypeArgument[typeParameters.length];
261
+		StoredType[] result = new StoredType[typeParameters.length];
263 262
 		for (int i = 0; i < typeParameters.length; i++) {
264 263
 			TypeParameter typeParameter = typeParameters[i];
265 264
 			if (!mapping.containsKey(typeParameter)) {
@@ -366,7 +365,7 @@ public class FunctionHeader {
366 365
 	
367 366
 	public FunctionHeader instanceForCall(GlobalTypeRegistry registry, CallArguments arguments) {
368 367
 		if (arguments.getNumberOfTypeArguments() > 0) {
369
-			Map<TypeParameter, TypeArgument> typeParameters = TypeArgument.getMapping(this.typeParameters, arguments.typeArguments);
368
+			Map<TypeParameter, StoredType> typeParameters = StoredType.getMapping(this.typeParameters, arguments.typeArguments);
370 369
 			return withGenericArguments(
371 370
 					registry,
372 371
 					new GenericMapper(registry, typeParameters));
@@ -377,7 +376,7 @@ public class FunctionHeader {
377 376
 	
378 377
 	public FunctionHeader withGenericArguments(GlobalTypeRegistry registry, GenericMapper mapper) {
379 378
 		if (typeParameters.length > 0)
380
-			mapper = mapper.getInner(registry, TypeArgument.getSelfMapping(registry, typeParameters));
379
+			mapper = mapper.getInner(registry, StoredType.getSelfMapping(registry, typeParameters));
381 380
 		
382 381
 		StoredType returnType = this.returnType.instance(mapper);
383 382
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
@@ -387,11 +386,11 @@ public class FunctionHeader {
387 386
 		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.instance(mapper), storage, parameters);
388 387
 	}
389 388
 	
390
-	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, TypeArgument[] arguments, GenericMapper typeParameterMapping) {
389
+	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, StoredType[] arguments, GenericMapper typeParameterMapping) {
391 390
 		if (arguments == null || arguments.length == 0)
392 391
 			return this;
393 392
 		
394
-		Map<TypeParameter, TypeArgument> typeArguments = TypeArgument.getMapping(typeParameters, arguments);
393
+		Map<TypeParameter, StoredType> typeArguments = StoredType.getMapping(typeParameters, arguments);
395 394
 		GenericMapper mapper = typeParameterMapping.getInner(registry, typeArguments);
396 395
 		
397 396
 		StoredType returnType = this.returnType.instance(mapper);

+ 12
- 14
CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java View File

@@ -13,8 +13,6 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 15
 import org.openzen.zenscript.codemodel.type.StoredType;
16
-import org.openzen.zenscript.codemodel.type.TypeArgument;
17
-import org.openzen.zenscript.codemodel.type.TypeID;
18 16
 
19 17
 /**
20 18
  *
@@ -24,19 +22,19 @@ public class GenericMapper {
24 22
 	public static final GenericMapper EMPTY = new GenericMapper(null, Collections.emptyMap());
25 23
 	
26 24
 	public final GlobalTypeRegistry registry;
27
-	private final Map<TypeParameter, TypeArgument> mapping;
25
+	private final Map<TypeParameter, StoredType> mapping;
28 26
 	
29
-	public GenericMapper(GlobalTypeRegistry registry, Map<TypeParameter, TypeArgument> mapping) {
27
+	public GenericMapper(GlobalTypeRegistry registry, Map<TypeParameter, StoredType> mapping) {
30 28
 		this.registry = registry;
31 29
 		this.mapping = mapping;
32 30
 	}
33 31
 	
34
-	public Map<TypeParameter, TypeArgument> getMapping() {
32
+	public Map<TypeParameter, StoredType> getMapping() {
35 33
 		return mapping;
36 34
 	}
37 35
 	
38
-	public TypeArgument map(CodePosition position, TypeArgument original) {
39
-		return mapping.isEmpty() ? original : original.instance(position, this, original.storage);
36
+	public StoredType map(CodePosition position, StoredType original) {
37
+		return mapping.isEmpty() ? original : original.instance(this);
40 38
 	}
41 39
 	
42 40
 	public StoredType[] map(StoredType[] original) {
@@ -49,27 +47,27 @@ public class GenericMapper {
49 47
 		return mapped;
50 48
 	}
51 49
 	
52
-	public TypeArgument map(GenericTypeID type) {
50
+	public StoredType map(GenericTypeID type) {
53 51
 		if (!mapping.containsKey(type.parameter))
54 52
 			throw new IllegalStateException("No mapping found for type " + type);
55 53
 		
56
-		return mapping.containsKey(type.parameter) ? mapping.get(type.parameter) : new TypeArgument(type, null);
54
+		return mapping.containsKey(type.parameter) ? mapping.get(type.parameter) : type.stored();
57 55
 	}
58 56
 	
59 57
 	public FunctionHeader map(FunctionHeader original) {
60 58
 		return mapping.isEmpty() ? original : original.withGenericArguments(registry, this);
61 59
 	}
62 60
 	
63
-	public GenericMapper getInner(GlobalTypeRegistry registry, Map<TypeParameter, TypeArgument> mapping) {
64
-		Map<TypeParameter, TypeArgument> resultMap = new HashMap<>(this.mapping);
61
+	public GenericMapper getInner(GlobalTypeRegistry registry, Map<TypeParameter, StoredType> mapping) {
62
+		Map<TypeParameter, StoredType> resultMap = new HashMap<>(this.mapping);
65 63
 		resultMap.putAll(mapping);
66 64
 		return new GenericMapper(registry, resultMap);
67 65
 	}
68 66
 	
69 67
 	public GenericMapper getInner(GlobalTypeRegistry registry, TypeParameter[] parameters) {
70
-		Map<TypeParameter, TypeArgument> resultMap = new HashMap<>(this.mapping);
68
+		Map<TypeParameter, StoredType> resultMap = new HashMap<>(this.mapping);
71 69
 		for (TypeParameter parameter : parameters)
72
-			resultMap.put(parameter, new TypeArgument(registry.getGeneric(parameter), null));
70
+			resultMap.put(parameter, new StoredType(registry.getGeneric(parameter), null));
73 71
 		return new GenericMapper(registry, resultMap);
74 72
 	}
75 73
 	
@@ -81,7 +79,7 @@ public class GenericMapper {
81 79
 		StringBuilder result = new StringBuilder();
82 80
 		result.append('{');
83 81
 		boolean first = true;
84
-		for (Map.Entry<TypeParameter, TypeArgument> entry : mapping.entrySet()) {
82
+		for (Map.Entry<TypeParameter, StoredType> entry : mapping.entrySet()) {
85 83
 			if (first) {
86 84
 				first = false;
87 85
 			} else {

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeContext.java View File

@@ -11,7 +11,6 @@ import java.util.Map;
11 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.type.StoredType;
14
-import org.openzen.zenscript.codemodel.type.TypeArgument;
15 14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
16 15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17 16
 
@@ -60,7 +59,7 @@ public class TypeContext {
60 59
 	}
61 60
 	
62 61
 	public GenericMapper getMapper() {
63
-		Map<TypeParameter, TypeArgument> mapper = TypeArgument.getSelfMapping(moduleContext.registry, typeParameters);
62
+		Map<TypeParameter, StoredType> mapper = StoredType.getSelfMapping(moduleContext.registry, typeParameters);
64 63
 		return new GenericMapper(moduleContext.registry, mapper);
65 64
 	}
66 65
 	

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java View File

@@ -8,14 +8,14 @@ package org.openzen.zenscript.codemodel.definition;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 10
 import org.openzen.zenscript.codemodel.Module;
11
-import org.openzen.zenscript.codemodel.type.TypeArgument;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
12 12
 
13 13
 /**
14 14
  *
15 15
  * @author Hoofdgebruiker
16 16
  */
17 17
 public class ExpansionDefinition extends HighLevelDefinition {
18
-	public TypeArgument target;
18
+	public StoredType target;
19 19
 	
20 20
 	public ExpansionDefinition(CodePosition position, Module module, ZSPackage pkg, int modifiers, HighLevelDefinition outerDefinition) {
21 21
 		super(position, module, pkg, null, modifiers, outerDefinition);

+ 8
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java View File

@@ -10,7 +10,7 @@ import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zencode.shared.CompileExceptionCode;
11 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12 12
 import org.openzen.zenscript.codemodel.scope.TypeScope;
13
-import org.openzen.zenscript.codemodel.type.TypeArgument;
13
+import org.openzen.zenscript.codemodel.type.StoredType;
14 14
 
15 15
 /**
16 16
  *
@@ -19,17 +19,17 @@ import org.openzen.zenscript.codemodel.type.TypeArgument;
19 19
 public class CallArguments {
20 20
 	public static final CallArguments EMPTY = new CallArguments(new Expression[0]);
21 21
 	
22
-	public final TypeArgument[] typeArguments;
22
+	public final StoredType[] typeArguments;
23 23
 	public final Expression[] arguments;
24 24
 	
25 25
 	public CallArguments(Expression... arguments) {
26
-		this.typeArguments = TypeArgument.NONE;
26
+		this.typeArguments = StoredType.NONE;
27 27
 		this.arguments = arguments;
28 28
 	}
29 29
 	
30
-	public CallArguments(TypeArgument[] typeArguments, Expression[] arguments) {
30
+	public CallArguments(StoredType[] typeArguments, Expression[] arguments) {
31 31
 		if (typeArguments == null)
32
-			typeArguments = TypeArgument.NONE;
32
+			typeArguments = StoredType.NONE;
33 33
 		if (arguments == null)
34 34
 			throw new IllegalArgumentException("Arguments cannot be null!");
35 35
 		
@@ -37,11 +37,11 @@ public class CallArguments {
37 37
 		this.arguments = arguments;
38 38
 	}
39 39
 	
40
-	public CallArguments(TypeArgument... dummy) {
41
-		this.typeArguments = TypeArgument.NONE;
40
+	public CallArguments(StoredType... dummy) {
41
+		this.typeArguments = StoredType.NONE;
42 42
 		this.arguments = new Expression[dummy.length];
43 43
 		for (int i = 0; i < dummy.length; i++)
44
-			arguments[i] = new DummyExpression(dummy[i].stored());
44
+			arguments[i] = new DummyExpression(dummy[i]);
45 45
 	}
46 46
 	
47 47
 	public int getNumberOfTypeArguments() {

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java View File

@@ -25,7 +25,6 @@ import org.openzen.zenscript.codemodel.statement.StatementTransformer;
25 25
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
26 26
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
27 27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeArgument;
29 28
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
30 29
 
31 30
 /**
@@ -131,7 +130,7 @@ public abstract class Expression implements IPartialExpression {
131 130
 	}
132 131
 	
133 132
 	@Override
134
-	public TypeArgument[] getTypeArguments() {
133
+	public StoredType[] getTypeArguments() {
135 134
 		return null;
136 135
 	}
137 136
 	

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java View File

@@ -33,7 +33,7 @@ public class ParameterTypeBound extends TypeParameterBound {
33 33
 
34 34
 	@Override
35 35
 	public void registerMembers(LocalMemberCache cache, TypeMembers members) {
36
-		cache.get(this.type.stored(members.type.storage))
36
+		cache.get(this.type.stored(members.type.getSpecifiedStorage()))
37 37
 				.copyMembersTo(position, members, TypeMemberPriority.FROM_TYPE_BOUNDS);
38 38
 	}
39 39
 

+ 2
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java View File

@@ -16,7 +16,6 @@ import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
16 16
 import org.openzen.zenscript.codemodel.scope.TypeScope;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.TypeArgument;
20 19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
21 20
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
22 21
 import org.openzen.zenscript.codemodel.type.TypeID;
@@ -41,10 +40,10 @@ public class ImplementationMember extends DefinitionMember {
41 40
 
42 41
 	@Override
43 42
 	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
44
-		TypeID instancedType = mapper == null ? type : mapper.map(position, new TypeArgument(type, null)).type;
43
+		TypeID instancedType = mapper == null ? type : mapper.map(position, type.stored()).type;
45 44
 		members.addImplementation(new ImplementationMemberRef(this, members.type, instancedType), priority);
46 45
 		
47
-		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType.stored(members.type.storage));
46
+		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType.stored(members.type.getActualStorage()));
48 47
 		interfaceTypeMembers.copyMembersTo(position, members, TypeMemberPriority.INTERFACE);
49 48
 	}
50 49
 

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinition.java View File

@@ -11,7 +11,7 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 12
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
-import org.openzen.zenscript.codemodel.type.TypeArgument;
14
+import org.openzen.zenscript.codemodel.type.StoredType;
15 15
 
16 16
 /**
17 17
  *
@@ -19,19 +19,19 @@ import org.openzen.zenscript.codemodel.type.TypeArgument;
19 19
  */
20 20
 public class InnerDefinition {
21 21
 	public final HighLevelDefinition definition;
22
-	public final Map<TypeParameter, TypeArgument> outerTypeArguments;
22
+	public final Map<TypeParameter, StoredType> outerTypeArguments;
23 23
 	
24 24
 	public InnerDefinition(HighLevelDefinition definition) {
25 25
 		this.definition = definition;
26 26
 		this.outerTypeArguments = Collections.emptyMap();
27 27
 	}
28 28
 	
29
-	public InnerDefinition(HighLevelDefinition definition, Map<TypeParameter, TypeArgument> outerTypeArguments) {
29
+	public InnerDefinition(HighLevelDefinition definition, Map<TypeParameter, StoredType> outerTypeArguments) {
30 30
 		this.definition = definition;
31 31
 		this.outerTypeArguments = outerTypeArguments;
32 32
 	}
33 33
 	
34
-	public DefinitionTypeID instance(GlobalTypeRegistry registry, TypeArgument[] typeArguments, DefinitionTypeID outer) {
34
+	public DefinitionTypeID instance(GlobalTypeRegistry registry, StoredType[] typeArguments, DefinitionTypeID outer) {
35 35
 		return registry.getForDefinition(definition, typeArguments, outer);
36 36
 	}
37 37
 }

+ 1
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/IPartialExpression.java View File

@@ -19,8 +19,6 @@ import org.openzen.zenscript.codemodel.member.IDefinitionMember;
19 19
 import org.openzen.zenscript.codemodel.type.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
-import org.openzen.zenscript.codemodel.type.TypeArgument;
23
-import org.openzen.zenscript.codemodel.type.TypeID;
24 22
 
25 23
 /**
26 24
  *
@@ -41,7 +39,7 @@ public interface IPartialExpression {
41 39
 	
42 40
 	Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException;
43 41
 	
44
-	TypeArgument[] getTypeArguments();
42
+	StoredType[] getTypeArguments();
45 43
 	
46 44
 	/**
47 45
 	 * Retrieves the (primary) member this expression refers to, or null if there is no primary target.

+ 3
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialGlobalExpression.java View File

@@ -16,7 +16,6 @@ import org.openzen.zenscript.codemodel.expression.GlobalExpression;
16 16
 import org.openzen.zenscript.codemodel.scope.TypeScope;
17 17
 import org.openzen.zenscript.codemodel.type.GenericName;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.TypeArgument;
20 19
 
21 20
 /**
22 21
  *
@@ -26,9 +25,9 @@ public class PartialGlobalExpression implements IPartialExpression {
26 25
 	private final CodePosition position;
27 26
 	private final String name;
28 27
 	private final IPartialExpression resolution;
29
-	private final TypeArgument[] typeArguments;
28
+	private final StoredType[] typeArguments;
30 29
 	
31
-	public PartialGlobalExpression(CodePosition position, String name, IPartialExpression resolution, TypeArgument[] typeArguments) {
30
+	public PartialGlobalExpression(CodePosition position, String name, IPartialExpression resolution, StoredType[] typeArguments) {
32 31
 		this.position = position;
33 32
 		this.name = name;
34 33
 		this.resolution = resolution;
@@ -61,7 +60,7 @@ public class PartialGlobalExpression implements IPartialExpression {
61 60
 	}
62 61
 
63 62
 	@Override
64
-	public TypeArgument[] getTypeArguments() {
63
+	public StoredType[] getTypeArguments() {
65 64
 		return typeArguments;
66 65
 	}
67 66
 }

+ 4
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java View File

@@ -19,7 +19,6 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
19 19
 import org.openzen.zenscript.codemodel.type.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
-import org.openzen.zenscript.codemodel.type.TypeArgument;
23 22
 import org.openzen.zenscript.codemodel.type.member.TypeMember;
24 23
 
25 24
 /**
@@ -30,7 +29,7 @@ public class PartialMemberGroupExpression implements IPartialExpression {
30 29
 	private final CodePosition position;
31 30
 	private final Expression target;
32 31
 	private final TypeMemberGroup group;
33
-	private final TypeArgument[] typeArguments;
32
+	private final StoredType[] typeArguments;
34 33
 	private final boolean allowStaticUsage;
35 34
 	private final TypeScope scope;
36 35
 	
@@ -39,7 +38,7 @@ public class PartialMemberGroupExpression implements IPartialExpression {
39 38
 			TypeScope scope,
40 39
 			Expression target,
41 40
 			TypeMemberGroup group,
42
-			TypeArgument[] typeArguments,
41
+			StoredType[] typeArguments,
43 42
 			boolean allowStaticMembers)
44 43
 	{
45 44
 		this.position = position;
@@ -56,7 +55,7 @@ public class PartialMemberGroupExpression implements IPartialExpression {
56 55
 			Expression target,
57 56
 			String name,
58 57
 			FunctionalMemberRef member,
59
-			TypeArgument[] typeArguments,
58
+			StoredType[] typeArguments,
60 59
 			boolean allowStaticMembers)
61 60
 	{
62 61
 		this.position = position;
@@ -127,7 +126,7 @@ public class PartialMemberGroupExpression implements IPartialExpression {
127 126
 	}
128 127
 
129 128
 	@Override
130
-	public TypeArgument[] getTypeArguments() {
129
+	public StoredType[] getTypeArguments() {
131 130
 		return typeArguments;
132 131
 	}
133 132
 }

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialPackageExpression.java View File

@@ -17,7 +17,6 @@ import org.openzen.zenscript.codemodel.expression.Expression;
17 17
 import org.openzen.zenscript.codemodel.type.GenericName;
18 18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
19 19
 import org.openzen.zenscript.codemodel.type.StoredType;
20
-import org.openzen.zenscript.codemodel.type.TypeArgument;
21 20
 
22 21
 /**
23 22
  *
@@ -58,7 +57,7 @@ public class PartialPackageExpression implements IPartialExpression {
58 57
 	}
59 58
 
60 59
 	@Override
61
-	public TypeArgument[] getTypeArguments() {
60
+	public StoredType[] getTypeArguments() {
62 61
 		return null;
63 62
 	}
64 63
 }

+ 4
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java View File

@@ -18,7 +18,6 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
18 18
 import org.openzen.zenscript.codemodel.type.GenericName;
19 19
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20 20
 import org.openzen.zenscript.codemodel.type.StoredType;
21
-import org.openzen.zenscript.codemodel.type.TypeArgument;
22 21
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
23 22
 import org.openzen.zenscript.codemodel.type.TypeID;
24 23
 
@@ -27,7 +26,7 @@ import org.openzen.zenscript.codemodel.type.TypeID;
27 26
  * @author Hoofdgebruiker
28 27
  */
29 28
 public class PartialStaticMemberGroupExpression implements IPartialExpression {
30
-	public static PartialStaticMemberGroupExpression forMethod(CodePosition position, TypeScope scope, String name, TypeID target, FunctionalMemberRef method, TypeArgument[] typeArguments) {
29
+	public static PartialStaticMemberGroupExpression forMethod(CodePosition position, TypeScope scope, String name, TypeID target, FunctionalMemberRef method, StoredType[] typeArguments) {
31 30
 		TypeMemberGroup group = new TypeMemberGroup(true, name);
32 31
 		group.addMethod(method, TypeMemberPriority.SPECIFIED);
33 32
 		return new PartialStaticMemberGroupExpression(position, scope, target, group, typeArguments);
@@ -37,9 +36,9 @@ public class PartialStaticMemberGroupExpression implements IPartialExpression {
37 36
 	private final TypeScope scope;
38 37
 	private final TypeID target;
39 38
 	private final TypeMemberGroup group;
40
-	private final TypeArgument[] typeArguments;
39
+	private final StoredType[] typeArguments;
41 40
 	
42
-	public PartialStaticMemberGroupExpression(CodePosition position, TypeScope scope, TypeID target, TypeMemberGroup group, TypeArgument[] typeArguments) {
41
+	public PartialStaticMemberGroupExpression(CodePosition position, TypeScope scope, TypeID target, TypeMemberGroup group, StoredType[] typeArguments) {
43 42
 		this.position = position;
44 43
 		this.scope = scope;
45 44
 		this.group = group;
@@ -81,7 +80,7 @@ public class PartialStaticMemberGroupExpression implements IPartialExpression {
81 80
 	}
82 81
 
83 82
 	@Override
84
-	public TypeArgument[] getTypeArguments() {
83
+	public StoredType[] getTypeArguments() {
85 84
 		return typeArguments;
86 85
 	}
87 86
 	

+ 3
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java View File

@@ -19,7 +19,6 @@ import org.openzen.zenscript.codemodel.expression.LambdaClosure;
19 19
 import org.openzen.zenscript.codemodel.type.GenericName;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
-import org.openzen.zenscript.codemodel.type.TypeArgument;
23 22
 import org.openzen.zenscript.codemodel.type.TypeID;
24 23
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
25 24
 
@@ -30,9 +29,9 @@ import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
30 29
 public class PartialTypeExpression implements IPartialExpression {
31 30
 	private final CodePosition position;
32 31
 	private final StoredType type;
33
-	private final TypeArgument[] typeArguments;
32
+	private final StoredType[] typeArguments;
34 33
 	
35
-	public PartialTypeExpression(CodePosition position, TypeID type, TypeArgument[] typeArguments) {
34
+	public PartialTypeExpression(CodePosition position, TypeID type, StoredType[] typeArguments) {
36 35
 		this.position = position;
37 36
 		this.type = type.stored(StaticExpressionStorageTag.INSTANCE);
38 37
 		this.typeArguments = typeArguments;
@@ -72,7 +71,7 @@ public class PartialTypeExpression implements IPartialExpression {
72 71
 	}
73 72
 
74 73
 	@Override
75
-	public TypeArgument[] getTypeArguments() {
74
+	public StoredType[] getTypeArguments() {
76 75
 		return typeArguments;
77 76
 	}
78 77
 	

+ 2
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialVariantOptionExpression.java View File

@@ -20,8 +20,6 @@ import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
20 20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21 21
 import org.openzen.zenscript.codemodel.type.GenericName;
22 22
 import org.openzen.zenscript.codemodel.type.StoredType;
23
-import org.openzen.zenscript.codemodel.type.TypeArgument;
24
-import org.openzen.zenscript.codemodel.type.TypeID;
25 23
 
26 24
 /**
27 25
  *
@@ -70,7 +68,7 @@ public class PartialVariantOptionExpression implements IPartialExpression {
70 68
 	}
71 69
 
72 70
 	@Override
73
-	public TypeArgument[] getTypeArguments() {
74
-		return TypeArgument.NONE;
71
+	public StoredType[] getTypeArguments() {
72
+		return StoredType.NONE;
75 73
 	}
76 74
 }

+ 4
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java View File

@@ -29,7 +29,6 @@ import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
29 29
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
30 30
 import org.openzen.zenscript.codemodel.type.GenericName;
31 31
 import org.openzen.zenscript.codemodel.type.StoredType;
32
-import org.openzen.zenscript.codemodel.type.TypeArgument;
33 32
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
34 33
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;
35 34
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -37,7 +36,6 @@ import org.openzen.zenscript.codemodel.type.storage.StorageTag;
37 36
 import org.openzen.zenscript.codemodel.type.TypeID;
38 37
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
39 38
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
40
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
41 39
 
42 40
 /**
43 41
  *
@@ -60,21 +58,19 @@ public class DefinitionScope extends BaseScope {
60 58
 		this.outer = outer;
61 59
 		this.definition = definition;
62 60
 		
63
-		Map<TypeParameter, TypeArgument> typeParameters = new HashMap<>();
61
+		Map<TypeParameter, StoredType> typeParameters = new HashMap<>();
64 62
 		if (definition instanceof ExpansionDefinition) {
65 63
 			ExpansionDefinition expansion = (ExpansionDefinition)definition;
66
-			type = expansion.target.storage == null
67
-					? expansion.target.stored(BorrowStorageTag.THIS)
68
-					: expansion.target.stored();
64
+			type = expansion.target;
69 65
 			this.typeParameters = expansion.typeParameters;
70
-			typeParameters = TypeArgument.getSelfMapping(outer.getTypeRegistry(), expansion.typeParameters);
66
+			typeParameters = StoredType.getSelfMapping(outer.getTypeRegistry(), expansion.typeParameters);
71 67
 		} else {
72 68
 			DefinitionTypeID definitionType = outer.getTypeRegistry().getForMyDefinition(definition);
73 69
 			type = definitionType.stored(BorrowStorageTag.THIS);
74 70
 			
75 71
 			List<TypeParameter> typeParameterList = new ArrayList<>();
76 72
 			while (definitionType != null) {
77
-				typeParameters = TypeArgument.getSelfMapping(outer.getTypeRegistry(), definitionType.definition.typeParameters);
73
+				typeParameters = StoredType.getSelfMapping(outer.getTypeRegistry(), definitionType.definition.typeParameters);
78 74
 				typeParameterList.addAll(Arrays.asList(definitionType.definition.typeParameters));
79 75
 				
80 76
 				definitionType = definitionType.definition.isStatic() ? null : definitionType.outer;

+ 3
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java View File

@@ -26,7 +26,6 @@ import org.openzen.zenscript.codemodel.statement.VarStatement;
26 26
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
27 27
 import org.openzen.zenscript.codemodel.type.GenericName;
28 28
 import org.openzen.zenscript.codemodel.type.StoredType;
29
-import org.openzen.zenscript.codemodel.type.TypeArgument;
30 29
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
31 30
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;
32 31
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
@@ -41,7 +40,7 @@ public class ExpressionScope extends BaseScope {
41 40
 	private final DollarEvaluator dollar;
42 41
 	
43 42
 	public final List<StoredType> hints;
44
-	public final Map<TypeParameter, TypeArgument> genericInferenceMap;
43
+	public final Map<TypeParameter, StoredType> genericInferenceMap;
45 44
 	public final Map<String, Function<CodePosition, Expression>> innerVariables = new HashMap<>();
46 45
 	
47 46
 	public ExpressionScope(BaseScope outer) {
@@ -69,7 +68,7 @@ public class ExpressionScope extends BaseScope {
69 68
 			BaseScope scope,
70 69
 			List<StoredType> hints,
71 70
 			DollarEvaluator dollar,
72
-			Map<TypeParameter, TypeArgument> genericInferenceMap,
71
+			Map<TypeParameter, StoredType> genericInferenceMap,
73 72
 			Map<String, Function<CodePosition, Expression>> innerVariables) {
74 73
 		this.outer = scope;
75 74
 		this.hints = hints;
@@ -110,7 +109,7 @@ public class ExpressionScope extends BaseScope {
110 109
 		if (header.typeParameters == null)
111 110
 			return this;
112 111
 		
113
-		Map<TypeParameter, TypeArgument> genericInferenceMap = new HashMap<>();
112
+		Map<TypeParameter, StoredType> genericInferenceMap = new HashMap<>();
114 113
 		for (TypeParameter parameter : header.typeParameters)
115 114
 			genericInferenceMap.put(parameter, null);
116 115
 		

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java View File

@@ -55,11 +55,6 @@ public class ArrayTypeID implements TypeID {
55 55
 	public boolean isOptional() {
56 56
 		return false;
57 57
 	}
58
-
59
-	@Override
60
-	public boolean isConst() {
61
-		return false;
62
-	}
63 58
 	
64 59
 	@Override
65 60
 	public boolean isValueType() {
@@ -77,8 +72,8 @@ public class ArrayTypeID implements TypeID {
77 72
 	}
78 73
 	
79 74
 	@Override
80
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
81
-		return mapper.registry.getArray(elementType.instance(mapper), dimension).argument(storage);
75
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
76
+		return mapper.registry.getArray(elementType.instance(mapper), dimension).stored(storage);
82 77
 	}
83 78
 
84 79
 	@Override

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java View File

@@ -32,10 +32,10 @@ public class AssocTypeID implements TypeID {
32 32
 	}
33 33
 	
34 34
 	@Override
35
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
35
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
36 36
 		return mapper.registry.getAssociative(
37 37
 				keyType.instance(mapper),
38
-				valueType.instance(mapper)).argument(storage);
38
+				valueType.instance(mapper)).stored(storage);
39 39
 	}
40 40
 	
41 41
 	@Override
@@ -57,11 +57,6 @@ public class AssocTypeID implements TypeID {
57 57
 	public boolean isOptional() {
58 58
 		return false;
59 59
 	}
60
-
61
-	@Override
62
-	public boolean isConst() {
63
-		return false;
64
-	}
65 60
 	
66 61
 	@Override
67 62
 	public boolean isValueType() {

+ 3
- 10
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java View File

@@ -41,12 +41,10 @@ public enum BasicTypeID implements TypeID {
41 41
 	
42 42
 	public final String name;
43 43
 	public final StoredType stored;
44
-	public final TypeArgument argument;
45 44
 	
46 45
 	BasicTypeID(String name) {
47 46
 		this.name = name;
48
-		stored = new StoredType(this, ValueStorageTag.INSTANCE);
49
-		argument = new TypeArgument(this, ValueStorageTag.INSTANCE);
47
+		stored = new StoredType(this, null);
50 48
 	}
51 49
 	
52 50
 	@Override
@@ -55,8 +53,8 @@ public enum BasicTypeID implements TypeID {
55 53
 	}
56 54
 	
57 55
 	@Override
58
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
59
-		return new TypeArgument(this, storage);
56
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
57
+		return stored(storage);
60 58
 	}
61 59
 	
62 60
 	@Override
@@ -78,11 +76,6 @@ public enum BasicTypeID implements TypeID {
78 76
 	public boolean isOptional() {
79 77
 		return false;
80 78
 	}
81
-
82
-	@Override
83
-	public boolean isConst() {
84
-		return false;
85
-	}
86 79
 	
87 80
 	@Override
88 81
 	public boolean isValueType() {

+ 18
- 23
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java View File

@@ -29,22 +29,22 @@ public class DefinitionTypeID implements TypeID {
29 29
 		if (definition.typeParameters != null && definition.typeParameters.length > 0)
30 30
 			throw new IllegalArgumentException("Definition has type arguments!");
31 31
 		
32
-		return new DefinitionTypeID(registry, definition, TypeArgument.NONE);
32
+		return new DefinitionTypeID(registry, definition, StoredType.NONE);
33 33
 	}
34 34
 	
35 35
 	public final HighLevelDefinition definition;
36
-	public final TypeArgument[] typeArguments;
36
+	public final StoredType[] typeArguments;
37 37
 	public final DefinitionTypeID outer;
38 38
 	private TypeID normalized;
39 39
 	
40 40
 	public TypeID superType;
41 41
 	
42
-	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeArgument[] typeArguments) {
42
+	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, StoredType[] typeArguments) {
43 43
 		this(typeRegistry, definition, typeArguments, null);
44 44
 	}
45 45
 	
46 46
 	// For inner classes of generic outer classes
47
-	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeArgument[] typeArguments, DefinitionTypeID outer) {
47
+	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, StoredType[] typeArguments, DefinitionTypeID outer) {
48 48
 		if (typeArguments == null)
49 49
 			throw new NullPointerException("typeParameters cannot be null");
50 50
 		if (typeArguments.length != definition.getNumberOfGenericParameters())
@@ -67,7 +67,7 @@ public class DefinitionTypeID implements TypeID {
67 67
 		if (definition instanceof AliasDefinition)
68 68
 			return true;
69 69
 		
70
-		for (TypeArgument typeArgument : typeArguments)
70
+		for (StoredType typeArgument : typeArguments)
71 71
 			if (!typeArgument.getNormalized().equals(typeArgument))
72 72
 				return true;
73 73
 		if (outer != null && !outer.getNormalized().equals(outer))
@@ -82,7 +82,7 @@ public class DefinitionTypeID implements TypeID {
82 82
 			if (alias.type == null)
83 83
 				throw new IllegalStateException("Alias type not yet initialized!");
84 84
 			
85
-			Map<TypeParameter, TypeArgument> typeMapping = new HashMap<>();
85
+			Map<TypeParameter, StoredType> typeMapping = new HashMap<>();
86 86
 			for (int i = 0; i < definition.typeParameters.length; i++)
87 87
 				typeMapping.put(definition.typeParameters[i], typeArguments[i].getNormalized());
88 88
 			GenericMapper mapper = new GenericMapper(typeRegistry, typeMapping);
@@ -90,7 +90,7 @@ public class DefinitionTypeID implements TypeID {
90 90
 			return result;
91 91
 		}
92 92
 		
93
-		TypeArgument[] normalizedTypeParameters = new TypeArgument[typeArguments.length];
93
+		StoredType[] normalizedTypeParameters = new StoredType[typeArguments.length];
94 94
 		for (int i = 0; i < normalizedTypeParameters.length; i++)
95 95
 			normalizedTypeParameters[i] = typeArguments[i].getNormalized();
96 96
 		
@@ -101,8 +101,8 @@ public class DefinitionTypeID implements TypeID {
101 101
 		return typeArguments.length > 0;
102 102
 	}
103 103
 	
104
-	public Map<TypeParameter, TypeArgument> getTypeParameterMapping() {
105
-		Map<TypeParameter, TypeArgument> mapping = new HashMap<>();
104
+	public Map<TypeParameter, StoredType> getTypeParameterMapping() {
105
+		Map<TypeParameter, StoredType> mapping = new HashMap<>();
106 106
 		DefinitionTypeID current = this;
107 107
 		do {
108 108
 			if (current.typeArguments != null) {
@@ -120,7 +120,7 @@ public class DefinitionTypeID implements TypeID {
120 120
 	
121 121
 	public DefinitionTypeID(HighLevelDefinition definition) {
122 122
 		this.definition = definition;
123
-		this.typeArguments = TypeArgument.NONE;
123
+		this.typeArguments = StoredType.NONE;
124 124
 		this.superType = definition.getSuperType();
125 125
 		this.outer = null;
126 126
 	}
@@ -131,23 +131,23 @@ public class DefinitionTypeID implements TypeID {
131 131
 	}
132 132
 	
133 133
 	@Override
134
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
134
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
135 135
 		if (!hasTypeParameters() && outer == null)
136
-			return argument(storage);
136
+			return stored(storage);
137 137
 		if (mapper.getMapping().isEmpty())
138
-			return argument(storage);
138
+			return stored(storage);
139 139
 		if (mapper.registry == null)
140 140
 			throw new NullPointerException();
141 141
 		
142
-		TypeArgument[] instancedArguments = TypeArgument.NONE;
142
+		StoredType[] instancedArguments = StoredType.NONE;
143 143
 		if (hasTypeParameters()) {
144
-			instancedArguments = new TypeArgument[typeArguments.length];
144
+			instancedArguments = new StoredType[typeArguments.length];
145 145
 			for (int i = 0; i < typeArguments.length; i++)
146 146
 				instancedArguments[i] = typeArguments[i].instance(mapper);
147 147
 		}
148 148
 		
149 149
 		DefinitionTypeID instancedOuter = outer == null ? null : (DefinitionTypeID)outer.instance(mapper, storage).type;
150
-		return mapper.registry.getForDefinition(definition, instancedArguments, instancedOuter).argument(storage);
150
+		return mapper.registry.getForDefinition(definition, instancedArguments, instancedOuter).stored(storage);
151 151
 	}
152 152
 	
153 153
 	@Override
@@ -169,11 +169,6 @@ public class DefinitionTypeID implements TypeID {
169 169
 	public boolean isOptional() {
170 170
 		return false;
171 171
 	}
172
-
173
-	@Override
174
-	public boolean isConst() {
175
-		return false;
176
-	}
177 172
 	
178 173
 	@Override
179 174
 	public boolean isValueType() {
@@ -203,7 +198,7 @@ public class DefinitionTypeID implements TypeID {
203 198
 	@Override
204 199
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
205 200
 		if (hasTypeParameters()) {
206
-			for (TypeArgument typeArgument : typeArguments)
201
+			for (StoredType typeArgument : typeArguments)
207 202
 				if (typeArgument.type.hasInferenceBlockingTypeParameters(parameters))
208 203
 					return true;
209 204
 		}
@@ -264,7 +259,7 @@ public class DefinitionTypeID implements TypeID {
264 259
 
265 260
 	@Override
266 261
 	public void extractTypeParameters(List<TypeParameter> typeParameters) {
267
-		for (TypeArgument type : this.typeArguments)
262
+		for (StoredType type : this.typeArguments)
268 263
 			type.type.extractTypeParameters(typeParameters);
269 264
 	}
270 265
 

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java View File

@@ -37,8 +37,8 @@ public class FunctionTypeID implements TypeID {
37 37
 	}
38 38
 	
39 39
 	@Override
40
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
41
-		return new TypeArgument(mapper.registry.getFunction(mapper.map(header)), storage);
40
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
41
+		return mapper.registry.getFunction(mapper.map(header)).stored(storage);
42 42
 	}
43 43
 	
44 44
 	@Override
@@ -55,11 +55,6 @@ public class FunctionTypeID implements TypeID {
55 55
 	public boolean isOptional() {
56 56
 		return false;
57 57
 	}
58
-
59
-	@Override
60
-	public boolean isConst() {
61
-		return false;
62
-	}
63 58
 	
64 59
 	@Override
65 60
 	public boolean isValueType() {

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java View File

@@ -48,11 +48,6 @@ public class GenericMapTypeID implements TypeID {
48 48
 	public boolean isOptional() {
49 49
 		return false;
50 50
 	}
51
-
52
-	@Override
53
-	public boolean isConst() {
54
-		return false;
55
-	}
56 51
 	
57 52
 	@Override
58 53
 	public boolean isValueType() {
@@ -70,8 +65,8 @@ public class GenericMapTypeID implements TypeID {
70 65
 	}
71 66
 	
72 67
 	@Override
73
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
74
-		return new TypeArgument(mapper.registry.getGenericMap(value.instance(mapper), key), storage);
68
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
69
+		return mapper.registry.getGenericMap(value.instance(mapper), key).stored(storage);
75 70
 	}
76 71
 
77 72
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericName.java View File

@@ -13,13 +13,13 @@ import java.util.List;
13 13
  */
14 14
 public class GenericName {
15 15
 	public final String name;
16
-	public final TypeArgument[] arguments;
16
+	public final StoredType[] arguments;
17 17
 	
18 18
 	public GenericName(String name) {
19
-		this(name, TypeArgument.NONE);
19
+		this(name, StoredType.NONE);
20 20
 	}
21 21
 	
22
-	public GenericName(String name, TypeArgument[] arguments) {
22
+	public GenericName(String name, StoredType[] arguments) {
23 23
 		if (arguments == null)
24 24
 			throw new NullPointerException("Arguments cannot be null");
25 25
 		

+ 5
- 9
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java View File

@@ -24,8 +24,8 @@ public class GenericTypeID implements TypeID {
24 24
 		this.parameter = parameter;
25 25
 	}
26 26
 	
27
-	public boolean matches(LocalMemberCache cache, TypeArgument type) {
28
-		if (type.storage != null && parameter.storage != null && !type.storage.equals(parameter.storage))
27
+	public boolean matches(LocalMemberCache cache, StoredType type) {
28
+		if (type.getSpecifiedStorage() != null && parameter.storage != null && !type.getActualStorage().equals(parameter.storage))
29 29
 			return false;
30 30
 		
31 31
 		return parameter.matches(cache, type.type);
@@ -37,8 +37,9 @@ public class GenericTypeID implements TypeID {
37 37
 	}
38 38
 	
39 39
 	@Override
40
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
41
-		return mapper.map(this).argument(StorageTag.union(parameter.storage, storage));
40
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
41
+		StoredType mapped = mapper.map(this);
42
+		return new StoredType(mapped.type, StorageTag.union(mapped.getSpecifiedStorage(), storage));
42 43
 	}
43 44
 	
44 45
 	@Override
@@ -55,11 +56,6 @@ public class GenericTypeID implements TypeID {
55 56
 	public boolean isOptional() {
56 57
 		return false;
57 58
 	}
58
-
59
-	@Override
60
-	public boolean isConst() {
61
-		return false;
62
-	}
63 59
 	
64 60
 	@Override
65 61
 	public boolean isValueType() {

+ 8
- 26
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GlobalTypeRegistry.java View File

@@ -26,7 +26,7 @@ public class GlobalTypeRegistry {
26 26
 	private final Map<DefinitionTypeID, DefinitionTypeID> definitionTypes = new HashMap<>();
27 27
 	private final Map<GenericTypeID, GenericTypeID> genericTypes = new HashMap<>();
28 28
 	
29
-	private final Map<ModifiedTypeID, ModifiedTypeID> modifiedTypes = new HashMap<>();
29
+	private final Map<OptionalTypeID, OptionalTypeID> optionalTypes = new HashMap<>();
30 30
 	
31 31
 	public final ZSPackage stdlib;
32 32
 	
@@ -76,11 +76,11 @@ public class GlobalTypeRegistry {
76 76
 	}
77 77
 	
78 78
 	public DefinitionTypeID getForMyDefinition(HighLevelDefinition definition) {
79
-		TypeArgument[] typeArguments = TypeArgument.NONE;
79
+		StoredType[] typeArguments = StoredType.NONE;
80 80
 		if (definition.getNumberOfGenericParameters() > 0) {
81
-			typeArguments = new TypeArgument[definition.getNumberOfGenericParameters()];
81
+			typeArguments = new StoredType[definition.getNumberOfGenericParameters()];
82 82
 			for (int i = 0; i < definition.typeParameters.length; i++)
83
-				typeArguments[i] = new TypeArgument(getGeneric(definition.typeParameters[i]), definition.typeParameters[i].storage);
83
+				typeArguments[i] = new StoredType(getGeneric(definition.typeParameters[i]), definition.typeParameters[i].storage);
84 84
 		}
85 85
 		DefinitionTypeID outer = null;
86 86
 		if (definition.outerDefinition != null)
@@ -89,35 +89,17 @@ public class GlobalTypeRegistry {
89 89
 		return getForDefinition(definition, typeArguments, outer);
90 90
 	}
91 91
 	
92
-	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeArgument... typeArguments) {
92
+	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, StoredType... typeArguments) {
93 93
 		return this.getForDefinition(definition, typeArguments, null);
94 94
 	}
95 95
 	
96
-	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeArgument[] typeArguments, DefinitionTypeID outer) {
96
+	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, StoredType[] typeArguments, DefinitionTypeID outer) {
97 97
 		DefinitionTypeID id = new DefinitionTypeID(this, definition, typeArguments, definition.isStatic() ? null : outer);
98
-		
99
-		if (definitionTypes.containsKey(id)) {
100
-			return definitionTypes.get(id);
101
-		} else {
102
-			definitionTypes.put(id, id);
103
-			return id;
104
-		}
98
+		return internalize(definitionTypes, id);
105 99
 	}
106 100
 	
107 101
 	public TypeID getOptional(TypeID original) {
108
-		return getModified(ModifiedTypeID.MODIFIER_OPTIONAL, original);
109
-	}
110
-	
111
-	public TypeID getModified(int modifiers, TypeID type) {
112
-		if (modifiers == 0)
113
-			return type;
114
-		if (type instanceof ModifiedTypeID) {
115
-			ModifiedTypeID modified = (ModifiedTypeID)type;
116
-			return getModified(modified.modifiers | modifiers, modified.baseType);
117
-		}
118
-		
119
-		ModifiedTypeID result = new ModifiedTypeID(this, modifiers, type);
120
-		return internalize(modifiedTypes, result);
102
+		return internalize(optionalTypes, new OptionalTypeID(this, original));
121 103
 	}
122 104
 	
123 105
 	private <T> T internalize(Map<T, T> identityMap, T id) {

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ISymbol.java View File

@@ -15,7 +15,7 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
15 15
  * @author Hoofdgebruiker
16 16
  */
17 17
 public interface ISymbol {
18
-	public IPartialExpression getExpression(CodePosition position, BaseScope scope, TypeArgument[] typeArguments);
18
+	public IPartialExpression getExpression(CodePosition position, BaseScope scope, StoredType[] typeArguments);
19 19
 	
20
-	public TypeID getType(CodePosition position, TypeResolutionContext context, TypeArgument[] typeArguments);
20
+	public TypeID getType(CodePosition position, TypeResolutionContext context, StoredType[] typeArguments);
21 21
 }

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/InvalidTypeID.java View File

@@ -35,8 +35,8 @@ public class InvalidTypeID implements TypeID {
35 35
 	}
36 36
 
37 37
 	@Override
38
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
39
-		return new TypeArgument(this, storage);
38
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
39
+		return stored(storage);
40 40
 	}
41 41
 
42 42
 	@Override

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java View File

@@ -61,11 +61,6 @@ public class IteratorTypeID implements TypeID {
61 61
 	public boolean isOptional() {
62 62
 		return false;
63 63
 	}
64
-
65
-	@Override
66
-	public boolean isConst() {
67
-		return false;
68
-	}
69 64
 	
70 65
 	@Override
71 66
 	public boolean isDestructible() {
@@ -83,9 +78,9 @@ public class IteratorTypeID implements TypeID {
83 78
 	}
84 79
 	
85 80
 	@Override
86
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
81
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
87 82
 		StoredType[] instanced = mapper.map(iteratorTypes);
88
-		return new TypeArgument(mapper.registry.getIterator(instanced), storage);
83
+		return mapper.registry.getIterator(instanced).stored(storage);
89 84
 	}
90 85
 
91 86
 	@Override

CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ModifiedTypeID.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java View File

@@ -17,22 +17,16 @@ import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17 17
  *
18 18
  * @author Hoofdgebruiker
19 19
  */
20
-public class ModifiedTypeID implements TypeID {
21
-	public static final int MODIFIER_OPTIONAL = 1;
22
-	public static final int MODIFIER_CONST = 2;
23
-	public static final int MODIFIER_IMMUTABLE = 4;
24
-	
25
-	public final int modifiers;
20
+public class OptionalTypeID implements TypeID {
26 21
 	public final TypeID baseType;
27 22
 	private final TypeID normalized;
28 23
 	private final GlobalTypeRegistry registry;
29 24
 	
30
-	public ModifiedTypeID(GlobalTypeRegistry registry, int modifiers, TypeID baseType) {
31
-		this.modifiers = modifiers;
25
+	public OptionalTypeID(GlobalTypeRegistry registry, TypeID baseType) {
32 26
 		this.baseType = baseType;
33 27
 		this.registry = registry;
34 28
 		
35
-		normalized = baseType.getNormalized() == baseType ? this : registry.getModified(modifiers, baseType.getNormalized());
29
+		normalized = baseType.getNormalized() == baseType ? this : registry.getOptional(baseType.getNormalized());
36 30
 	}
37 31
 	
38 32
 	@Override
@@ -41,14 +35,14 @@ public class ModifiedTypeID implements TypeID {
41 35
 	}
42 36
 	
43 37
 	@Override
44
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
45
-		TypeArgument base = baseType.instance(mapper, storage);
46
-		return new TypeArgument(mapper.registry.getModified(modifiers, base.type), base.storage);
38
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
39
+		StoredType base = baseType.instance(mapper, storage);
40
+		return mapper.registry.getOptional(base.type).stored(StorageTag.union(base.getSpecifiedStorage(), storage));
47 41
 	}
48 42
 	
49 43
 	@Override
50 44
 	public <R> R accept(TypeVisitor<R> visitor) {
51
-		return visitor.visitModified(this);
45
+		return visitor.visitOptional(this);
52 46
 	}
53 47
 	
54 48
 	@Override
@@ -58,17 +52,7 @@ public class ModifiedTypeID implements TypeID {
58 52
 
59 53
 	@Override
60 54
 	public boolean isOptional() {
61
-		return (modifiers & MODIFIER_OPTIONAL) > 0;
62
-	}
63
-	
64
-	@Override
65
-	public boolean isImmutable() {
66
-		return (modifiers & MODIFIER_IMMUTABLE) > 0;
67
-	}
68
-
69
-	@Override
70
-	public boolean isConst() {
71
-		return (modifiers & MODIFIER_CONST) > 0;
55
+		return true;
72 56
 	}
73 57
 	
74 58
 	@Override
@@ -88,22 +72,7 @@ public class ModifiedTypeID implements TypeID {
88 72
 	
89 73
 	@Override
90 74
 	public TypeID withoutOptional() {
91
-		return without(MODIFIER_OPTIONAL);
92
-	}
93
-	
94
-	@Override
95
-	public TypeID withoutImmutable() {
96
-		return without(MODIFIER_IMMUTABLE);
97
-	}
98
-	
99
-	@Override
100
-	public TypeID withoutConst() {
101
-		return without(MODIFIER_CONST);
102
-	}
103
-	
104
-	private TypeID without(int modifiers) {
105
-		int newModifiers = this.modifiers & ~modifiers;
106
-		return newModifiers == 0 ? baseType : registry.getModified(newModifiers, baseType);
75
+		return baseType;
107 76
 	}
108 77
 
109 78
 	@Override
@@ -125,7 +94,6 @@ public class ModifiedTypeID implements TypeID {
125 94
 	public int hashCode() {
126 95
 		int hash = 3;
127 96
 		hash = 79 * hash + Objects.hashCode(this.baseType);
128
-		hash = 79 * hash + modifiers;
129 97
 		return hash;
130 98
 	}
131 99
 
@@ -137,34 +105,20 @@ public class ModifiedTypeID implements TypeID {
137 105
 			return false;
138 106
 		if (getClass() != obj.getClass())
139 107
 			return false;
140
-		final ModifiedTypeID other = (ModifiedTypeID) obj;
141
-		return this.baseType == other.baseType
142
-				&& this.modifiers == other.modifiers;
108
+		final OptionalTypeID other = (OptionalTypeID) obj;
109
+		return this.baseType == other.baseType;
143 110
 	}
144 111
 	
145 112
 	@Override
146 113
 	public String toString() {
147
-		StringBuilder result = new StringBuilder();
148
-		if ((modifiers & MODIFIER_IMMUTABLE) > 0)
149
-			result.append("immutable ");
150
-		if ((modifiers & MODIFIER_CONST) > 0)
151
-			result.append("const ");
152
-		result.append(baseType.toString());
153
-		if ((modifiers & MODIFIER_OPTIONAL) > 0)
154
-			result.append("?");
155
-		return result.toString();
114
+		return baseType.toString() + "?";
156 115
 	}
157 116
 	
158 117
 	@Override
159 118
 	public String toString(StorageTag storage) {
160 119
 		StringBuilder result = new StringBuilder();
161
-		if ((modifiers & MODIFIER_IMMUTABLE) > 0)
162
-			result.append("immutable ");
163
-		if ((modifiers & MODIFIER_CONST) > 0)
164
-			result.append("const ");
165 120
 		result.append(baseType.toString(storage));
166
-		if ((modifiers & MODIFIER_OPTIONAL) > 0)
167
-			result.append("?");
121
+		result.append("?");
168 122
 		return result.toString();
169 123
 	}
170 124
 }

+ 3
- 9
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java View File

@@ -11,7 +11,6 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
15 14
 
16 15
 /**
17 16
  *
@@ -34,7 +33,7 @@ public class RangeTypeID implements TypeID {
34 33
 			normalized = registry.getRange(baseType.getNormalized());
35 34
 		}
36 35
 		
37
-		stored = new StoredType(this, baseType.storage);
36
+		stored = new StoredType(this, baseType.getSpecifiedStorage());
38 37
 	}
39 38
 	
40 39
 	@Override
@@ -43,8 +42,8 @@ public class RangeTypeID implements TypeID {
43 42
 	}
44 43
 	
45 44
 	@Override
46
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
47
-		return mapper.registry.getRange(baseType.instance(mapper)).argument(storage);
45
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
46
+		return mapper.registry.getRange(baseType.instance(mapper)).stored(storage);
48 47
 	}
49 48
 	
50 49
 	@Override
@@ -61,11 +60,6 @@ public class RangeTypeID implements TypeID {
61 60
 	public boolean isOptional() {
62 61
 		return false;
63 62
 	}
64
-
65
-	@Override
66
-	public boolean isConst() {
67
-		return false;
68
-	}
69 63
 	
70 64
 	@Override
71 65
 	public boolean isValueType() {

+ 56
- 47
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java View File

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
+import java.util.HashMap;
8 9
 import java.util.Map;
9 10
 import java.util.Objects;
10 11
 import java.util.Set;
@@ -12,6 +13,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
12 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
16
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
15 17
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16 18
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
17 19
 
@@ -20,24 +22,44 @@ import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
20 22
  * @author Hoofdgebruiker
21 23
  */
22 24
 public class StoredType {
25
+	public static Map<TypeParameter, StoredType> getMapping(TypeParameter[] parameters, StoredType[] arguments) {
26
+		Map<TypeParameter, StoredType> typeArguments = new HashMap<>();
27
+		for (int i = 0; i < parameters.length; i++)
28
+			typeArguments.put(parameters[i], arguments[i]);
29
+		return typeArguments;
30
+	}
31
+	
32
+	public static Map<TypeParameter, StoredType> getSelfMapping(GlobalTypeRegistry registry, TypeParameter[] parameters) {
33
+		Map<TypeParameter, StoredType> typeArguments = new HashMap<>();
34
+		for (TypeParameter parameter : parameters)
35
+			typeArguments.put(parameter, registry.getGeneric(parameter).stored(parameter.storage));
36
+		return typeArguments;
37
+	}
38
+	
23 39
 	public static final StoredType[] NONE = new StoredType[0];
24 40
 	
25 41
 	public final TypeID type;
26
-	public final StorageTag storage;
42
+	private final StorageTag storage;
27 43
 	
28 44
 	public StoredType(TypeID type, StorageTag storage) {
29
-		if (storage == null)
30
-			throw new NullPointerException();
31
-		
32
-		if (type.isValueType())
33
-			storage = ValueStorageTag.INSTANCE;
34
-		else if (storage == ValueStorageTag.INSTANCE)
45
+		if (/*!type.isValueType() && */storage == ValueStorageTag.INSTANCE)
35 46
 			throw new IllegalArgumentException("storage of a nonvalue type cannot be value");
36 47
 		
37 48
 		this.type = type;
38 49
 		this.storage = storage;
39 50
 	}
40 51
 	
52
+	public StorageTag getSpecifiedStorage() {
53
+		return storage;
54
+	}
55
+	
56
+	public StorageTag getActualStorage() {
57
+		if (storage != null)
58
+			return storage;
59
+		
60
+		return type.isValueType() ? ValueStorageTag.INSTANCE : AutoStorageTag.INSTANCE;
61
+	}
62
+	
41 63
 	public StoredType getNormalized() {
42 64
 		return type.getNormalized() == type ? this : new StoredType(type, storage);
43 65
 	}
@@ -48,16 +70,15 @@ public class StoredType {
48 70
 	}
49 71
 	
50 72
 	public StoredType instance(GenericMapper mapper) {
51
-		TypeArgument result = type.instance(mapper, storage);
52
-		return result == type ? this : result.stored();
73
+		return type.instance(mapper, storage);
53 74
 	}
54 75
 	
55 76
 	public boolean isDestructible() {
56
-		return type.isDestructible() && storage.isDestructible();
77
+		return type.isDestructible() && getActualStorage().isDestructible();
57 78
 	}
58 79
 	
59 80
 	public boolean isDestructible(Set<HighLevelDefinition> scanning) {
60
-		return type.isDestructible(scanning) && storage.isDestructible();
81
+		return type.isDestructible(scanning) && getActualStorage().isDestructible();
61 82
 	}
62 83
 	
63 84
 	public boolean hasDefaultValue() {
@@ -69,11 +90,11 @@ public class StoredType {
69 90
 	}
70 91
 	
71 92
 	public boolean isConst() {
72
-		return storage.isConst();
93
+		return getActualStorage().isConst();
73 94
 	}
74 95
 	
75 96
 	public boolean isImmutable() {
76
-		return storage.isImmutable();
97
+		return getActualStorage().isImmutable();
77 98
 	}
78 99
 	
79 100
 	public boolean isBasic(BasicTypeID type) {
@@ -88,21 +109,13 @@ public class StoredType {
88 109
 		return new StoredType(type.withoutOptional(), storage);
89 110
 	}
90 111
 	
91
-	public StoredType withoutConst() {
92
-		return new StoredType(type.withoutConst(), storage);
93
-	}
94
-	
95
-	public StoredType withoutImmutable() {
96
-		return new StoredType(type.withoutImmutable(), storage);
97
-	}
98
-	
99 112
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
100 113
 		return type.hasInferenceBlockingTypeParameters(parameters);
101 114
 	}
102 115
 	
103 116
 	// Infers type parameters for this type so it matches with targetType
104 117
 	// returns false if that isn't possible
105
-	public Map<TypeParameter, TypeArgument> inferTypeParameters(LocalMemberCache cache, TypeArgument targetType) {
118
+	public Map<TypeParameter, StoredType> inferTypeParameters(LocalMemberCache cache, StoredType targetType) {
106 119
 		return type.inferTypeParameters(cache, targetType);
107 120
 	}
108 121
 	
@@ -122,10 +135,6 @@ public class StoredType {
122 135
 		return (DefinitionTypeID)type;
123 136
 	}
124 137
 	
125
-	public TypeArgument asArgument() {
126
-		return new TypeArgument(type, storage);
127
-	}
128
-	
129 138
 	@Override
130 139
 	public int hashCode() {
131 140
 		int hash = 5;
@@ -148,15 +157,15 @@ public class StoredType {
148 157
 	
149 158
 	@Override
150 159
 	public String toString() {
151
-		return type.toString(storage);
160
+		return storage == null ? type.toString() : type.toString(storage);
152 161
 	}
153 162
 	
154 163
 	public static class MatchingTypeVisitor implements TypeVisitor<Boolean> {
155 164
 		private final TypeID type;
156
-		private final Map<TypeParameter, TypeArgument> mapping;
165
+		private final Map<TypeParameter, StoredType> mapping;
157 166
 		private final LocalMemberCache cache;
158 167
 		
159
-		public MatchingTypeVisitor(LocalMemberCache cache, TypeID type, Map<TypeParameter, TypeArgument> mapping) {
168
+		public MatchingTypeVisitor(LocalMemberCache cache, TypeID type, Map<TypeParameter, StoredType> mapping) {
160 169
 			this.type = type;
161 170
 			this.mapping = mapping;
162 171
 			this.cache = cache;
@@ -179,7 +188,7 @@ public class StoredType {
179 188
 				if (arrayType.dimension != array.dimension)
180 189
 					return false;
181 190
 				
182
-				return match(arrayType.elementType, array.elementType.asArgument());
191
+				return match(arrayType.elementType, array.elementType);
183 192
 			} else {
184 193
 				return false;
185 194
 			}
@@ -189,8 +198,8 @@ public class StoredType {
189 198
 		public Boolean visitAssoc(AssocTypeID assoc) {
190 199
 			if (type instanceof AssocTypeID) {
191 200
 				AssocTypeID assocType = (AssocTypeID) type;
192
-				return match(assocType.keyType, assoc.keyType.asArgument())
193
-						&& match(assocType.valueType, assoc.valueType.asArgument());
201
+				return match(assocType.keyType, assoc.keyType)
202
+						&& match(assocType.valueType, assoc.valueType);
194 203
 			} else {
195 204
 				return false;
196 205
 			}
@@ -205,7 +214,7 @@ public class StoredType {
205 214
 				
206 215
 				boolean result = true;
207 216
 				for (int i = 0; i < iteratorType.iteratorTypes.length; i++)
208
-					result = result && match(iterator.iteratorTypes[i], iteratorType.iteratorTypes[i].asArgument());
217
+					result = result && match(iterator.iteratorTypes[i], iteratorType.iteratorTypes[i]);
209 218
 				
210 219
 				return result;
211 220
 			} else {
@@ -220,11 +229,11 @@ public class StoredType {
220 229
 				if (functionType.header.parameters.length != function.header.parameters.length)
221 230
 					return false;
222 231
 				
223
-				if (!match(functionType.header.getReturnType(), function.header.getReturnType().asArgument()))
232
+				if (!match(functionType.header.getReturnType(), function.header.getReturnType()))
224 233
 					return false;
225 234
 				
226 235
 				for (int i = 0; i < function.header.parameters.length; i++) {
227
-					if (!match(functionType.header.parameters[i].type, function.header.parameters[i].type.asArgument()))
236
+					if (!match(functionType.header.parameters[i].type, function.header.parameters[i].type))
228 237
 						return false;
229 238
 				}
230 239
 				
@@ -243,7 +252,7 @@ public class StoredType {
243 252
 				
244 253
 				if (definition.typeArguments != null) {
245 254
 					for (int i = 0; i < definitionType.typeArguments.length; i++) {
246
-						if (!match(definitionType.typeArguments[i].stored(), definition.typeArguments[i]))
255
+						if (!match(definitionType.typeArguments[i], definition.typeArguments[i]))
247 256
 							return false;
248 257
 					}
249 258
 				}
@@ -258,8 +267,8 @@ public class StoredType {
258 267
 		public Boolean visitGeneric(GenericTypeID generic) {
259 268
 			if (mapping.containsKey(generic.parameter)) {
260 269
 				return mapping.get(generic.parameter) == type;
261
-			} else if (type == generic || generic.matches(cache, new TypeArgument(type, null))) {
262
-				mapping.put(generic.parameter, new TypeArgument(type, null));
270
+			} else if (type == generic || generic.matches(cache, type.stored())) {
271
+				mapping.put(generic.parameter, type.stored());
263 272
 				return true;
264 273
 			} else {
265 274
 				return false;
@@ -270,31 +279,31 @@ public class StoredType {
270 279
 		public Boolean visitRange(RangeTypeID range) {
271 280
 			if (type instanceof RangeTypeID) {
272 281
 				RangeTypeID rangeType = (RangeTypeID) type;
273
-				return match(rangeType.baseType, range.baseType.asArgument());
282
+				return match(rangeType.baseType, range.baseType);
274 283
 			} else {
275 284
 				return false;
276 285
 			}
277 286
 		}
278 287
 
279 288
 		@Override
280
-		public Boolean visitModified(ModifiedTypeID type) {
281
-			if (this.type instanceof ModifiedTypeID) {
282
-				ModifiedTypeID constType = (ModifiedTypeID) this.type;
283
-				return match(constType.baseType, new TypeArgument(type.baseType, null));
289
+		public Boolean visitOptional(OptionalTypeID type) {
290
+			if (this.type instanceof OptionalTypeID) {
291
+				OptionalTypeID constType = (OptionalTypeID) this.type;
292
+				return match(constType.baseType, type.baseType.stored());
284 293
 			} else {
285 294
 				return false;
286 295
 			}
287 296
 		}
288 297
 		
289
-		private boolean match(StoredType type, TypeArgument pattern) {
298
+		private boolean match(StoredType type, StoredType pattern) {
290 299
 			if (pattern.storage != null && type.storage != pattern.storage)
291 300
 				return false;
292 301
 			
293
-			return TypeMatcher.match(cache, type.asArgument(), pattern) != null;
302
+			return TypeMatcher.match(cache, type, pattern) != null;
294 303
 		}
295 304
 		
296
-		private boolean match(TypeID type, TypeArgument pattern) {
297
-			return TypeMatcher.match(cache, new TypeArgument(type, null), pattern) != null;
305
+		private boolean match(TypeID type, StoredType pattern) {
306
+			return TypeMatcher.match(cache, type.stored(), pattern) != null;
298 307
 		}
299 308
 
300 309
 		@Override

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java View File

@@ -68,8 +68,8 @@ public class StringTypeID implements TypeID {
68 68
 	}
69 69
 
70 70
 	@Override
71
-	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
72
-		return argument(storage);
71
+	public StoredType instance(GenericMapper mapper, StorageTag storage) {
72
+		return new StoredType(this, storage);
73 73
 	}
74 74
 
75 75
 	@Override

+ 0
- 111
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeArgument.java View File

@@ -1,111 +0,0 @@
1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.type;
7
-
8
-import java.util.HashMap;
9
-import java.util.Map;
10
-import java.util.Objects;
11
-import org.openzen.zencode.shared.CodePosition;
12
-import org.openzen.zencode.shared.CompileExceptionCode;
13
-import org.openzen.zenscript.codemodel.GenericMapper;
14
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
15
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
16
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
17
-import org.openzen.zenscript.codemodel.type.storage.StorageTag;
18
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
19
-
20
-/**
21
- *
22
- * @author Hoofdgebruiker
23
- */
24
-public class TypeArgument {
25
-	public static Map<TypeParameter, TypeArgument> getMapping(TypeParameter[] parameters, TypeArgument[] arguments) {
26
-		Map<TypeParameter, TypeArgument> typeArguments = new HashMap<>();
27
-		for (int i = 0; i < parameters.length; i++)
28
-			typeArguments.put(parameters[i], arguments[i]);
29
-		return typeArguments;
30
-	}
31
-	
32
-	public static Map<TypeParameter, TypeArgument> getSelfMapping(GlobalTypeRegistry registry, TypeParameter[] parameters) {
33
-		Map<TypeParameter, TypeArgument> typeArguments = new HashMap<>();
34
-		for (TypeParameter parameter : parameters)
35
-			typeArguments.put(parameter, new TypeArgument(registry.getGeneric(parameter), parameter.storage));
36
-		return typeArguments;
37
-	}
38
-	
39
-	public static final TypeArgument[] NONE = new TypeArgument[0];
40
-	
41
-	public final TypeID type;
42
-	public final StorageTag storage; // can be null
43
-	
44
-	public TypeArgument(TypeID type, StorageTag storage) {
45
-		this.type = type;
46
-		this.storage = storage;
47
-	}
48
-	
49
-	public TypeArgument instance(GenericMapper mapper) {
50
-		return type.instance(mapper, storage);
51
-	}
52
-	
53
-	public TypeArgument instance(CodePosition position, GenericMapper mapper, StorageTag storage) {
54
-		if (storage != null && this.storage != null && !storage.equals(this.storage))
55
-			return new TypeArgument(new InvalidTypeID(position, CompileExceptionCode.INCOMPATIBLE_STORAGE_TAG, "Incompatible storage tag"), null);
56
-		
57
-		return type.instance(mapper, storage);
58
-	}
59
-	
60
-	public TypeArgument getNormalized() {
61
-		return type.getNormalized() == type ? this : new TypeArgument(type, storage);
62
-	}
63
-	
64
-	public StoredType stored() {
65
-		return new StoredType(type, storage == null ? AutoStorageTag.INSTANCE : storage);
66
-	}
67
-	
68
-	public StoredType stored(StorageTag storage) {
69
-		return new StoredType(type, storage);
70
-	}
71
-	
72
-	public TypeArgument argument(StorageTag storage) {
73
-		return storage == null ? this : new TypeArgument(type, storage);
74
-	}
75
-	
76
-	public boolean isBasic(BasicTypeID type) {
77
-		return this.type == type;
78
-	}
79
-	
80
-	@Override
81
-	public String toString() {
82
-		if (storage == null)
83
-			return type.toString();
84
-		
85
-		return type.toString() + "`" + storage.toString();
86
-	}
87
-
88
-	@Override
89
-	public int hashCode() {
90
-		int hash = 3;
91
-		hash = 53 * hash + Objects.hashCode(this.type);
92
-		hash = 53 * hash + Objects.hashCode(this.storage);
93
-		return hash;
94
-	}
95
-
96
-	@Override
97
-	public boolean equals(Object obj) {
98
-		if (this == obj) {
99
-			return true;
100
-		}
101
-		if (obj == null) {
102
-			return false;
103
-		}
104
-		if (getClass() != obj.getClass()) {
105
-			return false;
106
-		}
107
-		final TypeArgument other = (TypeArgument) obj;
108
-		return Objects.equals(this.type, other.type)
109
-				&& Objects.equals(this.storage, other.storage);
110
-	}
111
-}

+ 4
- 25
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java View File

@@ -12,7 +12,6 @@ import org.openzen.zenscript.codemodel.GenericMapper;
12 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
15
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
16 15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17 16
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
18 17
 
@@ -27,7 +26,7 @@ public interface TypeID {
27 26
 		return null;
28 27
 	}
29 28
 	
30
-	TypeArgument instance(GenericMapper mapper, StorageTag storage);
29
+	StoredType instance(GenericMapper mapper, StorageTag storage);
31 30
 	
32 31
 	TypeID getNormalized();
33 32
 	
@@ -41,8 +40,8 @@ public interface TypeID {
41 40
 	
42 41
 	// Infers type parameters for this type so it matches with targetType
43 42
 	// returns false if that isn't possible
44
-	default Map<TypeParameter, TypeArgument> inferTypeParameters(LocalMemberCache cache, TypeArgument targetType) {
45
-		return TypeMatcher.match(cache, new TypeArgument(this, null), targetType);
43
+	default Map<TypeParameter, StoredType> inferTypeParameters(LocalMemberCache cache, StoredType targetType) {
44
+		return TypeMatcher.match(cache, stored(), targetType);
46 45
 	}
47 46
 	
48 47
 	void extractTypeParameters(List<TypeParameter> typeParameters);
@@ -56,25 +55,13 @@ public interface TypeID {
56 55
 	}
57 56
 	
58 57
 	default StoredType stored() {
59
-		return new StoredType(this, AutoStorageTag.INSTANCE);
60
-	}
61
-	
62
-	default TypeArgument argument(StorageTag storage) {
63
-		return new TypeArgument(this, storage);
58
+		return new StoredType(this, null);
64 59
 	}
65 60
 	
66 61
 	default boolean isOptional() {
67 62
 		return false;
68 63
 	}
69 64
 	
70
-	default boolean isConst() {
71
-		return false;
72
-	}
73
-	
74
-	default boolean isImmutable() {
75
-		return false;
76
-	}
77
-	
78 65
 	default boolean isGeneric() {
79 66
 		return false;
80 67
 	}
@@ -85,14 +72,6 @@ public interface TypeID {
85 72
 		throw new UnsupportedOperationException("Not an optional type");
86 73
 	}
87 74
 	
88
-	default TypeID withoutConst() {
89
-		throw new UnsupportedOperationException("Not a const type");
90
-	}
91
-	
92
-	default TypeID withoutImmutable() {
93
-		throw new UnsupportedOperationException("Not an immutable type");
94
-	}
95
-	
96 75
 	default boolean isVariant() {
97 76
 		return false;
98 77
 	}

+ 14
- 18
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeMatcher.java View File

@@ -15,7 +15,7 @@ import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
15 15
  * @author Hoofdgebruiker
16 16
  */
17 17
 public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching, Boolean, RuntimeException> {
18
-	public static Map<TypeParameter, TypeArgument> match(LocalMemberCache cache, TypeArgument type, TypeArgument pattern) {
18
+	public static Map<TypeParameter, StoredType> match(LocalMemberCache cache, StoredType type, StoredType pattern) {
19 19
 		Matching matching = new Matching(cache, type);
20 20
 		if (pattern.type.accept(matching, INSTANCE))
21 21
 			return matching.mapping;
@@ -127,8 +127,8 @@ public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching,
127 127
 	@Override
128 128
 	public Boolean visitGeneric(Matching context, GenericTypeID generic) {
129 129
 		if (context.mapping.containsKey(generic.parameter)) {
130
-			TypeArgument argument = context.mapping.get(generic.parameter);
131
-			return argument.type == context.type && (argument.storage == null || argument.storage == context.type.storage);
130
+			StoredType argument = context.mapping.get(generic.parameter);
131
+			return argument.type == context.type && (argument.getSpecifiedStorage() == null || argument.getSpecifiedStorage() == context.type.getSpecifiedStorage());
132 132
 		} else if (context.type.type == generic || generic.matches(context.cache, context.type)) {
133 133
 			context.mapping.put(generic.parameter, context.type);
134 134
 			return true;
@@ -148,25 +148,21 @@ public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching,
148 148
 	}
149 149
 
150 150
 	@Override
151
-	public Boolean visitModified(Matching context, ModifiedTypeID type) {
152
-		if (context.type.type instanceof ModifiedTypeID) {
153
-			ModifiedTypeID modified = (ModifiedTypeID) context.type.type;
154
-			return match(context, modified.baseType.argument(null), type.baseType.argument(null));
151
+	public Boolean visitModified(Matching context, OptionalTypeID type) {
152
+		if (context.type.type instanceof OptionalTypeID) {
153
+			OptionalTypeID modified = (OptionalTypeID) context.type.type;
154
+			return match(context, modified.baseType.stored(), type.baseType.stored());
155 155
 		} else {
156 156
 			return false;
157 157
 		}
158 158
 	}
159 159
 
160
-	private boolean match(Matching context, TypeArgument type, TypeArgument pattern) {
161
-		if (pattern.storage != null && !pattern.storage.equals(type.storage))
160
+	private boolean match(Matching context, StoredType type, StoredType pattern) {
161
+		if (pattern.getSpecifiedStorage() != null && !pattern.getSpecifiedStorage().equals(type.getSpecifiedStorage()))
162 162
 			return false;
163 163
 		
164 164
 		return pattern.type.accept(context.withType(type), this);
165 165
 	}
166
-	
167
-	private boolean match(Matching context, StoredType type, StoredType pattern) {
168
-		return match(context, type.asArgument(), pattern.asArgument());
169
-	}
170 166
 
171 167
 	@Override
172 168
 	public Boolean visitGenericMap(Matching context, GenericMapTypeID map) {
@@ -175,22 +171,22 @@ public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching,
175 171
 		
176 172
 	public static final class Matching {
177 173
 		public final LocalMemberCache cache;
178
-		public final TypeArgument type;
179
-		public final Map<TypeParameter, TypeArgument> mapping;
174
+		public final StoredType type;
175
+		public final Map<TypeParameter, StoredType> mapping;
180 176
 		
181
-		public Matching(LocalMemberCache cache, TypeArgument type) {
177
+		public Matching(LocalMemberCache cache, StoredType type) {
182 178
 			this.cache = cache;
183 179
 			this.type = type;
184 180
 			mapping = new HashMap<>();
185 181
 		}
186 182
 		
187
-		private Matching(LocalMemberCache cache, TypeArgument type, Map<TypeParameter, TypeArgument> mapping) {
183
+		private Matching(LocalMemberCache cache, StoredType type, Map<TypeParameter, StoredType> mapping) {
188 184
 			this.cache = cache;
189 185
 			this.type = type;
190 186
 			this.mapping = mapping;
191 187
 		}
192 188
 		
193
-		public Matching withType(TypeArgument type) {
189
+		public Matching withType(StoredType type) {
194 190
 			return new Matching(cache, type, mapping);
195 191
 		}
196 192
 	}

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java View File

@@ -65,7 +65,7 @@ public class TypeParameterCollector implements TypeVisitorWithContext<Map<TypePa
65 65
 
66 66
 	@Override
67 67
 	public Void visitDefinition(Map<TypeParameter, GenericTypeID> context, DefinitionTypeID definition) {
68
-		for (TypeArgument argument : definition.typeArguments)
68
+		for (StoredType argument : definition.typeArguments)
69 69
 			argument.type.accept(context, this);
70 70
 		if (definition.outer != null)
71 71
 			visitDefinition(context, definition.outer);
@@ -85,7 +85,7 @@ public class TypeParameterCollector implements TypeVisitorWithContext<Map<TypePa
85 85
 	}
86 86
 
87 87
 	@Override
88
-	public Void visitModified(Map<TypeParameter, GenericTypeID> context, ModifiedTypeID type) {
88
+	public Void visitModified(Map<TypeParameter, GenericTypeID> context, OptionalTypeID type) {
89 89
 		type.baseType.accept(context, this);
90 90
 		return null;
91 91
 	}

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeSymbol.java View File

@@ -24,12 +24,12 @@ public class TypeSymbol implements ISymbol {
24 24
 	}
25 25
 	
26 26
 	@Override
27
-	public IPartialExpression getExpression(CodePosition position, BaseScope scope, TypeArgument[] typeArguments) {
27
+	public IPartialExpression getExpression(CodePosition position, BaseScope scope, StoredType[] typeArguments) {
28 28
 		return new PartialTypeExpression(position, scope.getTypeRegistry().getForDefinition(definition, typeArguments), typeArguments);
29 29
 	}
30 30
 
31 31
 	@Override
32
-	public TypeID getType(CodePosition position, TypeResolutionContext context, TypeArgument[] typeArguments) {
32
+	public TypeID getType(CodePosition position, TypeResolutionContext context, StoredType[] typeArguments) {
33 33
 		return context.getTypeRegistry().getForDefinition(definition, typeArguments);
34 34
 	}
35 35
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java View File

@@ -30,7 +30,7 @@ public interface TypeVisitor<T> {
30 30
 	
31 31
 	public T visitRange(RangeTypeID range);
32 32
 	
33
-	public T visitModified(ModifiedTypeID type);
33
+	public T visitOptional(OptionalTypeID type);
34 34
 	
35 35
 	public default T visitInvalid(InvalidTypeID type) {
36 36
 		throw new UnsupportedOperationException("Invalid type: " + type.message);

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitorWithContext.java View File

@@ -30,7 +30,7 @@ public interface TypeVisitorWithContext<C, R, E extends Exception> {
30 30
 	
31 31
 	R visitRange(C context, RangeTypeID range) throws E;
32 32
 	
33
-	R visitModified(C context, ModifiedTypeID type) throws E;
33
+	R visitModified(C context, OptionalTypeID type) throws E;
34 34
 	
35 35
 	default R visitInvalid(C context, InvalidTypeID type) throws E {
36 36
 		throw new RuntimeException("Invalid type: " + type.message);

+ 23
- 20
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java View File

@@ -53,7 +53,7 @@ import org.openzen.zenscript.codemodel.type.ArrayTypeID;
53 53
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
54 54
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
55 55
 import static org.openzen.zenscript.codemodel.type.BasicTypeID.*;
56
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
56
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
57 57
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
58 58
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
59 59
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -70,14 +70,12 @@ import org.openzen.zenscript.codemodel.member.IteratorMember;
70 70
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
71 71
 import org.openzen.zenscript.codemodel.type.StoredType;
72 72
 import org.openzen.zenscript.codemodel.type.StringTypeID;
73
-import org.openzen.zenscript.codemodel.type.TypeArgument;
74 73
 import org.openzen.zenscript.codemodel.type.TypeVisitorWithContext;
75 74
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
76 75
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
77 76
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
78 77
 import org.openzen.zenscript.codemodel.type.TypeID;
79 78
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
80
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
81 79
 
82 80
 /**
83 81
  *
@@ -102,7 +100,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
102 100
 			if (expansion.target == null)
103 101
 				throw new RuntimeException(expansion.position.toString() + ": Missing expansion target");
104 102
 			
105
-			Map<TypeParameter, TypeArgument> mapping = matchType(type, expansion.target);
103
+			Map<TypeParameter, StoredType> mapping = matchType(type, expansion.target);
106 104
 			if (mapping == null)
107 105
 				continue;
108 106
 			
@@ -122,7 +120,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
122 120
 		}
123 121
 	}
124 122
 	
125
-	private Map<TypeParameter, TypeArgument> matchType(StoredType type, TypeArgument pattern) {
123
+	private Map<TypeParameter, StoredType> matchType(StoredType type, StoredType pattern) {
126 124
 		return type.inferTypeParameters(cache, pattern);
127 125
 	}
128 126
 
@@ -177,7 +175,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
177 175
 	public Void visitString(Void context, StringTypeID string) {
178 176
 		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "string", Modifiers.EXPORT, null);
179 177
 		
180
-		constructor(builtin, STRING_CONSTRUCTOR_CHARACTERS, new StoredType(registry.getModified(ModifiedTypeID.MODIFIER_CONST, registry.getArray(CHAR.stored, 1)), BorrowStorageTag.INVOCATION));
178
+		constructor(builtin, STRING_CONSTRUCTOR_CHARACTERS, new StoredType(registry.getOptional(registry.getArray(CHAR.stored, 1)), BorrowStorageTag.INVOCATION));
181 179
 		
182 180
 		add(builtin, STRING_ADD_STRING, StringTypeID.BORROW, StringTypeID.UNIQUE);
183 181
 		indexGet(builtin, STRING_INDEXGET, USIZE.stored, CHAR.stored);
@@ -204,7 +202,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
204 202
 		HighLevelDefinition definition = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
205 203
 		StoredType baseType = array.elementType;
206 204
 		int dimension = array.dimension;
207
-		StorageTag storage = type.storage;
205
+		StorageTag storage = type.getActualStorage();
208 206
 
209 207
 		FunctionParameter[] indexGetParameters = new FunctionParameter[dimension];
210 208
 		for (int i = 0; i < indexGetParameters.length; i++)
@@ -388,12 +386,17 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
388 386
 	@Override
389 387
 	public Void visitGenericMap(Void context, GenericMapTypeID map) {
390 388
 		TypeParameter functionParameter = new TypeParameter(BUILTIN, "T");
391
-		Map<TypeParameter, TypeArgument> parameterFilled = Collections.singletonMap(map.key, new TypeArgument(registry.getGeneric(functionParameter), null));
389
+		Map<TypeParameter, StoredType> parameterFilled = Collections.singletonMap(map.key, registry.getGeneric(functionParameter).stored());
392 390
 		StoredType valueType = map.value.instance(new GenericMapper(registry, parameterFilled));
393 391
 		
394
-		FunctionHeader getOptionalHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, registry.getOptional(valueType.type).stored(valueType.storage), null, null, new FunctionParameter[0]);
392
+		FunctionHeader getOptionalHeader = new FunctionHeader(
393
+				new TypeParameter[] { functionParameter },
394
+				registry.getOptional(valueType.type).stored(valueType.getSpecifiedStorage()),
395
+				null,
396
+				null,
397
+				FunctionParameter.NONE);
395 398
 		FunctionHeader putHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, VOID.stored, null, null, new FunctionParameter(valueType));
396
-		FunctionHeader containsHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BOOL.stored, null, null, new FunctionParameter[0]);
399
+		FunctionHeader containsHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BOOL.stored, null, null, FunctionParameter.NONE);
397 400
 		
398 401
 		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
399 402
 		constructor(builtin, GENERICMAP_CONSTRUCTOR);
@@ -443,7 +446,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
443 446
 		HighLevelDefinition definition = definitionType.definition;
444 447
 		GenericMapper mapper = null;
445 448
 		if (definitionType.hasTypeParameters() || (definitionType.outer != null && definitionType.outer.hasTypeParameters())) {
446
-			Map<TypeParameter, TypeArgument> mapping = definitionType.getTypeParameterMapping();
449
+			Map<TypeParameter, StoredType> mapping = definitionType.getTypeParameterMapping();
447 450
 			mapper = new GenericMapper(registry, mapping);
448 451
 		}
449 452
 		
@@ -508,7 +511,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
508 511
 			for (int i = 0; i < constValues.length; i++)
509 512
 				constValues[i] = new EnumConstantExpression(BUILTIN, definitionType, enumConstants.get(i));
510 513
 			
511
-			constant(definition, ENUM_VALUES, "values", new ArrayExpression(BUILTIN, constValues, registry.getArray(definitionType.stored(ValueStorageTag.INSTANCE), 1).stored(StaticStorageTag.INSTANCE)));
514
+			constant(definition, ENUM_VALUES, "values", new ArrayExpression(BUILTIN, constValues, registry.getArray(definitionType.stored(), 1).stored(StaticStorageTag.INSTANCE)));
512 515
 			compare(definition, ENUM_COMPARE, type);
513 516
 			
514 517
 			if (!members.canCast(StringTypeID.STATIC)) {
@@ -519,12 +522,12 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
519 522
 		if (definition instanceof InterfaceDefinition) {
520 523
 			InterfaceDefinition interfaceDefinition = (InterfaceDefinition)definition;
521 524
 			for (TypeID baseType : interfaceDefinition.baseInterfaces)
522
-				cache.get(baseType.instance(mapper, type.storage).stored())
525
+				cache.get(baseType.instance(mapper, type.getSpecifiedStorage()))
523 526
 						.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
524 527
 		}
525 528
 		
526 529
 		if (definitionType.superType != null) {
527
-			cache.get(definitionType.superType.stored(type.storage))
530
+			cache.get(definitionType.superType.stored(type.getSpecifiedStorage()))
528 531
 					.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
529 532
 		} else {
530 533
 			getter(definition, OBJECT_HASHCODE, "objectHashCode", INT.stored);
@@ -573,7 +576,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
573 576
 	}
574 577
 
575 578
 	@Override
576
-	public Void visitModified(Void context, ModifiedTypeID modified) {
579
+	public Void visitModified(Void context, OptionalTypeID modified) {
577 580
 		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "modified", Modifiers.EXPORT, null);
578 581
 		modified.baseType.accept(context, this);
579 582
 		
@@ -836,7 +839,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
836 839
 		method(builtin, INT_COUNT_LOW_ONES, "countLowOnes", USIZE.stored);
837 840
 		method(builtin, INT_COUNT_HIGH_ONES, "countHighOnes", USIZE.stored);
838 841
 		
839
-		StoredType optionalUSize = registry.getOptional(USIZE).stored(ValueStorageTag.INSTANCE);
842
+		StoredType optionalUSize = registry.getOptional(USIZE).stored();
840 843
 		getter(builtin, INT_HIGHEST_ONE_BIT, "highestOneBit", optionalUSize);
841 844
 		getter(builtin, INT_LOWEST_ONE_BIT, "lowestOneBit", optionalUSize);
842 845
 		getter(builtin, INT_HIGHEST_ZERO_BIT, "highestZeroBit", optionalUSize);
@@ -916,7 +919,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
916 919
 		method(builtin, UINT_COUNT_LOW_ONES, "countLowOnes", USIZE.stored);
917 920
 		method(builtin, UINT_COUNT_HIGH_ONES, "countHighOnes", USIZE.stored);
918 921
 		
919
-		StoredType optionalUSize = registry.getOptional(USIZE).stored(ValueStorageTag.INSTANCE);
922
+		StoredType optionalUSize = registry.getOptional(USIZE).stored();
920 923
 		getter(builtin, UINT_HIGHEST_ONE_BIT, "highestOneBit", optionalUSize);
921 924
 		getter(builtin, UINT_LOWEST_ONE_BIT, "lowestOneBit", optionalUSize);
922 925
 		getter(builtin, UINT_HIGHEST_ZERO_BIT, "highestZeroBit", optionalUSize);
@@ -989,7 +992,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
989 992
 		method(builtin, LONG_COUNT_LOW_ONES, "countLowOnes", USIZE.stored);
990 993
 		method(builtin, LONG_COUNT_HIGH_ONES, "countHighOnes", USIZE.stored);
991 994
 		
992
-		StoredType optionalUSize = registry.getOptional(USIZE).stored(ValueStorageTag.INSTANCE);
995
+		StoredType optionalUSize = registry.getOptional(USIZE).stored();
993 996
 		getter(builtin, LONG_HIGHEST_ONE_BIT, "highestOneBit", optionalUSize);
994 997
 		getter(builtin, LONG_LOWEST_ONE_BIT, "lowestOneBit", optionalUSize);
995 998
 		getter(builtin, LONG_HIGHEST_ZERO_BIT, "highestZeroBit", optionalUSize);
@@ -1061,7 +1064,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
1061 1064
 		method(builtin, ULONG_COUNT_LOW_ONES, "countLowOnes", USIZE.stored);
1062 1065
 		method(builtin, ULONG_COUNT_HIGH_ONES, "countHighOnes", USIZE.stored);
1063 1066
 		
1064
-		StoredType optionalUSize = registry.getOptional(USIZE).stored(ValueStorageTag.INSTANCE);
1067
+		StoredType optionalUSize = registry.getOptional(USIZE).stored();
1065 1068
 		getter(builtin, ULONG_HIGHEST_ONE_BIT, "highestOneBit", optionalUSize);
1066 1069
 		getter(builtin, ULONG_LOWEST_ONE_BIT, "lowestOneBit", optionalUSize);
1067 1070
 		getter(builtin, ULONG_HIGHEST_ZERO_BIT, "highestZeroBit", optionalUSize);
@@ -1138,7 +1141,7 @@ public class TypeMemberBuilder implements TypeVisitorWithContext<Void, Void, Run
1138 1141
 		method(builtin, USIZE_COUNT_LOW_ONES, "countLowOnes", USIZE.stored);
1139 1142
 		method(builtin, USIZE_COUNT_HIGH_ONES, "countHighOnes", USIZE.stored);
1140 1143
 		
1141
-		StoredType optionalUSize = registry.getOptional(USIZE).stored(ValueStorageTag.INSTANCE);
1144
+		StoredType optionalUSize = registry.getOptional(USIZE).stored();
1142 1145
 		getter(builtin, USIZE_HIGHEST_ONE_BIT, "highestOneBit", optionalUSize);
1143 1146
 		getter(builtin, USIZE_LOWEST_ONE_BIT, "lowestOneBit", optionalUSize);
1144 1147
 		getter(builtin, USIZE_HIGHEST_ZERO_BIT, "highestZeroBit", optionalUSize);

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java View File

@@ -33,7 +33,6 @@ import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
33 33
 import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
34 34
 import org.openzen.zenscript.codemodel.scope.TypeScope;
35 35
 import org.openzen.zenscript.codemodel.type.StoredType;
36
-import org.openzen.zenscript.codemodel.type.TypeArgument;
37 36
 import org.openzen.zenscript.codemodel.type.TypeID;
38 37
 
39 38
 /**
@@ -269,7 +268,7 @@ public class TypeMemberGroup {
269 268
 			
270 269
 			if (header.typeParameters != null) {
271 270
 				for (StoredType resultHint : typeHints) {
272
-					Map<TypeParameter, TypeArgument> mapping = header.getReturnType().inferTypeParameters(scope.getMemberCache(), resultHint.asArgument());
271
+					Map<TypeParameter, StoredType> mapping = header.getReturnType().inferTypeParameters(scope.getMemberCache(), resultHint);
273 272
 					if (mapping != null) {
274 273
 						header = header.withGenericArguments(scope.getTypeRegistry(), scope.getLocalTypeParameters().getInner(scope.getTypeRegistry(), mapping));
275 274
 						break;

+ 7
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java View File

@@ -20,7 +20,6 @@ import org.openzen.zenscript.codemodel.expression.CheckNullExpression;
20 20
 import org.openzen.zenscript.codemodel.expression.Expression;
21 21
 import org.openzen.zenscript.codemodel.expression.InterfaceCastExpression;
22 22
 import org.openzen.zenscript.codemodel.expression.InvalidExpression;
23
-import org.openzen.zenscript.codemodel.expression.MakeConstExpression;
24 23
 import org.openzen.zenscript.codemodel.expression.NullExpression;
25 24
 import org.openzen.zenscript.codemodel.expression.StorageCastExpression;
26 25
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
@@ -90,14 +89,14 @@ public final class TypeMembers {
90 89
 		if (superType != null) {
91 90
 			if (superType == other)
92 91
 				return true;
93
-			if (cache.get(superType.stored(type.storage)).extendsOrImplements(other))
92
+			if (cache.get(superType.stored(type.getActualStorage())).extendsOrImplements(other))
94 93
 				return true;
95 94
 		}
96 95
 		
97 96
 		for (TypeMember<ImplementationMemberRef> implementation : implementations) {
98 97
 			if (implementation.member.implementsType.equals(other)) // TODO: for some reason duplicate types are generated
99 98
 				return true;
100
-			if (cache.get(implementation.member.implementsType.stored(type.storage)).extendsOrImplements(other))
99
+			if (cache.get(implementation.member.implementsType.stored(type.getActualStorage())).extendsOrImplements(other))
101 100
 				return true;
102 101
 		}
103 102
 		
@@ -110,7 +109,7 @@ public final class TypeMembers {
110 109
 		if (superType != null) {
111 110
 			if (superType == other)
112 111
 				return true;
113
-			if (cache.get(superType.stored(type.storage)).extendsType(other))
112
+			if (cache.get(superType.stored(type.getActualStorage())).extendsType(other))
114 113
 				return true;
115 114
 		}
116 115
 		
@@ -403,7 +402,7 @@ public final class TypeMembers {
403 402
 		if (type.type == BasicTypeID.NULL && toType.type.isOptional())
404 403
 			return true;
405 404
 		
406
-		if (!type.storage.canCastTo(toType.storage) && !toType.storage.canCastFrom(type.storage))
405
+		if (!type.getActualStorage().canCastTo(toType.getActualStorage()) && !toType.getActualStorage().canCastFrom(type.getActualStorage()))
407 406
 			return false;
408 407
 		
409 408
 		if (toType.isOptional() && canCastImplicit(toType.withoutOptional()))
@@ -417,7 +416,7 @@ public final class TypeMembers {
417 416
 	private boolean areEquivalent(StoredType fromType, StoredType toType) {
418 417
 		if (fromType == toType)
419 418
 			return true;
420
-		if (!fromType.storage.canCastTo(toType.storage) && !toType.storage.canCastFrom(fromType.storage))
419
+		if (!fromType.getActualStorage().canCastTo(toType.getActualStorage()) && !toType.getActualStorage().canCastFrom(fromType.getActualStorage()))
421 420
 			return false;
422 421
 		
423 422
 		return fromType.type == toType.type;
@@ -461,7 +460,7 @@ public final class TypeMembers {
461 460
 			return value;
462 461
 		
463 462
 		if (!(toType.type instanceof StringTypeID))
464
-			System.out.println(position + ": " + value.type.storage + " -> " + toType.storage);
463
+			System.out.println(position + ": " + value.type.getActualStorage() + " -> " + toType.getActualStorage());
465 464
 		
466 465
 		return new StorageCastExpression(position, value, toType);
467 466
 	}
@@ -489,7 +488,7 @@ public final class TypeMembers {
489 488
 		}
490 489
 		for (TypeMember<ImplementationMemberRef> implementation : implementations) {
491 490
 			if (implementation.member.implementsType.equals(toType.type))
492
-				return castEquivalent(position, new InterfaceCastExpression(position, value, toType.type.stored(type.storage)), toType);
491
+				return castEquivalent(position, new InterfaceCastExpression(position, value, toType.type.stored(type.getActualStorage())), toType);
493 492
 		}
494 493
 		if (extendsType(toType.type))
495 494
 			return new SupertypeCastExpression(position, value, toType);

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageTag.java View File

@@ -22,7 +22,7 @@ public class BorrowStorageTag implements StorageTag {
22 22
 	
23 23
 	@Override
24 24
 	public String toString() {
25
-		return "borrow";
25
+		return this == THIS ? "borrow:this" : "borrow";
26 26
 	}
27 27
 
28 28
 	@Override

+ 52
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/MutableStorageTag.java View File

@@ -0,0 +1,52 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class MutableStorageTag implements StorageTag {
13
+	public static final MutableStorageTag INVOCATION = new MutableStorageTag();
14
+	public static final MutableStorageTag THIS = new MutableStorageTag();
15
+	
16
+	private MutableStorageTag() {} // TODO: scoped borrow
17
+
18
+	@Override
19
+	public StorageType getType() {
20
+		return BorrowStorageType.INSTANCE;
21
+	}
22
+	
23
+	@Override
24
+	public String toString() {
25
+		return this == THIS ? "mutable:this" : "mutable";
26
+	}
27
+
28
+	@Override
29
+	public boolean canCastTo(StorageTag other) {
30
+		return this == other;
31
+	}
32
+
33
+	@Override
34
+	public boolean canCastFrom(StorageTag other) {
35
+		return true;
36
+	}
37
+
38
+	@Override
39
+	public boolean isDestructible() {
40
+		return false;
41
+	}
42
+	
43
+	@Override
44
+	public boolean isConst() {
45
+		return true;
46
+	}
47
+	
48
+	@Override
49
+	public boolean isImmutable() {
50
+		return true;
51
+	}
52
+}

+ 36
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/MutableStorageType.java View File

@@ -0,0 +1,36 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.type.storage;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileExceptionCode;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class MutableStorageType implements StorageType {
16
+	public static final MutableStorageType INSTANCE = new MutableStorageType();
17
+
18
+	private MutableStorageType() {}
19
+
20
+	@Override
21
+	public String getName() {
22
+		return "mutable";
23
+	}
24
+
25
+	@Override
26
+	public StorageTag instance(CodePosition position, String[] arguments) {
27
+		if (arguments.length > 0) {
28
+			if (arguments.length == 1 && arguments[0].equals("this"))
29
+				return MutableStorageTag.THIS;
30
+			
31
+			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "mutable storage type doesn't take arguments");
32
+		}
33
+		
34
+		return MutableStorageTag.INVOCATION;
35
+	}
36
+}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageTag.java View File

@@ -28,7 +28,7 @@ public interface StorageTag {
28 28
 		if (major == AutoStorageTag.INSTANCE || major == null)
29 29
 			return minor;
30 30
 		if (!minor.equals(major))
31
-			throw new IllegalArgumentException("Could not unite storage types"); // TODO: proper reporting
31
+			throw new IllegalArgumentException("Could not unite storage types: " + minor + " and " + major); // TODO: proper reporting
32 32
 		
33 33
 		return major;
34 34
 	}

+ 1
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java View File

@@ -16,6 +16,7 @@ public interface StorageType {
16 16
 		return new StorageType[] {
17 17
 			AutoStorageType.INSTANCE,
18 18
 			BorrowStorageType.INSTANCE,
19
+			MutableStorageType.INSTANCE,
19 20
 			SharedStorageType.INSTANCE,
20 21
 			StaticStorageType.INSTANCE,
21 22
 			UniqueStorageType.INSTANCE

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/ValueStorageTag.java View File

@@ -43,4 +43,9 @@ public class ValueStorageTag implements StorageTag {
43 43
 	public boolean isImmutable() {
44 44
 		return false;
45 45
 	}
46
+	
47
+	@Override
48
+	public String toString() {
49
+		return "value";
50
+	}
46 51
 }

+ 1
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaBoxingTypeVisitor.java View File

@@ -122,7 +122,7 @@ public class JavaBoxingTypeVisitor implements TypeVisitorWithContext<StoredType,
122 122
 	}
123 123
 
124 124
 	@Override
125
-	public Void visitModified(StoredType context, ModifiedTypeID type) {
125
+	public Void visitModified(StoredType context, OptionalTypeID type) {
126 126
 		//NO-OP
127 127
 		return null;
128 128
 	}

+ 2
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java View File

@@ -2381,8 +2381,8 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
2381 2381
 		expression.value.accept(this);
2382 2382
 		
2383 2383
 		if (expression.type.isDestructible()) { // only destructible types matter here; nondestructible types never need conversion
2384
-			StorageTag fromTag = expression.value.type.storage;
2385
-			StorageTag toTag = expression.type.storage;
2384
+			StorageTag fromTag = expression.value.type.getActualStorage();
2385
+			StorageTag toTag = expression.type.getActualStorage();
2386 2386
 			if (JavaTypeUtils.isShared(fromTag) && toTag == BorrowStorageTag.INVOCATION) {
2387 2387
 				// Shared<T>.get()
2388 2388
 				javaWriter.invokeVirtual(SHARED_GET);

+ 2
- 6
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaSyntheticTypeSignatureConverter.java View File

@@ -19,7 +19,7 @@ import org.openzen.zenscript.codemodel.type.FunctionTypeID;
19 19
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
20 20
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
21 21
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
22
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
22
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
23 23
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
24 24
 import org.openzen.zenscript.codemodel.type.StoredType;
25 25
 import org.openzen.zenscript.codemodel.type.StringTypeID;
@@ -145,12 +145,8 @@ public class JavaSyntheticTypeSignatureConverter implements TypeVisitorWithConte
145 145
 	}
146 146
 
147 147
 	@Override
148
-	public String visitModified(StoredType context, ModifiedTypeID type) {
148
+	public String visitModified(StoredType context, OptionalTypeID type) {
149 149
 		StringBuilder result = new StringBuilder();
150
-		if (type.isConst())
151
-			result.append("Const");
152
-		if (type.isImmutable())
153
-			result.append("Immutable");
154 150
 		if (type.isOptional())
155 151
 			result.append("Optional");
156 152
 		

+ 2
- 5
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeDescriptorVisitor.java View File

@@ -127,11 +127,8 @@ public class JavaTypeDescriptorVisitor implements TypeVisitor<String> {
127 127
     }
128 128
 
129 129
     @Override
130
-    public String visitModified(ModifiedTypeID modified) {
131
-		if (modified.isOptional())
132
-			return modified.withoutOptional().accept(forOptional);
133
-		
134
-		return modified.baseType.accept(this);
130
+    public String visitOptional(OptionalTypeID modified) {
131
+		return modified.withoutOptional().accept(forOptional);
135 132
     }
136 133
 
137 134
 	@Override

+ 2
- 2
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeGenericVisitor.java View File

@@ -122,7 +122,7 @@ public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType
122 122
 
123 123
 		if (definition.typeArguments.length > 0) {
124 124
 			builder.append("<");
125
-			for (TypeArgument typeParameter : definition.typeArguments) {
125
+			for (StoredType typeParameter : definition.typeArguments) {
126 126
 				builder.append(typeParameter.type.accept(null, this));
127 127
 			}
128 128
 			builder.append(">");
@@ -142,7 +142,7 @@ public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType
142 142
 	}
143 143
 
144 144
 	@Override
145
-	public String visitModified(StoredType context, ModifiedTypeID type) {
145
+	public String visitModified(StoredType context, OptionalTypeID type) {
146 146
 		return type.baseType.accept(context, this);
147 147
 	}
148 148
 }

+ 2
- 2
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInfo.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.type.FunctionTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
16
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
16
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.StoredType;
19 19
 import org.openzen.zenscript.codemodel.type.StringTypeID;
@@ -95,7 +95,7 @@ public class JavaTypeInfo {
95 95
 		}
96 96
 
97 97
 		@Override
98
-		public JavaTypeInfo visitModified(StoredType context, ModifiedTypeID type) {
98
+		public JavaTypeInfo visitModified(StoredType context, OptionalTypeID type) {
99 99
 			return type.baseType.accept(null, this);
100 100
 		}
101 101
 	}

+ 1
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInternalNameVisitor.java View File

@@ -108,7 +108,7 @@ public class JavaTypeInternalNameVisitor implements TypeVisitorWithContext<Store
108 108
     }
109 109
 
110 110
     @Override
111
-    public String visitModified(StoredType context, ModifiedTypeID modified) {
111
+    public String visitModified(StoredType context, OptionalTypeID modified) {
112 112
 		if (modified.isOptional())
113 113
 			return modified.withoutOptional().accept(context, forOptional);
114 114
 		

+ 2
- 6
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeNameVisitor.java View File

@@ -9,7 +9,7 @@ import org.openzen.zenscript.codemodel.FunctionParameter;
9 9
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
10 10
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
11 11
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
12
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -114,14 +114,10 @@ public class JavaTypeNameVisitor implements TypeVisitorWithContext<StoredType, S
114 114
 	}
115 115
 
116 116
 	@Override
117
-	public String visitModified(StoredType context, ModifiedTypeID type) {
117
+	public String visitModified(StoredType context, OptionalTypeID type) {
118 118
 		StringBuilder result = new StringBuilder();
119
-		if (type.isConst())
120
-			result.append("Const");
121 119
 		if (type.isOptional())
122 120
 			result.append("Optional");
123
-		if (type.isImmutable())
124
-			result.append("Immutable");
125 121
 		result.append(type.baseType.accept(context, this));
126 122
 		return result.toString();
127 123
 	}

+ 1
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeUtils.java View File

@@ -18,7 +18,7 @@ public class JavaTypeUtils {
18 18
 	private JavaTypeUtils() {}
19 19
 	
20 20
 	public static boolean isShared(StoredType type) {
21
-		return type.type.isDestructible() && isShared(type.storage);
21
+		return type.type.isDestructible() && isShared(type.getActualStorage());
22 22
 	}
23 23
 	
24 24
 	public static boolean isShared(StorageTag storage) {

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java View File

@@ -9,7 +9,7 @@ import org.openzen.zenscript.codemodel.expression.CallArguments;
9 9
 import org.openzen.zenscript.codemodel.expression.Expression;
10 10
 import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
11 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
-import org.openzen.zenscript.codemodel.type.TypeArgument;
12
+import org.openzen.zenscript.codemodel.type.StoredType;
13 13
 import org.openzen.zenscript.formattershared.ExpressionString;
14 14
 import org.openzen.zenscript.formattershared.StatementFormattingTarget;
15 15
 import org.openzen.zenscript.javasource.scope.JavaSourceStatementScope;
@@ -52,7 +52,7 @@ public class FormattingUtils {
52 52
 			result.append("<");
53 53
 			
54 54
 			int index = 0;
55
-			for (TypeArgument typeArgument : arguments.typeArguments) {
55
+			for (StoredType typeArgument : arguments.typeArguments) {
56 56
 				if (index > 0)
57 57
 					result.append(", ");
58 58
 				result.append(scope.type(typeArgument));
@@ -79,7 +79,7 @@ public class FormattingUtils {
79 79
 			result.append("<");
80 80
 			
81 81
 			int index = 0;
82
-			for (TypeArgument typeArgument : arguments.typeArguments) {
82
+			for (StoredType typeArgument : arguments.typeArguments) {
83 83
 				if (index > 0)
84 84
 					result.append(", ");
85 85
 				result.append(scope.type(typeArgument));

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java View File

@@ -29,7 +29,7 @@ import org.openzen.zenscript.codemodel.statement.BlockStatement;
29 29
 import org.openzen.zenscript.codemodel.statement.Statement;
30 30
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
31 31
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
32
-import org.openzen.zenscript.codemodel.type.TypeArgument;
32
+import org.openzen.zenscript.codemodel.type.StoredType;
33 33
 import org.openzen.zenscript.codemodel.type.TypeID;
34 34
 import org.openzen.zenscript.compiler.CompileScope;
35 35
 import org.openzen.zenscript.compiler.SemanticModule;
@@ -370,9 +370,9 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
370 370
 	
371 371
 	private void compileMembers(JavaSourceFileScope scope, HighLevelDefinition definition) {
372 372
 		if (definition.hasTag(JavaNativeClass.class)) {
373
-			TypeArgument[] typeParameters = new TypeArgument[definition.getNumberOfGenericParameters()];
373
+			StoredType[] typeParameters = new StoredType[definition.getNumberOfGenericParameters()];
374 374
 			for (int i = 0; i < typeParameters.length; i++)
375
-				typeParameters[i] = new TypeArgument(scope.semanticScope.getTypeRegistry().getGeneric(definition.typeParameters[i]), definition.typeParameters[i].storage);
375
+				typeParameters[i] = scope.semanticScope.getTypeRegistry().getGeneric(definition.typeParameters[i]).stored(definition.typeParameters[i].storage);
376 376
 			TypeID targetType = scope.semanticScope.getTypeRegistry().getForDefinition(definition, typeParameters);
377 377
 			
378 378
 			JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, targetType, definition.typeParameters, indent + settings.indent, output, scope, definition);

+ 4
- 5
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java View File

@@ -91,7 +91,6 @@ import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
91 91
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
92 92
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
93 93
 import org.openzen.zenscript.codemodel.type.StoredType;
94
-import org.openzen.zenscript.codemodel.type.TypeArgument;
95 94
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
96 95
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
97 96
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
@@ -670,8 +669,8 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
670 669
 	public ExpressionString visitStorageCast(StorageCastExpression expression) {
671 670
 		ExpressionString value = expression.accept(this);
672 671
 		if (expression.value.type.isDestructible()) {
673
-			StorageTag fromTag = expression.value.type.storage;
674
-			StorageTag toTag = expression.type.storage;
672
+			StorageTag fromTag = expression.value.type.getActualStorage();
673
+			StorageTag toTag = expression.type.getActualStorage();
675 674
 			if (JavaTypeUtils.isShared(fromTag)) {
676 675
 				// Shared<T>.get()
677 676
 				return value.unaryPostfix(JavaOperator.CALL, ".get()");
@@ -761,7 +760,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
761 760
 		return expression.value.accept(this);
762 761
 	}
763 762
 	
764
-	private String formatTypeArguments(TypeArgument[] types) {
763
+	private String formatTypeArguments(StoredType[] types) {
765 764
 		if (types == null || types.length == 0)
766 765
 			return "";
767 766
 		
@@ -827,7 +826,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
827 826
 		output.append(method).append("(");
828 827
 		boolean first = true;
829 828
 		if (expression.arguments.typeArguments != null) {
830
-			for (TypeArgument typeArgument : expression.arguments.typeArguments) {
829
+			for (StoredType typeArgument : expression.arguments.typeArguments) {
831 830
 				if (!first)
832 831
 					output.append(", ");
833 832
 				

+ 2
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticHelperGenerator.java View File

@@ -19,7 +19,7 @@ import java.util.Map;
19 19
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
20 20
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
21 21
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
22
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
22
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
23 23
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
24 24
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
25 25
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -204,7 +204,7 @@ public class JavaSourceSyntheticHelperGenerator {
204 204
 		}
205 205
 
206 206
 		@Override
207
-		public ArrayKind visitModified(ModifiedTypeID type) {
207
+		public ArrayKind visitOptional(OptionalTypeID type) {
208 208
 			return ArrayKind.OBJECT;
209 209
 		}
210 210
 	}

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java View File

@@ -12,7 +12,7 @@ import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
12 12
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
15
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
16 16
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -198,8 +198,8 @@ public class JavaSourceTypeVisitor implements TypeVisitor<String>, GenericParame
198 198
 	}
199 199
 
200 200
 	@Override
201
-	public String visitModified(ModifiedTypeID optional) {
202
-		if (optional.isOptional() && optional.withoutOptional() == BasicTypeID.USIZE)
201
+	public String visitOptional(OptionalTypeID optional) {
202
+		if (optional.withoutOptional() == BasicTypeID.USIZE)
203 203
 			return "int"; // usize? is an int
204 204
 		
205 205
 		return optional.baseType.accept(new JavaSourceObjectTypeVisitor(importer, context));

+ 0
- 5
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceStatementScope.java View File

@@ -15,7 +15,6 @@ import org.openzen.zenscript.codemodel.statement.LoopStatement;
15 15
 import org.openzen.zenscript.codemodel.statement.VarStatement;
16 16
 import org.openzen.zenscript.codemodel.statement.VariableID;
17 17
 import org.openzen.zenscript.codemodel.type.StoredType;
18
-import org.openzen.zenscript.codemodel.type.TypeArgument;
19 18
 import org.openzen.zenscript.codemodel.type.TypeID;
20 19
 import org.openzen.zenscript.formattershared.ExpressionString;
21 20
 import org.openzen.zenscript.formattershared.StatementFormattingTarget;
@@ -82,10 +81,6 @@ public class JavaSourceStatementScope {
82 81
 		return fileScope.type(type);
83 82
 	}
84 83
 	
85
-	public String type(TypeArgument type) {
86
-		return type.storage == null ? type(type.type) : type(type.stored());
87
-	}
88
-	
89 84
 	public String type(TypeID type) {
90 85
 		return fileScope.type(type);
91 86
 	}

+ 5
- 5
ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/CodeReader.java View File

@@ -63,7 +63,7 @@ import org.openzen.zenscript.codemodel.type.ArrayTypeID;
63 63
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
64 64
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
65 65
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
66
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
66
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
67 67
 import org.openzen.zenscript.codemodel.type.StoredType;
68 68
 import org.openzen.zenscript.codemodel.type.StringTypeID;
69 69
 import org.openzen.zenscript.codemodel.type.TypeID;
@@ -336,9 +336,9 @@ public class CodeReader implements CodeSerializationInput {
336 336
 			case TypeEncoding.TYPE_OPTIONAL:
337 337
 				return registry.getOptional(deserializeTypeID(context));
338 338
 			case TypeEncoding.TYPE_CONST:
339
-				return registry.getModified(ModifiedTypeID.MODIFIER_CONST, deserializeTypeID(context));
339
+				return registry.getModified(OptionalTypeID.MODIFIER_CONST, deserializeTypeID(context));
340 340
 			case TypeEncoding.TYPE_IMMUTABLE:
341
-				return registry.getModified(ModifiedTypeID.MODIFIER_IMMUTABLE, deserializeTypeID(context));
341
+				return registry.getModified(OptionalTypeID.MODIFIER_IMMUTABLE, deserializeTypeID(context));
342 342
 			default:
343 343
 				throw new IllegalArgumentException("Unknown type: " + type);
344 344
 		}
@@ -794,7 +794,7 @@ public class CodeReader implements CodeSerializationInput {
794 794
 			}
795 795
 			case ExpressionEncoding.TYPE_MAKE_CONST: {
796 796
 				Expression value = deserializeExpression(context);
797
-				StoredType constType = registry.getModified(ModifiedTypeID.MODIFIER_CONST, value.type.type).stored(value.type.storage);
797
+				StoredType constType = registry.getModified(OptionalTypeID.MODIFIER_CONST, value.type.type).stored(value.type.getActualStorage());
798 798
 				return new MakeConstExpression(position, value, constType);
799 799
 			}
800 800
 			case ExpressionEncoding.TYPE_MAP: {
@@ -933,7 +933,7 @@ public class CodeReader implements CodeSerializationInput {
933 933
 			}
934 934
 			case ExpressionEncoding.TYPE_WRAP_OPTIONAL: {
935 935
 				Expression value = deserializeExpression(context);
936
-				StoredType optionalType = registry.getOptional(value.type.type).stored(value.type.storage);
936
+				StoredType optionalType = registry.getOptional(value.type.type).stored(value.type.getActualStorage());
937 937
 				return new WrapOptionalExpression(position, value, optionalType);
938 938
 			}
939 939
 			default:

+ 2
- 2
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/TypeSerializer.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.FunctionTypeID;
16 16
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
19
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
19
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
20 20
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.codemodel.type.StringTypeID;
@@ -137,7 +137,7 @@ public class TypeSerializer implements TypeVisitorWithContext<TypeContext, Void,
137 137
 	}
138 138
 
139 139
 	@Override
140
-	public Void visitModified(TypeContext context, ModifiedTypeID type) {
140
+	public Void visitModified(TypeContext context, OptionalTypeID type) {
141 141
 		if (type.isOptional()) {
142 142
 			output.writeUInt(TypeEncoding.TYPE_OPTIONAL);
143 143
 			type.withoutOptional().accept(context, this);

+ 5
- 5
Parser/src/main/java/org/openzen/zenscript/parser/ParsedAnnotation.java View File

@@ -34,7 +34,7 @@ import org.openzen.zenscript.parser.expression.ParsedCallArguments;
34 34
 import org.openzen.zenscript.parser.type.IParsedType;
35 35
 import org.openzen.zenscript.codemodel.type.TypeID;
36 36
 import org.openzen.zenscript.codemodel.annotations.ParameterAnnotation;
37
-import org.openzen.zenscript.codemodel.type.TypeArgument;
37
+import org.openzen.zenscript.codemodel.type.StoredType;
38 38
 
39 39
 /**
40 40
  *
@@ -134,7 +134,7 @@ public class ParsedAnnotation {
134 134
 		try {
135 135
 			AnnotationDefinition annotationType = type.compileAnnotation(scope);
136 136
 			ExpressionScope evalScope = annotationType.getScopeForMember(member, scope);
137
-			TypeArgument[] types = type.compileTypeArguments(scope);
137
+			StoredType[] types = type.compileTypeArguments(scope);
138 138
 			CallArguments cArguments = arguments.compileCall(position, evalScope, types, annotationType.getInitializers(scope));
139 139
 			return annotationType.createForMember(position, cArguments);
140 140
 		} catch (CompileException ex) {
@@ -149,7 +149,7 @@ public class ParsedAnnotation {
149 149
 		
150 150
 		try {
151 151
 			ExpressionScope evalScope = annotationType.getScopeForType(definition, scope);
152
-			TypeArgument[] types = type.compileTypeArguments(scope);
152
+			StoredType[] types = type.compileTypeArguments(scope);
153 153
 			CallArguments cArguments = arguments.compileCall(position, evalScope, types, annotationType.getInitializers(scope));
154 154
 			return annotationType.createForDefinition(position, cArguments);
155 155
 		} catch (CompileException ex) {
@@ -164,7 +164,7 @@ public class ParsedAnnotation {
164 164
 		
165 165
 		try {
166 166
 			ExpressionScope evalScope = annotationType.getScopeForStatement(statement, scope);
167
-			TypeArgument[] types = type.compileTypeArguments(scope);
167
+			StoredType[] types = type.compileTypeArguments(scope);
168 168
 			CallArguments cArguments = arguments.compileCall(position, evalScope, types, annotationType.getInitializers(scope));
169 169
 			return annotationType.createForStatement(position, cArguments);
170 170
 		} catch (CompileException ex) {
@@ -179,7 +179,7 @@ public class ParsedAnnotation {
179 179
 		
180 180
 		try {
181 181
 			ExpressionScope evalScope = annotationType.getScopeForParameter(header, parameter, scope);
182
-			TypeArgument[] types = type.compileTypeArguments(scope);
182
+			StoredType[] types = type.compileTypeArguments(scope);
183 183
 			CallArguments cArguments = arguments.compileCall(position, evalScope, types, annotationType.getInitializers(scope));
184 184
 			return annotationType.createForParameter(position, cArguments);
185 185
 		} catch (CompileException ex) {

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java View File

@@ -18,7 +18,7 @@ import org.openzen.zenscript.lexer.ZSTokenParser;
18 18
 import org.openzen.zenscript.lexer.ZSTokenType;
19 19
 import org.openzen.zenscript.codemodel.scope.BaseScope;
20 20
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
21
-import org.openzen.zenscript.codemodel.type.TypeArgument;
21
+import org.openzen.zenscript.codemodel.type.StoredType;
22 22
 import org.openzen.zenscript.lexer.ParseException;
23 23
 import org.openzen.zenscript.parser.ParsedAnnotation;
24 24
 import org.openzen.zenscript.parser.member.ParsedDefinitionMember;
@@ -97,7 +97,7 @@ public class ParsedEnum extends BaseParsedDefinition {
97 97
 	public void compile(BaseScope scope) throws CompileException {
98 98
 		super.compile(scope);
99 99
 		
100
-		DefinitionTypeID type = scope.getTypeRegistry().getForDefinition(compiled, TypeArgument.NONE);
100
+		DefinitionTypeID type = scope.getTypeRegistry().getForDefinition(compiled, StoredType.NONE);
101 101
 		ExpressionScope evalScope = new ExpressionScope(scope);
102 102
 		for (ParsedEnumConstant constant : enumValues) {
103 103
 			constant.compileCode(type, evalScope);

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnumConstant.java View File

@@ -74,7 +74,7 @@ public class ParsedEnumConstant {
74 74
 	
75 75
 	public void compileCode(DefinitionTypeID type, ExpressionScope scope) throws CompileException {
76 76
 		ParsedCallArguments arguments = new ParsedCallArguments(null, this.arguments);
77
-		compiled.constructor = (NewExpression)ParsedNewExpression.compile(position, type.stored(ValueStorageTag.INSTANCE), arguments, scope);
77
+		compiled.constructor = (NewExpression)ParsedNewExpression.compile(position, type.stored(), arguments, scope);
78 78
 		
79 79
 		if (value != null)
80 80
 			compiled.value = value.compile(scope).eval();

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java View File

@@ -69,7 +69,7 @@ public class ParsedExpansion extends BaseParsedDefinition {
69 69
 	@Override
70 70
 	public void linkTypesLocal(TypeResolutionContext context) {
71 71
 		ParsedTypeParameter.compile(context, compiled.typeParameters, this.parameters);
72
-		compiled.target = target.compileArgument(context);
72
+		compiled.target = target.compile(context);
73 73
 		if (compiled.target == null)
74 74
 			throw new RuntimeException(position + ": Could not compile expansion target: " + target);
75 75
 		

+ 12
- 13
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedCallArguments.java View File

@@ -23,7 +23,6 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
23 23
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
24 24
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
25 25
 import org.openzen.zenscript.codemodel.type.StoredType;
26
-import org.openzen.zenscript.codemodel.type.TypeArgument;
27 26
 import org.openzen.zenscript.lexer.ParseException;
28 27
 import org.openzen.zenscript.parser.type.IParsedType;
29 28
 
@@ -88,7 +87,7 @@ public class ParsedCallArguments {
88 87
 	public CallArguments compileCall(
89 88
 			CodePosition position, 
90 89
 			ExpressionScope scope,
91
-			TypeArgument[] genericParameters,
90
+			StoredType[] genericParameters,
92 91
 			TypeMemberGroup member) throws CompileException
93 92
 	{
94 93
 		List<FunctionHeader> possibleHeaders = member.getMethodMembers().stream()
@@ -100,13 +99,13 @@ public class ParsedCallArguments {
100 99
 	public CallArguments compileCall(
101 100
 			CodePosition position,
102 101
 			ExpressionScope scope,
103
-			TypeArgument[] typeArguments,
102
+			StoredType[] typeArguments,
104 103
 			List<FunctionHeader> candidateFunctions) throws CompileException
105 104
 	{
106 105
 		if (this.typeArguments != null) {
107
-			typeArguments = new TypeArgument[this.typeArguments.size()];
106
+			typeArguments = new StoredType[this.typeArguments.size()];
108 107
 			for (int i = 0; i < this.typeArguments.size(); i++)
109
-				typeArguments[i] = this.typeArguments.get(i).compileArgument(scope);
108
+				typeArguments[i] = this.typeArguments.get(i).compile(scope);
110 109
 		}
111 110
 		
112 111
 		List<FunctionHeader> candidates = new ArrayList<>();
@@ -153,14 +152,14 @@ public class ParsedCallArguments {
153 152
 			cArguments[i] = cArgument.eval();
154 153
 		}
155 154
 		
156
-		TypeArgument[] typeArguments2 = typeArguments;
155
+		StoredType[] typeArguments2 = typeArguments;
157 156
 		if (typeArguments2 == null || typeArguments2.length == 0) {
158 157
 			for (FunctionHeader candidate : candidates) {
159 158
 				if (candidate.typeParameters != null) {
160
-					typeArguments2 = new TypeArgument[candidate.typeParameters.length];
159
+					typeArguments2 = new StoredType[candidate.typeParameters.length];
161 160
 					for (int i = 0; i < typeArguments2.length; i++) {
162 161
 						if (innerScope.genericInferenceMap.get(candidate.typeParameters[i]) == null)
163
-							typeArguments2[i] = new TypeArgument(new InvalidTypeID(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer type parameter " + candidate.typeParameters[i].name), null);
162
+							typeArguments2[i] = new InvalidTypeID(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer type parameter " + candidate.typeParameters[i].name).stored();
164 163
 						else
165 164
 							typeArguments2[i] = innerScope.genericInferenceMap.get(candidate.typeParameters[i]);
166 165
 					}
@@ -177,7 +176,7 @@ public class ParsedCallArguments {
177 176
 	public CallArguments compileCall(
178 177
 			CodePosition position,
179 178
 			ExpressionScope scope,
180
-			TypeArgument[] typeArguments,
179
+			StoredType[] typeArguments,
181 180
 			FunctionHeader function) throws CompileException
182 181
 	{
183 182
 		ExpressionScope innerScope = scope.forCall(function);
@@ -194,10 +193,10 @@ public class ParsedCallArguments {
194 193
 			cArguments[i] = cArgument.eval();
195 194
 		}
196 195
 		
197
-		TypeArgument[] typeArguments2 = typeArguments;
196
+		StoredType[] typeArguments2 = typeArguments;
198 197
 		if (typeArguments2 == null) {
199 198
 			if (function.typeParameters != null) {
200
-				typeArguments2 = new TypeArgument[function.typeParameters.length];
199
+				typeArguments2 = new StoredType[function.typeParameters.length];
201 200
 				for (int i = 0; i < typeArguments2.length; i++) {
202 201
 					if (innerScope.genericInferenceMap.get(function.typeParameters[i]) == null)
203 202
 						throw new CompileException(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer type parameter " + function.typeParameters[i].name);
@@ -216,10 +215,10 @@ public class ParsedCallArguments {
216 215
 			IPartialExpression cArgument = arguments.get(i).compile(scope);
217 216
 			cArguments[i] = cArgument.eval();
218 217
 		}
219
-		return new CallArguments(TypeArgument.NONE, cArguments);
218
+		return new CallArguments(StoredType.NONE, cArguments);
220 219
 	}
221 220
 	
222
-	private boolean isCompatibleWith(BaseScope scope, FunctionHeader header, TypeArgument[] typeArguments) {
221
+	private boolean isCompatibleWith(BaseScope scope, FunctionHeader header, StoredType[] typeArguments) {
223 222
 		if (arguments.size() != header.parameters.length)
224 223
 			return false;
225 224
 		

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionCoalesce.java View File

@@ -43,7 +43,7 @@ public class ParsedExpressionCoalesce extends ParsedExpression {
43 43
 		
44 44
 		TypeMembers resultTypeMembers = scope.getTypeMembers(resultType);
45 45
 		resultType = resultTypeMembers.union(cRight.type);
46
-		cLeft = cLeft.castImplicit(position, scope, resultType.isOptional() ? resultType : scope.getTypeRegistry().getOptional(resultType.type).stored(resultType.storage));
46
+		cLeft = cLeft.castImplicit(position, scope, resultType.isOptional() ? resultType : scope.getTypeRegistry().getOptional(resultType.type).stored(resultType.getSpecifiedStorage()));
47 47
 		cRight = cRight.castImplicit(position, scope, resultType);
48 48
 		
49 49
 		return new CoalesceExpression(position, cLeft, cRight);

+ 1
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFloat.java View File

@@ -18,7 +18,6 @@ import org.openzen.zenscript.codemodel.partial.IPartialExpression;
18 18
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
19 19
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
20 20
 import org.openzen.zenscript.codemodel.type.StoredType;
21
-import org.openzen.zenscript.codemodel.type.TypeArgument;
22 21
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
23 22
 
24 23
 /**
@@ -69,7 +68,7 @@ public class ParsedExpressionFloat extends ParsedExpression {
69 68
 				if (method != null) {
70 69
 					try {
71 70
 						ParsedCallArguments parsedArguments = new ParsedCallArguments(Collections.emptyList(), Collections.singletonList(new ParsedExpressionFloat(position, value)));
72
-						CallArguments arguments = parsedArguments.compileCall(position, scope, TypeArgument.NONE, method.getHeader());
71
+						CallArguments arguments = parsedArguments.compileCall(position, scope, StoredType.NONE, method.getHeader());
73 72
 						method.callStatic(position, hint.type, method.getHeader(), arguments, scope);
74 73
 					} catch (CompileException ex) {
75 74
 						return new InvalidExpression(hint, ex);

+ 2
- 3
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java View File

@@ -25,7 +25,6 @@ import org.openzen.zenscript.codemodel.scope.LambdaScope;
25 25
 import org.openzen.zenscript.codemodel.scope.StatementScope;
26 26
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
27 27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeArgument;
29 28
 import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
30 29
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
31 30
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
@@ -59,7 +58,7 @@ public class ParsedExpressionFunction extends ParsedExpression {
59 58
 						return new InvalidExpression(position, hint, CompileExceptionCode.MULTIPLE_MATCHING_HINTS, "Ambiguity trying to resolve function types, can't decide for the type");
60 59
 					
61 60
 					header = functionHint.header.forLambda(definedHeader);
62
-					storage = hint.storage;
61
+					storage = hint.getActualStorage();
63 62
 				}
64 63
 			}
65 64
 		}
@@ -85,7 +84,7 @@ public class ParsedExpressionFunction extends ParsedExpression {
85 84
 		if (!scope.genericInferenceMap.isEmpty()) {
86 85
 			// perform type parameter inference
87 86
 			StoredType returnType = statements.getReturnType();
88
-			Map<TypeParameter, TypeArgument> inferredTypes = returnType.type.inferTypeParameters(scope.getMemberCache(), genericHeader.getReturnType().asArgument());
87
+			Map<TypeParameter, StoredType> inferredTypes = returnType.type.inferTypeParameters(scope.getMemberCache(), genericHeader.getReturnType());
89 88
 			if (inferredTypes == null)
90 89
 				throw new CompileException(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer generic type parameters");
91 90
 			

+ 1
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionIndex.java View File

@@ -19,7 +19,6 @@ import org.openzen.zenscript.codemodel.type.GenericName;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
20 20
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
21 21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
-import org.openzen.zenscript.codemodel.type.TypeArgument;
23 22
 
24 23
 /**
25 24
  *
@@ -111,7 +110,7 @@ public class ParsedExpressionIndex extends ParsedExpression {
111 110
 		}
112 111
 
113 112
 		@Override
114
-		public TypeArgument[] getTypeArguments() {
113
+		public StoredType[] getTypeArguments() {
115 114
 			return null;
116 115
 		}
117 116
 	}

+ 1
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionInt.java View File

@@ -28,7 +28,6 @@ import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
28 28
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
29 29
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
30 30
 import org.openzen.zenscript.codemodel.type.StoredType;
31
-import org.openzen.zenscript.codemodel.type.TypeArgument;
32 31
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
33 32
 
34 33
 /**
@@ -167,7 +166,7 @@ public class ParsedExpressionInt extends ParsedExpression {
167 166
 				if (method != null) {
168 167
 					try {
169 168
 						ParsedCallArguments parsedArguments = new ParsedCallArguments(Collections.emptyList(), Collections.singletonList(new ParsedExpressionInt(position, negative, value, "")));
170
-						CallArguments arguments = parsedArguments.compileCall(position, scope, TypeArgument.NONE, method.getHeader());
169
+						CallArguments arguments = parsedArguments.compileCall(position, scope, StoredType.NONE, method.getHeader());
171 170
 						method.callStatic(position, hint.type, method.getHeader(), arguments, scope);
172 171
 					} catch (CompileException ex) {
173 172
 						return new InvalidExpression(hint, ex);

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionMember.java View File

@@ -13,7 +13,7 @@ import org.openzen.zencode.shared.CompileExceptionCode;
13 13
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14 14
 import org.openzen.zenscript.codemodel.type.GenericName;
15 15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16
-import org.openzen.zenscript.codemodel.type.TypeArgument;
16
+import org.openzen.zenscript.codemodel.type.StoredType;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 18
 import org.openzen.zenscript.parser.type.IParsedType;
19 19
 
@@ -37,7 +37,7 @@ public class ParsedExpressionMember extends ParsedExpression {
37 37
 	@Override
38 38
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
39 39
 		IPartialExpression cValue = value.compile(scope.withoutHints());
40
-		TypeArgument[] typeArguments = IParsedType.compileArguments(genericParameters, scope);
40
+		StoredType[] typeArguments = IParsedType.compileTypes(genericParameters, scope);
41 41
 		IPartialExpression member = cValue.getMember(
42 42
 				position,
43 43
 				scope,

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionRange.java View File

@@ -50,7 +50,7 @@ public class ParsedExpressionRange extends ParsedExpression {
50 50
 		Expression to = this.to.compile(scope.withHints(toHints)).eval();
51 51
 		
52 52
 		StoredType baseType = scope.getTypeMembers(from.type).union(to.type);
53
-		return new RangeExpression(position, scope.getTypeRegistry().getRange(baseType).stored(baseType.storage), from, to);
53
+		return new RangeExpression(position, scope.getTypeRegistry().getRange(baseType).stored(baseType.getSpecifiedStorage()), from, to);
54 54
 	}
55 55
 
56 56
 	@Override

+ 1
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java View File

@@ -25,7 +25,6 @@ import org.openzen.zenscript.codemodel.type.GenericName;
25 25
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
26 26
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
27 27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeArgument;
29 28
 import org.openzen.zenscript.parser.ParsedAnnotation;
30 29
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
31 30
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
@@ -49,7 +48,7 @@ public class ParsedExpressionVariable extends ParsedExpression {
49 48
 
50 49
 	@Override
51 50
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
52
-		TypeArgument[] typeArguments = IParsedType.compileArguments(this.typeArguments, scope);
51
+		StoredType[] typeArguments = IParsedType.compileTypes(this.typeArguments, scope);
53 52
 		IPartialExpression result = scope.get(position, new GenericName(name, typeArguments));
54 53
 		if (result == null) {
55 54
 			for (StoredType hint : scope.hints) {

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryConvertExpression.java View File

@@ -38,8 +38,8 @@ public class ParsedTryConvertExpression extends ParsedExpression {
38 38
 		HighLevelDefinition result = scope.getTypeRegistry().stdlib.getDefinition("Result");
39 39
 		if (cValue.thrownType != null) {
40 40
 			// this function throws
41
-			DefinitionTypeID resultType = scope.getTypeRegistry().getForDefinition(result, cValue.type.asArgument(), cValue.thrownType.asArgument());
42
-			return new TryConvertExpression(position, resultType.stored(cValue.type.storage), cValue);
41
+			DefinitionTypeID resultType = scope.getTypeRegistry().getForDefinition(result, cValue.type, cValue.thrownType);
42
+			return new TryConvertExpression(position, resultType.stored(cValue.type.getActualStorage()), cValue);
43 43
 		} else {
44 44
 			throw new CompileException(position, CompileExceptionCode.TRY_CONVERT_ILLEGAL_TARGET, "try? can only be used on expressions that throw");
45 45
 		}

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryRethrowExpression.java View File

@@ -42,7 +42,7 @@ public class ParsedTryRethrowExpression extends ParsedExpression {
42 42
 				return new TryRethrowAsExceptionExpression(position, cSource.type, cSource, cSource.thrownType);
43 43
 			} else {
44 44
 				// rethrow as result
45
-				StoredType resultType = scope.getTypeRegistry().getForDefinition(result, cSource.type.asArgument(), cSource.thrownType.asArgument()).stored(cSource.thrownType.storage);
45
+				StoredType resultType = scope.getTypeRegistry().getForDefinition(result, cSource.type, cSource.thrownType).stored(cSource.thrownType.getSpecifiedStorage());
46 46
 				return new TryRethrowAsResultExpression(position, resultType, cSource);
47 47
 			}
48 48
 		} else {
@@ -50,7 +50,7 @@ public class ParsedTryRethrowExpression extends ParsedExpression {
50 50
 			if (cSource.type.type instanceof DefinitionTypeID) {
51 51
 				DefinitionTypeID sourceType = (DefinitionTypeID)cSource.type.type;
52 52
 				if (sourceType.definition == result) {
53
-					return new TryRethrowAsResultExpression(position, sourceType.typeArguments[0].stored(), cSource);
53
+					return new TryRethrowAsResultExpression(position, sourceType.typeArguments[0], cSource);
54 54
 				}
55 55
 			}
56 56
 			

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedSetter.java View File

@@ -70,13 +70,13 @@ public class ParsedSetter extends ParsedDefinitionMember {
70 70
 	
71 71
 	private void inferHeaders(BaseScope scope) throws CompileException {
72 72
 		if ((implementation != null && !Modifiers.isPrivate(modifiers))) {
73
-			fillOverride(scope, implementation.getCompiled().type.stored(scope.getThisType().storage));
73
+			fillOverride(scope, implementation.getCompiled().type.stored(scope.getThisType().getSpecifiedStorage()));
74 74
 			compiled.modifiers |= Modifiers.PUBLIC;
75 75
 		} else if (implementation == null && Modifiers.isOverride(modifiers)) {
76 76
 			if (definition.getSuperType() == null)
77 77
 				throw new CompileException(position, CompileExceptionCode.OVERRIDE_WITHOUT_BASE, "Override specified without base type");
78 78
 			
79
-			fillOverride(scope, definition.getSuperType().stored(scope.getThisType().storage));
79
+			fillOverride(scope, definition.getSuperType().stored(scope.getThisType().getSpecifiedStorage()));
80 80
 		}
81 81
 		
82 82
 		if (compiled == null)

+ 9
- 30
Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java View File

@@ -15,9 +15,7 @@ import org.openzen.zenscript.lexer.ZSTokenParser;
15 15
 import org.openzen.zenscript.lexer.ZSTokenType;
16 16
 import static org.openzen.zenscript.lexer.ZSTokenType.*;
17 17
 import org.openzen.zenscript.codemodel.scope.BaseScope;
18
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
19 18
 import org.openzen.zenscript.codemodel.type.StoredType;
20
-import org.openzen.zenscript.codemodel.type.TypeArgument;
21 19
 import org.openzen.zenscript.lexer.ParseException;
22 20
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
23 21
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
@@ -90,16 +88,6 @@ public interface IParsedType {
90 88
 	
91 89
 	public static IParsedType tryParse(ZSTokenParser tokens) throws ParseException {
92 90
 		CodePosition position = tokens.getPosition();
93
-		int modifiers = 0;
94
-		while (true) {
95
-			if (tokens.optional(ZSTokenType.K_CONST) != null) {
96
-				modifiers |= ModifiedTypeID.MODIFIER_CONST;
97
-			} else if (tokens.optional(ZSTokenType.K_IMMUTABLE) != null) {
98
-				modifiers |= ModifiedTypeID.MODIFIER_IMMUTABLE;
99
-			} else {
100
-				break;
101
-			}
102
-		}
103 91
 		
104 92
 		IParsedType result;
105 93
 		switch (tokens.peek().type) {
@@ -162,7 +150,7 @@ public interface IParsedType {
162 150
 			case K_STRING: {
163 151
 				tokens.next();
164 152
 				ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
165
-				result = new ParsedString(position, modifiers, storage);
153
+				result = new ParsedString(position, storage);
166 154
 				break;
167 155
 			}
168 156
 			case K_FUNCTION: {
@@ -210,7 +198,7 @@ public interface IParsedType {
210 198
 						tokens.required(T_GREATER, "> expected");
211 199
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
212 200
 						ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
213
-						result = new ParsedTypeGenericMap(position, parameter, result, modifiers, storage);
201
+						result = new ParsedTypeGenericMap(position, parameter, result, storage);
214 202
 					} else {
215 203
 						IParsedType keyType = parse(tokens);
216 204
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
@@ -220,16 +208,13 @@ public interface IParsedType {
220 208
 					break;
221 209
 				case T_QUEST:
222 210
 					tokens.next();
223
-					result = result.withOptional();
211
+					result = new ParsedOptionalType(result);
224 212
 					break;
225 213
 				default:
226 214
 					break outer;
227 215
 			}
228 216
 		}
229 217
 		
230
-		if (modifiers > 0)
231
-			result = result.withModifiers(modifiers);
232
-		
233 218
 		return result;
234 219
 	}
235 220
 	
@@ -255,32 +240,26 @@ public interface IParsedType {
255 240
 		return result;
256 241
 	}
257 242
 	
258
-	public static TypeArgument[] compileArguments(List<IParsedType> typeParameters, TypeResolutionContext context) {
259
-		TypeArgument[] result = TypeArgument.NONE;
243
+	public static StoredType[] compileTypes(List<IParsedType> typeParameters, TypeResolutionContext context) {
244
+		StoredType[] result = StoredType.NONE;
260 245
 		if (typeParameters != null && typeParameters.size() > 0) {
261
-			result = new TypeArgument[typeParameters.size()];
246
+			result = new StoredType[typeParameters.size()];
262 247
 			for (int i = 0; i < typeParameters.size(); i++) {
263
-				result[i] = typeParameters.get(i).compileArgument(context);
248
+				result[i] = typeParameters.get(i).compile(context);
264 249
 			}
265 250
 		}
266 251
 		return result;
267 252
 	}
268 253
 	
269
-	public IParsedType withOptional();
270
-	
271
-	public IParsedType withModifiers(int modifiers);
272
-	
273 254
 	public StoredType compile(TypeResolutionContext context);
274 255
 	
275 256
 	public TypeID compileUnstored(TypeResolutionContext context);
276 257
 	
277
-	public TypeArgument compileArgument(TypeResolutionContext context);
278
-	
279 258
 	public default AnnotationDefinition compileAnnotation(BaseScope scope) {
280 259
 		return null;
281 260
 	}
282 261
 	
283
-	public default TypeArgument[] compileTypeArguments(BaseScope scope) {
284
-		return TypeArgument.NONE;
262
+	public default StoredType[] compileTypeArguments(BaseScope scope) {
263
+		return StoredType.NONE;
285 264
 	}
286 265
 }

+ 3
- 31
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java View File

@@ -9,13 +9,10 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.CompileExceptionCode;
10 10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11 11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
12
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
13 12
 import org.openzen.zenscript.codemodel.type.StoredType;
14
-import org.openzen.zenscript.codemodel.type.TypeArgument;
15 13
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16 14
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
17 15
 import org.openzen.zenscript.codemodel.type.TypeID;
18
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
19 16
 
20 17
 /**
21 18
  *
@@ -23,38 +20,19 @@ import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
23 20
  */
24 21
 public class ParsedFunctionType implements IParsedType {
25 22
 	private final CodePosition position;
26
-	private final int modifiers;
27 23
 	private final ParsedFunctionHeader header;
28 24
 	private final ParsedStorageTag storage;
29 25
 	
30 26
 	public ParsedFunctionType(CodePosition position, ParsedFunctionHeader header, ParsedStorageTag storage) {
31 27
 		this.position = position;
32 28
 		this.header = header;
33
-		this.modifiers = 0;
34 29
 		this.storage = storage;
35 30
 	}
36
-	
37
-	private ParsedFunctionType(CodePosition position, ParsedFunctionHeader header, int modifiers, ParsedStorageTag storageTag) {
38
-		this.position = position;
39
-		this.header = header;
40
-		this.modifiers = modifiers;
41
-		this.storage = storageTag;
42
-	}
43
-	
44
-	@Override
45
-	public IParsedType withOptional() {
46
-		return new ParsedFunctionType(position, header, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
47
-	}
48
-
49
-	@Override
50
-	public IParsedType withModifiers(int modifiers) {
51
-		return new ParsedFunctionType(position, header, modifiers | this.modifiers, storage);
52
-	}
53 31
 
54 32
 	@Override
55 33
 	public StoredType compile(TypeResolutionContext context) {
56
-		StorageTag storage = this.storage == ParsedStorageTag.NULL ? AutoStorageTag.INSTANCE : this.storage.resolve(position, context);
57
-		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context))).stored(storage);
34
+		StorageTag storage = this.storage.resolve(position, context);
35
+		return context.getTypeRegistry().getFunction(header.compile(context)).stored(storage);
58 36
 	}
59 37
 	
60 38
 	@Override
@@ -62,12 +40,6 @@ public class ParsedFunctionType implements IParsedType {
62 40
 		if (storage != ParsedStorageTag.NULL)
63 41
 			return new InvalidTypeID(position, CompileExceptionCode.STORAGE_NOT_SUPPORTED, "Storage tag not supported here");
64 42
 		
65
-		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context)));
66
-	}
67
-
68
-	@Override
69
-	public TypeArgument compileArgument(TypeResolutionContext context) {
70
-		StorageTag storage = this.storage == ParsedStorageTag.NULL ? null : this.storage.resolve(position, context);
71
-		return new TypeArgument(context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context))), storage);
43
+		return context.getTypeRegistry().getFunction(header.compile(context));
72 44
 	}
73 45
 }

+ 7
- 70
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java View File

@@ -14,13 +14,8 @@ import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
14 14
 import org.openzen.zenscript.codemodel.type.GenericName;
15 15
 import org.openzen.zenscript.codemodel.scope.BaseScope;
16 16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
17
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
18 17
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.TypeArgument;
20
-import org.openzen.zenscript.codemodel.type.storage.StorageTag;
21 18
 import org.openzen.zenscript.codemodel.type.TypeID;
22
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
23
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
24 19
 
25 20
 /**
26 21
  *
@@ -28,20 +23,11 @@ import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
28 23
  */
29 24
 public class ParsedNamedType implements IParsedType {
30 25
 	private final CodePosition position;
31
-	private final int modifiers;
32 26
 	public final List<ParsedNamePart> name;
33 27
 	private final ParsedStorageTag storage;
34 28
 	
35 29
 	public ParsedNamedType(CodePosition position, List<ParsedNamePart> name, ParsedStorageTag storage) {
36 30
 		this.position = position;
37
-		this.modifiers = 0;
38
-		this.name = name;
39
-		this.storage = storage;
40
-	}
41
-	
42
-	private ParsedNamedType(CodePosition position, int modifiers, List<ParsedNamePart> name, ParsedStorageTag storage) {
43
-		this.position = position;
44
-		this.modifiers = modifiers;
45 31
 		this.name = name;
46 32
 		this.storage = storage;
47 33
 	}
@@ -55,21 +41,11 @@ public class ParsedNamedType implements IParsedType {
55 41
 		for (ParsedNamePart namePart : name)
56 42
 			genericNames.add(namePart.compile(context));
57 43
 		
58
-		TypeID baseType = context.getType(position, genericNames);
59
-		if (baseType == null)
60
-			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "Type not found: " + toString()).stored(ValueStorageTag.INSTANCE);
61
-		
62
-		TypeID result = context.getTypeRegistry().getModified(modifiers, baseType);
44
+		TypeID result = context.getType(position, genericNames);
63 45
 		if (result == null)
64
-			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "Type not found: " + toString()).stored(ValueStorageTag.INSTANCE);
46
+			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "Type not found: " + toString()).stored();
65 47
 		
66
-		StorageTag storage;
67
-		if (this.storage == ParsedStorageTag.NULL) {
68
-			storage = AutoStorageTag.INSTANCE;
69
-		} else {
70
-			storage = this.storage.resolve(position, context);
71
-		}
72
-		return result.stored(storage);
48
+		return result.stored(storage.resolve(position, context));
73 49
 	}
74 50
 	
75 51
 	@Override
@@ -80,42 +56,6 @@ public class ParsedNamedType implements IParsedType {
80 56
 		return compile(context).type;
81 57
 	}
82 58
 	
83
-	@Override
84
-	public TypeArgument compileArgument(TypeResolutionContext context) {
85
-		if (name.size() == 1 && name.get(0).name.equals("Iterator"))
86
-			return toIterator(context).asArgument();
87
-		
88
-		List<GenericName> genericNames = new ArrayList<>();
89
-		for (ParsedNamePart namePart : name)
90
-			genericNames.add(namePart.compile(context));
91
-		
92
-		TypeID baseType = context.getType(position, genericNames);
93
-		if (baseType == null)
94
-			return new TypeArgument(new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "Type not found: " + toString()), null);
95
-		
96
-		TypeID result = context.getTypeRegistry().getModified(modifiers, baseType);
97
-		if (result == null)
98
-			return new TypeArgument(new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "Type not found: " + toString()), null);
99
-		
100
-		StorageTag storage;
101
-		if (this.storage == ParsedStorageTag.NULL) {
102
-			storage = null;
103
-		} else {
104
-			storage = this.storage.resolve(position, context);
105
-		}
106
-		return new TypeArgument(result, storage);
107
-	}
108
-	
109
-	@Override
110
-	public IParsedType withOptional() {
111
-		return new ParsedNamedType(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, name, storage);
112
-	}
113
-	
114
-	@Override
115
-	public IParsedType withModifiers(int modifiers) {
116
-		return new ParsedNamedType(position, this.modifiers | modifiers, name, storage);
117
-	}
118
-	
119 59
 	@Override
120 60
 	public String toString() {
121 61
 		StringBuilder nameTotal = new StringBuilder();
@@ -136,9 +76,9 @@ public class ParsedNamedType implements IParsedType {
136 76
 	}
137 77
 	
138 78
 	@Override
139
-	public TypeArgument[] compileTypeArguments(BaseScope scope) {
79
+	public StoredType[] compileTypeArguments(BaseScope scope) {
140 80
 		ParsedNamePart last = name.get(name.size() - 1);
141
-		return IParsedType.compileArguments(last.typeArguments, scope);
81
+		return IParsedType.compileTypes(last.typeArguments, scope);
142 82
 	}
143 83
 	
144 84
 	private StoredType toIterator(TypeResolutionContext context) {
@@ -147,11 +87,8 @@ public class ParsedNamedType implements IParsedType {
147 87
 		for (int i = 0; i < genericTypes.size(); i++)
148 88
 			iteratorTypes[i] = genericTypes.get(i).compile(context);
149 89
 
150
-		StorageTag storage = this.storage.resolve(position, context);
151 90
 		TypeID type = context.getTypeRegistry().getIterator(iteratorTypes);
152
-		if (storage == null)
153
-			storage = AutoStorageTag.INSTANCE;
154
-		return context.getTypeRegistry().getModified(modifiers, type).stored(storage);
91
+		return type.stored(storage.resolve(position, context));
155 92
 	}
156 93
 	
157 94
 	public static class ParsedNamePart {
@@ -164,7 +101,7 @@ public class ParsedNamedType implements IParsedType {
164 101
 		}
165 102
 		
166 103
 		private GenericName compile(TypeResolutionContext context) {
167
-			return new GenericName(name, IParsedType.compileArguments(typeArguments, context));
104
+			return new GenericName(name, IParsedType.compileTypes(typeArguments, context));
168 105
 		}
169 106
 		
170 107
 		@Override

+ 0
- 51
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedOptionalBasicType.java View File

@@ -1,51 +0,0 @@
1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.parser.type;
7
-
8
-import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
10
-import org.openzen.zenscript.codemodel.type.StoredType;
11
-import org.openzen.zenscript.codemodel.type.TypeArgument;
12
-import org.openzen.zenscript.codemodel.type.TypeID;
13
-
14
-/**
15
- *
16
- * @author Hoofdgebruiker
17
- */
18
-public class ParsedOptionalBasicType implements IParsedType {
19
-	private final ParsedTypeBasic type;
20
-	
21
-	public ParsedOptionalBasicType(ParsedTypeBasic type) {
22
-		this.type = type;
23
-	}
24
-
25
-	@Override
26
-	public IParsedType withOptional() {
27
-		return this;
28
-	}
29
-
30
-	@Override
31
-	public IParsedType withModifiers(int modifiers) {
32
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
33
-	}
34
-
35
-	@Override
36
-	public StoredType compile(TypeResolutionContext context) {
37
-		StoredType base = type.compile(context);
38
-		return context.getTypeRegistry().getModified(ModifiedTypeID.MODIFIER_OPTIONAL, base.type).stored(base.storage);
39
-	}
40
-
41
-	@Override
42
-	public TypeID compileUnstored(TypeResolutionContext context) {
43
-		return context.getTypeRegistry().getModified(ModifiedTypeID.MODIFIER_OPTIONAL, type.compileUnstored(context));
44
-	}
45
-
46
-	@Override
47
-	public TypeArgument compileArgument(TypeResolutionContext context) {
48
-		TypeArgument base = type.compileArgument(context);
49
-		return new TypeArgument(context.getTypeRegistry().getModified(ModifiedTypeID.MODIFIER_OPTIONAL, base.type), base.storage);
50
-	}
51
-}

+ 33
- 0
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedOptionalType.java View File

@@ -0,0 +1,33 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.parser.type;
7
+
8
+import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
+import org.openzen.zenscript.codemodel.type.StoredType;
10
+import org.openzen.zenscript.codemodel.type.TypeID;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class ParsedOptionalType implements IParsedType {
17
+	private final IParsedType type;
18
+	
19
+	public ParsedOptionalType(IParsedType type) {
20
+		this.type = type;
21
+	}
22
+
23
+	@Override
24
+	public StoredType compile(TypeResolutionContext context) {
25
+		StoredType base = type.compile(context);
26
+		return new StoredType(context.getTypeRegistry().getOptional(base.type), base.getSpecifiedStorage());
27
+	}
28
+
29
+	@Override
30
+	public TypeID compileUnstored(TypeResolutionContext context) {
31
+		return context.getTypeRegistry().getOptional(type.compileUnstored(context));
32
+	}
33
+}

+ 2
- 25
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedString.java View File

@@ -9,12 +9,9 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.CompileExceptionCode;
10 10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11 11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
12
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
13 12
 import org.openzen.zenscript.codemodel.type.StoredType;
14 13
 import org.openzen.zenscript.codemodel.type.StringTypeID;
15
-import org.openzen.zenscript.codemodel.type.TypeArgument;
16 14
 import org.openzen.zenscript.codemodel.type.TypeID;
17
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
18 15
 
19 16
 /**
20 17
  *
@@ -22,30 +19,16 @@ import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
22 19
  */
23 20
 public class ParsedString implements IParsedType {
24 21
 	private final CodePosition position;
25
-	private final int modifiers;
26 22
 	private final ParsedStorageTag storage;
27 23
 	
28
-	public ParsedString(CodePosition position, int modifiers, ParsedStorageTag storage) {
24
+	public ParsedString(CodePosition position, ParsedStorageTag storage) {
29 25
 		this.position = position;
30
-		this.modifiers = modifiers;
31 26
 		this.storage = storage;
32 27
 	}
33 28
 
34
-	@Override
35
-	public IParsedType withOptional() {
36
-		return new ParsedString(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
37
-	}
38
-
39
-	@Override
40
-	public IParsedType withModifiers(int modifiers) {
41
-		return new ParsedString(position, this.modifiers | modifiers, storage);
42
-	}
43
-
44 29
 	@Override
45 30
 	public StoredType compile(TypeResolutionContext context) {
46
-		return context.getTypeRegistry()
47
-				.getModified(modifiers, StringTypeID.INSTANCE)
48
-				.stored(storage == ParsedStorageTag.NULL ? AutoStorageTag.INSTANCE : storage.resolve(position, context));
31
+		return StringTypeID.INSTANCE.stored(storage.resolve(position, context));
49 32
 	}
50 33
 
51 34
 	@Override
@@ -55,10 +38,4 @@ public class ParsedString implements IParsedType {
55 38
 		
56 39
 		return StringTypeID.INSTANCE;
57 40
 	}
58
-
59
-	@Override
60
-	public TypeArgument compileArgument(TypeResolutionContext context) {
61
-		return new TypeArgument(context.getTypeRegistry()
62
-				.getModified(modifiers, StringTypeID.INSTANCE), storage.resolve(position, context));
63
-	}
64 41
 }

+ 2
- 36
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeArray.java View File

@@ -10,11 +10,8 @@ import org.openzen.zencode.shared.CompileExceptionCode;
10 10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11 11
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 12
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
13
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
14 13
 import org.openzen.zenscript.codemodel.type.StoredType;
15
-import org.openzen.zenscript.codemodel.type.TypeArgument;
16 14
 import org.openzen.zenscript.codemodel.type.TypeID;
17
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
18 15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
19 16
 
20 17
 /**
@@ -25,7 +22,6 @@ public class ParsedTypeArray implements IParsedType {
25 22
 	private final CodePosition position;
26 23
 	public final IParsedType baseType;
27 24
 	public final int dimension;
28
-	public final int modifiers;
29 25
 	public final ParsedStorageTag storage;
30 26
 	
31 27
 	public ParsedTypeArray(CodePosition position, IParsedType baseType, int dimension, ParsedStorageTag storage) {
@@ -35,37 +31,15 @@ public class ParsedTypeArray implements IParsedType {
35 31
 		this.position = position;
36 32
 		this.baseType = baseType;
37 33
 		this.dimension = dimension;
38
-		this.modifiers = 0;
39 34
 		this.storage = storage;
40 35
 	}
41 36
 
42
-	private ParsedTypeArray(CodePosition position, IParsedType baseType, int dimension, int modifiers, ParsedStorageTag storage) {
43
-		if (storage == null)
44
-			throw new NullPointerException();
45
-		
46
-		this.position = position;
47
-		this.baseType = baseType;
48
-		this.dimension = dimension;
49
-		this.modifiers = modifiers;
50
-		this.storage = storage;
51
-	}
52
-	
53
-	@Override
54
-	public IParsedType withOptional() {
55
-		return new ParsedTypeArray(position, baseType, dimension, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
56
-	}
57
-
58
-	@Override
59
-	public IParsedType withModifiers(int modifiers) {
60
-		return new ParsedTypeArray(position, baseType, dimension, this.modifiers | modifiers, storage);
61
-	}
62
-
63 37
 	@Override
64 38
 	public StoredType compile(TypeResolutionContext context) {
65 39
 		StoredType baseType = this.baseType.compile(context);
66 40
 		StorageTag storage = this.storage.resolve(position, context);
67 41
 		GlobalTypeRegistry registry = context.getTypeRegistry();
68
-		return registry.getModified(modifiers, registry.getArray(baseType, dimension)).stored(storage == null ? AutoStorageTag.INSTANCE : storage);
42
+		return registry.getArray(baseType, dimension).stored(storage);
69 43
 	}
70 44
 	
71 45
 	@Override
@@ -76,14 +50,6 @@ public class ParsedTypeArray implements IParsedType {
76 50
 		StoredType baseType = this.baseType.compile(context);
77 51
 		StorageTag storage = this.storage.resolve(position, context);
78 52
 		GlobalTypeRegistry registry = context.getTypeRegistry();
79
-		return registry.getModified(modifiers, registry.getArray(baseType, dimension));
80
-	}
81
-
82
-	@Override
83
-	public TypeArgument compileArgument(TypeResolutionContext context) {
84
-		StoredType baseType = this.baseType.compile(context);
85
-		StorageTag storage = this.storage.resolve(position, context);
86
-		GlobalTypeRegistry registry = context.getTypeRegistry();
87
-		return new TypeArgument(registry.getModified(modifiers, registry.getArray(baseType, dimension)), storage);
53
+		return registry.getArray(baseType, dimension);
88 54
 	}
89 55
 }

+ 2
- 37
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeAssociative.java View File

@@ -8,13 +8,9 @@ package org.openzen.zenscript.parser.type;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.CompileExceptionCode;
10 10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
13
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
14 12
 import org.openzen.zenscript.codemodel.type.StoredType;
15
-import org.openzen.zenscript.codemodel.type.TypeArgument;
16 13
 import org.openzen.zenscript.codemodel.type.TypeID;
17
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
18 14
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
19 15
 
20 16
 /**
@@ -25,42 +21,21 @@ public class ParsedTypeAssociative implements IParsedType {
25 21
 	private final CodePosition position;
26 22
 	public final IParsedType key;
27 23
 	public final IParsedType value;
28
-	public final int modifiers;
29 24
 	private final ParsedStorageTag storage;
30 25
 	
31 26
 	public ParsedTypeAssociative(CodePosition position, IParsedType key, IParsedType value, ParsedStorageTag storage) {
32 27
 		this.position = position;
33 28
 		this.key = key;
34 29
 		this.value = value;
35
-		this.modifiers = 0;
36 30
 		this.storage = storage;
37 31
 	}
38 32
 
39
-	private ParsedTypeAssociative(CodePosition position, IParsedType key, IParsedType value, int modifiers, ParsedStorageTag storage) {
40
-		this.position = position;
41
-		this.key = key;
42
-		this.value = value;
43
-		this.modifiers = modifiers;
44
-		this.storage = storage;
45
-	}
46
-	
47
-	@Override
48
-	public IParsedType withOptional() {
49
-		return new ParsedTypeAssociative(position, key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
50
-	}
51
-
52
-	@Override
53
-	public IParsedType withModifiers(int modifiers) {
54
-		return new ParsedTypeAssociative(position, key, value, this.modifiers | modifiers, storage);
55
-	}
56
-
57 33
 	@Override
58 34
 	public StoredType compile(TypeResolutionContext context) {
59 35
 		StorageTag storage = this.storage.resolve(position, context);
60 36
 		StoredType key = this.key.compile(context);
61 37
 		StoredType value = this.value.compile(context);
62
-		GlobalTypeRegistry registry = context.getTypeRegistry();
63
-		return registry.getModified(modifiers, context.getTypeRegistry().getAssociative(key, value)).stored(storage == null ? AutoStorageTag.INSTANCE : storage);
38
+		return context.getTypeRegistry().getAssociative(key, value).stored(storage);
64 39
 	}
65 40
 
66 41
 	@Override
@@ -71,16 +46,6 @@ public class ParsedTypeAssociative implements IParsedType {
71 46
 		StorageTag storage = this.storage.resolve(position, context);
72 47
 		StoredType key = this.key.compile(context);
73 48
 		StoredType value = this.value.compile(context);
74
-		GlobalTypeRegistry registry = context.getTypeRegistry();
75
-		return registry.getModified(modifiers, context.getTypeRegistry().getAssociative(key, value));
76
-	}
77
-
78
-	@Override
79
-	public TypeArgument compileArgument(TypeResolutionContext context) {
80
-		StorageTag storage = this.storage.resolve(position, context);
81
-		StoredType key = this.key.compile(context);
82
-		StoredType value = this.value.compile(context);
83
-		GlobalTypeRegistry registry = context.getTypeRegistry();
84
-		return new TypeArgument(registry.getModified(modifiers, context.getTypeRegistry().getAssociative(key, value)), storage);
49
+		return context.getTypeRegistry().getAssociative(key, value);
85 50
 	}
86 51
 }

+ 0
- 16
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeBasic.java View File

@@ -8,7 +8,6 @@ package org.openzen.zenscript.parser.type;
8 8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9 9
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 10
 import org.openzen.zenscript.codemodel.type.StoredType;
11
-import org.openzen.zenscript.codemodel.type.TypeArgument;
12 11
 import org.openzen.zenscript.codemodel.type.TypeID;
13 12
 
14 13
 /**
@@ -48,19 +47,4 @@ public enum ParsedTypeBasic implements IParsedType {
48 47
 	public TypeID compileUnstored(TypeResolutionContext context) {
49 48
 		return type;
50 49
 	}
51
-	
52
-	@Override
53
-	public TypeArgument compileArgument(TypeResolutionContext context) {
54
-		return type.argument;
55
-	}
56
-
57
-	@Override
58
-	public IParsedType withOptional() {
59
-		return new ParsedOptionalBasicType(this);
60
-	}
61
-
62
-	@Override
63
-	public IParsedType withModifiers(int modifiers) {
64
-		throw new UnsupportedOperationException();
65
-	}
66 50
 }

+ 3
- 28
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java View File

@@ -14,11 +14,8 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 14
 import org.openzen.zenscript.codemodel.type.GenericName;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
17
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
18 17
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.TypeArgument;
20 18
 import org.openzen.zenscript.codemodel.type.TypeID;
21
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
22 19
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
23 20
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
24 21
 
@@ -30,27 +27,15 @@ public class ParsedTypeGenericMap implements IParsedType {
30 27
 	private final CodePosition position;
31 28
 	private final ParsedTypeParameter key;
32 29
 	private final IParsedType value;
33
-	private final int modifiers;
34 30
 	private final ParsedStorageTag storage;
35 31
 	
36
-	public ParsedTypeGenericMap(CodePosition position, ParsedTypeParameter key, IParsedType value, int modifiers, ParsedStorageTag storage) {
32
+	public ParsedTypeGenericMap(CodePosition position, ParsedTypeParameter key, IParsedType value, ParsedStorageTag storage) {
37 33
 		this.position = position;
38 34
 		this.key = key;
39 35
 		this.value = value;
40
-		this.modifiers = modifiers;
41 36
 		this.storage = storage;
42 37
 	}
43 38
 
44
-	@Override
45
-	public IParsedType withOptional() {
46
-		return new ParsedTypeGenericMap(position, key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
47
-	}
48
-
49
-	@Override
50
-	public IParsedType withModifiers(int modifiers) {
51
-		return new ParsedTypeGenericMap(position, key, value, modifiers | this.modifiers, storage);
52
-	}
53
-
54 39
 	@Override
55 40
 	public StoredType compile(TypeResolutionContext context) {
56 41
 		TypeParameter cKey = key.compiled;
@@ -58,7 +43,7 @@ public class ParsedTypeGenericMap implements IParsedType {
58 43
 		
59 44
 		GlobalTypeRegistry registry = context.getTypeRegistry();
60 45
 		StorageTag storage = this.storage.resolve(position, context);
61
-		return registry.getModified(modifiers, registry.getGenericMap(valueType, cKey)).stored(storage == null ? AutoStorageTag.INSTANCE : storage);
46
+		return registry.getGenericMap(valueType, cKey).stored(storage);
62 47
 	}
63 48
 
64 49
 	@Override
@@ -71,17 +56,7 @@ public class ParsedTypeGenericMap implements IParsedType {
71 56
 		
72 57
 		GlobalTypeRegistry registry = context.getTypeRegistry();
73 58
 		StorageTag storage = this.storage.resolve(position, context);
74
-		return registry.getModified(modifiers, registry.getGenericMap(valueType, cKey));
75
-	}
76
-
77
-	@Override
78
-	public TypeArgument compileArgument(TypeResolutionContext context) {
79
-		TypeParameter cKey = key.compiled;
80
-		StoredType valueType = this.value.compile(new GenericMapScope(context, cKey));
81
-		
82
-		GlobalTypeRegistry registry = context.getTypeRegistry();
83
-		StorageTag storage = this.storage.resolve(position, context);
84
-		return new TypeArgument(registry.getModified(modifiers, registry.getGenericMap(valueType, cKey)), storage);
59
+		return registry.getGenericMap(valueType, cKey);
85 60
 	}
86 61
 	
87 62
 	private class GenericMapScope implements TypeResolutionContext {

+ 3
- 34
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeRange.java View File

@@ -9,9 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.CompileExceptionCode;
10 10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11 11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
12
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
13 12
 import org.openzen.zenscript.codemodel.type.StoredType;
14
-import org.openzen.zenscript.codemodel.type.TypeArgument;
15 13
 import org.openzen.zenscript.codemodel.type.TypeID;
16 14
 
17 15
 /**
@@ -22,30 +20,11 @@ public class ParsedTypeRange implements IParsedType {
22 20
 	private final CodePosition position;
23 21
 	private final IParsedType from;
24 22
 	private final IParsedType to;
25
-	private final int modifiers;
26 23
 	
27 24
 	public ParsedTypeRange(CodePosition position, IParsedType from, IParsedType to) {
28 25
 		this.position = position;
29 26
 		this.from = from;
30 27
 		this.to = to;
31
-		this.modifiers = 0;
32
-	}
33
-	
34
-	private ParsedTypeRange(CodePosition position, IParsedType from, IParsedType to, int modifiers) {
35
-		this.position = position;
36
-		this.from = from;
37
-		this.to = to;
38
-		this.modifiers = modifiers;
39
-	}
40
-
41
-	@Override
42
-	public IParsedType withOptional() {
43
-		return new ParsedTypeRange(position, from, to, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL);
44
-	}
45
-
46
-	@Override
47
-	public IParsedType withModifiers(int modifiers) {
48
-		return new ParsedTypeRange(position, from, to, this.modifiers | modifiers);
49 28
 	}
50 29
 	
51 30
 	@Override
@@ -53,9 +32,9 @@ public class ParsedTypeRange implements IParsedType {
53 32
 		StoredType from = this.from.compile(context);
54 33
 		StoredType to = this.to.compile(context);
55 34
 		if (!from.equals(to))
56
-			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "from and to in a range must be the same type").stored(from.storage);
35
+			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "from and to in a range must be the same type").stored(from.getSpecifiedStorage());
57 36
 		
58
-		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getRange(from)).stored(from.storage);
37
+		return context.getTypeRegistry().getRange(from).stored(from.getSpecifiedStorage());
59 38
 	}
60 39
 	
61 40
 	@Override
@@ -65,16 +44,6 @@ public class ParsedTypeRange implements IParsedType {
65 44
 		if (!from.equals(to))
66 45
 			return new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "from and to in a range must be the same type");
67 46
 		
68
-		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getRange(from));
69
-	}
70
-	
71
-	@Override
72
-	public TypeArgument compileArgument(TypeResolutionContext context) {
73
-		StoredType from = this.from.compile(context);
74
-		StoredType to = this.to.compile(context);
75
-		if (!from.equals(to))
76
-			return new TypeArgument(new InvalidTypeID(position, CompileExceptionCode.NO_SUCH_TYPE, "from and to in a range must be the same type"), null);
77
-		
78
-		return new TypeArgument(context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getRange(from)), from.storage);
47
+		return context.getTypeRegistry().getRange(from);
79 48
 	}
80 49
 }

+ 3
- 3
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java View File

@@ -30,8 +30,8 @@ import org.openzen.zenscript.codemodel.type.BasicTypeID;
30 30
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
31 31
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
32 32
 import org.openzen.zenscript.codemodel.type.ISymbol;
33
+import org.openzen.zenscript.codemodel.type.StoredType;
33 34
 import org.openzen.zenscript.codemodel.type.StringTypeID;
34
-import org.openzen.zenscript.codemodel.type.TypeArgument;
35 35
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
36 36
 import org.openzen.zenscript.javashared.JavaClass;
37 37
 import org.openzen.zenscript.javashared.JavaField;
@@ -119,7 +119,7 @@ public class GlobalRegistry {
119 119
 	private class PrintlnSymbol implements ISymbol {
120 120
 
121 121
 		@Override
122
-		public IPartialExpression getExpression(CodePosition position, BaseScope scope, TypeArgument[] typeArguments) {
122
+		public IPartialExpression getExpression(CodePosition position, BaseScope scope, StoredType[] typeArguments) {
123 123
 			return new PartialMemberGroupExpression(
124 124
 					position,
125 125
 					scope,
@@ -131,7 +131,7 @@ public class GlobalRegistry {
131 131
 		}
132 132
 
133 133
 		@Override
134
-		public TypeID getType(CodePosition position, TypeResolutionContext context, TypeArgument[] typeArguments) {
134
+		public TypeID getType(CodePosition position, TypeResolutionContext context, StoredType[] typeArguments) {
135 135
 			return null; // not a type
136 136
 		}
137 137
 	}

+ 1
- 1
Validator/src/main/java/org/openzen/zenscript/validator/visitors/ExpressionValidator.java View File

@@ -613,7 +613,7 @@ public class ExpressionValidator implements ExpressionVisitor<Void> {
613 613
 	public Void visitStorageCast(StorageCastExpression expression) {
614 614
 		if (expression.value.type.type != expression.type.type)
615 615
 			validator.logError(ValidationLogEntry.Code.INVALID_STORAGE_CAST, expression.position, "Invalid storage cast");
616
-		if (!expression.value.type.storage.canCastTo(expression.type.storage) && !expression.type.storage.canCastFrom(expression.value.type.storage))
616
+		if (!expression.value.type.getActualStorage().canCastTo(expression.type.getActualStorage()) && !expression.type.getActualStorage().canCastFrom(expression.value.type.getActualStorage()))
617 617
 			validator.logError(ValidationLogEntry.Code.INVALID_STORAGE_CAST, expression.position, "Invalid storage cast");
618 618
 		
619 619
 		expression.value.accept(this);

+ 3
- 3
Validator/src/main/java/org/openzen/zenscript/validator/visitors/SupertypeValidator.java View File

@@ -11,7 +11,7 @@ import org.openzen.zenscript.codemodel.Modifiers;
11 11
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
12 12
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
-import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
14
+import org.openzen.zenscript.codemodel.type.OptionalTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
16 16
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -100,8 +100,8 @@ public class SupertypeValidator implements TypeVisitor<Void> {
100 100
 	}
101 101
 
102 102
 	@Override
103
-	public Void visitModified(ModifiedTypeID type) {
104
-		validator.logError(ValidationLogEntry.Code.SUPERCLASS_NOT_A_CLASS, position, "Superclass cannot be a modified type");
103
+	public Void visitOptional(OptionalTypeID type) {
104
+		validator.logError(ValidationLogEntry.Code.SUPERCLASS_NOT_A_CLASS, position, "Superclass cannot be an optional type");
105 105
 		return null;
106 106
 	}
107 107
 

+ 0
- 0
Validator/src/main/java/org/openzen/zenscript/validator/visitors/TypeValidator.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save