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
 package org.openzen.zenscript.javabytecode.compiler;
1
 package org.openzen.zenscript.javabytecode.compiler;
2
 
2
 
3
 import org.openzen.zenscript.codemodel.type.*;
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
     @Override
8
     @Override
7
     public String visitBasic(BasicTypeID basic) {
9
     public String visitBasic(BasicTypeID basic) {
8
         switch (basic) {
10
         switch (basic) {
60
 
62
 
61
     @Override
63
     @Override
62
     public String visitDefinition(DefinitionTypeID definition) {
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
     @Override
72
     @Override
68
     public String visitGeneric(GenericTypeID generic) {
73
     public String visitGeneric(GenericTypeID generic) {
74
+		// TODO: type erasure
69
         return null;
75
         return null;
70
     }
76
     }
71
 
77
 
76
 
82
 
77
     @Override
83
     @Override
78
     public String visitConst(ConstTypeID type) {
84
     public String visitConst(ConstTypeID type) {
79
-        return null;
85
+		return type.baseType.accept(this);
80
     }
86
     }
81
 
87
 
82
     @Override
88
     @Override

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

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public class CompileException extends RuntimeException {
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
 	public final CodePosition position;
17
 	public final CodePosition position;
14
 	public final CompileExceptionCode code;
18
 	public final CompileExceptionCode code;
15
 	
19
 	

Loading…
Cancel
Save