forked from JavaTX/JavaCompilerCore
Merge branch 'bytecode2' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bytecode2
This commit is contained in:
commit
f085f9f499
@ -121,8 +121,9 @@ public class JavaTXCompiler {
|
|||||||
System.out.println(xConsSet);
|
System.out.println(xConsSet);
|
||||||
Set<String> paraTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().map(y -> y.getParameterList().getFormalparalist()
|
Set<String> paraTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().map(y -> y.getParameterList().getFormalparalist()
|
||||||
.stream().filter(z -> z.getType() instanceof TypePlaceholder)
|
.stream().filter(z -> z.getType() instanceof TypePlaceholder)
|
||||||
.map(z -> ((TypePlaceholder)z.getType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;} ).get())
|
.map(z -> ((TypePlaceholder)z.getType()).getName()).collect(Collectors.toCollection(HashSet::new)))
|
||||||
.reduce((a,b) -> { a.addAll(b); return a;} ).get();
|
.reduce(new HashSet<String>(), (a,b) -> { a.addAll(b); return a;}, (a,b) -> { a.addAll(b); return a;} ) )
|
||||||
|
.reduce(new HashSet<String>(), (a,b) -> { a.addAll(b); return a;} );
|
||||||
|
|
||||||
Set<String> returnTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
Set<String> returnTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
||||||
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;} ).get();
|
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;} ).get();
|
||||||
|
@ -51,6 +51,10 @@ public class UnifyTypeFactory {
|
|||||||
return new UnifyPair(tl, tr, PairOperator.SMALLERDOT);
|
return new UnifyPair(tl, tr, PairOperator.SMALLERDOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UnifyPair generateSmallNotEqualDotPair(UnifyType tl, UnifyType tr){
|
||||||
|
return new UnifyPair(tl, tr, PairOperator.SMALLERNEQDOT);
|
||||||
|
}
|
||||||
|
|
||||||
public static UnifyPair generateEqualDotPair(UnifyType tl, UnifyType tr){
|
public static UnifyPair generateEqualDotPair(UnifyType tl, UnifyType tr){
|
||||||
return new UnifyPair(tl, tr, PairOperator.EQUALSDOT);
|
return new UnifyPair(tl, tr, PairOperator.EQUALSDOT);
|
||||||
}
|
}
|
||||||
@ -152,6 +156,10 @@ public class UnifyTypeFactory {
|
|||||||
UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1)
|
UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||||
, UnifyTypeFactory.convert(p.TA2));
|
, UnifyTypeFactory.convert(p.TA2));
|
||||||
return ret;
|
return ret;
|
||||||
|
}else if(p.GetOperator().equals(PairOperator.SMALLERNEQDOT)) {
|
||||||
|
UnifyPair ret = generateSmallNotEqualDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||||
|
, UnifyTypeFactory.convert(p.TA2));
|
||||||
|
return ret;
|
||||||
}else if(p.GetOperator().equals(PairOperator.EQUALSDOT)) {
|
}else if(p.GetOperator().equals(PairOperator.EQUALSDOT)) {
|
||||||
UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1)
|
UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1)
|
||||||
, UnifyTypeFactory.convert(p.TA2));
|
, UnifyTypeFactory.convert(p.TA2));
|
||||||
|
@ -42,14 +42,16 @@ public class Pair implements Serializable
|
|||||||
if( TA2 != null )
|
if( TA2 != null )
|
||||||
strElement2 = TA2.toString();
|
strElement2 = TA2.toString();
|
||||||
|
|
||||||
|
/* PL ausskommentiert 2018-05-24
|
||||||
if(OperatorEqual())
|
if(OperatorEqual())
|
||||||
Operator = "=";
|
Operator = "=";
|
||||||
if(OperatorSmaller())
|
if(OperatorSmaller())
|
||||||
Operator = "<.";
|
Operator = "<.";
|
||||||
if(OperatorSmallerExtends())
|
if(OperatorSmallerExtends())
|
||||||
Operator = "<?";
|
Operator = "<?";
|
||||||
|
*/
|
||||||
|
|
||||||
return "\n(" + strElement1 + " " + Operator + " " + strElement2 + ")";
|
return "\n(" + strElement1 + " " + eOperator.toString() + " " + strElement2 + ")";
|
||||||
|
|
||||||
/*- Equals: " + bEqual*/
|
/*- Equals: " + bEqual*/
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
binary.operation.equals(BinaryExpr.Operator.MUL)||
|
binary.operation.equals(BinaryExpr.Operator.MUL)||
|
||||||
binary.operation.equals(BinaryExpr.Operator.MOD)||
|
binary.operation.equals(BinaryExpr.Operator.MOD)||
|
||||||
binary.operation.equals(BinaryExpr.Operator.ADD)){
|
binary.operation.equals(BinaryExpr.Operator.ADD)){
|
||||||
Set<Constraint> numericAdditionOrStringConcatenation = new HashSet<>();
|
Set<Constraint<Pair>> numericAdditionOrStringConcatenation = new HashSet<>();
|
||||||
|
|
||||||
//Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
|
//Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
|
||||||
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
||||||
@ -272,8 +272,8 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
binary.operation.equals(BinaryExpr.Operator.BIGGEREQUAL) ||
|
binary.operation.equals(BinaryExpr.Operator.BIGGEREQUAL) ||
|
||||||
binary.operation.equals(BinaryExpr.Operator.BIGGERTHAN) ||
|
binary.operation.equals(BinaryExpr.Operator.BIGGERTHAN) ||
|
||||||
binary.operation.equals(BinaryExpr.Operator.LESSTHAN)){
|
binary.operation.equals(BinaryExpr.Operator.LESSTHAN)){
|
||||||
//eingefuegt PL 2018-05-24
|
/* //eingefuegt PL 2018-05-24
|
||||||
Set<Constraint> numericRelationConcatenation = new HashSet<>();
|
Set<Constraint<Pair>> numericRelationConcatenation = new HashSet<>();
|
||||||
Constraint<Pair> numeric = new Constraint<>();
|
Constraint<Pair> numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
@ -308,7 +308,13 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
//***ACHTUNG: Moeglicherweise oder und und-Contraint falsch
|
//***ACHTUNG: Moeglicherweise oder und und-Contraint falsch
|
||||||
constraintsSet.addOderConstraint(numericRelationConcatenation);
|
constraintsSet.addOderConstraint(numericRelationConcatenation);
|
||||||
//***ACHTUNG: Moeglicherweise oder und und-Contraint falsch
|
//***ACHTUNG: Moeglicherweise oder und und-Contraint falsch
|
||||||
|
*/
|
||||||
|
//Testeise eingefuegt PL 2018-05-24
|
||||||
|
constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
||||||
|
constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
||||||
|
//Rückgabetyp ist Boolean
|
||||||
|
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.SMALLERDOT));
|
||||||
|
|
||||||
//auskommentiert PL 2018-05-24
|
//auskommentiert PL 2018-05-24
|
||||||
//constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
|
//constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
|
||||||
//constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
|
//constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
|
||||||
|
@ -369,9 +369,13 @@ public class RuleSet implements IRuleSet{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean erase1(UnifyPair pair, IFiniteClosure fc) {
|
public boolean erase1(UnifyPair pair, IFiniteClosure fc) {
|
||||||
if(pair.getPairOp() != PairOperator.SMALLERDOT)
|
if((pair.getPairOp() != PairOperator.SMALLERDOT) && (pair.getPairOp() != PairOperator.SMALLERNEQDOT))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ((pair.getPairOp() == PairOperator.SMALLERNEQDOT) && (pair.getLhsType().equals(pair.getRhsType()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
UnifyType lhsType = pair.getLhsType();
|
UnifyType lhsType = pair.getLhsType();
|
||||||
if(!(lhsType instanceof ReferenceType) && !(lhsType instanceof PlaceholderType))
|
if(!(lhsType instanceof ReferenceType) && !(lhsType instanceof PlaceholderType))
|
||||||
return false;
|
return false;
|
||||||
|
@ -586,8 +586,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
|
|
||||||
protected boolean isUndefinedPairSet(Set<UnifyPair> s) {
|
protected boolean isUndefinedPairSet(Set<UnifyPair> s) {
|
||||||
|
if (s.size() >= 1 ) {
|
||||||
Boolean ret = s.stream().map(x -> x.isUndefinedPair()).reduce(true, (x,y)-> (x && y));
|
Boolean ret = s.stream().map(x -> x.isUndefinedPair()).reduce(true, (x,y)-> (x && y));
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isUndefinedPairSetSet(Set<Set<UnifyPair>> s) {
|
protected boolean isUndefinedPairSetSet(Set<Set<UnifyPair>> s) {
|
||||||
@ -789,10 +794,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
UnifyType rhsType = pair.getRhsType();
|
UnifyType rhsType = pair.getRhsType();
|
||||||
|
|
||||||
// Case 1: (a <. Theta')
|
// Case 1: (a <. Theta')
|
||||||
if(pairOp == PairOperator.SMALLERDOT && lhsType instanceof PlaceholderType) {
|
if (((pairOp == PairOperator.SMALLERDOT) || (pairOp == PairOperator.SMALLERNEQDOT)) && lhsType instanceof PlaceholderType) {
|
||||||
//System.out.println(pair);
|
//System.out.println(pair);
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
||||||
|
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
||||||
|
Set<UnifyType> remElem = new HashSet<>();
|
||||||
|
remElem.add(pair.getRhsType());
|
||||||
|
x1.remove(remElem);
|
||||||
|
}
|
||||||
//System.out.println(x1);
|
//System.out.println(x1);
|
||||||
result.get(0).add(x1);
|
result.get(0).add(x1);
|
||||||
if (x1.isEmpty()) {
|
if (x1.isEmpty()) {
|
||||||
@ -848,10 +858,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// result.get(3).add(unifyCase4((PlaceholderType) lhsType, rhsType, fc));
|
// result.get(3).add(unifyCase4((PlaceholderType) lhsType, rhsType, fc));
|
||||||
|
|
||||||
// Case 5: (Theta <. a)
|
// Case 5: (Theta <. a)
|
||||||
else if(pairOp == PairOperator.SMALLERDOT && rhsType instanceof PlaceholderType)
|
else if (((pairOp == PairOperator.SMALLERDOT) || (pairOp == PairOperator.SMALLERNEQDOT)) && rhsType instanceof PlaceholderType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
|
||||||
result.get(4).add(x1);
|
result.get(4).add(x1);
|
||||||
|
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
||||||
|
Set<UnifyType> remElem = new HashSet<>();
|
||||||
|
remElem.add(pair.getLhsType());
|
||||||
|
x1.remove(remElem);
|
||||||
|
}
|
||||||
if (x1.isEmpty()) {
|
if (x1.isEmpty()) {
|
||||||
undefined.add(pair); //Theta ist nicht im FC
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,12 @@ public enum PairOperator {
|
|||||||
*/
|
*/
|
||||||
SMALLERDOT,
|
SMALLERDOT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The smallernedot operator for arguments (T <!=. P) is the same as SMALLERDOT without
|
||||||
|
* T == P. It is used for operations + / - / * / < / > / ... with the Supertype Number
|
||||||
|
*/
|
||||||
|
SMALLERNEQDOT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The smallerdot operator for arguments (T <.? P) is used to express that
|
* The smallerdot operator for arguments (T <.? P) is used to express that
|
||||||
* T is an element of smArg(P) (or P is an element of grArg(T)) in a CONSTRAINT
|
* T is an element of smArg(P) (or P is an element of grArg(T)) in a CONSTRAINT
|
||||||
@ -35,6 +41,7 @@ public enum PairOperator {
|
|||||||
switch (this) {
|
switch (this) {
|
||||||
case SMALLER: return "<";
|
case SMALLER: return "<";
|
||||||
case SMALLERDOT: return "<.";
|
case SMALLERDOT: return "<.";
|
||||||
|
case SMALLERNEQDOT: return "<!=.";
|
||||||
case SMALLERDOTWC: return "<.?";
|
case SMALLERDOTWC: return "<.?";
|
||||||
default: return "=."; // EQUALSDOT
|
default: return "=."; // EQUALSDOT
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class LambdaTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Lambda2.jav";
|
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Lambda.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
compiler.generateBytecode();
|
compiler.generateBytecode();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
|
import java.lang.Boolean;
|
||||||
|
|
||||||
public class RelOps {
|
public class RelOps {
|
||||||
m(a,b){
|
m(a,b){
|
||||||
|
@ -16,8 +16,8 @@ class Matrix extends Vector<Vector<Integer>> {
|
|||||||
var k = 0;
|
var k = 0;
|
||||||
while(k < v1.size()) {
|
while(k < v1.size()) {
|
||||||
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
||||||
//erg = add1(erg, mul1(v1.elementAt(k),
|
//erg = add1(erg, mul1(v1.elementAt(k),
|
||||||
// m.elementAt(k).elementAt(j)));
|
// m.elementAt(k).elementAt(j)));
|
||||||
k++; }
|
k++; }
|
||||||
v2.addElement(new Integer(erg));
|
v2.addElement(new Integer(erg));
|
||||||
j++; }
|
j++; }
|
||||||
|
Loading…
Reference in New Issue
Block a user