Browse Source

- Renamed JavaTypeSignatureVisitor to JavaTypeVisitor

Stan Hebben 6 years ago
parent
commit
0aa2dfecdb

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaTypeVisitor.java → JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaTypeSignatureVisitor.java View File

@@ -1,8 +1,10 @@
1 1
 package org.openzen.zenscript.javabytecode.compiler;
2 2
 
3 3
 import org.openzen.zenscript.codemodel.type.*;
4
+import org.openzen.zenscript.javabytecode.JavaClassInfo;
5
+import org.openzen.zenscript.shared.CompileException;
4 6
 
5
-public class JavaTypeVisitor implements ITypeVisitor<String> {
7
+public class JavaTypeSignatureVisitor implements ITypeVisitor<String> {
6 8
     @Override
7 9
     public String visitBasic(BasicTypeID basic) {
8 10
         switch (basic) {
@@ -60,12 +62,16 @@ public class JavaTypeVisitor implements ITypeVisitor<String> {
60 62
 
61 63
     @Override
62 64
     public String visitDefinition(DefinitionTypeID definition) {
63
-
64
-        return definition.definition.name.replaceAll("\"", "");
65
+		JavaClassInfo classInfo = definition.definition.getTag(JavaClassInfo.class);
66
+		if (classInfo == null)
67
+			throw CompileException.internalError("Definition is missing java class tag!");
68
+		
69
+        return "L" + classInfo.internalClassName + ";";
65 70
     }
66 71
 
67 72
     @Override
68 73
     public String visitGeneric(GenericTypeID generic) {
74
+		// TODO: type erasure
69 75
         return null;
70 76
     }
71 77
 
@@ -76,7 +82,7 @@ public class JavaTypeVisitor implements ITypeVisitor<String> {
76 82
 
77 83
     @Override
78 84
     public String visitConst(ConstTypeID type) {
79
-        return null;
85
+		return type.baseType.accept(this);
80 86
     }
81 87
 
82 88
     @Override

+ 4
- 0
Shared/src/main/java/org/openzen/zenscript/shared/CompileException.java View File

@@ -10,6 +10,10 @@ package org.openzen.zenscript.shared;
10 10
  * @author Hoofdgebruiker
11 11
  */
12 12
 public class CompileException extends RuntimeException {
13
+	public static CompileException internalError(String message) {
14
+		return new CompileException(CodePosition.BUILTIN, CompileExceptionCode.INTERNAL_ERROR, message);
15
+	}
16
+	
13 17
 	public final CodePosition position;
14 18
 	public final CompileExceptionCode code;
15 19
 	

Loading…
Cancel
Save