Aufräumen

This commit is contained in:
JanUlrich 2016-09-13 17:32:22 +02:00
parent 5be508e943
commit 1ac500715b
10 changed files with 152 additions and 236 deletions

View File

@ -19,17 +19,13 @@ import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<GenericTypeVar>{ public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<GenericTypeVar>{
private int offsetOfLastElement; private int offsetOfLastElement;
private Menge<GenericTypeVar> gtvs = new Menge<>(); private List<GenericTypeVar> gtvs = new Menge<>();
public GenericDeclarationList(Menge<GenericTypeVar> values, int endOffset) { public GenericDeclarationList(List<GenericTypeVar> values, int endOffset) {
this.addAll(values); gtvs = values;
this.offsetOfLastElement = endOffset; this.offsetOfLastElement = endOffset;
} }
private void addAll(Menge<GenericTypeVar> values) {
this.gtvs.addAll(values);
}
public int getEndOffset(){ public int getEndOffset(){
return offsetOfLastElement; return offsetOfLastElement;
} }
@ -62,10 +58,6 @@ public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<G
return gtvs.size(); return gtvs.size();
} }
public Menge<GenericTypeVar> getMenge() {
return this.gtvs;
}
public void add(GenericTypeVar t) { public void add(GenericTypeVar t) {
this.gtvs.add(t); this.gtvs.add(t);
} }

View File

@ -301,8 +301,6 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
public static Method createEmptyMethod(String withSignature, Class parent) { public static Method createEmptyMethod(String withSignature, Class parent) {
Block block = new Block(new List<Statement>()); Block block = new Block(new List<Statement>());
Method ret = new Method(withSignature, new de.dhbwstuttgart.syntaxtree.type.Void(0), new ParameterList(), block, new EmptyGenericDeclarationList(), 0); Method ret = new Method(withSignature, new de.dhbwstuttgart.syntaxtree.type.Void(0), new ParameterList(), block, new EmptyGenericDeclarationList(), 0);
Method ret = new Method(0);
DeclId DImethod = new DeclId();
DImethod.set_Name(withSignature); DImethod.set_Name(withSignature);
ret.set_DeclId(DImethod); ret.set_DeclId(DImethod);
Block tempBlock = new Block(); Block tempBlock = new Block();

View File

@ -6,6 +6,7 @@ import de.dhbwstuttgart.typeinference.Menge;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
@ -13,30 +14,15 @@ 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;
// ino.end
// ino.class.ParameterList.23620.declaration
public class ParameterList extends SyntaxTreeNode implements Iterable<FormalParameter> public class ParameterList extends SyntaxTreeNode implements Iterable<FormalParameter>
// ino.end
// ino.class.ParameterList.23620.body
{ {
// ino.attribute.formalparameter.23623.declaration public List<FormalParameter> formalparameter = new Menge<FormalParameter>();
public Menge<FormalParameter> formalparameter = new Menge<FormalParameter>();
// ino.end // ino.end
public ParameterList(List<FormalParameter> params){
this.formalparameter = params;
// ino.method.set_AddParameter.23626.definition
public void set_AddParameter(FormalParameter fp)
// ino.end
// ino.method.set_AddParameter.23626.body
{
formalparameter.addElement(fp);
} }
// ino.end
// ino.method.getParameterAt.23632.definition // ino.method.getParameterAt.23632.definition
public FormalParameter getParameterAt(int i) public FormalParameter getParameterAt(int i)
@ -45,35 +31,24 @@ public class ParameterList extends SyntaxTreeNode implements Iterable<FormalPara
{ {
if (i >= formalparameter.size() ) return null; if (i >= formalparameter.size() ) return null;
return formalparameter.elementAt(i); return formalparameter.get(i);
} }
// ino.end // ino.end
// ino.method.sc_get_Formalparalist.23635.definition public List<FormalParameter> sc_get_Formalparalist()
public Menge<FormalParameter> sc_get_Formalparalist()
// ino.end
// ino.method.sc_get_Formalparalist.23635.body
{ {
return formalparameter; return formalparameter;
} }
// ino.end
// ino.method.getParameterCount.23641.defdescription type=javadoc
/** /**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/> * Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
* @return Die Anzahl der Parameter * @return Die Anzahl der Parameter
*/ */
// ino.end
// ino.method.getParameterCount.23641.definition
public int getParameterCount() public int getParameterCount()
// ino.end
// ino.method.getParameterCount.23641.body
{ {
return formalparameter.size(); return formalparameter.size();
} }
// ino.end
/** /**
* @author Andreas Stadelmeier, a10023 * @author Andreas Stadelmeier, a10023
@ -129,7 +104,7 @@ public class ParameterList extends SyntaxTreeNode implements Iterable<FormalPara
@Override @Override
public int getOffset() { public int getOffset() {
if(formalparameter == null || formalparameter.size()==0)return 0; if(formalparameter == null || formalparameter.size()==0)return 0;
return formalparameter.firstElement().getOffset(); return formalparameter.get(0).getOffset();
} }
@Override @Override
@ -138,7 +113,7 @@ public class ParameterList extends SyntaxTreeNode implements Iterable<FormalPara
} }
@Override @Override
public Menge<? extends SyntaxTreeNode> getChildren() { public List<? extends SyntaxTreeNode> getChildren() {
return formalparameter; return formalparameter;
} }

View File

@ -1,5 +1,7 @@
package de.dhbwstuttgart.syntaxtree; package de.dhbwstuttgart.syntaxtree;
import java.util.List;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
@ -21,7 +23,6 @@ import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
public abstract class SyntaxTreeNode implements IItemWithOffset{ public abstract class SyntaxTreeNode implements IItemWithOffset{
protected SyntaxTreeNode parent; protected SyntaxTreeNode parent;
protected SourceCodePosition position;
/** /**
* Wird nach dem Parsen aufgerufen. * Wird nach dem Parsen aufgerufen.
@ -44,7 +45,7 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{
return this.parent; return this.parent;
} }
public abstract Menge<? extends SyntaxTreeNode> getChildren(); public abstract List<? extends SyntaxTreeNode> getChildren();
/* /*
public Class getParentClass(){ public Class getParentClass(){

View File

@ -1,5 +1,8 @@
package de.dhbwstuttgart.syntaxtree.factory; package de.dhbwstuttgart.syntaxtree.factory;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Parameter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable; import java.lang.reflect.TypeVariable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -11,6 +14,7 @@ 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;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
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;
@ -19,10 +23,12 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
import de.dhbwstuttgart.syntaxtree.modifier.Public; import de.dhbwstuttgart.syntaxtree.modifier.Public;
import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.statement.SuperCall; import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; 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.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
@ -95,19 +101,54 @@ public class ASTFactory {
return new Class(name, methoden, felder, modifier, isInterface, superClass, implementedInterfaces, offset); return new Class(name, methoden, felder, modifier, isInterface, superClass, implementedInterfaces, offset);
} }
public static Method createMethod(java.lang.reflect.Method jreMethod){ public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName(); String name = jreMethod.getName();
Type returnType = createType(jreMethod.getReturnType()); Type returnType = createType(jreMethod.getReturnType());
, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset Parameter[] jreParams = jreMethod.getParameters();
return new Method(); List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
Type paramType = createType(jreParam.getType());
params.add(new FormalParameter(jreParam.getName(),paramType));
}
ParameterList parameterList = new ParameterList(params);
Block block = new Block(new ArrayList<Statement>(), -1);
List<GenericTypeVar> gtvs = new ArrayList<>();
for(TypeVariable jreTV : jreMethod.getTypeParameters()){
GenericTypeVar gtv = createGeneric(jreTV, inClass);
gtvs.add(gtv);
}
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(gtvs,-1);
int offset = -1;
return new Method(name, returnType, parameterList, block, gtvDeclarations, offset);
} }
public static RefType createType(java.lang.Class jreClass){ public static RefType createType(java.lang.Class jreClass){
jreClass.getTypeParameters(); for(TypeVariable jreTV : jreClass.getTypeParameters()){
GenericTypeVar gtv = createGeneric(jreTV, jreClass);
gtvs.add(gtv);
}
jreClass.getT
return new RefType(jreClass.getName(), -1); return new RefType(jreClass.getName(), -1);
} }
public static GenericTypeVar createGeneric(TypeVariable jreTypeVar){ /**
* Erstellt eine GenericTypeVar oder eine BoundedGenericTypeVar
* Um die Variablen korrekt zu generieren, muss die Klasse inClass übergeben werden, in der dieser Generic auftaucht
* @param jreTypeVar
* @param inClass Die Klasse in der der Typ auftritt
* @return
*/
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
String name = jreTypeVar.getTypeName();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){
bound
}
return new BoundedGenericVar();
}
return new GenericTypeVar(); return new GenericTypeVar();
} }
} }

View File

@ -0,0 +1,81 @@
package de.dhbwstuttgart.syntaxtree.factory;
public class NameGenerator {
private static String strNextName = "A";
/**
* Berechnet einen neuen, eindeutigen Namen ¯Â¿Â½r eine neue
* <code>TypePlaceholder</code>. <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return Der Name
*/
public static String makeNewName()
{
// otth: Funktion berechnet einen neuen Namen anhand eines alten gespeicherten
String strReturn = strNextName;
// ¯Â¿Â½chster Name berechnen und in strNextName speichern
inc( strNextName.length() - 1 );
return strReturn;
}
/**
* Hilfsfunktion zur Berechnung eines neuen Namens
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param i
*/
private static void inc(int i)
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Erh�hung des Buchstabens an der Stelle i im String strNextName
// otth: Nach �berlauf: rekursiver Aufruf
// falls i = -1 --> neuer Buchstabe vorne anf�gen
if ( i == -1 )
{
strNextName = "A" + strNextName;
return;
}
char cBuchstabe = (char)(strNextName.charAt( i ));
cBuchstabe++;
if ( cBuchstabe - 65 > 25 )
{
// aktuelle Stelle: auf A zuruecksetzen
manipulate( i, 'A' );
// vorherige Stelle erh�hen
inc( i - 1 );
}
else
{
// aktueller Buchstabe �ndern
manipulate( i, cBuchstabe );
}
}
/**
* Hilfsfunktion zur Berechnung eines neuen Namens.
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param nStelle
* @param nWert
*/
private static void manipulate( int nStelle, char nWert )
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Ersetzt im String 'strNextName' an der Position 'nStelle' den Buchstaben durch 'nWert'
String strTemp = "";
for( int i = 0; i < strNextName.length(); i++)
{
if ( i == nStelle )
strTemp = strTemp + nWert;
else
strTemp = strTemp + strNextName.charAt( i );
}
strNextName = strTemp;
}
}

View File

@ -46,17 +46,8 @@ public class Block extends Statement
private ConstantPoolGen _cp; private ConstantPoolGen _cp;
private ClassGen _cg; private ClassGen _cg;
// ino.method.Block.25041.definition public Block(List<Statement> statements, int offset) {
public Block() super(offset);
// ino.end
// ino.method.Block.25041.body
{
super(-1,-1);
}
// ino.end
public Block(List<Statement> statements) {
this.statements = statements; this.statements = statements;
} }
@ -82,38 +73,12 @@ public class Block extends Statement
// ino.method.get_Statement.25065.definition // ino.method.get_Statement.25065.definition
public Menge<Statement> get_Statement() public List<Statement> get_Statement()
// ino.end // ino.end
// ino.method.get_Statement.25065.body // ino.method.get_Statement.25065.body
{ {
return statements; return statements;
} }
// ino.end
// ino.method.set_Statement.25068.definition
public void set_Statement(Statement s)
// ino.end
// ino.method.set_Statement.25068.body
{
statements.addElement(s);
}
// ino.end
// ino.method.set_Statement_Menge.25071.definition
public void set_Statement_Menge(Menge<Statement> v)
// ino.end
// ino.method.set_Statement_Menge.25071.body
{
statements = v;
}
// ino.end
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// TypeReconstructionAlgorithmus // TypeReconstructionAlgorithmus
@ -136,33 +101,9 @@ public class Block extends Statement
} }
// ino.end // ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25086.defdescription type=javadoc
/**
* In allen lokalen Variablendeklarationen die "falschen" RefTypes ersetzen
* @param paralist
* @param genericMethodParameters
*/
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25086.definition
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25086.body
{
if(statements==null)
return;
for(int i=0;i<statements.size();i++){
statements.elementAt(i).wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
}
}
// ino.end
@Override @Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
if(statements.size()==0)this.setType(new Void(this,0));
/* this.setTypeVariable(TypePlaceholder.fresh(this)); */ /* this.setTypeVariable(TypePlaceholder.fresh(this)); */
for(Statement stmt : statements){ for(Statement stmt : statements){
typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE); typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE);
@ -173,11 +114,11 @@ public class Block extends Statement
*/ */
} }
if(statements.size()>0){ if(statements.size()>0){
Statement stmt = statements.elementAt(statements.size()-1); Statement stmt = statements.get(statements.size()-1);
typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE); typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE);
this.setType(stmt.getType()); this.setType(stmt.getType());
for(int i= statements.size()-2; i >= 0; i--) { for(int i= statements.size()-2; i >= 0; i--) {
stmt = statements.elementAt(i); stmt = statements.get(i);
typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE); typinferenceLog.debug("Prozessing statement: "+stmt, Section.TYPEINFERENCE);
if (!(stmt.getReturnType() instanceof Void)) if (!(stmt.getReturnType() instanceof Void))
if (this.getReturnType() instanceof Void) { if (this.getReturnType() instanceof Void) {
@ -191,8 +132,6 @@ public class Block extends Statement
this.setType(tph); this.setType(tph);
} }
} }
}else{
this.setType(new Void(this,0));
} }
return ret; return ret;
} }

View File

@ -65,14 +65,6 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
{ {
return variableLength; return variableLength;
} }
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26224.declaration
public abstract void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters);
// ino.end
/** /**
* @author AI10023 - Andreas Stadelmeier * @author AI10023 - Andreas Stadelmeier

View File

@ -28,8 +28,6 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
* @author ¯Â¿Â½rg ¯Â¿Â½uerle * @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/09/22 20:12:53 $ * @version $Date: 2013/09/22 20:12:53 $
*/ */
// ino.end
// ino.class.GenericTypeVar.26505.declaration
public class GenericTypeVar extends ObjectType public class GenericTypeVar extends ObjectType
// ino.end // ino.end
// ino.class.GenericTypeVar.26505.body // ino.class.GenericTypeVar.26505.body
@ -90,9 +88,7 @@ public class GenericTypeVar extends ObjectType
{ {
return new GenericTypeVar(this.getName().toString(), this.getParentClass(), getOffset()); return new GenericTypeVar(this.getName().toString(), this.getParentClass(), getOffset());
} }
// ino.end
// ino.method.equals.26515.defdescription type=javadoc
/** /**
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle * <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param obj * @param obj
@ -124,23 +120,16 @@ public class GenericTypeVar extends ObjectType
return this.name.hashCode(); return this.name.hashCode();
} }
// ino.method.get_codegen_Type.26521.defdescription type=javadoc
/** /**
* hoti 4.5.06 * hoti 4.5.06
* Generische Typen werden im Bytecode * Generische Typen werden im Bytecode
* aus Abwaertskompatiblitaet wie Object dargestellt * aus Abwaertskompatiblitaet wie Object dargestellt
*/ */
// ino.end
// ino.method.get_codegen_Type.26521.definition
public String get_codegen_Type(Menge paralist) public String get_codegen_Type(Menge paralist)
// ino.end
// ino.method.get_codegen_Type.26521.body
{ {
return("Ljava/lang/Object;"); return("Ljava/lang/Object;");
} }
// ino.end
// ino.method.getSignatureType.26524.definition
public String getSignatureType(Menge paralist) public String getSignatureType(Menge paralist)
// ino.end // ino.end
// ino.method.getSignatureType.26524.body // ino.method.getSignatureType.26524.body

View File

@ -14,6 +14,7 @@ import de.dhbwstuttgart.bytecode.TypePlaceholderType;
import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import de.dhbwstuttgart.typeinference.JavaCodeResult; 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;
@ -40,7 +41,6 @@ public class TypePlaceholder extends ObjectType
{ {
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.attribute.strNextName.26785.declaration
private static String strNextName = "A";
// ino.end // ino.end
// ino.attribute.m_TypePlaceholdersRegistry.26788.declaration // 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>();
@ -104,7 +104,7 @@ public class TypePlaceholder extends ObjectType
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);
if(oldTPH != null){ if(oldTPH != null){
oldTPH.name = new JavaClassName(makeNewName()); oldTPH.name = new JavaClassName(NameGenerator.makeNewName());
m_TypePlaceholdersRegistry.put(oldTPH.getName().toString(), oldTPH); m_TypePlaceholdersRegistry.put(oldTPH.getName().toString(), oldTPH);
} }
return typeVar; return typeVar;
@ -120,7 +120,7 @@ public class TypePlaceholder extends ObjectType
* @return * @return
*/ */
public static TypePlaceholder fresh(SyntaxTreeNode parent){ public static TypePlaceholder fresh(SyntaxTreeNode parent){
TypePlaceholder ret= new TypePlaceholder(makeNewName(), parent); TypePlaceholder ret= new TypePlaceholder(NameGenerator.makeNewName(), parent);
m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret); m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret);
return ret; return ret;
} }
@ -132,98 +132,6 @@ public class TypePlaceholder extends ObjectType
return ret; return ret;
} }
// ino.method.makeNewName.26803.defdescription type=javadoc
/**
* Berechnet einen neuen, eindeutigen Namen ¯Â¿Â½r eine neue
* <code>TypePlaceholder</code>. <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return Der Name
*/
// ino.end
// ino.method.makeNewName.26803.definition
private static String makeNewName()
// ino.end
// ino.method.makeNewName.26803.body
{
// otth: Funktion berechnet einen neuen Namen anhand eines alten gespeicherten
String strReturn = strNextName;
// ¯Â¿Â½chster Name berechnen und in strNextName speichern
inc( strNextName.length() - 1 );
return strReturn;
}
// ino.end
// ino.method.inc.26806.defdescription type=javadoc
/**
* Hilfsfunktion zur Berechnung eines neuen Namens
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param i
*/
// ino.end
// ino.method.inc.26806.definition
private static void inc(int i)
// ino.end
// ino.method.inc.26806.body
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Erh�hung des Buchstabens an der Stelle i im String strNextName
// otth: Nach �berlauf: rekursiver Aufruf
// falls i = -1 --> neuer Buchstabe vorne anf�gen
if ( i == -1 )
{
strNextName = "A" + strNextName;
return;
}
char cBuchstabe = (char)(strNextName.charAt( i ));
cBuchstabe++;
if ( cBuchstabe - 65 > 25 )
{
// aktuelle Stelle: auf A zuruecksetzen
manipulate( i, 'A' );
// vorherige Stelle erh�hen
inc( i - 1 );
}
else
{
// aktueller Buchstabe �ndern
manipulate( i, cBuchstabe );
}
}
// ino.end
// ino.method.manipulate.26809.defdescription type=javadoc
/**
* Hilfsfunktion zur Berechnung eines neuen Namens.
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param nStelle
* @param nWert
*/
// ino.end
// ino.method.manipulate.26809.definition
private static void manipulate( int nStelle, char nWert )
// ino.end
// ino.method.manipulate.26809.body
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Ersetzt im String 'strNextName' an der Position 'nStelle' den Buchstaben durch 'nWert'
String strTemp = "";
for( int i = 0; i < strNextName.length(); i++)
{
if ( i == nStelle )
strTemp = strTemp + nWert;
else
strTemp = strTemp + strNextName.charAt( i );
}
strNextName = strTemp;
}
// ino.end
// ino.method.equals.26812.defdescription type=javadoc // ino.method.equals.26812.defdescription type=javadoc
/** /**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/> * Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
@ -327,7 +235,7 @@ public class TypePlaceholder extends ObjectType
//backdoorvars werden registiert, weil am Ende beim execute //backdoorvars werden registiert, weil am Ende beim execute
//auf den CSubstitution nicht registrierte Variablen zu //auf den CSubstitution nicht registrierte Variablen zu
//Exceptions fuehrt //Exceptions fuehrt
TypePlaceholder typeVar = new TypePlaceholder(makeNewName(), null); TypePlaceholder typeVar = new TypePlaceholder(NameGenerator.makeNewName(), null);
m_TypePlaceholdersRegistry.put(typeVar.getName().toString(), typeVar); m_TypePlaceholdersRegistry.put(typeVar.getName().toString(), typeVar);
return typeVar; return typeVar;