From 9575afd0b4ae1a0c9fcae45ea1c9e2664e0faece Mon Sep 17 00:00:00 2001 From: Fayez Abu Alia Date: Tue, 15 May 2018 10:33:30 +0200 Subject: [PATCH] Fun umbenannt und Argumente umgedreht --- src/de/dhbwstuttgart/bytecode/BytecodeGen.java | 2 ++ src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java | 6 +++++- .../bytecode/descriptor/DescriptorToString.java | 10 +++++----- .../bytecode/descriptor/DescriptorVisitor.java | 10 +++++----- src/de/dhbwstuttgart/bytecode/signature/Signature.java | 8 +++++--- .../bytecode/{ => utilities}/KindOfLambda.java | 2 +- .../dhbwstuttgart/bytecode/{ => utilities}/Lambda.java | 2 +- .../bytecode/{ => utilities}/MethodFromMethodCall.java | 2 +- .../bytecode/{ => utilities}/NormalConstructor.java | 2 +- .../bytecode/{ => utilities}/NormalMethod.java | 2 +- .../bytecode/{ => utilities}/SamMethod.java | 2 +- src/de/dhbwstuttgart/core/JavaTXCompiler.java | 2 +- .../parser/SyntaxTreeGenerator/StatementGenerator.java | 2 +- 13 files changed, 30 insertions(+), 22 deletions(-) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/KindOfLambda.java (98%) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/Lambda.java (93%) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/MethodFromMethodCall.java (96%) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/NormalConstructor.java (95%) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/NormalMethod.java (97%) rename src/de/dhbwstuttgart/bytecode/{ => utilities}/SamMethod.java (94%) diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java index 52feb6e5..36c7173a 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java @@ -17,6 +17,8 @@ import de.dhbwstuttgart.bytecode.descriptor.DescriptorToString; import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor; import de.dhbwstuttgart.bytecode.signature.Signature; import de.dhbwstuttgart.bytecode.signature.TypeToString; +import de.dhbwstuttgart.bytecode.utilities.NormalConstructor; +import de.dhbwstuttgart.bytecode.utilities.NormalMethod; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal; import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.statement.Literal; diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index ce5d3def..c00c152a 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -31,6 +31,10 @@ import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor; import de.dhbwstuttgart.bytecode.signature.Signature; import de.dhbwstuttgart.bytecode.signature.TypeToSignature; import de.dhbwstuttgart.bytecode.signature.TypeToString; +import de.dhbwstuttgart.bytecode.utilities.KindOfLambda; +import de.dhbwstuttgart.bytecode.utilities.Lambda; +import de.dhbwstuttgart.bytecode.utilities.MethodFromMethodCall; +import de.dhbwstuttgart.bytecode.utilities.SamMethod; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.Method; @@ -566,7 +570,7 @@ public class BytecodeGenMethod implements StatementVisitor { methSig.visitReturnType().visitTypeVariable("R"); // ")"+lam.getReturn.getBounds Signature sig = new Signature(lambdaExpression, numberOfParams); - String name = "Fun" + numberOfParams; + String name = "Fun" + numberOfParams + "$$"; classWriter.visit(Opcodes.V1_8, Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT, name, sig.toString(), Type.getInternalName(Object.class), null); MethodVisitor mvApply = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "apply", methDesc, diff --git a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java index 65f48f71..cba540f8 100644 --- a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java +++ b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java @@ -2,12 +2,12 @@ package de.dhbwstuttgart.bytecode.descriptor; import java.util.Iterator; -import de.dhbwstuttgart.bytecode.Lambda; -import de.dhbwstuttgart.bytecode.MethodFromMethodCall; -import de.dhbwstuttgart.bytecode.NormalConstructor; -import de.dhbwstuttgart.bytecode.NormalMethod; -import de.dhbwstuttgart.bytecode.SamMethod; import de.dhbwstuttgart.bytecode.signature.TypeToSignature; +import de.dhbwstuttgart.bytecode.utilities.Lambda; +import de.dhbwstuttgart.bytecode.utilities.MethodFromMethodCall; +import de.dhbwstuttgart.bytecode.utilities.NormalConstructor; +import de.dhbwstuttgart.bytecode.utilities.NormalMethod; +import de.dhbwstuttgart.bytecode.utilities.SamMethod; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.statement.Expression; import de.dhbwstuttgart.syntaxtree.type.RefType; diff --git a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorVisitor.java b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorVisitor.java index 6bc57f21..35f1423e 100644 --- a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorVisitor.java +++ b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorVisitor.java @@ -1,10 +1,10 @@ package de.dhbwstuttgart.bytecode.descriptor; -import de.dhbwstuttgart.bytecode.Lambda; -import de.dhbwstuttgart.bytecode.MethodFromMethodCall; -import de.dhbwstuttgart.bytecode.NormalConstructor; -import de.dhbwstuttgart.bytecode.NormalMethod; -import de.dhbwstuttgart.bytecode.SamMethod; +import de.dhbwstuttgart.bytecode.utilities.Lambda; +import de.dhbwstuttgart.bytecode.utilities.MethodFromMethodCall; +import de.dhbwstuttgart.bytecode.utilities.NormalConstructor; +import de.dhbwstuttgart.bytecode.utilities.NormalMethod; +import de.dhbwstuttgart.bytecode.utilities.SamMethod; public interface DescriptorVisitor { public String visit(NormalMethod method); diff --git a/src/de/dhbwstuttgart/bytecode/signature/Signature.java b/src/de/dhbwstuttgart/bytecode/signature/Signature.java index 46202cb1..8c2cc1d3 100644 --- a/src/de/dhbwstuttgart/bytecode/signature/Signature.java +++ b/src/de/dhbwstuttgart/bytecode/signature/Signature.java @@ -59,9 +59,6 @@ public class Signature { private void createSignatureForFunN(LambdaExpression lambdaExpression, int numberOfParams) { - sw.visitFormalTypeParameter("R"); - // getBounds vom Return-Type - sw.visitClassBound().visitClassType(Type.getInternalName(Object.class)); sw.visitClassBound().visitEnd(); for(int i = 0;i> result = unify.unifySequential(xConsSet, finiteClosure, logFile); //Set> result = unify.unify(xConsSet, finiteClosure); diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index aaa31f74..15f2268d 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -904,7 +904,7 @@ public class StatementGenerator { funNParams.add(TypePlaceholder.fresh(expression.getStart()))); RefTypeOrTPHOrWildcardOrGeneric lambdaType = TypePlaceholder.fresh(expression.getStart()); //RefType lambdaType = new RefType(reg.getName("Fun"+params.getFormalparalist().size()), - //funNParams, name.getStart()); + //funNParams, name.getStart()); return new LambdaExpression(lambdaType, params, block, expression.getStart()); } }