Browse Source

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

kindlich 6 years ago
parent
commit
17cb528827
No known key found for this signature in database
100 changed files with 1848 additions and 1670 deletions
  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 View File

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

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

+ 0
- 11
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ZenScriptOperator.java View File

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

+ 4
- 4
CodeFormatterShared/src/main/java/org/openzen/zenscript/formattershared/ExpressionString.java View File

38
 	}
38
 	}
39
 	
39
 	
40
 	public ExpressionString unaryPrefix(FormattableOperator operator) {
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
 	public ExpressionString unaryPostfix(FormattableOperator operator) {
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
 	public ExpressionString unaryPrefix(FormattableOperator operator, String operatorString) {
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
 	public ExpressionString unaryPostfix(FormattableOperator operator, String operatorString) {
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 View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface FormattableOperator {
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
 	int getPriority();
19
 	int getPriority();
14
 	
20
 	
15
-	boolean isCommutative();
16
-	
17
 	String getOperatorString();
21
 	String getOperatorString();
18
 	
22
 	
19
 	public static boolean shouldWrapLeft(FormattableOperator inner, FormattableOperator outer) {
23
 	public static boolean shouldWrapLeft(FormattableOperator inner, FormattableOperator outer) {
21
 	}
25
 	}
22
 	
26
 	
23
 	public static boolean shouldWrapRight(FormattableOperator inner, FormattableOperator outer) {
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 View File

30
 	public final ITypeID thrownType;
30
 	public final ITypeID thrownType;
31
 	
31
 	
32
 	public FunctionHeader(ITypeID returnType) {
32
 	public FunctionHeader(ITypeID returnType) {
33
+		if (returnType == null)
34
+			throw new NullPointerException();
35
+		
33
 		this.typeParameters = null;
36
 		this.typeParameters = null;
34
 		this.returnType = returnType;
37
 		this.returnType = returnType;
35
 		this.parameters = NO_PARAMETERS;
38
 		this.parameters = NO_PARAMETERS;
37
 	}
40
 	}
38
 	
41
 	
39
 	public FunctionHeader(ITypeID returnType, ITypeID... parameterTypes) {
42
 	public FunctionHeader(ITypeID returnType, ITypeID... parameterTypes) {
43
+		if (returnType == null)
44
+			throw new NullPointerException();
45
+		
40
 		this.typeParameters = null;
46
 		this.typeParameters = null;
41
 		this.returnType = returnType;
47
 		this.returnType = returnType;
42
 		this.parameters = new FunctionParameter[parameterTypes.length];
48
 		this.parameters = new FunctionParameter[parameterTypes.length];
47
 	}
53
 	}
48
 	
54
 	
49
 	public FunctionHeader(ITypeID returnType, FunctionParameter... parameters) {
55
 	public FunctionHeader(ITypeID returnType, FunctionParameter... parameters) {
56
+		if (returnType == null)
57
+			throw new NullPointerException();
58
+		
50
 		this.typeParameters = null;
59
 		this.typeParameters = null;
51
 		this.returnType = returnType;
60
 		this.returnType = returnType;
52
 		this.parameters = parameters;
61
 		this.parameters = parameters;
54
 	}
63
 	}
55
 	
64
 	
56
 	public FunctionHeader(TypeParameter[] genericParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
65
 	public FunctionHeader(TypeParameter[] genericParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
66
+		if (returnType == null)
67
+			throw new NullPointerException();
68
+		
57
 		this.typeParameters = genericParameters;
69
 		this.typeParameters = genericParameters;
58
 		this.returnType = returnType;
70
 		this.returnType = returnType;
59
 		this.parameters = parameters;
71
 		this.parameters = parameters;
64
 		return typeParameters == null ? 0 : typeParameters.length;
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
 	public ITypeID[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<ITypeID> resultHint) {
100
 	public ITypeID[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<ITypeID> resultHint) {
200
 		return true;
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
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
224
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
206
 		for (int i = 0; i < parameters.length; i++) {
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
 		Map<TypeParameter, ITypeID> typeArguments = new HashMap<>();
235
 		Map<TypeParameter, ITypeID> typeArguments = new HashMap<>();
215
 		if (typeParameters != null)
236
 		if (typeParameters != null)
216
 			for (int i = 0; i < typeParameters.length; i++)
237
 			for (int i = 0; i < typeParameters.length; i++)
217
 				typeArguments.put(typeParameters[i], arguments[i]);
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
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
242
 		FunctionParameter[] parameters = new FunctionParameter[this.parameters.length];
221
 		for (int i = 0; i < parameters.length; i++) {
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
 	public FunctionHeader forTypeParameterInference() {
249
 	public FunctionHeader forTypeParameterInference() {

+ 7
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java View File

6
 package org.openzen.zenscript.codemodel;
6
 package org.openzen.zenscript.codemodel;
7
 
7
 
8
 import org.openzen.zenscript.codemodel.annotations.Annotation;
8
 import org.openzen.zenscript.codemodel.annotations.Annotation;
9
-import java.util.Map;
10
 import java.util.Objects;
9
 import java.util.Objects;
11
 import org.openzen.zenscript.codemodel.expression.Expression;
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
 import org.openzen.zenscript.codemodel.type.ITypeID;
11
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.shared.Taggable;
12
 import org.openzen.zenscript.shared.Taggable;
16
 
13
 
51
 		this.variadic = variadic;
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
 		result.annotations = annotations;
57
 		result.annotations = annotations;
58
+		result.addAllTagsFrom(this); // TODO: this will cause trouble -> references?
57
 		return result;
59
 		return result;
58
 	}
60
 	}
59
 	
61
 	

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

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel;
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 View File

46
 			pkg.register(this);
46
 			pkg.register(this);
47
 	}
47
 	}
48
 	
48
 	
49
+	public String getFullName() {
50
+		return pkg.fullName + '.' + name;
51
+	}
52
+	
49
 	public int getNumberOfGenericParameters() {
53
 	public int getNumberOfGenericParameters() {
50
 		return genericParameters == null ? 0 : genericParameters.length;
54
 		return genericParameters == null ? 0 : genericParameters.length;
51
 	}
55
 	}

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

9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.Modifiers;
10
 import org.openzen.zenscript.codemodel.Modifiers;
11
 import org.openzen.zenscript.codemodel.member.CallerMember;
11
 import org.openzen.zenscript.codemodel.member.CallerMember;
12
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
12
 import org.openzen.zenscript.codemodel.statement.Statement;
13
 import org.openzen.zenscript.codemodel.statement.Statement;
13
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
14
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
37
 	public void setHeader(FunctionHeader header) {
38
 	public void setHeader(FunctionHeader header) {
38
 		this.header = header;
39
 		this.header = header;
39
 		addMember(caller = new CallerMember(position, this, modifiers | Modifiers.STATIC, header, null));
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
 	public void setCode(Statement statement) {
44
 	public void setCode(Statement statement) {

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

7
 
7
 
8
 import java.util.ArrayList;
8
 import java.util.ArrayList;
9
 import java.util.List;
9
 import java.util.List;
10
-import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
13
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.shared.CodePosition;
14
 import org.openzen.zenscript.shared.CodePosition;
15
+import org.openzen.zenscript.shared.Taggable;
16
 
16
 
17
 /**
17
 /**
18
  *
18
  *
30
 		return visitor.visitVariant(this);
30
 		return visitor.visitVariant(this);
31
 	}
31
 	}
32
 	
32
 	
33
-	public static class Option {
33
+	public static class Option extends Taggable {
34
 		public final String name;
34
 		public final String name;
35
 		public final ITypeID[] types;
35
 		public final ITypeID[] types;
36
 		
36
 		
39
 			this.types = types;
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 View File

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

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

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.expression;
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
 import org.openzen.zenscript.shared.CodePosition;
9
 import org.openzen.zenscript.shared.CodePosition;
12
 
10
 
13
 /**
11
 /**
16
  */
14
  */
17
 public class CastExpression extends Expression {
15
 public class CastExpression extends Expression {
18
 	public final Expression target;
16
 	public final Expression target;
19
-	public final CasterMember member;
17
+	public final CasterMemberRef member;
20
 	public final boolean isImplicit;
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
 		this.target = target;
23
 		this.target = target;
26
 		this.member = member;
24
 		this.member = member;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java View File

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

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstExpression.java View File

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

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

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

36
 	public final ITypeID thrownType;
36
 	public final ITypeID thrownType;
37
 	
37
 	
38
 	public Expression(CodePosition position, ITypeID type, ITypeID thrownType) {
38
 	public Expression(CodePosition position, ITypeID type, ITypeID thrownType) {
39
+		if (type == null)
40
+			throw new NullPointerException();
41
+		
39
 		this.position = position;
42
 		this.position = position;
40
 		this.type = type;
43
 		this.type = type;
41
 		this.thrownType = thrownType;
44
 		this.thrownType = thrownType;

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java View File

9
 import java.util.List;
9
 import java.util.List;
10
 import org.openzen.zenscript.codemodel.OperatorType;
10
 import org.openzen.zenscript.codemodel.OperatorType;
11
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
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
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
13
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
14
 import org.openzen.zenscript.codemodel.type.GenericName;
14
 import org.openzen.zenscript.codemodel.type.GenericName;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
49
 		DefinitionMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
49
 		DefinitionMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
50
 		List<ITypeID>[] predictedTypes = constructors.predictCallTypes(scope, scope.hints, arguments.length);
50
 		List<ITypeID>[] predictedTypes = constructors.predictCallTypes(scope, scope.hints, arguments.length);
51
 		CallArguments compiledArguments = new CallArguments(arguments);
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
 		if (member == null)
53
 		if (member == null)
54
 			throw new CompileException(position, CompileExceptionCode.CALL_NO_VALID_METHOD, "No matching constructor found");
54
 			throw new CompileException(position, CompileExceptionCode.CALL_NO_VALID_METHOD, "No matching constructor found");
55
-		if (!(member instanceof ConstructorMember))
55
+		if (!member.isConstructor())
56
 			throw new CompileException(position, CompileExceptionCode.INTERNAL_ERROR, "COMPILER BUG: constructor is not a constructor");
56
 			throw new CompileException(position, CompileExceptionCode.INTERNAL_ERROR, "COMPILER BUG: constructor is not a constructor");
57
 		
57
 		
58
 		return new NewExpression(
58
 		return new NewExpression(
59
 				position,
59
 				position,
60
 				type,
60
 				type,
61
-				(ConstructorMember) member,
61
+				member,
62
 				compiledArguments,
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
 				scope);
64
 				scope);
65
 	}
65
 	}
66
 	
66
 	

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java View File

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

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java View File

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

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.expression;
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
 import org.openzen.zenscript.shared.CodePosition;
9
 import org.openzen.zenscript.shared.CodePosition;
10
 
10
 
11
 /**
11
 /**
14
  */
14
  */
15
 public class GetterExpression extends Expression {
15
 public class GetterExpression extends Expression {
16
 	public final Expression target;
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
 		super(position, getter.type, target.thrownType);
20
 		super(position, getter.type, target.thrownType);
21
 		
21
 		
22
 		this.target = target;
22
 		this.target = target;

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

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

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PostCallExpression.java View File

7
 
7
 
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.OperatorType;
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
 import org.openzen.zenscript.shared.CodePosition;
11
 import org.openzen.zenscript.shared.CodePosition;
12
 
12
 
13
 /**
13
 /**
17
  */
17
  */
18
 public class PostCallExpression extends Expression {
18
 public class PostCallExpression extends Expression {
19
 	public final Expression target;
19
 	public final Expression target;
20
-	public final OperatorMember member;
20
+	public final FunctionalMemberRef member;
21
 	public final FunctionHeader instancedHeader;
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
 		super(position, instancedHeader.returnType, binaryThrow(position, instancedHeader.thrownType, target.thrownType));
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
 			throw new IllegalArgumentException("Operator must be increment or decrement");
27
 			throw new IllegalArgumentException("Operator must be increment or decrement");
28
 		
28
 		
29
 		this.target = target;
29
 		this.target = target;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFieldExpression.java View File

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

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetStaticFieldExpression.java View File

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

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetterExpression.java View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.expression;
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
 import org.openzen.zenscript.shared.CodePosition;
9
 import org.openzen.zenscript.shared.CodePosition;
10
 
10
 
11
 /**
11
 /**
14
  */
14
  */
15
 public class SetterExpression extends Expression {
15
 public class SetterExpression extends Expression {
16
 	public final Expression target;
16
 	public final Expression target;
17
-	public final SetterMember setter;
17
+	public final SetterMemberRef setter;
18
 	public final Expression value;
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
 		this.target = target;
23
 		this.target = target;
24
 		this.setter = setter;
24
 		this.setter = setter;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticGetterExpression.java View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.expression;
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
 import org.openzen.zenscript.shared.CodePosition;
9
 import org.openzen.zenscript.shared.CodePosition;
10
 
10
 
11
 /**
11
 /**
13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public class StaticGetterExpression extends Expression {
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
 		this.getter = getter;
21
 		this.getter = getter;
22
 	}
22
 	}

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticSetterExpression.java View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.expression;
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
 import org.openzen.zenscript.shared.CodePosition;
9
 import org.openzen.zenscript.shared.CodePosition;
10
 
10
 
11
 /**
11
 /**
13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public class StaticSetterExpression extends Expression {
15
 public class StaticSetterExpression extends Expression {
16
-	public final SetterMember setter;
16
+	public final SetterMemberRef setter;
17
 	public final Expression value;
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
 		this.setter = setter;
22
 		this.setter = setter;
23
 		this.value = value;
23
 		this.value = value;

+ 4
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java View File

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

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

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

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.generic;
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
 import org.openzen.zenscript.codemodel.type.ITypeID;
9
 import org.openzen.zenscript.codemodel.type.ITypeID;
11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
10
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
24
 	
23
 	
25
 	public abstract boolean matches(LocalMemberCache cache, ITypeID type);
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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.generic;
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
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
9
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
12
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
21
 	public ParameterSuperBound(ITypeID type) {
20
 	public ParameterSuperBound(ITypeID type) {
22
 		this.type = type;
21
 		this.type = type;
23
 	}
22
 	}
23
+	
24
+	@Override
25
+	public String getCanonical() {
26
+		return "super|" + type.toString();
27
+	}
24
 
28
 
25
 	@Override
29
 	@Override
26
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
30
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
33
 	}
37
 	}
34
 
38
 
35
 	@Override
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
 		if (translated == type)
42
 		if (translated == type)
39
 			return this;
43
 			return this;
40
 		
44
 		

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.generic;
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
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
9
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
12
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
25
 		this.position = position;
24
 		this.position = position;
26
 		this.type = type;
25
 		this.type = type;
27
 	}
26
 	}
27
+	
28
+	@Override
29
+	public String getCanonical() {
30
+		return type.toString();
31
+	}
28
 
32
 
29
 	@Override
33
 	@Override
30
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
34
 	public void registerMembers(LocalMemberCache cache, TypeMembers type) {
37
 	}
41
 	}
38
 
42
 
39
 	@Override
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
 	@Override
48
 	@Override

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

63
 		return this;
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
 	public String toString() {
77
 	public String toString() {
67
 		return name + "@" + position.toShortString();
78
 		return name + "@" + position.toShortString();
68
 	}
79
 	}

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
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;
11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
32
 	}
29
 	}
33
 	
30
 	
34
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
46
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.Modifiers;
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
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
19
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
20
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
41
 	}
36
 	}
42
 	
37
 	
43
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
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
 	public ITypeID getTargetType() {
58
 	public ITypeID getTargetType() {
69
 		return toType;
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
 	public boolean isImplicit() {
62
 	public boolean isImplicit() {
82
 		return Modifiers.isImplicit(modifiers);
63
 		return Modifiers.isImplicit(modifiers);

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.expression.Expression;
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
 import org.openzen.zenscript.codemodel.type.ITypeID;
12
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
45
 	}
44
 	}
46
 
45
 
47
 	@Override
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
 	@Override
51
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
11
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
12
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
12
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
13
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
13
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
15
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
14
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
16
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
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
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
20
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
21
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
58
 	}
55
 	}
59
 	
56
 	
60
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
73
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
10
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
12
 import org.openzen.zenscript.codemodel.statement.Statement;
12
 import org.openzen.zenscript.codemodel.statement.Statement;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
13
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
51
 	}
50
 	}
52
 
51
 
53
 	@Override
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
 	@Override
57
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
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
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
 import org.openzen.zenscript.shared.CodePosition;
14
 import org.openzen.zenscript.shared.CodePosition;
28
 	}
25
 	}
29
 	
26
 	
30
 	@Override
27
 	@Override
31
-	public String getInformalName() {
32
-		return "destructor";
28
+	public String getCanonicalName() {
29
+		return definition.getFullName() + ":destructor";
33
 	}
30
 	}
34
-
31
+	
35
 	@Override
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
 	@Override
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
 	@Override
43
 	@Override

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

6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
 import java.util.Map;
8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.expression.Expression;
11
 import org.openzen.zenscript.codemodel.expression.Expression;
11
 import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
12
 import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
13
 import org.openzen.zenscript.codemodel.expression.SetFieldExpression;
14
 import org.openzen.zenscript.codemodel.expression.SetFieldExpression;
14
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
15
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
16
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
17
+import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
16
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
18
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
17
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
19
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
18
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
20
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
67
 		if (autoGetterAccess != 0) {
69
 		if (autoGetterAccess != 0) {
68
 			ITypeID myType = registry.getForDefinition(definition, parameters);
70
 			ITypeID myType = registry.getForDefinition(definition, parameters);
69
 			this.autoGetter = new GetterMember(position, definition, autoGetterAccess, name, type, null);
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
 		} else {
73
 		} else {
72
 			this.autoGetter = null;
74
 			this.autoGetter = null;
73
 		}
75
 		}
77
 			this.autoSetter.setBody(new ExpressionStatement(position, new SetFieldExpression(
79
 			this.autoSetter.setBody(new ExpressionStatement(position, new SetFieldExpression(
78
 					position,
80
 					position,
79
 					new ThisExpression(position, myType),
81
 					new ThisExpression(position, myType),
80
-					this,
82
+					new FieldMemberRef(this, myType),
81
 					new GetFunctionParameterExpression(position, this.autoSetter.header.parameters[0]))));
83
 					new GetFunctionParameterExpression(position, this.autoSetter.header.parameters[0]))));
82
 		} else {
84
 		} else {
83
 			this.autoSetter = null;
85
 			this.autoSetter = null;
120
 	}
122
 	}
121
 
123
 
122
 	@Override
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
 	@Override
129
 	@Override
129
 		return builtin;
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
 	@Override
134
 	@Override
148
 	public String describe() {
135
 	public String describe() {
149
 		return "field " + name;
136
 		return "field " + name;

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

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import org.openzen.zenscript.codemodel.CompareType;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
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
 import org.openzen.zenscript.codemodel.statement.Statement;
12
 import org.openzen.zenscript.codemodel.statement.Statement;
18
-import org.openzen.zenscript.codemodel.type.ITypeID;
19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
20
 import org.openzen.zenscript.shared.CodePosition;
14
 import org.openzen.zenscript.shared.CodePosition;
21
 
15
 
48
 		this.body = body;
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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
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
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
17
 import org.openzen.zenscript.codemodel.type.ITypeID;
13
 import org.openzen.zenscript.codemodel.type.ITypeID;
18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
41
 	}
37
 	}
42
 	
38
 	
43
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
54
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
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
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
9
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
10
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
25
 	
22
 	
26
 	public BuiltinID getBuiltin();
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
 	public <T> T accept(MemberVisitor<T> visitor);
27
 	public <T> T accept(MemberVisitor<T> visitor);
33
 	
28
 	

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

7
 
7
 
8
 import java.util.ArrayList;
8
 import java.util.ArrayList;
9
 import java.util.List;
9
 import java.util.List;
10
-import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
+import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
36
 	}
35
 	}
37
 
36
 
38
 	@Override
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
 	@Override
46
 	@Override
56
 	public String describe() {
47
 	public String describe() {
57
-		return "implementation " + type.toString();
48
+		return "implementation of " + type.toString();
58
 	}
49
 	}
59
 	
50
 	
60
 	@Override
51
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
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
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
10
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
11
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
29
 	}
26
 	}
30
 
27
 
31
 	@Override
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
 		} else {
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 View File

1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
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;
11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
26
 	}
23
 	}
27
 	
24
 	
28
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
40
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.OperatorType;
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
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
12
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
38
 	}
35
 	}
39
 	
36
 	
40
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
52
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
8
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.FunctionParameter;
9
 import org.openzen.zenscript.codemodel.FunctionParameter;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
+import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
44
 	}
43
 	}
45
 	
44
 	
46
 	@Override
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
 	@Override
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
 	@Override
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
 	@Override
60
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.statement.Statement;
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
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
11
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
46
 	}
43
 	}
47
 
44
 
48
 	@Override
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
 	@Override
50
 	@Override
59
 	public <T> T accept(MemberVisitor<T> visitor) {
51
 	public <T> T accept(MemberVisitor<T> visitor) {
60
 		return visitor.visitStaticInitializer(this);
52
 		return visitor.visitStaticInitializer(this);

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

35
 		
35
 		
36
 		this.translator = translator;
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 View File

6
 package org.openzen.zenscript.codemodel.member.builtin;
6
 package org.openzen.zenscript.codemodel.member.builtin;
7
 
7
 
8
 import java.util.Map;
8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
15
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
15
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
64
 	}
65
 	}
65
 
66
 
66
 	@Override
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
 	@Override
72
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member.builtin;
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
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
13
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
59
 	}
57
 	}
60
 
58
 
61
 	@Override
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
 	@Override
64
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member.builtin;
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
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
13
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
62
 	}
60
 	}
63
 
61
 
64
 	@Override
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
 	@Override
67
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member.builtin;
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
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
15
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
70
 	}
68
 	}
71
 
69
 
72
 	@Override
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
 	@Override
75
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member.builtin;
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
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
9
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
11
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
10
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
11
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
58
 	}
56
 	}
59
 
57
 
60
 	@Override
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
 	@Override
63
 	@Override

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

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.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 View File

12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
14
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
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
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
16
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
17
 import org.openzen.zenscript.codemodel.type.GenericName;
17
 import org.openzen.zenscript.codemodel.type.GenericName;
18
 import org.openzen.zenscript.codemodel.type.ITypeID;
18
 import org.openzen.zenscript.codemodel.type.ITypeID;
38
 		this.allowStaticUsage = allowStaticMembers;
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
 		this.position = position;
42
 		this.position = position;
43
 		this.target = target;
43
 		this.target = target;
44
-		this.group = DefinitionMemberGroup.forMethod(member);
44
+		this.group = DefinitionMemberGroup.forMethod(name, member);
45
 		this.typeArguments = typeArguments;
45
 		this.typeArguments = typeArguments;
46
 		this.allowStaticUsage = allowStaticMembers;
46
 		this.allowStaticUsage = allowStaticMembers;
47
 	}
47
 	}

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

11
 import org.openzen.zenscript.codemodel.FunctionHeader;
11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
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
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
15
 import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
16
 import org.openzen.zenscript.codemodel.type.GenericName;
16
 import org.openzen.zenscript.codemodel.type.GenericName;
17
 import org.openzen.zenscript.codemodel.type.ITypeID;
17
 import org.openzen.zenscript.codemodel.type.ITypeID;
24
  * @author Hoofdgebruiker
24
  * @author Hoofdgebruiker
25
  */
25
  */
26
 public class PartialStaticMemberGroupExpression implements IPartialExpression {
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
 		group.addMethod(method, TypeMemberPriority.SPECIFIED);
29
 		group.addMethod(method, TypeMemberPriority.SPECIFIED);
30
 		return new PartialStaticMemberGroupExpression(position, target, group, typeArguments);
30
 		return new PartialStaticMemberGroupExpression(position, target, group, typeArguments);
31
 	}
31
 	}
49
 
49
 
50
 	@Override
50
 	@Override
51
 	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
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
 	@Override
55
 	@Override

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

41
 
41
 
42
 	@Override
42
 	@Override
43
 	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
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
 	@Override
47
 	@Override
61
 
61
 
62
 	@Override
62
 	@Override
63
 	public Expression call(CodePosition position, TypeScope scope, List<ITypeID> hints, CallArguments arguments) {
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
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).callStatic(position, type, scope, arguments);
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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.scope;
6
 package org.openzen.zenscript.codemodel.scope;
7
 
7
 
8
+import java.util.Collections;
8
 import java.util.List;
9
 import java.util.List;
9
 import java.util.function.Function;
10
 import java.util.function.Function;
10
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12
 import org.openzen.zenscript.codemodel.FunctionHeader;
13
+import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.expression.Expression;
14
 import org.openzen.zenscript.codemodel.expression.Expression;
13
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
14
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
16
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
41
 		interfaceMembers.copyMembersTo(implementation.position, interfaceMembers, TypeMemberPriority.INHERITED);
43
 		interfaceMembers.copyMembersTo(implementation.position, interfaceMembers, TypeMemberPriority.INHERITED);
42
 		
44
 		
43
 		for (IDefinitionMember member : implementation.members) {
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 View File

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

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 
10
 
11
 /**
11
 /**
50
 	}
50
 	}
51
 	
51
 	
52
 	@Override
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
 	@Override
57
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 
10
 
11
 /**
11
 /**
22
 	}
22
 	}
23
 	
23
 	
24
 	@Override
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
 	@Override
31
 	@Override

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

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

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
9
 import java.util.Objects;
8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
23
 	}
23
 	}
24
 	
24
 	
25
 	@Override
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
 	@Override
30
 	@Override

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

10
 import java.util.HashMap;
10
 import java.util.HashMap;
11
 import java.util.Map;
11
 import java.util.Map;
12
 import java.util.Objects;
12
 import java.util.Objects;
13
+import org.openzen.zenscript.codemodel.GenericMapper;
13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
15
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
15
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
16
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
71
 			for (int i = 0; i < typeParameters.length; i++)
72
 			for (int i = 0; i < typeParameters.length; i++)
72
 				genericSuperArguments.put(definition.genericParameters[i], typeParameters[i]);
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
 		this.superType = superType;
77
 		this.superType = superType;
77
 	}
78
 	}
86
 	}
87
 	}
87
 	
88
 	
88
 	@Override
89
 	@Override
89
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
90
+	public ITypeID instance(GenericMapper mapper) {
90
 		if (!hasTypeParameters() && outerTypeParameters.isEmpty())
91
 		if (!hasTypeParameters() && outerTypeParameters.isEmpty())
91
 			return this;
92
 			return this;
92
 		
93
 		
96
 			for (int i = 0; i < typeParameters.length; i++) {
97
 			for (int i = 0; i < typeParameters.length; i++) {
97
 				// TODO: why was this line written like this?
98
 				// TODO: why was this line written like this?
98
 				//instancedArguments[i] = arguments.containsKey(definition.genericParameters[i]) ? arguments.get(definition.genericParameters[i]) : typeParameters[i].withGenericArguments(registry, arguments);
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
 		} else {
107
 		} else {
107
 			instancedOuter = new HashMap<>();
108
 			instancedOuter = new HashMap<>();
108
 			for (Map.Entry<TypeParameter, ITypeID> entry : outerTypeParameters.entrySet())
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
 	@Override
115
 	@Override

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

6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
 import java.util.Arrays;
8
 import java.util.Arrays;
9
-import java.util.Map;
10
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
11
 import org.openzen.zenscript.codemodel.FunctionParameter;
10
 import org.openzen.zenscript.codemodel.FunctionParameter;
11
+import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
13
 
13
 
14
 /**
14
 /**
23
 	}
23
 	}
24
 	
24
 	
25
 	@Override
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
 	@Override
30
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
9
 import java.util.Objects;
8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 
11
 
12
 /**
12
 /**
43
 	}
43
 	}
44
 
44
 
45
 	@Override
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
 	@Override
50
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
10
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
11
 
11
 
25
 	}
25
 	}
26
 	
26
 	
27
 	@Override
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
 	@Override
32
 	@Override

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

6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
 import java.util.Map;
8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
12
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
53
 		return false;
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
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters);
59
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters);
59
 	
60
 	

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

7
 
7
 
8
 import java.util.Arrays;
8
 import java.util.Arrays;
9
 import java.util.Map;
9
 import java.util.Map;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
 
12
 
12
 /**
13
 /**
46
 	}
47
 	}
47
 
48
 
48
 	@Override
49
 	@Override
49
-	public ITypeID withGenericArguments(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> arguments) {
50
+	public ITypeID instance(GenericMapper mapper) {
50
 		ITypeID[] instanced = new ITypeID[iteratorTypes.length];
51
 		ITypeID[] instanced = new ITypeID[iteratorTypes.length];
51
 		for (int i = 0; i < iteratorTypes.length; i++)
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
 	@Override
57
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
9
 import java.util.Objects;
8
 import java.util.Objects;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
11
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
12
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
23
 	}
23
 	}
24
 	
24
 	
25
 	@Override
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
 	@Override
30
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.type;
6
 package org.openzen.zenscript.codemodel.type;
7
 
7
 
8
-import java.util.Map;
8
+import org.openzen.zenscript.codemodel.GenericMapper;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
9
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
10
 
10
 
11
 /**
11
 /**
24
 	}
24
 	}
25
 	
25
 	
26
 	@Override
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
 	@Override
33
 	@Override

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

396
 	GENERICMAP_GETOPTIONAL,
396
 	GENERICMAP_GETOPTIONAL,
397
 	GENERICMAP_PUT,
397
 	GENERICMAP_PUT,
398
 	GENERICMAP_CONTAINS,
398
 	GENERICMAP_CONTAINS,
399
+	GENERICMAP_SIZE,
400
+	GENERICMAP_ISEMPTY,
399
 	GENERICMAP_HASHCODE,
401
 	GENERICMAP_HASHCODE,
400
 	GENERICMAP_EQUALS,
402
 	GENERICMAP_EQUALS,
401
 	GENERICMAP_NOTEQUALS,
403
 	GENERICMAP_NOTEQUALS,

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

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

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

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

+ 772
- 817
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
File diff suppressed because it is too large
View File


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

11
 import java.util.Map;
11
 import java.util.Map;
12
 import org.openzen.zenscript.codemodel.CompareType;
12
 import org.openzen.zenscript.codemodel.CompareType;
13
 import org.openzen.zenscript.codemodel.OperatorType;
13
 import org.openzen.zenscript.codemodel.OperatorType;
14
-import org.openzen.zenscript.codemodel.definition.VariantDefinition;
15
 import org.openzen.zenscript.codemodel.expression.CallArguments;
14
 import org.openzen.zenscript.codemodel.expression.CallArguments;
16
 import org.openzen.zenscript.codemodel.expression.CheckNullExpression;
15
 import org.openzen.zenscript.codemodel.expression.CheckNullExpression;
17
 import org.openzen.zenscript.codemodel.expression.Expression;
16
 import org.openzen.zenscript.codemodel.expression.Expression;
20
 import org.openzen.zenscript.codemodel.expression.NullExpression;
19
 import org.openzen.zenscript.codemodel.expression.NullExpression;
21
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
20
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
22
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
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
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
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
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
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
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
33
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
39
 import org.openzen.zenscript.codemodel.partial.PartialMemberGroupExpression;
34
 import org.openzen.zenscript.codemodel.partial.PartialMemberGroupExpression;
40
 import org.openzen.zenscript.codemodel.partial.PartialStaticMemberGroupExpression;
35
 import org.openzen.zenscript.codemodel.partial.PartialStaticMemberGroupExpression;
60
 	private final LocalMemberCache cache;
55
 	private final LocalMemberCache cache;
61
 	public final ITypeID type;
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
 	private final Map<String, EnumConstantMember> enumMembers = new HashMap<>();
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
 	private final Map<String, DefinitionMemberGroup> members = new HashMap<>();
64
 	private final Map<String, DefinitionMemberGroup> members = new HashMap<>();
70
 	private final Map<String, InnerDefinition> innerTypes = new HashMap<>();
65
 	private final Map<String, InnerDefinition> innerTypes = new HashMap<>();
71
 	private final Map<OperatorType, DefinitionMemberGroup> operators = new HashMap<>();
66
 	private final Map<OperatorType, DefinitionMemberGroup> operators = new HashMap<>();
91
 				return true;
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
 				return true;
91
 				return true;
97
-			if (cache.get(implementation.member.type).extendsOrImplements(other))
92
+			if (cache.get(implementation.member.implementsType).extendsOrImplements(other))
98
 				return true;
93
 				return true;
99
 		}
94
 		}
100
 		
95
 		
123
 		
118
 		
124
 		for (Map.Entry<String, EnumConstantMember> entry : enumMembers.entrySet())
119
 		for (Map.Entry<String, EnumConstantMember> entry : enumMembers.entrySet())
125
 			other.addEnumMember(entry.getValue(), priority);
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
 			other.addVariantOption(entry.getValue());
122
 			other.addVariantOption(entry.getValue());
128
 		for (Map.Entry<String, DefinitionMemberGroup> entry : members.entrySet())
123
 		for (Map.Entry<String, DefinitionMemberGroup> entry : members.entrySet())
129
 			other.getOrCreateGroup(entry.getKey(), entry.getValue().isStatic).merge(position, entry.getValue(), priority);
124
 			other.getOrCreateGroup(entry.getKey(), entry.getValue().isStatic).merge(position, entry.getValue(), priority);
145
 		return null;
140
 		return null;
146
 	}
141
 	}
147
 	
142
 	
148
-	public void addConstructor(ConstructorMember constructor, TypeMemberPriority priority) {
143
+	public void addConstructor(FunctionalMemberRef constructor, TypeMemberPriority priority) {
149
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, priority);
144
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, priority);
150
 	}
145
 	}
151
 	
146
 	
152
-	public void addConstructor(ConstructorMember constructor) {
147
+	public void addConstructor(FunctionalMemberRef constructor) {
153
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, TypeMemberPriority.SPECIFIED);
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
 		getOrCreateGroup(OperatorType.DESTRUCTOR).addMethod(destructor, priority);
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
 		getOrCreateGroup(OperatorType.CALL).addMethod(caller, priority);
156
 		getOrCreateGroup(OperatorType.CALL).addMethod(caller, priority);
162
 	}
157
 	}
163
 	
158
 	
164
-	public void addCaster(CasterMember caster) {
159
+	public void addCaster(CasterMemberRef caster) {
165
 		addCaster(caster, TypeMemberPriority.SPECIFIED);
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
 		for (int i = 0; i < casters.size(); i++) {
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
 				casters.set(i, casters.get(i).resolve(new TypeMember<>(priority, caster)));
166
 				casters.set(i, casters.get(i).resolve(new TypeMember<>(priority, caster)));
172
 				return;
167
 				return;
173
 			}
168
 			}
176
 		casters.add(new TypeMember<>(priority, caster));
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
 		group.setConst(member, TypeMemberPriority.SPECIFIED);
176
 		group.setConst(member, TypeMemberPriority.SPECIFIED);
182
 	}
177
 	}
183
 	
178
 	
184
-	public void addField(FieldMember member) {
179
+	public void addField(FieldMemberRef member) {
185
 		addField(member, TypeMemberPriority.SPECIFIED);
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
 		group.setField(member, priority);
185
 		group.setField(member, priority);
191
 	}
186
 	}
192
 	
187
 	
193
-	public void addGetter(GetterMember member) {
188
+	public void addGetter(GetterMemberRef member) {
194
 		addGetter(member, TypeMemberPriority.SPECIFIED);
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
 		group.setGetter(member, priority);
194
 		group.setGetter(member, priority);
200
 	}
195
 	}
201
 	
196
 	
202
-	public void addSetter(SetterMember member) {
197
+	public void addSetter(SetterMemberRef member) {
203
 		addSetter(member, TypeMemberPriority.SPECIFIED);
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
 		group.setSetter(member, priority);
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
 		group.addMethod(member, priority);
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
 	public boolean hasOperator(OperatorType operator) {
219
 	public boolean hasOperator(OperatorType operator) {
225
 		return operators.containsKey(operator) && operators.get(operator).hasMethods();
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
 		DefinitionMemberGroup group = getOrCreateGroup(operator);
224
 		DefinitionMemberGroup group = getOrCreateGroup(operator);
235
 		group.addMethod(member, priority);
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
 		for (int i = 0; i < iterators.size(); i++) {
233
 		for (int i = 0; i < iterators.size(); i++) {
244
 			if (iterators.get(i).member.getLoopVariableCount() == iterator.getLoopVariableCount()) {
234
 			if (iterators.get(i).member.getLoopVariableCount() == iterator.getLoopVariableCount()) {
245
 				iterators.set(i, iterators.get(i).resolve(new TypeMember<>(priority, iterator)));
235
 				iterators.set(i, iterators.get(i).resolve(new TypeMember<>(priority, iterator)));
250
 		iterators.add(new TypeMember<>(priority, iterator));
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
 		for (int i = 0; i < implementations.size(); i++) {
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
 				implementations.set(i, implementations.get(i).resolve(new TypeMember<>(priority, member)));
246
 				implementations.set(i, implementations.get(i).resolve(new TypeMember<>(priority, member)));
257
 				return;
247
 				return;
258
 			}
248
 			}
290
 		return enumMembers.get(name);
280
 		return enumMembers.get(name);
291
 	}
281
 	}
292
 	
282
 	
293
-	public VariantDefinition.Option getVariantOption(String name) {
283
+	public VariantOptionRef getVariantOption(String name) {
294
 		return variantOptions.get(name);
284
 		return variantOptions.get(name);
295
 	}
285
 	}
296
 	
286
 	
297
 	public Expression compare(CodePosition position, TypeScope scope, CompareType operator, Expression left, Expression right) {
287
 	public Expression compare(CodePosition position, TypeScope scope, CompareType operator, Expression left, Expression right) {
298
 		if (operator == CompareType.EQ) {
288
 		if (operator == CompareType.EQ) {
299
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.EQUALS);
289
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.EQUALS);
300
-			for (TypeMember<FunctionalMember> member : equal.getMethodMembers()) {
290
+			for (TypeMember<FunctionalMemberRef> member : equal.getMethodMembers()) {
301
 				if (member.member.header.accepts(scope, right))
291
 				if (member.member.header.accepts(scope, right))
302
 					return equal.call(position, scope, left, new CallArguments(right), false);
292
 					return equal.call(position, scope, left, new CallArguments(right), false);
303
 			}
293
 			}
304
 		} else if (operator == CompareType.NE) {
294
 		} else if (operator == CompareType.NE) {
305
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.NOTEQUALS);
295
 			DefinitionMemberGroup equal = getOrCreateGroup(OperatorType.NOTEQUALS);
306
-			for (TypeMember<FunctionalMember> member : equal.getMethodMembers()) {
296
+			for (TypeMember<FunctionalMemberRef> member : equal.getMethodMembers()) {
307
 				if (member.member.header.accepts(scope, right)) {
297
 				if (member.member.header.accepts(scope, right)) {
308
 					return equal.call(position, scope, left, new CallArguments(right), false);
298
 					return equal.call(position, scope, left, new CallArguments(right), false);
309
 				}
299
 				}
324
 		return members.call(position, scope, a, new CallArguments(b, c), false);
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
 			if (iterator.member.getLoopVariableCount() == variables)
319
 			if (iterator.member.getLoopVariableCount() == variables)
330
 				return iterator.member;
320
 				return iterator.member;
331
 		
321
 		
333
 	}
323
 	}
334
 	
324
 	
335
 	public ITypeID[] getLoopTypes(int variables) {
325
 	public ITypeID[] getLoopTypes(int variables) {
336
-		for (TypeMember<IIteratorMember> iterator : iterators)
326
+		for (TypeMember<IteratorMemberRef> iterator : iterators)
337
 			if (iterator.member.getLoopVariableCount() == variables)
327
 			if (iterator.member.getLoopVariableCount() == variables)
338
-				return iterator.member.getLoopVariableTypes();
328
+				return iterator.member.types;
339
 		
329
 		
340
 		return null;
330
 		return null;
341
 	}
331
 	}
357
 		if (type.isOptional() && type.unwrap() == toType)
347
 		if (type.isOptional() && type.unwrap() == toType)
358
 			return true;
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
 				return true;
352
 				return true;
363
 		}
353
 		}
364
 		
354
 		
369
 		if (canCastImplicit(toType))
359
 		if (canCastImplicit(toType))
370
 			return true;
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
 				return true;
364
 				return true;
375
 		}
365
 		}
376
 		
366
 		
392
 		if (type.isOptional() && type.unwrap() == toType)
382
 		if (type.isOptional() && type.unwrap() == toType)
393
 			return new CheckNullExpression(position, value);
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
 				return caster.member.cast(position, value, implicit);
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
 				return new InterfaceCastExpression(position, value, toType);
391
 				return new InterfaceCastExpression(position, value, toType);
402
 		}
392
 		}
403
 		if (extendsType(toType))
393
 		if (extendsType(toType))
410
 		if (this.canCastImplicit(toType))
400
 		if (this.canCastImplicit(toType))
411
 			return castImplicit(position, value, toType, false);
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
 				return caster.member.cast(position, value, false);
405
 				return caster.member.cast(position, value, false);
416
 		
406
 		
417
 		throw new CompileException(position, CompileExceptionCode.INVALID_CAST, "Cannot cast " + toString() + " to " + toType + ", even explicitly");
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 View File

98
 			throw new IllegalStateException("Module is not yet normalized");
98
 			throw new IllegalStateException("Module is not yet normalized");
99
 		
99
 		
100
 		Validator validator = new Validator();
100
 		Validator validator = new Validator();
101
-		boolean isValid = true;
102
 		for (ScriptBlock script : scripts) {
101
 		for (ScriptBlock script : scripts) {
103
-			isValid &= validator.validate(script);
102
+			validator.validate(script);
104
 		}
103
 		}
105
 		for (HighLevelDefinition definition : definitions.getAll()) {
104
 		for (HighLevelDefinition definition : definitions.getAll()) {
106
-			isValid &= validator.validate(definition);
105
+			validator.validate(definition);
107
 		}
106
 		}
108
 		
107
 		
109
 		for (ValidationLogEntry entry : validator.getLog()) {
108
 		for (ValidationLogEntry entry : validator.getLog()) {
110
 			System.out.println(entry.kind + " " + entry.position.toString() + ": " + entry.message);
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
 	public void compile(ZenCodeCompiler compiler) {
115
 	public void compile(ZenCodeCompiler compiler) {

+ 0
- 4
Constructor/libraries/collections/module.json View File

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

+ 0
- 11
Constructor/libraries/collections/src/HashSet.zs View File

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 View File

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 View File

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

+ 0
- 7
Constructor/libraries/collections/src/Queue.zs View File

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 View File

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 View File


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

Loading…
Cancel
Save