forked from JavaTX/JavaCompilerCore
Compare commits
6 Commits
9ec4d59f24
...
targetByte
Author | SHA1 | Date | |
---|---|---|---|
|
6247416e6c | ||
|
514a504f0f | ||
|
e9722e595c | ||
|
cb7c81c41b | ||
|
51b676a98a | ||
|
18728712d3 |
BIN
JavaTXcompiler-2.0-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.0-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
JavaTXcompiler-2.1-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.1-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
JavaTXcompiler-2.2-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.2-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
JavaTXcompiler-2.3-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.3-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
JavaTXcompiler-2.4-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.4-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
JavaTXcompiler-2.5-jar-with-dependencies.jar
Normal file
BIN
JavaTXcompiler-2.5-jar-with-dependencies.jar
Normal file
Binary file not shown.
25
compile.sh
25
compile.sh
@@ -3,7 +3,7 @@
|
||||
SRCDIR="javatx-src/main/java"
|
||||
DESTDIR="out"
|
||||
JAVAC_FLAGS="-g:none -nowarn"
|
||||
JAVATX_COMPILER_PATH="JavaTXcompiler-1.9-jar-with-dependencies.jar"
|
||||
JAVATX_COMPILER_PATH="JavaTXcompiler-2.5-jar-with-dependencies.jar"
|
||||
|
||||
#remove all files, if the script is called with parameter "clear"
|
||||
if [ "$1" = "clean" ]; then
|
||||
@@ -11,10 +11,19 @@ if [ "$1" = "clean" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#find all .java/.jav files recursively and store them in an array
|
||||
if [ "$1" != "" ]; then
|
||||
echo "invalid argument: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#find all .java/.jav files and store paths in an array
|
||||
#note: somehow absolute paths don't work correctly with find -newer
|
||||
#JAVA_FILES=($(find "$SRCDIR" -name "*.java" -exec realpath {} \;))
|
||||
#JAV_FILES=($(find "$SRCDIR" -name "*.jav" -exec realpath {} \;))
|
||||
JAVA_FILES=($(find "$SRCDIR" -name "*.java"))
|
||||
JAV_FILES=($(find "$SRCDIR" -name "*.jav"))
|
||||
|
||||
|
||||
#create empty arrays for .class file paths
|
||||
JAVA_CLASSES=()
|
||||
JAV_CLASSES=()
|
||||
@@ -51,10 +60,15 @@ for file in "${JAV_FILES[@]}"; do
|
||||
done
|
||||
|
||||
|
||||
#if [ "${#JAV_CHANGED[@]}" -ne 0 ]; then
|
||||
# echo "java -jar $JAVATX_COMPILER_PATH -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/" ${JAV_CHANGED[@]}"
|
||||
# java -jar $JAVATX_COMPILER_PATH -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/" "${JAV_CHANGED[@]}"
|
||||
#fi
|
||||
|
||||
if [ "${#JAV_CHANGED[@]}" -ne 0 ]; then
|
||||
for ((i = 0; i < "${#JAV_CHANGED[@]}"; i++)); do
|
||||
echo "java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" ${JAV_CHANGED[i]}"
|
||||
java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" "${JAV_CHANGED[i]}"
|
||||
echo "java -jar $(realpath $JAVATX_COMPILER_PATH) -d $(realpath "$DESTDIR") -cp "$(realpath $SRCDIR):$(realpath $DESTDIR):$(realpath "target/dependencies/")" ${JAV_CHANGED[i]}"
|
||||
java -jar $JAVATX_COMPILER_PATH -d "$DESTDIR" -cp "$SRCDIR:$DESTDIR:target/dependencies/" "${JAV_CHANGED[i]}"
|
||||
if [ $? -eq 1 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
@@ -65,6 +79,3 @@ if [ "${#JAVA_CHANGED[@]}" -ne 0 ]; then
|
||||
echo "javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JAVAC_FLAGS ${JAVA_CHANGED[@]}"
|
||||
javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JAVAC_FLAGS "${JAVA_CHANGED[@]}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,209 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
//import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
|
||||
/**
|
||||
* Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
|
||||
*/
|
||||
public class ClassOrInterface extends SyntaxTreeNode implements TypeScope {
|
||||
private Boolean methodAdded = false; // wird benoetigt bei in JavaTXCompiler.getConstraints()
|
||||
protected int modifiers;
|
||||
protected JavaClassName name;
|
||||
private final String fileName;
|
||||
|
||||
private List<Field> fields = new ArrayList<>();
|
||||
private Optional<Constructor> fieldInitializations; // PL 2018-11-24: Noetig, um Bytecode fuer initializators nur einmal zu erzeugen
|
||||
private Optional<Method> staticInitializer;
|
||||
private List<Method> methods = new ArrayList<>();
|
||||
private GenericDeclarationList genericClassParameters;
|
||||
private RefType superClass;
|
||||
protected boolean isInterface;
|
||||
protected boolean isFunctionalInterface;
|
||||
private List<RefType> implementedInterfaces;
|
||||
private List<RefType> permittedSubtypes;
|
||||
private List<Constructor> constructors;
|
||||
|
||||
public ClassOrInterface(modifiers, name, fielddecl, fieldInitializations, staticInitializer, methods, constructors, genericClassParameters, superClass, isInterface, isFunctionalInterface, implementedInterfaces, permittedSubtypes, offset, fileName) {
|
||||
super(offset);
|
||||
if (isInterface) {
|
||||
modifiers = modifiers | Modifier.INTERFACE | Modifier.ABSTRACT;
|
||||
}
|
||||
this.modifiers = modifiers;
|
||||
this.name = name;
|
||||
this.fields = fielddecl;
|
||||
this.fieldInitializations = fieldInitializations;
|
||||
this.staticInitializer = staticInitializer;
|
||||
this.genericClassParameters = genericClassParameters;
|
||||
this.superClass = superClass;
|
||||
this.isInterface = isInterface;
|
||||
this.isFunctionalInterface= isFunctionalInterface;
|
||||
this.implementedInterfaces = implementedInterfaces;
|
||||
this.permittedSubtypes = permittedSubtypes;
|
||||
this.methods = methods;
|
||||
this.constructors = constructors;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* erzeugt fuer Fields, Konstruktoren und Methoden neue ArrayList-Objekte alle anderen Datenobjekte werden nur kopiert.
|
||||
*/
|
||||
public ClassOrInterface(cl) {
|
||||
super(cl.getOffset());
|
||||
this.modifiers = cl.modifiers;
|
||||
this.name = cl.name;
|
||||
this.fields = new ArrayList<>(cl.fields);
|
||||
this.fieldInitializations = cl.fieldInitializations;
|
||||
this.staticInitializer = cl.staticInitializer;
|
||||
this.genericClassParameters = cl.genericClassParameters;
|
||||
this.superClass = cl.superClass;
|
||||
this.isInterface = cl.isInterface;
|
||||
this.isFunctionalInterface= cl.isFunctionalInterface;
|
||||
this.implementedInterfaces = cl.implementedInterfaces;
|
||||
this.methods = new ArrayList<>(cl.methods);
|
||||
this.constructors = new ArrayList<>(cl.constructors);
|
||||
this.fileName = cl.fileName;
|
||||
}
|
||||
|
||||
public getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public getField(name) {
|
||||
// TODO This should be a map
|
||||
return fields.stream().filter(field -> field.getName().equals(name)).findFirst();
|
||||
}
|
||||
|
||||
public getStaticInitializer() {
|
||||
return staticInitializer;
|
||||
}
|
||||
|
||||
public isInterface() {
|
||||
return (Modifier.INTERFACE & this.getModifiers()) != 0;
|
||||
}
|
||||
|
||||
public isFunctionalInterface() {
|
||||
return this.isFunctionalInterface;
|
||||
}
|
||||
|
||||
// Gets if it is added
|
||||
public areMethodsAdded() {
|
||||
return methodAdded;
|
||||
}
|
||||
|
||||
// Sets that it is added
|
||||
public setMethodsAdded() {
|
||||
methodAdded = true;
|
||||
}
|
||||
|
||||
// Gets class name
|
||||
public getClassName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
// Get modifiers
|
||||
public getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
public getFieldDecl() {
|
||||
return this.fields;
|
||||
}
|
||||
|
||||
public getfieldInitializations() {
|
||||
return this.fieldInitializations;
|
||||
}
|
||||
|
||||
public getMethods() {
|
||||
return this.methods;
|
||||
}
|
||||
|
||||
/*
|
||||
* public RefType getType() { return generateTypeOfClass(this.getClassName(), this.getGenerics(), this.getOffset()); }
|
||||
*/
|
||||
// TODO: Das hier ist ein Problem. Je nach Kontext wird hier ein anderer Typ benötigt
|
||||
public static generateTypeOfClass(name, genericsOfClass, offset) {
|
||||
// Hier wird immer ein generischer Typ generiert, also mit Type placeholdern
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for (GenericTypeVar genericTypeVar : genericsOfClass) {
|
||||
// params.add(genericTypeVar.getTypePlaceholder());
|
||||
params.add(TypePlaceholder.fresh(offset));
|
||||
}
|
||||
return new RefType(name, params, offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return die aktuelle Klasse als RefType
|
||||
*/
|
||||
public generateTypeOfThisClass() {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for (GenericTypeVar genericTypeVar : this.getGenerics()) {
|
||||
// params.add(genericTypeVar.getTypePlaceholder());
|
||||
params.add(new GenericRefType(genericTypeVar.getName(), new NullToken()));
|
||||
}
|
||||
return new RefType(name, params, new NullToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Superklasse im Kontext dieser ClassOrInterface Das bedeutet, dass generische Variablen als GenericRefTypes dargestellt sind
|
||||
*/
|
||||
public getSuperClass() {
|
||||
return superClass;
|
||||
}
|
||||
|
||||
public getGenerics() {
|
||||
return this.genericClassParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public getReturnType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getConstructors() {
|
||||
return constructors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public accept(visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
public getSuperInterfaces() {
|
||||
return implementedInterfaces;
|
||||
}
|
||||
|
||||
public toString() {
|
||||
return this.name.toString() + this.genericClassParameters.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -14,14 +14,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
|
||||
/**
|
||||
* Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
|
||||
*/
|
||||
@@ -46,7 +38,7 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope {
|
||||
public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, Optional<Constructor> fieldInitializations, Optional<Method> staticInitializer, List<Method> methods, List<Constructor> constructors, GenericDeclarationList genericClassParameters, RefType superClass, Boolean isInterface, Boolean isFunctionalInterface, List<RefType> implementedInterfaces, List<RefType> permittedSubtypes, Token offset, String fileName) {
|
||||
super(offset);
|
||||
if (isInterface) {
|
||||
modifiers = modifiers | Modifier.INTERFACE | Modifier.ABSTRACT;
|
||||
modifiers |= Modifier.INTERFACE | Modifier.ABSTRACT;
|
||||
}
|
||||
this.modifiers = modifiers;
|
||||
this.name = name;
|
||||
@@ -90,8 +82,7 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope {
|
||||
|
||||
public Optional<Field> getField(String name) {
|
||||
// TODO This should be a map
|
||||
Predicate<Field> func = field -> field.getName().equals(name);
|
||||
return fields.stream().filter(func).findFirst();
|
||||
return fields.stream().filter(field -> field.getName().equals(name)).findFirst();
|
||||
}
|
||||
|
||||
public Optional<Method> getStaticInitializer() {
|
||||
@@ -137,7 +128,6 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope {
|
||||
public List<Method> getMethods() {
|
||||
return this.methods;
|
||||
}
|
||||
|
||||
/*
|
||||
* public RefType getType() { return generateTypeOfClass(this.getClassName(), this.getGenerics(), this.getOffset()); }
|
||||
*/
|
||||
|
@@ -3,8 +3,18 @@ package de.dhbwstuttgart.syntaxtree;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import java.lang.Iterable;
|
||||
import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//TODO: curretly types are needed, or else wrong bytecode type in visitor.accept -> runtime crash, figure out why
|
||||
|
||||
public class Field extends SyntaxTreeNode implements TypeScope {
|
||||
|
||||
public final int modifier;
|
@@ -1,8 +1,9 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.lang.Iterable;
|
||||
|
||||
|
||||
public interface TypeScope {
|
||||
|
@@ -17,6 +17,37 @@ import java.util.List;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
|
||||
//imports of jav imports
|
||||
import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import javax.swing.text.html.Option;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class FieldAssumption extends Assumption{
|
||||
private ClassOrInterface receiverClass;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric type;
|
||||
@@ -37,7 +68,8 @@ public class FieldAssumption extends Assumption{
|
||||
return resolver.resolve(type);
|
||||
}
|
||||
|
||||
public getReceiverType(resolver) {
|
||||
//Hier inferiert Java-TX RefType, obwohl RefTypeOrTPHOrWildcardOrGeneric genereller sein sollte
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(resolver) {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for(gtv : receiverClass.getGenerics()){
|
||||
//Hier wird ein GenericRefType gebildet, welcher einen für dieses Feld eindeutigen Namen hat
|
||||
|
@@ -27,11 +27,13 @@ import java.util.Objects;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Iterable;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class FunNClass extends ClassOrInterface {
|
||||
public FunNClass(funNParams) {
|
||||
super(0, new JavaClassName("Fun" + (funNParams.size() - 1).toString()), new ArrayList<>(), Optional.empty(), Optional.empty() /* eingefuegt PL 2018-11-24 */, createMethods(funNParams), new ArrayList<>(), createGenerics(funNParams), ASTFactory.createObjectType(), true, false, new ArrayList<>(), new ArrayList<>(), new NullToken(), null);
|
||||
|
||||
}
|
||||
|
||||
private static createGenerics(funNParams) {
|
||||
|
@@ -18,6 +18,37 @@ import java.util.List;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
|
||||
//imports of jav imports
|
||||
import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import javax.swing.text.html.Option;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class MethodAssumption extends Assumption{
|
||||
private ClassOrInterface receiver;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric retType;
|
||||
@@ -39,25 +70,25 @@ public class MethodAssumption extends Assumption{
|
||||
}
|
||||
*/
|
||||
|
||||
public ClassOrInterface getReceiver(){
|
||||
public getReceiver(){
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
||||
public getReturnType() {
|
||||
return retType;
|
||||
}
|
||||
|
||||
public List<? extends RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(){
|
||||
public getArgTypes(){
|
||||
return params;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType(GenericsResolver resolver) {
|
||||
public getReturnType(resolver) {
|
||||
return resolver.resolve(retType);
|
||||
}
|
||||
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(GenericsResolver resolver) {
|
||||
public getArgTypes(resolver) {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : params){
|
||||
for(param : params){
|
||||
param = resolver.resolve(param);
|
||||
ret.add(param);
|
||||
}
|
||||
@@ -69,14 +100,15 @@ public class MethodAssumption extends Assumption{
|
||||
* @param resolver
|
||||
* @return
|
||||
*/
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(GenericsResolver resolver) {
|
||||
public getReceiverType(resolver) {
|
||||
if (receiver == null) return null;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
for(GenericTypeVar gtv : receiver.getGenerics()){
|
||||
for(gtv : receiver.getGenerics()){
|
||||
//Die Generics werden alle zu TPHs umgewandelt.
|
||||
params.add(resolver.resolve(new GenericRefType(gtv.getName(), new NullToken())));
|
||||
}
|
||||
RefTypeOrTPHOrWildcardOrGeneric receiverType;
|
||||
|
||||
if(receiver instanceof FunNClass){
|
||||
receiverType = new RefType(new JavaClassName(receiver.getClassName().toString()+"$$"), params, new NullToken()); // new FunN(params);
|
||||
}else{
|
||||
@@ -86,7 +118,7 @@ public class MethodAssumption extends Assumption{
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
public Boolean isInherited() {
|
||||
public isInherited() {
|
||||
return isInherited;
|
||||
}
|
||||
}
|
||||
|
@@ -24,8 +24,7 @@ public class TypeInferenceBlockInformation extends TypeInferenceInformation {
|
||||
private TypeScope methodContext;
|
||||
private ClassOrInterface currentClass;
|
||||
|
||||
public TypeInferenceBlockInformation(Collection<ClassOrInterface> availableClasses,
|
||||
ClassOrInterface currentClass, TypeScope methodContext) {
|
||||
public TypeInferenceBlockInformation(Collection<ClassOrInterface> availableClasses, ClassOrInterface currentClass, TypeScope methodContext) {
|
||||
super(availableClasses);
|
||||
this.methodContext = new TypeScopeContainer(currentClass, methodContext);
|
||||
this.currentClass = currentClass;
|
||||
@@ -34,10 +33,10 @@ public class TypeInferenceBlockInformation extends TypeInferenceInformation {
|
||||
public TypeInferenceBlockInformation(TypeInferenceBlockInformation oldScope, TypeScope newScope) {
|
||||
this(oldScope.getAvailableClasses(), oldScope.currentClass, new TypeScopeContainer(oldScope.methodContext, newScope));
|
||||
}
|
||||
public ClassOrInterface getCurrentClass() {
|
||||
public getCurrentClass() {
|
||||
return currentClass;
|
||||
}
|
||||
public TypeScope getCurrentTypeScope() {
|
||||
public getCurrentTypeScope() {
|
||||
return methodContext;
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
//TODO: Somehow this file is not compiling with javatx
|
||||
|
||||
package de.dhbwstuttgart.typeinference.assumptions;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
@@ -18,7 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
/*
|
||||
Anmerkung:
|
||||
@@ -49,9 +51,8 @@ public class TypeInferenceInformation {
|
||||
public List<FieldAssumption> getFields(String name){
|
||||
List<FieldAssumption> ret = new ArrayList<>();
|
||||
for(ClassOrInterface cl : classes){
|
||||
for(Field m : cl.getFieldDecl()){
|
||||
for(var m : cl.getFieldDecl()){
|
||||
if(m.getName().equals(name)){
|
||||
|
||||
ret.add(new FieldAssumption(name, cl, m.getType(), new TypeScopeContainer(cl, m)));
|
||||
}
|
||||
}
|
||||
|
@@ -27,47 +27,47 @@ public class Constraint<A> extends HashSet<A> {
|
||||
super();
|
||||
}
|
||||
|
||||
public Constraint(Boolean isInherited) {
|
||||
public Constraint(isInherited) {
|
||||
this.isInherited = isInherited;
|
||||
}
|
||||
|
||||
public Constraint(Boolean isInherited, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||
public Constraint(isInherited, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||
this.isInherited = isInherited;
|
||||
this.extendConstraint = extendConstraint;
|
||||
this.methodSignatureConstraint = methodSignatureConstraint;
|
||||
}
|
||||
|
||||
public void setIsInherited(Boolean isInherited) {
|
||||
public setIsInherited(isInherited) {
|
||||
this.isInherited = isInherited;
|
||||
}
|
||||
|
||||
public Boolean isInherited() {
|
||||
public isInherited() {
|
||||
return isInherited;
|
||||
}
|
||||
|
||||
public Constraint<A> getExtendConstraint() {
|
||||
public getExtendConstraint() {
|
||||
return extendConstraint;
|
||||
}
|
||||
|
||||
public void setExtendConstraint(Constraint<A> c) {
|
||||
public setExtendConstraint(c) {
|
||||
extendConstraint = c;
|
||||
}
|
||||
|
||||
public Set<A> getmethodSignatureConstraint() {
|
||||
public getmethodSignatureConstraint() {
|
||||
return methodSignatureConstraint;
|
||||
}
|
||||
|
||||
public void setmethodSignatureConstraint(Set<A> c) {
|
||||
public setmethodSignatureConstraint(c) {
|
||||
methodSignatureConstraint = c;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
public toString() {
|
||||
return super.toString() + "\nisInherited = " + isInherited.toString()
|
||||
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||
+ "\n" ;
|
||||
}
|
||||
|
||||
public String toStringBase() {
|
||||
public toStringBase() {
|
||||
return super.toString();
|
||||
}
|
||||
|
2
makefile
2
makefile
@@ -6,7 +6,7 @@ JTX = JavaTXcompiler-1.0-jar-with-dependencies.jar
|
||||
SRCDIR = javatx-src/main/java
|
||||
DESTDIR = out
|
||||
|
||||
# Use find to locate all .java files recursively
|
||||
# Use find to locate all .java and .jav files recursively
|
||||
JAVASOURCES := $(shell find $(SRCDIR) -name '*.java')
|
||||
JAVSOURCES := $(shell find $(SRCDIR) -name '*.jav')
|
||||
|
||||
|
Reference in New Issue
Block a user