Ver código fonte

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

kindlich 6 anos atrás
pai
commit
e5dd5f08fe
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados
100 arquivos alterados com 1149 adições e 207 exclusões
  1. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java
  2. 80
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  3. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/Modifiers.java
  4. 13
    7
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java
  5. 9
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java
  6. 29
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java
  7. 10
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  8. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java
  9. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java
  10. 16
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java
  11. 12
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java
  12. 7
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java
  13. 6
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java
  14. 11
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java
  15. 13
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java
  16. 9
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DestructorMember.java
  17. 7
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  18. 1
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java
  19. 17
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java
  20. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java
  21. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ImplementationMember.java
  22. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java
  23. 24
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MethodMember.java
  24. 14
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/OperatorMember.java
  25. 16
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/SetterMember.java
  26. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java
  27. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java
  28. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java
  29. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java
  30. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java
  31. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java
  32. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/CasterMemberRef.java
  33. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java
  34. 8
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/DefinitionMemberRef.java
  35. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FieldMemberRef.java
  36. 22
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java
  37. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/GetterMemberRef.java
  38. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ImplementationMemberRef.java
  39. 22
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/IteratorMemberRef.java
  40. 17
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/SetterMemberRef.java
  41. 0
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java
  42. 7
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/TypeScope.java
  43. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  44. 24
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java
  45. 19
    5
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  46. 1
    1
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java
  47. 3
    0
      Constructor/src/main/java/org/openzen/zenscript/constructor/Module.java
  48. 2
    1
      Constructor/src/main/java/org/openzen/zenscript/constructor/module/DirectoryModuleReference.java
  49. 0
    22
      Constructor/src/main/java/org/openzen/zenscript/constructor/module/SourceFile.java
  50. 3
    1
      Constructor/src/main/java/org/openzen/zenscript/constructor/module/SourcePackage.java
  51. 2
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java
  52. 25
    0
      IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeError.java
  53. 41
    0
      IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeSpace.java
  54. 6
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/IDEModule.java
  55. 2
    3
      IDE/src/main/java/org/openzen/zenscript/ide/host/IDESourceFile.java
  56. 10
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalModule.java
  57. 3
    2
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalPackage.java
  58. 12
    13
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalSourceFile.java
  59. 5
    5
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalTarget.java
  60. 48
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/PathGenerator.java
  61. 42
    24
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  62. 5
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourcePosition.java
  63. 10
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenLine.java
  64. 15
    6
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenModel.java
  65. 5
    4
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenRelexer.java
  66. 47
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/WavyLine.java
  67. 1
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java
  68. 5
    6
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  69. 0
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaOptionalTypeClassVisitor.java
  70. 1
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java
  71. 0
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaTypeClassVisitor.java
  72. 9
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaWriter.java
  73. 8
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/BaseMemberCompiler.java
  74. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java
  75. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java
  76. 25
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java
  77. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceCompiler.java
  78. 0
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceObjectTypeVisitor.java
  79. 2
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceStatementFormatter.java
  80. 0
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeNameVisitor.java
  81. 0
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java
  82. 19
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareClassMethodVisitor.java
  83. 24
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareDefinitionVisitor.java
  84. 11
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareExpansionMethodVisitor.java
  85. 14
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourceSignatureVisitor.java
  86. 20
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceImplementation.java
  87. 6
    5
      Parser/src/main/java/org/openzen/zenscript/lexer/CountingCharReader.java
  88. 9
    7
      Parser/src/main/java/org/openzen/zenscript/lexer/TokenParser.java
  89. 7
    6
      Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenParser.java
  90. 3
    1
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedDefinition.java
  91. 21
    19
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java
  92. 61
    0
      Parser/src/main/java/org/openzen/zenscript/parser/PrecompilationState.java
  93. 10
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/BaseParsedDefinition.java
  94. 7
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java
  95. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java
  96. 4
    3
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java
  97. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java
  98. 18
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java
  99. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunctionHeader.java
  100. 0
    0
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java Ver arquivo

@@ -78,7 +78,7 @@ public class FormattingUtils {
78 78
 			if (parameter.variadic)
79 79
 				result.append("...");
80 80
 			
81
-			if (!settings.showAnyInFunctionHeaders || parameter.type != BasicTypeID.ANY) {
81
+			if (!settings.showAnyInFunctionHeaders || parameter.type != BasicTypeID.UNDETERMINED) {
82 82
 				result.append(" as ");
83 83
 				result.append(header.returnType.accept(typeFormatter));
84 84
 			}
@@ -86,7 +86,7 @@ public class FormattingUtils {
86 86
 			parameterIndex++;
87 87
 		}
88 88
 		result.append(")");
89
-		if (!settings.showAnyInFunctionHeaders || header.returnType != BasicTypeID.ANY) {
89
+		if (!settings.showAnyInFunctionHeaders || header.returnType != BasicTypeID.UNDETERMINED) {
90 90
 			result.append(" as ");
91 91
 			result.append(header.returnType.accept(typeFormatter));
92 92
 		}

+ 80
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java Ver arquivo

@@ -5,6 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel;
7 7
 
8
+import java.util.Arrays;
9
+import java.util.Collections;
8 10
 import java.util.HashMap;
9 11
 import java.util.List;
10 12
 import java.util.Map;
@@ -15,6 +17,7 @@ import org.openzen.zenscript.codemodel.type.BasicTypeID;
15 17
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
16 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
17 19
 import org.openzen.zenscript.codemodel.scope.TypeScope;
20
+import org.openzen.zenscript.codemodel.type.GenericTypeID;
18 21
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
19 22
 
20 23
 /**
@@ -31,6 +34,7 @@ public class FunctionHeader {
31 34
 	
32 35
 	public final int minParameters;
33 36
 	public final int maxParameters;
37
+	public final boolean hasUnknowns;
34 38
 	
35 39
 	public FunctionHeader(ITypeID returnType) {
36 40
 		if (returnType == null)
@@ -43,6 +47,7 @@ public class FunctionHeader {
43 47
 		
44 48
 		minParameters = 0;
45 49
 		maxParameters = 0;
50
+		hasUnknowns = returnType == BasicTypeID.UNDETERMINED;
46 51
 	}
47 52
 	
48 53
 	public FunctionHeader(ITypeID returnType, ITypeID... parameterTypes) {
@@ -59,6 +64,7 @@ public class FunctionHeader {
59 64
 		
60 65
 		minParameters = parameterTypes.length;
61 66
 		maxParameters = parameterTypes.length;
67
+		hasUnknowns = hasUnknowns(parameterTypes);
62 68
 	}
63 69
 	
64 70
 	public FunctionHeader(ITypeID returnType, FunctionParameter... parameters) {
@@ -72,6 +78,7 @@ public class FunctionHeader {
72 78
 		
73 79
 		minParameters = getMinParameters(parameters);
74 80
 		maxParameters = getMaxParameters(parameters);
81
+		hasUnknowns = hasUnknowns(parameters);
75 82
 	}
76 83
 	
77 84
 	public FunctionHeader(TypeParameter[] genericParameters, ITypeID returnType, ITypeID thrownType, FunctionParameter... parameters) {
@@ -87,12 +94,50 @@ public class FunctionHeader {
87 94
 		
88 95
 		minParameters = getMinParameters(parameters);
89 96
 		maxParameters = getMaxParameters(parameters);
97
+		hasUnknowns = hasUnknowns(parameters);
90 98
 	}
91 99
 	
92 100
 	public int getNumberOfTypeParameters() {
93 101
 		return typeParameters.length;
94 102
 	}
95 103
 	
104
+	public FunctionHeader withReturnType(ITypeID returnType) {
105
+		return new FunctionHeader(typeParameters, returnType, thrownType, parameters);
106
+	}
107
+	
108
+	public FunctionHeader inferFromOverride(GlobalTypeRegistry registry, FunctionHeader overridden) {
109
+		TypeParameter[] resultTypeParameters = typeParameters;
110
+		GenericMapper mapper;
111
+		if (resultTypeParameters == TypeParameter.NONE) {
112
+			resultTypeParameters = overridden.typeParameters;
113
+			mapper = new GenericMapper(registry, Collections.emptyMap());
114
+		} else {
115
+			Map<TypeParameter, ITypeID> mapping = new HashMap<>();
116
+			for (int i = 0; i < overridden.typeParameters.length; i++)
117
+				mapping.put(overridden.typeParameters[i], new GenericTypeID(typeParameters[i]));
118
+			mapper = new GenericMapper(registry, mapping);
119
+		}
120
+		
121
+		ITypeID resultReturnType = this.returnType;
122
+		if (resultReturnType == BasicTypeID.UNDETERMINED)
123
+			resultReturnType = overridden.returnType.instance(mapper);
124
+		
125
+		ITypeID resultThrownType = this.thrownType;
126
+		if (resultThrownType == null && overridden.thrownType != null)
127
+			resultThrownType = overridden.thrownType.instance(mapper);
128
+		
129
+		FunctionParameter[] resultParameters = Arrays.copyOf(parameters, parameters.length);
130
+		for (int i = 0; i < resultParameters.length; i++) {
131
+			if (resultParameters[i].type == BasicTypeID.UNDETERMINED) {
132
+				FunctionParameter parameter = resultParameters[i];
133
+				FunctionParameter original = overridden.parameters[i];
134
+				resultParameters[i] = new FunctionParameter(original.type.instance(mapper), parameter.name, parameter.defaultValue, original.variadic);
135
+			}
136
+		}
137
+		
138
+		return new FunctionHeader(resultTypeParameters, resultReturnType, resultThrownType, resultParameters);
139
+	}
140
+	
96 141
 	public boolean matchesExactly(CallArguments arguments, TypeScope scope) {
97 142
 		if (arguments.arguments.length < minParameters || arguments.arguments.length > maxParameters)
98 143
 			return false;
@@ -211,6 +256,25 @@ public class FunctionHeader {
211 256
 		return true;
212 257
 	}
213 258
 	
259
+	public boolean canOverride(TypeScope scope, FunctionHeader other) {
260
+		if (parameters.length != other.parameters.length)
261
+			return false;
262
+		if (returnType != BasicTypeID.UNDETERMINED && !scope.getTypeMembers(returnType).canCastImplicit(other.returnType))
263
+			return false;
264
+		
265
+		for (int i = 0; i < parameters.length; i++) {
266
+			if (parameters[i].type == BasicTypeID.UNDETERMINED)
267
+				continue;
268
+			
269
+			if (parameters[i].variadic != other.parameters[i].variadic)
270
+				return false;
271
+			if (!scope.getTypeMembers(other.parameters[i].type).canCastImplicit(parameters[i].type))
272
+				return false;
273
+		}
274
+		
275
+		return true;
276
+	}
277
+	
214 278
 	/**
215 279
 	 * Checks if two function headers are equivalent. Functions headers are
216 280
 	 * equivalent if their types are the same.
@@ -361,4 +425,20 @@ public class FunctionHeader {
361 425
 		
362 426
 		return parameters[parameters.length - 1].variadic ? Integer.MAX_VALUE : parameters.length;
363 427
 	}
428
+	
429
+	private static boolean hasUnknowns(ITypeID[] types) {
430
+		for (ITypeID type : types)
431
+			if (type == BasicTypeID.UNDETERMINED)
432
+				return true;
433
+		
434
+		return false;
435
+	}
436
+	
437
+	private static boolean hasUnknowns(FunctionParameter[] parameters) {
438
+		for (FunctionParameter parameter : parameters)
439
+			if (parameter.type == BasicTypeID.UNDETERMINED)
440
+				return true;
441
+		
442
+		return false;
443
+	}
364 444
 }

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/Modifiers.java Ver arquivo

@@ -73,4 +73,8 @@ public class Modifiers {
73 73
 	public static boolean isExtern(int modifiers) {
74 74
 		return (modifiers & EXTERN) > 0;
75 75
 	}
76
+	
77
+	public static boolean isOverride(int modifiers) {
78
+		return (modifiers & OVERRIDE) > 0;
79
+	}
76 80
 }

+ 13
- 7
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java Ver arquivo

@@ -32,6 +32,8 @@ import org.openzen.zenscript.codemodel.member.MethodMember;
32 32
 import org.openzen.zenscript.codemodel.member.OperatorMember;
33 33
 import org.openzen.zenscript.codemodel.member.SetterMember;
34 34
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
35
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
36
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
35 37
 import org.openzen.zenscript.codemodel.scope.DefinitionScope;
36 38
 import org.openzen.zenscript.codemodel.scope.FileScope;
37 39
 import org.openzen.zenscript.codemodel.scope.FunctionScope;
@@ -187,7 +189,11 @@ public class AnnotationProcessor implements ModuleProcessor {
187 189
 		@Override
188 190
 		public Void visitStaticInitializer(StaticInitializerMember member) {
189 191
 			StatementScope scope = new FunctionScope(this.scope, new FunctionHeader(BasicTypeID.VOID));
190
-			member.body = process(member.body, scope);
192
+			if (member.body == null) {
193
+				throw new IllegalStateException("No body in static initializer @ " + member.position);
194
+			} else {
195
+				member.body = process(member.body, scope);
196
+			}
191 197
 			return null;
192 198
 		}
193 199
 		
@@ -195,8 +201,8 @@ public class AnnotationProcessor implements ModuleProcessor {
195 201
 			for (MemberAnnotation annotation : member.annotations)
196 202
 				annotation.apply(member, scope);
197 203
 			
198
-			if (member.overrides != null) {
199
-				functional(member, member.overrides);
204
+			if (member.getOverrides() != null) {
205
+				functional(member, member.getOverrides());
200 206
 			}
201 207
 			
202 208
 			if (member.body == null)
@@ -207,12 +213,12 @@ public class AnnotationProcessor implements ModuleProcessor {
207 213
 			return null;
208 214
 		}
209 215
 		
210
-		private void functional(FunctionalMember member, FunctionalMember overrides) {
211
-			for (MemberAnnotation annotation : overrides.annotations)
216
+		private void functional(FunctionalMember member, DefinitionMemberRef overrides) {
217
+			for (MemberAnnotation annotation : overrides.getAnnotations())
212 218
 				annotation.applyOnOverridingMethod(member, scope);
213 219
 			
214
-			if (overrides.overrides != null) {
215
-				functional(member, overrides.overrides);
220
+			if (overrides.getOverrides() != null) {
221
+				functional(member, overrides.getOverrides());
216 222
 			}
217 223
 		}
218 224
 	}

+ 9
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java Ver arquivo

@@ -18,20 +18,19 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
18 18
  * @author Hoofdgebruiker
19 19
  */
20 20
 public class CallArguments {
21
-	public static final ITypeID[] NO_TYPE_ARGUMENTS = new ITypeID[0];
22 21
 	public static final CallArguments EMPTY = new CallArguments(new Expression[0]);
23 22
 	
24 23
 	public final ITypeID[] typeArguments;
25 24
 	public final Expression[] arguments;
26 25
 	
27 26
 	public CallArguments(Expression... arguments) {
28
-		this.typeArguments = NO_TYPE_ARGUMENTS;
27
+		this.typeArguments = ITypeID.NONE;
29 28
 		this.arguments = arguments;
30 29
 	}
31 30
 	
32 31
 	public CallArguments(ITypeID[] typeArguments, Expression[] arguments) {
33 32
 		if (typeArguments == null)
34
-			typeArguments = NO_TYPE_ARGUMENTS;
33
+			typeArguments = ITypeID.NONE;
35 34
 		if (arguments == null)
36 35
 			throw new IllegalArgumentException("Arguments cannot be null!");
37 36
 		
@@ -39,6 +38,13 @@ public class CallArguments {
39 38
 		this.arguments = arguments;
40 39
 	}
41 40
 	
41
+	public CallArguments(ITypeID... dummy) {
42
+		this.typeArguments = ITypeID.NONE;
43
+		this.arguments = new Expression[dummy.length];
44
+		for (int i = 0; i < dummy.length; i++)
45
+			arguments[i] = new DummyExpression(dummy[i]);
46
+	}
47
+	
42 48
 	public int getNumberOfTypeArguments() {
43 49
 		return typeArguments.length;
44 50
 	}

+ 29
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/DummyExpression.java Ver arquivo

@@ -0,0 +1,29 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.expression;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class DummyExpression extends Expression {
16
+	public DummyExpression(ITypeID type) {
17
+		super(CodePosition.BUILTIN, type, null);
18
+	}
19
+
20
+	@Override
21
+	public <T> T accept(ExpressionVisitor<T> visitor) {
22
+		throw new UnsupportedOperationException("This is a dummy expression");
23
+	}
24
+
25
+	@Override
26
+	public Expression transform(ExpressionTransformer transformer) {
27
+		throw new UnsupportedOperationException("This is a dummy expression");
28
+	}
29
+}

+ 10
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java Ver arquivo

@@ -81,6 +81,16 @@ public abstract class Expression implements IPartialExpression {
81 81
 		return scope.getTypeMembers(type).castImplicit(position, this, asType, true);
82 82
 	}
83 83
 	
84
+	/**
85
+	 * Determines if this expression aborts execution; that is, it is either a
86
+	 * throw or a panic expression.
87
+	 * 
88
+	 * @return abort flag
89
+	 */
90
+	public boolean aborts() {
91
+		return false;
92
+	}
93
+	
84 94
 	@Override
85 95
 	public List<ITypeID>[] predictCallTypes(TypeScope scope, List<ITypeID> hints, int arguments) {
86 96
 		return scope.getTypeMembers(type).getOrCreateGroup(OperatorType.CALL).predictCallTypes(scope, hints, arguments);

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/PanicExpression.java Ver arquivo

@@ -20,6 +20,11 @@ public class PanicExpression extends Expression {
20 20
 		
21 21
 		this.value = value;
22 22
 	}
23
+	
24
+	@Override
25
+	public boolean aborts() {
26
+		return true;
27
+	}
23 28
 
24 29
 	@Override
25 30
 	public <T> T accept(ExpressionVisitor<T> visitor) {

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ThrowExpression.java Ver arquivo

@@ -20,6 +20,11 @@ public class ThrowExpression extends Expression {
20 20
 		
21 21
 		this.value = value;
22 22
 	}
23
+	
24
+	@Override
25
+	public boolean aborts() {
26
+		return true;
27
+	}
23 28
 
24 29
 	@Override
25 30
 	public <T> T accept(ExpressionVisitor<T> visitor) {

+ 16
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CallerMember.java Ver arquivo

@@ -9,6 +9,9 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -18,6 +21,8 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 21
  * @author Hoofdgebruiker
19 22
  */
20 23
 public class CallerMember extends FunctionalMember {
24
+	public FunctionalMemberRef overrides;
25
+	
21 26
 	public CallerMember(
22 27
 			CodePosition position,
23 28
 			HighLevelDefinition definition,
@@ -25,7 +30,7 @@ public class CallerMember extends FunctionalMember {
25 30
 			FunctionHeader header,
26 31
 			BuiltinID builtin)
27 32
 	{
28
-		super(position, definition, modifiers, "()", header, builtin);
33
+		super(position, definition, modifiers, header, builtin);
29 34
 	}
30 35
 	
31 36
 	@Override
@@ -52,4 +57,14 @@ public class CallerMember extends FunctionalMember {
52 57
 	public <T> T accept(MemberVisitor<T> visitor) {
53 58
 		return visitor.visitCaller(this);
54 59
 	}
60
+	
61
+	public void setOverrides(GlobalTypeRegistry registry, FunctionalMemberRef overrides) {
62
+		this.overrides = overrides;
63
+		header = header.inferFromOverride(registry, overrides.getHeader());
64
+	}
65
+
66
+	@Override
67
+	public DefinitionMemberRef getOverrides() {
68
+		return overrides;
69
+	}
55 70
 }

+ 12
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.Modifiers;
13 13
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
14
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14 15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15 16
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -22,6 +23,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
22 23
  */
23 24
 public class CasterMember extends FunctionalMember {
24 25
 	public final ITypeID toType;
26
+	public CasterMemberRef overrides;
25 27
 	
26 28
 	public CasterMember(
27 29
 			CodePosition position,
@@ -30,7 +32,7 @@ public class CasterMember extends FunctionalMember {
30 32
 			ITypeID toType,
31 33
 			BuiltinID builtin)
32 34
 	{
33
-		super(position, definition, modifiers, "as", new FunctionHeader(toType), builtin);
35
+		super(position, definition, modifiers, new FunctionHeader(toType), builtin);
34 36
 		
35 37
 		this.toType = toType;
36 38
 	}
@@ -67,4 +69,13 @@ public class CasterMember extends FunctionalMember {
67 69
 	public <T> T accept(MemberVisitor<T> visitor) {
68 70
 		return visitor.visitCaster(this);
69 71
 	}
72
+	
73
+	public void setOverrides(GlobalTypeRegistry registry, CasterMemberRef overrides) {
74
+		this.overrides = overrides;
75
+	}
76
+
77
+	@Override
78
+	public CasterMemberRef getOverrides() {
79
+		return overrides;
80
+	}
70 81
 }

+ 7
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstMember.java Ver arquivo

@@ -10,6 +10,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12 12
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
13
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13 14
 import org.openzen.zenscript.codemodel.type.ITypeID;
14 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
15 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -21,7 +22,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
21 22
  */
22 23
 public class ConstMember extends DefinitionMember {
23 24
 	public final String name;
24
-	public final ITypeID type;
25
+	public ITypeID type;
25 26
 	public Expression value;
26 27
 	public final BuiltinID builtin;
27 28
 	
@@ -52,4 +53,9 @@ public class ConstMember extends DefinitionMember {
52 53
 	public <T> T accept(MemberVisitor<T> visitor) {
53 54
 		return visitor.visitConst(this);
54 55
 	}
56
+
57
+	@Override
58
+	public DefinitionMemberRef getOverrides() {
59
+		return null;
60
+	}
55 61
 }

+ 6
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ConstructorMember.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.expression.ConstructorSuperCallExpression;
13 13
 import org.openzen.zenscript.codemodel.expression.ConstructorThisCallExpression;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
15 16
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
16 17
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
@@ -34,7 +35,6 @@ public class ConstructorMember extends FunctionalMember {
34 35
 				position,
35 36
 				definition,
36 37
 				modifiers,
37
-				"this",
38 38
 				new FunctionHeader(header.typeParameters, BasicTypeID.VOID, header.thrownType, header.parameters),
39 39
 				builtin);
40 40
 	}
@@ -79,4 +79,9 @@ public class ConstructorMember extends FunctionalMember {
79 79
 	public <T> T accept(MemberVisitor<T> visitor) {
80 80
 		return visitor.visitConstructor(this);
81 81
 	}
82
+
83
+	@Override
84
+	public DefinitionMemberRef getOverrides() {
85
+		return null;
86
+	}
82 87
 }

+ 11
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CustomIteratorMember.java Ver arquivo

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12 13
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
13 14
 import org.openzen.zenscript.codemodel.statement.Statement;
14 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -23,6 +24,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
23 24
 public class CustomIteratorMember extends DefinitionMember implements IIteratorMember {
24 25
 	private final ITypeID[] iteratorTypes;
25 26
 	public Statement body;
27
+	public IteratorMemberRef overrides;
26 28
 	
27 29
 	public CustomIteratorMember(CodePosition position, HighLevelDefinition definition, int modifiers, ITypeID[] iteratorTypes) {
28 30
 		super(position, definition, modifiers);
@@ -68,4 +70,13 @@ public class CustomIteratorMember extends DefinitionMember implements IIteratorM
68 70
 	public <T> T acceptForIterator(ForeachIteratorVisitor<T> visitor) {
69 71
 		return visitor.visitCustomIterator();
70 72
 	}
73
+	
74
+	public void setOverrides(IteratorMemberRef overrides) {
75
+		this.overrides = overrides;
76
+	}
77
+
78
+	@Override
79
+	public DefinitionMemberRef getOverrides() {
80
+		return overrides;
81
+	}
71 82
 }

+ 13
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java Ver arquivo

@@ -18,7 +18,7 @@ import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
18 18
 public abstract class DefinitionMember extends Taggable implements IDefinitionMember {
19 19
 	public final CodePosition position;
20 20
 	public final HighLevelDefinition definition;
21
-	public final int modifiers;
21
+	public int modifiers;
22 22
 	public MemberAnnotation[] annotations = MemberAnnotation.NONE;
23 23
 	
24 24
 	public DefinitionMember(CodePosition position, HighLevelDefinition definition, int modifiers) {
@@ -43,4 +43,16 @@ public abstract class DefinitionMember extends Taggable implements IDefinitionMe
43 43
 	public boolean isExtern() {
44 44
 		return Modifiers.isExtern(modifiers);
45 45
 	}
46
+	
47
+	public boolean isPrivate() {
48
+		return Modifiers.isPrivate(modifiers);
49
+	}
50
+	
51
+	public boolean isPublic() {
52
+		return Modifiers.isPublic(modifiers);
53
+	}
54
+	
55
+	public boolean isProtected() {
56
+		return Modifiers.isProtected(modifiers);
57
+	}
46 58
 }

+ 9
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DestructorMember.java Ver arquivo

@@ -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.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
12 14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
13 15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 16
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -19,9 +21,10 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
19 21
  */
20 22
 public class DestructorMember extends FunctionalMember {
21 23
 	private static final FunctionHeader HEADER = new FunctionHeader(BasicTypeID.VOID);
24
+	public FunctionalMemberRef overrides;
22 25
 	
23 26
 	public DestructorMember(CodePosition position, HighLevelDefinition definition, int modifiers) {
24
-		super(position, definition, modifiers, "~this", HEADER, null);
27
+		super(position, definition, modifiers, HEADER, null);
25 28
 	}
26 29
 	
27 30
 	@Override
@@ -49,4 +52,9 @@ public class DestructorMember extends FunctionalMember {
49 52
 	public <T> T accept(MemberVisitor<T> visitor) {
50 53
 		return visitor.visitDestructor(this);
51 54
 	}
55
+
56
+	@Override
57
+	public DefinitionMemberRef getOverrides() {
58
+		return overrides;
59
+	}
52 60
 }

+ 7
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java Ver arquivo

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.expression.GetFieldExpression;
13 13
 import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;
14 14
 import org.openzen.zenscript.codemodel.expression.SetFieldExpression;
15 15
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
16
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
16 17
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
17 18
 import org.openzen.zenscript.codemodel.statement.ExpressionStatement;
18 19
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
@@ -29,7 +30,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
29 30
  */
30 31
 public class FieldMember extends DefinitionMember {
31 32
 	public final String name;
32
-	public final ITypeID type;
33
+	public ITypeID type;
33 34
 	public Expression initializer;
34 35
 	public final int autoGetterAccess;
35 36
 	public final int autoSetterAccess;
@@ -138,4 +139,9 @@ public class FieldMember extends DefinitionMember {
138 139
 	public <T> T accept(MemberVisitor<T> visitor) {
139 140
 		return visitor.visitField(this);
140 141
 	}
142
+
143
+	@Override
144
+	public DefinitionMemberRef getOverrides() {
145
+		return null;
146
+	}
141 147
 }

+ 1
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FunctionalMember.java Ver arquivo

@@ -18,22 +18,18 @@ import org.openzen.zenscript.codemodel.type.member.BuiltinID;
18 18
  * @author Hoofdgebruiker
19 19
  */
20 20
 public abstract class FunctionalMember extends DefinitionMember {
21
-	public final FunctionHeader header;
22
-	public final String name;
21
+	public FunctionHeader header;
23 22
 	public final BuiltinID builtin;
24 23
 	public Statement body = null;
25
-	public FunctionalMember overrides = null;
26 24
 	
27 25
 	public FunctionalMember(
28 26
 			CodePosition position,
29 27
 			HighLevelDefinition definition,
30 28
 			int modifiers,
31
-			String name,
32 29
 			FunctionHeader header,
33 30
 			BuiltinID builtin) {
34 31
 		super(position, definition, modifiers);
35 32
 		
36
-		this.name = name;
37 33
 		this.header = header;
38 34
 		this.builtin = builtin;
39 35
 	}

+ 17
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/GetterMember.java Ver arquivo

@@ -9,7 +9,9 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12 13
 import org.openzen.zenscript.codemodel.member.ref.GetterMemberRef;
14
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
13 15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
14 16
 import org.openzen.zenscript.codemodel.type.ITypeID;
15 17
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
@@ -21,7 +23,8 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
21 23
  */
22 24
 public class GetterMember extends FunctionalMember {
23 25
 	public final String name;
24
-	public final ITypeID type;
26
+	public ITypeID type;
27
+	private GetterMemberRef overrides;
25 28
 	
26 29
 	public GetterMember(
27 30
 			CodePosition position,
@@ -30,7 +33,7 @@ public class GetterMember extends FunctionalMember {
30 33
 			String name,
31 34
 			ITypeID type,
32 35
 			BuiltinID builtin) {
33
-		super(position, definition, modifiers, name, new FunctionHeader(type), builtin);
36
+		super(position, definition, modifiers, new FunctionHeader(type), builtin);
34 37
 		
35 38
 		this.name = name;
36 39
 		this.type = type;
@@ -60,4 +63,16 @@ public class GetterMember extends FunctionalMember {
60 63
 	public <T> T accept(MemberVisitor<T> visitor) {
61 64
 		return visitor.visitGetter(this);
62 65
 	}
66
+
67
+	@Override
68
+	public GetterMemberRef getOverrides() {
69
+		return overrides;
70
+	}
71
+	
72
+	public void setOverrides(GetterMemberRef override) {
73
+		this.overrides = override;
74
+		
75
+		if (type == BasicTypeID.UNDETERMINED)
76
+			type = override.type;
77
+	}
63 78
 }

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/IDefinitionMember.java Ver arquivo

@@ -6,7 +6,9 @@
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;
11
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
10 12
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
11 13
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
12 14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -31,4 +33,6 @@ public interface IDefinitionMember {
31 33
 	public <T> void setTag(Class<T> tag, T value);
32 34
 
33 35
 	<T> boolean hasTag(Class<T> tag);
36
+	
37
+	DefinitionMemberRef getOverrides();
34 38
 }

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

@@ -10,6 +10,7 @@ import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.GenericMapper;
12 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
13
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
13 14
 import org.openzen.zenscript.codemodel.member.ref.ImplementationMemberRef;
14 15
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
15 16
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -57,4 +58,9 @@ public class ImplementationMember extends DefinitionMember {
57 58
 	public <T> T accept(MemberVisitor<T> visitor) {
58 59
 		return visitor.visitImplementation(this);
59 60
 	}
61
+
62
+	@Override
63
+	public DefinitionMemberRef getOverrides() {
64
+		return null;
65
+	}
60 66
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/InnerDefinitionMember.java Ver arquivo

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel.member;
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.GenericMapper;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
11 12
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
12 13
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
13 14
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -48,4 +49,9 @@ public class InnerDefinitionMember extends DefinitionMember {
48 49
 	public <T> T accept(MemberVisitor<T> visitor) {
49 50
 		return visitor.visitInnerDefinition(this);
50 51
 	}
52
+
53
+	@Override
54
+	public DefinitionMemberRef getOverrides() {
55
+		return null;
56
+	}
51 57
 }

+ 24
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/MethodMember.java Ver arquivo

@@ -9,6 +9,9 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.Modifiers;
13
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
12 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
13 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
14 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -18,8 +21,13 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 21
  * @author Hoofdgebruiker
19 22
  */
20 23
 public class MethodMember extends FunctionalMember {
24
+	public final String name;
25
+	private FunctionalMemberRef overrides;
26
+	
21 27
 	public MethodMember(CodePosition position, HighLevelDefinition definition, int modifiers, String name, FunctionHeader header, BuiltinID builtin) {
22
-		super(position, definition, modifiers, name, header, builtin);
28
+		super(position, definition, modifiers, header, builtin);
29
+		
30
+		this.name = name;
23 31
 	}
24 32
 	
25 33
 	@Override
@@ -46,4 +54,19 @@ public class MethodMember extends FunctionalMember {
46 54
 	public <T> T accept(MemberVisitor<T> visitor) {
47 55
 		return visitor.visitMethod(this);
48 56
 	}
57
+
58
+	@Override
59
+	public FunctionalMemberRef getOverrides() {
60
+		return overrides;
61
+	}
62
+	
63
+	public void setOverrides(GlobalTypeRegistry registry, FunctionalMemberRef overrides) {
64
+		this.overrides = overrides;
65
+		header = header.inferFromOverride(registry, overrides.header);
66
+		
67
+		if (overrides.getTarget().isPublic())
68
+			modifiers |= Modifiers.PUBLIC;
69
+		if (overrides.getTarget().isProtected())
70
+			modifiers |= Modifiers.PROTECTED;
71
+	}
49 72
 }

+ 14
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/OperatorMember.java Ver arquivo

@@ -10,6 +10,8 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.OperatorType;
13
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
14
+import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
13 15
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14 16
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
15 17
 import org.openzen.zenscript.codemodel.type.member.TypeMembers;
@@ -20,6 +22,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
20 22
  */
21 23
 public class OperatorMember extends FunctionalMember {
22 24
 	public final OperatorType operator;
25
+	private FunctionalMemberRef overrides;
23 26
 	
24 27
 	public OperatorMember(
25 28
 			CodePosition position,
@@ -29,7 +32,7 @@ public class OperatorMember extends FunctionalMember {
29 32
 			FunctionHeader header,
30 33
 			BuiltinID builtin)
31 34
 	{
32
-		super(position, definition, modifiers, operator.operator, header, builtin);
35
+		super(position, definition, modifiers, header, builtin);
33 36
 		
34 37
 		this.operator = operator;
35 38
 	}
@@ -58,4 +61,14 @@ public class OperatorMember extends FunctionalMember {
58 61
 	public <T> T accept(MemberVisitor<T> visitor) {
59 62
 		return visitor.visitOperator(this);
60 63
 	}
64
+
65
+	@Override
66
+	public FunctionalMemberRef getOverrides() {
67
+		return overrides;
68
+	}
69
+	
70
+	public void setOverrides(GlobalTypeRegistry registry, FunctionalMemberRef overrides) {
71
+		this.overrides = overrides;
72
+		header = header.inferFromOverride(registry, overrides.header);
73
+	}
61 74
 }

+ 16
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/SetterMember.java Ver arquivo

@@ -22,7 +22,9 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
22 22
  * @author Hoofdgebruiker
23 23
  */
24 24
 public class SetterMember extends FunctionalMember {
25
-	public final ITypeID type;
25
+	public ITypeID type;
26
+	public final String name;
27
+	private SetterMemberRef overrides;
26 28
 	
27 29
 	public SetterMember(
28 30
 			CodePosition position,
@@ -35,11 +37,11 @@ public class SetterMember extends FunctionalMember {
35 37
 		super(position,
36 38
 				definition,
37 39
 				modifiers,
38
-				name,
39 40
 				new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(type, "$")),
40 41
 				builtin);
41 42
 		
42 43
 		this.type = type;
44
+		this.name = name;
43 45
 	}
44 46
 	
45 47
 	@Override
@@ -66,4 +68,16 @@ public class SetterMember extends FunctionalMember {
66 68
 	public <T> T accept(MemberVisitor<T> visitor) {
67 69
 		return visitor.visitSetter(this);
68 70
 	}
71
+
72
+	@Override
73
+	public SetterMemberRef getOverrides() {
74
+		return overrides;
75
+	}
76
+	
77
+	public void setOverrides(SetterMemberRef overrides) {
78
+		this.overrides = overrides;
79
+		
80
+		if (type == BasicTypeID.UNDETERMINED)
81
+			type = overrides.type;
82
+	}
69 83
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/StaticInitializerMember.java Ver arquivo

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zencode.shared.Taggable;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
12
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12 13
 import org.openzen.zenscript.codemodel.statement.Statement;
13 14
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
14 15
 import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
@@ -51,4 +52,9 @@ public class StaticInitializerMember extends Taggable implements IDefinitionMemb
51 52
 	public <T> T accept(MemberVisitor<T> visitor) {
52 53
 		return visitor.visitStaticInitializer(this);
53 54
 	}
55
+
56
+	@Override
57
+	public DefinitionMemberRef getOverrides() {
58
+		return null;
59
+	}
54 60
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorKeyValues.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
15 16
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
@@ -75,4 +76,9 @@ public class ArrayIteratorKeyValues extends Taggable implements IIteratorMember
75 76
 	public <T> T acceptForIterator(ForeachIteratorVisitor<T> visitor) {
76 77
 		return visitor.visitArrayKeyValueIterator();
77 78
 	}
79
+
80
+	@Override
81
+	public DefinitionMemberRef getOverrides() {
82
+		return null;
83
+	}
78 84
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/ArrayIteratorValues.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
15 16
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -70,4 +71,9 @@ public class ArrayIteratorValues extends Taggable implements IIteratorMember {
70 71
 	public <T> T acceptForIterator(ForeachIteratorVisitor<T> visitor) {
71 72
 		return visitor.visitArrayValueIterator();
72 73
 	}
74
+
75
+	@Override
76
+	public DefinitionMemberRef getOverrides() {
77
+		return null;
78
+	}
73 79
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/AssocIterator.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
15 16
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -73,4 +74,9 @@ public class AssocIterator extends Taggable implements IIteratorMember {
73 74
 	public <T> T acceptForIterator(ForeachIteratorVisitor<T> visitor) {
74 75
 		return visitor.visitAssocKeyValueIterator();
75 76
 	}
77
+
78
+	@Override
79
+	public DefinitionMemberRef getOverrides() {
80
+		return null;
81
+	}
76 82
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/RangeIterator.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
15 16
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -81,4 +82,9 @@ public class RangeIterator extends Taggable implements IIteratorMember {
81 82
 	public <T> T acceptForIterator(ForeachIteratorVisitor<T> visitor) {
82 83
 		return visitor.visitIntRange();
83 84
 	}
85
+
86
+	@Override
87
+	public DefinitionMemberRef getOverrides() {
88
+		return null;
89
+	}
84 90
 }

+ 6
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringCharIterator.java Ver arquivo

@@ -11,6 +11,7 @@ import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.iterator.ForeachIteratorVisitor;
12 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
13 13
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
14
+import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
14 15
 import org.openzen.zenscript.codemodel.member.ref.IteratorMemberRef;
15 16
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
16 17
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -64,4 +65,9 @@ public class StringCharIterator extends Taggable implements IIteratorMember {
64 65
 	public <T> T accept(MemberVisitor<T> visitor) {
65 66
 		throw new UnsupportedOperationException("Not a compilable member");
66 67
 	}
68
+
69
+	@Override
70
+	public DefinitionMemberRef getOverrides() {
71
+		return null;
72
+	}
67 73
 }

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/CasterMemberRef.java Ver arquivo

@@ -6,7 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
9 10
 import org.openzen.zenscript.codemodel.Modifiers;
11
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
10 12
 import org.openzen.zenscript.codemodel.expression.CastExpression;
11 13
 import org.openzen.zenscript.codemodel.expression.Expression;
12 14
 import org.openzen.zenscript.codemodel.member.CasterMember;
@@ -47,4 +49,19 @@ public class CasterMemberRef implements DefinitionMemberRef {
47 49
 	public boolean isImplicit() {
48 50
 		return Modifiers.isImplicit(member.modifiers);
49 51
 	}
52
+
53
+	@Override
54
+	public DefinitionMemberRef getOverrides() {
55
+		return member.getOverrides();
56
+	}
57
+
58
+	@Override
59
+	public FunctionHeader getHeader() {
60
+		return member.header;
61
+	}
62
+
63
+	@Override
64
+	public MemberAnnotation[] getAnnotations() {
65
+		return member.annotations;
66
+	}
50 67
 }

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ConstMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 import org.openzen.zenscript.codemodel.member.ConstMember;
10 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 13
 
@@ -36,4 +38,19 @@ public class ConstMemberRef implements DefinitionMemberRef {
36 38
 	public <T> T getTag(Class<T> type) {
37 39
 		return member.getTag(type);
38 40
 	}
41
+
42
+	@Override
43
+	public DefinitionMemberRef getOverrides() {
44
+		return null;
45
+	}
46
+
47
+	@Override
48
+	public FunctionHeader getHeader() {
49
+		return null;
50
+	}
51
+
52
+	@Override
53
+	public MemberAnnotation[] getAnnotations() {
54
+		return member.annotations;
55
+	}
39 56
 }

+ 8
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/DefinitionMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 
10 12
 /**
11 13
  *
@@ -17,4 +19,10 @@ public interface DefinitionMemberRef {
17 19
 	String describe();
18 20
 	
19 21
 	<T> T getTag(Class<T> type);
22
+	
23
+	DefinitionMemberRef getOverrides();
24
+	
25
+	FunctionHeader getHeader();
26
+	
27
+	MemberAnnotation[] getAnnotations();
20 28
 }

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FieldMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 import org.openzen.zenscript.codemodel.member.FieldMember;
10 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 13
 
@@ -44,4 +46,19 @@ public class FieldMemberRef implements DefinitionMemberRef {
44 46
 	public boolean isFinal() {
45 47
 		return member.isFinal();
46 48
 	}
49
+
50
+	@Override
51
+	public DefinitionMemberRef getOverrides() {
52
+		return null;
53
+	}
54
+
55
+	@Override
56
+	public FunctionHeader getHeader() {
57
+		return null;
58
+	}
59
+
60
+	@Override
61
+	public MemberAnnotation[] getAnnotations() {
62
+		return member.annotations;
63
+	}
47 64
 }

+ 22
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java Ver arquivo

@@ -9,6 +9,7 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.CompareType;
10 10
 import org.openzen.zenscript.codemodel.FunctionHeader;
11 11
 import org.openzen.zenscript.codemodel.OperatorType;
12
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
12 13
 import org.openzen.zenscript.codemodel.expression.CallArguments;
13 14
 import org.openzen.zenscript.codemodel.expression.CallExpression;
14 15
 import org.openzen.zenscript.codemodel.expression.CallStaticExpression;
@@ -40,6 +41,10 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
40 41
 		return target.position;
41 42
 	}
42 43
 	
44
+	public FunctionalMember getTarget() {
45
+		return target;
46
+	}
47
+	
43 48
 	public String getCanonicalName() {
44 49
 		return target.getCanonicalName();
45 50
 	}
@@ -49,10 +54,26 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
49 54
 		return target.describe();
50 55
 	}
51 56
 	
57
+	@Override
52 58
 	public <T> T getTag(Class<T> cls) {
53 59
 		return target.getTag(cls);
54 60
 	}
55 61
 	
62
+	@Override
63
+	public MemberAnnotation[] getAnnotations() {
64
+		return target.annotations;
65
+	}
66
+	
67
+	@Override
68
+	public DefinitionMemberRef getOverrides() {
69
+		return target.getOverrides();
70
+	}
71
+
72
+	@Override
73
+	public FunctionHeader getHeader() {
74
+		return header;
75
+	}
76
+	
56 77
 	public BuiltinID getBuiltin() {
57 78
 		return target.builtin;
58 79
 	}
@@ -79,8 +100,7 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
79 100
 	}
80 101
 	
81 102
 	public String getMethodName() {
82
-		//FIXME
83
-		return (target).name;
103
+		return ((MethodMember) target).name;
84 104
 	}
85 105
 	
86 106
 	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/GetterMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 import org.openzen.zenscript.codemodel.expression.Expression;
10 12
 import org.openzen.zenscript.codemodel.expression.GetterExpression;
11 13
 import org.openzen.zenscript.codemodel.expression.StaticGetterExpression;
@@ -51,4 +53,19 @@ public class GetterMemberRef implements DefinitionMemberRef {
51 53
 	public Expression getStatic(CodePosition position) {
52 54
 		return new StaticGetterExpression(position, this);
53 55
 	}
56
+
57
+	@Override
58
+	public DefinitionMemberRef getOverrides() {
59
+		return member.getOverrides();
60
+	}
61
+
62
+	@Override
63
+	public FunctionHeader getHeader() {
64
+		return member.header;
65
+	}
66
+
67
+	@Override
68
+	public MemberAnnotation[] getAnnotations() {
69
+		return member.annotations;
70
+	}
54 71
 }

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/ImplementationMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
10 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 13
 
@@ -36,4 +38,19 @@ public class ImplementationMemberRef implements DefinitionMemberRef {
36 38
 	public <T> T getTag(Class<T> type) {
37 39
 		return member.getTag(type);
38 40
 	}
41
+
42
+	@Override
43
+	public DefinitionMemberRef getOverrides() {
44
+		return null;
45
+	}
46
+
47
+	@Override
48
+	public FunctionHeader getHeader() {
49
+		return null;
50
+	}
51
+
52
+	@Override
53
+	public MemberAnnotation[] getAnnotations() {
54
+		return member.annotations;
55
+	}
39 56
 }

+ 22
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/IteratorMemberRef.java Ver arquivo

@@ -6,6 +6,9 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
11
+import org.openzen.zenscript.codemodel.member.CustomIteratorMember;
9 12
 import org.openzen.zenscript.codemodel.member.IIteratorMember;
10 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 14
 
@@ -40,4 +43,23 @@ public class IteratorMemberRef implements DefinitionMemberRef {
40 43
 	public int getLoopVariableCount() {
41 44
 		return types.length;
42 45
 	}
46
+
47
+	@Override
48
+	public DefinitionMemberRef getOverrides() {
49
+		return target.getOverrides();
50
+	}
51
+
52
+	@Override
53
+	public FunctionHeader getHeader() {
54
+		return null; // TODO
55
+	}
56
+
57
+	@Override
58
+	public MemberAnnotation[] getAnnotations() {
59
+		if (target instanceof CustomIteratorMember) {
60
+			return ((CustomIteratorMember)target).annotations;
61
+		} else {
62
+			return null;
63
+		}
64
+	}
43 65
 }

+ 17
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/SetterMemberRef.java Ver arquivo

@@ -6,6 +6,8 @@
6 6
 package org.openzen.zenscript.codemodel.member.ref;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.codemodel.FunctionHeader;
10
+import org.openzen.zenscript.codemodel.annotations.MemberAnnotation;
9 11
 import org.openzen.zenscript.codemodel.member.SetterMember;
10 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 13
 
@@ -40,4 +42,19 @@ public class SetterMemberRef implements DefinitionMemberRef {
40 42
 	public boolean isStatic() {
41 43
 		return member.isStatic();
42 44
 	}
45
+
46
+	@Override
47
+	public DefinitionMemberRef getOverrides() {
48
+		return member.getOverrides();
49
+	}
50
+
51
+	@Override
52
+	public FunctionHeader getHeader() {
53
+		return member.header;
54
+	}
55
+
56
+	@Override
57
+	public MemberAnnotation[] getAnnotations() {
58
+		return member.annotations;
59
+	}
43 60
 }

+ 0
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/BaseScope.java Ver arquivo

@@ -23,8 +23,6 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
23 23
  * @author Hoofdgebruiker
24 24
  */
25 25
 public abstract class BaseScope implements TypeScope {
26
-	public abstract LocalMemberCache getMemberCache();
27
-	
28 26
 	public abstract IPartialExpression get(CodePosition position, GenericName name);
29 27
 	
30 28
 	public abstract ITypeID getType(CodePosition position, List<GenericName> name);

+ 7
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/TypeScope.java Ver arquivo

@@ -16,11 +16,15 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public interface TypeScope {
19
-	public GlobalTypeRegistry getTypeRegistry();
20
-	
21 19
 	public LocalMemberCache getMemberCache();
22 20
 	
23
-	public TypeMembers getTypeMembers(ITypeID type);
21
+	default TypeMembers getTypeMembers(ITypeID type) {
22
+		return getMemberCache().get(type);
23
+	}
24
+	
25
+	default GlobalTypeRegistry getTypeRegistry() {
26
+		return getMemberCache().getRegistry();
27
+	}
24 28
 	
25 29
 	public AnnotationDefinition getAnnotation(String name);
26 30
 }

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java Ver arquivo

@@ -17,7 +17,6 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
17 17
 public enum BasicTypeID implements ITypeID {
18 18
 	VOID("void"),
19 19
 	NULL("null"),
20
-	ANY("any"),
21 20
 	BOOL("bool"),
22 21
 	BYTE("byte"),
23 22
 	SBYTE("sbyte"),
@@ -74,7 +73,7 @@ public enum BasicTypeID implements ITypeID {
74 73
 	
75 74
 	@Override
76 75
 	public boolean isObjectType() {
77
-		return this == ANY || this == STRING;
76
+		return this == STRING;
78 77
 	}
79 78
 
80 79
 	@Override

+ 24
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java Ver arquivo

@@ -27,6 +27,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
27 27
 import org.openzen.zenscript.codemodel.GenericMapper;
28 28
 import org.openzen.zenscript.codemodel.expression.ConstExpression;
29 29
 import org.openzen.zenscript.codemodel.expression.PostCallExpression;
30
+import org.openzen.zenscript.codemodel.member.FunctionalMember;
30 31
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
31 32
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
32 33
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
@@ -84,6 +85,14 @@ public class DefinitionMemberGroup {
84 85
 		return this.setter == null ? null : this.setter.member;
85 86
 	}
86 87
 	
88
+	public FunctionalMemberRef getUnaryMethod() {
89
+		for (TypeMember<FunctionalMemberRef> method : methods)
90
+			if (method.member.header.parameters.length == 0)
91
+				return method.member;
92
+		
93
+		return null;
94
+	}
95
+	
87 96
 	public boolean hasMethods() {
88 97
 		return !methods.isEmpty();
89 98
 	}
@@ -350,4 +359,19 @@ public class DefinitionMemberGroup {
350 359
 		
351 360
 		return selected;
352 361
 	}
362
+	
363
+	public FunctionalMemberRef getOverride(CodePosition position, TypeScope scope, FunctionalMember member) {
364
+		List<FunctionalMemberRef> candidates = new ArrayList<>();
365
+		for (TypeMember<FunctionalMemberRef> method : methods) {
366
+			if (member.header.canOverride(scope, method.member.header))
367
+				candidates.add(method.member);
368
+		}
369
+		
370
+		if (candidates.isEmpty())
371
+			return null;
372
+		if (candidates.size() == 1)
373
+			return candidates.get(0);
374
+		
375
+		throw new CompileException(position, CompileExceptionCode.OVERRIDE_AMBIGUOUS, "Ambiguous override: has " + candidates.size() + " base candidates");
376
+	}
353 377
 }

+ 19
- 5
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java Ver arquivo

@@ -23,7 +23,10 @@ import org.openzen.zenscript.codemodel.expression.NullExpression;
23 23
 import org.openzen.zenscript.codemodel.expression.SupertypeCastExpression;
24 24
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
25 25
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
26
+import org.openzen.zenscript.codemodel.member.FunctionalMember;
26 27
 import org.openzen.zenscript.codemodel.member.InnerDefinition;
28
+import org.openzen.zenscript.codemodel.member.MethodMember;
29
+import org.openzen.zenscript.codemodel.member.OperatorMember;
27 30
 import org.openzen.zenscript.codemodel.member.ref.CasterMemberRef;
28 31
 import org.openzen.zenscript.codemodel.member.ref.ConstMemberRef;
29 32
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
@@ -306,7 +309,7 @@ public final class TypeMembers {
306 309
 	
307 310
 	public Expression unary(CodePosition position, TypeScope scope, OperatorType operator, Expression value) {
308 311
 		DefinitionMemberGroup members = getOrCreateGroup(operator);
309
-		return members.call(position, scope, value, new CallArguments(), false);
312
+		return members.call(position, scope, value, new CallArguments(Expression.NONE), false);
310 313
 	}
311 314
 	
312 315
 	public Expression ternary(CodePosition position, TypeScope scope, OperatorType operator, Expression a, Expression b, Expression c) {
@@ -335,8 +338,6 @@ public final class TypeMembers {
335 338
 			return true;
336 339
 		if (toType == null)
337 340
 			throw new NullPointerException();
338
-		if (type == BasicTypeID.ANY || toType == BasicTypeID.ANY || toType == BasicTypeID.UNDETERMINED)
339
-			return true;
340 341
 		
341 342
 		if (type == BasicTypeID.NULL && toType.isOptional())
342 343
 			return true;
@@ -347,12 +348,25 @@ public final class TypeMembers {
347 348
 		if (type.isOptional() && type.unwrap() == toType)
348 349
 			return true;
349 350
 		
351
+		return getImplicitCaster(toType) != null || extendsOrImplements(toType);
352
+	}
353
+	
354
+	public CasterMemberRef getImplicitCaster(ITypeID toType) {
350 355
 		for (TypeMember<CasterMemberRef> caster : casters) {
351 356
 			if (caster.member.isImplicit() && toType == caster.member.toType)
352
-				return true;
357
+				return caster.member;
358
+		}
359
+		
360
+		return null;
361
+	}
362
+	
363
+	public CasterMemberRef getCaster(ITypeID toType) {
364
+		for (TypeMember<CasterMemberRef> caster : casters) {
365
+			if (toType == caster.member.toType)
366
+				return caster.member;
353 367
 		}
354 368
 		
355
-		return extendsOrImplements(toType);
369
+		return null;
356 370
 	}
357 371
 	
358 372
 	public boolean canCast(ITypeID toType) {

+ 1
- 1
CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java Ver arquivo

@@ -98,7 +98,7 @@ public class SemanticModule {
98 98
 		if (state != State.NORMALIZED)
99 99
 			throw new IllegalStateException("Module is not yet normalized");
100 100
 		
101
-		Validator validator = new Validator();
101
+		Validator validator = new Validator(compilationUnit.globalTypeRegistry, expansions, annotations);
102 102
 		for (ScriptBlock script : scripts) {
103 103
 			validator.validate(script);
104 104
 		}

+ 3
- 0
Constructor/src/main/java/org/openzen/zenscript/constructor/Module.java Ver arquivo

@@ -130,6 +130,9 @@ public class Module {
130 130
 			}
131 131
 		}
132 132
 		
133
+		if (failed)
134
+			return new SemanticModule(name, dependencies, SemanticModule.State.INVALID, rootPackage, pkg, definitions, Collections.emptyList(), registry.compilationUnit, expansions, registry.getAnnotations());
135
+		
133 136
 		if (failed)
134 137
 			return new SemanticModule(name, dependencies, SemanticModule.State.INVALID, rootPackage, pkg, definitions, Collections.emptyList(), registry.compilationUnit, expansions, registry.getAnnotations());
135 138
 		

+ 2
- 1
Constructor/src/main/java/org/openzen/zenscript/constructor/module/DirectoryModuleReference.java Ver arquivo

@@ -14,6 +14,7 @@ import java.util.function.Consumer;
14 14
 import org.json.JSONArray;
15 15
 import org.json.JSONObject;
16 16
 import org.openzen.zencode.shared.CompileException;
17
+import org.openzen.zencode.shared.FileSourceFile;
17 18
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
18 19
 import org.openzen.zenscript.compiler.CompilationUnit;
19 20
 import org.openzen.zenscript.constructor.ConstructorException;
@@ -112,7 +113,7 @@ public class DirectoryModuleReference implements ModuleReference {
112 113
 			if (file.isDirectory()) {
113 114
 				pkg.addPackage(loadPackage(file.getName(), file));
114 115
 			} else if (file.isFile() && file.getName().toLowerCase().endsWith(".zs")) {
115
-				pkg.addFile(new SourceFile(file.getName(), file));
116
+				pkg.addFile(new FileSourceFile(file.getName(), file));
116 117
 			}
117 118
 		}
118 119
 		

+ 0
- 22
Constructor/src/main/java/org/openzen/zenscript/constructor/module/SourceFile.java Ver arquivo

@@ -1,22 +0,0 @@
1
-/*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-package org.openzen.zenscript.constructor.module;
7
-
8
-import java.io.File;
9
-
10
-/**
11
- *
12
- * @author Hoofdgebruiker
13
- */
14
-public class SourceFile {
15
-	public final String name;
16
-	public final File file;
17
-	
18
-	public SourceFile(String name, File file) {
19
-		this.name = name;
20
-		this.file = file;
21
-	}
22
-}

+ 3
- 1
Constructor/src/main/java/org/openzen/zenscript/constructor/module/SourcePackage.java Ver arquivo

@@ -8,6 +8,8 @@ package org.openzen.zenscript.constructor.module;
8 8
 import java.io.File;
9 9
 import java.util.HashMap;
10 10
 import java.util.Map;
11
+import org.openzen.zencode.shared.FileSourceFile;
12
+import org.openzen.zencode.shared.SourceFile;
11 13
 
12 14
 /**
13 15
  *
@@ -29,6 +31,6 @@ public class SourcePackage {
29 31
 	}
30 32
 	
31 33
 	public void addFile(SourceFile file) {
32
-		sourceFiles.put(file.name, file);
34
+		sourceFiles.put(file.getFilename(), file);
33 35
 	}
34 36
 }

+ 2
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java Ver arquivo

@@ -83,7 +83,7 @@ public final class SwingRoot extends Component implements ComponentListener, Mou
83 83
 			component.setBounds(new DIRectangle(0, 0, getWidth(), getHeight()));
84 84
 		}
85 85
 		
86
-		long start = System.currentTimeMillis();
86
+		//long start = System.currentTimeMillis();
87 87
 		Rectangle clipBounds = g.getClipBounds();
88 88
 		DIRectangle clipBounds2 = clipBounds == null ? null : new DIRectangle(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
89 89
 		Graphics2D g2d = (Graphics2D) g;
@@ -91,7 +91,7 @@ public final class SwingRoot extends Component implements ComponentListener, Mou
91 91
 		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
92 92
 		surface.paint(g2d, clipBounds2);
93 93
 		
94
-		System.out.println("Paint in " + (System.currentTimeMillis() - start) + " ms, bounds: " + clipBounds.toString());
94
+		//System.out.println("Paint in " + (System.currentTimeMillis() - start) + " ms, bounds: " + clipBounds.toString());
95 95
 	}
96 96
 
97 97
 	@Override

+ 25
- 0
IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeError.java Ver arquivo

@@ -0,0 +1,25 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.codemodel;
7
+
8
+import org.openzen.zencode.shared.CodePosition;
9
+import org.openzen.zenscript.ide.host.IDESourceFile;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class IDECodeError {
16
+	public final IDESourceFile file;
17
+	public final CodePosition position;
18
+	public final String message;
19
+	
20
+	public IDECodeError(IDESourceFile file, CodePosition position, String message) {
21
+		this.file = file;
22
+		this.position = position;
23
+		this.message = message;
24
+	}
25
+}

+ 41
- 0
IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeSpace.java Ver arquivo

@@ -5,8 +5,29 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.codemodel;
7 7
 
8
+import java.io.File;
9
+import java.util.ArrayList;
10
+import java.util.Collections;
11
+import java.util.HashMap;
12
+import java.util.HashSet;
13
+import java.util.List;
14
+import java.util.Map;
15
+import java.util.Set;
16
+import java.util.function.Consumer;
17
+import org.openzen.zenscript.compiler.CompilationUnit;
18
+import org.openzen.zenscript.compiler.SemanticModule;
19
+import org.openzen.zenscript.compiler.ZenCodeCompiler;
20
+import org.openzen.zenscript.constructor.Library;
21
+import org.openzen.zenscript.constructor.ModuleLoader;
22
+import org.openzen.zenscript.constructor.module.DirectoryModuleReference;
23
+import org.openzen.zenscript.constructor.module.ModuleReference;
8 24
 import org.openzen.zenscript.ide.host.DevelopmentHost;
25
+import org.openzen.zenscript.ide.host.IDEModule;
9 26
 import org.openzen.zenscript.ide.host.IDESourceFile;
27
+import org.openzen.zenscript.ide.ui.view.output.ErrorOutputSpan;
28
+import org.openzen.zenscript.ide.ui.view.output.OutputLine;
29
+import org.openzen.zenscript.validator.ValidationLogEntry;
30
+import stdlib.Strings;
10 31
 
11 32
 /**
12 33
  *
@@ -14,12 +35,32 @@ import org.openzen.zenscript.ide.host.IDESourceFile;
14 35
  */
15 36
 public class IDECodeSpace {
16 37
 	private final DevelopmentHost host;
38
+	private final Map<IDESourceFile, List<IDECodeError>> sourceFileErrors = new HashMap<>();
17 39
 	
18 40
 	public IDECodeSpace(DevelopmentHost host) {
19 41
 		this.host = host;
42
+		
43
+		ModuleLoader loader = new ModuleLoader(new CompilationUnit(), exception -> {
44
+			
45
+		});
46
+		for (IDEModule module : host.getModules()) {
47
+			module.prebuild(loader, this::addError);
48
+		}
20 49
 	}
21 50
 	
22 51
 	public void onSaved(IDESourceFile file) {
23 52
 		
24 53
 	}
54
+	
55
+	public List<IDECodeError> getErrors(IDESourceFile file) {
56
+		return sourceFileErrors.getOrDefault(file, Collections.emptyList());
57
+	}
58
+	
59
+	private void addError(IDECodeError error) {
60
+		if (error.file == null)
61
+			return;
62
+		if (!sourceFileErrors.containsKey(error.file))
63
+			sourceFileErrors.put(error.file, new ArrayList<>());
64
+		sourceFileErrors.get(error.file).add(error);
65
+	}
25 66
 }

+ 6
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/IDEModule.java Ver arquivo

@@ -5,6 +5,10 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.host;
7 7
 
8
+import java.util.function.Consumer;
9
+import org.openzen.zenscript.constructor.ModuleLoader;
10
+import org.openzen.zenscript.ide.codemodel.IDECodeError;
11
+
8 12
 /**
9 13
  *
10 14
  * @author Hoofdgebruiker
@@ -13,4 +17,6 @@ public interface IDEModule {
13 17
 	public String getName();
14 18
 	
15 19
 	public IDEPackage getRootPackage();
20
+	
21
+	void prebuild(ModuleLoader loader, Consumer<IDECodeError> errors);
16 22
 }

+ 2
- 3
IDE/src/main/java/org/openzen/zenscript/ide/host/IDESourceFile.java Ver arquivo

@@ -5,9 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.host;
7 7
 
8
-import java.io.IOException;
9
-import java.io.Reader;
10 8
 import org.openzen.drawablegui.live.LiveString;
9
+import org.openzen.zencode.shared.SourceFile;
11 10
 
12 11
 /**
13 12
  *
@@ -16,7 +15,7 @@ import org.openzen.drawablegui.live.LiveString;
16 15
 public interface IDESourceFile {
17 16
 	public LiveString getName();
18 17
 	
19
-	public Reader read() throws IOException;
18
+	public SourceFile getFile();
20 19
 	
21 20
 	public void update(String content);
22 21
 }

+ 10
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalModule.java Ver arquivo

@@ -5,7 +5,11 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.host.local;
7 7
 
8
+import java.util.function.Consumer;
9
+import org.openzen.zenscript.compiler.SemanticModule;
10
+import org.openzen.zenscript.constructor.ModuleLoader;
8 11
 import org.openzen.zenscript.constructor.module.ModuleReference;
12
+import org.openzen.zenscript.ide.codemodel.IDECodeError;
9 13
 import org.openzen.zenscript.ide.host.IDEModule;
10 14
 import org.openzen.zenscript.ide.host.IDEPackage;
11 15
 
@@ -31,4 +35,10 @@ public class LocalModule implements IDEModule {
31 35
 	public IDEPackage getRootPackage() {
32 36
 		return rootPackage;
33 37
 	}
38
+	
39
+	@Override
40
+	public void prebuild(ModuleLoader loader, Consumer<IDECodeError> errors) {
41
+		SemanticModule module = loader.getModule(this.module.getName());
42
+		module.validate(entry -> errors.accept(new IDECodeError(null, entry.position, entry.message)));
43
+	}
34 44
 }

+ 3
- 2
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalPackage.java Ver arquivo

@@ -12,7 +12,8 @@ import org.openzen.drawablegui.live.LiveArrayList;
12 12
 import org.openzen.drawablegui.live.LiveList;
13 13
 import org.openzen.drawablegui.live.MutableLiveList;
14 14
 import org.openzen.drawablegui.live.SortedLiveList;
15
-import org.openzen.zenscript.constructor.module.SourceFile;
15
+import org.openzen.zencode.shared.FileSourceFile;
16
+import org.openzen.zencode.shared.SourceFile;
16 17
 import org.openzen.zenscript.constructor.module.SourcePackage;
17 18
 import org.openzen.zenscript.ide.host.IDEPackage;
18 19
 import org.openzen.zenscript.ide.host.IDESourceFile;
@@ -87,7 +88,7 @@ public class LocalPackage implements IDEPackage {
87 88
 			ex.printStackTrace(); // TODO
88 89
 		}
89 90
 		
90
-		SourceFile sourceFile = new SourceFile(name, file);
91
+		FileSourceFile sourceFile = new FileSourceFile(name, file);
91 92
 		IDESourceFile localSourceFile = new LocalSourceFile(sourceFile);
92 93
 		this.pkg.sourceFiles.put(name, sourceFile);
93 94
 		sourceFiles.add(localSourceFile);

+ 12
- 13
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalSourceFile.java Ver arquivo

@@ -5,20 +5,17 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.host.local;
7 7
 
8
-import java.io.BufferedInputStream;
9 8
 import java.io.BufferedOutputStream;
10
-import java.io.FileInputStream;
11 9
 import java.io.FileOutputStream;
12 10
 import java.io.IOException;
13
-import java.io.InputStreamReader;
14 11
 import java.io.OutputStreamWriter;
15
-import java.io.Reader;
16 12
 import java.io.Writer;
17 13
 import java.nio.charset.StandardCharsets;
18 14
 import org.openzen.drawablegui.live.LiveString;
19 15
 import org.openzen.drawablegui.live.MutableLiveString;
20 16
 import org.openzen.drawablegui.live.SimpleLiveString;
21
-import org.openzen.zenscript.constructor.module.SourceFile;
17
+import org.openzen.zencode.shared.FileSourceFile;
18
+import org.openzen.zencode.shared.SourceFile;
22 19
 import org.openzen.zenscript.ide.host.IDESourceFile;
23 20
 
24 21
 /**
@@ -31,7 +28,7 @@ public class LocalSourceFile implements IDESourceFile {
31 28
 	
32 29
 	public LocalSourceFile(SourceFile file) {
33 30
 		this.file = file;
34
-		this.name = new SimpleLiveString(file.name);
31
+		this.name = new SimpleLiveString(file.getFilename());
35 32
 	}
36 33
 
37 34
 	@Override
@@ -40,18 +37,20 @@ public class LocalSourceFile implements IDESourceFile {
40 37
 	}
41 38
 
42 39
 	@Override
43
-	public Reader read() throws IOException {
44
-		return new InputStreamReader(
45
-				new BufferedInputStream(new FileInputStream(file.file)),
46
-				StandardCharsets.UTF_8);
40
+	public SourceFile getFile() {
41
+		return file;
47 42
 	}
48 43
 
49 44
 	@Override
50 45
 	public void update(String content) {
51 46
 		try {
52
-			Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file.file)), StandardCharsets.UTF_8);
53
-			writer.write(content);
54
-			writer.close();
47
+			if (file instanceof FileSourceFile) {
48
+				Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(((FileSourceFile)file).file)), StandardCharsets.UTF_8);
49
+				writer.write(content);
50
+				writer.close();
51
+			} else {
52
+				throw new UnsupportedOperationException("Cannot write to a non-file source file!");
53
+			}
55 54
 		} catch (IOException ex) {
56 55
 			ex.printStackTrace();
57 56
 		}

+ 5
- 5
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalTarget.java Ver arquivo

@@ -133,16 +133,16 @@ public class LocalTarget implements IDETarget {
133 133
 				continue;
134 134
 			
135 135
 			SemanticModule dependencyModule = loader.getModule(dependency);
136
-			module = module.normalize();
137
-			module.validate(logger);
138
-			if (!module.isValid())
136
+			dependencyModule = dependencyModule.normalize();
137
+			dependencyModule.validate(logger);
138
+			if (!dependencyModule.isValid())
139 139
 				return false;
140 140
 			
141 141
 			if (!compileDependencies(loader, compiler, compiledModules, dependencyModule, logger))
142 142
 				return false;
143 143
 			
144
-			module.compile(compiler);
145
-			compiledModules.add(module.name);
144
+			dependencyModule.compile(compiler);
145
+			compiledModules.add(dependencyModule.name);
146 146
 		}
147 147
 		
148 148
 		return true;

+ 48
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/PathGenerator.java Ver arquivo

@@ -0,0 +1,48 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.editor;
7
+
8
+import org.openzen.drawablegui.DPath;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public class PathGenerator {
15
+	private PathGenerator() {}
16
+	
17
+	public static class CubicBezierCurve {
18
+		public final float p1x;
19
+		public final float p1y;
20
+		public final float p2x;
21
+		public final float p2y;
22
+		public final float p3x;
23
+		public final float p3y;
24
+		public final float p4x;
25
+		public final float p4y;
26
+		
27
+		public CubicBezierCurve(float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y) {
28
+			this.p1x = p1x;
29
+			this.p1y = p1y;
30
+			this.p2x = p2x;
31
+			this.p2y = p2y;
32
+			this.p3x = p3x;
33
+			this.p3y = p3y;
34
+			this.p4x = p4x;
35
+			this.p4y = p4y;
36
+		}
37
+		
38
+		public void cut(float t0, float t1) {
39
+			// https://stackoverflow.com/questions/11703283/cubic-bezier-curve-segment
40
+			// P'1 = u0u0u0 P1 + (t0u0u0 + u0t0u0 + u0u0t0) P2 + (t0t0u0 + u0t0t0 + t0u0t0) P3 + t0t0t0 P4
41
+			// P'2 = u0u0u1 P1 + (t0u0u1 + u0t0u1 + u0u0t1) P2 + (t0t0u1 + u0t0t1 + t0u0t1) P3 + t0t0t1 P4
42
+			// P'3 = u0u1u1 P1 + (t0u1u1 + u0t1u1 + u0u1t1) P2 + (t0t1u1 + u0t1t1 + t0u1t1) P3 + t0t1t1 P4
43
+			// P'4 = u1u1u1 P1 + (t1u1u1 + u1t1u1 + u1u1t1) P2 + (t1t1u1 + u1t1t1 + t1u1t1) P3 + t1t1t1 P4
44
+			// u0 = 1 − t0 and u1 = 1 − t1
45
+			
46
+		}
47
+	}
48
+}

+ 42
- 24
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java Ver arquivo

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.ide.ui.view.editor;
7 7
 
8 8
 import java.io.IOException;
9
+import java.io.Reader;
9 10
 import java.util.ArrayList;
10 11
 import java.util.List;
11 12
 import org.openzen.drawablegui.DComponent;
@@ -29,6 +30,7 @@ import org.openzen.zenscript.lexer.ZSToken;
29 30
 import org.openzen.zenscript.lexer.ZSTokenParser;
30 31
 import org.openzen.zenscript.lexer.ZSTokenType;
31 32
 import org.openzen.drawablegui.DUIContext;
33
+import org.openzen.drawablegui.Destructible;
32 34
 import org.openzen.drawablegui.draw.DDrawSurface;
33 35
 import org.openzen.drawablegui.draw.DDrawnRectangle;
34 36
 import org.openzen.drawablegui.draw.DDrawnShape;
@@ -95,23 +97,27 @@ public class SourceEditor implements DComponent {
95 97
 	private final List<DDrawnText> lineNumbers = new ArrayList<>();
96 98
 	private final List<List<DDrawnText>> drawnTokens = new ArrayList<>();
97 99
 	
100
+	//private DDrawnShape test;
101
+	
98 102
 	public SourceEditor(DStyleClass styleClass, IDEWindow window, IDESourceFile sourceFile) {
99 103
 		this.styleClass = styleClass;
100 104
 		this.window = window;
101 105
 		this.sourceFile = sourceFile;
102 106
 		
103
-		tokens = new TokenModel(sourceFile.getName().getValue(), tab.length());
107
+		tokens = new TokenModel(sourceFile.getFile(), tab.length());
104 108
 		tokenListener = tokens.addListener(new TokenListener());
105 109
 		
106 110
 		editToolbar.controls.add(() -> new IconButtonControl(DStyleClass.EMPTY, ShadedSaveIcon.PURPLE, SaveIcon.GREY, unchanged, new ImmutableLiveString("Save file"), e -> save()));
107 111
 		updated = new InverseLiveBool(unchanged);
108 112
 		
109 113
 		try {
114
+			Reader reader = sourceFile.getFile().open();
110 115
 			TokenParser<ZSToken, ZSTokenType> parser = ZSTokenParser.createRaw(
111
-					sourceFile.getName().getValue(),
112
-					new ReaderCharReader(sourceFile.read()),
116
+					sourceFile.getFile(),
117
+					new ReaderCharReader(reader),
113 118
 					tab.length());
114 119
 			tokens.set(parser);
120
+			reader.close();
115 121
 		} catch (IOException ex) {
116 122
 			ex.printStackTrace();
117 123
 		}
@@ -188,6 +194,11 @@ public class SourceEditor implements DComponent {
188 194
 			cursor = null;
189 195
 		}
190 196
 		
197
+		/*if (test != null) {
198
+			test.close();
199
+			test = null;
200
+		}*/
201
+		
191 202
 		if (blinkTimer != null)
192 203
 			blinkTimer.close();
193 204
 		
@@ -251,6 +262,8 @@ public class SourceEditor implements DComponent {
251 262
 					bounds.y + style.selectionPaddingTop + i * fullLineHeight + fontMetrics.getAscent());
252 263
 		}
253 264
 		
265
+		//test = surface.strokePath(z + 4, new WavyLine(bounds.x + 50, bounds.y + 50, 100, surface.getContext().dp(2), surface.getContext().dp(3)), DTransform2D.IDENTITY, IDEStyling.ERROR_RED, surface.getScale());
266
+		
254 267
 		layoutLines(0);
255 268
 	}
256 269
 	
@@ -287,6 +300,10 @@ public class SourceEditor implements DComponent {
287 300
 		}
288 301
 	}
289 302
 	
303
+	private void setCursor(SourcePosition position) {
304
+		setCursor(position, position);
305
+	}
306
+	
290 307
 	private void setCursor(SourcePosition start, SourcePosition end) {
291 308
 		cursorStart = start;
292 309
 		cursorEnd = end;
@@ -563,20 +580,24 @@ public class SourceEditor implements DComponent {
563 580
 		if (value.equals("{")) {
564 581
 			String indent = tokens.getLine(cursorEnd.line).getIndent();
565 582
 			tokens.insert(cursorEnd, "{\n" + indent + "\t\n" + indent + "}");
566
-			
567
-			SourcePosition position = new SourcePosition(tokens, cursorEnd.line + 1, indent.length() + 1);
568
-			setCursor(position, position);
569
-		} else if (value.equals(";")) {
570
-			String indent = tokens.getLine(cursorEnd.line).getIndent();
571
-			tokens.insert(cursorEnd, ";\n" + indent);
572
-			
573
-			SourcePosition position = new SourcePosition(tokens, cursorEnd.line + 1, indent.length());
574
-			setCursor(position, position);
583
+			setCursor(new SourcePosition(tokens, cursorEnd.line + 1, indent.length() + 1));
584
+		} else if (value.equals("\"")) {
585
+			if (!tokens.extract(cursorEnd, cursorEnd.advance(1)).equals("\""))
586
+				tokens.insert(cursorEnd, "\"\"");
587
+			setCursor(cursorEnd.advance(1));
588
+		} else if (value.equals("(")) {
589
+			tokens.insert(cursorEnd, "()");
590
+			setCursor(cursorEnd.advance(1));
591
+		} else if (value.equals(")") && tokens.extract(cursorEnd, cursorEnd.advance(1)).equals(")")){
592
+			setCursor(cursorEnd.advance(1));
593
+		} else if (value.equals("[")) {
594
+			tokens.insert(cursorEnd, "[]");
595
+			setCursor(cursorEnd.advance(1));
596
+		} else if (value.equals("]") && tokens.extract(cursorEnd, cursorEnd.advance(1)).equals("]")) {
597
+			setCursor(cursorEnd.advance(1));
575 598
 		} else {
576 599
 			tokens.insert(cursorEnd, value);
577
-			
578
-			SourcePosition position = new SourcePosition(tokens, cursorEnd.line, cursorEnd.offset + value.length());
579
-			setCursor(position, position);
600
+			setCursor(cursorEnd.advance(value.length()));
580 601
 		}
581 602
 		
582 603
 		unchanged.setValue(false);
@@ -734,9 +755,8 @@ public class SourceEditor implements DComponent {
734 755
 		@Override
735 756
 		public void onLineChanged(int index) {
736 757
 			if (bounds != null) {
737
-				removeLineTokens(drawnTokens.get(index));
738
-				drawnTokens.get(index).clear();
739
-				drawnTokens.get(index).addAll(lineToTokens(tokens.getLine(index)));
758
+				Destructible.close(drawnTokens.get(index));
759
+				drawnTokens.set(index, lineToTokens(tokens.getLine(index)));
740 760
 				layoutLine(index);
741 761
 			}
742 762
 		}
@@ -745,17 +765,15 @@ public class SourceEditor implements DComponent {
745 765
 		public void onLineDeleted(int index) {
746 766
 			onLinesUpdated();
747 767
 			
768
+			if (index >= lineNumbers.size())
769
+				return;
770
+			
748 771
 			if (bounds != null) {
749 772
 				lineNumbers.remove(lineNumbers.size() - 1).close();
750
-				removeLineTokens(drawnTokens.remove(index));
773
+				Destructible.close(drawnTokens.remove(index));
751 774
 				layoutLines(index);
752 775
 			}
753 776
 		}
754
-		
755
-		private void removeLineTokens(List<DDrawnText> tokens) {
756
-			for (DDrawnText token : tokens)
757
-				token.close();
758
-		}
759 777
 	}
760 778
 	
761 779
 	private enum TokenClass {

+ 5
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourcePosition.java Ver arquivo

@@ -18,6 +18,11 @@ public class SourcePosition {
18 18
 	private TokenModel.Position position;
19 19
 
20 20
 	public SourcePosition(TokenModel tokens, int line, int offset) {
21
+		if (line < 0)
22
+			throw new IllegalArgumentException("line cannot be negative");
23
+		if (offset < 0)
24
+			throw new IllegalArgumentException("offset cannot be negative");
25
+		
21 26
 		this.tokens = tokens;
22 27
 		this.line = line;
23 28
 		this.offset = offset;

+ 10
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenLine.java Ver arquivo

@@ -54,6 +54,16 @@ public final class TokenLine {
54 54
 		}
55 55
 		return indent.toString();
56 56
 	}
57
+	
58
+	/**
59
+	 * Adds a temporary token. This token must be relexed later using the relexer.
60
+	 * 
61
+	 * @param token 
62
+	 */
63
+	public void addTemporary(ZSToken token) {
64
+		tokens.add(token);
65
+		length += token.content.length();
66
+	}
57 67
 
58 68
 	public void add(ZSToken token) {
59 69
 		insert(tokens.size(), token);

+ 15
- 6
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenModel.java Ver arquivo

@@ -13,6 +13,7 @@ import java.util.List;
13 13
 import java.util.Set;
14 14
 import org.openzen.drawablegui.listeners.ListenerHandle;
15 15
 import org.openzen.drawablegui.listeners.ListenerList;
16
+import org.openzen.zencode.shared.SourceFile;
16 17
 import org.openzen.zenscript.lexer.ZSToken;
17 18
 import org.openzen.zenscript.lexer.ZSTokenType;
18 19
 
@@ -23,13 +24,13 @@ import org.openzen.zenscript.lexer.ZSTokenType;
23 24
 public class TokenModel {
24 25
 	private final ListenerList<Listener> listeners = new ListenerList<>();
25 26
 	
26
-	private final String filename;
27
+	private final SourceFile file;
27 28
 	private final int spacesPerTab;
28 29
 	private final List<TokenLine> lines = new ArrayList<>();
29 30
 	private long version = 0;
30 31
 	
31
-	public TokenModel(String filename, int spacesPerTab) {
32
-		this.filename = filename;
32
+	public TokenModel(SourceFile file, int spacesPerTab) {
33
+		this.file = file;
33 34
 		this.spacesPerTab = spacesPerTab;
34 35
 	}
35 36
 	
@@ -193,7 +194,7 @@ public class TokenModel {
193 194
 		if (!remainder.isEmpty())
194 195
 			getLine(fromT.line).insert(fromT.token, new ZSToken(ZSTokenType.INVALID, remainder));
195 196
 		
196
-		relex(fromT.line, Math.max(0, fromT.token - 1), fromT.line, fromT.token + 1);
197
+		relex(fromT.line, Math.max(0, fromT.token - 1), fromT.line, Math.min(lines.get(fromT.line).getTokenCount(), fromT.token + 1));
197 198
 	}
198 199
 	
199 200
 	public void insert(SourcePosition position, String value) {
@@ -201,7 +202,7 @@ public class TokenModel {
201 202
 		Position tokenPosition = position.asTokenPosition();
202 203
 		ZSToken token = getTokenAt(tokenPosition);
203 204
 		if (token == null) {
204
-			line.add(new ZSToken(ZSTokenType.INVALID, value));
205
+			line.addTemporary(new ZSToken(ZSTokenType.INVALID, value));
205 206
 		} else {
206 207
 			token = token.insert(tokenPosition.offset, value);
207 208
 			line.replace(tokenPosition.token, token);
@@ -210,7 +211,7 @@ public class TokenModel {
210 211
 	}
211 212
 	
212 213
 	private void relex(int fromLine, int fromToken, int toLine, int toToken) {
213
-		TokenRelexer reparser = new TokenRelexer(filename, lines, fromLine, fromToken, toLine, toToken, spacesPerTab);
214
+		TokenRelexer reparser = new TokenRelexer(file, lines, fromLine, fromToken, toLine, toToken, spacesPerTab);
214 215
 		List<ZSToken> tokens = reparser.relex();
215 216
 		replaceTokens(fromLine, fromToken, reparser.getLine(), reparser.getToken(), tokens);
216 217
 	}
@@ -257,6 +258,7 @@ public class TokenModel {
257 258
 		TokenLine currentLine = lines.get(line);
258 259
 		Set<Integer> insertedLines = new HashSet<>();
259 260
 		Set<Integer> modifiedLines = new HashSet<>();
261
+		modifiedLines.add(line);
260 262
 		while (tokens.hasNext()) {
261 263
 			ZSToken token = tokens.next();
262 264
 			if (token.type.multiline && token.content.indexOf('\n') >= 0) {
@@ -336,6 +338,13 @@ public class TokenModel {
336 338
 		public final int offset;
337 339
 		
338 340
 		public Position(int line, int token, int offset) {
341
+			if (line < 0)
342
+				throw new IllegalArgumentException("line cannot be negative");
343
+			if (token < 0)
344
+				throw new IllegalArgumentException("token cannot be negative");
345
+			if (offset < 0)
346
+				throw new IllegalArgumentException("offset cannot be negative");
347
+			
339 348
 			this.line = line;
340 349
 			this.token = token;
341 350
 			this.offset = offset;

+ 5
- 4
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenRelexer.java Ver arquivo

@@ -8,6 +8,7 @@ package org.openzen.zenscript.ide.ui.view.editor;
8 8
 import java.io.IOException;
9 9
 import java.util.ArrayList;
10 10
 import java.util.List;
11
+import org.openzen.zencode.shared.SourceFile;
11 12
 import org.openzen.zenscript.lexer.CharReader;
12 13
 import org.openzen.zenscript.lexer.TokenParser;
13 14
 import org.openzen.zenscript.lexer.ZSToken;
@@ -20,7 +21,7 @@ import org.openzen.zenscript.lexer.ZSTokenType;
20 21
  */
21 22
 public class TokenRelexer {
22 23
 	private final List<TokenLine> lines;
23
-	private final String filename;
24
+	private final SourceFile file;
24 25
 	private final int toLine;
25 26
 	private final int toToken;
26 27
 	private final int spacesPerTab;
@@ -28,12 +29,12 @@ public class TokenRelexer {
28 29
 	private int lineIndex;
29 30
 	private int token;
30 31
 	
31
-	public TokenRelexer(String filename, List<TokenLine> lines, int fromLine, int fromToken, int toLine, int toToken, int spacesPerTab) {
32
+	public TokenRelexer(SourceFile file, List<TokenLine> lines, int fromLine, int fromToken, int toLine, int toToken, int spacesPerTab) {
32 33
 		if (fromToken < 0 || toToken < 0)
33 34
 			throw new IllegalArgumentException("fromToken or toToken cannot be < 0");
34 35
 		
35 36
 		this.lines = lines;
36
-		this.filename = filename;
37
+		this.file = file;
37 38
 		this.toLine = toLine;
38 39
 		this.toToken = toToken;
39 40
 		
@@ -44,7 +45,7 @@ public class TokenRelexer {
44 45
 	
45 46
 	public List<ZSToken> relex() {
46 47
 		RelexCharReader reader = new RelexCharReader();
47
-		TokenParser<ZSToken, ZSTokenType> reparser = ZSTokenParser.createRaw(filename, reader, spacesPerTab);
48
+		TokenParser<ZSToken, ZSTokenType> reparser = ZSTokenParser.createRaw(file, reader, spacesPerTab);
48 49
 		List<ZSToken> result = new ArrayList<>();
49 50
 		while ((lineIndex < toLine || token < toToken || !reader.isAtTokenBoundary()) && reparser.hasNext())
50 51
 			result.add(reparser.next());

+ 47
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/WavyLine.java Ver arquivo

@@ -0,0 +1,47 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.editor;
7
+
8
+import org.openzen.drawablegui.DPath;
9
+import org.openzen.drawablegui.DPathTracer;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class WavyLine implements DPath {
16
+	private final int x;
17
+	private final int y;
18
+	private final int width;
19
+	private final int height;
20
+	private final float stride;
21
+	
22
+	public WavyLine(int x, int y, int width, int height, float stride) {
23
+		this.x = x;
24
+		this.y = y;
25
+		this.width = width;
26
+		this.height = height;
27
+		this.stride = stride;
28
+	}
29
+	
30
+	@Override
31
+	public void trace(DPathTracer tracer) {
32
+		tracer.moveTo(x, y);
33
+		for (int i = 0; i < (width / stride); i++) {
34
+			if ((i % 2) == 0) {
35
+				tracer.bezierCubic(
36
+						x + (i + 0.5f) * stride, y,
37
+						x + (i + 0.5f) * stride, y + height,
38
+						x + (i + 1) * stride, y + height);
39
+			} else {
40
+				tracer.bezierCubic(
41
+						x + (i + 0.5f) * stride, y + height,
42
+						x + (i + 0.5f) * stride, y,
43
+						x + (i + 1) * stride, y);
44
+			}
45
+		}
46
+	}
47
+}

+ 1
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java Ver arquivo

@@ -56,7 +56,7 @@ public class JavaCompiler implements ZenCodeCompiler {
56 56
 	@Override
57 57
 	public void addScriptBlock(ScriptBlock script) {
58 58
 		final SourceFile sourceFile = script.getTag(SourceFile.class);
59
-		final String className = getClassName(sourceFile == null ? null : sourceFile.filename);
59
+		final String className = getClassName(sourceFile == null ? null : sourceFile.getFilename());
60 60
 		JavaScriptFile scriptFile = getScriptFile(className);
61 61
 		
62 62
 		String methodName = scriptFile.scriptMethods.isEmpty() ? "run" : "run" + scriptFile.scriptMethods.size();

+ 5
- 6
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java Ver arquivo

@@ -1,5 +1,10 @@
1 1
 package org.openzen.zenscript.javabytecode.compiler;
2 2
 
3
+import java.util.Arrays;
4
+import java.util.Collection;
5
+import java.util.Comparator;
6
+import java.util.Map;
7
+import java.util.StringJoiner;
3 8
 import org.objectweb.asm.ClassWriter;
4 9
 import org.objectweb.asm.Label;
5 10
 import org.objectweb.asm.Opcodes;
@@ -772,10 +777,6 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
772 777
 							javaWriter.invokeStatic(ARRAYS_COPY_OF_RANGE_OBJECTS);
773 778
 							javaWriter.checkCast("[Ljava/lang/String;");
774 779
 							break;
775
-						case ANY:
776
-							javaWriter.invokeStatic(ARRAYS_COPY_OF_RANGE_OBJECTS);
777
-							javaWriter.checkCast("[Lzsynthetic/Any;");
778
-							break;
779 780
 						default:
780 781
 							throw new IllegalArgumentException("Unknown basic type: " + type.elementType);
781 782
 					}
@@ -821,7 +822,6 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
821 822
 							javaWriter.invokeStatic(ARRAYS_EQUALS_CHARS);
822 823
 							break;
823 824
 						case STRING:
824
-						case ANY:
825 825
 							javaWriter.invokeStatic(ARRAYS_EQUALS_OBJECTS);
826 826
 							break;
827 827
 						default:
@@ -1864,7 +1864,6 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1864 1864
 							javaWriter.invokeStatic(ARRAYS_HASHCODE_CHARS);
1865 1865
 							break;
1866 1866
 						case STRING:
1867
-						case ANY:
1868 1867
 							javaWriter.invokeStatic(ARRAYS_DEEPHASHCODE);
1869 1868
 							break;
1870 1869
 						default:

+ 0
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaOptionalTypeClassVisitor.java Ver arquivo

@@ -36,8 +36,6 @@ public class JavaOptionalTypeClassVisitor implements ITypeVisitor<Class> {
36 36
 				return void.class;
37 37
 			case NULL:
38 38
 				return Object.class;
39
-			case ANY:
40
-				return Object.class; // TODO
41 39
 			case BOOL:
42 40
 				return Boolean.class;
43 41
 			case BYTE:

+ 1
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java Ver arquivo

@@ -278,7 +278,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
278 278
 
279 279
         Type type = statement.type.accept(JavaTypeVisitor.INSTANCE);
280 280
         int local = javaWriter.local(type);
281
-        if(statement.initializer != null)
281
+        if (statement.initializer != null)
282 282
             javaWriter.store(type, local);
283 283
         final Label variableStart = new Label();
284 284
         javaWriter.label(variableStart);

+ 0
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaTypeClassVisitor.java Ver arquivo

@@ -17,7 +17,6 @@ public class JavaTypeClassVisitor implements ITypeVisitor<Class> {
17 17
         switch (basic) {
18 18
             case VOID:
19 19
                 return void.class;
20
-            case ANY:
21 20
             case NULL:
22 21
             case UNDETERMINED:
23 22
                 return Object.class;

+ 9
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaWriter.java Ver arquivo

@@ -11,8 +11,16 @@ import java.util.ArrayList;
11 11
 import java.util.HashMap;
12 12
 import java.util.List;
13 13
 import java.util.Map;
14
-
14
+import org.objectweb.asm.*;
15 15
 import static org.objectweb.asm.Opcodes.*;
16
+import org.objectweb.asm.commons.LocalVariablesSorter;
17
+import org.openzen.zencode.shared.CodePosition;
18
+import org.openzen.zenscript.codemodel.HighLevelDefinition;
19
+import org.openzen.zenscript.javabytecode.JavaClassInfo;
20
+import org.openzen.zenscript.javabytecode.JavaFieldInfo;
21
+import org.openzen.zenscript.javabytecode.JavaLocalVariableInfo;
22
+import org.openzen.zenscript.javabytecode.JavaMethodInfo;
23
+import org.openzen.zenscript.javabytecode.JavaParameterInfo;
16 24
 
17 25
 public class JavaWriter {
18 26
     private static final JavaClassInfo T_STRING = new JavaClassInfo("java/lang/String");

+ 8
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/BaseMemberCompiler.java Ver arquivo

@@ -68,6 +68,12 @@ public abstract class BaseMemberCompiler implements MemberVisitor<Void> {
68 68
 		this.currentElementType = type;
69 69
 	}
70 70
 	
71
+	protected void override(boolean override) {
72
+		if (override) {
73
+			output.append(indent).append("@Override\n");
74
+		}
75
+	}
76
+	
71 77
 	protected void modifiers(int modifiers) {
72 78
 		if (Modifiers.isPublic(modifiers))
73 79
 			output.append("public ");
@@ -75,6 +81,8 @@ public abstract class BaseMemberCompiler implements MemberVisitor<Void> {
75 81
 			output.append("protected ");
76 82
 		if (Modifiers.isPrivate(modifiers))
77 83
 			output.append("private ");
84
+		if (Modifiers.isAbstract(modifiers))
85
+			output.append("abstract ");
78 86
 		if (Modifiers.isStatic(modifiers))
79 87
 			output.append("static ");
80 88
 		if (Modifiers.isFinal(modifiers))

+ 2
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java Ver arquivo

@@ -64,7 +64,7 @@ public class FormattingUtils {
64 64
 			if (parameter.variadic)
65 65
 				result.append("...");
66 66
 			
67
-			if (!settings.showAnyInFunctionHeaders || parameter.type != BasicTypeID.ANY) {
67
+			if (!settings.showAnyInFunctionHeaders || parameter.type != BasicTypeID.UNDETERMINED) {
68 68
 				result.append(" as ");
69 69
 				result.append(header.returnType.accept(typeFormatter));
70 70
 			}
@@ -72,7 +72,7 @@ public class FormattingUtils {
72 72
 			parameterIndex++;
73 73
 		}
74 74
 		result.append(")");
75
-		if (!settings.showAnyInFunctionHeaders || header.returnType != BasicTypeID.ANY) {
75
+		if (!settings.showAnyInFunctionHeaders || header.returnType != BasicTypeID.UNDETERMINED) {
76 76
 			result.append(" as ");
77 77
 			result.append(header.returnType.accept(typeFormatter));
78 78
 		}

+ 2
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java Ver arquivo

@@ -86,7 +86,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
86 86
 		}
87 87
 		
88 88
 		if (mergedImplementations.size() > 0) {
89
-			output.append("implements ");
89
+			output.append(" implements ");
90 90
 			for (int i = 0; i < mergedImplementations.size(); i++) {
91 91
 				if (i > 0)
92 92
 					output.append(", ");
@@ -289,7 +289,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
289 289
 			output.append("static ");
290 290
 		if (Modifiers.isAbstract(modifiers))
291 291
 			output.append("abstract ");
292
-		if (!Modifiers.isVirtual(modifiers))
292
+		if (!Modifiers.isVirtual(modifiers) && !Modifiers.isAbstract(modifiers))
293 293
 			output.append("final ");
294 294
 	}
295 295
 	

+ 25
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java Ver arquivo

@@ -20,6 +20,7 @@ import org.openzen.zenscript.codemodel.member.DefinitionMember;
20 20
 import org.openzen.zenscript.codemodel.member.DestructorMember;
21 21
 import org.openzen.zenscript.codemodel.member.FieldMember;
22 22
 import org.openzen.zenscript.codemodel.member.GetterMember;
23
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
23 24
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
24 25
 import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
25 26
 import org.openzen.zenscript.codemodel.member.MethodMember;
@@ -30,6 +31,7 @@ import org.openzen.zenscript.codemodel.statement.EmptyStatement;
30 31
 import org.openzen.zenscript.codemodel.statement.Statement;
31 32
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
32 33
 import org.openzen.zenscript.javasource.scope.JavaSourceFileScope;
34
+import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
33 35
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
34 36
 
35 37
 /**
@@ -67,6 +69,7 @@ public class JavaMemberCompiler extends BaseMemberCompiler {
67 69
 			
68 70
 		
69 71
 		begin(ElementType.METHOD);
72
+		override(member.getOverrides() != null);
70 73
 		output.append(indent);
71 74
 		if (isInterface && hasBody)
72 75
 			output.append("default ");
@@ -196,7 +199,28 @@ public class JavaMemberCompiler extends BaseMemberCompiler {
196 199
 
197 200
 	@Override
198 201
 	public Void visitImplementation(ImplementationMember member) {
199
-		// TODO
202
+		JavaSourceImplementation implementation = member.getTag(JavaSourceImplementation.class);
203
+		if (implementation.inline) {
204
+			for (IDefinitionMember m : member.members) {
205
+				m.accept(this);
206
+			}
207
+		} else {
208
+			String interfaceName = member.type.accept(new JavaSourceTypeNameVisitor());
209
+			String implementationName = interfaceName + "Implementation";
210
+			
211
+			begin(ElementType.FIELD);
212
+			output.append(indent);
213
+			modifiers(member.modifiers);
214
+			output.append("final ").append(scope.type(member.type)).append(" as").append(interfaceName).append(" = new ").append(implementationName).append("();\n");
215
+			
216
+			begin(ElementType.INNERCLASS);
217
+			output.append("private class ").append(implementationName).append(" implements ").append(scope.type(member.type)).append(" {\n");
218
+			JavaMemberCompiler memberCompiler = new JavaMemberCompiler(settings, indent + settings.indent, output, scope, isInterface, definition);
219
+			for (IDefinitionMember m : member.members) {
220
+				m.accept(memberCompiler);
221
+			}
222
+			output.append(indent).append("}\n");
223
+		}
200 224
 		return null;
201 225
 	}
202 226
 

+ 2
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceCompiler.java Ver arquivo

@@ -93,8 +93,8 @@ public class JavaSourceCompiler implements ZenCodeCompiler {
93 93
 	private String getFilename(HighLevelDefinition definition) {
94 94
 		SourceFile source = definition.getTag(SourceFile.class);
95 95
 		if (source != null) {
96
-			int slash = Math.max(source.filename.lastIndexOf('/'), source.filename.lastIndexOf('\\'));
97
-			String filename = source.filename.substring(slash < 0 ? 0 : slash + 1);
96
+			int slash = Math.max(source.getFilename().lastIndexOf('/'), source.getFilename().lastIndexOf('\\'));
97
+			String filename = source.getFilename().substring(slash < 0 ? 0 : slash + 1);
98 98
 			filename = filename.substring(0, filename.lastIndexOf('.'));
99 99
 			return filename;
100 100
 		} else {

+ 0
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceObjectTypeVisitor.java Ver arquivo

@@ -20,7 +20,6 @@ public class JavaSourceObjectTypeVisitor extends JavaSourceTypeVisitor {
20 20
 	public String visitBasic(BasicTypeID basic) {
21 21
 		switch (basic) {
22 22
 			case VOID: return "Void";
23
-			case ANY: return "Any";
24 23
 			case BOOL: return "Boolean";
25 24
 			case BYTE: return "Byte";
26 25
 			case SBYTE: return "Byte";

+ 2
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceStatementFormatter.java Ver arquivo

@@ -119,6 +119,8 @@ public class JavaSourceStatementFormatter implements StatementFormatter.Formatte
119 119
 	public void formatReturn(StatementFormattingTarget target, ReturnStatement statement) {
120 120
 		if (statement.value == null)
121 121
 			target.writeLine("return;");
122
+		else if (statement.value.aborts()) // throw or panic
123
+			target.writeLine(scope.expression(target, statement.value).value + ";");
122 124
 		else
123 125
 			target.writeLine("return " + scope.expression(target, statement.value).value + ";");
124 126
 	}

+ 0
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeNameVisitor.java Ver arquivo

@@ -29,7 +29,6 @@ public class JavaSourceTypeNameVisitor implements ITypeVisitor<String> {
29 29
 	@Override
30 30
 	public String visitBasic(BasicTypeID basic) {
31 31
 		switch (basic) {
32
-			case ANY: return "Any";
33 32
 			case VOID: return "Void";
34 33
 			case BOOL: return "Bool";
35 34
 			case BYTE: return "Byte";

+ 0
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java Ver arquivo

@@ -21,7 +21,6 @@ import org.openzen.zenscript.codemodel.type.IteratorTypeID;
21 21
 import org.openzen.zenscript.codemodel.type.OptionalTypeID;
22 22
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
23 23
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
24
-import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
25 24
 
26 25
 /**
27 26
  *
@@ -57,7 +56,6 @@ public class JavaSourceTypeVisitor implements ITypeVisitor<String>, GenericParam
57 56
 	public String visitBasic(BasicTypeID basic) {
58 57
 		switch (basic) {
59 58
 			case VOID: return "void";
60
-			case ANY: return "Any";
61 59
 			case BOOL: return "boolean";
62 60
 			case BYTE: return "byte";
63 61
 			case SBYTE: return "byte";

+ 19
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareClassMethodVisitor.java Ver arquivo

@@ -17,6 +17,7 @@ import org.openzen.zenscript.codemodel.member.DefinitionMember;
17 17
 import org.openzen.zenscript.codemodel.member.DestructorMember;
18 18
 import org.openzen.zenscript.codemodel.member.FieldMember;
19 19
 import org.openzen.zenscript.codemodel.member.GetterMember;
20
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
20 21
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
21 22
 import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
22 23
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
@@ -27,6 +28,7 @@ import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
27 28
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
28 29
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
29 30
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
31
+import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
30 32
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
31 33
 
32 34
 /**
@@ -64,7 +66,7 @@ public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void>
64 66
 
65 67
 	@Override
66 68
 	public Void visitConstructor(ConstructorMember member) {
67
-		visitFunctional(member, member.name);
69
+		visitFunctional(member, "<init>");
68 70
 		return null;
69 71
 	}
70 72
 
@@ -118,10 +120,25 @@ public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void>
118 120
 
119 121
 	@Override
120 122
 	public Void visitImplementation(ImplementationMember member) {
121
-		// TODO: implementation merge check
122 123
 		cls.empty = false;
124
+		if (canMergeImplementation(member)) {
125
+			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(true, cls));
126
+			for (IDefinitionMember m : member.members)
127
+				m.accept(this);
128
+		} else {
129
+			JavaSourceClass implementationClass = new JavaSourceClass(cls.pkg + "." + cls.name, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
130
+			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
131
+			
132
+			JavaSourcePrepareClassMethodVisitor visitor = new JavaSourcePrepareClassMethodVisitor(implementationClass, null, true);
133
+			for (IDefinitionMember m : member.members)
134
+				m.accept(visitor);
135
+		}
123 136
 		return null;
124 137
 	}
138
+	
139
+	private boolean canMergeImplementation(ImplementationMember member) {
140
+		return true; // TODO: implementation merge check
141
+	}
125 142
 
126 143
 	@Override
127 144
 	public Void visitInnerDefinition(InnerDefinitionMember member) {

+ 24
- 1
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareDefinitionVisitor.java Ver arquivo

@@ -22,7 +22,6 @@ import org.openzen.zenscript.codemodel.expression.CallExpression;
22 22
 import org.openzen.zenscript.codemodel.expression.CastExpression;
23 23
 import org.openzen.zenscript.codemodel.expression.Expression;
24 24
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
25
-import org.openzen.zenscript.codemodel.type.ArrayTypeID;
26 25
 import org.openzen.zenscript.formattershared.ExpressionString;
27 26
 import org.openzen.zenscript.javasource.JavaOperator;
28 27
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
@@ -168,6 +167,30 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
168 167
 			cls.addConstructor("constructorWithCause", "");
169 168
 			nativeClasses.put("stdlib::Exception", cls);
170 169
 		}
170
+		
171
+		{
172
+			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "IOException"));
173
+			cls.addConstructor("constructor", "");
174
+			nativeClasses.put("io::IOException", cls);
175
+		}
176
+		
177
+		{
178
+			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "Reader"));
179
+			cls.addInstanceMethod("destruct", "close");
180
+			cls.addInstanceMethod("readCharacter", "read");
181
+			cls.addInstanceMethod("readArray", "read");
182
+			cls.addInstanceMethod("readArraySlice", "read");
183
+			nativeClasses.put("io::Reader", cls);
184
+		}
185
+		
186
+		{
187
+			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "StringReader"));
188
+			cls.addInstanceMethod("constructor", "");
189
+			cls.addInstanceMethod("destructor", "close");
190
+			cls.addInstanceMethod("readCharacter", "read");
191
+			cls.addInstanceMethod("readSlice", "read");
192
+			nativeClasses.put("io::StringReader", cls);
193
+		}
171 194
 	}
172 195
 	
173 196
 	private final String filename;

+ 11
- 4
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareExpansionMethodVisitor.java Ver arquivo

@@ -17,6 +17,7 @@ import org.openzen.zenscript.codemodel.member.DefinitionMember;
17 17
 import org.openzen.zenscript.codemodel.member.DestructorMember;
18 18
 import org.openzen.zenscript.codemodel.member.FieldMember;
19 19
 import org.openzen.zenscript.codemodel.member.GetterMember;
20
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
20 21
 import org.openzen.zenscript.codemodel.member.ImplementationMember;
21 22
 import org.openzen.zenscript.codemodel.member.InnerDefinitionMember;
22 23
 import org.openzen.zenscript.codemodel.member.MemberVisitor;
@@ -27,6 +28,7 @@ import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
27 28
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
28 29
 import org.openzen.zenscript.javasource.tags.JavaSourceClass;
29 30
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
31
+import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
30 32
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
31 33
 
32 34
 /**
@@ -54,7 +56,8 @@ public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Vo
54 56
 	public Void visitField(FieldMember member) {
55 57
 		// TODO: expansion fields
56 58
 		member.setTag(JavaSourceField.class, new JavaSourceField(cls, member.name));
57
-		cls.empty = false;
59
+		if (member.hasAutoGetter() || member.hasAutoSetter())
60
+			cls.empty = false;
58 61
 		return null;
59 62
 	}
60 63
 
@@ -66,7 +69,8 @@ public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Vo
66 69
 
67 70
 	@Override
68 71
 	public Void visitDestructor(DestructorMember member) {
69
-		throw new UnsupportedOperationException("Destructors not allowed on expansions");
72
+		visitFunctional(member, "");
73
+		return null;
70 74
 	}
71 75
 
72 76
 	@Override
@@ -113,8 +117,11 @@ public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Vo
113 117
 
114 118
 	@Override
115 119
 	public Void visitImplementation(ImplementationMember member) {
116
-		// TODO: implementation merge check
117
-		cls.empty = false;
120
+		JavaSourceClass implementationClass = new JavaSourceClass(cls.pkg + "." + cls.name, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
121
+		member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
122
+		for (IDefinitionMember implementedMember : member.members)
123
+			implementedMember.accept(this);
124
+		
118 125
 		return null;
119 126
 	}
120 127
 

+ 14
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourceSignatureVisitor.java Ver arquivo

@@ -0,0 +1,14 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.javasource.prepare;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class JavaSourceSignatureVisitor {
13
+	
14
+}

+ 20
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceImplementation.java Ver arquivo

@@ -0,0 +1,20 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.javasource.tags;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class JavaSourceImplementation {
13
+	public final boolean inline;
14
+	public final JavaSourceClass implementationClass;
15
+	
16
+	public JavaSourceImplementation(boolean inline, JavaSourceClass implementationClass) {
17
+		this.inline = inline;
18
+		this.implementationClass = implementationClass;
19
+	}
20
+}

+ 6
- 5
Parser/src/main/java/org/openzen/zenscript/lexer/CountingCharReader.java Ver arquivo

@@ -2,6 +2,7 @@ package org.openzen.zenscript.lexer;
2 2
 
3 3
 import java.io.IOException;
4 4
 import org.openzen.zencode.shared.CodePosition;
5
+import org.openzen.zencode.shared.SourceFile;
5 6
 
6 7
 /*
7 8
  * To change this license header, choose License Headers in Project Properties.
@@ -15,16 +16,16 @@ import org.openzen.zencode.shared.CodePosition;
15 16
  */
16 17
 public class CountingCharReader implements CharReader {
17 18
 	private final CharReader reader;
18
-	private final String filename;
19
+	private final SourceFile file;
19 20
 	private final int tabSize;
20 21
 	
21 22
 	private int line;
22 23
 	private int lineOffset;
23
-
24
-	public CountingCharReader(CharReader reader, String filename, int tabSize)
24
+	
25
+	public CountingCharReader(CharReader reader, SourceFile file, int tabSize)
25 26
 	{
26 27
 		this.reader = reader;
27
-		this.filename = filename;
28
+		this.file = file;
28 29
 		this.tabSize = tabSize;
29 30
 		
30 31
 		line = 1;
@@ -32,7 +33,7 @@ public class CountingCharReader implements CharReader {
32 33
 	}
33 34
 	
34 35
 	public CodePosition getPosition() {
35
-		return new CodePosition(filename, line, lineOffset, line, lineOffset);
36
+		return new CodePosition(file, line, lineOffset, line, lineOffset);
36 37
 	}
37 38
 
38 39
 	@Override

+ 9
- 7
Parser/src/main/java/org/openzen/zenscript/lexer/TokenParser.java Ver arquivo

@@ -6,6 +6,7 @@ import java.util.Iterator;
6 6
 import org.openzen.zencode.shared.CodePosition;
7 7
 import org.openzen.zencode.shared.CompileException;
8 8
 import org.openzen.zencode.shared.CompileExceptionCode;
9
+import org.openzen.zencode.shared.SourceFile;
9 10
 
10 11
 /**
11 12
  * Represents a token stream. A token stream reads characters from a reader and
@@ -28,13 +29,13 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements I
28 29
     /**
29 30
      * Creates a token stream using the specified reader and DFA.
30 31
      *
31
-	 * @param filename filename
32
+	 * @param file filename
32 33
      * @param reader reader to read characters from
33 34
      * @param dfa DFA to tokenize the stream
34 35
 	 * @param eof end of file token type
35 36
      */
36 37
     public TokenParser(
37
-			String filename,
38
+			SourceFile file,
38 39
 			CharReader reader, 
39 40
 			CompiledDFA<TT> dfa,
40 41
 			TT eof,
@@ -44,7 +45,7 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements I
44 45
 		if (eof.isWhitespace()) // important for the advance() method
45 46
 			throw new IllegalArgumentException("EOF cannot be whitespace");
46 47
 		
47
-        this.reader = new CountingCharReader(reader, filename, 4);
48
+        this.reader = new CountingCharReader(reader, file, 4);
48 49
         this.dfa = dfa;
49 50
 		this.eof = eof;
50 51
 		this.invalid = invalid;
@@ -54,14 +55,14 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements I
54 55
     /**
55 56
      * Creates a token stream which reads data from the specified string.
56 57
      *
57
-	 * @param filename filename
58
+	 * @param file filename
58 59
      * @param data data to read
59 60
      * @param dfa DFA to tokenize the stream
60 61
 	 * @param eof end of file token type
61 62
      */
62
-    public TokenParser(String filename, String data, CompiledDFA<TT> dfa, TT eof, TT invalid, TokenFactory<T, TT> factory)
63
+    public TokenParser(SourceFile file, String data, CompiledDFA<TT> dfa, TT eof, TT invalid, TokenFactory<T, TT> factory)
63 64
 	{
64
-        this(filename, new StringCharReader(data), dfa, eof, invalid, factory);
65
+        this(file, new StringCharReader(data), dfa, eof, invalid, factory);
65 66
     }
66 67
 	
67 68
 	@Override
@@ -110,7 +111,8 @@ public class TokenParser<T extends Token<TT>, TT extends TokenType> implements I
110 111
 				if (reader.peek() < 0 && value.length() == 0)
111 112
 					return factory.create(eof, ""); // happens on comments at the end of files
112 113
 				
113
-				//value.append((char) reader.next());
114
+				if (value.length() == 0)
115
+					value.append((char) reader.next());
114 116
 				return factory.create(invalid, value.toString());
115 117
             }
116 118
         } catch (IOException ex) {

+ 7
- 6
Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenParser.java Ver arquivo

@@ -7,6 +7,7 @@ package org.openzen.zenscript.lexer;
7 7
 
8 8
 import java.io.IOException;
9 9
 import java.io.Reader;
10
+import org.openzen.zencode.shared.SourceFile;
10 11
 import org.openzen.zenscript.codemodel.WhitespaceInfo;
11 12
 
12 13
 /**
@@ -16,9 +17,9 @@ import org.openzen.zenscript.codemodel.WhitespaceInfo;
16 17
 public class ZSTokenParser extends LLParserTokenStream<ZSTokenType, ZSToken> {
17 18
 	private static final CompiledDFA DFA = CompiledDFA.createLexerDFA(ZSTokenType.values(), ZSTokenType.class);
18 19
 	
19
-	public static TokenParser<ZSToken, ZSTokenType> createRaw(String filename, CharReader reader, int spacesPerTab) {
20
+	public static TokenParser<ZSToken, ZSTokenType> createRaw(SourceFile file, CharReader reader, int spacesPerTab) {
20 21
 		return new TokenParser<>(
21
-				filename,
22
+				file,
22 23
 				reader,
23 24
 				DFA,
24 25
 				ZSTokenType.EOF,
@@ -26,16 +27,16 @@ public class ZSTokenParser extends LLParserTokenStream<ZSTokenType, ZSToken> {
26 27
 				new ZSTokenFactory(spacesPerTab));
27 28
 	}
28 29
 	
29
-	public static ZSTokenParser create(String filename, Reader reader, int spacesPerTab) throws IOException {
30
-		return new ZSTokenParser(createRaw(filename, new ReaderCharReader(reader), spacesPerTab));
30
+	public static ZSTokenParser create(SourceFile file, int spacesPerTab) throws IOException {
31
+		return new ZSTokenParser(createRaw(file, new ReaderCharReader(file.open()), spacesPerTab));
31 32
 	}
32 33
 	
33 34
 	public ZSTokenParser(TokenStream<ZSTokenType, ZSToken> parser) {
34 35
 		super(parser);
35 36
 	}
36 37
 	
37
-	public String getFilename() {
38
-		return getPosition().filename;
38
+	public SourceFile getFile() {
39
+		return getPosition().file;
39 40
 	}
40 41
 	
41 42
 	public WhitespaceInfo collectWhitespaceInfo(String whitespace, boolean skipLineBefore) {

+ 3
- 1
Parser/src/main/java/org/openzen/zenscript/parser/ParsedDefinition.java Ver arquivo

@@ -76,5 +76,7 @@ public abstract class ParsedDefinition {
76 76
 	
77 77
 	public abstract void compileMembers(BaseScope scope);
78 78
 	
79
-	public abstract void compileCode(BaseScope scope);
79
+	public abstract void listMembers(BaseScope scope, PrecompilationState state);
80
+	
81
+	public abstract void compileCode(BaseScope scope, PrecompilationState state);
80 82
 }

+ 21
- 19
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java Ver arquivo

@@ -6,16 +6,15 @@
6 6
 package org.openzen.zenscript.parser;
7 7
 
8 8
 import java.io.File;
9
-import java.io.FileReader;
10 9
 import java.io.IOException;
11
-import java.io.Reader;
12
-import java.io.StringReader;
13 10
 import java.util.ArrayList;
14 11
 import java.util.List;
15 12
 import java.util.Map;
16 13
 import org.openzen.zencode.shared.CodePosition;
17 14
 import org.openzen.zencode.shared.CompileException;
18 15
 import org.openzen.zencode.shared.CompileExceptionCode;
16
+import org.openzen.zencode.shared.FileSourceFile;
17
+import org.openzen.zencode.shared.LiteralSourceFile;
19 18
 import org.openzen.zencode.shared.SourceFile;
20 19
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
21 20
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
@@ -42,27 +41,24 @@ import org.openzen.zenscript.parser.statements.ParsedStatement;
42 41
  */
43 42
 public class ParsedFile {
44 43
 	public static ParsedFile parse(ZSPackage pkg, File file) throws IOException {
45
-		String filename = file.toString();
46
-		try (FileReader reader = new FileReader(file)) {
47
-			return parse(pkg, filename, reader);
48
-		}
44
+		return parse(pkg, new FileSourceFile(file.getName(), file));
49 45
 	}
50 46
 	
51 47
 	public static ParsedFile parse(ZSPackage pkg, String filename, String content) {
52
-		try (StringReader reader = new StringReader(content)) {
53
-			return parse(pkg, filename, reader);
48
+		try {
49
+			return parse(pkg, new LiteralSourceFile(filename, content));
54 50
 		} catch (IOException ex) {
55
-			throw new AssertionError(); // supposed to never happen in a StringReader
51
+			throw new AssertionError(); // shouldn't happen
56 52
 		}
57 53
 	}
58 54
 	
59
-	public static ParsedFile parse(ZSPackage pkg, String filename, Reader reader) throws IOException {
60
-		ZSTokenParser tokens = ZSTokenParser.create(filename, reader, 4);
55
+	public static ParsedFile parse(ZSPackage pkg, SourceFile file) throws IOException {
56
+		ZSTokenParser tokens = ZSTokenParser.create(file, 4);
61 57
 		return parse(pkg, tokens);
62 58
 	}
63 59
 	
64 60
 	public static ParsedFile parse(ZSPackage pkg, ZSTokenParser tokens) {
65
-		ParsedFile result = new ParsedFile(tokens.getFilename());
61
+		ParsedFile result = new ParsedFile(tokens.getFile());
66 62
 		ZSToken eof = null;
67 63
 
68 64
 		while (true) {
@@ -124,15 +120,15 @@ public class ParsedFile {
124 120
 		return result;
125 121
 	}
126 122
 	
127
-	public final String filename;
123
+	public final SourceFile file;
128 124
 	
129 125
 	private final List<ParsedImport> imports = new ArrayList<>();
130 126
 	private final List<ParsedDefinition> definitions = new ArrayList<>();
131 127
 	private final List<ParsedStatement> statements = new ArrayList<>();
132 128
 	private WhitespacePostComment postComment = null;
133 129
 	
134
-	public ParsedFile(String filename) {
135
-		this.filename = filename;
130
+	public ParsedFile(SourceFile file) {
131
+		this.file = file;
136 132
 	}
137 133
 	
138 134
 	public boolean hasErrors() {
@@ -145,7 +141,7 @@ public class ParsedFile {
145 141
 	
146 142
 	public void listDefinitions(PackageDefinitions definitions) {
147 143
 		for (ParsedDefinition definition : this.definitions) {
148
-			definition.getCompiled().setTag(SourceFile.class, new SourceFile(filename));
144
+			definition.getCompiled().setTag(SourceFile.class, file);
149 145
 			definitions.add(definition.getCompiled());
150 146
 			definition.linkInnerTypes();
151 147
 		}
@@ -192,8 +188,14 @@ public class ParsedFile {
192 188
 			List<AnnotationDefinition> annotations) {
193 189
 		FileScope scope = new FileScope(rootPackage, packageDefinitions, globalRegistry, expansions, globalSymbols, annotations);
194 190
 		loadImports(scope, rootPackage, modulePackage);
191
+		
192
+		PrecompilationState state = new PrecompilationState();
193
+		for (ParsedDefinition definition : this.definitions) {
194
+			definition.listMembers(scope, state);
195
+		}
196
+		
195 197
 		for (ParsedDefinition definition : this.definitions) {
196
-			definition.compileCode(scope);
198
+			definition.compileCode(scope, state);
197 199
 		}
198 200
 		
199 201
 		if (!statements.isEmpty() || postComment != null) {
@@ -204,7 +206,7 @@ public class ParsedFile {
204 206
 			}
205 207
 			
206 208
 			ScriptBlock block = new ScriptBlock(statements);
207
-			block.setTag(SourceFile.class, new SourceFile(filename));
209
+			block.setTag(SourceFile.class, file);
208 210
 			block.setTag(WhitespacePostComment.class, postComment);
209 211
 			scripts.add(block);
210 212
 		}

+ 61
- 0
Parser/src/main/java/org/openzen/zenscript/parser/PrecompilationState.java Ver arquivo

@@ -0,0 +1,61 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.parser;
7
+
8
+import java.util.HashMap;
9
+import java.util.HashSet;
10
+import java.util.Map;
11
+import java.util.Set;
12
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
13
+import org.openzen.zenscript.codemodel.scope.BaseScope;
14
+import org.openzen.zenscript.parser.member.ParsedDefinitionMember;
15
+
16
+/**
17
+ *
18
+ * @author Hoofdgebruiker
19
+ */
20
+public class PrecompilationState {
21
+	private final Map<IDefinitionMember, CompilableMember> members = new HashMap<>();
22
+	private final Set<ParsedDefinitionMember> compilingMembers = new HashSet<>();
23
+	
24
+	public PrecompilationState() {
25
+		
26
+	}
27
+	
28
+	public void register(BaseScope definitionScope, ParsedDefinitionMember member) {
29
+		members.put(member.getCompiled(), new CompilableMember(member, definitionScope));
30
+	}
31
+	
32
+	public boolean precompile(IDefinitionMember member) {
33
+		if (!members.containsKey(member))
34
+			return true;
35
+		
36
+		CompilableMember cMember = members.get(member);
37
+		if (compilingMembers.contains(cMember.member))
38
+			return false;
39
+		
40
+		compilingMembers.add(cMember.member);
41
+		if (!cMember.member.inferHeaders(cMember.definitionScope, this))
42
+			return false;
43
+		
44
+		compilingMembers.remove(cMember.member);
45
+		return true;
46
+	}
47
+	
48
+	public void end(ParsedDefinitionMember member) {
49
+		compilingMembers.remove(member);
50
+	}
51
+	
52
+	private class CompilableMember {
53
+		private final ParsedDefinitionMember member;
54
+		private final BaseScope definitionScope;
55
+		
56
+		public CompilableMember(ParsedDefinitionMember member, BaseScope definitionScope) {
57
+			this.member = member;
58
+			this.definitionScope = definitionScope;
59
+		}
60
+	}
61
+}

+ 10
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/BaseParsedDefinition.java Ver arquivo

@@ -12,6 +12,7 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
12 12
 import org.openzen.zenscript.codemodel.scope.DefinitionScope;
13 13
 import org.openzen.zenscript.parser.ParsedAnnotation;
14 14
 import org.openzen.zenscript.parser.ParsedDefinition;
15
+import org.openzen.zenscript.parser.PrecompilationState;
15 16
 import org.openzen.zenscript.parser.member.ParsedDefinitionMember;
16 17
 
17 18
 /**
@@ -45,11 +46,18 @@ public abstract class BaseParsedDefinition extends ParsedDefinition {
45 46
 			getCompiled().addMember(member.getCompiled());
46 47
 		}
47 48
 	}
49
+	
50
+	@Override
51
+	public void listMembers(BaseScope scope, PrecompilationState state) {
52
+		DefinitionScope innerScope = new DefinitionScope(scope, getCompiled());
53
+		for (ParsedDefinitionMember member : members)
54
+			state.register(innerScope, member);
55
+	}
48 56
 
49 57
 	@Override
50
-	public void compileCode(BaseScope scope) {
58
+	public void compileCode(BaseScope scope, PrecompilationState state) {
51 59
 		DefinitionScope innerScope = new DefinitionScope(scope, getCompiled());
52 60
 		for (ParsedDefinitionMember member : members)
53
-			member.compile(innerScope);
61
+			member.compile(innerScope, state);
54 62
 	}
55 63
 }

+ 7
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java Ver arquivo

@@ -17,6 +17,7 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
17 17
 import org.openzen.zenscript.codemodel.scope.DefinitionScope;
18 18
 import org.openzen.zenscript.parser.ParsedAnnotation;
19 19
 import org.openzen.zenscript.parser.ParsedDefinition;
20
+import org.openzen.zenscript.parser.PrecompilationState;
20 21
 import org.openzen.zenscript.parser.type.IParsedType;
21 22
 
22 23
 /**
@@ -73,9 +74,14 @@ public class ParsedAlias extends ParsedDefinition {
73 74
 		
74 75
 		compiled.setType(type.compile(innerScope));
75 76
 	}
77
+	
78
+	@Override
79
+	public void listMembers(BaseScope scope, PrecompilationState state) {
80
+		// nothing to do
81
+	}
76 82
 
77 83
 	@Override
78
-	public void compileCode(BaseScope scope) {
84
+	public void compileCode(BaseScope scope, PrecompilationState state) {
79 85
 		// nothing to do
80 86
 	}
81 87
 

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java Ver arquivo

@@ -36,7 +36,7 @@ public class ParsedClass extends BaseParsedDefinition {
36 36
 		
37 37
 		ParsedClass result = new ParsedClass(pkg, position, modifiers, annotations, name, genericParameters, superclass, outerDefinition);
38 38
 		while (tokens.optional(ZSTokenType.T_ACLOSE) == null) {
39
-			result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled));
39
+			result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled, null));
40 40
 		}
41 41
 		return result;
42 42
 	}

+ 4
- 3
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java Ver arquivo

@@ -18,6 +18,7 @@ import org.openzen.zenscript.lexer.ZSTokenType;
18 18
 import org.openzen.zenscript.codemodel.scope.BaseScope;
19 19
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
20 20
 import org.openzen.zenscript.parser.ParsedAnnotation;
21
+import org.openzen.zenscript.parser.PrecompilationState;
21 22
 import org.openzen.zenscript.parser.member.ParsedDefinitionMember;
22 23
 
23 24
 /**
@@ -39,7 +40,7 @@ public class ParsedEnum extends BaseParsedDefinition {
39 40
 		
40 41
 		if (tokens.optional(ZSTokenType.T_SEMICOLON) != null) {
41 42
 			while (tokens.optional(ZSTokenType.T_ACLOSE) == null) {
42
-				result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled));
43
+				result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled, null));
43 44
 			}
44 45
 		} else {
45 46
 			tokens.required(ZSTokenType.T_ACLOSE, "} expected");
@@ -76,8 +77,8 @@ public class ParsedEnum extends BaseParsedDefinition {
76 77
 	}
77 78
 
78 79
 	@Override
79
-	public void compileCode(BaseScope scope) {
80
-		super.compileCode(scope);
80
+	public void compileCode(BaseScope scope, PrecompilationState state) {
81
+		super.compileCode(scope, state);
81 82
 		
82 83
 		DefinitionTypeID type = new DefinitionTypeID(compiled, new ITypeID[0]);
83 84
 		ExpressionScope evalScope = new ExpressionScope(scope);

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java Ver arquivo

@@ -30,7 +30,7 @@ public class ParsedExpansion extends BaseParsedDefinition {
30 30
 		
31 31
 		ParsedExpansion result = new ParsedExpansion(pkg, position, modifiers, annotations, parameters, target, outerDefinition);
32 32
 		while (tokens.optional(ZSTokenType.T_ACLOSE) == null) {
33
-			result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled));
33
+			result.addMember(ParsedDefinitionMember.parse(tokens, result.compiled, null));
34 34
 		}
35 35
 		return result;
36 36
 	}

+ 18
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java Ver arquivo

@@ -7,6 +7,8 @@
7 7
 package org.openzen.zenscript.parser.definitions;
8 8
 
9 9
 import org.openzen.zencode.shared.CodePosition;
10
+import org.openzen.zencode.shared.CompileException;
11
+import org.openzen.zencode.shared.CompileExceptionCode;
10 12
 import static org.openzen.zenscript.lexer.ZSTokenType.*;
11 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 14
 import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
@@ -14,8 +16,11 @@ import org.openzen.zenscript.codemodel.definition.ZSPackage;
14 16
 import org.openzen.zenscript.lexer.ZSTokenParser;
15 17
 import org.openzen.zenscript.codemodel.scope.BaseScope;
16 18
 import org.openzen.zenscript.codemodel.scope.FunctionScope;
19
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
20
+import org.openzen.zenscript.codemodel.type.ITypeID;
17 21
 import org.openzen.zenscript.parser.ParsedAnnotation;
18 22
 import org.openzen.zenscript.parser.ParsedDefinition;
23
+import org.openzen.zenscript.parser.PrecompilationState;
19 24
 import org.openzen.zenscript.parser.statements.ParsedFunctionBody;
20 25
 import org.openzen.zenscript.parser.statements.ParsedStatement;
21 26
 
@@ -59,10 +64,22 @@ public class ParsedFunction extends ParsedDefinition {
59 64
 	public void compileMembers(BaseScope scope) {
60 65
 		compiled.setHeader(header.compile(scope));
61 66
 	}
67
+	
68
+	@Override
69
+	public void listMembers(BaseScope scope, PrecompilationState state) {
70
+		
71
+	}
62 72
 
63 73
 	@Override
64
-	public void compileCode(BaseScope scope) {
74
+	public void compileCode(BaseScope scope, PrecompilationState state) {
65 75
 		FunctionScope innerScope = new FunctionScope(scope, compiled.header);
66 76
 		compiled.setCode(body.compile(innerScope, compiled.header));
77
+		
78
+		if (compiled.header.returnType == BasicTypeID.UNDETERMINED) {
79
+			ITypeID result = body.precompileForResultType(new FunctionScope(scope, compiled.header), state);
80
+			if (result == null)
81
+				throw new CompileException(position, CompileExceptionCode.PRECOMPILE_FAILED, "Could not determine return type for method " + compiled.name);
82
+			compiled.header = compiled.header.withReturnType(result);
83
+		}
67 84
 	}
68 85
 }

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunctionHeader.java Ver arquivo

@@ -47,7 +47,7 @@ public class ParsedFunctionHeader {
47 47
 				ZSToken argName = tokens.required(T_IDENTIFIER, "identifier expected");
48 48
 				boolean variadic = tokens.optional(T_DOT3) != null;
49 49
 				
50
-				IParsedType type = ParsedTypeBasic.ANY;
50
+				IParsedType type = ParsedTypeBasic.UNDETERMINED;
51 51
 				if (tokens.optional(K_AS) != null) {
52 52
 					type = IParsedType.parse(tokens);
53 53
 				}
@@ -60,7 +60,7 @@ public class ParsedFunctionHeader {
60 60
 			tokens.required(T_BRCLOSE, ") expected");
61 61
 		}
62 62
 
63
-		IParsedType returnType = ParsedTypeBasic.ANY;
63
+		IParsedType returnType = ParsedTypeBasic.UNDETERMINED;
64 64
 		if (tokens.optional(K_AS) != null) {
65 65
 			returnType = IParsedType.parse(tokens);
66 66
 		}

+ 0
- 0
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java Ver arquivo


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff

Carregando…
Cancelar
Salvar