浏览代码

WIP on storage tags and improved error handling

Stan Hebben 6 年前
父节点
当前提交
e1b48ad7c8
共有 100 个文件被更改,包括 812 次插入419 次删除
  1. 1
    1
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/DefinitionFormatter.java
  2. 10
    10
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java
  3. 6
    6
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java
  4. 5
    5
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/MemberFormatter.java
  5. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/StatementFormatter.java
  6. 18
    40
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java
  7. 57
    40
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  8. 17
    18
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java
  9. 17
    16
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java
  10. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  11. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationDefinition.java
  12. 102
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidAnnotationDefinition.java
  13. 56
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidDefinitionAnnotation.java
  14. 70
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidMemberAnnotation.java
  15. 42
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidParameterAnnotation.java
  16. 44
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidStatementAnnotation.java
  17. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java
  18. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/ParameterAnnotation.java
  19. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java
  20. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionForMethod.java
  21. 6
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java
  22. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingType.java
  23. 8
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/FileResolutionContext.java
  24. 8
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/LocalTypeResolutionContext.java
  25. 9
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/ModuleTypeResolutionContext.java
  26. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/StatementContext.java
  27. 9
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeContext.java
  28. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeResolutionContext.java
  29. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java
  30. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java
  31. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java
  32. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java
  33. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java
  34. 12
    13
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ZSPackage.java
  35. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/AndAndExpression.java
  36. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ArrayExpression.java
  37. 12
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java
  38. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java
  39. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpression.java
  40. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedThisExpression.java
  41. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java
  42. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConditionalExpression.java
  43. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantBoolExpression.java
  44. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantByteExpression.java
  45. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantCharExpression.java
  46. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantDoubleExpression.java
  47. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantFloatExpression.java
  48. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantIntExpression.java
  49. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantLongExpression.java
  50. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantSByteExpression.java
  51. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantShortExpression.java
  52. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUIntExpression.java
  53. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantULongExpression.java
  54. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUShortExpression.java
  55. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUSizeExpression.java
  56. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorSuperCallExpression.java
  57. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java
  58. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java
  59. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java
  60. 23
    21
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  61. 9
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java
  62. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java
  63. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitorWithContext.java
  64. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/FunctionExpression.java
  65. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java
  66. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java
  67. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InterfaceCastExpression.java
  68. 57
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InvalidExpression.java
  69. 6
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/IsExpression.java
  70. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MakeConstExpression.java
  71. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MapExpression.java
  72. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MatchExpression.java
  73. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java
  74. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NullExpression.java
  75. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/OrOrExpression.java
  76. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java
  77. 7
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/RangeExpression.java
  78. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SameObjectExpression.java
  79. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StorageCastExpression.java
  80. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SupertypeCastExpression.java
  81. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThisExpression.java
  82. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java
  83. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryConvertExpression.java
  84. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsExceptionExpression.java
  85. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsResultExpression.java
  86. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java
  87. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/WrapOptionalExpression.java
  88. 7
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java
  89. 11
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  90. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java
  91. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameterBound.java
  92. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java
  93. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  94. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java
  95. 1
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java
  96. 9
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  97. 6
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  98. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  99. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  100. 0
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java

+ 1
- 1
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/DefinitionFormatter.java 查看文件

@@ -195,7 +195,7 @@ public class DefinitionFormatter implements DefinitionVisitor<Void> {
195 195
 				for (int i = 0; i < option.types.length; i++) {
196 196
 					if (i > 0)
197 197
 						output.append(", ");
198
-					output.append(option.types[i].accept(typeFormatter));
198
+					output.append(typeFormatter.format(option.types[i]));
199 199
 				}
200 200
 			}
201 201
 		}

+ 10
- 10
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java 查看文件

@@ -312,7 +312,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
312 312
 		result.append(expression.target.accept(this).value);
313 313
 		if (!expression.isImplicit) {
314 314
 			result.append(" as ");
315
-			result.append(expression.member.toType.accept(typeFormatter));
315
+			result.append(typeFormatter.format(expression.member.toType));
316 316
 		}
317 317
 		return new ExpressionString(result.toString(), ZenScriptOperator.PRIMARY);
318 318
 	}
@@ -341,7 +341,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
341 341
 	@Override
342 342
 	public ExpressionString visitConst(ConstExpression expression) {
343 343
 		StringBuilder result = new StringBuilder();
344
-		result.append(expression.type.accept(typeFormatter));
344
+		result.append(typeFormatter.format(expression.type));
345 345
 		result.append('.');
346 346
 		result.append(expression.constant.member.name);
347 347
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
@@ -440,7 +440,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
440 440
 
441 441
 	@Override
442 442
 	public ExpressionString visitEnumConstant(EnumConstantExpression expression) {
443
-		return new ExpressionString(expression.type.accept(typeFormatter) + "." + expression.value.name, ZenScriptOperator.MEMBER);
443
+		return new ExpressionString(typeFormatter.format(expression.type) + "." + expression.value.name, ZenScriptOperator.MEMBER);
444 444
 	}
445 445
 
446 446
 	@Override
@@ -497,7 +497,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
497 497
 	@Override
498 498
 	public ExpressionString visitGetStaticField(GetStaticFieldExpression expression) {
499 499
 		StringBuilder result = new StringBuilder();
500
-		result.append(expression.type.accept(typeFormatter));
500
+		result.append(typeFormatter.format(expression.type));
501 501
 		result.append('.');
502 502
 		result.append(expression.field.member.name);
503 503
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
@@ -530,7 +530,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
530 530
 		StringBuilder result = new StringBuilder();
531 531
 		result.append(expression.value.accept(this).value);
532 532
 		result.append(" as ");
533
-		result.append(expression.type.accept(typeFormatter));
533
+		result.append(typeFormatter.format(expression.type));
534 534
 		return new ExpressionString(result.toString(), ZenScriptOperator.CAST);
535 535
 	}
536 536
 
@@ -539,7 +539,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
539 539
 		StringBuilder result = new StringBuilder();
540 540
 		result.append(expression.value.accept(this).value);
541 541
 		result.append(" is ");
542
-		result.append(expression.type.accept(typeFormatter));
542
+		result.append(typeFormatter.format(expression.type));
543 543
 		return new ExpressionString(result.toString(), ZenScriptOperator.IS);
544 544
 	}
545 545
 
@@ -577,7 +577,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
577 577
 	public ExpressionString visitNew(NewExpression expression) {
578 578
 		StringBuilder result = new StringBuilder();
579 579
 		result.append("new ");
580
-		result.append(expression.type.accept(typeFormatter));
580
+		result.append(typeFormatter.format(expression.type));
581 581
 		FormattingUtils.formatCall(result, typeFormatter, this, expression.arguments);
582 582
 		return new ExpressionString(result.toString(), ZenScriptOperator.PRIMARY);
583 583
 	}
@@ -636,7 +636,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
636 636
 	@Override
637 637
 	public ExpressionString visitSetStaticField(SetStaticFieldExpression expression) {
638 638
 		return new ExpressionString(
639
-				expression.type.accept(typeFormatter) + "." + expression.field.member.name + " = " + expression.value.accept(this).value,
639
+				typeFormatter.format(expression.type) + "." + expression.field.member.name + " = " + expression.value.accept(this).value,
640 640
 				ZenScriptOperator.ASSIGN);
641 641
 	}
642 642
 
@@ -650,14 +650,14 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
650 650
 	@Override
651 651
 	public ExpressionString visitStaticGetter(StaticGetterExpression expression) {
652 652
 		return new ExpressionString(
653
-				expression.type.accept(typeFormatter) + "." + expression.getter.member.name, 
653
+				typeFormatter.format(expression.type) + "." + expression.getter.member.name, 
654 654
 				ZenScriptOperator.MEMBER);
655 655
 	}
656 656
 
657 657
 	@Override
658 658
 	public ExpressionString visitStaticSetter(StaticSetterExpression expression) {
659 659
 		return new ExpressionString(
660
-				expression.type.accept(typeFormatter) + "." + expression.setter.member.name + " = " + expression.setter.member.name,
660
+				typeFormatter.format(expression.type) + "." + expression.setter.member.name + " = " + expression.setter.member.name,
661 661
 				ZenScriptOperator.ASSIGN);
662 662
 	}
663 663
 	

+ 6
- 6
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java 查看文件

@@ -30,7 +30,7 @@ import org.openzen.zenscript.codemodel.statement.TryCatchStatement;
30 30
 import org.openzen.zenscript.codemodel.statement.VarStatement;
31 31
 import org.openzen.zenscript.codemodel.statement.WhileStatement;
32 32
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
33
-import org.openzen.zenscript.codemodel.type.ITypeID;
33
+import org.openzen.zenscript.codemodel.type.TypeID;
34 34
 
35 35
 /**
36 36
  *
@@ -78,17 +78,17 @@ public class FormattingUtils {
78 78
 			if (parameter.variadic)
79 79
 				result.append("...");
80 80
 			
81
-			if (!settings.showAnyInFunctionHeaders || parameter.type != BasicTypeID.UNDETERMINED) {
81
+			if (!settings.showAnyInFunctionHeaders || !parameter.type.isBasic(BasicTypeID.UNDETERMINED)) {
82 82
 				result.append(" as ");
83
-				result.append(header.getReturnType().accept(typeFormatter));
83
+				result.append(typeFormatter.format(header.getReturnType()));
84 84
 			}
85 85
 			
86 86
 			parameterIndex++;
87 87
 		}
88 88
 		result.append(")");
89
-		if (!settings.showAnyInFunctionHeaders || header.getReturnType() != BasicTypeID.UNDETERMINED) {
89
+		if (!settings.showAnyInFunctionHeaders || !header.getReturnType().isBasic(BasicTypeID.UNDETERMINED)) {
90 90
 			result.append(" as ");
91
-			result.append(header.getReturnType().accept(typeFormatter));
91
+			result.append(typeFormatter.format(header.getReturnType()));
92 92
 		}
93 93
 	}
94 94
 	
@@ -128,7 +128,7 @@ public class FormattingUtils {
128 128
 			result.append("<");
129 129
 			
130 130
 			int index = 0;
131
-			for (ITypeID typeArgument : arguments.typeArguments) {
131
+			for (TypeID typeArgument : arguments.typeArguments) {
132 132
 				if (index > 0)
133 133
 					result.append(", ");
134 134
 				result.append(typeArgument.accept(typeFormatter));

+ 5
- 5
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/MemberFormatter.java 查看文件

@@ -62,7 +62,7 @@ public class MemberFormatter implements MemberVisitor<Void> {
62 62
 		output.append("const")
63 63
 				.append(member.name)
64 64
 				.append(" as ")
65
-				.append(member.type.accept(typeFormatter))
65
+				.append(typeFormatter.format(member.type))
66 66
 				.append(" = ")
67 67
 				.append(member.value.accept(new ExpressionFormatter(settings, typeFormatter, indent)))
68 68
 				.append(";\n");
@@ -76,7 +76,7 @@ public class MemberFormatter implements MemberVisitor<Void> {
76 76
 		output.append(member.isFinal() ? "val " : "var ")
77 77
 				.append(member.name)
78 78
 				.append(" as ")
79
-				.append(member.type.accept(typeFormatter));
79
+				.append(typeFormatter.format(member.type));
80 80
 		
81 81
 		if (member.initializer != null) {
82 82
 			output.append(" = ")
@@ -122,7 +122,7 @@ public class MemberFormatter implements MemberVisitor<Void> {
122 122
 		output.append("get ");
123 123
 		output.append(member.name);
124 124
 		output.append(" as ");
125
-		output.append(member.type.accept(typeFormatter));
125
+		output.append(typeFormatter.format(member.type));
126 126
 		formatBody(member.body);
127 127
 		return null;
128 128
 	}
@@ -134,7 +134,7 @@ public class MemberFormatter implements MemberVisitor<Void> {
134 134
 		output.append("set ");
135 135
 		output.append(member.name);
136 136
 		output.append(" as ");
137
-		output.append(member.type.accept(typeFormatter));
137
+		output.append(typeFormatter.format(member.type));
138 138
 		formatBody(member.body);
139 139
 		return null;
140 140
 	}
@@ -186,7 +186,7 @@ public class MemberFormatter implements MemberVisitor<Void> {
186 186
 		visit(false);
187 187
 		FormattingUtils.formatModifiers(output, member.modifiers & ~Modifiers.FINAL);
188 188
 		output.append(" as ");
189
-		output.append(member.toType.accept(typeFormatter));
189
+		output.append(typeFormatter.format(member.toType));
190 190
 		formatBody(member.body);
191 191
 		return null;
192 192
 	}

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/StatementFormatter.java 查看文件

@@ -252,7 +252,7 @@ public class StatementFormatter implements StatementVisitor<Void> {
252 252
 		for (CatchClause catchClause : statement.catchClauses) {
253 253
 			output.append(indent).append("catch ");
254 254
 			if (catchClause.exceptionVariable != null)
255
-				output.append(catchClause.exceptionVariable.name).append(" as ").append(catchClause.exceptionVariable.type.accept(expressionFormatter.typeFormatter));
255
+				output.append(catchClause.exceptionVariable.name).append(" as ").append(expressionFormatter.typeFormatter.format(catchClause.exceptionVariable.type));
256 256
 			
257 257
 			format(ParentStatementType.CATCH, catchClause.content);
258 258
 		}
@@ -274,7 +274,7 @@ public class StatementFormatter implements StatementVisitor<Void> {
274 274
 		
275 275
 		if (statement.initializer == null || statement.initializer.type != statement.type) {
276 276
 			output.append(" as ");
277
-			output.append(statement.type.accept(expressionFormatter.typeFormatter));
277
+			output.append(expressionFormatter.typeFormatter.format(statement.type));
278 278
 		}
279 279
 		if (statement.initializer != null) {
280 280
 			output.append(" = ");

+ 18
- 40
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java 查看文件

@@ -18,10 +18,11 @@ import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
19 19
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
20 20
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
21
-import org.openzen.zenscript.codemodel.type.ITypeID;
22 21
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
23 22
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
23
+import org.openzen.zenscript.codemodel.type.StoredType;
24 24
 import org.openzen.zenscript.codemodel.type.StringTypeID;
25
+import org.openzen.zenscript.codemodel.type.TypeID;
25 26
 import stdlib.Chars;
26 27
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
27 28
 
@@ -37,6 +38,14 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
37 38
 		this.settings = settings;
38 39
 		this.importer = importer;
39 40
 	}
41
+	
42
+	public String format(TypeID type) {
43
+		return type.accept(this);
44
+	}
45
+	
46
+	public String format(StoredType type) {
47
+		return type.type.accept(this) + "`" + type.storage.toString();
48
+	}
40 49
 
41 50
 	@Override
42 51
 	public String visitBasic(BasicTypeID basic) {
@@ -45,34 +54,24 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
45 54
 	
46 55
 	@Override
47 56
 	public String visitString(StringTypeID string) {
48
-		if (string.storage == null)
49
-			return "string";
50
-		else
51
-			return "string`" + string.storage.toString();
57
+		return "string";
52 58
 	}
53 59
 
54 60
 	@Override
55 61
 	public String visitArray(ArrayTypeID array) {
56
-		String element = array.elementType.accept(this);
62
+		String element = format(array.elementType);
57 63
 		String result;
58 64
 		if (array.dimension == 1) {
59 65
 			result = element + "[]";
60 66
 		} else {
61 67
 			result = element + "[" + Chars.times(',', array.dimension - 1) + "]";
62 68
 		}
63
-		if (array.storage == null)
64
-			return result;
65
-		
66
-		return result + '`' + array.storage.toString();
69
+		return result;
67 70
 	}
68 71
 
69 72
 	@Override
70 73
 	public String visitAssoc(AssocTypeID assoc) {
71
-		String result = assoc.valueType.accept(this) + "[" + assoc.keyType.accept(this) + "]";
72
-		if (assoc.storage == null)
73
-			return result;
74
-		
75
-		return result + '`' + assoc.storage.toString();
74
+		return format(assoc.valueType) + "[" + format(assoc.keyType) + "]";
76 75
 	}
77 76
 
78 77
 	@Override
@@ -85,12 +84,6 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
85 84
 		StringBuilder result = new StringBuilder();
86 85
 		result.append("function");
87 86
 		FormattingUtils.formatHeader(result, settings, function.header, this);
88
-		
89
-		if (function.storage != null) {
90
-			result.append('`');
91
-			result.append(function.storage.toString());
92
-		}
93
-		
94 87
 		return result.toString();
95 88
 	}
96 89
 
@@ -104,33 +97,24 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
104 97
 		result.append(importedName);
105 98
 		result.append("<");
106 99
 		int index = 0;
107
-		for (ITypeID typeParameter : definition.typeArguments) {
100
+		for (TypeID typeParameter : definition.typeArguments) {
108 101
 			if (index > 0)
109 102
 				result.append(", ");
110 103
 			
111 104
 			result.append(typeParameter.accept(this));
112 105
 		}
113 106
 		result.append(">");
114
-		
115
-		if (definition.storage != null) {
116
-			result.append('`');
117
-			result.append(definition.storage.toString());
118
-		}
119
-		
120 107
 		return result.toString();
121 108
 	}
122 109
 
123 110
 	@Override
124 111
 	public String visitGeneric(GenericTypeID generic) {
125
-		if (generic.storage == null)
126
-			return generic.parameter.name;
127
-		
128
-		return generic.parameter.name + '`' + generic.storage.toString();
112
+		return generic.parameter.name;
129 113
 	}
130 114
 
131 115
 	@Override
132 116
 	public String visitRange(RangeTypeID range) {
133
-		return range.baseType.accept(this) + " .. " + range.baseType.accept(this);
117
+		return format(range.baseType) + " .. " + format(range.baseType);
134 118
 	}
135 119
 
136 120
 	@Override
@@ -160,16 +144,10 @@ public class TypeFormatter implements TypeVisitor<String>, GenericParameterBound
160 144
 	@Override
161 145
 	public String visitGenericMap(GenericMapTypeID map) {
162 146
 		StringBuilder result = new StringBuilder();
163
-		result.append(map.value.accept(this));
147
+		result.append(format(map.value));
164 148
 		result.append("[<");
165 149
 		FormattingUtils.formatTypeParameters(result, new TypeParameter[] { map.key }, this);
166 150
 		result.append("]>");
167
-		
168
-		if (map.storage != null) {
169
-			result.append('`');
170
-			result.append(map.storage.toString());
171
-		}
172
-		
173 151
 		return result.toString();
174 152
 	}
175 153
 }

+ 57
- 40
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java 查看文件

@@ -14,9 +14,10 @@ import org.openzen.zenscript.codemodel.expression.Expression;
14 14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
15 15
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17
-import org.openzen.zenscript.codemodel.type.ITypeID;
18 17
 import org.openzen.zenscript.codemodel.scope.TypeScope;
18
+import org.openzen.zenscript.codemodel.type.StoredType;
19 19
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
20
+import org.openzen.zenscript.codemodel.type.TypeID;
20 21
 
21 22
 /**
22 23
  *
@@ -24,15 +25,15 @@ import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
24 25
  */
25 26
 public class FunctionHeader {
26 27
 	public final TypeParameter[] typeParameters;
27
-	private ITypeID returnType;
28
+	private StoredType returnType;
28 29
 	public final FunctionParameter[] parameters;
29
-	public final ITypeID thrownType;
30
+	public final StoredType thrownType;
30 31
 	
31 32
 	public final int minParameters;
32 33
 	public final int maxParameters;
33 34
 	public final boolean hasUnknowns;
34 35
 	
35
-	public FunctionHeader(ITypeID returnType) {
36
+	public FunctionHeader(StoredType returnType) {
36 37
 		if (returnType == null)
37 38
 			throw new NullPointerException();
38 39
 		
@@ -43,10 +44,14 @@ public class FunctionHeader {
43 44
 		
44 45
 		minParameters = 0;
45 46
 		maxParameters = 0;
46
-		hasUnknowns = returnType == BasicTypeID.UNDETERMINED;
47
+		hasUnknowns = returnType == BasicTypeID.UNDETERMINED.stored;
47 48
 	}
48 49
 	
49
-	public FunctionHeader(ITypeID returnType, ITypeID... parameterTypes) {
50
+	public FunctionHeader(BasicTypeID returnType) {
51
+		this(returnType.stored);
52
+	}
53
+	
54
+	public FunctionHeader(StoredType returnType, StoredType... parameterTypes) {
50 55
 		if (returnType == null)
51 56
 			throw new NullPointerException();
52 57
 		
@@ -63,7 +68,11 @@ public class FunctionHeader {
63 68
 		hasUnknowns = hasUnknowns(parameterTypes, returnType);
64 69
 	}
65 70
 	
66
-	public FunctionHeader(ITypeID returnType, FunctionParameter... parameters) {
71
+	public FunctionHeader(BasicTypeID returnType, StoredType... parameterTypes) {
72
+		this(returnType.stored, parameterTypes);
73
+	}
74
+	
75
+	public FunctionHeader(StoredType returnType, FunctionParameter... parameters) {
67 76
 		if (returnType == null)
68 77
 			throw new NullPointerException();
69 78
 		
@@ -77,7 +86,11 @@ public class FunctionHeader {
77 86
 		hasUnknowns = hasUnknowns(parameters, returnType);
78 87
 	}
79 88
 	
80
-	public FunctionHeader(TypeParameter[] typeParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
89
+	public FunctionHeader(BasicTypeID returnType, FunctionParameter... parameters) {
90
+		this(returnType.stored, parameters);
91
+	}
92
+	
93
+	public FunctionHeader(TypeParameter[] typeParameters, StoredType returnType, StoredType thrownType, FunctionParameter... parameters) {
81 94
 		if (returnType == null)
82 95
 			throw new NullPointerException();
83 96
 		if (typeParameters == null)
@@ -93,11 +106,11 @@ public class FunctionHeader {
93 106
 		hasUnknowns = hasUnknowns(parameters, returnType);
94 107
 	}
95 108
 	
96
-	public ITypeID getReturnType() {
109
+	public StoredType getReturnType() {
97 110
 		return returnType;
98 111
 	}
99 112
 	
100
-	public void setReturnType(ITypeID returnType) {
113
+	public void setReturnType(StoredType returnType) {
101 114
 		if (returnType == null)
102 115
 			throw new NullPointerException();
103 116
 		
@@ -136,23 +149,23 @@ public class FunctionHeader {
136 149
 		return false;
137 150
 	}
138 151
 	
139
-	public FunctionHeader withReturnType(ITypeID returnType) {
152
+	public FunctionHeader withReturnType(StoredType returnType) {
140 153
 		return new FunctionHeader(typeParameters, returnType, thrownType, parameters);
141 154
 	}
142 155
 	
143 156
 	public FunctionHeader inferFromOverride(GlobalTypeRegistry registry, FunctionHeader overridden) {
144 157
 		TypeParameter[] resultTypeParameters = typeParameters;
145
-		ITypeID resultReturnType = this.returnType;
146
-		if (resultReturnType == BasicTypeID.UNDETERMINED)
158
+		StoredType resultReturnType = this.returnType;
159
+		if (resultReturnType.type == BasicTypeID.UNDETERMINED)
147 160
 			resultReturnType = overridden.returnType;
148 161
 		
149
-		ITypeID resultThrownType = this.thrownType;
162
+		StoredType resultThrownType = this.thrownType;
150 163
 		if (resultThrownType == null && overridden.thrownType != null)
151 164
 			resultThrownType = overridden.thrownType;
152 165
 		
153 166
 		FunctionParameter[] resultParameters = Arrays.copyOf(parameters, parameters.length);
154 167
 		for (int i = 0; i < resultParameters.length; i++) {
155
-			if (resultParameters[i].type == BasicTypeID.UNDETERMINED) {
168
+			if (resultParameters[i].type.type == BasicTypeID.UNDETERMINED) {
156 169
 				FunctionParameter parameter = resultParameters[i];
157 170
 				FunctionParameter original = overridden.parameters[i];
158 171
 				resultParameters[i] = new FunctionParameter(original.type, parameter.name, parameter.defaultValue, original.variadic);
@@ -209,15 +222,15 @@ public class FunctionHeader {
209 222
 		return result.toString();
210 223
 	}
211 224
 	
212
-	public ITypeID[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<ITypeID> resultHint) {
225
+	public TypeID[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<StoredType> resultHint) {
213 226
 		if (arguments.arguments.length != this.parameters.length)
214 227
 			return null;
215 228
 		
216
-		Map<TypeParameter, ITypeID> mapping = new HashMap<>();
229
+		Map<TypeParameter, TypeID> mapping = new HashMap<>();
217 230
 		if (!resultHint.isEmpty()) {
218
-			Map<TypeParameter, ITypeID> temp = new HashMap<>();
219
-			for (ITypeID hint : resultHint) {
220
-				if (returnType.inferTypeParameters(cache, hint, temp)) {
231
+			for (StoredType hint : resultHint) {
232
+				Map<TypeParameter, TypeID> temp = returnType.inferTypeParameters(cache, hint);
233
+				if (temp != null) {
221 234
 					mapping = temp;
222 235
 					break;
223 236
 				}
@@ -225,14 +238,18 @@ public class FunctionHeader {
225 238
 		}
226 239
 		
227 240
 		// TODO: lambda header inference
228
-		for (int i = 0; i < parameters.length; i++)
229
-			if (!parameters[i].type.inferTypeParameters(cache, arguments.arguments[i].type, mapping))
241
+		for (int i = 0; i < parameters.length; i++) {
242
+			Map<TypeParameter, TypeID> forParameter = parameters[i].type.inferTypeParameters(cache, arguments.arguments[i].type);
243
+			if (forParameter == null)
230 244
 				return null;
245
+			
246
+			mapping.putAll(forParameter);
247
+		}
231 248
 		
232 249
 		if (mapping.size() > typeParameters.length)
233 250
 			return null;
234 251
 		
235
-		ITypeID[] result = new ITypeID[typeParameters.length];
252
+		TypeID[] result = new TypeID[typeParameters.length];
236 253
 		for (int i = 0; i < typeParameters.length; i++) {
237 254
 			TypeParameter typeParameter = typeParameters[i];
238 255
 			if (!mapping.containsKey(typeParameter)) {
@@ -270,11 +287,11 @@ public class FunctionHeader {
270 287
 			throw new NullPointerException();
271 288
 		if (parameters.length != other.parameters.length)
272 289
 			return false;
273
-		if (returnType != BasicTypeID.UNDETERMINED && !scope.getTypeMembers(returnType).canCastImplicit(other.returnType))
290
+		if (returnType.type != BasicTypeID.UNDETERMINED && !scope.getTypeMembers(returnType).canCastImplicit(other.returnType))
274 291
 			return false;
275 292
 		
276 293
 		for (int i = 0; i < parameters.length; i++) {
277
-			if (parameters[i].type == BasicTypeID.UNDETERMINED)
294
+			if (parameters[i].type.type == BasicTypeID.UNDETERMINED)
278 295
 				continue;
279 296
 			
280 297
 			if (parameters[i].variadic != other.parameters[i].variadic)
@@ -339,7 +356,7 @@ public class FunctionHeader {
339 356
 	
340 357
 	public FunctionHeader instanceForCall(GlobalTypeRegistry registry, CallArguments arguments) {
341 358
 		if (arguments.getNumberOfTypeArguments() > 0) {
342
-			Map<TypeParameter, ITypeID> typeParameters = new HashMap<>();
359
+			Map<TypeParameter, TypeID> typeParameters = new HashMap<>();
343 360
 			for (int i = 0; i < this.typeParameters.length; i++) {
344 361
 				typeParameters.put(this.typeParameters[i], arguments.typeArguments[i]);
345 362
 			}
@@ -353,14 +370,14 @@ public class FunctionHeader {
353 370
 	
354 371
 	public FunctionHeader withGenericArguments(GlobalTypeRegistry registry, GenericMapper mapper) {
355 372
 		if (typeParameters.length > 0) {
356
-			Map<TypeParameter, ITypeID> innerMap = new HashMap<>();
373
+			Map<TypeParameter, TypeID> innerMap = new HashMap<>();
357 374
 			for (TypeParameter parameter : typeParameters)
358
-				innerMap.put(parameter, mapper.registry.getGeneric(parameter, null));
375
+				innerMap.put(parameter, mapper.registry.getGeneric(parameter));
359 376
 			
360 377
 			mapper = mapper.getInner(registry, innerMap);
361 378
 		}
362 379
 		
363
-		ITypeID returnType = this.returnType.instance(mapper);
380
+		StoredType returnType = this.returnType.instance(mapper);
364 381
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
365 382
 		for (int i = 0; i < parameters.length; i++) {
366 383
 			parameters[i] = this.parameters[i].withGenericArguments(mapper);
@@ -368,16 +385,16 @@ public class FunctionHeader {
368 385
 		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.instance(mapper), parameters);
369 386
 	}
370 387
 	
371
-	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, ITypeID[] arguments, GenericMapper typeParameterMapping) {
388
+	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, TypeID[] arguments, GenericMapper typeParameterMapping) {
372 389
 		if (arguments == null || arguments.length == 0)
373 390
 			return this;
374 391
 		
375
-		Map<TypeParameter, ITypeID> typeArguments = new HashMap<>();
392
+		Map<TypeParameter, TypeID> typeArguments = new HashMap<>();
376 393
 		for (int i = 0; i < typeParameters.length; i++)
377 394
 			typeArguments.put(typeParameters[i], arguments[i]);
378 395
 		GenericMapper mapper = typeParameterMapping.getInner(registry, typeArguments);
379 396
 		
380
-		ITypeID returnType = this.returnType.instance(mapper);
397
+		StoredType returnType = this.returnType.instance(mapper);
381 398
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
382 399
 		for (int i = 0; i < parameters.length; i++) {
383 400
 			parameters[i] = this.parameters[i].withGenericArguments(mapper);
@@ -386,7 +403,7 @@ public class FunctionHeader {
386 403
 	}
387 404
 	
388 405
 	public FunctionHeader forTypeParameterInference() {
389
-		return new FunctionHeader(BasicTypeID.UNDETERMINED, parameters);
406
+		return new FunctionHeader(BasicTypeID.UNDETERMINED.stored, parameters);
390 407
 	}
391 408
 	
392 409
 	public FunctionHeader forLambda(FunctionHeader lambdaHeader) {
@@ -460,23 +477,23 @@ public class FunctionHeader {
460 477
 		return parameters[parameters.length - 1].variadic ? Integer.MAX_VALUE : parameters.length;
461 478
 	}
462 479
 	
463
-	private static boolean hasUnknowns(ITypeID[] types, ITypeID returnType) {
464
-		if (returnType == BasicTypeID.UNDETERMINED)
480
+	private static boolean hasUnknowns(StoredType[] types, StoredType returnType) {
481
+		if (returnType.type == BasicTypeID.UNDETERMINED)
465 482
 			return true;
466 483
 		
467
-		for (ITypeID type : types)
468
-			if (type == BasicTypeID.UNDETERMINED)
484
+		for (StoredType type : types)
485
+			if (type.type == BasicTypeID.UNDETERMINED)
469 486
 				return true;
470 487
 		
471 488
 		return false;
472 489
 	}
473 490
 	
474
-	private static boolean hasUnknowns(FunctionParameter[] parameters, ITypeID returnType) {
475
-		if (returnType == BasicTypeID.UNDETERMINED)
491
+	private static boolean hasUnknowns(FunctionParameter[] parameters, StoredType returnType) {
492
+		if (returnType.type == BasicTypeID.UNDETERMINED)
476 493
 			return true;
477 494
 		
478 495
 		for (FunctionParameter parameter : parameters)
479
-			if (parameter.type == BasicTypeID.UNDETERMINED)
496
+			if (parameter.type.type == BasicTypeID.UNDETERMINED)
480 497
 				return true;
481 498
 		
482 499
 		return false;

+ 17
- 18
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java 查看文件

@@ -5,12 +5,13 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel;
7 7
 
8
-import org.openzen.zenscript.codemodel.annotations.Annotation;
9 8
 import java.util.Objects;
10 9
 import org.openzen.zencode.shared.Taggable;
11 10
 import org.openzen.zenscript.codemodel.expression.Expression;
11
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
12 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.codemodel.type.StoredType;
14
+import org.openzen.zenscript.codemodel.annotations.ParameterAnnotation;
14 15
 
15 16
 /**
16 17
  *
@@ -19,30 +20,34 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
19 20
 public class FunctionParameter extends Taggable {
20 21
 	public static final FunctionParameter[] NONE = new FunctionParameter[0];
21 22
 	
22
-	public Annotation[] annotations;
23
-	public final ITypeID type;
23
+	public ParameterAnnotation[] annotations;
24
+	public final StoredType type;
24 25
 	public final String name;
25 26
 	public Expression defaultValue;
26 27
 	public final boolean variadic;
27 28
 	
28
-	public FunctionParameter(ITypeID type) {
29
-		this.annotations = Annotation.NONE;
29
+	public FunctionParameter(StoredType type) {
30
+		this.annotations = ParameterAnnotation.NONE;
30 31
 		this.type = type;
31 32
 		this.name = "";
32 33
 		this.defaultValue = null;
33 34
 		this.variadic = false;
34 35
 	}
35 36
 	
36
-	public FunctionParameter(ITypeID type, String name) {
37
-		this.annotations = Annotation.NONE;
37
+	public FunctionParameter(BasicTypeID type) {
38
+		this(type.stored);
39
+	}
40
+	
41
+	public FunctionParameter(StoredType type, String name) {
42
+		this.annotations = ParameterAnnotation.NONE;
38 43
 		this.type = type;
39 44
 		this.name = name;
40 45
 		this.defaultValue = null;
41 46
 		this.variadic = false;
42 47
 	}
43 48
 	
44
-	public FunctionParameter(ITypeID type, String name, Expression defaultValue, boolean variadic) {
45
-		this.annotations = Annotation.NONE;
49
+	public FunctionParameter(StoredType type, String name, Expression defaultValue, boolean variadic) {
50
+		this.annotations = ParameterAnnotation.NONE;
46 51
 		this.type = type;
47 52
 		this.name = name;
48 53
 		this.defaultValue = defaultValue;
@@ -56,7 +61,7 @@ public class FunctionParameter extends Taggable {
56 61
 	}
57 62
 	
58 63
 	public FunctionParameter withGenericArguments(GenericMapper mapper) {
59
-		ITypeID instanced = type.instance(mapper);
64
+		StoredType instanced = type.instance(mapper);
60 65
 		if (instanced == type)
61 66
 			return this;
62 67
 		
@@ -91,12 +96,6 @@ public class FunctionParameter extends Taggable {
91 96
 			return false;
92 97
 		}
93 98
 		final FunctionParameter other = (FunctionParameter) obj;
94
-		if (this.variadic != other.variadic) {
95
-			return false;
96
-		}
97
-		if (!Objects.equals(this.type, other.type)) {
98
-			return false;
99
-		}
100
-		return true;
99
+		return this.variadic == other.variadic && this.type.equals(other.type);
101 100
 	}
102 101
 }

+ 17
- 16
CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java 查看文件

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

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java 查看文件

@@ -25,7 +25,7 @@ import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25 25
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
26 26
 import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
27 27
 import org.openzen.zenscript.codemodel.scope.TypeScope;
28
-import org.openzen.zenscript.codemodel.type.ITypeID;
28
+import org.openzen.zenscript.codemodel.type.TypeID;
29 29
 
30 30
 /**
31 31
  *
@@ -42,7 +42,7 @@ public abstract class HighLevelDefinition extends Taggable {
42 42
 	public DefinitionAnnotation[] annotations = DefinitionAnnotation.NONE;
43 43
 	
44 44
 	public HighLevelDefinition outerDefinition;
45
-	private ITypeID superType;
45
+	private TypeID superType;
46 46
 	
47 47
 	private boolean isDestructible = false;
48 48
 	
@@ -72,11 +72,11 @@ public abstract class HighLevelDefinition extends Taggable {
72 72
 		return pkg.fullName + '.' + name;
73 73
 	}
74 74
 	
75
-	public ITypeID getSuperType() {
75
+	public TypeID getSuperType() {
76 76
 		return superType;
77 77
 	}
78 78
 	
79
-	public void setSuperType(ITypeID superType) {
79
+	public void setSuperType(TypeID superType) {
80 80
 		this.superType = superType;
81 81
 		if (outerDefinition != null)
82 82
 			isDestructible |= outerDefinition.isDestructible;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationDefinition.java 查看文件

@@ -43,7 +43,7 @@ public interface AnnotationDefinition {
43 43
 	
44 44
 	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments);
45 45
 	
46
-	public Annotation createForParameter(CodePosition position, CallArguments arguments);
46
+	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments);
47 47
 	
48 48
 	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member);
49 49
 	
@@ -51,5 +51,5 @@ public interface AnnotationDefinition {
51 51
 	
52 52
 	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context);
53 53
 	
54
-	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context);
54
+	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context);
55 55
 }

+ 102
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidAnnotationDefinition.java 查看文件

@@ -0,0 +1,102 @@
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.annotations;
7
+
8
+import java.util.Collections;
9
+import java.util.List;
10
+import org.openzen.zencode.shared.CodePosition;
11
+import org.openzen.zenscript.codemodel.FunctionHeader;
12
+import org.openzen.zenscript.codemodel.FunctionParameter;
13
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
+import org.openzen.zenscript.codemodel.context.StatementContext;
15
+import org.openzen.zenscript.codemodel.context.TypeContext;
16
+import org.openzen.zenscript.codemodel.expression.CallArguments;
17
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
18
+import org.openzen.zenscript.codemodel.scope.BaseScope;
19
+import org.openzen.zenscript.codemodel.scope.ExpressionScope;
20
+import org.openzen.zenscript.codemodel.scope.StatementScope;
21
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
22
+import org.openzen.zenscript.codemodel.statement.Statement;
23
+
24
+/**
25
+ *
26
+ * @author Hoofdgebruiker
27
+ */
28
+public class InvalidAnnotationDefinition implements AnnotationDefinition {
29
+	public static final InvalidAnnotationDefinition INSTANCE = new InvalidAnnotationDefinition();
30
+	
31
+	private InvalidAnnotationDefinition() {}
32
+
33
+	@Override
34
+	public String getAnnotationName() {
35
+		return "Invalid";
36
+	}
37
+
38
+	@Override
39
+	public List<FunctionHeader> getInitializers(BaseScope scope) {
40
+		return Collections.emptyList();
41
+	}
42
+
43
+	@Override
44
+	public ExpressionScope getScopeForMember(IDefinitionMember member, BaseScope scope) {
45
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
46
+	}
47
+
48
+	@Override
49
+	public ExpressionScope getScopeForType(HighLevelDefinition definition, BaseScope scope) {
50
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
51
+	}
52
+
53
+	@Override
54
+	public ExpressionScope getScopeForStatement(Statement statement, StatementScope scope) {
55
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
56
+	}
57
+
58
+	@Override
59
+	public ExpressionScope getScopeForParameter(FunctionHeader header, FunctionParameter parameter, BaseScope scope) {
60
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
61
+	}
62
+
63
+	@Override
64
+	public MemberAnnotation createForMember(CodePosition position, CallArguments arguments) {
65
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
66
+	}
67
+
68
+	@Override
69
+	public DefinitionAnnotation createForDefinition(CodePosition position, CallArguments arguments) {
70
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
71
+	}
72
+
73
+	@Override
74
+	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments) {
75
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
76
+	}
77
+
78
+	@Override
79
+	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments) {
80
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
81
+	}
82
+
83
+	@Override
84
+	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member) {
85
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
86
+	}
87
+
88
+	@Override
89
+	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context) {
90
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
91
+	}
92
+
93
+	@Override
94
+	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context) {
95
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
96
+	}
97
+
98
+	@Override
99
+	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
100
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
101
+	}
102
+}

+ 56
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidDefinitionAnnotation.java 查看文件

@@ -0,0 +1,56 @@
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.annotations;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.context.TypeContext;
13
+import org.openzen.zenscript.codemodel.scope.BaseScope;
14
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
15
+
16
+/**
17
+ *
18
+ * @author Hoofdgebruiker
19
+ */
20
+public class InvalidDefinitionAnnotation implements DefinitionAnnotation {
21
+	public final CodePosition position;
22
+	public final CompileExceptionCode code;
23
+	public final String message;
24
+	
25
+	public InvalidDefinitionAnnotation(CodePosition position, CompileExceptionCode code, String message) {
26
+		this.position = position;
27
+		this.code = code;
28
+		this.message = message;
29
+	}
30
+	
31
+	public InvalidDefinitionAnnotation(CompileException ex) {
32
+		this.position = ex.position;
33
+		this.code = ex.code;
34
+		this.message = ex.getMessage();
35
+	}
36
+
37
+	@Override
38
+	public AnnotationDefinition getDefinition() {
39
+		return InvalidAnnotationDefinition.INSTANCE;
40
+	}
41
+
42
+	@Override
43
+	public void apply(HighLevelDefinition definition, BaseScope scope) {
44
+		
45
+	}
46
+
47
+	@Override
48
+	public void applyOnSubtype(HighLevelDefinition definition, BaseScope scope) {
49
+		
50
+	}
51
+
52
+	@Override
53
+	public void serialize(CodeSerializationOutput output, HighLevelDefinition definition, TypeContext context) {
54
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
55
+	}
56
+}

+ 70
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidMemberAnnotation.java 查看文件

@@ -0,0 +1,70 @@
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.annotations;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.context.TypeContext;
13
+import org.openzen.zenscript.codemodel.member.FunctionalMember;
14
+import org.openzen.zenscript.codemodel.member.GetterMember;
15
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
16
+import org.openzen.zenscript.codemodel.member.SetterMember;
17
+import org.openzen.zenscript.codemodel.scope.BaseScope;
18
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
19
+
20
+/**
21
+ *
22
+ * @author Hoofdgebruiker
23
+ */
24
+public class InvalidMemberAnnotation implements MemberAnnotation {
25
+	public final CodePosition position;
26
+	public final CompileExceptionCode code;
27
+	public final String message;
28
+	
29
+	public InvalidMemberAnnotation(CodePosition position, CompileExceptionCode code, String message) {
30
+		this.position = position;
31
+		this.code = code;
32
+		this.message = message;
33
+	}
34
+	
35
+	public InvalidMemberAnnotation(CompileException ex) {
36
+		this.position = ex.position;
37
+		this.code = ex.code;
38
+		this.message = ex.getMessage();
39
+	}
40
+
41
+	@Override
42
+	public AnnotationDefinition getDefinition() {
43
+		return InvalidAnnotationDefinition.INSTANCE;
44
+	}
45
+
46
+	@Override
47
+	public void apply(IDefinitionMember member, BaseScope scope) {
48
+		
49
+	}
50
+
51
+	@Override
52
+	public void applyOnOverridingMethod(FunctionalMember member, BaseScope scope) {
53
+		
54
+	}
55
+
56
+	@Override
57
+	public void applyOnOverridingGetter(GetterMember member, BaseScope scope) {
58
+		
59
+	}
60
+
61
+	@Override
62
+	public void applyOnOverridingSetter(SetterMember member, BaseScope scope) {
63
+		
64
+	}
65
+
66
+	@Override
67
+	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context) {
68
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
69
+	}
70
+}

+ 42
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidParameterAnnotation.java 查看文件

@@ -0,0 +1,42 @@
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.annotations;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class InvalidParameterAnnotation implements ParameterAnnotation {
17
+	public final CodePosition position;
18
+	public final CompileExceptionCode code;
19
+	public final String message;
20
+	
21
+	public InvalidParameterAnnotation(CodePosition position, CompileExceptionCode code, String message) {
22
+		this.position = position;
23
+		this.code = code;
24
+		this.message = message;
25
+	}
26
+	
27
+	public InvalidParameterAnnotation(CompileException ex) {
28
+		this.position = ex.position;
29
+		this.code = ex.code;
30
+		this.message = ex.getMessage();
31
+	}
32
+
33
+	@Override
34
+	public AnnotationDefinition getDefinition() {
35
+		return InvalidAnnotationDefinition.INSTANCE;
36
+	}
37
+
38
+	@Override
39
+	public void apply() {
40
+		
41
+	}
42
+}

+ 44
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidStatementAnnotation.java 查看文件

@@ -0,0 +1,44 @@
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.annotations;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+import org.openzen.zenscript.codemodel.scope.StatementScope;
12
+import org.openzen.zenscript.codemodel.statement.Statement;
13
+
14
+/**
15
+ *
16
+ * @author Hoofdgebruiker
17
+ */
18
+public class InvalidStatementAnnotation implements StatementAnnotation {
19
+	public final CodePosition position;
20
+	public final CompileExceptionCode code;
21
+	public final String message;
22
+	
23
+	public InvalidStatementAnnotation(CodePosition position, CompileExceptionCode code, String message) {
24
+		this.position = position;
25
+		this.code = code;
26
+		this.message = message;
27
+	}
28
+	
29
+	public InvalidStatementAnnotation(CompileException ex) {
30
+		this.position = ex.position;
31
+		this.code = ex.code;
32
+		this.message = ex.getMessage();
33
+	}
34
+
35
+	@Override
36
+	public AnnotationDefinition getDefinition() {
37
+		return InvalidAnnotationDefinition.INSTANCE;
38
+	}
39
+
40
+	@Override
41
+	public Statement apply(Statement statement, StatementScope scope) {
42
+		return statement;
43
+	}
44
+}

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java 查看文件

@@ -86,7 +86,7 @@ public class NativeAnnotationDefinition implements AnnotationDefinition {
86 86
 	}
87 87
 
88 88
 	@Override
89
-	public Annotation createForParameter(CodePosition position, CallArguments arguments) {
89
+	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments) {
90 90
 		throw new UnsupportedOperationException("Not supported");
91 91
 	}
92 92
 
@@ -108,7 +108,7 @@ public class NativeAnnotationDefinition implements AnnotationDefinition {
108 108
 	}
109 109
 
110 110
 	@Override
111
-	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
111
+	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
112 112
 		throw new UnsupportedOperationException("Not supported");
113 113
 	}
114 114
 }

CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/Annotation.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/ParameterAnnotation.java 查看文件

@@ -9,8 +9,8 @@ package org.openzen.zenscript.codemodel.annotations;
9 9
  *
10 10
  * @author Hoofdgebruiker
11 11
  */
12
-public interface Annotation {
13
-	public static final Annotation[] NONE = new Annotation[0];
12
+public interface ParameterAnnotation {
13
+	public static final ParameterAnnotation[] NONE = new ParameterAnnotation[0];
14 14
 	
15 15
 	public AnnotationDefinition getDefinition();
16 16
 	

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java 查看文件

@@ -51,9 +51,9 @@ public class PreconditionAnnotationDefinition implements AnnotationDefinition {
51 51
 	@Override
52 52
 	public List<FunctionHeader> getInitializers(BaseScope scope) {
53 53
 		return Collections.singletonList(new FunctionHeader(
54
-				BasicTypeID.VOID,
55
-				scope.getType(CodePosition.BUILTIN, enforcementLevelName, StaticStorageTag.INSTANCE),
56
-				BasicTypeID.BOOL,
54
+				BasicTypeID.VOID.stored,
55
+				scope.getType(CodePosition.BUILTIN, enforcementLevelName).stored(StaticStorageTag.INSTANCE),
56
+				BasicTypeID.BOOL.stored,
57 57
 				StringTypeID.UNIQUE));
58 58
 	}
59 59
 
@@ -106,7 +106,7 @@ public class PreconditionAnnotationDefinition implements AnnotationDefinition {
106 106
 	}
107 107
 
108 108
 	@Override
109
-	public Annotation createForParameter(CodePosition position, CallArguments arguments) {
109
+	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments) {
110 110
 		throw new UnsupportedOperationException("Not supported");
111 111
 	}
112 112
 
@@ -131,7 +131,7 @@ public class PreconditionAnnotationDefinition implements AnnotationDefinition {
131 131
 	}
132 132
 
133 133
 	@Override
134
-	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
134
+	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
135 135
 		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
136 136
 	}
137 137
 }

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionForMethod.java 查看文件

@@ -83,11 +83,11 @@ public class PreconditionForMethod implements MemberAnnotation {
83 83
 		if (body == null)
84 84
 			return body;
85 85
 		
86
-		ExpressionScope expressionScope = new ExpressionScope(scope, BasicTypeID.BOOL);
86
+		ExpressionScope expressionScope = new ExpressionScope(scope, BasicTypeID.BOOL.stored);
87 87
 		List<Statement> statements = new ArrayList<>();
88 88
 		ExpressionBuilder expressionBuilder = new ExpressionBuilder(position, expressionScope);
89 89
 		Expression inverseCondition = expressionBuilder.not(condition);
90
-		Statement throwStatement = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID, message));
90
+		Statement throwStatement = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID.stored, message));
91 91
 		statements.add(new IfStatement(position, inverseCondition, throwStatement, null));
92 92
 		
93 93
 		if (body instanceof BlockStatement) {

+ 6
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java 查看文件

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.Module;
13 13
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
14 14
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.GenericName;
16
-import org.openzen.zenscript.codemodel.type.ITypeID;
16
+import org.openzen.zenscript.codemodel.type.TypeID;
17 17
 
18 18
 /**
19 19
  *
@@ -71,11 +71,11 @@ public class CompilingPackage {
71 71
 		return getImportType(context, type.getInner(name.get(index)), name, index + 1);
72 72
 	}
73 73
 	
74
-	public ITypeID getType(TypeResolutionContext context, List<GenericName> name) {
74
+	public TypeID getType(TypeResolutionContext context, List<GenericName> name) {
75 75
 		return getType(context, name, 0);
76 76
 	}
77 77
 	
78
-	private ITypeID getType(TypeResolutionContext context, List<GenericName> name, int index) {
78
+	private TypeID getType(TypeResolutionContext context, List<GenericName> name, int index) {
79 79
 		if (index == name.size())
80 80
 			return null;
81 81
 		
@@ -84,14 +84,14 @@ public class CompilingPackage {
84 84
 		
85 85
 		if (types.containsKey(name.get(index).name)) {
86 86
 			CompilingType type = types.get(name.get(index).name);
87
-			DefinitionTypeID result = context.getTypeRegistry().getForDefinition(type.load(), null, name.get(index).arguments);
87
+			DefinitionTypeID result = context.getTypeRegistry().getForDefinition(type.load(), name.get(index).arguments);
88 88
 			return getInner(context, name, index + 1, type, result);
89 89
 		}
90 90
 		
91 91
 		return null;
92 92
 	}
93 93
 	
94
-	private ITypeID getInner(TypeResolutionContext context, List<GenericName> name, int index, CompilingType type, DefinitionTypeID result) {
94
+	private TypeID getInner(TypeResolutionContext context, List<GenericName> name, int index, CompilingType type, DefinitionTypeID result) {
95 95
 		if (index == name.size())
96 96
 			return result;
97 97
 		
@@ -99,7 +99,7 @@ public class CompilingPackage {
99 99
 		if (innerType == null)
100 100
 			return null;
101 101
 		
102
-		DefinitionTypeID innerResult = context.getTypeRegistry().getForDefinition(innerType.load(), name.get(index).arguments, result, null);
102
+		DefinitionTypeID innerResult = context.getTypeRegistry().getForDefinition(innerType.load(), name.get(index).arguments, result);
103 103
 		return getInner(context, name, index + 1, innerType, innerResult);
104 104
 	}
105 105
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingType.java 查看文件

@@ -21,7 +21,7 @@ public interface CompilingType {
21 21
 	HighLevelDefinition load();
22 22
 	
23 23
 	default DefinitionTypeID getInnerType(GlobalTypeRegistry registry, List<GenericName> name, int index, DefinitionTypeID outer) {
24
-		DefinitionTypeID type = registry.getForDefinition(load(), name.get(index).arguments, outer, null);
24
+		DefinitionTypeID type = registry.getForDefinition(load(), name.get(index).arguments, outer);
25 25
 		index++;
26 26
 		if (index == name.size())
27 27
 			return type;

+ 8
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/FileResolutionContext.java 查看文件

@@ -13,7 +13,8 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 13
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
14 14
 import org.openzen.zenscript.codemodel.type.GenericName;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16
-import org.openzen.zenscript.codemodel.type.ITypeID;
16
+import org.openzen.zenscript.codemodel.type.StoredType;
17
+import org.openzen.zenscript.codemodel.type.TypeID;
17 18
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
18 19
 
19 20
 /**
@@ -45,21 +46,20 @@ public class FileResolutionContext implements TypeResolutionContext {
45 46
 	}
46 47
 
47 48
 	@Override
48
-	public ITypeID getType(CodePosition position, List<GenericName> name, StorageTag storage) {
49
+	public TypeID getType(CodePosition position, List<GenericName> name) {
49 50
 		if (imports.containsKey(name.get(0).name)) {
50 51
 			return GenericName.getInnerType(
51 52
 					getTypeRegistry(),
52
-					getTypeRegistry().getForDefinition(imports.get(name.get(0).name), null, name.get(0).arguments),
53
+					getTypeRegistry().getForDefinition(imports.get(name.get(0).name), name.get(0).arguments),
53 54
 					name,
54
-					1,
55
-					storage);
55
+					1);
56 56
 		}
57 57
 		
58
-		ITypeID moduleType = modulePackage.getType(this, name);
58
+		TypeID moduleType = modulePackage.getType(this, name);
59 59
 		if (moduleType != null)
60 60
 			return moduleType;
61 61
 		
62
-		return module.getType(position, name, storage);
62
+		return module.getType(position, name);
63 63
 	}
64 64
 	
65 65
 	@Override
@@ -68,7 +68,7 @@ public class FileResolutionContext implements TypeResolutionContext {
68 68
 	}
69 69
 
70 70
 	@Override
71
-	public ITypeID getThisType() {
71
+	public StoredType getThisType() {
72 72
 		return null;
73 73
 	}
74 74
 }

+ 8
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/LocalTypeResolutionContext.java 查看文件

@@ -12,7 +12,9 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 12
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
13 13
 import org.openzen.zenscript.codemodel.type.GenericName;
14 14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15
-import org.openzen.zenscript.codemodel.type.ITypeID;
15
+import org.openzen.zenscript.codemodel.type.StoredType;
16
+import org.openzen.zenscript.codemodel.type.TypeID;
17
+import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
16 18
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
17 19
 
18 20
 /**
@@ -41,7 +43,7 @@ public class LocalTypeResolutionContext implements TypeResolutionContext {
41 43
 	}
42 44
 
43 45
 	@Override
44
-	public ITypeID getType(CodePosition position, List<GenericName> name, StorageTag storage) {
46
+	public TypeID getType(CodePosition position, List<GenericName> name) {
45 47
 		if (type != null) {
46 48
 			CompilingType compiling = type.getInner(name.get(0).name);
47 49
 			if (compiling != null) {
@@ -53,10 +55,10 @@ public class LocalTypeResolutionContext implements TypeResolutionContext {
53 55
 		if (name.size() == 1 && name.get(0).hasNoArguments()) {
54 56
 			for (TypeParameter parameter : parameters)
55 57
 				if (parameter.name.equals(name.get(0).name))
56
-					return getTypeRegistry().getGeneric(parameter, storage);
58
+					return getTypeRegistry().getGeneric(parameter);
57 59
 		}
58 60
 		
59
-		return outer.getType(position, name, storage);
61
+		return outer.getType(position, name);
60 62
 	}
61 63
 
62 64
 	@Override
@@ -65,7 +67,7 @@ public class LocalTypeResolutionContext implements TypeResolutionContext {
65 67
 	}
66 68
 	
67 69
 	@Override
68
-	public ITypeID getThisType() {
69
-		return type == null ? null : getTypeRegistry().getForMyDefinition(type.load());
70
+	public StoredType getThisType() {
71
+		return type == null ? null : getTypeRegistry().getForMyDefinition(type.load()).stored(BorrowStorageTag.THIS);
70 72
 	}
71 73
 }

+ 9
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/ModuleTypeResolutionContext.java 查看文件

@@ -9,14 +9,15 @@ import java.util.HashMap;
9 9
 import java.util.List;
10 10
 import java.util.Map;
11 11
 import org.openzen.zencode.shared.CodePosition;
12
-import org.openzen.zencode.shared.CompileException;
13 12
 import org.openzen.zencode.shared.CompileExceptionCode;
14 13
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
15 14
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
16 15
 import org.openzen.zenscript.codemodel.type.GenericName;
17 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
18 17
 import org.openzen.zenscript.codemodel.type.ISymbol;
19
-import org.openzen.zenscript.codemodel.type.ITypeID;
18
+import org.openzen.zenscript.codemodel.type.StoredType;
19
+import org.openzen.zenscript.codemodel.type.TypeID;
20
+import org.openzen.zenscript.codemodel.type.storage.InvalidStorageTag;
20 21
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
21 22
 import org.openzen.zenscript.codemodel.type.storage.StorageType;
22 23
 
@@ -63,29 +64,29 @@ public class ModuleTypeResolutionContext implements TypeResolutionContext {
63 64
 	}
64 65
 
65 66
 	@Override
66
-	public ITypeID getType(CodePosition position, List<GenericName> name, StorageTag storage) {
67
+	public TypeID getType(CodePosition position, List<GenericName> name) {
67 68
 		if (rootCompiling != null) {
68
-			ITypeID compiling = rootCompiling.getType(this, name);
69
+			TypeID compiling = rootCompiling.getType(this, name);
69 70
 			if (compiling != null)
70 71
 				return compiling;
71 72
 		}
72 73
 		
73 74
 		if (name.size() == 1 && globals.containsKey(name.get(0).name))
74
-			return globals.get(name.get(0).name).getType(position, this, name.get(0).arguments, storage);
75
+			return globals.get(name.get(0).name).getType(position, this, name.get(0).arguments);
75 76
 		
76
-		return rootPackage.getType(position, this, name, storage);
77
+		return rootPackage.getType(position, this, name);
77 78
 	}
78 79
 	
79 80
 	@Override
80 81
 	public StorageTag getStorageTag(CodePosition position, String name, String[] arguments) {
81 82
 		if (!storageTypes.containsKey(name))
82
-			throw new CompileException(position, CompileExceptionCode.NO_SUCH_STORAGE_TYPE, "No such storage type: " + name);
83
+			return new InvalidStorageTag(position, CompileExceptionCode.NO_SUCH_STORAGE_TYPE, "No such storage type: " + name);
83 84
 		
84 85
 		return storageTypes.get(name).instance(position, arguments);
85 86
 	}
86 87
 	
87 88
 	@Override
88
-	public ITypeID getThisType() {
89
+	public StoredType getThisType() {
89 90
 		return null;
90 91
 	}
91 92
 }

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/StatementContext.java 查看文件

@@ -15,7 +15,7 @@ import org.openzen.zenscript.codemodel.expression.switchvalue.VariantOptionSwitc
15 15
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
16 16
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
17 17
 import org.openzen.zenscript.codemodel.statement.VarStatement;
18
-import org.openzen.zenscript.codemodel.type.ITypeID;
18
+import org.openzen.zenscript.codemodel.type.StoredType;
19 19
 
20 20
 /**
21 21
  *
@@ -30,7 +30,7 @@ public class StatementContext extends TypeContext {
30 30
 	
31 31
 	public VariantOptionSwitchValue variantOptionSwitchValue;
32 32
 	
33
-	public StatementContext(ModuleContext module, ITypeID thisType) {
33
+	public StatementContext(ModuleContext module, StoredType thisType) {
34 34
 		super(module, TypeParameter.NONE, thisType);
35 35
 		
36 36
 		loops = LoopStatement.NONE;
@@ -39,7 +39,7 @@ public class StatementContext extends TypeContext {
39 39
 		lambdaOuter = null;
40 40
 	}
41 41
 	
42
-	public StatementContext(ModuleContext module, ITypeID thisType, FunctionHeader header) {
42
+	public StatementContext(ModuleContext module, StoredType thisType, FunctionHeader header) {
43 43
 		super(module, header.typeParameters, thisType);
44 44
 		
45 45
 		loops = LoopStatement.NONE;

+ 9
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeContext.java 查看文件

@@ -11,9 +11,10 @@ import java.util.List;
11 11
 import java.util.Map;
12 12
 import org.openzen.zenscript.codemodel.GenericMapper;
13 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
14
+import org.openzen.zenscript.codemodel.type.StoredType;
15 15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
16 16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
+import org.openzen.zenscript.codemodel.type.TypeID;
17 18
 
18 19
 /**
19 20
  *
@@ -21,25 +22,25 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
21 22
  */
22 23
 public class TypeContext {
23 24
 	protected final TypeParameter[] typeParameters;
24
-	public final ITypeID thisType;
25
+	public final StoredType thisType;
25 26
 	private final LocalMemberCache memberCache;
26 27
 	public final ModuleContext moduleContext;
27 28
 	
28
-	public TypeContext(ModuleContext context, TypeParameter[] parameters, ITypeID thisType) {
29
+	public TypeContext(ModuleContext context, TypeParameter[] parameters, StoredType thisType) {
29 30
 		this.typeParameters = parameters;
30 31
 		this.thisType = thisType;
31 32
 		memberCache = new LocalMemberCache(context.registry, context.expansions);
32 33
 		moduleContext = context;
33 34
 	}
34 35
 	
35
-	public TypeContext(TypeContext outer, ITypeID thisType, TypeParameter... inner) {
36
+	public TypeContext(TypeContext outer, StoredType thisType, TypeParameter... inner) {
36 37
 		typeParameters = concat(outer.typeParameters, inner);
37 38
 		this.thisType = thisType;
38 39
 		moduleContext = outer.moduleContext;
39 40
 		memberCache = new LocalMemberCache(moduleContext.registry, moduleContext.expansions);
40 41
 	}
41 42
 	
42
-	public TypeContext(TypeContext outer, ITypeID thisType, List<TypeParameter> inner) {
43
+	public TypeContext(TypeContext outer, StoredType thisType, List<TypeParameter> inner) {
43 44
 		this(outer, thisType, inner.toArray(new TypeParameter[inner.size()]));
44 45
 	}
45 46
 	
@@ -55,14 +56,14 @@ public class TypeContext {
55 56
 		return typeParameters[index];
56 57
 	}
57 58
 	
58
-	public TypeMembers getTypeMembers(ITypeID type) {
59
+	public TypeMembers getTypeMembers(StoredType type) {
59 60
 		return memberCache.get(type);
60 61
 	}
61 62
 	
62 63
 	public GenericMapper getMapper() {
63
-		Map<TypeParameter, ITypeID> mapper = new HashMap<>();
64
+		Map<TypeParameter, TypeID> mapper = new HashMap<>();
64 65
 		for (TypeParameter parameter : typeParameters)
65
-			mapper.put(parameter, moduleContext.registry.getGeneric(parameter, null));
66
+			mapper.put(parameter, moduleContext.registry.getGeneric(parameter));
66 67
 		return new GenericMapper(moduleContext.registry, mapper);
67 68
 	}
68 69
 	

+ 4
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/TypeResolutionContext.java 查看文件

@@ -10,7 +10,8 @@ import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11 11
 import org.openzen.zenscript.codemodel.type.GenericName;
12 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.codemodel.type.StoredType;
14
+import org.openzen.zenscript.codemodel.type.TypeID;
14 15
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
15 16
 
16 17
 /**
@@ -22,9 +23,9 @@ public interface TypeResolutionContext {
22 23
 	
23 24
 	AnnotationDefinition getAnnotation(String name);
24 25
 	
25
-	ITypeID getType(CodePosition position, List<GenericName> name, StorageTag storage);
26
+	TypeID getType(CodePosition position, List<GenericName> name);
26 27
 	
27 28
 	StorageTag getStorageTag(CodePosition position, String name, String[] parameters);
28 29
 	
29
-	ITypeID getThisType();
30
+	StoredType getThisType();
30 31
 }

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java 查看文件

@@ -9,20 +9,20 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 10
 import org.openzen.zenscript.codemodel.Module;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.TypeID;
13 13
 
14 14
 /**
15 15
  *
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class AliasDefinition extends HighLevelDefinition {
19
-	public ITypeID type;
19
+	public TypeID type;
20 20
 	
21 21
 	public AliasDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22 22
 		super(position, module, pkg, name, modifiers, outerDefinition);
23 23
 	}
24 24
 	
25
-	public void setType(ITypeID type) {
25
+	public void setType(TypeID type) {
26 26
 		if (type == null)
27 27
 			throw new NullPointerException("type cannot be null!");
28 28
 		

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java 查看文件

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

+ 5
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java 查看文件

@@ -15,8 +15,9 @@ import org.openzen.zenscript.codemodel.member.CallerMember;
15 15
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
16 16
 import org.openzen.zenscript.codemodel.statement.Statement;
17 17
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
18
-import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
18
+import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
20
+import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
20 21
 
21 22
 /**
22 23
  *
@@ -26,11 +27,11 @@ public class FunctionDefinition extends HighLevelDefinition {
26 27
 	public FunctionHeader header;
27 28
 	public Statement statement;
28 29
 	public CallerMember caller;
29
-	public final DefinitionMemberGroup callerGroup;
30
+	public final TypeMemberGroup callerGroup;
30 31
 	
31 32
 	public FunctionDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
32 33
 		super(position, module, pkg, name, modifiers, outerDefinition);
33
-		callerGroup = new DefinitionMemberGroup(true, name);
34
+		callerGroup = new TypeMemberGroup(true, name);
34 35
 	}
35 36
 	
36 37
 	public FunctionDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, FunctionHeader header, GlobalTypeRegistry registry) {
@@ -41,7 +42,7 @@ public class FunctionDefinition extends HighLevelDefinition {
41 42
 	public void setHeader(GlobalTypeRegistry registry, FunctionHeader header) {
42 43
 		this.header = header;
43 44
 		addMember(caller = new CallerMember(position, this, modifiers | Modifiers.STATIC, header, null));
44
-		callerGroup.addMethod(new FunctionalMemberRef(caller, registry.getFunction(header, null), GenericMapper.EMPTY), TypeMemberPriority.SPECIFIED);
45
+		callerGroup.addMethod(new FunctionalMemberRef(caller, registry.getFunction(header).stored(StaticStorageTag.INSTANCE), GenericMapper.EMPTY), TypeMemberPriority.SPECIFIED);
45 46
 	}
46 47
 	
47 48
 	public void setCode(Statement statement) {

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java 查看文件

@@ -10,26 +10,26 @@ import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.Module;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.codemodel.type.TypeID;
14 14
 
15 15
 /**
16 16
  *
17 17
  * @author Hoofdgebruiker
18 18
  */
19 19
 public class InterfaceDefinition extends HighLevelDefinition {
20
-	public final List<ITypeID> baseInterfaces = new ArrayList<>();
20
+	public final List<TypeID> baseInterfaces = new ArrayList<>();
21 21
 	
22 22
 	public InterfaceDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
23 23
 		super(position, module, pkg, name, modifiers, outerDefinition);
24 24
 	}
25 25
 	
26
-	public void addBaseInterface(ITypeID baseInterface) {
26
+	public void addBaseInterface(TypeID baseInterface) {
27 27
 		baseInterfaces.add(baseInterface);
28 28
 	}
29 29
 	
30 30
 	@Override
31 31
 	public boolean isDestructible() {
32
-		for (ITypeID baseInterface : baseInterfaces)
32
+		for (TypeID baseInterface : baseInterfaces)
33 33
 			if (baseInterface.isDestructible())
34 34
 				return true;
35 35
 		

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java 查看文件

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14 14
 import org.openzen.zenscript.codemodel.Module;
15 15
 import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
16
-import org.openzen.zenscript.codemodel.type.ITypeID;
16
+import org.openzen.zenscript.codemodel.type.StoredType;
17 17
 
18 18
 /**
19 19
  *
@@ -48,16 +48,16 @@ public class VariantDefinition extends HighLevelDefinition {
48 48
 		public final VariantDefinition variant;
49 49
 		public final String name;
50 50
 		public final int ordinal;
51
-		public final ITypeID[] types;
51
+		public final StoredType[] types;
52 52
 		
53
-		public Option(VariantDefinition variant, String name, int ordinal, ITypeID[] types) {
53
+		public Option(VariantDefinition variant, String name, int ordinal, StoredType[] types) {
54 54
 			this.variant = variant;
55 55
 			this.name = name;
56 56
 			this.ordinal = ordinal;
57 57
 			this.types = types;
58 58
 		}
59 59
 		
60
-		public VariantOptionRef instance(ITypeID variantType, GenericMapper mapper) {
60
+		public VariantOptionRef instance(StoredType variantType, GenericMapper mapper) {
61 61
 			return new VariantOptionRef(this, variantType, mapper.map(types));
62 62
 		}
63 63
 	}

+ 12
- 13
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ZSPackage.java 查看文件

@@ -9,18 +9,17 @@ import java.util.HashMap;
9 9
 import java.util.List;
10 10
 import java.util.Map;
11 11
 import org.openzen.zencode.shared.CodePosition;
12
-import org.openzen.zencode.shared.CompileException;
13 12
 import org.openzen.zencode.shared.CompileExceptionCode;
14 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15 14
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
15
+import org.openzen.zenscript.codemodel.expression.InvalidExpression;
16 16
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
17 17
 import org.openzen.zenscript.codemodel.partial.PartialPackageExpression;
18 18
 import org.openzen.zenscript.codemodel.partial.PartialTypeExpression;
19 19
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
20 20
 import org.openzen.zenscript.codemodel.type.GenericName;
21 21
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
22
-import org.openzen.zenscript.codemodel.type.ITypeID;
23
-import org.openzen.zenscript.codemodel.type.storage.StorageTag;
22
+import org.openzen.zenscript.codemodel.type.TypeID;
24 23
 
25 24
 /**
26 25
  *
@@ -57,9 +56,9 @@ public class ZSPackage {
57 56
 		
58 57
 		if (types.containsKey(name.name)) {
59 58
 			if (types.get(name.name).typeParameters.length != name.getNumberOfArguments())
60
-				throw new CompileException(position, CompileExceptionCode.TYPE_ARGUMENTS_INVALID_NUMBER, "Invalid number of type arguments");
59
+				return new InvalidExpression(position, CompileExceptionCode.TYPE_ARGUMENTS_INVALID_NUMBER, "Invalid number of type arguments");
61 60
 			
62
-			return new PartialTypeExpression(position, registry.getForDefinition(types.get(name.name), null, name.arguments), name.arguments);
61
+			return new PartialTypeExpression(position, registry.getForDefinition(types.get(name.name), name.arguments), name.arguments);
63 62
 		}
64 63
 		
65 64
 		return null;
@@ -86,29 +85,29 @@ public class ZSPackage {
86 85
 		return null;
87 86
 	}
88 87
 	
89
-	public ITypeID getType(CodePosition position, TypeResolutionContext context, List<GenericName> nameParts, StorageTag storage) {
90
-		return getType(position, context, nameParts, 0, storage);
88
+	public TypeID getType(CodePosition position, TypeResolutionContext context, List<GenericName> nameParts) {
89
+		return getType(position, context, nameParts, 0);
91 90
 	}
92 91
 	
93
-	public ITypeID getType(CodePosition position, TypeResolutionContext context, GenericName name, StorageTag storage) {
92
+	public TypeID getType(CodePosition position, TypeResolutionContext context, GenericName name) {
94 93
 		if (types.containsKey(name.name)) {
95
-			return context.getTypeRegistry().getForDefinition(types.get(name.name), storage, name.arguments);
94
+			return context.getTypeRegistry().getForDefinition(types.get(name.name), name.arguments);
96 95
 		}
97 96
 		
98 97
 		return null;
99 98
 	}
100 99
 	
101
-	private ITypeID getType(CodePosition position, TypeResolutionContext context, List<GenericName> nameParts, int depth, StorageTag storage) {
100
+	private TypeID getType(CodePosition position, TypeResolutionContext context, List<GenericName> nameParts, int depth) {
102 101
 		if (depth >= nameParts.size())
103 102
 			return null;
104 103
 		
105 104
 		GenericName name = nameParts.get(depth);
106 105
 		if (subPackages.containsKey(name.name) && name.hasNoArguments())
107
-			return subPackages.get(name.name).getType(position, context, nameParts, depth + 1, storage);
106
+			return subPackages.get(name.name).getType(position, context, nameParts, depth + 1);
108 107
 		
109 108
 		if (types.containsKey(name.name)) {
110
-			DefinitionTypeID type = context.getTypeRegistry().getForDefinition(types.get(name.name), null, name.arguments);
111
-			return GenericName.getInnerType(context.getTypeRegistry(), type, nameParts, depth + 1, storage);
109
+			DefinitionTypeID type = context.getTypeRegistry().getForDefinition(types.get(name.name), name.arguments);
110
+			return GenericName.getInnerType(context.getTypeRegistry(), type, nameParts, depth + 1);
112 111
 		}
113 112
 		
114 113
 		return null;

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/AndAndExpression.java 查看文件

@@ -18,7 +18,7 @@ public class AndAndExpression extends Expression {
18 18
 	public final Expression right;
19 19
 	
20 20
 	public AndAndExpression(CodePosition position, Expression left, Expression right) {
21
-		super(position, BasicTypeID.BOOL, binaryThrow(position, left.thrownType, right.thrownType));
21
+		super(position, BasicTypeID.BOOL.stored, binaryThrow(position, left.thrownType, right.thrownType));
22 22
 		
23 23
 		this.left = left;
24 24
 		this.right = right;

+ 5
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ArrayExpression.java 查看文件

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel.expression;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10 10
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
11 12
 
12 13
 /**
13 14
  *
@@ -17,11 +18,11 @@ public class ArrayExpression extends Expression {
17 18
 	public final Expression[] expressions;
18 19
 	public final ArrayTypeID arrayType;
19 20
 	
20
-	public ArrayExpression(CodePosition position, Expression[] expressions, ArrayTypeID type) {
21
+	public ArrayExpression(CodePosition position, Expression[] expressions, StoredType type) {
21 22
 		super(position, type, multiThrow(position, expressions));
22 23
 		
23 24
 		this.expressions = expressions;
24
-		this.arrayType = type;
25
+		this.arrayType = (ArrayTypeID)type.type;
25 26
 	}
26 27
 
27 28
 	@Override
@@ -37,7 +38,7 @@ public class ArrayExpression extends Expression {
37 38
 	@Override
38 39
 	public Expression transform(ExpressionTransformer transformer) {
39 40
 		Expression[] tExpressions = Expression.transform(expressions, transformer);
40
-		return tExpressions == expressions ? this : new ArrayExpression(position, tExpressions, (ArrayTypeID)type);
41
+		return tExpressions == expressions ? this : new ArrayExpression(position, tExpressions, type);
41 42
 	}
42 43
 
43 44
 	@Override
@@ -45,6 +46,6 @@ public class ArrayExpression extends Expression {
45 46
 		Expression[] normalized = new Expression[expressions.length];
46 47
 		for (int i = 0; i < normalized.length; i++)
47 48
 			normalized[i] = expressions[i].normalize(scope);
48
-		return new ArrayExpression(position, normalized, arrayType.getNormalized());
49
+		return new ArrayExpression(position, normalized, type.getNormalized());
49 50
 	}
50 51
 }

+ 12
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java 查看文件

@@ -7,11 +7,11 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import java.util.Arrays;
9 9
 import org.openzen.zencode.shared.CodePosition;
10
-import org.openzen.zencode.shared.CompileException;
11 10
 import org.openzen.zencode.shared.CompileExceptionCode;
12 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
13 12
 import org.openzen.zenscript.codemodel.scope.TypeScope;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
14
+import org.openzen.zenscript.codemodel.type.TypeID;
15 15
 
16 16
 /**
17 17
  *
@@ -20,17 +20,17 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
20 20
 public class CallArguments {
21 21
 	public static final CallArguments EMPTY = new CallArguments(new Expression[0]);
22 22
 	
23
-	public final ITypeID[] typeArguments;
23
+	public final TypeID[] typeArguments;
24 24
 	public final Expression[] arguments;
25 25
 	
26 26
 	public CallArguments(Expression... arguments) {
27
-		this.typeArguments = ITypeID.NONE;
27
+		this.typeArguments = TypeID.NONE;
28 28
 		this.arguments = arguments;
29 29
 	}
30 30
 	
31
-	public CallArguments(ITypeID[] typeArguments, Expression[] arguments) {
31
+	public CallArguments(TypeID[] typeArguments, Expression[] arguments) {
32 32
 		if (typeArguments == null)
33
-			typeArguments = ITypeID.NONE;
33
+			typeArguments = TypeID.NONE;
34 34
 		if (arguments == null)
35 35
 			throw new IllegalArgumentException("Arguments cannot be null!");
36 36
 		
@@ -38,11 +38,11 @@ public class CallArguments {
38 38
 		this.arguments = arguments;
39 39
 	}
40 40
 	
41
-	public CallArguments(ITypeID... dummy) {
42
-		this.typeArguments = ITypeID.NONE;
41
+	public CallArguments(TypeID... dummy) {
42
+		this.typeArguments = TypeID.NONE;
43 43
 		this.arguments = new Expression[dummy.length];
44 44
 		for (int i = 0; i < dummy.length; i++)
45
-			arguments[i] = new DummyExpression(dummy[i]);
45
+			arguments[i] = new DummyExpression(dummy[i].stored(UniqueStorageTag.INSTANCE));
46 46
 	}
47 47
 	
48 48
 	public int getNumberOfTypeArguments() {
@@ -65,8 +65,9 @@ public class CallArguments {
65 65
 			Expression[] newArguments = Arrays.copyOf(arguments, header.parameters.length);
66 66
 			for (int i = arguments.length; i < header.parameters.length; i++) {
67 67
 				if (header.parameters[i].defaultValue == null)
68
-					throw new CompileException(position, CompileExceptionCode.MISSING_PARAMETER, "Parameter missing and no default value specified");
69
-				newArguments[i] = header.parameters[i].defaultValue;
68
+					newArguments[i] = new InvalidExpression(position, header.parameters[i].type, CompileExceptionCode.MISSING_PARAMETER, "Parameter missing and no default value specified");
69
+				else
70
+					newArguments[i] = header.parameters[i].defaultValue;
70 71
 			}
71 72
 			result = new CallArguments(typeArguments, newArguments);
72 73
 		}

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java 查看文件

@@ -9,7 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.TypeID;
13 13
 
14 14
 /**
15 15
  *
@@ -17,11 +17,11 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
17 17
  */
18 18
 public class CallStaticExpression extends Expression {
19 19
 	public final FunctionalMemberRef member;
20
-	public final ITypeID target;
20
+	public final TypeID target;
21 21
 	public final CallArguments arguments;
22 22
 	public final FunctionHeader instancedHeader;
23 23
 	
24
-	public CallStaticExpression(CodePosition position, ITypeID target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments) {
24
+	public CallStaticExpression(CodePosition position, TypeID target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments) {
25 25
 		super(position, instancedHeader.getReturnType(), multiThrow(position, arguments.arguments));
26 26
 		
27 27
 		this.member = member;
@@ -50,7 +50,7 @@ public class CallStaticExpression extends Expression {
50 50
 	public Expression normalize(TypeScope scope) {
51 51
 		return new CallStaticExpression(
52 52
 				position,
53
-				target.getNormalized(),
53
+				target.getNormalizedUnstored(),
54 54
 				member,
55 55
 				instancedHeader.normalize(scope.getTypeRegistry()),
56 56
 				arguments.normalize(position, scope, instancedHeader));

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public abstract class CapturedExpression extends Expression {
17 17
 	public final LambdaClosure closure;
18 18
 	
19
-	public CapturedExpression(CodePosition position, ITypeID type, LambdaClosure closure) {
19
+	public CapturedExpression(CodePosition position, StoredType type, LambdaClosure closure) {
20 20
 		super(position, type, null);
21 21
 		
22 22
 		this.closure = closure;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedThisExpression.java 查看文件

@@ -7,14 +7,14 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
14 14
  * @author Hoofdgebruiker
15 15
  */
16 16
 public class CapturedThisExpression extends CapturedExpression {
17
-	public CapturedThisExpression(CodePosition position, ITypeID type, LambdaClosure closure) {
17
+	public CapturedThisExpression(CodePosition position, StoredType type, LambdaClosure closure) {
18 18
 		super(position, type, closure);
19 19
 	}
20 20
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java 查看文件

@@ -24,7 +24,7 @@ public class CompareExpression extends Expression {
24 24
 	public final CompareType comparison;
25 25
 	
26 26
 	public CompareExpression(CodePosition position, Expression left, Expression right, FunctionalMemberRef operator, CompareType comparison) {
27
-		super(position, BasicTypeID.BOOL, binaryThrow(position, left.thrownType, right.thrownType));
27
+		super(position, BasicTypeID.BOOL.stored, binaryThrow(position, left.thrownType, right.thrownType));
28 28
 		
29 29
 		this.left = left;
30 30
 		this.right = right;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConditionalExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -23,8 +23,8 @@ public class ConditionalExpression extends Expression {
23 23
 			Expression condition,
24 24
 			Expression ifThen,
25 25
 			Expression ifElse,
26
-			ITypeID type) {
27
-		super(position, ifThen.type, binaryThrow(position, condition.thrownType, binaryThrow(position, ifThen.thrownType, ifElse.thrownType)));
26
+			StoredType type) {
27
+		super(position, type, binaryThrow(position, condition.thrownType, binaryThrow(position, ifThen.thrownType, ifElse.thrownType)));
28 28
 		
29 29
 		if (ifThen.type != ifElse.type)
30 30
 			throw new AssertionError();

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantBoolExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantBoolExpression extends Expression {
17 17
 	public final boolean value;
18 18
 	
19 19
 	public ConstantBoolExpression(CodePosition position, boolean value) {
20
-		super(position, BasicTypeID.BOOL, null);
20
+		super(position, BasicTypeID.BOOL.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantByteExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantByteExpression extends Expression {
17 17
 	public final int value;
18 18
 	
19 19
 	public ConstantByteExpression(CodePosition position, int value) {
20
-		super(position, BasicTypeID.BYTE, null);
20
+		super(position, BasicTypeID.BYTE.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantCharExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantCharExpression extends Expression {
17 17
 	public final char value;
18 18
 	
19 19
 	public ConstantCharExpression(CodePosition position, char value) {
20
-		super(position, BasicTypeID.CHAR, null);
20
+		super(position, BasicTypeID.CHAR.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantDoubleExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantDoubleExpression extends Expression {
17 17
 	public final double value;
18 18
 	
19 19
 	public ConstantDoubleExpression(CodePosition position, double value) {
20
-		super(position, BasicTypeID.DOUBLE, null);
20
+		super(position, BasicTypeID.DOUBLE.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantFloatExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantFloatExpression extends Expression {
17 17
 	public final float value;
18 18
 	
19 19
 	public ConstantFloatExpression(CodePosition position, float value) {
20
-		super(position, BasicTypeID.FLOAT, null);
20
+		super(position, BasicTypeID.FLOAT.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantIntExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantIntExpression extends Expression {
17 17
 	public final int value;
18 18
 	
19 19
 	public ConstantIntExpression(CodePosition position, int value) {
20
-		super(position, BasicTypeID.INT, null);
20
+		super(position, BasicTypeID.INT.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantLongExpression.java 查看文件

@@ -18,7 +18,7 @@ public class ConstantLongExpression extends Expression {
18 18
 	public final long value;
19 19
 	
20 20
 	public ConstantLongExpression(CodePosition position, long value) {
21
-		super(position, BasicTypeID.LONG, null);
21
+		super(position, BasicTypeID.LONG.stored, null);
22 22
 		
23 23
 		this.value = value;
24 24
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantSByteExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantSByteExpression extends Expression {
17 17
 	public final byte value;
18 18
 	
19 19
 	public ConstantSByteExpression(CodePosition position, byte value) {
20
-		super(position, BasicTypeID.SBYTE, null);
20
+		super(position, BasicTypeID.SBYTE.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantShortExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantShortExpression extends Expression {
17 17
 	public final short value;
18 18
 	
19 19
 	public ConstantShortExpression(CodePosition position, short value) {
20
-		super(position, BasicTypeID.SHORT, null);
20
+		super(position, BasicTypeID.SHORT.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUIntExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantUIntExpression extends Expression {
17 17
 	public final int value;
18 18
 	
19 19
 	public ConstantUIntExpression(CodePosition position, int value) {
20
-		super(position, BasicTypeID.UINT, null);
20
+		super(position, BasicTypeID.UINT.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantULongExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantULongExpression extends Expression {
17 17
 	public final long value;
18 18
 	
19 19
 	public ConstantULongExpression(CodePosition position, long value) {
20
-		super(position, BasicTypeID.ULONG, null);
20
+		super(position, BasicTypeID.ULONG.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUShortExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantUShortExpression extends Expression {
17 17
 	public final int value;
18 18
 	
19 19
 	public ConstantUShortExpression(CodePosition position, int value) {
20
-		super(position, BasicTypeID.USHORT, null);
20
+		super(position, BasicTypeID.USHORT.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUSizeExpression.java 查看文件

@@ -17,7 +17,7 @@ public class ConstantUSizeExpression extends Expression {
17 17
 	public final long value;
18 18
 	
19 19
 	public ConstantUSizeExpression(CodePosition position, long value) {
20
-		super(position, BasicTypeID.USIZE, null);
20
+		super(position, BasicTypeID.USIZE.stored, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorSuperCallExpression.java 查看文件

@@ -9,19 +9,19 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
10 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11 11
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.StoredType;
13 13
 
14 14
 /**
15 15
  *
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class ConstructorSuperCallExpression extends Expression {
19
-	public final ITypeID objectType;
19
+	public final StoredType objectType;
20 20
 	public final FunctionalMemberRef constructor;
21 21
 	public final CallArguments arguments;
22 22
 	
23
-	public ConstructorSuperCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments) {
24
-		super(position, BasicTypeID.VOID, binaryThrow(position, constructor.getHeader().thrownType, multiThrow(position, arguments.arguments)));
23
+	public ConstructorSuperCallExpression(CodePosition position, StoredType type, FunctionalMemberRef constructor, CallArguments arguments) {
24
+		super(position, BasicTypeID.VOID.stored, binaryThrow(position, constructor.getHeader().thrownType, multiThrow(position, arguments.arguments)));
25 25
 		
26 26
 		this.objectType = type;
27 27
 		this.constructor = constructor;

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java 查看文件

@@ -9,21 +9,21 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
10 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11 11
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.StoredType;
13 13
 
14 14
 /**
15 15
  *
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class ConstructorThisCallExpression extends Expression {
19
-	public final ITypeID objectType;
19
+	public final StoredType objectType;
20 20
 	public final FunctionalMemberRef constructor;
21 21
 	public final CallArguments arguments;
22 22
 	
23
-	public ConstructorThisCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments) {
24
-		super(position, BasicTypeID.VOID, binaryThrow(position, constructor.getHeader().thrownType, multiThrow(position, arguments.arguments)));
23
+	public ConstructorThisCallExpression(CodePosition position, StoredType type, FunctionalMemberRef constructor, CallArguments arguments) {
24
+		super(position, BasicTypeID.VOID.stored, binaryThrow(position, constructor.getHeader().thrownType, multiThrow(position, arguments.arguments)));
25 25
 		
26
-		if (type instanceof BasicTypeID)
26
+		if (type.type instanceof BasicTypeID)
27 27
 			throw new IllegalArgumentException("Type cannot be basic type");
28 28
 		
29 29
 		this.objectType = type;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java 查看文件

@@ -7,14 +7,14 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
14 14
  * @author Hoofdgebruiker
15 15
  */
16 16
 public class DummyExpression extends Expression {
17
-	public DummyExpression(ITypeID type) {
17
+	public DummyExpression(StoredType type) {
18 18
 		super(CodePosition.BUILTIN, type, null);
19 19
 	}
20 20
 

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java 查看文件

@@ -10,7 +10,7 @@ import org.openzen.zenscript.codemodel.definition.EnumDefinition;
10 10
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.codemodel.type.TypeID;
14 14
 import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
15 15
 
16 16
 /**
@@ -20,14 +20,14 @@ import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
20 20
 public class EnumConstantExpression extends Expression {
21 21
 	public final EnumConstantMember value;
22 22
 	
23
-	public EnumConstantExpression(CodePosition position, ITypeID type, EnumConstantMember value) {
24
-		super(position, type, null);
23
+	public EnumConstantExpression(CodePosition position, TypeID type, EnumConstantMember value) {
24
+		super(position, type.stored(StaticStorageTag.INSTANCE), null);
25 25
 		
26 26
 		this.value = value;
27 27
 	}
28 28
 	
29 29
 	public EnumConstantExpression(CodePosition position, GlobalTypeRegistry registry, EnumDefinition type, EnumConstantMember value) {
30
-		super(position, registry.getForDefinition(type, StaticStorageTag.INSTANCE), null);
30
+		super(position, registry.getForDefinition(type).stored(StaticStorageTag.INSTANCE), null);
31 31
 		
32 32
 		this.value = value;
33 33
 	}

+ 23
- 21
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java 查看文件

@@ -7,23 +7,25 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import java.util.Collections;
9 9
 import java.util.List;
10
+import java.util.Objects;
10 11
 import java.util.function.Consumer;
11 12
 import java.util.stream.Collectors;
12 13
 import org.openzen.zencode.shared.CodePosition;
13
-import org.openzen.zencode.shared.CompileException;
14 14
 import org.openzen.zencode.shared.CompileExceptionCode;
15 15
 import org.openzen.zenscript.codemodel.FunctionHeader;
16 16
 import org.openzen.zenscript.codemodel.OperatorType;
17 17
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
18 18
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
19 19
 import org.openzen.zenscript.codemodel.type.GenericName;
20
-import org.openzen.zenscript.codemodel.type.ITypeID;
21 20
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
22 21
 import org.openzen.zenscript.codemodel.scope.TypeScope;
23 22
 import org.openzen.zenscript.codemodel.statement.Statement;
24 23
 import org.openzen.zenscript.codemodel.statement.StatementTransformer;
25 24
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
26
-import org.openzen.zenscript.codemodel.type.FunctionTypeID;
25
+import org.openzen.zenscript.codemodel.type.InvalidTypeID;
26
+import org.openzen.zenscript.codemodel.type.StoredType;
27
+import org.openzen.zenscript.codemodel.type.TypeID;
28
+import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
27 29
 
28 30
 /**
29 31
  *
@@ -33,13 +35,13 @@ public abstract class Expression implements IPartialExpression {
33 35
 	public static final Expression[] NONE = new Expression[0];
34 36
 	
35 37
 	public final CodePosition position;
36
-	public final ITypeID type;
37
-	public final ITypeID thrownType;
38
+	public final StoredType type;
39
+	public final StoredType thrownType;
38 40
 	
39
-	public Expression(CodePosition position, ITypeID type, ITypeID thrownType) {
41
+	public Expression(CodePosition position, StoredType type, StoredType thrownType) {
40 42
 		if (type == null)
41 43
 			throw new NullPointerException();
42
-		if (type == BasicTypeID.UNDETERMINED)
44
+		if (type.type == BasicTypeID.UNDETERMINED)
43 45
 			throw new IllegalArgumentException(position + ": Cannot use undetermined type as expression type");
44 46
 		
45 47
 		this.position = position;
@@ -61,7 +63,7 @@ public abstract class Expression implements IPartialExpression {
61 63
 				if (body == function.body)
62 64
 					return function;
63 65
 				
64
-				return new FunctionExpression(function.position, (FunctionTypeID)function.type, function.closure, function.header, body);
66
+				return new FunctionExpression(function.position, function.type, function.closure, function.header, body);
65 67
 			} else {
66 68
 				return expression;
67 69
 			}
@@ -71,7 +73,7 @@ public abstract class Expression implements IPartialExpression {
71 73
 	public abstract Expression normalize(TypeScope scope);
72 74
 	
73 75
 	@Override
74
-	public List<ITypeID> getAssignHints() {
76
+	public List<StoredType> getAssignHints() {
75 77
 		return Collections.singletonList(type);
76 78
 	}
77 79
 	
@@ -80,11 +82,11 @@ public abstract class Expression implements IPartialExpression {
80 82
 		return this;
81 83
 	}
82 84
 	
83
-	public Expression castExplicit(CodePosition position, TypeScope scope, ITypeID asType, boolean optional) {
85
+	public Expression castExplicit(CodePosition position, TypeScope scope, StoredType asType, boolean optional) {
84 86
 		return scope.getTypeMembers(type).castExplicit(position, this, asType, optional);
85 87
 	}
86 88
 	
87
-	public Expression castImplicit(CodePosition position, TypeScope scope, ITypeID asType) {
89
+	public Expression castImplicit(CodePosition position, TypeScope scope, StoredType asType) {
88 90
 		return scope.getTypeMembers(type).castImplicit(position, this, asType, true);
89 91
 	}
90 92
 	
@@ -99,12 +101,12 @@ public abstract class Expression implements IPartialExpression {
99 101
 	}
100 102
 	
101 103
 	@Override
102
-	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
104
+	public List<StoredType>[] predictCallTypes(TypeScope scope, List<StoredType> hints, int arguments) {
103 105
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).predictCallTypes(scope, hints, arguments);
104 106
 	}
105 107
 	
106 108
 	@Override
107
-	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<ITypeID> hints, int arguments) {
109
+	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<StoredType> hints, int arguments) {
108 110
 		return scope.getTypeMembers(type)
109 111
 				.getOrCreateGroup(OperatorType.CALL)
110 112
 				.getMethodMembers().stream()
@@ -114,12 +116,12 @@ public abstract class Expression implements IPartialExpression {
114 116
 	}
115 117
 	
116 118
 	@Override
117
-	public Expression call(CodePosition position, TypeScope scope, List<ITypeID> hints, CallArguments arguments) {
119
+	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) {
118 120
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).call(position, scope, this, arguments, false);
119 121
 	}
120 122
 	
121 123
 	@Override
122
-	public IPartialExpression getMember(CodePosition position, TypeScope scope, List<ITypeID> hints, GenericName name) {
124
+	public IPartialExpression getMember(CodePosition position, TypeScope scope, List<StoredType> hints, GenericName name) {
123 125
 		TypeMembers members = scope.getTypeMembers(type);
124 126
 		IPartialExpression result = members.getMemberExpression(position, scope, this, name, false);
125 127
 		if (result == null)
@@ -128,7 +130,7 @@ public abstract class Expression implements IPartialExpression {
128 130
 	}
129 131
 	
130 132
 	@Override
131
-	public ITypeID[] getGenericCallTypes() {
133
+	public TypeID[] getGenericCallTypes() {
132 134
 		return null;
133 135
 	}
134 136
 	
@@ -144,19 +146,19 @@ public abstract class Expression implements IPartialExpression {
144 146
 		throw new UnsupportedOperationException("Cannot evaluate this value to an enum constant!");
145 147
 	}
146 148
 	
147
-	public static ITypeID binaryThrow(CodePosition position, ITypeID left, ITypeID right) {
148
-		if (left == right)
149
+	public static StoredType binaryThrow(CodePosition position, StoredType left, StoredType right) {
150
+		if (Objects.equals(left, right))
149 151
 			return left;
150 152
 		else if (left == null)
151 153
 			return right;
152 154
 		else if (right == null)
153 155
 			return left;
154 156
 		else
155
-			throw new CompileException(position, CompileExceptionCode.DIFFERENT_EXCEPTIONS, "two different exceptions in same operation: " + left.toString() + " and " + right.toString());
157
+			return new InvalidTypeID(position, CompileExceptionCode.DIFFERENT_EXCEPTIONS, "two different exceptions in same operation: " + left.toString() + " and " + right.toString()).stored(UniqueStorageTag.INSTANCE);
156 158
 	}
157 159
 	
158
-	public static ITypeID multiThrow(CodePosition position, Expression[] expressions) {
159
-		ITypeID result = null;
160
+	public static StoredType multiThrow(CodePosition position, Expression[] expressions) {
161
+		StoredType result = null;
160 162
 		for (Expression expression : expressions)
161 163
 			result = binaryThrow(position, result, expression.thrownType);
162 164
 		return result;

+ 9
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java 查看文件

@@ -14,8 +14,9 @@ import org.openzen.zenscript.codemodel.OperatorType;
14 14
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
15 15
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16 16
 import org.openzen.zenscript.codemodel.type.GenericName;
17
-import org.openzen.zenscript.codemodel.type.ITypeID;
18
-import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
17
+import org.openzen.zenscript.codemodel.type.StoredType;
18
+import org.openzen.zenscript.codemodel.type.TypeID;
19
+import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
19 20
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
20 21
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
21 22
 import stdlib.Strings;
@@ -33,21 +34,21 @@ public class ExpressionBuilder {
33 34
 		this.scope = scope;
34 35
 	}
35 36
 	
36
-	public Expression constructNew(String typename, Expression... arguments) {
37
+	public Expression constructNew(String typename, Expression... arguments) throws CompileException {
37 38
 		String[] nameParts = Strings.split(typename, '.');
38 39
 		List<GenericName> name = new ArrayList<>();
39 40
 		for (String namePart : nameParts)
40 41
 			name.add(new GenericName(namePart));
41
-		ITypeID type = scope.getType(position, name, UniqueStorageTag.INSTANCE);
42
+		TypeID type = scope.getType(position, name);
42 43
 		if (type == null)
43 44
 			throw new CompileException(position, CompileExceptionCode.NO_SUCH_TYPE, "No such type: " + typename);
44 45
 		
45
-		return constructNew(type, arguments);
46
+		return constructNew(type.stored(UniqueStorageTag.INSTANCE), arguments);
46 47
 	}
47 48
 	
48
-	public Expression constructNew(ITypeID type, Expression... arguments) {
49
-		DefinitionMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
50
-		List<ITypeID>[] predictedTypes = constructors.predictCallTypes(scope, scope.hints, arguments.length);
49
+	public Expression constructNew(StoredType type, Expression... arguments) throws CompileException {
50
+		TypeMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
51
+		List<StoredType>[] predictedTypes = constructors.predictCallTypes(scope, scope.hints, arguments.length);
51 52
 		CallArguments compiledArguments = new CallArguments(arguments);
52 53
 		FunctionalMemberRef member = constructors.selectMethod(position, scope, compiledArguments, true, true);
53 54
 		if (member == null)

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java 查看文件

@@ -94,6 +94,10 @@ public interface ExpressionVisitor<T> {
94 94
 	
95 95
 	public T visitInterfaceCast(InterfaceCastExpression expression);
96 96
 	
97
+	public default T visitInvalid(InvalidExpression expression) {
98
+		throw new RuntimeException("Invalid expression");
99
+	}
100
+	
97 101
 	public T visitIs(IsExpression expression);
98 102
 	
99 103
 	public T visitMakeConst(MakeConstExpression expression);

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitorWithContext.java 查看文件

@@ -94,6 +94,8 @@ public interface ExpressionVisitorWithContext<C, R> {
94 94
 	
95 95
 	public R visitInterfaceCast(C context, InterfaceCastExpression expression);
96 96
 	
97
+	public R visitInvalid(C context, InvalidExpression expression);
98
+	
97 99
 	public R visitIs(C context, IsExpression expression);
98 100
 	
99 101
 	public R visitMakeConst(C context, MakeConstExpression expression);

+ 4
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/FunctionExpression.java 查看文件

@@ -18,6 +18,7 @@ import org.openzen.zenscript.codemodel.statement.LoopStatement;
18 18
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
19 19
 import org.openzen.zenscript.codemodel.statement.Statement;
20 20
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
21
+import org.openzen.zenscript.codemodel.type.StoredType;
21 22
 
22 23
 /**
23 24
  *
@@ -30,7 +31,7 @@ public class FunctionExpression extends Expression {
30 31
 	
31 32
 	public FunctionExpression(
32 33
 			CodePosition position,
33
-			FunctionTypeID type,
34
+			StoredType type,
34 35
 			LambdaClosure closure,
35 36
 			FunctionHeader header,
36 37
 			Statement body) {
@@ -54,7 +55,7 @@ public class FunctionExpression extends Expression {
54 55
 	@Override
55 56
 	public FunctionExpression transform(ExpressionTransformer transformer) {
56 57
 		Statement tBody = body.transform(transformer, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
57
-		return tBody == body ? this : new FunctionExpression(position, (FunctionTypeID)type, closure, header, tBody);
58
+		return tBody == body ? this : new FunctionExpression(position, type, closure, header, tBody);
58 59
 	}
59 60
 	
60 61
 	@Override
@@ -83,7 +84,7 @@ public class FunctionExpression extends Expression {
83 84
 
84 85
 	@Override
85 86
 	public Expression normalize(TypeScope scope) {
86
-		return new FunctionExpression(position, (FunctionTypeID)type, closure, header, body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class)));
87
+		return new FunctionExpression(position, type, closure, header, body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class)));
87 88
 	}
88 89
 	
89 90
 	private static class ReturnExpressionTransformer implements ExpressionTransformer {

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java 查看文件

@@ -11,7 +11,7 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 12
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
13 13
 import org.openzen.zenscript.codemodel.scope.TypeScope;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
14
+import org.openzen.zenscript.codemodel.type.StoredType;
15 15
 
16 16
 /**
17 17
  *
@@ -29,7 +29,7 @@ public class GetFieldExpression extends Expression {
29 29
 	}
30 30
 	
31 31
 	@Override
32
-	public List<ITypeID> getAssignHints() {
32
+	public List<StoredType> getAssignHints() {
33 33
 		return Collections.singletonList(type);
34 34
 	}
35 35
 	

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java 查看文件

@@ -11,7 +11,7 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 12
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
13 13
 import org.openzen.zenscript.codemodel.scope.TypeScope;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
14
+import org.openzen.zenscript.codemodel.type.StoredType;
15 15
 
16 16
 /**
17 17
  *
@@ -27,7 +27,7 @@ public class GetStaticFieldExpression extends Expression {
27 27
 	}
28 28
 	
29 29
 	@Override
30
-	public List<ITypeID> getAssignHints() {
30
+	public List<StoredType> getAssignHints() {
31 31
 		return Collections.singletonList(field.getType());
32 32
 	}
33 33
 	

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InterfaceCastExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class InterfaceCastExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public InterfaceCastExpression(CodePosition position, Expression value, ITypeID toType) {
19
+	public InterfaceCastExpression(CodePosition position, Expression value, StoredType toType) {
20 20
 		super(position, toType, value.thrownType);
21 21
 		
22 22
 		this.value = value;

+ 57
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InvalidExpression.java 查看文件

@@ -0,0 +1,57 @@
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.expression;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.CompileException;
10
+import org.openzen.zencode.shared.CompileExceptionCode;
11
+import org.openzen.zenscript.codemodel.scope.TypeScope;
12
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
13
+import org.openzen.zenscript.codemodel.type.StoredType;
14
+
15
+/**
16
+ *
17
+ * @author Hoofdgebruiker
18
+ */
19
+public class InvalidExpression extends Expression {
20
+	public final CompileExceptionCode code;
21
+	public final String message;
22
+	
23
+	public InvalidExpression(CodePosition position, StoredType type, CompileExceptionCode code, String message) {
24
+		super(position, type, null);
25
+		
26
+		this.code = code;
27
+		this.message = message;
28
+	}
29
+	
30
+	public InvalidExpression(CodePosition position, CompileExceptionCode code, String message) {
31
+		this(position, BasicTypeID.UNDETERMINED.stored, code, message);
32
+	}
33
+	
34
+	public InvalidExpression(StoredType type, CompileException cause) {
35
+		this(cause.position, type, cause.code, cause.getMessage());
36
+	}
37
+
38
+	@Override
39
+	public <T> T accept(ExpressionVisitor<T> visitor) {
40
+		return visitor.visitInvalid(this);
41
+	}
42
+
43
+	@Override
44
+	public <C, R> R accept(C context, ExpressionVisitorWithContext<C, R> visitor) {
45
+		return visitor.visitInvalid(context, this);
46
+	}
47
+
48
+	@Override
49
+	public Expression transform(ExpressionTransformer transformer) {
50
+		return this;
51
+	}
52
+
53
+	@Override
54
+	public Expression normalize(TypeScope scope) {
55
+		return this;
56
+	}
57
+}

+ 6
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/IsExpression.java 查看文件

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.expression;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
11
+import org.openzen.zenscript.codemodel.type.TypeID;
12 12
 
13 13
 /**
14 14
  *
@@ -16,10 +16,10 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
  */
17 17
 public class IsExpression extends Expression {
18 18
 	public final Expression value;
19
-	public final ITypeID isType;
19
+	public final TypeID isType;
20 20
 	
21
-	public IsExpression(CodePosition position, Expression value, ITypeID type) {
22
-		super(position, BasicTypeID.BOOL, value.thrownType);
21
+	public IsExpression(CodePosition position, Expression value, TypeID type) {
22
+		super(position, BasicTypeID.BOOL.stored, value.thrownType);
23 23
 		
24 24
 		this.value = value;
25 25
 		this.isType = type;
@@ -38,11 +38,11 @@ public class IsExpression extends Expression {
38 38
 	@Override
39 39
 	public Expression transform(ExpressionTransformer transformer) {
40 40
 		Expression tValue = value.transform(transformer);
41
-		return tValue == value ? this : new IsExpression(position, tValue, type);
41
+		return tValue == value ? this : new IsExpression(position, tValue, isType);
42 42
 	}
43 43
 
44 44
 	@Override
45 45
 	public Expression normalize(TypeScope scope) {
46
-		return new IsExpression(position, value.normalize(scope), type.getNormalized());
46
+		return new IsExpression(position, value.normalize(scope), isType.getNormalizedUnstored());
47 47
 	}
48 48
 }

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MakeConstExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class MakeConstExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public MakeConstExpression(CodePosition position, Expression value, ITypeID constType) {
19
+	public MakeConstExpression(CodePosition position, Expression value, StoredType constType) {
20 20
 		super(position, constType, value.thrownType);
21 21
 		
22 22
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MapExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -21,7 +21,7 @@ public class MapExpression extends Expression {
21 21
 			CodePosition position,
22 22
 			Expression[] keys,
23 23
 			Expression[] values,
24
-			ITypeID type) {
24
+			StoredType type) {
25 25
 		super(position, type, binaryThrow(position, multiThrow(position, keys), multiThrow(position, values)));
26 26
 		
27 27
 		this.keys = keys;

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MatchExpression.java 查看文件

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.statement.SwitchCase;
17 17
 import org.openzen.zenscript.codemodel.statement.SwitchStatement;
18 18
 import org.openzen.zenscript.codemodel.statement.VarStatement;
19 19
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
20
-import org.openzen.zenscript.codemodel.type.ITypeID;
20
+import org.openzen.zenscript.codemodel.type.StoredType;
21 21
 
22 22
 /**
23 23
  *
@@ -27,7 +27,7 @@ public class MatchExpression extends Expression {
27 27
 	public final Expression value;
28 28
 	public final Case[] cases;
29 29
 	
30
-	public MatchExpression(CodePosition position, Expression value, ITypeID type, Case[] cases) {
30
+	public MatchExpression(CodePosition position, Expression value, StoredType type, Case[] cases) {
31 31
 		super(position, type, binaryThrow(position, value.thrownType, getThrownType(position, cases)));
32 32
 		
33 33
 		this.value = value;
@@ -88,7 +88,7 @@ public class MatchExpression extends Expression {
88 88
 				hasDefault = true;
89 89
 		}
90 90
 		if (!hasDefault) {
91
-			Statement defaultCase = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID, new ConstantStringExpression(position, "Missing case")));
91
+			Statement defaultCase = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID.stored, new ConstantStringExpression(position, "Missing case")));
92 92
 			switchStatement.cases.add(new SwitchCase(null, new Statement[] { defaultCase }));
93 93
 		}
94 94
 		return new SwitchedMatch(result, switchStatement);
@@ -123,11 +123,11 @@ public class MatchExpression extends Expression {
123 123
 		}
124 124
 	}
125 125
 	
126
-	private static ITypeID getThrownType(CodePosition position, Case[] cases) {
126
+	private static StoredType getThrownType(CodePosition position, Case[] cases) {
127 127
 		if (cases.length == 0)
128 128
 			return null;
129 129
 		
130
-		ITypeID result = cases[0].value.thrownType;
130
+		StoredType result = cases[0].value.thrownType;
131 131
 		for (int i = 1; i < cases.length; i++)
132 132
 			result = binaryThrow(position, result, cases[i].value.thrownType);
133 133
 		

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java 查看文件

@@ -9,7 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.StoredType;
13 13
 
14 14
 /**
15 15
  *
@@ -22,7 +22,7 @@ public class NewExpression extends Expression {
22 22
 	
23 23
 	public NewExpression(
24 24
 			CodePosition position,
25
-			ITypeID type,
25
+			StoredType type,
26 26
 			FunctionalMemberRef constructor,
27 27
 			CallArguments arguments)
28 28
 	{
@@ -31,7 +31,7 @@ public class NewExpression extends Expression {
31 31
 	
32 32
 	public NewExpression(
33 33
 			CodePosition position,
34
-			ITypeID type,
34
+			StoredType type,
35 35
 			FunctionalMemberRef constructor,
36 36
 			CallArguments arguments,
37 37
 			FunctionHeader instancedHeader)

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NullExpression.java 查看文件

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.expression;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
12 12
 
13 13
 /**
14 14
  *
@@ -16,10 +16,10 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
  */
17 17
 public class NullExpression extends Expression {
18 18
 	public NullExpression(CodePosition position) {
19
-		super(position, BasicTypeID.NULL, null);
19
+		super(position, BasicTypeID.NULL.stored, null);
20 20
 	}
21 21
 	
22
-	public NullExpression(CodePosition position, ITypeID optionalType) {
22
+	public NullExpression(CodePosition position, StoredType optionalType) {
23 23
 		super(position, optionalType, null);
24 24
 	}
25 25
 

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/OrOrExpression.java 查看文件

@@ -18,7 +18,7 @@ public class OrOrExpression extends Expression {
18 18
 	public final Expression right;
19 19
 	
20 20
 	public OrOrExpression(CodePosition position, Expression left, Expression right) {
21
-		super(position, BasicTypeID.BOOL, binaryThrow(position, left.thrownType, right.thrownType));
21
+		super(position, BasicTypeID.BOOL.stored, binaryThrow(position, left.thrownType, right.thrownType));
22 22
 		
23 23
 		this.left = left;
24 24
 		this.right = right;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class PanicExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public PanicExpression(CodePosition position, ITypeID type, Expression value) {
19
+	public PanicExpression(CodePosition position, StoredType type, Expression value) {
20 20
 		super(position, type, null);
21 21
 		
22 22
 		this.value = value;

+ 7
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/RangeExpression.java 查看文件

@@ -7,8 +7,8 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
11 10
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
12 12
 
13 13
 /**
14 14
  *
@@ -18,14 +18,14 @@ public class RangeExpression extends Expression {
18 18
 	public final Expression from;
19 19
 	public final Expression to;
20 20
 	
21
-	public RangeExpression(CodePosition position, RangeTypeID type, Expression from, Expression to) {
21
+	public RangeExpression(CodePosition position, StoredType type, Expression from, Expression to) {
22 22
 		super(position, type, binaryThrow(position, from.thrownType, to.thrownType));
23 23
 	
24 24
 		this.from = from;
25 25
 		this.to = to;
26 26
 	}
27 27
 	
28
-	private RangeExpression(CodePosition position, ITypeID type, Expression from, Expression to, ITypeID thrownType) {
28
+	private RangeExpression(CodePosition position, StoredType type, Expression from, Expression to, StoredType thrownType) {
29 29
 		super(position, type, thrownType);
30 30
 		
31 31
 		this.from = from;
@@ -51,11 +51,11 @@ public class RangeExpression extends Expression {
51 51
 
52 52
 	@Override
53 53
 	public Expression normalize(TypeScope scope) {
54
-		RangeTypeID rangeType = (RangeTypeID)type;
54
+		StoredType baseType = ((RangeTypeID)type.type).baseType;
55 55
 		return new RangeExpression(
56 56
 				position,
57
-				rangeType,
58
-				from.normalize(scope).castImplicit(position, scope, rangeType.baseType),
59
-				to.normalize(scope).castImplicit(position, scope, rangeType.baseType));
57
+				type.getNormalized(),
58
+				from.normalize(scope).castImplicit(position, scope, baseType),
59
+				to.normalize(scope).castImplicit(position, scope, baseType));
60 60
 	}
61 61
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SameObjectExpression.java 查看文件

@@ -19,7 +19,7 @@ public class SameObjectExpression extends Expression {
19 19
 	public final boolean inverted;
20 20
 	
21 21
 	public SameObjectExpression(CodePosition position, Expression left, Expression right, boolean inverted) {
22
-		super(position, BasicTypeID.BOOL, binaryThrow(position, left.thrownType, right.thrownType));
22
+		super(position, BasicTypeID.BOOL.stored, binaryThrow(position, left.thrownType, right.thrownType));
23 23
 		
24 24
 		this.left = left;
25 25
 		this.right = right;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StorageCastExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class StorageCastExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public StorageCastExpression(CodePosition position, Expression value, ITypeID toType) {
19
+	public StorageCastExpression(CodePosition position, Expression value, StoredType toType) {
20 20
 		super(position, toType, value.thrownType);
21 21
 		
22 22
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SupertypeCastExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  * Using to cast a class type to a base type.
@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
17 17
 public class SupertypeCastExpression extends Expression {
18 18
 	public final Expression value;
19 19
 	
20
-	public SupertypeCastExpression(CodePosition position, Expression value, ITypeID type) {
20
+	public SupertypeCastExpression(CodePosition position, Expression value, StoredType type) {
21 21
 		super(position, type, value.thrownType);
22 22
 		
23 23
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThisExpression.java 查看文件

@@ -8,14 +8,14 @@ package org.openzen.zenscript.codemodel.expression;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
10 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
11
+import org.openzen.zenscript.codemodel.type.StoredType;
12 12
 
13 13
 /**
14 14
  *
15 15
  * @author Hoofdgebruiker
16 16
  */
17 17
 public class ThisExpression extends Expression {
18
-	public ThisExpression(CodePosition position, ITypeID type) {
18
+	public ThisExpression(CodePosition position, StoredType type) {
19 19
 		super(position, type, null);
20 20
 	}
21 21
 	

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class ThrowExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public ThrowExpression(CodePosition position, ITypeID type, Expression value) {
19
+	public ThrowExpression(CodePosition position, StoredType type, Expression value) {
20 20
 		super(position, type, value.type);
21 21
 		
22 22
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryConvertExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class TryConvertExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public TryConvertExpression(CodePosition position, ITypeID type, Expression value) {
19
+	public TryConvertExpression(CodePosition position, StoredType type, Expression value) {
20 20
 		super(position, type, null);
21 21
 		
22 22
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsExceptionExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class TryRethrowAsExceptionExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public TryRethrowAsExceptionExpression(CodePosition position, ITypeID type, Expression value, ITypeID thrownType) {
19
+	public TryRethrowAsExceptionExpression(CodePosition position, StoredType type, Expression value, StoredType thrownType) {
20 20
 		super(position, type, thrownType);
21 21
 		
22 22
 		this.value = value;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsResultExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class TryRethrowAsResultExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public TryRethrowAsResultExpression(CodePosition position, ITypeID type, Expression value) {
19
+	public TryRethrowAsResultExpression(CodePosition position, StoredType type, Expression value) {
20 20
 		super(position, type, null);
21 21
 		
22 22
 		this.value = value;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java 查看文件

@@ -9,7 +9,7 @@ import java.util.List;
9 9
 import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.codemodel.type.StoredType;
13 13
 
14 14
 /**
15 15
  *
@@ -19,11 +19,11 @@ public class VariantValueExpression extends Expression {
19 19
 	public final VariantOptionRef option;
20 20
 	public final Expression[] arguments;
21 21
 	
22
-	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantOptionRef option) {
22
+	public VariantValueExpression(CodePosition position, StoredType variantType, VariantOptionRef option) {
23 23
 		this(position, variantType, option, Expression.NONE);
24 24
 	}
25 25
 	
26
-	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantOptionRef option, Expression[] arguments) {
26
+	public VariantValueExpression(CodePosition position, StoredType variantType, VariantOptionRef option, Expression[] arguments) {
27 27
 		super(position, variantType, multiThrow(position, arguments));
28 28
 		
29 29
 		this.option = option;
@@ -35,7 +35,7 @@ public class VariantValueExpression extends Expression {
35 35
 	}
36 36
 	
37 37
 	@Override
38
-	public Expression call(CodePosition position, TypeScope scope, List<ITypeID> hints, CallArguments arguments) {
38
+	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) {
39 39
 		if (arguments != null)
40 40
 			return super.call(position, scope, hints, arguments);
41 41
 		

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/WrapOptionalExpression.java 查看文件

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.StoredType;
11 11
 
12 12
 /**
13 13
  *
@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 public class WrapOptionalExpression extends Expression {
17 17
 	public final Expression value;
18 18
 	
19
-	public WrapOptionalExpression(CodePosition position, Expression value, ITypeID optionalType) {
19
+	public WrapOptionalExpression(CodePosition position, Expression value, StoredType optionalType) {
20 20
 		super(position, optionalType, value.thrownType);
21 21
 		
22 22
 		if (value.type.isOptional())

+ 7
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java 查看文件

@@ -7,17 +7,18 @@ package org.openzen.zenscript.codemodel.generic;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
10
-import org.openzen.zenscript.codemodel.type.ITypeID;
11 10
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11
+import org.openzen.zenscript.codemodel.type.TypeID;
12
+import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
12 13
 
13 14
 /**
14 15
  *
15 16
  * @author Hoofdgebruiker
16 17
  */
17 18
 public class ParameterSuperBound extends TypeParameterBound {
18
-	public final ITypeID type;
19
+	public final TypeID type;
19 20
 	
20
-	public ParameterSuperBound(ITypeID type) {
21
+	public ParameterSuperBound(TypeID type) {
21 22
 		this.type = type;
22 23
 	}
23 24
 	
@@ -32,13 +33,13 @@ public class ParameterSuperBound extends TypeParameterBound {
32 33
 	}
33 34
 
34 35
 	@Override
35
-	public boolean matches(LocalMemberCache cache, ITypeID type) {
36
-		return cache.get(this.type).extendsOrImplements(type);
36
+	public boolean matches(LocalMemberCache cache, TypeID type) {
37
+		return cache.get(this.type.stored(BorrowStorageTag.THIS)).extendsOrImplements(type);
37 38
 	}
38 39
 
39 40
 	@Override
40 41
 	public TypeParameterBound instance(GenericMapper mapper) {
41
-		ITypeID translated = type.instance(mapper);
42
+		TypeID translated = type.instanceUnstored(mapper);
42 43
 		if (translated == type)
43 44
 			return this;
44 45
 		

+ 11
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java 查看文件

@@ -8,9 +8,10 @@ package org.openzen.zenscript.codemodel.generic;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
12 11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
13 12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
13
+import org.openzen.zenscript.codemodel.type.TypeID;
14
+import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
14 15
 
15 16
 /**
16 17
  *
@@ -18,9 +19,9 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
18 19
  */
19 20
 public class ParameterTypeBound extends TypeParameterBound {
20 21
 	public final CodePosition position;
21
-	public final ITypeID type;
22
+	public final TypeID type;
22 23
 	
23
-	public ParameterTypeBound(CodePosition position, ITypeID type) {
24
+	public ParameterTypeBound(CodePosition position, TypeID type) {
24 25
 		this.position = position;
25 26
 		this.type = type;
26 27
 	}
@@ -31,18 +32,20 @@ public class ParameterTypeBound extends TypeParameterBound {
31 32
 	}
32 33
 
33 34
 	@Override
34
-	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
35
-		cache.get(this.type).copyMembersTo(position, type, TypeMemberPriority.FROM_TYPE_BOUNDS);
35
+	public void registerMembers(LocalMemberCache cache, TypeMembers members) {
36
+		cache.get(this.type.stored(members.type.storage))
37
+				.copyMembersTo(position, members, TypeMemberPriority.FROM_TYPE_BOUNDS);
36 38
 	}
37 39
 
38 40
 	@Override
39
-	public boolean matches(LocalMemberCache cache, ITypeID type) {
40
-		return cache.get(type).extendsOrImplements(this.type);
41
+	public boolean matches(LocalMemberCache cache, TypeID type) {
42
+		return cache.get(type.stored(BorrowStorageTag.THIS))
43
+				.extendsOrImplements(this.type);
41 44
 	}
42 45
 
43 46
 	@Override
44 47
 	public TypeParameterBound instance(GenericMapper mapper) {
45
-		return new ParameterTypeBound(position, type.instance(mapper));
48
+		return new ParameterTypeBound(position, type.instanceUnstored(mapper));
46 49
 	}
47 50
 
48 51
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java 查看文件

@@ -11,7 +11,7 @@ import java.util.Map;
11 11
 import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zencode.shared.Taggable;
13 13
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
14
+import org.openzen.zenscript.codemodel.type.TypeID;
15 15
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
16 16
 
17 17
 /**
@@ -48,7 +48,7 @@ public class TypeParameter extends Taggable {
48 48
 		return false;
49 49
 	}
50 50
 	
51
-	public boolean matches(LocalMemberCache cache, ITypeID type) {
51
+	public boolean matches(LocalMemberCache cache, TypeID type) {
52 52
 		for (TypeParameterBound bound : bounds) {
53 53
 			if (!bound.matches(cache, type))
54 54
 				return false;
@@ -57,7 +57,7 @@ public class TypeParameter extends Taggable {
57 57
 		return true;
58 58
 	}
59 59
 	
60
-	public TypeParameter withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
60
+	public TypeParameter withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, TypeID> arguments) {
61 61
 		// TODO: think about this...
62 62
 		//List<GenericParameterBound> bounds = new ArrayList<>();
63 63
 		//for (GenericParameterBound bound : this.bounds)

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameterBound.java 查看文件

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.generic;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.GenericMapper;
9
-import org.openzen.zenscript.codemodel.type.ITypeID;
9
+import org.openzen.zenscript.codemodel.type.TypeID;
10 10
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11 11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
12 12
 
@@ -23,7 +23,7 @@ public abstract class TypeParameterBound {
23 23
 	
24 24
 	public abstract void registerMembers(LocalMemberCache cache, TypeMembers type);
25 25
 	
26
-	public abstract boolean matches(LocalMemberCache cache, ITypeID type);
26
+	public abstract boolean matches(LocalMemberCache cache, TypeID type);
27 27
 	
28 28
 	public abstract TypeParameterBound instance(GenericMapper mapper);
29 29
 	

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java 查看文件

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
14 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
-import org.openzen.zenscript.codemodel.type.ITypeID;
17
+import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
20 20
 
@@ -23,14 +23,14 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
23 23
  * @author Hoofdgebruiker
24 24
  */
25 25
 public class CasterMember extends FunctionalMember {
26
-	public ITypeID toType;
26
+	public StoredType toType;
27 27
 	public CasterMemberRef overrides;
28 28
 	
29 29
 	public CasterMember(
30 30
 			CodePosition position,
31 31
 			HighLevelDefinition definition,
32 32
 			int modifiers,
33
-			ITypeID toType,
33
+			StoredType toType,
34 34
 			BuiltinID builtin)
35 35
 	{
36 36
 		super(position, definition, modifiers, new FunctionHeader(toType), builtin);
@@ -50,7 +50,7 @@ public class CasterMember extends FunctionalMember {
50 50
 
51 51
 	@Override
52 52
 	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
53
-		type.addCaster(new CasterMemberRef(this, type.type, mapper == null ? toType : mapper.map(toType)), priority);
53
+		type.addCaster(new CasterMemberRef(this, type.type, mapper == null ? toType : toType.instance(mapper)), priority);
54 54
 	}
55 55
 
56 56
 	@Override
@@ -58,7 +58,7 @@ public class CasterMember extends FunctionalMember {
58 58
 		return "caster to " + toType.toString();
59 59
 	}
60 60
 	
61
-	public ITypeID getTargetType() {
61
+	public StoredType getTargetType() {
62 62
 		return toType;
63 63
 	}
64 64
 	

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java 查看文件

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.expression.Expression;
13 13
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.scope.TypeScope;
16
-import org.openzen.zenscript.codemodel.type.ITypeID;
16
+import org.openzen.zenscript.codemodel.type.StoredType;
17 17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -26,7 +26,7 @@ public class ConstMember extends PropertyMember {
26 26
 	public final String name;
27 27
 	public Expression value;
28 28
 	
29
-	public ConstMember(CodePosition position, HighLevelDefinition definition, int modifiers, String name, ITypeID type, BuiltinID builtin) {
29
+	public ConstMember(CodePosition position, HighLevelDefinition definition, int modifiers, String name, StoredType type, BuiltinID builtin) {
30 30
 		super(position, definition, modifiers, type, builtin);
31 31
 		
32 32
 		this.name = name;
@@ -69,7 +69,7 @@ public class ConstMember extends PropertyMember {
69 69
 	}
70 70
 
71 71
 	@Override
72
-	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
72
+	public DefinitionMemberRef ref(StoredType type, GenericMapper mapper) {
73 73
 		return new ConstMemberRef(type, this, mapper);
74 74
 	}
75 75
 	

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java 查看文件

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

+ 1
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java 查看文件

@@ -42,6 +42,7 @@ public abstract class DefinitionMember extends Taggable implements IDefinitionMe
42 42
 		return definition;
43 43
 	}
44 44
 	
45
+	@Override
45 46
 	public MemberAnnotation[] getAnnotations() {
46 47
 		return annotations;
47 48
 	}

+ 9
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java 查看文件

@@ -21,7 +21,8 @@ import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
21 21
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
22 22
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
23 23
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
24
-import org.openzen.zenscript.codemodel.type.ITypeID;
24
+import org.openzen.zenscript.codemodel.type.StoredType;
25
+import org.openzen.zenscript.codemodel.type.TypeID;
25 26
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
26 27
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
27 28
 
@@ -43,8 +44,8 @@ public class FieldMember extends PropertyMember {
43 44
 			HighLevelDefinition definition,
44 45
 			int modifiers,
45 46
 			String name,
46
-			ITypeID thisType,
47
-			ITypeID type,
47
+			StoredType thisType,
48
+			StoredType type,
48 49
 			GlobalTypeRegistry registry,
49 50
 			int autoGetterAccess,
50 51
 			int autoSetterAccess,
@@ -56,11 +57,11 @@ public class FieldMember extends PropertyMember {
56 57
 		this.autoGetterAccess = autoGetterAccess;
57 58
 		this.autoSetterAccess = autoSetterAccess;
58 59
 		
59
-		ITypeID[] parameters = null;
60
+		TypeID[] parameters = null;
60 61
 		if (definition.typeParameters != null) {
61
-			parameters = new ITypeID[definition.typeParameters.length];
62
+			parameters = new TypeID[definition.typeParameters.length];
62 63
 			for (int i = 0; i < parameters.length; i++)
63
-				parameters[i] = registry.getGeneric(definition.typeParameters[i], null);
64
+				parameters[i] = registry.getGeneric(definition.typeParameters[i]);
64 65
 		}
65 66
 		
66 67
 		if (autoGetterAccess != 0) {
@@ -89,7 +90,7 @@ public class FieldMember extends PropertyMember {
89 90
 			HighLevelDefinition definition,
90 91
 			int modifiers,
91 92
 			String name,
92
-			ITypeID type,
93
+			StoredType type,
93 94
 			int autoGetterAccess,
94 95
 			int autoSetterAccess,
95 96
 			GetterMember autoGetter,
@@ -160,7 +161,7 @@ public class FieldMember extends PropertyMember {
160 161
 	}
161 162
 
162 163
 	@Override
163
-	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
164
+	public DefinitionMemberRef ref(StoredType type, GenericMapper mapper) {
164 165
 		return new FieldMemberRef(type, this, mapper);
165 166
 	}
166 167
 	

+ 6
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java 查看文件

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
15 15
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16 16
 import org.openzen.zenscript.codemodel.statement.Statement;
17
-import org.openzen.zenscript.codemodel.type.ITypeID;
17
+import org.openzen.zenscript.codemodel.type.StoredType;
18 18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
19 19
 
20 20
 /**
@@ -46,7 +46,11 @@ public abstract class FunctionalMember extends DefinitionMember {
46 46
 	
47 47
 	public abstract FunctionalKind getKind();
48 48
 	
49
-	public FunctionalMemberRef ref(ITypeID type, GenericMapper mapper) {
49
+	public FunctionalMemberRef ref(StoredType type) {
50
+		return new FunctionalMemberRef(this, type, null);
51
+	}
52
+	
53
+	public FunctionalMemberRef ref(StoredType type, GenericMapper mapper) {
50 54
 		return new FunctionalMemberRef(this, type, mapper);
51 55
 	}
52 56
 	

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java 查看文件

@@ -17,7 +17,7 @@ import org.openzen.zenscript.codemodel.statement.LoopStatement;
17 17
 import org.openzen.zenscript.codemodel.statement.Statement;
18 18
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
19 19
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
20
-import org.openzen.zenscript.codemodel.type.ITypeID;
20
+import org.openzen.zenscript.codemodel.type.StoredType;
21 21
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
22 22
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
23 23
 
@@ -35,7 +35,7 @@ public class GetterMember extends PropertyMember {
35 35
 			HighLevelDefinition definition,
36 36
 			int modifiers,
37 37
 			String name,
38
-			ITypeID type,
38
+			StoredType type,
39 39
 			BuiltinID builtin) {
40 40
 		super(position, definition, modifiers, type, builtin);
41 41
 		
@@ -45,7 +45,7 @@ public class GetterMember extends PropertyMember {
45 45
 	public void setBody(Statement body) {
46 46
 		this.body = body;
47 47
 		
48
-		if (type == BasicTypeID.UNDETERMINED)
48
+		if (type.type == BasicTypeID.UNDETERMINED)
49 49
 			type = body.getReturnType();
50 50
 	}
51 51
 	
@@ -88,12 +88,12 @@ public class GetterMember extends PropertyMember {
88 88
 	public void setOverrides(GetterMemberRef override) {
89 89
 		this.overrides = override;
90 90
 		
91
-		if (type == BasicTypeID.UNDETERMINED)
91
+		if (type.type == BasicTypeID.UNDETERMINED)
92 92
 			type = override.getType();
93 93
 	}
94 94
 
95 95
 	@Override
96
-	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
96
+	public DefinitionMemberRef ref(StoredType type, GenericMapper mapper) {
97 97
 		return new GetterMemberRef(type, this, mapper);
98 98
 	}
99 99
 	

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java 查看文件

@@ -12,7 +12,7 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
13 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
15
-import org.openzen.zenscript.codemodel.type.ITypeID;
15
+import org.openzen.zenscript.codemodel.type.StoredType;
16 16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
17 17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
18 18
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -52,7 +52,7 @@ public interface IDefinitionMember {
52 52
 	
53 53
 	boolean isAbstract();
54 54
 	
55
-	DefinitionMemberRef ref(ITypeID type, GenericMapper mapper);
55
+	DefinitionMemberRef ref(StoredType type, GenericMapper mapper);
56 56
 	
57 57
 	FunctionHeader getHeader();
58 58
 }

+ 0
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java 查看文件


部分文件因为文件数量过多而无法显示

正在加载...
取消
保存