Browse Source

Continue work on storage tags. WIP on compile plugins.

Stan Hebben 6 years ago
parent
commit
f97c8450d9
100 changed files with 820 additions and 424 deletions
  1. 1
    1
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java
  2. 3
    3
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java
  3. 7
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java
  4. 11
    21
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  5. 14
    12
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java
  6. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java
  7. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/LocalTypeResolutionContext.java
  8. 2
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeContext.java
  9. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java
  10. 8
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java
  11. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java
  12. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java
  13. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  14. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/IsExpression.java
  15. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java
  16. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  17. 2
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java
  18. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  19. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinition.java
  20. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/IPartialExpression.java
  21. 6
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialGlobalExpression.java
  22. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java
  23. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialPackageExpression.java
  24. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  25. 8
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java
  26. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialVariantOptionExpression.java
  27. 29
    18
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java
  28. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java
  29. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java
  30. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java
  31. 6
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  32. 31
    30
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  33. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java
  34. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java
  35. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericName.java
  36. 9
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java
  37. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GlobalTypeRegistry.java
  38. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ISymbol.java
  39. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/InvalidTypeID.java
  40. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java
  41. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ModifiedTypeID.java
  42. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java
  43. 35
    29
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java
  44. 6
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java
  45. 111
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeArgument.java
  46. 13
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java
  47. 35
    34
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeMatcher.java
  48. 16
    16
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java
  49. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeSymbol.java
  50. 6
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  51. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java
  52. 2
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  53. 17
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AutoStorageTag.java
  54. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AutoStorageType.java
  55. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageTag.java
  56. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/InvalidStorageTag.java
  57. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageTag.java
  58. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticExpressionStorageTag.java
  59. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageTag.java
  60. 15
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageTag.java
  61. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java
  62. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageTag.java
  63. 12
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/ValueStorageTag.java
  64. 49
    0
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/BuiltinCompilePlugin.java
  65. 22
    0
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/CompilePlugin.java
  66. 0
    1
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  67. 3
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeContext.java
  68. 3
    3
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  69. 1
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaSyntheticTypeSignatureConverter.java
  70. 1
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeDescriptorVisitor.java
  71. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeGenericVisitor.java
  72. 27
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeUtils.java
  73. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java
  74. 5
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java
  75. 9
    9
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java
  76. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java
  77. 5
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceStatementScope.java
  78. 1
    1
      ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/Main.java
  79. 7
    5
      Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java
  80. 5
    4
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedAnnotation.java
  81. 3
    3
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java
  82. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java
  83. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java
  84. 8
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedTypeParameter.java
  85. 14
    14
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedCallArguments.java
  86. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionCall.java
  87. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFloat.java
  88. 4
    4
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java
  89. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionIndex.java
  90. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionInt.java
  91. 3
    3
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionMember.java
  92. 6
    14
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionVariable.java
  93. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryConvertExpression.java
  94. 2
    3
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedTryRethrowExpression.java
  95. 16
    2
      Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java
  96. 9
    2
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java
  97. 34
    6
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java
  98. 7
    0
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedOptionalBasicType.java
  99. 1
    2
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java
  100. 0
    0
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedString.java

+ 1
- 1
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java View File

238
 				case CAST: {
238
 				case CAST: {
239
 					StringBuilder result = new StringBuilder();
239
 					StringBuilder result = new StringBuilder();
240
 					result.append(" as ");
240
 					result.append(" as ");
241
-					result.append(expression.arguments.typeArguments[0].accept(typeFormatter));
241
+					result.append(typeFormatter.format(expression.arguments.typeArguments[0]));
242
 					return new ExpressionString(result.toString(), ZenScriptOperator.CAST);
242
 					return new ExpressionString(result.toString(), ZenScriptOperator.CAST);
243
 				}
243
 				}
244
 				default:
244
 				default:

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

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

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

22
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
22
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
23
 import org.openzen.zenscript.codemodel.type.StoredType;
23
 import org.openzen.zenscript.codemodel.type.StoredType;
24
 import org.openzen.zenscript.codemodel.type.StringTypeID;
24
 import org.openzen.zenscript.codemodel.type.StringTypeID;
25
+import org.openzen.zenscript.codemodel.type.TypeArgument;
25
 import org.openzen.zenscript.codemodel.type.TypeID;
26
 import org.openzen.zenscript.codemodel.type.TypeID;
26
 import stdlib.Chars;
27
 import stdlib.Chars;
27
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
28
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
43
 		return type.accept(this);
44
 		return type.accept(this);
44
 	}
45
 	}
45
 	
46
 	
47
+	public String format(TypeArgument type) {
48
+		return type.storage == null ? format(type.type) : format(type.stored());
49
+	}
50
+	
46
 	public String format(StoredType type) {
51
 	public String format(StoredType type) {
47
 		return type.type.accept(this) + "`" + type.storage.toString();
52
 		return type.type.accept(this) + "`" + type.storage.toString();
48
 	}
53
 	}
97
 		result.append(importedName);
102
 		result.append(importedName);
98
 		result.append("<");
103
 		result.append("<");
99
 		int index = 0;
104
 		int index = 0;
100
-		for (TypeID typeParameter : definition.typeArguments) {
105
+		for (TypeArgument typeParameter : definition.typeArguments) {
101
 			if (index > 0)
106
 			if (index > 0)
102
 				result.append(", ");
107
 				result.append(", ");
103
 			
108
 			
104
-			result.append(typeParameter.accept(this));
109
+			result.append(format(typeParameter));
105
 		}
110
 		}
106
 		result.append(">");
111
 		result.append(">");
107
 		return result.toString();
112
 		return result.toString();

+ 11
- 21
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

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

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

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

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java View File

52
 	public List<FunctionHeader> getInitializers(BaseScope scope) {
52
 	public List<FunctionHeader> getInitializers(BaseScope scope) {
53
 		return Collections.singletonList(new FunctionHeader(
53
 		return Collections.singletonList(new FunctionHeader(
54
 				BasicTypeID.VOID.stored,
54
 				BasicTypeID.VOID.stored,
55
-				scope.getType(CodePosition.BUILTIN, enforcementLevelName).stored(ValueStorageTag.INSTANCE),
55
+				scope.getType(CodePosition.BUILTIN, enforcementLevelName).stored(),
56
 				BasicTypeID.BOOL.stored,
56
 				BasicTypeID.BOOL.stored,
57
 				StringTypeID.UNIQUE));
57
 				StringTypeID.UNIQUE));
58
 	}
58
 	}

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

73
 			return null;
73
 			return null;
74
 		
74
 		
75
 		TypeID self = getTypeRegistry().getForMyDefinition(type.load());
75
 		TypeID self = getTypeRegistry().getForMyDefinition(type.load());
76
-		return self.stored(self.isValueType() ? ValueStorageTag.INSTANCE : BorrowStorageTag.THIS);
76
+		return self.stored(BorrowStorageTag.THIS);
77
 	}
77
 	}
78
 }
78
 }

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

6
 package org.openzen.zenscript.codemodel.context;
6
 package org.openzen.zenscript.codemodel.context;
7
 
7
 
8
 import java.util.Arrays;
8
 import java.util.Arrays;
9
-import java.util.HashMap;
10
 import java.util.List;
9
 import java.util.List;
11
 import java.util.Map;
10
 import java.util.Map;
12
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.type.StoredType;
13
 import org.openzen.zenscript.codemodel.type.StoredType;
14
+import org.openzen.zenscript.codemodel.type.TypeArgument;
15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
-import org.openzen.zenscript.codemodel.type.TypeID;
18
 
17
 
19
 /**
18
 /**
20
  *
19
  *
61
 	}
60
 	}
62
 	
61
 	
63
 	public GenericMapper getMapper() {
62
 	public GenericMapper getMapper() {
64
-		Map<TypeParameter, TypeID> mapper = new HashMap<>();
65
-		for (TypeParameter parameter : typeParameters)
66
-			mapper.put(parameter, moduleContext.registry.getGeneric(parameter));
63
+		Map<TypeParameter, TypeArgument> mapper = TypeArgument.getSelfMapping(moduleContext.registry, typeParameters);
67
 		return new GenericMapper(moduleContext.registry, mapper);
64
 		return new GenericMapper(moduleContext.registry, mapper);
68
 	}
65
 	}
69
 	
66
 	

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

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

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

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

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

50
 	public Expression normalize(TypeScope scope) {
50
 	public Expression normalize(TypeScope scope) {
51
 		return new CallStaticExpression(
51
 		return new CallStaticExpression(
52
 				position,
52
 				position,
53
-				target.getNormalizedUnstored(),
53
+				target.getNormalized(),
54
 				member,
54
 				member,
55
 				instancedHeader.normalize(scope.getTypeRegistry()),
55
 				instancedHeader.normalize(scope.getTypeRegistry()),
56
 				arguments.normalize(position, scope, instancedHeader));
56
 				arguments.normalize(position, scope, instancedHeader));

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

21
 	public final EnumConstantMember value;
21
 	public final EnumConstantMember value;
22
 	
22
 	
23
 	public EnumConstantExpression(CodePosition position, TypeID type, EnumConstantMember value) {
23
 	public EnumConstantExpression(CodePosition position, TypeID type, EnumConstantMember value) {
24
-		super(position, type.stored(ValueStorageTag.INSTANCE), null);
24
+		super(position, type.stored(), null);
25
 		
25
 		
26
 		this.value = value;
26
 		this.value = value;
27
 	}
27
 	}
28
 	
28
 	
29
 	public EnumConstantExpression(CodePosition position, GlobalTypeRegistry registry, EnumDefinition type, EnumConstantMember value) {
29
 	public EnumConstantExpression(CodePosition position, GlobalTypeRegistry registry, EnumDefinition type, EnumConstantMember value) {
30
-		super(position, registry.getForDefinition(type).stored(ValueStorageTag.INSTANCE), null);
30
+		super(position, registry.getForDefinition(type).stored(), null);
31
 		
31
 		
32
 		this.value = value;
32
 		this.value = value;
33
 	}
33
 	}

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

25
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
25
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
26
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
26
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeID;
28
+import org.openzen.zenscript.codemodel.type.TypeArgument;
29
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
29
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
30
 
30
 
31
 /**
31
 /**
131
 	}
131
 	}
132
 	
132
 	
133
 	@Override
133
 	@Override
134
-	public TypeID[] getGenericCallTypes() {
134
+	public TypeArgument[] getTypeArguments() {
135
 		return null;
135
 		return null;
136
 	}
136
 	}
137
 	
137
 	

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

43
 
43
 
44
 	@Override
44
 	@Override
45
 	public Expression normalize(TypeScope scope) {
45
 	public Expression normalize(TypeScope scope) {
46
-		return new IsExpression(position, value.normalize(scope), isType.getNormalizedUnstored());
46
+		return new IsExpression(position, value.normalize(scope), isType.getNormalized());
47
 	}
47
 	}
48
 }
48
 }

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

39
 
39
 
40
 	@Override
40
 	@Override
41
 	public TypeParameterBound instance(GenericMapper mapper) {
41
 	public TypeParameterBound instance(GenericMapper mapper) {
42
-		TypeID translated = type.instanceUnstored(mapper);
42
+		TypeID translated = type.instance(mapper, null).type;
43
 		if (translated == type)
43
 		if (translated == type)
44
 			return this;
44
 			return this;
45
 		
45
 		

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

45
 
45
 
46
 	@Override
46
 	@Override
47
 	public TypeParameterBound instance(GenericMapper mapper) {
47
 	public TypeParameterBound instance(GenericMapper mapper) {
48
-		return new ParameterTypeBound(position, type.instanceUnstored(mapper));
48
+		return new ParameterTypeBound(position, type.instance(mapper, null).type);
49
 	}
49
 	}
50
 
50
 
51
 	@Override
51
 	@Override

+ 2
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java View File

7
 
7
 
8
 import java.util.ArrayList;
8
 import java.util.ArrayList;
9
 import java.util.List;
9
 import java.util.List;
10
-import java.util.Map;
11
 import org.openzen.zencode.shared.CodePosition;
10
 import org.openzen.zencode.shared.CodePosition;
12
 import org.openzen.zencode.shared.Taggable;
11
 import org.openzen.zencode.shared.Taggable;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
 import org.openzen.zenscript.codemodel.type.TypeID;
12
 import org.openzen.zenscript.codemodel.type.TypeID;
15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
13
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
 
15
 
17
 /**
16
 /**
18
  *
17
  *
23
 	
22
 	
24
 	public final CodePosition position;
23
 	public final CodePosition position;
25
 	public final String name;
24
 	public final String name;
25
+	public StorageTag storage = null;
26
 	public final List<TypeParameterBound> bounds = new ArrayList<>();
26
 	public final List<TypeParameterBound> bounds = new ArrayList<>();
27
 	
27
 	
28
 	public TypeParameter(CodePosition position, String name) {
28
 	public TypeParameter(CodePosition position, String name) {
57
 		return true;
57
 		return true;
58
 	}
58
 	}
59
 	
59
 	
60
-	public TypeParameter withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, TypeID> arguments) {
61
-		// TODO: think about this...
62
-		//List<GenericParameterBound> bounds = new ArrayList<>();
63
-		//for (GenericParameterBound bound : this.bounds)
64
-		//	bounds.add(bound.withGenericArguments(registry, arguments));
65
-		//return new TypeParameter(name, bounds);
66
-		return this;
67
-	}
68
-	
69
 	public String getCanonical() {
60
 	public String getCanonical() {
70
 		StringBuilder result = new StringBuilder();
61
 		StringBuilder result = new StringBuilder();
71
 		result.append(name);
62
 		result.append(name);

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

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

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

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

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

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

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

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

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

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

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

17
 import org.openzen.zenscript.codemodel.type.GenericName;
17
 import org.openzen.zenscript.codemodel.type.GenericName;
18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
20
-import org.openzen.zenscript.codemodel.type.TypeID;
20
+import org.openzen.zenscript.codemodel.type.TypeArgument;
21
 
21
 
22
 /**
22
 /**
23
  *
23
  *
58
 	}
58
 	}
59
 
59
 
60
 	@Override
60
 	@Override
61
-	public TypeID[] getGenericCallTypes() {
61
+	public TypeArgument[] getTypeArguments() {
62
 		return null;
62
 		return null;
63
 	}
63
 	}
64
 }
64
 }

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

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

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

19
 import org.openzen.zenscript.codemodel.type.GenericName;
19
 import org.openzen.zenscript.codemodel.type.GenericName;
20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21
 import org.openzen.zenscript.codemodel.type.StoredType;
21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
+import org.openzen.zenscript.codemodel.type.TypeArgument;
22
 import org.openzen.zenscript.codemodel.type.TypeID;
23
 import org.openzen.zenscript.codemodel.type.TypeID;
23
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
24
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
24
 
25
 
29
 public class PartialTypeExpression implements IPartialExpression {
30
 public class PartialTypeExpression implements IPartialExpression {
30
 	private final CodePosition position;
31
 	private final CodePosition position;
31
 	private final StoredType type;
32
 	private final StoredType type;
32
-	private final TypeID[] typeParameters;
33
+	private final TypeArgument[] typeArguments;
33
 	
34
 	
34
-	public PartialTypeExpression(CodePosition position, TypeID type, TypeID[] typeParameters) {
35
+	public PartialTypeExpression(CodePosition position, TypeID type, TypeArgument[] typeArguments) {
35
 		this.position = position;
36
 		this.position = position;
36
 		this.type = type.stored(StaticExpressionStorageTag.INSTANCE);
37
 		this.type = type.stored(StaticExpressionStorageTag.INSTANCE);
37
-		this.typeParameters = typeParameters;
38
+		this.typeArguments = typeArguments;
38
 	}
39
 	}
39
 
40
 
40
 	@Override
41
 	@Override
64
 
65
 
65
 	@Override
66
 	@Override
66
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
67
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
67
-		if (arguments.getNumberOfTypeArguments() == 0 && (typeParameters != null && typeParameters.length > 0))
68
-			arguments = new CallArguments(typeParameters, arguments.arguments);
68
+		if (arguments.getNumberOfTypeArguments() == 0 && (typeArguments != null && typeArguments.length > 0))
69
+			arguments = new CallArguments(typeArguments, arguments.arguments);
69
 		
70
 		
70
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).callStatic(position, type.type, scope, arguments);
71
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).callStatic(position, type.type, scope, arguments);
71
 	}
72
 	}
72
 
73
 
73
 	@Override
74
 	@Override
74
-	public TypeID[] getGenericCallTypes() {
75
-		return typeParameters;
75
+	public TypeArgument[] getTypeArguments() {
76
+		return typeArguments;
76
 	}
77
 	}
77
 	
78
 	
78
 	@Override
79
 	@Override

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

20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21
 import org.openzen.zenscript.codemodel.type.GenericName;
21
 import org.openzen.zenscript.codemodel.type.GenericName;
22
 import org.openzen.zenscript.codemodel.type.StoredType;
22
 import org.openzen.zenscript.codemodel.type.StoredType;
23
+import org.openzen.zenscript.codemodel.type.TypeArgument;
23
 import org.openzen.zenscript.codemodel.type.TypeID;
24
 import org.openzen.zenscript.codemodel.type.TypeID;
24
 
25
 
25
 /**
26
 /**
69
 	}
70
 	}
70
 
71
 
71
 	@Override
72
 	@Override
72
-	public TypeID[] getGenericCallTypes() {
73
-		return TypeID.NONE;
73
+	public TypeArgument[] getTypeArguments() {
74
+		return TypeArgument.NONE;
74
 	}
75
 	}
75
 }
76
 }

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.scope;
6
 package org.openzen.zenscript.codemodel.scope;
7
 
7
 
8
+import java.util.ArrayList;
9
+import java.util.Arrays;
8
 import java.util.HashMap;
10
 import java.util.HashMap;
9
 import java.util.List;
11
 import java.util.List;
10
 import java.util.Map;
12
 import java.util.Map;
27
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
29
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
28
 import org.openzen.zenscript.codemodel.type.GenericName;
30
 import org.openzen.zenscript.codemodel.type.GenericName;
29
 import org.openzen.zenscript.codemodel.type.StoredType;
31
 import org.openzen.zenscript.codemodel.type.StoredType;
32
+import org.openzen.zenscript.codemodel.type.TypeArgument;
30
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
33
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
31
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;
34
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPreparer;
32
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
35
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
45
 	private final HighLevelDefinition definition;
48
 	private final HighLevelDefinition definition;
46
 	private final StoredType type;
49
 	private final StoredType type;
47
 	private final TypeMembers members;
50
 	private final TypeMembers members;
48
-	private final Map<String, TypeParameter> genericParameters = new HashMap<>();
51
+	private final TypeParameter[] typeParameters;
49
 	private final Map<String, Supplier<HighLevelDefinition>> innerTypes = new HashMap<>();
52
 	private final Map<String, Supplier<HighLevelDefinition>> innerTypes = new HashMap<>();
50
 	private final GenericMapper typeParameterMap;
53
 	private final GenericMapper typeParameterMap;
51
 	
54
 	
57
 		this.outer = outer;
60
 		this.outer = outer;
58
 		this.definition = definition;
61
 		this.definition = definition;
59
 		
62
 		
60
-		Map<TypeParameter, TypeID> typeParameters = new HashMap<>();
63
+		Map<TypeParameter, TypeArgument> typeParameters = new HashMap<>();
61
 		if (definition instanceof ExpansionDefinition) {
64
 		if (definition instanceof ExpansionDefinition) {
62
 			ExpansionDefinition expansion = (ExpansionDefinition)definition;
65
 			ExpansionDefinition expansion = (ExpansionDefinition)definition;
63
-			type = expansion.target.stored(expansion.target.isValueType() ? ValueStorageTag.INSTANCE : BorrowStorageTag.THIS);
64
-			
65
-			for (TypeParameter parameter : expansion.typeParameters) {
66
-				genericParameters.put(parameter.name, parameter);
67
-				typeParameters.put(parameter, outer.getTypeRegistry().getGeneric(parameter));
68
-			}
66
+			type = expansion.target.storage == null
67
+					? expansion.target.stored(BorrowStorageTag.THIS)
68
+					: expansion.target.stored();
69
+			this.typeParameters = expansion.typeParameters;
70
+			typeParameters = TypeArgument.getSelfMapping(outer.getTypeRegistry(), expansion.typeParameters);
69
 		} else {
71
 		} else {
70
 			DefinitionTypeID definitionType = outer.getTypeRegistry().getForMyDefinition(definition);
72
 			DefinitionTypeID definitionType = outer.getTypeRegistry().getForMyDefinition(definition);
71
-			type = definitionType.stored(definitionType.isValueType() ? ValueStorageTag.INSTANCE : BorrowStorageTag.THIS);
73
+			type = definitionType.stored(BorrowStorageTag.THIS);
72
 			
74
 			
75
+			List<TypeParameter> typeParameterList = new ArrayList<>();
73
 			while (definitionType != null) {
76
 			while (definitionType != null) {
74
-				for (TypeParameter parameter : definitionType.definition.typeParameters) {
75
-					genericParameters.put(parameter.name, parameter);
76
-					typeParameters.put(parameter, outer.getTypeRegistry().getGeneric(parameter));
77
-				}
77
+				typeParameters = TypeArgument.getSelfMapping(outer.getTypeRegistry(), definitionType.definition.typeParameters);
78
+				typeParameterList.addAll(Arrays.asList(definitionType.definition.typeParameters));
79
+				
78
 				definitionType = definitionType.definition.isStatic() ? null : definitionType.outer;
80
 				definitionType = definitionType.definition.isStatic() ? null : definitionType.outer;
79
 			}
81
 			}
82
+			this.typeParameters = typeParameterList.toArray(new TypeParameter[typeParameterList.size()]);
80
 		}
83
 		}
81
 		
84
 		
82
 		members = withMembers ? outer.getMemberCache().get(type) : null;
85
 		members = withMembers ? outer.getMemberCache().get(type) : null;
102
 		} else if (innerTypes.containsKey(name.name)) {
105
 		} else if (innerTypes.containsKey(name.name)) {
103
 			return new PartialTypeExpression(position, getTypeRegistry().getForDefinition(innerTypes.get(name).get(), name.arguments), name.arguments);
106
 			return new PartialTypeExpression(position, getTypeRegistry().getForDefinition(innerTypes.get(name).get(), name.arguments), name.arguments);
104
 		}
107
 		}
105
-		if (genericParameters.containsKey(name.name) && !name.hasArguments())
106
-			return new PartialTypeExpression(position, getTypeRegistry().getGeneric(genericParameters.get(name.name)), name.arguments);
108
+		if (!name.hasArguments()) {
109
+			for (TypeParameter parameter : typeParameters)
110
+				if (parameter.name.equals(name.name))
111
+					return new PartialTypeExpression(position, getTypeRegistry().getGeneric(parameter), name.arguments);
112
+		}
107
 		
113
 		
108
 		return outer.get(position, name);
114
 		return outer.get(position, name);
109
 	}
115
 	}
116
 				result = getTypeMembers(result.stored(StaticExpressionStorageTag.INSTANCE)).getInnerType(position, name.get(i));
122
 				result = getTypeMembers(result.stored(StaticExpressionStorageTag.INSTANCE)).getInnerType(position, name.get(i));
117
 			}
123
 			}
118
 			return result;
124
 			return result;
119
-		} else if (genericParameters.containsKey(name.get(0).name) && name.size() == 1 && !name.get(0).hasArguments()) {
120
-			return getTypeRegistry().getGeneric(genericParameters.get(name.get(0).name));
121
-		} else if (innerTypes.containsKey(name.get(0).name)) {
125
+		} 
126
+		
127
+		if (name.size() == 1 && !name.get(0).hasArguments())
128
+			for (TypeParameter parameter : typeParameters)
129
+				if (parameter.name.equals(name.get(0).name))
130
+					return getTypeRegistry().getGeneric(parameter);
131
+		
132
+		if (innerTypes.containsKey(name.get(0).name)) {
122
 			TypeID result = getTypeRegistry().getForDefinition(innerTypes.get(name.get(0).name).get(), name.get(0).arguments);
133
 			TypeID result = getTypeRegistry().getForDefinition(innerTypes.get(name.get(0).name).get(), name.get(0).arguments);
123
 			for (int i = 1; i < name.size(); i++) {
134
 			for (int i = 1; i < name.size(); i++) {
124
 				result = getTypeMembers(result.stored(StaticExpressionStorageTag.INSTANCE)).getInnerType(position, name.get(i));
135
 				result = getTypeMembers(result.stored(StaticExpressionStorageTag.INSTANCE)).getInnerType(position, name.get(i));

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

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

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

10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
13
 
14
 
14
 /**
15
 /**
15
  *
16
  *
36
 	}
37
 	}
37
 	
38
 	
38
 	@Override
39
 	@Override
39
-	public ArrayTypeID getNormalizedUnstored() {
40
+	public ArrayTypeID getNormalized() {
40
 		return normalized;
41
 		return normalized;
41
 	}
42
 	}
42
 	
43
 	
76
 	}
77
 	}
77
 	
78
 	
78
 	@Override
79
 	@Override
79
-	public ArrayTypeID instanceUnstored(GenericMapper mapper) {
80
-		return mapper.registry.getArray(elementType.instance(mapper), dimension);
80
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
81
+		return mapper.registry.getArray(elementType.instance(mapper), dimension).argument(storage);
81
 	}
82
 	}
82
 
83
 
83
 	@Override
84
 	@Override

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

10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
13
 
14
 
14
 /**
15
 /**
15
  *
16
  *
31
 	}
32
 	}
32
 	
33
 	
33
 	@Override
34
 	@Override
34
-	public AssocTypeID instanceUnstored(GenericMapper mapper) {
35
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
35
 		return mapper.registry.getAssociative(
36
 		return mapper.registry.getAssociative(
36
 				keyType.instance(mapper),
37
 				keyType.instance(mapper),
37
-				valueType.instance(mapper));
38
+				valueType.instance(mapper)).argument(storage);
38
 	}
39
 	}
39
 	
40
 	
40
 	@Override
41
 	@Override
41
-	public AssocTypeID getNormalizedUnstored() {
42
+	public AssocTypeID getNormalized() {
42
 		return normalized;
43
 		return normalized;
43
 	}
44
 	}
44
 	
45
 	

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

11
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
15
 
16
 
16
 /**
17
 /**
40
 	
41
 	
41
 	public final String name;
42
 	public final String name;
42
 	public final StoredType stored;
43
 	public final StoredType stored;
44
+	public final TypeArgument argument;
43
 	
45
 	
44
 	BasicTypeID(String name) {
46
 	BasicTypeID(String name) {
45
 		this.name = name;
47
 		this.name = name;
46
 		stored = new StoredType(this, ValueStorageTag.INSTANCE);
48
 		stored = new StoredType(this, ValueStorageTag.INSTANCE);
49
+		argument = new TypeArgument(this, ValueStorageTag.INSTANCE);
47
 	}
50
 	}
48
 	
51
 	
49
 	@Override
52
 	@Override
50
-	public BasicTypeID getNormalizedUnstored() {
53
+	public BasicTypeID getNormalized() {
51
 		return this;
54
 		return this;
52
 	}
55
 	}
53
 	
56
 	
54
 	@Override
57
 	@Override
55
-	public BasicTypeID instanceUnstored(GenericMapper mapper) {
56
-		return this;
58
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
59
+		return new TypeArgument(this, storage);
57
 	}
60
 	}
58
 	
61
 	
59
 	@Override
62
 	@Override

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

18
 import org.openzen.zenscript.codemodel.definition.StructDefinition;
18
 import org.openzen.zenscript.codemodel.definition.StructDefinition;
19
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
19
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
20
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
20
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
21
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
21
 
22
 
22
 /**
23
 /**
23
  *
24
  *
28
 		if (definition.typeParameters != null && definition.typeParameters.length > 0)
29
 		if (definition.typeParameters != null && definition.typeParameters.length > 0)
29
 			throw new IllegalArgumentException("Definition has type arguments!");
30
 			throw new IllegalArgumentException("Definition has type arguments!");
30
 		
31
 		
31
-		return new DefinitionTypeID(registry, definition, TypeID.NONE);
32
+		return new DefinitionTypeID(registry, definition, TypeArgument.NONE);
32
 	}
33
 	}
33
 	
34
 	
34
 	public final HighLevelDefinition definition;
35
 	public final HighLevelDefinition definition;
35
-	public final TypeID[] typeArguments;
36
+	public final TypeArgument[] typeArguments;
36
 	public final DefinitionTypeID outer;
37
 	public final DefinitionTypeID outer;
37
 	private TypeID normalized;
38
 	private TypeID normalized;
38
 	
39
 	
39
 	public TypeID superType;
40
 	public TypeID superType;
40
 	
41
 	
41
-	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeID[] typeArguments) {
42
+	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeArgument[] typeArguments) {
42
 		this(typeRegistry, definition, typeArguments, null);
43
 		this(typeRegistry, definition, typeArguments, null);
43
 	}
44
 	}
44
 	
45
 	
45
 	// For inner classes of generic outer classes
46
 	// For inner classes of generic outer classes
46
-	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeID[] typeArguments, DefinitionTypeID outer) {
47
+	public DefinitionTypeID(GlobalTypeRegistry typeRegistry, HighLevelDefinition definition, TypeArgument[] typeArguments, DefinitionTypeID outer) {
47
 		if (typeArguments == null)
48
 		if (typeArguments == null)
48
 			throw new NullPointerException("typeParameters cannot be null");
49
 			throw new NullPointerException("typeParameters cannot be null");
49
 		if (typeArguments.length != definition.getNumberOfGenericParameters())
50
 		if (typeArguments.length != definition.getNumberOfGenericParameters())
66
 		if (definition instanceof AliasDefinition)
67
 		if (definition instanceof AliasDefinition)
67
 			return true;
68
 			return true;
68
 		
69
 		
69
-		for (TypeID typeParameter : typeArguments)
70
-			if (typeParameter.getNormalizedUnstored() != typeParameter)
70
+		for (TypeArgument typeArgument : typeArguments)
71
+			if (!typeArgument.getNormalized().equals(typeArgument))
71
 				return true;
72
 				return true;
72
-		if (outer != null && outer.getNormalizedUnstored() != outer)
73
+		if (outer != null && !outer.getNormalized().equals(outer))
73
 			return true;
74
 			return true;
74
 		
75
 		
75
 		return false;
76
 		return false;
81
 			if (alias.type == null)
82
 			if (alias.type == null)
82
 				throw new IllegalStateException("Alias type not yet initialized!");
83
 				throw new IllegalStateException("Alias type not yet initialized!");
83
 			
84
 			
84
-			Map<TypeParameter, TypeID> typeMapping = new HashMap<>();
85
+			Map<TypeParameter, TypeArgument> typeMapping = new HashMap<>();
85
 			for (int i = 0; i < definition.typeParameters.length; i++)
86
 			for (int i = 0; i < definition.typeParameters.length; i++)
86
-				typeMapping.put(definition.typeParameters[i], typeArguments[i].getNormalizedUnstored());
87
+				typeMapping.put(definition.typeParameters[i], typeArguments[i].getNormalized());
87
 			GenericMapper mapper = new GenericMapper(typeRegistry, typeMapping);
88
 			GenericMapper mapper = new GenericMapper(typeRegistry, typeMapping);
88
-			TypeID result = alias.type.instanceUnstored(mapper).getNormalizedUnstored();
89
+			TypeID result = alias.type.instance(mapper, null).type.getNormalized();
89
 			return result;
90
 			return result;
90
 		}
91
 		}
91
 		
92
 		
92
-		TypeID[] normalizedTypeParameters = new TypeID[typeArguments.length];
93
+		TypeArgument[] normalizedTypeParameters = new TypeArgument[typeArguments.length];
93
 		for (int i = 0; i < normalizedTypeParameters.length; i++)
94
 		for (int i = 0; i < normalizedTypeParameters.length; i++)
94
-			normalizedTypeParameters[i] = typeArguments[i].getNormalizedUnstored();
95
+			normalizedTypeParameters[i] = typeArguments[i].getNormalized();
95
 		
96
 		
96
-		return typeRegistry.getForDefinition(definition, normalizedTypeParameters, outer == null ? null : (DefinitionTypeID)outer.getNormalizedUnstored());
97
+		return typeRegistry.getForDefinition(definition, normalizedTypeParameters, outer == null ? null : (DefinitionTypeID)outer.getNormalized());
97
 	}
98
 	}
98
 	
99
 	
99
 	public boolean hasTypeParameters() {
100
 	public boolean hasTypeParameters() {
100
 		return typeArguments.length > 0;
101
 		return typeArguments.length > 0;
101
 	}
102
 	}
102
 	
103
 	
103
-	public Map<TypeParameter, TypeID> getTypeParameterMapping() {
104
-		Map<TypeParameter, TypeID> mapping = new HashMap<>();
104
+	public Map<TypeParameter, TypeArgument> getTypeParameterMapping() {
105
+		Map<TypeParameter, TypeArgument> mapping = new HashMap<>();
105
 		DefinitionTypeID current = this;
106
 		DefinitionTypeID current = this;
106
 		do {
107
 		do {
107
 			if (current.typeArguments != null) {
108
 			if (current.typeArguments != null) {
119
 	
120
 	
120
 	public DefinitionTypeID(HighLevelDefinition definition) {
121
 	public DefinitionTypeID(HighLevelDefinition definition) {
121
 		this.definition = definition;
122
 		this.definition = definition;
122
-		this.typeArguments = TypeID.NONE;
123
+		this.typeArguments = TypeArgument.NONE;
123
 		this.superType = definition.getSuperType();
124
 		this.superType = definition.getSuperType();
124
 		this.outer = null;
125
 		this.outer = null;
125
 	}
126
 	}
126
 	
127
 	
127
 	@Override
128
 	@Override
128
-	public TypeID getNormalizedUnstored() {
129
+	public TypeID getNormalized() {
129
 		return normalized;
130
 		return normalized;
130
 	}
131
 	}
131
 	
132
 	
132
 	@Override
133
 	@Override
133
-	public DefinitionTypeID instanceUnstored(GenericMapper mapper) {
134
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
134
 		if (!hasTypeParameters() && outer == null)
135
 		if (!hasTypeParameters() && outer == null)
135
-			return this;
136
+			return argument(storage);
136
 		if (mapper.getMapping().isEmpty())
137
 		if (mapper.getMapping().isEmpty())
137
-			return this;
138
+			return argument(storage);
138
 		if (mapper.registry == null)
139
 		if (mapper.registry == null)
139
 			throw new NullPointerException();
140
 			throw new NullPointerException();
140
 		
141
 		
141
-		TypeID[] instancedArguments = TypeID.NONE;
142
+		TypeArgument[] instancedArguments = TypeArgument.NONE;
142
 		if (hasTypeParameters()) {
143
 		if (hasTypeParameters()) {
143
-			instancedArguments = new TypeID[typeArguments.length];
144
+			instancedArguments = new TypeArgument[typeArguments.length];
144
 			for (int i = 0; i < typeArguments.length; i++)
145
 			for (int i = 0; i < typeArguments.length; i++)
145
-				instancedArguments[i] = typeArguments[i].instanceUnstored(mapper);
146
+				instancedArguments[i] = typeArguments[i].instance(mapper);
146
 		}
147
 		}
147
 		
148
 		
148
-		DefinitionTypeID instancedOuter = outer == null ? null : outer.instanceUnstored(mapper);
149
-		return mapper.registry.getForDefinition(definition, instancedArguments, instancedOuter);
149
+		DefinitionTypeID instancedOuter = outer == null ? null : (DefinitionTypeID)outer.instance(mapper, storage).type;
150
+		return mapper.registry.getForDefinition(definition, instancedArguments, instancedOuter).argument(storage);
150
 	}
151
 	}
151
 	
152
 	
152
 	@Override
153
 	@Override
153
 	public TypeID getSuperType(GlobalTypeRegistry registry) {
154
 	public TypeID getSuperType(GlobalTypeRegistry registry) {
154
-		return definition.getSuperType() == null ? null : definition.getSuperType().instanceUnstored(new GenericMapper(registry, getTypeParameterMapping()));
155
+		return definition.getSuperType() == null ? null : definition.getSuperType().instance(new GenericMapper(registry, getTypeParameterMapping()), null).type;
155
 	}
156
 	}
156
 	
157
 	
157
 	@Override
158
 	@Override
202
 	@Override
203
 	@Override
203
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
204
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
204
 		if (hasTypeParameters()) {
205
 		if (hasTypeParameters()) {
205
-			for (TypeID typeParameter : typeArguments)
206
-				if (typeParameter.hasInferenceBlockingTypeParameters(parameters))
206
+			for (TypeArgument typeArgument : typeArguments)
207
+				if (typeArgument.type.hasInferenceBlockingTypeParameters(parameters))
207
 					return true;
208
 					return true;
208
 		}
209
 		}
209
 		
210
 		
263
 
264
 
264
 	@Override
265
 	@Override
265
 	public void extractTypeParameters(List<TypeParameter> typeParameters) {
266
 	public void extractTypeParameters(List<TypeParameter> typeParameters) {
266
-		for (TypeID type : this.typeArguments)
267
-			type.extractTypeParameters(typeParameters);
267
+		for (TypeArgument type : this.typeArguments)
268
+			type.type.extractTypeParameters(typeParameters);
268
 	}
269
 	}
269
 
270
 
270
 	public DefinitionTypeID getInnerType(GenericName name, GlobalTypeRegistry registry) {
271
 	public DefinitionTypeID getInnerType(GenericName name, GlobalTypeRegistry registry) {

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

32
 	}
32
 	}
33
 	
33
 	
34
 	@Override
34
 	@Override
35
-	public FunctionTypeID getNormalizedUnstored() {
35
+	public FunctionTypeID getNormalized() {
36
 		return normalized;
36
 		return normalized;
37
 	}
37
 	}
38
 	
38
 	
39
 	@Override
39
 	@Override
40
-	public TypeID instanceUnstored(GenericMapper mapper) {
41
-		return mapper.registry.getFunction(mapper.map(header));
40
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
41
+		return new TypeArgument(mapper.registry.getFunction(mapper.map(header)), storage);
42
 	}
42
 	}
43
 	
43
 	
44
 	@Override
44
 	@Override

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

11
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
 
15
 
15
 /**
16
 /**
16
  *
17
  *
29
 	}
30
 	}
30
 	
31
 	
31
 	@Override
32
 	@Override
32
-	public GenericMapTypeID getNormalizedUnstored() {
33
+	public GenericMapTypeID getNormalized() {
33
 		return normalized;
34
 		return normalized;
34
 	}
35
 	}
35
 
36
 
69
 	}
70
 	}
70
 	
71
 	
71
 	@Override
72
 	@Override
72
-	public TypeID instanceUnstored(GenericMapper mapper) {
73
-		return mapper.registry.getGenericMap(value.instance(mapper), key);
73
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
74
+		return new TypeArgument(mapper.registry.getGenericMap(value.instance(mapper), key), storage);
74
 	}
75
 	}
75
 
76
 
76
 	@Override
77
 	@Override

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

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

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

11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
13
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
 
15
 
15
 /**
16
 /**
16
  *
17
  *
23
 		this.parameter = parameter;
24
 		this.parameter = parameter;
24
 	}
25
 	}
25
 	
26
 	
26
-	public boolean matches(LocalMemberCache cache, TypeID type) {
27
-		return parameter.matches(cache, type);
27
+	public boolean matches(LocalMemberCache cache, TypeArgument type) {
28
+		if (type.storage != null && parameter.storage != null && !type.storage.equals(parameter.storage))
29
+			return false;
30
+		
31
+		return parameter.matches(cache, type.type);
28
 	}
32
 	}
29
 	
33
 	
30
 	@Override
34
 	@Override
31
-	public GenericTypeID getNormalizedUnstored() {
35
+	public GenericTypeID getNormalized() {
32
 		return this;
36
 		return this;
33
 	}
37
 	}
34
 	
38
 	
35
 	@Override
39
 	@Override
36
-	public TypeID instanceUnstored(GenericMapper mapper) {
37
-		return mapper.map(this);
40
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
41
+		return mapper.map(this).argument(StorageTag.union(parameter.storage, storage));
38
 	}
42
 	}
39
 	
43
 	
40
 	@Override
44
 	@Override

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

76
 	}
76
 	}
77
 	
77
 	
78
 	public DefinitionTypeID getForMyDefinition(HighLevelDefinition definition) {
78
 	public DefinitionTypeID getForMyDefinition(HighLevelDefinition definition) {
79
-		TypeID[] typeArguments = TypeID.NONE;
79
+		TypeArgument[] typeArguments = TypeArgument.NONE;
80
 		if (definition.getNumberOfGenericParameters() > 0) {
80
 		if (definition.getNumberOfGenericParameters() > 0) {
81
-			typeArguments = new TypeID[definition.getNumberOfGenericParameters()];
81
+			typeArguments = new TypeArgument[definition.getNumberOfGenericParameters()];
82
 			for (int i = 0; i < definition.typeParameters.length; i++)
82
 			for (int i = 0; i < definition.typeParameters.length; i++)
83
-				typeArguments[i] = getGeneric(definition.typeParameters[i]);
83
+				typeArguments[i] = new TypeArgument(getGeneric(definition.typeParameters[i]), definition.typeParameters[i].storage);
84
 		}
84
 		}
85
 		DefinitionTypeID outer = null;
85
 		DefinitionTypeID outer = null;
86
 		if (definition.outerDefinition != null)
86
 		if (definition.outerDefinition != null)
89
 		return getForDefinition(definition, typeArguments, outer);
89
 		return getForDefinition(definition, typeArguments, outer);
90
 	}
90
 	}
91
 	
91
 	
92
-	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeID... typeArguments) {
92
+	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeArgument... typeArguments) {
93
 		return this.getForDefinition(definition, typeArguments, null);
93
 		return this.getForDefinition(definition, typeArguments, null);
94
 	}
94
 	}
95
 	
95
 	
96
-	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeID[] typeArguments, DefinitionTypeID outer) {
96
+	public DefinitionTypeID getForDefinition(HighLevelDefinition definition, TypeArgument[] typeArguments, DefinitionTypeID outer) {
97
 		DefinitionTypeID id = new DefinitionTypeID(this, definition, typeArguments, definition.isStatic() ? null : outer);
97
 		DefinitionTypeID id = new DefinitionTypeID(this, definition, typeArguments, definition.isStatic() ? null : outer);
98
 		
98
 		
99
 		if (definitionTypes.containsKey(id)) {
99
 		if (definitionTypes.containsKey(id)) {

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

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

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

12
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.GenericMapper;
13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
15
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
15
 
16
 
16
 /**
17
 /**
17
  *
18
  *
34
 	}
35
 	}
35
 
36
 
36
 	@Override
37
 	@Override
37
-	public InvalidTypeID instanceUnstored(GenericMapper mapper) {
38
-		return this;
38
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
39
+		return new TypeArgument(this, storage);
39
 	}
40
 	}
40
 
41
 
41
 	@Override
42
 	@Override
64
 	}
65
 	}
65
 
66
 
66
 	@Override
67
 	@Override
67
-	public TypeID getNormalizedUnstored() {
68
+	public TypeID getNormalized() {
68
 		return this;
69
 		return this;
69
 	}
70
 	}
70
 	
71
 	

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

11
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
 
15
 
15
 /**
16
 /**
16
  *
17
  *
27
 	}
28
 	}
28
 	
29
 	
29
 	@Override
30
 	@Override
30
-	public IteratorTypeID getNormalizedUnstored() {
31
+	public IteratorTypeID getNormalized() {
31
 		return normalized;
32
 		return normalized;
32
 	}
33
 	}
33
 	
34
 	
82
 	}
83
 	}
83
 	
84
 	
84
 	@Override
85
 	@Override
85
-	public TypeID instanceUnstored(GenericMapper mapper) {
86
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
86
 		StoredType[] instanced = mapper.map(iteratorTypes);
87
 		StoredType[] instanced = mapper.map(iteratorTypes);
87
-		return mapper.registry.getIterator(instanced);
88
+		return new TypeArgument(mapper.registry.getIterator(instanced), storage);
88
 	}
89
 	}
89
 
90
 
90
 	@Override
91
 	@Override

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

32
 		this.baseType = baseType;
32
 		this.baseType = baseType;
33
 		this.registry = registry;
33
 		this.registry = registry;
34
 		
34
 		
35
-		normalized = baseType.getNormalizedUnstored() == baseType ? this : registry.getModified(modifiers, baseType.getNormalizedUnstored());
35
+		normalized = baseType.getNormalized() == baseType ? this : registry.getModified(modifiers, baseType.getNormalized());
36
 	}
36
 	}
37
 	
37
 	
38
 	@Override
38
 	@Override
39
-	public TypeID getNormalizedUnstored() {
39
+	public TypeID getNormalized() {
40
 		return normalized;
40
 		return normalized;
41
 	}
41
 	}
42
 	
42
 	
43
 	@Override
43
 	@Override
44
-	public TypeID instanceUnstored(GenericMapper mapper) {
45
-		return mapper.registry.getModified(modifiers, baseType.instanceUnstored(mapper));
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);
46
 	}
47
 	}
47
 	
48
 	
48
 	@Override
49
 	@Override

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

10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
13
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
14
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
14
 
15
 
15
 /**
16
 /**
33
 			normalized = registry.getRange(baseType.getNormalized());
34
 			normalized = registry.getRange(baseType.getNormalized());
34
 		}
35
 		}
35
 		
36
 		
36
-		stored = new StoredType(this, ValueStorageTag.INSTANCE);
37
+		stored = new StoredType(this, baseType.storage);
37
 	}
38
 	}
38
 	
39
 	
39
 	@Override
40
 	@Override
40
-	public RangeTypeID getNormalizedUnstored() {
41
+	public RangeTypeID getNormalized() {
41
 		return normalized;
42
 		return normalized;
42
 	}
43
 	}
43
 	
44
 	
44
 	@Override
45
 	@Override
45
-	public TypeID instanceUnstored(GenericMapper mapper) {
46
-		return mapper.registry.getRange(baseType.instance(mapper));
46
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
47
+		return mapper.registry.getRange(baseType.instance(mapper)).argument(storage);
47
 	}
48
 	}
48
 	
49
 	
49
 	@Override
50
 	@Override

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

12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
15
-import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
18
 
17
 
27
 	public final StorageTag storage;
26
 	public final StorageTag storage;
28
 	
27
 	
29
 	public StoredType(TypeID type, StorageTag storage) {
28
 	public StoredType(TypeID type, StorageTag storage) {
30
-		if (type.isValueType() && storage != ValueStorageTag.INSTANCE && storage != StaticExpressionStorageTag.INSTANCE)
31
-			throw new IllegalArgumentException("storage of a value type must be value");
32
-		if (!type.isValueType() && storage == ValueStorageTag.INSTANCE)
29
+		if (storage == null)
30
+			throw new NullPointerException();
31
+		
32
+		if (type.isValueType())
33
+			storage = ValueStorageTag.INSTANCE;
34
+		else if (storage == ValueStorageTag.INSTANCE)
33
 			throw new IllegalArgumentException("storage of a nonvalue type cannot be value");
35
 			throw new IllegalArgumentException("storage of a nonvalue type cannot be value");
34
 		
36
 		
35
 		this.type = type;
37
 		this.type = type;
37
 	}
39
 	}
38
 	
40
 	
39
 	public StoredType getNormalized() {
41
 	public StoredType getNormalized() {
40
-		return type.getNormalizedUnstored() == type ? this : new StoredType(type, storage);
42
+		return type.getNormalized() == type ? this : new StoredType(type, storage);
41
 	}
43
 	}
42
 	
44
 	
43
 	public StoredType getSuperType(GlobalTypeRegistry registry) {
45
 	public StoredType getSuperType(GlobalTypeRegistry registry) {
46
 	}
48
 	}
47
 	
49
 	
48
 	public StoredType instance(GenericMapper mapper) {
50
 	public StoredType instance(GenericMapper mapper) {
49
-		TypeID result = mapper.map(type);
50
-		return result == type ? this : new StoredType(result, result.isValueType() ? ValueStorageTag.INSTANCE : storage);
51
+		TypeArgument result = type.instance(mapper, storage);
52
+		return result == type ? this : result.stored();
51
 	}
53
 	}
52
 	
54
 	
53
 	public boolean isDestructible() {
55
 	public boolean isDestructible() {
67
 	}
69
 	}
68
 	
70
 	
69
 	public boolean isConst() {
71
 	public boolean isConst() {
70
-		return type.isConst();
72
+		return storage.isConst();
71
 	}
73
 	}
72
 	
74
 	
73
 	public boolean isImmutable() {
75
 	public boolean isImmutable() {
74
-		return type.isImmutable();
76
+		return storage.isImmutable();
75
 	}
77
 	}
76
 	
78
 	
77
 	public boolean isBasic(BasicTypeID type) {
79
 	public boolean isBasic(BasicTypeID type) {
100
 	
102
 	
101
 	// Infers type parameters for this type so it matches with targetType
103
 	// Infers type parameters for this type so it matches with targetType
102
 	// returns false if that isn't possible
104
 	// returns false if that isn't possible
103
-	public Map<TypeParameter, TypeID> inferTypeParameters(LocalMemberCache cache, StoredType targetType) {
104
-		return type.inferTypeParameters(cache, targetType.type);
105
+	public Map<TypeParameter, TypeArgument> inferTypeParameters(LocalMemberCache cache, TypeArgument targetType) {
106
+		return type.inferTypeParameters(cache, targetType);
105
 	}
107
 	}
106
 	
108
 	
107
 	public boolean isVariant() {
109
 	public boolean isVariant() {
120
 		return (DefinitionTypeID)type;
122
 		return (DefinitionTypeID)type;
121
 	}
123
 	}
122
 	
124
 	
125
+	public TypeArgument asArgument() {
126
+		return new TypeArgument(type, storage);
127
+	}
128
+	
123
 	@Override
129
 	@Override
124
 	public int hashCode() {
130
 	public int hashCode() {
125
 		int hash = 5;
131
 		int hash = 5;
147
 	
153
 	
148
 	public static class MatchingTypeVisitor implements TypeVisitor<Boolean> {
154
 	public static class MatchingTypeVisitor implements TypeVisitor<Boolean> {
149
 		private final TypeID type;
155
 		private final TypeID type;
150
-		private final Map<TypeParameter, TypeID> mapping;
156
+		private final Map<TypeParameter, TypeArgument> mapping;
151
 		private final LocalMemberCache cache;
157
 		private final LocalMemberCache cache;
152
 		
158
 		
153
-		public MatchingTypeVisitor(LocalMemberCache cache, TypeID type, Map<TypeParameter, TypeID> mapping) {
159
+		public MatchingTypeVisitor(LocalMemberCache cache, TypeID type, Map<TypeParameter, TypeArgument> mapping) {
154
 			this.type = type;
160
 			this.type = type;
155
 			this.mapping = mapping;
161
 			this.mapping = mapping;
156
 			this.cache = cache;
162
 			this.cache = cache;
173
 				if (arrayType.dimension != array.dimension)
179
 				if (arrayType.dimension != array.dimension)
174
 					return false;
180
 					return false;
175
 				
181
 				
176
-				return match(arrayType.elementType, array.elementType);
182
+				return match(arrayType.elementType, array.elementType.asArgument());
177
 			} else {
183
 			} else {
178
 				return false;
184
 				return false;
179
 			}
185
 			}
183
 		public Boolean visitAssoc(AssocTypeID assoc) {
189
 		public Boolean visitAssoc(AssocTypeID assoc) {
184
 			if (type instanceof AssocTypeID) {
190
 			if (type instanceof AssocTypeID) {
185
 				AssocTypeID assocType = (AssocTypeID) type;
191
 				AssocTypeID assocType = (AssocTypeID) type;
186
-				return match(assocType.keyType, assoc.keyType)
187
-						&& match(assocType.valueType, assoc.valueType);
192
+				return match(assocType.keyType, assoc.keyType.asArgument())
193
+						&& match(assocType.valueType, assoc.valueType.asArgument());
188
 			} else {
194
 			} else {
189
 				return false;
195
 				return false;
190
 			}
196
 			}
199
 				
205
 				
200
 				boolean result = true;
206
 				boolean result = true;
201
 				for (int i = 0; i < iteratorType.iteratorTypes.length; i++)
207
 				for (int i = 0; i < iteratorType.iteratorTypes.length; i++)
202
-					result = result && match(iterator.iteratorTypes[i], iteratorType.iteratorTypes[i]);
208
+					result = result && match(iterator.iteratorTypes[i], iteratorType.iteratorTypes[i].asArgument());
203
 				
209
 				
204
 				return result;
210
 				return result;
205
 			} else {
211
 			} else {
214
 				if (functionType.header.parameters.length != function.header.parameters.length)
220
 				if (functionType.header.parameters.length != function.header.parameters.length)
215
 					return false;
221
 					return false;
216
 				
222
 				
217
-				if (!match(functionType.header.getReturnType(), function.header.getReturnType()))
223
+				if (!match(functionType.header.getReturnType(), function.header.getReturnType().asArgument()))
218
 					return false;
224
 					return false;
219
 				
225
 				
220
 				for (int i = 0; i < function.header.parameters.length; i++) {
226
 				for (int i = 0; i < function.header.parameters.length; i++) {
221
-					if (!match(functionType.header.parameters[i].type, function.header.parameters[i].type))
227
+					if (!match(functionType.header.parameters[i].type, function.header.parameters[i].type.asArgument()))
222
 						return false;
228
 						return false;
223
 				}
229
 				}
224
 				
230
 				
237
 				
243
 				
238
 				if (definition.typeArguments != null) {
244
 				if (definition.typeArguments != null) {
239
 					for (int i = 0; i < definitionType.typeArguments.length; i++) {
245
 					for (int i = 0; i < definitionType.typeArguments.length; i++) {
240
-						if (!match(definitionType.typeArguments[i], definition.typeArguments[i]))
246
+						if (!match(definitionType.typeArguments[i].stored(), definition.typeArguments[i]))
241
 							return false;
247
 							return false;
242
 					}
248
 					}
243
 				}
249
 				}
252
 		public Boolean visitGeneric(GenericTypeID generic) {
258
 		public Boolean visitGeneric(GenericTypeID generic) {
253
 			if (mapping.containsKey(generic.parameter)) {
259
 			if (mapping.containsKey(generic.parameter)) {
254
 				return mapping.get(generic.parameter) == type;
260
 				return mapping.get(generic.parameter) == type;
255
-			} else if (type == generic || generic.matches(cache, type)) {
256
-				mapping.put(generic.parameter, type);
261
+			} else if (type == generic || generic.matches(cache, new TypeArgument(type, null))) {
262
+				mapping.put(generic.parameter, new TypeArgument(type, null));
257
 				return true;
263
 				return true;
258
 			} else {
264
 			} else {
259
 				return false;
265
 				return false;
264
 		public Boolean visitRange(RangeTypeID range) {
270
 		public Boolean visitRange(RangeTypeID range) {
265
 			if (type instanceof RangeTypeID) {
271
 			if (type instanceof RangeTypeID) {
266
 				RangeTypeID rangeType = (RangeTypeID) type;
272
 				RangeTypeID rangeType = (RangeTypeID) type;
267
-				return match(rangeType.baseType, range.baseType);
273
+				return match(rangeType.baseType, range.baseType.asArgument());
268
 			} else {
274
 			} else {
269
 				return false;
275
 				return false;
270
 			}
276
 			}
274
 		public Boolean visitModified(ModifiedTypeID type) {
280
 		public Boolean visitModified(ModifiedTypeID type) {
275
 			if (this.type instanceof ModifiedTypeID) {
281
 			if (this.type instanceof ModifiedTypeID) {
276
 				ModifiedTypeID constType = (ModifiedTypeID) this.type;
282
 				ModifiedTypeID constType = (ModifiedTypeID) this.type;
277
-				return match(constType.baseType, type.baseType);
283
+				return match(constType.baseType, new TypeArgument(type.baseType, null));
278
 			} else {
284
 			} else {
279
 				return false;
285
 				return false;
280
 			}
286
 			}
281
 		}
287
 		}
282
 		
288
 		
283
-		private boolean match(StoredType type, StoredType pattern) {
284
-			if (type.storage != pattern.storage)
289
+		private boolean match(StoredType type, TypeArgument pattern) {
290
+			if (pattern.storage != null && type.storage != pattern.storage)
285
 				return false;
291
 				return false;
286
 			
292
 			
287
-			return TypeMatcher.match(cache, type.type, pattern.type) != null;
293
+			return TypeMatcher.match(cache, type.asArgument(), pattern) != null;
288
 		}
294
 		}
289
 		
295
 		
290
-		private boolean match(TypeID type, TypeID pattern) {
291
-			return TypeMatcher.match(cache, type, pattern) != null;
296
+		private boolean match(TypeID type, TypeArgument pattern) {
297
+			return TypeMatcher.match(cache, new TypeArgument(type, null), pattern) != null;
292
 		}
298
 		}
293
 
299
 
294
 		@Override
300
 		@Override

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

10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.storage.AnyStorageTag;
13
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
14
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
14
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
17
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
18
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
18
 
19
 
19
 /**
20
 /**
23
 public class StringTypeID implements TypeID {
24
 public class StringTypeID implements TypeID {
24
 	public static final StringTypeID INSTANCE = new StringTypeID();
25
 	public static final StringTypeID INSTANCE = new StringTypeID();
25
 	
26
 	
26
-	public static final StoredType ANY = new StoredType(INSTANCE, AnyStorageTag.INSTANCE);
27
+	public static final StoredType AUTO = new StoredType(INSTANCE, AutoStorageTag.INSTANCE);
27
 	public static final StoredType STATIC = new StoredType(INSTANCE, StaticStorageTag.INSTANCE);
28
 	public static final StoredType STATIC = new StoredType(INSTANCE, StaticStorageTag.INSTANCE);
28
 	public static final StoredType UNIQUE = new StoredType(INSTANCE, UniqueStorageTag.INSTANCE);
29
 	public static final StoredType UNIQUE = new StoredType(INSTANCE, UniqueStorageTag.INSTANCE);
29
 	public static final StoredType BORROW = new StoredType(INSTANCE, BorrowStorageTag.INVOCATION);
30
 	public static final StoredType BORROW = new StoredType(INSTANCE, BorrowStorageTag.INVOCATION);
32
 	private StringTypeID() {}
33
 	private StringTypeID() {}
33
 	
34
 	
34
 	@Override
35
 	@Override
35
-	public TypeID getNormalizedUnstored() {
36
+	public TypeID getNormalized() {
36
 		return INSTANCE;
37
 		return INSTANCE;
37
 	}
38
 	}
38
 	
39
 	
67
 	}
68
 	}
68
 
69
 
69
 	@Override
70
 	@Override
70
-	public TypeID instanceUnstored(GenericMapper mapper) {
71
-		return this;
71
+	public TypeArgument instance(GenericMapper mapper, StorageTag storage) {
72
+		return argument(storage);
72
 	}
73
 	}
73
 
74
 
74
 	@Override
75
 	@Override

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

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
+}

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

12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
15
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
17
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
17
 
18
 
26
 		return null;
27
 		return null;
27
 	}
28
 	}
28
 	
29
 	
29
-	TypeID instanceUnstored(GenericMapper mapper);
30
+	TypeArgument instance(GenericMapper mapper, StorageTag storage);
30
 	
31
 	
31
-	TypeID getNormalizedUnstored();
32
+	TypeID getNormalized();
32
 	
33
 	
33
 	boolean isDestructible();
34
 	boolean isDestructible();
34
 	
35
 	
40
 	
41
 	
41
 	// Infers type parameters for this type so it matches with targetType
42
 	// Infers type parameters for this type so it matches with targetType
42
 	// returns false if that isn't possible
43
 	// returns false if that isn't possible
43
-	default Map<TypeParameter, TypeID> inferTypeParameters(LocalMemberCache cache, TypeID targetType) {
44
-		return TypeMatcher.match(cache, this, targetType);
44
+	default Map<TypeParameter, TypeArgument> inferTypeParameters(LocalMemberCache cache, TypeArgument targetType) {
45
+		return TypeMatcher.match(cache, new TypeArgument(this, null), targetType);
45
 	}
46
 	}
46
 	
47
 	
47
 	void extractTypeParameters(List<TypeParameter> typeParameters);
48
 	void extractTypeParameters(List<TypeParameter> typeParameters);
54
 		return new StoredType(this, storage);
55
 		return new StoredType(this, storage);
55
 	}
56
 	}
56
 	
57
 	
58
+	default StoredType stored() {
59
+		return new StoredType(this, AutoStorageTag.INSTANCE);
60
+	}
61
+	
62
+	default TypeArgument argument(StorageTag storage) {
63
+		return new TypeArgument(this, storage);
64
+	}
65
+	
57
 	default boolean isOptional() {
66
 	default boolean isOptional() {
58
 		return false;
67
 		return false;
59
 	}
68
 	}

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

15
  * @author Hoofdgebruiker
15
  * @author Hoofdgebruiker
16
  */
16
  */
17
 public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching, Boolean, RuntimeException> {
17
 public class TypeMatcher implements TypeVisitorWithContext<TypeMatcher.Matching, Boolean, RuntimeException> {
18
-	public static Map<TypeParameter, TypeID> match(LocalMemberCache cache, TypeID type, TypeID pattern) {
18
+	public static Map<TypeParameter, TypeArgument> match(LocalMemberCache cache, TypeArgument type, TypeArgument pattern) {
19
 		Matching matching = new Matching(cache, type);
19
 		Matching matching = new Matching(cache, type);
20
-		if (pattern.accept(matching, INSTANCE))
20
+		if (pattern.type.accept(matching, INSTANCE))
21
 			return matching.mapping;
21
 			return matching.mapping;
22
 		
22
 		
23
 		return null;
23
 		return null;
29
 	
29
 	
30
 	@Override
30
 	@Override
31
 	public Boolean visitBasic(Matching context, BasicTypeID basic) {
31
 	public Boolean visitBasic(Matching context, BasicTypeID basic) {
32
-		return basic == context.type;
32
+		return context.type.isBasic(basic);
33
 	}
33
 	}
34
 
34
 
35
 	@Override
35
 	@Override
36
 	public Boolean visitString(Matching context, StringTypeID string) {
36
 	public Boolean visitString(Matching context, StringTypeID string) {
37
-		return string == context.type;
37
+		return context.type.type == StringTypeID.INSTANCE;
38
 	}
38
 	}
39
 
39
 
40
 	@Override
40
 	@Override
41
 	public Boolean visitArray(Matching context, ArrayTypeID array) {
41
 	public Boolean visitArray(Matching context, ArrayTypeID array) {
42
-		if (context.type instanceof ArrayTypeID) {
43
-			ArrayTypeID arrayType = (ArrayTypeID) context.type;
42
+		if (context.type.type instanceof ArrayTypeID) {
43
+			ArrayTypeID arrayType = (ArrayTypeID) context.type.type;
44
 			if (arrayType.dimension != array.dimension)
44
 			if (arrayType.dimension != array.dimension)
45
 				return false;
45
 				return false;
46
 
46
 
52
 
52
 
53
 	@Override
53
 	@Override
54
 	public Boolean visitAssoc(Matching context, AssocTypeID assoc) {
54
 	public Boolean visitAssoc(Matching context, AssocTypeID assoc) {
55
-		if (context.type instanceof AssocTypeID) {
56
-			AssocTypeID assocType = (AssocTypeID) context.type;
55
+		if (context.type.type instanceof AssocTypeID) {
56
+			AssocTypeID assocType = (AssocTypeID) context.type.type;
57
 			return match(context, assocType.keyType, assoc.keyType)
57
 			return match(context, assocType.keyType, assoc.keyType)
58
 					&& match(context, assocType.valueType, assoc.valueType);
58
 					&& match(context, assocType.valueType, assoc.valueType);
59
 		} else {
59
 		} else {
68
 
68
 
69
 	@Override
69
 	@Override
70
 	public Boolean visitIterator(Matching context, IteratorTypeID iterator) {
70
 	public Boolean visitIterator(Matching context, IteratorTypeID iterator) {
71
-		if (context.type instanceof IteratorTypeID) {
72
-			IteratorTypeID iteratorType = (IteratorTypeID) context.type;
71
+		if (context.type.type instanceof IteratorTypeID) {
72
+			IteratorTypeID iteratorType = (IteratorTypeID) context.type.type;
73
 			if (iteratorType.iteratorTypes.length != iterator.iteratorTypes.length)
73
 			if (iteratorType.iteratorTypes.length != iterator.iteratorTypes.length)
74
 				return false;
74
 				return false;
75
 
75
 
85
 
85
 
86
 	@Override
86
 	@Override
87
 	public Boolean visitFunction(Matching context, FunctionTypeID function) {
87
 	public Boolean visitFunction(Matching context, FunctionTypeID function) {
88
-		if (context.type instanceof FunctionTypeID) {
89
-			FunctionTypeID functionType = (FunctionTypeID) context.type;
88
+		if (context.type.type instanceof FunctionTypeID) {
89
+			FunctionTypeID functionType = (FunctionTypeID) context.type.type;
90
 			if (functionType.header.parameters.length != function.header.parameters.length)
90
 			if (functionType.header.parameters.length != function.header.parameters.length)
91
 				return false;
91
 				return false;
92
 
92
 
106
 
106
 
107
 	@Override
107
 	@Override
108
 	public Boolean visitDefinition(Matching context, DefinitionTypeID definition) {
108
 	public Boolean visitDefinition(Matching context, DefinitionTypeID definition) {
109
-		if (context.type instanceof DefinitionTypeID) {
110
-			DefinitionTypeID definitionType = (DefinitionTypeID) context.type;
109
+		if (context.type.type instanceof DefinitionTypeID) {
110
+			DefinitionTypeID definitionType = (DefinitionTypeID) context.type.type;
111
 			if (definitionType.definition != definition.definition)
111
 			if (definitionType.definition != definition.definition)
112
 				return false;
112
 				return false;
113
 
113
 
127
 	@Override
127
 	@Override
128
 	public Boolean visitGeneric(Matching context, GenericTypeID generic) {
128
 	public Boolean visitGeneric(Matching context, GenericTypeID generic) {
129
 		if (context.mapping.containsKey(generic.parameter)) {
129
 		if (context.mapping.containsKey(generic.parameter)) {
130
-			return context.mapping.get(generic.parameter) == context.type;
131
-		} else if (context.type == generic || generic.matches(context.cache, context.type)) {
130
+			TypeArgument argument = context.mapping.get(generic.parameter);
131
+			return argument.type == context.type && (argument.storage == null || argument.storage == context.type.storage);
132
+		} else if (context.type.type == generic || generic.matches(context.cache, context.type)) {
132
 			context.mapping.put(generic.parameter, context.type);
133
 			context.mapping.put(generic.parameter, context.type);
133
 			return true;
134
 			return true;
134
 		} else {
135
 		} else {
138
 
139
 
139
 	@Override
140
 	@Override
140
 	public Boolean visitRange(Matching context, RangeTypeID range) {
141
 	public Boolean visitRange(Matching context, RangeTypeID range) {
141
-		if (context.type instanceof RangeTypeID) {
142
-			RangeTypeID rangeType = (RangeTypeID) context.type;
142
+		if (context.type.type instanceof RangeTypeID) {
143
+			RangeTypeID rangeType = (RangeTypeID) context.type.type;
143
 			return match(context, rangeType.baseType, range.baseType);
144
 			return match(context, rangeType.baseType, range.baseType);
144
 		} else {
145
 		} else {
145
 			return false;
146
 			return false;
148
 
149
 
149
 	@Override
150
 	@Override
150
 	public Boolean visitModified(Matching context, ModifiedTypeID type) {
151
 	public Boolean visitModified(Matching context, ModifiedTypeID type) {
151
-		if (context.type instanceof ModifiedTypeID) {
152
-			ModifiedTypeID modified = (ModifiedTypeID) context.type;
153
-			return match(context, modified.baseType, type.baseType);
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));
154
 		} else {
155
 		} else {
155
 			return false;
156
 			return false;
156
 		}
157
 		}
157
 	}
158
 	}
158
 
159
 
159
-	private boolean match(Matching context, TypeID type, TypeID pattern) {
160
-		return pattern.accept(context.withType(type), this);
161
-	}
162
-
163
-	private boolean match(Matching context, StoredType type, StoredType pattern) {
164
-		if (type.storage != pattern.storage)
160
+	private boolean match(Matching context, TypeArgument type, TypeArgument pattern) {
161
+		if (pattern.storage != null && !pattern.storage.equals(type.storage))
165
 			return false;
162
 			return false;
166
 		
163
 		
167
-		return pattern.type.accept(context.withType(type.type), this);
164
+		return pattern.type.accept(context.withType(type), this);
165
+	}
166
+	
167
+	private boolean match(Matching context, StoredType type, StoredType pattern) {
168
+		return match(context, type.asArgument(), pattern.asArgument());
168
 	}
169
 	}
169
 
170
 
170
 	@Override
171
 	@Override
171
 	public Boolean visitGenericMap(Matching context, GenericMapTypeID map) {
172
 	public Boolean visitGenericMap(Matching context, GenericMapTypeID map) {
172
-		return map == context.type; // TODO: improve this
173
+		return map == context.type.type; // TODO: improve this
173
 	}
174
 	}
174
 		
175
 		
175
 	public static final class Matching {
176
 	public static final class Matching {
176
 		public final LocalMemberCache cache;
177
 		public final LocalMemberCache cache;
177
-		public final TypeID type;
178
-		public final Map<TypeParameter, TypeID> mapping;
178
+		public final TypeArgument type;
179
+		public final Map<TypeParameter, TypeArgument> mapping;
179
 		
180
 		
180
-		public Matching(LocalMemberCache cache, TypeID type) {
181
+		public Matching(LocalMemberCache cache, TypeArgument type) {
181
 			this.cache = cache;
182
 			this.cache = cache;
182
 			this.type = type;
183
 			this.type = type;
183
 			mapping = new HashMap<>();
184
 			mapping = new HashMap<>();
184
 		}
185
 		}
185
 		
186
 		
186
-		private Matching(LocalMemberCache cache, TypeID type, Map<TypeParameter, TypeID> mapping) {
187
+		private Matching(LocalMemberCache cache, TypeArgument type, Map<TypeParameter, TypeArgument> mapping) {
187
 			this.cache = cache;
188
 			this.cache = cache;
188
 			this.type = type;
189
 			this.type = type;
189
 			this.mapping = mapping;
190
 			this.mapping = mapping;
190
 		}
191
 		}
191
 		
192
 		
192
-		public Matching withType(TypeID type) {
193
+		public Matching withType(TypeArgument type) {
193
 			return new Matching(cache, type, mapping);
194
 			return new Matching(cache, type, mapping);
194
 		}
195
 		}
195
 	}
196
 	}

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

13
  *
13
  *
14
  * @author Hoofdgebruiker
14
  * @author Hoofdgebruiker
15
  */
15
  */
16
-public class TypeParameterCollector implements TypeVisitorWithContext<Map<TypeParameter, TypeID>, Void, RuntimeException> {
17
-	private final Map<TypeParameter, TypeID> map;
16
+public class TypeParameterCollector implements TypeVisitorWithContext<Map<TypeParameter, GenericTypeID>, Void, RuntimeException> {
17
+	private final Map<TypeParameter, GenericTypeID> map;
18
 	
18
 	
19
-	public TypeParameterCollector(Map<TypeParameter, TypeID> map) {
19
+	public TypeParameterCollector(Map<TypeParameter, GenericTypeID> map) {
20
 		this.map = map;
20
 		this.map = map;
21
 	}
21
 	}
22
 
22
 
23
 	@Override
23
 	@Override
24
-	public Void visitBasic(Map<TypeParameter, TypeID> context, BasicTypeID basic) {
24
+	public Void visitBasic(Map<TypeParameter, GenericTypeID> context, BasicTypeID basic) {
25
 		return null;
25
 		return null;
26
 	}
26
 	}
27
 	
27
 	
28
 	@Override
28
 	@Override
29
-	public Void visitString(Map<TypeParameter, TypeID> context, StringTypeID string) {
29
+	public Void visitString(Map<TypeParameter, GenericTypeID> context, StringTypeID string) {
30
 		return null;
30
 		return null;
31
 	}
31
 	}
32
 
32
 
33
 	@Override
33
 	@Override
34
-	public Void visitArray(Map<TypeParameter, TypeID> context, ArrayTypeID array) {
34
+	public Void visitArray(Map<TypeParameter, GenericTypeID> context, ArrayTypeID array) {
35
 		array.elementType.type.accept(context, this);
35
 		array.elementType.type.accept(context, this);
36
 		return null;
36
 		return null;
37
 	}
37
 	}
38
 
38
 
39
 	@Override
39
 	@Override
40
-	public Void visitAssoc(Map<TypeParameter, TypeID> context, AssocTypeID assoc) {
40
+	public Void visitAssoc(Map<TypeParameter, GenericTypeID> context, AssocTypeID assoc) {
41
 		assoc.keyType.type.accept(context, this);
41
 		assoc.keyType.type.accept(context, this);
42
 		assoc.valueType.type.accept(context, this);
42
 		assoc.valueType.type.accept(context, this);
43
 		return null;
43
 		return null;
44
 	}
44
 	}
45
 
45
 
46
 	@Override
46
 	@Override
47
-	public Void visitGenericMap(Map<TypeParameter, TypeID> context, GenericMapTypeID map) {
47
+	public Void visitGenericMap(Map<TypeParameter, GenericTypeID> context, GenericMapTypeID map) {
48
 		return null;
48
 		return null;
49
 	}
49
 	}
50
 
50
 
51
 	@Override
51
 	@Override
52
-	public Void visitIterator(Map<TypeParameter, TypeID> context, IteratorTypeID iterator) {
52
+	public Void visitIterator(Map<TypeParameter, GenericTypeID> context, IteratorTypeID iterator) {
53
 		for (StoredType type : iterator.iteratorTypes)
53
 		for (StoredType type : iterator.iteratorTypes)
54
 			type.type.accept(context, this);
54
 			type.type.accept(context, this);
55
 		return null;
55
 		return null;
56
 	}
56
 	}
57
 
57
 
58
 	@Override
58
 	@Override
59
-	public Void visitFunction(Map<TypeParameter, TypeID> context, FunctionTypeID function) {
59
+	public Void visitFunction(Map<TypeParameter, GenericTypeID> context, FunctionTypeID function) {
60
 		function.header.getReturnType().type.accept(context, this);
60
 		function.header.getReturnType().type.accept(context, this);
61
 		for (FunctionParameter parameter : function.header.parameters)
61
 		for (FunctionParameter parameter : function.header.parameters)
62
 			parameter.type.type.accept(context, this);
62
 			parameter.type.type.accept(context, this);
64
 	}
64
 	}
65
 
65
 
66
 	@Override
66
 	@Override
67
-	public Void visitDefinition(Map<TypeParameter, TypeID> context, DefinitionTypeID definition) {
68
-		for (TypeID argument : definition.typeArguments)
69
-			argument.accept(context, this);
67
+	public Void visitDefinition(Map<TypeParameter, GenericTypeID> context, DefinitionTypeID definition) {
68
+		for (TypeArgument argument : definition.typeArguments)
69
+			argument.type.accept(context, this);
70
 		if (definition.outer != null)
70
 		if (definition.outer != null)
71
 			visitDefinition(context, definition.outer);
71
 			visitDefinition(context, definition.outer);
72
 		return null;
72
 		return null;
73
 	}
73
 	}
74
 
74
 
75
 	@Override
75
 	@Override
76
-	public Void visitGeneric(Map<TypeParameter, TypeID> context, GenericTypeID generic) {
76
+	public Void visitGeneric(Map<TypeParameter, GenericTypeID> context, GenericTypeID generic) {
77
 		map.put(generic.parameter, generic);
77
 		map.put(generic.parameter, generic);
78
 		return null;
78
 		return null;
79
 	}
79
 	}
80
 
80
 
81
 	@Override
81
 	@Override
82
-	public Void visitRange(Map<TypeParameter, TypeID> context, RangeTypeID range) {
82
+	public Void visitRange(Map<TypeParameter, GenericTypeID> context, RangeTypeID range) {
83
 		range.baseType.type.accept(context, this);
83
 		range.baseType.type.accept(context, this);
84
 		return null;
84
 		return null;
85
 	}
85
 	}
86
 
86
 
87
 	@Override
87
 	@Override
88
-	public Void visitModified(Map<TypeParameter, TypeID> context, ModifiedTypeID type) {
88
+	public Void visitModified(Map<TypeParameter, GenericTypeID> context, ModifiedTypeID type) {
89
 		type.baseType.accept(context, this);
89
 		type.baseType.accept(context, this);
90
 		return null;
90
 		return null;
91
 	}
91
 	}

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

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

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

70
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
70
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
71
 import org.openzen.zenscript.codemodel.type.StoredType;
71
 import org.openzen.zenscript.codemodel.type.StoredType;
72
 import org.openzen.zenscript.codemodel.type.StringTypeID;
72
 import org.openzen.zenscript.codemodel.type.StringTypeID;
73
+import org.openzen.zenscript.codemodel.type.TypeArgument;
73
 import org.openzen.zenscript.codemodel.type.TypeVisitorWithContext;
74
 import org.openzen.zenscript.codemodel.type.TypeVisitorWithContext;
74
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
75
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
75
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
76
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
101
 			if (expansion.target == null)
102
 			if (expansion.target == null)
102
 				throw new RuntimeException(expansion.position.toString() + ": Missing expansion target");
103
 				throw new RuntimeException(expansion.position.toString() + ": Missing expansion target");
103
 			
104
 			
104
-			Map<TypeParameter, TypeID> mapping = matchType(type.type, expansion.target);
105
+			Map<TypeParameter, TypeArgument> mapping = matchType(type, expansion.target);
105
 			if (mapping == null)
106
 			if (mapping == null)
106
 				continue;
107
 				continue;
107
 			
108
 			
121
 		}
122
 		}
122
 	}
123
 	}
123
 	
124
 	
124
-	private Map<TypeParameter, TypeID> matchType(TypeID type, TypeID pattern) {
125
+	private Map<TypeParameter, TypeArgument> matchType(StoredType type, TypeArgument pattern) {
125
 		return type.inferTypeParameters(cache, pattern);
126
 		return type.inferTypeParameters(cache, pattern);
126
 	}
127
 	}
127
 
128
 
387
 	@Override
388
 	@Override
388
 	public Void visitGenericMap(Void context, GenericMapTypeID map) {
389
 	public Void visitGenericMap(Void context, GenericMapTypeID map) {
389
 		TypeParameter functionParameter = new TypeParameter(BUILTIN, "T");
390
 		TypeParameter functionParameter = new TypeParameter(BUILTIN, "T");
390
-		Map<TypeParameter, TypeID> parameterFilled = Collections.singletonMap(map.key, registry.getGeneric(functionParameter));
391
+		Map<TypeParameter, TypeArgument> parameterFilled = Collections.singletonMap(map.key, new TypeArgument(registry.getGeneric(functionParameter), null));
391
 		StoredType valueType = map.value.instance(new GenericMapper(registry, parameterFilled));
392
 		StoredType valueType = map.value.instance(new GenericMapper(registry, parameterFilled));
392
 		
393
 		
393
 		FunctionHeader getOptionalHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, registry.getOptional(valueType.type).stored(valueType.storage), null, null, new FunctionParameter[0]);
394
 		FunctionHeader getOptionalHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, registry.getOptional(valueType.type).stored(valueType.storage), null, null, new FunctionParameter[0]);
442
 		HighLevelDefinition definition = definitionType.definition;
443
 		HighLevelDefinition definition = definitionType.definition;
443
 		GenericMapper mapper = null;
444
 		GenericMapper mapper = null;
444
 		if (definitionType.hasTypeParameters() || (definitionType.outer != null && definitionType.outer.hasTypeParameters())) {
445
 		if (definitionType.hasTypeParameters() || (definitionType.outer != null && definitionType.outer.hasTypeParameters())) {
445
-			Map<TypeParameter, TypeID> mapping = definitionType.getTypeParameterMapping();
446
+			Map<TypeParameter, TypeArgument> mapping = definitionType.getTypeParameterMapping();
446
 			mapper = new GenericMapper(registry, mapping);
447
 			mapper = new GenericMapper(registry, mapping);
447
 		}
448
 		}
448
 		
449
 		
518
 		if (definition instanceof InterfaceDefinition) {
519
 		if (definition instanceof InterfaceDefinition) {
519
 			InterfaceDefinition interfaceDefinition = (InterfaceDefinition)definition;
520
 			InterfaceDefinition interfaceDefinition = (InterfaceDefinition)definition;
520
 			for (TypeID baseType : interfaceDefinition.baseInterfaces)
521
 			for (TypeID baseType : interfaceDefinition.baseInterfaces)
521
-				cache.get(baseType.instanceUnstored(mapper).stored(type.storage))
522
+				cache.get(baseType.instance(mapper, type.storage).stored())
522
 						.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
523
 						.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
523
 		}
524
 		}
524
 		
525
 		

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

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

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

85
 	}
85
 	}
86
 	
86
 	
87
 	public boolean extendsOrImplements(TypeID other) {
87
 	public boolean extendsOrImplements(TypeID other) {
88
-		other = other.getNormalizedUnstored();
88
+		other = other.getNormalized();
89
 		TypeID superType = type.type.getSuperType(cache.getRegistry());
89
 		TypeID superType = type.type.getSuperType(cache.getRegistry());
90
 		if (superType != null) {
90
 		if (superType != null) {
91
 			if (superType == other)
91
 			if (superType == other)
105
 	}
105
 	}
106
 	
106
 	
107
 	public boolean extendsType(TypeID other) {
107
 	public boolean extendsType(TypeID other) {
108
-		other = other.getNormalizedUnstored();
108
+		other = other.getNormalized();
109
 		TypeID superType = type.type.getSuperType(cache.getRegistry());
109
 		TypeID superType = type.type.getSuperType(cache.getRegistry());
110
 		if (superType != null) {
110
 		if (superType != null) {
111
 			if (superType == other)
111
 			if (superType == other)
408
 		
408
 		
409
 		if (toType.isOptional() && canCastImplicit(toType.withoutOptional()))
409
 		if (toType.isOptional() && canCastImplicit(toType.withoutOptional()))
410
 			return true;
410
 			return true;
411
-		if (toType.isConst() && canCastImplicit(toType.withoutConst()))
412
-			return true;
413
 		if (type.isOptional() && areEquivalent(type.withoutOptional(), toType))
411
 		if (type.isOptional() && areEquivalent(type.withoutOptional(), toType))
414
 			return true;
412
 			return true;
415
 		
413
 		
482
 			return new NullExpression(position, toType);
480
 			return new NullExpression(position, toType);
483
 		if (toType.isOptional() && canCastImplicit(toType.withoutOptional()))
481
 		if (toType.isOptional() && canCastImplicit(toType.withoutOptional()))
484
 			return castEquivalent(position, new WrapOptionalExpression(position, castImplicit(position, value, toType.withoutOptional(), implicit), toType), toType);
482
 			return castEquivalent(position, new WrapOptionalExpression(position, castImplicit(position, value, toType.withoutOptional(), implicit), toType), toType);
485
-		if (toType.isConst() && canCastImplicit(toType.withoutConst()))
486
-			return castEquivalent(position, new MakeConstExpression(position, castImplicit(position, value, toType.withoutConst(), implicit), toType), toType);
487
 		if (type.isOptional() && areEquivalent(type.withoutOptional(), toType))
483
 		if (type.isOptional() && areEquivalent(type.withoutOptional(), toType))
488
 			return castEquivalent(position, new CheckNullExpression(position, value), toType);
484
 			return castEquivalent(position, new CheckNullExpression(position, value), toType);
489
 		
485
 		

CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageTag.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AutoStorageTag.java View File

9
  *
9
  *
10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
-public class AnyStorageTag implements StorageTag {
13
-	public static final AnyStorageTag INSTANCE = new AnyStorageTag();
12
+public class AutoStorageTag implements StorageTag {
13
+	public static final AutoStorageTag INSTANCE = new AutoStorageTag();
14
 	
14
 	
15
-	private AnyStorageTag() {}
15
+	private AutoStorageTag() {}
16
 
16
 
17
 	@Override
17
 	@Override
18
 	public StorageType getType() {
18
 	public StorageType getType() {
19
-		return AnyStorageType.INSTANCE;
19
+		return AutoStorageType.INSTANCE;
20
 	}
20
 	}
21
 	
21
 	
22
 	@Override
22
 	@Override
23
 	public String toString() {
23
 	public String toString() {
24
-		return "any";
24
+		return "auto";
25
 	}
25
 	}
26
 
26
 
27
 	@Override
27
 	@Override
28
 	public boolean canCastTo(StorageTag other) {
28
 	public boolean canCastTo(StorageTag other) {
29
-		return other == BorrowStorageTag.INVOCATION;
29
+		return other == BorrowStorageTag.INVOCATION || other == BorrowStorageTag.THIS;
30
 	}
30
 	}
31
 
31
 
32
 	@Override
32
 	@Override
33
 	public boolean canCastFrom(StorageTag other) {
33
 	public boolean canCastFrom(StorageTag other) {
34
-		return true;
34
+		return other == this || other == UniqueStorageTag.INSTANCE || other == StaticStorageTag.INSTANCE;
35
 	}
35
 	}
36
 
36
 
37
 	@Override
37
 	@Override
38
 	public boolean isDestructible() {
38
 	public boolean isDestructible() {
39
 		return true;
39
 		return true;
40
 	}
40
 	}
41
+	
42
+	@Override
43
+	public boolean isConst() {
44
+		return false;
45
+	}
46
+	
47
+	@Override
48
+	public boolean isImmutable() {
49
+		return false;
50
+	}
41
 }
51
 }

CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageType.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AutoStorageType.java View File

13
  *
13
  *
14
  * @author Hoofdgebruiker
14
  * @author Hoofdgebruiker
15
  */
15
  */
16
-public class AnyStorageType implements StorageType {
17
-	public static final AnyStorageType INSTANCE = new AnyStorageType();
16
+public class AutoStorageType implements StorageType {
17
+	public static final AutoStorageType INSTANCE = new AutoStorageType();
18
 	
18
 	
19
-	private AnyStorageType() {}
19
+	private AutoStorageType() {}
20
 
20
 
21
 	@Override
21
 	@Override
22
 	public String getName() {
22
 	public String getName() {
28
 		if (arguments.length > 0)
28
 		if (arguments.length > 0)
29
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "any storage type doesn't take arguments");
29
 			return new InvalidStorageTag(position, CompileExceptionCode.INVALID_STORAGE_TYPE_ARGUMENTS, "any storage type doesn't take arguments");
30
 		
30
 		
31
-		return AnyStorageTag.INSTANCE;
31
+		return AutoStorageTag.INSTANCE;
32
 	}
32
 	}
33
 }
33
 }

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

39
 	public boolean isDestructible() {
39
 	public boolean isDestructible() {
40
 		return false;
40
 		return false;
41
 	}
41
 	}
42
+	
43
+	@Override
44
+	public boolean isConst() {
45
+		return true;
46
+	}
47
+	
48
+	@Override
49
+	public boolean isImmutable() {
50
+		return true;
51
+	}
42
 }
52
 }

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

47
 	public String toString() {
47
 	public String toString() {
48
 		return "invalid";
48
 		return "invalid";
49
 	}
49
 	}
50
+	
51
+	@Override
52
+	public boolean isConst() {
53
+		return false;
54
+	}
55
+	
56
+	@Override
57
+	public boolean isImmutable() {
58
+		return false;
59
+	}
50
 }
60
 }

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

38
 	public boolean isDestructible() {
38
 	public boolean isDestructible() {
39
 		return false;
39
 		return false;
40
 	}
40
 	}
41
+	
42
+	@Override
43
+	public boolean isConst() {
44
+		return false;
45
+	}
46
+	
47
+	@Override
48
+	public boolean isImmutable() {
49
+		return false;
50
+	}
41
 }
51
 }

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

33
 	public boolean isDestructible() {
33
 	public boolean isDestructible() {
34
 		return false;
34
 		return false;
35
 	}
35
 	}
36
+	
37
+	@Override
38
+	public boolean isConst() {
39
+		return false;
40
+	}
41
+	
42
+	@Override
43
+	public boolean isImmutable() {
44
+		return false;
45
+	}
36
 }
46
 }

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

38
 	public boolean isDestructible() {
38
 	public boolean isDestructible() {
39
 		return false;
39
 		return false;
40
 	}
40
 	}
41
+	
42
+	@Override
43
+	public boolean isConst() {
44
+		return false;
45
+	}
46
+	
47
+	@Override
48
+	public boolean isImmutable() {
49
+		return false;
50
+	}
41
 }
51
 }

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

17
 	boolean canCastFrom(StorageTag other);
17
 	boolean canCastFrom(StorageTag other);
18
 	
18
 	
19
 	boolean isDestructible();
19
 	boolean isDestructible();
20
+	
21
+	boolean isConst();
22
+	
23
+	boolean isImmutable();
24
+	
25
+	static StorageTag union(StorageTag minor, StorageTag major) {
26
+		if (minor == AutoStorageTag.INSTANCE || minor == null)
27
+			return major;
28
+		if (major == AutoStorageTag.INSTANCE || major == null)
29
+			return minor;
30
+		if (!minor.equals(major))
31
+			throw new IllegalArgumentException("Could not unite storage types"); // TODO: proper reporting
32
+		
33
+		return major;
34
+	}
20
 }
35
 }

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

14
 public interface StorageType {
14
 public interface StorageType {
15
 	public static StorageType[] getStandard() {
15
 	public static StorageType[] getStandard() {
16
 		return new StorageType[] {
16
 		return new StorageType[] {
17
-			AnyStorageType.INSTANCE,
17
+			AutoStorageType.INSTANCE,
18
 			BorrowStorageType.INSTANCE,
18
 			BorrowStorageType.INSTANCE,
19
 			SharedStorageType.INSTANCE,
19
 			SharedStorageType.INSTANCE,
20
 			StaticStorageType.INSTANCE,
20
 			StaticStorageType.INSTANCE,

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

38
 	public boolean isDestructible() {
38
 	public boolean isDestructible() {
39
 		return true;
39
 		return true;
40
 	}
40
 	}
41
+	
42
+	@Override
43
+	public boolean isConst() {
44
+		return false;
45
+	}
46
+	
47
+	@Override
48
+	public boolean isImmutable() {
49
+		return false;
50
+	}
41
 }
51
 }

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

21
 
21
 
22
 	@Override
22
 	@Override
23
 	public boolean canCastTo(StorageTag other) {
23
 	public boolean canCastTo(StorageTag other) {
24
-		return other == this;
24
+		return true;
25
 	}
25
 	}
26
 
26
 
27
 	@Override
27
 	@Override
28
 	public boolean canCastFrom(StorageTag other) {
28
 	public boolean canCastFrom(StorageTag other) {
29
-		return other == this;
29
+		return true;
30
 	}
30
 	}
31
 
31
 
32
 	@Override
32
 	@Override
33
 	public boolean isDestructible() {
33
 	public boolean isDestructible() {
34
 		return false;
34
 		return false;
35
 	}
35
 	}
36
+	
37
+	@Override
38
+	public boolean isConst() {
39
+		return false;
40
+	}
41
+	
42
+	@Override
43
+	public boolean isImmutable() {
44
+		return false;
45
+	}
36
 }
46
 }

+ 49
- 0
CompilerShared/src/main/java/org/openzen/zenscript/compiler/BuiltinCompilePlugin.java View File

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.compiler;
7
+
8
+import java.util.Arrays;
9
+import java.util.Collections;
10
+import java.util.List;
11
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
12
+import org.openzen.zenscript.codemodel.annotations.NativeAnnotationDefinition;
13
+import org.openzen.zenscript.codemodel.annotations.PreconditionAnnotationDefinition;
14
+import org.openzen.zenscript.codemodel.type.storage.StorageType;
15
+
16
+/**
17
+ *
18
+ * @author Hoofdgebruiker
19
+ */
20
+public class BuiltinCompilePlugin implements CompilePlugin {
21
+	public static final BuiltinCompilePlugin BUILTIN = new BuiltinCompilePlugin();
22
+	
23
+	private final List<AnnotationDefinition> annotations;
24
+	private final List<StorageType> storageTypes;
25
+	
26
+	private BuiltinCompilePlugin() {
27
+		annotations = Arrays.asList(
28
+				NativeAnnotationDefinition.INSTANCE,
29
+				PreconditionAnnotationDefinition.INSTANCE
30
+		);
31
+		
32
+		storageTypes = Arrays.asList(StorageType.getStandard());
33
+	}
34
+
35
+	@Override
36
+	public List<ZenCodeCompiler> getCompilers() {
37
+		return Collections.emptyList();
38
+	}
39
+
40
+	@Override
41
+	public List<AnnotationDefinition> getAnnotations() {
42
+		return annotations;
43
+	}
44
+
45
+	@Override
46
+	public List<StorageType> getStorageTypes() {
47
+		return storageTypes;
48
+	}
49
+}

+ 22
- 0
CompilerShared/src/main/java/org/openzen/zenscript/compiler/CompilePlugin.java View File

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.compiler;
7
+
8
+import java.util.List;
9
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
10
+import org.openzen.zenscript.codemodel.type.storage.StorageType;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public interface CompilePlugin {
17
+	List<ZenCodeCompiler> getCompilers();
18
+	
19
+	List<AnnotationDefinition> getAnnotations();
20
+	
21
+	List<StorageType> getStorageTypes();
22
+}

+ 0
- 1
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java View File

884
 					return KEYWORD;
884
 					return KEYWORD;
885
 					
885
 					
886
 				case K_VOID:
886
 				case K_VOID:
887
-				case K_ANY:
888
 				case K_BOOL:
887
 				case K_BOOL:
889
 				case K_BYTE:
888
 				case K_BYTE:
890
 				case K_SBYTE:
889
 				case K_SBYTE:

+ 3
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeContext.java View File

11
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
11
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
 import org.openzen.zenscript.codemodel.type.StoredType;
12
 import org.openzen.zenscript.codemodel.type.StoredType;
13
 import org.openzen.zenscript.codemodel.type.TypeID;
13
 import org.openzen.zenscript.codemodel.type.TypeID;
14
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
14
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
15
 import org.openzen.zenscript.javabytecode.compiler.JavaWriter;
16
 import org.openzen.zenscript.javabytecode.compiler.JavaWriter;
16
 import org.openzen.zenscript.javashared.JavaContext;
17
 import org.openzen.zenscript.javashared.JavaContext;
20
 import org.openzen.zenscript.javashared.JavaSyntheticClassGenerator;
21
 import org.openzen.zenscript.javashared.JavaSyntheticClassGenerator;
21
 import org.openzen.zenscript.javashared.JavaTypeDescriptorVisitor;
22
 import org.openzen.zenscript.javashared.JavaTypeDescriptorVisitor;
22
 import org.openzen.zenscript.javashared.JavaTypeInternalNameVisitor;
23
 import org.openzen.zenscript.javashared.JavaTypeInternalNameVisitor;
24
+import org.openzen.zenscript.javashared.JavaTypeUtils;
23
 
25
 
24
 /**
26
 /**
25
  *
27
  *
49
 	
51
 	
50
 	@Override
52
 	@Override
51
 	public String getDescriptor(StoredType type) {
53
 	public String getDescriptor(StoredType type) {
52
-		if (type.storage == SharedStorageTag.INSTANCE && type.isDestructible())
54
+		if (JavaTypeUtils.isShared(type))
53
 			return "Lzsynthetic/Shared";
55
 			return "Lzsynthetic/Shared";
54
 		
56
 		
55
 		return type.type.accept(descriptorVisitor);
57
 		return type.type.accept(descriptorVisitor);

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

23
 import java.io.IOException;
23
 import java.io.IOException;
24
 import java.lang.reflect.Modifier;
24
 import java.lang.reflect.Modifier;
25
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
25
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
26
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
27
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
26
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
28
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
27
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
29
 import org.openzen.zenscript.javashared.JavaClass;
28
 import org.openzen.zenscript.javashared.JavaClass;
30
 import org.openzen.zenscript.javashared.JavaField;
29
 import org.openzen.zenscript.javashared.JavaField;
31
 import org.openzen.zenscript.javashared.JavaMethod;
30
 import org.openzen.zenscript.javashared.JavaMethod;
31
+import org.openzen.zenscript.javashared.JavaTypeUtils;
32
 import org.openzen.zenscript.javashared.JavaVariantOption;
32
 import org.openzen.zenscript.javashared.JavaVariantOption;
33
 
33
 
34
 public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
34
 public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
2383
 		if (expression.type.isDestructible()) { // only destructible types matter here; nondestructible types never need conversion
2383
 		if (expression.type.isDestructible()) { // only destructible types matter here; nondestructible types never need conversion
2384
 			StorageTag fromTag = expression.value.type.storage;
2384
 			StorageTag fromTag = expression.value.type.storage;
2385
 			StorageTag toTag = expression.type.storage;
2385
 			StorageTag toTag = expression.type.storage;
2386
-			if (fromTag == SharedStorageTag.INSTANCE && toTag == BorrowStorageTag.INVOCATION) {
2386
+			if (JavaTypeUtils.isShared(fromTag) && toTag == BorrowStorageTag.INVOCATION) {
2387
 				// Shared<T>.get()
2387
 				// Shared<T>.get()
2388
 				javaWriter.invokeVirtual(SHARED_GET);
2388
 				javaWriter.invokeVirtual(SHARED_GET);
2389
-			} else if (fromTag == UniqueStorageTag.INSTANCE && toTag == SharedStorageTag.INSTANCE) {
2389
+			} else if (fromTag == UniqueStorageTag.INSTANCE && JavaTypeUtils.isShared(toTag)) {
2390
 				// new Shared<T>(value)
2390
 				// new Shared<T>(value)
2391
 				javaWriter.newObject("zsynthetic/Shared");
2391
 				javaWriter.newObject("zsynthetic/Shared");
2392
 				javaWriter.dup();
2392
 				javaWriter.dup();

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

119
 		if (definition.typeArguments.length > 0) {
119
 		if (definition.typeArguments.length > 0) {
120
 			result.append("With");
120
 			result.append("With");
121
 			for (int i = 0; i < definition.typeArguments.length; i++) {
121
 			for (int i = 0; i < definition.typeArguments.length; i++) {
122
-				result.append(definition.typeArguments[i].accept(null, this));
122
+				result.append(definition.typeArguments[i].type.accept(null, this));
123
 			}
123
 			}
124
 		}
124
 		}
125
 		return result.toString();
125
 		return result.toString();

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

3
 import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
3
 import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
4
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
4
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
5
 import org.openzen.zenscript.codemodel.type.*;
5
 import org.openzen.zenscript.codemodel.type.*;
6
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
7
 
6
 
8
 public class JavaTypeDescriptorVisitor implements TypeVisitor<String> {
7
 public class JavaTypeDescriptorVisitor implements TypeVisitor<String> {
9
 	private final JavaTypeDescriptorVisitor forOptional;
8
 	private final JavaTypeDescriptorVisitor forOptional;
21
 	}
20
 	}
22
 	
21
 	
23
 	public String process(StoredType type) {
22
 	public String process(StoredType type) {
24
-		if (type.isDestructible() && type.storage == SharedStorageTag.INSTANCE)
23
+		if (JavaTypeUtils.isShared(type))
25
 			return "L" + JavaClass.SHARED.internalName + ";";
24
 			return "L" + JavaClass.SHARED.internalName + ";";
26
 		
25
 		
27
 		return type.type.accept(this);
26
 		return type.type.accept(this);

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

122
 
122
 
123
 		if (definition.typeArguments.length > 0) {
123
 		if (definition.typeArguments.length > 0) {
124
 			builder.append("<");
124
 			builder.append("<");
125
-			for (TypeID typeParameter : definition.typeArguments) {
126
-				builder.append(typeParameter.accept(null, this));
125
+			for (TypeArgument typeParameter : definition.typeArguments) {
126
+				builder.append(typeParameter.type.accept(null, this));
127
 			}
127
 			}
128
 			builder.append(">");
128
 			builder.append(">");
129
 		}
129
 		}

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

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.javashared;
7
+
8
+import org.openzen.zenscript.codemodel.type.StoredType;
9
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
10
+import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
11
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
12
+
13
+/**
14
+ *
15
+ * @author Hoofdgebruiker
16
+ */
17
+public class JavaTypeUtils {
18
+	private JavaTypeUtils() {}
19
+	
20
+	public static boolean isShared(StoredType type) {
21
+		return type.type.isDestructible() && isShared(type.storage);
22
+	}
23
+	
24
+	public static boolean isShared(StorageTag storage) {
25
+		return storage == SharedStorageTag.INSTANCE || storage == AutoStorageTag.INSTANCE;
26
+	}
27
+}

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

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

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

29
 import org.openzen.zenscript.codemodel.statement.Statement;
29
 import org.openzen.zenscript.codemodel.statement.Statement;
30
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
30
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
31
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
31
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
32
+import org.openzen.zenscript.codemodel.type.TypeArgument;
32
 import org.openzen.zenscript.codemodel.type.TypeID;
33
 import org.openzen.zenscript.codemodel.type.TypeID;
33
 import org.openzen.zenscript.compiler.CompileScope;
34
 import org.openzen.zenscript.compiler.CompileScope;
34
 import org.openzen.zenscript.compiler.SemanticModule;
35
 import org.openzen.zenscript.compiler.SemanticModule;
252
 		output.append(" {\n");
253
 		output.append(" {\n");
253
 		output.append(indent).append(settings.indent).append("private ").append(cls.getName()).append("() {}\n");
254
 		output.append(indent).append(settings.indent).append("private ").append(cls.getName()).append("() {}\n");
254
 		
255
 		
255
-		JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, definition.target, definition.typeParameters, "\t", output, scope, definition);
256
+		JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, definition.target.type, definition.typeParameters, "\t", output, scope, definition);
256
 		for (IDefinitionMember member : definition.members)
257
 		for (IDefinitionMember member : definition.members)
257
 			member.accept(memberCompiler);
258
 			member.accept(memberCompiler);
258
 		memberCompiler.finish();
259
 		memberCompiler.finish();
341
 	private void compileExpansions() {
342
 	private void compileExpansions() {
342
 		for (ExpansionDefinition definition : expansions) {
343
 		for (ExpansionDefinition definition : expansions) {
343
 			JavaSourceFileScope scope = createScope(definition);
344
 			JavaSourceFileScope scope = createScope(definition);
344
-			JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, definition.target, definition.typeParameters, indent + settings.indent, output, scope, definition);
345
+			JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, definition.target.type, definition.typeParameters, indent + settings.indent, output, scope, definition);
345
 			for (IDefinitionMember member : definition.members)
346
 			for (IDefinitionMember member : definition.members)
346
 				member.accept(memberCompiler);
347
 				member.accept(memberCompiler);
347
 			memberCompiler.finish();
348
 			memberCompiler.finish();
369
 	
370
 	
370
 	private void compileMembers(JavaSourceFileScope scope, HighLevelDefinition definition) {
371
 	private void compileMembers(JavaSourceFileScope scope, HighLevelDefinition definition) {
371
 		if (definition.hasTag(JavaNativeClass.class)) {
372
 		if (definition.hasTag(JavaNativeClass.class)) {
372
-			TypeID[] typeParameters = new TypeID[definition.getNumberOfGenericParameters()];
373
+			TypeArgument[] typeParameters = new TypeArgument[definition.getNumberOfGenericParameters()];
373
 			for (int i = 0; i < typeParameters.length; i++)
374
 			for (int i = 0; i < typeParameters.length; i++)
374
-				typeParameters[i] = scope.semanticScope.getTypeRegistry().getGeneric(definition.typeParameters[i]);
375
+				typeParameters[i] = new TypeArgument(scope.semanticScope.getTypeRegistry().getGeneric(definition.typeParameters[i]), definition.typeParameters[i].storage);
375
 			TypeID targetType = scope.semanticScope.getTypeRegistry().getForDefinition(definition, typeParameters);
376
 			TypeID targetType = scope.semanticScope.getTypeRegistry().getForDefinition(definition, typeParameters);
376
 			
377
 			
377
 			JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, targetType, definition.typeParameters, indent + settings.indent, output, scope, definition);
378
 			JavaExpansionMemberCompiler memberCompiler = new JavaExpansionMemberCompiler(settings, targetType, definition.typeParameters, indent + settings.indent, output, scope, definition);

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

91
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
91
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
92
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
92
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
93
 import org.openzen.zenscript.codemodel.type.StoredType;
93
 import org.openzen.zenscript.codemodel.type.StoredType;
94
-import org.openzen.zenscript.codemodel.type.TypeID;
94
+import org.openzen.zenscript.codemodel.type.TypeArgument;
95
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
95
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
96
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
96
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
97
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
98
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
97
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
99
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
98
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
100
 import org.openzen.zenscript.formattershared.ExpressionString;
99
 import org.openzen.zenscript.formattershared.ExpressionString;
105
 import org.openzen.zenscript.javashared.JavaNativeTranslator;
104
 import org.openzen.zenscript.javashared.JavaNativeTranslator;
106
 import org.openzen.zenscript.javashared.JavaMethod;
105
 import org.openzen.zenscript.javashared.JavaMethod;
107
 import org.openzen.zenscript.javashared.JavaSynthesizedFunctionInstance;
106
 import org.openzen.zenscript.javashared.JavaSynthesizedFunctionInstance;
107
+import org.openzen.zenscript.javashared.JavaTypeUtils;
108
 import org.openzen.zenscript.javashared.JavaVariantOption;
108
 import org.openzen.zenscript.javashared.JavaVariantOption;
109
 
109
 
110
 /**
110
 /**
672
 		if (expression.value.type.isDestructible()) {
672
 		if (expression.value.type.isDestructible()) {
673
 			StorageTag fromTag = expression.value.type.storage;
673
 			StorageTag fromTag = expression.value.type.storage;
674
 			StorageTag toTag = expression.type.storage;
674
 			StorageTag toTag = expression.type.storage;
675
-			if (fromTag == SharedStorageTag.INSTANCE) {
675
+			if (JavaTypeUtils.isShared(fromTag)) {
676
 				// Shared<T>.get()
676
 				// Shared<T>.get()
677
 				return value.unaryPostfix(JavaOperator.CALL, ".get()");
677
 				return value.unaryPostfix(JavaOperator.CALL, ".get()");
678
-			} else if (fromTag == UniqueStorageTag.INSTANCE && toTag == SharedStorageTag.INSTANCE) {
678
+			} else if (fromTag == UniqueStorageTag.INSTANCE && JavaTypeUtils.isShared(toTag)) {
679
 				// new Shared<T>(value)
679
 				// new Shared<T>(value)
680
 				return new ExpressionString("new " + scope.type(JavaClass.SHARED) + "<>(" + value.value + ")", JavaOperator.NEW);
680
 				return new ExpressionString("new " + scope.type(JavaClass.SHARED) + "<>(" + value.value + ")", JavaOperator.NEW);
681
 			}
681
 			}
761
 		return expression.value.accept(this);
761
 		return expression.value.accept(this);
762
 	}
762
 	}
763
 	
763
 	
764
-	private String formatTypeArguments(TypeID[] types) {
764
+	private String formatTypeArguments(TypeArgument[] types) {
765
 		if (types == null || types.length == 0)
765
 		if (types == null || types.length == 0)
766
 			return "";
766
 			return "";
767
 		
767
 		
772
 			if (i > 0)
772
 			if (i > 0)
773
 				output.append(", ");
773
 				output.append(", ");
774
 			
774
 			
775
-			output.append(types[i].accept(scope.fileScope.objectTypeVisitor));
775
+			output.append(types[i].type.accept(scope.fileScope.objectTypeVisitor));
776
 		}
776
 		}
777
 		output.append(">");
777
 		output.append(">");
778
 		return output.toString();
778
 		return output.toString();
827
 		output.append(method).append("(");
827
 		output.append(method).append("(");
828
 		boolean first = true;
828
 		boolean first = true;
829
 		if (expression.arguments.typeArguments != null) {
829
 		if (expression.arguments.typeArguments != null) {
830
-			for (TypeID typeArgument : expression.arguments.typeArguments) {
830
+			for (TypeArgument typeArgument : expression.arguments.typeArguments) {
831
 				if (!first)
831
 				if (!first)
832
 					output.append(", ");
832
 					output.append(", ");
833
 				
833
 				
834
-				if (typeArgument instanceof GenericTypeID) {
835
-					output.append("typeOf").append(((GenericTypeID) typeArgument).parameter.name);
834
+				if (typeArgument.type instanceof GenericTypeID) {
835
+					output.append("typeOf").append(((GenericTypeID) typeArgument.type).parameter.name);
836
 				} else {
836
 				} else {
837
 					output.append(scope.type(typeArgument));
837
 					output.append(scope.type(typeArgument));
838
 					output.append(".class");
838
 					output.append(".class");

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

25
 import org.openzen.zenscript.javashared.JavaClass;
25
 import org.openzen.zenscript.javashared.JavaClass;
26
 import org.openzen.zenscript.javashared.JavaSynthesizedFunctionInstance;
26
 import org.openzen.zenscript.javashared.JavaSynthesizedFunctionInstance;
27
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
27
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
28
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
28
+import org.openzen.zenscript.javashared.JavaTypeUtils;
29
 
29
 
30
 /**
30
 /**
31
  *
31
  *
54
 	}
54
 	}
55
 	
55
 	
56
 	public String process(StoredType type) {
56
 	public String process(StoredType type) {
57
-		if (type.isDestructible() && type.storage == SharedStorageTag.INSTANCE)
57
+		if (JavaTypeUtils.isShared(type))
58
 			return importer.importType(JavaClass.SHARED) + "<" + type.type.accept(this) + ">";
58
 			return importer.importType(JavaClass.SHARED) + "<" + type.type.accept(this) + ">";
59
 		
59
 		
60
 		return type.type.accept(this);
60
 		return type.type.accept(this);
168
 			for (int i = 0; i < type.typeArguments.length; i++) {
168
 			for (int i = 0; i < type.typeArguments.length; i++) {
169
 				if (i > 0)
169
 				if (i > 0)
170
 					output.append(", ");
170
 					output.append(", ");
171
-				output.append(type.typeArguments[i].accept(objectTypeVisitor));
171
+				output.append(type.typeArguments[i].type.accept(objectTypeVisitor));
172
 			}
172
 			}
173
 			output.append(">");
173
 			output.append(">");
174
 		}
174
 		}

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

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

+ 1
- 1
ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/Main.java View File

13
 import org.openzen.zenscript.codemodel.annotations.NativeAnnotationDefinition;
13
 import org.openzen.zenscript.codemodel.annotations.NativeAnnotationDefinition;
14
 import org.openzen.zenscript.codemodel.annotations.PreconditionAnnotationDefinition;
14
 import org.openzen.zenscript.codemodel.annotations.PreconditionAnnotationDefinition;
15
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
15
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
16
-import org.openzen.zenscript.codemodel.type.storage.AnyStorageType;
16
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageType;
17
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageType;
17
 import org.openzen.zenscript.codemodel.type.storage.BorrowStorageType;
18
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageType;
18
 import org.openzen.zenscript.codemodel.type.storage.SharedStorageType;
19
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageType;
19
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageType;

+ 7
- 5
Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java View File

19
 	T_WHITESPACE_CARRIAGE_RETURN(true, "\r", "\r"),
19
 	T_WHITESPACE_CARRIAGE_RETURN(true, "\r", "\r"),
20
 	T_IDENTIFIER("@?[a-zA-Z_][a-zA-Z_0-9]*"),
20
 	T_IDENTIFIER("@?[a-zA-Z_][a-zA-Z_0-9]*"),
21
 	T_LOCAL_IDENTIFIER("$[a-zA-Z_][a-zA-Z_0-9]*"),
21
 	T_LOCAL_IDENTIFIER("$[a-zA-Z_][a-zA-Z_0-9]*"),
22
-	T_FLOAT("\\-?(0|[1-9][0-9]*)\\.[0-9]+([eE][\\+\\-]?[0-9]+)?[a-zA-Z_]"),
22
+	T_FLOAT("\\-?(0|[1-9][0-9]*)\\.[0-9]+([eE][\\+\\-]?[0-9]+)?[a-zA-Z_]*"),
23
 	T_INT("\\-?(0|[1-9][0-9_]*)[a-zA-Z_]*"),
23
 	T_INT("\\-?(0|[1-9][0-9_]*)[a-zA-Z_]*"),
24
-	T_PREFIXED_INT("\\-?(0b|0x|0o|0B|0X|0O)(0|[1-9a-fA-F][0-9a-fA-F_]*)(u|U|l|L|ul|UL)?"),
25
-	T_STRING_SQ("\"([^\"\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\""),
26
-	T_STRING_DQ("\'([^\'\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\'"),
24
+	T_PREFIXED_INT("\\-?(0b|0x|0o|0B|0X|0O)(0|[1-9a-fA-F][0-9a-fA-F_]*)[a-zA-Z_]*"),
25
+	T_STRING_DQ("\"([^\"\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\""),
26
+	T_STRING_DQ_WYSIWYG("@\"[^\"]\""),
27
+	T_STRING_SQ("\'([^\'\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\'"),
28
+	T_STRING_SQ_WYSIWYG("@\'[^\']\'"),
27
 	T_AOPEN("\\{", "{"),
29
 	T_AOPEN("\\{", "{"),
28
 	T_ACLOSE("\\}", "}"),
30
 	T_ACLOSE("\\}", "}"),
29
 	T_SQOPEN("\\[", "["),
31
 	T_SQOPEN("\\[", "["),
55
 	T_XORASSIGN("\\^=", "^="),
57
 	T_XORASSIGN("\\^=", "^="),
56
 	T_XOR("\\^", "^"),
58
 	T_XOR("\\^", "^"),
57
 	T_COALESCE("\\?\\?", "??"),
59
 	T_COALESCE("\\?\\?", "??"),
60
+	T_OPTCALL("\\?\\.", "?."),
58
 	T_QUEST("\\?", "?"),
61
 	T_QUEST("\\?", "?"),
59
 	T_COLON(":", ":"),
62
 	T_COLON(":", ":"),
60
 	T_BROPEN("\\(", "("),
63
 	T_BROPEN("\\(", "("),
112
 	K_SET(true, "set"),
115
 	K_SET(true, "set"),
113
 	
116
 	
114
 	K_VOID(true, "void"),
117
 	K_VOID(true, "void"),
115
-	K_ANY(true, "any"),
116
 	K_BOOL(true, "bool"),
118
 	K_BOOL(true, "bool"),
117
 	K_BYTE(true, "byte"),
119
 	K_BYTE(true, "byte"),
118
 	K_SBYTE(true, "sbyte"),
120
 	K_SBYTE(true, "sbyte"),

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

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

+ 3
- 3
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java View File

212
 	}
212
 	}
213
 	
213
 	
214
 	public boolean hasErrors() {
214
 	public boolean hasErrors() {
215
-		return false;
215
+		return errors.size() > 0;
216
 	}
216
 	}
217
 	
217
 	
218
-	public void printErrors() {
219
-		
218
+	public List<ParseException> getErrors() {
219
+		return errors;
220
 	}
220
 	}
221
 	
221
 	
222
 	public void listDefinitions(PackageDefinitions definitions) {
222
 	public void listDefinitions(PackageDefinitions definitions) {

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

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

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

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

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

15
 import org.openzen.zenscript.lexer.ZSTokenType;
15
 import org.openzen.zenscript.lexer.ZSTokenType;
16
 import org.openzen.zenscript.lexer.ParseException;
16
 import org.openzen.zenscript.lexer.ParseException;
17
 import org.openzen.zenscript.parser.type.IParsedType;
17
 import org.openzen.zenscript.parser.type.IParsedType;
18
+import org.openzen.zenscript.parser.type.ParsedStorageTag;
18
 
19
 
19
 /**
20
 /**
20
  *
21
  *
24
 	public static ParsedTypeParameter parse(ZSTokenParser tokens) throws ParseException {
25
 	public static ParsedTypeParameter parse(ZSTokenParser tokens) throws ParseException {
25
 		CodePosition position = tokens.getPosition();
26
 		CodePosition position = tokens.getPosition();
26
 		ZSToken name = tokens.required(ZSTokenType.T_IDENTIFIER, "identifier expected");
27
 		ZSToken name = tokens.required(ZSTokenType.T_IDENTIFIER, "identifier expected");
28
+		ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
27
 		List<ParsedGenericBound> bounds = new ArrayList<>();
29
 		List<ParsedGenericBound> bounds = new ArrayList<>();
28
 		while (tokens.optional(ZSTokenType.T_COLON) != null) {
30
 		while (tokens.optional(ZSTokenType.T_COLON) != null) {
29
 			if (tokens.optional(ZSTokenType.K_SUPER) != null) {
31
 			if (tokens.optional(ZSTokenType.K_SUPER) != null) {
32
 				bounds.add(new ParsedTypeBound(tokens.getPosition(), IParsedType.parse(tokens)));
34
 				bounds.add(new ParsedTypeBound(tokens.getPosition(), IParsedType.parse(tokens)));
33
 			}
35
 			}
34
 		}
36
 		}
35
-		return new ParsedTypeParameter(position, name.content, bounds);
37
+		return new ParsedTypeParameter(position, name.content, storage, bounds);
36
 	}
38
 	}
37
 	
39
 	
38
 	public static List<ParsedTypeParameter> parseAll(ZSTokenParser tokens) throws ParseException {
40
 	public static List<ParsedTypeParameter> parseAll(ZSTokenParser tokens) throws ParseException {
54
 		for (int i = 0; i < compiled.length; i++) {
56
 		for (int i = 0; i < compiled.length; i++) {
55
 			for (ParsedGenericBound bound : parameters.get(i).bounds)
57
 			for (ParsedGenericBound bound : parameters.get(i).bounds)
56
 				compiled[i].addBound(bound.compile(context));
58
 				compiled[i].addBound(bound.compile(context));
59
+			
60
+			compiled[i].storage = parameters.get(i).storage == null ? null : parameters.get(i).storage.resolve(parameters.get(i).position, context);
57
 		}
61
 		}
58
 	}
62
 	}
59
 	
63
 	
69
 	
73
 	
70
 	public final CodePosition position;
74
 	public final CodePosition position;
71
 	public final String name;
75
 	public final String name;
76
+	public final ParsedStorageTag storage;
72
 	public final List<ParsedGenericBound> bounds;
77
 	public final List<ParsedGenericBound> bounds;
73
 	
78
 	
74
 	public final TypeParameter compiled;
79
 	public final TypeParameter compiled;
75
 	
80
 	
76
-	public ParsedTypeParameter(CodePosition position, String name, List<ParsedGenericBound> bounds) {
81
+	public ParsedTypeParameter(CodePosition position, String name, ParsedStorageTag storage, List<ParsedGenericBound> bounds) {
77
 		this.position = position;
82
 		this.position = position;
78
 		this.name = name;
83
 		this.name = name;
84
+		this.storage = storage;
79
 		this.bounds = bounds;
85
 		this.bounds = bounds;
80
 		
86
 		
81
 		compiled = new TypeParameter(position, name);
87
 		compiled = new TypeParameter(position, name);

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

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

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

92
 
92
 
93
 		IPartialExpression cReceiver = receiver.compile(scope.withoutHints());
93
 		IPartialExpression cReceiver = receiver.compile(scope.withoutHints());
94
 		List<FunctionHeader> headers = cReceiver.getPossibleFunctionHeaders(scope, scope.hints, arguments.arguments.size());
94
 		List<FunctionHeader> headers = cReceiver.getPossibleFunctionHeaders(scope, scope.hints, arguments.arguments.size());
95
-		CallArguments callArguments = arguments.compileCall(position, scope, cReceiver.getGenericCallTypes(), headers);
95
+		CallArguments callArguments = arguments.compileCall(position, scope, cReceiver.getTypeArguments(), headers);
96
 		return cReceiver.call(position, scope, scope.hints, callArguments);
96
 		return cReceiver.call(position, scope, scope.hints, callArguments);
97
 	}
97
 	}
98
 	
98
 	

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

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

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

25
 import org.openzen.zenscript.codemodel.scope.StatementScope;
25
 import org.openzen.zenscript.codemodel.scope.StatementScope;
26
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
26
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeID;
29
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
28
+import org.openzen.zenscript.codemodel.type.TypeArgument;
29
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
30
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
30
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
31
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
31
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
32
 import org.openzen.zenscript.parser.statements.ParsedFunctionBody;
32
 import org.openzen.zenscript.parser.statements.ParsedFunctionBody;
50
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
50
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
51
 		FunctionHeader definedHeader = header.compile(scope);
51
 		FunctionHeader definedHeader = header.compile(scope);
52
 		FunctionHeader header = definedHeader;
52
 		FunctionHeader header = definedHeader;
53
-		StorageTag storage = SharedStorageTag.INSTANCE;
53
+		StorageTag storage = AutoStorageTag.INSTANCE;
54
 		for (StoredType hint : scope.hints) {
54
 		for (StoredType hint : scope.hints) {
55
 			if (hint.getNormalized().type instanceof FunctionTypeID) {
55
 			if (hint.getNormalized().type instanceof FunctionTypeID) {
56
 				FunctionTypeID functionHint = (FunctionTypeID) hint.getNormalized().type;
56
 				FunctionTypeID functionHint = (FunctionTypeID) hint.getNormalized().type;
85
 		if (!scope.genericInferenceMap.isEmpty()) {
85
 		if (!scope.genericInferenceMap.isEmpty()) {
86
 			// perform type parameter inference
86
 			// perform type parameter inference
87
 			StoredType returnType = statements.getReturnType();
87
 			StoredType returnType = statements.getReturnType();
88
-			Map<TypeParameter, TypeID> inferredTypes = returnType.type.inferTypeParameters(scope.getMemberCache(), genericHeader.getReturnType().type);
88
+			Map<TypeParameter, TypeArgument> inferredTypes = returnType.type.inferTypeParameters(scope.getMemberCache(), genericHeader.getReturnType().asArgument());
89
 			if (inferredTypes == null)
89
 			if (inferredTypes == null)
90
 				throw new CompileException(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer generic type parameters");
90
 				throw new CompileException(position, CompileExceptionCode.TYPE_ARGUMENTS_NOT_INFERRABLE, "Could not infer generic type parameters");
91
 			
91
 			

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

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

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

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

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

13
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
13
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14
 import org.openzen.zenscript.codemodel.type.GenericName;
14
 import org.openzen.zenscript.codemodel.type.GenericName;
15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16
-import org.openzen.zenscript.codemodel.type.TypeID;
16
+import org.openzen.zenscript.codemodel.type.TypeArgument;
17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18
 import org.openzen.zenscript.parser.type.IParsedType;
18
 import org.openzen.zenscript.parser.type.IParsedType;
19
 
19
 
37
 	@Override
37
 	@Override
38
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
38
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
39
 		IPartialExpression cValue = value.compile(scope.withoutHints());
39
 		IPartialExpression cValue = value.compile(scope.withoutHints());
40
-		TypeID[] typeParameters = IParsedType.compileList(genericParameters, scope);
40
+		TypeArgument[] typeArguments = IParsedType.compileArguments(genericParameters, scope);
41
 		IPartialExpression member = cValue.getMember(
41
 		IPartialExpression member = cValue.getMember(
42
 				position,
42
 				position,
43
 				scope,
43
 				scope,
44
 				scope.hints,
44
 				scope.hints,
45
-				new GenericName(this.member, typeParameters));
45
+				new GenericName(this.member, typeArguments));
46
 		if (member == null) {
46
 		if (member == null) {
47
 			TypeMembers members = scope.getTypeMembers(cValue.eval().type);
47
 			TypeMembers members = scope.getTypeMembers(cValue.eval().type);
48
 			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "Member not found: " + this.member);
48
 			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "Member not found: " + this.member);

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

25
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
25
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
26
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
26
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
27
 import org.openzen.zenscript.codemodel.type.StoredType;
28
-import org.openzen.zenscript.codemodel.type.TypeID;
28
+import org.openzen.zenscript.codemodel.type.TypeArgument;
29
 import org.openzen.zenscript.parser.ParsedAnnotation;
29
 import org.openzen.zenscript.parser.ParsedAnnotation;
30
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
30
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
31
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
31
 import org.openzen.zenscript.parser.definitions.ParsedFunctionParameter;
32
 import org.openzen.zenscript.parser.type.IParsedType;
32
 import org.openzen.zenscript.parser.type.IParsedType;
33
-import org.openzen.zenscript.parser.type.ParsedStorageTag;
34
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
33
 import org.openzen.zenscript.parser.type.ParsedTypeBasic;
35
 
34
 
36
 /**
35
 /**
39
  */
38
  */
40
 public class ParsedExpressionVariable extends ParsedExpression {
39
 public class ParsedExpressionVariable extends ParsedExpression {
41
 	public final String name;
40
 	public final String name;
42
-	private final List<IParsedType> genericParameters;
41
+	private final List<IParsedType> typeArguments;
43
 	
42
 	
44
-	public ParsedExpressionVariable(CodePosition position, String name, List<IParsedType> genericParameters) {
43
+	public ParsedExpressionVariable(CodePosition position, String name, List<IParsedType> typeArguments) {
45
 		super(position);
44
 		super(position);
46
 
45
 
47
 		this.name = name;
46
 		this.name = name;
48
-		this.genericParameters = genericParameters;
47
+		this.typeArguments = typeArguments;
49
 	}
48
 	}
50
 
49
 
51
 	@Override
50
 	@Override
52
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
51
 	public IPartialExpression compile(ExpressionScope scope) throws CompileException {
53
-		TypeID[] genericArguments = TypeID.NONE;
54
-		if (genericParameters != null) {
55
-			genericArguments = new TypeID[genericParameters.size()];
56
-			for (int i = 0; i < genericParameters.size(); i++) {
57
-				genericArguments[i] = genericParameters.get(i).compileUnstored(scope);
58
-			}
59
-		}
60
-		
61
-		IPartialExpression result = scope.get(position, new GenericName(name, genericArguments));
52
+		TypeArgument[] typeArguments = IParsedType.compileArguments(this.typeArguments, scope);
53
+		IPartialExpression result = scope.get(position, new GenericName(name, typeArguments));
62
 		if (result == null) {
54
 		if (result == null) {
63
 			for (StoredType hint : scope.hints) {
55
 			for (StoredType hint : scope.hints) {
64
 				TypeMembers members = scope.getTypeMembers(hint);
56
 				TypeMembers members = scope.getTypeMembers(hint);

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

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

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

16
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
16
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
17
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
17
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
18
 import org.openzen.zenscript.codemodel.type.StoredType;
18
 import org.openzen.zenscript.codemodel.type.StoredType;
19
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
20
 
19
 
21
 /**
20
 /**
22
  *
21
  *
43
 				return new TryRethrowAsExceptionExpression(position, cSource.type, cSource, cSource.thrownType);
42
 				return new TryRethrowAsExceptionExpression(position, cSource.type, cSource, cSource.thrownType);
44
 			} else {
43
 			} else {
45
 				// rethrow as result
44
 				// rethrow as result
46
-				StoredType resultType = scope.getTypeRegistry().getForDefinition(result, cSource.type.type, cSource.thrownType.type).stored(cSource.thrownType.storage);
45
+				StoredType resultType = scope.getTypeRegistry().getForDefinition(result, cSource.type.asArgument(), cSource.thrownType.asArgument()).stored(cSource.thrownType.storage);
47
 				return new TryRethrowAsResultExpression(position, resultType, cSource);
46
 				return new TryRethrowAsResultExpression(position, resultType, cSource);
48
 			}
47
 			}
49
 		} else {
48
 		} else {
51
 			if (cSource.type.type instanceof DefinitionTypeID) {
50
 			if (cSource.type.type instanceof DefinitionTypeID) {
52
 				DefinitionTypeID sourceType = (DefinitionTypeID)cSource.type.type;
51
 				DefinitionTypeID sourceType = (DefinitionTypeID)cSource.type.type;
53
 				if (sourceType.definition == result) {
52
 				if (sourceType.definition == result) {
54
-					return new TryRethrowAsResultExpression(position, sourceType.typeArguments[0].stored(sourceType.typeArguments[0].isValueType() ? ValueStorageTag.INSTANCE : cSource.type.storage), cSource);
53
+					return new TryRethrowAsResultExpression(position, sourceType.typeArguments[0].stored(), cSource);
55
 				}
54
 				}
56
 			}
55
 			}
57
 			
56
 			

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

17
 import org.openzen.zenscript.codemodel.scope.BaseScope;
17
 import org.openzen.zenscript.codemodel.scope.BaseScope;
18
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
18
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
20
+import org.openzen.zenscript.codemodel.type.TypeArgument;
20
 import org.openzen.zenscript.lexer.ParseException;
21
 import org.openzen.zenscript.lexer.ParseException;
21
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
22
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
22
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
23
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
254
 		return result;
255
 		return result;
255
 	}
256
 	}
256
 	
257
 	
258
+	public static TypeArgument[] compileArguments(List<IParsedType> typeParameters, TypeResolutionContext context) {
259
+		TypeArgument[] result = TypeArgument.NONE;
260
+		if (typeParameters != null && typeParameters.size() > 0) {
261
+			result = new TypeArgument[typeParameters.size()];
262
+			for (int i = 0; i < typeParameters.size(); i++) {
263
+				result[i] = typeParameters.get(i).compileArgument(context);
264
+			}
265
+		}
266
+		return result;
267
+	}
268
+	
257
 	public IParsedType withOptional();
269
 	public IParsedType withOptional();
258
 	
270
 	
259
 	public IParsedType withModifiers(int modifiers);
271
 	public IParsedType withModifiers(int modifiers);
262
 	
274
 	
263
 	public TypeID compileUnstored(TypeResolutionContext context);
275
 	public TypeID compileUnstored(TypeResolutionContext context);
264
 	
276
 	
277
+	public TypeArgument compileArgument(TypeResolutionContext context);
278
+	
265
 	public default AnnotationDefinition compileAnnotation(BaseScope scope) {
279
 	public default AnnotationDefinition compileAnnotation(BaseScope scope) {
266
 		return null;
280
 		return null;
267
 	}
281
 	}
268
 	
282
 	
269
-	public default TypeID[] compileTypeArguments(BaseScope scope) {
270
-		return TypeID.NONE;
283
+	public default TypeArgument[] compileTypeArguments(BaseScope scope) {
284
+		return TypeArgument.NONE;
271
 	}
285
 	}
272
 }
286
 }

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

11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
11
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
12
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
13
 import org.openzen.zenscript.codemodel.type.StoredType;
13
 import org.openzen.zenscript.codemodel.type.StoredType;
14
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
14
+import org.openzen.zenscript.codemodel.type.TypeArgument;
15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
16
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
17
 import org.openzen.zenscript.codemodel.type.TypeID;
17
 import org.openzen.zenscript.codemodel.type.TypeID;
18
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
18
 
19
 
19
 /**
20
 /**
20
  *
21
  *
52
 
53
 
53
 	@Override
54
 	@Override
54
 	public StoredType compile(TypeResolutionContext context) {
55
 	public StoredType compile(TypeResolutionContext context) {
55
-		StorageTag storage = this.storage == null ? SharedStorageTag.INSTANCE : this.storage.resolve(position, context);
56
+		StorageTag storage = this.storage == ParsedStorageTag.NULL ? AutoStorageTag.INSTANCE : this.storage.resolve(position, context);
56
 		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context))).stored(storage);
57
 		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context))).stored(storage);
57
 	}
58
 	}
58
 	
59
 	
63
 		
64
 		
64
 		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context)));
65
 		return context.getTypeRegistry().getModified(modifiers, context.getTypeRegistry().getFunction(header.compile(context)));
65
 	}
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);
72
+	}
66
 }
73
 }

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

16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
16
 import org.openzen.zenscript.codemodel.type.InvalidTypeID;
17
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
17
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
18
 import org.openzen.zenscript.codemodel.type.StoredType;
18
 import org.openzen.zenscript.codemodel.type.StoredType;
19
+import org.openzen.zenscript.codemodel.type.TypeArgument;
19
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
20
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
20
 import org.openzen.zenscript.codemodel.type.TypeID;
21
 import org.openzen.zenscript.codemodel.type.TypeID;
21
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
22
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
22
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
23
 import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
23
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageType;
24
 
24
 
25
 /**
25
 /**
26
  *
26
  *
65
 		
65
 		
66
 		StorageTag storage;
66
 		StorageTag storage;
67
 		if (this.storage == ParsedStorageTag.NULL) {
67
 		if (this.storage == ParsedStorageTag.NULL) {
68
-			storage = result.isValueType() ? ValueStorageTag.INSTANCE : SharedStorageTag.INSTANCE;
68
+			storage = AutoStorageTag.INSTANCE;
69
 		} else {
69
 		} else {
70
 			storage = this.storage.resolve(position, context);
70
 			storage = this.storage.resolve(position, context);
71
 		}
71
 		}
80
 		return compile(context).type;
80
 		return compile(context).type;
81
 	}
81
 	}
82
 	
82
 	
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
+	
83
 	@Override
109
 	@Override
84
 	public IParsedType withOptional() {
110
 	public IParsedType withOptional() {
85
 		return new ParsedNamedType(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, name, storage);
111
 		return new ParsedNamedType(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, name, storage);
110
 	}
136
 	}
111
 	
137
 	
112
 	@Override
138
 	@Override
113
-	public TypeID[] compileTypeArguments(BaseScope scope) {
139
+	public TypeArgument[] compileTypeArguments(BaseScope scope) {
114
 		ParsedNamePart last = name.get(name.size() - 1);
140
 		ParsedNamePart last = name.get(name.size() - 1);
115
-		return IParsedType.compileListUnstored(last.typeArguments, scope);
141
+		return IParsedType.compileArguments(last.typeArguments, scope);
116
 	}
142
 	}
117
 	
143
 	
118
 	private StoredType toIterator(TypeResolutionContext context) {
144
 	private StoredType toIterator(TypeResolutionContext context) {
123
 
149
 
124
 		StorageTag storage = this.storage.resolve(position, context);
150
 		StorageTag storage = this.storage.resolve(position, context);
125
 		TypeID type = context.getTypeRegistry().getIterator(iteratorTypes);
151
 		TypeID type = context.getTypeRegistry().getIterator(iteratorTypes);
152
+		if (storage == null)
153
+			storage = AutoStorageTag.INSTANCE;
126
 		return context.getTypeRegistry().getModified(modifiers, type).stored(storage);
154
 		return context.getTypeRegistry().getModified(modifiers, type).stored(storage);
127
 	}
155
 	}
128
 	
156
 	
136
 		}
164
 		}
137
 		
165
 		
138
 		private GenericName compile(TypeResolutionContext context) {
166
 		private GenericName compile(TypeResolutionContext context) {
139
-			return new GenericName(name, IParsedType.compileListUnstored(typeArguments, context));
167
+			return new GenericName(name, IParsedType.compileArguments(typeArguments, context));
140
 		}
168
 		}
141
 		
169
 		
142
 		@Override
170
 		@Override

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

8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
9
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
10
 import org.openzen.zenscript.codemodel.type.StoredType;
10
 import org.openzen.zenscript.codemodel.type.StoredType;
11
+import org.openzen.zenscript.codemodel.type.TypeArgument;
11
 import org.openzen.zenscript.codemodel.type.TypeID;
12
 import org.openzen.zenscript.codemodel.type.TypeID;
12
 
13
 
13
 /**
14
 /**
41
 	public TypeID compileUnstored(TypeResolutionContext context) {
42
 	public TypeID compileUnstored(TypeResolutionContext context) {
42
 		return context.getTypeRegistry().getModified(ModifiedTypeID.MODIFIER_OPTIONAL, type.compileUnstored(context));
43
 		return context.getTypeRegistry().getModified(ModifiedTypeID.MODIFIER_OPTIONAL, type.compileUnstored(context));
43
 	}
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
+	}
44
 }
51
 }

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

9
 import java.util.List;
9
 import java.util.List;
10
 import org.openzen.zencode.shared.CodePosition;
10
 import org.openzen.zencode.shared.CodePosition;
11
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
11
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
12
-import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
13
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
12
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
14
 import org.openzen.zenscript.lexer.ParseException;
13
 import org.openzen.zenscript.lexer.ParseException;
15
 import org.openzen.zenscript.lexer.ZSTokenParser;
14
 import org.openzen.zenscript.lexer.ZSTokenParser;
44
 	
43
 	
45
 	public StorageTag resolve(CodePosition position, TypeResolutionContext context) {
44
 	public StorageTag resolve(CodePosition position, TypeResolutionContext context) {
46
 		if (this == NULL)
45
 		if (this == NULL)
47
-			return SharedStorageTag.INSTANCE;
46
+			return null;
48
 		
47
 		
49
 		return context.getStorageTag(position, name, arguments);
48
 		return context.getStorageTag(position, name, arguments);
50
 	}
49
 	}

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


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

Loading…
Cancel
Save