Compare commits
15 Commits
targetByte
...
bigCleanup
Author | SHA1 | Date | |
---|---|---|---|
|
c8a31a6063 | ||
|
5c60918c47 | ||
|
a0367d5464 | ||
|
722d897d4b | ||
|
e2d76d314a | ||
|
cd5fbac987 | ||
|
67df9aa262 | ||
|
5b970f9359 | ||
|
1b5eacf921 | ||
|
a35e69f878 | ||
|
643f7c0220 | ||
|
24f1b507c4 | ||
|
a4cc4cc357 | ||
|
e80e2db26c | ||
|
4c0fb34c00 |
1
pom.xml
1
pom.xml
@ -124,6 +124,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -1,37 +0,0 @@
|
||||
grammar UnifyResult;
|
||||
|
||||
answer : 'ANSWER' (resultSetRule '.')*;
|
||||
|
||||
resultSetRule :
|
||||
parameter
|
||||
| equals
|
||||
| smaller
|
||||
| typeVar
|
||||
| type
|
||||
| otherRule
|
||||
;
|
||||
|
||||
parameterList : '(' value (',' value)* ')';
|
||||
value : NAME
|
||||
| resultSetRule ;
|
||||
|
||||
parameter : PARAMLIST_NAME parameterList;
|
||||
equals : EQUALS_NAME parameterList;
|
||||
smaller : SMALLER_NAME parameterList;
|
||||
typeVar : TYPEVAR_NAME parameterList;
|
||||
type : TYPE_NAME parameterList;
|
||||
otherRule : NAME parameterList;
|
||||
|
||||
//TODO: Es sollte Regeln für das Result set geben, welche sich nicht mit den anderen überdecken, dann auch nur diese im Result ausgeben
|
||||
PARAMLIST_NAME : 'param';
|
||||
EQUALS_NAME : 'equals';
|
||||
SMALLER_NAME : 'smaller';
|
||||
TYPEVAR_NAME : 'typeVar';
|
||||
TYPE_NAME : 'type';
|
||||
NAME : [a-zA-Z0-9_]+;
|
||||
|
||||
WS : [ \t\r\n\u000C]+ -> skip
|
||||
;
|
||||
LINE_COMMENT
|
||||
: '%' ~[\r\n]* -> skip
|
||||
;
|
@ -1,23 +0,0 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
PARAMLIST_NAME=6
|
||||
EQUALS_NAME=7
|
||||
SMALLER_NAME=8
|
||||
TYPEVAR_NAME=9
|
||||
TYPE_NAME=10
|
||||
NAME=11
|
||||
WS=12
|
||||
LINE_COMMENT=13
|
||||
'ANSWER'=1
|
||||
'.'=2
|
||||
'('=3
|
||||
','=4
|
||||
')'=5
|
||||
'param'=6
|
||||
'equals'=7
|
||||
'smaller'=8
|
||||
'typeVar'=9
|
||||
'type'=10
|
@ -1,23 +0,0 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
PARAMLIST_NAME=6
|
||||
EQUALS_NAME=7
|
||||
SMALLER_NAME=8
|
||||
TYPEVAR_NAME=9
|
||||
TYPE_NAME=10
|
||||
NAME=11
|
||||
WS=12
|
||||
LINE_COMMENT=13
|
||||
'ANSWER'=1
|
||||
'.'=2
|
||||
'('=3
|
||||
','=4
|
||||
')'=5
|
||||
'param'=6
|
||||
'equals'=7
|
||||
'smaller'=8
|
||||
'typeVar'=9
|
||||
'type'=10
|
@ -45,6 +45,8 @@ public class TypeToDescriptor implements TypeVisitor<String>{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//ToDo Etienne: bin der Meinung hier müsste immer der Descriptor der extends-Schranke sein, z.b. <T> => Ljava/lang/Object; oder <T extends String> => Ljava/lang/String;
|
||||
//Tests sind aber damit grün?! => Fehler in Tests schon vorher aufgefallen und gut möglich!
|
||||
@Override
|
||||
public String visit(GenericRefType genericRefType) {
|
||||
return genericRefType.getParsedName().replace(".", "/");
|
||||
|
@ -12,27 +12,30 @@ import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
* //ToDo beschreiben
|
||||
* Represents a Singleton-Service implementation for the {@link FunNUtilities} interface.
|
||||
*
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
*/
|
||||
public class FunNGenerator implements FunNUtilities{
|
||||
public final class FunNGenerator implements FunNUtilities{
|
||||
|
||||
private static FunNGenerator funNGenerator = new FunNGenerator();
|
||||
private static final FunNGenerator funNGenerator = new FunNGenerator();
|
||||
|
||||
public static FunNGenerator getInstance(){
|
||||
return funNGenerator;
|
||||
}
|
||||
/**
|
||||
* @return the Singleton instance for {@link FunNGenerator}
|
||||
*/
|
||||
public static FunNUtilities getInstance(){ return funNGenerator; }
|
||||
|
||||
private final String argumentGenericBase = "T";
|
||||
private final String returnGeneric = "R";
|
||||
@ -43,9 +46,7 @@ public class FunNGenerator implements FunNUtilities{
|
||||
private final RefType objectRefType = new RefType(new JavaClassName(objectSuperType), null);
|
||||
private final String objectSignature = applySignature(objectRefType);
|
||||
|
||||
private String applyDescriptor(RefTypeOrTPHOrWildcardOrGeneric a) { return a.acceptTV(new TypeToDescriptor(true)); }
|
||||
private String applySignature(RefTypeOrTPHOrWildcardOrGeneric a) { return a.acceptTV(new TypeToSignature(true)); }
|
||||
private String applyNameDescriptor(RefTypeOrTPHOrWildcardOrGeneric a){ return a instanceof TypePlaceholder ? "LTPH;" : String.format("L%s;", applyDescriptor(a)); }
|
||||
private FunNGenerator(){}
|
||||
|
||||
@Override
|
||||
public byte[] generateSuperBytecode(int numberArguments) {
|
||||
@ -55,11 +56,11 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
for (int currentParameter = 1; currentParameter <= numberArguments; currentParameter++){
|
||||
superFunNClassSignature.append(String.format("%s%d:%s",argumentGenericBase, currentParameter, objectSignature));
|
||||
superFunNMethodSignature.append(String.format("T%s;", applySignature( new GenericRefType(argumentGenericBase + currentParameter, null))));
|
||||
superFunNMethodSignature.append(applySignature( new GenericRefType(argumentGenericBase + currentParameter, null)));
|
||||
superFunNMethodDescriptor.append(objectSignature);
|
||||
}
|
||||
superFunNClassSignature.append(String.format("%s:%s>%s", returnGeneric, objectSignature, objectSignature));
|
||||
superFunNMethodSignature.append(String.format(")T%s;", applySignature(new GenericRefType(returnGeneric, null))));
|
||||
superFunNMethodSignature.append(String.format(")%s", applySignature(new GenericRefType(returnGeneric, null))));
|
||||
superFunNMethodDescriptor.append(String.format(")%s", objectSignature));
|
||||
|
||||
ClassWriter classWriter = new ClassWriter(0);
|
||||
@ -78,8 +79,12 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
@Override
|
||||
public byte[] generateSpecializedBytecode(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||
Objects.requireNonNull(argumentTypes);
|
||||
Objects.requireNonNull(returnType);
|
||||
//generates a list of all params and substitutes the TPH
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> parameters = Stream
|
||||
.concat(argumentTypes.stream(), Stream.of(returnType))
|
||||
.map(this::substituteTPH)
|
||||
.collect(Collectors.toList());
|
||||
RefType superFunN = new RefType(new JavaClassName(getSuperClassName(argumentTypes.size())), parameters , null);
|
||||
StringBuilder funNClassSignature = new StringBuilder(objectSignature + (superFunN.acceptTV(new TypeToSignature(false))));
|
||||
@ -87,16 +92,11 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
String genericSignature = "<";
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric typeArgument : parameters) {
|
||||
//ToDo Etienne: Refactor
|
||||
if (typeArgument instanceof GenericRefType){
|
||||
GenericRefType generic = (GenericRefType) typeArgument;
|
||||
if(genericSignature.contains(generic.getParsedName())) continue;
|
||||
genericSignature += String.format("%s:%s", generic.getParsedName(), applyDescriptor(generic));
|
||||
containsGeneric = true;
|
||||
} else if(typeArgument instanceof TypePlaceholder){
|
||||
TypePlaceholder placeholder = (TypePlaceholder) typeArgument;
|
||||
if(genericSignature.contains(applySignature(placeholder).substring(1))) continue;
|
||||
genericSignature += String.format("%s:%s", applySignature(placeholder).substring(1), objectSignature);
|
||||
String signatureOfArgument = generic.getParsedName();
|
||||
if(genericSignature.contains(signatureOfArgument)) continue;
|
||||
genericSignature += String.format("%s:%s", signatureOfArgument, objectSignature);
|
||||
containsGeneric = true;
|
||||
}
|
||||
}
|
||||
@ -111,6 +111,8 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
@Override
|
||||
public String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||
Objects.requireNonNull(argumentTypes);
|
||||
Objects.requireNonNull(returnType);
|
||||
return String.format("Fun%d$$%s%s",
|
||||
argumentTypes.size(),
|
||||
argumentTypes
|
||||
@ -124,16 +126,21 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
@Override
|
||||
public String getSpecializedDescriptor(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||
return applyDescriptor(new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)), null));
|
||||
Objects.requireNonNull(argumentTypes);
|
||||
Objects.requireNonNull(returnType);
|
||||
return applyDescriptor(getSpecializedFunNRefType(argumentTypes, returnType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpecializedSignature(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||
return applySignature(new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)), null));
|
||||
Objects.requireNonNull(argumentTypes);
|
||||
Objects.requireNonNull(returnType);
|
||||
return applySignature(getSpecializedFunNRefType(argumentTypes, returnType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArguments(List<RefTypeOrTPHOrWildcardOrGeneric> list) {
|
||||
Objects.requireNonNull(list);
|
||||
return list
|
||||
.stream()
|
||||
.limit(Math.max(0, list.size() - 1))
|
||||
@ -142,8 +149,33 @@ public class FunNGenerator implements FunNUtilities{
|
||||
|
||||
@Override
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType(List<RefTypeOrTPHOrWildcardOrGeneric> list) {
|
||||
if(list.size() == 0)
|
||||
throw new IndexOutOfBoundsException();
|
||||
Objects.requireNonNull(list);
|
||||
if(list.size() == 0) return null;
|
||||
return list.get(list.size() - 1);
|
||||
}
|
||||
|
||||
private String applyDescriptor(RefTypeOrTPHOrWildcardOrGeneric a) { return a.acceptTV(new TypeToDescriptor(true)); }
|
||||
private String applySignature(RefTypeOrTPHOrWildcardOrGeneric a) { return a.acceptTV(new TypeToSignature(true)); }
|
||||
|
||||
/**
|
||||
* @param a
|
||||
* @return the name for the type {@code a} which should be used in the specialized name for FunN.
|
||||
*/
|
||||
private String applyNameDescriptor(RefTypeOrTPHOrWildcardOrGeneric a){ return a instanceof TypePlaceholder ? "LTPH;" : String.format("L%s;", applyDescriptor(a)); }
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric substituteTPH(RefTypeOrTPHOrWildcardOrGeneric t) {
|
||||
if (t instanceof TypePlaceholder) {
|
||||
TypePlaceholder tph = (TypePlaceholder) t;
|
||||
return new GenericRefType(tph.getName()+"$", t.getOffset());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
private RefType getSpecializedFunNRefType(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType){
|
||||
return new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)),
|
||||
Stream
|
||||
.concat(argumentTypes.stream(), Stream.of(returnType))
|
||||
.filter(t -> t instanceof GenericRefType ||
|
||||
t instanceof TypePlaceholder)
|
||||
.collect(Collectors.toList()),null);
|
||||
}
|
||||
}
|
||||
|
@ -3,25 +3,81 @@ package de.dhbwstuttgart.bytecode.funN;
|
||||
import de.dhbwstuttgart.bytecode.utilities.CONSTANTS;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface which represents the functionality for specifying and generating the specified functional types (FunN).
|
||||
*
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
*/
|
||||
public interface FunNUtilities {
|
||||
|
||||
/**
|
||||
* @param numberArguments (excluding the return type!)
|
||||
* @return the bytecode for the super FunN-interface
|
||||
*/
|
||||
byte[] generateSuperBytecode(int numberArguments);
|
||||
|
||||
/**
|
||||
* @param numberArguments (excluding the return type!)
|
||||
* @return the name for the super FunN-interface
|
||||
*/
|
||||
String getSuperClassName(int numberArguments);
|
||||
|
||||
/**
|
||||
* @param argumentTypes (excluding the return type!)
|
||||
* @param returnType
|
||||
* @return the bytecode for the specialized FunN-interface
|
||||
*/
|
||||
byte[] generateSpecializedBytecode(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType);
|
||||
|
||||
/**
|
||||
* @param argumentTypes (excluding the return type!)
|
||||
* @param returnType
|
||||
* @return the name for the specialized FunN-interface
|
||||
*/
|
||||
String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType);
|
||||
|
||||
/**
|
||||
* @param argumentTypes (excluding the return type!)
|
||||
* @param returnType
|
||||
* @return the descriptor for a specialized FunN-interface.
|
||||
*/
|
||||
String getSpecializedDescriptor(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType);
|
||||
|
||||
/**
|
||||
* @param argumentTypes (excluding the return type!)
|
||||
* @param returnType
|
||||
* @return the signature for a specialized FunN-interface.
|
||||
*/
|
||||
String getSpecializedSignature(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType);
|
||||
|
||||
/**
|
||||
* @param list containing type arguments and the return type.
|
||||
* @return a {@link List} containing only the arguments of the specialized FunN-interface.
|
||||
*/
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> getArguments(List<RefTypeOrTPHOrWildcardOrGeneric> list);
|
||||
|
||||
/**
|
||||
* @param list containing type arguments and the return type.
|
||||
* @return the return type of the {@code list} (last member)
|
||||
*/
|
||||
RefTypeOrTPHOrWildcardOrGeneric getReturnType(List<RefTypeOrTPHOrWildcardOrGeneric> list);
|
||||
|
||||
/**
|
||||
* Should be refactored into a central API.
|
||||
*
|
||||
* @param className
|
||||
* @param bytecode
|
||||
* @param directory
|
||||
* @return {@code true} iff the file could be generated and {@code false} if not
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean writeClassFile(String className, byte[] bytecode, File directory) {
|
||||
static boolean writeClassFile(String className, byte[] bytecode, File directory) {
|
||||
try (FileOutputStream output = new FileOutputStream(new File(directory , className + CONSTANTS.EXTENSIONCLASS))){
|
||||
output.write(bytecode);
|
||||
output.flush();
|
||||
@ -31,6 +87,4 @@ public interface FunNUtilities {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -102,9 +102,20 @@ public class TypeToSignature implements TypeVisitor<String> {
|
||||
return sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed that the correct signature is returned:
|
||||
* returns now T...; expect of only ...
|
||||
* where ... is {@code genericRefType.getParsedName()}
|
||||
*
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
*
|
||||
* @param genericRefType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String visit(GenericRefType genericRefType) {
|
||||
return genericRefType.getParsedName().replace(".", "/");
|
||||
return String.format("T%s;", genericRefType.getParsedName()).replace(".", "/");
|
||||
}
|
||||
|
||||
private Optional<GenericsGeneratorResult> getEqualTPHFromClassConstraints(List<GenericsGeneratorResult> listOfConstraints, String tph) {
|
||||
|
@ -26,7 +26,6 @@ public class Resolver {
|
||||
return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
}
|
||||
|
||||
//ToDo Etienne: Check ob benötigt
|
||||
public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||
return resultSet.resolveType(type).resolvedType;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
{
|
||||
private String name;
|
||||
@ -33,12 +35,20 @@ public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
if((! (o instanceof GenericRefType))) return false;
|
||||
GenericRefType genericRefType = (GenericRefType) o;
|
||||
return getParsedName().equals(genericRefType.getParsedName()) &&
|
||||
Objects.equals(getOffset(), genericRefType.getOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
@ -20,7 +20,8 @@ public class ASTToTargetAST {
|
||||
public TargetClass convert(ClassOrInterface input, Map<TypePlaceholder, TargetType> sigma){
|
||||
List<TargetConstructor> targetConstructors = new ArrayList<>();
|
||||
//TODO constructor conversion -> also reduce syntactic sugar
|
||||
return new TargetClass(input.getModifiers(),input.getClassName().toString(), sigma.get(input.getSuperClass()),
|
||||
return new TargetClass(input.getModifiers(),input.getClassName().toString(), null,
|
||||
sigma.get(input.getSuperClass()),
|
||||
input.getSuperInterfaces().stream().map(it -> sigma.get(it)).collect(Collectors.toList()),
|
||||
targetConstructors,
|
||||
input.getFieldDecl().stream().map(it -> convert(it, sigma)).collect(Collectors.toList()),
|
||||
@ -42,7 +43,7 @@ public class ASTToTargetAST {
|
||||
}
|
||||
|
||||
private TargetField convert(Field input, Map<TypePlaceholder, TargetType> sigma) {
|
||||
return null;
|
||||
return new TargetField(convert(input.getType(), sigma), input.getName());
|
||||
}
|
||||
|
||||
private TargetType convert(RefTypeOrTPHOrWildcardOrGeneric input, Map<TypePlaceholder, TargetType> sigma) {
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.dhbwstuttgart.target.tree;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.target.tree.type.TargetType;
|
||||
|
||||
public record GenericDeclaration(GenericRefType generic, TargetType bound) {
|
||||
}
|
@ -5,6 +5,7 @@ import de.dhbwstuttgart.target.tree.type.TargetType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record TargetClass(int modifiers, String qualifiedName, TargetType superType, List<TargetType> implementingInterfaces,
|
||||
public record TargetClass(int modifiers, String qualifiedName, List<GenericDeclaration> generics, TargetType superType,
|
||||
List<TargetType> implementingInterfaces,
|
||||
List<TargetConstructor> constructors, List<TargetField> fields, List<TargetMethod> methods) {}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package de.dhbwstuttgart.target.tree;
|
||||
|
||||
import de.dhbwstuttgart.target.tree.expression.TargetBlock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record TargetConstructor(List<MethodParameter> parameterTypes) {
|
||||
public record TargetConstructor(List<MethodParameter> parameterTypes, TargetBlock block) {
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package de.dhbwstuttgart.target.tree.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record TargetExtendsWildcard(TargetType innerType) implements TargetType{
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.function.Function;
|
||||
|
||||
import general.TestCleanUp;
|
||||
import org.junit.*;
|
||||
@ -12,7 +11,8 @@ import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* //ToDo Etienne: Beschreiben
|
||||
* Test for the file {@code OLFun2.jav}.
|
||||
* Tests if the expected overloading for the method {@code m} exists.
|
||||
*
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
@ -24,13 +24,12 @@ public class OLFun2Test {
|
||||
private static ClassLoader loader;
|
||||
private static Class<?> classToTest;
|
||||
private static Class<?> classFun1IntInt;
|
||||
private static Class<?> classFun1IntDouble;
|
||||
private static Class<?> classFun1DoubleDouble;
|
||||
private static Class<?> classFun1StringString;
|
||||
private static Class<?> classFun1DoubleInt;
|
||||
|
||||
private static String generatedByteCodeDirectory = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
|
||||
//ToDo Etienne: Nach Anpassung des Bytecode die Tests hinzufügen
|
||||
//ToDo Etienne: Aufruf von m testen
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/OLFun2.jav";
|
||||
@ -40,30 +39,37 @@ public class OLFun2Test {
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
||||
classToTest = loader.loadClass("OLFun2");
|
||||
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
||||
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
||||
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
||||
classFun1StringString = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$String$_$");
|
||||
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithInteger() throws Exception{
|
||||
public void mExistsWithIntegerInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble);
|
||||
public void mExistsWithIntegerDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithString() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1StringString);
|
||||
public void mExistsWithDoubleInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
//@AfterClass
|
||||
public static void cleanUp(){
|
||||
@Test
|
||||
public void mExistsWithDoubleDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp() {
|
||||
TestCleanUp.cleanUpDirectory(new File(generatedByteCodeDirectory), f -> f.getName().contains(".class"));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* //ToDo Etienne: Beschreiben
|
||||
* Test for the file {@code OLFun.jav}.
|
||||
* Tests if the expected overloading for the method {@code m} exists.
|
||||
*
|
||||
* @since Studienarbeit Type Erasure
|
||||
* @author etiennezink
|
||||
@ -23,13 +24,14 @@ public class OLFunTest {
|
||||
private static ClassLoader loader;
|
||||
private static Class<?> classToTest;
|
||||
private static Class<?> classFun1IntInt;
|
||||
private static Class<?> classFun1IntDouble;
|
||||
private static Class<?> classFun1DoubleDouble;
|
||||
private static Class<?> classFun1StringString;
|
||||
private static Class<?> classFun1DoubleInt;
|
||||
private static Class<?> classFun1StringInt;
|
||||
private static Class<?> classFun1StringDouble;
|
||||
|
||||
private static String generatedByteCodeDirectory = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
|
||||
//ToDo Etienne: Nach Anpassung des Bytecode die Tests hinzufügen
|
||||
//ToDo Etienne: Aufruf von m testen
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/OLFun.jav";
|
||||
@ -39,29 +41,50 @@ public class OLFunTest {
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
||||
classToTest = loader.loadClass("OLFun");
|
||||
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
||||
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
||||
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
||||
classFun1StringString = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$String$_$");
|
||||
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
||||
classFun1StringInt = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Integer$_$");
|
||||
classFun1StringDouble = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Double$_$");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt ,Integer.class);
|
||||
public void mExistsWithIntegerInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt, Integer.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble ,Double.class);
|
||||
public void mExistsWithIntegerDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble, Integer.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithString() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1StringString ,String.class);
|
||||
public void mExistsWithDoubleInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt, Double.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
//@AfterClass
|
||||
@Test
|
||||
public void mExistsWithDoubleDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble, Double.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithStringInteger() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1StringInt, String.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mExistsWithStringDouble() throws Exception{
|
||||
Method m = classToTest.getDeclaredMethod("m", classFun1StringDouble, String.class);
|
||||
assertNotNull(m);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUp(){
|
||||
TestCleanUp.cleanUpDirectory(new File(generatedByteCodeDirectory), f -> f.getName().contains(".class"));
|
||||
}
|
||||
|
248
src/test/java/bytecode/funN/FunNGeneratorTest.java
Normal file
248
src/test/java/bytecode/funN/FunNGeneratorTest.java
Normal file
@ -0,0 +1,248 @@
|
||||
package bytecode.funN;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.funN.FunNGenerator;
|
||||
import de.dhbwstuttgart.bytecode.funN.FunNUtilities;
|
||||
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 org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class FunNGeneratorTest {
|
||||
|
||||
static FunNUtilities funNGenerator;
|
||||
static RefType voidType;
|
||||
static RefType integerType;
|
||||
static GenericRefType genericT;
|
||||
static TypePlaceholder tph;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp(){
|
||||
|
||||
funNGenerator = FunNGenerator.getInstance();
|
||||
voidType = new RefType(new JavaClassName(Type.getInternalName(Void.class)), null);
|
||||
integerType = new RefType(new JavaClassName(Type.getInternalName(Integer.class)), null);
|
||||
genericT = new GenericRefType("T", null);
|
||||
tph = TypePlaceholder.fresh(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void superClassName_0(){
|
||||
var superClassName = funNGenerator.getSuperClassName(0);
|
||||
assertEquals("Fun0$$", superClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void superClassName_1(){
|
||||
var superClassName = funNGenerator.getSuperClassName(1);
|
||||
assertEquals("Fun1$$", superClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedClassName_VoidVoid(){
|
||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType);
|
||||
assertEquals("Fun0$$Ljava$lang$Void$_$", specializedClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedClassName_VoidInt(){
|
||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType);
|
||||
assertEquals("Fun0$$Ljava$lang$Integer$_$", specializedClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedClassName_IntInt(){
|
||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), integerType);
|
||||
assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", specializedClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedClassName_IntT(){
|
||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT);
|
||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", specializedClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedClassName_IntTPH(){
|
||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), TypePlaceholder.fresh(null));
|
||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LTPH$_$", specializedClassName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signature_IntInt(){
|
||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), integerType);
|
||||
assertEquals("LFun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$;", classSignature);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signature_IntT(){
|
||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT);
|
||||
assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signature_TPHTPH(){
|
||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph);
|
||||
assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptor_IntInt(){
|
||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType);
|
||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||
assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptor_IntT(){
|
||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT);
|
||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", classDescriptor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void descriptor_TPHTPH(){
|
||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph);
|
||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||
assertEquals("Fun1$$LTPH$_$LTPH$_$", classDescriptor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArguments_Empty(){
|
||||
var arguments = funNGenerator.getArguments(Arrays.asList());
|
||||
assertTrue(arguments.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArguments_Int(){
|
||||
var arguments = funNGenerator.getArguments(Arrays.asList(integerType));
|
||||
assertTrue(arguments.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArguments_IntT(){
|
||||
var arguments = funNGenerator.getArguments(Arrays.asList(integerType, genericT));
|
||||
assertTrue(arguments.size() == 1);
|
||||
assertTrue(arguments.contains(integerType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArguments_IntTInt(){
|
||||
var arguments = funNGenerator.getArguments(Arrays.asList(integerType, genericT, integerType));
|
||||
assertTrue(arguments.size() == 2);
|
||||
assertTrue(arguments.contains(integerType));
|
||||
assertTrue(arguments.contains(genericT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getReturnType_Empty(){
|
||||
var returnType = funNGenerator.getReturnType(Arrays.asList());
|
||||
assertNull(returnType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getReturnType_Int(){
|
||||
var returnType = funNGenerator.getReturnType(Arrays.asList(integerType));
|
||||
assertEquals(integerType, returnType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getReturnType_IntT(){
|
||||
var returnType = funNGenerator.getReturnType(Arrays.asList(integerType, genericT));
|
||||
assertEquals(genericT, returnType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void superBytecode_0(){
|
||||
var superBytecode = funNGenerator.generateSuperBytecode(0);
|
||||
assertArrayEquals(superBytecodeReference_0(), superBytecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void superBytecode_1(){
|
||||
var superBytecode = funNGenerator.generateSuperBytecode(1);
|
||||
assertArrayEquals(superBytecodeReference_1(), superBytecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void superBytecode_2(){
|
||||
var superBytecode = funNGenerator.generateSuperBytecode(2);
|
||||
assertArrayEquals(superBytecodeReference_2(), superBytecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedBytecode_VoidInt(){
|
||||
var specializedBytecode = funNGenerator.generateSpecializedBytecode(Arrays.asList(), integerType);
|
||||
assertArrayEquals(specializedBytecodeReference_VoidInt(), specializedBytecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedBytecode_IntInt(){
|
||||
var specializedBytecode = funNGenerator.generateSpecializedBytecode(Arrays.asList(integerType), integerType);
|
||||
assertArrayEquals(specializedBytecodeReference_IntInt(), specializedBytecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specializedBytecode_TIntInt(){
|
||||
var specializedBytecode = funNGenerator.generateSpecializedBytecode(Arrays.asList(genericT, integerType), integerType);
|
||||
assertArrayEquals(specializedBytecodeReference_TIntInt(), specializedBytecode);
|
||||
}
|
||||
|
||||
//super bytecode reference methods
|
||||
private static byte[] superBytecodeReference_0() {
|
||||
var classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$", "<R:Ljava/lang/Object;>Ljava/lang/Object;", "java/lang/Object", null);
|
||||
var methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "apply", "()Ljava/lang/Object;", "()TR;", null);
|
||||
methodVisitor.visitEnd();
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
private static byte[] superBytecodeReference_1() {
|
||||
var classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$", "<T1:Ljava/lang/Object;R:Ljava/lang/Object;>Ljava/lang/Object;", "java/lang/Object", null);
|
||||
var methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "apply", "(Ljava/lang/Object;)Ljava/lang/Object;", "(TT1;)TR;", null);
|
||||
methodVisitor.visitEnd();
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
private static byte[] superBytecodeReference_2() {
|
||||
ClassWriter classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$", "<T1:Ljava/lang/Object;T2:Ljava/lang/Object;R:Ljava/lang/Object;>Ljava/lang/Object;", "java/lang/Object", null);
|
||||
var methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "apply", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "(TT1;TT2;)TR;", null);
|
||||
methodVisitor.visitEnd();
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
//specialized bytecode reference methods
|
||||
private static byte[] specializedBytecodeReference_VoidInt() {
|
||||
ClassWriter classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$<Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun0$$"});
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
private static byte[] specializedBytecodeReference_IntInt() {
|
||||
ClassWriter classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun1$$<Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun1$$"});
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
|
||||
private static byte[] specializedBytecodeReference_TIntInt() {
|
||||
ClassWriter classWriter = new ClassWriter(0);
|
||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "<T:Ljava/lang/Object;>Ljava/lang/Object;LFun2$$<TT;Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun2$$"});
|
||||
classWriter.visitEnd();
|
||||
return classWriter.toByteArray();
|
||||
}
|
||||
}
|
@ -20,18 +20,17 @@ import org.junit.Test;
|
||||
*
|
||||
*/
|
||||
public class GeneralParserTest{
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
|
||||
|
||||
List<String> filenames = new ArrayList<String>();
|
||||
|
||||
filenames.add("javFiles/parser/NewTest.jav");
|
||||
//filenames.add("CastTest.jav");
|
||||
/*
|
||||
filenames.add("NewTest.jav");
|
||||
filenames.add("FieldInitializationTest.jav");
|
||||
filenames.add("ImportTest.jav");
|
||||
filenames.add("CastTest.jav");
|
||||
filenames.add("StatementsTest.jav");
|
||||
//filenames.add("Methods.jav");
|
||||
filenames.add("ImportTestGeneric.jav");
|
||||
@ -40,11 +39,14 @@ public class GeneralParserTest{
|
||||
//filenames.add("GenericFieldVarTest.jav");
|
||||
filenames.add("FieldVarTest.jav");
|
||||
filenames.add("StructuralTypes.jav");
|
||||
filenames.add("ExtendsTest.jav");
|
||||
*/
|
||||
// filenames.add("ExtendsTest.jav");
|
||||
filenames.add("PackageNameTest.jav");
|
||||
|
||||
//filenames.add("PackageNameTest.jav");
|
||||
try{
|
||||
new JavaTXCompiler(filenames.stream().map(s -> new File(rootDirectory + s)).collect(Collectors.toList()));
|
||||
for(String filename : filenames){
|
||||
new JavaTXCompiler(new File(Thread.currentThread().getContextClassLoader().getResource(filename).getPath()));
|
||||
}
|
||||
}catch(Exception exc){
|
||||
exc.printStackTrace();
|
||||
fail();
|
||||
|
@ -6,8 +6,7 @@ import java.lang.Boolean;
|
||||
|
||||
public class OLFun {
|
||||
|
||||
//f = x -> {return x + x;};
|
||||
m(f, x) {
|
||||
x = f.apply(x+x);
|
||||
var y = f.apply(x + x) + 1;
|
||||
}
|
||||
}
|
@ -6,8 +6,8 @@ import java.lang.Boolean;
|
||||
|
||||
public class OLFun2 {
|
||||
|
||||
x;
|
||||
m(f){
|
||||
x = f.apply(x + x)
|
||||
var x = 1;
|
||||
var y = f.apply(x + x) + 1;
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
|
||||
class Test{
|
||||
method(){
|
||||
if(true)i++;
|
9
src/test/resources/testBytecode/manually/OLFunTest.java
Normal file
9
src/test/resources/testBytecode/manually/OLFunTest.java
Normal file
@ -0,0 +1,9 @@
|
||||
public class OLFunTest{
|
||||
public static void main(String[] args){
|
||||
var olFun2 = new OLFun2();
|
||||
olFun2.m((Integer x) -> x);
|
||||
olFun2.m((Integer x) -> (Double) Double.valueOf(x));
|
||||
olFun2.m((Double x) -> x);
|
||||
olFun2.m((Double x) -> x.intValue());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user