Browse Source

- Fixed issues with closeables

- WIP on improving iterable implementations
- Added validation of implementation completeness
- Added definition normalization (now also adds destructors as necessary)
- Fix interfaces with base interfaces
Stan Hebben 6 years ago
parent
commit
0d7459484b
37 changed files with 384 additions and 50 deletions
  1. 5
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  2. 22
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  3. 9
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java
  4. 0
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java
  5. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  6. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  7. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  8. 9
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  9. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  10. 1
    9
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IPropertyMember.java
  11. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  12. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java
  13. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java
  14. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java
  15. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java
  16. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java
  17. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java
  18. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java
  19. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/CasterMemberRef.java
  20. 3
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/DefinitionMemberRef.java
  21. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ImplementationMemberRef.java
  22. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/IteratorMemberRef.java
  23. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/PropertyRef.java
  24. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/ReturnStatement.java
  25. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java
  26. 38
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  27. 19
    5
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java
  28. 1
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaExpansionMemberCompiler.java
  29. 9
    8
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java
  30. 4
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java
  31. 6
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaNativeClass.java
  32. 46
    6
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareClassMethodVisitor.java
  33. 64
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareDefinitionVisitor.java
  34. 14
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareExpansionMethodVisitor.java
  35. 6
    4
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java
  36. 2
    1
      Validator/src/main/java/org/openzen/zenscript/validator/ValidationLogEntry.java
  37. 41
    3
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/DefinitionMemberValidator.java

+ 5
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

80
 		hasUnknowns = hasUnknowns(parameters, returnType);
80
 		hasUnknowns = hasUnknowns(parameters, returnType);
81
 	}
81
 	}
82
 	
82
 	
83
-	public FunctionHeader(TypeParameter[] genericParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
83
+	public FunctionHeader(TypeParameter[] typeParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
84
 		if (returnType == null)
84
 		if (returnType == null)
85
 			throw new NullPointerException();
85
 			throw new NullPointerException();
86
-		if (genericParameters == null)
86
+		if (typeParameters == null)
87
 			throw new NullPointerException();
87
 			throw new NullPointerException();
88
 		
88
 		
89
-		this.typeParameters = genericParameters;
89
+		this.typeParameters = typeParameters;
90
 		this.returnType = returnType;
90
 		this.returnType = returnType;
91
 		this.parameters = parameters;
91
 		this.parameters = parameters;
92
 		this.thrownType = thrownType;
92
 		this.thrownType = thrownType;
250
 	}
250
 	}
251
 	
251
 	
252
 	public boolean canOverride(TypeScope scope, FunctionHeader other) {
252
 	public boolean canOverride(TypeScope scope, FunctionHeader other) {
253
+		if (other == null)
254
+			throw new NullPointerException();
253
 		if (parameters.length != other.parameters.length)
255
 		if (parameters.length != other.parameters.length)
254
 			return false;
256
 			return false;
255
 		if (returnType != BasicTypeID.UNDETERMINED && !scope.getTypeMembers(returnType).canCastImplicit(other.returnType))
257
 		if (returnType != BasicTypeID.UNDETERMINED && !scope.getTypeMembers(returnType).canCastImplicit(other.returnType))

+ 22
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java View File

12
 import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
12
 import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
13
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
13
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
14
 import org.openzen.zenscript.codemodel.definition.DefinitionVisitor;
14
 import org.openzen.zenscript.codemodel.definition.DefinitionVisitor;
15
+import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
15
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
16
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
16
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
17
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
17
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
18
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
141
 	}
142
 	}
142
 	
143
 	
143
 	public void normalize(TypeScope scope) {
144
 	public void normalize(TypeScope scope) {
145
+		DestructorMember destructor = null;
146
+		List<FieldMember> fields = new ArrayList();
147
+		
144
 		for (IDefinitionMember member : members) {
148
 		for (IDefinitionMember member : members) {
145
 			member.normalize(scope);
149
 			member.normalize(scope);
150
+			
151
+			if (member instanceof DestructorMember)
152
+				destructor = (DestructorMember)member;
153
+			if (member instanceof FieldMember)
154
+				fields.add((FieldMember)member);
155
+		}
156
+		
157
+		if (isDestructible() && destructor == null && !(this instanceof ExpansionDefinition)) {
158
+			System.out.println("Added destructor to " + position);
159
+			destructor = new DestructorMember(position, this, Modifiers.PUBLIC);
160
+			members.add(destructor);
161
+		}
162
+		
163
+		for (FieldMember field : fields) {
164
+			if (field.autoGetter != null)
165
+				members.add(field.autoGetter);
166
+			if (field.autoSetter != null)
167
+				members.add(field.autoSetter);
146
 		}
168
 		}
147
 	}
169
 	}
148
 	
170
 	

+ 9
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java View File

26
 		baseInterfaces.add(baseInterface);
26
 		baseInterfaces.add(baseInterface);
27
 	}
27
 	}
28
 	
28
 	
29
+	@Override
30
+	public boolean isDestructible() {
31
+		for (ITypeID baseInterface : baseInterfaces)
32
+			if (baseInterface.isDestructible())
33
+				return true;
34
+		
35
+		return super.isDestructible();
36
+	}
37
+	
29
 	@Override
38
 	@Override
30
 	public boolean isStatic() {
39
 	public boolean isStatic() {
31
 		return true;
40
 		return true;

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

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

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

63
 		type = type.getNormalized();
63
 		type = type.getNormalized();
64
 		value = value.normalize(scope);
64
 		value = value.normalize(scope);
65
 	}
65
 	}
66
+
67
+	@Override
68
+	public boolean isAbstract() {
69
+		return false;
70
+	}
66
 }
71
 }

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

147
 		if (initializer != null)
147
 		if (initializer != null)
148
 			initializer = initializer.normalize(scope);
148
 			initializer = initializer.normalize(scope);
149
 	}
149
 	}
150
+
151
+	@Override
152
+	public boolean isAbstract() {
153
+		return false;
154
+	}
150
 }
155
 }

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

60
 		if (body != null)
60
 		if (body != null)
61
 			body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
61
 			body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
62
 	}
62
 	}
63
+	
64
+	@Override
65
+	public boolean isAbstract() {
66
+		return body == null && builtin == null;
67
+	}
63
 }
68
 }

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

10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
12
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
13
+import org.openzen.zenscript.codemodel.statement.Statement;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
38
 		this.type = type;
39
 		this.type = type;
39
 	}
40
 	}
40
 	
41
 	
42
+	@Override
43
+	public void setBody(Statement body) {
44
+		super.setBody(body);
45
+		
46
+		if (type == BasicTypeID.UNDETERMINED)
47
+			type = body.getReturnType();
48
+	}
49
+	
41
 	@Override
50
 	@Override
42
 	public ITypeID getType() {
51
 	public ITypeID getType() {
43
 		return type;
52
 		return type;

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

38
 	DefinitionMemberRef getOverrides();
38
 	DefinitionMemberRef getOverrides();
39
 
39
 
40
 	public void normalize(TypeScope scope);
40
 	public void normalize(TypeScope scope);
41
+	
42
+	boolean isAbstract();
41
 }
43
 }

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

5
  */
5
  */
6
 package org.openzen.zenscript.codemodel.member;
6
 package org.openzen.zenscript.codemodel.member;
7
 
7
 
8
-import org.openzen.zencode.shared.CodePosition;
9
-import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
8
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
 import org.openzen.zenscript.codemodel.type.ITypeID;
9
 import org.openzen.zenscript.codemodel.type.ITypeID;
12
 
10
 
14
  *
12
  *
15
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
16
  */
14
  */
17
-public interface IPropertyMember {
15
+public interface IPropertyMember extends IDefinitionMember {
18
 	ITypeID getType();
16
 	ITypeID getType();
19
 	
17
 	
20
-	CodePosition getPosition();
21
-	
22
-	String describe();
23
-
24
-	<T> T getTag(Class<T> type);
25
-	
26
 	boolean isStatic();
18
 	boolean isStatic();
27
 	
19
 	
28
 	boolean isFinal();
20
 	boolean isFinal();

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

70
 		for (IDefinitionMember member : members)
70
 		for (IDefinitionMember member : members)
71
 			member.normalize(scope);
71
 			member.normalize(scope);
72
 	}
72
 	}
73
+
74
+	@Override
75
+	public boolean isAbstract() {
76
+		return false;
77
+	}
73
 }
78
 }

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

63
 	public void normalize(TypeScope scope) {
63
 	public void normalize(TypeScope scope) {
64
 		innerDefinition.normalize(scope);
64
 		innerDefinition.normalize(scope);
65
 	}
65
 	}
66
+
67
+	@Override
68
+	public boolean isAbstract() {
69
+		return false;
70
+	}
66
 }
71
 }

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

65
 	public void normalize(TypeScope scope) {
65
 	public void normalize(TypeScope scope) {
66
 		body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
66
 		body = body.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class));
67
 	}
67
 	}
68
+
69
+	@Override
70
+	public boolean isAbstract() {
71
+		return false;
72
+	}
68
 }
73
 }

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

87
 	public void normalize(TypeScope scope) {
87
 	public void normalize(TypeScope scope) {
88
 		
88
 		
89
 	}
89
 	}
90
+
91
+	@Override
92
+	public boolean isAbstract() {
93
+		return false;
94
+	}
90
 }
95
 }

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

82
 	public void normalize(TypeScope scope) {
82
 	public void normalize(TypeScope scope) {
83
 		
83
 		
84
 	}
84
 	}
85
+
86
+	@Override
87
+	public boolean isAbstract() {
88
+		return false;
89
+	}
85
 }
90
 }

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

85
 	public void normalize(TypeScope scope) {
85
 	public void normalize(TypeScope scope) {
86
 		
86
 		
87
 	}
87
 	}
88
+
89
+	@Override
90
+	public boolean isAbstract() {
91
+		return false;
92
+	}
88
 }
93
 }

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

93
 	public void normalize(TypeScope scope) {
93
 	public void normalize(TypeScope scope) {
94
 		
94
 		
95
 	}
95
 	}
96
+
97
+	@Override
98
+	public boolean isAbstract() {
99
+		return false;
100
+	}
96
 }
101
 }

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

76
 	public void normalize(TypeScope scope) {
76
 	public void normalize(TypeScope scope) {
77
 		
77
 		
78
 	}
78
 	}
79
+
80
+	@Override
81
+	public boolean isAbstract() {
82
+		return false;
83
+	}
79
 }
84
 }

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

12
 import org.openzen.zenscript.codemodel.expression.CastExpression;
12
 import org.openzen.zenscript.codemodel.expression.CastExpression;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
13
 import org.openzen.zenscript.codemodel.expression.Expression;
14
 import org.openzen.zenscript.codemodel.member.CasterMember;
14
 import org.openzen.zenscript.codemodel.member.CasterMember;
15
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 
17
 
17
 /**
18
 /**
64
 	public MemberAnnotation[] getAnnotations() {
65
 	public MemberAnnotation[] getAnnotations() {
65
 		return member.annotations;
66
 		return member.annotations;
66
 	}
67
 	}
68
+
69
+	@Override
70
+	public IDefinitionMember getTarget() {
71
+		return member;
72
+	}
67
 }
73
 }

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

8
 import org.openzen.zencode.shared.CodePosition;
8
 import org.openzen.zencode.shared.CodePosition;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
11
 
12
 
12
 /**
13
 /**
13
  *
14
  *
25
 	FunctionHeader getHeader();
26
 	FunctionHeader getHeader();
26
 	
27
 	
27
 	MemberAnnotation[] getAnnotations();
28
 	MemberAnnotation[] getAnnotations();
29
+	
30
+	IDefinitionMember getTarget();
28
 }
31
 }

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

8
 import org.openzen.zencode.shared.CodePosition;
8
 import org.openzen.zencode.shared.CodePosition;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
11
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
12
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
12
 import org.openzen.zenscript.codemodel.type.ITypeID;
13
 import org.openzen.zenscript.codemodel.type.ITypeID;
13
 
14
 
53
 	public MemberAnnotation[] getAnnotations() {
54
 	public MemberAnnotation[] getAnnotations() {
54
 		return member.annotations;
55
 		return member.annotations;
55
 	}
56
 	}
57
+
58
+	@Override
59
+	public IDefinitionMember getTarget() {
60
+		return member;
61
+	}
56
 }
62
 }

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

9
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
 import org.openzen.zenscript.codemodel.member.CustomIteratorMember;
11
 import org.openzen.zenscript.codemodel.member.CustomIteratorMember;
12
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
14
 
15
 
62
 			return null;
63
 			return null;
63
 		}
64
 		}
64
 	}
65
 	}
66
+
67
+	@Override
68
+	public IDefinitionMember getTarget() {
69
+		return target;
70
+	}
65
 }
71
 }

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

9
 import org.openzen.zenscript.codemodel.FunctionHeader;
9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
10
 import org.openzen.zenscript.codemodel.GenericMapper;
11
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
12
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
12
 import org.openzen.zenscript.codemodel.member.IPropertyMember;
13
 import org.openzen.zenscript.codemodel.member.IPropertyMember;
13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
79
 	public final MemberAnnotation[] getAnnotations() {
80
 	public final MemberAnnotation[] getAnnotations() {
80
 		return member.getAnnotations();
81
 		return member.getAnnotations();
81
 	}
82
 	}
83
+	
84
+	@Override
85
+	public final IDefinitionMember getTarget() {
86
+		return member;
87
+	}
82
 }
88
 }

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/ReturnStatement.java View File

48
 
48
 
49
 	@Override
49
 	@Override
50
 	public Statement transform(StatementTransformer transformer, ConcatMap<LoopStatement, LoopStatement> modified) {
50
 	public Statement transform(StatementTransformer transformer, ConcatMap<LoopStatement, LoopStatement> modified) {
51
-		Expression tValue = value.transform(transformer);
51
+		Expression tValue = value == null ? null : value.transform(transformer);
52
 		return tValue == value ? this : new ReturnStatement(position, tValue);
52
 		return tValue == value ? this : new ReturnStatement(position, tValue);
53
 	}
53
 	}
54
 
54
 
55
 	@Override
55
 	@Override
56
 	public Statement transform(ExpressionTransformer transformer, ConcatMap<LoopStatement, LoopStatement> modified) {
56
 	public Statement transform(ExpressionTransformer transformer, ConcatMap<LoopStatement, LoopStatement> modified) {
57
-		Expression tValue = value.transform(transformer);
57
+		Expression tValue = value == null ? null : value.transform(transformer);
58
 		return tValue == value ? this : new ReturnStatement(position, tValue);
58
 		return tValue == value ? this : new ReturnStatement(position, tValue);
59
 	}
59
 	}
60
 
60
 
61
 	@Override
61
 	@Override
62
 	public Statement normalize(TypeScope scope, ConcatMap<LoopStatement, LoopStatement> modified) {
62
 	public Statement normalize(TypeScope scope, ConcatMap<LoopStatement, LoopStatement> modified) {
63
-		return new ReturnStatement(position, value.normalize(scope));
63
+		return new ReturnStatement(position, value == null ? null : value.normalize(scope));
64
 	}
64
 	}
65
 }
65
 }

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

264
 				for (ITypeID resultHint : typeHints) {
264
 				for (ITypeID resultHint : typeHints) {
265
 					Map<TypeParameter, ITypeID> mapping = new HashMap<>();
265
 					Map<TypeParameter, ITypeID> mapping = new HashMap<>();
266
 					if (header.returnType.inferTypeParameters(scope.getMemberCache(), resultHint, mapping)) {
266
 					if (header.returnType.inferTypeParameters(scope.getMemberCache(), resultHint, mapping)) {
267
-						header = header.withGenericArguments(new GenericMapper(scope.getTypeRegistry(), mapping));
267
+						header = header.withGenericArguments(scope.getLocalTypeParameters().getInner(mapping));
268
 						break;
268
 						break;
269
 					}
269
 					}
270
 				}
270
 				}

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

9
 import java.util.HashMap;
9
 import java.util.HashMap;
10
 import java.util.List;
10
 import java.util.List;
11
 import java.util.Map;
11
 import java.util.Map;
12
+import java.util.Set;
12
 import org.openzen.zencode.shared.CodePosition;
13
 import org.openzen.zencode.shared.CodePosition;
13
 import org.openzen.zencode.shared.CompileException;
14
 import org.openzen.zencode.shared.CompileException;
14
 import org.openzen.zencode.shared.CompileExceptionCode;
15
 import org.openzen.zencode.shared.CompileExceptionCode;
23
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
24
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
24
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
25
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
25
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
26
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
27
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
26
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
28
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
27
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
29
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
28
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
30
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
142
 		return null;
144
 		return null;
143
 	}
145
 	}
144
 	
146
 	
147
+	public List<IDefinitionMember> getUnimplementedMembers(Set<IDefinitionMember> implemented) {
148
+		List<IDefinitionMember> result = new ArrayList<>();
149
+		for (TypeMember<CasterMemberRef> caster : casters) {
150
+			if (caster.member.member.isAbstract() && !implemented.contains(caster.member.member))
151
+				result.add(caster.member.member);
152
+		}
153
+		for (TypeMember<IteratorMemberRef> iterator : iterators) {
154
+			if (iterator.member.target.isAbstract() && !implemented.contains(iterator.member.target))
155
+				result.add(iterator.member.target);
156
+		}
157
+		for (Map.Entry<String, DefinitionMemberGroup> entry : members.entrySet()) {
158
+			DefinitionMemberGroup group = entry.getValue();
159
+			if (group.getGetter() != null && group.getGetter().member.isAbstract() && !implemented.contains(group.getGetter().member))
160
+				result.add(group.getGetter().member);
161
+			if (group.getSetter() != null && group.getSetter().member.isAbstract() && !implemented.contains(group.getSetter().member))
162
+				result.add(group.getSetter().member);
163
+			for (TypeMember<FunctionalMemberRef> member : group.getMethodMembers())
164
+				if (member.member.getTarget().isAbstract() && !implemented.contains(member.member.getTarget()))
165
+					result.add(member.member.getTarget());
166
+		}
167
+		for (Map.Entry<OperatorType, DefinitionMemberGroup> entry : operators.entrySet()) {
168
+			if (entry.getKey() == OperatorType.DESTRUCTOR)
169
+				continue; // destructor doesn't have to be implemented; the compiler can do so automatically
170
+			
171
+			DefinitionMemberGroup group = entry.getValue();
172
+			if (group.getGetter() != null && group.getGetter().member.isAbstract() && !implemented.contains(group.getGetter().member))
173
+				result.add(group.getGetter().member);
174
+			if (group.getSetter() != null && group.getSetter().member.isAbstract() && !implemented.contains(group.getSetter().member))
175
+				result.add(group.getSetter().member);
176
+			for (TypeMember<FunctionalMemberRef> member : group.getMethodMembers())
177
+				if (member.member.getTarget().isAbstract() && !implemented.contains(member.member.getTarget()))
178
+					result.add(member.member.getTarget());
179
+		}
180
+		return result;
181
+	}
182
+	
145
 	public void addConstructor(FunctionalMemberRef constructor, TypeMemberPriority priority) {
183
 	public void addConstructor(FunctionalMemberRef constructor, TypeMemberPriority priority) {
146
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, priority);
184
 		getOrCreateGroup(OperatorType.CONSTRUCTOR).addMethod(constructor, priority);
147
 	}
185
 	}

+ 19
- 5
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java View File

82
 	@Override
82
 	@Override
83
 	public Void visitClass(ClassDefinition definition) {
83
 	public Void visitClass(ClassDefinition definition) {
84
 		JavaSourceFileScope scope = createScope(definition);
84
 		JavaSourceFileScope scope = createScope(definition);
85
+		JavaSourceClass cls = definition.getTag(JavaSourceClass.class);
85
 		
86
 		
86
 		output.append(indent);
87
 		output.append(indent);
87
 		convertModifiers(definition.modifiers);
88
 		convertModifiers(definition.modifiers);
88
-		output.append("class ").append(definition.name);
89
+		output.append("class ").append(cls.getName());
89
 		JavaSourceUtils.formatTypeParameters(scope.typeVisitor, output, definition.genericParameters, false);
90
 		JavaSourceUtils.formatTypeParameters(scope.typeVisitor, output, definition.genericParameters, false);
90
 		if (definition.getSuperType() != null) {
91
 		if (definition.getSuperType() != null) {
91
 			output.append(" extends ");
92
 			output.append(" extends ");
99
 			}
100
 			}
100
 		}
101
 		}
101
 		
102
 		
102
-		if (mergedImplementations.size() > 0 || definition.isDestructible()) {
103
+		if (mergedImplementations.size() > 0 || cls.destructible) {
103
 			output.append(" implements ");
104
 			output.append(" implements ");
104
 			boolean first = true;
105
 			boolean first = true;
105
 			for (int i = 0; i < mergedImplementations.size(); i++) {
106
 			for (int i = 0; i < mergedImplementations.size(); i++) {
112
 				output.append(scope.type(implementation.type));
113
 				output.append(scope.type(implementation.type));
113
 			}
114
 			}
114
 			
115
 			
115
-			if (definition.isDestructible()) {
116
+			if (cls.destructible) {
116
 				if (first)
117
 				if (first)
117
 					first = false;
118
 					first = false;
118
 				else
119
 				else
132
 	@Override
133
 	@Override
133
 	public Void visitInterface(InterfaceDefinition definition) {
134
 	public Void visitInterface(InterfaceDefinition definition) {
134
 		JavaSourceFileScope scope = createScope(definition);
135
 		JavaSourceFileScope scope = createScope(definition);
136
+		JavaSourceClass cls = definition.getTag(JavaSourceClass.class);
135
 		
137
 		
136
 		output.append(indent);
138
 		output.append(indent);
137
 		convertModifiers(definition.modifiers | Modifiers.VIRTUAL); // to prevent 'final'
139
 		convertModifiers(definition.modifiers | Modifiers.VIRTUAL); // to prevent 'final'
138
-		output.append("interface ").append(definition.name);
140
+		output.append("interface ").append(cls.getName());
139
 		JavaSourceUtils.formatTypeParameters(scope.typeVisitor, output, definition.genericParameters, false);
141
 		JavaSourceUtils.formatTypeParameters(scope.typeVisitor, output, definition.genericParameters, false);
140
-			
142
+		
143
+		boolean firstExtends = true;
141
 		if (definition.isDestructible()) {
144
 		if (definition.isDestructible()) {
142
 			output.append(" extends ");
145
 			output.append(" extends ");
143
 			output.append(scope.importer.importType(new JavaSourceClass("java.lang", "AutoCloseable")));
146
 			output.append(scope.importer.importType(new JavaSourceClass("java.lang", "AutoCloseable")));
147
+			firstExtends = false;
148
+		}
149
+		
150
+		for (ITypeID base : definition.baseInterfaces) {
151
+			if (firstExtends) {
152
+				firstExtends = false;
153
+				output.append(" extends ");
154
+			} else {
155
+				output.append(", ");
156
+			}
157
+			output.append(scope.type(base));
144
 		}
158
 		}
145
 		
159
 		
146
 		output.append(" {\n");
160
 		output.append(" {\n");

+ 1
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaExpansionMemberCompiler.java View File

129
 
129
 
130
 	@Override
130
 	@Override
131
 	public Void visitDestructor(DestructorMember member) {
131
 	public Void visitDestructor(DestructorMember member) {
132
-		throw new UnsupportedOperationException("Expansions cannot declare destructors");
132
+		return null; // ignore
133
 	}
133
 	}
134
 
134
 
135
 	@Override
135
 	@Override

+ 9
- 8
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java View File

13
 import org.openzen.zenscript.codemodel.FunctionParameter;
13
 import org.openzen.zenscript.codemodel.FunctionParameter;
14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15
 import org.openzen.zenscript.codemodel.Modifiers;
15
 import org.openzen.zenscript.codemodel.Modifiers;
16
+import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
16
 import org.openzen.zenscript.codemodel.member.CallerMember;
17
 import org.openzen.zenscript.codemodel.member.CallerMember;
17
 import org.openzen.zenscript.codemodel.member.CasterMember;
18
 import org.openzen.zenscript.codemodel.member.CasterMember;
18
 import org.openzen.zenscript.codemodel.member.ConstMember;
19
 import org.openzen.zenscript.codemodel.member.ConstMember;
29
 import org.openzen.zenscript.codemodel.member.OperatorMember;
30
 import org.openzen.zenscript.codemodel.member.OperatorMember;
30
 import org.openzen.zenscript.codemodel.member.SetterMember;
31
 import org.openzen.zenscript.codemodel.member.SetterMember;
31
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
32
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
33
+import org.openzen.zenscript.codemodel.statement.BlockStatement;
32
 import org.openzen.zenscript.codemodel.statement.EmptyStatement;
34
 import org.openzen.zenscript.codemodel.statement.EmptyStatement;
33
 import org.openzen.zenscript.codemodel.statement.Statement;
35
 import org.openzen.zenscript.codemodel.statement.Statement;
34
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
36
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
166
 		
168
 		
167
 		output.append(indent).append("@Override\n");
169
 		output.append(indent).append("@Override\n");
168
 		output.append(indent).append("public void close()");
170
 		output.append(indent).append("public void close()");
169
-		compileBody(member.body, member.header);
171
+		
172
+		Statement body = member.body;
173
+		if ((body == null || body instanceof EmptyStatement) && !(definition instanceof InterfaceDefinition))
174
+			body = new BlockStatement(member.position, Collections.emptyList());
175
+		
176
+		compileBody(body, member.header);
170
 		return null;
177
 		return null;
171
 	}
178
 	}
172
 
179
 
263
 	}
270
 	}
264
 	
271
 	
265
 	public void finish() {
272
 	public void finish() {
266
-		// TODO: needs to be moved elsewhere (normalization stage?)
267
-		for (FieldMember field : fields) {
268
-			if (field.autoGetter != null)
269
-				visitGetter(field.autoGetter);
270
-			if (field.autoSetter != null)
271
-				visitSetter(field.autoSetter);
272
-		}
273
+		
273
 	}
274
 	}
274
 }
275
 }

+ 4
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java View File

1680
 					throw new UnsupportedOperationException("Not yet supported!");
1680
 					throw new UnsupportedOperationException("Not yet supported!");
1681
 				}
1681
 				}
1682
 			}
1682
 			}
1683
-			case ARRAY_CONSTRUCTOR_PROJECTED_INDEXED:
1683
+			case ARRAY_CONSTRUCTOR_PROJECTED_INDEXED: {
1684
 				ArrayTypeID type = (ArrayTypeID) expression.type;
1684
 				ArrayTypeID type = (ArrayTypeID) expression.type;
1685
 				
1685
 				
1686
 				if (type.dimension == 1) {
1686
 				if (type.dimension == 1) {
1759
 					// TODO: implement
1759
 					// TODO: implement
1760
 					throw new UnsupportedOperationException("Not yet supported!");
1760
 					throw new UnsupportedOperationException("Not yet supported!");
1761
 				}
1761
 				}
1762
+			}
1763
+			case CLASS_DEFAULT_CONSTRUCTOR:
1764
+				return new ExpressionString("new " + scope.type(expression.type) + "()", JavaOperator.NEW);
1762
 		}
1765
 		}
1763
 		
1766
 		
1764
 		throw new UnsupportedOperationException("Unknown builtin constructor: " + expression.constructor.getBuiltin());
1767
 		throw new UnsupportedOperationException("Unknown builtin constructor: " + expression.constructor.getBuiltin());

+ 6
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaNativeClass.java View File

17
 public class JavaNativeClass {
17
 public class JavaNativeClass {
18
 	public final JavaSourceClass cls;
18
 	public final JavaSourceClass cls;
19
 	private final Map<String, JavaSourceMethod> methods = new HashMap<>();
19
 	private final Map<String, JavaSourceMethod> methods = new HashMap<>();
20
+	public final boolean nonDestructible;
20
 	
21
 	
21
 	public JavaNativeClass(JavaSourceClass cls) {
22
 	public JavaNativeClass(JavaSourceClass cls) {
23
+		this(cls, false);
24
+	}
25
+	
26
+	public JavaNativeClass(JavaSourceClass cls, boolean nonDestructible) {
22
 		this.cls = cls;
27
 		this.cls = cls;
28
+		this.nonDestructible = nonDestructible;
23
 	}
29
 	}
24
 	
30
 	
25
 	public void addMethod(String key, JavaSourceMethod method) {
31
 	public void addMethod(String key, JavaSourceMethod method) {

+ 46
- 6
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareClassMethodVisitor.java View File

25
 import org.openzen.zenscript.codemodel.member.OperatorMember;
25
 import org.openzen.zenscript.codemodel.member.OperatorMember;
26
 import org.openzen.zenscript.codemodel.member.SetterMember;
26
 import org.openzen.zenscript.codemodel.member.SetterMember;
27
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
27
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
28
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
28
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
29
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
29
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
30
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
30
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
31
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
36
  * @author Hoofdgebruiker
37
  * @author Hoofdgebruiker
37
  */
38
  */
38
 public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void> {
39
 public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void> {
40
+	private static final boolean DEBUG_EMPTY = true;
41
+	
42
+	private final JavaSourcePrepareDefinitionVisitor definitionPreparer;
39
 	private final String filename;
43
 	private final String filename;
40
 	private final JavaSourceClass cls;
44
 	private final JavaSourceClass cls;
41
 	private final JavaNativeClass nativeClass;
45
 	private final JavaNativeClass nativeClass;
42
 	
46
 	
43
-	public JavaSourcePrepareClassMethodVisitor(String filename, JavaSourceClass cls, JavaNativeClass nativeClass, boolean startsEmpty) {
47
+	public JavaSourcePrepareClassMethodVisitor(
48
+			JavaSourcePrepareDefinitionVisitor definitionPreparer,
49
+			String filename,
50
+			JavaSourceClass cls,
51
+			JavaNativeClass nativeClass,
52
+			boolean startsEmpty) {
53
+		this.definitionPreparer = definitionPreparer;
44
 		this.filename = filename;
54
 		this.filename = filename;
45
 		this.cls = cls;
55
 		this.cls = cls;
46
 		this.nativeClass = nativeClass;
56
 		this.nativeClass = nativeClass;
57
+		
47
 		cls.empty = startsEmpty;
58
 		cls.empty = startsEmpty;
48
 	}
59
 	}
49
 	
60
 	
50
 	@Override
61
 	@Override
51
 	public Void visitConst(ConstMember member) {
62
 	public Void visitConst(ConstMember member) {
63
+		if (DEBUG_EMPTY && cls.empty)
64
+			System.out.println("Class " + cls.fullName + " not empty because of const " + member.name);
65
+		
52
 		cls.empty = false;
66
 		cls.empty = false;
53
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
67
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
54
 		return null;
68
 		return null;
56
 	
70
 	
57
 	@Override
71
 	@Override
58
 	public Void visitField(FieldMember member) {
72
 	public Void visitField(FieldMember member) {
59
-		cls.empty = false;
60
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
73
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
61
 		if (member.hasAutoGetter())
74
 		if (member.hasAutoGetter())
62
 			visitGetter(member.autoGetter);
75
 			visitGetter(member.autoGetter);
74
 
87
 
75
 	@Override
88
 	@Override
76
 	public Void visitDestructor(DestructorMember member) {
89
 	public Void visitDestructor(DestructorMember member) {
90
+		if (DEBUG_EMPTY && cls.empty)
91
+			System.out.println("Class " + cls.fullName + " not empty because of destructor");
92
+		
77
 		cls.empty = false;
93
 		cls.empty = false;
78
 		return null;
94
 		return null;
79
 	}
95
 	}
122
 
138
 
123
 	@Override
139
 	@Override
124
 	public Void visitImplementation(ImplementationMember member) {
140
 	public Void visitImplementation(ImplementationMember member) {
125
-		cls.empty = false;
141
+		definitionPreparer.prepare(member.type);
142
+		
126
 		if (canMergeImplementation(member)) {
143
 		if (canMergeImplementation(member)) {
127
 			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(true, cls));
144
 			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(true, cls));
128
 			for (IDefinitionMember m : member.members)
145
 			for (IDefinitionMember m : member.members)
129
 				m.accept(this);
146
 				m.accept(this);
130
 		} else {
147
 		} else {
148
+			if (DEBUG_EMPTY && cls.empty)
149
+				System.out.println("Class " + cls.fullName + " not empty because of unmergeable implementation");
150
+			
151
+			cls.empty = false;
152
+			
131
 			JavaSourceClass implementationClass = new JavaSourceClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
153
 			JavaSourceClass implementationClass = new JavaSourceClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
132
 			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
154
 			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
133
 			
155
 			
134
-			JavaSourcePrepareClassMethodVisitor visitor = new JavaSourcePrepareClassMethodVisitor(filename, implementationClass, null, true);
156
+			JavaSourcePrepareClassMethodVisitor visitor = new JavaSourcePrepareClassMethodVisitor(definitionPreparer, filename, implementationClass, null, true);
135
 			for (IDefinitionMember m : member.members)
157
 			for (IDefinitionMember m : member.members)
136
 				m.accept(visitor);
158
 				m.accept(visitor);
137
 		}
159
 		}
147
 		JavaSourcePrepareDefinitionVisitor innerDefinitionPrepare = new JavaSourcePrepareDefinitionVisitor(filename, cls);
169
 		JavaSourcePrepareDefinitionVisitor innerDefinitionPrepare = new JavaSourcePrepareDefinitionVisitor(filename, cls);
148
 		member.innerDefinition.accept(innerDefinitionPrepare);
170
 		member.innerDefinition.accept(innerDefinitionPrepare);
149
 		
171
 		
172
+		if (DEBUG_EMPTY && cls.empty)
173
+			System.out.println("Class " + cls.fullName + " not empty because of inner definition " + member.innerDefinition.name);
150
 		cls.empty = false;
174
 		cls.empty = false;
151
 		return null;
175
 		return null;
152
 	}
176
 	}
153
 
177
 
154
 	@Override
178
 	@Override
155
 	public Void visitStaticInitializer(StaticInitializerMember member) {
179
 	public Void visitStaticInitializer(StaticInitializerMember member) {
180
+		if (DEBUG_EMPTY && cls.empty)
181
+			System.out.println("Class " + cls.fullName + " not empty because of static initializer");
182
+		
156
 		cls.empty = false;
183
 		cls.empty = false;
157
 		return null;
184
 		return null;
158
 	}
185
 	}
252
 		JavaSourceMethod method = null;
279
 		JavaSourceMethod method = null;
253
 		if (nativeTag != null && nativeClass != null)
280
 		if (nativeTag != null && nativeClass != null)
254
 			method = nativeClass.getMethod(nativeTag.value);
281
 			method = nativeClass.getMethod(nativeTag.value);
255
-		if (method == null)
282
+		
283
+		if (member.getOverrides() != null) {
284
+			DefinitionMemberRef base = member.getOverrides();
285
+			JavaSourceMethod baseMethod = base.getTarget().getTag(JavaSourceMethod.class);
286
+			if (baseMethod == null)
287
+				throw new IllegalStateException("Base method not yet prepared!");
288
+			
289
+			method = new JavaSourceMethod(cls, baseMethod.kind, baseMethod.name, true);
290
+		} else if (method == null) {
256
 			method = new JavaSourceMethod(cls, getKind(member), name, true);
291
 			method = new JavaSourceMethod(cls, getKind(member), name, true);
292
+		}
257
 		
293
 		
258
-		if (method.compile)
294
+		if (method.compile) {
295
+			if (DEBUG_EMPTY && cls.empty)
296
+				System.out.println("Class " + cls.fullName + " not empty because of " + member.describe());
297
+			
259
 			cls.empty = false;
298
 			cls.empty = false;
299
+		}
260
 		
300
 		
261
 		member.setTag(JavaSourceMethod.class, method);
301
 		member.setTag(JavaSourceMethod.class, method);
262
 	}
302
 	}

+ 64
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareDefinitionVisitor.java View File

22
 import org.openzen.zenscript.codemodel.expression.CastExpression;
22
 import org.openzen.zenscript.codemodel.expression.CastExpression;
23
 import org.openzen.zenscript.codemodel.expression.Expression;
23
 import org.openzen.zenscript.codemodel.expression.Expression;
24
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
24
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25
+import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
26
+import org.openzen.zenscript.codemodel.type.ITypeID;
25
 import org.openzen.zenscript.formattershared.ExpressionString;
27
 import org.openzen.zenscript.formattershared.ExpressionString;
26
 import org.openzen.zenscript.javasource.JavaOperator;
28
 import org.openzen.zenscript.javasource.JavaOperator;
27
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
29
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
68
 			list.addInstanceMethod("insert", "add");
70
 			list.addInstanceMethod("insert", "add");
69
 			list.addInstanceMethod("remove", "remove");
71
 			list.addInstanceMethod("remove", "remove");
70
 			list.addInstanceMethod("indexOf", "indexOf");
72
 			list.addInstanceMethod("indexOf", "indexOf");
73
+			list.addInstanceMethod("lastIndexOf", "lastIndexOf");
71
 			list.addInstanceMethod("getAtIndex", "get");
74
 			list.addInstanceMethod("getAtIndex", "get");
72
 			list.addInstanceMethod("setAtIndex", "set");
75
 			list.addInstanceMethod("setAtIndex", "set");
73
 			list.addInstanceMethod("contains", "contains");
76
 			list.addInstanceMethod("contains", "contains");
74
 			list.addMethod("toArray", new JavaSourceMethod((formatter, call) -> formatter.listToArray((CastExpression)call)));
77
 			list.addMethod("toArray", new JavaSourceMethod((formatter, call) -> formatter.listToArray((CastExpression)call)));
75
-			list.addInstanceMethod("length", "length");
78
+			list.addInstanceMethod("length", "size");
76
 			list.addInstanceMethod("isEmpty", "isEmpty");
79
 			list.addInstanceMethod("isEmpty", "isEmpty");
80
+			list.addInstanceMethod("iterate", "iterator");
77
 			nativeClasses.put("stdlib::List", list);
81
 			nativeClasses.put("stdlib::List", list);
78
 		}
82
 		}
79
 		
83
 		
84
+		{
85
+			JavaNativeClass iterable = new JavaNativeClass(new JavaSourceClass("java.lang", "Iterable"));
86
+			iterable.addInstanceMethod("iterate", "iterator");
87
+			nativeClasses.put("stdlib::Iterable", iterable);
88
+		}
89
+		
90
+		{
91
+			JavaNativeClass iterator = new JavaNativeClass(new JavaSourceClass("java.lang", "Iterator"));
92
+			iterator.addInstanceMethod("hasNext", "hasNext");
93
+			iterator.addInstanceMethod("next", "next");
94
+			nativeClasses.put("stdlib::Iterator", iterator);
95
+		}
96
+		
80
 		{
97
 		{
81
 			JavaNativeClass comparable = new JavaNativeClass(new JavaSourceClass("java.lang", "Comparable"));
98
 			JavaNativeClass comparable = new JavaNativeClass(new JavaSourceClass("java.lang", "Comparable"));
82
 			comparable.addInstanceMethod("compareTo", "compareTo");
99
 			comparable.addInstanceMethod("compareTo", "compareTo");
184
 		}
201
 		}
185
 		
202
 		
186
 		{
203
 		{
187
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "StringReader"));
204
+			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "StringReader"), true);
188
 			cls.addInstanceMethod("constructor", "");
205
 			cls.addInstanceMethod("constructor", "");
189
 			cls.addInstanceMethod("destructor", "close");
206
 			cls.addInstanceMethod("destructor", "close");
190
 			cls.addInstanceMethod("readCharacter", "read");
207
 			cls.addInstanceMethod("readCharacter", "read");
201
 		this.outerClass = outerClass;
218
 		this.outerClass = outerClass;
202
 	}
219
 	}
203
 	
220
 	
221
+	private boolean isPrepared(HighLevelDefinition definition) {
222
+		return definition.hasTag(JavaSourceClass.class);
223
+	}
224
+	
225
+	public void prepare(ITypeID type) {
226
+		if (!(type instanceof DefinitionTypeID))
227
+			return;
228
+			
229
+		HighLevelDefinition definition = ((DefinitionTypeID)type).definition;
230
+		definition.accept(this);
231
+	}
232
+	
204
 	@Override
233
 	@Override
205
 	public JavaSourceClass visitClass(ClassDefinition definition) {
234
 	public JavaSourceClass visitClass(ClassDefinition definition) {
235
+		if (isPrepared(definition))
236
+			return definition.getTag(JavaSourceClass.class);
237
+		
206
 		return visitClassCompiled(definition, true);
238
 		return visitClassCompiled(definition, true);
207
 	}
239
 	}
208
 
240
 
209
 	@Override
241
 	@Override
210
 	public JavaSourceClass visitInterface(InterfaceDefinition definition) {
242
 	public JavaSourceClass visitInterface(InterfaceDefinition definition) {
243
+		if (isPrepared(definition))
244
+			return definition.getTag(JavaSourceClass.class);
245
+		
246
+		for (ITypeID baseType : definition.baseInterfaces)
247
+			prepare(baseType);
248
+		
211
 		return visitClassCompiled(definition, true);
249
 		return visitClassCompiled(definition, true);
212
 	}
250
 	}
213
 
251
 
214
 	@Override
252
 	@Override
215
 	public JavaSourceClass visitEnum(EnumDefinition definition) {
253
 	public JavaSourceClass visitEnum(EnumDefinition definition) {
254
+		if (isPrepared(definition))
255
+			return definition.getTag(JavaSourceClass.class);
256
+		
216
 		return visitClassCompiled(definition, false);
257
 		return visitClassCompiled(definition, false);
217
 	}
258
 	}
218
 
259
 
219
 	@Override
260
 	@Override
220
 	public JavaSourceClass visitStruct(StructDefinition definition) {
261
 	public JavaSourceClass visitStruct(StructDefinition definition) {
262
+		if (isPrepared(definition))
263
+			return definition.getTag(JavaSourceClass.class);
264
+		
221
 		return visitClassCompiled(definition, true);
265
 		return visitClassCompiled(definition, true);
222
 	}
266
 	}
223
 
267
 
224
 	@Override
268
 	@Override
225
 	public JavaSourceClass visitFunction(FunctionDefinition definition) {
269
 	public JavaSourceClass visitFunction(FunctionDefinition definition) {
270
+		if (isPrepared(definition))
271
+			return definition.getTag(JavaSourceClass.class);
272
+		
226
 		JavaSourceClass cls = new JavaSourceClass(definition.pkg.fullName, filename);
273
 		JavaSourceClass cls = new JavaSourceClass(definition.pkg.fullName, filename);
227
 		definition.setTag(JavaSourceClass.class, cls);
274
 		definition.setTag(JavaSourceClass.class, cls);
228
 		JavaSourceMethod method = new JavaSourceMethod(cls, JavaSourceMethod.Kind.STATIC, definition.name, true);
275
 		JavaSourceMethod method = new JavaSourceMethod(cls, JavaSourceMethod.Kind.STATIC, definition.name, true);
232
 
279
 
233
 	@Override
280
 	@Override
234
 	public JavaSourceClass visitExpansion(ExpansionDefinition definition) {
281
 	public JavaSourceClass visitExpansion(ExpansionDefinition definition) {
282
+		if (isPrepared(definition))
283
+			return definition.getTag(JavaSourceClass.class);
284
+		
235
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
285
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
236
 		JavaNativeClass nativeClass = null;
286
 		JavaNativeClass nativeClass = null;
237
 		if (nativeTag != null) {
287
 		if (nativeTag != null) {
252
 
302
 
253
 	@Override
303
 	@Override
254
 	public JavaSourceClass visitVariant(VariantDefinition variant) {
304
 	public JavaSourceClass visitVariant(VariantDefinition variant) {
305
+		if (isPrepared(variant))
306
+			return variant.getTag(JavaSourceClass.class);
307
+		
255
 		JavaSourceClass cls = new JavaSourceClass(variant.pkg.fullName, variant.name);
308
 		JavaSourceClass cls = new JavaSourceClass(variant.pkg.fullName, variant.name);
256
 		variant.setTag(JavaSourceClass.class, cls);
309
 		variant.setTag(JavaSourceClass.class, cls);
257
 		
310
 		
265
 	}
318
 	}
266
 	
319
 	
267
 	private JavaSourceClass visitClassCompiled(HighLevelDefinition definition, boolean startsEmpty) {
320
 	private JavaSourceClass visitClassCompiled(HighLevelDefinition definition, boolean startsEmpty) {
321
+		if (definition.getSuperType() != null)
322
+			prepare(definition.getSuperType());
323
+		
268
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
324
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
269
 		JavaNativeClass nativeClass = nativeTag == null ? null : nativeClasses.get(nativeTag.value);
325
 		JavaNativeClass nativeClass = nativeTag == null ? null : nativeClasses.get(nativeTag.value);
270
 		if (nativeClass == null) {
326
 		if (nativeClass == null) {
271
 			JavaSourceClass cls = outerClass == null ? new JavaSourceClass(definition.pkg.fullName, definition.name) : new JavaSourceClass(outerClass, definition.name);
327
 			JavaSourceClass cls = outerClass == null ? new JavaSourceClass(definition.pkg.fullName, definition.name) : new JavaSourceClass(outerClass, definition.name);
328
+			cls.destructible = definition.isDestructible();
272
 			definition.setTag(JavaSourceClass.class, cls);
329
 			definition.setTag(JavaSourceClass.class, cls);
273
 			visitClassMembers(definition, cls, null, startsEmpty);
330
 			visitClassMembers(definition, cls, null, startsEmpty);
274
 			return cls;
331
 			return cls;
277
 			definition.setTag(JavaSourceClass.class, nativeClass.cls);
334
 			definition.setTag(JavaSourceClass.class, nativeClass.cls);
278
 			definition.setTag(JavaNativeClass.class, nativeClass);
335
 			definition.setTag(JavaNativeClass.class, nativeClass);
279
 			visitExpansionMembers(definition, cls, nativeClass);
336
 			visitExpansionMembers(definition, cls, nativeClass);
337
+			
338
+			if (nativeClass.nonDestructible)
339
+				cls.destructible = false;
340
+			
280
 			return cls;
341
 			return cls;
281
 		}
342
 		}
282
 	}
343
 	}
283
 	
344
 	
284
 	private void visitClassMembers(HighLevelDefinition definition, JavaSourceClass cls, JavaNativeClass nativeClass, boolean startsEmpty) {
345
 	private void visitClassMembers(HighLevelDefinition definition, JavaSourceClass cls, JavaNativeClass nativeClass, boolean startsEmpty) {
285
-		JavaSourcePrepareClassMethodVisitor methodVisitor = new JavaSourcePrepareClassMethodVisitor(filename, cls, nativeClass, startsEmpty);
346
+		JavaSourcePrepareClassMethodVisitor methodVisitor = new JavaSourcePrepareClassMethodVisitor(this, filename, cls, nativeClass, startsEmpty);
286
 		for (IDefinitionMember member : definition.members) {
347
 		for (IDefinitionMember member : definition.members) {
287
 			member.accept(methodVisitor);
348
 			member.accept(methodVisitor);
288
 		}
349
 		}

+ 14
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareExpansionMethodVisitor.java View File

36
  * @author Hoofdgebruiker
36
  * @author Hoofdgebruiker
37
  */
37
  */
38
 public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Void> {
38
 public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Void> {
39
+	private static final boolean DEBUG_EMPTY = true;
40
+	
39
 	private final JavaSourceClass cls;
41
 	private final JavaSourceClass cls;
40
 	private final JavaNativeClass nativeClass;
42
 	private final JavaNativeClass nativeClass;
41
 	
43
 	
48
 	@Override
50
 	@Override
49
 	public Void visitConst(ConstMember member) {
51
 	public Void visitConst(ConstMember member) {
50
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
52
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
53
+		
54
+		if (DEBUG_EMPTY && cls.empty)
55
+			System.out.println("Class " + cls.fullName + " not empty because of const");
56
+		
51
 		cls.empty = false;
57
 		cls.empty = false;
52
 		return null;
58
 		return null;
53
 	}
59
 	}
69
 
75
 
70
 	@Override
76
 	@Override
71
 	public Void visitDestructor(DestructorMember member) {
77
 	public Void visitDestructor(DestructorMember member) {
78
+		if (nativeClass != null && nativeClass.nonDestructible)
79
+			return null;
80
+		
72
 		visitFunctional(member, "");
81
 		visitFunctional(member, "");
73
 		return null;
82
 		return null;
74
 	}
83
 	}
146
 		if (method == null)
155
 		if (method == null)
147
 			method = new JavaSourceMethod(cls, getKind(member), name, true); 
156
 			method = new JavaSourceMethod(cls, getKind(member), name, true); 
148
 		
157
 		
149
-		if (method.compile)
158
+		if (method.compile) {
159
+			if (DEBUG_EMPTY && cls.empty)
160
+				System.out.println("Class " + cls.fullName + " not empty because of " + member.describe());
161
+			
150
 			cls.empty = false;
162
 			cls.empty = false;
163
+		}
151
 		
164
 		
152
 		member.setTag(JavaSourceMethod.class, method);
165
 		member.setTag(JavaSourceMethod.class, method);
153
 	}
166
 	}

+ 6
- 4
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java View File

40
 		return result;
40
 		return result;
41
 	}
41
 	}
42
 	
42
 	
43
-	private final List<ParsedTypeParameter> genericParameters;
43
+	private final List<ParsedTypeParameter> parameters;
44
 	private final IParsedType superclass;
44
 	private final IParsedType superclass;
45
 	
45
 	
46
 	private final ClassDefinition compiled;
46
 	private final ClassDefinition compiled;
47
 	
47
 	
48
-	public ParsedClass(ZSPackage pkg, CodePosition position, int modifiers, ParsedAnnotation[] annotations, String name, List<ParsedTypeParameter> genericParameters, IParsedType superclass, HighLevelDefinition outerDefinition) {
48
+	public ParsedClass(ZSPackage pkg, CodePosition position, int modifiers, ParsedAnnotation[] annotations, String name, List<ParsedTypeParameter> parameters, IParsedType superclass, HighLevelDefinition outerDefinition) {
49
 		super(position, modifiers, annotations);
49
 		super(position, modifiers, annotations);
50
 		
50
 		
51
-		this.genericParameters = genericParameters;
51
+		this.parameters = parameters;
52
 		this.superclass = superclass;
52
 		this.superclass = superclass;
53
 		
53
 		
54
 		compiled = new ClassDefinition(position, pkg, name, modifiers, outerDefinition);
54
 		compiled = new ClassDefinition(position, pkg, name, modifiers, outerDefinition);
55
-		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(genericParameters));
55
+		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(parameters));
56
 	}
56
 	}
57
 
57
 
58
 	@Override
58
 	@Override
62
 
62
 
63
 	@Override
63
 	@Override
64
 	protected void linkTypesLocal(TypeResolutionContext context) {
64
 	protected void linkTypesLocal(TypeResolutionContext context) {
65
+		ParsedTypeParameter.compile(context, compiled.genericParameters, this.parameters);
66
+		
65
 		if (superclass != null)
67
 		if (superclass != null)
66
 			compiled.setSuperType(superclass.compile(context));
68
 			compiled.setSuperType(superclass.compile(context));
67
 		
69
 		

+ 2
- 1
Validator/src/main/java/org/openzen/zenscript/validator/ValidationLogEntry.java View File

71
 		OVERRIDE_MISSING_BASE,
71
 		OVERRIDE_MISSING_BASE,
72
 		INVALID_OVERRIDE,
72
 		INVALID_OVERRIDE,
73
 		SUPERTYPE_NOT_DESTRUCTIBLE,
73
 		SUPERTYPE_NOT_DESTRUCTIBLE,
74
-		INVALID_IMPLEMENTATION_TYPE
74
+		INVALID_IMPLEMENTATION_TYPE,
75
+		INCOMPLETE_IMPLEMENTATION
75
 	}
76
 	}
76
 }
77
 }

+ 41
- 3
Validator/src/main/java/org/openzen/zenscript/validator/visitors/DefinitionMemberValidator.java View File

35
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
35
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
36
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
36
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
37
 import org.openzen.zenscript.codemodel.type.ITypeID;
37
 import org.openzen.zenscript.codemodel.type.ITypeID;
38
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
38
 import org.openzen.zenscript.validator.ValidationLogEntry;
39
 import org.openzen.zenscript.validator.ValidationLogEntry;
39
 import org.openzen.zenscript.validator.Validator;
40
 import org.openzen.zenscript.validator.Validator;
40
 import org.openzen.zenscript.validator.analysis.ExpressionScope;
41
 import org.openzen.zenscript.validator.analysis.ExpressionScope;
151
 	public Void visitGetter(GetterMember member) {
152
 	public Void visitGetter(GetterMember member) {
152
 		ValidationUtils.validateIdentifier(validator, member.position, member.name);
153
 		ValidationUtils.validateIdentifier(validator, member.position, member.name);
153
 		member.type.accept(new TypeValidator(validator, member.position));
154
 		member.type.accept(new TypeValidator(validator, member.position));
154
-		validateFunctional(member, new MethodStatementScope(member.header));
155
+		validateProperty(member, new MethodStatementScope(member.header));
155
 		return null;
156
 		return null;
156
 	}
157
 	}
157
 
158
 
159
 	public Void visitSetter(SetterMember member) {
160
 	public Void visitSetter(SetterMember member) {
160
 		ValidationUtils.validateIdentifier(validator, member.position, member.name);
161
 		ValidationUtils.validateIdentifier(validator, member.position, member.name);
161
 		member.type.accept(new TypeValidator(validator, member.position));
162
 		member.type.accept(new TypeValidator(validator, member.position));
162
-		validateFunctional(member, new MethodStatementScope(member.header));
163
+		validateProperty(member, new MethodStatementScope(member.header));
163
 		return null;
164
 		return null;
164
 	}
165
 	}
165
 	
166
 	
191
 
192
 
192
 	@Override
193
 	@Override
193
 	public Void visitCustomIterator(CustomIteratorMember member) {
194
 	public Void visitCustomIterator(CustomIteratorMember member) {
194
-		// TODO: validate iterators
195
+		for (ITypeID type : member.getLoopVariableTypes())
196
+			type.accept(new TypeValidator(validator, member.position));
197
+		validateFunctional(member, new MethodStatementScope(new FunctionHeader(scope.getTypeRegistry().getIterator(member.getLoopVariableTypes()))));
195
 		return null;
198
 		return null;
196
 	}
199
 	}
197
 
200
 
229
 			member.accept(memberValidator);
232
 			member.accept(memberValidator);
230
 		}
233
 		}
231
 		
234
 		
235
+		checkImplementationComplete(implementation);
232
 		return null;
236
 		return null;
233
 	}
237
 	}
238
+	
239
+	private void checkImplementationComplete(ImplementationMember implementation) {
240
+		Set<IDefinitionMember> implemented = new HashSet<>();
241
+		for (IDefinitionMember member : implementation.members)
242
+			if (member.getOverrides() != null)
243
+				implemented.add(member.getOverrides().getTarget());
244
+		
245
+		TypeMembers members = scope.getTypeMembers(implementation.type);
246
+		List<IDefinitionMember> unimplemented = members.getUnimplementedMembers(implemented);
247
+		if (unimplemented.size() == 1) {
248
+			validator.logError(ValidationLogEntry.Code.INCOMPLETE_IMPLEMENTATION, implementation.position, unimplemented.get(0).describe() + " not implemented");
249
+		} else if (unimplemented.size() > 1) {
250
+			StringBuilder message = new StringBuilder();
251
+			message.append("Implementation incomplete: ").append(unimplemented.size()).append(" members not yet implemented:");
252
+			for (IDefinitionMember member : unimplemented) {
253
+				message.append("\n").append("  - ").append(member.describe());
254
+			}
255
+			validator.logError(ValidationLogEntry.Code.INCOMPLETE_IMPLEMENTATION, implementation.position, message.toString());
256
+		}
257
+	}
234
 
258
 
235
 	@Override
259
 	@Override
236
 	public Void visitInnerDefinition(InnerDefinitionMember innerDefinition) {
260
 	public Void visitInnerDefinition(InnerDefinitionMember innerDefinition) {
274
 		}
298
 		}
275
 	}
299
 	}
276
 	
300
 	
301
+	private void validateProperty(FunctionalMember member, StatementScope scope) {
302
+		if (Modifiers.isOverride(member.modifiers) || (context == DefinitionMemberContext.IMPLEMENTATION && !member.isPrivate())) {
303
+			if (member.getOverrides() == null) {
304
+				validator.logError(ValidationLogEntry.Code.OVERRIDE_MISSING_BASE, member.position, "Overridden method not identified");
305
+			}
306
+		}
307
+		
308
+		if (member.body != null) {
309
+			StatementValidator statementValidator = new StatementValidator(validator, scope);
310
+			member.body.accept(statementValidator);
311
+			validateThrow(member);
312
+		}
313
+	}
314
+	
277
 	private class FieldInitializerScope implements ExpressionScope {
315
 	private class FieldInitializerScope implements ExpressionScope {
278
 		private final FieldMember field;
316
 		private final FieldMember field;
279
 		
317
 		

Loading…
Cancel
Save