forked from JavaTX/JavaCompilerCore
Einsetzen von generischen Variablen
This commit is contained in:
parent
0327894686
commit
694899e73f
@ -65,6 +65,9 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
@ -75,13 +78,14 @@ import typinferenz.UndConstraint;
|
|||||||
import typinferenz.FunN;
|
import typinferenz.FunN;
|
||||||
import typinferenz.assumptions.ClassAssumption;
|
import typinferenz.assumptions.ClassAssumption;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
import typinferenz.exceptions.DebugException;
|
||||||
import typinferenz.exceptions.TypeinferenceException;
|
import typinferenz.exceptions.TypeinferenceException;
|
||||||
import typinferenz.typedeployment.TypeInsertPoint;
|
import typinferenz.typedeployment.TypeInsertPoint;
|
||||||
import typinferenz.*;
|
import typinferenz.*;
|
||||||
|
|
||||||
|
|
||||||
// ino.class.Class.23010.declaration
|
// ino.class.Class.23010.declaration
|
||||||
public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWithOffset, Generic
|
public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWithOffset, Generic, GenericTypeInsertable
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Class.23010.body
|
// ino.class.Class.23010.body
|
||||||
{
|
{
|
||||||
@ -1355,6 +1359,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<GenericTypeVar> getGenericParameter() {
|
||||||
|
if(this.genericClassParameters == null)return new Vector<GenericTypeVar>();
|
||||||
|
return this.genericClassParameters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
return "class "+this.getName();
|
return "class "+this.getName();
|
||||||
@ -1373,8 +1383,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
@Override
|
@Override
|
||||||
public int getGenericDeclOffset() {
|
public int getGenericDeclOffset() {
|
||||||
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
return -1;
|
return this.getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -35,6 +35,7 @@ public class Constructor extends Method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public void setGenericMethodParameters(
|
public void setGenericMethodParameters(
|
||||||
Vector<GenericTypeVar> genericMethodParameters) {
|
Vector<GenericTypeVar> genericMethodParameters) {
|
||||||
@ -47,7 +48,7 @@ public class Constructor extends Method {
|
|||||||
|
|
||||||
return this.methode.getGenericMethodParameters();
|
return this.methode.getGenericMethodParameters();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sc_init_parameterlist(boolean ext) {
|
public void sc_init_parameterlist(boolean ext) {
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import mycompiler.mytype.Type;
|
|||||||
import mycompiler.mytype.TypePlaceholder;
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
|
import typinferenz.GenericTypeInsertable;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.Typeable;
|
import typinferenz.Typeable;
|
||||||
@ -18,7 +19,7 @@ import typinferenz.TypeInsertable;
|
|||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
import typinferenz.typedeployment.TypeInsertPoint;
|
import typinferenz.typedeployment.TypeInsertPoint;
|
||||||
|
|
||||||
public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Typeable, Generic{
|
public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Typeable, Generic, GenericTypeInsertable{
|
||||||
|
|
||||||
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
||||||
|
|
||||||
@ -53,7 +54,11 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
|||||||
public abstract void codegen(ClassFile classfile, Vector paralist)
|
public abstract void codegen(ClassFile classfile, Vector paralist)
|
||||||
throws JVMCodeException;
|
throws JVMCodeException;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<GenericTypeVar> getGenericParameter() {
|
||||||
|
if(this.genericParameters == null)return new Vector<GenericTypeVar>();
|
||||||
|
return this.genericParameters;
|
||||||
|
}
|
||||||
|
|
||||||
public void set_DeclId(DeclId did)
|
public void set_DeclId(DeclId did)
|
||||||
{
|
{
|
||||||
@ -133,7 +138,7 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
|||||||
@Override
|
@Override
|
||||||
public int getGenericDeclOffset() {
|
public int getGenericDeclOffset() {
|
||||||
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
return -1;
|
return this.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mycompiler.myclass;
|
package mycompiler.myclass;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import mycompiler.mytype.GenericTypeVar;
|
import mycompiler.mytype.GenericTypeVar;
|
||||||
@ -11,9 +12,6 @@ import mycompiler.mytype.GenericTypeVar;
|
|||||||
*/
|
*/
|
||||||
public interface Generic {
|
public interface Generic {
|
||||||
public void setGenericParameter(GenericDeclarationList params);
|
public void setGenericParameter(GenericDeclarationList params);
|
||||||
/**
|
public Iterable<GenericTypeVar> getGenericParameter();
|
||||||
* Gibt den Offset im Quellcode an, an dem neue Deklarationen von generischen Variablen eingesetzt werden können.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getGenericDeclOffset();
|
|
||||||
}
|
}
|
@ -79,7 +79,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.genericMethodParameters.23500.declaration
|
// ino.attribute.genericMethodParameters.23500.declaration
|
||||||
private Vector<GenericTypeVar> genericMethodParameters=new Vector<GenericTypeVar>();
|
//private Vector<GenericTypeVar> genericMethodParameters=new Vector<GenericTypeVar>();
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.attribute.overloadedID.23503.declaration
|
// ino.attribute.overloadedID.23503.declaration
|
||||||
@ -106,6 +106,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
super(offset);
|
super(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// ino.method.setGenericMethodParameters.23521.definition
|
// ino.method.setGenericMethodParameters.23521.definition
|
||||||
public void setGenericMethodParameters(Vector<GenericTypeVar> genericMethodParameters)
|
public void setGenericMethodParameters(Vector<GenericTypeVar> genericMethodParameters)
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -122,7 +123,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
return(genericMethodParameters);
|
return(genericMethodParameters);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
*/
|
||||||
// ino.method.sc_init_parameterlist.23530.definition
|
// ino.method.sc_init_parameterlist.23530.definition
|
||||||
public void sc_init_parameterlist(boolean ext)
|
public void sc_init_parameterlist(boolean ext)
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -502,6 +503,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
@Override
|
@Override
|
||||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> classParalist)
|
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> classParalist)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Vector<Type> paralist = new Vector<Type>();//Mit den Generischen Typen der Methode
|
Vector<Type> paralist = new Vector<Type>();//Mit den Generischen Typen der Methode
|
||||||
paralist.addAll(classParalist);
|
paralist.addAll(classParalist);
|
||||||
paralist.addAll(this.genericMethodParameters);
|
paralist.addAll(this.genericMethodParameters);
|
||||||
@ -532,6 +534,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
if(block!=null){
|
if(block!=null){
|
||||||
block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.set_Method_Name.23617.definition
|
// ino.method.set_Method_Name.23617.definition
|
||||||
@ -550,7 +553,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
TypeAssumptions localAss = new TypeAssumptions();
|
TypeAssumptions localAss = new TypeAssumptions();
|
||||||
localAss.add(ass); //Die globalen Assumptions anhängen
|
localAss.add(ass); //Die globalen Assumptions anhängen
|
||||||
//Generische Parameterdeklarationen den Assumptions anfügen:
|
//Generische Parameterdeklarationen den Assumptions anfügen:
|
||||||
for(GenericTypeVar gtv : this.genericMethodParameters){
|
for(GenericTypeVar gtv : this.getGenericParameter()){
|
||||||
ret.add(gtv.TYPE(localAss));
|
ret.add(gtv.TYPE(localAss));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,6 +757,5 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -57,7 +57,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
|||||||
if(bounds != null)for(Type t : bounds){
|
if(bounds != null)for(Type t : bounds){
|
||||||
//if(t!=null)this.extendVars.add(t);
|
//if(t!=null)this.extendVars.add(t);
|
||||||
}
|
}
|
||||||
this.genericTypeVar = new RefType(s,offset);
|
//this.genericTypeVar = new RefType(s,offset);
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -41,7 +41,7 @@ public class GenericTypeVar extends Type
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.GenericTypeVar.26505.body
|
// ino.class.GenericTypeVar.26505.body
|
||||||
{
|
{
|
||||||
Type genericTypeVar;
|
//Type genericTypeVar;
|
||||||
//Vector<Type> extendVars = new Vector<Type>();
|
//Vector<Type> extendVars = new Vector<Type>();
|
||||||
protected Pair genericConstraint;
|
protected Pair genericConstraint;
|
||||||
/**
|
/**
|
||||||
@ -159,10 +159,11 @@ public class GenericTypeVar extends Type
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
|
/*
|
||||||
if(this.genericTypeVar!=null){
|
if(this.genericTypeVar!=null){
|
||||||
JavaCodeResult ret = new JavaCodeResult();
|
JavaCodeResult ret = new JavaCodeResult();
|
||||||
ret.attach(this.genericTypeVar.printJavaCode(resultSet));
|
ret.attach(this.genericTypeVar.printJavaCode(resultSet));
|
||||||
/*
|
|
||||||
if(this.extendVars.size()>0){
|
if(this.extendVars.size()>0){
|
||||||
ret.attach(" extends ");
|
ret.attach(" extends ");
|
||||||
Iterator<Type> it = this.extendVars.iterator();
|
Iterator<Type> it = this.extendVars.iterator();
|
||||||
@ -172,9 +173,10 @@ public class GenericTypeVar extends Type
|
|||||||
if(it.hasNext())ret.attach(", ");
|
if(it.hasNext())ret.attach(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return new JavaCodeResult(this.name);
|
return new JavaCodeResult(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/typinferenz/GenericTypeInsertable.java
Normal file
14
src/typinferenz/GenericTypeInsertable.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package typinferenz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wird von Knoten im Syntaxbaum implementiert, welche ein Einsetzen von generischen Variablendeklarationen erlauben.
|
||||||
|
*/
|
||||||
|
public interface GenericTypeInsertable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den Offset im Quellcode an, an dem neue Deklarationen von generischen Variablen eingesetzt werden können.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getGenericDeclOffset();
|
||||||
|
|
||||||
|
}
|
@ -21,4 +21,8 @@ public class GenericVarAssumption extends Assumption{
|
|||||||
public String getIdentifier(){
|
public String getIdentifier(){
|
||||||
return genericVar.getName();
|
return genericVar.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return this.getIdentifier() +"::"+this.getAssumedType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package typinferenz.typedeployment;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import typinferenz.GenericTypeInsertable;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
@ -24,16 +25,19 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
|
|
||||||
|
|
||||||
private GenericVarPatch patch;
|
private GenericVarPatch patch;
|
||||||
|
private GenericTypeInsertable genericInsertPoint;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Der Generic Type Insert Point sollte mit Generics konstruiert werden.
|
* TODO: Der Generic Type Insert Point sollte mit Generics konstruiert werden.
|
||||||
* Dabei hält jeder InsertPoint nur ein Generic. Die <>-Klammern fügt das insertSet in den Quellcode ein.
|
* Dabei hält jeder InsertPoint nur ein Generic. Die <>-Klammern fügt das insertSet in den Quellcode ein.
|
||||||
* Die Reihenfolge der GenericTIPs ist beim Einsetzen dann egal.
|
* Die Reihenfolge der GenericTIPs ist beim Einsetzen dann egal.
|
||||||
*/
|
*/
|
||||||
public GenericTypeInsertPoint(TypeInsertable syntaxTreeNode,
|
public GenericTypeInsertPoint(GenericTypeInsertable syntaxTreeNode,
|
||||||
GenericVarPatch gtv ,ResultSet resultSet) {
|
GenericVarPatch gtv ,ResultSet resultSet) {
|
||||||
|
this.resultSet = resultSet;
|
||||||
this.patch = gtv;
|
this.patch = gtv;
|
||||||
this.point = syntaxTreeNode;
|
this.genericInsertPoint = syntaxTreeNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -47,7 +51,7 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
|
|
||||||
|
|
||||||
public String getTypeInsertString() {
|
public String getTypeInsertString() {
|
||||||
return this.patch.getInsertString();
|
return this.patch.getInsertString(this.resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -97,9 +101,6 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TypeInsertable getInsertNode(){
|
|
||||||
return this.point;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Versucht den GenericTypeInsertPoint mit dem <FC>bergebenenen p2 zusam
|
* Versucht den GenericTypeInsertPoint mit dem <FC>bergebenenen p2 zusam
|
||||||
@ -122,8 +123,11 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
@Override
|
@Override
|
||||||
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
||||||
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
||||||
|
JavaCodeResult ret = new JavaCodeResult(fileContent.substring(0, this.getOffset()+additionalOffset));
|
||||||
return super.patch(fileContent, additionalOffset);
|
JavaCodeResult mitte = new JavaCodeResult(this.getTypeInsertString()).attach(fileContent.substring(this.getOffset()+additionalOffset));
|
||||||
|
ret.attach(mitte);
|
||||||
|
//this.
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -143,6 +147,66 @@ public class GenericTypeInsertPoint extends SourcePatchPoint {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
return point.getOffset();
|
return genericInsertPoint.getGenericDeclOffset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Hilfsklasse zur Einsetzung einer Generischen Variable.
|
||||||
|
* @author janulrich
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class GenericVarPatch {
|
||||||
|
|
||||||
|
private Vector<GenericVarDeclarationPatch> genericVarDeclarations = new Vector<GenericVarDeclarationPatch>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt eine generische Variable in Form eines Pairs an.
|
||||||
|
* @param p
|
||||||
|
*/
|
||||||
|
public void add(Pair p){
|
||||||
|
GenericVarDeclarationPatch toAdd = new GenericVarDeclarationPatch(p);
|
||||||
|
if(!this.genericVarDeclarations.contains(toAdd))this.genericVarDeclarations.add(toAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsertString(ResultSet rs){
|
||||||
|
String ret = "";
|
||||||
|
for(GenericVarDeclarationPatch p : this.genericVarDeclarations){
|
||||||
|
ret += p.getInsertString(rs) + ", ";
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Hilfsklasse zur Einsetzung einer Generischen Variable.
|
||||||
|
* @author janulrich
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class GenericVarDeclarationPatch {
|
||||||
|
|
||||||
|
private Pair genericPair;
|
||||||
|
|
||||||
|
public GenericVarDeclarationPatch(Pair p) {
|
||||||
|
this.genericPair = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsertString(ResultSet resultSet){
|
||||||
|
String ret = "";
|
||||||
|
if(this.genericPair != null){
|
||||||
|
ret += this.genericPair.TA1.printJavaCode(resultSet);
|
||||||
|
ret += " extends ";
|
||||||
|
ret += this.genericPair.TA2.printJavaCode(resultSet);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o){
|
||||||
|
if(!(o instanceof GenericVarDeclarationPatch))return false;
|
||||||
|
if(!(this.genericPair.equals(((GenericVarDeclarationPatch)o).genericPair)))return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package typinferenz.typedeployment;
|
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import mycompiler.mytype.Pair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Eine Hilfsklasse zur Einsetzung einer Generischen Variable.
|
|
||||||
* @author janulrich
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class GenericVarPatch {
|
|
||||||
|
|
||||||
private Vector<Pair> genericPairs = new Vector<Pair>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fügt eine generische Variable in Form eines Pairs an.
|
|
||||||
* @param p
|
|
||||||
*/
|
|
||||||
public void add(Pair p){
|
|
||||||
if(!this.genericPairs.contains(p))this.genericPairs.add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInsertString(){
|
|
||||||
return null; //TODO:
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,23 +5,18 @@ import typinferenz.ResultSet;
|
|||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
|
|
||||||
public abstract class SourcePatchPoint implements Comparable<SourcePatchPoint>{
|
public abstract class SourcePatchPoint implements Comparable<SourcePatchPoint>{
|
||||||
protected TypeInsertable point;
|
|
||||||
protected ResultSet resultSet;
|
protected ResultSet resultSet;
|
||||||
public abstract int getOffset();
|
public abstract int getOffset();
|
||||||
public ResultSet getResultSet() {
|
public ResultSet getResultSet() {
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
public TypeInsertable getTIP() {
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(SourcePatchPoint arg0) {
|
public int compareTo(SourcePatchPoint arg0) {
|
||||||
return new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
|
return new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
|
||||||
}
|
}
|
||||||
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
public abstract JavaCodeResult patch(String fileContent, int additionalOffset);
|
||||||
return new JavaCodeResult(fileContent);
|
|
||||||
}
|
|
||||||
public int getInsertLength() {
|
public int getInsertLength() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package typinferenz.typedeployment;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import typinferenz.GenericTypeInsertable;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
@ -23,6 +24,7 @@ public class TypeInsertPoint extends SourcePatchPoint {
|
|||||||
|
|
||||||
|
|
||||||
public Type type;
|
public Type type;
|
||||||
|
private TypeInsertable point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dieser Konstruktor erstellt einen TypInsertPoint
|
* Dieser Konstruktor erstellt einen TypInsertPoint
|
||||||
@ -101,7 +103,7 @@ public class TypeInsertPoint extends SourcePatchPoint {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TypeInsertable getGenericTypeVarInsertNode() {
|
public GenericTypeInsertable getGenericTypeVarInsertNode() {
|
||||||
SyntaxTreeNode ret = (SyntaxTreeNode)this.getTIP();
|
SyntaxTreeNode ret = (SyntaxTreeNode)this.getTIP();
|
||||||
while(!(ret instanceof Field || ret instanceof Class)){
|
while(!(ret instanceof Field || ret instanceof Class)){
|
||||||
ret = ret.getParent();
|
ret = ret.getParent();
|
||||||
@ -109,7 +111,11 @@ public class TypeInsertPoint extends SourcePatchPoint {
|
|||||||
throw new DebugException(this.getInsertNode().toString()+" hat kein Feld oder Klasse als Elternelement");
|
throw new DebugException(this.getInsertNode().toString()+" hat kein Feld oder Klasse als Elternelement");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (TypeInsertable) ret;
|
return (GenericTypeInsertable) ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TypeInsertable getTIP() {
|
||||||
|
return this.point;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user