Fehler beseitigt. wandleRefType2GenericVariables überarbeitet. getChildren()-Methode für alle Statements implementiert

This commit is contained in:
JanUlrich 2014-03-27 16:43:07 +01:00
parent b6e2d75174
commit 9784a10f84
30 changed files with 7905 additions and 7778 deletions

View File

@ -313,7 +313,8 @@ public Vector<Pair> testPair = new Vector<Pair>();
%type <Statement> explicitconstructorinvocation %type <Statement> explicitconstructorinvocation
%type <Method> staticinitializer %type <Method> staticinitializer
%type <CastExpr> castexpression %type <CastExpr> castexpression
%type <ParaList> paralist parameter %type <ParaList> paralist
%type <Vector> typelist parameter
%type <WildcardType> wildcardparameter %type <WildcardType> wildcardparameter
%left ',' %left ','
%% %%
@ -785,17 +786,30 @@ classbodydeclaration : classmemberdeclaration
classorinterfacetype : simplename parameter classorinterfacetype : simplename parameter
{ {
if ($2 != null) { if ($2 != null) {
$1.set_ParaList($2.get_ParaList()); //$1.set_ParaList($2.get_ParaList());
$1.set_ParaList($2);//Änderung von Andreas Stadelmeier. Type statt GenericVarType
/* otth: originale (also diese) Parameterliste retten */ /* otth: originale (also diese) Parameterliste retten */
((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() ); //((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
} }
$$=$1; $$=$1;
} }
typelist : type
{
Vector<Type> tl = new Vector<Type>();
tl.add($1);
$$ = tl;
}
| typelist ',' type
{
$1.add($3);
$$=$1;
}
/* PL 05-07-28 erg<72>nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */ /* PL 05-07-28 erg<72>nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */
//TODO: Das hier ist möglicherweise falsch. Ein Typ hat keine parameterliste, nur eine Liste von RefTypes
parameter : { $$ = null; } parameter : { $$ = null; }
| '<'paralist'>' | '<'typelist'>'//'<'paralist'>'//typelist statt
{ {
$$ = $2; $$ = $2;
} }

View File

@ -69,7 +69,7 @@ import typinferenz.UndConstraint;
import typinferenz.FunN; import typinferenz.FunN;
import typinferenz.assumptions.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import typinferenz.exceptions.TypinferenzException; import typinferenz.exceptions.TypinferenzException;
import typinferenz.*;
// ino.class.Class.23010.declaration // ino.class.Class.23010.declaration
@ -953,8 +953,10 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
// ino.end // ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23128.body // ino.method.wandleRefTypeAttributes2GenericAttributes.23128.body
{ {
for(Field f : this.getFields()){
f.wandleRefTypeAttributes2GenericAttributes(paralist);
}
/*
Vector fieldsAndMethods=this.getFields(); Vector fieldsAndMethods=this.getFields();
// Alle Methoden und Instanzvariablen durchgehen // Alle Methoden und Instanzvariablen durchgehen
@ -965,7 +967,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
Method method=(Method)fieldsAndMethods.get(i); Method method=(Method)fieldsAndMethods.get(i);
method.wandleRefTypeAttributes2GenericAttributes(paralist); method.wandleRefTypeAttributes2GenericAttributes(paralist);
}// Ist es eine InstanzVariable? }// Ist es eine InstanzVariable?
/* *//*
else if(fieldsAndMethods.get(i) instanceof InstVarDecl){ else if(fieldsAndMethods.get(i) instanceof InstVarDecl){
InstVarDecl instVar=(InstVarDecl)fieldsAndMethods.get(i); InstVarDecl instVar=(InstVarDecl)fieldsAndMethods.get(i);
Type type=instVar.getType(); Type type=instVar.getType();
@ -976,8 +978,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
instVar.setType(pendant); instVar.setType(pendant);
} }
} }
}*/
} }
}*/
} }
// ino.end // ino.end
@ -1302,6 +1305,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName(), this)); Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName(), this));
this.addField(standardKonstruktor); this.addField(standardKonstruktor);
} }
//Als RefType geparste Generische Variablen umwandeln:
this.wandleRefTypeAttributes2GenericAttributes();
} }
@Override @Override

View File

@ -324,3 +324,61 @@ public class Constructor extends Method {
} }
/*
// ino.class.Constructor.23267.declaration
public class Constructor_Backup extends Method
// ino.end
// ino.class.Constructor.23267.body
{
// ino.method.Constructor.23271.definition
public Constructor_Backup()
// ino.end
// ino.method.Constructor.23271.body
{
this.setParameterList(null);
// #JB# 04.06.2005
// ###########################################################
DeclId decl = new DeclId();
decl.set_Name("<init>");
this.set_DeclId(decl);
// ###########################################################
}
// ino.end
// ino.method.get_codegen_Param_Type.23274.definition
public String get_codegen_Param_Type(Vector paralist)
// ino.end
// ino.method.get_codegen_Param_Type.23274.body
{
String ret = new String();
if(this.getParameterList() == null)
{
ret += "()";
}
else
{
ret += this.getParameterList().get_codegen_ParameterList(paralist);
}
ret += "V";
return ret;
}
// ino.end
// ino.method.codegen.23277.definition
public void codegen(ClassFile classfile, Vector paralist)
throws JVMCodeException
// ino.end
// ino.method.codegen.23277.body
{
classfile.set_constructor_founded(true);
classfile.add_method("<init>", this.get_codegen_Param_Type(paralist), this.getParameterList(), null, get_Block(), declid.firstElement().get_access_flags(), paralist, false);
}
// ino.end
}
*/

View File

@ -1,79 +0,0 @@
// ino.module.Constructor.8557.package
package mycompiler.myclass;
// ino.end
// ino.module.Constructor.8557.import
import java.util.Iterator;
import java.util.Vector;
import typinferenz.ConstraintsSet;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException;
// ino.end
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
// ino.class.Constructor.23267.declaration
public class Constructor_Backup extends Method
// ino.end
// ino.class.Constructor.23267.body
{
// ino.method.Constructor.23271.definition
public Constructor_Backup()
// ino.end
// ino.method.Constructor.23271.body
{
this.setParameterList(null);
// #JB# 04.06.2005
// ###########################################################
DeclId decl = new DeclId();
decl.set_Name("<init>");
this.set_DeclId(decl);
// ###########################################################
}
// ino.end
// ino.method.get_codegen_Param_Type.23274.definition
public String get_codegen_Param_Type(Vector paralist)
// ino.end
// ino.method.get_codegen_Param_Type.23274.body
{
String ret = new String();
if(this.getParameterList() == null)
{
ret += "()";
}
else
{
ret += this.getParameterList().get_codegen_ParameterList(paralist);
}
ret += "V";
return ret;
}
// ino.end
// ino.method.codegen.23277.definition
public void codegen(ClassFile classfile, Vector paralist)
throws JVMCodeException
// ino.end
// ino.method.codegen.23277.body
{
classfile.set_constructor_founded(true);
classfile.add_method("<init>", this.get_codegen_Param_Type(paralist), this.getParameterList(), null, get_Block(), declid.firstElement().get_access_flags(), paralist, false);
}
// ino.end
}
// ino.end

View File

@ -5,6 +5,7 @@ import java.util.Vector;
import mycompiler.SyntaxTreeNode; import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent; import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
@ -104,4 +105,12 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
return new TypeInsertPoint(tph, this, resultSet.getTypeEqualTo(tph), resultSet); return new TypeInsertPoint(tph, this, resultSet.getTypeEqualTo(tph), resultSet);
} }
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist){
// Zuerst Returntype untersuchen
Type type=getType();
GenericTypeVar pendantReturnType=ClassHelper.findGenericType(type, paralist,new Vector<GenericTypeVar>());
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
setType(pendantReturnType);
}
}
} }

View File

@ -14,6 +14,7 @@ import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
import mycompiler.mystatement.Expr; import mycompiler.mystatement.Expr;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent; import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
@ -127,6 +128,10 @@ public class FieldDeclaration extends Field{
return ret; return ret;
} }
@Override
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist){
super.wandleRefTypeAttributes2GenericAttributes(paralist);
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Vector<GenericTypeVar>()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
}
} }

View File

@ -497,11 +497,9 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
{ {
return isAbstract; return isAbstract;
} }
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23614.definition @Override
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist)
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.23614.body
{ {
// Zuerst Returntype untersuchen // Zuerst Returntype untersuchen
Type returnType=getType(); Type returnType=getType();

File diff suppressed because it is too large Load Diff

View File

@ -313,7 +313,8 @@ public Vector<Pair> testPair = new Vector<Pair>();
%type <Statement> explicitconstructorinvocation %type <Statement> explicitconstructorinvocation
%type <Method> staticinitializer %type <Method> staticinitializer
%type <CastExpr> castexpression %type <CastExpr> castexpression
%type <ParaList> paralist parameter %type <ParaList> paralist
%type <Vector> typelist parameter
%type <WildcardType> wildcardparameter %type <WildcardType> wildcardparameter
%left ',' %left ','
%% %%
@ -785,17 +786,30 @@ classbodydeclaration : classmemberdeclaration
classorinterfacetype : simplename parameter classorinterfacetype : simplename parameter
{ {
if ($2 != null) { if ($2 != null) {
$1.set_ParaList($2.get_ParaList()); //$1.set_ParaList($2.get_ParaList());
$1.set_ParaList($2);//Änderung von Andreas Stadelmeier. Type statt GenericVarType
/* otth: originale (also diese) Parameterliste retten */ /* otth: originale (also diese) Parameterliste retten */
((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() ); //((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
} }
$$=$1; $$=$1;
} }
typelist : type
{
Vector<Type> tl = new Vector<Type>();
tl.add($1);
$$ = tl;
}
| typelist ',' type
{
$1.add($3);
$$=$1;
}
/* PL 05-07-28 erg<72>nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */ /* PL 05-07-28 erg<72>nzt, weil jeder classorinterfacetype auch parametrisiert sein kann */
//TODO: Das hier ist möglicherweise falsch. Ein Typ hat keine parameterliste, nur eine Liste von RefTypes
parameter : { $$ = null; } parameter : { $$ = null; }
| '<'paralist'>' | '<'typelist'>'//'<'paralist'>'//typelist statt
{ {
$$ = $2; $$ = $2;
} }

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -150,5 +152,14 @@ public class CastExpr extends UnaryExpr
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -114,5 +114,10 @@ public class EmptyStmt extends Statement
return new JavaCodeResult(""); return new JavaCodeResult("");
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
return new Vector<SyntaxTreeNode>();
}
} }
// ino.end // ino.end

View File

@ -7,6 +7,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -34,6 +35,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
@ -274,5 +276,12 @@ public class InstVar extends Expr
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult().attach(this.expr.printJavaCode(resultSet)).attach("."+this.usedid.get_Name_1Element()); return new JavaCodeResult().attach(this.expr.printJavaCode(resultSet)).attach("."+this.usedid.get_Name_1Element());
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -27,6 +28,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -151,6 +153,13 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -17,6 +17,7 @@ import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
import mycompiler.myclass.ClassHelper;
import mycompiler.myclass.FormalParameter; import mycompiler.myclass.FormalParameter;
import mycompiler.myclass.Method; import mycompiler.myclass.Method;
import mycompiler.myclass.ParameterList; import mycompiler.myclass.ParameterList;
@ -81,8 +82,28 @@ public class LambdaExpression extends Expr{
public void wandleRefTypeAttributes2GenericAttributes( public void wandleRefTypeAttributes2GenericAttributes(
Vector<Type> paralist, Vector<Type> paralist,
Vector<GenericTypeVar> genericMethodParameters) { Vector<GenericTypeVar> genericMethodParameters) {
// TODO Auto-generated method stub Block block = this.method_body;
// Zuerst Returntype untersuchen
Type returnType=getType();
GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
setType(pendantReturnType);
}
// Dann parameterlist untersuchen
for(FormalParameter fp : params){
Type fpType=fp.getType();
// Nur wenn es sich um ein RefType-Field handelt
GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
fp.setType(pendantPara);
}
}
// Zuletzt alle Lokalen Variablendeklarationen durchgehen
if(block!=null){
block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
}
} }
@Override @Override

View File

@ -39,10 +39,12 @@ import org.apache.log4j.Logger;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeInsertPoint;
import typinferenz.TypeInsertable; import typinferenz.TypeInsertable;
import typinferenz.assumptions.LocalVarAssumption; import typinferenz.assumptions.LocalVarAssumption;
import typinferenz.assumptions.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
@ -493,5 +495,11 @@ public class LocalVarDecl extends Statement implements TypeInsertable
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>(); Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
return ret; return ret;
} }
@Override
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
ResultSet resultSet) {
return new TypeInsertPoint(tph, this, resultSet.getTypeEqualTo(tph),resultSet);
}
} }
// ino.end // ino.end

View File

@ -236,7 +236,7 @@ public class MethodCall extends Expr
ParameterList pl=new ParameterList(); ParameterList pl=new ParameterList();
for(int i=0;i<paraAssumptions.size();i++){ for(int i=0;i<paraAssumptions.size();i++){
CParaTypeAssumption paraassumtion=paraAssumptions.elementAt(i); CParaTypeAssumption paraassumtion=paraAssumptions.elementAt(i);
FormalParameter fp=new FormalParameter(); FormalParameter fp=new FormalParameter(new DeclId());
fp.setType(paraassumtion.getAssumedType()); fp.setType(paraassumtion.getAssumedType());
parameterVector.addElement(fp); parameterVector.addElement(fp);
} }

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -30,6 +31,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -144,5 +146,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -23,6 +24,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -202,5 +204,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.addAll(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -29,6 +30,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -163,5 +165,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -22,6 +23,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -143,5 +145,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -182,5 +184,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -182,5 +184,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -179,6 +181,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -31,6 +32,7 @@ import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -183,5 +185,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr);
return ret;
}
} }
// ino.end // ino.end

View File

@ -142,6 +142,7 @@ public class FunN extends RefType implements ITypeReplacementListener{
} }
*/ */
/*
@Override @Override
public JavaCodeResult printJavaCode(ResultSet resultSet){ public JavaCodeResult printJavaCode(ResultSet resultSet){
//String ret = super.printJavaCode(resultSet) + (T!=null ? this.T.size() : 0) +"<"; //String ret = super.printJavaCode(resultSet) + (T!=null ? this.T.size() : 0) +"<";
@ -156,7 +157,7 @@ public class FunN extends RefType implements ITypeReplacementListener{
//ret = ret.substring(0, ret.length()-2); //ret = ret.substring(0, ret.length()-2);
return ret.attach(">"); return ret.attach(">");
} }
*/
/** /**
* Die Clone-Methode von RefType darf von FunN NICHT überschrieben werden. * Die Clone-Methode von RefType darf von FunN NICHT überschrieben werden.
@Override @Override

View File

@ -265,7 +265,15 @@ public class TypeAssumptions {
return new RefType(thisClassName, 0); return new RefType(thisClassName, 0);
} }
/**
* Prüft einen Typ auf das vorhandensein in den BasicAssumptions.
* Dabei werden alle Konstruktoren nach diesem Typ durchsucht. Denn jede Klasse hat einen Konstruktor und der muss in den TypeAssumptions vorhanden sein.
* @param t
* @return
public Type validateType(Type t){
return null;
}
*/
} }

View File

@ -1,12 +1,26 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: TestMethodCallMethod Assumptions: Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions:
[MethodAssumption: TPH B null { [null Return null (this(null))], MethodAssumption: TPH C null { [null Return null (null.getSomething( [ ]))], MethodAssumption: void void { [(var = null (null.getSomethingMore( [ ])))], MethodAssumption: TPH B null { [null Return null (this(null))], MethodAssumption: TPH C null { [null Return null (null.getSomething( [ ]))], MethodAssumption: void void { [(var = null (null.getSomethingMore( [ ])))], MethodAssumption: TPH E , MethodAssumption: TPH F , MethodAssumption: TPH H , MethodAssumption: TPH K , MethodAssumption: TPH O , MethodAssumption: TPH T , MethodAssumption: TPH B null { [null Return null (this(null))], MethodAssumption: TPH C null { [null Return null (null.getSomething( [ ]))], MethodAssumption: void void { [(var = null (null.getSomethingMore( [ ])))], MethodAssumption: TPH B null { [null Return null (this(null))], MethodAssumption: TPH C null { [null Return null (null.getSomething( [ ]))], MethodAssumption: void void { [(var = null (null.getSomethingMore( [ ])))]] [MethodAssumption: GTV R , MethodAssumption: GTV R , MethodAssumption: GTV R , MethodAssumption: GTV R , MethodAssumption: GTV R , MethodAssumption: GTV R ]
FieldVar Assumptions: FieldVar Assumptions:
[typinferenz.assumptions.FieldAssumption@6744719c, typinferenz.assumptions.FieldAssumption@3e7eedbb, typinferenz.assumptions.FieldAssumption@6744719c, typinferenz.assumptions.FieldAssumption@3e7eedbb] [FieldAssumption: TPH A op, FieldAssumption: TPH A op, FieldAssumption: TPH A op, FieldAssumption: TPH A op]
LocalVar Assumptions: LocalVar Assumptions:
[] []
Parameter Assumptions: Parameter Assumptions:
[] []
Block DEBUG [Typeinference] Prozessing statement: null Return null (this(null)) Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ f, ]) -> null { [null Return null (f.apply( [ null (this(null)), m, ]))])
Block DEBUG [Typeinference] Prozessing statement: TPH Z Return TestMethodCall (this(null)) Block DEBUG [Typeinference] Prozessing statement: null Return null (f.apply( [ null (this(null)), m, ]))
Block DEBUG [Typeinference] Prozessing statement: null Return null (null.getSomething( [ ])) Block DEBUG [Typeinference] Prozessing statement: TPH H Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ]))
Block DEBUG [Typeinference] Prozessing statement: TPH I Return TPH F (( [ TPH E f, ]) -> TPH H { [TPH H Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ]))])
Class DEBUG [Typeinference] Erstellte Constraints: TPH A < TPH A
[[(R <. TPH G), (Matrix <. T1), (TPH C <. T2), (TPH E <. Fun2< GTV R, GTV T1, GTV T2 >), ]| ]
TPH G < TPH H
Fun1< TPH H, TPH E > < TPH F
TPH F < TPH I
Fun1< TPH I, TPH C > < TPH D
TPH D < TPH A
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (R <. TPH G), (Matrix <. T1), (TPH C <. T2), (TPH E <. Fun2< GTV R, GTV T1, GTV T2 >), (TPH G <. TPH H), (Fun1< TPH H, TPH E > <. TPH F), (TPH F <. TPH I), (Fun1< TPH I, TPH C > <. TPH D), (TPH D <. TPH A)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: []
SourceFile DEBUG [Typeinference]
JavaFiles:

View File

@ -0,0 +1,5 @@
class LambdaTest{
Fun1<String, String> op = (var) -> {return var;};
}

View File

@ -0,0 +1,18 @@
package plugindevelopment.TypeInsertTests;
import java.util.Vector;
import org.junit.Test;
public class LambdaTest4 {
private static final String TEST_FILE = "LambdaTest4.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
mustContain.add("String var");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
}
}

File diff suppressed because it is too large Load Diff