replace makefile (which never worked very well) with custom bash script to generate class files and rollback some migrations to .jav which broke code

This commit is contained in:
julian 2024-03-15 19:59:58 +01:00
parent 427e568ff8
commit 2b767f1f4f
3 changed files with 73 additions and 21 deletions

59
compile.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
SRCDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/javatx-src/main/java"
DESTDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/out"
JAVAC_FLAGS="-g:none -nowarn"
JAVATX_COMPILER_PATH="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/JavaTXcompiler-1.1-jar-with-dependencies.jar"
#remove all files, if the script is called with parameter "clear"
if [ "$1" = "clear" ]; then
rm -r "$DESTDIR"
exit 0
fi
#find all .java/.jav files recursively and store them i an array
JAVA_FILES=($(find "$SRCDIR" -name "*.java"))
JAV_FILES=($(find "$SRCDIR" -name "*.jav"))
#create empty arrays for .class file paths
JAVA_CLASSES=()
JAV_CLASSES=()
JAVA_CHANGED=()
JAV_CHANGED=()
mkdir -p $DESTDIR
#fill class files arrays by subsituting .java/.jav -> .class for each file
for file in "${JAVA_FILES[@]}"; do
class_name="$DESTDIR${file#$SRCDIR}"
class_name="${class_name%.java}.class"
if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then
JAVA_CHANGED+=("$file")
JAVA_CLASSES+=("$class_name")
fi
done
for file in "${JAV_FILES[@]}"; do
class_name="$DESTDIR${file#$SRCDIR}"
class_name="${class_name%.jav}.class"
if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then
JAV_CHANGED+=("$file")
JAV_CLASSES+=("$class_name")
fi
done
if [ "${#JAV_CHANGED[@]}" -ne 0 ]; then
for ((i = 0; i < "${#JAV_CHANGED[@]}"; i++)); do
java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" ${JAV_CHANGED[i]}
done
fi
if [ "${#JAVA_CHANGED[@]}" -ne 0 ]; then
javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JFLAGS ${JAVA_CHANGED[@]}
fi

View File

@ -3,8 +3,11 @@ package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
import de.dhbwstuttgart.syntaxtree.type.TypeVisitor;
import org.antlr.v4.runtime.Token;
import java.lang.Object;
public abstract class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{
public RefTypeOrTPHOrWildcardOrGeneric(Token offset) {
super(offset);

View File

@ -10,16 +10,9 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.constraints.GenericsResolver;
import de.dhbwstuttgart.typeinference.assumptions.Assumption;
import de.dhbwstuttgart.typeinference.assumptions.FunNClass;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
import java.util.Optional;
import java.util.ArrayList;
import java.util.List;
import java.lang.Integer;
import java.lang.String;
import java.lang.Boolean;
public class MethodAssumption extends Assumption{
private ClassOrInterface receiver;
@ -27,7 +20,8 @@ public class MethodAssumption extends Assumption{
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params;
private final Boolean isInherited;
public MethodAssumption(receiver, retType, params, scope, isInherited){
public MethodAssumption(ClassOrInterface receiver, RefTypeOrTPHOrWildcardOrGeneric retType,
List<? extends RefTypeOrTPHOrWildcardOrGeneric> params, TypeScope scope, Boolean isInherited){
super(scope);
this.receiver = receiver;
this.retType = retType;
@ -42,31 +36,28 @@ public class MethodAssumption extends Assumption{
}
*/
public getReceiver(){
public ClassOrInterface getReceiver(){
return receiver;
}
public getReturnType() {
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return retType;
}
public getArgTypes(){
public List<? extends RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(){
return params;
}
public getReturnType(resolver) {
public RefTypeOrTPHOrWildcardOrGeneric getReturnType(GenericsResolver resolver) {
return resolver.resolve(retType);
}
public getArgTypes(resolver) {
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgTypes(GenericsResolver resolver) {
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
for(param : this.params){
for(RefTypeOrTPHOrWildcardOrGeneric param : params){
param = resolver.resolve(param);
ret.add(param);
}
return ret;
}
@ -75,11 +66,10 @@ public class MethodAssumption extends Assumption{
* @param resolver
* @return
*/
public getReceiverType(resolver) {
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(GenericsResolver resolver) {
if (receiver == null) return null;
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
for(gtv : receiver.getGenerics()){
for(GenericTypeVar gtv : receiver.getGenerics()){
//Die Generics werden alle zu TPHs umgewandelt.
params.add(resolver.resolve(new GenericRefType(gtv.getName(), new NullToken())));
}
@ -93,7 +83,7 @@ public class MethodAssumption extends Assumption{
return receiverType;
}
public isInherited() {
public Boolean isInherited() {
return isInherited;
}
}