Browse Source

- Minor code cleanup.

- WIP on map files (used to link zencode to already compiled classes, and to define native methods)
Stan Hebben 6 years ago
parent
commit
6eca301d7c
74 changed files with 776 additions and 863 deletions
  1. 6
    41
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  2. 6
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  3. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/ModuleProcessor.java
  4. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/OperatorType.java
  5. 14
    14
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationDefinition.java
  6. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/DefinitionAnnotation.java
  7. 12
    12
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidAnnotationDefinition.java
  8. 3
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidMemberAnnotation.java
  9. 7
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/MemberAnnotation.java
  10. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/ParameterAnnotation.java
  11. 8
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionForMethod.java
  12. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/StatementAnnotation.java
  13. 8
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/DefinitionVisitor.java
  14. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/EnumConstantExpression.java
  15. 8
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  16. 0
    72
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionBuilder.java
  17. 0
    18
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionContext.java
  18. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionSymbol.java
  19. 70
    70
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java
  20. 71
    71
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitorWithContext.java
  21. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/FunctionExpression.java
  22. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/GetterExpression.java
  23. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/NewExpression.java
  24. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/switchvalue/SwitchValue.java
  25. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/switchvalue/SwitchValueVisitor.java
  26. 5
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/switchvalue/SwitchValueVisitorWithContext.java
  27. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/GenericParameterBoundVisitor.java
  28. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/GenericParameterBoundVisitorWithContext.java
  29. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java
  30. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  31. 2
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java
  32. 8
    8
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameterBound.java
  33. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java
  34. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  35. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  36. 13
    13
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  37. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  38. 14
    14
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MemberVisitor.java
  39. 14
    14
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MemberVisitorWithContext.java
  40. 0
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  41. 16
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialTypeExpression.java
  42. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/processor/InterfaceProcessor.java
  43. 1
    17
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/DefinitionScope.java
  44. 1
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/ExpressionScope.java
  45. 0
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java
  46. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java
  47. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LambdaScope.java
  48. 15
    15
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/StatementVisitor.java
  49. 15
    15
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/StatementVisitorWithContext.java
  50. 1
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/AssocTypeID.java
  51. 0
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/DefinitionTypeID.java
  52. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ISymbol.java
  53. 1
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java
  54. 1
    158
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StoredType.java
  55. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeID.java
  56. 0
    92
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java
  57. 12
    12
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java
  58. 3
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMember.java
  59. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  60. 3
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberGroup.java
  61. 9
    16
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  62. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java
  63. 16
    0
      Constructor/src/main/java/org/openzen/zenscript/constructor/ConstructorRegistry.java
  64. 0
    15
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaBaseCompiler.java
  65. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompileSpace.java
  66. 22
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java
  67. 12
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaField.java
  68. 306
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaMappingWriter.java
  69. 14
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaMethod.java
  70. 2
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaNativeTranslation.java
  71. 8
    8
      Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java
  72. 2
    3
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/BaseParsedDefinition.java
  73. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java
  74. 3
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunctionParameter.java

+ 6
- 41
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
18
 import org.openzen.zenscript.codemodel.scope.TypeScope;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
19
 import org.openzen.zenscript.codemodel.type.StoredType;
20
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
20
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
21
+import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
21
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
22
 import org.openzen.zenscript.codemodel.type.storage.StorageTag;
22
 
23
 
23
 /**
24
 /**
207
 		return true;
208
 		return true;
208
 	}
209
 	}
209
 	
210
 	
210
-	public String getCanonical() {
211
+	public String getCanonicalWithoutReturnType() {
211
 		StringBuilder result = new StringBuilder();
212
 		StringBuilder result = new StringBuilder();
212
 		if (getNumberOfTypeParameters() > 0) {
213
 		if (getNumberOfTypeParameters() > 0) {
213
 			result.append('<');
214
 			result.append('<');
218
 			}
219
 			}
219
 			result.append('>');
220
 			result.append('>');
220
 		}
221
 		}
221
-		if (storage != null)
222
-			result.append(storage);
222
+		if (storage != null && storage != AutoStorageTag.INSTANCE)
223
+			result.append('`').append(storage);
223
 		result.append('(');
224
 		result.append('(');
224
 		for (int i = 0; i < parameters.length; i++) {
225
 		for (int i = 0; i < parameters.length; i++) {
225
 			if (i > 0)
226
 			if (i > 0)
230
 		return result.toString();
231
 		return result.toString();
231
 	}
232
 	}
232
 	
233
 	
233
-	public StoredType[] inferTypes(LocalMemberCache cache, CallArguments arguments, List<StoredType> resultHint) {
234
-		if (arguments.arguments.length != this.parameters.length)
235
-			return null;
236
-		
237
-		Map<TypeParameter, StoredType> mapping = new HashMap<>();
238
-		if (!resultHint.isEmpty()) {
239
-			for (StoredType hint : resultHint) {
240
-				Map<TypeParameter, StoredType> temp = returnType.inferTypeParameters(cache, hint);
241
-				if (temp != null) {
242
-					mapping = temp;
243
-					break;
244
-				}
245
-			}
246
-		}
247
-		
248
-		// TODO: lambda header inference
249
-		for (int i = 0; i < parameters.length; i++) {
250
-			Map<TypeParameter, StoredType> forParameter = parameters[i].type.inferTypeParameters(cache, arguments.arguments[i].type);
251
-			if (forParameter == null)
252
-				return null;
253
-			
254
-			mapping.putAll(forParameter);
255
-		}
256
-		
257
-		if (mapping.size() > typeParameters.length)
258
-			return null;
259
-		
260
-		StoredType[] result = new StoredType[typeParameters.length];
261
-		for (int i = 0; i < typeParameters.length; i++) {
262
-			TypeParameter typeParameter = typeParameters[i];
263
-			if (!mapping.containsKey(typeParameter)) {
264
-				return null;
265
-			} else {
266
-				result[i] = mapping.get(typeParameter);
267
-			}
268
-		}
269
-		
270
-		return result;
234
+	public String getCanonical() {
235
+		return getCanonicalWithoutReturnType() + returnType.type.toString();
271
 	}
236
 	}
272
 	
237
 	
273
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
238
 	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {

+ 6
- 9
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java View File

64
 			pkg.register(this);
64
 			pkg.register(this);
65
 	}
65
 	}
66
 	
66
 	
67
-	public HighLevelDefinition getOutermost() {
68
-		HighLevelDefinition result = this;
69
-		while (result.outerDefinition != null)
70
-			result = result.outerDefinition;
71
-		return result;
72
-	}
73
-	
74
 	public String getFullName() {
67
 	public String getFullName() {
75
 		return pkg.fullName + '.' + name;
68
 		return pkg.fullName + '.' + name;
76
 	}
69
 	}
102
 	public void setOuterDefinition(HighLevelDefinition outerDefinition) {
95
 	public void setOuterDefinition(HighLevelDefinition outerDefinition) {
103
 		this.outerDefinition = outerDefinition;
96
 		this.outerDefinition = outerDefinition;
104
 	}
97
 	}
105
-	
98
+
99
+	public boolean isExpansion() {
100
+		return this instanceof ExpansionDefinition;
101
+	}
102
+
106
 	public boolean isInnerDefinition() {
103
 	public boolean isInnerDefinition() {
107
 		return outerDefinition != null;
104
 		return outerDefinition != null;
108
 	}
105
 	}
187
 	
184
 	
188
 	public void normalize(TypeScope scope) {
185
 	public void normalize(TypeScope scope) {
189
 		DestructorMember destructor = null;
186
 		DestructorMember destructor = null;
190
-		List<FieldMember> fields = new ArrayList();
187
+		List<FieldMember> fields = new ArrayList<>();
191
 		
188
 		
192
 		for (IDefinitionMember member : members) {
189
 		for (IDefinitionMember member : members) {
193
 			member.normalize(scope);
190
 			member.normalize(scope);

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface ModuleProcessor {
12
 public interface ModuleProcessor {
13
-	public ScriptBlock process(ScriptBlock block);
13
+	ScriptBlock process(ScriptBlock block);
14
 	
14
 	
15
-	public void process(HighLevelDefinition definition);
15
+	void process(HighLevelDefinition definition);
16
 }
16
 }

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

59
 	public final String operator;
59
 	public final String operator;
60
 	public final String compiledName;
60
 	public final String compiledName;
61
 	
61
 	
62
-	private OperatorType(String operator, String compiledName) {
62
+	OperatorType(String operator, String compiledName) {
63
 		this.operator = operator;
63
 		this.operator = operator;
64
 		this.compiledName = compiledName;
64
 		this.compiledName = compiledName;
65
 		assignOperatorFor = null;
65
 		assignOperatorFor = null;
66
 	}
66
 	}
67
 	
67
 	
68
-	private OperatorType(String operator, String compiledName, OperatorType assignOperatorFor) {
68
+	OperatorType(String operator, String compiledName, OperatorType assignOperatorFor) {
69
 		this.operator = operator;
69
 		this.operator = operator;
70
 		this.compiledName = compiledName;
70
 		this.compiledName = compiledName;
71
 		this.assignOperatorFor = assignOperatorFor;
71
 		this.assignOperatorFor = assignOperatorFor;

+ 14
- 14
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationDefinition.java View File

25
  * @author Hoofdgebruiker
25
  * @author Hoofdgebruiker
26
  */
26
  */
27
 public interface AnnotationDefinition {
27
 public interface AnnotationDefinition {
28
-	public String getAnnotationName();
28
+	String getAnnotationName();
29
 	
29
 	
30
-	public List<FunctionHeader> getInitializers(BaseScope scope);
30
+	List<FunctionHeader> getInitializers(BaseScope scope);
31
 	
31
 	
32
-	public ExpressionScope getScopeForMember(IDefinitionMember member, BaseScope scope);
32
+	ExpressionScope getScopeForMember(IDefinitionMember member, BaseScope scope);
33
 	
33
 	
34
-	public ExpressionScope getScopeForType(HighLevelDefinition definition, BaseScope scope);
34
+	ExpressionScope getScopeForType(HighLevelDefinition definition, BaseScope scope);
35
 	
35
 	
36
-	public ExpressionScope getScopeForStatement(Statement statement, StatementScope scope);
36
+	ExpressionScope getScopeForStatement(Statement statement, StatementScope scope);
37
 	
37
 	
38
-	public ExpressionScope getScopeForParameter(FunctionHeader header, FunctionParameter parameter, BaseScope scope);
38
+	ExpressionScope getScopeForParameter(FunctionHeader header, FunctionParameter parameter, BaseScope scope);
39
 	
39
 	
40
-	public MemberAnnotation createForMember(CodePosition position, CallArguments arguments);
40
+	MemberAnnotation createForMember(CodePosition position, CallArguments arguments);
41
 	
41
 	
42
-	public DefinitionAnnotation createForDefinition(CodePosition position, CallArguments arguments);
42
+	DefinitionAnnotation createForDefinition(CodePosition position, CallArguments arguments);
43
 	
43
 	
44
-	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments);
44
+	StatementAnnotation createForStatement(CodePosition position, CallArguments arguments);
45
 	
45
 	
46
-	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments);
46
+	ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments);
47
 	
47
 	
48
-	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member);
48
+	MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member);
49
 	
49
 	
50
-	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context);
50
+	DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context);
51
 	
51
 	
52
-	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context);
52
+	StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context);
53
 	
53
 	
54
-	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context);
54
+	ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context);
55
 }
55
 }

+ 5
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/DefinitionAnnotation.java View File

15
  * @author Hoofdgebruiker
15
  * @author Hoofdgebruiker
16
  */
16
  */
17
 public interface DefinitionAnnotation {
17
 public interface DefinitionAnnotation {
18
-	public static final DefinitionAnnotation[] NONE = new DefinitionAnnotation[0];
18
+	DefinitionAnnotation[] NONE = new DefinitionAnnotation[0];
19
 	
19
 	
20
-	public AnnotationDefinition getDefinition();
20
+	AnnotationDefinition getDefinition();
21
 	
21
 	
22
-	public void apply(HighLevelDefinition definition, BaseScope scope);
22
+	void apply(HighLevelDefinition definition, BaseScope scope);
23
 	
23
 	
24
-	public void applyOnSubtype(HighLevelDefinition definition, BaseScope scope);
24
+	void applyOnSubtype(HighLevelDefinition definition, BaseScope scope);
25
 	
25
 	
26
-	public void serialize(CodeSerializationOutput output, HighLevelDefinition definition, TypeContext context);
26
+	void serialize(CodeSerializationOutput output, HighLevelDefinition definition, TypeContext context);
27
 }
27
 }

+ 12
- 12
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidAnnotationDefinition.java View File

42
 
42
 
43
 	@Override
43
 	@Override
44
 	public ExpressionScope getScopeForMember(IDefinitionMember member, BaseScope scope) {
44
 	public ExpressionScope getScopeForMember(IDefinitionMember member, BaseScope scope) {
45
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
45
+		throw new UnsupportedOperationException("Not a valid annotation");
46
 	}
46
 	}
47
 
47
 
48
 	@Override
48
 	@Override
49
 	public ExpressionScope getScopeForType(HighLevelDefinition definition, BaseScope scope) {
49
 	public ExpressionScope getScopeForType(HighLevelDefinition definition, BaseScope scope) {
50
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
50
+		throw new UnsupportedOperationException("Not a valid annotation");
51
 	}
51
 	}
52
 
52
 
53
 	@Override
53
 	@Override
54
 	public ExpressionScope getScopeForStatement(Statement statement, StatementScope scope) {
54
 	public ExpressionScope getScopeForStatement(Statement statement, StatementScope scope) {
55
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
55
+		throw new UnsupportedOperationException("Not a valid annotation");
56
 	}
56
 	}
57
 
57
 
58
 	@Override
58
 	@Override
59
 	public ExpressionScope getScopeForParameter(FunctionHeader header, FunctionParameter parameter, BaseScope scope) {
59
 	public ExpressionScope getScopeForParameter(FunctionHeader header, FunctionParameter parameter, BaseScope scope) {
60
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
60
+		throw new UnsupportedOperationException("Not a valid annotation");
61
 	}
61
 	}
62
 
62
 
63
 	@Override
63
 	@Override
64
 	public MemberAnnotation createForMember(CodePosition position, CallArguments arguments) {
64
 	public MemberAnnotation createForMember(CodePosition position, CallArguments arguments) {
65
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
65
+		throw new UnsupportedOperationException("Not a valid annotation");
66
 	}
66
 	}
67
 
67
 
68
 	@Override
68
 	@Override
69
 	public DefinitionAnnotation createForDefinition(CodePosition position, CallArguments arguments) {
69
 	public DefinitionAnnotation createForDefinition(CodePosition position, CallArguments arguments) {
70
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
70
+		throw new UnsupportedOperationException("Not a valid annotation");
71
 	}
71
 	}
72
 
72
 
73
 	@Override
73
 	@Override
74
 	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments) {
74
 	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments) {
75
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
75
+		throw new UnsupportedOperationException("Not a valid annotation");
76
 	}
76
 	}
77
 
77
 
78
 	@Override
78
 	@Override
79
 	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments) {
79
 	public ParameterAnnotation createForParameter(CodePosition position, CallArguments arguments) {
80
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
80
+		throw new UnsupportedOperationException("Not a valid annotation");
81
 	}
81
 	}
82
 
82
 
83
 	@Override
83
 	@Override
84
 	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member) {
84
 	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member) {
85
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
85
+		throw new UnsupportedOperationException("Not a valid annotation");
86
 	}
86
 	}
87
 
87
 
88
 	@Override
88
 	@Override
89
 	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context) {
89
 	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context) {
90
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
90
+		throw new UnsupportedOperationException("Not a valid annotation");
91
 	}
91
 	}
92
 
92
 
93
 	@Override
93
 	@Override
94
 	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context) {
94
 	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context) {
95
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
95
+		throw new UnsupportedOperationException("Not a valid annotation");
96
 	}
96
 	}
97
 
97
 
98
 	@Override
98
 	@Override
99
 	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
99
 	public ParameterAnnotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
100
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
100
+		throw new UnsupportedOperationException("Not a valid annotation");
101
 	}
101
 	}
102
 }
102
 }

+ 3
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/InvalidMemberAnnotation.java View File

26
 	public final CompileExceptionCode code;
26
 	public final CompileExceptionCode code;
27
 	public final String message;
27
 	public final String message;
28
 	
28
 	
29
-	public InvalidMemberAnnotation(CodePosition position, CompileExceptionCode code, String message) {
30
-		this.position = position;
31
-		this.code = code;
32
-		this.message = message;
33
-	}
34
-	
35
 	public InvalidMemberAnnotation(CompileException ex) {
29
 	public InvalidMemberAnnotation(CompileException ex) {
36
 		this.position = ex.position;
30
 		this.position = ex.position;
37
 		this.code = ex.code;
31
 		this.code = ex.code;
65
 
59
 
66
 	@Override
60
 	@Override
67
 	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context) {
61
 	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context) {
68
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
62
+		output.serialize(position);
63
+		output.writeUInt(code.ordinal());
64
+		output.writeString(message);
69
 	}
65
 	}
70
 }
66
 }

+ 7
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/MemberAnnotation.java View File

18
  * @author Hoofdgebruiker
18
  * @author Hoofdgebruiker
19
  */
19
  */
20
 public interface MemberAnnotation {
20
 public interface MemberAnnotation {
21
-	public static final MemberAnnotation[] NONE = new MemberAnnotation[0];
21
+	MemberAnnotation[] NONE = new MemberAnnotation[0];
22
 	
22
 	
23
-	public AnnotationDefinition getDefinition();
23
+	AnnotationDefinition getDefinition();
24
 	
24
 	
25
-	public void apply(IDefinitionMember member, BaseScope scope);
25
+	void apply(IDefinitionMember member, BaseScope scope);
26
 	
26
 	
27
-	public void applyOnOverridingMethod(FunctionalMember member, BaseScope scope);
27
+	void applyOnOverridingMethod(FunctionalMember member, BaseScope scope);
28
 	
28
 	
29
-	public void applyOnOverridingGetter(GetterMember member, BaseScope scope);
29
+	void applyOnOverridingGetter(GetterMember member, BaseScope scope);
30
 	
30
 	
31
-	public void applyOnOverridingSetter(SetterMember member, BaseScope scope);
31
+	void applyOnOverridingSetter(SetterMember member, BaseScope scope);
32
 	
32
 	
33
-	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context);
33
+	void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context);
34
 }
34
 }

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/ParameterAnnotation.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface ParameterAnnotation {
12
 public interface ParameterAnnotation {
13
-	public static final ParameterAnnotation[] NONE = new ParameterAnnotation[0];
13
+	ParameterAnnotation[] NONE = new ParameterAnnotation[0];
14
 	
14
 	
15
-	public AnnotationDefinition getDefinition();
15
+	AnnotationDefinition getDefinition();
16
 	
16
 	
17
-	public void apply();
17
+	void apply();
18
 }
18
 }

+ 8
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionForMethod.java View File

10
 import java.util.List;
10
 import java.util.List;
11
 import org.openzen.zencode.shared.CodePosition;
11
 import org.openzen.zencode.shared.CodePosition;
12
 import org.openzen.zencode.shared.CompileException;
12
 import org.openzen.zencode.shared.CompileException;
13
+import org.openzen.zenscript.codemodel.OperatorType;
13
 import org.openzen.zenscript.codemodel.context.StatementContext;
14
 import org.openzen.zenscript.codemodel.context.StatementContext;
14
 import org.openzen.zenscript.codemodel.context.TypeContext;
15
 import org.openzen.zenscript.codemodel.context.TypeContext;
16
+import org.openzen.zenscript.codemodel.expression.CallArguments;
15
 import org.openzen.zenscript.codemodel.expression.Expression;
17
 import org.openzen.zenscript.codemodel.expression.Expression;
16
-import org.openzen.zenscript.codemodel.expression.ExpressionBuilder;
17
 import org.openzen.zenscript.codemodel.expression.PanicExpression;
18
 import org.openzen.zenscript.codemodel.expression.PanicExpression;
18
 import org.openzen.zenscript.codemodel.member.FunctionalMember;
19
 import org.openzen.zenscript.codemodel.member.FunctionalMember;
19
 import org.openzen.zenscript.codemodel.member.GetterMember;
20
 import org.openzen.zenscript.codemodel.member.GetterMember;
20
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
21
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
21
 import org.openzen.zenscript.codemodel.member.SetterMember;
22
 import org.openzen.zenscript.codemodel.member.SetterMember;
22
 import org.openzen.zenscript.codemodel.scope.BaseScope;
23
 import org.openzen.zenscript.codemodel.scope.BaseScope;
23
-import org.openzen.zenscript.codemodel.scope.ExpressionScope;
24
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
24
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
25
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
25
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
26
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
26
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
27
 import org.openzen.zenscript.codemodel.statement.IfStatement;
27
 import org.openzen.zenscript.codemodel.statement.IfStatement;
28
 import org.openzen.zenscript.codemodel.statement.Statement;
28
 import org.openzen.zenscript.codemodel.statement.Statement;
29
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
29
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
30
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
30
 
31
 
31
 /**
32
 /**
32
  *
33
  *
85
 			return body;
86
 			return body;
86
 		
87
 		
87
 		try {
88
 		try {
88
-			ExpressionScope expressionScope = new ExpressionScope(scope, BasicTypeID.BOOL.stored);
89
-			List<Statement> statements = new ArrayList<>();
90
-			ExpressionBuilder expressionBuilder = new ExpressionBuilder(position, expressionScope);
91
-			Expression inverseCondition = expressionBuilder.not(condition);
89
+			TypeMembers members = scope.getTypeMembers(condition.type);
90
+			Expression inverseCondition = members.getGroup(OperatorType.NOT)
91
+					.call(position, scope, condition, CallArguments.EMPTY, false);
92
+
92
 			Statement throwStatement = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID.stored, message));
93
 			Statement throwStatement = new ExpressionStatement(position, new PanicExpression(position, BasicTypeID.VOID.stored, message));
94
+			List<Statement> statements = new ArrayList<>();
93
 			statements.add(new IfStatement(position, inverseCondition, throwStatement, null));
95
 			statements.add(new IfStatement(position, inverseCondition, throwStatement, null));
94
 
96
 
95
 			if (body instanceof BlockStatement) {
97
 			if (body instanceof BlockStatement) {

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/StatementAnnotation.java View File

13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public interface StatementAnnotation {
15
 public interface StatementAnnotation {
16
-	public static final StatementAnnotation[] NONE = new StatementAnnotation[0];
16
+	StatementAnnotation[] NONE = new StatementAnnotation[0];
17
 	
17
 	
18
-	public AnnotationDefinition getDefinition();
18
+	AnnotationDefinition getDefinition();
19
 	
19
 	
20
-	public Statement apply(Statement statement, StatementScope scope);
20
+	Statement apply(Statement statement, StatementScope scope);
21
 }
21
 }

+ 8
- 8
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/DefinitionVisitor.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface DefinitionVisitor<T> {
12
 public interface DefinitionVisitor<T> {
13
-	public T visitClass(ClassDefinition definition);
13
+	T visitClass(ClassDefinition definition);
14
 	
14
 	
15
-	public T visitInterface(InterfaceDefinition definition);
15
+	T visitInterface(InterfaceDefinition definition);
16
 	
16
 	
17
-	public T visitEnum(EnumDefinition definition);
17
+	T visitEnum(EnumDefinition definition);
18
 	
18
 	
19
-	public T visitStruct(StructDefinition definition);
19
+	T visitStruct(StructDefinition definition);
20
 	
20
 	
21
-	public T visitFunction(FunctionDefinition definition);
21
+	T visitFunction(FunctionDefinition definition);
22
 	
22
 	
23
-	public T visitExpansion(ExpansionDefinition definition);
23
+	T visitExpansion(ExpansionDefinition definition);
24
 	
24
 	
25
-	public T visitAlias(AliasDefinition definition);
25
+	T visitAlias(AliasDefinition definition);
26
 	
26
 	
27
-	public T visitVariant(VariantDefinition variant);
27
+	T visitVariant(VariantDefinition variant);
28
 }
28
 }

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

11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13
 import org.openzen.zenscript.codemodel.type.TypeID;
13
 import org.openzen.zenscript.codemodel.type.TypeID;
14
-import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
15
 
14
 
16
 /**
15
 /**
17
  *
16
  *

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

18
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
18
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
19
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
19
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
20
 import org.openzen.zenscript.codemodel.GenericName;
20
 import org.openzen.zenscript.codemodel.GenericName;
21
+import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
21
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
22
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
22
 import org.openzen.zenscript.codemodel.scope.TypeScope;
23
 import org.openzen.zenscript.codemodel.scope.TypeScope;
23
 import org.openzen.zenscript.codemodel.statement.Statement;
24
 import org.openzen.zenscript.codemodel.statement.Statement;
102
 	
103
 	
103
 	@Override
104
 	@Override
104
 	public List<StoredType>[] predictCallTypes(CodePosition position, TypeScope scope, List<StoredType> hints, int arguments) {
105
 	public List<StoredType>[] predictCallTypes(CodePosition position, TypeScope scope, List<StoredType> hints, int arguments) {
105
-		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).predictCallTypes(position, scope, hints, arguments);
106
+		TypeMemberGroup group = scope.getTypeMembers(type).getGroup(OperatorType.CALL);
107
+		return group.predictCallTypes(position, scope, hints, arguments);
106
 	}
108
 	}
107
 	
109
 	
108
 	@Override
110
 	@Override
109
 	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<StoredType> hints, int arguments) {
111
 	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<StoredType> hints, int arguments) {
110
-		return scope.getTypeMembers(type)
111
-				.getOrCreateGroup(OperatorType.CALL)
112
-				.getMethodMembers().stream()
113
-				.filter(method -> method.member.getHeader().parameters.length == arguments && !method.member.isStatic())
112
+		TypeMemberGroup group = scope.getTypeMembers(type).getGroup(OperatorType.CALL);
113
+		return group.getMethodMembers().stream()
114
+				.filter(method -> method.member.getHeader().accepts(arguments) && !method.member.isStatic())
114
 				.map(method -> method.member.getHeader())
115
 				.map(method -> method.member.getHeader())
115
 				.collect(Collectors.toList());
116
 				.collect(Collectors.toList());
116
 	}
117
 	}
117
 	
118
 	
118
 	@Override
119
 	@Override
119
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
120
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
120
-		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).call(position, scope, this, arguments, false);
121
+		TypeMemberGroup group = scope.getTypeMembers(type).getGroup(OperatorType.CALL);
122
+		return group.call(position, scope, this, arguments, false);
121
 	}
123
 	}
122
 	
124
 	
123
 	@Override
125
 	@Override

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

1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.expression;
7
-
8
-import java.util.ArrayList;
9
-import java.util.List;
10
-import org.openzen.zencode.shared.CodePosition;
11
-import org.openzen.zencode.shared.CompileException;
12
-import org.openzen.zencode.shared.CompileExceptionCode;
13
-import org.openzen.zenscript.codemodel.OperatorType;
14
-import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
15
-import org.openzen.zenscript.codemodel.scope.ExpressionScope;
16
-import org.openzen.zenscript.codemodel.GenericName;
17
-import org.openzen.zenscript.codemodel.type.StoredType;
18
-import org.openzen.zenscript.codemodel.type.TypeID;
19
-import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
20
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
21
-import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
22
-import stdlib.Strings;
23
-
24
-/**
25
- *
26
- * @author Hoofdgebruiker
27
- */
28
-public class ExpressionBuilder {
29
-	public final CodePosition position;
30
-	public final ExpressionScope scope;
31
-	
32
-	public ExpressionBuilder(CodePosition position, ExpressionScope scope) {
33
-		this.position = position;
34
-		this.scope = scope;
35
-	}
36
-	
37
-	public Expression constructNew(CodePosition position, String typename, Expression... arguments) throws CompileException {
38
-		String[] nameParts = Strings.split(typename, '.');
39
-		List<GenericName> name = new ArrayList<>();
40
-		for (String namePart : nameParts)
41
-			name.add(new GenericName(namePart));
42
-		TypeID type = scope.getType(position, name);
43
-		if (type == null)
44
-			throw new CompileException(position, CompileExceptionCode.NO_SUCH_TYPE, "No such type: " + typename);
45
-		
46
-		return constructNew(position, type.stored(UniqueStorageTag.INSTANCE), arguments);
47
-	}
48
-	
49
-	public Expression constructNew(CodePosition position, StoredType type, Expression... arguments) throws CompileException {
50
-		TypeMemberGroup constructors = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CONSTRUCTOR);
51
-		List<StoredType>[] predictedTypes = constructors.predictCallTypes(position, scope, scope.hints, arguments.length);
52
-		CallArguments compiledArguments = new CallArguments(arguments);
53
-		FunctionalMemberRef member = constructors.selectMethod(position, scope, compiledArguments, true, true);
54
-		if (member == null)
55
-			throw new CompileException(position, CompileExceptionCode.CALL_NO_VALID_METHOD, "No matching constructor found");
56
-		if (!member.isConstructor())
57
-			throw new CompileException(position, CompileExceptionCode.INTERNAL_ERROR, "COMPILER BUG: constructor is not a constructor");
58
-		
59
-		return new NewExpression(
60
-				position,
61
-				type,
62
-				member,
63
-				compiledArguments,
64
-				compiledArguments.getNumberOfTypeArguments() == 0 ? member.getHeader() : member.getHeader().fillGenericArguments(CodePosition.BUILTIN, scope, compiledArguments.typeArguments));
65
-	}
66
-	
67
-	public Expression not(Expression value) throws CompileException {
68
-		TypeMembers members = scope.getTypeMembers(value.type);
69
-		return members.getOrCreateGroup(OperatorType.NOT)
70
-				.call(position, scope, value, CallArguments.EMPTY, false);
71
-	}
72
-}

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

1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.expression;
7
-
8
-import org.openzen.zenscript.codemodel.statement.Statement;
9
-
10
-/**
11
- *
12
- * @author Hoofdgebruiker
13
- */
14
-public interface ExpressionContext {
15
-	void addStatementBefore(Statement statement);
16
-	
17
-	void addStatementAfter(Statement statement);
18
-}

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

6
 package org.openzen.zenscript.codemodel.expression;
6
 package org.openzen.zenscript.codemodel.expression;
7
 
7
 
8
 import java.util.function.BiFunction;
8
 import java.util.function.BiFunction;
9
-import java.util.function.Function;
10
 import org.openzen.zencode.shared.CodePosition;
9
 import org.openzen.zencode.shared.CodePosition;
11
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
10
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
12
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
11
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;

+ 70
- 70
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface ExpressionVisitor<T> {
12
 public interface ExpressionVisitor<T> {
13
-	public T visitAndAnd(AndAndExpression expression);
13
+	T visitAndAnd(AndAndExpression expression);
14
 	
14
 	
15
-	public T visitArray(ArrayExpression expression);
15
+	T visitArray(ArrayExpression expression);
16
 	
16
 	
17
-	public T visitCompare(CompareExpression expression);
17
+	T visitCompare(CompareExpression expression);
18
 	
18
 	
19
-	public T visitCall(CallExpression expression);
19
+	T visitCall(CallExpression expression);
20
 	
20
 	
21
-	public T visitCallStatic(CallStaticExpression expression);
21
+	T visitCallStatic(CallStaticExpression expression);
22
 	
22
 	
23
-	public T visitCapturedClosure(CapturedClosureExpression expression);
23
+	T visitCapturedClosure(CapturedClosureExpression expression);
24
 	
24
 	
25
-	public T visitCapturedDirect(CapturedDirectExpression expression);
25
+	T visitCapturedDirect(CapturedDirectExpression expression);
26
 	
26
 	
27
-	public T visitCapturedLocalVariable(CapturedLocalVariableExpression expression);
27
+	T visitCapturedLocalVariable(CapturedLocalVariableExpression expression);
28
 	
28
 	
29
-	public T visitCapturedParameter(CapturedParameterExpression expression);
29
+	T visitCapturedParameter(CapturedParameterExpression expression);
30
 	
30
 	
31
-	public T visitCapturedThis(CapturedThisExpression expression);
31
+	T visitCapturedThis(CapturedThisExpression expression);
32
 	
32
 	
33
-	public T visitCast(CastExpression expression);
33
+	T visitCast(CastExpression expression);
34
 	
34
 	
35
-	public T visitCheckNull(CheckNullExpression expression);
35
+	T visitCheckNull(CheckNullExpression expression);
36
 	
36
 	
37
-	public T visitCoalesce(CoalesceExpression expression);
37
+	T visitCoalesce(CoalesceExpression expression);
38
 	
38
 	
39
-	public T visitConditional(ConditionalExpression expression);
39
+	T visitConditional(ConditionalExpression expression);
40
 	
40
 	
41
-	public T visitConst(ConstExpression expression);
41
+	T visitConst(ConstExpression expression);
42
 	
42
 	
43
-	public T visitConstantBool(ConstantBoolExpression expression);
43
+	T visitConstantBool(ConstantBoolExpression expression);
44
 	
44
 	
45
-	public T visitConstantByte(ConstantByteExpression expression);
45
+	T visitConstantByte(ConstantByteExpression expression);
46
 	
46
 	
47
-	public T visitConstantChar(ConstantCharExpression expression);
47
+	T visitConstantChar(ConstantCharExpression expression);
48
 	
48
 	
49
-	public T visitConstantDouble(ConstantDoubleExpression expression);
49
+	T visitConstantDouble(ConstantDoubleExpression expression);
50
 	
50
 	
51
-	public T visitConstantFloat(ConstantFloatExpression expression);
51
+	T visitConstantFloat(ConstantFloatExpression expression);
52
 	
52
 	
53
-	public T visitConstantInt(ConstantIntExpression expression);
53
+	T visitConstantInt(ConstantIntExpression expression);
54
 	
54
 	
55
-	public T visitConstantLong(ConstantLongExpression expression);
55
+	T visitConstantLong(ConstantLongExpression expression);
56
 	
56
 	
57
-	public T visitConstantSByte(ConstantSByteExpression expression);
57
+	T visitConstantSByte(ConstantSByteExpression expression);
58
 	
58
 	
59
-	public T visitConstantShort(ConstantShortExpression expression);
59
+	T visitConstantShort(ConstantShortExpression expression);
60
 	
60
 	
61
-	public T visitConstantString(ConstantStringExpression expression);
61
+	T visitConstantString(ConstantStringExpression expression);
62
 	
62
 	
63
-	public T visitConstantUInt(ConstantUIntExpression expression);
63
+	T visitConstantUInt(ConstantUIntExpression expression);
64
 	
64
 	
65
-	public T visitConstantULong(ConstantULongExpression expression);
65
+	T visitConstantULong(ConstantULongExpression expression);
66
 	
66
 	
67
-	public T visitConstantUShort(ConstantUShortExpression expression);
67
+	T visitConstantUShort(ConstantUShortExpression expression);
68
 	
68
 	
69
-	public T visitConstantUSize(ConstantUSizeExpression expression);
69
+	T visitConstantUSize(ConstantUSizeExpression expression);
70
 	
70
 	
71
-	public T visitConstructorThisCall(ConstructorThisCallExpression expression);
71
+	T visitConstructorThisCall(ConstructorThisCallExpression expression);
72
 	
72
 	
73
-	public T visitConstructorSuperCall(ConstructorSuperCallExpression expression);
73
+	T visitConstructorSuperCall(ConstructorSuperCallExpression expression);
74
 	
74
 	
75
-	public T visitEnumConstant(EnumConstantExpression expression);
75
+	T visitEnumConstant(EnumConstantExpression expression);
76
 	
76
 	
77
-	public T visitFunction(FunctionExpression expression);
77
+	T visitFunction(FunctionExpression expression);
78
 	
78
 	
79
-	public T visitGetField(GetFieldExpression expression);
79
+	T visitGetField(GetFieldExpression expression);
80
 	
80
 	
81
-	public T visitGetFunctionParameter(GetFunctionParameterExpression expression);
81
+	T visitGetFunctionParameter(GetFunctionParameterExpression expression);
82
 	
82
 	
83
-	public T visitGetLocalVariable(GetLocalVariableExpression expression);
83
+	T visitGetLocalVariable(GetLocalVariableExpression expression);
84
 	
84
 	
85
-	public T visitGetMatchingVariantField(GetMatchingVariantField expression);
85
+	T visitGetMatchingVariantField(GetMatchingVariantField expression);
86
 	
86
 	
87
-	public T visitGetStaticField(GetStaticFieldExpression expression);
87
+	T visitGetStaticField(GetStaticFieldExpression expression);
88
 	
88
 	
89
-	public T visitGetter(GetterExpression expression);
89
+	T visitGetter(GetterExpression expression);
90
 	
90
 	
91
-	public T visitGlobal(GlobalExpression expression);
91
+	T visitGlobal(GlobalExpression expression);
92
 	
92
 	
93
-	public T visitGlobalCall(GlobalCallExpression expression);
93
+	T visitGlobalCall(GlobalCallExpression expression);
94
 	
94
 	
95
-	public T visitInterfaceCast(InterfaceCastExpression expression);
95
+	T visitInterfaceCast(InterfaceCastExpression expression);
96
 	
96
 	
97
-	public default T visitInvalid(InvalidExpression expression) {
97
+	default T visitInvalid(InvalidExpression expression) {
98
 		throw new RuntimeException("Invalid expression");
98
 		throw new RuntimeException("Invalid expression");
99
 	}
99
 	}
100
 	
100
 	
101
-	public T visitIs(IsExpression expression);
101
+	T visitIs(IsExpression expression);
102
 	
102
 	
103
-	public T visitMakeConst(MakeConstExpression expression);
103
+	T visitMakeConst(MakeConstExpression expression);
104
 	
104
 	
105
-	public T visitMap(MapExpression expression);
105
+	T visitMap(MapExpression expression);
106
 	
106
 	
107
-	public T visitMatch(MatchExpression expression);
107
+	T visitMatch(MatchExpression expression);
108
 	
108
 	
109
-	public T visitNew(NewExpression expression);
109
+	T visitNew(NewExpression expression);
110
 	
110
 	
111
-	public T visitNull(NullExpression expression);
111
+	T visitNull(NullExpression expression);
112
 	
112
 	
113
-	public T visitOrOr(OrOrExpression expression);
113
+	T visitOrOr(OrOrExpression expression);
114
 	
114
 	
115
-	public T visitPanic(PanicExpression expression);
115
+	T visitPanic(PanicExpression expression);
116
 	
116
 	
117
-	public T visitPostCall(PostCallExpression expression);
117
+	T visitPostCall(PostCallExpression expression);
118
 	
118
 	
119
-	public T visitRange(RangeExpression expression);
119
+	T visitRange(RangeExpression expression);
120
 	
120
 	
121
-	public T visitSameObject(SameObjectExpression expression);
121
+	T visitSameObject(SameObjectExpression expression);
122
 	
122
 	
123
-	public T visitSetField(SetFieldExpression expression);
123
+	T visitSetField(SetFieldExpression expression);
124
 	
124
 	
125
-	public T visitSetFunctionParameter(SetFunctionParameterExpression expression);
125
+	T visitSetFunctionParameter(SetFunctionParameterExpression expression);
126
 	
126
 	
127
-	public T visitSetLocalVariable(SetLocalVariableExpression expression);
127
+	T visitSetLocalVariable(SetLocalVariableExpression expression);
128
 	
128
 	
129
-	public T visitSetStaticField(SetStaticFieldExpression expression);
129
+	T visitSetStaticField(SetStaticFieldExpression expression);
130
 	
130
 	
131
-	public T visitSetter(SetterExpression expression);
131
+	T visitSetter(SetterExpression expression);
132
 	
132
 	
133
-	public T visitStaticGetter(StaticGetterExpression expression);
133
+	T visitStaticGetter(StaticGetterExpression expression);
134
 	
134
 	
135
-	public T visitStaticSetter(StaticSetterExpression expression);
135
+	T visitStaticSetter(StaticSetterExpression expression);
136
 	
136
 	
137
-	public T visitStorageCast(StorageCastExpression expression);
137
+	T visitStorageCast(StorageCastExpression expression);
138
 	
138
 	
139
-	public T visitSupertypeCast(SupertypeCastExpression expression);
139
+	T visitSupertypeCast(SupertypeCastExpression expression);
140
 	
140
 	
141
-	public T visitThis(ThisExpression expression);
141
+	T visitThis(ThisExpression expression);
142
 	
142
 	
143
-	public T visitThrow(ThrowExpression expression);
143
+	T visitThrow(ThrowExpression expression);
144
 	
144
 	
145
-	public T visitTryConvert(TryConvertExpression expression);
145
+	T visitTryConvert(TryConvertExpression expression);
146
 	
146
 	
147
-	public T visitTryRethrowAsException(TryRethrowAsExceptionExpression expression);
147
+	T visitTryRethrowAsException(TryRethrowAsExceptionExpression expression);
148
 	
148
 	
149
-	public T visitTryRethrowAsResult(TryRethrowAsResultExpression expression);
149
+	T visitTryRethrowAsResult(TryRethrowAsResultExpression expression);
150
 	
150
 	
151
-	public T visitVariantValue(VariantValueExpression expression);
151
+	T visitVariantValue(VariantValueExpression expression);
152
 	
152
 	
153
-	public T visitWrapOptional(WrapOptionalExpression expression);
153
+	T visitWrapOptional(WrapOptionalExpression expression);
154
 }
154
 }

+ 71
- 71
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitorWithContext.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface ExpressionVisitorWithContext<C, R> {
12
 public interface ExpressionVisitorWithContext<C, R> {
13
-	public R visitAndAnd(C context, AndAndExpression expression);
13
+	R visitAndAnd(C context, AndAndExpression expression);
14
 	
14
 	
15
-	public R visitArray(C context, ArrayExpression expression);
15
+	R visitArray(C context, ArrayExpression expression);
16
 	
16
 	
17
-	public R visitCompare(C context, CompareExpression expression);
17
+	R visitCompare(C context, CompareExpression expression);
18
 	
18
 	
19
-	public R visitCall(C context, CallExpression expression);
19
+	R visitCall(C context, CallExpression expression);
20
 	
20
 	
21
-	public R visitCallStatic(C context, CallStaticExpression expression);
21
+	R visitCallStatic(C context, CallStaticExpression expression);
22
 	
22
 	
23
-	public R visitCapturedClosure(C context, CapturedClosureExpression expression);
23
+	R visitCapturedClosure(C context, CapturedClosureExpression expression);
24
 	
24
 	
25
-	public R visitCapturedDirect(C context, CapturedDirectExpression expression);
25
+	R visitCapturedDirect(C context, CapturedDirectExpression expression);
26
 	
26
 	
27
-	public R visitCapturedLocalVariable(C context, CapturedLocalVariableExpression expression);
27
+	R visitCapturedLocalVariable(C context, CapturedLocalVariableExpression expression);
28
 	
28
 	
29
-	public R visitCapturedParameter(C context, CapturedParameterExpression expression);
29
+	R visitCapturedParameter(C context, CapturedParameterExpression expression);
30
 	
30
 	
31
-	public R visitCapturedThis(C context, CapturedThisExpression expression);
31
+	R visitCapturedThis(C context, CapturedThisExpression expression);
32
 	
32
 	
33
-	public R visitCast(C context, CastExpression expression);
33
+	R visitCast(C context, CastExpression expression);
34
 	
34
 	
35
-	public R visitCheckNull(C context, CheckNullExpression expression);
35
+	R visitCheckNull(C context, CheckNullExpression expression);
36
 	
36
 	
37
-	public R visitCoalesce(C context, CoalesceExpression expression);
37
+	R visitCoalesce(C context, CoalesceExpression expression);
38
 	
38
 	
39
-	public R visitConditional(C context, ConditionalExpression expression);
39
+	R visitConditional(C context, ConditionalExpression expression);
40
 	
40
 	
41
-	public R visitConst(C context, ConstExpression expression);
41
+	R visitConst(C context, ConstExpression expression);
42
 	
42
 	
43
-	public R visitConstantBool(C context, ConstantBoolExpression expression);
43
+	R visitConstantBool(C context, ConstantBoolExpression expression);
44
 	
44
 	
45
-	public R visitConstantByte(C context, ConstantByteExpression expression);
45
+	R visitConstantByte(C context, ConstantByteExpression expression);
46
 	
46
 	
47
-	public R visitConstantChar(C context, ConstantCharExpression expression);
47
+	R visitConstantChar(C context, ConstantCharExpression expression);
48
 	
48
 	
49
-	public R visitConstantDouble(C context, ConstantDoubleExpression expression);
49
+	R visitConstantDouble(C context, ConstantDoubleExpression expression);
50
 	
50
 	
51
-	public R visitConstantFloat(C context, ConstantFloatExpression expression);
51
+	R visitConstantFloat(C context, ConstantFloatExpression expression);
52
 	
52
 	
53
-	public R visitConstantInt(C context, ConstantIntExpression expression);
54
-	
55
-	public R visitConstantLong(C context, ConstantLongExpression expression);
53
+	R visitConstantInt(C context, ConstantIntExpression expression);
54
+
55
+	R visitConstantLong(C context, ConstantLongExpression expression);
56
 	
56
 	
57
-	public R visitConstantSByte(C context, ConstantSByteExpression expression);
57
+	R visitConstantSByte(C context, ConstantSByteExpression expression);
58
 	
58
 	
59
-	public R visitConstantShort(C context, ConstantShortExpression expression);
59
+	R visitConstantShort(C context, ConstantShortExpression expression);
60
 	
60
 	
61
-	public R visitConstantString(C context, ConstantStringExpression expression);
61
+	R visitConstantString(C context, ConstantStringExpression expression);
62
 	
62
 	
63
-	public R visitConstantUInt(C context, ConstantUIntExpression expression);
63
+	R visitConstantUInt(C context, ConstantUIntExpression expression);
64
 	
64
 	
65
-	public R visitConstantULong(C context, ConstantULongExpression expression);
65
+	R visitConstantULong(C context, ConstantULongExpression expression);
66
 	
66
 	
67
-	public R visitConstantUShort(C context, ConstantUShortExpression expression);
67
+	R visitConstantUShort(C context, ConstantUShortExpression expression);
68
 	
68
 	
69
-	public R visitConstantUSize(C context, ConstantUSizeExpression expression);
69
+	R visitConstantUSize(C context, ConstantUSizeExpression expression);
70
 	
70
 	
71
-	public R visitConstructorThisCall(C context, ConstructorThisCallExpression expression);
71
+	R visitConstructorThisCall(C context, ConstructorThisCallExpression expression);
72
 	
72
 	
73
-	public R visitConstructorSuperCall(C context, ConstructorSuperCallExpression expression);
73
+	R visitConstructorSuperCall(C context, ConstructorSuperCallExpression expression);
74
 	
74
 	
75
-	public R visitEnumConstant(C context, EnumConstantExpression expression);
75
+	R visitEnumConstant(C context, EnumConstantExpression expression);
76
 	
76
 	
77
-	public R visitFunction(C context, FunctionExpression expression);
77
+	R visitFunction(C context, FunctionExpression expression);
78
 	
78
 	
79
-	public R visitGetField(C context, GetFieldExpression expression);
79
+	R visitGetField(C context, GetFieldExpression expression);
80
 	
80
 	
81
-	public R visitGetFunctionParameter(C context, GetFunctionParameterExpression expression);
81
+	R visitGetFunctionParameter(C context, GetFunctionParameterExpression expression);
82
 	
82
 	
83
-	public R visitGetLocalVariable(C context, GetLocalVariableExpression expression);
83
+	R visitGetLocalVariable(C context, GetLocalVariableExpression expression);
84
 	
84
 	
85
-	public R visitGetMatchingVariantField(C context, GetMatchingVariantField expression);
85
+	R visitGetMatchingVariantField(C context, GetMatchingVariantField expression);
86
 	
86
 	
87
-	public R visitGetStaticField(C context, GetStaticFieldExpression expression);
87
+	R visitGetStaticField(C context, GetStaticFieldExpression expression);
88
 	
88
 	
89
-	public R visitGetter(C context, GetterExpression expression);
89
+	R visitGetter(C context, GetterExpression expression);
90
 	
90
 	
91
-	public R visitGlobal(C context, GlobalExpression expression);
91
+	R visitGlobal(C context, GlobalExpression expression);
92
 	
92
 	
93
-	public R visitGlobalCall(C context, GlobalCallExpression expression);
93
+	R visitGlobalCall(C context, GlobalCallExpression expression);
94
 	
94
 	
95
-	public R visitInterfaceCast(C context, InterfaceCastExpression expression);
95
+	R visitInterfaceCast(C context, InterfaceCastExpression expression);
96
 	
96
 	
97
-	public R visitInvalid(C context, InvalidExpression expression);
97
+	R visitInvalid(C context, InvalidExpression expression);
98
 	
98
 	
99
-	public R visitIs(C context, IsExpression expression);
99
+	R visitIs(C context, IsExpression expression);
100
 	
100
 	
101
-	public R visitMakeConst(C context, MakeConstExpression expression);
101
+	R visitMakeConst(C context, MakeConstExpression expression);
102
 	
102
 	
103
-	public R visitMap(C context, MapExpression expression);
103
+	R visitMap(C context, MapExpression expression);
104
 	
104
 	
105
-	public R visitMatch(C context, MatchExpression expression);
105
+	R visitMatch(C context, MatchExpression expression);
106
 	
106
 	
107
-	public R visitNew(C context, NewExpression expression);
107
+	R visitNew(C context, NewExpression expression);
108
 	
108
 	
109
-	public R visitNull(C context, NullExpression expression);
109
+	R visitNull(C context, NullExpression expression);
110
 	
110
 	
111
-	public R visitOrOr(C context, OrOrExpression expression);
111
+	R visitOrOr(C context, OrOrExpression expression);
112
 	
112
 	
113
-	public R visitPanic(C context, PanicExpression expression);
113
+	R visitPanic(C context, PanicExpression expression);
114
 	
114
 	
115
-	public R visitPostCall(C context, PostCallExpression expression);
115
+	R visitPostCall(C context, PostCallExpression expression);
116
 	
116
 	
117
-	public R visitRange(C context, RangeExpression expression);
117
+	R visitRange(C context, RangeExpression expression);
118
 	
118
 	
119
-	public R visitSameObject(C context, SameObjectExpression expression);
119
+	R visitSameObject(C context, SameObjectExpression expression);
120
 	
120
 	
121
-	public R visitSetField(C context, SetFieldExpression expression);
121
+	R visitSetField(C context, SetFieldExpression expression);
122
 	
122
 	
123
-	public R visitSetFunctionParameter(C context, SetFunctionParameterExpression expression);
123
+	R visitSetFunctionParameter(C context, SetFunctionParameterExpression expression);
124
 	
124
 	
125
-	public R visitSetLocalVariable(C context, SetLocalVariableExpression expression);
125
+	R visitSetLocalVariable(C context, SetLocalVariableExpression expression);
126
 	
126
 	
127
-	public R visitSetStaticField(C context, SetStaticFieldExpression expression);
127
+	R visitSetStaticField(C context, SetStaticFieldExpression expression);
128
 	
128
 	
129
-	public R visitSetter(C context, SetterExpression expression);
129
+	R visitSetter(C context, SetterExpression expression);
130
 	
130
 	
131
-	public R visitStaticGetter(C context, StaticGetterExpression expression);
131
+	R visitStaticGetter(C context, StaticGetterExpression expression);
132
 	
132
 	
133
-	public R visitStaticSetter(C context, StaticSetterExpression expression);
133
+	R visitStaticSetter(C context, StaticSetterExpression expression);
134
 	
134
 	
135
-	public R visitStorageCast(C context, StorageCastExpression expression);
135
+	R visitStorageCast(C context, StorageCastExpression expression);
136
 	
136
 	
137
-	public R visitSupertypeCast(C context, SupertypeCastExpression expression);
137
+	R visitSupertypeCast(C context, SupertypeCastExpression expression);
138
 	
138
 	
139
-	public R visitThis(C context, ThisExpression expression);
139
+	R visitThis(C context, ThisExpression expression);
140
 	
140
 	
141
-	public R visitThrow(C context, ThrowExpression expression);
141
+	R visitThrow(C context, ThrowExpression expression);
142
 	
142
 	
143
-	public R visitTryConvert(C context, TryConvertExpression expression);
143
+	R visitTryConvert(C context, TryConvertExpression expression);
144
 	
144
 	
145
-	public R visitTryRethrowAsException(C context, TryRethrowAsExceptionExpression expression);
145
+	R visitTryRethrowAsException(C context, TryRethrowAsExceptionExpression expression);
146
 	
146
 	
147
-	public R visitTryRethrowAsResult(C context, TryRethrowAsResultExpression expression);
147
+	R visitTryRethrowAsResult(C context, TryRethrowAsResultExpression expression);
148
 	
148
 	
149
-	public R visitVariantValue(C context, VariantValueExpression expression);
149
+	R visitVariantValue(C context, VariantValueExpression expression);
150
 	
150
 	
151
-	public R visitWrapOptional(C context, WrapOptionalExpression expression);
151
+	R visitWrapOptional(C context, WrapOptionalExpression expression);
152
 }
152
 }

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

17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
18
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
18
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
19
 import org.openzen.zenscript.codemodel.statement.Statement;
19
 import org.openzen.zenscript.codemodel.statement.Statement;
20
-import org.openzen.zenscript.codemodel.type.FunctionTypeID;
21
 import org.openzen.zenscript.codemodel.type.StoredType;
20
 import org.openzen.zenscript.codemodel.type.StoredType;
22
 
21
 
23
 /**
22
 /**

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

9
 import org.openzen.zencode.shared.CompileException;
9
 import org.openzen.zencode.shared.CompileException;
10
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
10
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 
12
 
14
 /**
13
 /**
15
  *
14
  *
50
 	@Override
49
 	@Override
51
 	public Expression assign(CodePosition position, TypeScope scope, Expression value) throws CompileException {
50
 	public Expression assign(CodePosition position, TypeScope scope, Expression value) throws CompileException {
52
 		return scope.getTypeMembers(getter.getOwnerType())
51
 		return scope.getTypeMembers(getter.getOwnerType())
53
-				.getOrCreateGroup(getter.member.name, false)
52
+				.getGroup(getter.member.name)
54
 				.setter(position, scope, target, value, false);
53
 				.setter(position, scope, target, value, false);
55
 	}
54
 	}
56
 }
55
 }

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

10
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
10
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12
 import org.openzen.zenscript.codemodel.type.StoredType;
12
 import org.openzen.zenscript.codemodel.type.StoredType;
13
-import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14
 
13
 
15
 /**
14
 /**
16
  *
15
  *

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface SwitchValue {
12
 public interface SwitchValue {
13
-	public <T> T accept(SwitchValueVisitor<T> visitor);
13
+	<T> T accept(SwitchValueVisitor<T> visitor);
14
 	
14
 	
15
-	public <C, R> R accept(C context, SwitchValueVisitorWithContext<C, R> visitor);
15
+	<C, R> R accept(C context, SwitchValueVisitorWithContext<C, R> visitor);
16
 }
16
 }

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface SwitchValueVisitor <T> {
12
 public interface SwitchValueVisitor <T> {
13
-	public T acceptInt(IntSwitchValue value);
13
+	T acceptInt(IntSwitchValue value);
14
 	
14
 	
15
-	public T acceptChar(CharSwitchValue value);
15
+	T acceptChar(CharSwitchValue value);
16
 	
16
 	
17
-	public T acceptString(StringSwitchValue value);
17
+	T acceptString(StringSwitchValue value);
18
 	
18
 	
19
-	public T acceptEnumConstant(EnumConstantSwitchValue value);
19
+	T acceptEnumConstant(EnumConstantSwitchValue value);
20
 	
20
 	
21
-	public T acceptVariantOption(VariantOptionSwitchValue value);
21
+	T acceptVariantOption(VariantOptionSwitchValue value);
22
 }
22
 }

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface SwitchValueVisitorWithContext <C, R> {
12
 public interface SwitchValueVisitorWithContext <C, R> {
13
-	public R acceptInt(C context, IntSwitchValue value);
13
+	R acceptInt(C context, IntSwitchValue value);
14
 	
14
 	
15
-	public R acceptChar(C context, CharSwitchValue value);
15
+	R acceptChar(C context, CharSwitchValue value);
16
 	
16
 	
17
-	public R acceptString(C context, StringSwitchValue value);
17
+	R acceptString(C context, StringSwitchValue value);
18
 	
18
 	
19
-	public R acceptEnumConstant(C context, EnumConstantSwitchValue value);
19
+	R acceptEnumConstant(C context, EnumConstantSwitchValue value);
20
 	
20
 	
21
-	public R acceptVariantOption(C context, VariantOptionSwitchValue value);
21
+	R acceptVariantOption(C context, VariantOptionSwitchValue value);
22
 }
22
 }

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface GenericParameterBoundVisitor<T> {
12
 public interface GenericParameterBoundVisitor<T> {
13
-	public T visitSuper(ParameterSuperBound bound);
13
+	T visitSuper(ParameterSuperBound bound);
14
 	
14
 	
15
-	public T visitType(ParameterTypeBound bound);
15
+	T visitType(ParameterTypeBound bound);
16
 }
16
 }

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface GenericParameterBoundVisitorWithContext<C, R> {
12
 public interface GenericParameterBoundVisitorWithContext<C, R> {
13
-	public R visitSuper(C context, ParameterSuperBound bound);
13
+	R visitSuper(C context, ParameterSuperBound bound);
14
 	
14
 	
15
-	public R visitType(C context, ParameterTypeBound bound);
15
+	R visitType(C context, ParameterTypeBound bound);
16
 }
16
 }

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

15
  *
15
  *
16
  * @author Hoofdgebruiker
16
  * @author Hoofdgebruiker
17
  */
17
  */
18
-public class ParameterSuperBound extends TypeParameterBound {
18
+public final class ParameterSuperBound implements TypeParameterBound {
19
 	public final TypeID type;
19
 	public final TypeID type;
20
 	
20
 	
21
 	public ParameterSuperBound(TypeID type) {
21
 	public ParameterSuperBound(TypeID type) {

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

17
  *
17
  *
18
  * @author Hoofdgebruiker
18
  * @author Hoofdgebruiker
19
  */
19
  */
20
-public class ParameterTypeBound extends TypeParameterBound {
20
+public final class ParameterTypeBound implements TypeParameterBound {
21
 	public final CodePosition position;
21
 	public final CodePosition position;
22
 	public final TypeID type;
22
 	public final TypeID type;
23
 	
23
 	
33
 
33
 
34
 	@Override
34
 	@Override
35
 	public void registerMembers(LocalMemberCache cache, TypeMembers members) {
35
 	public void registerMembers(LocalMemberCache cache, TypeMembers members) {
36
-		cache.get(this.type.stored(members.type.getSpecifiedStorage()))
37
-				.copyMembersTo(position, members, TypeMemberPriority.FROM_TYPE_BOUNDS);
36
+		cache.get(type.stored(members.type.getSpecifiedStorage()))
37
+				.copyMembersTo(members, TypeMemberPriority.FROM_TYPE_BOUNDS);
38
 	}
38
 	}
39
 
39
 
40
 	@Override
40
 	@Override

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

30
 		this.name = name;
30
 		this.name = name;
31
 	}
31
 	}
32
 	
32
 	
33
-	private TypeParameter(CodePosition position, String name, List<TypeParameterBound> bounds) {
34
-		this.position = position;
35
-		this.name = name;
36
-		bounds.addAll(bounds);
37
-	}
38
-	
39
 	public void addBound(TypeParameterBound bound) {
33
 	public void addBound(TypeParameterBound bound) {
40
 		bounds.add(bound);
34
 		bounds.add(bound);
41
 	}
35
 	}
42
-	
36
+
43
 	public boolean isObjectType() {
37
 	public boolean isObjectType() {
44
 		for (TypeParameterBound bound : bounds)
38
 		for (TypeParameterBound bound : bounds)
45
 			if (bound.isObjectType())
39
 			if (bound.isObjectType())
46
 				return true;
40
 				return true;
47
-		
41
+
48
 		return false;
42
 		return false;
49
 	}
43
 	}
50
 	
44
 	

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

14
  *
14
  *
15
  * @author Hoofdgebruiker
15
  * @author Hoofdgebruiker
16
  */
16
  */
17
-public abstract class TypeParameterBound {
18
-	public abstract boolean isObjectType();
17
+public interface TypeParameterBound {
18
+	boolean isObjectType();
19
 	
19
 	
20
-	public abstract <T> T accept(GenericParameterBoundVisitor<T> visitor);
20
+	<T> T accept(GenericParameterBoundVisitor<T> visitor);
21
 	
21
 	
22
-	public abstract <C, R> R accept(C context, GenericParameterBoundVisitorWithContext<C, R> visitor);
22
+	<C, R> R accept(C context, GenericParameterBoundVisitorWithContext<C, R> visitor);
23
 	
23
 	
24
-	public abstract void registerMembers(LocalMemberCache cache, TypeMembers type);
24
+	void registerMembers(LocalMemberCache cache, TypeMembers type);
25
 	
25
 	
26
-	public abstract boolean matches(LocalMemberCache cache, TypeID type);
26
+	boolean matches(LocalMemberCache cache, TypeID type);
27
 	
27
 	
28
-	public abstract TypeParameterBound instance(GenericMapper mapper);
28
+	TypeParameterBound instance(GenericMapper mapper);
29
 	
29
 	
30
-	public abstract String getCanonical();
30
+	String getCanonical();
31
 }
31
 }

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

14
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
14
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
15
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
15
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
16
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
16
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
17
-import org.openzen.zenscript.codemodel.scope.TypeScope;
18
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
17
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
19
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
18
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
20
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
19
 import org.openzen.zenscript.codemodel.type.BasicTypeID;

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

10
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.FunctionHeader;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
-import org.openzen.zenscript.codemodel.Modifiers;
14
 import org.openzen.zenscript.codemodel.expression.Expression;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
15
 import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
14
 import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
16
 import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;
15
 import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;

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

11
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.Modifiers;
13
 import org.openzen.zenscript.codemodel.Modifiers;
14
-import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
14
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
16
 import org.openzen.zenscript.codemodel.scope.TypeScope;
15
 import org.openzen.zenscript.codemodel.scope.TypeScope;
17
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16
 import org.openzen.zenscript.codemodel.statement.LoopStatement;

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

24
  * @author Hoofdgebruiker
24
  * @author Hoofdgebruiker
25
  */
25
  */
26
 public interface IDefinitionMember {
26
 public interface IDefinitionMember {
27
-	public CodePosition getPosition();
27
+	CodePosition getPosition();
28
 	
28
 	
29
-	public int getSpecifiedModifiers();
29
+	int getSpecifiedModifiers();
30
 	
30
 	
31
-	public int getEffectiveModifiers();
31
+	int getEffectiveModifiers();
32
 	
32
 	
33
-	public MemberAnnotation[] getAnnotations();
33
+	MemberAnnotation[] getAnnotations();
34
 	
34
 	
35
-	public HighLevelDefinition getDefinition();
35
+	HighLevelDefinition getDefinition();
36
 	
36
 	
37
-	public String describe();
37
+	String describe();
38
 	
38
 	
39
-	public BuiltinID getBuiltin();
39
+	BuiltinID getBuiltin();
40
 	
40
 	
41
-	public void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper);
41
+	void registerTo(TypeMembers type, TypeMemberPriority priority, GenericMapper mapper);
42
 	
42
 	
43
-	public <T> T accept(MemberVisitor<T> visitor);
43
+	<T> T accept(MemberVisitor<T> visitor);
44
 	
44
 	
45
-	public <C, R> R accept(C context, MemberVisitorWithContext<C, R> visitor);
45
+	<C, R> R accept(C context, MemberVisitorWithContext<C, R> visitor);
46
 	
46
 	
47
-	public <T extends Tag> T getTag(Class<T> tag);
47
+	<T extends Tag> T getTag(Class<T> tag);
48
 	
48
 	
49
-	public <T extends Tag> void setTag(Class<T> tag, T value);
49
+	<T extends Tag> void setTag(Class<T> tag, T value);
50
 
50
 
51
 	<T extends Tag> boolean hasTag(Class<T> tag);
51
 	<T extends Tag> boolean hasTag(Class<T> tag);
52
 	
52
 	
53
 	DefinitionMemberRef getOverrides();
53
 	DefinitionMemberRef getOverrides();
54
 
54
 
55
-	public void normalize(TypeScope scope);
55
+	void normalize(TypeScope scope);
56
 	
56
 	
57
 	boolean isAbstract();
57
 	boolean isAbstract();
58
 	
58
 	

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

45
 		members.addImplementation(new ImplementationMemberRef(this, members.type, instancedType.stored(members.type.getSpecifiedStorage())), priority);
45
 		members.addImplementation(new ImplementationMemberRef(this, members.type, instancedType.stored(members.type.getSpecifiedStorage())), priority);
46
 		
46
 		
47
 		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType.stored(members.type.getActualStorage()));
47
 		TypeMembers interfaceTypeMembers = members.getMemberCache().get(instancedType.stored(members.type.getActualStorage()));
48
-		interfaceTypeMembers.copyMembersTo(position, members, TypeMemberPriority.INTERFACE);
48
+		interfaceTypeMembers.copyMembersTo(members, TypeMemberPriority.INTERFACE);
49
 	}
49
 	}
50
 
50
 
51
 	@Override
51
 	@Override

+ 14
- 14
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MemberVisitor.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface MemberVisitor<T> {
12
 public interface MemberVisitor<T> {
13
-	public T visitConst(ConstMember member);
13
+	T visitConst(ConstMember member);
14
 	
14
 	
15
-	public T visitField(FieldMember member);
15
+	T visitField(FieldMember member);
16
 	
16
 	
17
-	public T visitConstructor(ConstructorMember member);
17
+	T visitConstructor(ConstructorMember member);
18
 	
18
 	
19
-	public T visitDestructor(DestructorMember member);
19
+	T visitDestructor(DestructorMember member);
20
 	
20
 	
21
-	public T visitMethod(MethodMember member);
21
+	T visitMethod(MethodMember member);
22
 	
22
 	
23
-	public T visitGetter(GetterMember member);
23
+	T visitGetter(GetterMember member);
24
 	
24
 	
25
-	public T visitSetter(SetterMember member);
25
+	T visitSetter(SetterMember member);
26
 	
26
 	
27
-	public T visitOperator(OperatorMember member);
27
+	T visitOperator(OperatorMember member);
28
 	
28
 	
29
-	public T visitCaster(CasterMember member);
29
+	T visitCaster(CasterMember member);
30
 	
30
 	
31
-	public T visitCustomIterator(IteratorMember member);
31
+	T visitCustomIterator(IteratorMember member);
32
 	
32
 	
33
-	public T visitCaller(CallerMember member);
33
+	T visitCaller(CallerMember member);
34
 	
34
 	
35
-	public T visitImplementation(ImplementationMember member);
35
+	T visitImplementation(ImplementationMember member);
36
 	
36
 	
37
-	public T visitInnerDefinition(InnerDefinitionMember member);
37
+	T visitInnerDefinition(InnerDefinitionMember member);
38
 	
38
 	
39
-	public T visitStaticInitializer(StaticInitializerMember member);
39
+	T visitStaticInitializer(StaticInitializerMember member);
40
 }
40
 }

+ 14
- 14
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MemberVisitorWithContext.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface MemberVisitorWithContext<C, R> {
12
 public interface MemberVisitorWithContext<C, R> {
13
-	public R visitConst(C context, ConstMember member);
13
+	R visitConst(C context, ConstMember member);
14
 	
14
 	
15
-	public R visitField(C context, FieldMember member);
15
+	R visitField(C context, FieldMember member);
16
 	
16
 	
17
-	public R visitConstructor(C context, ConstructorMember member);
17
+	R visitConstructor(C context, ConstructorMember member);
18
 	
18
 	
19
-	public R visitDestructor(C context, DestructorMember member);
19
+	R visitDestructor(C context, DestructorMember member);
20
 	
20
 	
21
-	public R visitMethod(C context, MethodMember member);
21
+	R visitMethod(C context, MethodMember member);
22
 	
22
 	
23
-	public R visitGetter(C context, GetterMember member);
23
+	R visitGetter(C context, GetterMember member);
24
 	
24
 	
25
-	public R visitSetter(C context, SetterMember member);
25
+	R visitSetter(C context, SetterMember member);
26
 	
26
 	
27
-	public R visitOperator(C context, OperatorMember member);
27
+	R visitOperator(C context, OperatorMember member);
28
 	
28
 	
29
-	public R visitCaster(C context, CasterMember member);
29
+	R visitCaster(C context, CasterMember member);
30
 	
30
 	
31
-	public R visitIterator(C context, IteratorMember member);
31
+	R visitIterator(C context, IteratorMember member);
32
 	
32
 	
33
-	public R visitCaller(C context, CallerMember member);
33
+	R visitCaller(C context, CallerMember member);
34
 	
34
 	
35
-	public R visitImplementation(C context, ImplementationMember member);
35
+	R visitImplementation(C context, ImplementationMember member);
36
 	
36
 	
37
-	public R visitInnerDefinition(C context, InnerDefinitionMember member);
37
+	R visitInnerDefinition(C context, InnerDefinitionMember member);
38
 	
38
 	
39
-	public R visitStaticInitializer(C context, StaticInitializerMember member);
39
+	R visitStaticInitializer(C context, StaticInitializerMember member);
40
 }
40
 }

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

26
  * @author Hoofdgebruiker
26
  * @author Hoofdgebruiker
27
  */
27
  */
28
 public class PartialStaticMemberGroupExpression implements IPartialExpression {
28
 public class PartialStaticMemberGroupExpression implements IPartialExpression {
29
-	public static PartialStaticMemberGroupExpression forMethod(CodePosition position, TypeScope scope, String name, TypeID target, FunctionalMemberRef method, StoredType[] typeArguments) {
30
-		TypeMemberGroup group = new TypeMemberGroup(true, name);
31
-		group.addMethod(method, TypeMemberPriority.SPECIFIED);
32
-		return new PartialStaticMemberGroupExpression(position, scope, target, group, typeArguments);
33
-	}
34
-	
35
 	private final CodePosition position;
29
 	private final CodePosition position;
36
 	private final TypeScope scope;
30
 	private final TypeScope scope;
37
 	private final TypeID target;
31
 	private final TypeID target;

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.partial;
6
 package org.openzen.zenscript.codemodel.partial;
7
 
7
 
8
+import java.util.Collections;
8
 import java.util.List;
9
 import java.util.List;
9
 import java.util.stream.Collectors;
10
 import java.util.stream.Collectors;
10
 import org.openzen.zencode.shared.CodePosition;
11
 import org.openzen.zencode.shared.CodePosition;
20
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21
 import org.openzen.zenscript.codemodel.scope.TypeScope;
21
 import org.openzen.zenscript.codemodel.type.StoredType;
22
 import org.openzen.zenscript.codemodel.type.StoredType;
22
 import org.openzen.zenscript.codemodel.type.TypeID;
23
 import org.openzen.zenscript.codemodel.type.TypeID;
24
+import org.openzen.zenscript.codemodel.type.member.TypeMemberGroup;
23
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
25
 import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
24
 
26
 
25
 /**
27
 /**
44
 
46
 
45
 	@Override
47
 	@Override
46
 	public List<StoredType>[] predictCallTypes(CodePosition position, TypeScope scope, List<StoredType> hints, int arguments) {
48
 	public List<StoredType>[] predictCallTypes(CodePosition position, TypeScope scope, List<StoredType> hints, int arguments) {
47
-		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).predictCallTypes(position, scope, hints, arguments);
49
+		TypeMemberGroup group = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL);
50
+		if (group == null)
51
+			return new List[0];
52
+
53
+		return group.predictCallTypes(position, scope, hints, arguments);
48
 	}
54
 	}
49
 	
55
 	
50
 	@Override
56
 	@Override
51
 	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<StoredType> hints, int arguments) {
57
 	public List<FunctionHeader> getPossibleFunctionHeaders(TypeScope scope, List<StoredType> hints, int arguments) {
52
-		return scope.getTypeMembers(type)
53
-				.getOrCreateGroup(OperatorType.CALL)
58
+		TypeMemberGroup group = scope.getTypeMembers(type).getGroup(OperatorType.CALL);
59
+		return group
54
 				.getMethodMembers().stream()
60
 				.getMethodMembers().stream()
55
-				.filter(method -> method.member.getHeader().parameters.length == arguments && method.member.isStatic())
61
+				.filter(method -> method.member.getHeader().accepts(arguments) && method.member.isStatic())
56
 				.map(method -> method.member.getHeader())
62
 				.map(method -> method.member.getHeader())
57
 				.collect(Collectors.toList());
63
 				.collect(Collectors.toList());
58
 	}
64
 	}
66
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
72
 	public Expression call(CodePosition position, TypeScope scope, List<StoredType> hints, CallArguments arguments) throws CompileException {
67
 		if (arguments.getNumberOfTypeArguments() == 0 && (typeArguments != null && typeArguments.length > 0))
73
 		if (arguments.getNumberOfTypeArguments() == 0 && (typeArguments != null && typeArguments.length > 0))
68
 			arguments = new CallArguments(typeArguments, arguments.arguments);
74
 			arguments = new CallArguments(typeArguments, arguments.arguments);
69
-		
70
-		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).callStatic(position, type.type, scope, arguments);
75
+
76
+		TypeMemberGroup group = scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL);
77
+		if (group == null)
78
+			throw new CompileException(position, CompileExceptionCode.NO_SUCH_MEMBER, "This type has not call operator");
79
+
80
+		return group.callStatic(position, type.type, scope, arguments);
71
 	}
81
 	}
72
 
82
 
73
 	@Override
83
 	@Override

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/processor/InterfaceProcessor.java View File

13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public interface InterfaceProcessor {
15
 public interface InterfaceProcessor {
16
-	public void apply(ImplementationMember implementation);
16
+	void apply(ImplementationMember implementation);
17
 
17
 
18
-	public void applyOnSubclass(HighLevelDefinition definition, ImplementationMember implementation);
18
+	void applyOnSubclass(HighLevelDefinition definition, ImplementationMember implementation);
19
 }
19
 }

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

10
 import java.util.HashMap;
10
 import java.util.HashMap;
11
 import java.util.List;
11
 import java.util.List;
12
 import java.util.Map;
12
 import java.util.Map;
13
-import java.util.function.Supplier;
14
 import org.openzen.zencode.shared.CodePosition;
13
 import org.openzen.zencode.shared.CodePosition;
15
 import org.openzen.zencode.shared.CompileException;
14
 import org.openzen.zencode.shared.CompileException;
16
 import org.openzen.zencode.shared.CompileExceptionCode;
15
 import org.openzen.zencode.shared.CompileExceptionCode;
47
 	private final StoredType type;
46
 	private final StoredType type;
48
 	private final TypeMembers members;
47
 	private final TypeMembers members;
49
 	private final TypeParameter[] typeParameters;
48
 	private final TypeParameter[] typeParameters;
50
-	private final Map<String, Supplier<HighLevelDefinition>> innerTypes = new HashMap<>();
51
 	private final GenericMapper typeParameterMap;
49
 	private final GenericMapper typeParameterMap;
52
 	
50
 	
53
 	public DefinitionScope(BaseScope outer, HighLevelDefinition definition) {
51
 	public DefinitionScope(BaseScope outer, HighLevelDefinition definition) {
82
 		typeParameterMap = outer.getLocalTypeParameters().getInner(definition.position, getTypeRegistry(), typeParameters);
80
 		typeParameterMap = outer.getLocalTypeParameters().getInner(definition.position, getTypeRegistry(), typeParameters);
83
 	}
81
 	}
84
 	
82
 	
85
-	public void addInnerType(String name, Supplier<HighLevelDefinition> innerType) {
86
-		innerTypes.put(name, innerType);
87
-	}
88
-	
89
 	@Override
83
 	@Override
90
 	public ZSPackage getRootPackage() {
84
 	public ZSPackage getRootPackage() {
91
 		return outer.getRootPackage();
85
 		return outer.getRootPackage();
103
 				return new PartialTypeExpression(position, members.getInnerType(position, name), name.arguments);
97
 				return new PartialTypeExpression(position, members.getInnerType(position, name), name.arguments);
104
 			if (members.hasMember(name.name) && !name.hasArguments())
98
 			if (members.hasMember(name.name) && !name.hasArguments())
105
 				return members.getMemberExpression(position, this, new ThisExpression(position, type), name, true);
99
 				return members.getMemberExpression(position, this, new ThisExpression(position, type), name, true);
106
-		} else if (innerTypes.containsKey(name.name)) {
107
-			return new PartialTypeExpression(position, getTypeRegistry().getForDefinition(innerTypes.get(name).get(), name.arguments), name.arguments);
108
 		}
100
 		}
109
 		if (!name.hasArguments()) {
101
 		if (!name.hasArguments()) {
110
 			for (TypeParameter parameter : typeParameters)
102
 			for (TypeParameter parameter : typeParameters)
129
 			for (TypeParameter parameter : typeParameters)
121
 			for (TypeParameter parameter : typeParameters)
130
 				if (parameter.name.equals(name.get(0).name))
122
 				if (parameter.name.equals(name.get(0).name))
131
 					return getTypeRegistry().getGeneric(parameter);
123
 					return getTypeRegistry().getGeneric(parameter);
132
-		
133
-		if (innerTypes.containsKey(name.get(0).name)) {
134
-			TypeID result = getTypeRegistry().getForDefinition(innerTypes.get(name.get(0).name).get(), name.get(0).arguments);
135
-			for (int i = 1; i < name.size(); i++) {
136
-				result = getTypeMembers(result.stored(StaticExpressionStorageTag.INSTANCE)).getInnerType(position, name.get(i));
137
-			}
138
-			return result;
139
-		}
140
-		
124
+
141
 		return outer.getType(position, name);
125
 		return outer.getType(position, name);
142
 	}
126
 	}
143
 
127
 

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

42
 	
42
 	
43
 	public final List<StoredType> hints;
43
 	public final List<StoredType> hints;
44
 	public final Map<TypeParameter, StoredType> genericInferenceMap;
44
 	public final Map<TypeParameter, StoredType> genericInferenceMap;
45
-	public final Map<String, Function<CodePosition, Expression>> innerVariables = new HashMap<>();
45
+	private final Map<String, Function<CodePosition, Expression>> innerVariables = new HashMap<>();
46
 	
46
 	
47
 	public ExpressionScope(BaseScope outer) {
47
 	public ExpressionScope(BaseScope outer) {
48
 		this.outer = outer;
48
 		this.outer = outer;
78
 		this.innerVariables.putAll(innerVariables);
78
 		this.innerVariables.putAll(innerVariables);
79
 	}
79
 	}
80
 	
80
 	
81
-	public void addInnerVariable(VarStatement variable) {
82
-		innerVariables.put(variable.name, position -> new GetLocalVariableExpression(position, variable));
83
-	}
84
-	
85
 	public void addMatchingVariantOption(String name, int index, VariantOptionSwitchValue value) {
81
 	public void addMatchingVariantOption(String name, int index, VariantOptionSwitchValue value) {
86
 		innerVariables.put(name, position -> new GetMatchingVariantField(position, value, index));
82
 		innerVariables.put(name, position -> new GetMatchingVariantField(position, value, index));
87
 	}
83
 	}

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

125
 	@Override
125
 	@Override
126
 	public DollarEvaluator getDollar() {
126
 	public DollarEvaluator getDollar() {
127
 		return dollar;
127
 		return dollar;
128
-		/*for (FunctionParameter parameter : header.parameters)
129
-			if (parameter.name.equals("$"))
130
-				return position -> new GetFunctionParameterExpression(position, parameter);
131
-		
132
-		return null;*/
133
 	}
128
 	}
134
 	
129
 	
135
 	@Override
130
 	@Override

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java View File

78
 
78
 
79
 	@Override
79
 	@Override
80
 	public DollarEvaluator getDollar() {
80
 	public DollarEvaluator getDollar() {
81
-		return null; // script arguments?
81
+		return null;
82
 	}
82
 	}
83
 
83
 
84
 	@Override
84
 	@Override

+ 0
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/LambdaScope.java View File

14
 import org.openzen.zenscript.codemodel.FunctionParameter;
14
 import org.openzen.zenscript.codemodel.FunctionParameter;
15
 import org.openzen.zenscript.codemodel.GenericMapper;
15
 import org.openzen.zenscript.codemodel.GenericMapper;
16
 import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;
16
 import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;
17
-import org.openzen.zenscript.codemodel.expression.InvalidExpression;
18
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
17
 import org.openzen.zenscript.codemodel.expression.LambdaClosure;
19
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
18
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
20
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
19
 import org.openzen.zenscript.codemodel.statement.LoopStatement;

+ 15
- 15
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/StatementVisitor.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface StatementVisitor<T> {
12
 public interface StatementVisitor<T> {
13
-	public T visitBlock(BlockStatement statement);
13
+	T visitBlock(BlockStatement statement);
14
 	
14
 	
15
-	public T visitBreak(BreakStatement statement);
15
+	T visitBreak(BreakStatement statement);
16
 	
16
 	
17
-	public T visitContinue(ContinueStatement statement);
17
+	T visitContinue(ContinueStatement statement);
18
 	
18
 	
19
-	public T visitDoWhile(DoWhileStatement statement);
19
+	T visitDoWhile(DoWhileStatement statement);
20
 	
20
 	
21
-	public T visitEmpty(EmptyStatement statement);
21
+	T visitEmpty(EmptyStatement statement);
22
 	
22
 	
23
-	public T visitExpression(ExpressionStatement statement);
23
+	T visitExpression(ExpressionStatement statement);
24
 	
24
 	
25
-	public T visitForeach(ForeachStatement statement);
25
+	T visitForeach(ForeachStatement statement);
26
 	
26
 	
27
-	public T visitIf(IfStatement statement);
27
+	T visitIf(IfStatement statement);
28
 	
28
 	
29
 	default T visitInvalid(InvalidStatement statement) {
29
 	default T visitInvalid(InvalidStatement statement) {
30
 		throw new UnsupportedOperationException("Invalid statement");
30
 		throw new UnsupportedOperationException("Invalid statement");
31
 	}
31
 	}
32
 	
32
 	
33
-	public T visitLock(LockStatement statement);
33
+	T visitLock(LockStatement statement);
34
 	
34
 	
35
-	public T visitReturn(ReturnStatement statement);
35
+	T visitReturn(ReturnStatement statement);
36
 	
36
 	
37
-	public T visitSwitch(SwitchStatement statement);
37
+	T visitSwitch(SwitchStatement statement);
38
 	
38
 	
39
-	public T visitThrow(ThrowStatement statement);
39
+	T visitThrow(ThrowStatement statement);
40
 	
40
 	
41
-	public T visitTryCatch(TryCatchStatement statement);
41
+	T visitTryCatch(TryCatchStatement statement);
42
 	
42
 	
43
-	public T visitVar(VarStatement statement);
43
+	T visitVar(VarStatement statement);
44
 	
44
 	
45
-	public T visitWhile(WhileStatement statement);
45
+	T visitWhile(WhileStatement statement);
46
 }
46
 }

+ 15
- 15
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/StatementVisitorWithContext.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface StatementVisitorWithContext<C, R> {
12
 public interface StatementVisitorWithContext<C, R> {
13
-	public R visitBlock(C context, BlockStatement statement);
13
+	R visitBlock(C context, BlockStatement statement);
14
 	
14
 	
15
-	public R visitBreak(C context, BreakStatement statement);
15
+	R visitBreak(C context, BreakStatement statement);
16
 	
16
 	
17
-	public R visitContinue(C context, ContinueStatement statement);
17
+	R visitContinue(C context, ContinueStatement statement);
18
 	
18
 	
19
-	public R visitDoWhile(C context, DoWhileStatement statement);
19
+	R visitDoWhile(C context, DoWhileStatement statement);
20
 	
20
 	
21
-	public R visitEmpty(C context, EmptyStatement statement);
21
+	R visitEmpty(C context, EmptyStatement statement);
22
 	
22
 	
23
-	public R visitExpression(C context, ExpressionStatement statement);
23
+	R visitExpression(C context, ExpressionStatement statement);
24
 	
24
 	
25
-	public R visitForeach(C context, ForeachStatement statement);
25
+	R visitForeach(C context, ForeachStatement statement);
26
 	
26
 	
27
-	public R visitIf(C context, IfStatement statement);
27
+	R visitIf(C context, IfStatement statement);
28
 	
28
 	
29
 	default R visitInvalid(C context, InvalidStatement statement) {
29
 	default R visitInvalid(C context, InvalidStatement statement) {
30
 		throw new UnsupportedOperationException("Invalid statement");
30
 		throw new UnsupportedOperationException("Invalid statement");
31
 	}
31
 	}
32
 	
32
 	
33
-	public R visitLock(C context, LockStatement statement);
33
+	R visitLock(C context, LockStatement statement);
34
 	
34
 	
35
-	public R visitReturn(C context, ReturnStatement statement);
35
+	R visitReturn(C context, ReturnStatement statement);
36
 	
36
 	
37
-	public R visitSwitch(C context, SwitchStatement statement);
37
+	R visitSwitch(C context, SwitchStatement statement);
38
 	
38
 	
39
-	public R visitThrow(C context, ThrowStatement statement);
39
+	R visitThrow(C context, ThrowStatement statement);
40
 	
40
 	
41
-	public R visitTryCatch(C context, TryCatchStatement statement);
41
+	R visitTryCatch(C context, TryCatchStatement statement);
42
 	
42
 	
43
-	public R visitVar(C context, VarStatement statement);
43
+	R visitVar(C context, VarStatement statement);
44
 	
44
 	
45
-	public R visitWhile(C context, WhileStatement statement);
45
+	R visitWhile(C context, WhileStatement statement);
46
 }
46
 }

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

115
 	
115
 	
116
 	@Override
116
 	@Override
117
 	public String toString() {
117
 	public String toString() {
118
-		StringBuilder result = new StringBuilder();
119
-		result.append(valueType.toString());
120
-		result.append('[');
121
-		result.append(keyType.toString());
122
-		result.append(']');
123
-		return result.toString();
118
+		return valueType.toString() + '[' + keyType.toString() + ']';
124
 	}
119
 	}
125
 }
120
 }

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

26
  * @author Hoofdgebruiker
26
  * @author Hoofdgebruiker
27
  */
27
  */
28
 public class DefinitionTypeID implements TypeID {
28
 public class DefinitionTypeID implements TypeID {
29
-	public static DefinitionTypeID forType(GlobalTypeRegistry registry, HighLevelDefinition definition) {
30
-		if (definition.typeParameters != null && definition.typeParameters.length > 0)
31
-			throw new IllegalArgumentException("Definition has type arguments!");
32
-		
33
-		return new DefinitionTypeID(registry, definition, StoredType.NONE);
34
-	}
35
-	
36
 	public final HighLevelDefinition definition;
29
 	public final HighLevelDefinition definition;
37
 	public final StoredType[] typeArguments;
30
 	public final StoredType[] typeArguments;
38
 	public final DefinitionTypeID outer;
31
 	public final DefinitionTypeID outer;

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

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

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

20
 public class OptionalTypeID implements TypeID {
20
 public class OptionalTypeID implements TypeID {
21
 	public final TypeID baseType;
21
 	public final TypeID baseType;
22
 	private final TypeID normalized;
22
 	private final TypeID normalized;
23
-	private final GlobalTypeRegistry registry;
24
 	
23
 	
25
 	public OptionalTypeID(GlobalTypeRegistry registry, TypeID baseType) {
24
 	public OptionalTypeID(GlobalTypeRegistry registry, TypeID baseType) {
26
 		this.baseType = baseType;
25
 		this.baseType = baseType;
27
-		this.registry = registry;
28
 		
26
 		
29
 		normalized = baseType.getNormalized() == baseType ? this : registry.getOptional(baseType.getNormalized());
27
 		normalized = baseType.getNormalized() == baseType ? this : registry.getOptional(baseType.getNormalized());
30
 	}
28
 	}
116
 	
114
 	
117
 	@Override
115
 	@Override
118
 	public String toString(StorageTag storage) {
116
 	public String toString(StorageTag storage) {
119
-		StringBuilder result = new StringBuilder();
120
-		result.append(baseType.toString(storage));
121
-		result.append("?");
122
-		return result.toString();
117
+		return baseType.toString(storage) + '?';
123
 	}
118
 	}
124
 }
119
 }

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

9
 import java.util.Map;
9
 import java.util.Map;
10
 import java.util.Objects;
10
 import java.util.Objects;
11
 import java.util.Set;
11
 import java.util.Set;
12
-import org.openzen.zencode.shared.CodePosition;
13
 import org.openzen.zenscript.codemodel.GenericMapper;
12
 import org.openzen.zenscript.codemodel.GenericMapper;
14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
127
 	public boolean isEnum() {
126
 	public boolean isEnum() {
128
 		return type.isEnum();
127
 		return type.isEnum();
129
 	}
128
 	}
130
-	
131
-	public boolean isDefinition(HighLevelDefinition definition) {
132
-		return type.isDefinition(definition);
133
-	}
134
-	
129
+
135
 	public DefinitionTypeID asDefinition() {
130
 	public DefinitionTypeID asDefinition() {
136
 		return (DefinitionTypeID)type;
131
 		return (DefinitionTypeID)type;
137
 	}
132
 	}
160
 	public String toString() {
155
 	public String toString() {
161
 		return storage == null ? type.toString() : type.toString(storage);
156
 		return storage == null ? type.toString() : type.toString(storage);
162
 	}
157
 	}
163
-	
164
-	public static class MatchingTypeVisitor implements TypeVisitor<Boolean> {
165
-		private final TypeID type;
166
-		private final Map<TypeParameter, StoredType> mapping;
167
-		private final LocalMemberCache cache;
168
-		
169
-		public MatchingTypeVisitor(LocalMemberCache cache, TypeID type, Map<TypeParameter, StoredType> mapping) {
170
-			this.type = type;
171
-			this.mapping = mapping;
172
-			this.cache = cache;
173
-		}
174
-
175
-		@Override
176
-		public Boolean visitBasic(BasicTypeID basic) {
177
-			return basic == type;
178
-		}
179
-		
180
-		@Override
181
-		public Boolean visitString(StringTypeID string) {
182
-			return string == type;
183
-		}
184
-
185
-		@Override
186
-		public Boolean visitArray(ArrayTypeID array) {
187
-			if (type instanceof ArrayTypeID) {
188
-				ArrayTypeID arrayType = (ArrayTypeID) type;
189
-				if (arrayType.dimension != array.dimension)
190
-					return false;
191
-				
192
-				return match(arrayType.elementType, array.elementType);
193
-			} else {
194
-				return false;
195
-			}
196
-		}
197
-
198
-		@Override
199
-		public Boolean visitAssoc(AssocTypeID assoc) {
200
-			if (type instanceof AssocTypeID) {
201
-				AssocTypeID assocType = (AssocTypeID) type;
202
-				return match(assocType.keyType, assoc.keyType)
203
-						&& match(assocType.valueType, assoc.valueType);
204
-			} else {
205
-				return false;
206
-			}
207
-		}
208
-		
209
-		@Override
210
-		public Boolean visitIterator(IteratorTypeID iterator) {
211
-			if (type instanceof IteratorTypeID) {
212
-				IteratorTypeID iteratorType = (IteratorTypeID) type;
213
-				if (iteratorType.iteratorTypes.length != iterator.iteratorTypes.length)
214
-					return false;
215
-				
216
-				boolean result = true;
217
-				for (int i = 0; i < iteratorType.iteratorTypes.length; i++)
218
-					result = result && match(iterator.iteratorTypes[i], iteratorType.iteratorTypes[i]);
219
-				
220
-				return result;
221
-			} else {
222
-				return false;
223
-			}
224
-		}
225
-
226
-		@Override
227
-		public Boolean visitFunction(FunctionTypeID function) {
228
-			if (type instanceof FunctionTypeID) {
229
-				FunctionTypeID functionType = (FunctionTypeID) type;
230
-				if (functionType.header.parameters.length != function.header.parameters.length)
231
-					return false;
232
-				
233
-				if (!match(functionType.header.getReturnType(), function.header.getReturnType()))
234
-					return false;
235
-				
236
-				for (int i = 0; i < function.header.parameters.length; i++) {
237
-					if (!match(functionType.header.parameters[i].type, function.header.parameters[i].type))
238
-						return false;
239
-				}
240
-				
241
-				return true;
242
-			} else {
243
-				return false;
244
-			}
245
-		}
246
-
247
-		@Override
248
-		public Boolean visitDefinition(DefinitionTypeID definition) {
249
-			if (type instanceof DefinitionTypeID) {
250
-				DefinitionTypeID definitionType = (DefinitionTypeID) type;
251
-				if (definitionType.definition != definition.definition)
252
-					return false;
253
-				
254
-				if (definition.typeArguments != null) {
255
-					for (int i = 0; i < definitionType.typeArguments.length; i++) {
256
-						if (!match(definitionType.typeArguments[i], definition.typeArguments[i]))
257
-							return false;
258
-					}
259
-				}
260
-				
261
-				return true;
262
-			} else {
263
-				return false;
264
-			}
265
-		}
266
-
267
-		@Override
268
-		public Boolean visitGeneric(GenericTypeID generic) {
269
-			if (mapping.containsKey(generic.parameter)) {
270
-				return mapping.get(generic.parameter) == type;
271
-			} else if (type == generic || generic.matches(cache, type.stored())) {
272
-				mapping.put(generic.parameter, type.stored());
273
-				return true;
274
-			} else {
275
-				return false;
276
-			}
277
-		}
278
-
279
-		@Override
280
-		public Boolean visitRange(RangeTypeID range) {
281
-			if (type instanceof RangeTypeID) {
282
-				RangeTypeID rangeType = (RangeTypeID) type;
283
-				return match(rangeType.baseType, range.baseType);
284
-			} else {
285
-				return false;
286
-			}
287
-		}
288
-
289
-		@Override
290
-		public Boolean visitOptional(OptionalTypeID type) {
291
-			if (this.type instanceof OptionalTypeID) {
292
-				OptionalTypeID constType = (OptionalTypeID) this.type;
293
-				return match(constType.baseType, type.baseType.stored());
294
-			} else {
295
-				return false;
296
-			}
297
-		}
298
-		
299
-		private boolean match(StoredType type, StoredType pattern) {
300
-			if (pattern.storage != null && type.storage != pattern.storage)
301
-				return false;
302
-			
303
-			return TypeMatcher.match(cache, type, pattern) != null;
304
-		}
305
-		
306
-		private boolean match(TypeID type, StoredType pattern) {
307
-			return TypeMatcher.match(cache, type.stored(), pattern) != null;
308
-		}
309
-
310
-		@Override
311
-		public Boolean visitGenericMap(GenericMapTypeID map) {
312
-			return map == type; // TODO: improve this
313
-		}
314
-	}
315
 }
158
 }

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

20
  * @author Hoofdgebruiker
20
  * @author Hoofdgebruiker
21
  */
21
  */
22
 public interface TypeID {
22
 public interface TypeID {
23
-	public static final TypeID[] NONE = new TypeID[0];
23
+	TypeID[] NONE = new TypeID[0];
24
 	
24
 	
25
 	default TypeID getSuperType(GlobalTypeRegistry registry) {
25
 	default TypeID getSuperType(GlobalTypeRegistry registry) {
26
 		return null;
26
 		return null;

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

1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.codemodel.type;
7
-
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.FunctionParameter;
10
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
-
12
-/**
13
- *
14
- * @author Hoofdgebruiker
15
- */
16
-public class TypeParameterCollector implements TypeVisitorWithContext<Map<TypeParameter, GenericTypeID>, Void, RuntimeException> {
17
-	private final Map<TypeParameter, GenericTypeID> map;
18
-	
19
-	public TypeParameterCollector(Map<TypeParameter, GenericTypeID> map) {
20
-		this.map = map;
21
-	}
22
-
23
-	@Override
24
-	public Void visitBasic(Map<TypeParameter, GenericTypeID> context, BasicTypeID basic) {
25
-		return null;
26
-	}
27
-	
28
-	@Override
29
-	public Void visitString(Map<TypeParameter, GenericTypeID> context, StringTypeID string) {
30
-		return null;
31
-	}
32
-
33
-	@Override
34
-	public Void visitArray(Map<TypeParameter, GenericTypeID> context, ArrayTypeID array) {
35
-		array.elementType.type.accept(context, this);
36
-		return null;
37
-	}
38
-
39
-	@Override
40
-	public Void visitAssoc(Map<TypeParameter, GenericTypeID> context, AssocTypeID assoc) {
41
-		assoc.keyType.type.accept(context, this);
42
-		assoc.valueType.type.accept(context, this);
43
-		return null;
44
-	}
45
-
46
-	@Override
47
-	public Void visitGenericMap(Map<TypeParameter, GenericTypeID> context, GenericMapTypeID map) {
48
-		return null;
49
-	}
50
-
51
-	@Override
52
-	public Void visitIterator(Map<TypeParameter, GenericTypeID> context, IteratorTypeID iterator) {
53
-		for (StoredType type : iterator.iteratorTypes)
54
-			type.type.accept(context, this);
55
-		return null;
56
-	}
57
-
58
-	@Override
59
-	public Void visitFunction(Map<TypeParameter, GenericTypeID> context, FunctionTypeID function) {
60
-		function.header.getReturnType().type.accept(context, this);
61
-		for (FunctionParameter parameter : function.header.parameters)
62
-			parameter.type.type.accept(context, this);
63
-		return null;
64
-	}
65
-
66
-	@Override
67
-	public Void visitDefinition(Map<TypeParameter, GenericTypeID> context, DefinitionTypeID definition) {
68
-		for (StoredType argument : definition.typeArguments)
69
-			argument.type.accept(context, this);
70
-		if (definition.outer != null)
71
-			visitDefinition(context, definition.outer);
72
-		return null;
73
-	}
74
-
75
-	@Override
76
-	public Void visitGeneric(Map<TypeParameter, GenericTypeID> context, GenericTypeID generic) {
77
-		map.put(generic.parameter, generic);
78
-		return null;
79
-	}
80
-
81
-	@Override
82
-	public Void visitRange(Map<TypeParameter, GenericTypeID> context, RangeTypeID range) {
83
-		range.baseType.type.accept(context, this);
84
-		return null;
85
-	}
86
-
87
-	@Override
88
-	public Void visitModified(Map<TypeParameter, GenericTypeID> context, OptionalTypeID type) {
89
-		type.baseType.accept(context, this);
90
-		return null;
91
-	}
92
-}

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface TypeVisitor<T> {
12
 public interface TypeVisitor<T> {
13
-	public T visitBasic(BasicTypeID basic);
13
+	T visitBasic(BasicTypeID basic);
14
 	
14
 	
15
-	public T visitString(StringTypeID string);
15
+	T visitString(StringTypeID string);
16
 	
16
 	
17
-	public T visitArray(ArrayTypeID array);
17
+	T visitArray(ArrayTypeID array);
18
 	
18
 	
19
-	public T visitAssoc(AssocTypeID assoc);
19
+	T visitAssoc(AssocTypeID assoc);
20
 	
20
 	
21
-	public T visitGenericMap(GenericMapTypeID map);
21
+	T visitGenericMap(GenericMapTypeID map);
22
 	
22
 	
23
-	public T visitIterator(IteratorTypeID iterator);
23
+	T visitIterator(IteratorTypeID iterator);
24
 	
24
 	
25
-	public T visitFunction(FunctionTypeID function);
25
+	T visitFunction(FunctionTypeID function);
26
 	
26
 	
27
-	public T visitDefinition(DefinitionTypeID definition);
27
+	T visitDefinition(DefinitionTypeID definition);
28
 	
28
 	
29
-	public T visitGeneric(GenericTypeID generic);
29
+	T visitGeneric(GenericTypeID generic);
30
 	
30
 	
31
-	public T visitRange(RangeTypeID range);
31
+	T visitRange(RangeTypeID range);
32
 	
32
 	
33
-	public T visitOptional(OptionalTypeID type);
33
+	T visitOptional(OptionalTypeID type);
34
 	
34
 	
35
-	public default T visitInvalid(InvalidTypeID type) {
35
+	default T visitInvalid(InvalidTypeID type) {
36
 		throw new UnsupportedOperationException("Invalid type: " + type.message);
36
 		throw new UnsupportedOperationException("Invalid type: " + type.message);
37
 	}
37
 	}
38
 }
38
 }

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

21
 	}
21
 	}
22
 	
22
 	
23
 	public TypeMember<T> resolve(TypeMember<T> other) {
23
 	public TypeMember<T> resolve(TypeMember<T> other) {
24
-		if (priority == other.priority) {
25
-			//if (priority == TypeMemberPriority.SPECIFIED)
26
-			//	throw new CompileException(other.member.getPosition(), CompileExceptionCode.MEMBER_DUPLICATE, "Duplicate " + other.member.describe());
27
-			return this;
28
-		}
29
-		
24
+		if (priority == other.priority)
25
+			return this; // this is actually an error; but that error will be reported through the validator
26
+
30
 		if (priority.compareTo(other.priority) < 0) {
27
 		if (priority.compareTo(other.priority) < 0) {
31
 			return other;
28
 			return other;
32
 		} else {
29
 		} else {

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

523
 			InterfaceDefinition interfaceDefinition = (InterfaceDefinition)definition;
523
 			InterfaceDefinition interfaceDefinition = (InterfaceDefinition)definition;
524
 			for (TypeID baseType : interfaceDefinition.baseInterfaces)
524
 			for (TypeID baseType : interfaceDefinition.baseInterfaces)
525
 				cache.get(baseType.instance(mapper, type.getSpecifiedStorage()))
525
 				cache.get(baseType.instance(mapper, type.getSpecifiedStorage()))
526
-						.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
526
+						.copyMembersTo(members, TypeMemberPriority.INHERITED);
527
 		}
527
 		}
528
 		
528
 		
529
 		if (definitionType.superType != null) {
529
 		if (definitionType.superType != null) {
530
 			cache.get(definitionType.superType.stored(type.getSpecifiedStorage()))
530
 			cache.get(definitionType.superType.stored(type.getSpecifiedStorage()))
531
-					.copyMembersTo(definitionType.definition.position, members, TypeMemberPriority.INHERITED);
531
+					.copyMembersTo(members, TypeMemberPriority.INHERITED);
532
 		} else {
532
 		} else {
533
 			getter(definition, OBJECT_HASHCODE, "objectHashCode", INT.stored);
533
 			getter(definition, OBJECT_HASHCODE, "objectHashCode", INT.stored);
534
 		}
534
 		}

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

40
  * @author Hoofdgebruiker
40
  * @author Hoofdgebruiker
41
  */
41
  */
42
 public class TypeMemberGroup {
42
 public class TypeMemberGroup {
43
+	public static final TypeMemberGroup EMPTY = new TypeMemberGroup(false, "");
44
+
43
 	public static TypeMemberGroup forMethod(String name, FunctionalMemberRef member) {
45
 	public static TypeMemberGroup forMethod(String name, FunctionalMemberRef member) {
44
 		TypeMemberGroup instance = new TypeMemberGroup(member.isStatic(), name);
46
 		TypeMemberGroup instance = new TypeMemberGroup(member.isStatic(), name);
45
 		instance.addMethod(member, TypeMemberPriority.SPECIFIED);
47
 		instance.addMethod(member, TypeMemberPriority.SPECIFIED);
59
 		this.name = name;
61
 		this.name = name;
60
 	}
62
 	}
61
 	
63
 	
62
-	public void merge(CodePosition position, TypeMemberGroup other, TypeMemberPriority priority) {
64
+	public void merge(TypeMemberGroup other, TypeMemberPriority priority) {
63
 		if (other.constant != null)
65
 		if (other.constant != null)
64
 			setConst(other.constant.member, priority);
66
 			setConst(other.constant.member, priority);
65
 		if (other.field != null)
67
 		if (other.field != null)
198
 			scope.getPreparer().prepare(setter.member.member);
200
 			scope.getPreparer().prepare(setter.member.member);
199
 			return new SetterExpression(position, target, setter.member, value.castImplicit(position, scope, setter.member.getType()));
201
 			return new SetterExpression(position, target, setter.member, value.castImplicit(position, scope, setter.member.getType()));
200
 		} else if (field != null) {
202
 		} else if (field != null) {
201
-			// TODO: perform proper checks on val fields
202
-			//if (field.isFinal)
203
-			//	throw new CompileException(position, "This field cannot be modified");
204
 			if (field.member.isStatic()) {
203
 			if (field.member.isStatic()) {
205
 				if (!allowStaticUsage)
204
 				if (!allowStaticUsage)
206
 					return new InvalidExpression(position, field.member.getType(), CompileExceptionCode.USING_STATIC_ON_INSTANCE, "This field is static");
205
 					return new InvalidExpression(position, field.member.getType(), CompileExceptionCode.USING_STATIC_ON_INSTANCE, "This field is static");
244
 			scope.getPreparer().prepare(setter.member.member);
243
 			scope.getPreparer().prepare(setter.member.member);
245
 			return new StaticSetterExpression(position, setter.member, value.castImplicit(position, scope, setter.member.getType()));
244
 			return new StaticSetterExpression(position, setter.member, value.castImplicit(position, scope, setter.member.getType()));
246
 		} else if (field != null) {
245
 		} else if (field != null) {
247
-			//if (field.member.isFinal)
248
-			//	throw new CompileException(position, CompileExceptionCode.MEMBER_IS_FINAL, "This field cannot be modified");
249
 			if (!field.member.isStatic())
246
 			if (!field.member.isStatic())
250
 				return new InvalidExpression(position, field.member.getType(), CompileExceptionCode.MEMBER_NOT_STATIC, "This field is not static");
247
 				return new InvalidExpression(position, field.member.getType(), CompileExceptionCode.MEMBER_NOT_STATIC, "This field is not static");
251
 
248
 

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

48
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
48
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
49
 import org.openzen.zenscript.codemodel.scope.TypeScope;
49
 import org.openzen.zenscript.codemodel.scope.TypeScope;
50
 import org.openzen.zenscript.codemodel.type.StoredType;
50
 import org.openzen.zenscript.codemodel.type.StoredType;
51
-import org.openzen.zenscript.codemodel.type.StringTypeID;
52
 import org.openzen.zenscript.codemodel.type.TypeID;
51
 import org.openzen.zenscript.codemodel.type.TypeID;
53
 
52
 
54
 /**
53
 /**
120
 		return cache.getRegistry();
119
 		return cache.getRegistry();
121
 	}
120
 	}
122
 	
121
 	
123
-	public void copyMembersTo(CodePosition position, TypeMembers other, TypeMemberPriority priority) {
122
+	public void copyMembersTo(TypeMembers other, TypeMemberPriority priority) {
124
 		other.casters.addAll(casters);
123
 		other.casters.addAll(casters);
125
 		other.iterators.addAll(iterators);
124
 		other.iterators.addAll(iterators);
126
 		
125
 		
129
 		for (Map.Entry<String, VariantOptionRef> entry : variantOptions.entrySet())
128
 		for (Map.Entry<String, VariantOptionRef> entry : variantOptions.entrySet())
130
 			other.addVariantOption(entry.getValue());
129
 			other.addVariantOption(entry.getValue());
131
 		for (Map.Entry<String, TypeMemberGroup> entry : members.entrySet())
130
 		for (Map.Entry<String, TypeMemberGroup> entry : members.entrySet())
132
-			other.getOrCreateGroup(entry.getKey(), entry.getValue().isStatic).merge(position, entry.getValue(), priority);
131
+			other.getOrCreateGroup(entry.getKey(), entry.getValue().isStatic).merge(entry.getValue(), priority);
133
 		for (Map.Entry<String, InnerDefinition> entry : innerTypes.entrySet())
132
 		for (Map.Entry<String, InnerDefinition> entry : innerTypes.entrySet())
134
 			other.innerTypes.put(entry.getKey(), entry.getValue());
133
 			other.innerTypes.put(entry.getKey(), entry.getValue());
135
 		for (Map.Entry<OperatorType, TypeMemberGroup> entry : operators.entrySet())
134
 		for (Map.Entry<OperatorType, TypeMemberGroup> entry : operators.entrySet())
136
-			other.getOrCreateGroup(entry.getKey()).merge(position, entry.getValue(), priority);
135
+			other.getOrCreateGroup(entry.getKey()).merge(entry.getValue(), priority);
137
 	}
136
 	}
138
 	
137
 	
139
 	public DefinitionMemberRef getBuiltin(BuiltinID builtin) {
138
 	public DefinitionMemberRef getBuiltin(BuiltinID builtin) {
256
 		group.setField(member, priority);
255
 		group.setField(member, priority);
257
 	}
256
 	}
258
 	
257
 	
259
-	public void addGetter(GetterMemberRef member) throws CompileException {
260
-		addGetter(member, TypeMemberPriority.SPECIFIED);
261
-	}
262
-	
263
 	public void addGetter(GetterMemberRef member, TypeMemberPriority priority) {
258
 	public void addGetter(GetterMemberRef member, TypeMemberPriority priority) {
264
 		TypeMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
259
 		TypeMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
265
 		group.setGetter(member, priority);
260
 		group.setGetter(member, priority);
266
 	}
261
 	}
267
 	
262
 	
268
-	public void addSetter(SetterMemberRef member) throws CompileException {
269
-		addSetter(member, TypeMemberPriority.SPECIFIED);
270
-	}
271
-	
272
 	public void addSetter(SetterMemberRef member, TypeMemberPriority priority) {
263
 	public void addSetter(SetterMemberRef member, TypeMemberPriority priority) {
273
 		TypeMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
264
 		TypeMemberGroup group = getOrCreateGroup(member.member.name, member.isStatic());
274
 		group.setSetter(member, priority);
265
 		group.setSetter(member, priority);
275
 	}
266
 	}
276
 	
267
 	
277
-	public void addMethod(String name, FunctionalMemberRef member) {
278
-		addMethod(name, member, TypeMemberPriority.SPECIFIED);
279
-	}
280
-	
281
 	public void addMethod(String name, FunctionalMemberRef member, TypeMemberPriority priority) {
268
 	public void addMethod(String name, FunctionalMemberRef member, TypeMemberPriority priority) {
282
 		TypeMemberGroup group = getOrCreateGroup(name, member.isStatic());
269
 		TypeMemberGroup group = getOrCreateGroup(name, member.isStatic());
283
 		group.addMethod(member, priority);
270
 		group.addMethod(member, priority);
334
 	}
321
 	}
335
 	
322
 	
336
 	public TypeMemberGroup getGroup(String name) {
323
 	public TypeMemberGroup getGroup(String name) {
324
+		if (!members.containsKey(name))
325
+			return new TypeMemberGroup(false, name);
326
+
337
 		return members.get(name);
327
 		return members.get(name);
338
 	}
328
 	}
339
 	
329
 	
345
 	}
335
 	}
346
 	
336
 	
347
 	public TypeMemberGroup getGroup(OperatorType operator) {
337
 	public TypeMemberGroup getGroup(OperatorType operator) {
338
+		if (!operators.containsKey(operator))
339
+			return new TypeMemberGroup(false, operator.operator + " operator");
340
+
348
 		return operators.get(operator);
341
 		return operators.get(operator);
349
 	}
342
 	}
350
 	
343
 	

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

12
  * @author Hoofdgebruiker
12
  * @author Hoofdgebruiker
13
  */
13
  */
14
 public interface StorageType {
14
 public interface StorageType {
15
-	public static StorageType[] getStandard() {
15
+	static StorageType[] getStandard() {
16
 		return new StorageType[] {
16
 		return new StorageType[] {
17
 			AutoStorageType.INSTANCE,
17
 			AutoStorageType.INSTANCE,
18
 			BorrowStorageType.INSTANCE,
18
 			BorrowStorageType.INSTANCE,

+ 16
- 0
Constructor/src/main/java/org/openzen/zenscript/constructor/ConstructorRegistry.java View File

6
 package org.openzen.zenscript.constructor;
6
 package org.openzen.zenscript.constructor;
7
 
7
 
8
 import java.io.File;
8
 import java.io.File;
9
+import java.io.FileOutputStream;
10
+import java.io.IOException;
11
+import java.io.OutputStreamWriter;
12
+import java.nio.charset.StandardCharsets;
9
 import java.util.ArrayList;
13
 import java.util.ArrayList;
10
 import java.util.HashMap;
14
 import java.util.HashMap;
11
 import java.util.List;
15
 import java.util.List;
21
 import org.openzen.zenscript.javabytecode.JavaBytecodeRunUnit;
25
 import org.openzen.zenscript.javabytecode.JavaBytecodeRunUnit;
22
 import org.openzen.zenscript.javabytecode.JavaCompiler;
26
 import org.openzen.zenscript.javabytecode.JavaCompiler;
23
 import org.openzen.zenscript.javashared.JavaCompileSpace;
27
 import org.openzen.zenscript.javashared.JavaCompileSpace;
28
+import org.openzen.zenscript.javashared.JavaCompiledModule;
24
 import org.openzen.zenscript.javashared.SimpleJavaCompileSpace;
29
 import org.openzen.zenscript.javashared.SimpleJavaCompileSpace;
25
 import org.openzen.zenscript.javasource.JavaDirectoryOutput;
30
 import org.openzen.zenscript.javasource.JavaDirectoryOutput;
26
 import org.openzen.zenscript.javasource.JavaSourceCompiler;
31
 import org.openzen.zenscript.javasource.JavaSourceCompiler;
112
 		@Override
117
 		@Override
113
 		public void addModule(SemanticModule module) {
118
 		public void addModule(SemanticModule module) {
114
 			JavaSourceModule result = compiler.compile(module, space, module.modulePackage.fullName);
119
 			JavaSourceModule result = compiler.compile(module, space, module.modulePackage.fullName);
120
+			writeMappings(result);
121
+			
115
 			modules.add(result);
122
 			modules.add(result);
116
 			space.register(result);
123
 			space.register(result);
117
 		}
124
 		}
128
 		public void run() {
135
 		public void run() {
129
 			throw new UnsupportedOperationException();
136
 			throw new UnsupportedOperationException();
130
 		}
137
 		}
138
+		
139
+		private void writeMappings(JavaCompiledModule module) {
140
+			String mappings = module.generateMappings();
141
+			try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(new File(output, "java.map")), StandardCharsets.UTF_8)) {
142
+				writer.write(mappings);
143
+			} catch (IOException ex) {
144
+				
145
+			}
146
+		}
131
 	}
147
 	}
132
 	
148
 	
133
 	private static class JavaBytecodeTargetType implements TargetType {
149
 	private static class JavaBytecodeTargetType implements TargetType {

+ 0
- 15
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaBaseCompiler.java View File

1
-package org.openzen.zenscript.javashared;
2
-
3
-/*
4
- * To change this license header, choose License Headers in Project Properties.
5
- * To change this template file, choose Tools | Templates
6
- * and open the template in the editor.
7
- */
8
-
9
-/**
10
- *
11
- * @author Hoofdgebruiker
12
- */
13
-public abstract class JavaBaseCompiler {
14
-	//public abstract JavaCompiledModule compile(SemanticModule module, JavaCompileSpace space);
15
-}

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

13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public interface JavaCompileSpace {
15
 public interface JavaCompileSpace {
16
-	public GlobalTypeRegistry getRegistry();
16
+	GlobalTypeRegistry getRegistry();
17
 	
17
 	
18
-	public JavaCompiledModule getCompiled(Module module);
18
+	JavaCompiledModule getCompiled(Module module);
19
 }
19
 }

+ 22
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java View File

11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.Modifiers;
12
 import org.openzen.zenscript.codemodel.Modifiers;
13
 import org.openzen.zenscript.codemodel.Module;
13
 import org.openzen.zenscript.codemodel.Module;
14
+import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
14
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
15
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
15
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
16
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
16
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
17
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
37
 		this.module = module;
38
 		this.module = module;
38
 	}
39
 	}
39
 	
40
 	
41
+	public void loadMappings(String mappings) {
42
+		
43
+	}
44
+	
45
+	public String generateMappings() {
46
+		JavaMappingWriter writer = new JavaMappingWriter(this);
47
+		for (HighLevelDefinition definition : classes.keySet()) {
48
+			if (!(definition instanceof ExpansionDefinition))
49
+				definition.accept(writer);
50
+		}
51
+		for (HighLevelDefinition definition : expansionClasses.keySet()) {
52
+			definition.accept(writer);
53
+		}
54
+		
55
+		return writer.getOutput();
56
+	}
57
+	
40
 	public void setClassInfo(HighLevelDefinition definition, JavaClass cls) {
58
 	public void setClassInfo(HighLevelDefinition definition, JavaClass cls) {
41
 		classes.put(definition, cls);
59
 		classes.put(definition, cls);
42
 	}
60
 	}
121
 		methods.put(member, method);
139
 		methods.put(member, method);
122
 	}
140
 	}
123
 	
141
 	
142
+	public JavaMethod optMethodInfo(IDefinitionMember member) {
143
+		return methods.get(member);
144
+	}
145
+	
124
 	public JavaMethod getMethodInfo(DefinitionMemberRef member) {
146
 	public JavaMethod getMethodInfo(DefinitionMemberRef member) {
125
 		return getMethodInfo(member.getTarget());
147
 		return getMethodInfo(member.getTarget());
126
 	}
148
 	}

+ 12
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaField.java View File

20
 		this.name = name;
20
 		this.name = name;
21
 		this.descriptor = descriptor;
21
 		this.descriptor = descriptor;
22
 	}
22
 	}
23
+	
24
+	public String getMapping(JavaClass definition) {
25
+		StringBuilder result = new StringBuilder();
26
+		result.append(name);
27
+		result.append(':');
28
+		result.append(descriptor);
29
+		
30
+		if (!cls.internalName.equals(definition.internalName))
31
+			result.append(definition.internalName);
32
+		
33
+		return result.toString();
34
+	}
23
 }
35
 }

+ 306
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaMappingWriter.java View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.javashared;
7
+
8
+import org.openzen.zenscript.codemodel.FunctionHeader;
9
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
+import org.openzen.zenscript.codemodel.definition.AliasDefinition;
11
+import org.openzen.zenscript.codemodel.definition.ClassDefinition;
12
+import org.openzen.zenscript.codemodel.definition.DefinitionVisitor;
13
+import org.openzen.zenscript.codemodel.definition.EnumDefinition;
14
+import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
15
+import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
16
+import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
17
+import org.openzen.zenscript.codemodel.definition.StructDefinition;
18
+import org.openzen.zenscript.codemodel.definition.VariantDefinition;
19
+import org.openzen.zenscript.codemodel.member.CallerMember;
20
+import org.openzen.zenscript.codemodel.member.CasterMember;
21
+import org.openzen.zenscript.codemodel.member.ConstMember;
22
+import org.openzen.zenscript.codemodel.member.ConstructorMember;
23
+import org.openzen.zenscript.codemodel.member.DestructorMember;
24
+import org.openzen.zenscript.codemodel.member.FieldMember;
25
+import org.openzen.zenscript.codemodel.member.GetterMember;
26
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
27
+import org.openzen.zenscript.codemodel.member.ImplementationMember;
28
+import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
29
+import org.openzen.zenscript.codemodel.member.IteratorMember;
30
+import org.openzen.zenscript.codemodel.member.MemberVisitor;
31
+import org.openzen.zenscript.codemodel.member.MethodMember;
32
+import org.openzen.zenscript.codemodel.member.OperatorMember;
33
+import org.openzen.zenscript.codemodel.member.SetterMember;
34
+import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
35
+
36
+/**
37
+ *
38
+ * @author Hoofdgebruiker
39
+ */
40
+public class JavaMappingWriter implements DefinitionVisitor<Void> {
41
+	private final JavaCompiledModule module;
42
+	private final StringBuilder result = new StringBuilder();
43
+	
44
+	public JavaMappingWriter(JavaCompiledModule module) {
45
+		this.module = module;
46
+	}
47
+	
48
+	public String getOutput() {
49
+		return result.toString();
50
+	}
51
+
52
+	@Override
53
+	public Void visitClass(ClassDefinition definition) {
54
+		result.append("class:");
55
+		writeDefinitionDescriptor(definition);
56
+		return null;
57
+	}
58
+
59
+	@Override
60
+	public Void visitInterface(InterfaceDefinition definition) {
61
+		result.append("interface:");
62
+		writeDefinitionDescriptor(definition);
63
+		return null;
64
+	}
65
+
66
+	@Override
67
+	public Void visitEnum(EnumDefinition definition) {
68
+		result.append("enum:");
69
+		writeDefinitionDescriptor(definition);
70
+		return null;
71
+	}
72
+
73
+	@Override
74
+	public Void visitStruct(StructDefinition definition) {
75
+		result.append("struct:");
76
+		writeDefinitionDescriptor(definition);
77
+		return null;
78
+	}
79
+
80
+	@Override
81
+	public Void visitFunction(FunctionDefinition definition) {
82
+		result.append("function:").append(definition.name);
83
+		writeFunctionDescriptor(definition.header);
84
+		return null;
85
+	}
86
+
87
+	@Override
88
+	public Void visitExpansion(ExpansionDefinition definition) {
89
+		result.append("expansion:");
90
+		writeDefinitionDescriptor(definition);
91
+		return null;
92
+	}
93
+
94
+	@Override
95
+	public Void visitAlias(AliasDefinition definition) {
96
+		// aliases don't have mappings
97
+		return null;
98
+	}
99
+
100
+	@Override
101
+	public Void visitVariant(VariantDefinition variant) {
102
+		result.append("variant:");
103
+		writeDefinitionDescriptor(variant);
104
+		return null;
105
+	}
106
+	
107
+	private void writeFunctionDescriptor(FunctionHeader header) {
108
+		result.append(header.getCanonical());
109
+	}
110
+	
111
+	private void writeDefinitionDescriptor(HighLevelDefinition definition) {
112
+		if (definition.name != null)
113
+			result.append(definition.name);
114
+		if (definition.typeParameters.length > 0) {
115
+			result.append('<');
116
+			for (int i = 0; i < definition.typeParameters.length; i++) {
117
+				if (i > 0)
118
+					result.append(',');
119
+				result.append(definition.typeParameters[i].getCanonical());
120
+			}
121
+			result.append('>');
122
+		}
123
+		
124
+		JavaClass definitionClass = definition instanceof ExpansionDefinition
125
+				? module.getExpansionClassInfo(definition)
126
+				: module.getClassInfo(definition);
127
+		if (definitionClass != null) {
128
+			result.append('@').append(definitionClass.internalName);
129
+		}
130
+		result.append('\n');
131
+		
132
+		MemberMappingWriter memberWriter = new MemberMappingWriter(definitionClass);
133
+		for (IDefinitionMember member : definition.members) {
134
+			member.accept(memberWriter);
135
+		}
136
+	}
137
+	
138
+	private class MemberMappingWriter implements MemberVisitor<Void> {
139
+		private final JavaClass definition;
140
+		
141
+		public MemberMappingWriter(JavaClass definition) {
142
+			this.definition = definition;
143
+		}
144
+
145
+		@Override
146
+		public Void visitConst(ConstMember member) {
147
+			JavaField field = module.optFieldInfo(member);
148
+			if (field == null)
149
+				return null;
150
+			
151
+			result.append(":const:");
152
+			result.append(member.name);
153
+			result.append("=");
154
+			result.append(field.getMapping(definition));
155
+			result.append('\n');
156
+			return null;
157
+		}
158
+
159
+		@Override
160
+		public Void visitField(FieldMember member) {
161
+			JavaField field = module.optFieldInfo(member);
162
+			if (field == null)
163
+				return null;
164
+			
165
+			result.append(":field:");
166
+			result.append(member.name);
167
+			result.append("=");
168
+			result.append(field.getMapping(definition));
169
+			result.append('\n');
170
+			return null;
171
+		}
172
+
173
+		@Override
174
+		public Void visitConstructor(ConstructorMember member) {
175
+			JavaMethod method = module.optMethodInfo(member);
176
+			if (method == null)
177
+				return null;
178
+			
179
+			result.append(":constructor:");
180
+			result.append(member.header.getCanonicalWithoutReturnType());
181
+			result.append("=");
182
+			result.append(method.getMapping(definition));
183
+			result.append('\n');
184
+			return null;
185
+		}
186
+
187
+		@Override
188
+		public Void visitDestructor(DestructorMember member) {
189
+			JavaMethod method = module.optMethodInfo(member);
190
+			if (method == null)
191
+				return null;
192
+			
193
+			result.append(":destructor=");
194
+			result.append(method.getMapping(definition));
195
+			result.append('\n');
196
+			return null;
197
+		}
198
+
199
+		@Override
200
+		public Void visitMethod(MethodMember member) {
201
+			JavaMethod method = module.optMethodInfo(member);
202
+			if (method == null)
203
+				return null;
204
+			
205
+			result.append(":method:");
206
+			result.append(member.name);
207
+			result.append(member.header.getCanonical());
208
+			result.append("=");
209
+			result.append(method.getMapping(definition));
210
+			result.append('\n');
211
+			return null;
212
+		}
213
+
214
+		@Override
215
+		public Void visitGetter(GetterMember member) {
216
+			JavaMethod method = module.optMethodInfo(member);
217
+			if (method == null)
218
+				return null;
219
+			
220
+			result.append(":getter:");
221
+			result.append(member.name);
222
+			result.append("=");
223
+			result.append(method.getMapping(definition));
224
+			result.append('\n');
225
+			return null;
226
+		}
227
+
228
+		@Override
229
+		public Void visitSetter(SetterMember member) {
230
+			JavaMethod method = module.optMethodInfo(member);
231
+			if (method == null)
232
+				return null;
233
+			
234
+			result.append(":setter:");
235
+			result.append(member.name);
236
+			result.append("=");
237
+			result.append(method.getMapping(definition));
238
+			result.append('\n');
239
+			return null;
240
+		}
241
+
242
+		@Override
243
+		public Void visitOperator(OperatorMember member) {
244
+			JavaMethod method = module.optMethodInfo(member);
245
+			if (method == null)
246
+				return null;
247
+			
248
+			result.append(":operator:");
249
+			result.append(member.operator.name().toLowerCase());
250
+			result.append(member.header.getCanonical());
251
+			result.append("=");
252
+			result.append(method.getMapping(definition));
253
+			result.append('\n');
254
+			return null;
255
+		}
256
+
257
+		@Override
258
+		public Void visitCaster(CasterMember member) {
259
+			JavaMethod method = module.optMethodInfo(member);
260
+			if (method == null)
261
+				return null;
262
+			
263
+			result.append(":caster:");
264
+			result.append(member.toType.type.toString());
265
+			result.append("=");
266
+			result.append(method.getMapping(definition));
267
+			result.append('\n');
268
+			return null;
269
+		}
270
+
271
+		@Override
272
+		public Void visitCustomIterator(IteratorMember member) {
273
+			return null;
274
+		}
275
+
276
+		@Override
277
+		public Void visitCaller(CallerMember member) {
278
+			JavaMethod method = module.optMethodInfo(member);
279
+			if (method == null)
280
+				return null;
281
+			
282
+			result.append(":caller:");
283
+			result.append(member.header.getCanonical());
284
+			result.append("=");
285
+			result.append(method.getMapping(definition));
286
+			result.append('\n');
287
+			return null;
288
+		}
289
+
290
+		@Override
291
+		public Void visitImplementation(ImplementationMember member) {
292
+			JavaImplementation implementation = module.getImplementationInfo(member);
293
+			return null;
294
+		}
295
+
296
+		@Override
297
+		public Void visitInnerDefinition(InnerDefinitionMember member) {
298
+			return null;
299
+		}
300
+
301
+		@Override
302
+		public Void visitStaticInitializer(StaticInitializerMember member) {
303
+			return null;
304
+		}
305
+	}
306
+}

+ 14
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaMethod.java View File

78
 		this.genericResult = false;
78
 		this.genericResult = false;
79
 	}
79
 	}
80
 	
80
 	
81
+	public String getMapping(JavaClass definition) {
82
+		if (cls == null)
83
+			return "!TODO";
84
+		
85
+		StringBuilder result = new StringBuilder();
86
+		result.append(name);
87
+		result.append(descriptor);
88
+		
89
+		if (definition == null || !definition.internalName.equals(cls.internalName))
90
+			result.append('@').append(cls.internalName);
91
+		
92
+		return result.toString();
93
+	}
94
+	
81
 	public enum Kind {
95
 	public enum Kind {
82
 		STATIC,
96
 		STATIC,
83
 		STATICINIT,
97
 		STATICINIT,

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

11
  *
11
  *
12
  * @author Hoofdgebruiker
12
  * @author Hoofdgebruiker
13
  */
13
  */
14
+@FunctionalInterface
14
 public interface JavaNativeTranslation<T> {
15
 public interface JavaNativeTranslation<T> {
15
-	public T translate(Expression expression, JavaNativeTranslator<T> translator);
16
+	T translate(Expression expression, JavaNativeTranslator<T> translator);
16
 }
17
 }

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

172
 	public final boolean isKeyword;
172
 	public final boolean isKeyword;
173
 	public final boolean multiline;
173
 	public final boolean multiline;
174
 	
174
 	
175
-	private ZSTokenType() {
175
+	ZSTokenType() {
176
 		this.regexp = null;
176
 		this.regexp = null;
177
 		this.whitespace = false;
177
 		this.whitespace = false;
178
 		this.isKeyword = false;
178
 		this.isKeyword = false;
180
 		this.multiline = false;
180
 		this.multiline = false;
181
 	}
181
 	}
182
 	
182
 	
183
-	private ZSTokenType(String regexp) {
183
+	ZSTokenType(String regexp) {
184
 		this.regexp = regexp;
184
 		this.regexp = regexp;
185
 		this.whitespace = false;
185
 		this.whitespace = false;
186
 		this.isKeyword = false;
186
 		this.isKeyword = false;
188
 		this.multiline = false;
188
 		this.multiline = false;
189
 	}
189
 	}
190
 	
190
 	
191
-	private ZSTokenType(String regexp, boolean whitespace) {
191
+	ZSTokenType(String regexp, boolean whitespace) {
192
 		this.regexp = regexp;
192
 		this.regexp = regexp;
193
 		this.whitespace = whitespace;
193
 		this.whitespace = whitespace;
194
 		this.isKeyword = false;
194
 		this.isKeyword = false;
196
 		this.multiline = false;
196
 		this.multiline = false;
197
 	}
197
 	}
198
 	
198
 	
199
-	private ZSTokenType(String regexp, boolean whitespace, boolean multiline) {
199
+	ZSTokenType(String regexp, boolean whitespace, boolean multiline) {
200
 		this.regexp = regexp;
200
 		this.regexp = regexp;
201
 		this.whitespace = whitespace;
201
 		this.whitespace = whitespace;
202
 		this.isKeyword = false;
202
 		this.isKeyword = false;
204
 		this.multiline = multiline;
204
 		this.multiline = multiline;
205
 	}
205
 	}
206
 	
206
 	
207
-	private ZSTokenType(String regexp, String content) {
207
+	ZSTokenType(String regexp, String content) {
208
 		this.regexp = regexp;
208
 		this.regexp = regexp;
209
 		this.whitespace = false;
209
 		this.whitespace = false;
210
 		this.isKeyword = false;
210
 		this.isKeyword = false;
212
 		this.multiline = false;
212
 		this.multiline = false;
213
 	}
213
 	}
214
 	
214
 	
215
-	private ZSTokenType(boolean isWhitespace, String regexp, String content) {
215
+	ZSTokenType(boolean isWhitespace, String regexp, String content) {
216
 		this.regexp = regexp;
216
 		this.regexp = regexp;
217
 		this.whitespace = isWhitespace;
217
 		this.whitespace = isWhitespace;
218
 		this.isKeyword = false;
218
 		this.isKeyword = false;
220
 		this.multiline = false;
220
 		this.multiline = false;
221
 	}
221
 	}
222
 	
222
 	
223
-	private ZSTokenType(boolean isWhitespace, String regexp, String content, boolean multiline) {
223
+	ZSTokenType(boolean isWhitespace, String regexp, String content, boolean multiline) {
224
 		this.regexp = regexp;
224
 		this.regexp = regexp;
225
 		this.whitespace = isWhitespace;
225
 		this.whitespace = isWhitespace;
226
 		this.isKeyword = false;
226
 		this.isKeyword = false;
228
 		this.multiline = multiline;
228
 		this.multiline = multiline;
229
 	}
229
 	}
230
 	
230
 	
231
-	private ZSTokenType(boolean isKeyword, String content) {
231
+	ZSTokenType(boolean isKeyword, String content) {
232
 		this.regexp = null;
232
 		this.regexp = null;
233
 		this.whitespace = false;
233
 		this.whitespace = false;
234
 		this.isKeyword = isKeyword;
234
 		this.isKeyword = isKeyword;

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

47
 		if (typesCompiled)
47
 		if (typesCompiled)
48
 			return;
48
 			return;
49
 		typesCompiled = true;
49
 		typesCompiled = true;
50
-		
51
-		//System.out.println("compileTypes " + getCompiled().name);
50
+
52
 		linkTypesLocal(context);
51
 		linkTypesLocal(context);
53
 	}
52
 	}
54
 	
53
 	
89
 	private class Compiling implements CompilingType {
88
 	private class Compiling implements CompilingType {
90
 		private final TypeResolutionContext context;
89
 		private final TypeResolutionContext context;
91
 		
90
 		
92
-		public Compiling(TypeResolutionContext context) {
91
+		private Compiling(TypeResolutionContext context) {
93
 			this.context = new LocalTypeResolutionContext(context, this, getCompiled().typeParameters);
92
 			this.context = new LocalTypeResolutionContext(context, this, getCompiled().typeParameters);
94
 		}
93
 		}
95
 		
94
 		

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

114
 	private class Compiling implements CompilingType {
114
 	private class Compiling implements CompilingType {
115
 		private final TypeResolutionContext context;
115
 		private final TypeResolutionContext context;
116
 		
116
 		
117
-		public Compiling(TypeResolutionContext context) {
117
+		private Compiling(TypeResolutionContext context) {
118
 			this.context = new LocalTypeResolutionContext(context, this, compiled.typeParameters);
118
 			this.context = new LocalTypeResolutionContext(context, this, compiled.typeParameters);
119
 		}
119
 		}
120
 		
120
 		

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

40
 		
40
 		
41
 		StoredType cType = type.compile(context);
41
 		StoredType cType = type.compile(context);
42
 		Expression cDefaultValue = null;
42
 		Expression cDefaultValue = null;
43
-		return compiled = new FunctionParameter(cType, name, cDefaultValue, variadic);
43
+		return compiled = new FunctionParameter(cType, name, null, variadic);
44
 	}
44
 	}
45
-	
45
+
46
+	// TODO: this isn't called!
46
 	public void compileInitializer(BaseScope scope, PrecompilationState state) {
47
 	public void compileInitializer(BaseScope scope, PrecompilationState state) {
47
 		if (defaultValue != null) {
48
 		if (defaultValue != null) {
48
 			try {
49
 			try {

Loading…
Cancel
Save