GenericType für Bytecodegenerierung eingeführt

This commit is contained in:
JanUlrich 2016-12-16 14:33:04 +01:00
parent 1b99f74f39
commit ddbcc5ee6e
2 changed files with 22 additions and 19 deletions

View File

@ -64,8 +64,8 @@ public class BytecodeTypeFactory {
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ReferenceTypeSignature
*/
private static String generateTypeSignature(RefType t){
if(t.isGenericType())return generateReferenceTypeSignature(t);
return generateGenericTypeSignature(t);
if(t.isGenericType())return generateGenericTypeSignature(t);
return generateReferenceTypeSignature(t);
}
private static String generateReferenceTypeSignature(RefType t){
@ -81,7 +81,7 @@ public class BytecodeTypeFactory {
}
private static String generateGenericTypeSignature(RefType t){
String ret = "T" + t.get_Name();
String ret = "T" + t.getName();
return ret + ";";
}

View File

@ -3,7 +3,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class;
@ -27,13 +26,7 @@ public class RefType extends SyntaxTreeNode
private boolean IsArray = false;
protected JavaClassName name;
protected List<RefType> parameter = null;
/**
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
* den primitiven Datentyp ersetzt werden
*
* Bsp: java.lang.Integer mit Flag wird dann zu [int]
*/
private boolean primitiveFlag=false;
private boolean isGeneric = false;
public RefType(JavaClassName fullyQualifiedName, int offset)
{
@ -49,11 +42,18 @@ public class RefType extends SyntaxTreeNode
return hash;
}
public RefType(JavaClassName fullyQualifiedName, List<RefType> parameter, int offset)
{
this(fullyQualifiedName, offset);
if(parameter != null && parameter.size()>0)this.parameter = parameter;
}
public RefType(JavaClassName fullyQualifiedName, List<RefType> parameter, int offset)
{
this(fullyQualifiedName, offset);
if(parameter != null && parameter.size()>0)this.parameter = parameter;
}
public RefType(JavaClassName fullyQualifiedName, List<RefType> parameter, boolean isGneric,int offset)
{
this(fullyQualifiedName, offset);
if(parameter != null && parameter.size()>0)this.parameter = parameter;
this.isGeneric = isGneric;
}
public JavaClassName getName()
{
@ -127,10 +127,9 @@ public class RefType extends SyntaxTreeNode
public String toString()
{
String primitiveFlagMarker=primitiveFlag?"*":"";
if(parameter==null)
{
return name+primitiveFlagMarker;
return this.getName().toString();
}
else
{
@ -146,7 +145,7 @@ public class RefType extends SyntaxTreeNode
}
String ret = name.toString();
if(parameter.size()>0)ret += "<"+para + " >";
return ret + primitiveFlagMarker;//name + "<"+para + " >" +primitiveFlagMarker;
return ret;
}
}
@ -250,5 +249,9 @@ public class RefType extends SyntaxTreeNode
}
return ret;
}
public boolean isGenericType() {
return isGeneric;
}
}