Browse Source

WIP on refactoring code to reuse code between JavaBytecode and JavaSource

Stan Hebben 6 years ago
parent
commit
60574d3913
42 changed files with 395 additions and 321 deletions
  1. 5
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/ScriptBlock.java
  2. 6
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/FunctionScope.java
  3. 1
    0
      JavaBytecodeCompiler/build.gradle
  4. 0
    30
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaClassInfo.java
  5. 23
    0
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompileUtils.java
  6. 3
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java
  7. 4
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaFieldInfo.java
  8. 4
    3
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMethodInfo.java
  9. 28
    27
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  10. 2
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java
  11. 15
    21
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaWriter.java
  12. 9
    12
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaDefinitionVisitor.java
  13. 3
    3
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaMemberVisitor.java
  14. 18
    0
      JavaShared/build.gradle
  15. 122
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaClass.java
  16. 1
    0
      JavaSourceCompiler/build.gradle
  17. 7
    7
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaDefinitionVisitor.java
  18. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java
  19. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceCompiler.java
  20. 9
    9
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java
  21. 5
    5
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceFile.java
  22. 10
    10
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceImporter.java
  23. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceStatementFormatter.java
  24. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticHelperGenerator.java
  25. 4
    14
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticTypeGenerator.java
  26. 7
    14
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java
  27. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSynthesizedClass.java
  28. 4
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaNativeClass.java
  29. 4
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareClassMethodVisitor.java
  30. 53
    53
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareDefinitionVisitor.java
  31. 4
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/prepare/JavaSourcePrepareExpansionMethodVisitor.java
  32. 4
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceFileScope.java
  33. 3
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceStatementScope.java
  34. 0
    55
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceClass.java
  35. 4
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceField.java
  36. 4
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceImplementation.java
  37. 3
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceMethod.java
  38. 5
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceVariantOption.java
  39. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java
  40. 3
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java
  41. 4
    7
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java
  42. 1
    1
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java

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

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel;
7 7
 
8 8
 import java.util.List;
9 9
 import org.openzen.zencode.shared.Taggable;
10
+import org.openzen.zenscript.codemodel.definition.ZSPackage;
10 11
 import org.openzen.zenscript.codemodel.statement.Statement;
11 12
 
12 13
 /**
@@ -14,14 +15,16 @@ import org.openzen.zenscript.codemodel.statement.Statement;
14 15
  * @author Hoofdgebruiker
15 16
  */
16 17
 public class ScriptBlock extends Taggable {
18
+	public final ZSPackage pkg;
17 19
 	public final List<Statement> statements;
18 20
 	
19
-	public ScriptBlock(List<Statement> statements) {
21
+	public ScriptBlock(ZSPackage pkg, List<Statement> statements) {
22
+		this.pkg = pkg;
20 23
 		this.statements = statements;
21 24
 	}
22 25
 	
23 26
 	public ScriptBlock withStatements(List<Statement> newStatements) {
24
-		ScriptBlock result = new ScriptBlock(newStatements);
27
+		ScriptBlock result = new ScriptBlock(pkg, newStatements);
25 28
 		result.addAllTagsFrom(this);
26 29
 		return result;
27 30
 	}

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

@@ -35,6 +35,12 @@ public class FunctionScope extends StatementScope {
35 35
 	public FunctionScope(BaseScope outer, FunctionHeader header) {
36 36
 		this.outer = outer;
37 37
 		this.header = header;
38
+		
39
+		if (outer.getLocalTypeParameters() == null)
40
+			throw new NullPointerException();
41
+		if (header == null)
42
+			throw new NullPointerException();
43
+		
38 44
 		typeParameterMap = outer.getLocalTypeParameters().getInner(outer.getTypeRegistry(), header.typeParameters);
39 45
 	}
40 46
 	

+ 1
- 0
JavaBytecodeCompiler/build.gradle View File

@@ -17,4 +17,5 @@ dependencies {
17 17
 	compile 'org.ow2.asm:asm-debug-all:6.0_BETA'
18 18
 	compile project(':CodeModel')
19 19
 	compile project(':CompilerShared')
20
+	compile project(':JavaShared')
20 21
 }

+ 0
- 30
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaClassInfo.java View File

@@ -1,30 +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.javabytecode;
7
-
8
-import org.objectweb.asm.Type;
9
-
10
-/**
11
- *
12
- * @author Hoofdgebruiker
13
- */
14
-public class JavaClassInfo {
15
-	public static JavaClassInfo get(Class<?> cls) {
16
-		return new JavaClassInfo(Type.getInternalName(cls), cls.isEnum());
17
-	}
18
-	
19
-	public final String internalClassName;
20
-	public final boolean isEnum;
21
-	
22
-	public JavaClassInfo(String internalClassName) {
23
-		this(internalClassName, false);
24
-	}
25
-	
26
-	public JavaClassInfo(String internalClassName, boolean isEnum) {
27
-		this.internalClassName = internalClassName;
28
-		this.isEnum = isEnum;
29
-	}
30
-}

+ 23
- 0
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompileUtils.java View File

@@ -0,0 +1,23 @@
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.javabytecode;
7
+
8
+import org.objectweb.asm.Type;
9
+import org.openzen.zenscript.javashared.JavaClass;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class JavaCompileUtils {
16
+	private JavaCompileUtils() {}
17
+	
18
+	public static JavaClass get(Class<?> cls) {
19
+		return JavaClass.fromInternalName(
20
+				Type.getInternalName(cls),
21
+				cls.isInterface() ? JavaClass.Kind.INTERFACE : (cls.isEnum() ? JavaClass.Kind.ENUM : JavaClass.Kind.CLASS));
22
+	}
23
+}

+ 3
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java View File

@@ -23,6 +23,7 @@ import org.openzen.zenscript.javabytecode.compiler.definitions.JavaDefinitionVis
23 23
 import org.openzen.zenscript.javabytecode.compiler.JavaStatementVisitor;
24 24
 import org.openzen.zenscript.javabytecode.compiler.JavaWriter;
25 25
 import org.openzen.zenscript.compiler.ZenCodeCompiler;
26
+import org.openzen.zenscript.javashared.JavaClass;
26 27
 
27 28
 /**
28 29
  *
@@ -67,7 +68,7 @@ public class JavaCompiler implements ZenCodeCompiler {
67 68
 		// convert scripts into methods (add them to a Scripts class?)
68 69
 		// (TODO: can we break very long scripts into smaller methods? for the extreme scripts)
69 70
 		final JavaClassWriter visitor = scriptFile.classWriter;
70
-		JavaMethodInfo method = new JavaMethodInfo(new JavaClassInfo(className), methodName, "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
71
+		JavaMethodInfo method = new JavaMethodInfo(new JavaClass(script.pkg.fullName, className, JavaClass.Kind.CLASS), methodName, "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
71 72
 		scriptFile.scriptMethods.add(method);
72 73
 		
73 74
 		final JavaStatementVisitor statementVisitor = new JavaStatementVisitor(new JavaWriter(visitor, method, null, null, null));
@@ -121,7 +122,7 @@ public class JavaCompiler implements ZenCodeCompiler {
121 122
 			throw new IllegalStateException("Already finished!");
122 123
 		finished = true;
123 124
 		
124
-		JavaMethodInfo runMethod = new JavaMethodInfo(new JavaClassInfo("Scripts"), "run", "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
125
+		JavaMethodInfo runMethod = new JavaMethodInfo(new JavaClass("script", "Scripts", JavaClass.Kind.CLASS), "run", "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
125 126
 		final JavaWriter runWriter = new JavaWriter(scriptsClassWriter, runMethod, null, null, null);
126 127
 		runWriter.start();
127 128
 		for (Map.Entry<String, JavaScriptFile> entry : scriptBlocks.entrySet()) {

+ 4
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaFieldInfo.java View File

@@ -5,16 +5,18 @@
5 5
  */
6 6
 package org.openzen.zenscript.javabytecode;
7 7
 
8
+import org.openzen.zenscript.javashared.JavaClass;
9
+
8 10
 /**
9 11
  *
10 12
  * @author Hoofdgebruiker
11 13
  */
12 14
 public class JavaFieldInfo {
13
-	public final JavaClassInfo javaClass;
15
+	public final JavaClass javaClass;
14 16
 	public final String name;
15 17
 	public final String signature;
16 18
 	
17
-	public JavaFieldInfo(JavaClassInfo javaClass, String name, String signature) {
19
+	public JavaFieldInfo(JavaClass javaClass, String name, String signature) {
18 20
 		this.javaClass = javaClass;
19 21
 		this.name = name;
20 22
 		this.signature = signature;

+ 4
- 3
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMethodInfo.java View File

@@ -7,6 +7,7 @@ package org.openzen.zenscript.javabytecode;
7 7
 
8 8
 import org.objectweb.asm.Opcodes;
9 9
 import org.objectweb.asm.Type;
10
+import org.openzen.zenscript.javashared.JavaClass;
10 11
 
11 12
 /**
12 13
  *
@@ -21,15 +22,15 @@ public class JavaMethodInfo {
21 22
         }
22 23
         descriptor.append(')');
23 24
         descriptor.append(result == null ? 'V' : Type.getDescriptor(result));
24
-		return new JavaMethodInfo(new JavaClassInfo(Type.getInternalName(owner)), name, descriptor.toString(), modifiers);
25
+		return new JavaMethodInfo(JavaCompileUtils.get(owner), name, descriptor.toString(), modifiers);
25 26
     }
26 27
 	
27
-	public final JavaClassInfo javaClass;
28
+	public final JavaClass javaClass;
28 29
 	public final String name;
29 30
 	public final String descriptor;
30 31
 	public final int modifiers;
31 32
 	
32
-	public JavaMethodInfo(JavaClassInfo javaClass, String name, String signature, int modifiers) {
33
+	public JavaMethodInfo(JavaClass javaClass, String name, String signature, int modifiers) {
33 34
 		this.javaClass = javaClass;
34 35
 		this.name = name;
35 36
 		this.descriptor = signature;

+ 28
- 27
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java View File

@@ -24,28 +24,29 @@ import org.openzen.zenscript.javabytecode.*;
24 24
 
25 25
 import java.io.FileOutputStream;
26 26
 import java.io.IOException;
27
+import org.openzen.zenscript.javashared.JavaClass;
27 28
 
28 29
 public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
29 30
 	private static final int PUBLIC = Opcodes.ACC_PUBLIC;
30 31
 	private static final int STATIC = Opcodes.ACC_STATIC;
31 32
 	private static final int PUBLIC_STATIC = PUBLIC | STATIC;
32 33
 
33
-	private static final JavaClassInfo BOOLEAN = JavaClassInfo.get(Boolean.class);
34
+	private static final JavaClass BOOLEAN = JavaCompileUtils.get(Boolean.class);
34 35
 	private static final JavaMethodInfo BOOLEAN_PARSE = new JavaMethodInfo(BOOLEAN, "parseBoolean", "(Ljava/lang/String;)Z", PUBLIC_STATIC);
35 36
 	private static final JavaMethodInfo BOOLEAN_TO_STRING = new JavaMethodInfo(BOOLEAN, "toString", "(Z)Ljava/lang/String;", PUBLIC_STATIC);
36
-	private static final JavaClassInfo BYTE = JavaClassInfo.get(Byte.class);
37
+	private static final JavaClass BYTE = JavaCompileUtils.get(Byte.class);
37 38
 	private static final JavaMethodInfo BYTE_PARSE = new JavaMethodInfo(BYTE, "parseByte", "(Ljava/lang/String;)B", PUBLIC_STATIC);
38 39
 	private static final JavaMethodInfo BYTE_PARSE_WITH_BASE = new JavaMethodInfo(BYTE, "parseByte", "(Ljava/lang/String;I)B", PUBLIC_STATIC);
39 40
 	private static final JavaFieldInfo BYTE_MIN_VALUE = new JavaFieldInfo(BYTE, "MIN_VALUE", "B");
40 41
 	private static final JavaFieldInfo BYTE_MAX_VALUE = new JavaFieldInfo(BYTE, "MAX_VALUE", "B");
41 42
 	private static final JavaMethodInfo BYTE_TO_STRING = new JavaMethodInfo(BYTE, "toString", "(B)Ljava/lang/String;", PUBLIC_STATIC);
42
-	private static final JavaClassInfo SHORT = JavaClassInfo.get(Short.class);
43
+	private static final JavaClass SHORT = JavaCompileUtils.get(Short.class);
43 44
 	private static final JavaMethodInfo SHORT_PARSE = new JavaMethodInfo(SHORT, "parseShort", "(Ljava/lang/String;)S", PUBLIC_STATIC);
44 45
 	private static final JavaMethodInfo SHORT_PARSE_WITH_BASE = new JavaMethodInfo(SHORT, "parseShort", "(Ljava/lang/String;I)S", PUBLIC_STATIC);
45 46
 	private static final JavaFieldInfo SHORT_MIN_VALUE = new JavaFieldInfo(SHORT, "MIN_VALUE", "S");
46 47
 	private static final JavaFieldInfo SHORT_MAX_VALUE = new JavaFieldInfo(SHORT, "MAX_VALUE", "S");
47 48
 	private static final JavaMethodInfo SHORT_TO_STRING = new JavaMethodInfo(SHORT, "toString", "(S)Ljava/lang/String;", PUBLIC_STATIC);
48
-	private static final JavaClassInfo INTEGER = JavaClassInfo.get(Integer.class);
49
+	private static final JavaClass INTEGER = JavaCompileUtils.get(Integer.class);
49 50
 	private static final JavaMethodInfo INTEGER_COMPARE_UNSIGNED = new JavaMethodInfo(INTEGER, "compareUnsigned", "(II)I", PUBLIC_STATIC);
50 51
 	private static final JavaMethodInfo INTEGER_DIVIDE_UNSIGNED = new JavaMethodInfo(INTEGER, "divideUnsigned", "(II)I", PUBLIC_STATIC);
51 52
 	private static final JavaMethodInfo INTEGER_REMAINDER_UNSIGNED = new JavaMethodInfo(INTEGER, "remainderUnsigned", "(II)I", PUBLIC_STATIC);
@@ -62,7 +63,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
62 63
 	private static final JavaFieldInfo INTEGER_MAX_VALUE = new JavaFieldInfo(INTEGER, "MAX_VALUE", "I");
63 64
 	private static final JavaMethodInfo INTEGER_TO_STRING = new JavaMethodInfo(INTEGER, "toString", "(I)Ljava/lang/String;", PUBLIC_STATIC);
64 65
 	private static final JavaMethodInfo INTEGER_TO_UNSIGNED_STRING = new JavaMethodInfo(INTEGER, "toUnsignedString", "(I)Ljava/lang/String;", PUBLIC_STATIC);
65
-	private static final JavaClassInfo LONG = new JavaClassInfo(Type.getInternalName(Long.class));
66
+	private static final JavaClass LONG = JavaCompileUtils.get(Long.class);
66 67
 	private static final JavaMethodInfo LONG_COMPARE = new JavaMethodInfo(LONG, "compare", "(JJ)I", PUBLIC_STATIC);
67 68
 	private static final JavaMethodInfo LONG_COMPARE_UNSIGNED = new JavaMethodInfo(LONG, "compareUnsigned", "(JJ)I", PUBLIC_STATIC);
68 69
 	private static final JavaMethodInfo LONG_DIVIDE_UNSIGNED = new JavaMethodInfo(LONG, "divideUnsigned", "(JJ)J", PUBLIC_STATIC);
@@ -80,7 +81,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
80 81
 	private static final JavaFieldInfo LONG_MAX_VALUE = new JavaFieldInfo(LONG, "MAX_VALUE", "J");
81 82
 	private static final JavaMethodInfo LONG_TO_STRING = new JavaMethodInfo(LONG, "toString", "(J)Ljava/lang/String;", PUBLIC_STATIC);
82 83
 	private static final JavaMethodInfo LONG_TO_UNSIGNED_STRING = new JavaMethodInfo(LONG, "toUnsignedString", "(J)Ljava/lang/String;", PUBLIC_STATIC);
83
-	private static final JavaClassInfo FLOAT = new JavaClassInfo(Type.getInternalName(Float.class));
84
+	private static final JavaClass FLOAT = JavaCompileUtils.get(Float.class);
84 85
 	private static final JavaMethodInfo FLOAT_COMPARE = new JavaMethodInfo(FLOAT, "compare", "(FF)I", PUBLIC_STATIC);
85 86
 	private static final JavaMethodInfo FLOAT_PARSE = new JavaMethodInfo(FLOAT, "parseFloat", "(Ljava/lang/String;)F", PUBLIC_STATIC);
86 87
 	private static final JavaMethodInfo FLOAT_FROM_BITS = new JavaMethodInfo(FLOAT, "intBitsToFloat", "(I)F", PUBLIC_STATIC);
@@ -88,7 +89,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
88 89
 	private static final JavaFieldInfo FLOAT_MIN_VALUE = new JavaFieldInfo(FLOAT, "MIN_VALUE", "F");
89 90
 	private static final JavaFieldInfo FLOAT_MAX_VALUE = new JavaFieldInfo(FLOAT, "MAX_VALUE", "F");
90 91
 	private static final JavaMethodInfo FLOAT_TO_STRING = new JavaMethodInfo(FLOAT, "toString", "(F)Ljava/lang/String;", PUBLIC_STATIC);
91
-	private static final JavaClassInfo DOUBLE = new JavaClassInfo(Type.getInternalName(Double.class));
92
+	private static final JavaClass DOUBLE = JavaCompileUtils.get(Double.class);
92 93
 	private static final JavaMethodInfo DOUBLE_COMPARE = new JavaMethodInfo(DOUBLE, "compare", "(DD)I", PUBLIC_STATIC);
93 94
 	private static final JavaMethodInfo DOUBLE_PARSE = new JavaMethodInfo(DOUBLE, "parseDouble", "(Ljava/lang/String;)D", PUBLIC_STATIC);
94 95
 	private static final JavaMethodInfo DOUBLE_FROM_BITS = new JavaMethodInfo(DOUBLE, "longBitsToDouble", "(J)D", PUBLIC_STATIC);
@@ -96,13 +97,13 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
96 97
 	private static final JavaFieldInfo DOUBLE_MIN_VALUE = new JavaFieldInfo(DOUBLE, "MIN_VALUE", "D");
97 98
 	private static final JavaFieldInfo DOUBLE_MAX_VALUE = new JavaFieldInfo(DOUBLE, "MAX_VALUE", "D");
98 99
 	private static final JavaMethodInfo DOUBLE_TO_STRING = new JavaMethodInfo(DOUBLE, "toString", "(D)Ljava/lang/String;", PUBLIC_STATIC);
99
-	private static final JavaClassInfo CHARACTER = new JavaClassInfo(Type.getInternalName(Character.class));
100
+	private static final JavaClass CHARACTER = JavaCompileUtils.get(Character.class);
100 101
 	private static final JavaMethodInfo CHARACTER_TO_LOWER_CASE = new JavaMethodInfo(CHARACTER, "toLowerCase", "()C", PUBLIC);
101 102
 	private static final JavaMethodInfo CHARACTER_TO_UPPER_CASE = new JavaMethodInfo(CHARACTER, "toUpperCase", "()C", PUBLIC);
102 103
 	private static final JavaFieldInfo CHARACTER_MIN_VALUE = new JavaFieldInfo(CHARACTER, "MIN_VALUE", "C");
103 104
 	private static final JavaFieldInfo CHARACTER_MAX_VALUE = new JavaFieldInfo(CHARACTER, "MAX_VALUE", "C");
104 105
 	private static final JavaMethodInfo CHARACTER_TO_STRING = new JavaMethodInfo(CHARACTER, "toString", "(C)Ljava/lang/String;", PUBLIC_STATIC);
105
-	private static final JavaClassInfo STRING = new JavaClassInfo(Type.getInternalName(String.class));
106
+	private static final JavaClass STRING = JavaCompileUtils.get(String.class);
106 107
 	private static final JavaMethodInfo STRING_COMPARETO = new JavaMethodInfo(STRING, "compareTo", "(Ljava/lang/String;)I", PUBLIC);
107 108
 	private static final JavaMethodInfo STRING_CONCAT = new JavaMethodInfo(STRING, "concat", "(Ljava/lang/String;)Ljava/lang/String;", PUBLIC);
108 109
 	private static final JavaMethodInfo STRING_CHAR_AT = new JavaMethodInfo(STRING, "charAt", "(I)C", PUBLIC);
@@ -113,11 +114,11 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
113 114
 	private static final JavaMethodInfo STRING_LENGTH = new JavaMethodInfo(STRING, "length", "()I", PUBLIC);
114 115
 	private static final JavaMethodInfo STRING_CHARACTERS = new JavaMethodInfo(STRING, "toCharArray", "()[C", PUBLIC);
115 116
 	private static final JavaMethodInfo STRING_ISEMPTY = new JavaMethodInfo(STRING, "isEmpty", "()Z", PUBLIC);
116
-	private static final JavaClassInfo ENUM = new JavaClassInfo(Type.getInternalName(Enum.class));
117
+	private static final JavaClass ENUM = JavaCompileUtils.get(Enum.class);
117 118
 	private static final JavaMethodInfo ENUM_COMPARETO = new JavaMethodInfo(STRING, "compareTo", "(Ljava/lang/Enum;)I", PUBLIC);
118 119
 	private static final JavaMethodInfo ENUM_NAME = new JavaMethodInfo(STRING, "name", "()Ljava/lang/String;", PUBLIC);
119 120
 	private static final JavaMethodInfo ENUM_ORDINAL = new JavaMethodInfo(STRING, "ordinal", "()I", PUBLIC);
120
-	private static final JavaClassInfo MAP = new JavaClassInfo(Type.getInternalName(Map.class));
121
+	private static final JavaClass MAP = JavaCompileUtils.get(Map.class);
121 122
 	private static final JavaMethodInfo MAP_GET = new JavaMethodInfo(MAP, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", PUBLIC);
122 123
 	private static final JavaMethodInfo MAP_PUT = new JavaMethodInfo(MAP, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", PUBLIC);
123 124
 	private static final JavaMethodInfo MAP_CONTAINS_KEY = new JavaMethodInfo(MAP, "containsKey", "(Ljava/lang/Object;)Z", PUBLIC);
@@ -125,7 +126,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
125 126
 	private static final JavaMethodInfo MAP_ISEMPTY = new JavaMethodInfo(MAP, "isEmpty", "()Z", PUBLIC);
126 127
 	private static final JavaMethodInfo MAP_KEYS = new JavaMethodInfo(MAP, "keys", "()Ljava/lang/Object;", PUBLIC);
127 128
 	private static final JavaMethodInfo MAP_VALUES = new JavaMethodInfo(MAP, "values", "()Ljava/lang/Object;", PUBLIC);
128
-	private static final JavaClassInfo ARRAYS = new JavaClassInfo(Type.getInternalName(Arrays.class));
129
+	private static final JavaClass ARRAYS = JavaCompileUtils.get(Arrays.class);
129 130
 	private static final JavaMethodInfo ARRAYS_COPY_OF_RANGE_OBJECTS = new JavaMethodInfo(ARRAYS, "copyOfRange", "([Ljava/lang/Object;II)[Ljava/lang/Object;", PUBLIC_STATIC);
130 131
 	private static final JavaMethodInfo ARRAYS_COPY_OF_RANGE_BOOLS = new JavaMethodInfo(ARRAYS, "copyOfRange", "([ZII)[Z", PUBLIC_STATIC);
131 132
 	private static final JavaMethodInfo ARRAYS_COPY_OF_RANGE_BYTES = new JavaMethodInfo(ARRAYS, "copyOfRange", "([BII)[B", PUBLIC_STATIC);
@@ -153,9 +154,9 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
153 154
 	private static final JavaMethodInfo ARRAYS_HASHCODE_FLOATS = new JavaMethodInfo(ARRAYS, "hashCode", "([F)I", PUBLIC_STATIC);
154 155
 	private static final JavaMethodInfo ARRAYS_HASHCODE_DOUBLES = new JavaMethodInfo(ARRAYS, "hashCode", "([D)I", PUBLIC_STATIC);
155 156
 	private static final JavaMethodInfo ARRAYS_HASHCODE_CHARS = new JavaMethodInfo(ARRAYS, "hashCode", "([C)I", PUBLIC_STATIC);
156
-	private static final JavaClassInfo OBJECT = JavaClassInfo.get(Object.class);
157
+	private static final JavaClass OBJECT = JavaCompileUtils.get(Object.class);
157 158
 	private static final JavaMethodInfo OBJECT_HASHCODE = new JavaMethodInfo(OBJECT, "hashCode", "()I", PUBLIC);
158
-	private static final JavaClassInfo COLLECTION = JavaClassInfo.get(Collection.class);
159
+	private static final JavaClass COLLECTION = JavaCompileUtils.get(Collection.class);
159 160
 	private static final JavaMethodInfo COLLECTION_SIZE = new JavaMethodInfo(COLLECTION, "size", "()I", PUBLIC);
160 161
 	private static final JavaMethodInfo COLLECTION_TOARRAY = new JavaMethodInfo(COLLECTION, "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", PUBLIC);
161 162
 
@@ -837,13 +838,13 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
837 838
 				break;
838 839
 			}
839 840
 			case FUNCTION_CALL:
840
-				//expression.target.accept(this);
841
-				//for (Expression argument : expression.arguments.arguments) {
842
-				//	argument.accept(this);
843
-				//}
844
-				javaWriter.invokeInterface(new JavaMethodInfo(new JavaClassInfo(expression.target.type.accept(JavaTypeVisitor.INSTANCE).getInternalName()), "accept", CompilerUtils.calcSign(expression.instancedHeader, false), Opcodes.ACC_PUBLIC));
841
+				javaWriter.invokeInterface(
842
+						new JavaMethodInfo(
843
+								JavaClass.fromInternalName(expression.target.type.accept(JavaTypeVisitor.INSTANCE).getInternalName(), JavaClass.Kind.INTERFACE),
844
+								"accept",
845
+								CompilerUtils.calcSign(expression.instancedHeader, false),
846
+								Opcodes.ACC_PUBLIC));
845 847
 				break;
846
-				//throw new UnsupportedOperationException("Not yet supported!");
847 848
 			case AUTOOP_NOTEQUALS:
848 849
 				throw new UnsupportedOperationException("Not yet supported!");
849 850
 			default:
@@ -1425,8 +1426,8 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1425 1426
 				break;
1426 1427
 			case ENUM_VALUES: {
1427 1428
 				DefinitionTypeID type = (DefinitionTypeID) expression.type;
1428
-				JavaClassInfo cls = type.definition.getTag(JavaClassInfo.class);
1429
-				javaWriter.invokeStatic(new JavaMethodInfo(cls, "values", "()[L" + cls.internalClassName + ";", PUBLIC_STATIC));
1429
+				JavaClass cls = type.definition.getTag(JavaClass.class);
1430
+				javaWriter.invokeStatic(new JavaMethodInfo(cls, "values", "()[L" + cls.internalName + ";", PUBLIC_STATIC));
1430 1431
 				break;
1431 1432
 			}
1432 1433
 			default:
@@ -1527,7 +1528,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1527 1528
 		}
1528 1529
 
1529 1530
         javaWriter.loadObject(0);
1530
-        if (javaWriter.method.javaClass.isEnum) {
1531
+        if (javaWriter.method.javaClass.isEnum()) {
1531 1532
             javaWriter.loadObject(1);
1532 1533
             javaWriter.loadInt(2);
1533 1534
         }
@@ -1536,7 +1537,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1536 1537
             argument.accept(this);
1537 1538
         }
1538 1539
 		String internalName = type.getInternalName();
1539
-        javaWriter.invokeSpecial(internalName, "<init>", CompilerUtils.calcDesc(expression.constructor.getHeader(), javaWriter.method.javaClass.isEnum));
1540
+        javaWriter.invokeSpecial(internalName, "<init>", CompilerUtils.calcDesc(expression.constructor.getHeader(), javaWriter.method.javaClass.isEnum()));
1540 1541
         return null;
1541 1542
     }
1542 1543
 
@@ -1962,7 +1963,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1962 1963
         javaWriter.label(start);
1963 1964
         expression.value.accept(this);
1964 1965
         if (expression.value.type == BasicTypeID.STRING)
1965
-            javaWriter.invokeVirtual(new JavaMethodInfo(new JavaClassInfo("java/lang/Object"), "hashCode", "()I", 0));
1966
+            javaWriter.invokeVirtual(new JavaMethodInfo(OBJECT, "hashCode", "()I", 0));
1966 1967
 
1967 1968
         final boolean hasNoDefault = hasNoDefault(expression);
1968 1969
 
@@ -2242,8 +2243,8 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
2242 2243
 				break;
2243 2244
 			case ENUM_VALUES: {
2244 2245
 				DefinitionTypeID type = (DefinitionTypeID) expression.type;
2245
-				JavaClassInfo cls = type.definition.getTag(JavaClassInfo.class);
2246
-				javaWriter.invokeStatic(new JavaMethodInfo(cls, "values", "()[L" + cls.internalClassName + ";", PUBLIC_STATIC));
2246
+				JavaClass cls = type.definition.getTag(JavaClass.class);
2247
+				javaWriter.invokeStatic(new JavaMethodInfo(cls, "values", "()[L" + cls.internalName + ";", PUBLIC_STATIC));
2247 2248
 				break;
2248 2249
 			}
2249 2250
 			default:

+ 2
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java View File

@@ -4,12 +4,12 @@ import org.objectweb.asm.Label;
4 4
 import org.objectweb.asm.Type;
5 5
 import org.openzen.zenscript.codemodel.statement.*;
6 6
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
7
-import org.openzen.zenscript.javabytecode.JavaClassInfo;
8 7
 import org.openzen.zenscript.javabytecode.JavaLocalVariableInfo;
9 8
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
10 9
 
11 10
 import java.util.Arrays;
12 11
 import java.util.List;
12
+import org.openzen.zenscript.javashared.JavaClass;
13 13
 
14 14
 public class JavaStatementVisitor implements StatementVisitor<Boolean> {
15 15
     private final JavaWriter javaWriter;
@@ -162,7 +162,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
162 162
         javaWriter.label(start);
163 163
         statement.value.accept(expressionVisitor);
164 164
         if (statement.value.type == BasicTypeID.STRING)
165
-            javaWriter.invokeVirtual(new JavaMethodInfo(new JavaClassInfo("java/lang/Object"), "hashCode", "()I", 0));
165
+            javaWriter.invokeVirtual(new JavaMethodInfo(JavaClass.OBJECT, "hashCode", "()I", 0));
166 166
         boolean out = false;
167 167
 
168 168
         final boolean hasNoDefault = hasNoDefault(statement);

+ 15
- 21
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaWriter.java View File

@@ -1,31 +1,25 @@
1 1
 package org.openzen.zenscript.javabytecode.compiler;
2 2
 
3 3
 import org.objectweb.asm.*;
4
-import org.objectweb.asm.commons.LocalVariablesSorter;
5
-import org.openzen.zencode.shared.CodePosition;
6
-import org.openzen.zenscript.codemodel.HighLevelDefinition;
7
-import org.openzen.zenscript.javabytecode.*;
8 4
 
9 5
 import java.lang.reflect.Field;
10 6
 import java.util.ArrayList;
11 7
 import java.util.HashMap;
12 8
 import java.util.List;
13 9
 import java.util.Map;
14
-import org.objectweb.asm.*;
15 10
 import static org.objectweb.asm.Opcodes.*;
16 11
 import org.objectweb.asm.commons.LocalVariablesSorter;
17 12
 import org.openzen.zencode.shared.CodePosition;
18 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
19
-import org.openzen.zenscript.javabytecode.JavaClassInfo;
20 14
 import org.openzen.zenscript.javabytecode.JavaFieldInfo;
21 15
 import org.openzen.zenscript.javabytecode.JavaLocalVariableInfo;
22 16
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
23 17
 import org.openzen.zenscript.javabytecode.JavaParameterInfo;
18
+import org.openzen.zenscript.javashared.JavaClass;
24 19
 
25 20
 public class JavaWriter {
26
-    private static final JavaClassInfo T_STRING = new JavaClassInfo("java/lang/String");
27 21
     private static final JavaMethodInfo STRING_CONCAT = new JavaMethodInfo(
28
-            T_STRING,
22
+            JavaClass.STRING,
29 23
             "concat",
30 24
             "(Ljava/lang/String;)Ljava/lang/String;",
31 25
             Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
@@ -819,7 +813,7 @@ public class JavaWriter {
819 813
 	public void invokeStatic(JavaMethodInfo method) {
820 814
 		visitor.visitMethodInsn(
821 815
 				INVOKESTATIC,
822
-				method.javaClass.internalClassName,
816
+				method.javaClass.internalName,
823 817
 				method.name,
824 818
 				method.descriptor,
825 819
 				false);
@@ -838,16 +832,16 @@ public class JavaWriter {
838 832
 
839 833
     public void invokeVirtual(JavaMethodInfo method) {
840 834
         if (debug)
841
-            System.out.println("invokeVirtual " + method.javaClass.internalClassName + '.' + method.name + method.descriptor);
835
+            System.out.println("invokeVirtual " + method.javaClass.internalName + '.' + method.name + method.descriptor);
842 836
 
843
-        visitor.visitMethodInsn(INVOKEVIRTUAL, method.javaClass.internalClassName, method.name, method.descriptor, false);
837
+        visitor.visitMethodInsn(INVOKEVIRTUAL, method.javaClass.internalName, method.name, method.descriptor, false);
844 838
     }
845 839
 
846 840
     public void invokeInterface(JavaMethodInfo method) {
847 841
         if (debug)
848
-            System.out.println("invokeInterface " + method.javaClass.internalClassName + '.' + method.name + method.descriptor);
842
+            System.out.println("invokeInterface " + method.javaClass.internalName + '.' + method.name + method.descriptor);
849 843
 
850
-        visitor.visitMethodInsn(INVOKEINTERFACE, method.javaClass.internalClassName, method.name, method.descriptor, true);
844
+        visitor.visitMethodInsn(INVOKEINTERFACE, method.javaClass.internalName, method.name, method.descriptor, true);
851 845
     }
852 846
 
853 847
     public void newObject(Class type) {
@@ -1060,9 +1054,9 @@ public class JavaWriter {
1060 1054
 	
1061 1055
 	public void getField(JavaFieldInfo field) {
1062 1056
         if (debug)
1063
-            System.out.println("getField " + field.javaClass.internalClassName + '.' + field.name + ":" + field.signature);
1057
+            System.out.println("getField " + field.javaClass.internalName + '.' + field.name + ":" + field.signature);
1064 1058
 		
1065
-		visitor.visitFieldInsn(GETFIELD, field.javaClass.internalClassName, field.name, field.signature);
1059
+		visitor.visitFieldInsn(GETFIELD, field.javaClass.internalName, field.name, field.signature);
1066 1060
 	}
1067 1061
 
1068 1062
     public void putField(String owner, String name, String descriptor) {
@@ -1081,9 +1075,9 @@ public class JavaWriter {
1081 1075
 	
1082 1076
 	public void putField(JavaFieldInfo field) {
1083 1077
         if (debug)
1084
-            System.out.println("putField " + field.javaClass.internalClassName + '.' + field.name + ":" + field.signature);
1078
+            System.out.println("putField " + field.javaClass.internalName + '.' + field.name + ":" + field.signature);
1085 1079
 		
1086
-		visitor.visitFieldInsn(PUTFIELD, field.javaClass.internalClassName, field.name, field.signature);
1080
+		visitor.visitFieldInsn(PUTFIELD, field.javaClass.internalName, field.name, field.signature);
1087 1081
 	}
1088 1082
 
1089 1083
     public void getStaticField(String owner, String name, String descriptor) {
@@ -1095,9 +1089,9 @@ public class JavaWriter {
1095 1089
 	
1096 1090
 	public void getStaticField(JavaFieldInfo field) {
1097 1091
         if (debug)
1098
-            System.out.println("getStaticField " + field.javaClass.internalClassName + '.' + field.name + ":" + field.signature);
1092
+            System.out.println("getStaticField " + field.javaClass.internalName + '.' + field.name + ":" + field.signature);
1099 1093
 		
1100
-		visitor.visitFieldInsn(GETSTATIC, field.javaClass.internalClassName, field.name, field.signature);
1094
+		visitor.visitFieldInsn(GETSTATIC, field.javaClass.internalName, field.name, field.signature);
1101 1095
 	}
1102 1096
 
1103 1097
     public void putStaticField(String owner, String name, String descriptor) {
@@ -1116,9 +1110,9 @@ public class JavaWriter {
1116 1110
 	
1117 1111
 	public void putStaticField(JavaFieldInfo field) {
1118 1112
         if (debug)
1119
-            System.out.println("putStaticField " + field.javaClass.internalClassName + '.' + field.name + ":" + field.signature);
1113
+            System.out.println("putStaticField " + field.javaClass.internalName + '.' + field.name + ":" + field.signature);
1120 1114
 		
1121
-		visitor.visitFieldInsn(PUTSTATIC, field.javaClass.internalClassName, field.name, field.signature);
1115
+		visitor.visitFieldInsn(PUTSTATIC, field.javaClass.internalName, field.name, field.signature);
1122 1116
 	}
1123 1117
 
1124 1118
     public void aThrow() {

+ 9
- 12
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaDefinitionVisitor.java View File

@@ -7,23 +7,21 @@ import org.openzen.zenscript.codemodel.definition.*;
7 7
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
8 8
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
9 9
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
-import org.openzen.zenscript.javabytecode.JavaClassInfo;
11 10
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
12 11
 import org.openzen.zenscript.javabytecode.JavaModule;
13 12
 import org.openzen.zenscript.javabytecode.compiler.*;
13
+import org.openzen.zenscript.javashared.JavaClass;
14 14
 
15 15
 
16 16
 public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
17
-	private static final JavaClassInfo T_CLASS = new JavaClassInfo("java/lang/Class");
18 17
 	private static final JavaMethodInfo CLASS_FORNAME = new JavaMethodInfo(
19
-			T_CLASS,
18
+			JavaClass.CLASS,
20 19
 			"forName",
21 20
 			"(Ljava/lang/String;)Ljava/lang/Class;",
22 21
 			Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC);
23 22
 	
24
-	private static final JavaClassInfo T_ENUM = new JavaClassInfo("java/lang/Enum");
25 23
 	private static final JavaMethodInfo ENUM_VALUEOF = new JavaMethodInfo(
26
-			T_ENUM,
24
+			JavaClass.ENUM,
27 25
 			"valueOf",
28 26
 			"(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;",
29 27
 			Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC);
@@ -45,14 +43,13 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
45 43
         else
46 44
             superType = Type.getType(definition.getSuperType().accept(JavaTypeClassVisitor.INSTANCE));
47 45
 
48
-		JavaClassInfo toClass = new JavaClassInfo(definition.name);
46
+		JavaClass toClass = new JavaClass(definition.pkg.fullName, definition.name, JavaClass.Kind.CLASS);
49 47
         JavaClassWriter writer = new JavaClassWriter(ClassWriter.COMPUTE_FRAMES);
50 48
 
51 49
         //TODO: Calculate signature from generic parameters
52 50
         //TODO: Interfaces?
53 51
         String signature = null;
54
-
55
-
52
+		
56 53
         writer.visit(Opcodes.V1_8, definition.modifiers, definition.name, signature, superType.getInternalName(), null);
57 54
 		JavaMemberVisitor memberVisitor = new JavaMemberVisitor(writer, toClass, definition); 
58 55
         for (IDefinitionMember member : definition.members) {
@@ -65,7 +62,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
65 62
 
66 63
     @Override
67 64
     public byte[] visitInterface(InterfaceDefinition definition) {
68
-		JavaClassInfo toClass = new JavaClassInfo(definition.name);
65
+		JavaClass toClass = new JavaClass(definition.pkg.fullName, definition.name, JavaClass.Kind.INTERFACE);
69 66
         ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
70 67
 
71 68
         //TODO: Calculate signature from generic parameters
@@ -95,7 +92,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
95 92
 
96 93
         writer.visit(Opcodes.V1_8, Opcodes.ACC_ENUM | Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER | Opcodes.ACC_FINAL, definition.name, "Ljava/lang/Enum<L" + definition.name + ";>;", superType.getInternalName(), null);
97 94
 
98
-		JavaClassInfo toClass = new JavaClassInfo(definition.name, true);
95
+		JavaClass toClass = new JavaClass(definition.pkg.fullName, definition.name, JavaClass.Kind.ENUM);
99 96
 
100 97
         //Enum Stuff(required!)
101 98
         writer.visitField(Opcodes.ACC_STATIC | Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC, "$VALUES", "[L" + definition.name + ";", null, null).visitEnd();
@@ -105,7 +102,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
105 102
             member.accept(visitor);
106 103
         }
107 104
 		
108
-		JavaClassInfo arrayClass = new JavaClassInfo("[L" + definition.name + ";");
105
+		JavaClass arrayClass = JavaClass.fromInternalName("[L" + definition.name + ";", JavaClass.Kind.ARRAY);
109 106
 		JavaMethodInfo arrayClone = new JavaMethodInfo(arrayClass, "clone", "()Ljava/lang/Object;", Opcodes.ACC_PUBLIC);
110 107
 
111 108
 		JavaMethodInfo valuesMethodInfo = new JavaMethodInfo(toClass, "values", "()[L" + definition.name + ";", Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC);
@@ -143,7 +140,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
143 140
 		
144 141
         final String signature = CompilerUtils.calcSign(definition.header, false);
145 142
 		
146
-		final JavaClassInfo toClass = new JavaClassInfo(CompilerUtils.calcClasName(definition.position));
143
+		final JavaClass toClass = new JavaClass(definition.pkg.fullName, CompilerUtils.calcClasName(definition.position), JavaClass.Kind.CLASS);
147 144
 		final JavaMethodInfo methodInfo = new JavaMethodInfo(toClass, definition.name, CompilerUtils.calcDesc(definition.header, false), CompilerUtils.calcAccess(definition.modifiers) | Opcodes.ACC_STATIC);
148 145
 
149 146
 		final JavaWriter writer = new JavaWriter(outerWriter, true, methodInfo, definition, signature, null);

+ 3
- 3
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaMemberVisitor.java View File

@@ -10,22 +10,22 @@ import org.openzen.zenscript.codemodel.Modifiers;
10 10
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12 12
 import org.openzen.zenscript.codemodel.member.*;
13
-import org.openzen.zenscript.javabytecode.JavaClassInfo;
14 13
 import org.openzen.zenscript.javabytecode.JavaFieldInfo;
15 14
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
16 15
 import org.openzen.zenscript.javabytecode.JavaParameterInfo;
17 16
 import org.openzen.zenscript.javabytecode.compiler.*;
18 17
 
19 18
 import java.util.List;
19
+import org.openzen.zenscript.javashared.JavaClass;
20 20
 
21 21
 public class JavaMemberVisitor implements MemberVisitor<Void> {
22 22
     private final ClassWriter writer;
23
-    private final JavaClassInfo toClass;
23
+    private final JavaClass toClass;
24 24
     private final HighLevelDefinition definition;
25 25
     private final JavaStatementVisitor clinitStatementVisitor;
26 26
     private EnumDefinition enumDefinition = null;
27 27
 
28
-    public JavaMemberVisitor(ClassWriter writer, JavaClassInfo toClass, HighLevelDefinition definition) {
28
+    public JavaMemberVisitor(ClassWriter writer, JavaClass toClass, HighLevelDefinition definition) {
29 29
         this.writer = writer;
30 30
         this.toClass = toClass;
31 31
         this.definition = definition;

+ 18
- 0
JavaShared/build.gradle View File

@@ -0,0 +1,18 @@
1
+// Note: "common.gradle" in the root project contains additional initialization
2
+//   for this project. This initialization is applied in the "build.gradle"
3
+//   of the root project.
4
+
5
+// NetBeans will automatically add "run" and "debug" tasks relying on the
6
+// "mainClass" property. You may however define the property prior executing
7
+// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
8
+//
9
+// Note however, that you may define your own "run" and "debug" task if you
10
+// prefer. In this case NetBeans will not add these tasks but you may rely on
11
+// your own implementation.
12
+if (!hasProperty('mainClass')) {
13
+    ext.mainClass = ''
14
+}
15
+
16
+dependencies {
17
+	compile project(':CodeModel')
18
+}

+ 122
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaClass.java View File

@@ -0,0 +1,122 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.javashared;
7
+
8
+import java.util.Arrays;
9
+import stdlib.Strings;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class JavaClass implements Comparable<JavaClass> {
16
+	public static final JavaClass CLASS = new JavaClass("java.lang", "Class", Kind.CLASS);
17
+	public static final JavaClass ENUM = new JavaClass("java.lang", "Enum", Kind.CLASS);
18
+	public static final JavaClass OBJECT = new JavaClass("java.lang", "Object", Kind.CLASS);
19
+	public static final JavaClass STRING = new JavaClass("java.lang", "String", Kind.CLASS);
20
+	public static final JavaClass CLOSEABLE = new JavaClass("java.lang", "AutoCloseable", Kind.INTERFACE);
21
+	public static final JavaClass MAP = new JavaClass("java.util", "Map", JavaClass.Kind.INTERFACE);
22
+	public static final JavaClass HASHMAP = new JavaClass("java.util", "HashMap", JavaClass.Kind.CLASS);
23
+	public static final JavaClass ITERATOR = new JavaClass("java.util", "Iterator", JavaClass.Kind.INTERFACE);
24
+	
25
+	public static JavaClass fromInternalName(String internalName, Kind kind) {
26
+		if (kind == Kind.ARRAY)
27
+			return new JavaClass("", internalName, kind, new String[0]);
28
+		
29
+		int lastSlash = internalName.lastIndexOf('/');
30
+		if (lastSlash < 0)
31
+			System.out.println(internalName);
32
+		
33
+		String pkg = lastSlash < 0 ? "" : internalName.substring(0, lastSlash);
34
+		String className = lastSlash < 0 ? internalName : internalName.substring(lastSlash + 1);
35
+		String[] nameParts = Strings.split(className, '$');
36
+		return new JavaClass(pkg, internalName, kind, nameParts);
37
+	}
38
+	
39
+	public final JavaClass outer;
40
+	
41
+	public final String pkg;
42
+	public final String fullName;
43
+	public final String internalName;
44
+	public final Kind kind;
45
+	
46
+	public boolean empty = false;
47
+	public boolean destructible = false;
48
+	
49
+	private final String[] classNameParts;
50
+	
51
+	private JavaClass(String pkg, String internalName, Kind kind, String[] classNameParts) {
52
+		if (classNameParts.length > 1) {
53
+			String[] outerParts = Arrays.copyOf(classNameParts, classNameParts.length - 1);
54
+			outer = new JavaClass(pkg, internalName.substring(0, internalName.lastIndexOf('$')), kind, outerParts);
55
+		} else {
56
+			outer = null;
57
+		}
58
+		
59
+		this.pkg = pkg;
60
+		this.fullName = String.join(".", classNameParts);
61
+		this.internalName = internalName;
62
+		this.kind = kind;
63
+		this.classNameParts = classNameParts;
64
+	}
65
+	
66
+	public JavaClass(String pkg, String name, Kind kind) {
67
+		this.pkg = pkg;
68
+		this.classNameParts = new String[] { name };
69
+		this.fullName = pkg + '.' + name;
70
+		this.internalName = pkg.isEmpty() ? name : pkg.replace('.', '/') + '/' + name;
71
+		this.kind = kind;
72
+		
73
+		outer = this;
74
+	}
75
+	
76
+	public JavaClass(JavaClass outer, String name, Kind kind) {
77
+		this.pkg = outer.pkg;
78
+		this.classNameParts = Arrays.copyOf(outer.classNameParts, outer.classNameParts.length + 1);
79
+		this.classNameParts[outer.classNameParts.length] = name;
80
+		this.fullName = outer.fullName + '.' + name;
81
+		this.internalName = outer.internalName + '$' + name;
82
+		this.kind = kind;
83
+		
84
+		this.outer = outer.outer;
85
+	}
86
+	
87
+	/**
88
+	 * Retrieves the name of the class itself, excluding outer class or package
89
+	 * name.
90
+	 * 
91
+	 * @return 
92
+	 */
93
+	public String getName() {
94
+		return classNameParts[classNameParts.length - 1];
95
+	}
96
+	
97
+	/**
98
+	 * Retrieves the full name of the class, including outer class but excluding 
99
+	 * package name.
100
+	 * 
101
+	 * @return 
102
+	 */
103
+	public String getClassName() {
104
+		return fullName.substring(pkg.length() + 1);
105
+	}
106
+	
107
+	@Override
108
+	public int compareTo(JavaClass o) {
109
+		return fullName.compareTo(o.fullName);
110
+	}
111
+
112
+	public boolean isEnum() {
113
+		return kind == Kind.ENUM;
114
+	}
115
+	
116
+	public enum Kind {
117
+		CLASS,
118
+		INTERFACE,
119
+		ENUM,
120
+		ARRAY
121
+	}
122
+}

+ 1
- 0
JavaSourceCompiler/build.gradle View File

@@ -17,4 +17,5 @@ dependencies {
17 17
     compile project(':CodeModel')
18 18
 	compile project(':CompilerShared')
19 19
 	compile project(':CodeFormatterShared')
20
+	compile project(':JavaShared')
20 21
 }

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

@@ -35,7 +35,7 @@ import org.openzen.zenscript.compiler.SemanticModule;
35 35
 import org.openzen.zenscript.javasource.prepare.JavaNativeClass;
36 36
 import org.openzen.zenscript.javasource.scope.JavaSourceFileScope;
37 37
 import org.openzen.zenscript.javasource.scope.JavaSourceStatementScope;
38
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
38
+import org.openzen.zenscript.javashared.JavaClass;
39 39
 
40 40
 /**
41 41
  *
@@ -44,7 +44,7 @@ import org.openzen.zenscript.javasource.tags.JavaSourceClass;
44 44
 public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
45 45
 	private final String indent;
46 46
 	private final JavaSourceCompiler compiler;
47
-	private final JavaSourceClass cls;
47
+	private final JavaClass cls;
48 48
 	private final JavaSourceFile file;
49 49
 	private final JavaSourceFormattingSettings settings;
50 50
 	private final List<ExpansionDefinition> expansions;
@@ -54,7 +54,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
54 54
 	public JavaDefinitionVisitor(
55 55
 			String indent,
56 56
 			JavaSourceCompiler compiler,
57
-			JavaSourceClass cls,
57
+			JavaClass cls,
58 58
 			JavaSourceFile file,
59 59
 			StringBuilder output,
60 60
 			List<ExpansionDefinition> expansions,
@@ -82,7 +82,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
82 82
 	@Override
83 83
 	public Void visitClass(ClassDefinition definition) {
84 84
 		JavaSourceFileScope scope = createScope(definition);
85
-		JavaSourceClass cls = definition.getTag(JavaSourceClass.class);
85
+		JavaClass cls = definition.getTag(JavaClass.class);
86 86
 		
87 87
 		output.append(indent);
88 88
 		convertModifiers(definition.modifiers);
@@ -119,7 +119,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
119 119
 				else
120 120
 					output.append(", ");
121 121
 				
122
-				output.append(scope.importer.importType(new JavaSourceClass("java.lang", "AutoCloseable")));
122
+				output.append(scope.importer.importType(JavaClass.CLOSEABLE));
123 123
 			}
124 124
 		}
125 125
 		
@@ -133,7 +133,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
133 133
 	@Override
134 134
 	public Void visitInterface(InterfaceDefinition definition) {
135 135
 		JavaSourceFileScope scope = createScope(definition);
136
-		JavaSourceClass cls = definition.getTag(JavaSourceClass.class);
136
+		JavaClass cls = definition.getTag(JavaClass.class);
137 137
 		
138 138
 		output.append(indent);
139 139
 		convertModifiers(definition.modifiers | Modifiers.VIRTUAL); // to prevent 'final'
@@ -143,7 +143,7 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<Void> {
143 143
 		boolean firstExtends = true;
144 144
 		if (definition.isDestructible()) {
145 145
 			output.append(" extends ");
146
-			output.append(scope.importer.importType(new JavaSourceClass("java.lang", "AutoCloseable")));
146
+			output.append(scope.importer.importType(JavaClass.CLOSEABLE));
147 147
 			firstExtends = false;
148 148
 		}
149 149
 		

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

@@ -36,7 +36,7 @@ import org.openzen.zenscript.codemodel.statement.Statement;
36 36
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
37 37
 import org.openzen.zenscript.compiler.SemanticModule;
38 38
 import org.openzen.zenscript.javasource.scope.JavaSourceFileScope;
39
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
39
+import org.openzen.zenscript.javashared.JavaClass;
40 40
 import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
41 41
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
42 42
 
@@ -248,7 +248,7 @@ public class JavaMemberCompiler extends BaseMemberCompiler {
248 248
 
249 249
 	@Override
250 250
 	public Void visitInnerDefinition(InnerDefinitionMember member) {
251
-		JavaSourceClass cls = member.innerDefinition.getTag(JavaSourceClass.class);
251
+		JavaClass cls = member.innerDefinition.getTag(JavaClass.class);
252 252
 		JavaDefinitionVisitor visitor = new JavaDefinitionVisitor(
253 253
 				indent,
254 254
 				compiler,

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

@@ -16,7 +16,7 @@ import org.openzen.zenscript.compiler.CompilationUnit;
16 16
 import org.openzen.zenscript.compiler.SemanticModule;
17 17
 import org.openzen.zenscript.compiler.ZenCodeCompiler;
18 18
 import org.openzen.zenscript.javasource.prepare.JavaSourcePrepareDefinitionVisitor;
19
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
19
+import org.openzen.zenscript.javashared.JavaClass;
20 20
 
21 21
 /**
22 22
  *
@@ -47,7 +47,7 @@ public class JavaSourceCompiler implements ZenCodeCompiler {
47 47
 	public void addDefinition(HighLevelDefinition definition, SemanticModule module) {
48 48
 		String filename = getFilename(definition);
49 49
 		JavaSourcePrepareDefinitionVisitor prepare = new JavaSourcePrepareDefinitionVisitor(filename, null);
50
-		JavaSourceClass cls = definition.accept(prepare);
50
+		JavaClass cls = definition.accept(prepare);
51 51
 		if (cls.empty)
52 52
 			return;
53 53
 		

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

@@ -93,7 +93,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMembers;
93 93
 import org.openzen.zenscript.formattershared.ExpressionString;
94 94
 import org.openzen.zenscript.formattershared.StatementFormattingTarget;
95 95
 import org.openzen.zenscript.javasource.scope.JavaSourceStatementScope;
96
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
96
+import org.openzen.zenscript.javashared.JavaClass;
97 97
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
98 98
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
99 99
 import org.openzen.zenscript.javasource.tags.JavaSourceVariantOption;
@@ -103,9 +103,9 @@ import org.openzen.zenscript.javasource.tags.JavaSourceVariantOption;
103 103
  * @author Hoofdgebruiker
104 104
  */
105 105
 public class JavaSourceExpressionFormatter implements ExpressionVisitor<ExpressionString> {
106
-	private static final JavaSourceClass RESULT = new JavaSourceClass("stdlib", "Result");
107
-	private static final JavaSourceClass RESULT_OK = new JavaSourceClass("stdlib", "Result.Ok");
108
-	private static final JavaSourceClass RESULT_ERROR = new JavaSourceClass("stdlib", "Result.Error");
106
+	private static final JavaClass RESULT = new JavaClass("stdlib", "Result", JavaClass.Kind.CLASS);
107
+	private static final JavaClass RESULT_OK = new JavaClass("stdlib", "Result.Ok", JavaClass.Kind.CLASS);
108
+	private static final JavaClass RESULT_ERROR = new JavaClass("stdlib", "Result.Error", JavaClass.Kind.CLASS);
109 109
 	
110 110
 	public final JavaSourceStatementScope scope;
111 111
 	public final StatementFormattingTarget target;
@@ -287,7 +287,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
287 287
 			return visitBuiltinConstant(expression, expression.constant.member.builtin);
288 288
 		
289 289
 		return new ExpressionString(
290
-				scope.type(expression.constant.member.definition.getTag(JavaSourceClass.class)) + "." + expression.constant.member.name, 
290
+				scope.type(expression.constant.member.definition.getTag(JavaClass.class)) + "." + expression.constant.member.name, 
291 291
 				JavaOperator.MEMBER);
292 292
 	}
293 293
 
@@ -649,7 +649,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
649 649
 	}
650 650
 	
651 651
 	private String constructThisName(DefinitionTypeID type) {
652
-		JavaSourceClass cls = type.definition.getTag(JavaSourceClass.class);
652
+		JavaClass cls = type.definition.getTag(JavaClass.class);
653 653
 		return cls.getClassName();
654 654
 	}
655 655
 
@@ -733,7 +733,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
733 733
 		if (elementType instanceof GenericTypeID) {
734 734
 			// generic array creation
735 735
 			GenericTypeID generic = (GenericTypeID)elementType;
736
-			String array = scope.type(new JavaSourceClass("java.lang.reflect", "Array"));
736
+			String array = scope.type(new JavaClass("java.lang.reflect", "Array", JavaClass.Kind.CLASS));
737 737
 			return new ExpressionString("(" + generic.parameter.name + "[])(" + array + ".newInstance(typeOf" + generic.parameter.name + ", " + length.value + "))", JavaOperator.CAST);
738 738
 		} else {
739 739
 			return new ExpressionString("new " + scope.type(elementType) + "[" + length.value + "]", JavaOperator.NEW);
@@ -1472,7 +1472,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1472 1472
 			case STRING_CONSTRUCTOR_CHARACTERS:
1473 1473
 				return callStatic("new String", expression.arguments.arguments[0]);
1474 1474
 			case ASSOC_CONSTRUCTOR: {
1475
-				String typeName = scope.type(new JavaSourceClass("java.util", "HashMap"));
1475
+				String typeName = scope.type(new JavaClass("java.util", "HashMap", JavaClass.Kind.CLASS));
1476 1476
 				AssocTypeID type = (AssocTypeID) expression.type;
1477 1477
 				
1478 1478
 				StringBuilder result = new StringBuilder();
@@ -1484,7 +1484,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1484 1484
 				return new ExpressionString(result.toString(), JavaOperator.NEW);
1485 1485
 			}
1486 1486
 			case GENERICMAP_CONSTRUCTOR: {
1487
-				String typeName = scope.type(new JavaSourceClass("java.util", "HashMap"));
1487
+				String typeName = scope.type(new JavaClass("java.util", "HashMap", JavaClass.Kind.CLASS));
1488 1488
 				StringBuilder result = new StringBuilder();
1489 1489
 				result.append("new ").append(typeName).append("<Class<?>, Object>()");
1490 1490
 				return new ExpressionString(result.toString(), JavaOperator.NEW);

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

@@ -22,7 +22,7 @@ import org.openzen.zenscript.codemodel.HighLevelDefinition;
22 22
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
23 23
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
24 24
 import org.openzen.zenscript.compiler.SemanticModule;
25
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
25
+import org.openzen.zenscript.javashared.JavaClass;
26 26
 
27 27
 /**
28 28
  *
@@ -32,7 +32,7 @@ public class JavaSourceFile {
32 32
 	public final JavaSourceImporter importer;
33 33
 	private final JavaSourceCompiler compiler;
34 34
 	private final File file;
35
-	private final JavaSourceClass cls;
35
+	private final JavaClass cls;
36 36
 	private final StringBuilder contents = new StringBuilder();
37 37
 	private final ZSPackage pkg;
38 38
 	
@@ -42,7 +42,7 @@ public class JavaSourceFile {
42 42
 	private final Map<HighLevelDefinition, SemanticModule> modules = new HashMap<>();
43 43
 	private final Set<String> existing = new HashSet<>();
44 44
 	
45
-	public JavaSourceFile(JavaSourceCompiler compiler, File file, JavaSourceClass cls, ZSPackage pkg) {
45
+	public JavaSourceFile(JavaSourceCompiler compiler, File file, JavaClass cls, ZSPackage pkg) {
46 46
 		this.compiler = compiler;
47 47
 		this.pkg = pkg;
48 48
 		this.cls = cls;
@@ -92,9 +92,9 @@ public class JavaSourceFile {
92 92
 			writer.write(pkg.fullName);
93 93
 			writer.write(";\n\n");
94 94
 			
95
-			JavaSourceClass[] imports = importer.getUsedImports();
95
+			JavaClass[] imports = importer.getUsedImports();
96 96
 			if (imports.length > 0) {
97
-				for (JavaSourceClass import_ : imports) {
97
+				for (JavaClass import_ : imports) {
98 98
 					if (import_.pkg.equals("java.lang"))
99 99
 						continue;
100 100
 					

+ 10
- 10
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceImporter.java View File

@@ -11,23 +11,23 @@ import java.util.HashSet;
11 11
 import java.util.Map;
12 12
 import java.util.Set;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
14
+import org.openzen.zenscript.javashared.JavaClass;
15 15
 
16 16
 /**
17 17
  *
18 18
  * @author Hoofdgebruiker
19 19
  */
20 20
 public class JavaSourceImporter {
21
-	private final JavaSourceClass cls;
22
-	private final Map<String, JavaSourceClass> imports = new HashMap<>();
23
-	private final Set<JavaSourceClass> usedImports = new HashSet<>();
21
+	private final JavaClass cls;
22
+	private final Map<String, JavaClass> imports = new HashMap<>();
23
+	private final Set<JavaClass> usedImports = new HashSet<>();
24 24
 	
25
-	public JavaSourceImporter(JavaSourceClass cls) {
25
+	public JavaSourceImporter(JavaClass cls) {
26 26
 		this.cls = cls;
27 27
 	}
28 28
 	
29 29
 	public String importType(HighLevelDefinition definition) {
30
-		JavaSourceClass cls = definition.getTag(JavaSourceClass.class);
30
+		JavaClass cls = definition.getTag(JavaClass.class);
31 31
 		if (cls == null)
32 32
 			throw new IllegalStateException("Missing source class tag on " + definition.name);
33 33
 		if (cls.pkg.equals(this.cls.pkg))
@@ -36,9 +36,9 @@ public class JavaSourceImporter {
36 36
 		return importType(cls);
37 37
 	}
38 38
 	
39
-	public String importType(JavaSourceClass cls) {
39
+	public String importType(JavaClass cls) {
40 40
 		if (imports.containsKey(cls.outer.getName())) {
41
-			JavaSourceClass imported = imports.get(cls.outer.getName());
41
+			JavaClass imported = imports.get(cls.outer.getName());
42 42
 			usedImports.add(imported);
43 43
 			return imported.fullName.equals(cls.outer.fullName) ? cls.getName() : cls.fullName;
44 44
 		}
@@ -48,8 +48,8 @@ public class JavaSourceImporter {
48 48
 		return cls.getClassName();
49 49
 	}
50 50
 	
51
-	public JavaSourceClass[] getUsedImports() {
52
-		JavaSourceClass[] imports = usedImports.toArray(new JavaSourceClass[usedImports.size()]);
51
+	public JavaClass[] getUsedImports() {
52
+		JavaClass[] imports = usedImports.toArray(new JavaClass[usedImports.size()]);
53 53
 		Arrays.sort(imports);
54 54
 		return imports;
55 55
 	}

+ 2
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceStatementFormatter.java View File

@@ -43,7 +43,7 @@ import org.openzen.zenscript.formattershared.StatementFormatter;
43 43
 import org.openzen.zenscript.formattershared.StatementFormattingSubBlock;
44 44
 import org.openzen.zenscript.formattershared.StatementFormattingTarget;
45 45
 import org.openzen.zenscript.javasource.scope.JavaSourceStatementScope;
46
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
46
+import org.openzen.zenscript.javashared.JavaClass;
47 47
 
48 48
 /**
49 49
  *
@@ -134,7 +134,7 @@ public class JavaSourceStatementFormatter implements StatementFormatter.Formatte
134 134
 			
135 135
 			DefinitionTypeID variantType = (DefinitionTypeID)statement.value.type;
136 136
 			HighLevelDefinition variant = variantType.definition;
137
-			String variantTypeName = scope.type(variant.getTag(JavaSourceClass.class));
137
+			String variantTypeName = scope.type(variant.getTag(JavaClass.class));
138 138
 			for (SwitchCase switchCase : statement.cases) {
139 139
 				VariantOptionSwitchValue switchValue = (VariantOptionSwitchValue)switchCase.value;
140 140
 				String header = switchValue == null ? "default:" : "case " + switchValue.option.getName() + ":";

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticHelperGenerator.java View File

@@ -27,7 +27,7 @@ import org.openzen.zenscript.codemodel.type.GenericTypeID;
27 27
 import org.openzen.zenscript.codemodel.type.ITypeVisitor;
28 28
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
29 29
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
30
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
30
+import org.openzen.zenscript.javashared.JavaClass;
31 31
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
32 32
 
33 33
 /**
@@ -38,7 +38,7 @@ public class JavaSourceSyntheticHelperGenerator {
38 38
 	private final File directory;
39 39
 	private final JavaSourceFormattingSettings settings;
40 40
 	private final Map<String, List<String>> members = new HashMap<>();
41
-	private final JavaSourceClass arrayHelpers = new JavaSourceClass("zsynthetic", "ArrayHelpers");
41
+	private final JavaClass arrayHelpers = new JavaClass("zsynthetic", "ArrayHelpers", JavaClass.Kind.CLASS);
42 42
 	private final Map<ArrayKind, JavaSourceMethod> existingContains = new HashMap<>();
43 43
 	private final Map<ArrayKind, JavaSourceMethod> existingIndexOf = new HashMap<>();
44 44
 	
@@ -115,7 +115,7 @@ public class JavaSourceSyntheticHelperGenerator {
115 115
 		}
116 116
 	}
117 117
 	
118
-	private void addMember(JavaSourceClass className, String content) {
118
+	private void addMember(JavaClass className, String content) {
119 119
 		if (!members.containsKey(className.getName()))
120 120
 			members.put(className.getName(), new ArrayList<>());
121 121
 		

+ 4
- 14
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceSyntheticTypeGenerator.java View File

@@ -16,12 +16,11 @@ import java.util.ArrayList;
16 16
 import java.util.HashMap;
17 17
 import java.util.List;
18 18
 import java.util.Map;
19
-import org.openzen.zenscript.codemodel.FunctionHeader;
20 19
 import org.openzen.zenscript.codemodel.FunctionParameter;
21 20
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
22 21
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
23 22
 import org.openzen.zenscript.codemodel.type.ITypeID;
24
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
23
+import org.openzen.zenscript.javashared.JavaClass;
25 24
 
26 25
 /**
27 26
  *
@@ -35,8 +34,6 @@ public class JavaSourceSyntheticTypeGenerator {
35 34
 	public JavaSourceSyntheticTypeGenerator(File directory, JavaSourceFormattingSettings settings) {
36 35
 		this.directory = new File(directory, "zsynthetic");
37 36
 		this.settings = settings;
38
-		
39
-		
40 37
 	}
41 38
 	
42 39
 	public JavaSynthesizedClass createFunction(JavaSourceTypeVisitor typeFormatter, FunctionTypeID function) {
@@ -45,7 +42,7 @@ public class JavaSourceSyntheticTypeGenerator {
45 42
 			return functions.get(signature).withTypeParameters(extractTypeParameters(function));
46 43
 		
47 44
 		String className = "Function" + signature;
48
-		JavaSourceClass cls = new JavaSourceClass("zsynthetic", className);
45
+		JavaClass cls = new JavaClass("zsynthetic", className, JavaClass.Kind.INTERFACE);
49 46
 		JavaSynthesizedClass result = new JavaSynthesizedClass(cls, extractTypeParameters(function));
50 47
 		functions.put(signature, result);
51 48
 		
@@ -92,9 +89,9 @@ public class JavaSourceSyntheticTypeGenerator {
92 89
 		try (Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file)), StandardCharsets.UTF_8)) {
93 90
 			writer.write("package zsynthetic;\n");
94 91
 			
95
-			JavaSourceClass[] imports = importer.getUsedImports();
92
+			JavaClass[] imports = importer.getUsedImports();
96 93
 			if (imports.length > 0) {
97
-				for (JavaSourceClass import_ : imports) {
94
+				for (JavaClass import_ : imports) {
98 95
 					if (import_.pkg.equals("java.lang"))
99 96
 						continue;
100 97
 					
@@ -114,13 +111,6 @@ public class JavaSourceSyntheticTypeGenerator {
114 111
 		return result;
115 112
 	}
116 113
 	
117
-	private String createFunctionClassName(FunctionTypeID function) {
118
-		StringBuilder className = new StringBuilder();
119
-		className.append("Function");
120
-		className.append(functions.size() + 1); // TODO: create more meaningful names
121
-		return className.toString();
122
-	}
123
-	
124 114
 	private TypeParameter[] extractTypeParameters(ITypeID type) {
125 115
 		List<TypeParameter> result = new ArrayList<>();
126 116
 		type.extractTypeParameters(result);

+ 7
- 14
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceTypeVisitor.java View File

@@ -5,11 +5,9 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource;
7 7
 
8
-import org.openzen.zenscript.codemodel.HighLevelDefinition;
9 8
 import org.openzen.zenscript.codemodel.generic.GenericParameterBoundVisitor;
10 9
 import org.openzen.zenscript.codemodel.generic.ParameterSuperBound;
11 10
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
12
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 11
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
14 12
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
15 13
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
@@ -18,31 +16,26 @@ import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
18 16
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
19 17
 import org.openzen.zenscript.codemodel.type.GenericMapTypeID;
20 18
 import org.openzen.zenscript.codemodel.type.GenericTypeID;
21
-import org.openzen.zenscript.codemodel.type.ITypeID;
22 19
 import org.openzen.zenscript.codemodel.type.ITypeVisitor;
23 20
 import org.openzen.zenscript.codemodel.type.IteratorTypeID;
24 21
 import org.openzen.zenscript.codemodel.type.RangeTypeID;
25
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
22
+import org.openzen.zenscript.javashared.JavaClass;
26 23
 
27 24
 /**
28 25
  *
29 26
  * @author Hoofdgebruiker
30 27
  */
31 28
 public class JavaSourceTypeVisitor implements ITypeVisitor<String>, GenericParameterBoundVisitor<String> {
32
-	private static final JavaSourceClass MAP = new JavaSourceClass("java.util", "Map");
33
-	private static final JavaSourceClass HASHMAP = new JavaSourceClass("java.util", "HashMap");
34
-	private static final JavaSourceClass ITERATOR = new JavaSourceClass("java.util", "Iterator");
35
-	
36 29
 	public final JavaSourceImporter importer;
37 30
 	public final JavaSourceSyntheticTypeGenerator typeGenerator;
38 31
 	public final JavaSourceObjectTypeVisitor objectTypeVisitor;
39
-	public final JavaSourceClass cls;
32
+	public final JavaClass cls;
40 33
 	
41 34
 	public JavaSourceTypeVisitor(JavaSourceImporter importer, JavaSourceSyntheticTypeGenerator typeGenerator) {
42 35
 		this(importer, typeGenerator, null);
43 36
 	}
44 37
 	
45
-	public JavaSourceTypeVisitor(JavaSourceImporter importer, JavaSourceSyntheticTypeGenerator typeGenerator, JavaSourceClass cls) {
38
+	public JavaSourceTypeVisitor(JavaSourceImporter importer, JavaSourceSyntheticTypeGenerator typeGenerator, JavaClass cls) {
46 39
 		this.importer = importer;
47 40
 		this.typeGenerator = typeGenerator;
48 41
 		this.cls = cls;
@@ -88,19 +81,19 @@ public class JavaSourceTypeVisitor implements ITypeVisitor<String>, GenericParam
88 81
 
89 82
 	@Override
90 83
 	public String visitAssoc(AssocTypeID assoc) {
91
-		String map = importer.importType(MAP);
84
+		String map = importer.importType(JavaClass.MAP);
92 85
 		return map + "<" + assoc.keyType.accept(new JavaSourceObjectTypeVisitor(importer, typeGenerator)) + ", " + assoc.valueType.accept(new JavaSourceObjectTypeVisitor(importer, typeGenerator)) + ">";
93 86
 	}
94 87
 
95 88
 	@Override
96 89
 	public String visitGenericMap(GenericMapTypeID map) {
97
-		return importer.importType(MAP) + "<Class<?>, Object>";
90
+		return importer.importType(JavaClass.MAP) + "<Class<?>, Object>";
98 91
 	}
99 92
 
100 93
 	@Override
101 94
 	public String visitIterator(IteratorTypeID iterator) {
102 95
 		if (iterator.iteratorTypes.length == 1) {
103
-			return importer.importType(ITERATOR) + "<" + iterator.iteratorTypes[0].accept(objectTypeVisitor) + '>';
96
+			return importer.importType(JavaClass.ITERATOR) + "<" + iterator.iteratorTypes[0].accept(objectTypeVisitor) + '>';
104 97
 		} else {
105 98
 			throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
106 99
 		}
@@ -131,7 +124,7 @@ public class JavaSourceTypeVisitor implements ITypeVisitor<String>, GenericParam
131 124
 		return result.toString();
132 125
 	}
133 126
 	
134
-	private void format(StringBuilder output, DefinitionTypeID type, JavaSourceClass cls, boolean isStatic) {
127
+	private void format(StringBuilder output, DefinitionTypeID type, JavaClass cls, boolean isStatic) {
135 128
 		if (type.outer != null) {
136 129
 			format(output, type.outer, null, type.definition.isStatic() || type.definition.isInterface());
137 130
 			output.append(".");

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSynthesizedClass.java View File

@@ -6,17 +6,17 @@
6 6
 package org.openzen.zenscript.javasource;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
9
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
9
+import org.openzen.zenscript.javashared.JavaClass;
10 10
 
11 11
 /**
12 12
  *
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class JavaSynthesizedClass {
16
-	public final JavaSourceClass cls;
16
+	public final JavaClass cls;
17 17
 	public final TypeParameter[] typeParameters;
18 18
 	
19
-	public JavaSynthesizedClass(JavaSourceClass cls, TypeParameter[] typeParameters) {
19
+	public JavaSynthesizedClass(JavaClass cls, TypeParameter[] typeParameters) {
20 20
 		this.cls = cls;
21 21
 		this.typeParameters = typeParameters;
22 22
 	}

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

@@ -7,7 +7,7 @@ package org.openzen.zenscript.javasource.prepare;
7 7
 
8 8
 import java.util.HashMap;
9 9
 import java.util.Map;
10
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
10
+import org.openzen.zenscript.javashared.JavaClass;
11 11
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
12 12
 
13 13
 /**
@@ -15,15 +15,15 @@ import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
15 15
  * @author Hoofdgebruiker
16 16
  */
17 17
 public class JavaNativeClass {
18
-	public final JavaSourceClass cls;
18
+	public final JavaClass cls;
19 19
 	private final Map<String, JavaSourceMethod> methods = new HashMap<>();
20 20
 	public final boolean nonDestructible;
21 21
 	
22
-	public JavaNativeClass(JavaSourceClass cls) {
22
+	public JavaNativeClass(JavaClass cls) {
23 23
 		this(cls, false);
24 24
 	}
25 25
 	
26
-	public JavaNativeClass(JavaSourceClass cls, boolean nonDestructible) {
26
+	public JavaNativeClass(JavaClass cls, boolean nonDestructible) {
27 27
 		this.cls = cls;
28 28
 		this.nonDestructible = nonDestructible;
29 29
 	}

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

@@ -27,7 +27,7 @@ import org.openzen.zenscript.codemodel.member.SetterMember;
27 27
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
28 28
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
29 29
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
30
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
30
+import org.openzen.zenscript.javashared.JavaClass;
31 31
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
32 32
 import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
33 33
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
@@ -41,13 +41,13 @@ public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void>
41 41
 	
42 42
 	private final JavaSourcePrepareDefinitionVisitor definitionPreparer;
43 43
 	private final String filename;
44
-	private final JavaSourceClass cls;
44
+	private final JavaClass cls;
45 45
 	private final JavaNativeClass nativeClass;
46 46
 	
47 47
 	public JavaSourcePrepareClassMethodVisitor(
48 48
 			JavaSourcePrepareDefinitionVisitor definitionPreparer,
49 49
 			String filename,
50
-			JavaSourceClass cls,
50
+			JavaClass cls,
51 51
 			JavaNativeClass nativeClass,
52 52
 			boolean startsEmpty) {
53 53
 		this.definitionPreparer = definitionPreparer;
@@ -150,7 +150,7 @@ public class JavaSourcePrepareClassMethodVisitor implements MemberVisitor<Void>
150 150
 			
151 151
 			cls.empty = false;
152 152
 			
153
-			JavaSourceClass implementationClass = new JavaSourceClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
153
+			JavaClass implementationClass = new JavaClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation", JavaClass.Kind.CLASS);
154 154
 			member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
155 155
 			
156 156
 			JavaSourcePrepareClassMethodVisitor visitor = new JavaSourcePrepareClassMethodVisitor(definitionPreparer, filename, implementationClass, null, true);

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

@@ -26,7 +26,7 @@ import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
26 26
 import org.openzen.zenscript.codemodel.type.ITypeID;
27 27
 import org.openzen.zenscript.formattershared.ExpressionString;
28 28
 import org.openzen.zenscript.javasource.JavaOperator;
29
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
29
+import org.openzen.zenscript.javashared.JavaClass;
30 30
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
31 31
 import org.openzen.zenscript.javasource.tags.JavaSourceVariantOption;
32 32
 
@@ -34,12 +34,12 @@ import org.openzen.zenscript.javasource.tags.JavaSourceVariantOption;
34 34
  *
35 35
  * @author Hoofdgebruiker
36 36
  */
37
-public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<JavaSourceClass> {
37
+public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<JavaClass> {
38 38
 	private static final Map<String, JavaNativeClass> nativeClasses = new HashMap<>();
39 39
 	
40 40
 	static {
41 41
 		{
42
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.lang", "StringBuilder"));
42
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.lang", "StringBuilder", JavaClass.Kind.CLASS));
43 43
 			cls.addConstructor("constructor", "");
44 44
 			cls.addConstructor("constructorWithCapacity", "");
45 45
 			cls.addConstructor("constructorWithValue", "");
@@ -63,8 +63,8 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
63 63
 		}
64 64
 		
65 65
 		{
66
-			JavaNativeClass list = new JavaNativeClass(new JavaSourceClass("java.util", "List"));
67
-			JavaSourceClass arrayList = new JavaSourceClass("java.util", "ArrayList");
66
+			JavaNativeClass list = new JavaNativeClass(new JavaClass("java.util", "List", JavaClass.Kind.INTERFACE));
67
+			JavaClass arrayList = new JavaClass("java.util", "ArrayList", JavaClass.Kind.CLASS);
68 68
 			list.addMethod("constructor", new JavaSourceMethod(arrayList, JavaSourceMethod.Kind.CONSTRUCTOR, "", false));
69 69
 			list.addInstanceMethod("add", "add");
70 70
 			list.addInstanceMethod("insert", "add");
@@ -82,27 +82,27 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
82 82
 		}
83 83
 		
84 84
 		{
85
-			JavaNativeClass iterable = new JavaNativeClass(new JavaSourceClass("java.lang", "Iterable"));
85
+			JavaNativeClass iterable = new JavaNativeClass(new JavaClass("java.lang", "Iterable", JavaClass.Kind.INTERFACE));
86 86
 			iterable.addInstanceMethod("iterate", "iterator");
87 87
 			nativeClasses.put("stdlib::Iterable", iterable);
88 88
 		}
89 89
 		
90 90
 		{
91
-			JavaNativeClass iterator = new JavaNativeClass(new JavaSourceClass("java.lang", "Iterator"));
91
+			JavaNativeClass iterator = new JavaNativeClass(JavaClass.ITERATOR);
92 92
 			iterator.addInstanceMethod("hasNext", "hasNext");
93 93
 			iterator.addInstanceMethod("next", "next");
94 94
 			nativeClasses.put("stdlib::Iterator", iterator);
95 95
 		}
96 96
 		
97 97
 		{
98
-			JavaNativeClass comparable = new JavaNativeClass(new JavaSourceClass("java.lang", "Comparable"));
98
+			JavaNativeClass comparable = new JavaNativeClass(new JavaClass("java.lang", "Comparable", JavaClass.Kind.INTERFACE));
99 99
 			comparable.addInstanceMethod("compareTo", "compareTo");
100 100
 			nativeClasses.put("stdlib::Comparable", comparable);
101 101
 		}
102 102
 		
103 103
 		{
104
-			JavaSourceClass integer = new JavaSourceClass("java.lang", "Integer");
105
-			JavaSourceClass math = new JavaSourceClass("java.lang", "Math");
104
+			JavaClass integer = new JavaClass("java.lang", "Integer", JavaClass.Kind.CLASS);
105
+			JavaClass math = new JavaClass("java.lang", "Math", JavaClass.Kind.CLASS);
106 106
 			
107 107
 			JavaNativeClass cls = new JavaNativeClass(integer);
108 108
 			cls.addMethod("min", new JavaSourceMethod(math, JavaSourceMethod.Kind.STATIC, "min", false));
@@ -112,7 +112,7 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
112 112
 		}
113 113
 		
114 114
 		{
115
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.lang", "String"));
115
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.lang", "String", JavaClass.Kind.CLASS));
116 116
 			cls.addMethod("contains", new JavaSourceMethod((formatter, calle) -> {
117 117
 				CallExpression call = (CallExpression)calle;
118 118
 				ExpressionString str = call.arguments.arguments[0].accept(formatter);
@@ -128,7 +128,7 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
128 128
 		}
129 129
 		
130 130
 		{
131
-			JavaSourceClass arrays = new JavaSourceClass("java.lang", "Arrays");
131
+			JavaClass arrays = new JavaClass("java.lang", "Arrays", JavaClass.Kind.CLASS);
132 132
 			JavaNativeClass cls = new JavaNativeClass(arrays);
133 133
 			cls.addMethod("sort", new JavaSourceMethod(arrays, JavaSourceMethod.Kind.EXPANSION, "sort", false));
134 134
 			cls.addMethod("sorted", new JavaSourceMethod((formatter, calle) -> {
@@ -173,26 +173,26 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
173 173
 		}
174 174
 		
175 175
 		{
176
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.lang", "IllegalArgumentException"));
176
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.lang", "IllegalArgumentException", JavaClass.Kind.CLASS));
177 177
 			cls.addConstructor("constructor", "");
178 178
 			nativeClasses.put("stdlib::IllegalArgumentException", cls);
179 179
 		}
180 180
 		
181 181
 		{
182
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.lang", "Exception"));
182
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.lang", "Exception", JavaClass.Kind.CLASS));
183 183
 			cls.addConstructor("constructor", "");
184 184
 			cls.addConstructor("constructorWithCause", "");
185 185
 			nativeClasses.put("stdlib::Exception", cls);
186 186
 		}
187 187
 		
188 188
 		{
189
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "IOException"));
189
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.io", "IOException", JavaClass.Kind.CLASS));
190 190
 			cls.addConstructor("constructor", "");
191 191
 			nativeClasses.put("io::IOException", cls);
192 192
 		}
193 193
 		
194 194
 		{
195
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "Reader"));
195
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.io", "Reader", JavaClass.Kind.INTERFACE));
196 196
 			cls.addInstanceMethod("destruct", "close");
197 197
 			cls.addInstanceMethod("readCharacter", "read");
198 198
 			cls.addInstanceMethod("readArray", "read");
@@ -201,7 +201,7 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
201 201
 		}
202 202
 		
203 203
 		{
204
-			JavaNativeClass cls = new JavaNativeClass(new JavaSourceClass("java.io", "StringReader"), true);
204
+			JavaNativeClass cls = new JavaNativeClass(new JavaClass("java.io", "StringReader", JavaClass.Kind.CLASS), true);
205 205
 			cls.addConstructor("constructor", "");
206 206
 			cls.addInstanceMethod("destructor", "close");
207 207
 			cls.addInstanceMethod("readCharacter", "read");
@@ -211,15 +211,15 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
211 211
 	}
212 212
 	
213 213
 	private final String filename;
214
-	private final JavaSourceClass outerClass;
214
+	private final JavaClass outerClass;
215 215
 	
216
-	public JavaSourcePrepareDefinitionVisitor(String filename, JavaSourceClass outerClass) {
216
+	public JavaSourcePrepareDefinitionVisitor(String filename, JavaClass outerClass) {
217 217
 		this.filename = filename;
218 218
 		this.outerClass = outerClass;
219 219
 	}
220 220
 	
221 221
 	private boolean isPrepared(HighLevelDefinition definition) {
222
-		return definition.hasTag(JavaSourceClass.class);
222
+		return definition.hasTag(JavaClass.class);
223 223
 	}
224 224
 	
225 225
 	public void prepare(ITypeID type) {
@@ -231,56 +231,56 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
231 231
 	}
232 232
 	
233 233
 	@Override
234
-	public JavaSourceClass visitClass(ClassDefinition definition) {
234
+	public JavaClass visitClass(ClassDefinition definition) {
235 235
 		if (isPrepared(definition))
236
-			return definition.getTag(JavaSourceClass.class);
236
+			return definition.getTag(JavaClass.class);
237 237
 		
238
-		return visitClassCompiled(definition, true);
238
+		return visitClassCompiled(definition, true, JavaClass.Kind.CLASS);
239 239
 	}
240 240
 
241 241
 	@Override
242
-	public JavaSourceClass visitInterface(InterfaceDefinition definition) {
242
+	public JavaClass visitInterface(InterfaceDefinition definition) {
243 243
 		if (isPrepared(definition))
244
-			return definition.getTag(JavaSourceClass.class);
244
+			return definition.getTag(JavaClass.class);
245 245
 		
246 246
 		for (ITypeID baseType : definition.baseInterfaces)
247 247
 			prepare(baseType);
248 248
 		
249
-		return visitClassCompiled(definition, true);
249
+		return visitClassCompiled(definition, true, JavaClass.Kind.INTERFACE);
250 250
 	}
251 251
 
252 252
 	@Override
253
-	public JavaSourceClass visitEnum(EnumDefinition definition) {
253
+	public JavaClass visitEnum(EnumDefinition definition) {
254 254
 		if (isPrepared(definition))
255
-			return definition.getTag(JavaSourceClass.class);
255
+			return definition.getTag(JavaClass.class);
256 256
 		
257
-		return visitClassCompiled(definition, false);
257
+		return visitClassCompiled(definition, false, JavaClass.Kind.ENUM);
258 258
 	}
259 259
 
260 260
 	@Override
261
-	public JavaSourceClass visitStruct(StructDefinition definition) {
261
+	public JavaClass visitStruct(StructDefinition definition) {
262 262
 		if (isPrepared(definition))
263
-			return definition.getTag(JavaSourceClass.class);
263
+			return definition.getTag(JavaClass.class);
264 264
 		
265
-		return visitClassCompiled(definition, true);
265
+		return visitClassCompiled(definition, true, JavaClass.Kind.CLASS);
266 266
 	}
267 267
 
268 268
 	@Override
269
-	public JavaSourceClass visitFunction(FunctionDefinition definition) {
269
+	public JavaClass visitFunction(FunctionDefinition definition) {
270 270
 		if (isPrepared(definition))
271
-			return definition.getTag(JavaSourceClass.class);
271
+			return definition.getTag(JavaClass.class);
272 272
 		
273
-		JavaSourceClass cls = new JavaSourceClass(definition.pkg.fullName, filename);
274
-		definition.setTag(JavaSourceClass.class, cls);
273
+		JavaClass cls = new JavaClass(definition.pkg.fullName, filename, JavaClass.Kind.CLASS);
274
+		definition.setTag(JavaClass.class, cls);
275 275
 		JavaSourceMethod method = new JavaSourceMethod(cls, JavaSourceMethod.Kind.STATIC, definition.name, true);
276 276
 		definition.caller.setTag(JavaSourceMethod.class, method);
277 277
 		return cls;
278 278
 	}
279 279
 
280 280
 	@Override
281
-	public JavaSourceClass visitExpansion(ExpansionDefinition definition) {
281
+	public JavaClass visitExpansion(ExpansionDefinition definition) {
282 282
 		if (isPrepared(definition))
283
-			return definition.getTag(JavaSourceClass.class);
283
+			return definition.getTag(JavaClass.class);
284 284
 		
285 285
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
286 286
 		JavaNativeClass nativeClass = null;
@@ -288,28 +288,28 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
288 288
 			nativeClass = nativeClasses.get(nativeTag.value);
289 289
 		}
290 290
 		
291
-		JavaSourceClass cls = new JavaSourceClass(definition.pkg.fullName, filename);
292
-		definition.setTag(JavaSourceClass.class, cls);
291
+		JavaClass cls = new JavaClass(definition.pkg.fullName, filename, JavaClass.Kind.CLASS);
292
+		definition.setTag(JavaClass.class, cls);
293 293
 		visitExpansionMembers(definition, cls, nativeClass);
294 294
 		return cls;
295 295
 	}
296 296
 
297 297
 	@Override
298
-	public JavaSourceClass visitAlias(AliasDefinition definition) {
298
+	public JavaClass visitAlias(AliasDefinition definition) {
299 299
 		// nothing to do
300 300
 		return null;
301 301
 	}
302 302
 
303 303
 	@Override
304
-	public JavaSourceClass visitVariant(VariantDefinition variant) {
304
+	public JavaClass visitVariant(VariantDefinition variant) {
305 305
 		if (isPrepared(variant))
306
-			return variant.getTag(JavaSourceClass.class);
306
+			return variant.getTag(JavaClass.class);
307 307
 		
308
-		JavaSourceClass cls = new JavaSourceClass(variant.pkg.fullName, variant.name);
309
-		variant.setTag(JavaSourceClass.class, cls);
308
+		JavaClass cls = new JavaClass(variant.pkg.fullName, variant.name, JavaClass.Kind.CLASS);
309
+		variant.setTag(JavaClass.class, cls);
310 310
 		
311 311
 		for (VariantDefinition.Option option : variant.options) {
312
-			JavaSourceClass variantCls = new JavaSourceClass(cls.fullName, option.name);
312
+			JavaClass variantCls = new JavaClass(cls.fullName, option.name, JavaClass.Kind.CLASS);
313 313
 			option.setTag(JavaSourceVariantOption.class, new JavaSourceVariantOption(cls, variantCls));
314 314
 		}
315 315
 		
@@ -317,21 +317,21 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
317 317
 		return cls;
318 318
 	}
319 319
 	
320
-	private JavaSourceClass visitClassCompiled(HighLevelDefinition definition, boolean startsEmpty) {
320
+	private JavaClass visitClassCompiled(HighLevelDefinition definition, boolean startsEmpty, JavaClass.Kind kind) {
321 321
 		if (definition.getSuperType() != null)
322 322
 			prepare(definition.getSuperType());
323 323
 		
324 324
 		NativeTag nativeTag = definition.getTag(NativeTag.class);
325 325
 		JavaNativeClass nativeClass = nativeTag == null ? null : nativeClasses.get(nativeTag.value);
326 326
 		if (nativeClass == null) {
327
-			JavaSourceClass cls = outerClass == null ? new JavaSourceClass(definition.pkg.fullName, definition.name) : new JavaSourceClass(outerClass, definition.name);
327
+			JavaClass cls = outerClass == null ? new JavaClass(definition.pkg.fullName, definition.name, kind) : new JavaClass(outerClass, definition.name, kind);
328 328
 			cls.destructible = definition.isDestructible();
329
-			definition.setTag(JavaSourceClass.class, cls);
329
+			definition.setTag(JavaClass.class, cls);
330 330
 			visitClassMembers(definition, cls, null, startsEmpty);
331 331
 			return cls;
332 332
 		} else {
333
-			JavaSourceClass cls = outerClass == null ? new JavaSourceClass(definition.pkg.fullName, filename) : new JavaSourceClass(outerClass, filename);
334
-			definition.setTag(JavaSourceClass.class, nativeClass.cls);
333
+			JavaClass cls = outerClass == null ? new JavaClass(definition.pkg.fullName, filename, kind) : new JavaClass(outerClass, filename, kind);
334
+			definition.setTag(JavaClass.class, nativeClass.cls);
335 335
 			definition.setTag(JavaNativeClass.class, nativeClass);
336 336
 			visitExpansionMembers(definition, cls, nativeClass);
337 337
 			
@@ -342,14 +342,14 @@ public class JavaSourcePrepareDefinitionVisitor implements DefinitionVisitor<Jav
342 342
 		}
343 343
 	}
344 344
 	
345
-	private void visitClassMembers(HighLevelDefinition definition, JavaSourceClass cls, JavaNativeClass nativeClass, boolean startsEmpty) {
345
+	private void visitClassMembers(HighLevelDefinition definition, JavaClass cls, JavaNativeClass nativeClass, boolean startsEmpty) {
346 346
 		JavaSourcePrepareClassMethodVisitor methodVisitor = new JavaSourcePrepareClassMethodVisitor(this, filename, cls, nativeClass, startsEmpty);
347 347
 		for (IDefinitionMember member : definition.members) {
348 348
 			member.accept(methodVisitor);
349 349
 		}
350 350
 	}
351 351
 	
352
-	private void visitExpansionMembers(HighLevelDefinition definition, JavaSourceClass cls, JavaNativeClass nativeClass) {
352
+	private void visitExpansionMembers(HighLevelDefinition definition, JavaClass cls, JavaNativeClass nativeClass) {
353 353
 		JavaSourcePrepareExpansionMethodVisitor methodVisitor = new JavaSourcePrepareExpansionMethodVisitor(cls, nativeClass);
354 354
 		for (IDefinitionMember member : definition.members) {
355 355
 			member.accept(methodVisitor);

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

@@ -26,7 +26,7 @@ import org.openzen.zenscript.codemodel.member.OperatorMember;
26 26
 import org.openzen.zenscript.codemodel.member.SetterMember;
27 27
 import org.openzen.zenscript.codemodel.member.StaticInitializerMember;
28 28
 import org.openzen.zenscript.javasource.JavaSourceTypeNameVisitor;
29
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
29
+import org.openzen.zenscript.javashared.JavaClass;
30 30
 import org.openzen.zenscript.javasource.tags.JavaSourceField;
31 31
 import org.openzen.zenscript.javasource.tags.JavaSourceImplementation;
32 32
 import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
@@ -38,10 +38,10 @@ import org.openzen.zenscript.javasource.tags.JavaSourceMethod;
38 38
 public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Void> {
39 39
 	private static final boolean DEBUG_EMPTY = true;
40 40
 	
41
-	private final JavaSourceClass cls;
41
+	private final JavaClass cls;
42 42
 	private final JavaNativeClass nativeClass;
43 43
 	
44
-	public JavaSourcePrepareExpansionMethodVisitor(JavaSourceClass cls, JavaNativeClass nativeClass) {
44
+	public JavaSourcePrepareExpansionMethodVisitor(JavaClass cls, JavaNativeClass nativeClass) {
45 45
 		this.cls = cls;
46 46
 		this.nativeClass = nativeClass;
47 47
 		cls.empty = true;
@@ -126,7 +126,7 @@ public class JavaSourcePrepareExpansionMethodVisitor implements MemberVisitor<Vo
126 126
 
127 127
 	@Override
128 128
 	public Void visitImplementation(ImplementationMember member) {
129
-		JavaSourceClass implementationClass = new JavaSourceClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation");
129
+		JavaClass implementationClass = new JavaClass(cls, member.type.accept(new JavaSourceTypeNameVisitor()) + "Implementation", JavaClass.Kind.CLASS);
130 130
 		member.setTag(JavaSourceImplementation.class, new JavaSourceImplementation(false, implementationClass));
131 131
 		for (IDefinitionMember implementedMember : member.members)
132 132
 			implementedMember.accept(this);

+ 4
- 4
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceFileScope.java View File

@@ -12,7 +12,7 @@ import org.openzen.zenscript.javasource.JavaSourceObjectTypeVisitor;
12 12
 import org.openzen.zenscript.javasource.JavaSourceSyntheticHelperGenerator;
13 13
 import org.openzen.zenscript.javasource.JavaSourceSyntheticTypeGenerator;
14 14
 import org.openzen.zenscript.javasource.JavaSourceTypeVisitor;
15
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
15
+import org.openzen.zenscript.javashared.JavaClass;
16 16
 
17 17
 /**
18 18
  *
@@ -22,7 +22,7 @@ public class JavaSourceFileScope {
22 22
 	public final JavaSourceImporter importer;
23 23
 	public final JavaSourceSyntheticTypeGenerator typeGenerator;
24 24
 	public final JavaSourceSyntheticHelperGenerator helperGenerator;
25
-	public final JavaSourceClass cls;
25
+	public final JavaClass cls;
26 26
 	public final JavaSourceTypeVisitor typeVisitor;
27 27
 	public final JavaSourceObjectTypeVisitor objectTypeVisitor;
28 28
 	public final TypeScope semanticScope;
@@ -33,7 +33,7 @@ public class JavaSourceFileScope {
33 33
 			JavaSourceImporter importer, 
34 34
 			JavaSourceSyntheticTypeGenerator typeGenerator,
35 35
 			JavaSourceSyntheticHelperGenerator helperGenerator,
36
-			JavaSourceClass cls,
36
+			JavaClass cls,
37 37
 			TypeScope semanticScope,
38 38
 			boolean isInterface,
39 39
 			ITypeID thisType)
@@ -54,7 +54,7 @@ public class JavaSourceFileScope {
54 54
 		return type.accept(typeVisitor);
55 55
 	}
56 56
 	
57
-	public String type(ITypeID type, JavaSourceClass rename) {
57
+	public String type(ITypeID type, JavaClass rename) {
58 58
 		return type.accept(new JavaSourceTypeVisitor(importer, typeGenerator, rename));
59 59
 	}
60 60
 }

+ 3
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/scope/JavaSourceStatementScope.java View File

@@ -20,7 +20,7 @@ import org.openzen.zenscript.javasource.ExpressionHoistingChecker;
20 20
 import org.openzen.zenscript.javasource.JavaSourceFormattingSettings;
21 21
 import org.openzen.zenscript.javasource.JavaSourceExpressionFormatter;
22 22
 import org.openzen.zenscript.javasource.JavaSourceStatementFormatter;
23
-import org.openzen.zenscript.javasource.tags.JavaSourceClass;
23
+import org.openzen.zenscript.javashared.JavaClass;
24 24
 
25 25
 /**
26 26
  *
@@ -76,11 +76,11 @@ public class JavaSourceStatementScope {
76 76
 		return fileScope.type(type);
77 77
 	}
78 78
 	
79
-	public String type(ITypeID type, JavaSourceClass renamed) {
79
+	public String type(ITypeID type, JavaClass renamed) {
80 80
 		return fileScope.type(type, renamed);
81 81
 	}
82 82
 	
83
-	public String type(JavaSourceClass cls) {
83
+	public String type(JavaClass cls) {
84 84
 		return fileScope.importer.importType(cls);
85 85
 	}
86 86
 	

+ 0
- 55
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceClass.java View File

@@ -1,55 +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.javasource.tags;
7
-
8
-import java.util.ArrayList;
9
-import java.util.Collections;
10
-import java.util.List;
11
-
12
-/**
13
- *
14
- * @author Hoofdgebruiker
15
- */
16
-public class JavaSourceClass implements Comparable<JavaSourceClass> {
17
-	public final JavaSourceClass outer;
18
-	
19
-	public final String pkg;
20
-	public final String fullName;
21
-	public final List<String> className;
22
-	public boolean empty = false;
23
-	public boolean destructible = false;
24
-	
25
-	public JavaSourceClass(String pkg, String name) {
26
-		this.pkg = pkg;
27
-		this.className = Collections.singletonList(name);
28
-		this.fullName = pkg + '.' + name;
29
-		
30
-		outer = this;
31
-	}
32
-	
33
-	public JavaSourceClass(JavaSourceClass outer, String name) {
34
-		this.pkg = outer.pkg;
35
-		this.className = new ArrayList<>();
36
-		this.className.addAll(outer.className);
37
-		this.className.add(name);
38
-		this.fullName = outer.fullName + '.' + name;
39
-		
40
-		this.outer = outer.outer;
41
-	}
42
-	
43
-	public String getName() {
44
-		return className.get(className.size() - 1);
45
-	}
46
-	
47
-	public String getClassName() {
48
-		return fullName.substring(pkg.length() + 1);
49
-	}
50
-
51
-	@Override
52
-	public int compareTo(JavaSourceClass o) {
53
-		return fullName.compareTo(o.fullName);
54
-	}
55
-}

+ 4
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceField.java View File

@@ -5,15 +5,17 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource.tags;
7 7
 
8
+import org.openzen.zenscript.javashared.JavaClass;
9
+
8 10
 /**
9 11
  *
10 12
  * @author Hoofdgebruiker
11 13
  */
12 14
 public class JavaSourceField {
13
-	public final JavaSourceClass cls;
15
+	public final JavaClass cls;
14 16
 	public final String name;
15 17
 	
16
-	public JavaSourceField(JavaSourceClass cls, String name) {
18
+	public JavaSourceField(JavaClass cls, String name) {
17 19
 		this.cls = cls;
18 20
 		this.name = name;
19 21
 	}

+ 4
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceImplementation.java View File

@@ -5,15 +5,17 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource.tags;
7 7
 
8
+import org.openzen.zenscript.javashared.JavaClass;
9
+
8 10
 /**
9 11
  *
10 12
  * @author Hoofdgebruiker
11 13
  */
12 14
 public class JavaSourceImplementation {
13 15
 	public final boolean inline;
14
-	public final JavaSourceClass implementationClass;
16
+	public final JavaClass implementationClass;
15 17
 	
16
-	public JavaSourceImplementation(boolean inline, JavaSourceClass implementationClass) {
18
+	public JavaSourceImplementation(boolean inline, JavaClass implementationClass) {
17 19
 		this.inline = inline;
18 20
 		this.implementationClass = implementationClass;
19 21
 	}

+ 3
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceMethod.java View File

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource.tags;
7 7
 
8
+import org.openzen.zenscript.javashared.JavaClass;
8 9
 import org.openzen.zenscript.javasource.JavaCallCompiler;
9 10
 
10 11
 /**
@@ -12,13 +13,13 @@ import org.openzen.zenscript.javasource.JavaCallCompiler;
12 13
  * @author Hoofdgebruiker
13 14
  */
14 15
 public class JavaSourceMethod {
15
-	public final JavaSourceClass cls;
16
+	public final JavaClass cls;
16 17
 	public final Kind kind;
17 18
 	public final String name;
18 19
 	public final boolean compile;
19 20
 	public final JavaCallCompiler compiler;
20 21
 	
21
-	public JavaSourceMethod(JavaSourceClass cls, Kind kind, String name, boolean compile) {
22
+	public JavaSourceMethod(JavaClass cls, Kind kind, String name, boolean compile) {
22 23
 		this.cls = cls;
23 24
 		this.kind = kind;
24 25
 		this.name = name;

+ 5
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/tags/JavaSourceVariantOption.java View File

@@ -5,15 +5,17 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource.tags;
7 7
 
8
+import org.openzen.zenscript.javashared.JavaClass;
9
+
8 10
 /**
9 11
  *
10 12
  * @author Hoofdgebruiker
11 13
  */
12 14
 public class JavaSourceVariantOption {
13
-	public final JavaSourceClass variantClass;
14
-	public final JavaSourceClass variantOptionClass;
15
+	public final JavaClass variantClass;
16
+	public final JavaClass variantOptionClass;
15 17
 	
16
-	public JavaSourceVariantOption(JavaSourceClass variantClass, JavaSourceClass variantOptionClass) {
18
+	public JavaSourceVariantOption(JavaClass variantClass, JavaClass variantOptionClass) {
17 19
 		this.variantClass = variantClass;
18 20
 		this.variantOptionClass = variantOptionClass;
19 21
 	}

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

@@ -212,7 +212,7 @@ public class ParsedFile {
212 212
 				statements.add(statement.compile(statementScope));
213 213
 			}
214 214
 			
215
-			ScriptBlock block = new ScriptBlock(statements);
215
+			ScriptBlock block = new ScriptBlock(modulePackage.getPackage(), statements);
216 216
 			block.setTag(SourceFile.class, file);
217 217
 			block.setTag(WhitespacePostComment.class, postComment);
218 218
 			scripts.add(block);

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

@@ -56,7 +56,8 @@ public class ParsedFunction extends ParsedDefinition {
56 56
 
57 57
 	@Override
58 58
 	public void linkTypes(TypeResolutionContext context) {
59
-		compiled.setHeader(header.compile(context));
59
+		if (compiled.header == null)
60
+			compiled.setHeader(header.compile(context));
60 61
 	}
61 62
 	
62 63
 	@Override
@@ -93,6 +94,7 @@ public class ParsedFunction extends ParsedDefinition {
93 94
 
94 95
 		@Override
95 96
 		public HighLevelDefinition load() {
97
+			linkTypes(context);
96 98
 			return compiled;
97 99
 		}
98 100
 	}

+ 4
- 7
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java View File

@@ -5,7 +5,6 @@
5 5
  */
6 6
 package org.openzen.zenscript.scriptingexample;
7 7
 
8
-import java.io.PrintStream;
9 8
 import java.util.ArrayList;
10 9
 import java.util.HashMap;
11 10
 import java.util.List;
@@ -19,7 +18,6 @@ import org.openzen.zenscript.codemodel.Modifiers;
19 18
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
20 19
 import org.openzen.zenscript.codemodel.definition.ClassDefinition;
21 20
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
22
-import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
23 21
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
24 22
 import org.openzen.zenscript.codemodel.expression.GetStaticFieldExpression;
25 23
 import org.openzen.zenscript.codemodel.member.FieldMember;
@@ -31,11 +29,10 @@ import org.openzen.zenscript.codemodel.scope.BaseScope;
31 29
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
32 30
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
33 31
 import org.openzen.zenscript.codemodel.type.ITypeID;
34
-import org.openzen.zenscript.javabytecode.JavaBytecodeImplementation;
35
-import org.openzen.zenscript.javabytecode.JavaClassInfo;
36 32
 import org.openzen.zenscript.javabytecode.JavaFieldInfo;
37 33
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
38 34
 import org.openzen.zenscript.codemodel.type.ISymbol;
35
+import org.openzen.zenscript.javashared.JavaClass;
39 36
 
40 37
 /**
41 38
  *
@@ -48,11 +45,11 @@ public class GlobalRegistry {
48 45
 	private final ZSPackage javaLang = rootPackage.getOrCreatePackage("java").getOrCreatePackage("lang");
49 46
 	
50 47
 	public GlobalRegistry(ZSPackage globals) {
51
-		JavaClassInfo jPrintStream = new JavaClassInfo("java/io/PrintStream");
48
+		JavaClass jPrintStream = new JavaClass("java.io", "PrintStream", JavaClass.Kind.CLASS);
52 49
 		JavaMethodInfo printstreamPrintln = new JavaMethodInfo(jPrintStream, "println", "(Ljava/lang/String;)V", Opcodes.ACC_PUBLIC);
53 50
 		PRINTSTREAM_PRINTLN.setTag(JavaMethodInfo.class, printstreamPrintln);
54 51
 		
55
-		JavaClassInfo jSystem = new JavaClassInfo("java/lang/System");
52
+		JavaClass jSystem = new JavaClass("java.lang", "System", JavaClass.Kind.CLASS);
56 53
 		SYSTEM_OUT.setTag(JavaFieldInfo.class, new JavaFieldInfo(jSystem, "out", "Ljava/io/PrintStream;"));
57 54
 	}
58 55
 	
@@ -64,7 +61,7 @@ public class GlobalRegistry {
64 61
 			// the visitors can then during compilation check if a method is an instance of NativeMethodMember and treat it accordingly
65 62
 			ZSPackage packageMyPackage = rootPackage.getOrCreatePackage("my").getOrCreatePackage("package");
66 63
 			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, packageMyPackage, "MyClass", Modifiers.PUBLIC, null);
67
-			JavaClassInfo myClassInfo = new JavaClassInfo("my/test/MyClass");
64
+			JavaClass myClassInfo = new JavaClass("my.test", "MyClass", JavaClass.Kind.CLASS);
68 65
 			
69 66
 			MethodMember member = new MethodMember(CodePosition.NATIVE, myClassDefinition, Modifiers.PUBLIC, "test", new FunctionHeader(BasicTypeID.STRING), null);
70 67
 			member.setTag(JavaMethodInfo.class, new JavaMethodInfo(myClassInfo, "test", "()Ljava/lang/String;", Opcodes.ACC_PUBLIC));

+ 1
- 1
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java View File

@@ -123,7 +123,7 @@ public class Main {
123 123
 	}
124 124
 	
125 125
 	private static JavaModule compileSemanticToJava(SemanticModule module) {
126
-		JavaCompiler compiler = new JavaCompiler(false);
126
+		JavaCompiler compiler = new JavaCompiler(false, null);
127 127
 		for (HighLevelDefinition definition : module.definitions.getAll()) {
128 128
 			compiler.addDefinition(definition, module);
129 129
 		}

Loading…
Cancel
Save