mathStrucInteger.jav funktioniert gerade nicht
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 12m21s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 12m21s
modified: resources/bytecode/javFiles/Matrix.jav modified: src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java modified: src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java modified: src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java modified: src/main/java/de/dhbwstuttgart/syntaxtree/statement/NewClass.java modified: src/main/java/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java modified: src/main/java/de/dhbwstuttgart/syntaxtree/statement/ThisCall.java modified: src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java
This commit is contained in:
parent
df2ec4b1ba
commit
58110c474a
@ -1,3 +1,4 @@
|
||||
import java.util.AbstractList;
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Float;
|
||||
@ -30,8 +31,8 @@ public class Matrix extends Vector<Vector<Integer>> {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m.elementAt(k).elementAt(j);
|
||||
erg = erg + v1.get(k)
|
||||
* m.get(k).get(j);
|
||||
k++; }
|
||||
// v2.addElement(new Integer(erg));
|
||||
v2.addElement(erg);
|
||||
|
@ -279,7 +279,7 @@ public class StatementGenerator {
|
||||
|
||||
if (!Objects.isNull(creator.classCreatorRest())) {
|
||||
ArgumentList args = convertArguments(creator.classCreatorRest().arguments().expressionList());
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(creator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<TypePlaceholder> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(creator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||
argTypes.add(TypePlaceholder.fresh(creator.getStart())); // return type
|
||||
Statement ret = new NewClass(newclass, args, null, argTypes, creator.getStart());
|
||||
ret.setStatement();
|
||||
@ -311,7 +311,7 @@ public class StatementGenerator {
|
||||
IdentifierContext identifier = innercreator.identifier();
|
||||
RefType newclass = (RefType) TypeGenerator.convertTypeName(identifier.getText(), genericArgs, identifier.getStart(), reg, generics);
|
||||
ArgumentList args = convertArguments(innercreator.classCreatorRest().arguments().expressionList());
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(innercreator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<TypePlaceholder> argTypes = args.getArguments().stream().map(x -> TypePlaceholder.fresh(innercreator.getStart())).collect(Collectors.toCollection(ArrayList::new));
|
||||
Statement ret = new NewClass(newclass, args, null, argTypes, innercreator.getStart());
|
||||
ret.setStatement();
|
||||
return ret;
|
||||
@ -712,7 +712,7 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
ArgumentList argumentList = convertArguments(expr.expressionList());
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream().map(x -> (RefTypeOrTPHOrWildcardOrGeneric) TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||
signature.add(TypePlaceholder.fresh(offset)); // return type
|
||||
|
||||
MethodCall ret;
|
||||
@ -737,7 +737,7 @@ public class StatementGenerator {
|
||||
name = expr.SUPER().getText();
|
||||
}
|
||||
ArgumentList argumentList = convertArguments(expr.expressionList());
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream().map(x -> (RefTypeOrTPHOrWildcardOrGeneric) TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||
signature.add(TypePlaceholder.fresh(offset)); // return type
|
||||
MethodCall ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||
ret.setStatement();
|
||||
|
@ -452,8 +452,8 @@ public class SyntaxTreeGenerator {
|
||||
protected static Block prepareBlock(Block constructorBlock, RefType superClass) {
|
||||
List<Statement> statements = constructorBlock.getStatements();
|
||||
if (statements.isEmpty() || !(statements.get(0) instanceof SuperCall || statements.get(0) instanceof ThisCall)) {
|
||||
var signature = new ArrayList<RefTypeOrTPHOrWildcardOrGeneric>();
|
||||
signature.add(new Void(new NullToken()));
|
||||
var signature = new ArrayList<TypePlaceholder>();
|
||||
signature.add(TypePlaceholder.fresh(new NullToken()));
|
||||
statements.add(0, new SuperCall(superClass, signature, constructorBlock.getOffset()));
|
||||
}
|
||||
/* statements.addAll(fieldInitializations); geloescht PL 2018-11-24 */
|
||||
|
@ -27,10 +27,10 @@ public class MethodCall extends Statement
|
||||
public RefTypeOrTPHOrWildcardOrGeneric receiverType;
|
||||
|
||||
//sind Tphs, repraesentieren im Resultset die Signatur der aufgerufenen Methoden, letztes Element ist der Returntyp
|
||||
public final ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature;
|
||||
public final ArrayList<TypePlaceholder> signature;
|
||||
|
||||
public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList,
|
||||
RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature, Token offset){
|
||||
RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<TypePlaceholder> signature, Token offset){
|
||||
super(retType,offset);
|
||||
this.arglist = argumentList;
|
||||
this.name = methodName;
|
||||
@ -40,7 +40,7 @@ public class MethodCall extends Statement
|
||||
if (signature == null) throw new NullPointerException();
|
||||
}
|
||||
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> signatureArguments() {
|
||||
public List<TypePlaceholder> signatureArguments() {
|
||||
return signature.subList(0, signature.size() - 1);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
@ -30,9 +31,9 @@ public class NewClass extends MethodCall
|
||||
* @param start
|
||||
*/
|
||||
public NewClass(RefType newClass, ArgumentList args, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token start) {
|
||||
ArrayList<TypePlaceholder> signature, Token start) {
|
||||
super(newClass, new ExpressionReceiver(new EmptyStmt(start)), newClass.getName().toString(),
|
||||
args, receiverType, argTypes, start);
|
||||
args, receiverType, signature, start);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
@ -16,12 +17,12 @@ import java.util.List;
|
||||
public class SuperCall extends MethodCall
|
||||
{
|
||||
public SuperCall(RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset){
|
||||
ArrayList<TypePlaceholder> argTypes, Token offset){
|
||||
this(new ArgumentList(new ArrayList<Expression>(), offset), receiverType, argTypes, offset);
|
||||
}
|
||||
|
||||
public SuperCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
||||
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset){
|
||||
ArrayList<TypePlaceholder> argTypes, Token offset){
|
||||
super(new Void(offset), new ExpressionReceiver(new Super(receiverType, offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
@ -11,7 +12,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class ThisCall extends MethodCall
|
||||
{
|
||||
public ThisCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset) {
|
||||
public ThisCall(ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<TypePlaceholder> argTypes, Token offset) {
|
||||
super(new Void(offset), new ExpressionReceiver(new This(offset)), "<init>", argumentList, receiverType, argTypes, offset);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,8 @@ public class Constraint<A> extends HashSet<A> {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString() + "\nisInherited = " + isInherited
|
||||
return super.toString() + "\nisInherited = " + isInherited
|
||||
+ methodSignatureConstraint
|
||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||
+ "\n" ;
|
||||
}
|
||||
|
@ -253,13 +253,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
one = true;
|
||||
Set<UnifyPair> neweq = new HashSet<>(eq);
|
||||
/* 1-elementige Oder-Constraints werden in und-Constraints umgewandelt */
|
||||
Set<UnifyPair> methodSignatureConstraint = new HashSet<>();
|
||||
oderConstraintsField.stream()
|
||||
.filter(x -> x.size()==1)
|
||||
.map(y -> y.stream().findFirst().get()).forEach(x -> neweq.addAll(x));
|
||||
.map(y -> y.stream().findFirst().get()).forEach(x -> { neweq.addAll(x); methodSignatureConstraint.addAll(x.getmethodSignatureConstraint());} );
|
||||
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
||||
.filter(x -> x.size()>1)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, methodSignatureConstraint);
|
||||
noOfThread--;
|
||||
try {
|
||||
logFile.close();
|
||||
|
@ -36,6 +36,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||
import de.dhbwstuttgart.util.Pair;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.apache.commons.io.output.NullWriter;
|
||||
|
||||
/**
|
||||
* The finite closure for the type unification
|
||||
@ -140,6 +141,10 @@ implements IFiniteClosure {
|
||||
}
|
||||
}
|
||||
|
||||
public FiniteClosure(Set<UnifyPair> constraints, Writer writer) {
|
||||
this(constraints, writer, null);
|
||||
}
|
||||
|
||||
void testSmaller() {
|
||||
UnifyType tq1, tq2, tq3;
|
||||
tq1 = new ExtendsType(PlaceholderType.freshPlaceholder());
|
||||
|
@ -34,6 +34,12 @@ public class ReferenceType extends UnifyType {
|
||||
this.genericTypeVar = genericTypeVar;
|
||||
}
|
||||
|
||||
public ReferenceType(String name, UnifyType... params) {
|
||||
super(name, new TypeParams(params));
|
||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||
genericTypeVar = false;
|
||||
}
|
||||
|
||||
public ReferenceType(String name, TypeParams params) {
|
||||
super(name, params);
|
||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||
|
Loading…
Reference in New Issue
Block a user