Hack in ASP-Constraint generation for WLP2024 paper Prototype Test
This commit is contained in:
parent
2aa3997f17
commit
fcda301b1e
1
pom.xml
1
pom.xml
@ -53,7 +53,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerArgs>--enable-preview</compilerArgs>
|
|
||||||
<source>21</source>
|
<source>21</source>
|
||||||
<target>21</target>
|
<target>21</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -5,10 +5,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassName;
|
|||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
@ -45,7 +42,7 @@ public class TYPE {
|
|||||||
|
|
||||||
private String toASP(RefTypeOrTPHOrWildcardOrGeneric type){
|
private String toASP(RefTypeOrTPHOrWildcardOrGeneric type){
|
||||||
if(type instanceof TypePlaceholder){
|
if(type instanceof TypePlaceholder){
|
||||||
return "tph"+((TypePlaceholder) type).getName();
|
return "_"+((TypePlaceholder) type).getName();
|
||||||
}else if(type instanceof RefType){
|
}else if(type instanceof RefType){
|
||||||
if(((RefType) type).getParaList().size() > 0){
|
if(((RefType) type).getParaList().size() > 0){
|
||||||
return ((RefType) type).getName() + "<" +
|
return ((RefType) type).getName() + "<" +
|
||||||
@ -55,7 +52,11 @@ public class TYPE {
|
|||||||
return ((RefType) type).getName().toString();
|
return ((RefType) type).getName().toString();
|
||||||
}
|
}
|
||||||
}else if(type instanceof ExtendsWildcardType){
|
}else if(type instanceof ExtendsWildcardType){
|
||||||
//TODO
|
return toASP(((ExtendsWildcardType) type).getInnerType());
|
||||||
|
} else if(type instanceof SuperWildcardType) {
|
||||||
|
return toASP(((SuperWildcardType) type).getInnerType());
|
||||||
|
} else if(type instanceof GenericRefType){
|
||||||
|
return "G"+((GenericRefType) type).getParsedName();
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Unsupported Type: "+ type);
|
throw new RuntimeException("Unsupported Type: "+ type);
|
||||||
}
|
}
|
||||||
@ -68,6 +69,8 @@ public class TYPE {
|
|||||||
ret +=(toASP(p.TA1) + "<." + toASP(p.TA2) + "\n");
|
ret +=(toASP(p.TA1) + "<." + toASP(p.TA2) + "\n");
|
||||||
} else if (p.OperatorSmallerNEQDot()) {
|
} else if (p.OperatorSmallerNEQDot()) {
|
||||||
ret += (toASP(p.TA1) + "<." + toASP(p.TA2) + "\n");
|
ret += (toASP(p.TA1) + "<." + toASP(p.TA2) + "\n");
|
||||||
|
}else if(p.OperatorSmaller()){
|
||||||
|
ret += toASP(p.TA1) +"<"+toASP(p.TA2)+ "\n";
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Operator unsupported: " + p.GetOperator());
|
throw new RuntimeException("Operator unsupported: " + p.GetOperator());
|
||||||
}
|
}
|
||||||
@ -77,15 +80,23 @@ public class TYPE {
|
|||||||
private void writeASP(ConstraintSet<Pair> cs){
|
private void writeASP(ConstraintSet<Pair> cs){
|
||||||
try(var f = new FileWriter("/tmp/output")){
|
try(var f = new FileWriter("/tmp/output")){
|
||||||
f.append(genASP(cs.getUndConstraints()));
|
f.append(genASP(cs.getUndConstraints()));
|
||||||
List<Set<Pair>> orCons = cs.getOderConstraints().stream().map(css -> {
|
List<List<Set<Pair>>> orCons = cs.getOderConstraints().stream().map(css -> {
|
||||||
return css.stream().flatMap(cp -> {
|
return css.stream().map(cp -> {
|
||||||
return cp.stream();
|
return cp.stream().collect(Collectors.toSet());
|
||||||
}).collect(Collectors.toSet());
|
}).collect(Collectors.toList());
|
||||||
}).toList();
|
}).toList();
|
||||||
for(Set<Pair> orC : orCons) {
|
|
||||||
|
for(var orCon : orCons){
|
||||||
|
f.append("{\n");
|
||||||
|
var it = orCon.iterator();
|
||||||
|
while(it.hasNext()) {
|
||||||
|
var orC = it.next();
|
||||||
f.append("{\n");
|
f.append("{\n");
|
||||||
f.append(genASP(orC));
|
f.append(genASP(orC));
|
||||||
f.append("}\n");
|
f.append("}\n");
|
||||||
|
if(it.hasNext())f.append("|");
|
||||||
|
}
|
||||||
|
f.append("}\n");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user