From 337ff8b865627dfe830d8199e92fc4c54ee7fa03 Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Wed, 24 May 2023 16:51:53 +0200 Subject: [PATCH] Fix incorrect signatures --- resources/bytecode/javFiles/Fac.jav | 2 +- resources/bytecode/javFiles/Id.jav | 2 +- .../dhbwstuttgart/bytecode/FunNGenerator.java | 20 +++++++++++-------- .../syntaxtree/factory/ASTFactory.java | 4 +++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/resources/bytecode/javFiles/Fac.jav b/resources/bytecode/javFiles/Fac.jav index 28650b45..2edee01e 100644 --- a/resources/bytecode/javFiles/Fac.jav +++ b/resources/bytecode/javFiles/Fac.jav @@ -1,5 +1,5 @@ import java.lang.Integer; -//import java.lang.Double; +import java.lang.Double; public class Fac { diff --git a/resources/bytecode/javFiles/Id.jav b/resources/bytecode/javFiles/Id.jav index 03cf2a09..f31991db 100644 --- a/resources/bytecode/javFiles/Id.jav +++ b/resources/bytecode/javFiles/Id.jav @@ -1,4 +1,4 @@ -public class Id { +public class Id { // a; // id(b){ // return b; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java index e25a229c..422d5e7c 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java @@ -33,18 +33,22 @@ public class FunNGenerator { private static String applyDescriptor(TargetType type, int[] start) { - var res = "L" + type.getInternalName() + "<"; + var res = "L" + type.getInternalName(); if (type instanceof TargetSpecializedType a) - for (var param : a.params()) { - if (param instanceof TargetGenericType gp) { - res += "TT" + start[0] + ";"; - start[0] += 1; - } else { - res += applyDescriptor(param, start); + if (a.params().size() > 0) { + res += "<"; + for (var param : a.params()) { + if (param instanceof TargetGenericType gp) { + res += "TT" + start[0] + ";"; + start[0] += 1; + } else { + res += applyDescriptor(param, start); + } } + res += ">"; } else return type.toDescriptor(); - res += ">;"; + res += ";"; return res; } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index bdef497f..f33fa76a 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -156,6 +156,7 @@ public class ASTFactory { List params = new ArrayList<>(); int i = 0; for(Type jreParam : jreGenericParams){ + if (jreParam == null) continue; RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam); params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken())); i++; @@ -188,6 +189,7 @@ public class ASTFactory { List params = new ArrayList<>(); int i = 0; for(Type jreParam : jreGenericParams){ + if (jreParam == null) continue; RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam); params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken())); i++; @@ -333,7 +335,7 @@ public class ASTFactory { } private static RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type){ - if(type.getTypeName().equals("void")){ + if(type == null || type.getTypeName().equals("void")){ return new Void(new NullToken()); }else if(type.getTypeName().equals("int")){ return new RefType(new JavaClassName("java.lang.Integer"), new ArrayList<>(), new NullToken());