Przeglądaj źródła

- Added type aliasing

- Changed the way modified types are processed
- Added immutable keyword
- Added expression, statement and type normalization
- Improved naming of synthetic functions
Stan Hebben 6 lat temu
rodzic
commit
0f45f3cd45
100 zmienionych plików z 693 dodań i 68 usunięć
  1. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/DefinitionFormatter.java
  2. 13
    9
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java
  3. 21
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  4. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java
  5. 53
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  6. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java
  7. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java
  8. 1
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java
  9. 1
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java
  10. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/AndAndExpression.java
  11. 9
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ArrayExpression.java
  12. 13
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallExpression.java
  13. 13
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java
  14. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedClosureExpression.java
  15. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedDirectExpression.java
  16. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpression.java
  17. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedLocalVariableExpression.java
  18. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedParameterExpression.java
  19. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedThisExpression.java
  20. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java
  21. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CheckNullExpression.java
  22. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CoalesceExpression.java
  23. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java
  24. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConditionalExpression.java
  25. 7
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstExpression.java
  26. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantBoolExpression.java
  27. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantByteExpression.java
  28. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantCharExpression.java
  29. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantDoubleExpression.java
  30. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantFloatExpression.java
  31. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantIntExpression.java
  32. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantLongExpression.java
  33. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantSByteExpression.java
  34. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantShortExpression.java
  35. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantStringExpression.java
  36. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUIntExpression.java
  37. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantULongExpression.java
  38. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUShortExpression.java
  39. 8
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorSuperCallExpression.java
  40. 8
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java
  41. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java
  42. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java
  43. 4
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  44. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java
  45. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/FunctionExpression.java
  46. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java
  47. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFunctionParameterExpression.java
  48. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetLocalVariableExpression.java
  49. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java
  50. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java
  51. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GlobalCallExpression.java
  52. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GlobalExpression.java
  53. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InterfaceCastExpression.java
  54. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/IsExpression.java
  55. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MakeConstExpression.java
  56. 14
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MapExpression.java
  57. 13
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MatchExpression.java
  58. 9
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java
  59. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NullExpression.java
  60. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/OrOrExpression.java
  61. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java
  62. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PostCallExpression.java
  63. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/RangeExpression.java
  64. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SameObjectExpression.java
  65. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFieldExpression.java
  66. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFunctionParameterExpression.java
  67. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetLocalVariableExpression.java
  68. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetStaticFieldExpression.java
  69. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetterExpression.java
  70. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticGetterExpression.java
  71. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticSetterExpression.java
  72. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SupertypeCastExpression.java
  73. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThisExpression.java
  74. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java
  75. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryConvertExpression.java
  76. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsExceptionExpression.java
  77. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsResultExpression.java
  78. 8
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java
  79. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/WrapOptionalExpression.java
  80. 1
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java
  81. 8
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java
  82. 8
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  83. 19
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java
  84. 13
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  85. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalKind.java
  86. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  87. 3
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  88. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  89. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinition.java
  90. 9
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java
  91. 8
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java
  92. 7
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java
  93. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java
  94. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java
  95. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java
  96. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java
  97. 16
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java
  98. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java
  99. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java
  100. 0
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/DefinitionFormatter.java Wyświetl plik

@@ -42,9 +42,9 @@ public class DefinitionFormatter implements DefinitionVisitor<Void> {
42 42
 		output.append(definition.name);
43 43
 		FormattingUtils.formatTypeParameters(output, definition.genericParameters, typeFormatter);
44 44
 		output.append(" ");
45
-		if (definition.superType != null) {
45
+		if (definition.getSuperType() != null) {
46 46
 			output.append("extends ");
47
-			output.append(definition.superType.accept(typeFormatter));
47
+			output.append(definition.getSuperType().accept(typeFormatter));
48 48
 			output.append(" ");
49 49
 		}
50 50
 		if (settings.classBracketOnSameLine) {

+ 13
- 9
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java Wyświetl plik

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
14 14
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16
-import org.openzen.zenscript.codemodel.type.ConstTypeID;
16
+import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
18 18
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
19 19
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
@@ -21,8 +21,8 @@ import org.openzen.zenscript.codemodel.type.GenericTypeID;
21 21
 import org.openzen.zenscript.codemodel.type.ITypeID;
22 22
 import org.openzen.zenscript.codemodel.type.ITypeVisitor;
23 23
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
24
-import org.openzen.zenscript.codemodel.type.OptionalTypeID;
25 24
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
25
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
26 26
 import stdlib.Chars;
27 27
 
28 28
 /**
@@ -102,13 +102,17 @@ public class TypeFormatter implements ITypeVisitor<String>, GenericParameterBoun
102 102
 	}
103 103
 
104 104
 	@Override
105
-	public String visitConst(ConstTypeID type) {
106
-		return "const " + type.accept(this);
107
-	}
108
-
109
-	@Override
110
-	public String visitOptional(OptionalTypeID optional) {
111
-		return optional.baseType.accept(this) + "?";
105
+	public String visitModified(ModifiedTypeID type) {
106
+		StringBuilder result = new StringBuilder();
107
+		if ((type.modifiers & TypeMembers.MODIFIER_CONST) > 0)
108
+			result.append("const ");
109
+		if ((type.modifiers & TypeMembers.MODIFIER_IMMUTABLE) > 0)
110
+			result.append("immutable ");
111
+		result.append(type.accept(this));
112
+		if ((type.modifiers & TypeMembers.MODIFIER_OPTIONAL) > 0)
113
+			result.append("?");
114
+		
115
+		return result.toString();
112 116
 	}
113 117
 
114 118
 	@Override

+ 21
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java Wyświetl plik

@@ -17,7 +17,6 @@ import org.openzen.zenscript.codemodel.type.BasicTypeID;
17 17
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
18 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
19 19
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20
-import org.openzen.zenscript.codemodel.type.GenericTypeID;
21 20
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
22 21
 
23 22
 /**
@@ -97,6 +96,26 @@ public class FunctionHeader {
97 96
 		hasUnknowns = hasUnknowns(parameters);
98 97
 	}
99 98
 	
99
+	public boolean isDenormalized() {
100
+		if (returnType.getNormalized() != returnType)
101
+			return true;
102
+		for (FunctionParameter parameter : parameters)
103
+			if (parameter.type.getNormalized() != parameter.type)
104
+				return true;
105
+		
106
+		return false;
107
+	}
108
+	
109
+	public FunctionHeader normalize(GlobalTypeRegistry registry) {
110
+		if (!isDenormalized())
111
+			return this;
112
+		
113
+		FunctionParameter[] normalizedParameters = new FunctionParameter[parameters.length];
114
+		for (int i = 0; i < normalizedParameters.length; i++)
115
+			normalizedParameters[i] = parameters[i].normalized(registry);
116
+		return new FunctionHeader(typeParameters, returnType.getNormalized(), thrownType == null ? null : thrownType.getNormalized(), normalizedParameters);
117
+	}
118
+	
100 119
 	public int getNumberOfTypeParameters() {
101 120
 		return typeParameters.length;
102 121
 	}
@@ -114,7 +133,7 @@ public class FunctionHeader {
114 133
 		} else {
115 134
 			Map<TypeParameter, ITypeID> mapping = new HashMap<>();
116 135
 			for (int i = 0; i < overridden.typeParameters.length; i++)
117
-				mapping.put(overridden.typeParameters[i], new GenericTypeID(typeParameters[i]));
136
+				mapping.put(overridden.typeParameters[i], registry.getGeneric(typeParameters[i]));
118 137
 			mapper = new GenericMapper(registry, mapping);
119 138
 		}
120 139
 		

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionParameter.java Wyświetl plik

@@ -9,6 +9,7 @@ import org.openzen.zenscript.codemodel.annotations.Annotation;
9 9
 import java.util.Objects;
10 10
 import org.openzen.zencode.shared.Taggable;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 14
 
14 15
 /**
@@ -48,6 +49,12 @@ public class FunctionParameter extends Taggable {
48 49
 		this.variadic = variadic;
49 50
 	}
50 51
 	
52
+	public FunctionParameter normalized(GlobalTypeRegistry registry) {
53
+		FunctionParameter result = new FunctionParameter(type.getNormalized(), name, defaultValue, variadic);
54
+		result.annotations = this.annotations;
55
+		return result;
56
+	}
57
+	
51 58
 	public FunctionParameter withGenericArguments(GenericMapper mapper) {
52 59
 		ITypeID instanced = type.instance(mapper);
53 60
 		if (instanced == type)

+ 53
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java Wyświetl plik

@@ -10,12 +10,17 @@ import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zencode.shared.Taggable;
12 12
 import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
13
+import org.openzen.zenscript.codemodel.definition.AliasDefinition;
13 14
 import org.openzen.zenscript.codemodel.definition.DefinitionVisitor;
15
+import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
14 16
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
15 17
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
16 18
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
19
+import org.openzen.zenscript.codemodel.member.DestructorMember;
17 20
 import org.openzen.zenscript.codemodel.member.FieldMember;
18 21
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
22
+import org.openzen.zenscript.codemodel.member.ImplementationMember;
23
+import org.openzen.zenscript.codemodel.scope.TypeScope;
19 24
 import org.openzen.zenscript.codemodel.type.ITypeID;
20 25
 
21 26
 /**
@@ -28,11 +33,13 @@ public abstract class HighLevelDefinition extends Taggable {
28 33
 	public final String name;
29 34
 	public final int modifiers;
30 35
 	public final List<IDefinitionMember> members = new ArrayList<>();
31
-	public TypeParameter[] genericParameters = null;
36
+	public TypeParameter[] genericParameters = TypeParameter.NONE;
32 37
 	public DefinitionAnnotation[] annotations = DefinitionAnnotation.NONE;
33 38
 	
34 39
 	public HighLevelDefinition outerDefinition;
35
-	public ITypeID superType;
40
+	private ITypeID superType;
41
+	
42
+	private boolean isDestructible = false;
36 43
 	
37 44
 	public HighLevelDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
38 45
 		this.position = position;
@@ -45,10 +52,27 @@ public abstract class HighLevelDefinition extends Taggable {
45 52
 			pkg.register(this);
46 53
 	}
47 54
 	
55
+	public HighLevelDefinition getOutermost() {
56
+		HighLevelDefinition result = this;
57
+		while (result.outerDefinition != null)
58
+			result = result.outerDefinition;
59
+		return result;
60
+	}
61
+	
48 62
 	public String getFullName() {
49 63
 		return pkg.fullName + '.' + name;
50 64
 	}
51 65
 	
66
+	public ITypeID getSuperType() {
67
+		return superType;
68
+	}
69
+	
70
+	public void setSuperType(ITypeID superType) {
71
+		this.superType = superType;
72
+		if (outerDefinition != null)
73
+			isDestructible |= outerDefinition.isDestructible;
74
+	}
75
+	
52 76
 	public int getNumberOfGenericParameters() {
53 77
 		return genericParameters == null ? 0 : genericParameters.length;
54 78
 	}
@@ -61,11 +85,32 @@ public abstract class HighLevelDefinition extends Taggable {
61 85
 		return outerDefinition != null;
62 86
 	}
63 87
 	
88
+	public boolean isInterface() {
89
+		return this instanceof InterfaceDefinition;
90
+	}
91
+	
92
+	public boolean isAlias() {
93
+		return this instanceof AliasDefinition;
94
+	}
95
+	
64 96
 	public void addMember(IDefinitionMember member) {
65 97
 		if (!members.contains(member))
66 98
 			members.add(member);
67 99
 	}
68 100
 	
101
+	public boolean isDestructible() {
102
+		boolean isDestructible = false;
103
+		for (IDefinitionMember member : members) {
104
+			if (member instanceof DestructorMember)
105
+				isDestructible = true;
106
+			if ((member instanceof FieldMember) && ((FieldMember)member).type.isDestructible())
107
+				isDestructible = true;
108
+			if ((member instanceof ImplementationMember) && ((ImplementationMember)member).type.isDestructible())
109
+				isDestructible = true;
110
+		}
111
+		return isDestructible;
112
+	}
113
+	
69 114
 	public void setTypeParameters(TypeParameter[] typeParameters) {
70 115
 		this.genericParameters = typeParameters;
71 116
 	}
@@ -94,5 +139,11 @@ public abstract class HighLevelDefinition extends Taggable {
94 139
 		return (modifiers & Modifiers.STATIC) > 0;
95 140
 	}
96 141
 	
142
+	public void normalize(TypeScope scope) {
143
+		for (IDefinitionMember member : members) {
144
+			member.normalize(scope);
145
+		}
146
+	}
147
+	
97 148
 	public abstract <T> T accept(DefinitionVisitor<T> visitor);
98 149
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java Wyświetl plik

@@ -164,7 +164,7 @@ public class AnnotationProcessor implements ModuleProcessor {
164 164
 
165 165
 		@Override
166 166
 		public Void visitCustomIterator(CustomIteratorMember member) {
167
-			throw new UnsupportedOperationException("Not supported yet!");
167
+			return functional(member);
168 168
 		}
169 169
 
170 170
 		@Override

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
12 13
 /**
@@ -28,4 +29,9 @@ public class AliasDefinition extends HighLevelDefinition {
28 29
 	public <T> T accept(DefinitionVisitor<T> visitor) {
29 30
 		return visitor.visitAlias(this);
30 31
 	}
32
+
33
+	@Override
34
+	public void normalize(TypeScope scope) {
35
+		// nothing to do
36
+	}
31 37
 }

+ 1
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
12 13
 /**
@@ -21,10 +22,6 @@ public class ClassDefinition extends HighLevelDefinition {
21 22
 	public ClassDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22 23
 		super(position, pkg, name, modifiers, outerDefinition);
23 24
 	}
24
-	
25
-	public void setSuperclass(ITypeID superclass) {
26
-		this.superType = superclass;
27
-	}
28 25
 
29 26
 	@Override
30 27
 	public <T> T accept(DefinitionVisitor<T> visitor) {

+ 1
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java Wyświetl plik

@@ -9,6 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.Modifiers;
12 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 14
 
14 15
 /**

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/AndAndExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -36,4 +37,9 @@ public class AndAndExpression extends Expression {
36 37
 				? this
37 38
 				: new AndAndExpression(position, tLeft, tRight);
38 39
 	}
40
+
41
+	@Override
42
+	public Expression normalize(TypeScope scope) {
43
+		return new AndAndExpression(position, left.normalize(scope), right.normalize(scope));
44
+	}
39 45
 }

+ 9
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ArrayExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
10 11
 
11 12
 /**
@@ -33,4 +34,12 @@ public class ArrayExpression extends Expression {
33 34
 		Expression[] tExpressions = Expression.transform(expressions, transformer);
34 35
 		return tExpressions == expressions ? this : new ArrayExpression(position, tExpressions, (ArrayTypeID)type);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		Expression[] normalized = new Expression[expressions.length];
41
+		for (int i = 0; i < normalized.length; i++)
42
+			normalized[i] = expressions[i].normalize(scope);
43
+		return new ArrayExpression(position, normalized, arrayType.getNormalized());
44
+	}
36 45
 }

+ 13
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallExpression.java Wyświetl plik

@@ -20,12 +20,12 @@ public class CallExpression extends Expression {
20 20
 	public final CallArguments arguments;
21 21
 	public final FunctionHeader instancedHeader;
22 22
 	
23
-	public CallExpression(CodePosition position, Expression target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
23
+	public CallExpression(CodePosition position, Expression target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments) {
24 24
 		super(position, instancedHeader.returnType, multiThrow(position, arguments.arguments));
25 25
 		
26 26
 		this.target = target;
27 27
 		this.member = member;
28
-		this.arguments = scope == null ? arguments : arguments.normalize(position, scope, instancedHeader);
28
+		this.arguments = arguments;
29 29
 		this.instancedHeader = instancedHeader;
30 30
 	}
31 31
 	
@@ -44,7 +44,7 @@ public class CallExpression extends Expression {
44 44
 		CallArguments tArguments = arguments.transform(transformer);
45 45
 		return tTarget == target && tArguments == arguments
46 46
 				? this
47
-				: new CallExpression(position, tTarget, member, instancedHeader, tArguments, null);
47
+				: new CallExpression(position, tTarget, member, instancedHeader, tArguments);
48 48
 	}
49 49
 	
50 50
 	@Override
@@ -59,4 +59,14 @@ public class CallExpression extends Expression {
59 59
 				throw new UnsupportedOperationException("Cannot evaluate to a string constant!");
60 60
 		}
61 61
 	}
62
+
63
+	@Override
64
+	public Expression normalize(TypeScope scope) {
65
+		return new CallExpression(
66
+				position,
67
+				target.normalize(scope),
68
+				member,
69
+				instancedHeader.normalize(scope.getTypeRegistry()),
70
+				arguments.normalize(position, scope, instancedHeader));
71
+	}
62 72
 }

+ 13
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallStaticExpression.java Wyświetl plik

@@ -21,12 +21,12 @@ public class CallStaticExpression extends Expression {
21 21
 	public final CallArguments arguments;
22 22
 	public final FunctionHeader instancedHeader;
23 23
 	
24
-	public CallStaticExpression(CodePosition position, ITypeID target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
24
+	public CallStaticExpression(CodePosition position, ITypeID target, FunctionalMemberRef member, FunctionHeader instancedHeader, CallArguments arguments) {
25 25
 		super(position, instancedHeader.returnType, multiThrow(position, arguments.arguments));
26 26
 		
27 27
 		this.member = member;
28 28
 		this.target = target;
29
-		this.arguments = scope == null ? arguments : arguments.normalize(position, scope, instancedHeader);
29
+		this.arguments = arguments;
30 30
 		this.instancedHeader = instancedHeader;
31 31
 	}
32 32
 
@@ -38,6 +38,16 @@ public class CallStaticExpression extends Expression {
38 38
 	@Override
39 39
 	public Expression transform(ExpressionTransformer transformer) {
40 40
 		CallArguments tArguments = arguments.transform(transformer);
41
-		return arguments == tArguments ? this : new CallStaticExpression(position, target, member, instancedHeader, tArguments, null);
41
+		return arguments == tArguments ? this : new CallStaticExpression(position, target, member, instancedHeader, tArguments);
42
+	}
43
+
44
+	@Override
45
+	public Expression normalize(TypeScope scope) {
46
+		return new CallStaticExpression(
47
+				position,
48
+				target.getNormalized(),
49
+				member,
50
+				instancedHeader.normalize(scope.getTypeRegistry()),
51
+				arguments.normalize(position, scope, instancedHeader));
42 52
 	}
43 53
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedClosureExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  *
@@ -39,4 +40,9 @@ public class CapturedClosureExpression extends CapturedExpression {
39 40
 			return tValue == value ? this : new CapturedClosureExpression(position, (CapturedExpression)tValue, closure);
40 41
 		}
41 42
 	}
43
+
44
+	@Override
45
+	public CapturedExpression normalize(TypeScope scope) {
46
+		return new CapturedClosureExpression(position, value.normalize(scope), closure);
47
+	}
42 48
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedDirectExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  *
@@ -34,4 +35,9 @@ public class CapturedDirectExpression extends CapturedExpression {
34 35
 		Expression tValue = transformer.transform(value);
35 36
 		return tValue == value ? this : new CapturedDirectExpression(position, closure, tValue);
36 37
 	}
38
+
39
+	@Override
40
+	public CapturedExpression normalize(TypeScope scope) {
41
+		return new CapturedDirectExpression(position, closure, value.normalize(scope));
42
+	}
37 43
 }

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -28,5 +29,8 @@ public abstract class CapturedExpression extends Expression {
28 29
 		return result;
29 30
 	}
30 31
 	
32
+	@Override
33
+	public abstract CapturedExpression normalize(TypeScope scope);
34
+	
31 35
 	public abstract <T> T accept(CapturedExpressionVisitor<T> visitor);
32 36
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedLocalVariableExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.statement.VarStatement;
10 11
 
11 12
 /**
@@ -35,4 +36,9 @@ public class CapturedLocalVariableExpression extends CapturedExpression {
35 36
 	public Expression transform(ExpressionTransformer transformer) {
36 37
 		return this;
37 38
 	}
39
+
40
+	@Override
41
+	public CapturedExpression normalize(TypeScope scope) {
42
+		return this;
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedParameterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionParameter;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -35,4 +36,9 @@ public class CapturedParameterExpression extends CapturedExpression {
35 36
 	public Expression transform(ExpressionTransformer transformer) {
36 37
 		return this;
37 38
 	}
39
+
40
+	@Override
41
+	public CapturedExpression normalize(TypeScope scope) {
42
+		return this;
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedThisExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class CapturedThisExpression extends CapturedExpression {
31 32
 	public Expression transform(ExpressionTransformer transformer) {
32 33
 		return this;
33 34
 	}
35
+
36
+	@Override
37
+	public CapturedExpression normalize(TypeScope scope) {
38
+		return this;
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -35,4 +36,9 @@ public class CastExpression extends Expression {
35 36
 		Expression tTarget = target.transform(transformer);
36 37
 		return target == tTarget ? this : new CastExpression(position, tTarget, member, isImplicit);
37 38
 	}
39
+
40
+	@Override
41
+	public Expression normalize(TypeScope scope) {
42
+		return new CastExpression(position, target.normalize(scope), member, isImplicit);
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CheckNullExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  * Converts a value from X? to X. Throws a NullPointerException if the value is null.
@@ -31,4 +32,9 @@ public class CheckNullExpression extends Expression {
31 32
 		Expression tValue = transformer.transform(value);
32 33
 		return value == tValue ? this : new CheckNullExpression(position, tValue);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new CheckNullExpression(position, value.normalize(scope));
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CoalesceExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  *
@@ -33,4 +34,9 @@ public class CoalesceExpression extends Expression {
33 34
 		Expression tRight = right.transform(transformer);
34 35
 		return tLeft == left && tRight == right ? this : new CoalesceExpression(position, tLeft, tRight);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new CoalesceExpression(position, left.normalize(scope), right.normalize(scope));
41
+	}
36 42
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CompareExpression.java Wyświetl plik

@@ -43,4 +43,9 @@ public class CompareExpression extends Expression {
43 43
 		Expression tRight = right.transform(transformer);
44 44
 		return left == tLeft && right == tRight ? this : new CompareExpression(position, tLeft, tRight, operator, comparison, null);
45 45
 	}
46
+
47
+	@Override
48
+	public Expression normalize(TypeScope scope) {
49
+		return new CompareExpression(position, left.normalize(scope), right.normalize(scope), operator, comparison, scope);
50
+	}
46 51
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConditionalExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -47,4 +48,9 @@ public class ConditionalExpression extends Expression {
47 48
 				? this
48 49
 				: new ConditionalExpression(position, tCondition, tIfThen, tIfElse, type);
49 50
 	}
51
+
52
+	@Override
53
+	public Expression normalize(TypeScope scope) {
54
+		return new ConditionalExpression(position, condition.normalize(scope), ifThen.normalize(scope), ifElse.normalize(scope), type.getNormalized());
55
+	}
50 56
 }

+ 7
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstExpression.java Wyświetl plik

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
10 10
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
11 11
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
12
+import org.openzen.zenscript.codemodel.scope.TypeScope;
12 13
 
13 14
 /**
14 15
  *
@@ -18,7 +19,7 @@ public class ConstExpression extends Expression {
18 19
 	public final ConstMemberRef constant;
19 20
 	
20 21
 	public ConstExpression(CodePosition position, ConstMemberRef constant) {
21
-		super(position, constant.type, null);
22
+		super(position, constant.getType(), null);
22 23
 		
23 24
 		this.constant = constant;
24 25
 	}
@@ -47,4 +48,9 @@ public class ConstExpression extends Expression {
47 48
 	public IDefinitionMember getMember() {
48 49
 		return constant.member;
49 50
 	}
51
+
52
+	@Override
53
+	public Expression normalize(TypeScope scope) {
54
+		return this;
55
+	}
50 56
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantBoolExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantBoolExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantByteExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantByteExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantCharExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantCharExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantDoubleExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantDoubleExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantFloatExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantFloatExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantIntExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantIntExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantLongExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantLongExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantSByteExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantSByteExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantShortExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantShortExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantStringExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -35,4 +36,9 @@ public class ConstantStringExpression extends Expression {
35 36
 	public String evaluateStringConstant() {
36 37
 		return value;
37 38
 	}
39
+
40
+	@Override
41
+	public Expression normalize(TypeScope scope) {
42
+		return this;
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUIntExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantUIntExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantULongExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantULongExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantUShortExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -30,4 +31,9 @@ public class ConstantUShortExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 8
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorSuperCallExpression.java Wyświetl plik

@@ -20,12 +20,12 @@ public class ConstructorSuperCallExpression extends Expression {
20 20
 	public final FunctionalMemberRef constructor;
21 21
 	public final CallArguments arguments;
22 22
 	
23
-	public ConstructorSuperCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments, TypeScope scope) {
23
+	public ConstructorSuperCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments) {
24 24
 		super(position, BasicTypeID.VOID, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
25 25
 		
26 26
 		this.objectType = type;
27 27
 		this.constructor = constructor;
28
-		this.arguments = scope == null ? arguments : arguments.normalize(position, scope, constructor.header);
28
+		this.arguments = arguments;
29 29
 	}
30 30
 
31 31
 	@Override
@@ -36,6 +36,11 @@ public class ConstructorSuperCallExpression extends Expression {
36 36
 	@Override
37 37
 	public Expression transform(ExpressionTransformer transformer) {
38 38
 		CallArguments tArguments = arguments.transform(transformer);
39
-		return tArguments == arguments ? this : new ConstructorSuperCallExpression(position, type, constructor, tArguments, null);
39
+		return tArguments == arguments ? this : new ConstructorSuperCallExpression(position, type, constructor, tArguments);
40
+	}
41
+
42
+	@Override
43
+	public Expression normalize(TypeScope scope) {
44
+		return new ConstructorSuperCallExpression(position, type.getNormalized(), constructor, arguments.normalize(position, scope, constructor.header));
40 45
 	}
41 46
 }

+ 8
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstructorThisCallExpression.java Wyświetl plik

@@ -20,12 +20,12 @@ public class ConstructorThisCallExpression extends Expression {
20 20
 	public final FunctionalMemberRef constructor;
21 21
 	public final CallArguments arguments;
22 22
 	
23
-	public ConstructorThisCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments, TypeScope scope) {
23
+	public ConstructorThisCallExpression(CodePosition position, ITypeID type, FunctionalMemberRef constructor, CallArguments arguments) {
24 24
 		super(position, BasicTypeID.VOID, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
25 25
 		
26 26
 		this.objectType = type;
27 27
 		this.constructor = constructor;
28
-		this.arguments = scope == null ? arguments : arguments.normalize(position, scope, constructor.header);
28
+		this.arguments = arguments;
29 29
 	}
30 30
 
31 31
 	@Override
@@ -36,6 +36,11 @@ public class ConstructorThisCallExpression extends Expression {
36 36
 	@Override
37 37
 	public Expression transform(ExpressionTransformer transformer) {
38 38
 		CallArguments tArguments = arguments.transform(transformer);
39
-		return tArguments == arguments ? this : new ConstructorThisCallExpression(position, type, constructor, tArguments, null);
39
+		return tArguments == arguments ? this : new ConstructorThisCallExpression(position, type, constructor, tArguments);
40
+	}
41
+
42
+	@Override
43
+	public Expression normalize(TypeScope scope) {
44
+		return new ConstructorThisCallExpression(position, type, constructor, arguments.normalize(position, scope, constructor.header));
40 45
 	}
41 46
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -26,4 +27,9 @@ public class DummyExpression extends Expression {
26 27
 	public Expression transform(ExpressionTransformer transformer) {
27 28
 		throw new UnsupportedOperationException("This is a dummy expression");
28 29
 	}
30
+
31
+	@Override
32
+	public Expression normalize(TypeScope scope) {
33
+		return this;
34
+	}
29 35
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java Wyświetl plik

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel.expression;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
10 10
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
11
+import org.openzen.zenscript.codemodel.scope.TypeScope;
11 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 14
 
@@ -44,4 +45,9 @@ public class EnumConstantExpression extends Expression {
44 45
 	public EnumConstantMember evaluateEnumConstant() {
45 46
 		return value;
46 47
 	}
48
+
49
+	@Override
50
+	public Expression normalize(TypeScope scope) {
51
+		return this;
52
+	}
47 53
 }

+ 4
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java Wyświetl plik

@@ -40,10 +40,10 @@ public abstract class Expression implements IPartialExpression {
40 40
 		if (type == null)
41 41
 			throw new NullPointerException();
42 42
 		if (type == BasicTypeID.UNDETERMINED)
43
-			throw new IllegalArgumentException("Cannot use undetermined type as expression type");
43
+			throw new IllegalArgumentException(position + ": Cannot use undetermined type as expression type");
44 44
 		
45 45
 		this.position = position;
46
-		this.type = type;
46
+		this.type = type.getNormalized();
47 47
 		this.thrownType = thrownType;
48 48
 	}
49 49
 	
@@ -66,6 +66,8 @@ public abstract class Expression implements IPartialExpression {
66 66
 		});
67 67
 	}
68 68
 	
69
+	public abstract Expression normalize(TypeScope scope);
70
+	
69 71
 	@Override
70 72
 	public List<ITypeID> getAssignHints() {
71 73
 		return Collections.singletonList(type);

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java Wyświetl plik

@@ -59,8 +59,7 @@ public class ExpressionBuilder {
59 59
 				type,
60 60
 				member,
61 61
 				compiledArguments,
62
-				compiledArguments.getNumberOfTypeArguments() == 0 ? member.header : member.header.fillGenericArguments(scope.getTypeRegistry(), compiledArguments.typeArguments),
63
-				scope);
62
+				compiledArguments.getNumberOfTypeArguments() == 0 ? member.header : member.header.fillGenericArguments(scope.getTypeRegistry(), compiledArguments.typeArguments));
64 63
 	}
65 64
 	
66 65
 	public Expression not(Expression value) {

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/FunctionExpression.java Wyświetl plik

@@ -12,6 +12,7 @@ import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zencode.shared.ConcatMap;
13 13
 import org.openzen.zenscript.codemodel.FunctionHeader;
14 14
 import org.openzen.zenscript.codemodel.FunctionParameter;
15
+import org.openzen.zenscript.codemodel.scope.TypeScope;
15 16
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
16 17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
17 18
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
@@ -74,6 +75,11 @@ public class FunctionExpression extends Expression {
74 75
 			return null;
75 76
 		}
76 77
 	}
78
+
79
+	@Override
80
+	public Expression normalize(TypeScope scope) {
81
+		return new FunctionExpression(position, (FunctionTypeID)type, closure, header, body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class)));
82
+	}
77 83
 	
78 84
 	private static class ReturnExpressionTransformer implements ExpressionTransformer {
79 85
 		private final LambdaClosure closure;

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFieldExpression.java Wyświetl plik

@@ -58,4 +58,9 @@ public class GetFieldExpression extends Expression {
58 58
 	public IDefinitionMember getMember() {
59 59
 		return field.member;
60 60
 	}
61
+
62
+	@Override
63
+	public Expression normalize(TypeScope scope) {
64
+		return new GetFieldExpression(position, target.normalize(scope), field);
65
+	}
61 66
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetFunctionParameterExpression.java Wyświetl plik

@@ -43,4 +43,9 @@ public class GetFunctionParameterExpression extends Expression {
43 43
 	public Expression transform(ExpressionTransformer transformer) {
44 44
 		return this;
45 45
 	}
46
+
47
+	@Override
48
+	public Expression normalize(TypeScope scope) {
49
+		return this;
50
+	}
46 51
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetLocalVariableExpression.java Wyświetl plik

@@ -43,4 +43,9 @@ public class GetLocalVariableExpression extends Expression {
43 43
 	public Expression transform(ExpressionTransformer transformer) {
44 44
 		return this;
45 45
 	}
46
+
47
+	@Override
48
+	public Expression normalize(TypeScope scope) {
49
+		return this;
50
+	}
46 51
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetStaticFieldExpression.java Wyświetl plik

@@ -10,6 +10,7 @@ import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12 12
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
13
+import org.openzen.zenscript.codemodel.scope.TypeScope;
13 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
14 15
 
15 16
 /**
@@ -49,4 +50,9 @@ public class GetStaticFieldExpression extends Expression {
49 50
 	public IDefinitionMember getMember() {
50 51
 		return field.member;
51 52
 	}
53
+
54
+	@Override
55
+	public Expression normalize(TypeScope scope) {
56
+		return this;
57
+	}
52 58
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -33,4 +34,9 @@ public class GetterExpression extends Expression {
33 34
 		Expression tTarget = target.transform(transformer);
34 35
 		return target == tTarget ? this : new GetterExpression(position, tTarget, getter);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new GetterExpression(position, target.normalize(scope), getter);
41
+	}
36 42
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GlobalCallExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  *
@@ -35,4 +36,9 @@ public class GlobalCallExpression extends Expression {
35 36
 		Expression tResolution = resolution.transform(transformer);
36 37
 		return tArguments == arguments && tResolution == resolution ? this : new GlobalCallExpression(position, name, tArguments, tResolution);
37 38
 	}
39
+
40
+	@Override
41
+	public Expression normalize(TypeScope scope) {
42
+		return new GlobalCallExpression(position, name, arguments, resolution.normalize(scope));
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GlobalExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 
10 11
 /**
11 12
  *
@@ -32,4 +33,9 @@ public class GlobalExpression extends Expression {
32 33
 		Expression tResolution = resolution.transform(transformer);
33 34
 		return resolution == tResolution ? this : new GlobalExpression(position, name, resolution);
34 35
 	}
36
+
37
+	@Override
38
+	public Expression normalize(TypeScope scope) {
39
+		return new GlobalExpression(position, name, resolution.normalize(scope));
40
+	}
35 41
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/InterfaceCastExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class InterfaceCastExpression extends Expression {
31 32
 		Expression tValue = value.transform(transformer);
32 33
 		return value == tValue ? this : new InterfaceCastExpression(position, tValue, type);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new InterfaceCastExpression(position, value.normalize(scope), type.getNormalized());
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/IsExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
@@ -34,4 +35,9 @@ public class IsExpression extends Expression {
34 35
 		Expression tValue = value.transform(transformer);
35 36
 		return tValue == value ? this : new IsExpression(position, tValue, type);
36 37
 	}
38
+
39
+	@Override
40
+	public Expression normalize(TypeScope scope) {
41
+		return new IsExpression(position, value.normalize(scope), type.getNormalized());
42
+	}
37 43
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MakeConstExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class MakeConstExpression extends Expression {
31 32
 		Expression tValue = value.transform(transformer);
32 33
 		return tValue == value ? this : new MakeConstExpression(position, tValue, type);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new MakeConstExpression(position, value.normalize(scope), type.getNormalized());
39
+	}
34 40
 }

+ 14
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MapExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -38,4 +39,17 @@ public class MapExpression extends Expression {
38 39
 		Expression[] tValues = Expression.transform(values, transformer);
39 40
 		return tKeys == keys && tValues == values ? this : new MapExpression(position, tKeys, tValues, type);
40 41
 	}
42
+
43
+	@Override
44
+	public Expression normalize(TypeScope scope) {
45
+		Expression[] normalizedKeys = new Expression[keys.length];
46
+		for (int i = 0; i < normalizedKeys.length; i++)
47
+			normalizedKeys[i] = keys[i].normalize(scope);
48
+		
49
+		Expression[] normalizedValues = new Expression[values.length];
50
+		for (int i = 0; i < normalizedValues.length; i++)
51
+			normalizedValues[i] = values[i].normalize(scope);
52
+		
53
+		return new MapExpression(position, normalizedKeys, normalizedValues, type.getNormalized());
54
+	}
41 55
 }

+ 13
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/MatchExpression.java Wyświetl plik

@@ -10,6 +10,7 @@ import java.util.Collections;
10 10
 import java.util.List;
11 11
 import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zenscript.codemodel.expression.switchvalue.SwitchValue;
13
+import org.openzen.zenscript.codemodel.scope.TypeScope;
13 14
 import org.openzen.zenscript.codemodel.statement.BreakStatement;
14 15
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
15 16
 import org.openzen.zenscript.codemodel.statement.Statement;
@@ -50,6 +51,14 @@ public class MatchExpression extends Expression {
50 51
 		}
51 52
 		return unmodified && tValue == value ? this : new MatchExpression(position, tValue, type, tCases);
52 53
 	}
54
+
55
+	@Override
56
+	public Expression normalize(TypeScope scope) {
57
+		Case[] normalizedCases = new Case[cases.length];
58
+		for (int i = 0; i < cases.length; i++)
59
+			normalizedCases[i] = cases[i].normalize(scope);
60
+		return new MatchExpression(position, value.normalize(scope), type, normalizedCases);
61
+	}
53 62
 	
54 63
 	public SwitchedMatch convertToSwitch(String tempVariable) {
55 64
 		VarStatement result = new VarStatement(position, tempVariable, type, null, false);
@@ -103,6 +112,10 @@ public class MatchExpression extends Expression {
103 112
 			Expression tValue = value.transform(transformer);
104 113
 			return tValue == value ? this : new Case(key, tValue);
105 114
 		}
115
+		
116
+		public Case normalize(TypeScope scope) {
117
+			return new Case(key, value.normalize(scope));
118
+		}
106 119
 	}
107 120
 	
108 121
 	private static ITypeID getThrownType(CodePosition position, Case[] cases) {

+ 9
- 9
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java Wyświetl plik

@@ -26,11 +26,7 @@ public class NewExpression extends Expression {
26 26
 			FunctionalMemberRef constructor,
27 27
 			CallArguments arguments)
28 28
 	{
29
-		super(position, type, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
30
-		
31
-		this.constructor = constructor;
32
-		this.arguments = arguments;
33
-		this.instancedHeader = constructor.header;
29
+		this(position, type, constructor, arguments, constructor.header);
34 30
 	}
35 31
 	
36 32
 	public NewExpression(
@@ -38,13 +34,12 @@ public class NewExpression extends Expression {
38 34
 			ITypeID type,
39 35
 			FunctionalMemberRef constructor,
40 36
 			CallArguments arguments,
41
-			FunctionHeader instancedHeader,
42
-			TypeScope scope)
37
+			FunctionHeader instancedHeader)
43 38
 	{
44 39
 		super(position, type, binaryThrow(position, constructor.header.thrownType, multiThrow(position, arguments.arguments)));
45 40
 		
46 41
 		this.constructor = constructor;
47
-		this.arguments = scope == null ? arguments : arguments.normalize(position, scope, instancedHeader);
42
+		this.arguments = arguments;
48 43
 		this.instancedHeader = instancedHeader;
49 44
 	}
50 45
 
@@ -56,6 +51,11 @@ public class NewExpression extends Expression {
56 51
 	@Override
57 52
 	public Expression transform(ExpressionTransformer transformer) {
58 53
 		CallArguments tArguments = arguments.transform(transformer);
59
-		return tArguments == arguments ? this : new NewExpression(position, type, constructor, tArguments, instancedHeader, null);
54
+		return tArguments == arguments ? this : new NewExpression(position, type, constructor, tArguments, instancedHeader);
55
+	}
56
+
57
+	@Override
58
+	public Expression normalize(TypeScope scope) {
59
+		return new NewExpression(position, type.getNormalized(), constructor, arguments.normalize(position, scope, instancedHeader), instancedHeader);
60 60
 	}
61 61
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NullExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
@@ -31,4 +32,9 @@ public class NullExpression extends Expression {
31 32
 	public Expression transform(ExpressionTransformer transformer) {
32 33
 		return this;
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return this;
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/OrOrExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -34,4 +35,9 @@ public class OrOrExpression extends Expression {
34 35
 		Expression tRight = right.transform(transformer);
35 36
 		return tLeft == left && tRight == right ? this : new OrOrExpression(position, tLeft, tRight);
36 37
 	}
38
+
39
+	@Override
40
+	public Expression normalize(TypeScope scope) {
41
+		return new OrOrExpression(position, left.normalize(scope), right.normalize(scope));
42
+	}
37 43
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -35,4 +36,9 @@ public class PanicExpression extends Expression {
35 36
 	public Expression transform(ExpressionTransformer transformer) {
36 37
 		return new PanicExpression(position, type, transformer.transform(value));
37 38
 	}
39
+
40
+	@Override
41
+	public Expression normalize(TypeScope scope) {
42
+		return new PanicExpression(position, type, value.normalize(scope));
43
+	}
38 44
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PostCallExpression.java Wyświetl plik

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.OperatorType;
11 11
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
12
+import org.openzen.zenscript.codemodel.scope.TypeScope;
12 13
 
13 14
 /**
14 15
  * Used for post-increment and post-decrement.
@@ -41,4 +42,9 @@ public class PostCallExpression extends Expression {
41 42
 		Expression tTarget = target.transform(transformer);
42 43
 		return target == tTarget ? this : new PostCallExpression(position, tTarget, member, instancedHeader);
43 44
 	}
45
+
46
+	@Override
47
+	public Expression normalize(TypeScope scope) {
48
+		return new PostCallExpression(position, target.normalize(scope), member, instancedHeader.normalize(scope.getTypeRegistry()));
49
+	}
44 50
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/RangeExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
@@ -42,4 +43,9 @@ public class RangeExpression extends Expression {
42 43
 		Expression tTo = to.transform(transformer);
43 44
 		return tFrom == from && tTo == to ? this : new RangeExpression(position, type, tFrom, tTo, thrownType);
44 45
 	}
46
+
47
+	@Override
48
+	public Expression normalize(TypeScope scope) {
49
+		return new RangeExpression(position, scope.getTypeRegistry(), from.normalize(scope), to.normalize(scope));
50
+	}
45 51
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SameObjectExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
10 11
 
11 12
 /**
@@ -36,4 +37,9 @@ public class SameObjectExpression extends Expression {
36 37
 		Expression tRight = right.transform(transformer);
37 38
 		return tLeft == left && tRight == right ? this : new SameObjectExpression(position, tLeft, tRight, inverted);
38 39
 	}
40
+
41
+	@Override
42
+	public Expression normalize(TypeScope scope) {
43
+		return new SameObjectExpression(position, left.normalize(scope), right.normalize(scope), inverted);
44
+	}
39 45
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFieldExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -38,4 +39,9 @@ public class SetFieldExpression extends Expression {
38 39
 				? this
39 40
 				: new SetFieldExpression(position, tTarget, field, tValue);
40 41
 	}
42
+
43
+	@Override
44
+	public Expression normalize(TypeScope scope) {
45
+		return new SetFieldExpression(position, target, field, value.normalize(scope));
46
+	}
41 47
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetFunctionParameterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionParameter;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -33,4 +34,9 @@ public class SetFunctionParameterExpression extends Expression {
33 34
 		Expression tValue = value.transform(transformer);
34 35
 		return tValue == value ? this : new SetFunctionParameterExpression(position, parameter, tValue);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new SetFunctionParameterExpression(position, parameter, value.normalize(scope));
41
+	}
36 42
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetLocalVariableExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.statement.VarStatement;
10 11
 
11 12
 /**
@@ -33,4 +34,9 @@ public class SetLocalVariableExpression extends Expression {
33 34
 		Expression tValue = value.transform(transformer);
34 35
 		return tValue == value ? this : new SetLocalVariableExpression(position, variable, tValue);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new SetLocalVariableExpression(position, variable, value.normalize(scope));
41
+	}
36 42
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetStaticFieldExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -33,4 +34,9 @@ public class SetStaticFieldExpression extends Expression {
33 34
 		Expression tValue = value.transform(transformer);
34 35
 		return value == tValue ? this : new SetStaticFieldExpression(position, field, tValue);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new SetStaticFieldExpression(position, field, value.normalize(scope));
41
+	}
36 42
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SetterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -36,4 +37,9 @@ public class SetterExpression extends Expression {
36 37
 		Expression tValue = value.transform(transformer);
37 38
 		return tTarget == target && tValue == value ? this : new SetterExpression(position, tTarget, setter, tValue);
38 39
 	}
40
+
41
+	@Override
42
+	public Expression normalize(TypeScope scope) {
43
+		return new SetterExpression(position, target.normalize(scope), setter, value.normalize(scope));
44
+	}
39 45
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticGetterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -30,4 +31,9 @@ public class StaticGetterExpression extends Expression {
30 31
 	public Expression transform(ExpressionTransformer transformer) {
31 32
 		return this;
32 33
 	}
34
+
35
+	@Override
36
+	public Expression normalize(TypeScope scope) {
37
+		return this;
38
+	}
33 39
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/StaticSetterExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.member.ref.SetterMemberRef;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 
11 12
 /**
12 13
  *
@@ -33,4 +34,9 @@ public class StaticSetterExpression extends Expression {
33 34
 		Expression tValue = value.transform(transformer);
34 35
 		return tValue == value ? this : new StaticSetterExpression(position, setter, tValue);
35 36
 	}
37
+
38
+	@Override
39
+	public Expression normalize(TypeScope scope) {
40
+		return new StaticSetterExpression(position, setter, value.normalize(scope));
41
+	}
36 42
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/SupertypeCastExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -32,4 +33,9 @@ public class SupertypeCastExpression extends Expression {
32 33
 		Expression tValue = value.transform(transformer);
33 34
 		return tValue == value ? this : new SupertypeCastExpression(position, tValue, type);
34 35
 	}
36
+
37
+	@Override
38
+	public Expression normalize(TypeScope scope) {
39
+		return new SupertypeCastExpression(position, value.normalize(scope), type.getNormalized());
40
+	}
35 41
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThisExpression.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
10
+import org.openzen.zenscript.codemodel.scope.TypeScope;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
12 13
 /**
@@ -34,4 +35,9 @@ public class ThisExpression extends Expression {
34 35
 	public Expression transform(ExpressionTransformer transformer) {
35 36
 		return this;
36 37
 	}
38
+
39
+	@Override
40
+	public Expression normalize(TypeScope scope) {
41
+		return this;
42
+	}
37 43
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -36,4 +37,9 @@ public class ThrowExpression extends Expression {
36 37
 		Expression tValue = transformer.transform(value);
37 38
 		return tValue == value ? this : new ThrowExpression(position, type, value);
38 39
 	}
40
+
41
+	@Override
42
+	public Expression normalize(TypeScope scope) {
43
+		return new ThrowExpression(position, type, value.normalize(scope));
44
+	}
39 45
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryConvertExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class TryConvertExpression extends Expression {
31 32
 		Expression tValue = value.transform(transformer);
32 33
 		return tValue == value ? this : new TryConvertExpression(position, type, tValue);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new TryConvertExpression(position, type, value.normalize(scope));
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsExceptionExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class TryRethrowAsExceptionExpression extends Expression {
31 32
 		Expression tValue = value.transform(transformer);
32 33
 		return tValue == value ? this : new TryRethrowAsExceptionExpression(position, type, tValue, thrownType);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new TryRethrowAsExceptionExpression(position, type, value.normalize(scope), thrownType.getNormalized());
39
+	}
34 40
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/TryRethrowAsResultExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -31,4 +32,9 @@ public class TryRethrowAsResultExpression extends Expression {
31 32
 		Expression tValue = value.transform(transformer);
32 33
 		return tValue == value ? this : new TryRethrowAsResultExpression(position, type, tValue);
33 34
 	}
35
+
36
+	@Override
37
+	public Expression normalize(TypeScope scope) {
38
+		return new TryRethrowAsResultExpression(position, type, value.normalize(scope));
39
+	}
34 40
 }

+ 8
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/VariantValueExpression.java Wyświetl plik

@@ -52,4 +52,12 @@ public class VariantValueExpression extends Expression {
52 52
 		Expression[] tArguments = Expression.transform(arguments, transformer);
53 53
 		return tArguments == arguments ? this : new VariantValueExpression(position, type, option, tArguments);
54 54
 	}
55
+
56
+	@Override
57
+	public Expression normalize(TypeScope scope) {
58
+		Expression[] normalized = new Expression[arguments.length];
59
+		for (int i = 0; i < normalized.length; i++)
60
+			normalized[i] = arguments[i].normalize(scope);
61
+		return new VariantValueExpression(position, type, option, normalized);
62
+	}
55 63
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/WrapOptionalExpression.java Wyświetl plik

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.scope.TypeScope;
9 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10 11
 
11 12
 /**
@@ -34,4 +35,9 @@ public class WrapOptionalExpression extends Expression {
34 35
 		Expression tValue = value.transform(transformer);
35 36
 		return tValue == value ? this : new WrapOptionalExpression(position, tValue, type);
36 37
 	}
38
+
39
+	@Override
40
+	public Expression normalize(TypeScope scope) {
41
+		return new WrapOptionalExpression(position, value.normalize(scope), type);
42
+	}
37 43
 }

+ 1
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java Wyświetl plik

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13 13
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
14 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16 17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;

+ 8
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java Wyświetl plik

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.Modifiers;
13 13
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
14 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -22,7 +23,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
22 23
  * @author Hoofdgebruiker
23 24
  */
24 25
 public class CasterMember extends FunctionalMember {
25
-	public final ITypeID toType;
26
+	public ITypeID toType;
26 27
 	public CasterMemberRef overrides;
27 28
 	
28 29
 	public CasterMember(
@@ -78,4 +79,10 @@ public class CasterMember extends FunctionalMember {
78 79
 	public CasterMemberRef getOverrides() {
79 80
 		return overrides;
80 81
 	}
82
+	
83
+	@Override
84
+	public void normalize(TypeScope scope) {
85
+		super.normalize(scope);
86
+		toType = toType.getNormalized();
87
+	}
81 88
 }

+ 8
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java Wyświetl plik

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12 12
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
13 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
14 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
15 16
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
16 17
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -46,7 +47,7 @@ public class ConstMember extends DefinitionMember {
46 47
 
47 48
 	@Override
48 49
 	public void registerTo(TypeMembers members, TypeMemberPriority priority, GenericMapper mapper) {
49
-		members.addConst(new ConstMemberRef(this, mapper.map(type)));
50
+		members.addConst(new ConstMemberRef(this, type, mapper));
50 51
 	}
51 52
 
52 53
 	@Override
@@ -58,4 +59,10 @@ public class ConstMember extends DefinitionMember {
58 59
 	public DefinitionMemberRef getOverrides() {
59 60
 		return null;
60 61
 	}
62
+
63
+	@Override
64
+	public void normalize(TypeScope scope) {
65
+		type = type.getNormalized();
66
+		value = value.normalize(scope);
67
+	}
61 68
 }

+ 19
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java Wyświetl plik

@@ -6,12 +6,14 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 12
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13 14
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
14 15
 import org.openzen.zenscript.codemodel.statement.Statement;
16
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
17 19
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -21,13 +23,13 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
21 23
  *
22 24
  * @author Hoofdgebruiker
23 25
  */
24
-public class CustomIteratorMember extends DefinitionMember implements IIteratorMember {
26
+public class CustomIteratorMember extends FunctionalMember implements IIteratorMember {
25 27
 	private final ITypeID[] iteratorTypes;
26 28
 	public Statement body;
27 29
 	public IteratorMemberRef overrides;
28 30
 	
29
-	public CustomIteratorMember(CodePosition position, HighLevelDefinition definition, int modifiers, ITypeID[] iteratorTypes) {
30
-		super(position, definition, modifiers);
31
+	public CustomIteratorMember(CodePosition position, HighLevelDefinition definition, int modifiers, ITypeID[] iteratorTypes, GlobalTypeRegistry registry, BuiltinID builtin) {
32
+		super(position, definition, modifiers, createIteratorHeader(registry, iteratorTypes), builtin);
31 33
 		
32 34
 		this.iteratorTypes = iteratorTypes;
33 35
 	}
@@ -35,6 +37,11 @@ public class CustomIteratorMember extends DefinitionMember implements IIteratorM
35 37
 	public void setContent(Statement body) {
36 38
 		this.body = body;
37 39
 	}
40
+	
41
+	@Override
42
+	public String getCanonicalName() {
43
+		return definition.getFullName() + ":iterator:" + iteratorTypes.length;
44
+	}
38 45
 
39 46
 	@Override
40 47
 	public int getLoopVariableCount() {
@@ -79,4 +86,13 @@ public class CustomIteratorMember extends DefinitionMember implements IIteratorM
79 86
 	public DefinitionMemberRef getOverrides() {
80 87
 		return overrides;
81 88
 	}
89
+	
90
+	@Override
91
+	public FunctionalKind getKind() {
92
+		return FunctionalKind.ITERATOR;
93
+	}
94
+	
95
+	private static FunctionHeader createIteratorHeader(GlobalTypeRegistry registry, ITypeID[] iteratorTypes) {
96
+		return new FunctionHeader(registry.getIterator(iteratorTypes));
97
+	}
82 98
 }

+ 13
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java Wyświetl plik

@@ -15,6 +15,7 @@ import org.openzen.zenscript.codemodel.expression.SetFieldExpression;
15 15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
16 16
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
17 17
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
18
+import org.openzen.zenscript.codemodel.scope.TypeScope;
18 19
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
19 20
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
20 21
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
@@ -44,6 +45,7 @@ public class FieldMember extends DefinitionMember {
44 45
 			HighLevelDefinition definition,
45 46
 			int modifiers,
46 47
 			String name,
48
+			ITypeID thisType,
47 49
 			ITypeID type,
48 50
 			GlobalTypeRegistry registry,
49 51
 			int autoGetterAccess,
@@ -62,23 +64,21 @@ public class FieldMember extends DefinitionMember {
62 64
 		if (definition.genericParameters != null) {
63 65
 			parameters = new ITypeID[definition.genericParameters.length];
64 66
 			for (int i = 0; i < parameters.length; i++)
65
-				parameters[i] = new GenericTypeID(definition.genericParameters[i]);
67
+				parameters[i] = registry.getGeneric(definition.genericParameters[i]);
66 68
 		}
67 69
 		
68 70
 		if (autoGetterAccess != 0) {
69
-			ITypeID myType = registry.getForDefinition(definition, parameters);
70 71
 			this.autoGetter = new GetterMember(position, definition, autoGetterAccess, name, type, null);
71
-			this.autoGetter.setBody(new ReturnStatement(position, new GetFieldExpression(position, new ThisExpression(position, myType), new FieldMemberRef(this, myType))));
72
+			this.autoGetter.setBody(new ReturnStatement(position, new GetFieldExpression(position, new ThisExpression(position, thisType), new FieldMemberRef(this, thisType))));
72 73
 		} else {
73 74
 			this.autoGetter = null;
74 75
 		}
75 76
 		if (autoSetterAccess != 0) {
76
-			ITypeID myType = registry.getForDefinition(definition, parameters);
77 77
 			this.autoSetter = new SetterMember(position, definition, autoSetterAccess, name, type, null);
78 78
 			this.autoSetter.setBody(new ExpressionStatement(position, new SetFieldExpression(
79 79
 					position,
80
-					new ThisExpression(position, myType),
81
-					new FieldMemberRef(this, myType),
80
+					new ThisExpression(position, thisType),
81
+					new FieldMemberRef(this, thisType),
82 82
 					new GetFunctionParameterExpression(position, this.autoSetter.header.parameters[0]))));
83 83
 		} else {
84 84
 			this.autoSetter = null;
@@ -144,4 +144,11 @@ public class FieldMember extends DefinitionMember {
144 144
 	public DefinitionMemberRef getOverrides() {
145 145
 		return null;
146 146
 	}
147
+
148
+	@Override
149
+	public void normalize(TypeScope scope) {
150
+		type = type.getNormalized();
151
+		if (initializer != null)
152
+			initializer = initializer.normalize(scope);
153
+	}
147 154
 }

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalKind.java Wyświetl plik

@@ -17,5 +17,6 @@ public enum FunctionalKind {
17 17
 	GETTER,
18 18
 	SETTER,
19 19
 	CALLER,
20
-	CASTER
20
+	CASTER,
21
+	ITERATOR
21 22
 }

+ 10
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java Wyświetl plik

@@ -6,10 +6,13 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.ConcatMap;
9 10
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
15
+import org.openzen.zenscript.codemodel.statement.LoopStatement;
13 16
 import org.openzen.zenscript.codemodel.statement.Statement;
14 17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 18
 
@@ -50,4 +53,11 @@ public abstract class FunctionalMember extends DefinitionMember {
50 53
 	public BuiltinID getBuiltin() {
51 54
 		return builtin;
52 55
 	}
56
+
57
+	@Override
58
+	public void normalize(TypeScope scope) {
59
+		header = header.normalize(scope.getTypeRegistry());
60
+		if (body != null)
61
+			body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
62
+	}
53 63
 }

+ 3
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java Wyświetl plik

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12
+import org.openzen.zenscript.codemodel.scope.TypeScope;
12 13
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13 14
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -35,4 +36,6 @@ public interface IDefinitionMember {
35 36
 	<T> boolean hasTag(Class<T> tag);
36 37
 	
37 38
 	DefinitionMemberRef getOverrides();
39
+
40
+	public void normalize(TypeScope scope);
38 41
 }

+ 7
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java Wyświetl plik

@@ -12,6 +12,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
12 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 14
 import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
15
+import org.openzen.zenscript.codemodel.scope.TypeScope;
15 16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 18
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -63,4 +64,10 @@ public class ImplementationMember extends DefinitionMember {
63 64
 	public DefinitionMemberRef getOverrides() {
64 65
 		return null;
65 66
 	}
67
+
68
+	@Override
69
+	public void normalize(TypeScope scope) {
70
+		for (IDefinitionMember member : members)
71
+			member.normalize(scope);
72
+	}
66 73
 }

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinition.java Wyświetl plik

@@ -31,7 +31,7 @@ public class InnerDefinition {
31 31
 		this.outerTypeArguments = outerTypeArguments;
32 32
 	}
33 33
 	
34
-	public DefinitionTypeID instance(GlobalTypeRegistry registry, ITypeID[] typeArguments) {
35
-		return registry.getForDefinition(definition, typeArguments, outerTypeArguments);
34
+	public DefinitionTypeID instance(GlobalTypeRegistry registry, ITypeID[] typeArguments, DefinitionTypeID outer) {
35
+		return registry.getForDefinition(definition, typeArguments, outer);
36 36
 	}
37 37
 }

+ 9
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java Wyświetl plik

@@ -8,7 +8,10 @@ package org.openzen.zenscript.codemodel.member;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
+import org.openzen.zenscript.codemodel.Modifiers;
12
+import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
11 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
12 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -21,7 +24,7 @@ public class InnerDefinitionMember extends DefinitionMember {
21 24
 	public final HighLevelDefinition innerDefinition;
22 25
 	
23 26
 	public InnerDefinitionMember(CodePosition position, HighLevelDefinition outer, int modifiers, HighLevelDefinition definition) {
24
-		super(position, outer, modifiers);
27
+		super(position, outer, definition instanceof InterfaceDefinition ? modifiers | Modifiers.STATIC : modifiers);
25 28
 		
26 29
 		this.innerDefinition = definition;
27 30
 	}
@@ -54,4 +57,9 @@ public class InnerDefinitionMember extends DefinitionMember {
54 57
 	public DefinitionMemberRef getOverrides() {
55 58
 		return null;
56 59
 	}
60
+
61
+	@Override
62
+	public void normalize(TypeScope scope) {
63
+		innerDefinition.normalize(scope);
64
+	}
57 65
 }

+ 8
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java Wyświetl plik

@@ -6,10 +6,13 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zencode.shared.ConcatMap;
9 10
 import org.openzen.zencode.shared.Taggable;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
12 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14
+import org.openzen.zenscript.codemodel.scope.TypeScope;
15
+import org.openzen.zenscript.codemodel.statement.LoopStatement;
13 16
 import org.openzen.zenscript.codemodel.statement.Statement;
14 17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 18
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -57,4 +60,9 @@ public class StaticInitializerMember extends Taggable implements IDefinitionMemb
57 60
 	public DefinitionMemberRef getOverrides() {
58 61
 		return null;
59 62
 	}
63
+
64
+	@Override
65
+	public void normalize(TypeScope scope) {
66
+		body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
67
+	}
60 68
 }

+ 7
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java Wyświetl plik

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
16
+import org.openzen.zenscript.codemodel.scope.TypeScope;
16 17
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
17 18
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
18 19
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -25,7 +26,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
25 26
  * @author Hoofdgebruiker
26 27
  */
27 28
 public class ArrayIteratorKeyValues extends Taggable implements IIteratorMember {
28
-	private final ArrayTypeID type;
29
+	private ArrayTypeID type;
29 30
 	private final ITypeID[] loopVariableTypes;
30 31
 	
31 32
 	public ArrayIteratorKeyValues(ArrayTypeID type) {
@@ -81,4 +82,9 @@ public class ArrayIteratorKeyValues extends Taggable implements IIteratorMember
81 82
 	public DefinitionMemberRef getOverrides() {
82 83
 		return null;
83 84
 	}
85
+
86
+	@Override
87
+	public void normalize(TypeScope scope) {
88
+		
89
+	}
84 90
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java Wyświetl plik

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
16
+import org.openzen.zenscript.codemodel.scope.TypeScope;
16 17
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
17 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
18 19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -76,4 +77,9 @@ public class ArrayIteratorValues extends Taggable implements IIteratorMember {
76 77
 	public DefinitionMemberRef getOverrides() {
77 78
 		return null;
78 79
 	}
80
+
81
+	@Override
82
+	public void normalize(TypeScope scope) {
83
+		
84
+	}
79 85
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java Wyświetl plik

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
16
+import org.openzen.zenscript.codemodel.scope.TypeScope;
16 17
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
17 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
18 19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -79,4 +80,9 @@ public class AssocIterator extends Taggable implements IIteratorMember {
79 80
 	public DefinitionMemberRef getOverrides() {
80 81
 		return null;
81 82
 	}
83
+
84
+	@Override
85
+	public void normalize(TypeScope scope) {
86
+		
87
+	}
82 88
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java Wyświetl plik

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
16
+import org.openzen.zenscript.codemodel.scope.TypeScope;
16 17
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
17 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
18 19
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
@@ -87,4 +88,9 @@ public class RangeIterator extends Taggable implements IIteratorMember {
87 88
 	public DefinitionMemberRef getOverrides() {
88 89
 		return null;
89 90
 	}
91
+
92
+	@Override
93
+	public void normalize(TypeScope scope) {
94
+		
95
+	}
90 96
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java Wyświetl plik

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
16
+import org.openzen.zenscript.codemodel.scope.TypeScope;
16 17
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
17 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
18 19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -70,4 +71,9 @@ public class StringCharIterator extends Taggable implements IIteratorMember {
70 71
 	public DefinitionMemberRef getOverrides() {
71 72
 		return null;
72 73
 	}
74
+
75
+	@Override
76
+	public void normalize(TypeScope scope) {
77
+		
78
+	}
73 79
 }

+ 16
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java Wyświetl plik

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11 12
 import org.openzen.zenscript.codemodel.member.ConstMember;
12 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -17,11 +18,23 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
17 18
  */
18 19
 public class ConstMemberRef implements DefinitionMemberRef {
19 20
 	public final ConstMember member;
20
-	public final ITypeID type;
21
+	private ITypeID type;
22
+	private ITypeID originalType;
23
+	private final GenericMapper mapper;
21 24
 	
22
-	public ConstMemberRef(ConstMember member, ITypeID type) {
25
+	public ConstMemberRef(ConstMember member, ITypeID originalType, GenericMapper mapper) {
23 26
 		this.member = member;
24
-		this.type = type;
27
+		this.type = originalType.instance(mapper);
28
+		this.originalType = originalType;
29
+		this.mapper = mapper;
30
+	}
31
+	
32
+	public ITypeID getType() {
33
+		if (originalType != member.type) {
34
+			originalType = member.type;
35
+			type = originalType.instance(mapper);
36
+		}
37
+		return type;
25 38
 	}
26 39
 
27 40
 	@Override

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java Wyświetl plik

@@ -104,7 +104,7 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
104 104
 	}
105 105
 	
106 106
 	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
107
-		return new CallExpression(position, target, this, instancedHeader, arguments, scope);
107
+		return new CallExpression(position, target, this, instancedHeader, arguments);
108 108
 	}
109 109
 	
110 110
 	public final Expression call(CodePosition position, Expression target, CallArguments arguments, TypeScope scope) {
@@ -116,6 +116,6 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
116 116
 	}
117 117
 	
118 118
 	public Expression callStatic(CodePosition position, ITypeID target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
119
-		return new CallStaticExpression(position, target, this, instancedHeader, arguments, scope);
119
+		return new CallStaticExpression(position, target, this, instancedHeader, arguments);
120 120
 	}
121 121
 }

+ 0
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java Wyświetl plik

@@ -15,7 +15,6 @@ import org.openzen.zenscript.codemodel.statement.LoopStatement;
15 15
 import org.openzen.zenscript.codemodel.type.GenericName;
16 16
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
17 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
18
-import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
19 18
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
20 19
 
21 20
 /**

+ 0
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java Wyświetl plik


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików

Ładowanie…
Anuluj
Zapisz