Methodenparameter können nun auch inferiert werden

This commit is contained in:
JanUlrich 2014-03-18 13:38:47 +01:00
parent 75f9a74c44
commit 59106a7e7b
4 changed files with 51 additions and 2 deletions

View File

@ -3,6 +3,9 @@ package mycompiler.myclass;
// ino.end
// ino.module.FormalParameter.8561.import
import java.util.Vector;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mytype.Type;
@ -16,6 +19,8 @@ import org.apache.log4j.Logger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
@ -23,7 +28,7 @@ import typinferenz.Typeable;
import typinferenz.TypeInsertable;
// ino.class.FormalParameter.23391.declaration
public class FormalParameter implements ITypeReplacementListener, Typeable, TypeInsertable
public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementListener, Typeable, TypeInsertable
// ino.end
// ino.class.FormalParameter.23391.body
{
@ -213,5 +218,20 @@ public class FormalParameter implements ITypeReplacementListener, Typeable, Type
}
@Override
public Vector<SyntaxTreeNode> getChildren() {
return new Vector<SyntaxTreeNode>();
}
@Override
public void parserPostProcessing(SyntaxTreeNode parent) {
super.parserPostProcessing(parent);
if(this.type==null)this.type = TypePlaceholder.fresh(this);
}
}
// ino.end

View File

@ -59,7 +59,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
private Block block;
// ino.end
// ino.attribute.parameterlist.23491.declaration
public ParameterList parameterlist = null;
public ParameterList parameterlist = new ParameterList();
// ino.end
// ino.attribute.exceptionlist.23494.declaration
private ExceptionList exceptionlist;
@ -668,6 +668,9 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.block);
for(FormalParameter param : this.parameterlist){
ret.add(param);
}
return ret;
}

View File

@ -58,4 +58,16 @@ public class TypeInsertPoint {
public TypeInsertable getInsertNode(){
return this.point;
}
@Override
public boolean equals(Object obj){
if(! (obj instanceof TypeInsertPoint))return false;
TypeInsertPoint equals = (TypeInsertPoint) obj;
if(!(equals.point.equals(this.point)))return false;
if(!(equals.tph.equals(this.tph)))return false;
if(!(equals.resultSet.equals(this.resultSet)))return false;
if(!(equals.type.equals(this.type)))return false;
return true;
}
}

View File

@ -52,4 +52,18 @@ public class TypeInsertSet {
return null;
}
@Override
public boolean equals(Object obj){
if(! (obj instanceof TypeInsertSet))return false;
TypeInsertSet equals = (TypeInsertSet) obj;
for(TypeInsertPoint point : points){
//Jeder TypeInsertPoint muss auch in equals vorkommen:
if(!equals.points.contains(point))return false;
//... aber nicht öfter als 1x :
if(equals.points.lastIndexOf(point)!=equals.points.indexOf(point))return false;
}
return true;
}
}