Aufräumen
This commit is contained in:
parent
01a954ca68
commit
c34b3c4c14
@ -1,9 +1,7 @@
|
|||||||
package de.dhbwstuttgart.bytecode;
|
package de.dhbwstuttgart.bytecode;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
public class BytecodeTypeFactory {
|
public class BytecodeTypeFactory {
|
||||||
@ -11,7 +9,7 @@ public class BytecodeTypeFactory {
|
|||||||
/**
|
/**
|
||||||
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-FieldType
|
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-FieldType
|
||||||
*/
|
*/
|
||||||
public static String generateFieldDescriptor(Type t){
|
public static String generateFieldDescriptor(RefType t){
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if(t instanceof RefType){
|
if(t instanceof RefType){
|
||||||
ret += "L" + t.getName().toString().replace('.', '/') + ";";
|
ret += "L" + t.getName().toString().replace('.', '/') + ";";
|
||||||
@ -39,15 +37,15 @@ public class BytecodeTypeFactory {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateSuperClassSignature(Type superClass){
|
public static String generateSuperClassSignature(RefType superClass){
|
||||||
String ret = "";
|
String ret = "";
|
||||||
//TODO:
|
//TODO:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateTypeParameter(GenericTypeVar gtv){
|
private static String generateTypeParameter(GenericTypeVar gtv){
|
||||||
String ret = gtv.get_Name() + ":";
|
String ret = gtv.getName() + ":";
|
||||||
for(ObjectType t : gtv.getBounds()){
|
for(RefType t : gtv.getBounds()){
|
||||||
ret += generateReferenceTypeSignature(t);
|
ret += generateReferenceTypeSignature(t);
|
||||||
ret += ":";
|
ret += ":";
|
||||||
}
|
}
|
||||||
@ -65,17 +63,16 @@ public class BytecodeTypeFactory {
|
|||||||
/**
|
/**
|
||||||
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ReferenceTypeSignature
|
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ReferenceTypeSignature
|
||||||
*/
|
*/
|
||||||
private static String generateReferenceTypeSignature(Type t){
|
private static String generateReferenceTypeSignature(RefType t){
|
||||||
if(t instanceof RefType)return generateReferenceTypeSignature((RefType)t);
|
if(t instanceof RefType)return generateReferenceTypeSignature((RefType)t);
|
||||||
if(t instanceof GenericTypeVar)return generateReferenceTypeSignature((GenericTypeVar)t);
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateReferenceTypeSignature(RefType t){
|
private static String generateReferenceTypeSignature(RefType t){
|
||||||
String ret = "L" + t.get_Name();
|
String ret = "L" + t.getName();
|
||||||
if(t.getParaList() != null && t.getParaList().size() > 0){
|
if(t.getParaList() != null && t.getParaList().size() > 0){
|
||||||
ret += "<";
|
ret += "<";
|
||||||
for(Type p : t.getParaList()){
|
for(RefType p : t.getParaList()){
|
||||||
ret += generateReferenceTypeSignature(p);
|
ret += generateReferenceTypeSignature(p);
|
||||||
}
|
}
|
||||||
ret+=">";
|
ret+=">";
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree;
|
package de.dhbwstuttgart.syntaxtree;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,10 +26,12 @@ public class GenericTypeVar extends SyntaxTreeNode
|
|||||||
*/
|
*/
|
||||||
List<RefType> bounds=new ArrayList<RefType>();
|
List<RefType> bounds=new ArrayList<RefType>();
|
||||||
private int endOffset;
|
private int endOffset;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public GenericTypeVar(String s, List<RefType> bounds, int offset, int endOffset)
|
public GenericTypeVar(String s, List<RefType> bounds, int offset, int endOffset)
|
||||||
{
|
{
|
||||||
super(s, offset);
|
super(offset);
|
||||||
|
name = s;
|
||||||
if(bounds != null)for(RefType t : bounds){
|
if(bounds != null)for(RefType t : bounds){
|
||||||
//if(t!=null)this.extendVars.add(t);
|
//if(t!=null)this.extendVars.add(t);
|
||||||
}
|
}
|
||||||
@ -34,8 +39,7 @@ public class GenericTypeVar extends SyntaxTreeNode
|
|||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
this.endOffset = endOffset;
|
this.endOffset = endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEndOffset(){
|
public int getEndOffset(){
|
||||||
return this.endOffset;
|
return this.endOffset;
|
||||||
}
|
}
|
||||||
@ -44,22 +48,25 @@ public class GenericTypeVar extends SyntaxTreeNode
|
|||||||
{
|
{
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericTypeVar clone()
|
|
||||||
{
|
|
||||||
return new GenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "BoGTV " + this.getName();
|
return "BoGTV " + this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Menge<SyntaxTreeNode> getChildren() {
|
public List<SyntaxTreeNode> getChildren() {
|
||||||
Menge<SyntaxTreeNode> ret = super.getChildren();
|
List<SyntaxTreeNode> ret = new ArrayList<>();
|
||||||
ret.addAll(this.bounds);
|
ret.addAll(this.bounds);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user