Browse Source

- Annotations are now serializable

- Fixed various serialization bugs, continuing work on serializer
Stan Hebben 6 years ago
parent
commit
17a2cadf8a
35 changed files with 353 additions and 66 deletions
  1. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/Annotation.java
  2. 11
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationDefinition.java
  3. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/DefinitionAnnotation.java
  4. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/MemberAnnotation.java
  5. 25
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java
  6. 12
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeDefinitionAnnotation.java
  7. 12
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeMemberAnnotation.java
  8. 28
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java
  9. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionForMethod.java
  10. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/StatementAnnotation.java
  11. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  12. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  13. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  14. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  15. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  16. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  17. 6
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java
  18. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/SetterMember.java
  19. 7
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java
  20. 3
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/serialization/CodeSerializationInput.java
  21. 3
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/serialization/CodeSerializationOutput.java
  22. 2
    2
      IDE/src/main/java/org/openzen/zenscript/ide/Arguments.java
  23. 1
    1
      IDE/src/main/java/org/openzen/zenscript/ide/JavaBytecodeMain.java
  24. 1
    1
      IDE/src/main/java/org/openzen/zenscript/ide/Main.java
  25. 16
    3
      ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/CodeReader.java
  26. 46
    16
      ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/DefinitionMemberDeserializer.java
  27. 13
    5
      ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/ModuleDeserializer.java
  28. 1
    0
      ModuleSerializationShared/src/main/java/org/openzen/zenscript/moduleserialization/DefinitionEncoding.java
  29. 1
    0
      ModuleSerializationShared/src/main/java/org/openzen/zenscript/moduleserialization/MemberEncoding.java
  30. 21
    12
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/CodeWriter.java
  31. 17
    2
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/ModuleSerializer.java
  32. 11
    0
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/TableBuilder.java
  33. 0
    4
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/DefinitionMemberSerializer.java
  34. 15
    3
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/DefinitionSerializer.java
  35. 27
    15
      ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/MemberSerializer.java

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

@@ -12,5 +12,7 @@ package org.openzen.zenscript.codemodel.annotations;
12 12
 public interface Annotation {
13 13
 	public static final Annotation[] NONE = new Annotation[0];
14 14
 	
15
+	public AnnotationDefinition getDefinition();
16
+	
15 17
 	public void apply();
16 18
 }

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

@@ -10,11 +10,14 @@ import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zenscript.codemodel.FunctionHeader;
11 11
 import org.openzen.zenscript.codemodel.FunctionParameter;
12 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
+import org.openzen.zenscript.codemodel.context.StatementContext;
14
+import org.openzen.zenscript.codemodel.context.TypeContext;
13 15
 import org.openzen.zenscript.codemodel.expression.CallArguments;
14 16
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
15 17
 import org.openzen.zenscript.codemodel.scope.BaseScope;
16 18
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
17 19
 import org.openzen.zenscript.codemodel.scope.StatementScope;
20
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
18 21
 import org.openzen.zenscript.codemodel.statement.Statement;
19 22
 
20 23
 /**
@@ -41,4 +44,12 @@ public interface AnnotationDefinition {
41 44
 	public StatementAnnotation createForStatement(CodePosition position, CallArguments arguments);
42 45
 	
43 46
 	public Annotation createForParameter(CodePosition position, CallArguments arguments);
47
+	
48
+	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member);
49
+	
50
+	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context);
51
+	
52
+	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context);
53
+	
54
+	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context);
44 55
 }

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

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.annotations;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
+import org.openzen.zenscript.codemodel.context.TypeContext;
9 10
 import org.openzen.zenscript.codemodel.scope.BaseScope;
11
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
10 12
 
11 13
 /**
12 14
  *
@@ -15,7 +17,11 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
15 17
 public interface DefinitionAnnotation {
16 18
 	public static final DefinitionAnnotation[] NONE = new DefinitionAnnotation[0];
17 19
 	
20
+	public AnnotationDefinition getDefinition();
21
+	
18 22
 	public void apply(HighLevelDefinition definition, BaseScope scope);
19 23
 	
20 24
 	public void applyOnSubtype(HighLevelDefinition definition, BaseScope scope);
25
+	
26
+	public void serialize(CodeSerializationOutput output, HighLevelDefinition definition, TypeContext context);
21 27
 }

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

@@ -5,11 +5,13 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.annotations;
7 7
 
8
+import org.openzen.zenscript.codemodel.context.TypeContext;
8 9
 import org.openzen.zenscript.codemodel.member.FunctionalMember;
9 10
 import org.openzen.zenscript.codemodel.member.GetterMember;
10 11
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
11 12
 import org.openzen.zenscript.codemodel.member.SetterMember;
12 13
 import org.openzen.zenscript.codemodel.scope.BaseScope;
14
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
13 15
 
14 16
 /**
15 17
  *
@@ -18,6 +20,8 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
18 20
 public interface MemberAnnotation {
19 21
 	public static final MemberAnnotation[] NONE = new MemberAnnotation[0];
20 22
 	
23
+	public AnnotationDefinition getDefinition();
24
+	
21 25
 	public void apply(IDefinitionMember member, BaseScope scope);
22 26
 	
23 27
 	public void applyOnOverridingMethod(FunctionalMember member, BaseScope scope);
@@ -25,4 +29,6 @@ public interface MemberAnnotation {
25 29
 	public void applyOnOverridingGetter(GetterMember member, BaseScope scope);
26 30
 	
27 31
 	public void applyOnOverridingSetter(SetterMember member, BaseScope scope);
32
+	
33
+	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context);
28 34
 }

+ 25
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java View File

@@ -11,12 +11,15 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12 12
 import org.openzen.zenscript.codemodel.FunctionParameter;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
+import org.openzen.zenscript.codemodel.context.StatementContext;
15
+import org.openzen.zenscript.codemodel.context.TypeContext;
14 16
 import org.openzen.zenscript.codemodel.expression.CallArguments;
15 17
 import org.openzen.zenscript.codemodel.expression.Expression;
16 18
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
17 19
 import org.openzen.zenscript.codemodel.scope.BaseScope;
18 20
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
19 21
 import org.openzen.zenscript.codemodel.scope.StatementScope;
22
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
20 23
 import org.openzen.zenscript.codemodel.statement.Statement;
21 24
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
22 25
 
@@ -85,4 +88,26 @@ public class NativeAnnotationDefinition implements AnnotationDefinition {
85 88
 	public Annotation createForParameter(CodePosition position, CallArguments arguments) {
86 89
 		throw new UnsupportedOperationException("Not supported");
87 90
 	}
91
+
92
+	@Override
93
+	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member) {
94
+		String name = input.readString();
95
+		return new NativeMemberAnnotation(name);
96
+	}
97
+
98
+	@Override
99
+	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context) {
100
+		String name = input.readString();
101
+		return new NativeDefinitionAnnotation(name);
102
+	}
103
+
104
+	@Override
105
+	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context) {
106
+		throw new UnsupportedOperationException("Not supported");
107
+	}
108
+
109
+	@Override
110
+	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
111
+		throw new UnsupportedOperationException("Not supported");
112
+	}
88 113
 }

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

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.annotations;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
+import org.openzen.zenscript.codemodel.context.TypeContext;
9 10
 import org.openzen.zenscript.codemodel.scope.BaseScope;
11
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
10 12
 
11 13
 /**
12 14
  *
@@ -18,6 +20,11 @@ public class NativeDefinitionAnnotation implements DefinitionAnnotation {
18 20
 	public NativeDefinitionAnnotation(String identifier) {
19 21
 		this.identifier = identifier;
20 22
 	}
23
+
24
+	@Override
25
+	public AnnotationDefinition getDefinition() {
26
+		return NativeAnnotationDefinition.INSTANCE;
27
+	}
21 28
 	
22 29
 	@Override
23 30
 	public void apply(HighLevelDefinition definition, BaseScope scope) {
@@ -28,4 +35,9 @@ public class NativeDefinitionAnnotation implements DefinitionAnnotation {
28 35
 	public void applyOnSubtype(HighLevelDefinition definition, BaseScope scope) {
29 36
 		// this annotation is not inherited
30 37
 	}
38
+
39
+	@Override
40
+	public void serialize(CodeSerializationOutput output, HighLevelDefinition definition, TypeContext context) {
41
+		output.writeString(identifier);
42
+	}
31 43
 }

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

@@ -5,11 +5,13 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.annotations;
7 7
 
8
+import org.openzen.zenscript.codemodel.context.TypeContext;
8 9
 import org.openzen.zenscript.codemodel.member.FunctionalMember;
9 10
 import org.openzen.zenscript.codemodel.member.GetterMember;
10 11
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
11 12
 import org.openzen.zenscript.codemodel.member.SetterMember;
12 13
 import org.openzen.zenscript.codemodel.scope.BaseScope;
14
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
13 15
 
14 16
 /**
15 17
  *
@@ -21,6 +23,11 @@ public class NativeMemberAnnotation implements MemberAnnotation {
21 23
 	public NativeMemberAnnotation(String identifier) {
22 24
 		this.identifier = identifier;
23 25
 	}
26
+
27
+	@Override
28
+	public AnnotationDefinition getDefinition() {
29
+		return NativeAnnotationDefinition.INSTANCE;
30
+	}
24 31
 	
25 32
 	@Override
26 33
 	public void apply(IDefinitionMember member, BaseScope scope) {
@@ -41,4 +48,9 @@ public class NativeMemberAnnotation implements MemberAnnotation {
41 48
 	public void applyOnOverridingSetter(SetterMember member, BaseScope scope) {
42 49
 		// not inherited
43 50
 	}
51
+
52
+	@Override
53
+	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context) {
54
+		output.writeString(identifier);
55
+	}
44 56
 }

+ 28
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java View File

@@ -12,6 +12,8 @@ import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zenscript.codemodel.FunctionHeader;
13 13
 import org.openzen.zenscript.codemodel.FunctionParameter;
14 14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15
+import org.openzen.zenscript.codemodel.context.StatementContext;
16
+import org.openzen.zenscript.codemodel.context.TypeContext;
15 17
 import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
16 18
 import org.openzen.zenscript.codemodel.expression.CallArguments;
17 19
 import org.openzen.zenscript.codemodel.expression.Expression;
@@ -21,6 +23,7 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
21 23
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
22 24
 import org.openzen.zenscript.codemodel.scope.FunctionScope;
23 25
 import org.openzen.zenscript.codemodel.scope.StatementScope;
26
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
24 27
 import org.openzen.zenscript.codemodel.statement.Statement;
25 28
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
26 29
 import org.openzen.zenscript.codemodel.type.GenericName;
@@ -104,4 +107,29 @@ public class PreconditionAnnotationDefinition implements AnnotationDefinition {
104 107
 	public Annotation createForParameter(CodePosition position, CallArguments arguments) {
105 108
 		throw new UnsupportedOperationException("Not supported");
106 109
 	}
110
+
111
+	@Override
112
+	public MemberAnnotation deserializeForMember(CodeSerializationInput input, TypeContext context, IDefinitionMember member) {
113
+		CodePosition position = input.deserializePosition();
114
+		String enforcement = input.readString();
115
+		StatementContext statementContext = new StatementContext(context, member.getHeader());
116
+		Expression condition = input.deserializeExpression(statementContext);
117
+		Expression message = input.deserializeExpression(statementContext);
118
+		return new PreconditionForMethod(position, enforcement, condition, message);
119
+	}
120
+
121
+	@Override
122
+	public DefinitionAnnotation deserializeForDefinition(CodeSerializationInput input, TypeContext context) {
123
+		throw new UnsupportedOperationException("Not supported");
124
+	}
125
+
126
+	@Override
127
+	public StatementAnnotation deserializeForStatement(CodeSerializationInput input, StatementContext context) {
128
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
129
+	}
130
+
131
+	@Override
132
+	public Annotation deserializeForParameter(CodeSerializationInput input, TypeContext context) {
133
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
134
+	}
107 135
 }

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

@@ -9,6 +9,8 @@ import java.util.ArrayList;
9 9
 import java.util.Arrays;
10 10
 import java.util.List;
11 11
 import org.openzen.zencode.shared.CodePosition;
12
+import org.openzen.zenscript.codemodel.context.StatementContext;
13
+import org.openzen.zenscript.codemodel.context.TypeContext;
12 14
 import org.openzen.zenscript.codemodel.expression.Expression;
13 15
 import org.openzen.zenscript.codemodel.expression.ExpressionBuilder;
14 16
 import org.openzen.zenscript.codemodel.expression.PanicExpression;
@@ -18,6 +20,7 @@ import org.openzen.zenscript.codemodel.member.IDefinitionMember;
18 20
 import org.openzen.zenscript.codemodel.member.SetterMember;
19 21
 import org.openzen.zenscript.codemodel.scope.BaseScope;
20 22
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
23
+import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
21 24
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
22 25
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
23 26
 import org.openzen.zenscript.codemodel.statement.IfStatement;
@@ -44,6 +47,11 @@ public class PreconditionForMethod implements MemberAnnotation {
44 47
 		this.condition = condition;
45 48
 		this.message = message;
46 49
 	}
50
+	
51
+	@Override
52
+	public AnnotationDefinition getDefinition() {
53
+		return PreconditionAnnotationDefinition.INSTANCE;
54
+	}
47 55
 
48 56
 	@Override
49 57
 	public void apply(IDefinitionMember member, BaseScope scope) {
@@ -89,4 +97,13 @@ public class PreconditionForMethod implements MemberAnnotation {
89 97
 		}
90 98
 		return new BlockStatement(position, statements.toArray(new Statement[statements.size()]));
91 99
 	}
100
+
101
+	@Override
102
+	public void serialize(CodeSerializationOutput output, IDefinitionMember member, TypeContext context) {
103
+		output.serialize(position);
104
+		output.writeString(enforcement);
105
+		StatementContext statementContext = new StatementContext(context, member.getHeader());
106
+		output.serialize(statementContext, condition);
107
+		output.serialize(statementContext, message);
108
+	}
92 109
 }

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

@@ -15,5 +15,7 @@ import org.openzen.zenscript.codemodel.statement.Statement;
15 15
 public interface StatementAnnotation {
16 16
 	public static final StatementAnnotation[] NONE = new StatementAnnotation[0];
17 17
 	
18
+	public AnnotationDefinition getDefinition();
19
+	
18 20
 	public Statement apply(Statement statement, StatementScope scope);
19 21
 }

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

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 12
 import org.openzen.zenscript.codemodel.expression.Expression;
@@ -71,4 +72,9 @@ public class ConstMember extends PropertyMember {
71 72
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
72 73
 		return new ConstMemberRef(type, this, mapper);
73 74
 	}
75
+	
76
+	@Override
77
+	public FunctionHeader getHeader() {
78
+		return null;
79
+	}
74 80
 }

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

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 12
 import org.openzen.zenscript.codemodel.expression.Expression;
@@ -162,4 +163,9 @@ public class FieldMember extends PropertyMember {
162 163
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
163 164
 		return new FieldMemberRef(type, this, mapper);
164 165
 	}
166
+	
167
+	@Override
168
+	public FunctionHeader getHeader() {
169
+		return null;
170
+	}
165 171
 }

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

@@ -66,4 +66,9 @@ public abstract class FunctionalMember extends DefinitionMember {
66 66
 	public boolean isAbstract() {
67 67
 		return body == null && builtin == null;
68 68
 	}
69
+	
70
+	@Override
71
+	public FunctionHeader getHeader() {
72
+		return header;
73
+	}
69 74
 }

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

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.ConcatMap;
10
+import org.openzen.zenscript.codemodel.FunctionHeader;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
@@ -95,4 +96,9 @@ public class GetterMember extends PropertyMember {
95 96
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
96 97
 		return new GetterMemberRef(type, this, mapper);
97 98
 	}
99
+	
100
+	@Override
101
+	public FunctionHeader getHeader() {
102
+		return new FunctionHeader(type);
103
+	}
98 104
 }

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

@@ -6,8 +6,10 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
13 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -24,6 +26,8 @@ public interface IDefinitionMember {
24 26
 	
25 27
 	public int getModifiers();
26 28
 	
29
+	public MemberAnnotation[] getAnnotations();
30
+	
27 31
 	public HighLevelDefinition getDefinition();
28 32
 	
29 33
 	public String describe();
@@ -49,4 +53,6 @@ public interface IDefinitionMember {
49 53
 	boolean isAbstract();
50 54
 	
51 55
 	DefinitionMemberRef ref(ITypeID type, GenericMapper mapper);
56
+	
57
+	FunctionHeader getHeader();
52 58
 }

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

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel.member;
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11
+import org.openzen.zenscript.codemodel.FunctionHeader;
11 12
 import org.openzen.zenscript.codemodel.GenericMapper;
12 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
@@ -85,4 +86,9 @@ public class ImplementationMember extends DefinitionMember {
85 86
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
86 87
 		throw new UnsupportedOperationException("Cannot create an implementation reference");
87 88
 	}
89
+
90
+	@Override
91
+	public FunctionHeader getHeader() {
92
+		return null;
93
+	}
88 94
 }

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

@@ -6,10 +6,10 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.GenericMapper;
10 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 12
 import org.openzen.zenscript.codemodel.Modifiers;
12
-import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
13 13
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
15 15
 import org.openzen.zenscript.codemodel.scope.TypeScope;
@@ -79,4 +79,9 @@ public class InnerDefinitionMember extends DefinitionMember {
79 79
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
80 80
 		throw new UnsupportedOperationException("Cannot create an inner definition reference");
81 81
 	}
82
+	
83
+	@Override
84
+	public FunctionHeader getHeader() {
85
+		return null;
86
+	}
82 87
 }

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

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.ConcatMap;
10
+import org.openzen.zenscript.codemodel.FunctionHeader;
10 11
 import org.openzen.zenscript.codemodel.FunctionParameter;
11 12
 import org.openzen.zenscript.codemodel.GenericMapper;
12 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
@@ -100,4 +101,9 @@ public class SetterMember extends PropertyMember {
100 101
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
101 102
 		return new SetterMemberRef(type, this, mapper);
102 103
 	}
104
+	
105
+	@Override
106
+	public FunctionHeader getHeader() {
107
+		return new FunctionHeader(BasicTypeID.VOID, type);
108
+	}
103 109
 }

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

@@ -7,12 +7,14 @@ package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.ConcatMap;
10
+import org.openzen.zenscript.codemodel.FunctionHeader;
10 11
 import org.openzen.zenscript.codemodel.GenericMapper;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
14 15
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
15 16
 import org.openzen.zenscript.codemodel.statement.Statement;
17
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 19
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 20
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -73,4 +75,9 @@ public class StaticInitializerMember extends DefinitionMember {
73 75
 	public DefinitionMemberRef ref(ITypeID type, GenericMapper mapper) {
74 76
 		throw new UnsupportedOperationException("Cannot reference a static initializer");
75 77
 	}
78
+	
79
+	@Override
80
+	public FunctionHeader getHeader() {
81
+		return new FunctionHeader(BasicTypeID.VOID);
82
+	}
76 83
 }

+ 3
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/serialization/CodeSerializationInput.java View File

@@ -8,7 +8,7 @@ package org.openzen.zenscript.codemodel.serialization;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
-import org.openzen.zenscript.codemodel.context.ModuleContext;
11
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
12 12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13 13
 import org.openzen.zenscript.codemodel.expression.Expression;
14 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
@@ -59,6 +59,8 @@ public interface CodeSerializationInput {
59 59
 	
60 60
 	VariantOptionRef readVariantOption(TypeContext context, ITypeID type);
61 61
 	
62
+	AnnotationDefinition readAnnotationType();
63
+	
62 64
 	ITypeID deserializeType(TypeContext context);
63 65
 	
64 66
 	CodePosition deserializePosition();

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

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel.serialization;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
11 12
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12 13
 import org.openzen.zenscript.codemodel.expression.Expression;
13 14
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
@@ -60,6 +61,8 @@ public interface CodeSerializationOutput {
60 61
 	
61 62
 	void write(TypeContext context, DefinitionMemberRef member);
62 63
 	
64
+	void write(AnnotationDefinition annotationType);
65
+	
63 66
 	void serialize(TypeContext context, IDefinitionMember member);
64 67
 	
65 68
 	void serialize(TypeContext context, ITypeID type);

+ 2
- 2
IDE/src/main/java/org/openzen/zenscript/ide/Arguments.java View File

@@ -14,8 +14,8 @@ import java.io.File;
14 14
 public class Arguments {
15 15
 	public final File projectDirectory;
16 16
 	
17
-	public Arguments(String[] arguments) {
18
-		File projectDir = new File("../../ZenCode"); // TODO: remove this and open a project chooser/creator instead
17
+	public Arguments(String[] arguments, File defaultProjectDir) {
18
+		File projectDir = defaultProjectDir;
19 19
 		int positional = 0;
20 20
 		for (int i = 0; i < arguments.length; i++) {
21 21
 			switch (positional) {

+ 1
- 1
IDE/src/main/java/org/openzen/zenscript/ide/JavaBytecodeMain.java View File

@@ -21,7 +21,7 @@ public class JavaBytecodeMain {
21 21
      * @param args the command line arguments
22 22
      */
23 23
     public static void main(String[] args) throws IOException {
24
-		Arguments arguments = new Arguments(args);
24
+		Arguments arguments = new Arguments(args, new File("../../ZenCode")); // TODO: remove this and open a project chooser/creator instead
25 25
 		File directory = arguments.projectDirectory;
26 26
 		
27 27
 		Project project = new Project(directory);

+ 1
- 1
IDE/src/main/java/org/openzen/zenscript/ide/Main.java View File

@@ -18,7 +18,7 @@ public class Main {
18 18
      * @param args the command line arguments
19 19
      */
20 20
     public static void main(String[] args) throws IOException {
21
-		Arguments arguments = new Arguments(args);
21
+		Arguments arguments = new Arguments(args, new File("../../ZenCode")); // TODO: remove this and open a project chooser/creator instead
22 22
 		File directory = arguments.projectDirectory;
23 23
 		
24 24
 		Project project = new Project(directory);

+ 16
- 3
ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/CodeReader.java View File

@@ -14,8 +14,8 @@ import org.openzen.zencode.shared.SourceFile;
14 14
 import org.openzen.zenscript.codemodel.CompareType;
15 15
 import org.openzen.zenscript.codemodel.FunctionHeader;
16 16
 import org.openzen.zenscript.codemodel.FunctionParameter;
17
-import org.openzen.zenscript.codemodel.GenericMapper;
18 17
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
18
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
19 19
 import org.openzen.zenscript.codemodel.context.StatementContext;
20 20
 import org.openzen.zenscript.codemodel.context.TypeContext;
21 21
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
@@ -91,6 +91,7 @@ public class CodeReader implements CodeSerializationInput {
91 91
 	
92 92
 	private final String[] strings;
93 93
 	private final SourceFile[] sourceFiles;
94
+	private final AnnotationDefinition[] annotations;
94 95
 	private final List<HighLevelDefinition> definitions = new ArrayList<>();
95 96
 	private final List<IDefinitionMember> memberList = new ArrayList<>();
96 97
 	private final List<EnumConstantMember> enumConstantMembers = new ArrayList<>();
@@ -102,12 +103,14 @@ public class CodeReader implements CodeSerializationInput {
102 103
 			CompactDataInput input,
103 104
 			String[] strings,
104 105
 			SourceFile[] sourceFiles,
106
+			AnnotationDefinition[] annotations,
105 107
 			GlobalTypeRegistry registry)
106 108
 	{
107 109
 		this.input = input;
108 110
 		
109 111
 		this.strings = strings;
110 112
 		this.sourceFiles = sourceFiles;
113
+		this.annotations = annotations;
111 114
 		this.registry = registry;
112 115
 	}
113 116
 	
@@ -202,7 +205,12 @@ public class CodeReader implements CodeSerializationInput {
202 205
 
203 206
 	@Override
204 207
 	public HighLevelDefinition readDefinition() {
205
-		return definitions.get(input.readVarUInt());
208
+		int id = input.readVarUInt();
209
+		if (id == 0)
210
+			return null;
211
+		
212
+		HighLevelDefinition definition = definitions.get(id - 1);
213
+		return definition;
206 214
 	}
207 215
 
208 216
 	@Override
@@ -232,6 +240,11 @@ public class CodeReader implements CodeSerializationInput {
232 240
 	public VariantOptionRef readVariantOption(TypeContext context, ITypeID type) {
233 241
 		return variantOptions.get(readUInt()).instance(type, context.getMapper());
234 242
 	}
243
+	
244
+	@Override
245
+	public AnnotationDefinition readAnnotationType() {
246
+		return annotations[readUInt()];
247
+	}
235 248
 
236 249
 	@Override
237 250
 	public ITypeID deserializeType(TypeContext context) {
@@ -344,7 +357,7 @@ public class CodeReader implements CodeSerializationInput {
344 357
 			fromLine = input.readVarUInt();
345 358
 		if ((flags & CodePositionEncoding.FLAG_FROM_OFFSET) > 0)
346 359
 			fromLineOffset = input.readVarUInt();
347
-		int toLine = lastPosition.toLine;
360
+		int toLine = fromLine;
348 361
 		if ((flags & CodePositionEncoding.FLAG_TO_LINE) > 0)
349 362
 			toLine = fromLine + input.readVarUInt();
350 363
 		int toLineOffset = lastPosition.toLineOffset;

+ 46
- 16
ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/DefinitionMemberDeserializer.java View File

@@ -9,6 +9,8 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.OperatorType;
12
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
13
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
12 14
 import org.openzen.zenscript.codemodel.context.StatementContext;
13 15
 import org.openzen.zenscript.codemodel.context.TypeContext;
14 16
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
@@ -26,6 +28,7 @@ import org.openzen.zenscript.codemodel.member.CallerMember;
26 28
 import org.openzen.zenscript.codemodel.member.CasterMember;
27 29
 import org.openzen.zenscript.codemodel.member.ConstMember;
28 30
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
31
+import org.openzen.zenscript.codemodel.member.DefinitionMember;
29 32
 import org.openzen.zenscript.codemodel.member.DestructorMember;
30 33
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
31 34
 import org.openzen.zenscript.codemodel.member.FieldMember;
@@ -99,6 +102,7 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
99 102
 			modifiers = reader.readUInt();
100 103
 		}
101 104
 		
105
+		DefinitionMember member;
102 106
 		switch (kind) {
103 107
 			case MemberEncoding.TYPE_CONST: {
104 108
 				String name = readName(flags);
@@ -106,7 +110,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
106 110
 				
107 111
 				ConstMember result = new ConstMember(position, definition, modifiers, name, type, null);
108 112
 				reader.enqueueCode(reader -> result.value = reader.deserializeExpression(new StatementContext(context)));
109
-				return result;
113
+				member = result;
114
+				break;
110 115
 			}
111 116
 			case MemberEncoding.TYPE_FIELD: {
112 117
 				String name = readName(flags);
@@ -116,7 +121,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
116 121
 				
117 122
 				FieldMember result = new FieldMember(position, definition, flags, name, context.thisType, type, context.moduleContext.registry, autoGetterAccess, autoSetterAccess, null);
118 123
 				reader.enqueueCode(reader -> result.initializer = reader.deserializeExpression(new StatementContext(context)));
119
-				return result;
124
+				member = result;
125
+				break;
120 126
 			}
121 127
 			case MemberEncoding.TYPE_CONSTRUCTOR: {
122 128
 				FunctionHeader header = reader.deserializeHeader(context);
@@ -124,7 +130,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
124 130
 				reader.enqueueCode(reader -> {
125 131
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
126 132
 				});
127
-				return result;
133
+				member = result;
134
+				break;
128 135
 			}
129 136
 			case MemberEncoding.TYPE_DESTRUCTOR: {
130 137
 				DestructorMember result = new DestructorMember(position, definition, modifiers);
@@ -132,7 +139,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
132 139
 					result.overrides = (FunctionalMemberRef)reader.readMember(context, supertype);
133 140
 					result.setBody(reader.deserializeStatement(new StatementContext(context, result.header)));
134 141
 				});
135
-				return result;
142
+				member = result;
143
+				break;
136 144
 			}
137 145
 			case MemberEncoding.TYPE_METHOD: {
138 146
 				String name = readName(flags);
@@ -142,7 +150,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
142 150
 					result.setOverrides(context.moduleContext.registry, (FunctionalMemberRef)reader.readMember(context, supertype));
143 151
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
144 152
 				});
145
-				return result;
153
+				member = result;
154
+				break;
146 155
 			}
147 156
 			case MemberEncoding.TYPE_GETTER: {
148 157
 				ITypeID type = reader.deserializeType(context);
@@ -154,7 +163,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
154 163
 					FunctionHeader header = new FunctionHeader(type);
155 164
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
156 165
 				});
157
-				return result;
166
+				member = result;
167
+				break;
158 168
 			}
159 169
 			case MemberEncoding.TYPE_SETTER: {
160 170
 				ITypeID type = reader.deserializeType(context);
@@ -166,7 +176,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
166 176
 					FunctionHeader header = new FunctionHeader(BasicTypeID.VOID, result.parameter);
167 177
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
168 178
 				});
169
-				return result;
179
+				member = result;
180
+				break;
170 181
 			}
171 182
 			case MemberEncoding.TYPE_OPERATOR: {
172 183
 				OperatorType operator = readOperator();
@@ -177,7 +188,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
177 188
 					result.setOverrides(context.moduleContext.registry, (FunctionalMemberRef)reader.readMember(context, supertype));
178 189
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
179 190
 				});
180
-				return result;
191
+				member = result;
192
+				break;
181 193
 			}
182 194
 			case MemberEncoding.TYPE_CASTER: {
183 195
 				ITypeID toType = reader.deserializeType(context);
@@ -187,7 +199,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
187 199
 					result.setOverrides(context.moduleContext.registry, (CasterMemberRef)reader.readMember(context, supertype));
188 200
 					result.setBody(reader.deserializeStatement(new StatementContext(context, new FunctionHeader(toType))));
189 201
 				});
190
-				return result;
202
+				member = result;
203
+				break;
191 204
 			}
192 205
 			case MemberEncoding.TYPE_ITERATOR: {
193 206
 				ITypeID[] types = new ITypeID[reader.readUInt()];
@@ -199,7 +212,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
199 212
 					result.setOverrides((IteratorMemberRef)reader.readMember(context, supertype));
200 213
 					result.setBody(reader.deserializeStatement(new StatementContext(context, result.header)));
201 214
 				});
202
-				return result;
215
+				member = result;
216
+				break;
203 217
 			}
204 218
 			case MemberEncoding.TYPE_CALLER: {
205 219
 				FunctionHeader header = reader.deserializeHeader(context);
@@ -209,7 +223,8 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
209 223
 					result.setOverrides(context.moduleContext.registry, (FunctionalMemberRef)reader.readMember(context, supertype));
210 224
 					result.setBody(reader.deserializeStatement(new StatementContext(context, header)));
211 225
 				});
212
-				return result;
226
+				member = result;
227
+				break;
213 228
 			}
214 229
 			case MemberEncoding.TYPE_IMPLEMENTATION: {
215 230
 				ITypeID type = reader.deserializeType(context);
@@ -217,12 +232,13 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
217 232
 				
218 233
 				int members = reader.readUInt();
219 234
 				for (int i = 0; i < members; i++) {
220
-					IDefinitionMember member = deserializeMember(context, definition, type);
221
-					result.addMember(member);
222
-					reader.add(member);
235
+					IDefinitionMember imember = deserializeMember(context, definition, type);
236
+					result.addMember(imember);
237
+					reader.add(imember);
223 238
 				}
224 239
 				
225
-				return result;
240
+				member = result;
241
+				break;
226 242
 			}
227 243
 			case MemberEncoding.TYPE_INNER_DEFINITION:
228 244
 				return null;
@@ -231,11 +247,25 @@ public class DefinitionMemberDeserializer implements DefinitionVisitorWithContex
231 247
 				reader.enqueueCode(reader -> {
232 248
 					result.body = reader.deserializeStatement(new StatementContext(context, new FunctionHeader(BasicTypeID.VOID)));
233 249
 				});
234
-				return result;
250
+				member = result;
251
+				break;
235 252
 			}
236 253
 			default:
237 254
 				throw new RuntimeException("Invalid member type: " + kind);
238 255
 		}
256
+		
257
+		if ((flags & MemberEncoding.FLAG_ANNOTATIONS) > 0) {
258
+			reader.enqueueCode(input -> {
259
+				MemberAnnotation[] annotations = new MemberAnnotation[input.readUInt()];
260
+				for (int i = 0; i < annotations.length; i++) {
261
+					AnnotationDefinition type = input.readAnnotationType();
262
+					annotations[i] = type.deserializeForMember(input, context, member);
263
+				}
264
+				member.annotations = annotations;
265
+			});
266
+			
267
+		}
268
+		return member;
239 269
 	}
240 270
 	
241 271
 	private OperatorType readOperator() {

+ 13
- 5
ModuleDeserializer/src/main/java/org/openzen/zenscript/moduledeserializer/ModuleDeserializer.java View File

@@ -75,10 +75,22 @@ public class ModuleDeserializer {
75 75
 		for (int i = 0; i < sourceFiles.length; i++)
76 76
 			sourceFiles[i] = new VirtualSourceFile(input.readString());
77 77
 		
78
+		AnnotationDefinition[] annotations = new AnnotationDefinition[input.readVarUInt()];
79
+		for (int i = 0; i < annotations.length; i++) {
80
+			String name = stringTable[input.readVarUInt()];
81
+			for (AnnotationDefinition annotation : this.annotations)
82
+				if (annotation.getAnnotationName().equals(name))
83
+					annotations[i] = annotation;
84
+			
85
+			if (annotations[i] == null)
86
+				throw new DeserializationException("Annotation type not found: " + name);
87
+		}
88
+		
78 89
 		CodeReader decoder = new CodeReader(
79 90
 				input,
80 91
 				stringTable,
81 92
 				sourceFiles,
93
+				annotations,
82 94
 				compilationUnit.globalTypeRegistry);
83 95
 		
84 96
 		DeserializingModule[] packagedModules = new DeserializingModule[decoder.readUInt()];
@@ -147,18 +159,14 @@ public class ModuleDeserializer {
147 159
 		@Override
148 160
 		public void decode(CodeSerializationInput input) throws DeserializationException {
149 161
 			int numDefinitions = input.readUInt();
150
-			DefinitionMemberDeserializer memberDeserializer = new DefinitionMemberDeserializer(reader);
151 162
 			for (int i = 0; i < numDefinitions; i++) {
152 163
 				HighLevelDefinition definition = deserializeDefinition(reader, module.context, null);
153 164
 				reader.add(definition);
154 165
 				module.add(definition);
155
-				
156
-				TypeContext typeContext = new TypeContext(module.context, definition.typeParameters, module.context.registry.getForMyDefinition(definition));
157
-				reader.members.enqueue(in -> definition.accept(typeContext, memberDeserializer));
158 166
 			}
159 167
 		}
160 168
 	}
161
-		
169
+	
162 170
 	private HighLevelDefinition deserializeDefinition(CodeReader reader, ModuleContext context, HighLevelDefinition outer) throws DeserializationException {
163 171
 		int type = reader.readUInt();
164 172
 		int flags = reader.readUInt();

+ 1
- 0
ModuleSerializationShared/src/main/java/org/openzen/zenscript/moduleserialization/DefinitionEncoding.java View File

@@ -15,6 +15,7 @@ public class DefinitionEncoding {
15 15
 	public static final int FLAG_POSITION = 1;
16 16
 	public static final int FLAG_NAME = 2;
17 17
 	public static final int FLAG_TYPE_PARAMETERS = 4;
18
+	public static final int FLAG_ANNOTATIONS = 8;
18 19
 	
19 20
 	public static final int TYPE_CLASS = 1;
20 21
 	public static final int TYPE_STRUCT = 2;

+ 1
- 0
ModuleSerializationShared/src/main/java/org/openzen/zenscript/moduleserialization/MemberEncoding.java View File

@@ -16,6 +16,7 @@ public class MemberEncoding {
16 16
 	public static final int FLAG_NAME = 2;
17 17
 	public static final int FLAG_AUTO_GETTER = 4;
18 18
 	public static final int FLAG_AUTO_SETTER = 8;
19
+	public static final int FLAG_ANNOTATIONS = 16;
19 20
 	
20 21
 	public static final int TYPE_BUILTIN = 1;
21 22
 	public static final int TYPE_CONST = 2;

+ 21
- 12
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/CodeWriter.java View File

@@ -16,6 +16,7 @@ import org.openzen.zencode.shared.SourceFile;
16 16
 import org.openzen.zenscript.codemodel.FunctionHeader;
17 17
 import org.openzen.zenscript.codemodel.FunctionParameter;
18 18
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
19
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
19 20
 import org.openzen.zenscript.codemodel.expression.CallArguments;
20 21
 import org.openzen.zenscript.codemodel.expression.Expression;
21 22
 import org.openzen.zenscript.codemodel.expression.switchvalue.SwitchValue;
@@ -50,8 +51,7 @@ import org.openzen.zenscript.moduleserializer.encoder.TypeSerializer;
50 51
 public class CodeWriter implements CodeSerializationOutput {
51 52
 	private final Map<String, Integer> stringMap = new HashMap<>();
52 53
 	private final Map<SourceFile, Integer> sourceFileMap = new HashMap<>();
53
-	
54
-	private final List<HighLevelDefinition> definitions = new ArrayList<>();
54
+	private final Map<AnnotationDefinition, Integer> annotationMap = new HashMap<>();
55 55
 	private final Map<HighLevelDefinition, Integer> definitionsMap = new HashMap<>();
56 56
 	
57 57
 	private final Map<IDefinitionMember, Integer> memberMap = new HashMap<>();
@@ -78,7 +78,9 @@ public class CodeWriter implements CodeSerializationOutput {
78 78
 			SerializationOptions options,
79 79
 			String[] strings,
80 80
 			SourceFile[] sourceFiles,
81
-			List<IDefinitionMember> members)
81
+			HighLevelDefinition[] definitions,
82
+			List<IDefinitionMember> members,
83
+			AnnotationDefinition[] annotations)
82 84
 	{
83 85
 		this.output = output;
84 86
 		this.options = options;
@@ -93,8 +95,12 @@ public class CodeWriter implements CodeSerializationOutput {
93 95
 			stringMap.put(string, stringMap.size());
94 96
 		for (SourceFile sourceFile : sourceFiles)
95 97
 			sourceFileMap.put(sourceFile, sourceFileMap.size());
98
+		for (HighLevelDefinition definition : definitions)
99
+			definitionsMap.put(definition, definitionsMap.size());
96 100
 		for (IDefinitionMember member : members)
97 101
 			memberMap.put(member, memberMap.size());
102
+		for (AnnotationDefinition annotation : annotations)
103
+			annotationMap.put(annotation, annotationMap.size());
98 104
 	}
99 105
 	
100 106
 	public void startClasses() {
@@ -109,11 +115,6 @@ public class CodeWriter implements CodeSerializationOutput {
109 115
 		currentStage = code;
110 116
 	}
111 117
 	
112
-	public void add(HighLevelDefinition definition) {
113
-		definitions.add(definition);
114
-		definitionsMap.put(definition, definitions.size());
115
-	}
116
-	
117 118
 	public void add(SourceFile file) {
118 119
 		sourceFileMap.put(file, sourceFileMap.size());
119 120
 	}
@@ -198,7 +199,8 @@ public class CodeWriter implements CodeSerializationOutput {
198 199
 		if (!definitionsMap.containsKey(definition))
199 200
 			throw new IllegalStateException("Definition not yet prepared: " + definition.name);
200 201
 		
201
-		output.writeVarUInt(definitionsMap.get(definition) + 1);
202
+		int id = definitionsMap.get(definition) + 1;
203
+		output.writeVarUInt(id);
202 204
 	}
203 205
 	
204 206
 	@Override
@@ -235,6 +237,11 @@ public class CodeWriter implements CodeSerializationOutput {
235 237
 		writeUInt(definition.getTag(EncodingDefinition.class).variantOptions.indexOf(option));
236 238
 	}
237 239
 	
240
+	@Override
241
+	public void write(AnnotationDefinition annotationType) {
242
+		writeUInt(annotationMap.get(annotationType));
243
+	}
244
+	
238 245
 	@Override
239 246
 	public void serialize(TypeContext context, ITypeID type) {
240 247
 		if (type == null) {
@@ -280,9 +287,11 @@ public class CodeWriter implements CodeSerializationOutput {
280 287
 	
281 288
 	private void serializeRemaining(int flags, TypeContext context, TypeParameter parameter) {
282 289
 		if (currentStage == code || currentStage == members) {
283
-			output.writeVarUInt(parameter.bounds.size());
284
-			for (TypeParameterBound bound : parameter.bounds)
285
-				bound.accept(context, typeParameterEncoder);
290
+			if ((flags & TypeParameterEncoding.FLAG_BOUNDS) > 0) {
291
+				writeUInt(parameter.bounds.size());
292
+				for (TypeParameterBound bound : parameter.bounds)
293
+					bound.accept(context, typeParameterEncoder);
294
+			}
286 295
 		} else {
287 296
 			members.enqueue(encoder -> {
288 297
 				if ((flags & TypeParameterEncoding.FLAG_BOUNDS) > 0) {

+ 17
- 2
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/ModuleSerializer.java View File

@@ -12,6 +12,7 @@ import java.util.List;
12 12
 import org.openzen.zencode.shared.SourceFile;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14 14
 import org.openzen.zenscript.codemodel.ScriptBlock;
15
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
15 16
 import org.openzen.zenscript.codemodel.context.ModuleContext;
16 17
 import org.openzen.zenscript.codemodel.statement.Statement;
17 18
 import org.openzen.zenscript.compiler.SemanticModule;
@@ -61,9 +62,19 @@ public class ModuleSerializer {
61 62
 			}
62 63
 		}
63 64
 		
65
+		List<HighLevelDefinition> definitions = new ArrayList<>();
66
+		for (EncodingModule module : tableBuilder.modules) {
67
+			for (EncodingDefinition definition : module.definitions)
68
+				definitions.add(definition.definition);
69
+		}
70
+		
71
+		for (AnnotationDefinition annotation : tableBuilder.getAnnotations())
72
+			tableBuilder.writeString(annotation.getAnnotationName());
73
+		
64 74
 		SourceFile[] sourceFiles = tableBuilder.getSourceFileList();
65 75
 		String[] strings = tableBuilder.getStrings();
66 76
 		List<IDefinitionMember> members = tableBuilder.getMembers();
77
+		AnnotationDefinition[] annotations = tableBuilder.getAnnotations();
67 78
 		
68 79
 		CompactBytesDataOutput output = new CompactBytesDataOutput();
69 80
 		CodeWriter encoder = new CodeWriter(
@@ -71,7 +82,9 @@ public class ModuleSerializer {
71 82
 				options,
72 83
 				strings,
73 84
 				sourceFiles,
74
-				members);
85
+				definitions.toArray(new HighLevelDefinition[definitions.size()]),
86
+				members,
87
+				annotations);
75 88
 		
76 89
 		output.writeInt(0x5A43424D); // 'ZCBM' = ZenCode Binary Module
77 90
 		output.writeVarUInt(0); // version
@@ -79,6 +92,9 @@ public class ModuleSerializer {
79 92
 		output.writeVarUInt(sourceFiles.length);
80 93
 		for (SourceFile file : sourceFiles)
81 94
 			output.writeString(file.getFilename());
95
+		output.writeVarUInt(annotations.length);
96
+		for (AnnotationDefinition annotation : annotations)
97
+			encoder.writeString(annotation.getAnnotationName());
82 98
 		
83 99
 		encoder.writeUInt(encodingModules.size());
84 100
 		System.out.println("Encoding list of modules");
@@ -162,7 +178,6 @@ public class ModuleSerializer {
162 178
 			for (EncodingDefinition definition : module.definitions) {
163 179
 				System.out.println("Encoding definition " + definition.definition.name);
164 180
 				definition.definition.accept(module.context, definitionEncoder);
165
-				encoder.add(definition.definition);
166 181
 			}
167 182
 		}
168 183
 	}

+ 11
- 0
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/TableBuilder.java View File

@@ -18,6 +18,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
18 18
 import org.openzen.zenscript.codemodel.FunctionParameter;
19 19
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
20 20
 import org.openzen.zenscript.codemodel.Module;
21
+import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
21 22
 import org.openzen.zenscript.codemodel.context.ModuleContext;
22 23
 import org.openzen.zenscript.codemodel.context.StatementContext;
23 24
 import org.openzen.zenscript.codemodel.context.TypeContext;
@@ -55,6 +56,7 @@ public class TableBuilder implements CodeSerializationOutput {
55 56
 	private final Set<SourceFile> sourceFiles = new HashSet<>();
56 57
 	public final List<EncodingModule> modules = new ArrayList<>();
57 58
 	private final List<IDefinitionMember> members = new ArrayList<>();
59
+	private final Set<AnnotationDefinition> annotations = new HashSet<>();
58 60
 	
59 61
 	private final SerializationOptions options;
60 62
 	
@@ -109,6 +111,10 @@ public class TableBuilder implements CodeSerializationOutput {
109 111
 		return members;
110 112
 	}
111 113
 	
114
+	public AnnotationDefinition[] getAnnotations() {
115
+		return annotations.toArray(new AnnotationDefinition[annotations.size()]);
116
+	}
117
+	
112 118
 	private EncodingDefinition prepare(HighLevelDefinition definition) {
113 119
 		register(definition.module, null);
114 120
 		
@@ -194,6 +200,11 @@ public class TableBuilder implements CodeSerializationOutput {
194 200
 				members.add(member.getTarget());
195 201
 		}
196 202
 	}
203
+	
204
+	@Override
205
+	public void write(AnnotationDefinition annotationType) {
206
+		annotations.add(annotationType);
207
+	}
197 208
 
198 209
 	@Override
199 210
 	public void serialize(TypeContext context, IDefinitionMember member) {

+ 0
- 4
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/DefinitionMemberSerializer.java View File

@@ -43,10 +43,6 @@ public class DefinitionMemberSerializer implements DefinitionVisitorWithContext<
43 43
 	private EncodingDefinition visit(TypeContext context, HighLevelDefinition definition) {
44 44
 		EncodingDefinition encoding = definition.getTag(EncodingDefinition.class);
45 45
 		
46
-		for (DefinitionAnnotation annotation : definition.annotations) {
47
-			// TODO: how to serialize annotations?
48
-		}
49
-		
50 46
 		output.serialize(context, definition.getSuperType());
51 47
 		
52 48
 		output.writeUInt(encoding.members.size());

+ 15
- 3
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/DefinitionSerializer.java View File

@@ -10,6 +10,7 @@ import java.util.List;
10 10
 import org.openzen.zenscript.codemodel.context.TypeContext;
11 11
 import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
+import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
13 14
 import org.openzen.zenscript.codemodel.context.ModuleContext;
14 15
 import org.openzen.zenscript.codemodel.definition.AliasDefinition;
15 16
 import org.openzen.zenscript.codemodel.definition.ClassDefinition;
@@ -20,7 +21,6 @@ import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
20 21
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
21 22
 import org.openzen.zenscript.codemodel.definition.StructDefinition;
22 23
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
23
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
24 24
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25 25
 import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
26 26
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
@@ -48,6 +48,8 @@ public class DefinitionSerializer implements DefinitionVisitorWithContext<Module
48 48
 			flags |= DefinitionEncoding.FLAG_NAME;
49 49
 		if (definition.typeParameters.length > 0)
50 50
 			flags |= DefinitionEncoding.FLAG_TYPE_PARAMETERS;
51
+		if (definition.annotations.length > 0)
52
+			flags |= DefinitionEncoding.FLAG_ANNOTATIONS;
51 53
 		
52 54
 		output.writeUInt(flags);
53 55
 		output.writeUInt(definition.modifiers);
@@ -56,9 +58,19 @@ public class DefinitionSerializer implements DefinitionVisitorWithContext<Module
56 58
 		output.writeString(definition.pkg.fullName);
57 59
 		if (definition.name != null)
58 60
 			output.writeString(definition.name);
59
-		if (definition.typeParameters.length > 0) {
60
-			TypeContext typeContext = new TypeContext(context, TypeParameter.NONE, null);
61
+		
62
+		TypeContext typeContext = new TypeContext(context, definition.typeParameters, null);
63
+		if (definition.typeParameters.length > 0)
61 64
 			output.serialize(typeContext, definition.typeParameters);
65
+		
66
+		if (definition.annotations.length > 0) {
67
+			output.enqueueCode(output -> {
68
+				output.writeUInt(definition.annotations.length);
69
+				for (DefinitionAnnotation annotation : definition.annotations) {
70
+					output.write(annotation.getDefinition());
71
+					annotation.serialize(output, definition, typeContext);
72
+				}
73
+			});
62 74
 		}
63 75
 	}
64 76
 	

+ 27
- 15
ModuleSerializer/src/main/java/org/openzen/zenscript/moduleserializer/encoder/MemberSerializer.java View File

@@ -10,6 +10,7 @@ import org.openzen.zenscript.codemodel.context.StatementContext;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.FunctionHeader;
12 12
 import org.openzen.zenscript.codemodel.OperatorType;
13
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
13 14
 import org.openzen.zenscript.codemodel.member.CallerMember;
14 15
 import org.openzen.zenscript.codemodel.member.CasterMember;
15 16
 import org.openzen.zenscript.codemodel.member.ConstMember;
@@ -29,7 +30,6 @@ import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
29 30
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationOutput;
30 31
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
31 32
 import org.openzen.zenscript.codemodel.type.ITypeID;
32
-import org.openzen.zenscript.codemodel.type.IteratorTypeID;
33 33
 import org.openzen.zenscript.moduleserialization.MemberEncoding;
34 34
 import org.openzen.zenscript.moduleserializer.SerializationOptions;
35 35
 
@@ -50,16 +50,28 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
50 50
 		int flags = 0;
51 51
 		if (member.getPosition() != CodePosition.UNKNOWN && options.positions)
52 52
 			flags |= MemberEncoding.FLAG_POSITION;
53
+		if (member.getAnnotations().length > 0)
54
+			flags |= MemberEncoding.FLAG_ANNOTATIONS;
53 55
 		
54 56
 		return flags;
55 57
 	}
56 58
 	
57
-	private void serialize(int flags, IDefinitionMember member) {
59
+	private void serialize(int flags, TypeContext context, IDefinitionMember member) {
58 60
 		output.writeUInt(flags);
59 61
 		if ((flags & MemberEncoding.FLAG_POSITION) > 0)
60 62
 			output.serialize(member.getPosition());
61 63
 		
62 64
 		output.writeUInt(member.getModifiers());
65
+		
66
+		if (member.getAnnotations().length > 0) {
67
+			output.enqueueCode(output -> {
68
+				output.writeUInt(member.getAnnotations().length);
69
+				for (MemberAnnotation annotation : member.getAnnotations()) {
70
+					output.write(annotation.getDefinition());
71
+					annotation.serialize(output, member, context);
72
+				}
73
+			});
74
+		}
63 75
 	}
64 76
 	
65 77
 	private void writeName(int flags, String name) {
@@ -75,7 +87,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
75 87
 		if (member.name != null)
76 88
 			flags |= MemberEncoding.FLAG_NAME;
77 89
 		
78
-		serialize(flags, member);
90
+		serialize(flags, context, member);
79 91
 		if ((flags & MemberEncoding.FLAG_NAME) > 0)
80 92
 			output.writeString(member.name);
81 93
 		
@@ -96,7 +108,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
96 108
 		if (member.autoSetterAccess != 0)
97 109
 			flags |= MemberEncoding.FLAG_AUTO_SETTER;
98 110
 		
99
-		serialize(flags, member);
111
+		serialize(flags, context, member);
100 112
 		writeName(flags, member.name);
101 113
 		if ((flags & MemberEncoding.FLAG_AUTO_GETTER) > 0)
102 114
 			output.writeUInt(member.autoGetterAccess);
@@ -113,7 +125,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
113 125
 		output.writeUInt(MemberEncoding.TYPE_CONSTRUCTOR);
114 126
 		
115 127
 		int flags = getFlags(member);
116
-		serialize(flags, member);
128
+		serialize(flags, context, member);
117 129
 		
118 130
 		StatementContext inner = new StatementContext(context, member.header);
119 131
 		output.serialize(inner, member.header);
@@ -128,7 +140,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
128 140
 	public Void visitDestructor(TypeContext context, DestructorMember member) {
129 141
 		output.writeUInt(MemberEncoding.TYPE_DESTRUCTOR);
130 142
 		int flags = getFlags(member);
131
-		serialize(flags, member);
143
+		serialize(flags, context, member);
132 144
 		
133 145
 		output.enqueueCode(encoder -> {
134 146
 			encoder.write(context, member.overrides);
@@ -143,7 +155,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
143 155
 		int flags = getFlags(member);
144 156
 		if (member.name != null)
145 157
 			flags |= MemberEncoding.FLAG_NAME;
146
-		serialize(flags, member);
158
+		serialize(flags, context, member);
147 159
 		writeName(flags, member.name);
148 160
 		
149 161
 		StatementContext inner = new StatementContext(context, member.header);
@@ -162,7 +174,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
162 174
 		int flags = getFlags(member);
163 175
 		if (member.name != null)
164 176
 			flags |= MemberEncoding.FLAG_NAME;
165
-		serialize(flags, member);
177
+		serialize(flags, context, member);
166 178
 		output.serialize(context, member.type);
167 179
 		writeName(flags, member.name);
168 180
 		
@@ -177,7 +189,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
177 189
 	public Void visitSetter(TypeContext context, SetterMember member) {
178 190
 		output.writeUInt(MemberEncoding.TYPE_SETTER);
179 191
 		int flags = getFlags(member);
180
-		serialize(flags, member);
192
+		serialize(flags, context, member);
181 193
 		output.serialize(context, member.type);
182 194
 		writeName(flags, member.name);
183 195
 		
@@ -195,7 +207,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
195 207
 	public Void visitOperator(TypeContext context, OperatorMember member) {
196 208
 		output.writeUInt(MemberEncoding.TYPE_OPERATOR);
197 209
 		int flags = getFlags(member);
198
-		serialize(flags, member);
210
+		serialize(flags, context, member);
199 211
 		output.writeUInt(getId(member.operator));
200 212
 		
201 213
 		StatementContext inner = new StatementContext(context, member.header);
@@ -212,7 +224,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
212 224
 	public Void visitCaster(TypeContext context, CasterMember member) {
213 225
 		output.writeUInt(MemberEncoding.TYPE_CASTER);
214 226
 		int flags = getFlags(member);
215
-		serialize(flags, member);
227
+		serialize(flags, context, member);
216 228
 		output.serialize(context, member.toType);
217 229
 		
218 230
 		output.enqueueCode(encoder -> {
@@ -228,7 +240,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
228 240
 	public Void visitIterator(TypeContext context, IteratorMember member) {
229 241
 		output.writeUInt(MemberEncoding.TYPE_ITERATOR);
230 242
 		int flags = getFlags(member);
231
-		serialize(flags, member);
243
+		serialize(flags, context, member);
232 244
 		output.writeUInt(member.getLoopVariableCount());
233 245
 		for (ITypeID type : member.getLoopVariableTypes())
234 246
 			output.serialize(context, type);
@@ -246,7 +258,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
246 258
 	public Void visitCaller(TypeContext context, CallerMember member) {
247 259
 		output.writeUInt(MemberEncoding.TYPE_CALLER);
248 260
 		int flags = getFlags(member);
249
-		serialize(flags, member);
261
+		serialize(flags, context, member);
250 262
 		
251 263
 		StatementContext inner = new StatementContext(context, member.header);
252 264
 		output.serialize(inner, member.header);
@@ -262,7 +274,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
262 274
 	public Void visitImplementation(TypeContext context, ImplementationMember member) {
263 275
 		output.writeUInt(MemberEncoding.TYPE_IMPLEMENTATION);
264 276
 		int flags = getFlags(member);
265
-		serialize(flags, member);
277
+		serialize(flags, context, member);
266 278
 		output.serialize(context, member.type);
267 279
 		
268 280
 		output.writeUInt(member.members.size());
@@ -282,7 +294,7 @@ public class MemberSerializer implements MemberVisitorWithContext<TypeContext, V
282 294
 	public Void visitStaticInitializer(TypeContext context, StaticInitializerMember member) {
283 295
 		output.writeUInt(MemberEncoding.TYPE_STATIC_INITIALIZER);
284 296
 		int flags = getFlags(member);
285
-		serialize(flags, member);
297
+		serialize(flags, context, member);
286 298
 		
287 299
 		output.enqueueCode(encoder -> {
288 300
 			encoder.serialize(new StatementContext(context, new FunctionHeader(BasicTypeID.VOID)), member.body);

Loading…
Cancel
Save