Ein Feld wird nur einmal in Bytecode uebersetzt. genIns in ResultSet
wird angepasst.
This commit is contained in:
parent
5b527ec8ab
commit
6a519ff6dc
@ -80,7 +80,8 @@ public class BytecodeGen implements ASTVisitor {
|
||||
byte[] bytecode;
|
||||
HashMap<String,byte[]> classFiles;
|
||||
|
||||
ArrayList<String> methodNameAndParamsT = new ArrayList<>();
|
||||
private final ArrayList<String> methodNameAndParamsT = new ArrayList<>();
|
||||
private final ArrayList<String> fieldNameAndParamsT = new ArrayList<>();
|
||||
|
||||
private HashMap<String, SimplifyResult> simplifyResults = new HashMap<>();
|
||||
private List<HashMap<String, SimplifyResult>> simplifyResultsList = new ArrayList<>();
|
||||
@ -501,7 +502,14 @@ public class BytecodeGen implements ASTVisitor {
|
||||
System.out.println(sig);
|
||||
if(sig.charAt(sig.length()-1) != (";").charAt(0)) {
|
||||
sig +=";";
|
||||
}
|
||||
}
|
||||
String nameAndDesc = field.getName() + "%%" + des;
|
||||
|
||||
if(fieldNameAndParamsT.contains(nameAndDesc))
|
||||
return;
|
||||
|
||||
fieldNameAndParamsT.add(nameAndDesc);
|
||||
|
||||
cw.visitField(field.modifier, field.getName(),
|
||||
des, sig,
|
||||
null);
|
||||
|
@ -28,6 +28,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
/**
|
||||
@ -44,7 +45,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
boolean inLocalOrParam = false;
|
||||
|
||||
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
||||
final ArrayList<GenericInsertPair> allPairs = new ArrayList<>();
|
||||
final ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> allPairs = new ArrayList<>();
|
||||
public final ArrayList<TPHConstraint> allCons = new ArrayList<>();
|
||||
private ResultSet resultSet;
|
||||
|
||||
@ -97,7 +98,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
if (inMethod)
|
||||
methodAndTph.getPairs().add(ag);
|
||||
allPairs.add(ag);
|
||||
TPHConstraint con = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||
TPHConstraint con = new ExtendsConstraint(ag.getLeft().getName(), ag.getRight().getName(), Relation.EXTENDS);
|
||||
if(!containsConstraint(allCons,con))
|
||||
allCons.add(con);
|
||||
// }
|
||||
|
@ -237,7 +237,7 @@ public class Signature {
|
||||
if(resolved instanceof TypePlaceholder) {
|
||||
//resType.getAdditionalGenerics().forEach(ag ->{
|
||||
resultSet.genIns.forEach(ag ->{
|
||||
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||
TPHConstraint constr = new ExtendsConstraint(ag.getLeft().getName(), ag.getRight().getName(), Relation.EXTENDS);
|
||||
if(!contains(res,constr)) {
|
||||
res.add(constr);
|
||||
}
|
||||
@ -249,7 +249,7 @@ public class Signature {
|
||||
if(resType2.resolvedType instanceof TypePlaceholder) {
|
||||
//resType2.getAdditionalGenerics().forEach(ag ->{
|
||||
resultSet.genIns.forEach(ag ->{
|
||||
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||
TPHConstraint constr = new ExtendsConstraint(ag.getLeft().getName(), ag.getRight().getName(), Relation.EXTENDS);
|
||||
if(!contains(res,constr)) {
|
||||
res.add(constr);
|
||||
}
|
||||
|
@ -2,14 +2,17 @@ package de.dhbwstuttgart.bytecode.utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
|
||||
public class MethodAndTPH {
|
||||
|
||||
private String name;
|
||||
private final ArrayList<String> tphs = new ArrayList<>();
|
||||
private final ArrayList<GenericInsertPair> pairs = new ArrayList<>();
|
||||
//private final ArrayList<GenericInsertPair> pairs = new ArrayList<>();
|
||||
private final ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> pairs = new ArrayList<>();
|
||||
// tphs of local variables and parameters
|
||||
private final ArrayList<String> localTphs = new ArrayList<>();
|
||||
|
||||
@ -21,7 +24,10 @@ public class MethodAndTPH {
|
||||
return tphs;
|
||||
}
|
||||
|
||||
public ArrayList<GenericInsertPair> getPairs(){
|
||||
// public ArrayList<GenericInsertPair> getPairs(){
|
||||
// return pairs;
|
||||
// }
|
||||
public ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> getPairs(){
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,11 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ResultSet {
|
||||
public final Set<ResultPair> results;
|
||||
public Set<GenericInsertPair> genIns;
|
||||
public Set<ResultPair<TypePlaceholder, TypePlaceholder>> genIns;
|
||||
public ResultSet(Set<ResultPair> results){
|
||||
this.results = results;
|
||||
this.genIns = results.stream().filter(a -> a instanceof PairTPHsmallerTPH)
|
||||
.map(b -> new GenericInsertPair( (TypePlaceholder)(b.getLeft()), (TypePlaceholder)(b.getRight())))
|
||||
//.map(b -> new GenericInsertPair( (TypePlaceholder)(b.getLeft()), (TypePlaceholder)(b.getRight())))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
}
|
||||
}
|
||||
|
||||
mul = (m1, m2) -> {
|
||||
public mul = (m1, m2) -> {
|
||||
var ret = new MatrixOP();
|
||||
var i = 0;
|
||||
while(i < m1.size()) {
|
||||
|
Loading…
Reference in New Issue
Block a user