From c34b3c4c14f4ccce5436395fb78f9c150184361d Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 15 Dec 2016 16:00:28 +0100 Subject: [PATCH] =?UTF-8?q?Aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bytecode/BytecodeTypeFactory.java | 19 +++++------- .../syntaxtree/GenericTypeVar.java | 29 ++++++++++++------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java b/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java index 424ef909..8d9a3fe9 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java @@ -1,9 +1,7 @@ package de.dhbwstuttgart.bytecode; -import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; -import de.dhbwstuttgart.syntaxtree.type.ObjectType; +import de.dhbwstuttgart.syntaxtree.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.RefType; -import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; 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 */ - public static String generateFieldDescriptor(Type t){ + public static String generateFieldDescriptor(RefType t){ String ret = ""; if(t instanceof RefType){ ret += "L" + t.getName().toString().replace('.', '/') + ";"; @@ -39,15 +37,15 @@ public class BytecodeTypeFactory { return ret; } - public static String generateSuperClassSignature(Type superClass){ + public static String generateSuperClassSignature(RefType superClass){ String ret = ""; //TODO: throw new NotImplementedException(); } private static String generateTypeParameter(GenericTypeVar gtv){ - String ret = gtv.get_Name() + ":"; - for(ObjectType t : gtv.getBounds()){ + String ret = gtv.getName() + ":"; + for(RefType t : gtv.getBounds()){ ret += generateReferenceTypeSignature(t); ret += ":"; } @@ -65,17 +63,16 @@ public class BytecodeTypeFactory { /** * @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 GenericTypeVar)return generateReferenceTypeSignature((GenericTypeVar)t); throw new NotImplementedException(); } 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){ ret += "<"; - for(Type p : t.getParaList()){ + for(RefType p : t.getParaList()){ ret += generateReferenceTypeSignature(p); } ret+=">"; diff --git a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java index 7cdf5c72..a1ecd49c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java @@ -1,7 +1,10 @@ package de.dhbwstuttgart.syntaxtree; import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.ResultSet; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import java.util.ArrayList; import java.util.List; @@ -23,10 +26,12 @@ public class GenericTypeVar extends SyntaxTreeNode */ List bounds=new ArrayList(); private int endOffset; + private String name; public GenericTypeVar(String s, List bounds, int offset, int endOffset) { - super(s, offset); + super(offset); + name = s; if(bounds != null)for(RefType t : bounds){ //if(t!=null)this.extendVars.add(t); } @@ -34,8 +39,7 @@ public class GenericTypeVar extends SyntaxTreeNode this.bounds = bounds; this.endOffset = endOffset; } - - @Override + public int getEndOffset(){ return this.endOffset; } @@ -44,22 +48,25 @@ public class GenericTypeVar extends SyntaxTreeNode { return bounds; } - - public GenericTypeVar clone() - { - return new GenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset()); - } public String toString() { - return "BoGTV " + this.getName(); + return "BoGTV " + this.name; } @Override - public Menge getChildren() { - Menge ret = super.getChildren(); + public List getChildren() { + List ret = new ArrayList<>(); ret.addAll(this.bounds); return ret; } + @Override + public JavaCodeResult printJavaCode(ResultSet resultSet) { + throw new NotImplementedException(); + } + + public String getName() { + return name; + } }