Bladeren bron

Merge remote-tracking branch 'Stan/development' into development

kindlich 6 jaren geleden
bovenliggende
commit
17cb528827
Geen bekende sleutel gevonden voor deze handtekening in de database
100 gewijzigde bestanden met toevoegingen van 1848 en 1670 verwijderingen
  1. 22
    24
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java
  2. 1
    1
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/SwitchValueFormatter.java
  3. 0
    11
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ZenScriptOperator.java
  4. 4
    4
      CodeFormatterShared/src/main/java/org/openzen/zenscript/formattershared/ExpressionString.java
  5. 7
    3
      CodeFormatterShared/src/main/java/org/openzen/zenscript/formattershared/FormattableOperator.java
  6. 43
    22
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  7. 7
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java
  8. 52
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java
  9. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  10. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java
  11. 6
    10
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java
  12. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallExpression.java
  13. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java
  14. 4
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java
  15. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java
  16. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstExpression.java
  17. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java
  18. 3
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  19. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java
  20. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java
  21. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java
  22. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java
  23. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java
  24. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PostCallExpression.java
  25. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFieldExpression.java
  26. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetStaticFieldExpression.java
  27. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetterExpression.java
  28. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticGetterExpression.java
  29. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticSetterExpression.java
  30. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java
  31. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/switchvalue/VariantOptionSwitchValue.java
  32. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/GenericParameterBound.java
  33. 8
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java
  34. 8
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  35. 11
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java
  36. 8
    16
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java
  37. 11
    30
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java
  38. 4
    10
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  39. 9
    18
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java
  40. 4
    13
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java
  41. 9
    12
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DestructorMember.java
  42. 6
    19
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  43. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalKind.java
  44. 9
    25
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  45. 9
    27
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  46. 2
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  47. 8
    17
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  48. 5
    13
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java
  49. 0
    77
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InstancedInnerDefinitionMember.java
  50. 8
    17
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MethodMember.java
  51. 8
    17
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/OperatorMember.java
  52. 9
    16
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/SetterMember.java
  53. 2
    10
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java
  54. 0
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/TranslatedOperatorMember.java
  55. 4
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java
  56. 4
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java
  57. 4
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java
  58. 4
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java
  59. 4
    11
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java
  60. 50
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/CasterMemberRef.java
  61. 39
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java
  62. 20
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/DefinitionMemberRef.java
  63. 47
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FieldMemberRef.java
  64. 95
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java
  65. 54
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/GetterMemberRef.java
  66. 39
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ImplementationMemberRef.java
  67. 43
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/IteratorMemberRef.java
  68. 43
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/SetterMemberRef.java
  69. 33
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/TranslatedOperatorMemberRef.java
  70. 35
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/VariantOptionRef.java
  71. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java
  72. 4
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  73. 4
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java
  74. 3
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ImplementationScope.java
  75. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/ForeachStatement.java
  76. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java
  77. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java
  78. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  79. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ConstTypeID.java
  80. 6
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  81. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java
  82. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java
  83. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java
  84. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ITypeID.java
  85. 4
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/IteratorTypeID.java
  86. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java
  87. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java
  88. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/BuiltinID.java
  89. 42
    43
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java
  90. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMember.java
  91. 772
    817
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  92. 64
    74
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  93. 4
    7
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java
  94. 0
    4
      Constructor/libraries/collections/module.json
  95. 0
    11
      Constructor/libraries/collections/src/HashSet.zs
  96. 0
    73
      Constructor/libraries/collections/src/LinkedList.zs
  97. 0
    5
      Constructor/libraries/collections/src/NoSuchElementException.zs
  98. 0
    7
      Constructor/libraries/collections/src/Queue.zs
  99. 0
    12
      Constructor/libraries/collections/src/Set.zs
  100. 0
    0
      Constructor/libraries/collections/src/Stack.zs

+ 22
- 24
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java Bestand weergeven

@@ -74,7 +74,6 @@ import org.openzen.zenscript.codemodel.expression.TryRethrowAsExceptionExpressio
74 74
 import org.openzen.zenscript.codemodel.expression.TryRethrowAsResultExpression;
75 75
 import org.openzen.zenscript.codemodel.expression.VariantValueExpression;
76 76
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
77
-import org.openzen.zenscript.codemodel.member.OperatorMember;
78 77
 import org.openzen.zenscript.shared.StringUtils;
79 78
 
80 79
 /**
@@ -121,9 +120,8 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
121 120
 
122 121
 	@Override
123 122
 	public ExpressionString visitCall(CallExpression expression) {
124
-		if (expression.member instanceof OperatorMember) {
125
-			OperatorMember operator = (OperatorMember) expression.member;
126
-			switch (operator.operator) {
123
+		if (expression.member.isOperator()) {
124
+			switch (expression.member.getOperator()) {
127 125
 				case NOT:
128 126
 					return unaryPrefix(expression.target, ZenScriptOperator.NOT, "!");
129 127
 				case NEG:
@@ -236,13 +234,13 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
236 234
 					return new ExpressionString(result.toString(), ZenScriptOperator.CAST);
237 235
 				}
238 236
 				default:
239
-					throw new UnsupportedOperationException("Unknown operator: " + operator.operator);
237
+					throw new UnsupportedOperationException("Unknown operator: " + expression.member.getOperator());
240 238
 			}
241 239
 		} else {
242 240
 			StringBuilder result = new StringBuilder();
243 241
 			result.append(expression.target.accept(this).value);
244 242
 			result.append(".");
245
-			result.append(expression.member.name);
243
+			result.append(expression.member.getMethodName());
246 244
 			FormattingUtils.formatCall(result, typeFormatter, this, expression.arguments);
247 245
 			return new ExpressionString(result.toString(), ZenScriptOperator.PRIMARY);
248 246
 		}
@@ -252,17 +250,17 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
252 250
 	public ExpressionString visitCallStatic(CallStaticExpression expression) {
253 251
 		StringBuilder result = new StringBuilder();
254 252
 		result.append(expression.target.accept(typeFormatter));
255
-		if (expression.member instanceof OperatorMember) {
256
-			OperatorMember operator = (OperatorMember) expression.member;
257
-			if (operator.operator == OperatorType.CALL) {
253
+		if (expression.member.isOperator()) {
254
+			OperatorType operator = expression.member.getOperator();
255
+			if (operator == OperatorType.CALL) {
258 256
 				// nothing
259 257
 			} else {
260 258
 				result.append(".");
261
-				result.append(expression.member.name);
259
+				result.append(operator.operator);
262 260
 			}
263 261
 		} else {
264 262
 			result.append(".");
265
-			result.append(expression.member.name);
263
+			result.append(expression.member.getMethodName());
266 264
 		}
267 265
 		FormattingUtils.formatCall(result, typeFormatter, this, expression.arguments);
268 266
 		return new ExpressionString(result.toString(), ZenScriptOperator.PRIMARY);
@@ -330,7 +328,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
330 328
 		StringBuilder result = new StringBuilder();
331 329
 		result.append(expression.type.accept(typeFormatter));
332 330
 		result.append('.');
333
-		result.append(expression.constant.name);
331
+		result.append(expression.constant.member.name);
334 332
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
335 333
 	}
336 334
 
@@ -435,7 +433,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
435 433
 		StringBuilder result = new StringBuilder();
436 434
 		result.append(expression.target.accept(this));
437 435
 		result.append('.');
438
-		result.append(expression.field.name);
436
+		result.append(expression.field.member.name);
439 437
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
440 438
 	}
441 439
 
@@ -454,7 +452,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
454 452
 		StringBuilder result = new StringBuilder();
455 453
 		result.append(expression.type.accept(typeFormatter));
456 454
 		result.append('.');
457
-		result.append(expression.field.name);
455
+		result.append(expression.field.member.name);
458 456
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
459 457
 	}
460 458
 
@@ -463,7 +461,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
463 461
 		StringBuilder result = new StringBuilder();
464 462
 		result.append(expression.target.accept(this));
465 463
 		result.append('.');
466
-		result.append(expression.getter.name);
464
+		result.append(expression.getter.member.name);
467 465
 		return new ExpressionString(result.toString(), ZenScriptOperator.MEMBER);
468 466
 	}
469 467
 	
@@ -549,7 +547,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
549 547
 	
550 548
 	@Override
551 549
 	public ExpressionString visitPostCall(PostCallExpression expression) {
552
-		return unaryPostfix(expression.target, ZenScriptOperator.INCREMENT, expression.member.operator == OperatorType.INCREMENT ? "++" : "--");
550
+		return unaryPostfix(expression.target, ZenScriptOperator.INCREMENT, expression.member.getOperator() == OperatorType.INCREMENT ? "++" : "--");
553 551
 	}
554 552
 
555 553
 	@Override
@@ -565,7 +563,7 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
565 563
 	@Override
566 564
 	public ExpressionString visitSetField(SetFieldExpression expression) {
567 565
 		return new ExpressionString(
568
-				expression.target.accept(this) + "." + expression.field.name + " = " + expression.value.accept(this).value, 
566
+				expression.target.accept(this) + "." + expression.field.member.name + " = " + expression.value.accept(this).value, 
569 567
 				ZenScriptOperator.ASSIGN);
570 568
 	}
571 569
 
@@ -586,28 +584,28 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
586 584
 	@Override
587 585
 	public ExpressionString visitSetStaticField(SetStaticFieldExpression expression) {
588 586
 		return new ExpressionString(
589
-				expression.type.accept(typeFormatter) + "." + expression.field.name + " = " + expression.value.accept(this).value,
587
+				expression.type.accept(typeFormatter) + "." + expression.field.member.name + " = " + expression.value.accept(this).value,
590 588
 				ZenScriptOperator.ASSIGN);
591 589
 	}
592 590
 
593 591
 	@Override
594 592
 	public ExpressionString visitSetter(SetterExpression expression) {
595 593
 		return new ExpressionString(
596
-				expression.target.accept(this) + "." + expression.setter.name + " = " + expression.value.accept(this),
594
+				expression.target.accept(this) + "." + expression.setter.member.name + " = " + expression.value.accept(this),
597 595
 				ZenScriptOperator.ASSIGN);
598 596
 	}
599 597
 
600 598
 	@Override
601 599
 	public ExpressionString visitStaticGetter(StaticGetterExpression expression) {
602 600
 		return new ExpressionString(
603
-				expression.type.accept(typeFormatter) + "." + expression.getter.name, 
601
+				expression.type.accept(typeFormatter) + "." + expression.getter.member.name, 
604 602
 				ZenScriptOperator.MEMBER);
605 603
 	}
606 604
 
607 605
 	@Override
608 606
 	public ExpressionString visitStaticSetter(StaticSetterExpression expression) {
609 607
 		return new ExpressionString(
610
-				expression.type.accept(typeFormatter) + "." + expression.setter.name + " = " + expression.setter.name,
608
+				expression.type.accept(typeFormatter) + "." + expression.setter.member.name + " = " + expression.setter.member.name,
611 609
 				ZenScriptOperator.ASSIGN);
612 610
 	}
613 611
 	
@@ -628,19 +626,19 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
628 626
 
629 627
 	@Override
630 628
 	public ExpressionString visitTryConvert(TryConvertExpression expression) {
631
-		ExpressionString value = expression.accept(this);
629
+		ExpressionString value = expression.value.accept(this);
632 630
 		return new ExpressionString("try?" + value.value, value.priority);
633 631
 	}
634 632
 
635 633
 	@Override
636 634
 	public ExpressionString visitTryRethrowAsException(TryRethrowAsExceptionExpression expression) {
637
-		ExpressionString value = expression.accept(this);
635
+		ExpressionString value = expression.value.accept(this);
638 636
 		return new ExpressionString("try!" + value.value, value.priority);
639 637
 	}
640 638
 
641 639
 	@Override
642 640
 	public ExpressionString visitTryRethrowAsResult(TryRethrowAsResultExpression expression) {
643
-		ExpressionString value = expression.accept(this);
641
+		ExpressionString value = expression.value.accept(this);
644 642
 		return new ExpressionString("try!" + value.value, value.priority);
645 643
 	}
646 644
 	

+ 1
- 1
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/SwitchValueFormatter.java Bestand weergeven

@@ -47,7 +47,7 @@ public class SwitchValueFormatter implements SwitchValueVisitor<String> {
47 47
 	@Override
48 48
 	public String acceptVariantOption(VariantOptionSwitchValue value) {
49 49
 		StringBuilder result = new StringBuilder();
50
-		result.append(value.option.name);
50
+		result.append(value.option.getName());
51 51
 		result.append("(");
52 52
 		for (int i = 0; i < value.parameters.length; i++) {
53 53
 			if (i > 0)

+ 0
- 11
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ZenScriptOperator.java Bestand weergeven

@@ -63,16 +63,10 @@ public enum ZenScriptOperator implements FormattableOperator {
63 63
 	PRIMARY(10, null);
64 64
 	
65 65
 	private final int priority;
66
-	private final boolean isCommutative;
67 66
 	private final String operatorString;
68 67
 	
69 68
 	private ZenScriptOperator(int priority, String operatorString) {
70
-		this(priority, false, operatorString);
71
-	}
72
-	
73
-	private ZenScriptOperator(int priority, boolean isCommutative, String operatorString) {
74 69
 		this.priority = priority;
75
-		this.isCommutative = isCommutative;
76 70
 		this.operatorString = operatorString;
77 71
 	}
78 72
 
@@ -80,11 +74,6 @@ public enum ZenScriptOperator implements FormattableOperator {
80 74
 	public int getPriority() {
81 75
 		return priority;
82 76
 	}
83
-
84
-	@Override
85
-	public boolean isCommutative() {
86
-		return isCommutative;
87
-	}
88 77
 	
89 78
 	@Override
90 79
 	public String getOperatorString() {

+ 4
- 4
CodeFormatterShared/src/main/java/org/openzen/zenscript/formattershared/ExpressionString.java Bestand weergeven

@@ -38,18 +38,18 @@ public class ExpressionString {
38 38
 	}
39 39
 	
40 40
 	public ExpressionString unaryPrefix(FormattableOperator operator) {
41
-		return new ExpressionString(operator.getOperatorString() + value, operator);
41
+		return new ExpressionString(operator.getOperatorString() + wrapRight(operator), operator);
42 42
 	}
43 43
 	
44 44
 	public ExpressionString unaryPostfix(FormattableOperator operator) {
45
-		return new ExpressionString(value + operator.getOperatorString(), operator);
45
+		return new ExpressionString(wrapLeft(operator) + operator.getOperatorString(), operator);
46 46
 	}
47 47
 	
48 48
 	public ExpressionString unaryPrefix(FormattableOperator operator, String operatorString) {
49
-		return new ExpressionString(operatorString + value, operator);
49
+		return new ExpressionString(operatorString + wrapRight(operator), operator);
50 50
 	}
51 51
 	
52 52
 	public ExpressionString unaryPostfix(FormattableOperator operator, String operatorString) {
53
-		return new ExpressionString(value + operatorString, operator);
53
+		return new ExpressionString(wrapLeft(operator) + operatorString, operator);
54 54
 	}
55 55
 }

+ 7
- 3
CodeFormatterShared/src/main/java/org/openzen/zenscript/formattershared/FormattableOperator.java Bestand weergeven

@@ -10,10 +10,14 @@ package org.openzen.zenscript.formattershared;
10 10
  * @author Hoofdgebruiker
11 11
  */
12 12
 public interface FormattableOperator {
13
+	/**
14
+	 * Operator priority: if priority of the inner operation is lower, it should
15
+	 * be wrapped in parenthesis.
16
+	 * 
17
+	 * @return 
18
+	 */
13 19
 	int getPriority();
14 20
 	
15
-	boolean isCommutative();
16
-	
17 21
 	String getOperatorString();
18 22
 	
19 23
 	public static boolean shouldWrapLeft(FormattableOperator inner, FormattableOperator outer) {
@@ -21,6 +25,6 @@ public interface FormattableOperator {
21 25
 	}
22 26
 	
23 27
 	public static boolean shouldWrapRight(FormattableOperator inner, FormattableOperator outer) {
24
-		return (inner == outer && inner.isCommutative()) || (inner.getPriority() <= outer.getPriority());
28
+		return inner.getPriority() <= outer.getPriority();
25 29
 	}
26 30
 }

+ 43
- 22
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java Bestand weergeven

@@ -30,6 +30,9 @@ public class FunctionHeader {
30 30
 	public final ITypeID thrownType;
31 31
 	
32 32
 	public FunctionHeader(ITypeID returnType) {
33
+		if (returnType == null)
34
+			throw new NullPointerException();
35
+		
33 36
 		this.typeParameters = null;
34 37
 		this.returnType = returnType;
35 38
 		this.parameters = NO_PARAMETERS;
@@ -37,6 +40,9 @@ public class FunctionHeader {
37 40
 	}
38 41
 	
39 42
 	public FunctionHeader(ITypeID returnType, ITypeID... parameterTypes) {
43
+		if (returnType == null)
44
+			throw new NullPointerException();
45
+		
40 46
 		this.typeParameters = null;
41 47
 		this.returnType = returnType;
42 48
 		this.parameters = new FunctionParameter[parameterTypes.length];
@@ -47,6 +53,9 @@ public class FunctionHeader {
47 53
 	}
48 54
 	
49 55
 	public FunctionHeader(ITypeID returnType, FunctionParameter... parameters) {
56
+		if (returnType == null)
57
+			throw new NullPointerException();
58
+		
50 59
 		this.typeParameters = null;
51 60
 		this.returnType = returnType;
52 61
 		this.parameters = parameters;
@@ -54,6 +63,9 @@ public class FunctionHeader {
54 63
 	}
55 64
 	
56 65
 	public FunctionHeader(TypeParameter[] genericParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
66
+		if (returnType == null)
67
+			throw new NullPointerException();
68
+		
57 69
 		this.typeParameters = genericParameters;
58 70
 		this.returnType = returnType;
59 71
 		this.parameters = parameters;
@@ -64,18 +76,25 @@ public class FunctionHeader {
64 76
 		return typeParameters == null ? 0 : typeParameters.length;
65 77
 	}
66 78
 	
67
-	public FunctionHeader instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
68
-		TypeParameter[] genericParameters = this.typeParameters == null ? null : new TypeParameter[this.typeParameters.length];
69
-		if (genericParameters != null)
70
-			for (int i = 0; i < genericParameters.length; i++)
71
-				genericParameters[i] = this.typeParameters[i].withGenericArguments(registry, mapping);
72
-		
73
-		ITypeID returnType = this.returnType.withGenericArguments(registry, mapping);
74
-		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
75
-		for (int i = 0; i < parameters.length; i++)
76
-			parameters[i] = this.parameters[i].withGenericArguments(registry, mapping);
77
-		
78
-		return new FunctionHeader(genericParameters, returnType, thrownType == null ? null : thrownType.withGenericArguments(registry, mapping), parameters);
79
+	public String getCanonical() {
80
+		StringBuilder result = new StringBuilder();
81
+		if (getNumberOfTypeParameters() > 0) {
82
+			result.append('<');
83
+			for (int i = 0; i < typeParameters.length; i++) {
84
+				if (i > 0)
85
+					result.append(',');
86
+				result.append(typeParameters[i].getCanonical());
87
+			}
88
+			result.append('>');
89
+		}
90
+		result.append('(');
91
+		for (int i = 0; i < parameters.length; i++) {
92
+			if (i > 0)
93
+				result.append(',');
94
+			result.append(parameters[i].type.toString());
95
+		}
96
+		result.append(')');
97
+		return result.toString();
79 98
 	}
80 99
 	
81 100
 	public ITypeID[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<ITypeID> resultHint) {
@@ -200,29 +219,31 @@ public class FunctionHeader {
200 219
 		return true;
201 220
 	}
202 221
 	
203
-	public FunctionHeader withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
204
-		ITypeID returnType = this.returnType.withGenericArguments(registry, arguments);
222
+	public FunctionHeader withGenericArguments(GenericMapper mapper) {
223
+		ITypeID returnType = this.returnType.instance(mapper);
205 224
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
206 225
 		for (int i = 0; i < parameters.length; i++) {
207
-			ITypeID modified = this.parameters[i].type.withGenericArguments(registry, arguments);
208
-			parameters[i] = modified == this.parameters[i].type ? this.parameters[i] : new FunctionParameter(modified, this.parameters[i].name);
226
+			parameters[i] = this.parameters[i].withGenericArguments(mapper);
209 227
 		}
210
-		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.withGenericArguments(registry, arguments), parameters);
228
+		return new FunctionHeader(typeParameters, returnType, thrownType == null ? null : thrownType.instance(mapper), parameters);
211 229
 	}
212 230
 	
213
-	public FunctionHeader withGenericArguments(GlobalTypeRegistry registry, ITypeID[] arguments) {
231
+	public FunctionHeader fillGenericArguments(GlobalTypeRegistry registry, ITypeID[] arguments) {
232
+		if (arguments == null || arguments.length == 0)
233
+			return this;
234
+		
214 235
 		Map<TypeParameter, ITypeID> typeArguments = new HashMap<>();
215 236
 		if (typeParameters != null)
216 237
 			for (int i = 0; i < typeParameters.length; i++)
217 238
 				typeArguments.put(typeParameters[i], arguments[i]);
239
+		GenericMapper mapper = new GenericMapper(registry, typeArguments);
218 240
 		
219
-		ITypeID returnType = this.returnType.withGenericArguments(registry, typeArguments);
241
+		ITypeID returnType = this.returnType.instance(mapper);
220 242
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
221 243
 		for (int i = 0; i < parameters.length; i++) {
222
-			ITypeID modified = this.parameters[i].type.withGenericArguments(registry, typeArguments);
223
-			parameters[i] = modified == this.parameters[i].type ? this.parameters[i] : new FunctionParameter(modified, this.parameters[i].name);
244
+			parameters[i] = this.parameters[i].withGenericArguments(mapper);
224 245
 		}
225
-		return new FunctionHeader(returnType, parameters);
246
+		return new FunctionHeader(null, returnType, thrownType == null ? null : thrownType.instance(mapper), parameters);
226 247
 	}
227 248
 	
228 249
 	public FunctionHeader forTypeParameterInference() {

+ 7
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java Bestand weergeven

@@ -6,11 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.annotations.Annotation;
9
-import java.util.Map;
10 9
 import java.util.Objects;
11 10
 import org.openzen.zenscript.codemodel.expression.Expression;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
15 12
 import org.openzen.zenscript.shared.Taggable;
16 13
 
@@ -51,9 +48,14 @@ public class FunctionParameter extends Taggable {
51 48
 		this.variadic = variadic;
52 49
 	}
53 50
 	
54
-	public FunctionParameter withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
55
-		FunctionParameter result = new FunctionParameter(type.withGenericArguments(registry, arguments), name, defaultValue, variadic);
51
+	public FunctionParameter withGenericArguments(GenericMapper mapper) {
52
+		ITypeID instanced = type.instance(mapper);
53
+		if (instanced == type)
54
+			return this;
55
+		
56
+		FunctionParameter result = new FunctionParameter(instanced, name, defaultValue, variadic);
56 57
 		result.annotations = annotations;
58
+		result.addAllTagsFrom(this); // TODO: this will cause trouble -> references?
57 59
 		return result;
58 60
 	}
59 61
 	

+ 52
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/GenericMapper.java Bestand weergeven

@@ -0,0 +1,52 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel;
7
+
8
+import java.util.Map;
9
+import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
+import org.openzen.zenscript.codemodel.type.GenericTypeID;
11
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.type.ITypeID;
13
+
14
+/**
15
+ *
16
+ * @author Hoofdgebruiker
17
+ */
18
+public class GenericMapper {
19
+	public final GlobalTypeRegistry registry;
20
+	private final Map<TypeParameter, ITypeID> mapping;
21
+	
22
+	public GenericMapper(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
23
+		this.registry = registry;
24
+		this.mapping = mapping;
25
+	}
26
+	
27
+	public Map<TypeParameter, ITypeID> getMapping() {
28
+		return mapping;
29
+	}
30
+	
31
+	public ITypeID map(ITypeID original) {
32
+		return mapping.isEmpty() ? original : original.instance(this);
33
+	}
34
+	
35
+	public ITypeID[] map(ITypeID[] original) {
36
+		if (mapping.isEmpty())
37
+			return original;
38
+		
39
+		ITypeID[] mapped = new ITypeID[original.length];
40
+		for (int i = 0; i < original.length; i++)
41
+			mapped[i] = original[i].instance(this);
42
+		return mapped;
43
+	}
44
+	
45
+	public ITypeID map(GenericTypeID type) {
46
+		return mapping.containsKey(type.parameter) ? mapping.get(type.parameter) : type;
47
+	}
48
+	
49
+	public FunctionHeader map(FunctionHeader original) {
50
+		return mapping.isEmpty() ? original : original.withGenericArguments(this);
51
+	}
52
+}

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java Bestand weergeven

@@ -46,6 +46,10 @@ public abstract class HighLevelDefinition extends Taggable {
46 46
 			pkg.register(this);
47 47
 	}
48 48
 	
49
+	public String getFullName() {
50
+		return pkg.fullName + '.' + name;
51
+	}
52
+	
49 53
 	public int getNumberOfGenericParameters() {
50 54
 		return genericParameters == null ? 0 : genericParameters.length;
51 55
 	}

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java Bestand weergeven

@@ -9,6 +9,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 10
 import org.openzen.zenscript.codemodel.Modifiers;
11 11
 import org.openzen.zenscript.codemodel.member.CallerMember;
12
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
12 13
 import org.openzen.zenscript.codemodel.statement.Statement;
13 14
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
14 15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -37,7 +38,7 @@ public class FunctionDefinition extends HighLevelDefinition {
37 38
 	public void setHeader(FunctionHeader header) {
38 39
 		this.header = header;
39 40
 		addMember(caller = new CallerMember(position, this, modifiers | Modifiers.STATIC, header, null));
40
-		callerGroup.addMethod(caller, TypeMemberPriority.SPECIFIED);
41
+		callerGroup.addMethod(new FunctionalMemberRef(caller, caller.header), TypeMemberPriority.SPECIFIED);
41 42
 	}
42 43
 	
43 44
 	public void setCode(Statement statement) {

+ 6
- 10
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java Bestand weergeven

@@ -7,12 +7,12 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10
-import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
14 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
15 14
 import org.openzen.zenscript.shared.CodePosition;
15
+import org.openzen.zenscript.shared.Taggable;
16 16
 
17 17
 /**
18 18
  *
@@ -30,7 +30,7 @@ public class VariantDefinition extends HighLevelDefinition {
30 30
 		return visitor.visitVariant(this);
31 31
 	}
32 32
 	
33
-	public static class Option {
33
+	public static class Option extends Taggable {
34 34
 		public final String name;
35 35
 		public final ITypeID[] types;
36 36
 		
@@ -39,12 +39,8 @@ public class VariantDefinition extends HighLevelDefinition {
39 39
 			this.types = types;
40 40
 		}
41 41
 		
42
-		public Option instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
43
-			ITypeID[] newTypes = new ITypeID[types.length];
44
-			for (int i = 0; i < types.length; i++)
45
-				newTypes[i] = types[i].withGenericArguments(registry, mapping);
46
-			
47
-			return new Option(name, newTypes);
42
+		public VariantOptionRef instance(GenericMapper mapper) {
43
+			return new VariantOptionRef(this, mapper.map(types));
48 44
 		}
49 45
 	}
50 46
 }

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallExpression.java Bestand weergeven

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
9
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
10 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11 11
 import org.openzen.zenscript.shared.CodePosition;
12 12
 
@@ -16,11 +16,11 @@ import org.openzen.zenscript.shared.CodePosition;
16 16
  */
17 17
 public class CallExpression extends Expression {
18 18
 	public final Expression target;
19
-	public final FunctionalMember member;
19
+	public final FunctionalMemberRef member;
20 20
 	public final CallArguments arguments;
21 21
 	public final FunctionHeader instancedHeader;
22 22
 	
23
-	public CallExpression(CodePosition position, Expression target, FunctionalMember member, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
23
+	public CallExpression(CodePosition position, Expression target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
24 24
 		super(position, instancedHeader.returnType, multiThrow(position, arguments.arguments));
25 25
 		
26 26
 		this.target = target;
@@ -49,10 +49,10 @@ public class CallExpression extends Expression {
49 49
 	
50 50
 	@Override
51 51
 	public String evaluateStringConstant() {
52
-		if (member.builtin == null)
52
+		if (member.getBuiltin() == null)
53 53
 			throw new UnsupportedOperationException("Cannot evaluate to a string constant!");
54 54
 		
55
-		switch (member.builtin) {
55
+		switch (member.getBuiltin()) {
56 56
 			case STRING_ADD_STRING:
57 57
 				return target.evaluateStringConstant() + arguments.arguments[0].evaluateStringConstant();
58 58
 			default:

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java Bestand weergeven

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
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.ITypeID;
12 12
 import org.openzen.zenscript.shared.CodePosition;
@@ -16,12 +16,12 @@ import org.openzen.zenscript.shared.CodePosition;
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class CallStaticExpression extends Expression {
19
-	public final FunctionalMember member;
19
+	public final FunctionalMemberRef member;
20 20
 	public final ITypeID target;
21 21
 	public final CallArguments arguments;
22 22
 	public final FunctionHeader instancedHeader;
23 23
 	
24
-	public CallStaticExpression(CodePosition position, ITypeID target, FunctionalMember member, CallArguments arguments, FunctionHeader instancedHeader, TypeScope scope) {
24
+	public CallStaticExpression(CodePosition position, ITypeID target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
25 25
 		super(position, instancedHeader.returnType, multiThrow(position, arguments.arguments));
26 26
 		
27 27
 		this.member = member;
@@ -38,6 +38,6 @@ public class CallStaticExpression extends Expression {
38 38
 	@Override
39 39
 	public Expression transform(ExpressionTransformer transformer) {
40 40
 		CallArguments tArguments = arguments.transform(transformer);
41
-		return arguments == tArguments ? this : new CallStaticExpression(position, target, member, tArguments, instancedHeader, null);
41
+		return arguments == tArguments ? this : new CallStaticExpression(position, target, member, instancedHeader, tArguments, null);
42 42
 	}
43 43
 }

+ 4
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java Bestand weergeven

@@ -5,9 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.FunctionParameter;
10
-import org.openzen.zenscript.codemodel.member.CasterMember;
8
+import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
11 9
 import org.openzen.zenscript.shared.CodePosition;
12 10
 
13 11
 /**
@@ -16,11 +14,11 @@ import org.openzen.zenscript.shared.CodePosition;
16 14
  */
17 15
 public class CastExpression extends Expression {
18 16
 	public final Expression target;
19
-	public final CasterMember member;
17
+	public final CasterMemberRef member;
20 18
 	public final boolean isImplicit;
21 19
 	
22
-	public CastExpression(CodePosition position, Expression target, CasterMember member, boolean isImplicit) {
23
-		super(position, member.getTargetType(), binaryThrow(position, target.thrownType, member.header.thrownType));
20
+	public CastExpression(CodePosition position, Expression target, CasterMemberRef member, boolean isImplicit) {
21
+		super(position, member.toType, binaryThrow(position, target.thrownType, member.member.header.thrownType));
24 22
 		
25 23
 		this.target = target;
26 24
 		this.member = member;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java Bestand weergeven

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.CompareType;
9
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
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 12
 import org.openzen.zenscript.shared.CodePosition;
@@ -20,10 +20,10 @@ import org.openzen.zenscript.shared.CodePosition;
20 20
 public class CompareExpression extends Expression {
21 21
 	public final Expression left;
22 22
 	public final Expression right;
23
-	public final FunctionalMember operator;
23
+	public final FunctionalMemberRef operator;
24 24
 	public final CompareType comparison;
25 25
 	
26
-	public CompareExpression(CodePosition position, Expression left, Expression right, FunctionalMember operator, CompareType comparison, TypeScope scope) {
26
+	public CompareExpression(CodePosition position, Expression left, Expression right, FunctionalMemberRef operator, CompareType comparison, TypeScope scope) {
27 27
 		super(position, BasicTypeID.BOOL, binaryThrow(position, left.thrownType, right.thrownType));
28 28
 		
29 29
 		this.left = left;

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstExpression.java Bestand weergeven

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.ConstMember;
9 8
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
9
+import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
10 10
 import org.openzen.zenscript.shared.CodePosition;
11 11
 
12 12
 /**
@@ -14,9 +14,9 @@ import org.openzen.zenscript.shared.CodePosition;
14 14
  * @author Hoofdgebruiker
15 15
  */
16 16
 public class ConstExpression extends Expression {
17
-	public final ConstMember constant;
17
+	public final ConstMemberRef constant;
18 18
 	
19
-	public ConstExpression(CodePosition position, ConstMember constant) {
19
+	public ConstExpression(CodePosition position, ConstMemberRef constant) {
20 20
 		super(position, constant.type, null);
21 21
 		
22 22
 		this.constant = constant;
@@ -34,11 +34,11 @@ public class ConstExpression extends Expression {
34 34
 	
35 35
 	@Override
36 36
 	public String evaluateStringConstant() {
37
-		return constant.value.evaluateStringConstant();
37
+		return constant.member.value.evaluateStringConstant();
38 38
 	}
39 39
 	
40 40
 	@Override
41 41
 	public EnumConstantMember evaluateEnumConstant() {
42
-		return constant.value.evaluateEnumConstant();
42
+		return constant.member.value.evaluateEnumConstant();
43 43
 	}
44 44
 }

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java Bestand weergeven

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
9
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
9 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
11 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -17,10 +18,10 @@ import org.openzen.zenscript.shared.CodePosition;
17 18
  */
18 19
 public class ConstructorThisCallExpression extends Expression {
19 20
 	public final ITypeID objectType;
20
-	public final ConstructorMember constructor;
21
+	public final FunctionalMemberRef constructor;
21 22
 	public final CallArguments arguments;
22 23
 	
23
-	public ConstructorThisCallExpression(CodePosition position, ITypeID type, ConstructorMember constructor, CallArguments arguments, TypeScope scope) {
24
+	public ConstructorThisCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments, TypeScope scope) {
24 25
 		super(position, BasicTypeID.VOID, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
25 26
 		
26 27
 		this.objectType = type;

+ 3
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java Bestand weergeven

@@ -36,6 +36,9 @@ public abstract class Expression implements IPartialExpression {
36 36
 	public final ITypeID thrownType;
37 37
 	
38 38
 	public Expression(CodePosition position, ITypeID type, ITypeID thrownType) {
39
+		if (type == null)
40
+			throw new NullPointerException();
41
+		
39 42
 		this.position = position;
40 43
 		this.type = type;
41 44
 		this.thrownType = thrownType;

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java Bestand weergeven

@@ -9,7 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zenscript.codemodel.OperatorType;
11 11
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
12
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
12
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
13 13
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
14 14
 import org.openzen.zenscript.codemodel.type.GenericName;
15 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -49,18 +49,18 @@ public class ExpressionBuilder {
49 49
 		DefinitionMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
50 50
 		List<ITypeID>[] predictedTypes = constructors.predictCallTypes(scope, scope.hints, arguments.length);
51 51
 		CallArguments compiledArguments = new CallArguments(arguments);
52
-		FunctionalMember member = constructors.selectMethod(position, scope, compiledArguments, true, true);
52
+		FunctionalMemberRef member = constructors.selectMethod(position, scope, compiledArguments, true, true);
53 53
 		if (member == null)
54 54
 			throw new CompileException(position, CompileExceptionCode.CALL_NO_VALID_METHOD, "No matching constructor found");
55
-		if (!(member instanceof ConstructorMember))
55
+		if (!member.isConstructor())
56 56
 			throw new CompileException(position, CompileExceptionCode.INTERNAL_ERROR, "COMPILER BUG: constructor is not a constructor");
57 57
 		
58 58
 		return new NewExpression(
59 59
 				position,
60 60
 				type,
61
-				(ConstructorMember) member,
61
+				member,
62 62
 				compiledArguments,
63
-				compiledArguments.getNumberOfTypeArguments() == 0 ? member.header : member.header.withGenericArguments(scope.getTypeRegistry(), compiledArguments.typeArguments),
63
+				compiledArguments.getNumberOfTypeArguments() == 0 ? member.header : member.header.fillGenericArguments(scope.getTypeRegistry(), compiledArguments.typeArguments),
64 64
 				scope);
65 65
 	}
66 66
 	

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java Bestand weergeven

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import java.util.Collections;
9 9
 import java.util.List;
10
-import org.openzen.zenscript.codemodel.member.FieldMember;
10
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 13
 import org.openzen.zenscript.shared.CodePosition;
@@ -18,9 +18,9 @@ import org.openzen.zenscript.shared.CodePosition;
18 18
  */
19 19
 public class GetFieldExpression extends Expression {
20 20
 	public final Expression target;
21
-	public final FieldMember field;
21
+	public final FieldMemberRef field;
22 22
 	
23
-	public GetFieldExpression(CodePosition position, Expression target, FieldMember field) {
23
+	public GetFieldExpression(CodePosition position, Expression target, FieldMemberRef field) {
24 24
 		super(position, field.type, target.thrownType);
25 25
 		
26 26
 		this.target = target;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java Bestand weergeven

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import java.util.Collections;
9 9
 import java.util.List;
10
-import org.openzen.zenscript.codemodel.member.FieldMember;
10
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
11 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
12 12
 import org.openzen.zenscript.shared.CodePosition;
13 13
 
@@ -16,9 +16,9 @@ import org.openzen.zenscript.shared.CodePosition;
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class GetStaticFieldExpression extends Expression {
19
-	public final FieldMember field;
19
+	public final FieldMemberRef field;
20 20
 	
21
-	public GetStaticFieldExpression(CodePosition position, FieldMember field) {
21
+	public GetStaticFieldExpression(CodePosition position, FieldMemberRef field) {
22 22
 		super(position, field.type, null);
23 23
 		
24 24
 		this.field = field;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.GetterMember;
8
+import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -14,9 +14,9 @@ import org.openzen.zenscript.shared.CodePosition;
14 14
  */
15 15
 public class GetterExpression extends Expression {
16 16
 	public final Expression target;
17
-	public final GetterMember getter;
17
+	public final GetterMemberRef getter;
18 18
 	
19
-	public GetterExpression(CodePosition position, Expression target, GetterMember getter) {
19
+	public GetterExpression(CodePosition position, Expression target, GetterMemberRef getter) {
20 20
 		super(position, getter.type, target.thrownType);
21 21
 		
22 22
 		this.target = target;

+ 4
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java Bestand weergeven

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9 9
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
10
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
10 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
12 13
 import org.openzen.zenscript.shared.CodePosition;
@@ -16,14 +17,14 @@ import org.openzen.zenscript.shared.CodePosition;
16 17
  * @author Hoofdgebruiker
17 18
  */
18 19
 public class NewExpression extends Expression {
19
-	public final ConstructorMember constructor;
20
+	public final FunctionalMemberRef constructor;
20 21
 	public final CallArguments arguments;
21 22
 	public final FunctionHeader instancedHeader;
22 23
 	
23 24
 	public NewExpression(
24 25
 			CodePosition position,
25 26
 			ITypeID type,
26
-			ConstructorMember constructor,
27
+			FunctionalMemberRef constructor,
27 28
 			CallArguments arguments)
28 29
 	{
29 30
 		super(position, type, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
@@ -36,7 +37,7 @@ public class NewExpression extends Expression {
36 37
 	public NewExpression(
37 38
 			CodePosition position,
38 39
 			ITypeID type,
39
-			ConstructorMember constructor,
40
+			FunctionalMemberRef constructor,
40 41
 			CallArguments arguments,
41 42
 			FunctionHeader instancedHeader,
42 43
 			TypeScope scope)

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PostCallExpression.java Bestand weergeven

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9 9
 import org.openzen.zenscript.codemodel.OperatorType;
10
-import org.openzen.zenscript.codemodel.member.OperatorMember;
10
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
11 11
 import org.openzen.zenscript.shared.CodePosition;
12 12
 
13 13
 /**
@@ -17,13 +17,13 @@ import org.openzen.zenscript.shared.CodePosition;
17 17
  */
18 18
 public class PostCallExpression extends Expression {
19 19
 	public final Expression target;
20
-	public final OperatorMember member;
20
+	public final FunctionalMemberRef member;
21 21
 	public final FunctionHeader instancedHeader;
22 22
 	
23
-	public PostCallExpression(CodePosition position, Expression target, OperatorMember member, FunctionHeader instancedHeader) {
23
+	public PostCallExpression(CodePosition position, Expression target, FunctionalMemberRef member, FunctionHeader instancedHeader) {
24 24
 		super(position, instancedHeader.returnType, binaryThrow(position, instancedHeader.thrownType, target.thrownType));
25 25
 		
26
-		if (member.operator != OperatorType.DECREMENT && member.operator != OperatorType.INCREMENT)
26
+		if (member.getOperator() != OperatorType.DECREMENT && member.getOperator() != OperatorType.INCREMENT)
27 27
 			throw new IllegalArgumentException("Operator must be increment or decrement");
28 28
 		
29 29
 		this.target = target;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFieldExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.FieldMember;
8
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -14,10 +14,10 @@ import org.openzen.zenscript.shared.CodePosition;
14 14
  */
15 15
 public class SetFieldExpression extends Expression {
16 16
 	public final Expression target;
17
-	public final FieldMember field;
17
+	public final FieldMemberRef field;
18 18
 	public final Expression value;
19 19
 	
20
-	public SetFieldExpression(CodePosition position, Expression target, FieldMember field, Expression value) {
20
+	public SetFieldExpression(CodePosition position, Expression target, FieldMemberRef field, Expression value) {
21 21
 		super(position, field.type, binaryThrow(position, target.thrownType, value.thrownType));
22 22
 		
23 23
 		this.target = target;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetStaticFieldExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.FieldMember;
8
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -13,10 +13,10 @@ import org.openzen.zenscript.shared.CodePosition;
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class SetStaticFieldExpression extends Expression {
16
-	public final FieldMember field;
16
+	public final FieldMemberRef field;
17 17
 	public final Expression value;
18 18
 	
19
-	public SetStaticFieldExpression(CodePosition position, FieldMember field, Expression value) {
19
+	public SetStaticFieldExpression(CodePosition position, FieldMemberRef field, Expression value) {
20 20
 		super(position, field.type, value.thrownType);
21 21
 		
22 22
 		this.field = field;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetterExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.SetterMember;
8
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -14,11 +14,11 @@ import org.openzen.zenscript.shared.CodePosition;
14 14
  */
15 15
 public class SetterExpression extends Expression {
16 16
 	public final Expression target;
17
-	public final SetterMember setter;
17
+	public final SetterMemberRef setter;
18 18
 	public final Expression value;
19 19
 	
20
-	public SetterExpression(CodePosition position, Expression target, SetterMember setter, Expression value) {
21
-		super(position, setter.type, binaryThrow(position, value.thrownType, setter.header.thrownType));
20
+	public SetterExpression(CodePosition position, Expression target, SetterMemberRef setter, Expression value) {
21
+		super(position, setter.type, value.thrownType);
22 22
 		
23 23
 		this.target = target;
24 24
 		this.setter = setter;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticGetterExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.GetterMember;
8
+import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -13,10 +13,10 @@ import org.openzen.zenscript.shared.CodePosition;
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class StaticGetterExpression extends Expression {
16
-	public final GetterMember getter;
16
+	public final GetterMemberRef getter;
17 17
 	
18
-	public StaticGetterExpression(CodePosition position, GetterMember getter) {
19
-		super(position, getter.type, getter.header.thrownType);
18
+	public StaticGetterExpression(CodePosition position, GetterMemberRef getter) {
19
+		super(position, getter.type, null);
20 20
 		
21 21
 		this.getter = getter;
22 22
 	}

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticSetterExpression.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.SetterMember;
8
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
9 9
 import org.openzen.zenscript.shared.CodePosition;
10 10
 
11 11
 /**
@@ -13,11 +13,11 @@ import org.openzen.zenscript.shared.CodePosition;
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class StaticSetterExpression extends Expression {
16
-	public final SetterMember setter;
16
+	public final SetterMemberRef setter;
17 17
 	public final Expression value;
18 18
 	
19
-	public StaticSetterExpression(CodePosition position, SetterMember setter, Expression value) {
20
-		super(position, setter.type, binaryThrow(position, setter.header.thrownType, value.thrownType));
19
+	public StaticSetterExpression(CodePosition position, SetterMemberRef setter, Expression value) {
20
+		super(position, setter.type, value.thrownType);
21 21
 		
22 22
 		this.setter = setter;
23 23
 		this.value = value;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java Bestand weergeven

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import java.util.List;
9
-import org.openzen.zenscript.codemodel.definition.VariantDefinition;
9
+import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
10 10
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
12 12
 import org.openzen.zenscript.shared.CodePosition;
@@ -16,14 +16,14 @@ import org.openzen.zenscript.shared.CodePosition;
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class VariantValueExpression extends Expression {
19
-	public final VariantDefinition.Option option;
19
+	public final VariantOptionRef option;
20 20
 	public final Expression[] arguments;
21 21
 	
22
-	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantDefinition.Option option) {
22
+	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantOptionRef option) {
23 23
 		this(position, variantType, option, Expression.NONE);
24 24
 	}
25 25
 	
26
-	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantDefinition.Option option, Expression[] arguments) {
26
+	public VariantValueExpression(CodePosition position, ITypeID variantType, VariantOptionRef option, Expression[] arguments) {
27 27
 		super(position, variantType, multiThrow(position, arguments));
28 28
 		
29 29
 		this.option = option;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/switchvalue/VariantOptionSwitchValue.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression.switchvalue;
7 7
 
8
-import org.openzen.zenscript.codemodel.definition.VariantDefinition;
8
+import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
9 9
 import org.openzen.zenscript.codemodel.statement.VarStatement;
10 10
 
11 11
 /**
@@ -13,10 +13,10 @@ import org.openzen.zenscript.codemodel.statement.VarStatement;
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class VariantOptionSwitchValue implements SwitchValue {
16
-	public final VariantDefinition.Option option;
16
+	public final VariantOptionRef option;
17 17
 	public final VarStatement[] parameters;
18 18
 	
19
-	public VariantOptionSwitchValue(VariantDefinition.Option option, VarStatement[] parameters) {
19
+	public VariantOptionSwitchValue(VariantOptionRef option, VarStatement[] parameters) {
20 20
 		this.option = option;
21 21
 		this.parameters = parameters;
22 22
 	}

+ 4
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/GenericParameterBound.java Bestand weergeven

@@ -5,8 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.generic;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 10
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12 11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
@@ -24,5 +23,7 @@ public abstract class GenericParameterBound {
24 23
 	
25 24
 	public abstract boolean matches(LocalMemberCache cache, ITypeID type);
26 25
 	
27
-	public abstract GenericParameterBound withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments);
26
+	public abstract GenericParameterBound instance(GenericMapper mapper);
27
+	
28
+	public abstract String getCanonical();
28 29
 }

+ 8
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java Bestand weergeven

@@ -5,8 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.generic;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
12 11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
@@ -21,6 +20,11 @@ public class ParameterSuperBound extends GenericParameterBound {
21 20
 	public ParameterSuperBound(ITypeID type) {
22 21
 		this.type = type;
23 22
 	}
23
+	
24
+	@Override
25
+	public String getCanonical() {
26
+		return "super|" + type.toString();
27
+	}
24 28
 
25 29
 	@Override
26 30
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
@@ -33,8 +37,8 @@ public class ParameterSuperBound extends GenericParameterBound {
33 37
 	}
34 38
 
35 39
 	@Override
36
-	public GenericParameterBound withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
37
-		ITypeID translated = type.withGenericArguments(registry, arguments);
40
+	public GenericParameterBound instance(GenericMapper mapper) {
41
+		ITypeID translated = type.instance(mapper);
38 42
 		if (translated == type)
39 43
 			return this;
40 44
 		

+ 8
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java Bestand weergeven

@@ -5,8 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.generic;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
12 11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
@@ -25,6 +24,11 @@ public class ParameterTypeBound extends GenericParameterBound {
25 24
 		this.position = position;
26 25
 		this.type = type;
27 26
 	}
27
+	
28
+	@Override
29
+	public String getCanonical() {
30
+		return type.toString();
31
+	}
28 32
 
29 33
 	@Override
30 34
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
@@ -37,8 +41,8 @@ public class ParameterTypeBound extends GenericParameterBound {
37 41
 	}
38 42
 
39 43
 	@Override
40
-	public GenericParameterBound withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
41
-		return new ParameterTypeBound(position, type.withGenericArguments(registry, arguments));
44
+	public GenericParameterBound instance(GenericMapper mapper) {
45
+		return new ParameterTypeBound(position, type.instance(mapper));
42 46
 	}
43 47
 
44 48
 	@Override

+ 11
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java Bestand weergeven

@@ -63,6 +63,17 @@ public class TypeParameter {
63 63
 		return this;
64 64
 	}
65 65
 	
66
+	public String getCanonical() {
67
+		StringBuilder result = new StringBuilder();
68
+		result.append(name);
69
+		for(GenericParameterBound bound : bounds) {
70
+			result.append(':');
71
+			result.append(bound.getCanonical());
72
+		}
73
+		return result.toString();
74
+	}
75
+	
76
+	@Override
66 77
 	public String toString() {
67 78
 		return name + "@" + position.toShortString();
68 79
 	}

+ 8
- 16
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java Bestand weergeven

@@ -5,12 +5,9 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
14 11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -32,23 +29,18 @@ public class CallerMember extends FunctionalMember {
32 29
 	}
33 30
 	
34 31
 	@Override
35
-	public String getInformalName() {
36
-		return "caller";
32
+	public String getCanonicalName() {
33
+		return definition.getFullName() + ":caller:" + header.getCanonical();
37 34
 	}
38
-
35
+	
39 36
 	@Override
40
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
41
-		type.addCaller(this, priority);
37
+	public FunctionalKind getKind() {
38
+		return FunctionalKind.CALLER;
42 39
 	}
43 40
 
44 41
 	@Override
45
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
46
-		return new CallerMember(
47
-				position,
48
-				definition,
49
-				modifiers,
50
-				header.instance(registry, mapping),
51
-				builtin);
42
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
43
+		type.addCaller(ref(mapper), priority);
52 44
 	}
53 45
 
54 46
 	@Override

+ 11
- 30
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java Bestand weergeven

@@ -5,16 +5,11 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.Modifiers;
12
-import org.openzen.zenscript.codemodel.expression.CallArguments;
13
-import org.openzen.zenscript.codemodel.expression.CastExpression;
14
-import org.openzen.zenscript.codemodel.expression.Expression;
15
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
16
-import org.openzen.zenscript.codemodel.scope.TypeScope;
17
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
18 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
19 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
20 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -41,42 +36,28 @@ public class CasterMember extends FunctionalMember {
41 36
 	}
42 37
 	
43 38
 	@Override
44
-	public String getInformalName() {
45
-		return "caster to " + toType.toString();
39
+	public String getCanonicalName() {
40
+		return definition.getFullName() + ":caster:" + toType.toString();
46 41
 	}
47
-
42
+	
48 43
 	@Override
49
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
50
-		type.addCaster(this, priority);
44
+	public FunctionalKind getKind() {
45
+		return FunctionalKind.CASTER;
51 46
 	}
52 47
 
53 48
 	@Override
54
-	public String describe() {
55
-		return "caster to " + toType.toString();
49
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
50
+		type.addCaster(new CasterMemberRef(this, mapper.map(toType)), priority);
56 51
 	}
57 52
 
58 53
 	@Override
59
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
60
-		return new CasterMember(
61
-				position,
62
-				definition,
63
-				modifiers,
64
-				toType.withGenericArguments(registry, mapping),
65
-				builtin);
54
+	public String describe() {
55
+		return "caster to " + toType.toString();
66 56
 	}
67 57
 	
68 58
 	public ITypeID getTargetType() {
69 59
 		return toType;
70 60
 	}
71
-
72
-	@Override
73
-	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
74
-		throw new UnsupportedOperationException("Cannot call a caster!");
75
-	}
76
-	
77
-	public Expression cast(CodePosition position, Expression value, boolean implicit) {
78
-		return new CastExpression(position, value, this, implicit);
79
-	}
80 61
 	
81 62
 	public boolean isImplicit() {
82 63
 		return Modifiers.isImplicit(modifiers);

+ 4
- 10
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java Bestand weergeven

@@ -5,11 +5,10 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 10
 import org.openzen.zenscript.codemodel.expression.Expression;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
11
+import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
13 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
14 13
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 14
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -45,13 +44,8 @@ public class ConstMember extends DefinitionMember {
45 44
 	}
46 45
 
47 46
 	@Override
48
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
49
-		type.addConst(this);
50
-	}
51
-
52
-	@Override
53
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
54
-		return this;
47
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
48
+		members.addConst(new ConstMemberRef(this, mapper.map(type)));
55 49
 	}
56 50
 
57 51
 	@Override

+ 9
- 18
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java Bestand weergeven

@@ -5,17 +5,14 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
12 12
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
13
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 13
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
15 14
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
16 15
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
17
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
18
-import org.openzen.zenscript.codemodel.type.ITypeID;
19 16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
20 17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
21 18
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -58,25 +55,19 @@ public class ConstructorMember extends FunctionalMember {
58 55
 	}
59 56
 	
60 57
 	@Override
61
-	public String getInformalName() {
62
-		return "constructor";
58
+	public String getCanonicalName() {
59
+		return definition.getFullName() + ":this" + header.getCanonical();
63 60
 	}
64
-
61
+	
65 62
 	@Override
66
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
67
-		if (priority == TypeMemberPriority.SPECIFIED)
68
-			type.addConstructor(this, priority);
63
+	public FunctionalKind getKind() {
64
+		return FunctionalKind.CONSTRUCTOR;
69 65
 	}
70 66
 
71 67
 	@Override
72
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
73
-		ConstructorMember result = new ConstructorMember(
74
-				position,
75
-				definition,
76
-				modifiers,
77
-				header.instance(registry, mapping),
78
-				builtin);
79
-		return result;
68
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
69
+		if (priority == TypeMemberPriority.SPECIFIED)
70
+			type.addConstructor(ref(mapper), priority);
80 71
 	}
81 72
 
82 73
 	@Override

+ 4
- 13
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java Bestand weergeven

@@ -5,12 +5,11 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 10
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
12 12
 import org.openzen.zenscript.codemodel.statement.Statement;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
15 14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16 15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -51,16 +50,8 @@ public class CustomIteratorMember extends DefinitionMember implements IIteratorM
51 50
 	}
52 51
 
53 52
 	@Override
54
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
55
-		type.addIterator(this, priority);
56
-	}
57
-
58
-	@Override
59
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
60
-		ITypeID[] newIteratorTypes = new ITypeID[iteratorTypes.length];
61
-		for (int i = 0; i < newIteratorTypes.length; i++)
62
-			newIteratorTypes[i] = iteratorTypes[i].withGenericArguments(registry, mapping);
63
-		return new CustomIteratorMember(position, definition, modifiers, newIteratorTypes);
53
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
54
+		type.addIterator(new IteratorMemberRef(this, mapper.map(iteratorTypes)), priority);
64 55
 	}
65 56
 
66 57
 	@Override

+ 9
- 12
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DestructorMember.java Bestand weergeven

@@ -5,13 +5,10 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 11
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
15 12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17 14
 import org.openzen.zenscript.shared.CodePosition;
@@ -28,19 +25,19 @@ public class DestructorMember extends FunctionalMember {
28 25
 	}
29 26
 	
30 27
 	@Override
31
-	public String getInformalName() {
32
-		return "destructor";
28
+	public String getCanonicalName() {
29
+		return definition.getFullName() + ":destructor";
33 30
 	}
34
-
31
+	
35 32
 	@Override
36
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
37
-		if (priority == TypeMemberPriority.SPECIFIED)
38
-			type.addDestructor(this, priority);
33
+	public FunctionalKind getKind() {
34
+		return FunctionalKind.DESTRUCTOR;
39 35
 	}
40 36
 
41 37
 	@Override
42
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
43
-		return this;
38
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
39
+		if (priority == TypeMemberPriority.SPECIFIED)
40
+			type.addDestructor(ref(mapper), priority);
44 41
 	}
45 42
 
46 43
 	@Override

+ 6
- 19
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java Bestand weergeven

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 11
 import org.openzen.zenscript.codemodel.expression.Expression;
11 12
 import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
@@ -13,6 +14,7 @@ import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression
13 14
 import org.openzen.zenscript.codemodel.expression.SetFieldExpression;
14 15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
15 16
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
17
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
16 18
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
17 19
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
18 20
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
@@ -67,7 +69,7 @@ public class FieldMember extends DefinitionMember {
67 69
 		if (autoGetterAccess != 0) {
68 70
 			ITypeID myType = registry.getForDefinition(definition, parameters);
69 71
 			this.autoGetter = new GetterMember(position, definition, autoGetterAccess, name, type, null);
70
-			this.autoGetter.setBody(new ReturnStatement(position, new GetFieldExpression(position, new ThisExpression(position, myType), this)));
72
+			this.autoGetter.setBody(new ReturnStatement(position, new GetFieldExpression(position, new ThisExpression(position, myType), new FieldMemberRef(this, myType))));
71 73
 		} else {
72 74
 			this.autoGetter = null;
73 75
 		}
@@ -77,7 +79,7 @@ public class FieldMember extends DefinitionMember {
77 79
 			this.autoSetter.setBody(new ExpressionStatement(position, new SetFieldExpression(
78 80
 					position,
79 81
 					new ThisExpression(position, myType),
80
-					this,
82
+					new FieldMemberRef(this, myType),
81 83
 					new GetFunctionParameterExpression(position, this.autoSetter.header.parameters[0]))));
82 84
 		} else {
83 85
 			this.autoSetter = null;
@@ -120,8 +122,8 @@ public class FieldMember extends DefinitionMember {
120 122
 	}
121 123
 
122 124
 	@Override
123
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
124
-		type.addField(this, priority);
125
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
126
+		members.addField(new FieldMemberRef(this, mapper.map(type)), priority);
125 127
 	}
126 128
 	
127 129
 	@Override
@@ -129,21 +131,6 @@ public class FieldMember extends DefinitionMember {
129 131
 		return builtin;
130 132
 	}
131 133
 
132
-	@Override
133
-	public FieldMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
134
-		return new FieldMember(
135
-				position,
136
-				definition,
137
-				modifiers,
138
-				name,
139
-				type.withGenericArguments(registry, mapping),
140
-				autoGetterAccess,
141
-				autoSetterAccess,
142
-				autoGetter == null ? null : autoGetter.instance(registry, mapping),
143
-				autoSetter == null ? null : autoSetter.instance(registry, mapping),
144
-				builtin);
145
-	}
146
-
147 134
 	@Override
148 135
 	public String describe() {
149 136
 		return "field " + name;

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalKind.java Bestand weergeven

@@ -0,0 +1,21 @@
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.member;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public enum FunctionalKind {
13
+	CONSTRUCTOR,
14
+	DESTRUCTOR,
15
+	METHOD,
16
+	OPERATOR,
17
+	GETTER,
18
+	SETTER,
19
+	CALLER,
20
+	CASTER
21
+}

+ 9
- 25
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java Bestand weergeven

@@ -5,17 +5,11 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import org.openzen.zenscript.codemodel.CompareType;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.expression.CallArguments;
12
-import org.openzen.zenscript.codemodel.expression.CallExpression;
13
-import org.openzen.zenscript.codemodel.expression.CallStaticExpression;
14
-import org.openzen.zenscript.codemodel.expression.CompareExpression;
15
-import org.openzen.zenscript.codemodel.expression.Expression;
16
-import org.openzen.zenscript.codemodel.scope.TypeScope;
11
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
17 12
 import org.openzen.zenscript.codemodel.statement.Statement;
18
-import org.openzen.zenscript.codemodel.type.ITypeID;
19 13
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
20 14
 import org.openzen.zenscript.shared.CodePosition;
21 15
 
@@ -48,26 +42,16 @@ public abstract class FunctionalMember extends DefinitionMember {
48 42
 		this.body = body;
49 43
 	}
50 44
 	
51
-	public abstract String getInformalName();
45
+	public abstract String getCanonicalName();
52 46
 	
53
-	@Override
54
-	public BuiltinID getBuiltin() {
55
-		return builtin;
56
-	}
57
-	
58
-	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
59
-		return new CallExpression(position, target, this, instancedHeader, arguments, scope);
60
-	}
47
+	public abstract FunctionalKind getKind();
61 48
 	
62
-	public final Expression call(CodePosition position, Expression target, CallArguments arguments, TypeScope scope) {
63
-		return call(position, target, header, arguments, scope);
49
+	public FunctionalMemberRef ref(GenericMapper mapper) {
50
+		return new FunctionalMemberRef(this, mapper.map(header));
64 51
 	}
65 52
 	
66
-	public Expression callWithComparator(CodePosition position, CompareType comparison, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
67
-		return new CompareExpression(position, target, arguments.arguments[0], this, comparison, scope);
68
-	}
69
-	
70
-	public Expression callStatic(CodePosition position, ITypeID target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
71
-		return new CallStaticExpression(position, target, this, arguments, instancedHeader, scope);
53
+	@Override
54
+	public BuiltinID getBuiltin() {
55
+		return builtin;
72 56
 	}
73 57
 }

+ 9
- 27
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java Bestand weergeven

@@ -5,14 +5,10 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.expression.Expression;
12
-import org.openzen.zenscript.codemodel.expression.GetterExpression;
13
-import org.openzen.zenscript.codemodel.expression.StaticGetterExpression;
14
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
11
+import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
16 12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
18 14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -41,32 +37,18 @@ public class GetterMember extends FunctionalMember {
41 37
 	}
42 38
 	
43 39
 	@Override
44
-	public String getInformalName() {
45
-		return "getter " + name;
46
-	}
47
-	
48
-	public Expression get(CodePosition position, Expression target) {
49
-		return new GetterExpression(position, target, this);
50
-	}
51
-	
52
-	public Expression getStatic(CodePosition position) {
53
-		return new StaticGetterExpression(position, this);
40
+	public String getCanonicalName() {
41
+		return definition.getFullName() + ":getter:" + name;
54 42
 	}
55 43
 	
56 44
 	@Override
57
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
58
-		type.addGetter(this, priority);
45
+	public FunctionalKind getKind() {
46
+		return FunctionalKind.GETTER;
59 47
 	}
60
-
48
+	
61 49
 	@Override
62
-	public GetterMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
63
-		return new GetterMember(
64
-				position,
65
-				definition,
66
-				modifiers,
67
-				name,
68
-				type.withGenericArguments(registry, mapping),
69
-				builtin);
50
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
51
+		members.addGetter(new GetterMemberRef(this, mapper.map(type)), priority);
70 52
 	}
71 53
 
72 54
 	@Override

+ 2
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java Bestand weergeven

@@ -5,10 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
12 9
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13 10
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -25,9 +22,7 @@ public interface IDefinitionMember {
25 22
 	
26 23
 	public BuiltinID getBuiltin();
27 24
 	
28
-	public void registerTo(TypeMembers type, TypeMemberPriority priority);
29
-	
30
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping);
25
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper);
31 26
 	
32 27
 	public <T> T accept(MemberVisitor<T> visitor);
33 28
 	

+ 8
- 17
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java Bestand weergeven

@@ -7,10 +7,9 @@ package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10
-import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
14 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -36,25 +35,17 @@ public class ImplementationMember extends DefinitionMember {
36 35
 	}
37 36
 
38 37
 	@Override
39
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
40
-		type.addImplementation(this, priority);
38
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
39
+		ITypeID instancedType = mapper.map(type);
40
+		members.addImplementation(new ImplementationMemberRef(this, instancedType), priority);
41 41
 		
42
-		TypeMembers interfaceTypeMembers = type.getMemberCache().get(this.type);
43
-		interfaceTypeMembers.copyMembersTo(position, type, TypeMemberPriority.INTERFACE);
44
-	}
45
-
46
-	@Override
47
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
48
-		ITypeID instancedType = type.withGenericArguments(registry, mapping);
49
-		ImplementationMember result = new ImplementationMember(position, definition, modifiers, instancedType);
50
-		for (IDefinitionMember member : members)
51
-			result.addMember(member.instance(registry, mapping));
52
-		return result;
42
+		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType);
43
+		interfaceTypeMembers.copyMembersTo(position, members, TypeMemberPriority.INTERFACE);
53 44
 	}
54 45
 
55 46
 	@Override
56 47
 	public String describe() {
57
-		return "implementation " + type.toString();
48
+		return "implementation of " + type.toString();
58 49
 	}
59 50
 	
60 51
 	@Override

+ 5
- 13
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java Bestand weergeven

@@ -5,11 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
-import org.openzen.zenscript.codemodel.type.ITypeID;
13 10
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14 11
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
15 12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -29,16 +26,11 @@ public class InnerDefinitionMember extends DefinitionMember {
29 26
 	}
30 27
 
31 28
 	@Override
32
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
33
-		type.addInnerType(innerDefinition.name, new InnerDefinition(innerDefinition));
34
-	}
35
-
36
-	@Override
37
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
38
-		if (this.isStatic()) {
39
-			return this;
29
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
30
+		if (isStatic() || mapper.getMapping().isEmpty()) {
31
+			type.addInnerType(innerDefinition.name, new InnerDefinition(innerDefinition));
40 32
 		} else {
41
-			return new InstancedInnerDefinitionMember(position, definition, modifiers, innerDefinition, mapping);
33
+			type.addInnerType(innerDefinition.name, new InnerDefinition(innerDefinition, mapper.getMapping()));
42 34
 		}
43 35
 	}
44 36
 

+ 0
- 77
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InstancedInnerDefinitionMember.java Bestand weergeven

@@ -1,77 +0,0 @@
1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.member;
7
-
8
-import java.util.HashMap;
9
-import java.util.Map;
10
-import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
14
-import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
-import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
-import org.openzen.zenscript.shared.CodePosition;
18
-
19
-/**
20
- *
21
- * @author Hoofdgebruiker
22
- */
23
-// How it works:
24
-// - A type definition with type parameters contains an inner definition (which may contain references to one or more type parameters)
25
-// - The type is instanced somewhere
26
-// - The members of that type are instanced and registered to the TypeMembers. This will generate an InstancedInnerDefinitionMember for the inner definition.
27
-public class InstancedInnerDefinitionMember extends DefinitionMember {
28
-	public final HighLevelDefinition definition;
29
-	public final Map<TypeParameter, ITypeID> outerMapping;
30
-	
31
-	public InstancedInnerDefinitionMember(
32
-			CodePosition position,
33
-			HighLevelDefinition outer,
34
-			int modifiers,
35
-			HighLevelDefinition definition,
36
-			Map<TypeParameter, ITypeID> outerMapping)
37
-	{
38
-		super(position, outer, modifiers);
39
-		this.definition = definition;
40
-		this.outerMapping = outerMapping;
41
-	}
42
-
43
-	@Override
44
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
45
-		type.addInnerType(this.definition.name, new InnerDefinition(this.definition, outerMapping));
46
-	}
47
-	
48
-	@Override
49
-	public BuiltinID getBuiltin() {
50
-		return null;
51
-	}
52
-
53
-	@Override
54
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
55
-		if (this.isStatic()) {
56
-			return this;
57
-		} else {
58
-			Map<TypeParameter, ITypeID> totalMap = new HashMap<>();
59
-			for (Map.Entry<TypeParameter, ITypeID> entry : outerMapping.entrySet())
60
-				totalMap.put(entry.getKey(), entry.getValue().withGenericArguments(registry, mapping));
61
-			for (Map.Entry<TypeParameter, ITypeID> entry : mapping.entrySet())
62
-				totalMap.put(entry.getKey(), entry.getValue());
63
-			
64
-			return new InstancedInnerDefinitionMember(position, definition, modifiers, definition, totalMap);
65
-		}
66
-	}
67
-
68
-	@Override
69
-	public String describe() {
70
-		return "inner type " + definition.name;
71
-	}
72
-
73
-	@Override
74
-	public <T> T accept(MemberVisitor<T> visitor) {
75
-		throw new UnsupportedOperationException("Should never be called on this member!");
76
-	}
77
-}

+ 8
- 17
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MethodMember.java Bestand weergeven

@@ -5,12 +5,9 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
14 11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -26,24 +23,18 @@ public class MethodMember extends FunctionalMember {
26 23
 	}
27 24
 	
28 25
 	@Override
29
-	public String getInformalName() {
30
-		return name + " method";
26
+	public String getCanonicalName() {
27
+		return definition.getFullName() + ":" + name + header.getCanonical();
31 28
 	}
32
-
29
+	
33 30
 	@Override
34
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
35
-		type.addMethod(this, priority);
31
+	public FunctionalKind getKind() {
32
+		return FunctionalKind.METHOD;
36 33
 	}
37 34
 
38 35
 	@Override
39
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
40
-		return new MethodMember(
41
-				position,
42
-				definition,
43
-				modifiers,
44
-				name,
45
-				header.instance(registry, mapping),
46
-				builtin);
36
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
37
+		type.addMethod(name, ref(mapper), priority);
47 38
 	}
48 39
 
49 40
 	@Override

+ 8
- 17
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/OperatorMember.java Bestand weergeven

@@ -5,13 +5,10 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.OperatorType;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
-import org.openzen.zenscript.codemodel.type.ITypeID;
15 12
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16 13
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
17 14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -38,24 +35,18 @@ public class OperatorMember extends FunctionalMember {
38 35
 	}
39 36
 	
40 37
 	@Override
41
-	public String getInformalName() {
42
-		return operator.operator + " operator";
38
+	public String getCanonicalName() {
39
+		return definition.getFullName() + ":" + operator.operator + header.getCanonical();
43 40
 	}
44
-
41
+	
45 42
 	@Override
46
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
47
-		type.addOperator(this, priority);
43
+	public FunctionalKind getKind() {
44
+		return FunctionalKind.OPERATOR;
48 45
 	}
49 46
 
50 47
 	@Override
51
-	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
52
-		return new OperatorMember(
53
-				position,
54
-				definition,
55
-				modifiers,
56
-				operator,
57
-				header.instance(registry, mapping),
58
-				builtin);
48
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
49
+		type.addOperator(operator, ref(mapper), priority);
59 50
 	}
60 51
 
61 52
 	@Override

+ 9
- 16
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/SetterMember.java Bestand weergeven

@@ -5,13 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
9 8
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 9
 import org.openzen.zenscript.codemodel.FunctionParameter;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
13 13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
17 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -44,24 +43,18 @@ public class SetterMember extends FunctionalMember {
44 43
 	}
45 44
 	
46 45
 	@Override
47
-	public String getInformalName() {
48
-		return "setter " + name;
49
-	}																																							
46
+	public String getCanonicalName() {
47
+		return definition.getFullName() + ":setter:" + name;
48
+	}
50 49
 
51 50
 	@Override
52
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
53
-		type.addSetter(this, priority);
51
+	public FunctionalKind getKind() {
52
+		return FunctionalKind.SETTER;
54 53
 	}
55 54
 
56 55
 	@Override
57
-	public SetterMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
58
-		return new SetterMember(
59
-				position,
60
-				definition,
61
-				modifiers,
62
-				name,
63
-				type.withGenericArguments(registry, mapping),
64
-				builtin);
56
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
57
+		members.addSetter(new SetterMemberRef(this, mapper.map(type)), priority);
65 58
 	}
66 59
 
67 60
 	@Override

+ 2
- 10
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java Bestand weergeven

@@ -5,12 +5,9 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 10
 import org.openzen.zenscript.codemodel.statement.Statement;
12
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
-import org.openzen.zenscript.codemodel.type.ITypeID;
14 11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16 13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -46,15 +43,10 @@ public class StaticInitializerMember extends Taggable implements IDefinitionMemb
46 43
 	}
47 44
 
48 45
 	@Override
49
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
46
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
50 47
 		
51 48
 	}
52 49
 
53
-	@Override
54
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
55
-		return this;
56
-	}
57
-
58 50
 	@Override
59 51
 	public <T> T accept(MemberVisitor<T> visitor) {
60 52
 		return visitor.visitStaticInitializer(this);

+ 0
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/TranslatedOperatorMember.java Bestand weergeven

@@ -35,9 +35,4 @@ public class TranslatedOperatorMember extends OperatorMember {
35 35
 		
36 36
 		this.translator = translator;
37 37
 	}
38
-
39
-	@Override
40
-	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
41
-		return translator.translate(new CallTranslator.Call(position, target, instancedHeader, arguments, scope));
42
-	}
43 38
 }

+ 4
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java Bestand weergeven

@@ -6,11 +6,12 @@
6 6
 package org.openzen.zenscript.codemodel.member.builtin;
7 7
 
8 8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9 10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 15
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
15 16
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
@@ -64,13 +65,8 @@ public class ArrayIteratorKeyValues extends Taggable implements IIteratorMember
64 65
 	}
65 66
 
66 67
 	@Override
67
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
68
-		type.addIterator(this, priority);
69
-	}
70
-
71
-	@Override
72
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
73
-		return new ArrayIteratorKeyValues(type.withGenericArguments(registry, mapping));
68
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
69
+		members.addIterator(new IteratorMemberRef(this, mapper.map(loopVariableTypes)), priority);
74 70
 	}
75 71
 
76 72
 	@Override

+ 4
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java Bestand weergeven

@@ -5,14 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member.builtin;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 13
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -59,13 +57,8 @@ public class ArrayIteratorValues extends Taggable implements IIteratorMember {
59 57
 	}
60 58
 
61 59
 	@Override
62
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
63
-		type.addIterator(this, priority);
64
-	}
65
-
66
-	@Override
67
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
68
-		return new ArrayIteratorValues(type.withGenericArguments(registry, mapping));
60
+	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
61
+		members.addIterator(new IteratorMemberRef(this, mapper.map(loopVariableTypes)), priority);
69 62
 	}
70 63
 
71 64
 	@Override

+ 4
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java Bestand weergeven

@@ -5,14 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member.builtin;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 13
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -62,13 +60,8 @@ public class AssocIterator extends Taggable implements IIteratorMember {
62 60
 	}
63 61
 
64 62
 	@Override
65
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
66
-		type.addIterator(this, priority);
67
-	}
68
-
69
-	@Override
70
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
71
-		return new AssocIterator(type.withGenericArguments(registry, mapping));
63
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
64
+		type.addIterator(new IteratorMemberRef(this, mapper.map(loopVariableTypes)), priority);
72 65
 	}
73 66
 
74 67
 	@Override

+ 4
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java Bestand weergeven

@@ -5,14 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member.builtin;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 15
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
18 16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -70,13 +68,8 @@ public class RangeIterator extends Taggable implements IIteratorMember {
70 68
 	}
71 69
 
72 70
 	@Override
73
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
74
-		type.addIterator(this, priority);
75
-	}
76
-
77
-	@Override
78
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
79
-		return this; // only use for basic types
71
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
72
+		type.addIterator(new IteratorMemberRef(this, mapper.map(loopVariableTypes)), priority);
80 73
 	}
81 74
 
82 75
 	@Override

+ 4
- 11
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java Bestand weergeven

@@ -5,14 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.member.builtin;
7 7
 
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
10 9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -58,13 +56,8 @@ public class StringCharIterator extends Taggable implements IIteratorMember {
58 56
 	}
59 57
 
60 58
 	@Override
61
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
62
-		type.addIterator(this, priority);
63
-	}
64
-
65
-	@Override
66
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
67
-		return this;
59
+	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper) {
60
+		type.addIterator(new IteratorMemberRef(this, TYPES), priority);
68 61
 	}
69 62
 
70 63
 	@Override

+ 50
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/CasterMemberRef.java Bestand weergeven

@@ -0,0 +1,50 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.Modifiers;
9
+import org.openzen.zenscript.codemodel.expression.CastExpression;
10
+import org.openzen.zenscript.codemodel.expression.Expression;
11
+import org.openzen.zenscript.codemodel.member.CasterMember;
12
+import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.shared.CodePosition;
14
+
15
+/**
16
+ *
17
+ * @author Hoofdgebruiker
18
+ */
19
+public class CasterMemberRef implements DefinitionMemberRef {
20
+	public final CasterMember member;
21
+	public final ITypeID toType;
22
+	
23
+	public CasterMemberRef(CasterMember member, ITypeID toType) {
24
+		this.member = member;
25
+		this.toType = toType;
26
+	}
27
+
28
+	@Override
29
+	public CodePosition getPosition() {
30
+		return member.position;
31
+	}
32
+
33
+	@Override
34
+	public String describe() {
35
+		return member.describe();
36
+	}
37
+
38
+	@Override
39
+	public <T> T getTag(Class<T> type) {
40
+		return member.getTag(type);
41
+	}
42
+	
43
+	public Expression cast(CodePosition position, Expression value, boolean implicit) {
44
+		return new CastExpression(position, value, this, implicit);
45
+	}
46
+	
47
+	public boolean isImplicit() {
48
+		return Modifiers.isImplicit(member.modifiers);
49
+	}
50
+}

+ 39
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java Bestand weergeven

@@ -0,0 +1,39 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.member.ConstMember;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class ConstMemberRef implements DefinitionMemberRef {
17
+	public final ConstMember member;
18
+	public final ITypeID type;
19
+	
20
+	public ConstMemberRef(ConstMember member, ITypeID type) {
21
+		this.member = member;
22
+		this.type = type;
23
+	}
24
+
25
+	@Override
26
+	public CodePosition getPosition() {
27
+		return member.position;
28
+	}
29
+
30
+	@Override
31
+	public String describe() {
32
+		return member.describe();
33
+	}
34
+
35
+	@Override
36
+	public <T> T getTag(Class<T> type) {
37
+		return member.getTag(type);
38
+	}
39
+}

+ 20
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/DefinitionMemberRef.java Bestand weergeven

@@ -0,0 +1,20 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.shared.CodePosition;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public interface DefinitionMemberRef {
15
+	CodePosition getPosition();
16
+	
17
+	String describe();
18
+	
19
+	<T> T getTag(Class<T> type);
20
+}

+ 47
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FieldMemberRef.java Bestand weergeven

@@ -0,0 +1,47 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.member.FieldMember;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class FieldMemberRef implements DefinitionMemberRef {
17
+	public final FieldMember member;
18
+	public final ITypeID type;
19
+	
20
+	public FieldMemberRef(FieldMember member, ITypeID type) {
21
+		this.member = member;
22
+		this.type = type;
23
+	}
24
+
25
+	@Override
26
+	public CodePosition getPosition() {
27
+		return member.position;
28
+	}
29
+
30
+	@Override
31
+	public String describe() {
32
+		return member.describe();
33
+	}
34
+
35
+	@Override
36
+	public <T> T getTag(Class<T> type) {
37
+		return member.getTag(type);
38
+	}
39
+	
40
+	public boolean isStatic() {
41
+		return member.isStatic();
42
+	}
43
+	
44
+	public boolean isFinal() {
45
+		return member.isFinal();
46
+	}
47
+}

+ 95
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java Bestand weergeven

@@ -0,0 +1,95 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.CompareType;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.OperatorType;
11
+import org.openzen.zenscript.codemodel.expression.CallArguments;
12
+import org.openzen.zenscript.codemodel.expression.CallExpression;
13
+import org.openzen.zenscript.codemodel.expression.CallStaticExpression;
14
+import org.openzen.zenscript.codemodel.expression.CompareExpression;
15
+import org.openzen.zenscript.codemodel.expression.Expression;
16
+import org.openzen.zenscript.codemodel.member.FunctionalKind;
17
+import org.openzen.zenscript.codemodel.member.FunctionalMember;
18
+import org.openzen.zenscript.codemodel.member.MethodMember;
19
+import org.openzen.zenscript.codemodel.member.OperatorMember;
20
+import org.openzen.zenscript.codemodel.scope.TypeScope;
21
+import org.openzen.zenscript.codemodel.type.ITypeID;
22
+import org.openzen.zenscript.codemodel.type.member.BuiltinID;
23
+import org.openzen.zenscript.shared.CodePosition;
24
+
25
+/**
26
+ *
27
+ * @author Hoofdgebruiker
28
+ */
29
+public class FunctionalMemberRef implements DefinitionMemberRef {
30
+	private final FunctionalMember target;
31
+	public final FunctionHeader header;
32
+	
33
+	public FunctionalMemberRef(FunctionalMember target, FunctionHeader header) {
34
+		this.target = target;
35
+		this.header = header;
36
+	}
37
+	
38
+	@Override
39
+	public CodePosition getPosition() {
40
+		return target.position;
41
+	}
42
+	
43
+	public String getCanonicalName() {
44
+		return target.getCanonicalName();
45
+	}
46
+	
47
+	@Override
48
+	public String describe() {
49
+		return target.describe();
50
+	}
51
+	
52
+	public <T> T getTag(Class<T> cls) {
53
+		return target.getTag(cls);
54
+	}
55
+	
56
+	public BuiltinID getBuiltin() {
57
+		return target.builtin;
58
+	}
59
+	
60
+	public boolean isStatic() {
61
+		return target.isStatic();
62
+	}
63
+	
64
+	public boolean isConstructor() {
65
+		return target.getKind() == FunctionalKind.CONSTRUCTOR;
66
+	}
67
+	
68
+	public boolean isOperator() {
69
+		return target.getKind() == FunctionalKind.OPERATOR;
70
+	}
71
+	
72
+	public OperatorType getOperator() {
73
+		return ((OperatorMember) target).operator;
74
+	}
75
+	
76
+	public String getMethodName() {
77
+		return ((MethodMember) target).name;
78
+	}
79
+	
80
+	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
81
+		return new CallExpression(position, target, this, instancedHeader, arguments, scope);
82
+	}
83
+	
84
+	public final Expression call(CodePosition position, Expression target, CallArguments arguments, TypeScope scope) {
85
+		return call(position, target, header, arguments, scope);
86
+	}
87
+	
88
+	public Expression callWithComparator(CodePosition position, CompareType comparison, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
89
+		return new CompareExpression(position, target, arguments.arguments[0], this, comparison, scope);
90
+	}
91
+	
92
+	public Expression callStatic(CodePosition position, ITypeID target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
93
+		return new CallStaticExpression(position, target, this, instancedHeader, arguments, scope);
94
+	}
95
+}

+ 54
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/GetterMemberRef.java Bestand weergeven

@@ -0,0 +1,54 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.expression.Expression;
9
+import org.openzen.zenscript.codemodel.expression.GetterExpression;
10
+import org.openzen.zenscript.codemodel.expression.StaticGetterExpression;
11
+import org.openzen.zenscript.codemodel.member.GetterMember;
12
+import org.openzen.zenscript.codemodel.type.ITypeID;
13
+import org.openzen.zenscript.shared.CodePosition;
14
+
15
+/**
16
+ *
17
+ * @author Hoofdgebruiker
18
+ */
19
+public class GetterMemberRef implements DefinitionMemberRef {
20
+	public final GetterMember member;
21
+	public final ITypeID type;
22
+	
23
+	public GetterMemberRef(GetterMember member, ITypeID type) {
24
+		this.member = member;
25
+		this.type = type;
26
+	}
27
+
28
+	@Override
29
+	public CodePosition getPosition() {
30
+		return member.position;
31
+	}
32
+
33
+	@Override
34
+	public String describe() {
35
+		return member.describe();
36
+	}
37
+
38
+	@Override
39
+	public <T> T getTag(Class<T> type) {
40
+		return member.getTag(type);
41
+	}
42
+	
43
+	public boolean isStatic() {
44
+		return member.isStatic();
45
+	}
46
+	
47
+	public Expression get(CodePosition position, Expression target) {
48
+		return new GetterExpression(position, target, this);
49
+	}
50
+	
51
+	public Expression getStatic(CodePosition position) {
52
+		return new StaticGetterExpression(position, this);
53
+	}
54
+}

+ 39
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ImplementationMemberRef.java Bestand weergeven

@@ -0,0 +1,39 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.member.ImplementationMember;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class ImplementationMemberRef implements DefinitionMemberRef {
17
+	public final ImplementationMember member;
18
+	public final ITypeID implementsType;
19
+	
20
+	public ImplementationMemberRef(ImplementationMember member, ITypeID implementsType) {
21
+		this.member = member;
22
+		this.implementsType = implementsType;
23
+	}
24
+
25
+	@Override
26
+	public CodePosition getPosition() {
27
+		return member.position;
28
+	}
29
+
30
+	@Override
31
+	public String describe() {
32
+		return member.describe();
33
+	}
34
+
35
+	@Override
36
+	public <T> T getTag(Class<T> type) {
37
+		return member.getTag(type);
38
+	}
39
+}

+ 43
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/IteratorMemberRef.java Bestand weergeven

@@ -0,0 +1,43 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.member.IIteratorMember;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class IteratorMemberRef implements DefinitionMemberRef {
17
+	public final IIteratorMember target;
18
+	public final ITypeID[] types;
19
+	
20
+	public IteratorMemberRef(IIteratorMember target, ITypeID... types) {
21
+		this.target = target;
22
+		this.types = types;
23
+	}
24
+
25
+	@Override
26
+	public CodePosition getPosition() {
27
+		return target.getPosition();
28
+	}
29
+
30
+	@Override
31
+	public String describe() {
32
+		return target.describe();
33
+	}
34
+
35
+	@Override
36
+	public <T> T getTag(Class<T> type) {
37
+		return target.getTag(type);
38
+	}
39
+	
40
+	public int getLoopVariableCount() {
41
+		return types.length;
42
+	}
43
+}

+ 43
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/SetterMemberRef.java Bestand weergeven

@@ -0,0 +1,43 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.member.SetterMember;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class SetterMemberRef implements DefinitionMemberRef {
17
+	public final SetterMember member;
18
+	public final ITypeID type;
19
+	
20
+	public SetterMemberRef(SetterMember member, ITypeID type) {
21
+		this.member = member;
22
+		this.type = type;
23
+	}
24
+
25
+	@Override
26
+	public CodePosition getPosition() {
27
+		return member.position;
28
+	}
29
+
30
+	@Override
31
+	public String describe() {
32
+		return member.describe();
33
+	}
34
+
35
+	@Override
36
+	public <T> T getTag(Class<T> type) {
37
+		return member.getTag(type);
38
+	}
39
+	
40
+	public boolean isStatic() {
41
+		return member.isStatic();
42
+	}
43
+}

+ 33
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/TranslatedOperatorMemberRef.java Bestand weergeven

@@ -0,0 +1,33 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.expression.CallArguments;
10
+import org.openzen.zenscript.codemodel.expression.CallTranslator;
11
+import org.openzen.zenscript.codemodel.expression.Expression;
12
+import org.openzen.zenscript.codemodel.member.OperatorMember;
13
+import org.openzen.zenscript.codemodel.scope.TypeScope;
14
+import org.openzen.zenscript.shared.CodePosition;
15
+
16
+/**
17
+ *
18
+ * @author Hoofdgebruiker
19
+ */
20
+public class TranslatedOperatorMemberRef extends FunctionalMemberRef {
21
+	private final CallTranslator translator;
22
+	
23
+	public TranslatedOperatorMemberRef(OperatorMember member, FunctionHeader header, CallTranslator translator) {
24
+		super(member, header);
25
+		
26
+		this.translator = translator;
27
+	}
28
+
29
+	@Override
30
+	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
31
+		return translator.translate(new CallTranslator.Call(position, target, instancedHeader, arguments, scope));
32
+	}
33
+}

+ 35
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/VariantOptionRef.java Bestand weergeven

@@ -0,0 +1,35 @@
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.member.ref;
7
+
8
+import org.openzen.zenscript.codemodel.definition.VariantDefinition;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class VariantOptionRef {
16
+	private final VariantDefinition.Option option;
17
+	public final ITypeID[] types;
18
+	
19
+	public VariantOptionRef(VariantDefinition.Option option, ITypeID[] types) {
20
+		this.option = option;
21
+		this.types = types;
22
+	}
23
+	
24
+	public String getName() {
25
+		return option.name;
26
+	}
27
+	
28
+	public ITypeID getParameterType(int index) {
29
+		return types[index];
30
+	}
31
+	
32
+	public <T> T getTag(Class<T> type) {
33
+		return option.getTag(type);
34
+	}
35
+}

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialMemberGroupExpression.java Bestand weergeven

@@ -12,7 +12,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
12 12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13 13
 import org.openzen.zenscript.codemodel.expression.Expression;
14 14
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
15
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
15
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
16 16
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
17 17
 import org.openzen.zenscript.codemodel.type.GenericName;
18 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -38,10 +38,10 @@ public class PartialMemberGroupExpression implements IPartialExpression {
38 38
 		this.allowStaticUsage = allowStaticMembers;
39 39
 	}
40 40
 	
41
-	public PartialMemberGroupExpression(CodePosition position, Expression target, FunctionalMember member, ITypeID[] typeArguments, boolean allowStaticMembers) {
41
+	public PartialMemberGroupExpression(CodePosition position, Expression target, String name, FunctionalMemberRef member, ITypeID[] typeArguments, boolean allowStaticMembers) {
42 42
 		this.position = position;
43 43
 		this.target = target;
44
-		this.group = DefinitionMemberGroup.forMethod(member);
44
+		this.group = DefinitionMemberGroup.forMethod(name, member);
45 45
 		this.typeArguments = typeArguments;
46 46
 		this.allowStaticUsage = allowStaticMembers;
47 47
 	}

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java Bestand weergeven

@@ -11,7 +11,7 @@ import java.util.stream.Collectors;
11 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12 12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13 13
 import org.openzen.zenscript.codemodel.expression.Expression;
14
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
14
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
15 15
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
16 16
 import org.openzen.zenscript.codemodel.type.GenericName;
17 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -24,8 +24,8 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
24 24
  * @author Hoofdgebruiker
25 25
  */
26 26
 public class PartialStaticMemberGroupExpression implements IPartialExpression {
27
-	public static PartialStaticMemberGroupExpression forMethod(CodePosition position, ITypeID target, FunctionalMember method, ITypeID[] typeArguments) {
28
-		DefinitionMemberGroup group = new DefinitionMemberGroup(true, method.getInformalName());
27
+	public static PartialStaticMemberGroupExpression forMethod(CodePosition position, String name, ITypeID target, FunctionalMemberRef method, ITypeID[] typeArguments) {
28
+		DefinitionMemberGroup group = new DefinitionMemberGroup(true, name);
29 29
 		group.addMethod(method, TypeMemberPriority.SPECIFIED);
30 30
 		return new PartialStaticMemberGroupExpression(position, target, group, typeArguments);
31 31
 	}
@@ -49,7 +49,7 @@ public class PartialStaticMemberGroupExpression implements IPartialExpression {
49 49
 
50 50
 	@Override
51 51
 	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
52
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
52
+		return group.predictCallTypes(scope, hints, arguments);
53 53
 	}
54 54
 	
55 55
 	@Override

+ 4
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java Bestand weergeven

@@ -41,7 +41,7 @@ public class PartialTypeExpression implements IPartialExpression {
41 41
 
42 42
 	@Override
43 43
 	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
44
-		return new List[arguments];
44
+		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).predictCallTypes(scope, hints, arguments);
45 45
 	}
46 46
 	
47 47
 	@Override
@@ -61,6 +61,9 @@ public class PartialTypeExpression implements IPartialExpression {
61 61
 
62 62
 	@Override
63 63
 	public Expression call(CodePosition position, TypeScope scope, List<ITypeID> hints, CallArguments arguments) {
64
+		if (arguments.getNumberOfTypeArguments() == 0 && typeParameters.length > 0)
65
+			arguments = new CallArguments(typeParameters, arguments.arguments);
66
+		
64 67
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).callStatic(position, type, scope, arguments);
65 68
 	}
66 69
 

+ 3
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ImplementationScope.java Bestand weergeven

@@ -5,10 +5,12 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.scope;
7 7
 
8
+import java.util.Collections;
8 9
 import java.util.List;
9 10
 import java.util.function.Function;
10 11
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11 12
 import org.openzen.zenscript.codemodel.FunctionHeader;
13
+import org.openzen.zenscript.codemodel.GenericMapper;
12 14
 import org.openzen.zenscript.codemodel.expression.Expression;
13 15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
14 16
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
@@ -41,7 +43,7 @@ public class ImplementationScope extends BaseScope {
41 43
 		interfaceMembers.copyMembersTo(implementation.position, interfaceMembers, TypeMemberPriority.INHERITED);
42 44
 		
43 45
 		for (IDefinitionMember member : implementation.members) {
44
-			member.registerTo(members, TypeMemberPriority.SPECIFIED);
46
+			member.registerTo(members, TypeMemberPriority.SPECIFIED, new GenericMapper(outer.getTypeRegistry(), Collections.emptyMap()));
45 47
 		}
46 48
 	}
47 49
 

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/ForeachStatement.java Bestand weergeven

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.statement;
8 8
 import java.util.function.Consumer;
9 9
 import org.openzen.zenscript.codemodel.expression.Expression;
10 10
 import org.openzen.zenscript.codemodel.expression.ExpressionTransformer;
11
-import org.openzen.zenscript.codemodel.member.IIteratorMember;
11
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
12 12
 import org.openzen.zenscript.shared.CodePosition;
13 13
 import org.openzen.zenscript.shared.ConcatMap;
14 14
 
@@ -19,10 +19,10 @@ import org.openzen.zenscript.shared.ConcatMap;
19 19
 public class ForeachStatement extends LoopStatement {
20 20
 	public final VarStatement[] loopVariables;
21 21
 	public final Expression list;
22
-	public final IIteratorMember iterator;
22
+	public final IteratorMemberRef iterator;
23 23
 	public Statement content;
24 24
 	
25
-	public ForeachStatement(CodePosition position, VarStatement[] loopVariables, IIteratorMember iterator, Expression list) {
25
+	public ForeachStatement(CodePosition position, VarStatement[] loopVariables, IteratorMemberRef iterator, Expression list) {
26 26
 		super(position, loopVariables[0].name, null); // TODO: thrown type
27 27
 		
28 28
 		this.loopVariables = loopVariables;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ArrayTypeID.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10 10
 
11 11
 /**
@@ -50,8 +50,8 @@ public class ArrayTypeID implements ITypeID {
50 50
 	}
51 51
 	
52 52
 	@Override
53
-	public ArrayTypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
54
-		return registry.getArray(elementType.withGenericArguments(registry, arguments), dimension);
53
+	public ArrayTypeID instance(GenericMapper mapper) {
54
+		return mapper.registry.getArray(elementType.instance(mapper), dimension);
55 55
 	}
56 56
 
57 57
 	@Override

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10 10
 
11 11
 /**
@@ -22,10 +22,10 @@ public class AssocTypeID implements ITypeID {
22 22
 	}
23 23
 	
24 24
 	@Override
25
-	public AssocTypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
26
-		return registry.getAssociative(
27
-				keyType.withGenericArguments(registry, arguments),
28
-				valueType.withGenericArguments(registry, arguments));
25
+	public AssocTypeID instance(GenericMapper mapper) {
26
+		return mapper.registry.getAssociative(
27
+				keyType.instance(mapper),
28
+				valueType.instance(mapper));
29 29
 	}
30 30
 	
31 31
 	@Override

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java Bestand weergeven

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Collections;
9 9
 import java.util.List;
10
-import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 12
 
13 13
 /**
@@ -43,7 +43,7 @@ public enum BasicTypeID implements ITypeID {
43 43
 	}
44 44
 	
45 45
 	@Override
46
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
46
+	public ITypeID instance(GenericMapper mapper) {
47 47
 		return this;
48 48
 	}
49 49
 	

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ConstTypeID.java Bestand weergeven

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
9 8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12 12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -23,8 +23,8 @@ public class ConstTypeID implements ITypeID {
23 23
 	}
24 24
 	
25 25
 	@Override
26
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
27
-		return registry.getModified(TypeMembers.MODIFIER_CONST, baseType.withGenericArguments(registry, arguments));
26
+	public ITypeID instance(GenericMapper mapper) {
27
+		return mapper.registry.getModified(TypeMembers.MODIFIER_CONST, baseType.instance(mapper));
28 28
 	}
29 29
 	
30 30
 	@Override

+ 6
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java Bestand weergeven

@@ -10,6 +10,7 @@ import java.util.Collections;
10 10
 import java.util.HashMap;
11 11
 import java.util.Map;
12 12
 import java.util.Objects;
13
+import org.openzen.zenscript.codemodel.GenericMapper;
13 14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14 15
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
15 16
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
@@ -71,7 +72,7 @@ public class DefinitionTypeID implements ITypeID {
71 72
 			for (int i = 0; i < typeParameters.length; i++)
72 73
 				genericSuperArguments.put(definition.genericParameters[i], typeParameters[i]);
73 74
 			
74
-			superType = definition.superType.withGenericArguments(registry, genericSuperArguments);
75
+			superType = definition.superType.instance(new GenericMapper(registry, genericSuperArguments));
75 76
 		}
76 77
 		this.superType = superType;
77 78
 	}
@@ -86,7 +87,7 @@ public class DefinitionTypeID implements ITypeID {
86 87
 	}
87 88
 	
88 89
 	@Override
89
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
90
+	public ITypeID instance(GenericMapper mapper) {
90 91
 		if (!hasTypeParameters() && outerTypeParameters.isEmpty())
91 92
 			return this;
92 93
 		
@@ -96,7 +97,7 @@ public class DefinitionTypeID implements ITypeID {
96 97
 			for (int i = 0; i < typeParameters.length; i++) {
97 98
 				// TODO: why was this line written like this?
98 99
 				//instancedArguments[i] = arguments.containsKey(definition.genericParameters[i]) ? arguments.get(definition.genericParameters[i]) : typeParameters[i].withGenericArguments(registry, arguments);
99
-				instancedArguments[i] = typeParameters[i].withGenericArguments(registry, arguments);
100
+				instancedArguments[i] = typeParameters[i].instance(mapper);
100 101
 			}
101 102
 		}
102 103
 		
@@ -106,9 +107,9 @@ public class DefinitionTypeID implements ITypeID {
106 107
 		} else {
107 108
 			instancedOuter = new HashMap<>();
108 109
 			for (Map.Entry<TypeParameter, ITypeID> entry : outerTypeParameters.entrySet())
109
-				instancedOuter.put(entry.getKey(), entry.getValue().withGenericArguments(registry, arguments));
110
+				instancedOuter.put(entry.getKey(), entry.getValue().instance(mapper));
110 111
 		}
111
-		return registry.getForDefinition(definition, instancedArguments, instancedOuter);
112
+		return mapper.registry.getForDefinition(definition, instancedArguments, instancedOuter);
112 113
 	}
113 114
 	
114 115
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/FunctionTypeID.java Bestand weergeven

@@ -6,9 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Arrays;
9
-import java.util.Map;
10 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
11 10
 import org.openzen.zenscript.codemodel.FunctionParameter;
11
+import org.openzen.zenscript.codemodel.GenericMapper;
12 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 
14 14
 /**
@@ -23,8 +23,8 @@ public class FunctionTypeID implements ITypeID {
23 23
 	}
24 24
 	
25 25
 	@Override
26
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
27
-		return registry.getFunction(header.withGenericArguments(registry, arguments));
26
+	public ITypeID instance(GenericMapper mapper) {
27
+		return mapper.registry.getFunction(mapper.map(header));
28 28
 	}
29 29
 	
30 30
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericMapTypeID.java Bestand weergeven

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
9 8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 11
 
12 12
 /**
@@ -43,8 +43,8 @@ public class GenericMapTypeID implements ITypeID {
43 43
 	}
44 44
 
45 45
 	@Override
46
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
47
-		return registry.getGenericMap(value.withGenericArguments(registry, arguments), key);
46
+	public ITypeID instance(GenericMapper mapper) {
47
+		return mapper.registry.getGenericMap(value.instance(mapper), key);
48 48
 	}
49 49
 
50 50
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10 10
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11 11
 
@@ -25,8 +25,8 @@ public class GenericTypeID implements ITypeID {
25 25
 	}
26 26
 	
27 27
 	@Override
28
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
29
-		return arguments.containsKey(parameter) ? arguments.get(parameter) : this;
28
+	public ITypeID instance(GenericMapper mapper) {
29
+		return mapper.map(this);
30 30
 	}
31 31
 
32 32
 	@Override

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ITypeID.java Bestand weergeven

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 12
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
@@ -53,7 +54,7 @@ public interface ITypeID {
53 54
 		return false;
54 55
 	}
55 56
 	
56
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments);
57
+	public ITypeID instance(GenericMapper mapper);
57 58
 	
58 59
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters);
59 60
 	

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

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.type;
7 7
 
8 8
 import java.util.Arrays;
9 9
 import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 12
 
12 13
 /**
@@ -46,11 +47,11 @@ public class IteratorTypeID implements ITypeID {
46 47
 	}
47 48
 
48 49
 	@Override
49
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
50
+	public ITypeID instance(GenericMapper mapper) {
50 51
 		ITypeID[] instanced = new ITypeID[iteratorTypes.length];
51 52
 		for (int i = 0; i < iteratorTypes.length; i++)
52
-			instanced[i] = iteratorTypes[i].withGenericArguments(registry, arguments);
53
-		return registry.getIterator(instanced);
53
+			instanced[i] = iteratorTypes[i].instance(mapper);
54
+		return mapper.registry.getIterator(instanced);
54 55
 	}
55 56
 
56 57
 	@Override

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java Bestand weergeven

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
9 8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12 12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
@@ -23,8 +23,8 @@ public class OptionalTypeID implements ITypeID {
23 23
 	}
24 24
 	
25 25
 	@Override
26
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
27
-		return registry.getModified(TypeMembers.MODIFIER_OPTIONAL, baseType.withGenericArguments(registry, arguments));
26
+	public ITypeID instance(GenericMapper mapper) {
27
+		return mapper.registry.getModified(TypeMembers.MODIFIER_OPTIONAL, baseType.instance(mapper));
28 28
 	}
29 29
 
30 30
 	@Override

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/RangeTypeID.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type;
7 7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9 9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10 10
 
11 11
 /**
@@ -24,10 +24,10 @@ public class RangeTypeID implements ITypeID {
24 24
 	}
25 25
 	
26 26
 	@Override
27
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
28
-		return registry.getRange(
29
-				from.withGenericArguments(registry, arguments),
30
-				to.withGenericArguments(registry, arguments));
27
+	public ITypeID instance(GenericMapper mapper) {
28
+		return mapper.registry.getRange(
29
+				from.instance(mapper),
30
+				to.instance(mapper));
31 31
 	}
32 32
 
33 33
 	@Override

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/BuiltinID.java Bestand weergeven

@@ -396,6 +396,8 @@ public enum BuiltinID {
396 396
 	GENERICMAP_GETOPTIONAL,
397 397
 	GENERICMAP_PUT,
398 398
 	GENERICMAP_CONTAINS,
399
+	GENERICMAP_SIZE,
400
+	GENERICMAP_ISEMPTY,
399 401
 	GENERICMAP_HASHCODE,
400 402
 	GENERICMAP_EQUALS,
401 403
 	GENERICMAP_NOTEQUALS,

+ 42
- 43
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java Bestand weergeven

@@ -18,17 +18,17 @@ import org.openzen.zenscript.codemodel.expression.SetStaticFieldExpression;
18 18
 import org.openzen.zenscript.codemodel.expression.SetterExpression;
19 19
 import org.openzen.zenscript.codemodel.expression.StaticSetterExpression;
20 20
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
21
-import org.openzen.zenscript.codemodel.member.FieldMember;
22
-import org.openzen.zenscript.codemodel.member.SetterMember;
23 21
 import org.openzen.zenscript.codemodel.type.ITypeID;
24 22
 import org.openzen.zenscript.codemodel.CompareType;
25 23
 import org.openzen.zenscript.codemodel.FunctionHeader;
24
+import org.openzen.zenscript.codemodel.GenericMapper;
26 25
 import org.openzen.zenscript.codemodel.expression.ConstExpression;
27 26
 import org.openzen.zenscript.codemodel.expression.PostCallExpression;
28
-import org.openzen.zenscript.codemodel.member.ConstMember;
29
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
30
-import org.openzen.zenscript.codemodel.member.GetterMember;
31
-import org.openzen.zenscript.codemodel.member.OperatorMember;
27
+import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
28
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
29
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
30
+import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
31
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
32 32
 import org.openzen.zenscript.shared.CodePosition;
33 33
 import org.openzen.zenscript.shared.CompileException;
34 34
 import org.openzen.zenscript.shared.CompileExceptionCode;
@@ -39,17 +39,17 @@ import org.openzen.zenscript.codemodel.scope.TypeScope;
39 39
  * @author Hoofdgebruiker
40 40
  */
41 41
 public class DefinitionMemberGroup {
42
-	public static DefinitionMemberGroup forMethod(FunctionalMember member) {
43
-		DefinitionMemberGroup instance = new DefinitionMemberGroup(member.isStatic(), member.getInformalName());
42
+	public static DefinitionMemberGroup forMethod(String name, FunctionalMemberRef member) {
43
+		DefinitionMemberGroup instance = new DefinitionMemberGroup(member.isStatic(), name);
44 44
 		instance.addMethod(member, TypeMemberPriority.SPECIFIED);
45 45
 		return instance;
46 46
 	}
47 47
 	
48
-	private TypeMember<ConstMember> constant;
49
-	private TypeMember<FieldMember> field;
50
-	private TypeMember<GetterMember> getter;
51
-	private TypeMember<SetterMember> setter;
52
-	private final List<TypeMember<FunctionalMember>> methods = new ArrayList<>();
48
+	private TypeMember<ConstMemberRef> constant;
49
+	private TypeMember<FieldMemberRef> field;
50
+	private TypeMember<GetterMemberRef> getter;
51
+	private TypeMember<SetterMemberRef> setter;
52
+	private final List<TypeMember<FunctionalMemberRef>> methods = new ArrayList<>();
53 53
 	public final boolean isStatic;
54 54
 	public final String name;
55 55
 	
@@ -68,19 +68,19 @@ public class DefinitionMemberGroup {
68 68
 		if (other.setter != null)
69 69
 			setSetter(other.setter.member, priority);
70 70
 		
71
-		for (TypeMember<FunctionalMember> method : other.methods)
71
+		for (TypeMember<FunctionalMemberRef> method : other.methods)
72 72
 			addMethod(method.member, priority);
73 73
 	}
74 74
 	
75
-	public FieldMember getField() {
75
+	public FieldMemberRef getField() {
76 76
 		return this.field == null ? null : this.field.member;
77 77
 	}
78 78
 	
79
-	public GetterMember getGetter() {
79
+	public GetterMemberRef getGetter() {
80 80
 		return this.getter == null ? null : this.getter.member;
81 81
 	}
82 82
 	
83
-	public SetterMember getSetter() {
83
+	public SetterMemberRef getSetter() {
84 84
 		return this.setter == null ? null : this.setter.member;
85 85
 	}
86 86
 	
@@ -89,7 +89,7 @@ public class DefinitionMemberGroup {
89 89
 	}
90 90
 	
91 91
 	public boolean hasMethod(FunctionHeader header) {
92
-		for (TypeMember<FunctionalMember> method : methods) {
92
+		for (TypeMember<FunctionalMemberRef> method : methods) {
93 93
 			if (method.member.header.isEquivalentTo(header))
94 94
 				return true;
95 95
 		}
@@ -97,11 +97,11 @@ public class DefinitionMemberGroup {
97 97
 		return false;
98 98
 	}
99 99
 	
100
-	public List<TypeMember<FunctionalMember>> getMethodMembers() {
100
+	public List<TypeMember<FunctionalMemberRef>> getMethodMembers() {
101 101
 		return this.methods;
102 102
 	}
103 103
 	
104
-	public void setConst(ConstMember constant, TypeMemberPriority priority) {
104
+	public void setConst(ConstMemberRef constant, TypeMemberPriority priority) {
105 105
 		if (this.constant != null) {
106 106
 			this.constant = this.constant.resolve(new TypeMember<>(priority, constant));
107 107
 		} else {
@@ -109,7 +109,7 @@ public class DefinitionMemberGroup {
109 109
 		}
110 110
 	}
111 111
 	
112
-	public void setField(FieldMember field, TypeMemberPriority priority) {
112
+	public void setField(FieldMemberRef field, TypeMemberPriority priority) {
113 113
 		if (this.field != null) {
114 114
 			this.field = this.field.resolve(new TypeMember<>(priority, field));
115 115
 		} else {
@@ -117,7 +117,7 @@ public class DefinitionMemberGroup {
117 117
 		}
118 118
 	}
119 119
 	
120
-	public void setGetter(GetterMember getter, TypeMemberPriority priority) {
120
+	public void setGetter(GetterMemberRef getter, TypeMemberPriority priority) {
121 121
 		if (this.getter != null) {
122 122
 			this.getter = this.getter.resolve(new TypeMember<>(priority, getter));
123 123
 		} else {
@@ -125,7 +125,7 @@ public class DefinitionMemberGroup {
125 125
 		}
126 126
 	}
127 127
 	
128
-	public void setSetter(SetterMember setter, TypeMemberPriority priority) {
128
+	public void setSetter(SetterMemberRef setter, TypeMemberPriority priority) {
129 129
 		if (this.setter != null) {
130 130
 			this.setter = this.setter.resolve(new TypeMember<>(priority, setter));
131 131
 		} else {
@@ -133,7 +133,7 @@ public class DefinitionMemberGroup {
133 133
 		}
134 134
 	}
135 135
 	
136
-	public void addMethod(FunctionalMember method, TypeMemberPriority priority) {
136
+	public void addMethod(FunctionalMemberRef method, TypeMemberPriority priority) {
137 137
 		for (int i = 0; i < methods.size(); i++) {
138 138
 			if (methods.get(i).member.header.isEquivalentTo(method.header)) {
139 139
 				methods.set(i, methods.get(i).resolve(new TypeMember<>(priority, method)));
@@ -236,7 +236,7 @@ public class DefinitionMemberGroup {
236 236
 		for (int i = 0; i < result.length; i++)
237 237
 			result[i] = new ArrayList<>();
238 238
 		
239
-		for (TypeMember<FunctionalMember> method : methods) {
239
+		for (TypeMember<FunctionalMemberRef> method : methods) {
240 240
 			FunctionHeader header = method.member.header;
241 241
 			if (header.parameters.length != arguments)
242 242
 				continue;
@@ -245,7 +245,7 @@ public class DefinitionMemberGroup {
245 245
 				for (ITypeID resultHint : typeHints) {
246 246
 					Map<TypeParameter, ITypeID> mapping = new HashMap<>();
247 247
 					if (header.returnType.inferTypeParameters(scope.getMemberCache(), resultHint, mapping)) {
248
-						header = header.withGenericArguments(scope.getTypeRegistry(), mapping);
248
+						header = header.withGenericArguments(new GenericMapper(scope.getTypeRegistry(), mapping));
249 249
 						break;
250 250
 					}
251 251
 				}
@@ -261,8 +261,8 @@ public class DefinitionMemberGroup {
261 261
 	}
262 262
 	
263 263
 	public Expression call(CodePosition position, TypeScope scope, Expression target, CallArguments arguments, boolean allowStaticUsage) {
264
-		FunctionalMember method = selectMethod(position, scope, arguments, true, allowStaticUsage);
265
-		FunctionHeader instancedHeader = method.header.withGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
264
+		FunctionalMemberRef method = selectMethod(position, scope, arguments, true, allowStaticUsage);
265
+		FunctionHeader instancedHeader = method.header.fillGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
266 266
 		for (int i = 0; i < arguments.arguments.length; i++) {
267 267
 			arguments.arguments[i] = arguments.arguments[i].castImplicit(position, scope, instancedHeader.parameters[i].type);
268 268
 		}
@@ -274,12 +274,11 @@ public class DefinitionMemberGroup {
274 274
 		if (methods.isEmpty())
275 275
 			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "There is no such operator");
276 276
 		
277
-		FunctionalMember method = methods.get(0).member;
278
-		if (!(method instanceof OperatorMember)) {
277
+		FunctionalMemberRef method = methods.get(0).member;
278
+		if (!method.isOperator()) {
279 279
 			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "Member is not an operator");
280 280
 		}
281
-		OperatorMember operator = (OperatorMember) method;
282
-		return new PostCallExpression(position, target, operator, operator.header);
281
+		return new PostCallExpression(position, target, method, method.header);
283 282
 	}
284 283
 	
285 284
 	public Expression callWithComparator(
@@ -288,20 +287,20 @@ public class DefinitionMemberGroup {
288 287
 			Expression target,
289 288
 			CallArguments arguments,
290 289
 			CompareType compareType) {
291
-		FunctionalMember method = selectMethod(position, scope, arguments, true, false);
292
-		FunctionHeader instancedHeader = method.header.withGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
290
+		FunctionalMemberRef method = selectMethod(position, scope, arguments, true, false);
291
+		FunctionHeader instancedHeader = method.header.fillGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
293 292
 		return method.callWithComparator(position, compareType, target, instancedHeader, arguments, scope);
294 293
 	}
295 294
 	
296 295
 	public Expression callStatic(CodePosition position, ITypeID target, TypeScope scope, CallArguments arguments) {
297
-		FunctionalMember method = selectMethod(position, scope, arguments, false, true);
298
-		FunctionHeader instancedHeader = method.header.withGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
296
+		FunctionalMemberRef method = selectMethod(position, scope, arguments, false, true);
297
+		FunctionHeader instancedHeader = method.header.fillGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
299 298
 		return method.callStatic(position, target, instancedHeader, arguments, scope);
300 299
 	}
301 300
 	
302
-	public FunctionalMember selectMethod(CodePosition position, TypeScope scope, CallArguments arguments, boolean allowNonStatic, boolean allowStatic) {
301
+	public FunctionalMemberRef selectMethod(CodePosition position, TypeScope scope, CallArguments arguments, boolean allowNonStatic, boolean allowStatic) {
303 302
 		// try to match with exact types
304
-		outer: for (TypeMember<FunctionalMember> method : methods) {
303
+		outer: for (TypeMember<FunctionalMemberRef> method : methods) {
305 304
 			if (!(method.member.isStatic() ? allowStatic : allowNonStatic))
306 305
 				continue;
307 306
 			
@@ -312,7 +311,7 @@ public class DefinitionMemberGroup {
312 311
 				continue;
313 312
 			
314 313
 			if (arguments.typeArguments.length > 0) {
315
-				header = header.withGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
314
+				header = header.fillGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
316 315
 			}
317 316
 			
318 317
 			for (int i = 0; i < header.parameters.length; i++) {
@@ -324,8 +323,8 @@ public class DefinitionMemberGroup {
324 323
 		}
325 324
 		
326 325
 		// try to match with approximate types
327
-		FunctionalMember selected = null;
328
-		outer: for (TypeMember<FunctionalMember> method : methods) {
326
+		FunctionalMemberRef selected = null;
327
+		outer: for (TypeMember<FunctionalMemberRef> method : methods) {
329 328
 			if (!(method.member.isStatic() ? allowStatic : allowNonStatic))
330 329
 				continue;
331 330
 			
@@ -336,7 +335,7 @@ public class DefinitionMemberGroup {
336 335
 				continue;
337 336
 			
338 337
 			if (arguments.typeArguments.length > 0) {
339
-				header = header.withGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
338
+				header = header.fillGenericArguments(scope.getTypeRegistry(), arguments.typeArguments);
340 339
 			}
341 340
 			
342 341
 			for (int i = 0; i < header.parameters.length; i++) {
@@ -361,7 +360,7 @@ public class DefinitionMemberGroup {
361 360
 				throw new CompileException(position, CompileExceptionCode.CALL_NO_VALID_METHOD, "This type has no " + name);
362 361
 			}
363 362
 			
364
-			outer: for (TypeMember<FunctionalMember> method : methods) {
363
+			outer: for (TypeMember<FunctionalMemberRef> method : methods) {
365 364
 				if (!(method.member.isStatic() ? allowStatic : allowNonStatic)) {
366 365
 					message.append(method.member.isStatic() ? "Method must not be static" : "Method must be static").append('\n');
367 366
 					continue;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMember.java Bestand weergeven

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.type.member;
7 7
 
8
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
8
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
9 9
 import org.openzen.zenscript.shared.CompileException;
10 10
 import org.openzen.zenscript.shared.CompileExceptionCode;
11 11
 
@@ -13,7 +13,7 @@ import org.openzen.zenscript.shared.CompileExceptionCode;
13 13
  *
14 14
  * @author Hoofdgebruiker
15 15
  */
16
-public class TypeMember<T extends IDefinitionMember> {
16
+public class TypeMember<T extends DefinitionMemberRef> {
17 17
 	public final TypeMemberPriority priority;
18 18
 	public final T member;
19 19
 	

+ 772
- 817
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 64
- 74
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java Bestand weergeven

@@ -11,7 +11,6 @@ import java.util.List;
11 11
 import java.util.Map;
12 12
 import org.openzen.zenscript.codemodel.CompareType;
13 13
 import org.openzen.zenscript.codemodel.OperatorType;
14
-import org.openzen.zenscript.codemodel.definition.VariantDefinition;
15 14
 import org.openzen.zenscript.codemodel.expression.CallArguments;
16 15
 import org.openzen.zenscript.codemodel.expression.CheckNullExpression;
17 16
 import org.openzen.zenscript.codemodel.expression.Expression;
@@ -20,21 +19,17 @@ import org.openzen.zenscript.codemodel.expression.MakeConstExpression;
20 19
 import org.openzen.zenscript.codemodel.expression.NullExpression;
21 20
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
22 21
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
23
-import org.openzen.zenscript.codemodel.member.CallerMember;
24
-import org.openzen.zenscript.codemodel.member.CasterMember;
25
-import org.openzen.zenscript.codemodel.member.ConstMember;
26
-import org.openzen.zenscript.codemodel.member.ConstructorMember;
27
-import org.openzen.zenscript.codemodel.member.DestructorMember;
28 22
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
29
-import org.openzen.zenscript.codemodel.member.FieldMember;
30
-import org.openzen.zenscript.codemodel.member.FunctionalMember;
31
-import org.openzen.zenscript.codemodel.member.GetterMember;
32
-import org.openzen.zenscript.codemodel.member.IIteratorMember;
33
-import org.openzen.zenscript.codemodel.member.ImplementationMember;
34 23
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
35
-import org.openzen.zenscript.codemodel.member.MethodMember;
36
-import org.openzen.zenscript.codemodel.member.OperatorMember;
37
-import org.openzen.zenscript.codemodel.member.SetterMember;
24
+import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
25
+import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
26
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
27
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
28
+import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
29
+import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
30
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
31
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
32
+import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
38 33
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
39 34
 import org.openzen.zenscript.codemodel.partial.PartialMemberGroupExpression;
40 35
 import org.openzen.zenscript.codemodel.partial.PartialStaticMemberGroupExpression;
@@ -60,12 +55,12 @@ public final class TypeMembers {
60 55
 	private final LocalMemberCache cache;
61 56
 	public final ITypeID type;
62 57
 	
63
-	private final List<TypeMember<CasterMember>> casters = new ArrayList<>();
64
-	private final List<TypeMember<ImplementationMember>> implementations = new ArrayList<>();
65
-	private final List<TypeMember<IIteratorMember>> iterators = new ArrayList<>();
58
+	private final List<TypeMember<CasterMemberRef>> casters = new ArrayList<>();
59
+	private final List<TypeMember<ImplementationMemberRef>> implementations = new ArrayList<>();
60
+	private final List<TypeMember<IteratorMemberRef>> iterators = new ArrayList<>();
66 61
 	
67 62
 	private final Map<String, EnumConstantMember> enumMembers = new HashMap<>();
68
-	private final Map<String, VariantDefinition.Option> variantOptions = new HashMap<>();
63
+	private final Map<String, VariantOptionRef> variantOptions = new HashMap<>();
69 64
 	private final Map<String, DefinitionMemberGroup> members = new HashMap<>();
70 65
 	private final Map<String, InnerDefinition> innerTypes = new HashMap<>();
71 66
 	private final Map<OperatorType, DefinitionMemberGroup> operators = new HashMap<>();
@@ -91,10 +86,10 @@ public final class TypeMembers {
91 86
 				return true;
92 87
 		}
93 88
 		
94
-		for (TypeMember<ImplementationMember> implementation : implementations) {
95
-			if (implementation.member.type.equals(other)) // TODO: for some reason duplicate types are generated
89
+		for (TypeMember<ImplementationMemberRef> implementation : implementations) {
90
+			if (implementation.member.implementsType.equals(other)) // TODO: for some reason duplicate types are generated
96 91
 				return true;
97
-			if (cache.get(implementation.member.type).extendsOrImplements(other))
92
+			if (cache.get(implementation.member.implementsType).extendsOrImplements(other))
98 93
 				return true;
99 94
 		}
100 95
 		
@@ -123,7 +118,7 @@ public final class TypeMembers {
123 118
 		
124 119
 		for (Map.Entry<String, EnumConstantMember> entry : enumMembers.entrySet())
125 120
 			other.addEnumMember(entry.getValue(), priority);
126
-		for (Map.Entry<String, VariantDefinition.Option> entry : variantOptions.entrySet())
121
+		for (Map.Entry<String, VariantOptionRef> entry : variantOptions.entrySet())
127 122
 			other.addVariantOption(entry.getValue());
128 123
 		for (Map.Entry<String, DefinitionMemberGroup> entry : members.entrySet())
129 124
 			other.getOrCreateGroup(entry.getKey(), entry.getValue().isStatic).merge(position, entry.getValue(), priority);
@@ -145,29 +140,29 @@ public final class TypeMembers {
145 140
 		return null;
146 141
 	}
147 142
 	
148
-	public void addConstructor(ConstructorMember constructor, TypeMemberPriority priority) {
143
+	public void addConstructor(FunctionalMemberRef constructor, TypeMemberPriority priority) {
149 144
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, priority);
150 145
 	}
151 146
 	
152
-	public void addConstructor(ConstructorMember constructor) {
147
+	public void addConstructor(FunctionalMemberRef constructor) {
153 148
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, TypeMemberPriority.SPECIFIED);
154 149
 	}
155 150
 	
156
-	public void addDestructor(DestructorMember destructor, TypeMemberPriority priority) {
151
+	public void addDestructor(FunctionalMemberRef destructor, TypeMemberPriority priority) {
157 152
 		getOrCreateGroup(OperatorType.DESTRUCTOR).addMethod(destructor, priority);
158 153
 	}
159 154
 	
160
-	public void addCaller(CallerMember caller, TypeMemberPriority priority) {
155
+	public void addCaller(FunctionalMemberRef caller, TypeMemberPriority priority) {
161 156
 		getOrCreateGroup(OperatorType.CALL).addMethod(caller, priority);
162 157
 	}
163 158
 	
164
-	public void addCaster(CasterMember caster) {
159
+	public void addCaster(CasterMemberRef caster) {
165 160
 		addCaster(caster, TypeMemberPriority.SPECIFIED);
166 161
 	}
167 162
 	
168
-	public void addCaster(CasterMember caster, TypeMemberPriority priority) {
163
+	public void addCaster(CasterMemberRef caster, TypeMemberPriority priority) {
169 164
 		for (int i = 0; i < casters.size(); i++) {
170
-			if (casters.get(i).member.getTargetType() == caster.toType) {
165
+			if (casters.get(i).member.toType == caster.toType) {
171 166
 				casters.set(i, casters.get(i).resolve(new TypeMember<>(priority, caster)));
172 167
 				return;
173 168
 			}
@@ -176,70 +171,65 @@ public final class TypeMembers {
176 171
 		casters.add(new TypeMember<>(priority, caster));
177 172
 	}
178 173
 	
179
-	public void addConst(ConstMember member) {
180
-		DefinitionMemberGroup group = getOrCreateGroup(member.name, true);
174
+	public void addConst(ConstMemberRef member) {
175
+		DefinitionMemberGroup group = getOrCreateGroup(member.member.name, true);
181 176
 		group.setConst(member, TypeMemberPriority.SPECIFIED);
182 177
 	}
183 178
 	
184
-	public void addField(FieldMember member) {
179
+	public void addField(FieldMemberRef member) {
185 180
 		addField(member, TypeMemberPriority.SPECIFIED);
186 181
 	}
187 182
 	
188
-	public void addField(FieldMember member, TypeMemberPriority priority) {
189
-		DefinitionMemberGroup group = getOrCreateGroup(member.name, member.isStatic());
183
+	public void addField(FieldMemberRef member, TypeMemberPriority priority) {
184
+		DefinitionMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
190 185
 		group.setField(member, priority);
191 186
 	}
192 187
 	
193
-	public void addGetter(GetterMember member) {
188
+	public void addGetter(GetterMemberRef member) {
194 189
 		addGetter(member, TypeMemberPriority.SPECIFIED);
195 190
 	}
196 191
 	
197
-	public void addGetter(GetterMember member, TypeMemberPriority priority) {
198
-		DefinitionMemberGroup group = getOrCreateGroup(member.name, member.isStatic());
192
+	public void addGetter(GetterMemberRef member, TypeMemberPriority priority) {
193
+		DefinitionMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
199 194
 		group.setGetter(member, priority);
200 195
 	}
201 196
 	
202
-	public void addSetter(SetterMember member) {
197
+	public void addSetter(SetterMemberRef member) {
203 198
 		addSetter(member, TypeMemberPriority.SPECIFIED);
204 199
 	}
205 200
 	
206
-	public void addSetter(SetterMember member, TypeMemberPriority priority) {
207
-		DefinitionMemberGroup group = getOrCreateGroup(member.name, member.isStatic());
201
+	public void addSetter(SetterMemberRef member, TypeMemberPriority priority) {
202
+		DefinitionMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
208 203
 		group.setSetter(member, priority);
209 204
 	}
210 205
 	
211
-	public void addMethod(MethodMember member) {
212
-		addMethod(member, TypeMemberPriority.SPECIFIED);
206
+	public void addMethod(String name, FunctionalMemberRef member) {
207
+		addMethod(name, member, TypeMemberPriority.SPECIFIED);
213 208
 	}
214 209
 	
215
-	public void addMethod(MethodMember member, TypeMemberPriority priority) {
216
-		DefinitionMemberGroup group = getOrCreateGroup(member.name, member.isStatic());
210
+	public void addMethod(String name, FunctionalMemberRef member, TypeMemberPriority priority) {
211
+		DefinitionMemberGroup group = getOrCreateGroup(name, member.isStatic());
217 212
 		group.addMethod(member, priority);
218 213
 	}
219 214
 	
220
-	public void addOperator(OperatorMember member) {
221
-		addOperator(member, TypeMemberPriority.SPECIFIED);
215
+	public void addOperator(OperatorType operator, FunctionalMemberRef member) {
216
+		addOperator(operator, member, TypeMemberPriority.SPECIFIED);
222 217
 	}
223 218
 	
224 219
 	public boolean hasOperator(OperatorType operator) {
225 220
 		return operators.containsKey(operator) && operators.get(operator).hasMethods();
226 221
 	}
227 222
 	
228
-	public void addOperator(OperatorMember member, TypeMemberPriority priority) {
229
-		DefinitionMemberGroup group = getOrCreateGroup(member.operator);
230
-		group.addMethod(member, priority);
231
-	}
232
-	
233
-	public void addOperator(OperatorType operator, FunctionalMember member, TypeMemberPriority priority) {
223
+	public void addOperator(OperatorType operator, FunctionalMemberRef member, TypeMemberPriority priority) {
234 224
 		DefinitionMemberGroup group = getOrCreateGroup(operator);
235 225
 		group.addMethod(member, priority);
236 226
 	}
237 227
 	
238
-	public void addVariantOption(VariantDefinition.Option option) {
239
-		variantOptions.put(option.name, option);
228
+	public void addVariantOption(VariantOptionRef option) {
229
+		variantOptions.put(option.getName(), option);
240 230
 	}
241 231
 	
242
-	public void addIterator(IIteratorMember iterator, TypeMemberPriority priority) {
232
+	public void addIterator(IteratorMemberRef iterator, TypeMemberPriority priority) {
243 233
 		for (int i = 0; i < iterators.size(); i++) {
244 234
 			if (iterators.get(i).member.getLoopVariableCount() == iterator.getLoopVariableCount()) {
245 235
 				iterators.set(i, iterators.get(i).resolve(new TypeMember<>(priority, iterator)));
@@ -250,9 +240,9 @@ public final class TypeMembers {
250 240
 		iterators.add(new TypeMember<>(priority, iterator));
251 241
 	}
252 242
 	
253
-	public void addImplementation(ImplementationMember member, TypeMemberPriority priority) {
243
+	public void addImplementation(ImplementationMemberRef member, TypeMemberPriority priority) {
254 244
 		for (int i = 0; i < implementations.size(); i++) {
255
-			if (implementations.get(i).member.type == member.type) {
245
+			if (implementations.get(i).member.implementsType == member.implementsType) {
256 246
 				implementations.set(i, implementations.get(i).resolve(new TypeMember<>(priority, member)));
257 247
 				return;
258 248
 			}
@@ -290,20 +280,20 @@ public final class TypeMembers {
290 280
 		return enumMembers.get(name);
291 281
 	}
292 282
 	
293
-	public VariantDefinition.Option getVariantOption(String name) {
283
+	public VariantOptionRef getVariantOption(String name) {
294 284
 		return variantOptions.get(name);
295 285
 	}
296 286
 	
297 287
 	public Expression compare(CodePosition position, TypeScope scope, CompareType operator, Expression left, Expression right) {
298 288
 		if (operator == CompareType.EQ) {
299 289
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.EQUALS);
300
-			for (TypeMember<FunctionalMember> member : equal.getMethodMembers()) {
290
+			for (TypeMember<FunctionalMemberRef> member : equal.getMethodMembers()) {
301 291
 				if (member.member.header.accepts(scope, right))
302 292
 					return equal.call(position, scope, left, new CallArguments(right), false);
303 293
 			}
304 294
 		} else if (operator == CompareType.NE) {
305 295
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.NOTEQUALS);
306
-			for (TypeMember<FunctionalMember> member : equal.getMethodMembers()) {
296
+			for (TypeMember<FunctionalMemberRef> member : equal.getMethodMembers()) {
307 297
 				if (member.member.header.accepts(scope, right)) {
308 298
 					return equal.call(position, scope, left, new CallArguments(right), false);
309 299
 				}
@@ -324,8 +314,8 @@ public final class TypeMembers {
324 314
 		return members.call(position, scope, a, new CallArguments(b, c), false);
325 315
 	}
326 316
 	
327
-	public IIteratorMember getIterator(int variables) {
328
-		for (TypeMember<IIteratorMember> iterator : iterators)
317
+	public IteratorMemberRef getIterator(int variables) {
318
+		for (TypeMember<IteratorMemberRef> iterator : iterators)
329 319
 			if (iterator.member.getLoopVariableCount() == variables)
330 320
 				return iterator.member;
331 321
 		
@@ -333,9 +323,9 @@ public final class TypeMembers {
333 323
 	}
334 324
 	
335 325
 	public ITypeID[] getLoopTypes(int variables) {
336
-		for (TypeMember<IIteratorMember> iterator : iterators)
326
+		for (TypeMember<IteratorMemberRef> iterator : iterators)
337 327
 			if (iterator.member.getLoopVariableCount() == variables)
338
-				return iterator.member.getLoopVariableTypes();
328
+				return iterator.member.types;
339 329
 		
340 330
 		return null;
341 331
 	}
@@ -357,8 +347,8 @@ public final class TypeMembers {
357 347
 		if (type.isOptional() && type.unwrap() == toType)
358 348
 			return true;
359 349
 		
360
-		for (TypeMember<CasterMember> caster : casters) {
361
-			if (caster.member.isImplicit() && toType == caster.member.getTargetType())
350
+		for (TypeMember<CasterMemberRef> caster : casters) {
351
+			if (caster.member.isImplicit() && toType == caster.member.toType)
362 352
 				return true;
363 353
 		}
364 354
 		
@@ -369,8 +359,8 @@ public final class TypeMembers {
369 359
 		if (canCastImplicit(toType))
370 360
 			return true;
371 361
 		
372
-		for (TypeMember<CasterMember> caster : casters) {
373
-			if (toType == caster.member.getTargetType())
362
+		for (TypeMember<CasterMemberRef> caster : casters) {
363
+			if (toType == caster.member.toType)
374 364
 				return true;
375 365
 		}
376 366
 		
@@ -392,12 +382,12 @@ public final class TypeMembers {
392 382
 		if (type.isOptional() && type.unwrap() == toType)
393 383
 			return new CheckNullExpression(position, value);
394 384
 		
395
-		for (TypeMember<CasterMember> caster : casters) {
396
-			if (caster.member.isImplicit() && toType == caster.member.getTargetType())
385
+		for (TypeMember<CasterMemberRef> caster : casters) {
386
+			if (caster.member.isImplicit() && toType == caster.member.toType)
397 387
 				return caster.member.cast(position, value, implicit);
398 388
 		}
399
-		for (TypeMember<ImplementationMember> implementation : implementations) {
400
-			if (implementation.member.type.equals(toType))
389
+		for (TypeMember<ImplementationMemberRef> implementation : implementations) {
390
+			if (implementation.member.implementsType.equals(toType))
401 391
 				return new InterfaceCastExpression(position, value, toType);
402 392
 		}
403 393
 		if (extendsType(toType))
@@ -410,8 +400,8 @@ public final class TypeMembers {
410 400
 		if (this.canCastImplicit(toType))
411 401
 			return castImplicit(position, value, toType, false);
412 402
 		
413
-		for (TypeMember<CasterMember> caster : casters)
414
-			if (toType == caster.member.getTargetType())
403
+		for (TypeMember<CasterMemberRef> caster : casters)
404
+			if (toType == caster.member.toType)
415 405
 				return caster.member.cast(position, value, false);
416 406
 		
417 407
 		throw new CompileException(position, CompileExceptionCode.INVALID_CAST, "Cannot cast " + toString() + " to " + toType + ", even explicitly");

+ 4
- 7
CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java Bestand weergeven

@@ -98,21 +98,18 @@ public class SemanticModule {
98 98
 			throw new IllegalStateException("Module is not yet normalized");
99 99
 		
100 100
 		Validator validator = new Validator();
101
-		boolean isValid = true;
102 101
 		for (ScriptBlock script : scripts) {
103
-			isValid &= validator.validate(script);
102
+			validator.validate(script);
104 103
 		}
105 104
 		for (HighLevelDefinition definition : definitions.getAll()) {
106
-			isValid &= validator.validate(definition);
105
+			validator.validate(definition);
107 106
 		}
108 107
 		
109 108
 		for (ValidationLogEntry entry : validator.getLog()) {
110 109
 			System.out.println(entry.kind + " " + entry.position.toString() + ": " + entry.message);
111 110
 		}
112
-		state = isValid ? State.VALIDATED : State.INVALID;
113
-		if (!isValid && validator.getLog().isEmpty())
114
-			System.out.println("ERROR: module is invalid but no errors have been generated");
115
-		return isValid;
111
+		state = validator.hasErrors() ? State.INVALID : State.VALIDATED;
112
+		return !validator.hasErrors();
116 113
 	}
117 114
 	
118 115
 	public void compile(ZenCodeCompiler compiler) {

+ 0
- 4
Constructor/libraries/collections/module.json Bestand weergeven

@@ -1,4 +0,0 @@
1
-{
2
-	"package": "collections",
3
-	"host": "universal"
4
-}

+ 0
- 11
Constructor/libraries/collections/src/HashSet.zs Bestand weergeven

@@ -1,11 +0,0 @@
1
-export class HashSet<T> {
2
-	public implements Set<T> {
3
-		add(value as T) as bool;
4
-		remove(value as T) as bool;
5
-		
6
-		get size as int;
7
-		
8
-		in(value as T) as bool;
9
-		for(x as T);
10
-	}
11
-}

+ 0
- 73
Constructor/libraries/collections/src/LinkedList.zs Bestand weergeven

@@ -1,73 +0,0 @@
1
-export class LinkedList<T> {
2
-	var first as Node?;
3
-	var last as Node?;
4
-	var size as int : get;
5
-	
6
-	public get empty as bool
7
-		=> first == null;
8
-	
9
-	public add(value as T) as void {
10
-		if first == null {
11
-			first = last = new Node(value);
12
-		} else {
13
-			val node = new Node(value);
14
-			last.next = node;
15
-			node.prev = last;
16
-			last = node;
17
-		}
18
-		size++;
19
-	}
20
-	
21
-	public clear() as void {
22
-		first = last = null;
23
-		size = 0;
24
-	}
25
-	
26
-	public [](index as int) as T {
27
-		var node = first;
28
-		while index > 0 {
29
-			if node == null
30
-				return panic<T>("index out of bounds");
31
-			
32
-			node = node.next;
33
-		}
34
-		
35
-		if node == null
36
-			return panic<T>("index out of bounds");
37
-		
38
-		return node.value;
39
-	}
40
-	
41
-	public implements Queue<T> {
42
-		poll() as T {
43
-			if first == null
44
-				return panic<T>("Cannot poll an empty queue");
45
-			
46
-			val result = first.value;
47
-			first = first.next;
48
-			if first == null
49
-				last = null;
50
-			else
51
-				first.prev = null;
52
-				
53
-			size--;
54
-		}
55
-		
56
-		peek() as T? {
57
-			return first.value;
58
-		}
59
-		
60
-		offer(value as T) as void
61
-			=> add(value);
62
-	}
63
-	
64
-	private struct Node {
65
-		var next as Node?;
66
-		var prev as Node?;
67
-		val value as T;
68
-		
69
-		this(value as T) {
70
-			this.value = value;
71
-		}
72
-	}
73
-}

+ 0
- 5
Constructor/libraries/collections/src/NoSuchElementException.zs Bestand weergeven

@@ -1,5 +0,0 @@
1
-export class NoSuchElementException : Exception {
2
-	public this(message as string) {
3
-		super(message);
4
-	}
5
-}

+ 0
- 7
Constructor/libraries/collections/src/Queue.zs Bestand weergeven

@@ -1,7 +0,0 @@
1
-export interface Queue<T> {
2
-	get empty as bool;
3
-	
4
-	poll() as T;
5
-	peek() as T;
6
-	push(value as T) as void;
7
-}

+ 0
- 12
Constructor/libraries/collections/src/Set.zs Bestand weergeven

@@ -1,12 +0,0 @@
1
-export interface Set<T> {
2
-	add(value as T) as bool;
3
-	remove(value as T) as bool;
4
-	
5
-	get size as int;
6
-	
7
-	toArray();
8
-	toArray(comparator as function(a as T, b as T) as int);
9
-	
10
-	in(value as T) as bool;
11
-	for(x as T);
12
-}

+ 0
- 0
Constructor/libraries/collections/src/Stack.zs Bestand weergeven


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

Laden…
Annuleren
Opslaan