Mergen... (nicht fertig)

This commit is contained in:
JanUlrich 2016-11-11 11:01:55 +01:00
commit 6a4cb673bf
31 changed files with 391 additions and 361 deletions

View File

@ -0,0 +1,93 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
public class BytecodeTypeFactory {
/**
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-FieldType
*/
public static String generateFieldDescriptor(Type t){
String ret = "";
if(t instanceof RefType){
ret += "L" + t.getName().toString().replace('.', '/') + ";";
}else{
throw new NotImplementedException();
}
return ret;
}
/**
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ClassSignature
*/
public static String generateClassSignature(de.dhbwstuttgart.syntaxtree.Class c){
String ret = "";
if(c.getGenericParameter() != null && c.getGenericParameter().size() > 0){
ret += "<";
for(GenericTypeVar gtv : c.getGenericParameter()){
ret += generateTypeParameter(gtv);
}
ret += ">";
}
//Add the SuperClassSignature:
c.getSuperClass();
ret += generateClassTypeSignature();
return ret;
}
public static String generateSuperClassSignature(Type superClass){
String ret = "";
//TODO:
throw new NotImplementedException();
}
private static String generateTypeParameter(GenericTypeVar gtv){
String ret = gtv.get_Name() + ":";
for(ObjectType t : gtv.getBounds()){
ret += generateReferenceTypeSignature(t);
ret += ":";
}
ret = ret.substring(0, ret.length()-1);
return ret;
}
/**
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ClassTypeSignature
*/
private static String generateClassTypeSignature(){
return null;
}
/**
* @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-ReferenceTypeSignature
*/
private static String generateReferenceTypeSignature(Type t){
if(t instanceof RefType)return generateReferenceTypeSignature((RefType)t);
if(t instanceof GenericTypeVar)return generateReferenceTypeSignature((GenericTypeVar)t);
throw new NotImplementedException();
}
private static String generateReferenceTypeSignature(RefType t){
String ret = "L" + t.get_Name();
if(t.getParaList() != null && t.getParaList().size() > 0){
ret += "<";
for(Type p : t.getParaList()){
ret += generateReferenceTypeSignature(p);
}
ret+=">";
}
return ret + ";";
}
private static String generateReferenceTypeSignature(GenericTypeVar t){
String ret = "T" + t.get_Name();
return ret + ";";
}
}

View File

@ -20,6 +20,8 @@ import org.apache.bcel.classfile.Signature;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.ConstantPoolGen;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
@ -36,6 +38,7 @@ public class ClassGenerator extends ClassGen{
private TypeinferenceResults tiResult; private TypeinferenceResults tiResult;
private int lambdaMethodeNr = 0; private int lambdaMethodeNr = 0;
private Type superClass; private Type superClass;
private List<GenericTypeVar> generics;
private Menge<TypePlaceholder> usedTPHs = new Menge<>(); private Menge<TypePlaceholder> usedTPHs = new Menge<>();
@ -43,11 +46,14 @@ public class ClassGenerator extends ClassGen{
private List<String> methodsNamesAndTypes = new LinkedList<>(); private List<String> methodsNamesAndTypes = new LinkedList<>();
private MethodGenerator methodGenerator; private MethodGenerator methodGenerator;
public ClassGenerator(String name, Type superClass, String string, short accessflags, String[] strings, TypeinferenceResults typeinferenceResults) { public ClassGenerator(JavaClassName name, Type superClass, List<GenericTypeVar> generics,
super(name,superClass.get_Name(),string,accessflags,strings, new DHBWConstantPoolGen()); String sourceFileName, short accessflags, String[] implementedInterfaces, TypeinferenceResults rs) {
this.tiResult = typeinferenceResults; super(name.toString(),superClass.get_Name(),sourceFileName,accessflags,implementedInterfaces, new DHBWConstantPoolGen());
//this.tiResult = typeinferenceResultSet;
this.superClass = superClass; this.superClass = superClass;
this.generics = generics;
tiResult = rs;
cp = (DHBWConstantPoolGen) super.getConstantPool(); cp = (DHBWConstantPoolGen) super.getConstantPool();
factory = new DHBWInstructionFactory(this, cp); factory = new DHBWInstructionFactory(this, cp);
this.setMajor(52); //Java 8 Version 52.0 this.setMajor(52); //Java 8 Version 52.0
@ -62,7 +68,7 @@ public class ClassGenerator extends ClassGen{
* Versucht einen Type zu finden von dem dieser TPH ein Subtyp sein muss. * Versucht einen Type zu finden von dem dieser TPH ein Subtyp sein muss.
* @param toTPH * @param toTPH
* @return Es gilt dann "toTPH extends Type" * @return Es gilt dann "toTPH extends Type"
*/
public org.apache.bcel.generic.Type getNearestUsedType(Type t, Menge<TypePlaceholder> usedTypes){ public org.apache.bcel.generic.Type getNearestUsedType(Type t, Menge<TypePlaceholder> usedTypes){
if(t == null){ if(t == null){
return this.getInstructionFactory().createObjectType(); return this.getInstructionFactory().createObjectType();
@ -70,13 +76,13 @@ public class ClassGenerator extends ClassGen{
//return getNearestType((TypePlaceholder) t); //return getNearestType((TypePlaceholder) t);
return new TypePlaceholderType((TypePlaceholder) t); return new TypePlaceholderType((TypePlaceholder) t);
}else{ }else{
return t.getBytecodeType(this, getTypeinferenceResults().getTypeReconstructions().get(0)); return t.getBytecodeType(this, getTypeinferenceResultSet().getTypeReconstructions().get(0));
} }
} }
public org.apache.bcel.generic.Type getNearestUsedType(TypePlaceholder toTPH){ public org.apache.bcel.generic.Type getNearestUsedType(TypePlaceholder toTPH){
return this.getNearestUsedType(toTPH, null); return this.getNearestUsedType(toTPH, null);
} }
*/
public String createLambdaMethodName() { public String createLambdaMethodName() {
return "lambda$methode$"+(lambdaMethodeNr++); return "lambda$methode$"+(lambdaMethodeNr++);
} }
@ -152,8 +158,19 @@ public class ClassGenerator extends ClassGen{
//Signatur setzen: //Signatur setzen:
String typeParameters = this.generateParameterSignature(); String typeParameters = this.generateParameterSignature();
String superClassSignature = this.superClass.getBytecodeSignature(this, null); String superClassSignature = BytecodeTypeFactory.generateSuperClassSignature(this.superClass);//"L" + this.superClass.getBytecodeType(cg, rs)
String classSignature = typeParameters + superClassSignature; superClassSignature = superClassSignature.substring(0, superClassSignature.length()-1); //Das ";" am Ende entfernen
if(this.superClass instanceof RefType &&
((RefType)superClass).get_ParaList() != null &&
((RefType)superClass).get_ParaList().size() > 0){
superClassSignature += "<";
RefType superRefType = (RefType) this.superClass;
for(Type param : superRefType.get_ParaList()){
superClassSignature += param.getBytecodeSignature(this, null);
}
superClassSignature += ">;";
}
String classSignature = typeParameters + superClassSignature; //TOOD: Hier noch die Signaturen der SuperInterfaces anfügen
if(classSignature.length()>0){ if(classSignature.length()>0){
this.addAttribute(new Signature(cp.addUtf8("Signature"),2,cp.addUtf8(classSignature),cp.getConstantPool())); this.addAttribute(new Signature(cp.addUtf8("Signature"),2,cp.addUtf8(classSignature),cp.getConstantPool()));
} }
@ -178,6 +195,16 @@ public class ClassGenerator extends ClassGen{
private String generateParameterSignature(){ private String generateParameterSignature(){
String ret = ""; String ret = "";
//ret += "L" + this.getClassName().replace(".", "/") + ";";
if(this.generics != null && this.generics.size() > 0){
ret += "<";
for(GenericTypeVar gtv : this.generics){
ret += gtv.getBytecodeSignature(this, tiResult.getTypeReconstructions().get(0));
}
ret += ">";
}
/*
if(this.getUsedTPH().size()>0){ if(this.getUsedTPH().size()>0){
ret += "<"; ret += "<";
Iterator<TypePlaceholder> it = ((Menge<TypePlaceholder>)this.getUsedTPH().clone()).iterator(); Iterator<TypePlaceholder> it = ((Menge<TypePlaceholder>)this.getUsedTPH().clone()).iterator();
@ -185,10 +212,11 @@ public class ClassGenerator extends ClassGen{
TypePlaceholder tph = it.next(); TypePlaceholder tph = it.next();
//ret += tph.getBytecodeMethodSignature(this); //ret += tph.getBytecodeMethodSignature(this);
//ret += ":"; //ret += ":";
ret += tph.getClassSignature(this, getTypeinferenceResults().getTypeReconstructions().get(0)); ret += tph.getClassSignature(this, null); //Es wird null übergeben. Die ClassSignaturen dürfen von keinem ResultSet abhängen.
} }
ret += ">"; ret += ">";
} }
*/
return ret; return ret;
} }
@ -199,11 +227,12 @@ public class ClassGenerator extends ClassGen{
public Map<String, ClassGenerator> getExtraClasses() { public Map<String, ClassGenerator> getExtraClasses() {
return extraClasses; return extraClasses;
} }
/*
public TypeinferenceResults getTypeinferenceResults() { public TypeinferenceResults getTypeinferenceResultSet() {
return tiResult; return tiResult;
} }
*/
@Override @Override
public void addMethod(Method m) { public void addMethod(Method m) {
//TODO: Die Prüfung, ob Methode bereits vorhanden vor die Bytecodegenerierung verlegen (Beispielsweise in Method) //TODO: Die Prüfung, ob Methode bereits vorhanden vor die Bytecodegenerierung verlegen (Beispielsweise in Method)
@ -225,4 +254,5 @@ public class ClassGenerator extends ClassGen{
return methodGenerator; return methodGenerator;
} }
} }

View File

@ -145,7 +145,7 @@ public class MyCompiler implements MyCompilerAPI{
* Fun0-FunN (momentan ¼r N = 6) * Fun0-FunN (momentan ¼r N = 6)
* @return * @return
*/ */
private TypeAssumptions makeFunNAssumptions(){ public static TypeAssumptions makeFunNAssumptions(){
TypeAssumptions ret = new TypeAssumptions(); TypeAssumptions ret = new TypeAssumptions();
//Basic Assumptions ¼r die FunN Interfaces: //Basic Assumptions ¼r die FunN Interfaces:

View File

@ -71,13 +71,14 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
protected Logger typinferenzLog = Logger.getLogger(Class.class.getName()); protected Logger typinferenzLog = Logger.getLogger(Class.class.getName());
protected Modifiers modifiers; protected Modifiers modifiers;
protected JavaClassName name; protected JavaClassName name;
private Menge<RefType> superif;
public Class(JavaClassName name, List<Method> methoden, List<Field> felder, Modifiers modifier, public Class(JavaClassName name, List<Method> methoden, List<Field> felder, Modifiers modifier,
boolean isInterface, RefType superClass, List<RefType> implementedInterfaces, int offset){ boolean isInterface, RefType superClass, List<RefType> implementedInterfaces, int offset){
super(offset); super(offset);
} }
protected List<RefType> implementedInterfaces = new ArrayList<>();
/** /**
* *
* @param resultSet - Fehlende Typen im Syntaxbaum werden nach diesem ResultSet aufgelöst * @param resultSet - Fehlende Typen im Syntaxbaum werden nach diesem ResultSet aufgelöst
@ -93,8 +94,11 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
SectionLogger logger = Logger.getSectionLogger(this.getClass().getName(), Section.CODEGEN); SectionLogger logger = Logger.getSectionLogger(this.getClass().getName(), Section.CODEGEN);
logger.debug("Test"); logger.debug("Test");
short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public if(pkgName != null)throw new NotImplementedException();
_cg = new ClassGenerator(name.toString(), this.getSuperClass(), name.getName() + ".java", constants , new String[] { }, typeinferenceResults); //letzter Parameter sind implementierte Interfaces short constants = Const.ACC_PUBLIC; //Per Definition ist jede Methode public
if(isInterface())constants+=Const.ACC_INTERFACE;
_cg = new ClassGenerator(name, this.getSuperClass(), this.getGenericParameter(), name + ".java", constants , new String[] { }, typeinferenceResults); //letzter Parameter sind implementierte Interfaces
_cp = _cg.getConstantPool(); _cp = _cg.getConstantPool();
_factory = new DHBWInstructionFactory(_cg, _cp); _factory = new DHBWInstructionFactory(_cg, _cp);
@ -108,12 +112,14 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
if(field instanceof FieldDeclaration)fieldDeclarations.add((FieldDeclaration)field); if(field instanceof FieldDeclaration)fieldDeclarations.add((FieldDeclaration)field);
//field.genByteCode(_cg); //field.genByteCode(_cg);
} }
//Zuerst die Methoden und Felder abarbeiten: //Zuerst die Methoden und Felder abarbeiten:
for(Method m : methods){ for(Method m : methods){
m.genByteCode(_cg, this); m.genByteCode(_cg, this, typeinferenceResults);
} }
InstructionList fieldInitializations = new InstructionList(); InstructionList fieldInitializations = new InstructionList();
for(FieldDeclaration f : fieldDeclarations){ for(FieldDeclaration f : fieldDeclarations){
//Die Felder können noch nicht überladen werden. Hier ist nur die erste der Lösungen möglich:
fieldInitializations.append(f.genByteCode(_cg, typeinferenceResults.getTypeReconstructions().get(0))); fieldInitializations.append(f.genByteCode(_cg, typeinferenceResults.getTypeReconstructions().get(0)));
} }
//Die Konstruktoren müssen die Feld initialisierungswerte beinhalten: //Die Konstruktoren müssen die Feld initialisierungswerte beinhalten:
@ -126,7 +132,15 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
public JavaClassName getName() public JavaClassName getName()
{ {
return name; return new JavaClassName((this.pkgName!=null ? this.pkgName.toString() +"." : "") +this.name);
}
public void setName(String strName)
{
name = new JavaClassName(strName);
}
public void setModifiers(Modifiers mod)
{
this.modifiers = mod;
} }
public Modifiers getModifiers() public Modifiers getModifiers()
{ {
@ -276,9 +290,7 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
*/ */
public String toString() public String toString()
{ {
//return superclassid.toString() + body.toString(); return name.toString();
//geaendert PL 07-07-28
return name.getName();
} }
public String getTypeInformation(Menge<Method> methodList, Menge<Expr> fieldList){ public String getTypeInformation(Menge<Method> methodList, Menge<Expr> fieldList){
@ -443,11 +455,6 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
public String getDescription(){ public String getDescription(){
return "class "+this.getName(); return "class "+this.getName();
} }
@Override
public int getVariableLength() {
// TODO Auto-generated method stub
return 0;
}
@Override @Override
public void setGenericParameter(GenericDeclarationList params) { public void setGenericParameter(GenericDeclarationList params) {
@ -485,10 +492,10 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
return true; return true;
} }
protected boolean isInterface;
public boolean isInterface(){ public boolean isInterface(){
return false; return isInterface;
} }
/* /*
private Collection<? extends ByteCodeResult> getGenericClasses() { private Collection<? extends ByteCodeResult> getGenericClasses() {
Collection<ByteCodeResult> results = new Menge<>(); Collection<ByteCodeResult> results = new Menge<>();

View File

@ -27,6 +27,7 @@ import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
import de.dhbwstuttgart.typeinference.assumptions.ConstructorAssumption; import de.dhbwstuttgart.typeinference.assumptions.ConstructorAssumption;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption; import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption;
@ -64,9 +65,15 @@ public class Constructor extends Method {
DHBWConstantPoolGen _cp = cg.getConstantPool(); DHBWConstantPoolGen _cp = cg.getConstantPool();
InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen
<<<<<<< HEAD
MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg, null), MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg, null),
this.parameterlist.getBytecodeTypeList(cg,null) , this.parameterlist.getParameterNameArray(), this.parameterlist.getBytecodeTypeList(cg,null) , this.parameterlist.getParameterNameArray(),
"<init>", cg.getClassName(), il, _cp); "<init>", cg.getClassName(), il, _cp);
=======
MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC,
this.getType().getBytecodeType(cg, null), this.parameterlist.getBytecodeTypeList(cg,null),
this.parameterlist.getParameterNameArray(), "<init>", parentClass.name.toString(), il, _cp);
>>>>>>> refactoring
//FieldInitializations an Block anfügen //FieldInitializations an Block anfügen
Block block = this.get_Block(); Block block = this.get_Block();
@ -81,7 +88,7 @@ public class Constructor extends Method {
@Override @Override
public void genByteCode(ClassGenerator cg, Class classObj) { public void genByteCode(ClassGenerator cg, Class classObj, TypeinferenceResults resultSets) {
this.genByteCode(cg, new InstructionList()); this.genByteCode(cg, new InstructionList());
} }
// super statement muss drin sein // super statement muss drin sein

View File

@ -164,11 +164,5 @@ public class FieldDeclaration extends Field{
il.append(putFieldInstruction ); il.append(putFieldInstruction );
return il; return il;
} }
/*@Override
public void genByteCode(ClassGen cg) {
// TODO Auto-generated method stub
}*/
} }

View File

@ -21,9 +21,18 @@ public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<G
private int offsetOfLastElement; private int offsetOfLastElement;
private List<GenericTypeVar> gtvs = new Menge<>(); private List<GenericTypeVar> gtvs = new Menge<>();
<<<<<<< HEAD
public GenericDeclarationList(List<GenericTypeVar> values, int endOffset) { public GenericDeclarationList(List<GenericTypeVar> values, int endOffset) {
super(endOffset); super(endOffset);
gtvs = values; gtvs = values;
=======
public GenericDeclarationList(){
this(new Menge<GenericTypeVar>(), -1);
}
public GenericDeclarationList(Menge<GenericTypeVar> values, int endOffset) {
this.addAll(values);
>>>>>>> refactoring
this.offsetOfLastElement = endOffset; this.offsetOfLastElement = endOffset;
} }

View File

@ -44,6 +44,7 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable; import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
import de.dhbwstuttgart.typeinference.UndConstraint; import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption; import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption;
@ -81,7 +82,8 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
super(offset); super(offset);
} }
public Method(String name, Type returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset) { public Method(String name, Type returnType, ParameterList parameterList, Block block,
GenericDeclarationList gtvDeclarations, int offset) {
this(offset); this(offset);
this.name = name; this.name = name;
this.parameterlist = parameterList; this.parameterlist = parameterList;
@ -326,16 +328,21 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
return super.equals(obj); return super.equals(obj);
} }
public void genByteCode(ClassGenerator cg, Class classObj) { public void genByteCode(ClassGenerator cg, Class classObj, TypeinferenceResults resultSets) {
List<TypeinferenceResultSet> typeInterferenceResults = cg.getTypeinferenceResults().getTypeReconstructions(this, cg); List<TypeinferenceResultSet> typeInterferenceResults = resultSets.getTypeReconstructions(this, cg);
DHBWInstructionFactory _factory = cg.getInstructionFactory(); DHBWInstructionFactory _factory = cg.getInstructionFactory();
for(TypeinferenceResultSet t: typeInterferenceResults){ for(TypeinferenceResultSet t: typeInterferenceResults){
addMethodToClassGenerator(cg, _factory, t, classObj); addMethodToClassGenerator(cg, _factory, t, classObj);
} }
} }
<<<<<<< HEAD
private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t, Class parentClass) { private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t, Class parentClass) {
=======
private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
>>>>>>> refactoring
DHBWConstantPoolGen _cp = cg.getConstantPool(); DHBWConstantPoolGen _cp = cg.getConstantPool();
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
@ -352,8 +359,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
Type returnType = this.getType(); Type returnType = this.getType();
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t),
<<<<<<< HEAD
argumentTypes.toArray(new org.apache.bcel.generic.Type[parameterlist.size()]) argumentTypes.toArray(new org.apache.bcel.generic.Type[parameterlist.size()])
, argumentNames.toArray(new String[parameterlist.size()]), this.get_Name(), parentClass.name.toString(), il, _cp); , argumentNames.toArray(new String[parameterlist.size()]), this.get_Name(), parentClass.name.toString(), il, _cp);
=======
argumentTypes.toArray(new org.apache.bcel.generic.Type[parameterlist.size()]) ,
argumentNames.toArray(new String[parameterlist.size()]), this.get_Method_Name(),
getParentClass().name.toString(), il, _cp);
>>>>>>> refactoring
cg.setMethodeGenerator(method); cg.setMethodeGenerator(method);

View File

@ -676,227 +676,6 @@ public class SourceFile
} }
//} //}
} }
// ino.end
// ino.method.makeBasicAssumptions.21418.defdescription type=javadoc
/**
* Erzeugt die Anfangsinformationen �ber bereits bekannte Klassen.
* <br/>Achtung Workaround: Die RefTypes ¯Â¿Â½ssen sp�ter noch durch BaseTypes
* ersetzt werden. <br>
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle
*
* @return A priori Typinformationen
* @throws ClassNotFoundException
*/
// ino.end
// ino.method.makeBasicAssumptions.21418.definition
private TypeAssumptions makeBasicAssumptions()
// ino.end
// ino.method.makeBasicAssumptions.21418.body
{
/*
if(LOAD_BASIC_ASSUMPTIONS_FROM_JRE){
Menge<UsedId> strImports=new Menge<UsedId>();
ImportDeclarations usedIdImports=getImports();
for(int i=0;i<usedIdImports.size();i++){
UsedId uid=usedIdImports.get(i);
if(uid.hasWildCard()){
throw new CTypeReconstructionException("Wildcards in den Imports werden bislang nicht unterstuetzt: "+uid.getQualifiedName(),uid);
//throw new ClassNotFoundException("Bei den Imports sind momentan keine Wildcards erlaubt!");
}else{
strImports.addElement(uid);
}
}
TypeinferenceResultSet res=makeBasicAssumptionsFromJRE(strImports);
ImportDeclarations newImports=new ImportDeclarations();
for(int i=0;i<strImports.size();i++){
newImports.addElement(strImports.get(i));
}
setImports(newImports);
return(res);
}
TypeinferenceResultSet foo = new TypeinferenceResultSet(null);
CMethodTypeAssumption meth = null;
CInstVarTypeAssumption instVar = null;
Class c = null;
UsedId ui = null;
//Menge pl = null;
Modifiers mod = new Modifiers();
mod.addModifier(new Public());
//------------------------
// Integer bauen:
//------------------------
foo.addClassName("java.lang.Integer"); //PL 05-08-01 eingefuegt
instVar = new CInstVarTypeAssumption("java.lang.Integer", "MAX_VALUE", new RefType("java.lang.Integer",-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>());
foo.addFieldOrLocalVarAssumption(instVar);
meth = new CMethodTypeAssumption(new RefType("java.lang.Integer", 0), "<init>", new RefType("java.lang.Integer",-1), 0,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Integer", 0), "<init>", new RefType("java.lang.Integer",-1),1, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
meth.addParaAssumption(new CParaTypeAssumption("java.lang.Integer", "<init>", 1, 0,"value", new RefType("java.lang.Integer",-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>()));
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Integer", 0), "intValue", new RefType("java.lang.Integer",-1), 0,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
c = new BasicAssumptionClass("java.lang.Integer", mod);
// ui = new UsedId();
// ui.set_Name("Super-Class-Blub");
// c.set_UsedId(ui);
// pl = new Menge();
// pl.addElement(new GenericTypeVar("bla"));
// c.set_ParaList(pl);
this.addElement(c);
//------------------------
// Boolean bauen:
//------------------------
foo.addClassName("java.lang.Boolean"); //PL 05-08-01 eingefuegt
meth = new CMethodTypeAssumption(new RefType("java.lang.Boolean", 0), "<init>", new RefType("java.lang.Boolean",-1),0, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Boolean", 0), "<init>", new RefType("java.lang.Boolean",-1), 1,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
meth.addParaAssumption(new CParaTypeAssumption("java.lang.Boolean", "<init>", 1, 0, "value", new RefType("java.lang.Boolean",-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>()));
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Boolean", 0), "booleanValue", new RefType("java.lang.Boolean",-1), 0,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
c = new BasicAssumptionClass("java.lang.Boolean", mod);
// ui = new UsedId();
// ui.set_Name("Super-Class-Blub");
// c.set_UsedId(ui);
// pl = new Menge();
// pl.addElement(new GenericTypeVar("bla"));
// c.set_ParaList(pl);
this.addElement(c);
//------------------------
// Character bauen:
//------------------------
foo.addClassName("java.lang.Character"); //PL 05-08-01 eingefuegt
meth = new CMethodTypeAssumption(new RefType("java.lang.Character", 0), "<init>", new RefType("java.lang.Character",-1),0, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Character", 0), "<init>", new RefType("java.lang.Character",-1),1, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
meth.addParaAssumption(new CParaTypeAssumption("java.lang.Character", "<init>", 1, 0,"value", new RefType("java.lang.Character",-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>()));
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Character", 0), "charValue", new BooleanType(),0, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
c = new BasicAssumptionClass("java.lang.Character", mod);
// ui = new UsedId();
// ui.set_Name("Super-Class-Blub");
// c.set_UsedId(ui);
// pl = new Menge();
// pl.addElement(new GenericTypeVar("bla"));
// c.set_ParaList(pl);
this.addElement(c);
//------------------------
// Menge bauen:
//------------------------
foo.addClassName("java.lang.Menge"); //PL 05-08-01 eingefuegt
TypePlaceholder E = TypePlaceholder.fresh(); // Sp�ter ersetzen durch GenericTypeVar
Menge<GenericTypeVar> typeGenPara = new Menge<GenericTypeVar>();
typeGenPara.addElement(new GenericTypeVar(E.getName(),-1));
foo.addGenericTypeVars("java.lang.Menge", typeGenPara);
meth = new CMethodTypeAssumption(new RefType("java.lang.Menge", 0), "elementAt", new GenericTypeVar(E.getName(),-1), 1,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
meth.addParaAssumption(new CParaTypeAssumption("java.lang.Menge", "elementAt", 1, 0, "index", new RefType("java.lang.Integer",-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>()));
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Menge", 0), "addElement", new Void(-1),1, MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
meth.addParaAssumption(new CParaTypeAssumption("java.lang.Menge", "addElement", 1, 0,"element", new GenericTypeVar(E.getName(),-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>()));
foo.addMethodIntersectionType(new CIntersectionType(meth));
meth = new CMethodTypeAssumption(new RefType("java.lang.Menge", 0), "size", new RefType("java.lang.Integer",-1), 0,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Menge<Integer>(),null);
foo.addMethodIntersectionType(new CIntersectionType(meth));
c = new BasicAssumptionClass("java.lang.Menge", mod);
// ui = new UsedId();
// ui.set_Name("Super-Class-Blub");
// c.set_UsedId(ui);
// pl = new Menge();
// pl.addElement(E);
// c.set_ParaList(pl);
this.addElement(c);
//------------------------
// Stack bauen:
//------------------------
foo.addClassName("java.lang.Stack"); //PL 05-08-01 eingefuegt
c = new BasicAssumptionClass("java.lang.Stack", mod);
ui = new UsedId(-1);
ui.set_Name("java.lang.Menge");
c.set_UsedId(ui);
// pl = new Menge();
// pl.addElement(E);
// c.set_ParaList(pl);
this.addElement(c);
return foo;
*/
TypeAssumptions ret = new TypeAssumptions();
//Basic Assumptions ¼r die FunN Interfaces:
//TODO: Hier mehr als Fun1-Fun5 implementieren
for(int i = 0; i<6; i++){
FunNInterface funN = new FunNInterface(i);
ret.add(funN.getPublicFieldAssumptions());
}
return ret; //TODO: Diese TypeAssumptions mit basic-Assumptions ¼llen
}
// ino.end
// ino.method.setImports.21421.definition
private void setImports(ImportDeclarations newImports)
// ino.end
// ino.method.setImports.21421.body
{
this.imports=newImports;
}
// ino.end
// ino.method.removeBasicAssumptions.21424.defdescription type=javadoc
/**
* ¯Â¿Â½scht die Anfangsinformation wieder aus dem Klassenvektor
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
*/
// ino.end
// ino.method.removeBasicAssumptions.21424.definition
private void removeBasicAssumptions()
// ino.end
// ino.method.removeBasicAssumptions.21424.body
{
for(int i=0; i<KlassenVektor.size(); i++){
Class cl = KlassenVektor.elementAt(i);
if(cl instanceof BasicAssumptionClass){
KlassenVektor.removeElementAt(i);
i--;
}
}
}
// ino.end
// ino.method.getPackageName.21427.defdescription type=javadoc // ino.method.getPackageName.21427.defdescription type=javadoc
/** /**
@ -1019,7 +798,7 @@ public class SourceFile
} }
/** /**
* Bisher wird nur der Bytecode der Klassen generiert. Nicht der Interfaces. * Bytecode generieren für das resultSet
* @return * @return
*/ */
public Menge<ByteCodeResult> generateBytecode(TypeinferenceResults results) { public Menge<ByteCodeResult> generateBytecode(TypeinferenceResults results) {
@ -1027,6 +806,22 @@ public class SourceFile
for(Class cl : this.KlassenVektor){ for(Class cl : this.KlassenVektor){
ret.add(cl.genByteCode(results)); ret.add(cl.genByteCode(results));
} }
//Alle FunN Klassen erzeugen:
for(ClassAssumption funNAss : MyCompiler.makeFunNAssumptions().getClassAssumptions()){
ret.add(funNAss.getAssumedClass().genByteCode(results));
}
/*
//Add all FunN Interfaces
for(Pair ucons : results.getUnifiedConstraints()){
for(Type t : ucons.getTypes()){
List<Class> xClasses = t.isClassFromJavaX();
for(Class xClass : xClasses){
ByteCodeResult bC = xClass.genByteCode(results);
if(! ret.contains(bC))ret.add(bC);
}
}
}
*/
return ret; return ret;
} }

View File

@ -9,12 +9,20 @@ import java.util.List;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
=======
import java.util.ArrayList;
import java.util.List;
>>>>>>> refactoring
import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.Constructor; import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.Field; import de.dhbwstuttgart.syntaxtree.Field;
<<<<<<< HEAD
import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.FormalParameter;
=======
>>>>>>> refactoring
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList; import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.ParameterList; import de.dhbwstuttgart.syntaxtree.ParameterList;
@ -34,11 +42,6 @@ import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
public class ASTFactory { public class ASTFactory {
public static Method createMethod(String name, ParameterList paralist, Block block, Class parent) {
return method;
}
public static Method createEmptyMethod(String withSignature, Class parent) { public static Method createEmptyMethod(String withSignature, Class parent) {
return ASTFactory.createMethod(withSignature, new ParameterList(), new Block(), parent); return ASTFactory.createMethod(withSignature, new ParameterList(), new Block(), parent);
@ -138,7 +141,6 @@ public class ASTFactory {
* @param jreTypeVar * @param jreTypeVar
* @param inClass Die Klasse in der der Typ auftritt * @param inClass Die Klasse in der der Typ auftritt
* @return * @return
*/
public static GenericTypeVar createGeneric(TypeVariable jreTypeVar, java.lang.Class inClass){ public static GenericTypeVar createGeneric(TypeVariable jreTypeVar, java.lang.Class inClass){
//TODO: Bei den Namen der Parameter des Generishen Typs nachschauen, ob er in der Klasse als Generic deklariert wurde //TODO: Bei den Namen der Parameter des Generishen Typs nachschauen, ob er in der Klasse als Generic deklariert wurde
String name = jreTypeVar.getTypeName(); String name = jreTypeVar.getTypeName();
@ -151,4 +153,23 @@ public class ASTFactory {
} }
return new GenericTypeVar(); return new GenericTypeVar();
} }
*/
public static Class createInterface(String className, RefType superClass, Modifiers modifiers,
Menge supertypeGenPara, SourceFile parent){
Class generatedClass = new Class(new JavaClassName(className), new ArrayList<Method>(), new ArrayList<Field>(), modifiers,
true, superClass, new ArrayList<RefType>(), new GenericDeclarationList(), -1);
generatedClass.parserPostProcessing(parent);
return generatedClass;
}
public static Class createObjectClass() {
Class generatedClass = new Class("java.lang.Object", 0);
return generatedClass;
}
public static RefType createObjectType(){
return createObjectClass().getType();
}
} }

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import org.apache.bcel.Const; import org.apache.bcel.Const;
import org.apache.bcel.Constants; import org.apache.bcel.Constants;
@ -214,6 +215,16 @@ public class LambdaExpression extends Expr{
return ret; return ret;
} }
/*
private List<LocalOrFieldVarOrClassname> crawlVariables(SyntaxTreeNode inStatements){
List<LocalOrFieldVarOrClassname> ret = new ArrayList<>();
for(SyntaxTreeNode child : inStatements.getChildren()){
ret.addAll(crawlVariables(child));
}
return ret;
}
*/
@Override @Override
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) { public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
DHBWConstantPoolGen cp = cg.getConstantPool(); DHBWConstantPoolGen cp = cg.getConstantPool();
@ -296,7 +307,7 @@ public class LambdaExpression extends Expr{
String interfaceMethodName = "apply"; //Das ist ein Hack, funktioniert momentan, da nur FunN Interfaces für LambdaAusdrücke funktionieren String interfaceMethodName = "apply"; //Das ist ein Hack, funktioniert momentan, da nur FunN Interfaces für LambdaAusdrücke funktionieren
//String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(lambdaType.getBytecodeType(cg, rs), additionalParameters); //String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(lambdaType.getBytecodeType(cg, rs), additionalParameters);
String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(new org.apache.bcel.generic.ObjectType("Fun0"), additionalParameters); String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(lambdaType.getBytecodeType(cg, rs), additionalParameters);
il.append(cg.getInstructionFactory().createInvokeDynamic(interfaceMethodName,invokeDynamicType, bMethod)); il.append(cg.getInstructionFactory().createInvokeDynamic(interfaceMethodName,invokeDynamicType, bMethod));
return il; return il;

View File

@ -160,11 +160,12 @@ public class LocalOrFieldVarOrClassname extends Expr
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) { public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
if(this.isFieldAccess){ if(this.isFieldAccess){
il.append(new This(this).genByteCode(cg, rs));
il.append(cg.getInstructionFactory().createFieldAccess(this.getParentClass().getName().toString(), this.get_Name(), this.getType().getBytecodeType(cg, rs), Constants.GETFIELD)); il.append(cg.getInstructionFactory().createFieldAccess(this.getParentClass().getName().toString(), this.get_Name(), this.getType().getBytecodeType(cg, rs), Constants.GETFIELD));
}else{
il.append(createLoad(cg, rs));
} }
il.append(createLoad(cg, rs));
return il; return il;
} }

View File

@ -4,6 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.MethodCall.8639.import // ino.module.MethodCall.8639.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.Const;
import org.apache.bcel.Constants; import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory; import org.apache.bcel.generic.InstructionFactory;
@ -333,9 +334,9 @@ public class MethodCall extends Expr
de.dhbwstuttgart.syntaxtree.Class receiverClass = this.receiver.getReceiverClass(cg, rs); de.dhbwstuttgart.syntaxtree.Class receiverClass = this.receiver.getReceiverClass(cg, rs);
short kind = 0; short kind = 0;
if(receiverClass.isInterface()){ if(receiverClass.isInterface()){
kind = Constants.INVOKEINTERFACE; kind = Const.INVOKEINTERFACE;
}else{//Ansonsten muss es eine Klasse sein: }else{//Ansonsten muss es eine Klasse sein:
kind = Constants.INVOKEVIRTUAL; kind = Const.INVOKEVIRTUAL;
} }
org.apache.bcel.generic.Type[] argumentTypen = org.apache.bcel.generic.Type.NO_ARGS; org.apache.bcel.generic.Type[] argumentTypen = org.apache.bcel.generic.Type.NO_ARGS;
@ -353,7 +354,10 @@ public class MethodCall extends Expr
} }
org.apache.bcel.generic.Type returnType = this.getType().getBytecodeType(cg, rs); org.apache.bcel.generic.Type returnType = this.getType().getBytecodeType(cg, rs);
il.append(_factory.createInvoke(receiver.getReceiverClass(cg, rs).getName().toString(), this.get_Name(), returnType , argumentTypen, kind)); il.append(_factory.createInvoke(
receiver.get_Expr().getType().getBytecodeType(cg, rs).toString(),
//receiver.getReceiverClass(cg, rs).getBytecodeType(cg, rs).toString(),
this.get_Name(), returnType , argumentTypen, kind));
return il; return il;
} }

View File

@ -122,5 +122,6 @@ public class Receiver
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult().attach(this.get_Expr().printJavaCode(resultSet)); return new JavaCodeResult().attach(this.get_Expr().printJavaCode(resultSet));
} }
} }
// ino.end // ino.end

View File

@ -13,6 +13,7 @@ import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.ParameterList; import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException; import de.dhbwstuttgart.typeinference.exceptions.DebugException;
@ -50,18 +51,19 @@ public class FunN extends RefType {
/** /**
* Spezieller Konstruktor um eine FunN ohne Returntype zu generieren * Spezieller Konstruktor um eine FunN ohne Returntype zu generieren
*/
protected FunN(List<? extends Type> list){ protected FunN(List<? extends Type> list){
super("",0); super("",0);
if(list==null)throw new NullPointerException(); if(list==null)throw new NullPointerException();
setT(list); setT(list);
this.name = new JavaClassName("Fun"+list.size());//getName(); this.name = new JavaClassName("Fun"+list.size());//getName();
} }
*/
/** /**
* Erstellt eine FunN: * Erstellt eine FunN:
* FunN<R, T1, ..., TparameterCount> * FunN<R, T1, ..., TparameterCount>
* R und T1 - TparameterCount werden mit TypePlaceholdern besetzt. * R und T1 - TparameterCount werden mit GenericTypeVars besetzt.
* @param parameterCount * @param parameterCount
*/ */
public FunN(int parameterCount) { public FunN(int parameterCount) {
@ -69,14 +71,15 @@ public class FunN extends RefType {
if(parameterCount<0)throw new RuntimeException("Anzahl der Parameter muss >0 sein"); if(parameterCount<0)throw new RuntimeException("Anzahl der Parameter muss >0 sein");
Menge<Type> t = new Menge<Type>(); Menge<Type> t = new Menge<Type>();
for(int i=0;i<parameterCount;i++){ for(int i=0;i<parameterCount;i++){
t.add(TypePlaceholder.fresh(this)); //t.add(TypePlaceholder.fresh(this));
t.add(new GenericTypeVar(NameGenerator.makeNewName(), -1));
} }
setR(TypePlaceholder.fresh(this)); setR(new GenericTypeVar(NameGenerator.makeNewName(), -1));
setT(t); setT(t);
this.name = new JavaClassName("Fun"+parameterCount); this.name = new JavaClassName("Fun"+parameterCount);
} }
/** /**
* Muss nach jeder Änderung von T oder R aufgerufen werden. * Muss nach jeder Änderung von T oder R aufgerufen werden.
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig ¼r den Typinferenzalgorithmus. * Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig ¼r den Typinferenzalgorithmus.

View File

@ -30,7 +30,8 @@ public class FunVoidN extends FunN {
* @return * @return
*/ */
public FunVoidN(Menge<Type> T) { public FunVoidN(Menge<Type> T) {
super(T); super(null,T);
this.setR(new Void(this, -1));
this.name = new JavaClassName("FunVoid"+T.size()); this.name = new JavaClassName("FunVoid"+T.size());
} }

View File

@ -2,9 +2,12 @@
package de.dhbwstuttgart.syntaxtree.type; package de.dhbwstuttgart.syntaxtree.type;
// ino.end // ino.end
import java.util.ArrayList;
// ino.module.GenericTypeVar.8671.import // ino.module.GenericTypeVar.8671.import
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.ConstraintsSet;
@ -22,15 +25,14 @@ import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext; import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
// ino.class.GenericTypeVar.26505.description type=javadoc import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
/** /**
* TODO: Diese Klasse überarbeiten. Pair genericTypeVar ist nicht implementiert. * TODO: Diese Klasse überarbeiten. Pair genericTypeVar ist nicht implementiert.
* @author ¯Â¿Â½rg ¯Â¿Â½uerle * @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/09/22 20:12:53 $ * @version $Date: 2013/09/22 20:12:53 $
*/ */
public class GenericTypeVar extends ObjectType public class GenericTypeVar extends ObjectType
// ino.end
// ino.class.GenericTypeVar.26505.body
{ {
//Type genericTypeVar; //Type genericTypeVar;
//Menge<Type> extendVars = new Menge<Type>(); //Menge<Type> extendVars = new Menge<Type>();
@ -225,7 +227,14 @@ public class GenericTypeVar extends ObjectType
// TODO Bytecode // TODO Bytecode
return org.apache.bcel.generic.Type.getType(getSignatureType(null));// new org.apache.bcel.generic.ObjectType("Object"); return org.apache.bcel.generic.Type.getType(getSignatureType(null));// new org.apache.bcel.generic.ObjectType("Object");
} }
public List<ObjectType> getBounds()
{
//Gibt eine Liste mit "java.lang.Object" zurück, da jede Generic von Object erbt
ArrayList<ObjectType> ret = new ArrayList<>();
ret.add(ASTFactory.createObjectType());
return ret;
}
} }
// ino.end // ino.end

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.syntaxtree.type; package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
/** /**
@ -9,7 +10,7 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
*/ */
public abstract class ObjectType extends Type { public abstract class ObjectType extends Type {
public ObjectType(String s, int offset) { public ObjectType(JavaClassName s, int offset) {
super(s, offset); super(s, offset);
} }
public abstract ObjectType clone(); public abstract ObjectType clone();

View File

@ -96,7 +96,7 @@ public class RefType extends ObjectType implements IMatchable
} }
/** /**
* Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt. * Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
* @return * @return
*/ */
@ -535,12 +535,9 @@ public class RefType extends ObjectType implements IMatchable
@Override @Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) { public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
String combinedType = getCombinedType(cg, rs); String combinedType = getCombinedType(cg, rs);
if(!combinedType.equals(getName().toString())){ /*
getSuperWildcardTypes();
Class generatedClass = ASTFactory.createClass(getCombinedType(cg, rs), getGenericClassType(), null, null, new SourceFile()); */
cg.addExtraClass(generatedClass.genByteCode(new TypeinferenceResults()).getByteCode());
}
String ret = new org.apache.bcel.generic.ObjectType(combinedType).getSignature(); String ret = new org.apache.bcel.generic.ObjectType(combinedType).getSignature();
return ret; return ret;
} }
@ -548,32 +545,48 @@ public class RefType extends ObjectType implements IMatchable
public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){ public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){
//Bsp.: Ljava/util/Vector<Ljava/lang/String;>; //Bsp.: Ljava/util/Vector<Ljava/lang/String;>;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String ret;
List<Type> newParams = new ArrayList<>();
if(parameter != null && parameter.size() > 0){ if(parameter != null && parameter.size() > 0){
sb.append(getName().toString().replace(".", "%")); sb.append(getName().toString().replace(".", "%"));
sb.append("%%"); sb.append("%%");
for(Type type: parameter){ for(Type type: parameter){
Type newParameter;
if(type instanceof RefType){ if(type instanceof RefType){
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%")); sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
newParameter = type;
}else if(type instanceof TypePlaceholder){ }else if(type instanceof TypePlaceholder){
newParameter = rs.getTypeOfPlaceholder((TypePlaceholder)type);
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%")); sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
}else if(type instanceof WildcardType){ }else if(type instanceof WildcardType){
//TODO: unresolved!
return this.getName().toString(); return this.getName().toString();
}else{ }else{
newParameter = type;
sb.append(type.getBytecodeType(cg, rs).toString().replace(".", "%")); sb.append(type.getBytecodeType(cg, rs).toString().replace(".", "%"));
} }
newParams.add(newParameter);
sb.append("%"); sb.append("%");
} }
return sb.toString(); ret = sb.toString();
} }else{
ret = sb.append(this.getName().toString()).toString();
return sb.append(this.getName().toString()).toString(); }
if(!ret.equals(getName().toString())){
//getSuperWildcardTypes();
RefType superClass = new RefType(this.getName(),newParams,this.getOffset());
Class generatedClass = ASTFactory.createInterface(ret, superClass, null, null, new SourceFile());
cg.addExtraClass(generatedClass.genByteCode(new TypeinferenceResults()).getByteCode());
}
return ret;
} }
/*
public GenericClassType getGenericClassType(){ public GenericClassType getGenericClassType(){
return new GenericClassType(getName().toString(), getParaList(), parent, getOffset()); return new GenericClassType(getName().toString(), getParaList(), parent, getOffset());
} }
*/
} }
// ino.end // ino.end

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.type;
// ino.end // ino.end
// ino.module.Type.8677.import // ino.module.Type.8677.import
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.bytecode.ClassGenerator;
@ -26,16 +27,9 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
protected JavaClassName name; protected JavaClassName name;
private int offset; private int offset;
public Type(String s, int offset)
{
this.offset = offset;
this.name = new JavaClassName(s);
}
// ino.end
public Type(JavaClassName s, int offset) public Type(JavaClassName s, int offset)
{ {
super(offset);
this.offset = offset; this.offset = offset;
this.name = s; this.name = s;
} }
@ -290,5 +284,15 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs){ public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs){
return this.getBytecodeSignature(cg, rs); return this.getBytecodeSignature(cg, rs);
} }
/**
* Wird beim Bytecode gebraucht.
* Einige Klassen werden vom Compiler als gegeben angenommen,
* obwohl sie sich nicht in der Java Standard Library befinden.
* Diese müssen beim generieren von Bytecode als zusätzliche Klassen generiert werden.
*
* @return - Eine Liste der Klassen, welche bei Verwendung dieses Typs zusätzlich gebraucht werden.
*/
//public abstract List<de.dhbwstuttgart.syntaxtree.Class> isClassFromJavaX();
} }
// ino.end // ino.end

View File

@ -40,9 +40,7 @@ public class TypePlaceholder extends ObjectType
// ino.class.TypePlaceholder.26780.body // ino.class.TypePlaceholder.26780.body
{ {
private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName()); private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName());
// ino.attribute.strNextName.26785.declaration
// ino.end
// ino.attribute.m_TypePlaceholdersRegistry.26788.declaration
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>(); private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
// ino.end // ino.end
private SyntaxTreeNode parent; private SyntaxTreeNode parent;
@ -61,14 +59,12 @@ public class TypePlaceholder extends ObjectType
*/ */
private TypePlaceholder(String typeName, SyntaxTreeNode parent) private TypePlaceholder(String typeName, SyntaxTreeNode parent)
{ {
super(typeName, -1); super(new JavaClassName(typeName), -1);
if(typeName == null)throw new NullPointerException(); if(typeName == null)throw new NullPointerException();
this.name = new JavaClassName(typeName); this.name = new JavaClassName(typeName);
if(parent != null)log.debug("Erstelle TPH "+typeName+" für SyntaxTreeNode: "+parent, Section.TYPEINFERENCE); if(parent != null)log.debug("Erstelle TPH "+typeName+" für SyntaxTreeNode: "+parent, Section.TYPEINFERENCE);
} }
// ino.end
// ino.method.getInstance.26797.defdescription type=javadoc
/** /**
* Statische Methode, um einen TypePlaceholder aus der Registry zu holen. * Statische Methode, um einen TypePlaceholder aus der Registry zu holen.
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle * <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
@ -76,15 +72,10 @@ public class TypePlaceholder extends ObjectType
* @return Der TypePlaceholder oder <code>null</code>, falls er nicht in der * @return Der TypePlaceholder oder <code>null</code>, falls er nicht in der
* Registry existiert * Registry existiert
*/ */
// ino.end
// ino.method.getInstance.26797.definition
public static TypePlaceholder getInstance(String name) public static TypePlaceholder getInstance(String name)
// ino.end
// ino.method.getInstance.26797.body
{ {
return m_TypePlaceholdersRegistry.get(name); return m_TypePlaceholdersRegistry.get(name);
} }
// ino.end
/** /**
* Generiert einen neuen TPH mit einem bestimmten Namen. * Generiert einen neuen TPH mit einem bestimmten Namen.
@ -93,8 +84,6 @@ public class TypePlaceholder extends ObjectType
* @return * @return
*/ */
public static TypePlaceholder fresh(String name, SyntaxTreeNode parent) public static TypePlaceholder fresh(String name, SyntaxTreeNode parent)
// ino.end
// ino.method.fresh.26800.body
{ {
TypePlaceholder typeVar = new TypePlaceholder(name, parent); TypePlaceholder typeVar = new TypePlaceholder(name, parent);
TypePlaceholder oldTPH = m_TypePlaceholdersRegistry.put(typeVar.getName().toString(), typeVar); TypePlaceholder oldTPH = m_TypePlaceholdersRegistry.put(typeVar.getName().toString(), typeVar);
@ -104,7 +93,6 @@ public class TypePlaceholder extends ObjectType
} }
return typeVar; return typeVar;
} }
// ino.end
/** /**
@ -127,17 +115,12 @@ public class TypePlaceholder extends ObjectType
return ret; return ret;
} }
// ino.method.equals.26812.defdescription type=javadoc
/** /**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/> * Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
* @param Object * @param Object
* @return * @return
*/ */
// ino.end
// ino.method.equals.26812.definition
public boolean equals(Object obj) public boolean equals(Object obj)
// ino.end
// ino.method.equals.26812.body
{ {
if(obj instanceof TypePlaceholder){ if(obj instanceof TypePlaceholder){
return this.toString().equals(((TypePlaceholder)obj).toString()); return this.toString().equals(((TypePlaceholder)obj).toString());
@ -147,27 +130,18 @@ public class TypePlaceholder extends ObjectType
return false; return false;
} }
} }
// ino.end
// ino.method.deleteRegistry.26839.defdescription type=javadoc
/** /**
* ¯Â¿Â½scht die komplette Registry von TypePlaceholders. Sollte nur und * ¯Â¿Â½scht die komplette Registry von TypePlaceholders. Sollte nur und
* ausschlie�lich von <code>MyCompiler.init()</code> aufgerufen werden!!! * ausschlie�lich von <code>MyCompiler.init()</code> aufgerufen werden!!!
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle * <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
*/ */
// ino.end
// ino.method.deleteRegistry.26839.definition
public static void deleteRegistry() public static void deleteRegistry()
// ino.end
// ino.method.deleteRegistry.26839.body
{ {
m_TypePlaceholdersRegistry.clear(); m_TypePlaceholdersRegistry.clear();
m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>(); m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
} }
// ino.end
// ino.method.clone.26842.defdescription type=javadoc
/** /**
* Diese Methode sollte nur sehr sparsam und mit Vorsicht verwendet werden, da die * Diese Methode sollte nur sehr sparsam und mit Vorsicht verwendet werden, da die
* Registrierung neuer Listener �ber die zentrale Instanz in der Registry laufen * Registrierung neuer Listener �ber die zentrale Instanz in der Registry laufen
@ -178,16 +152,11 @@ public class TypePlaceholder extends ObjectType
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle * <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return * @return
*/ */
// ino.end
// ino.method.clone.26842.definition
public TypePlaceholder clone() public TypePlaceholder clone()
// ino.end
// ino.method.clone.26842.body
{ {
TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent); TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent);
return dolly; return dolly;
} }
// ino.end
/** /**
* @author Andreas Stadelmeier, a10023 * @author Andreas Stadelmeier, a10023
@ -198,14 +167,10 @@ public class TypePlaceholder extends ObjectType
return getName().toString(); return getName().toString();
} }
// ino.method.toString.26845.definition
public String toString() public String toString()
// ino.end
// ino.method.toString.26845.body
{ {
return "TPH " + this.getName(); return "TPH " + this.getName();
} }
// ino.end
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// Spezialfunktionen, ¯Â¿Â½r makeFC() und unify() // Spezialfunktionen, ¯Â¿Â½r makeFC() und unify()
@ -269,11 +234,7 @@ public class TypePlaceholder extends ObjectType
* @param name * @param name
* @return * @return
*/ */
// ino.end
// ino.method.backdoorCreate.26854.definition
public static TypePlaceholder backdoorCreate(String name) public static TypePlaceholder backdoorCreate(String name)
// ino.end
// ino.method.backdoorCreate.26854.body
{ {
//PL 05-08-22 SEHR GEFAEHRLICH //PL 05-08-22 SEHR GEFAEHRLICH
@ -286,7 +247,7 @@ public class TypePlaceholder extends ObjectType
//return new TypePlaceholder(name); //return new TypePlaceholder(name);
} }
// ino.end
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// Ende Spezialfunktionen // Ende Spezialfunktionen
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -350,6 +311,10 @@ public class TypePlaceholder extends ObjectType
@Override @Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) { public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
if(rs == null){
System.out.println("");
return null;
}
Type resolvedType = rs.getTypeOfPlaceholder(this); Type resolvedType = rs.getTypeOfPlaceholder(this);
if(resolvedType instanceof TypePlaceholder){ if(resolvedType instanceof TypePlaceholder){
cg.addUsedTPH((TypePlaceholder)resolvedType); cg.addUsedTPH((TypePlaceholder)resolvedType);
@ -366,7 +331,8 @@ public class TypePlaceholder extends ObjectType
ret+=":"; ret+=":";
Menge<TypePlaceholder> possibleTPHs = cg.getUsedTPH(); Menge<TypePlaceholder> possibleTPHs = cg.getUsedTPH();
possibleTPHs.remove(this); possibleTPHs.remove(this);
org.apache.bcel.generic.Type nearestType = cg.getNearestUsedType(this, possibleTPHs); //TODO: hier komplett überarbeiten. Wann wird ein TPH eine generische Variable, das sollte geklärt werden.
org.apache.bcel.generic.Type nearestType = null;//cg.getNearestUsedType(this, possibleTPHs);
//if(nearestType instanceof TypePlaceholderType){ //Handelt es sich um einen weiteren TPH als nächsten Typ, so ist es ein allgemeiner Typ und wir nehmen Object als Superklasse //if(nearestType instanceof TypePlaceholderType){ //Handelt es sich um einen weiteren TPH als nächsten Typ, so ist es ein allgemeiner Typ und wir nehmen Object als Superklasse
if(nearestType == null){ if(nearestType == null){
ret += cg.getInstructionFactory().createObjectType().getSignature(); ret += cg.getInstructionFactory().createObjectType().getSignature();
@ -377,4 +343,3 @@ public class TypePlaceholder extends ObjectType
} }
} }
// ino.end

View File

@ -18,4 +18,4 @@ public class IdTest extends SourceFileBytecodeTest{
Object obj = cls.newInstance(); Object obj = cls.newInstance();
assertTrue(true); assertTrue(true);
} }
} }

View File

@ -1,4 +1,7 @@
class Identity{ class Identity{
op = (x)->x; op = (x)->x;
m(){
op.apply(1);
}
} }

View File

@ -1,9 +1,9 @@
class LambdaExpr { class LambdaExpr {
void method() { method() {
lambda; lambda;
lambda = () -> 1; lambda = (Integer a) -> a;
return lambda;
} }
} }

View File

@ -38,21 +38,18 @@ public class SingleClassTester {
Menge<ByteCodeResult> bytecode = compiler.generateBytecode(sourceFiles, results); Menge<ByteCodeResult> bytecode = compiler.generateBytecode(sourceFiles, results);
//System.out.println(bytecode); //System.out.println(bytecode);
for(ByteCodeResult result: bytecode){ for(ByteCodeResult result: bytecode){
JavaClass javaClass = result.getByteCode().getJavaClass(); JavaClass javaClass = result.getByteCode().getJavaClass();
javaClass.dump(new File(outputDirectory+javaClass.getClassName()+".class")); javaClass.dump(new File(outputDirectory+javaClass.getClassName()+".class"));
///*
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){ for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
JavaClass jc = cg.getJavaClass(); JavaClass jc = cg.getJavaClass();
jc.dump(new File(outputDirectory+jc.getClassName()+".class")); jc.dump(new File(outputDirectory+jc.getClassName()+".class"));
} }
//*/
Logger.getLogger("SingleClassTester").error(result.getByteCode().getJavaClass().toString(), Section.CODEGEN); Logger.getLogger("SingleClassTester").error(result.getByteCode().getJavaClass().toString(), Section.CODEGEN);
} }
} catch (IOException | yyException e) { } catch (IOException | yyException e) {
Logger.getLogger("SingleClassTester").error(e.toString(), Section.CODEGEN); Logger.getLogger("SingleClassTester").error(e.toString(), Section.CODEGEN);

View File

@ -4,6 +4,8 @@ import static org.junit.Assert.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
@ -60,4 +62,13 @@ public abstract class SourceFileBytecodeTest extends TestCase{
return new URLClassLoader(urls); return new URLClassLoader(urls);
} }
protected void testMethod(String methodName) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{
Class testClass = getClassToTest();
for(Method m : testClass.getMethods()){
if(m.getName().equals(methodName)){
m.invoke(testClass, new Object[0]);
}
}
}
} }

View File

@ -0,0 +1,8 @@
class Simple{
op = (i)->i;
public void main(){
op.apply(1);
}
}

View File

@ -0,0 +1,19 @@
package bytecode.lambda;
import org.junit.Test;
import bytecode.SourceFileBytecodeTest;
public class SimpleTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "Simple";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/lambda/";
}
@Test
public void testConstruct() throws Exception{
this.testMethod("main");
assertTrue(true);
}
}

View File

@ -0,0 +1,5 @@
class Test{
public static void main(String[] args){
new Simple().main();
}
}

View File

@ -0,0 +1 @@
interface TestInterface extends Fun1<String,Integer>{}

View File

@ -1,4 +1,8 @@
class Id{ class Id {
op = (x)->x; op = (x) -> x;
}
m(){
op.apply(1);
}
}