forked from JavaTX/JavaCompilerCore
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;
|
byte[] bytecode;
|
||||||
HashMap<String,byte[]> classFiles;
|
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 HashMap<String, SimplifyResult> simplifyResults = new HashMap<>();
|
||||||
private List<HashMap<String, SimplifyResult>> simplifyResultsList = new ArrayList<>();
|
private List<HashMap<String, SimplifyResult>> simplifyResultsList = new ArrayList<>();
|
||||||
@ -501,7 +502,14 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
System.out.println(sig);
|
System.out.println(sig);
|
||||||
if(sig.charAt(sig.length()-1) != (";").charAt(0)) {
|
if(sig.charAt(sig.length()-1) != (";").charAt(0)) {
|
||||||
sig +=";";
|
sig +=";";
|
||||||
}
|
}
|
||||||
|
String nameAndDesc = field.getName() + "%%" + des;
|
||||||
|
|
||||||
|
if(fieldNameAndParamsT.contains(nameAndDesc))
|
||||||
|
return;
|
||||||
|
|
||||||
|
fieldNameAndParamsT.add(nameAndDesc);
|
||||||
|
|
||||||
cw.visitField(field.modifier, field.getName(),
|
cw.visitField(field.modifier, field.getName(),
|
||||||
des, sig,
|
des, sig,
|
||||||
null);
|
null);
|
||||||
|
@ -28,6 +28,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||||
|
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
boolean inLocalOrParam = false;
|
boolean inLocalOrParam = false;
|
||||||
|
|
||||||
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
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<>();
|
public final ArrayList<TPHConstraint> allCons = new ArrayList<>();
|
||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
if (inMethod)
|
if (inMethod)
|
||||||
methodAndTph.getPairs().add(ag);
|
methodAndTph.getPairs().add(ag);
|
||||||
allPairs.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))
|
if(!containsConstraint(allCons,con))
|
||||||
allCons.add(con);
|
allCons.add(con);
|
||||||
// }
|
// }
|
||||||
|
@ -237,7 +237,7 @@ public class Signature {
|
|||||||
if(resolved instanceof TypePlaceholder) {
|
if(resolved instanceof TypePlaceholder) {
|
||||||
//resType.getAdditionalGenerics().forEach(ag ->{
|
//resType.getAdditionalGenerics().forEach(ag ->{
|
||||||
resultSet.genIns.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)) {
|
if(!contains(res,constr)) {
|
||||||
res.add(constr);
|
res.add(constr);
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ public class Signature {
|
|||||||
if(resType2.resolvedType instanceof TypePlaceholder) {
|
if(resType2.resolvedType instanceof TypePlaceholder) {
|
||||||
//resType2.getAdditionalGenerics().forEach(ag ->{
|
//resType2.getAdditionalGenerics().forEach(ag ->{
|
||||||
resultSet.genIns.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)) {
|
if(!contains(res,constr)) {
|
||||||
res.add(constr);
|
res.add(constr);
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,17 @@ package de.dhbwstuttgart.bytecode.utilities;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||||
|
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||||
|
|
||||||
public class MethodAndTPH {
|
public class MethodAndTPH {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private final ArrayList<String> tphs = new ArrayList<>();
|
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
|
// tphs of local variables and parameters
|
||||||
private final ArrayList<String> localTphs = new ArrayList<>();
|
private final ArrayList<String> localTphs = new ArrayList<>();
|
||||||
|
|
||||||
@ -21,7 +24,10 @@ public class MethodAndTPH {
|
|||||||
return tphs;
|
return tphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<GenericInsertPair> getPairs(){
|
// public ArrayList<GenericInsertPair> getPairs(){
|
||||||
|
// return pairs;
|
||||||
|
// }
|
||||||
|
public ArrayList<ResultPair<TypePlaceholder, TypePlaceholder>> getPairs(){
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ResultSet {
|
public class ResultSet {
|
||||||
public final Set<ResultPair> results;
|
public final Set<ResultPair> results;
|
||||||
public Set<GenericInsertPair> genIns;
|
public Set<ResultPair<TypePlaceholder, TypePlaceholder>> genIns;
|
||||||
public ResultSet(Set<ResultPair> results){
|
public ResultSet(Set<ResultPair> results){
|
||||||
this.results = results;
|
this.results = results;
|
||||||
this.genIns = results.stream().filter(a -> a instanceof PairTPHsmallerTPH)
|
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));
|
.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 ret = new MatrixOP();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while(i < m1.size()) {
|
while(i < m1.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user